aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-12-30 11:55:28 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-12-30 11:55:28 +0000
commite81d9d49145e432d917eea3a70d2ae74dcad1d89 (patch)
tree9ed5e1a91f242e2cb5911577356e487a55c01b78
parent85d8ef8f1f0e0e063a8571944302be2d2026f823 (diff)
downloadsrc-e81d9d49145e432d917eea3a70d2ae74dcad1d89.tar.gz
src-e81d9d49145e432d917eea3a70d2ae74dcad1d89.zip
Vendor import of stripped lldb trunk r256633:
Notes
Notes: svn path=/vendor/lldb/dist/; revision=292932
-rw-r--r--docs/lldb.185
-rw-r--r--include/lldb/API/LLDB.h20
-rw-r--r--include/lldb/API/SBAttachInfo.h75
-rw-r--r--include/lldb/API/SBCommandInterpreter.h30
-rw-r--r--include/lldb/API/SBCommandReturnObject.h20
-rw-r--r--include/lldb/API/SBDebugger.h36
-rw-r--r--include/lldb/API/SBDefines.h2
-rw-r--r--include/lldb/API/SBFunction.h6
-rw-r--r--include/lldb/API/SBProcess.h54
-rw-r--r--include/lldb/API/SBStream.h4
-rw-r--r--include/lldb/API/SBTarget.h70
-rw-r--r--include/lldb/API/SBType.h13
-rw-r--r--include/lldb/API/SBTypeCategory.h9
-rw-r--r--include/lldb/API/SBTypeSummary.h15
-rw-r--r--include/lldb/API/SBValue.h12
-rw-r--r--include/lldb/API/SystemInitializerFull.h8
-rw-r--r--include/lldb/Breakpoint/Breakpoint.h61
-rw-r--r--include/lldb/Breakpoint/BreakpointLocation.h28
-rw-r--r--include/lldb/Breakpoint/BreakpointLocationList.h23
-rw-r--r--include/lldb/Breakpoint/BreakpointOptions.h31
-rw-r--r--include/lldb/Breakpoint/BreakpointResolver.h9
-rw-r--r--include/lldb/Breakpoint/BreakpointResolverAddress.h17
-rw-r--r--include/lldb/Breakpoint/BreakpointResolverFileLine.h5
-rw-r--r--include/lldb/Breakpoint/BreakpointResolverFileRegex.h5
-rw-r--r--include/lldb/Breakpoint/BreakpointResolverName.h11
-rw-r--r--include/lldb/Breakpoint/BreakpointSite.h25
-rw-r--r--include/lldb/Breakpoint/Watchpoint.h58
-rw-r--r--include/lldb/Breakpoint/WatchpointOptions.h27
-rw-r--r--include/lldb/Core/Address.h23
-rw-r--r--include/lldb/Core/AddressRange.h8
-rw-r--r--include/lldb/Core/AddressResolver.h9
-rw-r--r--include/lldb/Core/AddressResolverFileLine.h17
-rw-r--r--include/lldb/Core/AddressResolverName.h17
-rw-r--r--include/lldb/Core/ArchSpec.h44
-rw-r--r--include/lldb/Core/Broadcaster.h24
-rw-r--r--include/lldb/Core/ClangForward.h2
-rw-r--r--include/lldb/Core/Communication.h29
-rw-r--r--include/lldb/Core/Connection.h12
-rw-r--r--include/lldb/Core/ConnectionSharedMemory.h31
-rw-r--r--include/lldb/Core/ConstString.h46
-rw-r--r--include/lldb/Core/DataBufferHeap.h19
-rw-r--r--include/lldb/Core/DataBufferMemoryMap.h20
-rw-r--r--include/lldb/Core/DataEncoder.h2
-rw-r--r--include/lldb/Core/DataExtractor.h104
-rw-r--r--include/lldb/Core/Debugger.h111
-rw-r--r--include/lldb/Core/Disassembler.h36
-rw-r--r--include/lldb/Core/EmulateInstruction.h21
-rw-r--r--include/lldb/Core/Event.h24
-rw-r--r--include/lldb/Core/FileLineResolver.h17
-rw-r--r--include/lldb/Core/FormatEntity.h24
-rw-r--r--include/lldb/Core/History.h39
-rw-r--r--include/lldb/Core/IOHandler.h86
-rw-r--r--include/lldb/Core/Language.h117
-rw-r--r--include/lldb/Core/Listener.h39
-rw-r--r--include/lldb/Core/Log.h8
-rw-r--r--include/lldb/Core/Logging.h1
-rw-r--r--include/lldb/Core/MappedHash.h47
-rw-r--r--include/lldb/Core/Module.h96
-rw-r--r--include/lldb/Core/ModuleList.h32
-rw-r--r--include/lldb/Core/ModuleSpec.h64
-rw-r--r--include/lldb/Core/Opcode.h18
-rw-r--r--include/lldb/Core/PluginManager.h178
-rw-r--r--include/lldb/Core/RangeMap.h174
-rw-r--r--include/lldb/Core/RegisterValue.h131
-rw-r--r--include/lldb/Core/RegularExpression.h21
-rw-r--r--include/lldb/Core/STLUtils.h26
-rw-r--r--include/lldb/Core/Scalar.h123
-rw-r--r--include/lldb/Core/SearchFilter.h17
-rw-r--r--include/lldb/Core/Section.h43
-rw-r--r--include/lldb/Core/SourceManager.h66
-rw-r--r--include/lldb/Core/Stream.h28
-rw-r--r--include/lldb/Core/StreamAsynchronousIO.h14
-rw-r--r--include/lldb/Core/StreamCallback.h14
-rw-r--r--include/lldb/Core/StreamFile.h13
-rw-r--r--include/lldb/Core/StreamGDBRemote.h5
-rw-r--r--include/lldb/Core/StreamString.h15
-rw-r--r--include/lldb/Core/StreamTee.h15
-rw-r--r--include/lldb/Core/StringList.h15
-rw-r--r--include/lldb/Core/StructuredData.h228
-rw-r--r--include/lldb/Core/ThreadSafeDenseMap.h22
-rw-r--r--include/lldb/Core/ThreadSafeDenseSet.h7
-rw-r--r--include/lldb/Core/Timer.h43
-rw-r--r--include/lldb/Core/UUID.h5
-rw-r--r--include/lldb/Core/UniqueCStringMap.h30
-rw-r--r--include/lldb/Core/Value.h41
-rw-r--r--include/lldb/Core/ValueObject.h173
-rw-r--r--include/lldb/Core/ValueObjectCast.h66
-rw-r--r--include/lldb/Core/ValueObjectChild.h77
-rw-r--r--include/lldb/Core/ValueObjectConstResult.h103
-rw-r--r--include/lldb/Core/ValueObjectConstResultCast.h76
-rw-r--r--include/lldb/Core/ValueObjectConstResultChild.h39
-rw-r--r--include/lldb/Core/ValueObjectConstResultImpl.h29
-rw-r--r--include/lldb/Core/ValueObjectDynamicValue.h135
-rw-r--r--include/lldb/Core/ValueObjectList.h1
-rw-r--r--include/lldb/Core/ValueObjectMemory.h51
-rw-r--r--include/lldb/Core/ValueObjectRegister.h138
-rw-r--r--include/lldb/Core/ValueObjectSyntheticFilter.h170
-rw-r--r--include/lldb/Core/ValueObjectVariable.h75
-rw-r--r--include/lldb/Core/dwarf.h6
-rw-r--r--include/lldb/DataFormatters/CXXFormatterFunctions.h375
-rw-r--r--include/lldb/DataFormatters/CXXFunctionPointer.h23
-rw-r--r--include/lldb/DataFormatters/DataVisualization.h25
-rw-r--r--include/lldb/DataFormatters/DumpValueObjectOptions.h185
-rw-r--r--include/lldb/DataFormatters/FormatCache.h1
-rw-r--r--include/lldb/DataFormatters/FormatClasses.h84
-rw-r--r--include/lldb/DataFormatters/FormatManager.h165
-rw-r--r--include/lldb/DataFormatters/FormattersContainer.h70
-rw-r--r--include/lldb/DataFormatters/FormattersHelpers.h279
-rw-r--r--include/lldb/DataFormatters/LanguageCategory.h99
-rw-r--r--include/lldb/DataFormatters/StringPrinter.h765
-rw-r--r--include/lldb/DataFormatters/TypeCategory.h302
-rw-r--r--include/lldb/DataFormatters/TypeCategoryMap.h37
-rw-r--r--include/lldb/DataFormatters/TypeFormat.h43
-rw-r--r--include/lldb/DataFormatters/TypeSummary.h190
-rw-r--r--include/lldb/DataFormatters/TypeSynthetic.h199
-rw-r--r--include/lldb/DataFormatters/TypeValidator.h20
-rw-r--r--include/lldb/DataFormatters/ValueObjectPrinter.h282
-rw-r--r--include/lldb/DataFormatters/VectorIterator.h53
-rw-r--r--include/lldb/Expression/DWARFExpression.h45
-rw-r--r--include/lldb/Expression/Expression.h (renamed from include/lldb/Expression/ClangExpression.h)64
-rw-r--r--include/lldb/Expression/ExpressionParser.h123
-rw-r--r--include/lldb/Expression/ExpressionTypeSystemHelper.h54
-rw-r--r--include/lldb/Expression/ExpressionVariable.h320
-rw-r--r--include/lldb/Expression/FunctionCaller.h (renamed from include/lldb/Expression/ClangFunction.h)138
-rw-r--r--include/lldb/Expression/IRDynamicChecks.h20
-rw-r--r--include/lldb/Expression/IRExecutionUnit.h74
-rw-r--r--include/lldb/Expression/IRInterpreter.h1
-rw-r--r--include/lldb/Expression/IRMemoryMap.h9
-rw-r--r--include/lldb/Expression/IRToDWARF.h111
-rw-r--r--include/lldb/Expression/LLVMUserExpression.h118
-rw-r--r--include/lldb/Expression/Materializer.h73
-rw-r--r--include/lldb/Expression/REPL.h211
-rw-r--r--include/lldb/Expression/UserExpression.h (renamed from include/lldb/Expression/ClangUserExpression.h)220
-rw-r--r--include/lldb/Expression/UtilityFunction.h (renamed from include/lldb/Expression/ClangUtilityFunction.h)93
-rw-r--r--include/lldb/Host/Condition.h25
-rw-r--r--include/lldb/Host/Config.h6
-rw-r--r--include/lldb/Host/Debug.h16
-rw-r--r--include/lldb/Host/Endian.h4
-rw-r--r--include/lldb/Host/File.h82
-rw-r--r--include/lldb/Host/FileSpec.h41
-rw-r--r--include/lldb/Host/FileSystem.h5
-rw-r--r--include/lldb/Host/HostGetOpt.h4
-rw-r--r--include/lldb/Host/HostInfo.h3
-rw-r--r--include/lldb/Host/HostNativeThread.h2
-rw-r--r--include/lldb/Host/HostNativeThreadForward.h3
-rw-r--r--include/lldb/Host/MainLoopBase.h12
-rw-r--r--include/lldb/Host/MonitoringProcessLauncher.h11
-rw-r--r--include/lldb/Host/Mutex.h39
-rw-r--r--include/lldb/Host/OptionParser.h3
-rw-r--r--include/lldb/Host/Predicate.h45
-rw-r--r--include/lldb/Host/ProcessRunLock.h22
-rw-r--r--include/lldb/Host/Socket.h63
-rw-r--r--include/lldb/Host/Symbols.h2
-rw-r--r--include/lldb/Host/XML.h13
-rw-r--r--include/lldb/Host/common/GetOptInc.h65
-rw-r--r--include/lldb/Host/common/NativeProcessProtocol.h17
-rw-r--r--include/lldb/Host/common/TCPSocket.h46
-rw-r--r--include/lldb/Host/common/UDPSocket.h35
-rw-r--r--include/lldb/Host/netbsd/Config.h28
-rw-r--r--include/lldb/Host/netbsd/HostInfoNetBSD.h30
-rw-r--r--include/lldb/Host/netbsd/HostThreadNetBSD.h32
-rw-r--r--include/lldb/Host/posix/ConnectionFileDescriptorPosix.h15
-rw-r--r--include/lldb/Host/posix/DomainSocket.h37
-rw-r--r--include/lldb/Host/posix/HostProcessPosix.h11
-rw-r--r--include/lldb/Host/posix/HostThreadPosix.h7
-rw-r--r--include/lldb/Host/posix/LockFilePosix.h6
-rw-r--r--include/lldb/Host/posix/MainLoopPosix.h2
-rw-r--r--include/lldb/Initialization/SystemInitializerCommon.h7
-rw-r--r--include/lldb/Interpreter/Args.h3
-rw-r--r--include/lldb/Interpreter/CommandCompletions.h76
-rw-r--r--include/lldb/Interpreter/CommandHistory.h1
-rw-r--r--include/lldb/Interpreter/CommandInterpreter.h82
-rw-r--r--include/lldb/Interpreter/CommandObject.h86
-rw-r--r--include/lldb/Interpreter/CommandObjectMultiword.h229
-rw-r--r--include/lldb/Interpreter/CommandObjectRegexCommand.h6
-rw-r--r--include/lldb/Interpreter/CommandOptionValidators.h13
-rw-r--r--include/lldb/Interpreter/CommandReturnObject.h8
-rw-r--r--include/lldb/Interpreter/OptionGroupArchitecture.h35
-rw-r--r--include/lldb/Interpreter/OptionGroupBoolean.h29
-rw-r--r--include/lldb/Interpreter/OptionGroupFile.h56
-rw-r--r--include/lldb/Interpreter/OptionGroupFormat.h30
-rw-r--r--include/lldb/Interpreter/OptionGroupOutputFile.h30
-rw-r--r--include/lldb/Interpreter/OptionGroupPlatform.h28
-rw-r--r--include/lldb/Interpreter/OptionGroupString.h32
-rw-r--r--include/lldb/Interpreter/OptionGroupUInt64.h33
-rw-r--r--include/lldb/Interpreter/OptionGroupUUID.h28
-rw-r--r--include/lldb/Interpreter/OptionGroupValueObjectDisplay.h47
-rw-r--r--include/lldb/Interpreter/OptionGroupVariable.h28
-rw-r--r--include/lldb/Interpreter/OptionGroupWatchpoint.h32
-rw-r--r--include/lldb/Interpreter/OptionValue.h18
-rw-r--r--include/lldb/Interpreter/OptionValueArch.h41
-rw-r--r--include/lldb/Interpreter/OptionValueArgs.h9
-rw-r--r--include/lldb/Interpreter/OptionValueArray.h41
-rw-r--r--include/lldb/Interpreter/OptionValueBoolean.h41
-rw-r--r--include/lldb/Interpreter/OptionValueChar.h28
-rw-r--r--include/lldb/Interpreter/OptionValueDictionary.h53
-rw-r--r--include/lldb/Interpreter/OptionValueEnumeration.h42
-rw-r--r--include/lldb/Interpreter/OptionValueFileSpec.h41
-rw-r--r--include/lldb/Interpreter/OptionValueFileSpecList.h32
-rw-r--r--include/lldb/Interpreter/OptionValueFormat.h27
-rw-r--r--include/lldb/Interpreter/OptionValueFormatEntity.h6
-rw-r--r--include/lldb/Interpreter/OptionValueLanguage.h5
-rw-r--r--include/lldb/Interpreter/OptionValuePathMappings.h31
-rw-r--r--include/lldb/Interpreter/OptionValueProperties.h83
-rw-r--r--include/lldb/Interpreter/OptionValueRegex.h39
-rw-r--r--include/lldb/Interpreter/OptionValueSInt64.h27
-rw-r--r--include/lldb/Interpreter/OptionValueString.h53
-rw-r--r--include/lldb/Interpreter/OptionValueUInt64.h27
-rw-r--r--include/lldb/Interpreter/OptionValueUUID.h41
-rw-r--r--include/lldb/Interpreter/Options.h63
-rw-r--r--include/lldb/Interpreter/PythonDataObjects.h280
-rw-r--r--include/lldb/Interpreter/ScriptInterpreter.h41
-rw-r--r--include/lldb/Interpreter/ScriptInterpreterNone.h35
-rw-r--r--include/lldb/Symbol/ArmUnwindInfo.h77
-rw-r--r--include/lldb/Symbol/Block.h70
-rw-r--r--include/lldb/Symbol/ClangASTContext.h941
-rw-r--r--include/lldb/Symbol/ClangASTImporter.h53
-rw-r--r--include/lldb/Symbol/ClangExternalASTSourceCallbacks.h38
-rw-r--r--include/lldb/Symbol/ClangExternalASTSourceCommon.h21
-rw-r--r--include/lldb/Symbol/ClangNamespaceDecl.h105
-rw-r--r--include/lldb/Symbol/CompileUnit.h61
-rw-r--r--include/lldb/Symbol/CompilerDecl.h135
-rw-r--r--include/lldb/Symbol/CompilerDeclContext.h146
-rw-r--r--include/lldb/Symbol/CompilerType.h (renamed from include/lldb/Symbol/ClangASTType.h)477
-rw-r--r--include/lldb/Symbol/DebugMacros.h140
-rw-r--r--include/lldb/Symbol/FuncUnwinders.h5
-rw-r--r--include/lldb/Symbol/Function.h78
-rw-r--r--include/lldb/Symbol/GoASTContext.h402
-rw-r--r--include/lldb/Symbol/LineEntry.h26
-rw-r--r--include/lldb/Symbol/LineTable.h27
-rw-r--r--include/lldb/Symbol/ObjectContainer.h16
-rw-r--r--include/lldb/Symbol/ObjectFile.h18
-rw-r--r--include/lldb/Symbol/Symbol.h19
-rw-r--r--include/lldb/Symbol/SymbolContext.h73
-rw-r--r--include/lldb/Symbol/SymbolContextScope.h13
-rw-r--r--include/lldb/Symbol/SymbolFile.h49
-rw-r--r--include/lldb/Symbol/SymbolVendor.h35
-rw-r--r--include/lldb/Symbol/TaggedASTType.h18
-rw-r--r--include/lldb/Symbol/Type.h259
-rw-r--r--include/lldb/Symbol/TypeList.h13
-rw-r--r--include/lldb/Symbol/TypeMap.h98
-rw-r--r--include/lldb/Symbol/TypeSystem.h604
-rw-r--r--include/lldb/Symbol/UnwindPlan.h40
-rw-r--r--include/lldb/Symbol/UnwindTable.h10
-rw-r--r--include/lldb/Symbol/Variable.h26
-rw-r--r--include/lldb/Symbol/VariableList.h4
-rw-r--r--include/lldb/Target/ABI.h12
-rw-r--r--include/lldb/Target/CPPLanguageRuntime.h130
-rw-r--r--include/lldb/Target/DynamicLoader.h21
-rw-r--r--include/lldb/Target/ExecutionContext.h111
-rw-r--r--include/lldb/Target/InstrumentationRuntimeStopInfo.h19
-rw-r--r--include/lldb/Target/JITLoader.h3
-rw-r--r--include/lldb/Target/Language.h206
-rw-r--r--include/lldb/Target/LanguageRuntime.h50
-rw-r--r--include/lldb/Target/ObjCLanguageRuntime.h269
-rw-r--r--include/lldb/Target/OperatingSystem.h6
-rw-r--r--include/lldb/Target/Platform.h280
-rw-r--r--include/lldb/Target/Process.h550
-rw-r--r--include/lldb/Target/QueueItem.h20
-rw-r--r--include/lldb/Target/RegisterContext.h28
-rw-r--r--include/lldb/Target/SectionLoadList.h1
-rw-r--r--include/lldb/Target/StackFrame.h58
-rw-r--r--include/lldb/Target/StackFrameList.h22
-rw-r--r--include/lldb/Target/StackID.h20
-rw-r--r--include/lldb/Target/StopInfo.h4
-rw-r--r--include/lldb/Target/SystemRuntime.h6
-rw-r--r--include/lldb/Target/Target.h351
-rw-r--r--include/lldb/Target/TargetList.h28
-rw-r--r--include/lldb/Target/Thread.h164
-rw-r--r--include/lldb/Target/ThreadList.h10
-rw-r--r--include/lldb/Target/ThreadPlan.h54
-rw-r--r--include/lldb/Target/ThreadPlanBase.h32
-rw-r--r--include/lldb/Target/ThreadPlanCallFunction.h77
-rw-r--r--include/lldb/Target/ThreadPlanCallFunctionUsingABI.h5
-rw-r--r--include/lldb/Target/ThreadPlanCallUserExpression.h31
-rw-r--r--include/lldb/Target/ThreadPlanPython.h48
-rw-r--r--include/lldb/Target/ThreadPlanRunToAddress.h43
-rw-r--r--include/lldb/Target/ThreadPlanShouldStopHere.h16
-rw-r--r--include/lldb/Target/ThreadPlanStepInRange.h26
-rw-r--r--include/lldb/Target/ThreadPlanStepInstruction.h24
-rw-r--r--include/lldb/Target/ThreadPlanStepOut.h33
-rw-r--r--include/lldb/Target/ThreadPlanStepOverBreakpoint.h35
-rw-r--r--include/lldb/Target/ThreadPlanStepOverRange.h23
-rw-r--r--include/lldb/Target/ThreadPlanStepRange.h28
-rw-r--r--include/lldb/Target/ThreadPlanStepThrough.h26
-rw-r--r--include/lldb/Target/ThreadPlanStepUntil.h28
-rw-r--r--include/lldb/Target/ThreadPlanTracer.h23
-rw-r--r--include/lldb/Target/ThreadSpec.h14
-rw-r--r--include/lldb/Target/UnixSignals.h13
-rw-r--r--include/lldb/Target/UnwindAssembly.h7
-rw-r--r--include/lldb/Utility/AnsiTerminal.h9
-rw-r--r--include/lldb/Utility/Either.h154
-rw-r--r--include/lldb/Utility/Iterable.h25
-rw-r--r--include/lldb/Utility/JSON.h127
-rw-r--r--include/lldb/Utility/ProcessStructReader.h8
-rw-r--r--include/lldb/Utility/PseudoTerminal.h2
-rw-r--r--include/lldb/Utility/PythonPointer.h73
-rw-r--r--include/lldb/Utility/SharedCluster.h6
-rw-r--r--include/lldb/Utility/SharingPtr.h79
-rw-r--r--include/lldb/Utility/StringExtractor.h3
-rw-r--r--include/lldb/Utility/TaskPool.h221
-rw-r--r--include/lldb/lldb-defines.h2
-rw-r--r--include/lldb/lldb-enumerations.h41
-rw-r--r--include/lldb/lldb-forward.h50
-rw-r--r--include/lldb/lldb-private-enumerations.h28
-rw-r--r--include/lldb/lldb-private-interfaces.h10
-rw-r--r--include/lldb/lldb-private-types.h18
-rw-r--r--include/lldb/lldb-python.h31
-rw-r--r--include/lldb/lldb-types.h2
-rw-r--r--source/API/SBAttachInfo.cpp16
-rw-r--r--source/API/SBBreakpoint.cpp48
-rw-r--r--source/API/SBCommandInterpreter.cpp152
-rw-r--r--source/API/SBCommandReturnObject.cpp112
-rw-r--r--source/API/SBDebugger.cpp250
-rw-r--r--source/API/SBFrame.cpp133
-rw-r--r--source/API/SBFunction.cpp30
-rw-r--r--source/API/SBLanguageRuntime.cpp6
-rw-r--r--source/API/SBModule.cpp24
-rw-r--r--source/API/SBPlatform.cpp2
-rw-r--r--source/API/SBProcess.cpp46
-rw-r--r--source/API/SBStream.cpp7
-rw-r--r--source/API/SBTarget.cpp137
-rw-r--r--source/API/SBThread.cpp20
-rw-r--r--source/API/SBType.cpp148
-rw-r--r--source/API/SBTypeCategory.cpp25
-rw-r--r--source/API/SBTypeEnumMember.cpp3
-rw-r--r--source/API/SBTypeNameSpecifier.cpp4
-rw-r--r--source/API/SBTypeSummary.cpp151
-rw-r--r--source/API/SBValue.cpp47
-rw-r--r--source/API/SBValueList.cpp4
-rw-r--r--source/API/SystemInitializerFull.cpp96
-rw-r--r--source/API/liblldb.exports3
-rw-r--r--source/API/liblldb.xcode.exports3
-rw-r--r--source/Breakpoint/Breakpoint.cpp55
-rw-r--r--source/Breakpoint/BreakpointID.cpp17
-rw-r--r--source/Breakpoint/BreakpointIDList.cpp20
-rw-r--r--source/Breakpoint/BreakpointLocation.cpp105
-rw-r--r--source/Breakpoint/BreakpointLocationList.cpp16
-rw-r--r--source/Breakpoint/BreakpointOptions.cpp29
-rw-r--r--source/Breakpoint/BreakpointResolverAddress.cpp90
-rw-r--r--source/Breakpoint/BreakpointResolverName.cpp103
-rw-r--r--source/Breakpoint/BreakpointSite.cpp29
-rw-r--r--source/Breakpoint/StoppointCallbackContext.cpp7
-rw-r--r--source/Breakpoint/Watchpoint.cpp83
-rw-r--r--source/Breakpoint/WatchpointList.cpp7
-rw-r--r--source/Breakpoint/WatchpointOptions.cpp26
-rw-r--r--source/Commands/CommandObjectApropos.h13
-rw-r--r--source/Commands/CommandObjectArgs.cpp27
-rw-r--r--source/Commands/CommandObjectArgs.h28
-rw-r--r--source/Commands/CommandObjectBreakpoint.cpp232
-rw-r--r--source/Commands/CommandObjectBreakpoint.h5
-rw-r--r--source/Commands/CommandObjectBreakpointCommand.cpp59
-rw-r--r--source/Commands/CommandObjectBreakpointCommand.h8
-rw-r--r--source/Commands/CommandObjectBugreport.cpp2
-rw-r--r--source/Commands/CommandObjectBugreport.h5
-rw-r--r--source/Commands/CommandObjectCommands.cpp171
-rw-r--r--source/Commands/CommandObjectCommands.h6
-rw-r--r--source/Commands/CommandObjectDisassemble.cpp2
-rw-r--r--source/Commands/CommandObjectDisassemble.h30
-rw-r--r--source/Commands/CommandObjectExpression.cpp100
-rw-r--r--source/Commands/CommandObjectExpression.h46
-rw-r--r--source/Commands/CommandObjectFrame.cpp52
-rw-r--r--source/Commands/CommandObjectFrame.h6
-rw-r--r--source/Commands/CommandObjectGUI.h12
-rw-r--r--source/Commands/CommandObjectHelp.h43
-rw-r--r--source/Commands/CommandObjectLanguage.cpp5
-rw-r--r--source/Commands/CommandObjectLanguage.h10
-rw-r--r--source/Commands/CommandObjectLog.cpp41
-rw-r--r--source/Commands/CommandObjectLog.h5
-rw-r--r--source/Commands/CommandObjectMemory.cpp181
-rw-r--r--source/Commands/CommandObjectMemory.h6
-rw-r--r--source/Commands/CommandObjectMultiword.cpp8
-rw-r--r--source/Commands/CommandObjectPlatform.cpp274
-rw-r--r--source/Commands/CommandObjectPlatform.h7
-rw-r--r--source/Commands/CommandObjectPlugin.cpp6
-rw-r--r--source/Commands/CommandObjectPlugin.h6
-rw-r--r--source/Commands/CommandObjectProcess.cpp315
-rw-r--r--source/Commands/CommandObjectProcess.h6
-rw-r--r--source/Commands/CommandObjectQuit.h12
-rw-r--r--source/Commands/CommandObjectRegister.cpp35
-rw-r--r--source/Commands/CommandObjectRegister.h5
-rw-r--r--source/Commands/CommandObjectSettings.cpp134
-rw-r--r--source/Commands/CommandObjectSettings.h6
-rw-r--r--source/Commands/CommandObjectSource.cpp32
-rw-r--r--source/Commands/CommandObjectSource.h6
-rw-r--r--source/Commands/CommandObjectSyntax.h13
-rw-r--r--source/Commands/CommandObjectTarget.cpp332
-rw-r--r--source/Commands/CommandObjectTarget.h7
-rw-r--r--source/Commands/CommandObjectThread.cpp182
-rw-r--r--source/Commands/CommandObjectThread.h6
-rw-r--r--source/Commands/CommandObjectType.cpp2507
-rw-r--r--source/Commands/CommandObjectType.h6
-rw-r--r--source/Commands/CommandObjectVersion.h12
-rw-r--r--source/Commands/CommandObjectWatchpoint.cpp128
-rw-r--r--source/Commands/CommandObjectWatchpoint.h6
-rw-r--r--source/Commands/CommandObjectWatchpointCommand.cpp45
-rw-r--r--source/Commands/CommandObjectWatchpointCommand.h7
-rw-r--r--source/Core/Address.cpp32
-rw-r--r--source/Core/AddressResolverName.cpp1
-rw-r--r--source/Core/ArchSpec.cpp174
-rw-r--r--source/Core/ConnectionSharedMemory.cpp2
-rw-r--r--source/Core/ConstString.cpp145
-rw-r--r--source/Core/CxaDemangle.cpp2
-rw-r--r--source/Core/DataEncoder.cpp10
-rw-r--r--source/Core/DataExtractor.cpp97
-rw-r--r--source/Core/Debugger.cpp146
-rw-r--r--source/Core/Disassembler.cpp17
-rw-r--r--source/Core/DynamicLoader.cpp46
-rw-r--r--source/Core/EmulateInstruction.cpp8
-rw-r--r--source/Core/Event.cpp2
-rw-r--r--source/Core/FastDemangle.cpp2
-rw-r--r--source/Core/FormatEntity.cpp399
-rw-r--r--source/Core/IOHandler.cpp184
-rw-r--r--source/Core/Language.cpp169
-rw-r--r--source/Core/Log.cpp3
-rw-r--r--source/Core/Logging.cpp3
-rw-r--r--source/Core/Mangled.cpp37
-rw-r--r--source/Core/Module.cpp222
-rw-r--r--source/Core/ModuleList.cpp83
-rw-r--r--source/Core/Opcode.cpp2
-rw-r--r--source/Core/PluginManager.cpp716
-rw-r--r--source/Core/RegisterValue.cpp583
-rw-r--r--source/Core/RegularExpression.cpp3
-rw-r--r--source/Core/Scalar.cpp2514
-rw-r--r--source/Core/Section.cpp19
-rw-r--r--source/Core/SourceManager.cpp25
-rw-r--r--source/Core/Stream.cpp20
-rw-r--r--source/Core/StreamAsynchronousIO.cpp2
-rw-r--r--source/Core/StreamString.cpp2
-rw-r--r--source/Core/Timer.cpp73
-rw-r--r--source/Core/Value.cpp58
-rw-r--r--source/Core/ValueObject.cpp607
-rw-r--r--source/Core/ValueObjectCast.cpp27
-rw-r--r--source/Core/ValueObjectChild.cpp119
-rw-r--r--source/Core/ValueObjectConstResult.cpp59
-rw-r--r--source/Core/ValueObjectConstResultCast.cpp75
-rw-r--r--source/Core/ValueObjectConstResultChild.cpp21
-rw-r--r--source/Core/ValueObjectConstResultImpl.cpp66
-rw-r--r--source/Core/ValueObjectDynamicValue.cpp142
-rw-r--r--source/Core/ValueObjectMemory.cpp47
-rw-r--r--source/Core/ValueObjectRegister.cpp51
-rw-r--r--source/Core/ValueObjectSyntheticFilter.cpp92
-rw-r--r--source/Core/ValueObjectVariable.cpp27
-rw-r--r--source/DataFormatters/CXXFormatterFunctions.cpp1228
-rw-r--r--source/DataFormatters/CXXFunctionPointer.cpp66
-rw-r--r--source/DataFormatters/DataVisualization.cpp34
-rw-r--r--source/DataFormatters/DumpValueObjectOptions.cpp245
-rw-r--r--source/DataFormatters/FormatClasses.cpp47
-rw-r--r--source/DataFormatters/FormatManager.cpp1156
-rw-r--r--source/DataFormatters/FormattersHelpers.cpp336
-rw-r--r--source/DataFormatters/LanguageCategory.cpp271
-rw-r--r--source/DataFormatters/LibStdcpp.cpp160
-rw-r--r--source/DataFormatters/StringPrinter.cpp307
-rw-r--r--source/DataFormatters/TypeCategory.cpp151
-rw-r--r--source/DataFormatters/TypeCategoryMap.cpp105
-rw-r--r--source/DataFormatters/TypeFormat.cpp26
-rw-r--r--source/DataFormatters/TypeSummary.cpp44
-rw-r--r--source/DataFormatters/TypeSynthetic.cpp20
-rw-r--r--source/DataFormatters/ValueObjectPrinter.cpp444
-rw-r--r--source/DataFormatters/VectorType.cpp128
-rw-r--r--source/Expression/ClangExpressionVariable.cpp142
-rw-r--r--source/Expression/ClangUserExpression.cpp1172
-rw-r--r--source/Expression/DWARFExpression.cpp659
-rw-r--r--source/Expression/Expression.cpp32
-rw-r--r--source/Expression/ExpressionSourceCode.cpp145
-rw-r--r--source/Expression/ExpressionVariable.cpp36
-rw-r--r--source/Expression/FunctionCaller.cpp (renamed from source/Expression/ClangFunction.cpp)248
-rw-r--r--source/Expression/IRDynamicChecks.cpp100
-rw-r--r--source/Expression/IRExecutionUnit.cpp22
-rw-r--r--source/Expression/IRInterpreter.cpp16
-rw-r--r--source/Expression/IRMemoryMap.cpp21
-rw-r--r--source/Expression/LLVMUserExpression.cpp363
-rw-r--r--source/Expression/Materializer.cpp303
-rw-r--r--source/Expression/REPL.cpp649
-rw-r--r--source/Expression/UserExpression.cpp348
-rw-r--r--source/Expression/UtilityFunction.cpp124
-rw-r--r--source/Host/common/Editline.cpp52
-rw-r--r--source/Host/common/File.cpp22
-rw-r--r--source/Host/common/FileSpec.cpp26
-rw-r--r--source/Host/common/GetOptInc.cpp473
-rw-r--r--source/Host/common/Host.cpp10
-rw-r--r--source/Host/common/HostInfoBase.cpp24
-rw-r--r--source/Host/common/Mutex.cpp2
-rw-r--r--source/Host/common/NativeProcessProtocol.cpp8
-rw-r--r--source/Host/common/OptionParser.cpp4
-rw-r--r--source/Host/common/Socket.cpp622
-rw-r--r--source/Host/common/SocketAddress.cpp6
-rw-r--r--source/Host/common/Symbols.cpp68
-rw-r--r--source/Host/common/TCPSocket.cpp288
-rw-r--r--source/Host/common/ThisThread.cpp2
-rw-r--r--source/Host/common/UDPSocket.cpp158
-rw-r--r--source/Host/common/XML.cpp6
-rw-r--r--source/Host/freebsd/Host.cpp2
-rw-r--r--source/Host/netbsd/Host.cpp287
-rw-r--r--source/Host/netbsd/HostInfoNetBSD.cpp112
-rw-r--r--source/Host/netbsd/HostThreadNetBSD.cpp50
-rw-r--r--source/Host/netbsd/ThisThread.cpp30
-rw-r--r--source/Host/posix/ConnectionFileDescriptorPosix.cpp108
-rw-r--r--source/Host/posix/DomainSocket.cpp133
-rw-r--r--source/Host/posix/FileSystem.cpp57
-rw-r--r--source/Host/posix/HostInfoPosix.cpp21
-rw-r--r--source/Host/posix/MainLoopPosix.cpp6
-rw-r--r--source/Host/posix/PipePosix.cpp10
-rw-r--r--source/Initialization/SystemInitializerCommon.cpp27
-rw-r--r--source/Interpreter/Args.cpp47
-rw-r--r--source/Interpreter/CommandInterpreter.cpp121
-rw-r--r--source/Interpreter/CommandObject.cpp6
-rw-r--r--source/Interpreter/CommandObjectScript.h14
-rw-r--r--source/Interpreter/OptionGroupValueObjectDisplay.cpp2
-rw-r--r--source/Interpreter/OptionValueLanguage.cpp29
-rw-r--r--source/Interpreter/OptionValueProperties.cpp9
-rw-r--r--source/Interpreter/Property.cpp4
-rw-r--r--source/Interpreter/PythonDataObjects.cpp524
-rw-r--r--source/Interpreter/ScriptInterpreterNone.cpp42
-rw-r--r--source/Interpreter/embedded_interpreter.py15
-rw-r--r--source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp317
-rw-r--r--source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h81
-rw-r--r--source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp170
-rw-r--r--source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h72
-rw-r--r--source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp397
-rw-r--r--source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h84
-rw-r--r--source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp262
-rw-r--r--source/Plugins/ABI/SysV-arm/ABISysV_arm.h16
-rw-r--r--source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp31
-rw-r--r--source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h17
-rw-r--r--source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp38
-rw-r--r--source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h117
-rw-r--r--source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp495
-rw-r--r--source/Plugins/ABI/SysV-i386/ABISysV_i386.h37
-rw-r--r--source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp327
-rw-r--r--source/Plugins/ABI/SysV-mips/ABISysV_mips.h96
-rw-r--r--source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp542
-rw-r--r--source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h88
-rw-r--r--source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp347
-rw-r--r--source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h98
-rw-r--r--source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp348
-rw-r--r--source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h98
-rw-r--r--source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp475
-rw-r--r--source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h88
-rw-r--r--source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp236
-rw-r--r--source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h57
-rw-r--r--source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp37
-rw-r--r--source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h66
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp42
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp63
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h76
-rw-r--r--source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h42
-rw-r--r--source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp42
-rw-r--r--source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h25
-rw-r--r--source/Plugins/ExpressionParser/Clang/ASTDumper.cpp (renamed from source/Expression/ASTDumper.cpp)12
-rw-r--r--source/Plugins/ExpressionParser/Clang/ASTDumper.h (renamed from include/lldb/Expression/ASTDumper.h)5
-rw-r--r--source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp (renamed from source/Expression/ASTResultSynthesizer.cpp)8
-rw-r--r--source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.h (renamed from include/lldb/Expression/ASTResultSynthesizer.h)27
-rw-r--r--source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp (renamed from source/Expression/ASTStructExtractor.cpp)5
-rw-r--r--source/Plugins/ExpressionParser/Clang/ASTStructExtractor.h (renamed from include/lldb/Expression/ASTStructExtractor.h)40
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp (renamed from source/Expression/ClangASTSource.cpp)292
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangASTSource.h (renamed from include/lldb/Expression/ClangASTSource.h)47
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp (renamed from source/Expression/ClangExpressionDeclMap.cpp)634
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h (renamed from include/lldb/Expression/ClangExpressionDeclMap.h)47
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h79
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (renamed from source/Expression/ClangExpressionParser.cpp)140
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h (renamed from include/lldb/Expression/ClangExpressionParser.h)36
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp76
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h (renamed from include/lldb/Expression/ClangExpressionVariable.h)291
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp221
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h173
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp (renamed from source/Expression/ClangModulesDeclVendor.cpp)64
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h (renamed from include/lldb/Expression/ClangModulesDeclVendor.h)13
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp (renamed from source/Expression/ClangPersistentVariables.cpp)23
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h (renamed from include/lldb/Expression/ClangPersistentVariables.h)51
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp673
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangUserExpression.h218
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp (renamed from source/Expression/ClangUtilityFunction.cpp)43
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h137
-rw-r--r--source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (renamed from source/Expression/IRForTarget.cpp)43
-rw-r--r--source/Plugins/ExpressionParser/Clang/IRForTarget.h (renamed from include/lldb/Expression/IRForTarget.h)18
-rw-r--r--source/Plugins/ExpressionParser/Go/GoAST.h3225
-rw-r--r--source/Plugins/ExpressionParser/Go/GoLexer.cpp402
-rw-r--r--source/Plugins/ExpressionParser/Go/GoLexer.h201
-rw-r--r--source/Plugins/ExpressionParser/Go/GoParser.cpp1035
-rw-r--r--source/Plugins/ExpressionParser/Go/GoParser.h165
-rw-r--r--source/Plugins/ExpressionParser/Go/GoUserExpression.cpp756
-rw-r--r--source/Plugins/ExpressionParser/Go/GoUserExpression.h98
-rw-r--r--source/Plugins/ExpressionParser/Go/gen_go_ast.py356
-rw-r--r--source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp406
-rw-r--r--source/Plugins/Instruction/ARM/EmulateInstructionARM.h48
-rw-r--r--source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp304
-rw-r--r--source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h93
-rw-r--r--source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp1823
-rw-r--r--source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h132
-rw-r--r--source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp1119
-rw-r--r--source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h114
-rw-r--r--source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp74
-rw-r--r--source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h48
-rw-r--r--source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp77
-rw-r--r--source/Plugins/JITLoader/GDB/JITLoaderGDB.h36
-rw-r--r--source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp792
-rw-r--r--source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h186
-rw-r--r--source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp204
-rw-r--r--source/Plugins/Language/CPlusPlus/CxxStringTypes.h41
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxx.cpp (renamed from source/DataFormatters/LibCxx.cpp)200
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxx.h141
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp (renamed from source/DataFormatters/LibCxxInitializerList.cpp)56
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxList.cpp (renamed from source/DataFormatters/LibCxxList.cpp)391
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxMap.cpp (renamed from source/DataFormatters/LibCxxMap.cpp)154
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp (renamed from source/DataFormatters/LibCxxUnorderedMap.cpp)48
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxVector.cpp (renamed from source/DataFormatters/LibCxxVector.cpp)60
-rw-r--r--source/Plugins/Language/CPlusPlus/LibStdcpp.cpp373
-rw-r--r--source/Plugins/Language/CPlusPlus/LibStdcpp.h33
-rw-r--r--source/Plugins/Language/Go/GoFormatterFunctions.cpp173
-rw-r--r--source/Plugins/Language/Go/GoFormatterFunctions.h43
-rw-r--r--source/Plugins/Language/Go/GoLanguage.cpp146
-rw-r--r--source/Plugins/Language/Go/GoLanguage.h66
-rw-r--r--source/Plugins/Language/ObjC/CF.cpp (renamed from source/DataFormatters/CF.cpp)51
-rw-r--r--source/Plugins/Language/ObjC/CF.h34
-rw-r--r--source/Plugins/Language/ObjC/Cocoa.cpp (renamed from source/DataFormatters/Cocoa.cpp)450
-rw-r--r--source/Plugins/Language/ObjC/Cocoa.h97
-rw-r--r--source/Plugins/Language/ObjC/CoreMedia.cpp (renamed from source/DataFormatters/CoreMedia.cpp)18
-rw-r--r--source/Plugins/Language/ObjC/CoreMedia.h26
-rw-r--r--source/Plugins/Language/ObjC/NSArray.cpp (renamed from source/DataFormatters/NSArray.cpp)336
-rw-r--r--source/Plugins/Language/ObjC/NSDictionary.cpp (renamed from source/DataFormatters/NSDictionary.cpp)253
-rw-r--r--source/Plugins/Language/ObjC/NSDictionary.h48
-rw-r--r--source/Plugins/Language/ObjC/NSError.cpp218
-rw-r--r--source/Plugins/Language/ObjC/NSException.cpp219
-rw-r--r--source/Plugins/Language/ObjC/NSIndexPath.cpp (renamed from source/DataFormatters/NSIndexPath.cpp)77
-rw-r--r--source/Plugins/Language/ObjC/NSSet.cpp (renamed from source/DataFormatters/NSSet.cpp)279
-rw-r--r--source/Plugins/Language/ObjC/NSSet.h40
-rw-r--r--source/Plugins/Language/ObjC/NSString.cpp405
-rw-r--r--source/Plugins/Language/ObjC/NSString.h42
-rw-r--r--source/Plugins/Language/ObjC/ObjCLanguage.cpp877
-rw-r--r--source/Plugins/Language/ObjC/ObjCLanguage.h210
-rw-r--r--source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp68
-rw-r--r--source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h63
-rw-r--r--source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp49
-rw-r--r--source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h83
-rw-r--r--source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.cpp238
-rw-r--r--source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.h93
-rw-r--r--source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp3171
-rw-r--r--source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h229
-rw-r--r--source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp108
-rw-r--r--source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h34
-rw-r--r--source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp10
-rw-r--r--source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h65
-rw-r--r--source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp508
-rw-r--r--source/Plugins/ObjectFile/ELF/ObjectFileELF.h19
-rw-r--r--source/Plugins/ObjectFile/JIT/ObjectFileJIT.h114
-rw-r--r--source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp559
-rw-r--r--source/Plugins/OperatingSystem/Go/OperatingSystemGo.h87
-rw-r--r--source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp5
-rw-r--r--source/Plugins/OperatingSystem/Python/OperatingSystemPython.h60
-rw-r--r--source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h13
-rw-r--r--source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp685
-rw-r--r--source/Plugins/Platform/NetBSD/PlatformNetBSD.h177
-rw-r--r--source/Plugins/Platform/POSIX/PlatformPOSIX.cpp185
-rw-r--r--source/Plugins/Platform/POSIX/PlatformPOSIX.h60
-rw-r--r--source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp125
-rw-r--r--source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h33
-rw-r--r--source/Plugins/Process/FreeBSD/FreeBSDThread.cpp623
-rw-r--r--source/Plugins/Process/FreeBSD/FreeBSDThread.h109
-rw-r--r--source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp2
-rw-r--r--source/Plugins/Process/FreeBSD/POSIXStopInfo.h8
-rw-r--r--source/Plugins/Process/FreeBSD/POSIXThread.cpp661
-rw-r--r--source/Plugins/Process/FreeBSD/POSIXThread.h132
-rw-r--r--source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp829
-rw-r--r--source/Plugins/Process/FreeBSD/ProcessFreeBSD.h197
-rw-r--r--source/Plugins/Process/FreeBSD/ProcessMonitor.cpp6
-rw-r--r--source/Plugins/Process/FreeBSD/ProcessMonitor.h4
-rw-r--r--source/Plugins/Process/FreeBSD/ProcessPOSIX.cpp939
-rw-r--r--source/Plugins/Process/FreeBSD/ProcessPOSIX.h205
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIX.h (renamed from source/Plugins/Process/Utility/RegisterContextPOSIX.h)0
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp4
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.h1
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp6
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h1
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp4
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h1
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp4
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.h1
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp35
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h2
-rw-r--r--source/Plugins/Process/POSIX/CrashReason.cpp5
-rw-r--r--source/Plugins/Process/Utility/DynamicRegisterInfo.cpp18
-rw-r--r--source/Plugins/Process/Utility/FreeBSDSignals.cpp132
-rw-r--r--source/Plugins/Process/Utility/HistoryThread.h47
-rw-r--r--source/Plugins/Process/Utility/HistoryUnwind.h20
-rw-r--r--source/Plugins/Process/Utility/InferiorCallPOSIX.cpp15
-rw-r--r--source/Plugins/Process/Utility/LinuxSignals.cpp134
-rw-r--r--source/Plugins/Process/Utility/MipsLinuxSignals.cpp134
-rw-r--r--source/Plugins/Process/Utility/NetBSDSignals.cpp34
-rw-r--r--source/Plugins/Process/Utility/NetBSDSignals.h31
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp184
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_arm.h76
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp114
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_arm64.h64
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp228
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_i386.h55
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp406
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h52
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDummy.cpp4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDummy.h56
-rw-r--r--source/Plugins/Process/Utility/RegisterContextFreeBSD_arm.cpp1
-rw-r--r--source/Plugins/Process/Utility/RegisterContextFreeBSD_arm.h1
-rw-r--r--source/Plugins/Process/Utility/RegisterContextFreeBSD_arm64.h2
-rw-r--r--source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.h2
-rw-r--r--source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h2
-rw-r--r--source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h18
-rw-r--r--source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h2
-rw-r--r--source/Plugins/Process/Utility/RegisterContextHistory.cpp4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextHistory.h55
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLLDB.cpp93
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLLDB.h58
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_arm.cpp1
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_arm.h1
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_arm64.cpp2
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_arm64.h1
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp14
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_i386.h8
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp17
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_mips.h5
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp16
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_mips64.h2
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp11
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h57
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMemory.h61
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp48
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h30
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h27
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h27
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h29
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h29
-rw-r--r--source/Plugins/Process/Utility/RegisterContextThreadMemory.h104
-rw-r--r--source/Plugins/Process/Utility/RegisterContext_mips.h663
-rw-r--r--source/Plugins/Process/Utility/RegisterContext_powerpc.h321
-rw-r--r--source/Plugins/Process/Utility/RegisterContext_x86.h411
-rw-r--r--source/Plugins/Process/Utility/RegisterInfoInterface.h22
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_arm.h334
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_arm64.h156
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_i386.h73
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_mips.h233
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_mips64.h319
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_powerpc.h14
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_x86_64.h94
-rw-r--r--source/Plugins/Process/Utility/StopInfoMachException.cpp4
-rw-r--r--source/Plugins/Process/Utility/StopInfoMachException.h16
-rw-r--r--source/Plugins/Process/Utility/ThreadMemory.h92
-rw-r--r--source/Plugins/Process/Utility/UnwindLLDB.cpp86
-rw-r--r--source/Plugins/Process/Utility/UnwindLLDB.h37
-rw-r--r--source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h28
-rw-r--r--source/Plugins/Process/Utility/lldb-arm-register-enums.h50
-rw-r--r--source/Plugins/Process/elf-core/ProcessElfCore.cpp77
-rw-r--r--source/Plugins/Process/elf-core/ProcessElfCore.h32
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp1
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h40
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp1
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h40
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp1
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h40
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp1
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h42
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp1
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h40
-rw-r--r--source/Plugins/Process/elf-core/ThreadElfCore.cpp5
-rw-r--r--source/Plugins/Process/elf-core/ThreadElfCore.h41
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp232
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h77
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp287
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h76
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h8
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp105
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h17
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp600
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h41
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp305
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h52
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp290
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h22
-rw-r--r--source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp1080
-rw-r--r--source/Plugins/Process/gdb-remote/ProcessGDBRemote.h138
-rw-r--r--source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp8
-rw-r--r--source/Plugins/Process/gdb-remote/ThreadGDBRemote.h32
-rw-r--r--source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp93
-rw-r--r--source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h66
-rw-r--r--source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp1069
-rw-r--r--source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h498
-rw-r--r--source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp201
-rw-r--r--source/Plugins/ScriptInterpreter/Python/PythonExceptionState.h70
-rw-r--r--source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (renamed from source/Interpreter/ScriptInterpreterPython.cpp)1004
-rw-r--r--source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h (renamed from include/lldb/Interpreter/ScriptInterpreterPython.h)170
-rw-r--r--source/Plugins/ScriptInterpreter/Python/lldb-python.h31
-rw-r--r--source/Plugins/SymbolFile/DWARF/DIERef.cpp56
-rw-r--r--source/Plugins/SymbolFile/DWARF/DIERef.h42
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFASTParser.h65
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp4034
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h213
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp828
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.h84
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp90
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFAttribute.h60
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp459
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h124
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp543
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDIE.h281
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp18
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h12
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h5
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp230
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h35
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp953
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h138
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp95
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h9
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp128
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h68
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp60
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp54
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h16
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h7
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp114
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFFormValue.h40
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp172
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.h24
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp94
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFLocationList.h34
-rw-r--r--source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp747
-rw-r--r--source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h950
-rw-r--r--source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h34
-rw-r--r--source/Plugins/SymbolFile/DWARF/NameToDIE.cpp34
-rw-r--r--source/Plugins/SymbolFile/DWARF/NameToDIE.h33
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp5934
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h807
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp212
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h45
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp131
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h70
-rw-r--r--source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp49
-rw-r--r--source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h35
-rw-r--r--source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp83
-rw-r--r--source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h129
-rw-r--r--source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp8
-rw-r--r--source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h31
-rw-r--r--source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp56
-rw-r--r--source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h100
-rw-r--r--source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h51
-rw-r--r--source/Symbol/ArmUnwindInfo.cpp445
-rw-r--r--source/Symbol/Block.cpp33
-rw-r--r--source/Symbol/ClangASTContext.cpp8450
-rw-r--r--source/Symbol/ClangASTImporter.cpp130
-rw-r--r--source/Symbol/ClangASTType.cpp7057
-rw-r--r--source/Symbol/ClangExternalASTSourceCallbacks.cpp14
-rw-r--r--source/Symbol/ClangNamespaceDecl.cpp25
-rw-r--r--source/Symbol/CompactUnwindInfo.cpp10
-rw-r--r--source/Symbol/CompileUnit.cpp55
-rw-r--r--source/Symbol/CompilerDecl.cpp76
-rw-r--r--source/Symbol/CompilerDeclContext.cpp75
-rw-r--r--source/Symbol/CompilerType.cpp1320
-rw-r--r--source/Symbol/DWARFCallFrameInfo.cpp6
-rw-r--r--source/Symbol/DebugMacros.cpp65
-rw-r--r--source/Symbol/FuncUnwinders.cpp43
-rw-r--r--source/Symbol/Function.cpp78
-rw-r--r--source/Symbol/GoASTContext.cpp1519
-rw-r--r--source/Symbol/LineEntry.cpp39
-rw-r--r--source/Symbol/LineTable.cpp14
-rw-r--r--source/Symbol/ObjectFile.cpp50
-rw-r--r--source/Symbol/SymbolContext.cpp175
-rw-r--r--source/Symbol/SymbolFile.cpp69
-rw-r--r--source/Symbol/SymbolVendor.cpp51
-rw-r--r--source/Symbol/Symtab.cpp10
-rw-r--r--source/Symbol/Type.cpp370
-rw-r--r--source/Symbol/TypeList.cpp73
-rw-r--r--source/Symbol/TypeMap.cpp322
-rw-r--r--source/Symbol/TypeSystem.cpp255
-rw-r--r--source/Symbol/UnwindTable.cpp36
-rw-r--r--source/Symbol/Variable.cpp106
-rw-r--r--source/Symbol/VariableList.cpp18
-rw-r--r--source/Target/ABI.cpp19
-rw-r--r--source/Target/CPPLanguageRuntime.cpp372
-rw-r--r--source/Target/ExecutionContext.cpp2
-rw-r--r--source/Target/Language.cpp458
-rw-r--r--source/Target/LanguageRuntime.cpp144
-rw-r--r--source/Target/Memory.cpp26
-rw-r--r--source/Target/ObjCLanguageRuntime.cpp299
-rw-r--r--source/Target/Platform.cpp167
-rw-r--r--source/Target/Process.cpp1033
-rw-r--r--source/Target/ProcessLaunchInfo.cpp3
-rw-r--r--source/Target/RegisterContext.cpp30
-rw-r--r--source/Target/StackFrame.cpp86
-rw-r--r--source/Target/StackFrameList.cpp14
-rw-r--r--source/Target/StopInfo.cpp237
-rw-r--r--source/Target/Target.cpp1088
-rw-r--r--source/Target/TargetList.cpp63
-rw-r--r--source/Target/Thread.cpp323
-rw-r--r--source/Target/ThreadList.cpp38
-rw-r--r--source/Target/ThreadPlan.cpp38
-rw-r--r--source/Target/ThreadPlanCallFunction.cpp32
-rw-r--r--source/Target/ThreadPlanCallFunctionUsingABI.cpp13
-rw-r--r--source/Target/ThreadPlanCallUserExpression.cpp6
-rw-r--r--source/Target/ThreadPlanRunToAddress.cpp7
-rw-r--r--source/Target/ThreadPlanShouldStopHere.cpp40
-rw-r--r--source/Target/ThreadPlanStepInRange.cpp62
-rw-r--r--source/Target/ThreadPlanStepInstruction.cpp30
-rw-r--r--source/Target/ThreadPlanStepOut.cpp79
-rw-r--r--source/Target/ThreadPlanStepOverRange.cpp69
-rw-r--r--source/Target/ThreadPlanStepRange.cpp65
-rw-r--r--source/Target/ThreadPlanStepThrough.cpp14
-rw-r--r--source/Target/ThreadPlanStepUntil.cpp211
-rw-r--r--source/Target/ThreadPlanTracer.cpp63
-rw-r--r--source/Target/ThreadSpec.cpp24
-rw-r--r--source/Target/UnixSignals.cpp95
-rw-r--r--source/Utility/ARM64_ehframe_Registers.h (renamed from source/Utility/ARM64_GCC_Registers.h)13
-rw-r--r--source/Utility/ARM_GCC_Registers.h146
-rw-r--r--source/Utility/ARM_ehframe_Registers.h38
-rw-r--r--source/Utility/ConvertEnum.cpp12
-rw-r--r--source/Utility/JSON.cpp89
-rw-r--r--source/Utility/ModuleCache.cpp186
-rw-r--r--source/Utility/ModuleCache.h9
-rw-r--r--source/Utility/SharingPtr.cpp2
-rw-r--r--source/Utility/StringExtractor.cpp17
-rw-r--r--source/Utility/StringExtractorGDBRemote.cpp20
-rw-r--r--source/Utility/StringExtractorGDBRemote.h4
-rw-r--r--source/Utility/TaskPool.cpp88
-rw-r--r--source/Utility/UriParser.cpp88
-rw-r--r--source/Utility/UriParser.h12
-rw-r--r--source/lldb.cpp2
-rw-r--r--tools/argdumper/argdumper.exports (renamed from tools/argdumper/exports)0
-rw-r--r--tools/driver/Driver.cpp217
-rw-r--r--tools/driver/Driver.h3
-rw-r--r--tools/lldb-mi/MICmdArgContext.cpp24
-rw-r--r--tools/lldb-mi/MICmdArgContext.h17
-rw-r--r--tools/lldb-mi/MICmdArgSet.cpp46
-rw-r--r--tools/lldb-mi/MICmdArgSet.h47
-rw-r--r--tools/lldb-mi/MICmdArgValBase.cpp30
-rw-r--r--tools/lldb-mi/MICmdArgValBase.h66
-rw-r--r--tools/lldb-mi/MICmdArgValConsume.cpp14
-rw-r--r--tools/lldb-mi/MICmdArgValConsume.h11
-rw-r--r--tools/lldb-mi/MICmdArgValFile.cpp14
-rw-r--r--tools/lldb-mi/MICmdArgValFile.h7
-rw-r--r--tools/lldb-mi/MICmdArgValListBase.cpp6
-rw-r--r--tools/lldb-mi/MICmdArgValListBase.h9
-rw-r--r--tools/lldb-mi/MICmdArgValListOfN.cpp6
-rw-r--r--tools/lldb-mi/MICmdArgValListOfN.h9
-rw-r--r--tools/lldb-mi/MICmdArgValNumber.cpp6
-rw-r--r--tools/lldb-mi/MICmdArgValNumber.h9
-rw-r--r--tools/lldb-mi/MICmdArgValOptionLong.cpp18
-rw-r--r--tools/lldb-mi/MICmdArgValOptionLong.h11
-rw-r--r--tools/lldb-mi/MICmdArgValOptionShort.cpp6
-rw-r--r--tools/lldb-mi/MICmdArgValOptionShort.h7
-rw-r--r--tools/lldb-mi/MICmdArgValPrintValues.cpp6
-rw-r--r--tools/lldb-mi/MICmdArgValPrintValues.h6
-rw-r--r--tools/lldb-mi/MICmdArgValString.cpp8
-rw-r--r--tools/lldb-mi/MICmdArgValString.h7
-rw-r--r--tools/lldb-mi/MICmdArgValThreadGrp.cpp12
-rw-r--r--tools/lldb-mi/MICmdArgValThreadGrp.h9
-rw-r--r--tools/lldb-mi/MICmdBase.cpp59
-rw-r--r--tools/lldb-mi/MICmdBase.h56
-rw-r--r--tools/lldb-mi/MICmdCmd.cpp20
-rw-r--r--tools/lldb-mi/MICmdCmd.h26
-rw-r--r--tools/lldb-mi/MICmdCmdBreak.cpp211
-rw-r--r--tools/lldb-mi/MICmdCmdBreak.h98
-rw-r--r--tools/lldb-mi/MICmdCmdData.cpp406
-rw-r--r--tools/lldb-mi/MICmdCmdData.h156
-rw-r--r--tools/lldb-mi/MICmdCmdEnviro.cpp16
-rw-r--r--tools/lldb-mi/MICmdCmdEnviro.h15
-rw-r--r--tools/lldb-mi/MICmdCmdExec.cpp227
-rw-r--r--tools/lldb-mi/MICmdCmdExec.h146
-rw-r--r--tools/lldb-mi/MICmdCmdFile.cpp31
-rw-r--r--tools/lldb-mi/MICmdCmdFile.h18
-rw-r--r--tools/lldb-mi/MICmdCmdGdbInfo.cpp20
-rw-r--r--tools/lldb-mi/MICmdCmdGdbInfo.h19
-rw-r--r--tools/lldb-mi/MICmdCmdGdbSet.cpp24
-rw-r--r--tools/lldb-mi/MICmdCmdGdbSet.h16
-rw-r--r--tools/lldb-mi/MICmdCmdGdbShow.cpp24
-rw-r--r--tools/lldb-mi/MICmdCmdGdbShow.h15
-rw-r--r--tools/lldb-mi/MICmdCmdGdbThread.cpp10
-rw-r--r--tools/lldb-mi/MICmdCmdGdbThread.h13
-rw-r--r--tools/lldb-mi/MICmdCmdMiscellanous.cpp64
-rw-r--r--tools/lldb-mi/MICmdCmdMiscellanous.h56
-rw-r--r--tools/lldb-mi/MICmdCmdStack.cpp139
-rw-r--r--tools/lldb-mi/MICmdCmdStack.h105
-rw-r--r--tools/lldb-mi/MICmdCmdSupportInfo.cpp16
-rw-r--r--tools/lldb-mi/MICmdCmdSupportInfo.h15
-rw-r--r--tools/lldb-mi/MICmdCmdSupportList.cpp19
-rw-r--r--tools/lldb-mi/MICmdCmdSupportList.h13
-rw-r--r--tools/lldb-mi/MICmdCmdSymbol.cpp136
-rw-r--r--tools/lldb-mi/MICmdCmdSymbol.h12
-rw-r--r--tools/lldb-mi/MICmdCmdTarget.cpp50
-rw-r--r--tools/lldb-mi/MICmdCmdTarget.h39
-rw-r--r--tools/lldb-mi/MICmdCmdThread.cpp16
-rw-r--r--tools/lldb-mi/MICmdCmdThread.h15
-rw-r--r--tools/lldb-mi/MICmdCmdTrace.cpp10
-rw-r--r--tools/lldb-mi/MICmdCmdTrace.h13
-rw-r--r--tools/lldb-mi/MICmdCmdVar.cpp230
-rw-r--r--tools/lldb-mi/MICmdCmdVar.h140
-rw-r--r--tools/lldb-mi/MICmdCommands.cpp6
-rw-r--r--tools/lldb-mi/MICmdCommands.h5
-rw-r--r--tools/lldb-mi/MICmdData.h9
-rw-r--r--tools/lldb-mi/MICmdFactory.cpp17
-rw-r--r--tools/lldb-mi/MICmdFactory.h19
-rw-r--r--tools/lldb-mi/MICmdInterpreter.cpp20
-rw-r--r--tools/lldb-mi/MICmdInterpreter.h11
-rw-r--r--tools/lldb-mi/MICmdInvoker.cpp32
-rw-r--r--tools/lldb-mi/MICmdInvoker.h35
-rw-r--r--tools/lldb-mi/MICmdMgr.cpp8
-rw-r--r--tools/lldb-mi/MICmdMgr.h11
-rw-r--r--tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.cpp4
-rw-r--r--tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.h12
-rw-r--r--tools/lldb-mi/MICmnBase.cpp10
-rw-r--r--tools/lldb-mi/MICmnBase.h13
-rw-r--r--tools/lldb-mi/MICmnLLDBBroadcaster.cpp8
-rw-r--r--tools/lldb-mi/MICmnLLDBBroadcaster.h11
-rw-r--r--tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp110
-rw-r--r--tools/lldb-mi/MICmnLLDBDebugSessionInfo.h17
-rw-r--r--tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp30
-rw-r--r--tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h31
-rw-r--r--tools/lldb-mi/MICmnLLDBDebugger.cpp131
-rw-r--r--tools/lldb-mi/MICmnLLDBDebugger.h36
-rw-r--r--tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp179
-rw-r--r--tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h29
-rw-r--r--tools/lldb-mi/MICmnLLDBProxySBValue.h3
-rw-r--r--tools/lldb-mi/MICmnLLDBUtilSBValue.cpp288
-rw-r--r--tools/lldb-mi/MICmnLLDBUtilSBValue.h40
-rw-r--r--tools/lldb-mi/MICmnLog.cpp16
-rw-r--r--tools/lldb-mi/MICmnLog.h29
-rw-r--r--tools/lldb-mi/MICmnLogMediumFile.cpp62
-rw-r--r--tools/lldb-mi/MICmnLogMediumFile.h33
-rw-r--r--tools/lldb-mi/MICmnMIOutOfBandRecord.cpp183
-rw-r--r--tools/lldb-mi/MICmnMIOutOfBandRecord.h37
-rw-r--r--tools/lldb-mi/MICmnMIResultRecord.cpp103
-rw-r--r--tools/lldb-mi/MICmnMIResultRecord.h35
-rw-r--r--tools/lldb-mi/MICmnMIValue.cpp8
-rw-r--r--tools/lldb-mi/MICmnMIValue.h9
-rw-r--r--tools/lldb-mi/MICmnMIValueConst.cpp6
-rw-r--r--tools/lldb-mi/MICmnMIValueConst.h8
-rw-r--r--tools/lldb-mi/MICmnMIValueList.cpp49
-rw-r--r--tools/lldb-mi/MICmnMIValueList.h17
-rw-r--r--tools/lldb-mi/MICmnMIValueResult.cpp28
-rw-r--r--tools/lldb-mi/MICmnMIValueResult.h13
-rw-r--r--tools/lldb-mi/MICmnMIValueTuple.cpp58
-rw-r--r--tools/lldb-mi/MICmnMIValueTuple.h21
-rw-r--r--tools/lldb-mi/MICmnResources.cpp13
-rw-r--r--tools/lldb-mi/MICmnResources.h15
-rw-r--r--tools/lldb-mi/MICmnStreamStderr.cpp12
-rw-r--r--tools/lldb-mi/MICmnStreamStderr.h15
-rw-r--r--tools/lldb-mi/MICmnStreamStdin.cpp14
-rw-r--r--tools/lldb-mi/MICmnStreamStdin.h17
-rw-r--r--tools/lldb-mi/MICmnStreamStdout.cpp16
-rw-r--r--tools/lldb-mi/MICmnStreamStdout.h17
-rw-r--r--tools/lldb-mi/MICmnThreadMgrStd.cpp12
-rw-r--r--tools/lldb-mi/MICmnThreadMgrStd.h13
-rw-r--r--tools/lldb-mi/MIDataTypes.h16
-rw-r--r--tools/lldb-mi/MIDriver.cpp72
-rw-r--r--tools/lldb-mi/MIDriver.h73
-rw-r--r--tools/lldb-mi/MIDriverBase.cpp14
-rw-r--r--tools/lldb-mi/MIDriverBase.h21
-rw-r--r--tools/lldb-mi/MIDriverMain.cpp2
-rw-r--r--tools/lldb-mi/MIDriverMgr.cpp38
-rw-r--r--tools/lldb-mi/MIDriverMgr.h49
-rw-r--r--tools/lldb-mi/MIExtensions.txt9
-rw-r--r--tools/lldb-mi/MIUtilDateTimeStd.cpp10
-rw-r--r--tools/lldb-mi/MIUtilDateTimeStd.h13
-rw-r--r--tools/lldb-mi/MIUtilDebug.cpp10
-rw-r--r--tools/lldb-mi/MIUtilDebug.h16
-rw-r--r--tools/lldb-mi/MIUtilFileStd.cpp12
-rw-r--r--tools/lldb-mi/MIUtilFileStd.h15
-rw-r--r--tools/lldb-mi/MIUtilMapIdToVariant.cpp8
-rw-r--r--tools/lldb-mi/MIUtilMapIdToVariant.h11
-rw-r--r--tools/lldb-mi/MIUtilParse.cpp75
-rw-r--r--tools/lldb-mi/MIUtilParse.h93
-rw-r--r--tools/lldb-mi/MIUtilSingletonBase.h14
-rw-r--r--tools/lldb-mi/MIUtilSingletonHelper.h7
-rw-r--r--tools/lldb-mi/MIUtilString.cpp118
-rw-r--r--tools/lldb-mi/MIUtilString.h33
-rw-r--r--tools/lldb-mi/MIUtilSystemLinux.cpp111
-rw-r--r--tools/lldb-mi/MIUtilSystemLinux.h45
-rw-r--r--tools/lldb-mi/MIUtilSystemOsx.cpp111
-rw-r--r--tools/lldb-mi/MIUtilSystemOsx.h45
-rw-r--r--tools/lldb-mi/MIUtilSystemWindows.cpp141
-rw-r--r--tools/lldb-mi/MIUtilSystemWindows.h44
-rw-r--r--tools/lldb-mi/MIUtilThreadBaseStd.cpp36
-rw-r--r--tools/lldb-mi/MIUtilThreadBaseStd.h59
-rw-r--r--tools/lldb-mi/MIUtilVariant.cpp18
-rw-r--r--tools/lldb-mi/MIUtilVariant.h49
-rw-r--r--tools/lldb-mi/lldb-mi.exports (renamed from tools/lldb-server/exports)0
-rw-r--r--tools/lldb-server/Acceptor.cpp170
-rw-r--r--tools/lldb-server/Acceptor.h68
-rw-r--r--tools/lldb-server/LLDBServerUtilities.cpp2
-rw-r--r--tools/lldb-server/lldb-gdbserver.cpp158
-rw-r--r--tools/lldb-server/lldb-platform.cpp95
-rw-r--r--tools/lldb-server/lldb-server.exports0
1089 files changed, 93010 insertions, 55864 deletions
diff --git a/docs/lldb.1 b/docs/lldb.1
index 0d94dcbe6a78..a28cabe7acc0 100644
--- a/docs/lldb.1
+++ b/docs/lldb.1
@@ -1,19 +1,20 @@
-.Dd June 7, 2012 \" DATE
+.Dd December 16, 2015 \" DATE
.Dt LLDB 1 \" Program name and manual section number
-.Os Darwin \" Operating System
-.Sh NAME \" Section Header - required - don't modify
+.Os
+.Sh NAME \" Section Header - required - do not modify
.Nm lldb
.Nd The debugger
-.Sh SYNOPSIS \" Section Header - required - don't modify
+.Sh SYNOPSIS \" Section Header - required - do not modify
.Nm lldb
.Op Fl hvdexw
.Op Fl a Ar arch
+.Op Fl c Ar core-file
.Op Fl l Ar script-language
.Op Fl s Ar lldb-commands
.Op Fl n Ar process-name
.Op Fl p Ar pid
.Ar [[--] <PROGRAM-ARG1> <PROGRAM-ARG2> ...]
-.Sh DESCRIPTION \" Section Header - required - don't modify
+.Sh DESCRIPTION \" Section Header - required - do not modify
.Nm
is the command line interface for the LLDB debugger library.
.Nm
@@ -24,7 +25,10 @@ The following options are available:
.It Fl h, -help
Prints out the usage information for the
.Nm
-debugger. The \fB\-\-help\fR text may be more up-to-date and
+debugger.
+The
+.Fl -help
+text may be more up-to-date and
authoritative than the command line options described in this man
page.
.It Fl v, -version
@@ -42,9 +46,13 @@ Specifies the executable file that
will be launching / attaching to.
.It Fl n, -attach-name Ar process-name
Specifies the name of a currently-running process to attach to.
-(or the name of a process to wait for if \fB\-w\fR is used.)
+(or the name of a process to wait for if
+.Fl w
+is used.)
.It Fl w, -wait-for
-When used in concert with \&\fB\-n process-name\-E\fR, indicates that
+When used in concert with
+.Fl n Ar process-name ,
+indicates that
.Nm
should wait for a new process of that name to be started -- and attach
to it as early in the process-launch as possible.
@@ -52,9 +60,12 @@ to it as early in the process-launch as possible.
Specifies a currently running process that
.Nm
should attach to.
+.It Fl c, -core Ar core-file
+Specifies the core file to examine.
.It Fl l, -script-language Ar language
Tells the debugger to use the specified scripting language for
-user-defined scripts, rather than the default. Valid scripting
+user-defined scripts, rather than the default.
+Valid scripting
languages that can be specified include Python, Perl, Ruby and Tcl.
Currently only the Python extensions have been implemented.
.It Fl d, -debug
@@ -62,8 +73,9 @@ Tells the debugger to print out extra information for debugging itself.
.It Fl s, -source Ar filename
Tells
.Nm
-to read in and execute the file "\fBfilename\fR", which
-should contain
+to read in and execute the file
+.Qq Ar filename ,
+which should contain
.Nm
commands.
.It Fl e, -editor
@@ -73,39 +85,62 @@ to open source files using the host's "external editor" mechanism.
.It Fl x, -no-lldbinit
Do not automatically parse any '.lldbinit' files.
.Pp
-(If you don't provide -f then the first argument will be the file to be debugged
+(If you do not provide -f then the first argument will be the file to
+be debugged
so 'lldb -- <filename> [<ARG1> [<ARG2>]]' also works.
-Remember to end the options with "--" if any of your arguments have a "-" in them.)
+Remember to end the options with "--" if any of your arguments have
+a "-" in them.)
.El
.Sh USING LLDB
In
.Nm
-there is a \fBhelp\fR command which can be used to find descriptions and examples of
-all
+there is a
+.Cm help
+command which can be used to find descriptions and examples of all
.Nm
-commands. To get help on "\fBbreakpoint set\fR" you would type "\fBhelp breakpoint set\fR".
+commands.
+To get help on
+.Qq Cm breakpoint set
+you would type
+.Qq Cm help breakpoint set .
.Pp
-There is also an \fBapropos\fR command which will search the help text of all commands
-for a given term -- this is useful for locating a command by topic. For instance, "\fBapropos breakpoint\fR"
-will list any command that has the word \fBbreakpoint\fR in its help text.
+There is also an
+.Cm apropos
+command which will search the help text of all commands
+for a given term -- this is useful for locating a command by topic.
+For instance,
+.Qq Cm apropos breakpoint
+will list any command that has the word
+.Qq Cm breakpoint
+in its help text.
.Sh FILES
.Nm
will read settings/aliases/commands from three files at startup, if they exist.
.Pp
-First, it will read a \fB~/.lldbinit-\fIdebugger\fR command file. If you are using the
+First, it will read a
+.Pa ~/.lldbinit-debugger
+command file.
+If you are using the
.Nm
-command line interface, this is \fB~/.lldbinit-lldb\fR. If you are using
+command line interface, this is
+.Pa ~/.lldbinit-lldb .
+If you are using
.Nm
inside a GUI debugger like
.Nm Xcode
-this will be \fB~/.lldbinit-Xcode\fR. This is a useful place to put settings that you
-want to apply only when a given
+this will be
+.Pa ~/.lldbinit-Xcode .
+This is a useful place to put settings that you want to apply only when a given
.Nm
command interpreter is used.
.Pp
-Second, \fB~/.lldbinit\fR is read.
+Second,
+.Pa ~/.lldbinit
+is read.
.Pp
-Third, an \fR.lldbinit\fR file in the current working directory (where
+Third, an
+.Pa .lldbinit
+file in the current working directory (where
.Nm
is started) will be read.
.Sh SEE ALSO
diff --git a/include/lldb/API/LLDB.h b/include/lldb/API/LLDB.h
index 66e095395f13..eed10d08c6cc 100644
--- a/include/lldb/API/LLDB.h
+++ b/include/lldb/API/LLDB.h
@@ -16,6 +16,7 @@
// Project includes
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBAddress.h"
+#include "lldb/API/SBAttachInfo.h"
#include "lldb/API/SBBlock.h"
#include "lldb/API/SBBreakpoint.h"
#include "lldb/API/SBBreakpointLocation.h"
@@ -30,28 +31,47 @@
#include "lldb/API/SBError.h"
#include "lldb/API/SBEvent.h"
#include "lldb/API/SBExecutionContext.h"
+#include "lldb/API/SBExpressionOptions.h"
#include "lldb/API/SBFileSpec.h"
+#include "lldb/API/SBFileSpecList.h"
#include "lldb/API/SBFrame.h"
#include "lldb/API/SBFunction.h"
#include "lldb/API/SBHostOS.h"
#include "lldb/API/SBInstruction.h"
#include "lldb/API/SBInstructionList.h"
+#include "lldb/API/SBLanguageRuntime.h"
+#include "lldb/API/SBLaunchInfo.h"
#include "lldb/API/SBLineEntry.h"
#include "lldb/API/SBListener.h"
#include "lldb/API/SBModule.h"
+#include "lldb/API/SBModuleSpec.h"
+#include "lldb/API/SBPlatform.h"
#include "lldb/API/SBProcess.h"
#include "lldb/API/SBQueue.h"
#include "lldb/API/SBQueueItem.h"
+#include "lldb/API/SBSection.h"
#include "lldb/API/SBSourceManager.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBStringList.h"
#include "lldb/API/SBSymbol.h"
#include "lldb/API/SBSymbolContext.h"
+#include "lldb/API/SBSymbolContextList.h"
#include "lldb/API/SBTarget.h"
#include "lldb/API/SBThread.h"
+#include "lldb/API/SBThreadCollection.h"
+#include "lldb/API/SBThreadPlan.h"
#include "lldb/API/SBType.h"
+#include "lldb/API/SBTypeCategory.h"
+#include "lldb/API/SBTypeEnumMember.h"
+#include "lldb/API/SBTypeFilter.h"
+#include "lldb/API/SBTypeFormat.h"
+#include "lldb/API/SBTypeNameSpecifier.h"
+#include "lldb/API/SBTypeSummary.h"
+#include "lldb/API/SBTypeSynthetic.h"
+#include "lldb/API/SBUnixSignals.h"
#include "lldb/API/SBValue.h"
#include "lldb/API/SBValueList.h"
#include "lldb/API/SBVariablesOptions.h"
+#include "lldb/API/SBWatchpoint.h"
#endif // LLDB_LLDB_h_
diff --git a/include/lldb/API/SBAttachInfo.h b/include/lldb/API/SBAttachInfo.h
index 712150e128be..a246d9919cfa 100644
--- a/include/lldb/API/SBAttachInfo.h
+++ b/include/lldb/API/SBAttachInfo.h
@@ -23,8 +23,47 @@ 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
+ /// A full or partial name for the process to attach to.
+ ///
+ /// @param[in] wait_for
+ /// If \b false, attach to an existing process whose name matches.
+ /// If \b true, then wait for the next process whose name matches.
+ //------------------------------------------------------------------
SBAttachInfo (const char *path, bool wait_for);
+ //------------------------------------------------------------------
+ /// Attach to a process by name.
+ ///
+ /// Future calls to SBTarget::Attach(...) will be synchronous or
+ /// asynchronous depending on the \a async argument.
+ ///
+ /// @param[in] path
+ /// A full or partial name for the process to attach to.
+ ///
+ /// @param[in] wait_for
+ /// If \b false, attach to an existing process whose name matches.
+ /// If \b true, then wait for the next process whose name matches.
+ ///
+ /// @param[in] async
+ /// If \b false, then the SBTarget::Attach(...) call will be a
+ /// synchronous call with no way to cancel the attach in
+ /// progress.
+ /// If \b true, then the SBTarget::Attach(...) function will
+ /// return immediately and clients are expected to wait for a
+ /// process eStateStopped event if a suitable process is
+ /// eventually found. If the client wants to cancel the event,
+ /// SBProcess::Stop() can be called and an eStateExited process
+ /// event will be delivered.
+ //------------------------------------------------------------------
+ SBAttachInfo (const char *path, bool wait_for, bool async);
+
SBAttachInfo (const SBAttachInfo &rhs);
~SBAttachInfo();
@@ -47,9 +86,45 @@ 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] wait_for
+ /// If \b false, attach to an existing process whose name matches.
+ /// If \b true, then wait for the next process whose name matches.
+ //------------------------------------------------------------------
void
SetWaitForLaunch (bool b);
+ //------------------------------------------------------------------
+ /// Set attach by process name settings.
+ ///
+ /// Designed to be used after a call to SBAttachInfo::SetExecutable().
+ /// Future calls to SBTarget::Attach(...) will be synchronous or
+ /// asynchronous depending on the \a async argument.
+ ///
+ /// @param[in] wait_for
+ /// If \b false, attach to an existing process whose name matches.
+ /// If \b true, then wait for the next process whose name matches.
+ ///
+ /// @param[in] async
+ /// If \b false, then the SBTarget::Attach(...) call will be a
+ /// synchronous call with no way to cancel the attach in
+ /// progress.
+ /// If \b true, then the SBTarget::Attach(...) function will
+ /// return immediately and clients are expected to wait for a
+ /// process eStateStopped event if a suitable process is
+ /// eventually found. If the client wants to cancel the event,
+ /// SBProcess::Stop() can be called and an eStateExited process
+ /// event will be delivered.
+ //------------------------------------------------------------------
+ void
+ SetWaitForLaunch (bool b, bool async);
+
bool
GetIgnoreExisting ();
diff --git a/include/lldb/API/SBCommandInterpreter.h b/include/lldb/API/SBCommandInterpreter.h
index 235a2f3ea603..a8e9bf7ed769 100644
--- a/include/lldb/API/SBCommandInterpreter.h
+++ b/include/lldb/API/SBCommandInterpreter.h
@@ -10,6 +10,12 @@
#ifndef LLDB_SBCommandInterpreter_h_
#define LLDB_SBCommandInterpreter_h_
+// C Includes
+// C++ Includes
+#include <memory>
+
+// Other libraries and framework includes
+// Project includes
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBDebugger.h"
@@ -59,6 +65,7 @@ public:
void
SetAddToHistory (bool);
+
private:
lldb_private::CommandInterpreterRunOptions *
get () const;
@@ -84,11 +91,11 @@ public:
SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs);
+ ~SBCommandInterpreter ();
+
const lldb::SBCommandInterpreter &
operator = (const lldb::SBCommandInterpreter &rhs);
- ~SBCommandInterpreter ();
-
static const char *
GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type);
@@ -187,7 +194,7 @@ public:
lldb::CommandOverrideCallback callback,
void *baton);
- SBCommandInterpreter (lldb_private::CommandInterpreter *interpreter_ptr = NULL); // Access using SBDebugger::GetCommandInterpreter();
+ SBCommandInterpreter(lldb_private::CommandInterpreter *interpreter_ptr = nullptr); // Access using SBDebugger::GetCommandInterpreter();
//----------------------------------------------------------------------
/// Return true if the command interpreter is the active IO handler.
@@ -213,7 +220,7 @@ public:
///
/// @return
/// The string that should be written into the file handle that is
- /// feeding the input stream for the debugger, or NULL if there is
+ /// feeding the input stream for the debugger, or nullptr if there is
/// no string for this control key.
//----------------------------------------------------------------------
const char *
@@ -233,7 +240,6 @@ public:
ResolveCommand(const char *command_line, SBCommandReturnObject &result);
protected:
-
lldb_private::CommandInterpreter &
ref ();
@@ -242,6 +248,7 @@ protected:
void
reset (lldb_private::CommandInterpreter *);
+
private:
friend class SBDebugger;
@@ -254,6 +261,9 @@ private:
class SBCommandPluginInterface
{
public:
+ virtual
+ ~SBCommandPluginInterface() = default;
+
virtual bool
DoExecute (lldb::SBDebugger /*debugger*/,
char** /*command*/,
@@ -261,16 +271,11 @@ public:
{
return false;
}
-
- virtual
- ~SBCommandPluginInterface ()
- {}
};
class SBCommand
{
public:
-
SBCommand ();
bool
@@ -298,13 +303,12 @@ public:
SetFlags (uint32_t flags);
lldb::SBCommand
- AddMultiwordCommand (const char* name, const char* help = NULL);
+ AddMultiwordCommand(const char* name, const char* help = nullptr);
lldb::SBCommand
- AddCommand (const char* name, lldb::SBCommandPluginInterface* impl, const char* help = NULL);
+ AddCommand(const char* name, lldb::SBCommandPluginInterface* impl, const char* help = nullptr);
private:
-
friend class SBDebugger;
friend class SBCommandInterpreter;
diff --git a/include/lldb/API/SBCommandReturnObject.h b/include/lldb/API/SBCommandReturnObject.h
index c51d6bc8d2d5..b45eb9c14c04 100644
--- a/include/lldb/API/SBCommandReturnObject.h
+++ b/include/lldb/API/SBCommandReturnObject.h
@@ -10,8 +10,14 @@
#ifndef LLDB_SBCommandReturnObject_h_
#define LLDB_SBCommandReturnObject_h_
+// C Includes
#include <stdio.h>
+// C++ Includes
+#include <memory>
+
+// Other libraries and framework includes
+// Project includes
#include "lldb/API/SBDefines.h"
namespace lldb {
@@ -19,22 +25,20 @@ namespace lldb {
class LLDB_API SBCommandReturnObject
{
public:
-
SBCommandReturnObject ();
SBCommandReturnObject (const lldb::SBCommandReturnObject &rhs);
+ ~SBCommandReturnObject ();
+
const lldb::SBCommandReturnObject &
operator = (const lldb::SBCommandReturnObject &rhs);
-
SBCommandReturnObject (lldb_private::CommandReturnObject *ptr);
lldb_private::CommandReturnObject *
Release ();
- ~SBCommandReturnObject ();
-
bool
IsValid() const;
@@ -99,8 +103,8 @@ public:
GetError (bool only_if_no_immediate);
void
- SetError (lldb::SBError &error,
- const char *fallback_error_cstr = NULL);
+ SetError(lldb::SBError &error,
+ const char *fallback_error_cstr = nullptr);
void
SetError (const char* error_cstr);
@@ -124,10 +128,10 @@ protected:
void
SetLLDBObjectPtr (lldb_private::CommandReturnObject *ptr);
- private:
+private:
std::unique_ptr<lldb_private::CommandReturnObject> m_opaque_ap;
};
} // namespace lldb
-#endif // LLDB_SBCommandReturnObject_h_
+#endif // LLDB_SBCommandReturnObject_h_
diff --git a/include/lldb/API/SBDebugger.h b/include/lldb/API/SBDebugger.h
index 4f2c1d7f8756..7588cfc9ec42 100644
--- a/include/lldb/API/SBDebugger.h
+++ b/include/lldb/API/SBDebugger.h
@@ -16,13 +16,13 @@
#include "lldb/API/SBPlatform.h"
namespace lldb {
-
class LLDB_API SBInputReader
{
public:
- SBInputReader();
- ~SBInputReader();
+ SBInputReader() = default;
+ ~SBInputReader() = default;
+
SBError Initialize(lldb::SBDebugger&, unsigned long (*)(void*, lldb::SBInputReader*, lldb::InputReaderAction, char const*, unsigned long), void*, lldb::InputReaderGranularity, char const*, char const*, bool);
void SetIsDone(bool);
bool IsActive() const;
@@ -31,6 +31,16 @@ public:
class LLDB_API SBDebugger
{
public:
+ SBDebugger();
+
+ SBDebugger(const lldb::SBDebugger &rhs);
+
+ SBDebugger(const lldb::DebuggerSP &debugger_sp);
+
+ ~SBDebugger();
+
+ lldb::SBDebugger &
+ operator = (const lldb::SBDebugger &rhs);
static void
Initialize();
@@ -54,17 +64,6 @@ public:
static void
MemoryPressureDetected ();
- SBDebugger();
-
- SBDebugger(const lldb::SBDebugger &rhs);
-
- SBDebugger(const lldb::DebuggerSP &debugger_sp);
-
- lldb::SBDebugger &
- operator = (const lldb::SBDebugger &rhs);
-
- ~SBDebugger();
-
bool
IsValid() const;
@@ -288,6 +287,9 @@ public:
GetCategory (const char* category_name);
SBTypeCategory
+ GetCategory (lldb::LanguageType lang_type);
+
+ SBTypeCategory
CreateCategory (const char* category_name);
bool
@@ -329,8 +331,11 @@ public:
int &num_errors,
bool &quit_requested,
bool &stopped_for_crash);
-private:
+
+ SBError
+ RunREPL (lldb::LanguageType language, const char *repl_options);
+private:
friend class SBCommandInterpreter;
friend class SBInputReader;
friend class SBListener;
@@ -357,7 +362,6 @@ private:
}; // class SBDebugger
-
} // namespace lldb
#endif // LLDB_SBDebugger_h_
diff --git a/include/lldb/API/SBDefines.h b/include/lldb/API/SBDefines.h
index 09bea502dd01..d81bba5a2e23 100644
--- a/include/lldb/API/SBDefines.h
+++ b/include/lldb/API/SBDefines.h
@@ -86,9 +86,7 @@ class LLDB_API SBTypeMemberFunction;
class LLDB_API SBTypeNameSpecifier;
class LLDB_API SBTypeSummary;
class LLDB_API SBTypeSummaryOptions;
-#ifndef LLDB_DISABLE_PYTHON
class LLDB_API SBTypeSynthetic;
-#endif
class LLDB_API SBTypeList;
class LLDB_API SBValue;
class LLDB_API SBValueList;
diff --git a/include/lldb/API/SBFunction.h b/include/lldb/API/SBFunction.h
index 86cfeb49bb58..f76c77c44e3f 100644
--- a/include/lldb/API/SBFunction.h
+++ b/include/lldb/API/SBFunction.h
@@ -53,6 +53,9 @@ public:
lldb::SBAddress
GetEndAddress ();
+ const char *
+ GetArgumentName (uint32_t arg_idx);
+
uint32_t
GetPrologueByteSize ();
@@ -66,6 +69,9 @@ public:
GetLanguage ();
bool
+ GetIsOptimized ();
+
+ bool
operator == (const lldb::SBFunction &rhs) const;
bool
diff --git a/include/lldb/API/SBProcess.h b/include/lldb/API/SBProcess.h
index 71bca4fc697a..1a9cc8022880 100644
--- a/include/lldb/API/SBProcess.h
+++ b/include/lldb/API/SBProcess.h
@@ -294,8 +294,56 @@ public:
uint32_t
GetNumSupportedHardwareWatchpoints (lldb::SBError &error) const;
+ //------------------------------------------------------------------
+ /// Load a shared library into this process.
+ ///
+ /// @param[in] remote_image_spec
+ /// The path for the shared library on the target what you want
+ /// to load.
+ ///
+ /// @param[out] error
+ /// An error object that gets filled in with any errors that
+ /// might occur when trying to load the shared library.
+ ///
+ /// @return
+ /// A token that represents the shared library that can be
+ /// later used to unload the shared library. A value of
+ /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared
+ /// library can't be opened.
+ //------------------------------------------------------------------
uint32_t
- LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error);
+ LoadImage (lldb::SBFileSpec &remote_image_spec, lldb::SBError &error);
+
+ //------------------------------------------------------------------
+ /// Load a shared library into this process.
+ ///
+ /// @param[in] local_image_spec
+ /// The file spec that points to the shared library that you
+ /// want to load if the library is located on the host. The
+ /// library will be copied over to the location specified by
+ /// remote_image_spec or into the current working directory with
+ /// the same filename if the remote_image_spec isn't specified.
+ ///
+ /// @param[in] remote_image_spec
+ /// If local_image_spec is specified then the location where the
+ /// library should be copied over from the host. If
+ /// local_image_spec isn't specified, then the path for the
+ /// shared library on the target what you want to load.
+ ///
+ /// @param[out] error
+ /// An error object that gets filled in with any errors that
+ /// might occur when trying to load the shared library.
+ ///
+ /// @return
+ /// A token that represents the shared library that can be
+ /// later used to unload the shared library. A value of
+ /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared
+ /// library can't be opened.
+ //------------------------------------------------------------------
+ uint32_t
+ LoadImage (const lldb::SBFileSpec &local_image_spec,
+ const lldb::SBFileSpec &remote_image_spec,
+ lldb::SBError &error);
lldb::SBError
UnloadImage (uint32_t image_token);
@@ -341,6 +389,10 @@ public:
bool
IsInstrumentationRuntimePresent(InstrumentationRuntimeType type);
+ // Save the state of the process in a core file (or mini dump on Windows).
+ lldb::SBError
+ SaveCore(const char *file_name);
+
protected:
friend class SBAddress;
friend class SBBreakpoint;
diff --git a/include/lldb/API/SBStream.h b/include/lldb/API/SBStream.h
index 2b25cd2c68f2..e62723c2f37e 100644
--- a/include/lldb/API/SBStream.h
+++ b/include/lldb/API/SBStream.h
@@ -21,7 +21,9 @@ class LLDB_API SBStream
public:
SBStream ();
-
+
+ SBStream (SBStream &&rhs);
+
~SBStream ();
bool
diff --git a/include/lldb/API/SBTarget.h b/include/lldb/API/SBTarget.h
index 2ca0b124ce0a..723c433b521a 100644
--- a/include/lldb/API/SBTarget.h
+++ b/include/lldb/API/SBTarget.h
@@ -10,6 +10,10 @@
#ifndef LLDB_SBTarget_h_
#define LLDB_SBTarget_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBAttachInfo.h"
@@ -50,14 +54,14 @@ public:
SBTarget (const lldb::TargetSP& target_sp);
- const lldb::SBTarget&
- operator = (const lldb::SBTarget& rhs);
-
//------------------------------------------------------------------
// Destructor
//------------------------------------------------------------------
~SBTarget();
+ const lldb::SBTarget&
+ operator = (const lldb::SBTarget& rhs);
+
bool
IsValid() const;
@@ -135,17 +139,17 @@ public:
///
/// @param[in] stdin_path
/// The path to use when re-directing the STDIN of the new
- /// process. If all stdXX_path arguments are NULL, a pseudo
+ /// process. If all stdXX_path arguments are nullptr, a pseudo
/// terminal will be used.
///
/// @param[in] stdout_path
/// The path to use when re-directing the STDOUT of the new
- /// process. If all stdXX_path arguments are NULL, a pseudo
+ /// process. If all stdXX_path arguments are nullptr, a pseudo
/// terminal will be used.
///
/// @param[in] stderr_path
/// The path to use when re-directing the STDERR of the new
- /// process. If all stdXX_path arguments are NULL, a pseudo
+ /// process. If all stdXX_path arguments are nullptr, a pseudo
/// terminal will be used.
///
/// @param[in] working_directory
@@ -175,8 +179,10 @@ public:
uint32_t launch_flags, // See LaunchFlags
bool stop_at_entry,
lldb::SBError& error);
-
-
+
+ SBProcess
+ LoadCore (const char *core_file);
+
//------------------------------------------------------------------
/// Launch a new process with sensible defaults.
///
@@ -212,9 +218,6 @@ public:
Launch (SBLaunchInfo &launch_info, SBError& error);
SBProcess
- LoadCore (const char *core_file);
-
- SBProcess
Attach (SBAttachInfo &attach_info, SBError& error);
//------------------------------------------------------------------
@@ -248,6 +251,7 @@ public:
::pid_t pid, // 32 bit int process ID
lldb::SBError& error); // DEPRECATED
#endif
+
//------------------------------------------------------------------
/// Attach to process with name.
///
@@ -288,7 +292,7 @@ public:
/// The url to connect to, e.g., 'connect://localhost:12345'.
///
/// @param[in] plugin_name
- /// The plugin name to be used; can be NULL.
+ /// The plugin name to be used; can be nullptr.
///
/// @param[out] error
/// An error explaining what went wrong if the connect fails.
@@ -421,7 +425,6 @@ public:
lldb::SBError
SetModuleLoadAddress (lldb::SBModule module,
int64_t sections_offset);
-
//------------------------------------------------------------------
/// Clear the section base load addresses for all sections in a module.
@@ -618,7 +621,7 @@ public:
BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line);
lldb::SBBreakpoint
- BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL);
+ BreakpointCreateByName(const char *symbol_name, const char *module_name = nullptr);
// This version uses name_type_mask = eFunctionNameTypeAuto
lldb::SBBreakpoint
@@ -633,14 +636,29 @@ public:
const SBFileSpecList &comp_unit_list);
lldb::SBBreakpoint
+ BreakpointCreateByName (const char *symbol_name,
+ uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
+ lldb::LanguageType symbol_language,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
+ lldb::SBBreakpoint
+ BreakpointCreateByNames (const char *symbol_name[],
+ uint32_t num_names,
+ uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
+ lldb::SBBreakpoint
BreakpointCreateByNames (const char *symbol_name[],
uint32_t num_names,
uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
+ lldb::LanguageType symbol_language,
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list);
lldb::SBBreakpoint
- BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL);
+ BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = nullptr);
lldb::SBBreakpoint
BreakpointCreateByRegex (const char *symbol_name_regex,
@@ -648,9 +666,15 @@ public:
const SBFileSpecList &comp_unit_list);
lldb::SBBreakpoint
- BreakpointCreateBySourceRegex (const char *source_regex,
- const SBFileSpec &source_file,
- const char *module_name = NULL);
+ BreakpointCreateByRegex (const char *symbol_name_regex,
+ lldb::LanguageType symbol_language,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
+ lldb::SBBreakpoint
+ BreakpointCreateBySourceRegex(const char *source_regex,
+ const SBFileSpec &source_file,
+ const char *module_name = nullptr);
lldb::SBBreakpoint
BreakpointCreateBySourceRegex (const char *source_regex,
@@ -665,6 +689,9 @@ public:
lldb::SBBreakpoint
BreakpointCreateByAddress (addr_t address);
+ lldb::SBBreakpoint
+ BreakpointCreateBySBAddress (SBAddress &address);
+
uint32_t
GetNumBreakpoints () const;
@@ -808,15 +835,10 @@ protected:
void
SetSP (const lldb::TargetSP& target_sp);
-
private:
- //------------------------------------------------------------------
- // For Target only
- //------------------------------------------------------------------
-
lldb::TargetSP m_opaque_sp;
};
} // namespace lldb
-#endif // LLDB_SBTarget_h_
+#endif // LLDB_SBTarget_h_
diff --git a/include/lldb/API/SBType.h b/include/lldb/API/SBType.h
index 01f0c6afc795..ed3c2ff23863 100644
--- a/include/lldb/API/SBType.h
+++ b/include/lldb/API/SBType.h
@@ -85,7 +85,13 @@ public:
const char *
GetName ();
-
+
+ const char *
+ GetDemangledName ();
+
+ const char *
+ GetMangledName ();
+
lldb::SBType
GetType ();
@@ -158,6 +164,9 @@ public:
bool
IsTypedefType ();
+ bool
+ IsAnonymousType ();
+
lldb::SBType
GetPointerType();
@@ -290,7 +299,7 @@ protected:
friend class SBTypeList;
friend class SBValue;
- SBType (const lldb_private::ClangASTType &);
+ SBType (const lldb_private::CompilerType &);
SBType (const lldb::TypeSP &);
SBType (const lldb::TypeImplSP &);
diff --git a/include/lldb/API/SBTypeCategory.h b/include/lldb/API/SBTypeCategory.h
index 30c338b28a46..997b3fc2f98d 100644
--- a/include/lldb/API/SBTypeCategory.h
+++ b/include/lldb/API/SBTypeCategory.h
@@ -36,6 +36,15 @@ namespace lldb {
const char*
GetName();
+ lldb::LanguageType
+ GetLanguageAtIndex (uint32_t idx);
+
+ uint32_t
+ GetNumLanguages ();
+
+ void
+ AddLanguage (lldb::LanguageType language);
+
bool
GetDescription (lldb::SBStream &description,
lldb::DescriptionLevel description_level);
diff --git a/include/lldb/API/SBTypeSummary.h b/include/lldb/API/SBTypeSummary.h
index 9b367ba5f982..f4c666180085 100644
--- a/include/lldb/API/SBTypeSummary.h
+++ b/include/lldb/API/SBTypeSummary.h
@@ -12,8 +12,6 @@
#include "lldb/API/SBDefines.h"
-#ifndef LLDB_DISABLE_PYTHON
-
namespace lldb {
class LLDB_API SBTypeSummaryOptions
{
@@ -71,6 +69,9 @@ namespace lldb {
public:
SBTypeSummary();
+
+ // Native function summary formatter callback
+ typedef bool (*FormatCallback) (SBValue, SBTypeSummaryOptions, SBStream&);
static SBTypeSummary
CreateWithSummaryString (const char* data,
@@ -83,6 +84,11 @@ namespace lldb {
static SBTypeSummary
CreateWithScriptCode (const char* data,
uint32_t options = 0); // see lldb::eTypeOption values
+
+ static SBTypeSummary
+ CreateWithCallback (FormatCallback cb,
+ uint32_t options = 0,
+ const char* description = nullptr);
SBTypeSummary (const lldb::SBTypeSummary &rhs);
@@ -126,6 +132,9 @@ namespace lldb {
operator = (const lldb::SBTypeSummary &rhs);
bool
+ DoesPrintValue (lldb::SBValue value);
+
+ bool
IsEqualTo (lldb::SBTypeSummary &rhs);
bool
@@ -160,6 +169,4 @@ namespace lldb {
} // namespace lldb
-#endif // LLDB_DISABLE_PYTHON
-
#endif // LLDB_SBTypeSummary_h_
diff --git a/include/lldb/API/SBValue.h b/include/lldb/API/SBValue.h
index a070b149f34f..a7e015064f96 100644
--- a/include/lldb/API/SBValue.h
+++ b/include/lldb/API/SBValue.h
@@ -139,10 +139,8 @@ public:
lldb::SBTypeFormat
GetTypeFormat ();
-#ifndef LLDB_DISABLE_PYTHON
lldb::SBTypeSummary
GetTypeSummary ();
-#endif
lldb::SBTypeFilter
GetTypeFilter ();
@@ -206,7 +204,11 @@ public:
/// pointer to a 'Point' type, then the child at index zero will be
/// the 'x' member, and the child at index 1 will be the 'y' member
/// (the child at index zero won't be a 'Point' instance).
- ///
+ ///
+ /// If you actually need an SBValue that represents the type pointed
+ /// to by a SBValue for which GetType().IsPointeeType() returns true,
+ /// regardless of the pointee type, you can do that with SBValue::Dereference.
+ ///
/// Arrays have a preset number of children that can be accessed by
/// index and will returns invalid child values for indexes that are
/// out of bounds unless the \a synthetic_allowed is \b true. In this
@@ -332,6 +334,9 @@ public:
uint32_t
GetNumChildren ();
+ uint32_t
+ GetNumChildren (uint32_t max);
+
void *
GetOpaqueType();
@@ -350,6 +355,7 @@ public:
lldb::SBValue
Dereference ();
+ // Deprecated - please use GetType().IsPointerType() instead.
bool
TypeIsPointerType ();
diff --git a/include/lldb/API/SystemInitializerFull.h b/include/lldb/API/SystemInitializerFull.h
index 6280fe8aef04..9e37611a6598 100644
--- a/include/lldb/API/SystemInitializerFull.h
+++ b/include/lldb/API/SystemInitializerFull.h
@@ -26,15 +26,15 @@ class SystemInitializerFull : public SystemInitializerCommon
{
public:
SystemInitializerFull();
- virtual ~SystemInitializerFull();
+ ~SystemInitializerFull() override;
void Initialize() override;
void Terminate() override;
private:
void InitializeSWIG();
- void TerminateSWIG();
};
-}
-#endif
+} // namespace lldb_private
+
+#endif // LLDB_API_SYSTEM_INITIALIZER_FULL_H
diff --git a/include/lldb/Breakpoint/Breakpoint.h b/include/lldb/Breakpoint/Breakpoint.h
index a70c2787a1ef..7fdf06da3936 100644
--- a/include/lldb/Breakpoint/Breakpoint.h
+++ b/include/lldb/Breakpoint/Breakpoint.h
@@ -12,7 +12,10 @@
// C Includes
// C++ Includes
+#include <memory>
+#include <string>
#include <unordered_set>
+#include <vector>
// Other libraries and framework includes
// Project includes
@@ -81,11 +84,9 @@ class Breakpoint:
public Stoppoint
{
public:
-
static const ConstString &
GetEventIdentifier ();
-
//------------------------------------------------------------------
/// An enum specifying the match style for breakpoint settings. At
/// present only used for function name style breakpoints.
@@ -101,18 +102,16 @@ public:
public EventData
{
public:
+ BreakpointEventData (lldb::BreakpointEventType sub_type,
+ const lldb::BreakpointSP &new_breakpoint_sp);
+
+ ~BreakpointEventData() override;
static const ConstString &
GetFlavorString ();
- virtual const ConstString &
- GetFlavor () const;
-
- BreakpointEventData (lldb::BreakpointEventType sub_type,
- const lldb::BreakpointSP &new_breakpoint_sp);
-
- virtual
- ~BreakpointEventData();
+ const ConstString &
+ GetFlavor() const override;
lldb::BreakpointEventType
GetBreakpointEventType () const;
@@ -126,9 +125,8 @@ public:
return m_locations;
}
-
- virtual void
- Dump (Stream *s) const;
+ void
+ Dump(Stream *s) const override;
static lldb::BreakpointEventType
GetBreakpointEventTypeFromEvent (const lldb::EventSP &event_sp);
@@ -146,7 +144,6 @@ public:
GetEventDataFromEvent (const Event *event_sp);
private:
-
lldb::BreakpointEventType m_breakpoint_event;
lldb::BreakpointSP m_new_breakpoint_sp;
BreakpointLocationCollection m_locations;
@@ -154,11 +151,10 @@ public:
DISALLOW_COPY_AND_ASSIGN (BreakpointEventData);
};
-
class BreakpointPrecondition
{
public:
- virtual ~BreakpointPrecondition() {}
+ virtual ~BreakpointPrecondition() = default;
virtual bool
EvaluatePrecondition(StoppointCallbackContext &context);
@@ -167,7 +163,7 @@ public:
ConfigurePrecondition(Args &options);
virtual void
- DescribePrecondition(Stream &stream, lldb::DescriptionLevel level);
+ GetDescription(Stream &stream, lldb::DescriptionLevel level);
};
typedef std::shared_ptr<BreakpointPrecondition> BreakpointPreconditionSP;
@@ -179,7 +175,7 @@ public:
/// breakpoints. The varieties of breakpoints are specified instead by
/// providing different resolvers & filters.
//------------------------------------------------------------------
- ~Breakpoint();
+ ~Breakpoint() override;
//------------------------------------------------------------------
// Methods
@@ -197,14 +193,13 @@ public:
/// Standard "Dump" method. At present it does nothing.
//------------------------------------------------------------------
void
- Dump (Stream *s);
+ 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.
@@ -262,7 +257,6 @@ public:
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
@@ -294,8 +288,8 @@ public:
/// Returns a pointer to the new location.
//------------------------------------------------------------------
lldb::BreakpointLocationSP
- AddLocation (const Address &addr,
- bool *new_location = NULL);
+ AddLocation(const Address &addr,
+ bool *new_location = nullptr);
//------------------------------------------------------------------
/// Find a breakpoint location by Address.
@@ -304,7 +298,7 @@ public:
/// The Address specifying the location.
/// @return
/// Returns a shared pointer to the location at \a addr. The pointer
- /// in the shared pointer will be NULL if there is no location at that address.
+ /// in the shared pointer will be nullptr if there is no location at that address.
//------------------------------------------------------------------
lldb::BreakpointLocationSP
FindLocationByAddress (const Address &addr);
@@ -328,7 +322,7 @@ public:
/// The ID specifying the location.
/// @return
/// Returns a shared pointer to the location with ID \a bp_loc_id. The pointer
- /// in the shared pointer will be NULL if there is no location with that ID.
+ /// 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);
@@ -341,7 +335,7 @@ public:
///
/// @return
/// Returns a shared pointer to the location with index \a
- /// index. The shared pointer might contain NULL if \a index is
+ /// index. The shared pointer might contain nullptr if \a index is
/// greater than then number of actual locations.
//------------------------------------------------------------------
lldb::BreakpointLocationSP
@@ -373,7 +367,7 @@ public:
/// If \a enable is \b true, enable the breakpoint, if \b false disable it.
//------------------------------------------------------------------
void
- SetEnabled (bool enable);
+ SetEnabled(bool enable) override;
//------------------------------------------------------------------
/// Check the Enable/Disable state.
@@ -381,7 +375,7 @@ public:
/// \b true if the breakpoint is enabled, \b false if disabled.
//------------------------------------------------------------------
bool
- IsEnabled ();
+ IsEnabled() override;
//------------------------------------------------------------------
/// Set the breakpoint to ignore the next \a count breakpoint hits.
@@ -407,7 +401,6 @@ public:
uint32_t
GetHitCount () const;
-
//------------------------------------------------------------------
/// If \a one_shot is \b true, breakpoint will be deleted on first hit.
//------------------------------------------------------------------
@@ -490,7 +483,7 @@ public:
///
/// @param[in] condition
/// The condition expression to evaluate when the breakpoint is hit.
- /// Pass in NULL to clear the condition.
+ /// Pass in nullptr to clear the condition.
//------------------------------------------------------------------
void SetCondition (const char *condition);
@@ -498,7 +491,7 @@ public:
/// Return a pointer to the text of the condition expression.
///
/// @return
- /// A pointer to the condition expression text, or NULL if no
+ /// A pointer to the condition expression text, or nullptr if no
// condition has been set.
//------------------------------------------------------------------
const char *GetConditionText () const;
@@ -560,7 +553,7 @@ public:
/// Return the "kind" description for a breakpoint.
///
/// @return
- /// The breakpoint kind, or NULL if none is set.
+ /// The breakpoint kind, or nullptr if none is set.
//------------------------------------------------------------------
const char *GetBreakpointKind () const
{
@@ -619,7 +612,6 @@ public:
BreakpointOptions *
GetOptions ();
-
//------------------------------------------------------------------
/// Invoke the callback action when the breakpoint is hit.
///
@@ -713,7 +705,6 @@ protected:
// Protected Methods
//------------------------------------------------------------------
-
//------------------------------------------------------------------
/// Constructors and Destructors
/// Only the Target can make a breakpoint, and it owns the breakpoint lifespans.
@@ -807,4 +798,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_Breakpoint_h_
+#endif // liblldb_Breakpoint_h_
diff --git a/include/lldb/Breakpoint/BreakpointLocation.h b/include/lldb/Breakpoint/BreakpointLocation.h
index c3e620d085c6..58d144cfb668 100644
--- a/include/lldb/Breakpoint/BreakpointLocation.h
+++ b/include/lldb/Breakpoint/BreakpointLocation.h
@@ -11,12 +11,10 @@
#define liblldb_BreakpointLocation_h_
// C Includes
-
// C++ Includes
-#include <list>
+#include <memory>
// Other libraries and framework includes
-
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Breakpoint/StoppointLocation.h"
@@ -49,7 +47,7 @@ class BreakpointLocation :
public StoppointLocation
{
public:
- ~BreakpointLocation ();
+ ~BreakpointLocation() override;
//------------------------------------------------------------------
/// Gets the load address for this breakpoint location
@@ -58,7 +56,7 @@ public:
/// LLDB_INVALID_ADDRESS if not yet set.
//------------------------------------------------------------------
lldb::addr_t
- GetLoadAddress () const;
+ GetLoadAddress() const override;
//------------------------------------------------------------------
/// Gets the Address for this breakpoint location
@@ -74,6 +72,9 @@ public:
//------------------------------------------------------------------
Breakpoint &
GetBreakpoint ();
+
+ Target &
+ GetTarget();
//------------------------------------------------------------------
/// Determines whether we should stop due to a hit at this
@@ -88,7 +89,7 @@ public:
/// \b false otherwise.
//------------------------------------------------------------------
bool
- ShouldStop (StoppointCallbackContext *context);
+ ShouldStop(StoppointCallbackContext *context) override;
//------------------------------------------------------------------
// The next section deals with various breakpoint options.
@@ -169,16 +170,15 @@ public:
/// Return a pointer to the text of the condition expression.
///
/// @return
- /// A pointer to the condition expression text, or NULL if no
+ /// A pointer to the condition expression text, or nullptr if no
// condition has been set.
//------------------------------------------------------------------
const char *
- GetConditionText (size_t *hash = NULL) const;
+ GetConditionText(size_t *hash = nullptr) const;
bool
ConditionSaysStop (ExecutionContext &exe_ctx, Error &error);
-
//------------------------------------------------------------------
/// Set the valid thread to be checked when the breakpoint is hit.
///
@@ -270,7 +270,7 @@ public:
/// Standard "Dump" method. At present it does nothing.
//------------------------------------------------------------------
void
- Dump (Stream *s) const;
+ Dump(Stream *s) const override;
//------------------------------------------------------------------
/// Use this to set location specific breakpoint options.
@@ -299,7 +299,6 @@ public:
bool
ValidForThisThread (Thread *thread);
-
//------------------------------------------------------------------
/// Invoke the callback action when the breakpoint is hit.
///
@@ -418,7 +417,6 @@ private:
void
UndoBumpHitCount();
-
//------------------------------------------------------------------
// Constructors and Destructors
//
@@ -459,9 +457,9 @@ private:
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, NULL if we're using our breakpoint's options.
+ std::unique_ptr<BreakpointOptions> m_options_ap; ///< Breakpoint options pointer, nullptr if we're using our breakpoint's options.
lldb::BreakpointSiteSP m_bp_site_sp; ///< Our breakpoint site (it may be shared by more than one location.)
- lldb::ClangUserExpressionSP m_user_expression_sp; ///< The compiled expression to use in testing our condition.
+ lldb::UserExpressionSP m_user_expression_sp; ///< The compiled expression to use in testing our condition.
Mutex m_condition_mutex; ///< Guards parsing and evaluation of the condition, which could be evaluated by multiple processes.
size_t m_condition_hash; ///< For testing whether the condition source code changed.
@@ -479,4 +477,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_BreakpointLocation_h_
+#endif // liblldb_BreakpointLocation_h_
diff --git a/include/lldb/Breakpoint/BreakpointLocationList.h b/include/lldb/Breakpoint/BreakpointLocationList.h
index f67ef89ad705..81526089b427 100644
--- a/include/lldb/Breakpoint/BreakpointLocationList.h
+++ b/include/lldb/Breakpoint/BreakpointLocationList.h
@@ -12,8 +12,9 @@
// C Includes
// C++ Includes
-#include <vector>
#include <map>
+#include <vector>
+
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
@@ -56,7 +57,7 @@ public:
/// The address to look for.
///
/// @result
- /// A shared pointer to the breakpoint. May contain a NULL
+ /// A shared pointer to the breakpoint. May contain a nullptr
/// pointer if the breakpoint doesn't exist.
//------------------------------------------------------------------
const lldb::BreakpointLocationSP
@@ -70,7 +71,7 @@ public:
/// The breakpoint location ID to seek for.
///
/// @result
- /// A shared pointer to the breakpoint. May contain a NULL
+ /// A shared pointer to the breakpoint. May contain a nullptr
/// pointer if the breakpoint doesn't exist.
//------------------------------------------------------------------
lldb::BreakpointLocationSP
@@ -116,7 +117,7 @@ public:
/// The breakpoint location index to seek for.
///
/// @result
- /// A shared pointer to the breakpoint. May contain a NULL
+ /// A shared pointer to the breakpoint. May contain a nullptr
/// pointer if the breakpoint doesn't exist.
//------------------------------------------------------------------
lldb::BreakpointLocationSP
@@ -130,7 +131,7 @@ public:
/// The breakpoint location index to seek for.
///
/// @result
- /// A shared pointer to the breakpoint. May contain a NULL
+ /// A shared pointer to the breakpoint. May contain a nullptr
/// pointer if the breakpoint doesn't exist.
//------------------------------------------------------------------
const lldb::BreakpointLocationSP
@@ -216,7 +217,6 @@ public:
lldb::DescriptionLevel level);
protected:
-
//------------------------------------------------------------------
/// This is the standard constructor.
///
@@ -246,9 +246,9 @@ protected:
StopRecordingNewLocations();
lldb::BreakpointLocationSP
- AddLocation (const Address &addr,
- bool resolve_indirect_symbols,
- bool *new_location = NULL);
+ AddLocation(const Address &addr,
+ bool resolve_indirect_symbols,
+ bool *new_location = nullptr);
void
SwapLocation (lldb::BreakpointLocationSP to_location_sp, lldb::BreakpointLocationSP from_location_sp);
@@ -273,16 +273,17 @@ protected:
mutable Mutex m_mutex;
lldb::break_id_t m_next_id;
BreakpointLocationCollection *m_new_location_recorder;
+
public:
typedef AdaptedIterable<collection, lldb::BreakpointLocationSP, vector_adapter> BreakpointLocationIterable;
+
BreakpointLocationIterable
BreakpointLocations()
{
return BreakpointLocationIterable(m_locations);
}
-
};
} // namespace lldb_private
-#endif // liblldb_BreakpointLocationList_h_
+#endif // liblldb_BreakpointLocationList_h_
diff --git a/include/lldb/Breakpoint/BreakpointOptions.h b/include/lldb/Breakpoint/BreakpointOptions.h
index bf10fc096d75..e7882147a4da 100644
--- a/include/lldb/Breakpoint/BreakpointOptions.h
+++ b/include/lldb/Breakpoint/BreakpointOptions.h
@@ -12,6 +12,9 @@
// C Includes
// C++ Includes
+#include <memory>
+#include <string>
+
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
@@ -115,7 +118,6 @@ public:
//------------------------------------------------------------------
void SetCallback (BreakpointHitCallback callback, const lldb::BatonSP &baton_sp, bool synchronous = false);
-
//------------------------------------------------------------------
/// Remove the callback from this option set.
//------------------------------------------------------------------
@@ -184,10 +186,10 @@ public:
/// Return a pointer to the text of the condition expression.
///
/// @return
- /// A pointer to the condition expression text, or NULL if no
+ /// A pointer to the condition expression text, or nullptr if no
// condition has been set.
//------------------------------------------------------------------
- const char *GetConditionText (size_t *hash = NULL) const;
+ const char *GetConditionText(size_t *hash = nullptr) const;
//------------------------------------------------------------------
// Enabled/Ignore Count
@@ -257,10 +259,10 @@ public:
}
//------------------------------------------------------------------
- /// Return the current thread spec for this option. This will return NULL if the no thread
+ /// Return the current thread spec for this option. This will return nullptr if the no thread
/// specifications have been set for this Option yet.
/// @return
- /// The thread specification pointer for this option, or NULL if none has
+ /// The thread specification pointer for this option, or nullptr if none has
/// been set yet.
//------------------------------------------------------------------
const ThreadSpec *
@@ -298,7 +300,6 @@ public:
lldb::user_id_t break_id,
lldb::user_id_t break_loc_id);
-
struct CommandData
{
CommandData () :
@@ -308,10 +309,8 @@ public:
{
}
- ~CommandData ()
- {
- }
-
+ ~CommandData() = default;
+
StringList user_source;
std::string script_source;
bool stop_on_error;
@@ -325,16 +324,14 @@ public:
{
}
- virtual
- ~CommandBaton ()
+ ~CommandBaton() override
{
delete ((CommandData *)m_data);
- m_data = NULL;
+ m_data = nullptr;
}
- virtual void
- GetDescription (Stream *s, lldb::DescriptionLevel level) const;
-
+ void
+ GetDescription (Stream *s, lldb::DescriptionLevel level) const override;
};
protected:
@@ -359,4 +356,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_BreakpointOptions_h_
+#endif // liblldb_BreakpointOptions_h_
diff --git a/include/lldb/Breakpoint/BreakpointResolver.h b/include/lldb/Breakpoint/BreakpointResolver.h
index 6ba53ea92f36..198abed841b2 100644
--- a/include/lldb/Breakpoint/BreakpointResolver.h
+++ b/include/lldb/Breakpoint/BreakpointResolver.h
@@ -66,8 +66,7 @@ public:
/// The Destructor is virtual, all significant breakpoint resolvers derive
/// from this class.
//------------------------------------------------------------------
- virtual
- ~BreakpointResolver ();
+ ~BreakpointResolver() override;
//------------------------------------------------------------------
/// This sets the breakpoint for this resolver.
@@ -105,8 +104,8 @@ public:
/// @param[in] s
/// Stream to which the output is copied.
//------------------------------------------------------------------
- virtual void
- GetDescription (Stream *s) = 0;
+ void
+ GetDescription(Stream *s) override = 0;
//------------------------------------------------------------------
/// Standard "Dump" method. At present it does nothing.
@@ -157,4 +156,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_BreakpointResolver_h_
+#endif // liblldb_BreakpointResolver_h_
diff --git a/include/lldb/Breakpoint/BreakpointResolverAddress.h b/include/lldb/Breakpoint/BreakpointResolverAddress.h
index c8f034d7345b..8ec1e39e52ab 100644
--- a/include/lldb/Breakpoint/BreakpointResolverAddress.h
+++ b/include/lldb/Breakpoint/BreakpointResolverAddress.h
@@ -15,6 +15,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointResolver.h"
+#include "lldb/Core/ModuleSpec.h"
namespace lldb_private {
@@ -31,8 +32,11 @@ public:
BreakpointResolverAddress (Breakpoint *bkpt,
const Address &addr);
- virtual
- ~BreakpointResolverAddress ();
+ BreakpointResolverAddress (Breakpoint *bkpt,
+ const Address &addr,
+ const FileSpec &module_spec);
+
+ ~BreakpointResolverAddress() override;
void
ResolveBreakpoint (SearchFilter &filter) override;
@@ -66,12 +70,15 @@ public:
CopyForBreakpoint (Breakpoint &breakpoint) override;
protected:
- Address m_addr;
-
+ Address m_addr; // The address - may be Section Offset or may be just an offset
+ lldb::addr_t m_resolved_addr; // The current value of the resolved load address for this breakpoint,
+ FileSpec m_module_filespec; // If this filespec is Valid, and m_addr is an offset, then it will be converted
+ // to a Section+Offset address in this module, whenever that module gets around to
+ // being loaded.
private:
DISALLOW_COPY_AND_ASSIGN(BreakpointResolverAddress);
};
} // namespace lldb_private
-#endif // liblldb_BreakpointResolverAddress_h_
+#endif // liblldb_BreakpointResolverAddress_h_
diff --git a/include/lldb/Breakpoint/BreakpointResolverFileLine.h b/include/lldb/Breakpoint/BreakpointResolverFileLine.h
index 2403d24515a7..2dde1546f126 100644
--- a/include/lldb/Breakpoint/BreakpointResolverFileLine.h
+++ b/include/lldb/Breakpoint/BreakpointResolverFileLine.h
@@ -35,8 +35,7 @@ public:
bool skip_prologue,
bool exact_match);
- virtual
- ~BreakpointResolverFileLine ();
+ ~BreakpointResolverFileLine() override;
Searcher::CallbackReturn
SearchCallback (SearchFilter &filter,
@@ -76,4 +75,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_BreakpointResolverFileLine_h_
+#endif // liblldb_BreakpointResolverFileLine_h_
diff --git a/include/lldb/Breakpoint/BreakpointResolverFileRegex.h b/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
index 8e18fff16447..a8d7a50b5d93 100644
--- a/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
+++ b/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
@@ -32,8 +32,7 @@ public:
RegularExpression &regex,
bool exact_match);
- virtual
- ~BreakpointResolverFileRegex ();
+ ~BreakpointResolverFileRegex() override;
Searcher::CallbackReturn
SearchCallback (SearchFilter &filter,
@@ -70,4 +69,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_BreakpointResolverFileRegex_h_
+#endif // liblldb_BreakpointResolverFileRegex_h_
diff --git a/include/lldb/Breakpoint/BreakpointResolverName.h b/include/lldb/Breakpoint/BreakpointResolverName.h
index c2a5b180f289..aaae9c1a12cf 100644
--- a/include/lldb/Breakpoint/BreakpointResolverName.h
+++ b/include/lldb/Breakpoint/BreakpointResolverName.h
@@ -14,6 +14,7 @@
// C++ Includes
#include <vector>
#include <string>
+
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointResolver.h"
@@ -34,6 +35,7 @@ public:
BreakpointResolverName (Breakpoint *bkpt,
const char *name,
uint32_t name_type_mask,
+ lldb::LanguageType language,
Breakpoint::MatchType type,
bool skip_prologue);
@@ -42,17 +44,20 @@ public:
const char *names[],
size_t num_names,
uint32_t name_type_mask,
+ lldb::LanguageType language,
bool skip_prologue);
// This one takes a C++ array of names. It is always MatchType = Exact.
BreakpointResolverName (Breakpoint *bkpt,
std::vector<std::string> names,
uint32_t name_type_mask,
+ lldb::LanguageType language,
bool skip_prologue);
// Creates a function breakpoint by regular expression. Takes over control of the lifespan of func_regex.
BreakpointResolverName (Breakpoint *bkpt,
RegularExpression &func_regex,
+ lldb::LanguageType language,
bool skip_prologue);
BreakpointResolverName (Breakpoint *bkpt,
@@ -61,8 +66,7 @@ public:
Breakpoint::MatchType type,
bool skip_prologue);
- virtual
- ~BreakpointResolverName ();
+ ~BreakpointResolverName() override;
Searcher::CallbackReturn
SearchCallback (SearchFilter &filter,
@@ -114,6 +118,7 @@ protected:
ConstString m_class_name;
RegularExpression m_regex;
Breakpoint::MatchType m_match_type;
+ lldb::LanguageType m_language;
bool m_skip_prologue;
void
@@ -122,4 +127,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_BreakpointResolverName_h_
+#endif // liblldb_BreakpointResolverName_h_
diff --git a/include/lldb/Breakpoint/BreakpointSite.h b/include/lldb/Breakpoint/BreakpointSite.h
index d67fc8bb57f1..6cebcab8e2db 100644
--- a/include/lldb/Breakpoint/BreakpointSite.h
+++ b/include/lldb/Breakpoint/BreakpointSite.h
@@ -55,7 +55,7 @@ public:
// display any breakpoint opcodes.
};
- virtual ~BreakpointSite ();
+ ~BreakpointSite() override;
//----------------------------------------------------------------------
// This section manages the breakpoint traps
@@ -139,8 +139,8 @@ public:
/// @return
/// \b true if we should stop, \b false otherwise.
//------------------------------------------------------------------
- virtual bool
- ShouldStop (StoppointCallbackContext *context);
+ bool
+ ShouldStop(StoppointCallbackContext *context) override;
//------------------------------------------------------------------
/// Standard Dump method
@@ -149,7 +149,7 @@ public:
/// The stream to dump this output.
//------------------------------------------------------------------
void
- Dump (Stream *s) const;
+ Dump(Stream *s) const override;
//------------------------------------------------------------------
/// The "Owners" are the breakpoint locations that share this
@@ -187,6 +187,20 @@ public:
GetOwnerAtIndex (size_t idx);
//------------------------------------------------------------------
+ /// This method copies the breakpoint site's owners into a new collection.
+ /// It does this while the owners mutex is locked.
+ ///
+ /// @param[out] out_collection
+ /// The BreakpointLocationCollection into which to put the owners
+ /// of this breakpoint site.
+ ///
+ /// @return
+ /// The number of elements copied into out_collection.
+ //------------------------------------------------------------------
+ size_t
+ CopyOwnersList (BreakpointLocationCollection &out_collection);
+
+ //------------------------------------------------------------------
/// Check whether the owners of this breakpoint site have any
/// thread specifiers, and if yes, is \a thread contained in any
/// of these specifiers.
@@ -201,7 +215,6 @@ public:
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.
@@ -301,4 +314,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_BreakpointSite_h_
+#endif // liblldb_BreakpointSite_h_
diff --git a/include/lldb/Breakpoint/Watchpoint.h b/include/lldb/Breakpoint/Watchpoint.h
index 926e0b506f31..34df24a92c06 100644
--- a/include/lldb/Breakpoint/Watchpoint.h
+++ b/include/lldb/Breakpoint/Watchpoint.h
@@ -11,19 +11,17 @@
#define liblldb_Watchpoint_h_
// C Includes
-
// C++ Includes
-#include <list>
+#include <memory>
#include <string>
// Other libraries and framework includes
-
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Breakpoint/WatchpointOptions.h"
#include "lldb/Breakpoint/StoppointLocation.h"
#include "lldb/Core/UserID.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/Target.h"
namespace lldb_private {
@@ -33,23 +31,20 @@ class Watchpoint :
public StoppointLocation
{
public:
-
class WatchpointEventData :
public EventData
{
public:
+ WatchpointEventData (lldb::WatchpointEventType sub_type,
+ const lldb::WatchpointSP &new_watchpoint_sp);
+
+ ~WatchpointEventData() override;
static const ConstString &
GetFlavorString ();
- virtual const ConstString &
- GetFlavor () const;
-
- WatchpointEventData (lldb::WatchpointEventType sub_type,
- const lldb::WatchpointSP &new_watchpoint_sp);
-
- virtual
- ~WatchpointEventData();
+ const ConstString &
+ GetFlavor() const override;
lldb::WatchpointEventType
GetWatchpointEventType () const;
@@ -57,8 +52,8 @@ public:
lldb::WatchpointSP &
GetWatchpoint ();
- virtual void
- Dump (Stream *s) const;
+ void
+ Dump(Stream *s) const override;
static lldb::WatchpointEventType
GetWatchpointEventTypeFromEvent (const lldb::EventSP &event_sp);
@@ -70,15 +65,15 @@ public:
GetEventDataFromEvent (const Event *event_sp);
private:
-
lldb::WatchpointEventType m_watchpoint_event;
lldb::WatchpointSP m_new_watchpoint_sp;
DISALLOW_COPY_AND_ASSIGN (WatchpointEventData);
};
- Watchpoint (Target& target, lldb::addr_t addr, uint32_t size, const ClangASTType *type, bool hardware = true);
- ~Watchpoint ();
+ Watchpoint (Target& target, lldb::addr_t addr, uint32_t size, const CompilerType *type, bool hardware = true);
+
+ ~Watchpoint() override;
void
IncrementFalseAlarmsAndReviseHitCount();
@@ -89,11 +84,11 @@ public:
void
SetEnabled (bool enabled, bool notify = true);
- virtual bool
- IsHardware () const;
+ bool
+ IsHardware() const override;
- virtual bool
- ShouldStop (StoppointCallbackContext *context);
+ bool
+ ShouldStop(StoppointCallbackContext *context) override;
bool WatchpointRead () const;
bool WatchpointWrite () const;
@@ -110,8 +105,8 @@ public:
bool CaptureWatchedValue (const ExecutionContext &exe_ctx);
void GetDescription (Stream *s, lldb::DescriptionLevel level);
- void Dump (Stream *s) const;
- void DumpSnapshots (Stream *s, const char * prefix = NULL) const;
+ void Dump (Stream *s) const override;
+ void DumpSnapshots(Stream *s, const char *prefix = nullptr) const;
void DumpWithLevel (Stream *s, lldb::DescriptionLevel description_level) const;
Target &GetTarget() { return m_target; }
const Error &GetError() { return m_error; }
@@ -173,7 +168,7 @@ public:
///
/// @param[in] condition
/// The condition expression to evaluate when the watchpoint is hit.
- /// Pass in NULL to clear the condition.
+ /// Pass in nullptr to clear the condition.
//------------------------------------------------------------------
void SetCondition (const char *condition);
@@ -181,7 +176,7 @@ public:
/// Return a pointer to the text of the condition expression.
///
/// @return
- /// A pointer to the condition expression text, or NULL if no
+ /// A pointer to the condition expression text, or nullptr if no
// condition has been set.
//------------------------------------------------------------------
const char *GetConditionText () const;
@@ -195,13 +190,12 @@ public:
bool
IsDisabledDuringEphemeralMode();
- const ClangASTType &
- GetClangASTType()
+ const CompilerType &
+ GetCompilerType()
{
return m_type;
}
-
private:
friend class Target;
friend class WatchpointList;
@@ -240,13 +234,13 @@ private:
std::string m_watch_spec_str; // Spec for the watchpoint.
lldb::ValueObjectSP m_old_value_sp;
lldb::ValueObjectSP m_new_value_sp;
- ClangASTType m_type;
+ CompilerType m_type;
Error m_error; // An error object describing errors associated with this watchpoint.
WatchpointOptions m_options; // Settable watchpoint options, which is a delegate to handle
// the callback machinery.
bool m_being_created;
- std::unique_ptr<ClangUserExpression> m_condition_ap; // The condition to test.
+ std::unique_ptr<UserExpression> m_condition_ap; // The condition to test.
void SetID(lldb::watch_id_t id) { m_loc_id = id; }
@@ -261,4 +255,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_Watchpoint_h_
+#endif // liblldb_Watchpoint_h_
diff --git a/include/lldb/Breakpoint/WatchpointOptions.h b/include/lldb/Breakpoint/WatchpointOptions.h
index 64c65f92b44f..eb08bb32e6ce 100644
--- a/include/lldb/Breakpoint/WatchpointOptions.h
+++ b/include/lldb/Breakpoint/WatchpointOptions.h
@@ -12,6 +12,9 @@
// C Includes
// C++ Includes
+#include <memory>
+#include <string>
+
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
@@ -99,7 +102,6 @@ public:
//------------------------------------------------------------------
void SetCallback (WatchpointHitCallback callback, const lldb::BatonSP &baton_sp, bool synchronous = false);
-
//------------------------------------------------------------------
/// Remove the callback from this option set.
//------------------------------------------------------------------
@@ -150,10 +152,10 @@ public:
const Baton *GetBaton () const;
//------------------------------------------------------------------
- /// Return the current thread spec for this option. This will return NULL if the no thread
+ /// Return the current thread spec for this option. This will return nullptr if the no thread
/// specifications have been set for this Option yet.
/// @return
- /// The thread specification pointer for this option, or NULL if none has
+ /// The thread specification pointer for this option, or nullptr if none has
/// been set yet.
//------------------------------------------------------------------
const ThreadSpec *
@@ -196,7 +198,6 @@ public:
StoppointCallbackContext *context,
lldb::user_id_t watch_id);
-
struct CommandData
{
CommandData () :
@@ -206,10 +207,8 @@ public:
{
}
- ~CommandData ()
- {
- }
-
+ ~CommandData() = default;
+
StringList user_source;
std::string script_source;
bool stop_on_error;
@@ -223,16 +222,14 @@ public:
{
}
- virtual
- ~CommandBaton ()
+ ~CommandBaton() override
{
delete ((CommandData *)m_data);
- m_data = NULL;
+ m_data = nullptr;
}
- virtual void
- GetDescription (Stream *s, lldb::DescriptionLevel level) const;
-
+ void
+ GetDescription(Stream *s, lldb::DescriptionLevel level) const override;
};
protected:
@@ -252,4 +249,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_WatchpointOptions_h_
+#endif // liblldb_WatchpointOptions_h_
diff --git a/include/lldb/Core/Address.h b/include/lldb/Core/Address.h
index cfa16c30bedb..0afe55b12be3 100644
--- a/include/lldb/Core/Address.h
+++ b/include/lldb/Core/Address.h
@@ -13,6 +13,7 @@
// C Includes
// C++ Includes
#include <atomic>
+
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
@@ -108,7 +109,6 @@ public:
{
}
-
//------------------------------------------------------------------
/// Copy constructor
///
@@ -176,6 +176,7 @@ public:
const Address&
operator= (const Address& rhs);
#endif
+
//------------------------------------------------------------------
/// Clear the object's state.
///
@@ -216,7 +217,7 @@ public:
class ModulePointerAndOffsetLessThanFunctionObject
{
public:
- ModulePointerAndOffsetLessThanFunctionObject () {}
+ ModulePointerAndOffsetLessThanFunctionObject() = default;
bool
operator() (const Address& a, const Address& b) const
@@ -326,7 +327,8 @@ public:
/// not loaded.
//------------------------------------------------------------------
lldb::addr_t
- GetOpcodeLoadAddress (Target *target) const;
+ GetOpcodeLoadAddress (Target *target,
+ lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const;
//------------------------------------------------------------------
/// Get the section relative offset value.
@@ -354,7 +356,7 @@ public:
bool
IsSectionOffset() const
{
- return IsValid() && (GetSection().get() != NULL);
+ return IsValid() && (GetSection().get() != nullptr);
}
//------------------------------------------------------------------
@@ -374,7 +376,6 @@ public:
return m_offset != LLDB_INVALID_ADDRESS;
}
-
//------------------------------------------------------------------
/// Get the memory cost of this object.
///
@@ -425,7 +426,9 @@ public:
SetLoadAddress (lldb::addr_t load_addr, Target *target);
bool
- SetOpcodeLoadAddress (lldb::addr_t load_addr, Target *target);
+ SetOpcodeLoadAddress (lldb::addr_t load_addr,
+ Target *target,
+ lldb::AddressClass addr_class = lldb::eAddressClassInvalid);
bool
SetCallableLoadAddress (lldb::addr_t load_addr, Target *target);
@@ -505,6 +508,7 @@ public:
{
m_section_wp.reset();
}
+
//------------------------------------------------------------------
/// Reconstruct a symbol context from an address.
///
@@ -564,10 +568,8 @@ protected:
//------------------------------------------------------------------
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
@@ -584,12 +586,9 @@ protected:
//----------------------------------------------------------------------
bool operator< (const Address& lhs, const Address& rhs);
bool operator> (const Address& lhs, const Address& rhs);
-
-
-
bool operator== (const Address& lhs, const Address& rhs);
bool operator!= (const Address& lhs, const Address& rhs);
} // namespace lldb_private
-#endif // liblldb_Address_h_
+#endif // liblldb_Address_h_
diff --git a/include/lldb/Core/AddressRange.h b/include/lldb/Core/AddressRange.h
index 9d781f3e85ae..31e3286cb110 100644
--- a/include/lldb/Core/AddressRange.h
+++ b/include/lldb/Core/AddressRange.h
@@ -10,6 +10,10 @@
#ifndef liblldb_AddressRange_h_
#define liblldb_AddressRange_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Core/Address.h"
namespace lldb_private {
@@ -62,7 +66,7 @@ public:
/// @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 = NULL);
+ 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.
@@ -281,4 +285,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_AddressRange_h_
+#endif // liblldb_AddressRange_h_
diff --git a/include/lldb/Core/AddressResolver.h b/include/lldb/Core/AddressResolver.h
index e5fe276e3fb1..711cc57c14a4 100644
--- a/include/lldb/Core/AddressResolver.h
+++ b/include/lldb/Core/AddressResolver.h
@@ -54,8 +54,7 @@ public:
AddressResolver ();
- virtual
- ~AddressResolver ();
+ ~AddressResolver () override;
virtual void
ResolveAddress (SearchFilter &filter);
@@ -64,8 +63,8 @@ public:
ResolveAddressInModules (SearchFilter &filter,
ModuleList &modules);
- virtual void
- GetDescription (Stream *s) = 0;
+ void
+ GetDescription (Stream *s) override = 0;
std::vector<AddressRange> &
GetAddressRanges ();
@@ -86,4 +85,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_AddressResolver_h_
+#endif // liblldb_AddressResolver_h_
diff --git a/include/lldb/Core/AddressResolverFileLine.h b/include/lldb/Core/AddressResolverFileLine.h
index ddeb0e0301d2..5b47379ed18e 100644
--- a/include/lldb/Core/AddressResolverFileLine.h
+++ b/include/lldb/Core/AddressResolverFileLine.h
@@ -30,20 +30,19 @@ public:
uint32_t line_no,
bool check_inlines);
- virtual
- ~AddressResolverFileLine ();
+ ~AddressResolverFileLine () override;
- virtual Searcher::CallbackReturn
+ Searcher::CallbackReturn
SearchCallback (SearchFilter &filter,
SymbolContext &context,
Address *addr,
- bool containing);
+ bool containing) override;
- virtual Searcher::Depth
- GetDepth ();
+ Searcher::Depth
+ GetDepth () override;
- virtual void
- GetDescription (Stream *s);
+ void
+ GetDescription (Stream *s) override;
protected:
FileSpec m_file_spec; // This is the file spec we are looking for.
@@ -56,4 +55,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_AddressResolverFileLine_h_
+#endif // liblldb_AddressResolverFileLine_h_
diff --git a/include/lldb/Core/AddressResolverName.h b/include/lldb/Core/AddressResolverName.h
index afde675a89bb..cf792f5054e6 100644
--- a/include/lldb/Core/AddressResolverName.h
+++ b/include/lldb/Core/AddressResolverName.h
@@ -38,20 +38,19 @@ public:
const char *method,
AddressResolver::MatchType type);
- virtual
- ~AddressResolverName ();
+ ~AddressResolverName () override;
- virtual Searcher::CallbackReturn
+ Searcher::CallbackReturn
SearchCallback (SearchFilter &filter,
SymbolContext &context,
Address *addr,
- bool containing);
+ bool containing) override;
- virtual Searcher::Depth
- GetDepth ();
+ Searcher::Depth
+ GetDepth () override;
- virtual void
- GetDescription (Stream *s);
+ void
+ GetDescription (Stream *s) override;
protected:
ConstString m_func_name;
@@ -65,4 +64,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_AddressResolverName_h_
+#endif // liblldb_AddressResolverName_h_
diff --git a/include/lldb/Core/ArchSpec.h b/include/lldb/Core/ArchSpec.h
index 0b818a0c7123..13ff436cf08f 100644
--- a/include/lldb/Core/ArchSpec.h
+++ b/include/lldb/Core/ArchSpec.h
@@ -65,7 +65,11 @@ public:
eMIPSAse_mips16 = 0x00000400, // MIPS16 ASE
eMIPSAse_micromips = 0x00000800, // MICROMIPS ASE
eMIPSAse_xpa = 0x00001000, // XPA ASE
- eMIPSAse_mask = 0x00001fff
+ eMIPSAse_mask = 0x00001fff,
+ eMIPSABI_O32 = 0x00002000,
+ eMIPSABI_N32 = 0x00004000,
+ eMIPSABI_N64 = 0x00008000,
+ eMIPSABI_mask = 0x000ff000
};
enum Core
@@ -208,7 +212,11 @@ public:
kCore_mips64_last = eCore_mips64r6,
kCore_mips64el_first = eCore_mips64el,
- kCore_mips64el_last = eCore_mips64r6el
+ kCore_mips64el_last = eCore_mips64r6el,
+
+ kCore_mips_first = eCore_mips32,
+ kCore_mips_last = eCore_mips64r6el
+
};
typedef void (* StopInfoOverrideCallbackType)(lldb_private::Thread &thread);
@@ -337,10 +345,28 @@ public:
}
bool
+ TripleVendorIsUnspecifiedUnknown() const
+ {
+ return m_triple.getVendor() == llvm::Triple::UnknownVendor && m_triple.getVendorName().empty();
+ }
+
+ bool
TripleOSWasSpecified() const
{
return !m_triple.getOSName().empty();
}
+
+ bool
+ TripleEnvironmentWasSpecified () const
+ {
+ return !m_triple.getEnvironmentName().empty();
+ }
+
+ bool
+ TripleOSIsUnspecifiedUnknown() const
+ {
+ return m_triple.getOS() == llvm::Triple::UnknownOS && m_triple.getOSName().empty();
+ }
//------------------------------------------------------------------
/// Merges fields from another ArchSpec into this ArchSpec.
@@ -480,6 +506,9 @@ public:
return m_triple;
}
+ void
+ DumpTriple(Stream &s) const;
+
//------------------------------------------------------------------
/// Architecture tripple setter.
///
@@ -564,7 +593,18 @@ public:
//------------------------------------------------------------------
StopInfoOverrideCallbackType
GetStopInfoOverrideCallback () const;
+
+ bool
+ IsFullySpecifiedTriple () const;
+ void
+ PiecewiseTripleCompare (const ArchSpec &other,
+ bool &arch_different,
+ bool &vendor_different,
+ bool &os_different,
+ bool &os_version_different,
+ bool &env_different);
+
uint32_t
GetFlags () const
{
diff --git a/include/lldb/Core/Broadcaster.h b/include/lldb/Core/Broadcaster.h
index 6d54b1b43133..8e59a41805ec 100644
--- a/include/lldb/Core/Broadcaster.h
+++ b/include/lldb/Core/Broadcaster.h
@@ -42,7 +42,7 @@ public:
BroadcastEventSpec (const BroadcastEventSpec &rhs);
- ~BroadcastEventSpec() {}
+ ~BroadcastEventSpec() = default;
const ConstString &GetBroadcasterClass() const
{
@@ -89,7 +89,7 @@ public:
BroadcasterManager ();
- ~BroadcasterManager () {}
+ ~BroadcasterManager() = default;
uint32_t
RegisterListenerForEvents (Listener &listener, BroadcastEventSpec event_spec);
@@ -128,7 +128,7 @@ private:
{
}
- ~BroadcasterClassMatches () {}
+ ~BroadcasterClassMatches() = default;
bool operator() (const event_listener_key input) const
{
@@ -147,7 +147,7 @@ private:
{
}
- ~BroadcastEventSpecMatches () {}
+ ~BroadcastEventSpecMatches() = default;
bool operator() (const event_listener_key input) const
{
@@ -168,7 +168,7 @@ private:
{
}
- ~ListenerMatchesAndSharedBits () {}
+ ~ListenerMatchesAndSharedBits() = default;
bool operator() (const event_listener_key input) const
{
@@ -190,7 +190,7 @@ private:
{
}
- ~ListenerMatches() {}
+ ~ListenerMatches() = default;
bool operator () (const event_listener_key input) const
{
@@ -204,7 +204,6 @@ private:
const Listener *m_listener;
};
-
};
//----------------------------------------------------------------------
@@ -286,10 +285,10 @@ public:
BroadcastEventIfUnique (lldb::EventSP &event_sp);
void
- BroadcastEvent (uint32_t event_type, EventData *event_data = NULL);
+ BroadcastEvent(uint32_t event_type, EventData *event_data = nullptr);
void
- BroadcastEventIfUnique (uint32_t event_type, EventData *event_data = NULL);
+ BroadcastEventIfUnique(uint32_t event_type, EventData *event_data = nullptr);
void
Clear();
@@ -332,7 +331,6 @@ public:
const ConstString &
GetBroadcasterName ();
-
//------------------------------------------------------------------
/// Get the event name(s) for one or more event bits.
///
@@ -364,10 +362,10 @@ public:
const char *
GetEventName (uint32_t event_mask) const
{
- event_names_map::const_iterator pos = m_event_names.find (event_mask);
+ const auto pos = m_event_names.find (event_mask);
if (pos != m_event_names.end())
return pos->second.c_str();
- return NULL;
+ return nullptr;
}
bool
@@ -437,8 +435,6 @@ public:
BroadcasterManager *GetManager();
protected:
-
-
void
PrivateBroadcastEvent (lldb::EventSP &event_sp, bool unique);
diff --git a/include/lldb/Core/ClangForward.h b/include/lldb/Core/ClangForward.h
index 6c627c2ad3b7..80abc15f671c 100644
--- a/include/lldb/Core/ClangForward.h
+++ b/include/lldb/Core/ClangForward.h
@@ -132,6 +132,8 @@ namespace clang
namespace llvm
{
+ class APInt;
+ class APSInt;
class LLVMContext;
class ExecutionEngine;
}
diff --git a/include/lldb/Core/Communication.h b/include/lldb/Core/Communication.h
index 7924ed293d3c..d29aaca9c2ea 100644
--- a/include/lldb/Core/Communication.h
+++ b/include/lldb/Core/Communication.h
@@ -100,7 +100,6 @@ 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.
@@ -118,8 +117,7 @@ public:
///
/// The destructor is virtual since this class gets subclassed.
//------------------------------------------------------------------
- virtual
- ~Communication();
+ ~Communication() override;
void
Clear ();
@@ -157,7 +155,7 @@ public:
/// @see bool Connection::Disconnect ();
//------------------------------------------------------------------
lldb::ConnectionStatus
- Disconnect (Error *error_ptr = NULL);
+ Disconnect(Error *error_ptr = nullptr);
//------------------------------------------------------------------
/// Check if the connection is valid.
@@ -177,6 +175,7 @@ public:
{
return m_connection_sp.get();
}
+
//------------------------------------------------------------------
/// Read bytes from the current connection.
///
@@ -278,7 +277,7 @@ public:
/// @see void Communication::AppendBytesToCache (const uint8_t * bytes, size_t len, bool broadcast);
//------------------------------------------------------------------
virtual bool
- StartReadThread (Error *error_ptr = NULL);
+ StartReadThread(Error *error_ptr = nullptr);
//------------------------------------------------------------------
/// Stops the read thread by cancelling it.
@@ -288,10 +287,10 @@ public:
/// false otherwise.
//------------------------------------------------------------------
virtual bool
- StopReadThread (Error *error_ptr = NULL);
+ StopReadThread(Error *error_ptr = nullptr);
virtual bool
- JoinReadThread (Error *error_ptr = NULL);
+ JoinReadThread(Error *error_ptr = nullptr);
//------------------------------------------------------------------
/// Checks if there is a currently running read thread.
///
@@ -323,7 +322,6 @@ public:
SetReadThreadBytesReceivedCallback (ReadThreadBytesReceived callback,
void *callback_baton);
-
//------------------------------------------------------------------
/// Wait for the read thread to process all outstanding data.
///
@@ -350,18 +348,11 @@ public:
static ConstString &GetStaticBroadcasterClass ();
- virtual ConstString &GetBroadcasterClass() const
+ ConstString &GetBroadcasterClass() const override
{
return GetStaticBroadcasterClass();
}
-private:
- //------------------------------------------------------------------
- // For Communication only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (Communication);
-
-
protected:
lldb::ConnectionSP m_connection_sp; ///< The connection that is current in use by this communications class.
HostThread m_read_thread; ///< The read thread handle in case we need to cancel the thread.
@@ -381,6 +372,7 @@ protected:
uint32_t timeout_usec,
lldb::ConnectionStatus &status,
Error *error_ptr);
+
//------------------------------------------------------------------
/// Append new bytes that get read from the read thread into the
/// internal object byte cache. This will cause a \b
@@ -424,8 +416,11 @@ protected:
//------------------------------------------------------------------
size_t
GetCachedBytes (void *dst, size_t dst_len);
+
+private:
+ DISALLOW_COPY_AND_ASSIGN (Communication);
};
} // namespace lldb_private
-#endif // liblldb_Communication_h_
+#endif // liblldb_Communication_h_
diff --git a/include/lldb/Core/Connection.h b/include/lldb/Core/Connection.h
index 121395c0b23c..4b3024ebdc57 100644
--- a/include/lldb/Core/Connection.h
+++ b/include/lldb/Core/Connection.h
@@ -58,7 +58,7 @@ public:
///
/// @param[out] error_ptr
/// A pointer to an error object that should be given an
- /// approriate error value if this method returns false. This
+ /// appropriate error value if this method returns false. This
/// value can be NULL if the error value should be ignored.
///
/// @return
@@ -77,7 +77,7 @@ public:
///
/// @param[out] error_ptr
/// A pointer to an error object that should be given an
- /// approriate error value if this method returns false. This
+ /// appropriate error value if this method returns false. This
/// value can be NULL if the error value should be ignored.
///
/// @return
@@ -115,12 +115,12 @@ public:
/// The number of microseconds to wait for the data.
///
/// @param[out] status
- /// On return, indicates whether the call was sucessful or terminated
+ /// On return, indicates whether the call was successful or terminated
/// due to some error condition.
///
/// @param[out] error_ptr
/// A pointer to an error object that should be given an
- /// approriate error value if this method returns zero. This
+ /// appropriate error value if this method returns zero. This
/// value can be NULL if the error value should be ignored.
///
/// @return
@@ -151,7 +151,7 @@ public:
///
/// @param[out] error_ptr
/// A pointer to an error object that should be given an
- /// approriate error value if this method returns zero. This
+ /// appropriate error value if this method returns zero. This
/// value can be NULL if the error value should be ignored.
///
/// @return
@@ -182,7 +182,7 @@ public:
/// operation).
///
/// @return
- /// Returns true is the interrupt request was sucessful.
+ /// Returns true is the interrupt request was successful.
//------------------------------------------------------------------
virtual bool
InterruptRead() = 0;
diff --git a/include/lldb/Core/ConnectionSharedMemory.h b/include/lldb/Core/ConnectionSharedMemory.h
index 48e62142954e..d0553699e14e 100644
--- a/include/lldb/Core/ConnectionSharedMemory.h
+++ b/include/lldb/Core/ConnectionSharedMemory.h
@@ -28,33 +28,32 @@ public:
ConnectionSharedMemory ();
- virtual
- ~ConnectionSharedMemory ();
+ ~ConnectionSharedMemory () override;
- virtual bool
- IsConnected () const;
+ bool
+ IsConnected () const override;
virtual lldb::ConnectionStatus
BytesAvailable (uint32_t timeout_usec, Error *error_ptr);
- virtual lldb::ConnectionStatus
- Connect (const char *s, Error *error_ptr);
+ lldb::ConnectionStatus
+ Connect (const char *s, Error *error_ptr) override;
- virtual lldb::ConnectionStatus
- Disconnect (Error *error_ptr);
+ lldb::ConnectionStatus
+ Disconnect (Error *error_ptr) override;
- virtual size_t
+ size_t
Read (void *dst,
size_t dst_len,
uint32_t timeout_usec,
lldb::ConnectionStatus &status,
- Error *error_ptr);
+ Error *error_ptr) override;
- virtual size_t
- Write (const void *src, size_t src_len, lldb::ConnectionStatus &status, Error *error_ptr);
+ size_t
+ Write (const void *src, size_t src_len, lldb::ConnectionStatus &status, Error *error_ptr) override;
- virtual std::string
- GetURI();
+ std::string
+ GetURI() override;
lldb::ConnectionStatus
Open (bool create, const char *name, size_t size, Error *error_ptr);
@@ -64,10 +63,12 @@ protected:
std::string m_name;
int m_fd; // One buffer that contains all we need
DataBufferMemoryMap m_mmap;
+
private:
+
DISALLOW_COPY_AND_ASSIGN (ConnectionSharedMemory);
};
} // namespace lldb_private
-#endif // liblldb_ConnectionSharedMemory_h_
+#endif // liblldb_ConnectionSharedMemory_h_
diff --git a/include/lldb/Core/ConstString.h b/include/lldb/Core/ConstString.h
index cfe8ea2db0e1..6e234da0a595 100644
--- a/include/lldb/Core/ConstString.h
+++ b/include/lldb/Core/ConstString.h
@@ -9,13 +9,14 @@
#ifndef liblldb_ConstString_h_
#define liblldb_ConstString_h_
-#if defined(__cplusplus)
-#include <assert.h>
-
-#include "lldb/lldb-private.h"
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
#include "llvm/ADT/StringRef.h"
+// Project includes
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -41,12 +42,11 @@ public:
///
/// Initializes the string to an empty string.
//------------------------------------------------------------------
- ConstString ():
- m_string (NULL)
+ ConstString():
+ m_string(nullptr)
{
}
-
//------------------------------------------------------------------
/// Copy constructor
///
@@ -105,10 +105,7 @@ public:
/// Since constant string values are currently not reference counted,
/// there isn't much to do here.
//------------------------------------------------------------------
- ~ConstString ()
- {
- }
-
+ ~ConstString() = default;
//----------------------------------------------------------------------
/// C string equality binary predicate function object for ConstString
@@ -224,18 +221,16 @@ public:
/// Get the value of the contained string as a NULL terminated C
/// string value.
///
- /// If \a value_if_empty is NULL, then NULL will be returned.
+ /// If \a value_if_empty is nullptr, then nullptr will be returned.
///
/// @return
/// Returns \a value_if_empty if the string is empty, otherwise
/// the C string value contained in this object.
//------------------------------------------------------------------
const char *
- AsCString(const char *value_if_empty = NULL) const
+ AsCString(const char *value_if_empty = nullptr) const
{
- if (IsEmpty())
- return value_if_empty;
- return m_string;
+ return (IsEmpty() ? value_if_empty : m_string);
}
//------------------------------------------------------------------
@@ -256,12 +251,12 @@ public:
///
/// Get the value of the contained string as a NULL terminated C
/// string value. Similar to the ConstString::AsCString() function,
- /// yet this function will always return NULL if the string is not
+ /// yet this function will always return nullptr if the string is not
/// valid. So this function is a direct accessor to the string
/// pointer value.
///
/// @return
- /// Returns NULL the string is invalid, otherwise the C string
+ /// Returns nullptr the string is invalid, otherwise the C string
/// value contained in this object.
//------------------------------------------------------------------
const char *
@@ -270,7 +265,6 @@ public:
return m_string;
}
-
//------------------------------------------------------------------
/// Get the length in bytes of string value.
///
@@ -293,7 +287,7 @@ public:
void
Clear ()
{
- m_string = NULL;
+ m_string = nullptr;
}
//------------------------------------------------------------------
@@ -326,18 +320,18 @@ public:
///
/// 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 NULL, then nothing will be dumped to the
+ /// \a value_if_empty is nullptr, then nothing will be dumped to the
/// stream.
///
/// @param[in] s
/// The stream that will be used to dump the object description.
///
/// @param[in] value_if_empty
- /// The value to dump if the string is empty. If NULL, nothing
+ /// 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 = NULL) const;
+ Dump(Stream *s, const char *value_if_empty = nullptr) const;
//------------------------------------------------------------------
/// Dump the object debug description to a stream.
@@ -358,7 +352,7 @@ public:
bool
IsEmpty () const
{
- return m_string == NULL || m_string[0] == '\0';
+ return m_string == nullptr || m_string[0] == '\0';
}
//------------------------------------------------------------------
@@ -473,7 +467,6 @@ public:
{
return sizeof(ConstString);
}
-
//------------------------------------------------------------------
/// Get the size in bytes of the current global string pool.
@@ -503,5 +496,4 @@ Stream& operator << (Stream& s, const ConstString& str);
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // liblldb_ConstString_h_
+#endif // liblldb_ConstString_h_
diff --git a/include/lldb/Core/DataBufferHeap.h b/include/lldb/Core/DataBufferHeap.h
index ad73fabe5f1e..d379c4cf4e86 100644
--- a/include/lldb/Core/DataBufferHeap.h
+++ b/include/lldb/Core/DataBufferHeap.h
@@ -9,7 +9,6 @@
#ifndef liblldb_DataBufferHeap_h_
#define liblldb_DataBufferHeap_h_
-#if defined(__cplusplus)
#include <vector>
@@ -69,26 +68,25 @@ public:
/// Virtual destructor since this class inherits from a pure virtual
/// base class #DataBuffer.
//------------------------------------------------------------------
- virtual
- ~DataBufferHeap();
+ ~DataBufferHeap() override;
//------------------------------------------------------------------
/// @copydoc DataBuffer::GetBytes()
//------------------------------------------------------------------
- virtual uint8_t *
- GetBytes ();
+ uint8_t *
+ GetBytes () override;
//------------------------------------------------------------------
/// @copydoc DataBuffer::GetBytes() const
//------------------------------------------------------------------
- virtual const uint8_t *
- GetBytes () const;
+ const uint8_t *
+ GetBytes () const override;
//------------------------------------------------------------------
/// @copydoc DataBuffer::GetByteSize() const
//------------------------------------------------------------------
- virtual lldb::offset_t
- GetByteSize () const;
+ lldb::offset_t
+ GetByteSize () const override;
//------------------------------------------------------------------
/// Set the number of bytes in the data buffer.
@@ -138,5 +136,4 @@ private:
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // liblldb_DataBufferHeap_h_
+#endif // liblldb_DataBufferHeap_h_
diff --git a/include/lldb/Core/DataBufferMemoryMap.h b/include/lldb/Core/DataBufferMemoryMap.h
index 944b975a318a..9479d4e1a455 100644
--- a/include/lldb/Core/DataBufferMemoryMap.h
+++ b/include/lldb/Core/DataBufferMemoryMap.h
@@ -9,8 +9,6 @@
#ifndef liblldb_DataBufferMemoryMap_h_
#define liblldb_DataBufferMemoryMap_h_
-#if defined(__cplusplus)
-
#include "lldb/lldb-private.h"
#include "lldb/Core/DataBuffer.h"
@@ -45,8 +43,7 @@ public:
/// Virtual destructor since this class inherits from a pure virtual
/// base class #DataBuffer.
//------------------------------------------------------------------
- virtual
- ~DataBufferMemoryMap ();
+ ~DataBufferMemoryMap () override;
//------------------------------------------------------------------
/// Reverts this object to an empty state by unmapping any memory
@@ -58,20 +55,20 @@ public:
//------------------------------------------------------------------
/// @copydoc DataBuffer::GetBytes()
//------------------------------------------------------------------
- virtual uint8_t *
- GetBytes ();
+ uint8_t *
+ GetBytes () override;
//------------------------------------------------------------------
/// @copydoc DataBuffer::GetBytes() const
//------------------------------------------------------------------
- virtual const uint8_t *
- GetBytes () const;
+ const uint8_t *
+ GetBytes () const override;
//------------------------------------------------------------------
/// @copydoc DataBuffer::GetByteSize() const
//------------------------------------------------------------------
- virtual lldb::offset_t
- GetByteSize () const;
+ lldb::offset_t
+ GetByteSize () const override;
//------------------------------------------------------------------
/// Error get accessor.
@@ -161,5 +158,4 @@ private:
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // liblldb_DataBufferMemoryMap_h_
+#endif // liblldb_DataBufferMemoryMap_h_
diff --git a/include/lldb/Core/DataEncoder.h b/include/lldb/Core/DataEncoder.h
index 7889f4191e50..8b4727eb2de2 100644
--- a/include/lldb/Core/DataEncoder.h
+++ b/include/lldb/Core/DataEncoder.h
@@ -252,7 +252,7 @@ public:
/// The offset in bytes into the contained data at which to
/// start encoding.
///
- /// @param[int] src
+ /// @param[in] src
/// The buffer that contains the bytes to encode.
///
/// @param[in] src_len
diff --git a/include/lldb/Core/DataExtractor.h b/include/lldb/Core/DataExtractor.h
index e61189b98103..d5cb5e8ba4bc 100644
--- a/include/lldb/Core/DataExtractor.h
+++ b/include/lldb/Core/DataExtractor.h
@@ -9,17 +9,18 @@
#ifndef liblldb_DataExtractor_h_
#define liblldb_DataExtractor_h_
-#if defined (__cplusplus)
-
-
-#include "lldb/lldb-private.h"
-
-#include "llvm/ADT/SmallVector.h"
+// C Includes
#include <limits.h>
#include <stdint.h>
#include <string.h>
-#include <vector>
+
+// C++ Includes
+// Other libraries and framework includes
+#include "llvm/ADT/SmallVector.h"
+
+// Project includes
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -64,6 +65,7 @@ public:
size_t src_len,
uint32_t bytes_per_line,
lldb::addr_t base_addr); // Pass LLDB_INVALID_ADDRESS to not show address at start of line
+
//------------------------------------------------------------------
/// Default constructor.
///
@@ -146,6 +148,7 @@ public:
DataExtractor (const DataExtractor& data, lldb::offset_t offset, lldb::offset_t length, uint32_t target_byte_size = 1);
DataExtractor (const DataExtractor& rhs);
+
//------------------------------------------------------------------
/// Assignment operator.
///
@@ -183,14 +186,14 @@ public:
//------------------------------------------------------------------
/// Dumps the binary data as \a type objects to stream \a s (or to
- /// Log() if \a s is NULL) starting \a offset bytes into the data
+ /// Log() if \a s is nullptr) starting \a offset bytes into the data
/// and stopping after dumping \a length bytes. The offset into the
/// data is displayed at the beginning of each line and can be
/// offset by base address \a base_addr. \a num_per_line objects
/// will be displayed on each line.
///
/// @param[in] s
- /// The stream to dump the output to. If NULL the output will
+ /// The stream to dump the output to. If nullptr the output will
/// be dumped to Log().
///
/// @param[in] offset
@@ -212,19 +215,19 @@ public:
///
/// @param[in] type_format
/// The optional format to use for the \a type objects. If this
- /// is NULL, the default format for the \a type will be used.
+ /// is nullptr, the default format for the \a type will be used.
///
/// @return
/// The offset at which dumping ended.
//------------------------------------------------------------------
lldb::offset_t
- PutToLog (Log *log,
- lldb::offset_t offset,
- lldb::offset_t length,
- uint64_t base_addr,
- uint32_t num_per_line,
- Type type,
- const char *type_format = NULL) const;
+ PutToLog(Log *log,
+ lldb::offset_t offset,
+ lldb::offset_t length,
+ uint64_t base_addr,
+ uint32_t num_per_line,
+ Type type,
+ const char *type_format = nullptr) const;
//------------------------------------------------------------------
/// Dumps \a item_count objects into the stream \a s.
@@ -241,7 +244,7 @@ public:
/// item_bit_size and \a item_bit_offset values.
///
/// @param[in] s
- /// The stream to dump the output to. This value can not be NULL.
+ /// The stream to dump the output to. This value can not be nullptr.
///
/// @param[in] offset
/// The offset into the data at which to start dumping.
@@ -287,25 +290,25 @@ public:
/// The offset at which dumping ended.
//------------------------------------------------------------------
lldb::offset_t
- Dump (Stream *s,
- lldb::offset_t offset,
- lldb::Format item_format,
- size_t item_byte_size,
- size_t item_count,
- size_t num_per_line,
- uint64_t base_addr,
- uint32_t item_bit_size,
- uint32_t item_bit_offset,
- ExecutionContextScope *exe_scope = NULL) const;
+ Dump(Stream *s,
+ lldb::offset_t offset,
+ lldb::Format item_format,
+ size_t item_byte_size,
+ size_t item_count,
+ size_t num_per_line,
+ uint64_t base_addr,
+ uint32_t item_bit_size,
+ uint32_t item_bit_offset,
+ ExecutionContextScope *exe_scope = nullptr) const;
//------------------------------------------------------------------
/// Dump a UUID value at \a offset.
///
/// Dump a UUID starting at \a offset bytes into this object's data.
- /// If the stream \a s is NULL, the output will be sent to Log().
+ /// If the stream \a s is nullptr, the output will be sent to Log().
///
/// @param[in] s
- /// The stream to dump the output to. If NULL the output will
+ /// The stream to dump the output to. If nullptr the output will
/// be dumped to Log().
///
/// @param[in] offset
@@ -418,7 +421,7 @@ public:
/// 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.
+ /// nullptr will be returned.
//------------------------------------------------------------------
const char *
GetCStr (lldb::offset_t *offset_ptr) const;
@@ -443,7 +446,7 @@ public:
/// A pointer to the C string value in the data. If the offset
/// pointed to by \a offset_ptr is out of bounds, or if the
/// offset plus the length of the field is out of bounds, or if
- /// the field does not contain a NULL terminator byte, NULL will
+ /// the field does not contain a NULL terminator byte, nullptr will
/// be returned.
const char *
GetCStr (lldb::offset_t *offset_ptr, lldb::offset_t len) const;
@@ -454,7 +457,7 @@ public:
/// Returns a pointer to a bytes in this object's data at the offset
/// pointed to by \a offset_ptr. If \a length is zero or too large,
/// then the offset pointed to by \a offset_ptr will not be updated
- /// and NULL will be returned.
+ /// and nullptr will be returned.
///
/// @param[in,out] offset_ptr
/// A pointer to an offset within the data that will be advanced
@@ -469,7 +472,7 @@ public:
///
/// @return
/// A pointer to the bytes in this object's data if the offset
- /// and length are valid, or NULL otherwise.
+ /// and length are valid, or nullptr otherwise.
//------------------------------------------------------------------
const void*
GetData (lldb::offset_t *offset_ptr, lldb::offset_t length) const
@@ -552,7 +555,7 @@ public:
///
/// @return
/// Returns a pointer to the next byte contained in this
- /// object's data, or NULL of there is no data in this object.
+ /// object's data, or nullptr of there is no data in this object.
//------------------------------------------------------------------
const uint8_t *
GetDataEnd () const
@@ -578,7 +581,7 @@ public:
///
/// @return
/// Returns a pointer to the first byte contained in this
- /// object's data, or NULL of there is no data in this object.
+ /// object's data, or nullptr of there is no data in this object.
//------------------------------------------------------------------
const uint8_t *
GetDataStart () const
@@ -586,7 +589,6 @@ public:
return m_start;
}
-
//------------------------------------------------------------------
/// Extract a float from \a *offset_ptr.
///
@@ -908,7 +910,7 @@ public:
///
/// @return
/// \a dst if all values were properly extracted and copied,
- /// NULL otherwise.
+ /// nullptr otherwise.
//------------------------------------------------------------------
void *
GetU8 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;
@@ -955,7 +957,7 @@ public:
///
/// @return
/// \a dst if all values were properly extracted and copied,
- /// NULL otherwise.
+ /// nullptr otherwise.
//------------------------------------------------------------------
void *
GetU16 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;
@@ -1002,7 +1004,7 @@ public:
///
/// @return
/// \a dst if all values were properly extracted and copied,
- /// NULL otherwise.
+ /// nullptr otherwise.
//------------------------------------------------------------------
void *
GetU32 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;
@@ -1049,7 +1051,7 @@ public:
///
/// @return
/// \a dst if all values were properly extracted and copied,
- /// NULL otherwise.
+ /// nullptr otherwise.
//------------------------------------------------------------------
void *
GetU64 ( lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;
@@ -1113,8 +1115,8 @@ public:
/// An offset into the data.
///
/// @return
- /// A non-NULL C string pointer if \a offset is a valid offset,
- /// NULL otherwise.
+ /// A non-nullptr C string pointer if \a offset is a valid offset,
+ /// nullptr otherwise.
//------------------------------------------------------------------
const char *
PeekCStr (lldb::offset_t offset) const;
@@ -1126,8 +1128,8 @@ public:
/// there are \a length bytes available starting at \a offset.
///
/// @return
- /// A non-NULL data pointer if \a offset is a valid offset and
- /// there are \a length bytes available at that offset, NULL
+ /// 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*
@@ -1135,7 +1137,7 @@ public:
{
if (length > 0 && ValidOffsetForDataOfSize(offset, length))
return m_start + offset;
- return NULL;
+ return nullptr;
}
//------------------------------------------------------------------
@@ -1150,6 +1152,9 @@ public:
void
SetAddressByteSize (uint32_t addr_size)
{
+#ifdef LLDB_CONFIGURATION_DEBUG
+ assert (addr_size == 4 || addr_size == 8);
+#endif
m_addr_size = addr_size;
}
@@ -1159,7 +1164,7 @@ public:
/// Use data that is owned by the caller when extracting values.
/// The data must stay around as long as this object, or any object
/// that copies a subset of this object's data, is valid. If \a
- /// bytes is NULL, or \a length is zero, this object will contain
+ /// bytes is nullptr, or \a length is zero, this object will contain
/// no data.
///
/// @param[in] bytes
@@ -1317,10 +1322,8 @@ public:
void
Checksum (llvm::SmallVectorImpl<uint8_t> &dest,
uint64_t max_data = 0);
-
protected:
-
//------------------------------------------------------------------
// Member variables
//------------------------------------------------------------------
@@ -1334,5 +1337,4 @@ protected:
} // namespace lldb_private
-#endif // #if defined (__cplusplus)
-#endif // #ifndef liblldb_DataExtractor_h_
+#endif // liblldb_DataExtractor_h_
diff --git a/include/lldb/Core/Debugger.h b/include/lldb/Core/Debugger.h
index 0d9b90c8919d..4ca648ca296e 100644
--- a/include/lldb/Core/Debugger.h
+++ b/include/lldb/Core/Debugger.h
@@ -9,11 +9,17 @@
#ifndef liblldb_Debugger_h_
#define liblldb_Debugger_h_
-#if defined(__cplusplus)
-
+// C Includes
#include <stdint.h>
+// C++ Includes
+#include <memory>
+#include <map>
+#include <vector>
+
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-public.h"
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/FormatEntity.h"
@@ -32,8 +38,8 @@ namespace llvm
namespace sys
{
class DynamicLibrary;
-}
-}
+} // namespace sys
+} // namespace llvm
namespace lldb_private {
@@ -44,7 +50,6 @@ namespace lldb_private {
/// Provides a global root objects for the debugger core.
//----------------------------------------------------------------------
-
class Debugger :
public std::enable_shared_from_this<Debugger>,
public UserID,
@@ -54,9 +59,10 @@ class Debugger :
friend class SourceManager; // For GetSourceFileCache.
public:
+ ~Debugger() override;
static lldb::DebuggerSP
- CreateInstance (lldb::LogOutputCallback log_callback = NULL, void *baton = NULL);
+ CreateInstance(lldb::LogOutputCallback log_callback = nullptr, void *baton = nullptr);
static lldb::TargetSP
FindTargetWithProcessID (lldb::pid_t pid);
@@ -79,9 +85,26 @@ public:
static void
Destroy (lldb::DebuggerSP &debugger_sp);
- virtual
- ~Debugger ();
+ static lldb::DebuggerSP
+ FindDebuggerWithID(lldb::user_id_t id);
+ static lldb::DebuggerSP
+ FindDebuggerWithInstanceName(const ConstString &instance_name);
+
+ static size_t
+ GetNumDebuggers();
+
+ static lldb::DebuggerSP
+ GetDebuggerAtIndex(size_t index);
+
+ static bool
+ FormatDisassemblerAddress(const FormatEntity::Entry *format,
+ const SymbolContext *sc,
+ const SymbolContext *prev_sc,
+ const ExecutionContext *exe_ctx,
+ const Address *addr,
+ Stream &s);
+
void Clear();
bool
@@ -108,8 +131,6 @@ public:
return m_error_file_sp;
}
-
-
void
SetInputFileHandle (FILE *fh, bool tranfer_ownership);
@@ -209,6 +230,10 @@ public:
bool
IsTopIOHandler (const lldb::IOHandlerSP& reader_sp);
+
+ bool
+ CheckTopIOHandlerTypes (IOHandler::Type top_type,
+ IOHandler::Type second_top_type);
void
PrintAsync (const char *s, size_t len, bool is_stdout);
@@ -222,26 +247,6 @@ public:
const char *
GetIOHandlerHelpPrologue();
- static lldb::DebuggerSP
- FindDebuggerWithID (lldb::user_id_t id);
-
- static lldb::DebuggerSP
- FindDebuggerWithInstanceName (const ConstString &instance_name);
-
- static size_t
- GetNumDebuggers();
-
- static lldb::DebuggerSP
- GetDebuggerAtIndex (size_t index);
-
- static bool
- FormatDisassemblerAddress (const FormatEntity::Entry *format,
- const SymbolContext *sc,
- const SymbolContext *prev_sc,
- const ExecutionContext *exe_ctx,
- const Address *addr,
- Stream &s);
-
void
ClearIOHandlers ();
@@ -257,22 +262,22 @@ public:
void
SetLoggingCallback (lldb::LogOutputCallback log_callback, void *baton);
-
//----------------------------------------------------------------------
// Properties Functions
//----------------------------------------------------------------------
enum StopDisassemblyType
{
eStopDisassemblyTypeNever = 0,
+ eStopDisassemblyTypeNoDebugInfo,
eStopDisassemblyTypeNoSource,
eStopDisassemblyTypeAlways
};
- virtual Error
- SetPropertyValue (const ExecutionContext *exe_ctx,
- VarSetOperationType op,
- const char *property_path,
- const char *value);
+ Error
+ SetPropertyValue(const ExecutionContext *exe_ctx,
+ VarSetOperationType op,
+ const char *property_path,
+ const char *value) override;
bool
GetAutoConfirm () const;
@@ -329,6 +334,24 @@ public:
GetAutoOneLineSummaries () const;
bool
+ GetAutoIndent () const;
+
+ bool
+ SetAutoIndent (bool b);
+
+ bool
+ GetPrintDecls () const;
+
+ bool
+ SetPrintDecls (bool b);
+
+ uint32_t
+ GetTabSize () const;
+
+ bool
+ SetTabSize (uint32_t tab_size);
+
+ bool
GetEscapeNonPrintables () const;
bool
@@ -360,6 +383,9 @@ public:
{
return m_event_handler_thread.IsJoinable();
}
+
+ Error
+ RunREPL (lldb::LanguageType language, const char *repl_options);
// This is for use in the command interpreter, when you either want the selected target, or if no target
// is present you want to prime the dummy target with entities that will be copied over to new targets.
@@ -367,8 +393,8 @@ public:
Target *GetDummyTarget();
protected:
-
friend class CommandInterpreter;
+ friend class REPL;
bool
StartEventHandlerThread();
@@ -380,11 +406,17 @@ protected:
EventHandlerThread (lldb::thread_arg_t arg);
bool
+ HasIOHandlerThread();
+
+ bool
StartIOHandlerThread();
void
StopIOHandlerThread();
+ void
+ JoinIOHandlerThread();
+
static lldb::thread_result_t
IOHandlerThread (lldb::thread_arg_t arg);
@@ -450,16 +482,13 @@ protected:
};
private:
-
// Use Debugger::CreateInstance() to get a shared pointer to a new
// debugger object
Debugger (lldb::LogOutputCallback m_log_callback, void *baton);
DISALLOW_COPY_AND_ASSIGN (Debugger);
-
};
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // liblldb_Debugger_h_
+#endif // liblldb_Debugger_h_
diff --git a/include/lldb/Core/Disassembler.h b/include/lldb/Core/Disassembler.h
index e08e2def4c18..bfa99de81ea4 100644
--- a/include/lldb/Core/Disassembler.h
+++ b/include/lldb/Core/Disassembler.h
@@ -48,6 +48,7 @@ public:
CalculateMnemonicOperandsAndCommentIfNeeded (exe_ctx);
return m_opcode_name.c_str();
}
+
const char *
GetOperands (const ExecutionContext* exe_ctx)
{
@@ -127,7 +128,6 @@ public:
/// 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,
@@ -142,6 +142,9 @@ public:
virtual bool
DoesBranch () = 0;
+ virtual bool
+ HasDelaySlot ();
+
virtual size_t
Decode (const Disassembler &disassembler,
const DataExtractor& data,
@@ -208,7 +211,6 @@ protected:
}
};
-
class InstructionList
{
public:
@@ -260,30 +262,32 @@ public:
PseudoInstruction ();
- virtual
- ~PseudoInstruction ();
+ ~PseudoInstruction() override;
- virtual bool
- DoesBranch ();
+ bool
+ DoesBranch() override;
- virtual void
- CalculateMnemonicOperandsAndComment (const ExecutionContext* exe_ctx)
+ bool
+ HasDelaySlot() override;
+
+ void
+ CalculateMnemonicOperandsAndComment(const ExecutionContext* exe_ctx) override
{
// TODO: fill this in and put opcode name into Instruction::m_opcode_name,
// mnemonic into Instruction::m_mnemonics, and any comment into
// Instruction::m_comment
}
- virtual size_t
- Decode (const Disassembler &disassembler,
- const DataExtractor &data,
- lldb::offset_t data_offset);
+ size_t
+ Decode(const Disassembler &disassembler,
+ const DataExtractor &data,
+ lldb::offset_t data_offset) override;
void
SetOpcode (size_t opcode_size, void *opcode_data);
- virtual void
- SetDescription (const char *description);
+ void
+ SetDescription(const char *description) override;
protected:
std::string m_description;
@@ -405,7 +409,7 @@ public:
// Constructors and Destructors
//------------------------------------------------------------------
Disassembler(const ArchSpec &arch, const char *flavor);
- virtual ~Disassembler();
+ ~Disassembler() override;
typedef const char * (*SummaryCallback)(const Instruction& inst, ExecutionContext *exe_context, void *user_data);
@@ -478,4 +482,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_Disassembler_h_
+#endif // liblldb_Disassembler_h_
diff --git a/include/lldb/Core/EmulateInstruction.h b/include/lldb/Core/EmulateInstruction.h
index 774d80968ff9..c5e60022fc96 100644
--- a/include/lldb/Core/EmulateInstruction.h
+++ b/include/lldb/Core/EmulateInstruction.h
@@ -19,6 +19,8 @@
#include "lldb/Core/Opcode.h"
#include "lldb/Core/RegisterValue.h"
+namespace lldb_private {
+
//----------------------------------------------------------------------
/// @class EmulateInstruction EmulateInstruction.h "lldb/Core/EmulateInstruction.h"
/// @brief A class that allows emulation of CPU opcodes.
@@ -79,8 +81,6 @@
/// and emulating the instruction is just a bonus.
//----------------------------------------------------------------------
-namespace lldb_private {
-
class EmulateInstruction :
public PluginInterface
{
@@ -233,7 +233,6 @@ public:
} ISAAndImmediateSigned;
uint32_t isa;
-
} info;
Context () :
@@ -387,9 +386,8 @@ public:
EmulateInstruction (const ArchSpec &arch);
- virtual ~EmulateInstruction()
- {
- }
+ ~EmulateInstruction() override = default;
+
//----------------------------------------------------------------------
// Mandatory overrides
//----------------------------------------------------------------------
@@ -404,7 +402,10 @@ public:
virtual bool
EvaluateInstruction (uint32_t evaluate_options) = 0;
-
+
+ virtual bool
+ IsInstructionConditional() { return false; }
+
virtual bool
TestEmulation (Stream *out_stream, ArchSpec &arch, OptionValueDictionary *test_data) = 0;
@@ -527,7 +528,6 @@ public:
return m_arch;
}
-
static size_t
ReadMemoryFrame (EmulateInstruction *instruction,
void *baton,
@@ -628,7 +628,6 @@ protected:
lldb::addr_t m_addr;
Opcode m_opcode;
-
private:
//------------------------------------------------------------------
// For EmulateInstruction only
@@ -636,6 +635,6 @@ private:
DISALLOW_COPY_AND_ASSIGN (EmulateInstruction);
};
-} // namespace lldb_private
+} // namespace lldb_private
-#endif // lldb_EmulateInstruction_h_
+#endif // lldb_EmulateInstruction_h_
diff --git a/include/lldb/Core/Event.h b/include/lldb/Core/Event.h
index 1c3eec0359c3..e8867c0e7e77 100644
--- a/include/lldb/Core/Event.h
+++ b/include/lldb/Core/Event.h
@@ -12,7 +12,7 @@
// C Includes
// C++ Includes
-#include <list>
+#include <memory>
#include <string>
// Other libraries and framework includes
@@ -49,7 +49,6 @@ private:
}
DISALLOW_COPY_AND_ASSIGN (EventData);
-
};
//----------------------------------------------------------------------
@@ -67,17 +66,16 @@ public:
EventDataBytes (const void *src, size_t src_len);
- virtual
- ~EventDataBytes();
+ ~EventDataBytes() override;
//------------------------------------------------------------------
// Member functions
//------------------------------------------------------------------
- virtual const ConstString &
- GetFlavor () const;
+ const ConstString &
+ GetFlavor () const override;
- virtual void
- Dump (Stream *s) const;
+ void
+ Dump (Stream *s) const override;
const void *
GetBytes() const;
@@ -113,7 +111,6 @@ private:
std::string m_bytes;
DISALLOW_COPY_AND_ASSIGN (EventDataBytes);
-
};
//----------------------------------------------------------------------
@@ -126,10 +123,9 @@ class Event
friend class EventData;
public:
+ Event(Broadcaster *broadcaster, uint32_t event_type, EventData *data = nullptr);
- Event (Broadcaster *broadcaster, uint32_t event_type, EventData *data = NULL);
-
- Event (uint32_t event_type, EventData *data = NULL);
+ Event(uint32_t event_type, EventData *data = nullptr);
~Event ();
@@ -184,7 +180,6 @@ public:
m_data_ap.reset();
}
-
private:
// This is only called by Listener when it pops an event off the queue for
// the listener. It calls the Event Data's DoOnRemoval() method, which is
@@ -202,7 +197,6 @@ private:
m_broadcaster = broadcaster;
}
-
Broadcaster * m_broadcaster; // The broadcaster that sent this event
uint32_t m_type; // The bit describing this event
std::unique_ptr<EventData> m_data_ap; // User specific data for this event
@@ -214,4 +208,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_Event_h_
+#endif // liblldb_Event_h_
diff --git a/include/lldb/Core/FileLineResolver.h b/include/lldb/Core/FileLineResolver.h
index e1928f1b063d..f0f7fbdf756f 100644
--- a/include/lldb/Core/FileLineResolver.h
+++ b/include/lldb/Core/FileLineResolver.h
@@ -38,20 +38,19 @@ public:
uint32_t line_no,
bool check_inlines);
- virtual
- ~FileLineResolver ();
+ ~FileLineResolver () override;
- virtual Searcher::CallbackReturn
+ Searcher::CallbackReturn
SearchCallback (SearchFilter &filter,
SymbolContext &context,
Address *addr,
- bool containing);
+ bool containing) override;
- virtual Searcher::Depth
- GetDepth ();
+ Searcher::Depth
+ GetDepth () override;
- virtual void
- GetDescription (Stream *s);
+ void
+ GetDescription (Stream *s) override;
const SymbolContextList &
GetFileLineMatches()
@@ -78,4 +77,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_FileLineResolver_h_
+#endif // liblldb_FileLineResolver_h_
diff --git a/include/lldb/Core/FormatEntity.h b/include/lldb/Core/FormatEntity.h
index db4f59132832..659b696e61fd 100644
--- a/include/lldb/Core/FormatEntity.h
+++ b/include/lldb/Core/FormatEntity.h
@@ -9,18 +9,21 @@
#ifndef liblldb_FormatEntity_h_
#define liblldb_FormatEntity_h_
-#if defined(__cplusplus)
+// C Includes
+// C++ Includes
#include <string>
#include <vector>
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/Error.h"
namespace llvm
{
class StringRef;
-}
+} // namespace llvm
namespace lldb_private
{
@@ -81,6 +84,7 @@ namespace lldb_private
FunctionPCOffset,
FunctionInitial,
FunctionChanged,
+ FunctionIsOptimized,
LineEntryFile,
LineEntryLineNumber,
LineEntryStartAddress,
@@ -108,13 +112,13 @@ namespace lldb_private
bool keep_separator;
};
- Entry (Type t = Type::Invalid,
- const char *s = NULL,
- const char *f = NULL) :
+ Entry(Type t = Type::Invalid,
+ const char *s = nullptr,
+ const char *f = nullptr) :
string (s ? s : ""),
printf_format (f ? f : ""),
children (),
- definition (NULL),
+ definition (nullptr),
type (t),
fmt (lldb::eFormatDefault),
number (0),
@@ -146,7 +150,7 @@ namespace lldb_private
string.clear();
printf_format.clear();
children.clear();
- definition = NULL;
+ definition = nullptr;
type = Type::Invalid;
fmt = lldb::eFormatDefault;
number = 0;
@@ -252,12 +256,10 @@ namespace lldb_private
static bool
FormatFileSpec (const FileSpec &file, Stream &s, llvm::StringRef elements, llvm::StringRef element_format);
protected:
-
static Error
ParseInternal (llvm::StringRef &format, Entry &parent_entry, uint32_t depth);
};
+} // namespace lldb_private
-}
-#endif // #if defined(__cplusplus)
-#endif // liblldb_FormatEntity_h_
+#endif // liblldb_FormatEntity_h_
diff --git a/include/lldb/Core/History.h b/include/lldb/Core/History.h
index b3626882f843..fbb7bd8b0c1a 100644
--- a/include/lldb/Core/History.h
+++ b/include/lldb/Core/History.h
@@ -82,7 +82,6 @@ private:
collection m_events;
DISALLOW_COPY_AND_ASSIGN (HistorySource);
-
};
//----------------------------------------------------------------------
@@ -103,8 +102,7 @@ class HistorySourceUInt : public HistorySource
{
}
- virtual
- ~HistorySourceUInt()
+ ~HistorySourceUInt() override
{
}
@@ -112,44 +110,44 @@ class HistorySourceUInt : public HistorySource
// in the subclass of this class to produce a history event and push it
// onto the end of the history stack.
- virtual HistoryEvent
- CreateHistoryEvent ()
+ HistoryEvent
+ CreateHistoryEvent () override
{
++m_curr_id;
return (HistoryEvent)m_curr_id;
}
- virtual void
- DeleteHistoryEvent (HistoryEvent event)
+ void
+ DeleteHistoryEvent (HistoryEvent event) override
{
// Nothing to delete, the event contains the integer
}
- virtual void
- DumpHistoryEvent (Stream &strm, HistoryEvent event);
+ void
+ DumpHistoryEvent (Stream &strm, HistoryEvent event) override;
- virtual size_t
- GetHistoryEventCount()
+ size_t
+ GetHistoryEventCount() override
{
return m_curr_id;
}
- virtual HistoryEvent
- GetHistoryEventAtIndex (uint32_t idx)
+ HistoryEvent
+ GetHistoryEventAtIndex (uint32_t idx) override
{
return (HistoryEvent)((uintptr_t)idx);
}
- virtual HistoryEvent
- GetCurrentHistoryEvent ()
+ HistoryEvent
+ GetCurrentHistoryEvent () override
{
return (HistoryEvent)m_curr_id;
}
// Return 0 when lhs == rhs, 1 if lhs > rhs, or -1 if lhs < rhs.
- virtual int
+ int
CompareHistoryEvents (const HistoryEvent lhs,
- const HistoryEvent rhs)
+ const HistoryEvent rhs) override
{
uintptr_t lhs_uint = (uintptr_t)lhs;
uintptr_t rhs_uint = (uintptr_t)rhs;
@@ -160,8 +158,8 @@ class HistorySourceUInt : public HistorySource
return 0;
}
- virtual bool
- IsCurrentHistoryEvent (const HistoryEvent event)
+ bool
+ IsCurrentHistoryEvent (const HistoryEvent event) override
{
return (uintptr_t)event == m_curr_id;
}
@@ -171,7 +169,6 @@ protected:
uintptr_t m_curr_id; // The current value of the history unsigned unteger
};
-
} // namespace lldb_private
-#endif // lldb_History_h_
+#endif // lldb_History_h_
diff --git a/include/lldb/Core/IOHandler.h b/include/lldb/Core/IOHandler.h
index b617d8e75f58..3eba1c3cc9d8 100644
--- a/include/lldb/Core/IOHandler.h
+++ b/include/lldb/Core/IOHandler.h
@@ -10,10 +10,16 @@
#ifndef liblldb_IOHandler_h_
#define liblldb_IOHandler_h_
+// C Includes
#include <string.h>
-#include <stack>
+// C++ Includes
+#include <memory>
+#include <string>
+#include <vector>
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/Core/ConstString.h"
@@ -29,7 +35,7 @@ namespace curses
{
class Application;
typedef std::unique_ptr<Application> ApplicationAP;
-}
+} // namespace curses
namespace lldb_private {
@@ -42,6 +48,7 @@ namespace lldb_private {
Confirm,
Curses,
Expression,
+ REPL,
ProcessIO,
PythonInterpreter,
PythonCode,
@@ -123,7 +130,7 @@ namespace lldb_private {
GetPrompt ()
{
// Prompt support isn't mandatory
- return NULL;
+ return nullptr;
}
virtual bool
@@ -142,13 +149,13 @@ namespace lldb_private {
virtual const char *
GetCommandPrefix ()
{
- return NULL;
+ return nullptr;
}
virtual const char *
GetHelpPrologue()
{
- return NULL;
+ return nullptr;
}
int
@@ -257,7 +264,6 @@ namespace lldb_private {
private:
DISALLOW_COPY_AND_ASSIGN (IOHandler);
};
-
//------------------------------------------------------------------
/// A delegate class for use with IOHandler subclasses.
@@ -283,9 +289,7 @@ namespace lldb_private {
}
virtual
- ~IOHandlerDelegate()
- {
- }
+ ~IOHandlerDelegate() = default;
virtual void
IOHandlerActivated (IOHandler &io_handler)
@@ -309,7 +313,7 @@ namespace lldb_private {
virtual const char *
IOHandlerGetFixIndentationCharacters ()
{
- return NULL;
+ return nullptr;
}
//------------------------------------------------------------------
@@ -395,13 +399,13 @@ namespace lldb_private {
virtual const char *
IOHandlerGetCommandPrefix ()
{
- return NULL;
+ return nullptr;
}
virtual const char *
IOHandlerGetHelpPrologue ()
{
- return NULL;
+ return nullptr;
}
//------------------------------------------------------------------
@@ -415,6 +419,7 @@ namespace lldb_private {
{
return false;
}
+
protected:
Completion m_completion; // Support for common builtin completions
bool m_io_handler_done;
@@ -438,10 +443,7 @@ namespace lldb_private {
{
}
- virtual
- ~IOHandlerDelegateMultiline ()
- {
- }
+ ~IOHandlerDelegateMultiline() override = default;
ConstString
IOHandlerGetControlSequence (char ch) override
@@ -467,11 +469,11 @@ namespace lldb_private {
}
return false;
}
+
protected:
const std::string m_end_line;
};
-
class IOHandlerEditline : public IOHandler
{
public:
@@ -499,8 +501,7 @@ namespace lldb_private {
uint32_t line_number_start, // If non-zero show line numbers starting at 'line_number_start'
IOHandlerDelegate &delegate);
- virtual
- ~IOHandlerEditline ();
+ ~IOHandlerEditline() override;
void
Run () override;
@@ -632,8 +633,7 @@ namespace lldb_private {
const char *prompt,
bool default_response);
- virtual
- ~IOHandlerConfirm ();
+ ~IOHandlerConfirm() override;
bool
GetResponse () const
@@ -694,14 +694,14 @@ namespace lldb_private {
public:
IOHandlerCursesValueObjectList (Debugger &debugger, ValueObjectList &valobj_list);
- virtual
- ~IOHandlerCursesValueObjectList ();
+ ~IOHandlerCursesValueObjectList() override;
void
Run () override;
void
GotEOF() override;
+
protected:
ValueObjectList m_valobj_list;
};
@@ -709,17 +709,14 @@ namespace lldb_private {
class IOHandlerStack
{
public:
-
IOHandlerStack () :
m_stack(),
m_mutex(Mutex::eMutexTypeRecursive),
- m_top (NULL)
+ m_top (nullptr)
{
}
- ~IOHandlerStack ()
- {
- }
+ ~IOHandlerStack() = default;
size_t
GetSize () const
@@ -771,10 +768,8 @@ namespace lldb_private {
sp->SetPopped (true);
}
// Set m_top the non-locking IsTop() call
- if (m_stack.empty())
- m_top = NULL;
- else
- m_top = m_stack.back().get();
+
+ m_top = (m_stack.empty() ? nullptr : m_stack.back().get());
}
Mutex &
@@ -794,53 +789,42 @@ namespace lldb_private {
{
Mutex::Locker locker (m_mutex);
const size_t num_io_handlers = m_stack.size();
- if (num_io_handlers >= 2 &&
- m_stack[num_io_handlers-1]->GetType() == top_type &&
- m_stack[num_io_handlers-2]->GetType() == second_top_type)
- {
- return true;
- }
- return false;
+ return (num_io_handlers >= 2 &&
+ m_stack[num_io_handlers-1]->GetType() == top_type &&
+ m_stack[num_io_handlers-2]->GetType() == second_top_type);
}
+
ConstString
GetTopIOHandlerControlSequence (char ch)
{
- if (m_top)
- return m_top->GetControlSequence(ch);
- return ConstString();
+ return ((m_top != nullptr) ? m_top->GetControlSequence(ch) : ConstString());
}
const char *
GetTopIOHandlerCommandPrefix()
{
- if (m_top)
- return m_top->GetCommandPrefix();
- return NULL;
+ return ((m_top != nullptr) ? m_top->GetCommandPrefix() : nullptr);
}
const char *
GetTopIOHandlerHelpPrologue()
{
- if (m_top)
- return m_top->GetHelpPrologue();
- return NULL;
+ return ((m_top != nullptr) ? m_top->GetHelpPrologue() : nullptr);
}
void
PrintAsync (Stream *stream, const char *s, size_t len);
protected:
-
typedef std::vector<lldb::IOHandlerSP> collection;
collection m_stack;
mutable Mutex m_mutex;
IOHandler *m_top;
private:
-
DISALLOW_COPY_AND_ASSIGN (IOHandlerStack);
};
} // namespace lldb_private
-#endif // #ifndef liblldb_IOHandler_h_
+#endif // liblldb_IOHandler_h_
diff --git a/include/lldb/Core/Language.h b/include/lldb/Core/Language.h
deleted file mode 100644
index 670c6aa695e1..000000000000
--- a/include/lldb/Core/Language.h
+++ /dev/null
@@ -1,117 +0,0 @@
-//===-- Language.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_Language_h_
-#define liblldb_Language_h_
-
-#include "lldb/lldb-private.h"
-
-namespace lldb_private {
-
-//----------------------------------------------------------------------
-/// @class Language Language.h "lldb/Core/Language.h"
-/// @brief Encapsulates the programming language for an lldb object.
-///
-/// Languages are represented by an enumeration value.
-///
-/// The enumeration values used when describing the programming language
-/// are the same values as the latest DWARF specification.
-//----------------------------------------------------------------------
-class Language
-{
-public:
- //------------------------------------------------------------------
- /// Construct with optional language enumeration.
- //------------------------------------------------------------------
- Language(lldb::LanguageType language = lldb::eLanguageTypeUnknown);
-
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// The destructor is virtual in case this class is subclassed.
- //------------------------------------------------------------------
- virtual
- ~Language();
-
- //------------------------------------------------------------------
- /// Get the language value as a NULL termianted C string.
- ///
- /// @return
- /// The C string representation of the language. The returned
- /// string does not need to be freed as it comes from constant
- /// strings. NULL can be returned when the language is set to
- /// a value that doesn't match of of the lldb::LanguageType
- /// enumerations.
- //------------------------------------------------------------------
- const char *
- AsCString (lldb::DescriptionLevel level = lldb::eDescriptionLevelBrief) const;
-
- void
- Clear();
-
- void
- GetDescription (Stream *s, lldb::DescriptionLevel level) const;
-
- //------------------------------------------------------------------
- /// Dump the language value to the stream \a s.
- ///
- /// @param[in] s
- /// The stream to which to dump the language description.
- //------------------------------------------------------------------
- void
- Dump(Stream *s) const;
-
- //------------------------------------------------------------------
- /// Get accessor for the language.
- ///
- /// @return
- /// The enumeration value that describes the programming
- /// language that an object is associated with.
- //------------------------------------------------------------------
- virtual lldb::LanguageType
- GetLanguage() const;
-
- //------------------------------------------------------------------
- /// Set accessor for the language.
- ///
- /// @param[in] language
- /// The new enumeration value that describes the programming
- /// language that an object is associated with.
- //------------------------------------------------------------------
- void
- SetLanguage(lldb::LanguageType language);
-
- //------------------------------------------------------------------
- /// Set accessor for the language.
- ///
- /// @param[in] language_cstr
- /// The language name as a C string.
- //------------------------------------------------------------------
- bool
- SetLanguageFromCString(const char *language_cstr);
-
-
-protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- lldb::LanguageType m_language; ///< The programming language enumeration value.
- ///< The enumeration values are the same as the
- ///< latest DWARF specification.
-};
-
-//--------------------------------------------------------------
-/// Stream the language enumeration as a string object to a
-/// Stream.
-//--------------------------------------------------------------
-Stream& operator << (Stream& s, const Language& language);
-
-} // namespace lldb_private
-
-#endif // liblldb_Language_h_
diff --git a/include/lldb/Core/Listener.h b/include/lldb/Core/Listener.h
index 2dbd2eb436ce..b11c1644507b 100644
--- a/include/lldb/Core/Listener.h
+++ b/include/lldb/Core/Listener.h
@@ -14,11 +14,9 @@
// C++ Includes
#include <list>
#include <map>
-#include <set>
#include <string>
#include <vector>
-
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
@@ -118,13 +116,12 @@ public:
HandleBroadcastEvent (lldb::EventSP &event_sp);
private:
-
//------------------------------------------------------------------
// Classes that inherit from Listener can see and modify these
//------------------------------------------------------------------
struct BroadcasterInfo
{
- BroadcasterInfo(uint32_t mask, HandleBroadcastCallback cb = NULL, void *ud = NULL) :
+ BroadcasterInfo(uint32_t mask, HandleBroadcastCallback cb = nullptr, void *ud = nullptr) :
event_mask (mask),
callback (cb),
callback_user_data (ud)
@@ -141,28 +138,28 @@ private:
typedef std::vector<BroadcasterManager *> broadcaster_manager_collection;
bool
- FindNextEventInternal (Broadcaster *broadcaster, // NULL for any broadcaster
- const ConstString *sources, // NULL for any event
- uint32_t num_sources,
- uint32_t event_type_mask,
- lldb::EventSP &event_sp,
- bool remove);
+ FindNextEventInternal(Broadcaster *broadcaster, // nullptr for any broadcaster
+ const ConstString *sources, // nullptr for any event
+ uint32_t num_sources,
+ uint32_t event_type_mask,
+ lldb::EventSP &event_sp,
+ bool remove);
+
+ bool
+ GetNextEventInternal(Broadcaster *broadcaster, // nullptr for any broadcaster
+ const ConstString *sources, // nullptr for any event
+ uint32_t num_sources,
+ uint32_t event_type_mask,
+ lldb::EventSP &event_sp);
bool
- GetNextEventInternal (Broadcaster *broadcaster, // NULL for any broadcaster
- const ConstString *sources, // NULL for any event
+ WaitForEventsInternal(const TimeValue *timeout,
+ Broadcaster *broadcaster, // nullptr for any broadcaster
+ const ConstString *sources, // nullptr for any event
uint32_t num_sources,
uint32_t event_type_mask,
lldb::EventSP &event_sp);
- bool
- WaitForEventsInternal (const TimeValue *timeout,
- Broadcaster *broadcaster, // NULL for any broadcaster
- const ConstString *sources, // NULL for any event
- uint32_t num_sources,
- uint32_t event_type_mask,
- lldb::EventSP &event_sp);
-
std::string m_name;
broadcaster_collection m_broadcasters;
Mutex m_broadcasters_mutex; // Protects m_broadcasters
@@ -191,4 +188,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_Select_h_
+#endif // liblldb_Select_h_
diff --git a/include/lldb/Core/Log.h b/include/lldb/Core/Log.h
index 3aa4b4d48e17..674fdfdfc0b2 100644
--- a/include/lldb/Core/Log.h
+++ b/include/lldb/Core/Log.h
@@ -182,17 +182,16 @@ private:
DISALLOW_COPY_AND_ASSIGN(Log);
};
-
class LogChannel : public PluginInterface
{
public:
LogChannel();
- virtual ~LogChannel();
+ ~LogChannel() override;
static lldb::LogChannelSP FindPlugin(const char *plugin_name);
- // categories is a an array of chars that ends with a NULL element.
+ // categories is an array of chars that ends with a NULL element.
virtual void Disable(const char **categories, Stream *feedback_strm) = 0;
virtual bool Enable(
@@ -209,7 +208,6 @@ private:
DISALLOW_COPY_AND_ASSIGN(LogChannel);
};
-
} // namespace lldb_private
-#endif // liblldb_Log_H_
+#endif // liblldb_Log_h_
diff --git a/include/lldb/Core/Logging.h b/include/lldb/Core/Logging.h
index a4dd76f11237..ca04c84b21a6 100644
--- a/include/lldb/Core/Logging.h
+++ b/include/lldb/Core/Logging.h
@@ -48,6 +48,7 @@
#define LIBLLDB_LOG_SYSTEM_RUNTIME (1u << 26)
#define LIBLLDB_LOG_JIT_LOADER (1u << 27)
#define LIBLLDB_LOG_LANGUAGE (1u << 28)
+#define LIBLLDB_LOG_DATAFORMATTERS (1u << 29)
#define LIBLLDB_LOG_ALL (UINT32_MAX)
#define LIBLLDB_LOG_DEFAULT (LIBLLDB_LOG_PROCESS |\
LIBLLDB_LOG_THREAD |\
diff --git a/include/lldb/Core/MappedHash.h b/include/lldb/Core/MappedHash.h
index 4b77ff1ab8fc..5a52ab2b8b2d 100644
--- a/include/lldb/Core/MappedHash.h
+++ b/include/lldb/Core/MappedHash.h
@@ -1,29 +1,38 @@
+//===-- MappedHash.h --------------------------------------------*- C++ -*-===//
//
-// MappedHash.h
+// The LLVM Compiler Infrastructure
//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
#ifndef liblldb_MappedHash_h_
#define liblldb_MappedHash_h_
+// C Includes
#include <assert.h>
#include <stdint.h>
+// C++ Includes
+#include <algorithm>
+#include <functional>
#include <map>
#include <vector>
+// Other libraries and framework includes
+// Project includes
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Stream.h"
class MappedHash
{
public:
-
enum HashFunctionType
{
eHashFunctionDJB = 0u // Daniel J Bernstein hash function that is also used by the ELF GNU_HASH sections
};
-
static uint32_t
HashStringUsingDJB (const char *s)
{
@@ -50,7 +59,6 @@ public:
return 0;
}
-
static const uint32_t HASH_MAGIC = 0x48415348u;
static const uint32_t HASH_CIGAM = 0x48534148u;
@@ -77,11 +85,9 @@ public:
header_data ()
{
}
-
+
virtual
- ~Header()
- {
- }
+ ~Header() = default;
size_t
GetByteSize() const
@@ -254,8 +260,7 @@ public:
header.bucket_count = num_unique_hashes;
if (header.bucket_count == 0)
header.bucket_count = 1;
-
-
+
std::vector<HashToHashData> hash_buckets;
std::vector<uint32_t> hash_indexes (header.bucket_count, 0);
std::vector<uint32_t> hash_values;
@@ -345,10 +350,12 @@ public:
}
}
}
+
protected:
typedef std::vector<Entry> collection;
collection m_entries;
};
+
// A class for reading and using a saved hash table from a block of data
// in memory
template <typename __KeyType, class __HeaderType, class __HashData>
@@ -375,9 +382,9 @@ public:
MemoryTable (lldb_private::DataExtractor &data) :
m_header (),
- m_hash_indexes (NULL),
- m_hash_values (NULL),
- m_hash_offsets (NULL)
+ m_hash_indexes (nullptr),
+ m_hash_values (nullptr),
+ m_hash_offsets (nullptr)
{
lldb::offset_t offset = m_header.Read (data, 0);
if (offset != LLDB_INVALID_OFFSET && IsValid ())
@@ -387,12 +394,10 @@ public:
m_hash_offsets = (const uint32_t *)data.GetData (&offset, m_header.hashes_count * sizeof(uint32_t));
}
}
-
+
virtual
- ~MemoryTable ()
- {
- }
-
+ ~MemoryTable() = default;
+
bool
IsValid () const
{
@@ -483,7 +488,6 @@ public:
// subclass and return a valie "const char *" given a "key". The value
// could also be a C string pointer, in which case just returning "key"
// will suffice.
-
virtual const char *
GetStringForKeyType (KeyType key) const = 0;
@@ -506,7 +510,6 @@ public:
// should be returned. If anything else goes wrong during parsing,
// return "eResultError" and the corresponding "Find()" function will
// be canceled and return false.
-
virtual Result
GetHashDataForName (const char *name,
lldb::offset_t* hash_data_offset_ptr,
@@ -518,7 +521,6 @@ public:
return m_header;
}
-
void
ForEach (std::function <bool(const HashData &hash_data)> const &callback) const
{
@@ -546,7 +548,6 @@ public:
const uint32_t *m_hash_values;
const uint32_t *m_hash_offsets;
};
-
};
-#endif // #ifndef liblldb_MappedHash_h_
+#endif // liblldb_MappedHash_h_
diff --git a/include/lldb/Core/Module.h b/include/lldb/Core/Module.h
index 127ddaeb9fd4..35b182aa9801 100644
--- a/include/lldb/Core/Module.h
+++ b/include/lldb/Core/Module.h
@@ -10,6 +10,14 @@
#ifndef liblldb_Module_h_
#define liblldb_Module_h_
+// C Includes
+// C++ Includes
+#include <atomic>
+#include <string>
+#include <vector>
+
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-forward.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/UUID.h"
@@ -17,6 +25,7 @@
#include "lldb/Host/Mutex.h"
#include "lldb/Host/TimeValue.h"
#include "lldb/Symbol/SymbolContextScope.h"
+#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/PathMappingList.h"
namespace lldb_private {
@@ -85,11 +94,11 @@ public:
/// module within a module (.a files and modules that contain
/// multiple architectures).
//------------------------------------------------------------------
- Module (const FileSpec& file_spec,
- const ArchSpec& arch,
- const ConstString *object_name = NULL,
- lldb::offset_t object_offset = 0,
- const TimeValue *object_mod_time_ptr = NULL);
+ Module(const FileSpec& file_spec,
+ const ArchSpec& arch,
+ const ConstString *object_name = nullptr,
+ lldb::offset_t object_offset = 0,
+ const TimeValue *object_mod_time_ptr = nullptr);
Module (const ModuleSpec &module_spec);
@@ -99,8 +108,7 @@ public:
//------------------------------------------------------------------
/// Destructor.
//------------------------------------------------------------------
- virtual
- ~Module ();
+ ~Module() override;
bool
MatchesModuleSpec (const ModuleSpec &module_ref);
@@ -154,11 +162,11 @@ public:
///
/// @see SymbolContextScope
//------------------------------------------------------------------
- virtual void
- CalculateSymbolContext (SymbolContext* sc);
+ void
+ CalculateSymbolContext(SymbolContext* sc) override;
- virtual lldb::ModuleSP
- CalculateSymbolContextModule ();
+ lldb::ModuleSP
+ CalculateSymbolContextModule() override;
void
GetDescription (Stream *s,
@@ -207,10 +215,9 @@ public:
///
/// @see SymbolContextScope
//------------------------------------------------------------------
- virtual void
- DumpSymbolContext (Stream *s);
+ void
+ DumpSymbolContext(Stream *s) override;
-
//------------------------------------------------------------------
/// Find a symbol in the object file's symbol table.
///
@@ -225,7 +232,7 @@ public:
///
/// @return
/// Returns a valid symbol pointer if a symbol was found,
- /// NULL otherwise.
+ /// nullptr otherwise.
//------------------------------------------------------------------
const Symbol *
FindFirstSymbolWithNameAndType (const ConstString &name,
@@ -288,7 +295,6 @@ public:
FindCompileUnits (const FileSpec &path,
bool append,
SymbolContextList &sc_list);
-
//------------------------------------------------------------------
/// Find functions by name.
@@ -323,7 +329,7 @@ public:
//------------------------------------------------------------------
size_t
FindFunctions (const ConstString &name,
- const ClangNamespaceDecl *namespace_decl,
+ const CompilerDeclContext *parent_decl_ctx,
uint32_t name_type_mask,
bool symbols_ok,
bool inlines_ok,
@@ -392,8 +398,8 @@ public:
/// The name of the global or static variable we are looking
/// for.
///
- /// @param[in] namespace_decl
- /// If valid, a namespace to search in.
+ /// @param[in] parent_decl_ctx
+ /// If valid, a decl context that results must exist within
///
/// @param[in] append
/// If \b true, any matches will be appended to \a
@@ -413,7 +419,7 @@ public:
//------------------------------------------------------------------
size_t
FindGlobalVariables (const ConstString &name,
- const ClangNamespaceDecl *namespace_decl,
+ const CompilerDeclContext *parent_decl_ctx,
bool append,
size_t max_matches,
VariableList& variable_list);
@@ -524,7 +530,7 @@ public:
size_t
FindTypesInNamespace (const SymbolContext& sc,
const ConstString &type_name,
- const ClangNamespaceDecl *namespace_decl,
+ const CompilerDeclContext *parent_decl_ctx,
size_t max_matches,
TypeList& type_list);
@@ -646,10 +652,10 @@ public:
IsLoadedInTarget (Target *target);
bool
- LoadScriptingResourceInTarget (Target *target,
- Error& error,
- Stream* feedback_stream = NULL);
-
+ LoadScriptingResourceInTarget(Target *target,
+ Error& error,
+ Stream* feedback_stream = nullptr);
+
//------------------------------------------------------------------
/// Get the number of compile units for this module.
///
@@ -682,7 +688,7 @@ public:
/// @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, NULL will be
+ /// 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.
@@ -730,7 +736,7 @@ public:
/// process.
///
/// @return
- /// The object file loaded from memory or NULL, if the operation
+ /// The object file loaded from memory or nullptr, if the operation
/// failed (see the `error` for more information in that case).
//------------------------------------------------------------------
ObjectFile *
@@ -747,20 +753,20 @@ public:
///
/// @return
/// If this module does not have a valid object file, or no
- /// plug-in can be found that can use the object file, NULL will
+ /// 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 = NULL);
+ lldb_private::Stream *feedback_strm = nullptr);
//------------------------------------------------------------------
/// Get accessor the type list for this module.
///
/// @return
- /// A valid type list pointer, or NULL if there is no valid
+ /// A valid type list pointer, or nullptr if there is no valid
/// symbol vendor for this module.
//------------------------------------------------------------------
TypeList*
@@ -935,7 +941,6 @@ public:
uint32_t
ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list);
-
void
SetFileSpecAndObjectName (const FileSpec &file,
const ConstString &object_name);
@@ -943,8 +948,8 @@ public:
bool
GetIsDynamicLinkEditor ();
- ClangASTContext &
- GetClangASTContext ();
+ TypeSystem *
+ GetTypeSystemForLanguage (lldb::LanguageType language);
// Special error functions that can do printf style formatting that will prepend the message with
// something appropriate for this module (like the architecture, path and object name (if any)).
@@ -1041,7 +1046,6 @@ public:
bool
RemapSourceFile (const char *path, std::string &new_path) const;
-
//------------------------------------------------------------------
/// Prepare to do a function name lookup.
///
@@ -1067,6 +1071,10 @@ public:
/// The mask of bits from lldb::FunctionNameType enumerations
/// that tell us what kind of name we are looking for.
///
+ /// @param[out] language
+ /// If known, the language to use for determining the
+ /// lookup_name_type_mask.
+ ///
/// @param[out] lookup_name
/// The actual name that will be used when calling
/// SymbolVendor::FindFunctions() or Symtab::FindFunctionSymbols()
@@ -1087,6 +1095,7 @@ public:
static void
PrepareForFunctionNameLookup (const ConstString &name,
uint32_t name_type_mask,
+ lldb::LanguageType language,
ConstString &lookup_name,
uint32_t &lookup_name_type_mask,
bool &match_name_after_lookup);
@@ -1110,17 +1119,16 @@ protected:
lldb::SymbolVendorUP m_symfile_ap; ///< A pointer to the symbol vendor for this module.
std::vector<lldb::SymbolVendorUP> m_old_symfiles; ///< If anyone calls Module::SetSymbolFileFileSpec() and changes the symbol file,
///< we need to keep all old symbol files around in case anyone has type references to them
- lldb::ClangASTContextUP m_ast; ///< The AST context for this module.
+ TypeSystemMap m_type_system_map; ///< A map of any type systems associated with this module
PathMappingList m_source_mappings; ///< Module specific source remappings for when you have debug info for a module that doesn't match where the sources currently are
lldb::SectionListUP m_sections_ap; ///< Unified section list for module that is used by the ObjectFile and and ObjectFile instances for the debug info
- bool m_did_load_objfile:1,
- m_did_load_symbol_vendor:1,
- m_did_parse_uuid:1,
- m_did_init_ast:1;
+ std::atomic<bool> m_did_load_objfile;
+ std::atomic<bool> m_did_load_symbol_vendor;
+ std::atomic<bool> m_did_parse_uuid;
mutable bool m_file_has_changed:1,
m_first_file_changed_log:1; /// See if the module was modified after it was initially opened.
-
+
//------------------------------------------------------------------
/// Resolve a file or load virtual address.
///
@@ -1178,21 +1186,19 @@ protected:
friend class SymbolFile;
private:
-
Module (); // Only used internally by CreateJITModule ()
size_t
FindTypes_Impl (const SymbolContext& sc,
const ConstString &name,
- const ClangNamespaceDecl *namespace_decl,
+ const CompilerDeclContext *parent_decl_ctx,
bool append,
size_t max_matches,
- TypeList& types);
+ TypeMap& types);
-
DISALLOW_COPY_AND_ASSIGN (Module);
};
} // namespace lldb_private
-#endif // liblldb_Module_h_
+#endif // liblldb_Module_h_
diff --git a/include/lldb/Core/ModuleList.h b/include/lldb/Core/ModuleList.h
index f4c12cf168ac..a0dd43263a2c 100644
--- a/include/lldb/Core/ModuleList.h
+++ b/include/lldb/Core/ModuleList.h
@@ -10,10 +10,14 @@
#ifndef liblldb_ModuleList_h_
#define liblldb_ModuleList_h_
-#include <vector>
-#include <list>
+// C Includes
+// C++ Includes
#include <functional>
+#include <list>
+#include <vector>
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Utility/Iterable.h"
@@ -30,10 +34,12 @@ namespace lldb_private {
class ModuleList
{
public:
-
class Notifier
{
public:
+ virtual
+ ~Notifier() = default;
+
virtual void
ModuleAdded (const ModuleList& module_list, const lldb::ModuleSP& module_sp) = 0;
virtual void
@@ -43,10 +49,6 @@ public:
const lldb::ModuleSP& new_module_sp) = 0;
virtual void
WillClearList (const ModuleList& module_list) = 0;
-
- virtual
- ~Notifier ()
- {}
};
//------------------------------------------------------------------
@@ -144,6 +146,7 @@ public:
//------------------------------------------------------------------
void
Destroy();
+
//------------------------------------------------------------------
/// Dump the description of each module contained in this list.
///
@@ -209,7 +212,7 @@ public:
/// An index into this module collection.
///
/// @return
- /// A pointer to a Module which can by NULL if \a idx is out
+ /// A pointer to a Module which can by nullptr if \a idx is out
/// of range.
///
/// @see ModuleList::GetSize()
@@ -226,7 +229,7 @@ public:
/// An index into this module collection.
///
/// @return
- /// A pointer to a Module which can by NULL if \a idx is out
+ /// A pointer to a Module which can by nullptr if \a idx is out
/// of range.
///
/// @see ModuleList::GetSize()
@@ -534,10 +537,10 @@ public:
GetSize () const;
bool
- LoadScriptingResourcesInTarget (Target *target,
- std::list<Error>& errors,
- Stream* feedback_stream = NULL,
- bool continue_on_error = true);
+ LoadScriptingResourcesInTarget(Target *target,
+ std::list<Error>& errors,
+ Stream* feedback_stream = nullptr,
+ bool continue_on_error = true);
static bool
ModuleIsInCache (const Module *module_ptr);
@@ -606,9 +609,8 @@ public:
{
return ModuleIterableNoLocking(m_modules);
}
-
};
} // namespace lldb_private
-#endif // liblldb_ModuleList_h_
+#endif // liblldb_ModuleList_h_
diff --git a/include/lldb/Core/ModuleSpec.h b/include/lldb/Core/ModuleSpec.h
index be7041981a0a..95de7f375736 100644
--- a/include/lldb/Core/ModuleSpec.h
+++ b/include/lldb/Core/ModuleSpec.h
@@ -10,6 +10,12 @@
#ifndef liblldb_ModuleSpec_h_
#define liblldb_ModuleSpec_h_
+// C Includes
+// C++ Includes
+#include <vector>
+
+// Other libraries and framework includes
+// Project includes
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/UUID.h"
@@ -100,17 +106,13 @@ public:
FileSpec *
GetFileSpecPtr ()
{
- if (m_file)
- return &m_file;
- return NULL;
+ return (m_file ? &m_file : nullptr);
}
const FileSpec *
GetFileSpecPtr () const
{
- if (m_file)
- return &m_file;
- return NULL;
+ return (m_file ? &m_file : nullptr);
}
FileSpec &
@@ -118,6 +120,7 @@ public:
{
return m_file;
}
+
const FileSpec &
GetFileSpec () const
{
@@ -127,17 +130,13 @@ public:
FileSpec *
GetPlatformFileSpecPtr ()
{
- if (m_platform_file)
- return &m_platform_file;
- return NULL;
+ return (m_platform_file ? &m_platform_file : nullptr);
}
const FileSpec *
GetPlatformFileSpecPtr () const
{
- if (m_platform_file)
- return &m_platform_file;
- return NULL;
+ return (m_platform_file ? &m_platform_file : nullptr);
}
FileSpec &
@@ -155,17 +154,13 @@ public:
FileSpec *
GetSymbolFileSpecPtr ()
{
- if (m_symbol_file)
- return &m_symbol_file;
- return NULL;
+ return (m_symbol_file ? &m_symbol_file : nullptr);
}
const FileSpec *
GetSymbolFileSpecPtr () const
{
- if (m_symbol_file)
- return &m_symbol_file;
- return NULL;
+ return (m_symbol_file ? &m_symbol_file : nullptr);
}
FileSpec &
@@ -180,21 +175,16 @@ public:
return m_symbol_file;
}
-
ArchSpec *
GetArchitecturePtr ()
{
- if (m_arch.IsValid())
- return &m_arch;
- return NULL;
+ return (m_arch.IsValid() ? &m_arch : nullptr);
}
const ArchSpec *
GetArchitecturePtr () const
{
- if (m_arch.IsValid())
- return &m_arch;
- return NULL;
+ return (m_arch.IsValid() ? &m_arch : nullptr);
}
ArchSpec &
@@ -212,17 +202,13 @@ public:
UUID *
GetUUIDPtr ()
{
- if (m_uuid.IsValid())
- return &m_uuid;
- return NULL;
+ return (m_uuid.IsValid() ? &m_uuid : nullptr);
}
const UUID *
GetUUIDPtr () const
{
- if (m_uuid.IsValid())
- return &m_uuid;
- return NULL;
+ return (m_uuid.IsValid() ? &m_uuid : nullptr);
}
UUID &
@@ -306,7 +292,6 @@ public:
m_object_mod_time.Clear();
}
-
explicit operator bool () const
{
if (m_file)
@@ -329,7 +314,7 @@ public:
}
void
- Dump (Stream &strm)
+ Dump (Stream &strm) const
{
bool dumped_something = false;
if (m_file)
@@ -361,7 +346,8 @@ public:
{
if (dumped_something)
strm.PutCString(", ");
- strm.Printf("arch = %s", m_arch.GetTriple().str().c_str());
+ strm.Printf("arch = ");
+ m_arch.DumpTriple(strm);
dumped_something = true;
}
if (m_uuid.IsValid())
@@ -476,9 +462,7 @@ public:
m_specs = rhs.m_specs;
}
- ~ModuleSpecList ()
- {
- }
+ ~ModuleSpecList() = default;
ModuleSpecList &
operator = (const ModuleSpecList &rhs)
@@ -528,6 +512,7 @@ public:
{
return m_specs[i];
}
+
bool
GetModuleSpecAtIndex (size_t i, ModuleSpec &module_spec) const
{
@@ -540,8 +525,7 @@ public:
module_spec.Clear();
return false;
}
-
-
+
bool
FindMatchingModuleSpec (const ModuleSpec &module_spec, ModuleSpec &match_module_spec) const
{
@@ -620,4 +604,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_ModuleSpec_h_
+#endif // liblldb_ModuleSpec_h_
diff --git a/include/lldb/Core/Opcode.h b/include/lldb/Core/Opcode.h
index 57b8077477ce..eac0746baba1 100644
--- a/include/lldb/Core/Opcode.h
+++ b/include/lldb/Core/Opcode.h
@@ -16,6 +16,7 @@
// C++ Includes
// Other libraries and framework includes
#include "llvm/Support/MathExtras.h"
+
// Project includes
#include "lldb/Host/Endian.h"
#include "lldb/lldb-public.h"
@@ -23,7 +24,7 @@
namespace lldb
{
class SBInstruction;
-}
+} // namespace lldb
namespace lldb_private {
@@ -76,6 +77,7 @@ namespace lldb_private {
m_byte_order = lldb::eByteOrderInvalid;
m_type = Opcode::eTypeInvalid;
}
+
Opcode::Type
GetType () const
{
@@ -189,7 +191,7 @@ namespace lldb_private {
void
SetOpcodeBytes (const void *bytes, size_t length)
{
- if (bytes && length > 0)
+ if (bytes != nullptr && length > 0)
{
m_type = eTypeBytes;
m_data.inst.length = length;
@@ -210,9 +212,7 @@ namespace lldb_private {
const void *
GetOpcodeBytes () const
{
- if (m_type == Opcode::eTypeBytes)
- return m_data.inst.bytes;
- return NULL;
+ return ((m_type == Opcode::eTypeBytes) ? m_data.inst.bytes : nullptr);
}
uint32_t
@@ -252,7 +252,7 @@ namespace lldb_private {
case Opcode::eType64: return &m_data.inst64;
case Opcode::eTypeBytes: return m_data.inst.bytes;
}
- return NULL;
+ return nullptr;
}
lldb::ByteOrder
@@ -261,8 +261,8 @@ namespace lldb_private {
bool
GetEndianSwap() const
{
- return (m_byte_order == lldb::eByteOrderBig && lldb::endian::InlHostByteOrder() == lldb::eByteOrderLittle) ||
- (m_byte_order == lldb::eByteOrderLittle && lldb::endian::InlHostByteOrder() == lldb::eByteOrderBig);
+ return (m_byte_order == lldb::eByteOrderBig && endian::InlHostByteOrder() == lldb::eByteOrderLittle) ||
+ (m_byte_order == lldb::eByteOrderLittle && endian::InlHostByteOrder() == lldb::eByteOrderBig);
}
lldb::ByteOrder m_byte_order;
@@ -284,4 +284,4 @@ namespace lldb_private {
} // namespace lldb_private
-#endif // lldb_Opcode_h
+#endif // lldb_Opcode_h
diff --git a/include/lldb/Core/PluginManager.h b/include/lldb/Core/PluginManager.h
index af940d788ab0..6f8001fbfd2b 100644
--- a/include/lldb/Core/PluginManager.h
+++ b/include/lldb/Core/PluginManager.h
@@ -7,10 +7,13 @@
//
//===----------------------------------------------------------------------===//
-
#ifndef liblldb_PluginManager_h_
#define liblldb_PluginManager_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Host/FileSpec.h"
@@ -42,7 +45,6 @@ public:
static ABICreateInstance
GetABICreateCallbackForPluginName (const ConstString &name);
-
//------------------------------------------------------------------
// Disassembler
//------------------------------------------------------------------
@@ -60,15 +62,14 @@ public:
static DisassemblerCreateInstance
GetDisassemblerCreateCallbackForPluginName (const ConstString &name);
-
//------------------------------------------------------------------
// DynamicLoader
//------------------------------------------------------------------
static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- DynamicLoaderCreateInstance create_callback,
- DebuggerInitializeCallback debugger_init_callback = NULL);
+ RegisterPlugin(const ConstString &name,
+ const char *description,
+ DynamicLoaderCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback = nullptr);
static bool
UnregisterPlugin (DynamicLoaderCreateInstance create_callback);
@@ -83,10 +84,10 @@ public:
// JITLoader
//------------------------------------------------------------------
static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- JITLoaderCreateInstance create_callback,
- DebuggerInitializeCallback debugger_init_callback = NULL);
+ RegisterPlugin(const ConstString &name,
+ const char *description,
+ JITLoaderCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback = nullptr);
static bool
UnregisterPlugin (JITLoaderCreateInstance create_callback);
@@ -117,11 +118,10 @@ public:
//------------------------------------------------------------------
// OperatingSystem
//------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- OperatingSystemCreateInstance create_callback);
-
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ OperatingSystemCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback);
+
static bool
UnregisterPlugin (OperatingSystemCreateInstance create_callback);
@@ -132,6 +132,23 @@ public:
GetOperatingSystemCreateCallbackForPluginName (const ConstString &name);
//------------------------------------------------------------------
+ // Language
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin (const ConstString &name,
+ const char *description,
+ LanguageCreateInstance create_callback);
+
+ static bool
+ UnregisterPlugin (LanguageCreateInstance create_callback);
+
+ static LanguageCreateInstance
+ GetLanguageCreateCallbackAtIndex (uint32_t idx);
+
+ static LanguageCreateInstance
+ GetLanguageCreateCallbackForPluginName (const ConstString &name);
+
+ //------------------------------------------------------------------
// LanguageRuntime
//------------------------------------------------------------------
static bool
@@ -152,7 +169,6 @@ public:
static LanguageRuntimeCreateInstance
GetLanguageRuntimeCreateCallbackForPluginName (const ConstString &name);
-
//------------------------------------------------------------------
// SystemRuntime
//------------------------------------------------------------------
@@ -170,17 +186,16 @@ public:
static SystemRuntimeCreateInstance
GetSystemRuntimeCreateCallbackForPluginName (const ConstString &name);
-
//------------------------------------------------------------------
// ObjectFile
//------------------------------------------------------------------
static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- ObjectFileCreateInstance create_callback,
- ObjectFileCreateMemoryInstance create_memory_callback,
- ObjectFileGetModuleSpecifications get_module_specifications,
- ObjectFileSaveCore save_core = NULL);
+ RegisterPlugin(const ConstString &name,
+ const char *description,
+ ObjectFileCreateInstance create_callback,
+ ObjectFileCreateMemoryInstance create_memory_callback,
+ ObjectFileGetModuleSpecifications get_module_specifications,
+ ObjectFileSaveCore save_core = nullptr);
static bool
UnregisterPlugin (ObjectFileCreateInstance create_callback);
@@ -248,10 +263,10 @@ public:
// Platform
//------------------------------------------------------------------
static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- PlatformCreateInstance create_callback,
- DebuggerInitializeCallback debugger_init_callback = NULL);
+ RegisterPlugin(const ConstString &name,
+ const char *description,
+ PlatformCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback = nullptr);
static bool
UnregisterPlugin (PlatformCreateInstance create_callback);
@@ -275,10 +290,10 @@ public:
// Process
//------------------------------------------------------------------
static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- ProcessCreateInstance create_callback,
- DebuggerInitializeCallback debugger_init_callback = NULL);
+ RegisterPlugin(const ConstString &name,
+ const char *description,
+ ProcessCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback = nullptr);
static bool
UnregisterPlugin (ProcessCreateInstance create_callback);
@@ -296,12 +311,30 @@ public:
GetProcessPluginDescriptionAtIndex (uint32_t idx);
//------------------------------------------------------------------
+ // ScriptInterpreter
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description, lldb::ScriptLanguage script_lang,
+ ScriptInterpreterCreateInstance create_callback);
+
+ static bool
+ UnregisterPlugin(ScriptInterpreterCreateInstance create_callback);
+
+ static ScriptInterpreterCreateInstance
+ GetScriptInterpreterCreateCallbackAtIndex(uint32_t idx);
+
+ static lldb::ScriptInterpreterSP
+ GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang,
+ CommandInterpreter &interpreter);
+
+ //------------------------------------------------------------------
// SymbolFile
//------------------------------------------------------------------
static bool
RegisterPlugin (const ConstString &name,
const char *description,
- SymbolFileCreateInstance create_callback);
+ SymbolFileCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback = nullptr);
static bool
UnregisterPlugin (SymbolFileCreateInstance create_callback);
@@ -312,7 +345,6 @@ public:
static SymbolFileCreateInstance
GetSymbolFileCreateCallbackForPluginName (const ConstString &name);
-
//------------------------------------------------------------------
// SymbolVendor
//------------------------------------------------------------------
@@ -385,6 +417,53 @@ public:
static InstrumentationRuntimeCreateInstance
GetInstrumentationRuntimeCreateCallbackForPluginName (const ConstString &name);
+ //------------------------------------------------------------------
+ // TypeSystem
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin (const ConstString &name,
+ const char *description,
+ TypeSystemCreateInstance create_callback,
+ TypeSystemEnumerateSupportedLanguages enumerate_languages_callback);
+
+ static bool
+ UnregisterPlugin (TypeSystemCreateInstance create_callback);
+
+ static TypeSystemCreateInstance
+ GetTypeSystemCreateCallbackAtIndex (uint32_t idx);
+
+ static TypeSystemCreateInstance
+ GetTypeSystemCreateCallbackForPluginName (const ConstString &name);
+
+ static TypeSystemEnumerateSupportedLanguages
+ GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx);
+
+ static TypeSystemEnumerateSupportedLanguages
+ GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName (const ConstString &name);
+
+ //------------------------------------------------------------------
+ // REPL
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin (const ConstString &name,
+ const char *description,
+ REPLCreateInstance create_callback,
+ REPLEnumerateSupportedLanguages enumerate_languages_callback);
+
+ static bool
+ UnregisterPlugin (REPLCreateInstance create_callback);
+
+ static REPLCreateInstance
+ GetREPLCreateCallbackAtIndex (uint32_t idx);
+
+ static REPLCreateInstance
+ GetREPLCreateCallbackForPluginName (const ConstString &name);
+
+ static REPLEnumerateSupportedLanguages
+ GetREPLEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx);
+
+ static REPLEnumerateSupportedLanguages
+ GetREPLSystemEnumerateSupportedLanguagesCallbackForPluginName (const ConstString &name);
//------------------------------------------------------------------
// Some plug-ins might register a DebuggerInitializeCallback
@@ -419,16 +498,41 @@ public:
static lldb::OptionValuePropertiesSP
GetSettingForProcessPlugin (Debugger &debugger,
const ConstString &setting_name);
-
+
static bool
CreateSettingForProcessPlugin (Debugger &debugger,
const lldb::OptionValuePropertiesSP &properties_sp,
const ConstString &description,
bool is_global_property);
-};
+ static lldb::OptionValuePropertiesSP
+ GetSettingForSymbolFilePlugin (Debugger &debugger,
+ const ConstString &setting_name);
+
+ static bool
+ CreateSettingForSymbolFilePlugin (Debugger &debugger,
+ const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description,
+ bool is_global_property);
+
+ static lldb::OptionValuePropertiesSP
+ GetSettingForJITLoaderPlugin (Debugger &debugger,
+ const ConstString &setting_name);
+ static bool
+ CreateSettingForJITLoaderPlugin (Debugger &debugger,
+ const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description,
+ bool is_global_property);
+
+ static lldb::OptionValuePropertiesSP GetSettingForOperatingSystemPlugin(Debugger &debugger,
+ const ConstString &setting_name);
+
+ static bool CreateSettingForOperatingSystemPlugin(Debugger &debugger,
+ const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description, bool is_global_property);
+};
} // namespace lldb_private
-#endif // liblldb_PluginManager_h_
+#endif // liblldb_PluginManager_h_
diff --git a/include/lldb/Core/RangeMap.h b/include/lldb/Core/RangeMap.h
index d2c43a5d794d..b2e3f06f08a9 100644
--- a/include/lldb/Core/RangeMap.h
+++ b/include/lldb/Core/RangeMap.h
@@ -10,16 +10,21 @@
#ifndef liblldb_RangeMap_h_
#define liblldb_RangeMap_h_
+// C Includes
+// C++ Includes
+#include <algorithm>
#include <vector>
-#include "lldb/lldb-private.h"
+// Other libraries and framework includes
#include "llvm/ADT/SmallVector.h"
+// Project includes
+#include "lldb/lldb-private.h"
+
// Uncomment to make sure all Range objects are sorted when needed
//#define ASSERT_RANGEMAP_ARE_SORTED
namespace lldb_private {
-
//----------------------------------------------------------------------
// Templatized classes for dealing with generic ranges and also
@@ -187,16 +192,11 @@ namespace lldb_private {
typedef S SizeType;
typedef Range<B,S> Entry;
typedef llvm::SmallVector<Entry, N> Collection;
-
- RangeArray () :
- m_entries ()
- {
- }
-
- ~RangeArray()
- {
- }
-
+
+ RangeArray() = default;
+
+ ~RangeArray() = default;
+
void
Append (const Entry &entry)
{
@@ -236,6 +236,7 @@ namespace lldb_private {
return true;
}
#endif
+
void
CombineConsecutiveRanges ()
{
@@ -281,7 +282,6 @@ namespace lldb_private {
}
}
-
BaseType
GetMinRangeBase (BaseType fail_value) const
{
@@ -337,9 +337,7 @@ namespace lldb_private {
const Entry *
GetEntryAtIndex (size_t i) const
{
- if (i<m_entries.size())
- return &m_entries[i];
- return NULL;
+ return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
}
// Clients must ensure that "i" is a valid index prior to calling this function
@@ -352,17 +350,13 @@ namespace lldb_private {
Entry *
Back()
{
- if (m_entries.empty())
- return NULL;
- return &m_entries.back();
+ return (m_entries.empty() ? nullptr : &m_entries.back());
}
const Entry *
Back() const
{
- if (m_entries.empty())
- return NULL;
- return &m_entries.back();
+ return (m_entries.empty() ? nullptr : &m_entries.back());
}
static bool
@@ -424,7 +418,7 @@ namespace lldb_private {
}
}
}
- return NULL;
+ return nullptr;
}
const Entry *
@@ -452,7 +446,7 @@ namespace lldb_private {
}
}
}
- return NULL;
+ return nullptr;
}
protected:
@@ -467,16 +461,11 @@ namespace lldb_private {
typedef S SizeType;
typedef Range<B,S> Entry;
typedef std::vector<Entry> Collection;
-
- RangeVector () :
- m_entries ()
- {
- }
-
- ~RangeVector()
- {
- }
-
+
+ RangeVector() = default;
+
+ ~RangeVector() = default;
+
void
Append (const Entry &entry)
{
@@ -516,6 +505,7 @@ namespace lldb_private {
return true;
}
#endif
+
void
CombineConsecutiveRanges ()
{
@@ -560,8 +550,7 @@ namespace lldb_private {
}
}
}
-
-
+
BaseType
GetMinRangeBase (BaseType fail_value) const
{
@@ -623,9 +612,7 @@ namespace lldb_private {
const Entry *
GetEntryAtIndex (size_t i) const
{
- if (i<m_entries.size())
- return &m_entries[i];
- return NULL;
+ return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
}
// Clients must ensure that "i" is a valid index prior to calling this function
@@ -638,17 +625,13 @@ namespace lldb_private {
Entry *
Back()
{
- if (m_entries.empty())
- return NULL;
- return &m_entries.back();
+ return (m_entries.empty() ? nullptr : &m_entries.back());
}
const Entry *
Back() const
{
- if (m_entries.empty())
- return NULL;
- return &m_entries.back();
+ return (m_entries.empty() ? nullptr : &m_entries.back());
}
static bool
@@ -710,7 +693,7 @@ namespace lldb_private {
}
}
}
- return NULL;
+ return nullptr;
}
const Entry *
@@ -738,7 +721,7 @@ namespace lldb_private {
}
}
}
- return NULL;
+ return nullptr;
}
protected:
@@ -812,15 +795,10 @@ namespace lldb_private {
typedef RangeData<B,S,T> Entry;
typedef llvm::SmallVector<Entry, N> Collection;
+ RangeDataArray() = default;
+
+ ~RangeDataArray() = default;
- RangeDataArray ()
- {
- }
-
- ~RangeDataArray()
- {
- }
-
void
Append (const Entry &entry)
{
@@ -911,9 +889,7 @@ namespace lldb_private {
const Entry *
GetEntryAtIndex (size_t i) const
{
- if (i<m_entries.size())
- return &m_entries[i];
- return NULL;
+ return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
}
// Clients must ensure that "i" is a valid index prior to calling this function
@@ -984,8 +960,9 @@ namespace lldb_private {
}
}
}
- return NULL;
+ return nullptr;
}
+
const Entry *
FindEntryThatContains (B addr) const
{
@@ -1014,7 +991,7 @@ namespace lldb_private {
}
}
}
- return NULL;
+ return nullptr;
}
const Entry *
@@ -1042,23 +1019,19 @@ namespace lldb_private {
}
}
}
- return NULL;
+ return nullptr;
}
Entry *
Back()
{
- if (!m_entries.empty())
- return &m_entries.back();
- return NULL;
+ return (m_entries.empty() ? nullptr : &m_entries.back());
}
const Entry *
Back() const
{
- if (!m_entries.empty())
- return &m_entries.back();
- return NULL;
+ return (m_entries.empty() ? nullptr : &m_entries.back());
}
protected:
@@ -1073,15 +1046,11 @@ namespace lldb_private {
public:
typedef RangeData<B,S,T> Entry;
typedef std::vector<Entry> Collection;
-
- RangeDataVector ()
- {
- }
-
- ~RangeDataVector()
- {
- }
-
+
+ RangeDataVector() = default;
+
+ ~RangeDataVector() = default;
+
void
Append (const Entry &entry)
{
@@ -1181,7 +1150,6 @@ namespace lldb_private {
}
}
}
-
}
void
@@ -1211,9 +1179,7 @@ namespace lldb_private {
const Entry *
GetEntryAtIndex (size_t i) const
{
- if (i<m_entries.size())
- return &m_entries[i];
- return NULL;
+ return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
}
// Clients must ensure that "i" is a valid index prior to calling this function
@@ -1272,8 +1238,9 @@ namespace lldb_private {
if (pos != end && pos->Contains(addr))
return &(*pos);
}
- return NULL;
+ return nullptr;
}
+
const Entry *
FindEntryThatContains (B addr) const
{
@@ -1295,7 +1262,7 @@ namespace lldb_private {
if (pos != end && pos->Contains(addr))
return &(*pos);
}
- return NULL;
+ return nullptr;
}
const Entry *
@@ -1316,30 +1283,25 @@ namespace lldb_private {
if (pos != end && pos->Contains(range))
return &(*pos);
}
- return NULL;
+ return nullptr;
}
Entry *
Back()
{
- if (!m_entries.empty())
- return &m_entries.back();
- return NULL;
+ return (m_entries.empty() ? nullptr : &m_entries.back());
}
const Entry *
Back() const
{
- if (!m_entries.empty())
- return &m_entries.back();
- return NULL;
+ return (m_entries.empty() ? nullptr : &m_entries.back());
}
protected:
Collection m_entries;
};
-
-
+
//----------------------------------------------------------------------
// A simple range with data class where you get to define the type of
// the range base "B", the type used for the range byte size "S", and
@@ -1389,7 +1351,6 @@ namespace lldb_private {
}
};
-
template <typename B, typename T, unsigned N>
class AddressDataArray
{
@@ -1397,15 +1358,10 @@ namespace lldb_private {
typedef AddressData<B,T> Entry;
typedef llvm::SmallVector<Entry, N> Collection;
+ AddressDataArray() = default;
+
+ ~AddressDataArray() = default;
- AddressDataArray ()
- {
- }
-
- ~AddressDataArray()
- {
- }
-
void
Append (const Entry &entry)
{
@@ -1456,9 +1412,7 @@ namespace lldb_private {
const Entry *
GetEntryAtIndex (size_t i) const
{
- if (i<m_entries.size())
- return &m_entries[i];
- return NULL;
+ return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
}
// Clients must ensure that "i" is a valid index prior to calling this function
@@ -1497,7 +1451,7 @@ namespace lldb_private {
return &(*pos);
}
}
- return NULL;
+ return nullptr;
}
const Entry *
@@ -1505,23 +1459,19 @@ namespace lldb_private {
{
if (entry >= &*m_entries.begin() && entry + 1 < &*m_entries.end())
return entry + 1;
- return NULL;
+ return nullptr;
}
Entry *
Back()
{
- if (!m_entries.empty())
- return &m_entries.back();
- return NULL;
+ return (m_entries.empty() ? nullptr : &m_entries.back());
}
const Entry *
Back() const
{
- if (!m_entries.empty())
- return &m_entries.back();
- return NULL;
+ return (m_entries.empty() ? nullptr : &m_entries.back());
}
protected:
@@ -1530,4 +1480,4 @@ namespace lldb_private {
} // namespace lldb_private
-#endif // liblldb_RangeMap_h_
+#endif // liblldb_RangeMap_h_
diff --git a/include/lldb/Core/RegisterValue.h b/include/lldb/Core/RegisterValue.h
index 1b1a71a11c5a..030b849212c4 100644
--- a/include/lldb/Core/RegisterValue.h
+++ b/include/lldb/Core/RegisterValue.h
@@ -1,4 +1,4 @@
-//===-- RegisterValue.h ------------------------------------------*- C++ -*-===//
+//===-- RegisterValue.h -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -15,12 +15,14 @@
// C++ Includes
// Other libraries and framework includes
+#include "llvm/ADT/APInt.h"
+
// Project includes
#include "lldb/lldb-public.h"
#include "lldb/lldb-private.h"
#include "lldb/Host/Endian.h"
+#include "lldb/Core/Scalar.h"
-//#define ENABLE_128_BIT_SUPPORT 1
namespace lldb_private {
class RegisterValue
@@ -30,6 +32,7 @@ namespace lldb_private {
{
kMaxRegisterByteSize = 32u
};
+
enum Type
{
eTypeInvalid,
@@ -37,9 +40,7 @@ namespace lldb_private {
eTypeUInt16,
eTypeUInt32,
eTypeUInt64,
-#if defined (ENABLE_128_BIT_SUPPORT)
eTypeUInt128,
-#endif
eTypeFloat,
eTypeDouble,
eTypeLongDouble,
@@ -47,7 +48,8 @@ namespace lldb_private {
};
RegisterValue () :
- m_type (eTypeInvalid)
+ m_type (eTypeInvalid),
+ m_scalar ((unsigned long)0)
{
}
@@ -55,57 +57,56 @@ namespace lldb_private {
RegisterValue (uint8_t inst) :
m_type (eTypeUInt8)
{
- m_data.uint8 = inst;
+ m_scalar = inst;
}
explicit
RegisterValue (uint16_t inst) :
m_type (eTypeUInt16)
{
- m_data.uint16 = inst;
+ m_scalar = inst;
}
explicit
RegisterValue (uint32_t inst) :
m_type (eTypeUInt32)
{
- m_data.uint32 = inst;
+ m_scalar = inst;
}
explicit
RegisterValue (uint64_t inst) :
m_type (eTypeUInt64)
{
- m_data.uint64 = inst;
+ m_scalar = inst;
}
-#if defined (ENABLE_128_BIT_SUPPORT)
explicit
- RegisterValue (__uint128_t inst) :
+ RegisterValue (llvm::APInt inst) :
m_type (eTypeUInt128)
{
- m_data.uint128 = inst;
+ m_scalar = llvm::APInt(inst);
}
-#endif
+
explicit
RegisterValue (float value) :
m_type (eTypeFloat)
{
- m_data.ieee_float = value;
+ m_scalar = value;
}
explicit
RegisterValue (double value) :
m_type (eTypeDouble)
{
- m_data.ieee_double = value;
+ m_scalar = value;
}
explicit
RegisterValue (long double value) :
m_type (eTypeLongDouble)
{
- m_data.ieee_long_double = value;
+ m_scalar = value;
}
explicit
@@ -161,13 +162,13 @@ namespace lldb_private {
GetScalarValue (Scalar &scalar) const;
uint8_t
- GetAsUInt8 (uint8_t fail_value = UINT8_MAX, bool *success_ptr = NULL) const
+ GetAsUInt8(uint8_t fail_value = UINT8_MAX, bool *success_ptr = nullptr) const
{
if (m_type == eTypeUInt8)
{
if (success_ptr)
*success_ptr = true;
- return m_data.uint8;
+ return m_scalar.UChar(fail_value);
}
if (success_ptr)
*success_ptr = true;
@@ -175,27 +176,25 @@ namespace lldb_private {
}
uint16_t
- GetAsUInt16 (uint16_t fail_value = UINT16_MAX, bool *success_ptr = NULL) const;
+ GetAsUInt16(uint16_t fail_value = UINT16_MAX, bool *success_ptr = nullptr) const;
uint32_t
- GetAsUInt32 (uint32_t fail_value = UINT32_MAX, bool *success_ptr = NULL) const;
+ GetAsUInt32(uint32_t fail_value = UINT32_MAX, bool *success_ptr = nullptr) const;
uint64_t
- GetAsUInt64 (uint64_t fail_value = UINT64_MAX, bool *success_ptr = NULL) const;
+ GetAsUInt64(uint64_t fail_value = UINT64_MAX, bool *success_ptr = nullptr) const;
-#if defined (ENABLE_128_BIT_SUPPORT)
- __uint128_t
- GetAsUInt128 (__uint128_t fail_value = ~((__uint128_t)0), bool *success_ptr = NULL) const;
-#endif
+ llvm::APInt
+ GetAsUInt128(const llvm::APInt& fail_value, bool *success_ptr = nullptr) const;
float
- GetAsFloat (float fail_value = 0.0f, bool *success_ptr = NULL) const;
+ GetAsFloat(float fail_value = 0.0f, bool *success_ptr = nullptr) const;
double
- GetAsDouble (double fail_value = 0.0, bool *success_ptr = NULL) const;
+ GetAsDouble(double fail_value = 0.0, bool *success_ptr = nullptr) const;
long double
- GetAsLongDouble (long double fail_value = 0.0, bool *success_ptr = NULL) const;
+ GetAsLongDouble(long double fail_value = 0.0, bool *success_ptr = nullptr) const;
void
SetValueToInvalid ()
@@ -219,95 +218,93 @@ namespace lldb_private {
operator = (uint8_t uint)
{
m_type = eTypeUInt8;
- m_data.uint8 = uint;
+ m_scalar = uint;
}
void
operator = (uint16_t uint)
{
m_type = eTypeUInt16;
- m_data.uint16 = uint;
+ m_scalar = uint;
}
void
operator = (uint32_t uint)
{
m_type = eTypeUInt32;
- m_data.uint32 = uint;
+ m_scalar = uint;
}
void
operator = (uint64_t uint)
{
m_type = eTypeUInt64;
- m_data.uint64 = uint;
+ m_scalar = uint;
}
-#if defined (ENABLE_128_BIT_SUPPORT)
void
- operator = (__uint128_t uint)
+ operator = (llvm::APInt uint)
{
m_type = eTypeUInt128;
- m_data.uint128 = uint;
+ m_scalar = llvm::APInt(uint);
}
-#endif
+
void
operator = (float f)
{
m_type = eTypeFloat;
- m_data.ieee_float = f;
+ m_scalar = f;
}
void
operator = (double f)
{
m_type = eTypeDouble;
- m_data.ieee_double = f;
+ m_scalar = f;
}
void
operator = (long double f)
{
m_type = eTypeLongDouble;
- m_data.ieee_long_double = f;
+ m_scalar = f;
}
void
SetUInt8 (uint8_t uint)
{
m_type = eTypeUInt8;
- m_data.uint8 = uint;
+ m_scalar = uint;
}
void
SetUInt16 (uint16_t uint)
{
m_type = eTypeUInt16;
- m_data.uint16 = uint;
+ m_scalar = uint;
}
void
SetUInt32 (uint32_t uint, Type t = eTypeUInt32)
{
m_type = t;
- m_data.uint32 = uint;
+ m_scalar = uint;
}
void
SetUInt64 (uint64_t uint, Type t = eTypeUInt64)
{
m_type = t;
- m_data.uint64 = uint;
+ m_scalar = uint;
}
-#if defined (ENABLE_128_BIT_SUPPORT)
void
- SetUInt128 (__uint128_t uint)
+ SetUInt128 (llvm::APInt uint)
{
m_type = eTypeUInt128;
- m_data.uint128 = uint;
+ m_scalar = uint;
}
-#endif
+
bool
SetUInt (uint64_t uint, uint32_t byte_size);
@@ -315,21 +312,21 @@ namespace lldb_private {
SetFloat (float f)
{
m_type = eTypeFloat;
- m_data.ieee_float = f;
+ m_scalar = f;
}
void
SetDouble (double f)
{
m_type = eTypeDouble;
- m_data.ieee_double = f;
+ m_scalar = f;
}
void
SetLongDouble (long double f)
{
m_type = eTypeLongDouble;
- m_data.ieee_long_double = f;
+ m_scalar = f;
}
void
@@ -367,8 +364,8 @@ namespace lldb_private {
GetByteOrder () const
{
if (m_type == eTypeBytes)
- return m_data.buffer.byte_order;
- return lldb::endian::InlHostByteOrder();
+ return buffer.byte_order;
+ return endian::InlHostByteOrder();
}
uint32_t
@@ -384,29 +381,17 @@ namespace lldb_private {
Clear();
protected:
-
RegisterValue::Type m_type;
- union
- {
- uint8_t uint8;
- uint16_t uint16;
- uint32_t uint32;
- uint64_t uint64;
-#if defined (ENABLE_128_BIT_SUPPORT)
- __uint128_t uint128;
-#endif
- float ieee_float;
- double ieee_double;
- long double ieee_long_double;
- struct
- {
- uint8_t bytes[kMaxRegisterByteSize]; // This must be big enough to hold any register for any supported target.
- uint8_t length;
- lldb::ByteOrder byte_order;
- } buffer;
- } m_data;
+ Scalar m_scalar;
+
+ struct
+ {
+ uint8_t bytes[kMaxRegisterByteSize]; // This must be big enough to hold any register for any supported target.
+ uint8_t length;
+ lldb::ByteOrder byte_order;
+ } buffer;
};
} // namespace lldb_private
-#endif // lldb_RegisterValue_h
+#endif // lldb_RegisterValue_h
diff --git a/include/lldb/Core/RegularExpression.h b/include/lldb/Core/RegularExpression.h
index a58d17b4a794..b0ece5154ce1 100644
--- a/include/lldb/Core/RegularExpression.h
+++ b/include/lldb/Core/RegularExpression.h
@@ -7,9 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DBRegex_h_
-#define liblldb_DBRegex_h_
-#if defined(__cplusplus)
+#ifndef liblldb_RegularExpression_h_
+#define liblldb_RegularExpression_h_
#ifdef _WIN32
#include "../lib/Support/regex_impl.h"
@@ -37,7 +36,6 @@ inline void regfree(llvm_regex_t * a)
{
llvm_regfree(a);
}
-
#else
#if __ANDROID_NDK__
#include <regex>
@@ -52,7 +50,7 @@ inline void regfree(llvm_regex_t * a)
namespace llvm
{
class StringRef;
-}
+} // namespace llvm
namespace lldb_private {
@@ -95,9 +93,7 @@ public:
regmatch_t *
GetData ()
{
- if (m_matches.empty())
- return NULL;
- return m_matches.data();
+ return (m_matches.empty() ? nullptr : m_matches.data());
}
bool
@@ -110,9 +106,9 @@ public:
GetMatchSpanningIndices (const char* s, uint32_t idx1, uint32_t idx2, llvm::StringRef& match_str) const;
protected:
-
std::vector<regmatch_t> m_matches; ///< Where parenthesized subexpressions results are stored
};
+
//------------------------------------------------------------------
/// Default constructor.
///
@@ -172,14 +168,14 @@ public:
/// @param[in] match
/// A pointer to a RegularExpression::Match structure that was
/// properly initialized with the desired number of maximum
- /// matches, or NULL if no parenthesized matching is needed.
+ /// matches, or nullptr if no parenthesized matching is needed.
///
/// @return
/// \b true if \a string matches the compiled regular
/// expression, \b false otherwise.
//------------------------------------------------------------------
bool
- Execute (const char* string, Match *match = NULL) const;
+ Execute(const char* string, Match *match = nullptr) const;
size_t
GetErrorAsCString (char *err_str, size_t err_str_max_len) const;
@@ -246,5 +242,4 @@ private:
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // liblldb_DBRegex_h_
+#endif // liblldb_RegularExpression_h_
diff --git a/include/lldb/Core/STLUtils.h b/include/lldb/Core/STLUtils.h
index 9321e057a397..b3c2124f447d 100644
--- a/include/lldb/Core/STLUtils.h
+++ b/include/lldb/Core/STLUtils.h
@@ -9,14 +9,18 @@
#ifndef liblldb_STLUtils_h_
#define liblldb_STLUtils_h_
-#if defined(__cplusplus)
+// C Includes
#include <string.h>
+// C++ Includes
#include <map>
#include <ostream>
#include <vector>
+// Other libraries and framework includes
+// Project includes
+
//----------------------------------------------------------------------
// C string less than compare function object
//----------------------------------------------------------------------
@@ -28,7 +32,6 @@ struct CStringCompareFunctionObject
}
};
-
//----------------------------------------------------------------------
// C string equality function object (binary predicate).
//----------------------------------------------------------------------
@@ -40,7 +43,6 @@ struct CStringEqualBinaryPredicate
}
};
-
//----------------------------------------------------------------------
// Templated type for finding an entry in a std::map<F,S> whose value
// is equal to something
@@ -48,21 +50,26 @@ struct CStringEqualBinaryPredicate
template <class F, class S>
class ValueEquals
{
-private:
- S second_value;
-
public:
ValueEquals (const S& val) : second_value(val)
{}
+
// Compare the second item
bool operator() (std::pair<const F, S> elem)
{
return elem.second == second_value;
}
+
+private:
+ S second_value;
};
template <class T>
-inline void PrintAllCollectionElements (std::ostream &s, const T& coll, const char* header_cstr=NULL, const char* separator_cstr=" ")
+inline void
+PrintAllCollectionElements(std::ostream &s,
+ const T& coll,
+ const char* header_cstr = nullptr,
+ const char* separator_cstr = " ")
{
typename T::const_iterator pos;
@@ -88,7 +95,4 @@ struct for_each_cplusplus_delete
typedef std::vector<std::string> STLStringArray;
typedef std::vector<const char *> CStringArray;
-
-
-#endif // #if defined(__cplusplus)
-#endif // liblldb_STLUtils_h_
+#endif // liblldb_STLUtils_h_
diff --git a/include/lldb/Core/Scalar.h b/include/lldb/Core/Scalar.h
index 821a0fb1ae21..a476cd3bd867 100644
--- a/include/lldb/Core/Scalar.h
+++ b/include/lldb/Core/Scalar.h
@@ -11,6 +11,11 @@
#define liblldb_Scalar_h_
#include "lldb/lldb-private.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/APFloat.h"
+
+#define NUM_OF_WORDS_INT128 2
+#define BITWIDTH_INT128 128
namespace lldb_private {
@@ -34,22 +39,60 @@ public:
e_ulonglong,
e_float,
e_double,
- e_long_double
+ e_long_double,
+ e_uint128,
+ e_sint128
};
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
Scalar();
- Scalar(int v) : m_type(e_sint), m_data() { m_data.sint = v; }
- Scalar(unsigned int v) : m_type(e_uint), m_data() { m_data.uint = v; }
- Scalar(long v) : m_type(e_slong), m_data() { m_data.slong = v; }
- Scalar(unsigned long v) : m_type(e_ulong), m_data() { m_data.ulong = v; }
- Scalar(long long v) : m_type(e_slonglong), m_data() { m_data.slonglong = v; }
- Scalar(unsigned long long v): m_type(e_ulonglong), m_data() { m_data.ulonglong = v; }
- Scalar(float v) : m_type(e_float), m_data() { m_data.flt = v; }
- Scalar(double v) : m_type(e_double), m_data() { m_data.dbl = v; }
- Scalar(long double v) : m_type(e_long_double), m_data() { m_data.ldbl = v; }
+ Scalar(int v) : m_type(e_sint), m_float((float)0) { m_integer = llvm::APInt(sizeof(int) * 8, v, true);}
+ Scalar(unsigned int v) : m_type(e_uint), m_float((float)0) { m_integer = llvm::APInt(sizeof(int) * 8, v);}
+ Scalar(long v) : m_type(e_slong), m_float((float)0) { m_integer = llvm::APInt(sizeof(long) * 8, v, true);}
+ Scalar(unsigned long v) : m_type(e_ulong), m_float((float)0) { m_integer = llvm::APInt(sizeof(long) * 8, v);}
+ Scalar(long long v) : m_type(e_slonglong), m_float((float)0) { m_integer = llvm::APInt(sizeof(long long) * 8, v, true);}
+ Scalar(unsigned long long v): m_type(e_ulonglong), m_float((float)0) { m_integer = llvm::APInt(sizeof(long long) * 8, v);}
+ Scalar(float v) : m_type(e_float), m_float(v) { m_float = llvm::APFloat(v); }
+ Scalar(double v) : m_type(e_double), m_float(v) { m_float = llvm::APFloat(v); }
+ Scalar(long double v, bool ieee_quad)
+ : m_type(e_long_double), m_float((float)0), m_ieee_quad(ieee_quad)
+ {
+ if(ieee_quad)
+ m_float = llvm::APFloat(llvm::APFloat::IEEEquad, llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x));
+ else
+ m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x));
+ }
+ Scalar(llvm::APInt v) :
+ m_type(),
+ m_float((float)0)
+ {
+ m_integer = llvm::APInt(v);
+ switch(m_integer.getBitWidth())
+ {
+ case 8:
+ case 16:
+ case 32:
+ if(m_integer.isSignedIntN(sizeof(sint_t) * 8))
+ m_type = e_sint;
+ else
+ m_type = e_uint;
+ break;
+ case 64:
+ if(m_integer.isSignedIntN(sizeof(slonglong_t) * 8))
+ m_type = e_slonglong;
+ else
+ m_type = e_ulonglong;
+ break;
+ case 128:
+ if(m_integer.isSignedIntN(BITWIDTH_INT128))
+ m_type = e_sint128;
+ else
+ m_type = e_uint128;
+ break;
+ }
+ }
Scalar(const Scalar& rhs);
//Scalar(const RegisterValue& reg_value);
virtual ~Scalar();
@@ -61,15 +104,18 @@ public:
ExtractBitfield (uint32_t bit_size,
uint32_t bit_offset);
+ bool
+ SetBit(uint32_t bit);
+
+ bool
+ ClearBit(uint32_t bit);
+
+ void *
+ GetBytes() const;
+
size_t
GetByteSize() const;
- static size_t
- GetMaxByteSize()
- {
- return sizeof(ValueData);
- }
-
bool
GetData (DataExtractor &data, size_t limit_byte_size = UINT32_MAX) const;
@@ -83,7 +129,7 @@ public:
IsZero() const;
void
- Clear() { m_type = e_void; m_data.ulonglong = 0; }
+ Clear() { m_type = e_void; m_integer.clearAllBits(); }
const char *
GetTypeAsCString() const;
@@ -133,6 +179,7 @@ public:
Scalar& operator= (float v);
Scalar& operator= (double v);
Scalar& operator= (long double v);
+ Scalar& operator= (llvm::APInt v);
Scalar& operator= (const Scalar& rhs); // Assignment operator
Scalar& operator+= (const Scalar& rhs);
Scalar& operator<<= (const Scalar& rhs); // Shift left
@@ -174,6 +221,9 @@ public:
Scalar::Type
GetType() const { return m_type; }
+ void
+ SetType(const RegisterInfo*);
+
//----------------------------------------------------------------------
// Returns a casted value of the current contained data without
// modifying the current value. FAIL_VALUE will be returned if the type
@@ -194,6 +244,18 @@ public:
unsigned long long
RawULongLong () const;
+ unsigned char
+ UChar(unsigned char fail_value = 0) const;
+
+ char
+ SChar(char fail_value = 0) const;
+
+ unsigned short
+ UShort(unsigned short fail_value = 0) const;
+
+ short
+ SShort(short fail_value = 0) const;
+
unsigned int
UInt(unsigned int fail_value = 0) const;
@@ -209,6 +271,12 @@ public:
unsigned long long
ULongLong(unsigned long long fail_value = 0) const;
+ llvm::APInt
+ SInt128(llvm::APInt& fail_value) const;
+
+ llvm::APInt
+ UInt128(const llvm::APInt& fail_value) const;
+
float
Float(float fail_value = 0.0f) const;
@@ -255,6 +323,10 @@ public:
}
protected:
+ typedef char schar_t;
+ typedef unsigned char uchar_t;
+ typedef short sshort_t;
+ typedef unsigned short ushort_t;
typedef int sint_t;
typedef unsigned int uint_t;
typedef long slong_t;
@@ -265,24 +337,13 @@ protected:
typedef double double_t;
typedef long double long_double_t;
- union ValueData
- {
- int sint;
- unsigned int uint;
- long slong;
- unsigned long ulong;
- long long slonglong;
- unsigned long long ulonglong;
- float flt;
- double dbl;
- long double ldbl;
- };
-
//------------------------------------------------------------------
// Classes that inherit from Scalar can see and modify these
//------------------------------------------------------------------
Scalar::Type m_type;
- ValueData m_data;
+ llvm::APInt m_integer;
+ llvm::APFloat m_float;
+ bool m_ieee_quad = false;
private:
friend const Scalar operator+ (const Scalar& lhs, const Scalar& rhs);
diff --git a/include/lldb/Core/SearchFilter.h b/include/lldb/Core/SearchFilter.h
index bbb7509cedb2..3d5e1fb39b43 100644
--- a/include/lldb/Core/SearchFilter.h
+++ b/include/lldb/Core/SearchFilter.h
@@ -272,7 +272,7 @@ class SearchFilterForUnconstrainedSearches :
{
public:
SearchFilterForUnconstrainedSearches (const lldb::TargetSP &target_sp) : SearchFilter(target_sp) {}
- ~SearchFilterForUnconstrainedSearches () {}
+ ~SearchFilterForUnconstrainedSearches() override = default;
bool
ModulePasses (const FileSpec &module_spec) override;
@@ -283,7 +283,6 @@ public:
protected:
lldb::SearchFilterSP
DoCopyForBreakpoint (Breakpoint &breakpoint) override;
-
};
//----------------------------------------------------------------------
@@ -311,8 +310,7 @@ public:
SearchFilterByModule (const SearchFilterByModule& rhs);
- virtual
- ~SearchFilterByModule ();
+ ~SearchFilterByModule() override;
const SearchFilterByModule&
operator=(const SearchFilterByModule& rhs);
@@ -372,8 +370,7 @@ public:
SearchFilterByModuleList (const SearchFilterByModuleList& rhs);
- virtual
- ~SearchFilterByModuleList ();
+ ~SearchFilterByModuleList() override;
const SearchFilterByModuleList&
operator=(const SearchFilterByModuleList& rhs);
@@ -409,7 +406,7 @@ protected:
lldb::SearchFilterSP
DoCopyForBreakpoint (Breakpoint &breakpoint) override;
-private:
+protected:
FileSpecList m_module_spec_list;
};
@@ -434,8 +431,7 @@ public:
SearchFilterByModuleListAndCU (const SearchFilterByModuleListAndCU& rhs);
- virtual
- ~SearchFilterByModuleListAndCU ();
+ ~SearchFilterByModuleListAndCU() override;
const SearchFilterByModuleListAndCU&
operator=(const SearchFilterByModuleListAndCU& rhs);
@@ -466,10 +462,9 @@ protected:
DoCopyForBreakpoint (Breakpoint &breakpoint) override;
private:
- FileSpecList m_module_spec_list;
FileSpecList m_cu_spec_list;
};
} // namespace lldb_private
-#endif // liblldb_SearchFilter_h_
+#endif // liblldb_SearchFilter_h_
diff --git a/include/lldb/Core/Section.h b/include/lldb/Core/Section.h
index 65d408e29867..8c92f1ba667e 100644
--- a/include/lldb/Core/Section.h
+++ b/include/lldb/Core/Section.h
@@ -64,9 +64,6 @@ public:
lldb::SectionSP
FindSectionContainingFileAddress (lldb::addr_t addr, uint32_t depth = UINT32_MAX) const;
- bool
- GetSectionData (const DataExtractor& module_data, DataExtractor& section_data) const;
-
// Get the number of sections in this list only
size_t
GetSize () const
@@ -288,6 +285,46 @@ public:
return m_obj_file;
}
+ //------------------------------------------------------------------
+ /// Read the section data from the object file that the section
+ /// resides in.
+ ///
+ /// @param[in] dst
+ /// Where to place the data
+ ///
+ /// @param[in] dst_len
+ /// How many bytes of section data to read
+ ///
+ /// @param[in] offset
+ /// The offset in bytes within this section's data at which to
+ /// start copying data from.
+ ///
+ /// @return
+ /// The number of bytes read from the section, or zero if the
+ /// section has no data or \a offset is not a valid offset
+ /// in this section.
+ //------------------------------------------------------------------
+ lldb::offset_t
+ GetSectionData (void *dst, lldb::offset_t dst_len, lldb::offset_t offset = 0);
+
+ //------------------------------------------------------------------
+ /// Get the shared reference to the section data from the object
+ /// file that the section resides in. No copies of the data will be
+ /// make unless the object file has been read from memory. If the
+ /// object file is on disk, it will shared the mmap data for the
+ /// entire object file.
+ ///
+ /// @param[in] data
+ /// Where to place the data, address byte size, and byte order
+ ///
+ /// @return
+ /// The number of bytes read from the section, or zero if the
+ /// section has no data or \a offset is not a valid offset
+ /// in this section.
+ //------------------------------------------------------------------
+ lldb::offset_t
+ GetSectionData (DataExtractor& data) const;
+
uint32_t GetLog2Align()
{
return m_log2align;
diff --git a/include/lldb/Core/SourceManager.h b/include/lldb/Core/SourceManager.h
index 0f65be1bee4b..5504bafd6b7e 100644
--- a/include/lldb/Core/SourceManager.h
+++ b/include/lldb/Core/SourceManager.h
@@ -13,6 +13,7 @@
// C Includes
// C++ Includes
#include <map>
+#include <memory>
#include <vector>
// Other libraries and framework includes
@@ -26,15 +27,17 @@ class SourceManager
{
public:
#ifndef SWIG
-
class File
{
- friend bool operator== (const SourceManager::File &lhs, const SourceManager::File &rhs);
+ friend bool operator== (const SourceManager::File &lhs, const SourceManager::File &rhs);
+
public:
-
File (const FileSpec &file_spec, Target *target);
~File();
+ void
+ UpdateIfNeeded ();
+
size_t
DisplaySourceLines (uint32_t line,
uint32_t context_before,
@@ -80,7 +83,6 @@ public:
GetNumLines ();
protected:
-
bool
CalculateLineOffsets (uint32_t line = UINT32_MAX);
@@ -92,20 +94,18 @@ public:
typedef std::vector<uint32_t> LineOffsets;
LineOffsets m_offsets;
};
-
#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.
class SourceFileCache
{
public:
- SourceFileCache () {}
- ~SourceFileCache() {}
+ SourceFileCache() = default;
+ ~SourceFileCache() = default;
void AddSourceFile (const FileSP &file_sp);
FileSP FindSourceFile (const FileSpec &file_spec) const;
@@ -114,8 +114,7 @@ public:
typedef std::map <FileSpec, FileSP> FileCache;
FileCache m_file_cache;
};
-#endif
-
+#endif // SWIG
//------------------------------------------------------------------
// Constructors and Destructors
@@ -127,7 +126,6 @@ public:
~SourceManager();
-
FileSP
GetLastFile ()
{
@@ -135,28 +133,28 @@ public:
}
size_t
- DisplaySourceLinesWithLineNumbers (const FileSpec &file,
- uint32_t line,
- uint32_t context_before,
- uint32_t context_after,
- const char* current_line_cstr,
- Stream *s,
- const SymbolContextList *bp_locs = NULL);
+ DisplaySourceLinesWithLineNumbers(const FileSpec &file,
+ uint32_t line,
+ uint32_t context_before,
+ uint32_t context_after,
+ const char* current_line_cstr,
+ Stream *s,
+ const SymbolContextList *bp_locs = nullptr);
// This variant uses the last file we visited.
size_t
- DisplaySourceLinesWithLineNumbersUsingLastFile (uint32_t start_line,
- uint32_t count,
- uint32_t curr_line,
- const char* current_line_cstr,
- Stream *s,
- const SymbolContextList *bp_locs = NULL);
+ DisplaySourceLinesWithLineNumbersUsingLastFile(uint32_t start_line,
+ uint32_t count,
+ uint32_t curr_line,
+ const char* current_line_cstr,
+ Stream *s,
+ const SymbolContextList *bp_locs = nullptr);
size_t
- DisplayMoreWithLineNumbers (Stream *s,
- uint32_t count,
- bool reverse,
- const SymbolContextList *bp_locs = NULL);
+ DisplayMoreWithLineNumbers(Stream *s,
+ uint32_t count,
+ bool reverse,
+ const SymbolContextList *bp_locs = nullptr);
bool
SetDefaultFileAndLine (const FileSpec &file_spec, uint32_t line);
@@ -167,7 +165,7 @@ public:
bool
DefaultFileAndLineSet ()
{
- return (m_last_file_sp.get() != NULL);
+ return (m_last_file_sp.get() != nullptr);
}
void
@@ -181,10 +179,6 @@ public:
GetFile (const FileSpec &file_spec);
protected:
-
- //------------------------------------------------------------------
- // Classes that inherit from SourceManager can see and modify these
- //------------------------------------------------------------------
FileSP m_last_file_sp;
uint32_t m_last_line;
uint32_t m_last_count;
@@ -193,13 +187,11 @@ protected:
lldb::DebuggerWP m_debugger_wp;
private:
- //------------------------------------------------------------------
- // For SourceManager only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (SourceManager);
};
bool operator== (const SourceManager::File &lhs, const SourceManager::File &rhs);
+
} // namespace lldb_private
-#endif // liblldb_SourceManager_h_
+#endif // liblldb_SourceManager_h_
diff --git a/include/lldb/Core/Stream.h b/include/lldb/Core/Stream.h
index 11780aa6ff0f..f784069894ec 100644
--- a/include/lldb/Core/Stream.h
+++ b/include/lldb/Core/Stream.h
@@ -9,11 +9,15 @@
#ifndef liblldb_Stream_h_
#define liblldb_Stream_h_
-#if defined(__cplusplus)
+// C Includes
+#include <stdarg.h>
+
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/Flags.h"
-#include <stdarg.h>
namespace lldb_private {
@@ -221,7 +225,7 @@ public:
/// in one statement.
//------------------------------------------------------------------
Stream&
- operator<< (void *p);
+ operator<< (const void *p);
//------------------------------------------------------------------
/// Output a character \a ch to the stream \a s.
@@ -353,13 +357,13 @@ public:
/// Size in bytes of the address, used for formatting.
///
/// @param[in] prefix
- /// A prefix C string. If NULL, no prefix will be output.
+ /// A prefix C string. If nullptr, no prefix will be output.
///
/// @param[in] suffix
- /// A suffix C string. If NULL, no suffix will be output.
+ /// A suffix C string. If nullptr, no suffix will be output.
//------------------------------------------------------------------
void
- Address (uint64_t addr, uint32_t addr_size, const char *prefix = NULL, const char *suffix = NULL);
+ Address(uint64_t addr, uint32_t addr_size, const char *prefix = nullptr, const char *suffix = nullptr);
//------------------------------------------------------------------
/// Output an address range to this stream.
@@ -377,13 +381,13 @@ public:
/// Size in bytes of the address, used for formatting.
///
/// @param[in] prefix
- /// A prefix C string. If NULL, no prefix will be output.
+ /// A prefix C string. If nullptr, no prefix will be output.
///
/// @param[in] suffix
- /// A suffix C string. If NULL, no suffix will be output.
+ /// 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 = NULL, const char *suffix = NULL);
+ 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.
@@ -475,11 +479,11 @@ public:
/// print an optional string following the indentation spaces.
///
/// @param[in] s
- /// A C string to print following the indentation. If NULL, just
+ /// A C string to print following the indentation. If nullptr, just
/// output the indentation characters.
//------------------------------------------------------------------
size_t
- Indent(const char *s = NULL);
+ Indent(const char *s = nullptr);
//------------------------------------------------------------------
/// Decrement the current indentation level.
@@ -607,6 +611,4 @@ protected:
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
#endif // liblldb_Stream_h_
-
diff --git a/include/lldb/Core/StreamAsynchronousIO.h b/include/lldb/Core/StreamAsynchronousIO.h
index d3b054463fa7..b069cfd496e1 100644
--- a/include/lldb/Core/StreamAsynchronousIO.h
+++ b/include/lldb/Core/StreamAsynchronousIO.h
@@ -22,14 +22,13 @@ class StreamAsynchronousIO :
public:
StreamAsynchronousIO (Debugger &debugger, bool for_stdout);
- virtual ~StreamAsynchronousIO ();
+ ~StreamAsynchronousIO () override;
- virtual void
- Flush ();
-
- virtual size_t
- Write (const void *src, size_t src_len);
+ void
+ Flush () override;
+ size_t
+ Write (const void *src, size_t src_len) override;
private:
Debugger &m_debugger;
@@ -38,4 +37,5 @@ private:
};
} // namespace lldb_private
-#endif // #ifndef liblldb_StreamAsynchronousIO_h
+
+#endif // liblldb_StreamAsynchronousIO_h
diff --git a/include/lldb/Core/StreamCallback.h b/include/lldb/Core/StreamCallback.h
index b5fb91c6ce07..e5a9da7512bb 100644
--- a/include/lldb/Core/StreamCallback.h
+++ b/include/lldb/Core/StreamCallback.h
@@ -24,14 +24,13 @@ class StreamCallback :
public:
StreamCallback (lldb::LogOutputCallback callback, void *baton);
- virtual ~StreamCallback ();
+ ~StreamCallback () override;
- virtual void
- Flush ();
-
- virtual size_t
- Write (const void *src, size_t src_len);
+ void
+ Flush () override;
+ size_t
+ Write (const void *src, size_t src_len) override;
private:
typedef std::map<lldb::tid_t, StreamString> collection;
@@ -44,4 +43,5 @@ private:
};
} // namespace lldb_private
-#endif // #ifndef liblldb_StreamCallback_h
+
+#endif // liblldb_StreamCallback_h
diff --git a/include/lldb/Core/StreamFile.h b/include/lldb/Core/StreamFile.h
index 55bb361780a5..781f0a599493 100644
--- a/include/lldb/Core/StreamFile.h
+++ b/include/lldb/Core/StreamFile.h
@@ -43,8 +43,7 @@ public:
StreamFile (FILE *fh, bool transfer_ownership);
- virtual
- ~StreamFile();
+ ~StreamFile() override;
File &
GetFile ()
@@ -58,11 +57,11 @@ public:
return m_file;
}
- virtual void
- Flush ();
+ void
+ Flush () override;
- virtual size_t
- Write (const void *s, size_t length);
+ size_t
+ Write (const void *s, size_t length) override;
protected:
//------------------------------------------------------------------
@@ -76,4 +75,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_StreamFile_h_
+#endif // liblldb_StreamFile_h_
diff --git a/include/lldb/Core/StreamGDBRemote.h b/include/lldb/Core/StreamGDBRemote.h
index 3fdb6f6e7012..834f412d0a03 100644
--- a/include/lldb/Core/StreamGDBRemote.h
+++ b/include/lldb/Core/StreamGDBRemote.h
@@ -29,8 +29,7 @@ namespace lldb_private {
uint32_t addr_size,
lldb::ByteOrder byte_order);
- virtual
- ~StreamGDBRemote ();
+ ~StreamGDBRemote() override;
//------------------------------------------------------------------
/// Output a block of data to the stream performing GDB-remote escaping.
@@ -51,4 +50,4 @@ namespace lldb_private {
} // namespace lldb_private
-#endif // liblldb_StreamGDBRemote_h_
+#endif // liblldb_StreamGDBRemote_h_
diff --git a/include/lldb/Core/StreamString.h b/include/lldb/Core/StreamString.h
index 1aa46dd80a68..5b6bde7a13c2 100644
--- a/include/lldb/Core/StreamString.h
+++ b/include/lldb/Core/StreamString.h
@@ -25,14 +25,13 @@ public:
uint32_t addr_size,
lldb::ByteOrder byte_order);
- virtual
- ~StreamString ();
+ ~StreamString () override;
- virtual void
- Flush ();
+ void
+ Flush () override;
- virtual size_t
- Write (const void *s, size_t length);
+ size_t
+ Write (const void *s, size_t length) override;
void
Clear();
@@ -60,8 +59,8 @@ public:
protected:
std::string m_packet;
-
};
} // namespace lldb_private
-#endif // #ifndef liblldb_StreamString_h_
+
+#endif // liblldb_StreamString_h_
diff --git a/include/lldb/Core/StreamTee.h b/include/lldb/Core/StreamTee.h
index e2a29a374553..7ab619b3bb79 100644
--- a/include/lldb/Core/StreamTee.h
+++ b/include/lldb/Core/StreamTee.h
@@ -59,8 +59,7 @@ public:
m_streams = rhs.m_streams;
}
- virtual
- ~StreamTee ()
+ ~StreamTee () override
{
}
@@ -76,8 +75,8 @@ public:
return *this;
}
- virtual void
- Flush ()
+ void
+ Flush () override
{
Mutex::Locker locker (m_streams_mutex);
collection::iterator pos, end;
@@ -93,8 +92,8 @@ public:
}
}
- virtual size_t
- Write (const void *s, size_t length)
+ size_t
+ Write (const void *s, size_t length) override
{
Mutex::Locker locker (m_streams_mutex);
if (m_streams.empty())
@@ -164,7 +163,6 @@ public:
m_streams[idx] = stream_sp;
}
-
protected:
typedef std::vector<lldb::StreamSP> collection;
mutable Mutex m_streams_mutex;
@@ -172,4 +170,5 @@ protected:
};
} // namespace lldb_private
-#endif // #ifndef liblldb_StreamTee_h_
+
+#endif // liblldb_StreamTee_h_
diff --git a/include/lldb/Core/StringList.h b/include/lldb/Core/StringList.h
index c69ed872c30d..3e341b994075 100644
--- a/include/lldb/Core/StringList.h
+++ b/include/lldb/Core/StringList.h
@@ -10,18 +10,24 @@
#ifndef liblldb_StringList_h_
#define liblldb_StringList_h_
+// C Includes
#include <stdint.h>
-#include "lldb/Core/STLUtils.h"
-#include "lldb/lldb-forward.h"
+// C++ Includes
+#include <string>
+
+// Other libraries and framework includes
#include "llvm/ADT/StringRef.h"
+// Project includes
+#include "lldb/lldb-forward.h"
+#include "lldb/Core/STLUtils.h"
+
namespace lldb_private {
class StringList
{
public:
-
StringList ();
StringList (const char *str);
@@ -120,7 +126,7 @@ public:
SplitIntoLines (const char *lines, size_t len);
std::string
- CopyList(const char* item_preamble = NULL,
+ CopyList(const char* item_preamble = nullptr,
const char* items_sep = "\n") const;
StringList&
@@ -142,7 +148,6 @@ public:
size_t &exact_matches_idx) const;
private:
-
STLStringArray m_strings;
};
diff --git a/include/lldb/Core/StructuredData.h b/include/lldb/Core/StructuredData.h
index 7da29e48299d..52f34521ef0e 100644
--- a/include/lldb/Core/StructuredData.h
+++ b/include/lldb/Core/StructuredData.h
@@ -12,16 +12,16 @@
// C Includes
// C++ Includes
-
#include <functional>
#include <map>
+#include <memory>
#include <string>
#include <utility>
#include <vector>
+// Other libraries and framework includes
#include "llvm/ADT/StringRef.h"
-// Other libraries and framework includes
// Project includes
#include "lldb/lldb-defines.h"
#include "lldb/Core/ConstString.h"
@@ -47,7 +47,6 @@ namespace lldb_private {
class StructuredData
{
public:
-
class Object;
class Array;
class Integer;
@@ -89,9 +88,7 @@ public:
{
}
- virtual ~Object ()
- {
- }
+ virtual ~Object() = default;
virtual bool
IsValid() const
@@ -120,80 +117,62 @@ public:
Array *
GetAsArray ()
{
- if (m_type == Type::eTypeArray)
- return (Array *)this;
- return NULL;
+ return ((m_type == Type::eTypeArray) ? static_cast<Array *>(this) : nullptr);
}
Dictionary *
GetAsDictionary ()
{
- if (m_type == Type::eTypeDictionary)
- return (Dictionary *)this;
- return NULL;
+ return ((m_type == Type::eTypeDictionary) ? static_cast<Dictionary *>(this) : nullptr);
}
Integer *
GetAsInteger ()
{
- if (m_type == Type::eTypeInteger)
- return (Integer *)this;
- return NULL;
+ return ((m_type == Type::eTypeInteger) ? static_cast<Integer *>(this) : nullptr);
}
uint64_t
GetIntegerValue (uint64_t fail_value = 0)
{
Integer *integer = GetAsInteger ();
- if (integer)
- return integer->GetValue();
- return fail_value;
+ return ((integer != nullptr) ? integer->GetValue() : fail_value);
}
Float *
GetAsFloat ()
{
- if (m_type == Type::eTypeFloat)
- return (Float *)this;
- return NULL;
+ return ((m_type == Type::eTypeFloat) ? static_cast<Float *>(this) : nullptr);
}
double
GetFloatValue (double fail_value = 0.0)
{
Float *f = GetAsFloat ();
- if (f)
- return f->GetValue();
- return fail_value;
+ return ((f != nullptr) ? f->GetValue() : fail_value);
}
Boolean *
GetAsBoolean ()
{
- if (m_type == Type::eTypeBoolean)
- return (Boolean *)this;
- return NULL;
+ return ((m_type == Type::eTypeBoolean) ? static_cast<Boolean *>(this) : nullptr);
}
bool
GetBooleanValue (bool fail_value = false)
{
Boolean *b = GetAsBoolean ();
- if (b)
- return b->GetValue();
- return fail_value;
+ return ((b != nullptr) ? b->GetValue() : fail_value);
}
String *
GetAsString ()
{
- if (m_type == Type::eTypeString)
- return (String *)this;
- return NULL;
+ return ((m_type == Type::eTypeString) ? static_cast<String *>(this) : nullptr);
}
std::string
- GetStringValue(const char *fail_value = NULL)
+ GetStringValue(const char *fail_value = nullptr)
{
String *s = GetAsString ();
if (s)
@@ -208,9 +187,7 @@ public:
Generic *
GetAsGeneric()
{
- if (m_type == Type::eTypeGeneric)
- return (Generic *)this;
- return NULL;
+ return ((m_type == Type::eTypeGeneric) ? static_cast<Generic *>(this) : nullptr);
}
ObjectSP
@@ -233,10 +210,7 @@ public:
{
}
- virtual
- ~Array()
- {
- }
+ ~Array() override = default;
bool
ForEach (std::function <bool(Object* object)> const &foreach_callback) const
@@ -249,7 +223,6 @@ public:
return true;
}
-
size_t
GetSize() const
{
@@ -277,11 +250,14 @@ public:
bool
GetItemAtIndexAsInteger(size_t idx, IntType &result) const
{
- ObjectSP value = GetItemAtIndex(idx);
- if (auto int_value = value->GetAsInteger())
+ ObjectSP value_sp = GetItemAtIndex(idx);
+ if (value_sp.get())
{
- result = static_cast<IntType>(int_value->GetValue());
- return true;
+ if (auto int_value = value_sp->GetAsInteger())
+ {
+ result = static_cast<IntType>(int_value->GetValue());
+ return true;
+ }
}
return false;
}
@@ -299,11 +275,14 @@ public:
bool
GetItemAtIndexAsString(size_t idx, std::string &result) const
{
- ObjectSP value = GetItemAtIndex(idx);
- if (auto string_value = value->GetAsString())
+ ObjectSP value_sp = GetItemAtIndex(idx);
+ if (value_sp.get())
{
- result = string_value->GetValue();
- return true;
+ if (auto string_value = value_sp->GetAsString())
+ {
+ result = string_value->GetValue();
+ return true;
+ }
}
return false;
}
@@ -320,13 +299,13 @@ public:
bool
GetItemAtIndexAsString(size_t idx, ConstString &result) const
{
- ObjectSP value = GetItemAtIndex(idx);
- if (!value)
- return false;
- if (auto string_value = value->GetAsString())
- {
- result = ConstString(string_value->GetValue());
- return true;
+ ObjectSP value_sp = GetItemAtIndex(idx);
+ if (value_sp.get()) {
+ if (auto string_value = value_sp->GetAsString())
+ {
+ result = ConstString(string_value->GetValue());
+ return true;
+ }
}
return false;
}
@@ -343,17 +322,27 @@ public:
bool
GetItemAtIndexAsDictionary(size_t idx, Dictionary *&result) const
{
- ObjectSP value = GetItemAtIndex(idx);
- result = value->GetAsDictionary();
- return (result != nullptr);
+ result = nullptr;
+ ObjectSP value_sp = GetItemAtIndex(idx);
+ if (value_sp.get())
+ {
+ result = value_sp->GetAsDictionary();
+ return (result != nullptr);
+ }
+ return false;
}
bool
GetItemAtIndexAsArray(size_t idx, Array *&result) const
{
- ObjectSP value = GetItemAtIndex(idx);
- result = value->GetAsArray();
- return (result != nullptr);
+ result = nullptr;
+ ObjectSP value_sp = GetItemAtIndex(idx);
+ if (value_sp.get())
+ {
+ result = value_sp->GetAsArray();
+ return (result != nullptr);
+ }
+ return false;
}
void
@@ -375,8 +364,7 @@ public:
collection m_items;
};
-
- class Integer : public Object
+ class Integer : public Object
{
public:
Integer (uint64_t i = 0) :
@@ -385,9 +373,7 @@ public:
{
}
- virtual ~Integer()
- {
- }
+ ~Integer() override = default;
void
SetValue (uint64_t value)
@@ -407,7 +393,7 @@ public:
uint64_t m_value;
};
- class Float : public Object
+ class Float : public Object
{
public:
Float (double d = 0.0) :
@@ -416,9 +402,7 @@ public:
{
}
- virtual ~Float()
- {
- }
+ ~Float() override = default;
void
SetValue (double value)
@@ -438,7 +422,7 @@ public:
double m_value;
};
- class Boolean : public Object
+ class Boolean : public Object
{
public:
Boolean (bool b = false) :
@@ -447,9 +431,7 @@ public:
{
}
- virtual ~Boolean()
- {
- }
+ ~Boolean() override = default;
void
SetValue (bool value)
@@ -469,12 +451,10 @@ public:
bool m_value;
};
-
-
- class String : public Object
+ class String : public Object
{
public:
- String (const char *cstr = NULL) :
+ String(const char *cstr = nullptr) :
Object (Type::eTypeString),
m_value ()
{
@@ -522,9 +502,7 @@ public:
{
}
- virtual ~Dictionary()
- {
- }
+ ~Dictionary() override = default;
size_t
GetSize() const
@@ -580,13 +558,13 @@ public:
bool
GetValueForKeyAsInteger(llvm::StringRef key, IntType &result) const
{
- ObjectSP value = GetValueForKey(key);
- if (!value)
- return false;
- if (auto int_value = value->GetAsInteger())
- {
- result = static_cast<IntType>(int_value->GetValue());
- return true;
+ ObjectSP value_sp = GetValueForKey(key);
+ if (value_sp) {
+ if (auto int_value = value_sp->GetAsInteger())
+ {
+ result = static_cast<IntType>(int_value->GetValue());
+ return true;
+ }
}
return false;
}
@@ -604,13 +582,14 @@ public:
bool
GetValueForKeyAsString(llvm::StringRef key, std::string &result) const
{
- ObjectSP value = GetValueForKey(key);
- if (!value)
- return false;
- if (auto string_value = value->GetAsString())
+ ObjectSP value_sp = GetValueForKey(key);
+ if (value_sp.get())
{
- result = string_value->GetValue();
- return true;
+ if (auto string_value = value_sp->GetAsString())
+ {
+ result = string_value->GetValue();
+ return true;
+ }
}
return false;
}
@@ -632,13 +611,14 @@ public:
bool
GetValueForKeyAsString(llvm::StringRef key, ConstString &result) const
{
- ObjectSP value = GetValueForKey(key);
- if (!value)
- return false;
- if (auto string_value = value->GetAsString())
+ ObjectSP value_sp = GetValueForKey(key);
+ if (value_sp.get())
{
- result = ConstString(string_value->GetValue());
- return true;
+ if (auto string_value = value_sp->GetAsString())
+ {
+ result = ConstString(string_value->GetValue());
+ return true;
+ }
}
return false;
}
@@ -656,22 +636,26 @@ public:
GetValueForKeyAsDictionary(llvm::StringRef key, Dictionary *&result) const
{
result = nullptr;
- ObjectSP value = GetValueForKey(key);
- if (!value)
- return false;
- result = value->GetAsDictionary();
- return true;
+ ObjectSP value_sp = GetValueForKey(key);
+ if (value_sp.get())
+ {
+ result = value_sp->GetAsDictionary();
+ return (result != nullptr);
+ }
+ return false;
}
bool
GetValueForKeyAsArray(llvm::StringRef key, Array *&result) const
{
result = nullptr;
- ObjectSP value = GetValueForKey(key);
- if (!value)
- return false;
- result = value->GetAsArray();
- return true;
+ ObjectSP value_sp = GetValueForKey(key);
+ if (value_sp.get())
+ {
+ result = value_sp->GetAsArray();
+ return (result != nullptr);
+ }
+ return false;
}
bool
@@ -683,10 +667,10 @@ public:
}
void
- AddItem (llvm::StringRef key, ObjectSP value)
+ AddItem (llvm::StringRef key, ObjectSP value_sp)
{
ConstString key_cs(key);
- m_dict[key_cs] = value;
+ m_dict[key_cs] = value_sp;
}
void
@@ -728,9 +712,7 @@ public:
{
}
- virtual ~Null()
- {
- }
+ ~Null() override = default;
bool
IsValid() const override
@@ -739,13 +721,11 @@ public:
}
void Dump(Stream &s) const override;
-
- protected:
};
class Generic : public Object
{
- public:
+ public:
explicit Generic(void *object = nullptr) :
Object (Type::eTypeGeneric),
m_object (object)
@@ -772,16 +752,14 @@ public:
void Dump(Stream &s) const override;
- private:
+ private:
void *m_object;
};
static ObjectSP
ParseJSON (std::string json_text);
-
-}; // class StructuredData
-
+};
} // namespace lldb_private
-#endif // liblldb_StructuredData_h_
+#endif // liblldb_StructuredData_h_
diff --git a/include/lldb/Core/ThreadSafeDenseMap.h b/include/lldb/Core/ThreadSafeDenseMap.h
index f5a7ccfb2ffa..6b2b59b7617c 100644
--- a/include/lldb/Core/ThreadSafeDenseMap.h
+++ b/include/lldb/Core/ThreadSafeDenseMap.h
@@ -54,7 +54,27 @@ public:
Mutex::Locker locker(m_mutex);
return m_map.lookup(k);
}
-
+
+ bool
+ Lookup (_KeyType k,
+ _ValueType& v)
+ {
+ Mutex::Locker locker(m_mutex);
+ auto iter = m_map.find(k),
+ end = m_map.end();
+ if (iter == end)
+ return false;
+ v = iter->second;
+ return true;
+ }
+
+ void
+ Clear ()
+ {
+ Mutex::Locker locker(m_mutex);
+ m_map.clear();
+ }
+
protected:
LLVMMapType m_map;
Mutex m_mutex;
diff --git a/include/lldb/Core/ThreadSafeDenseSet.h b/include/lldb/Core/ThreadSafeDenseSet.h
index 19c67b65e8c1..e019c70ed5e5 100644
--- a/include/lldb/Core/ThreadSafeDenseSet.h
+++ b/include/lldb/Core/ThreadSafeDenseSet.h
@@ -55,6 +55,13 @@ namespace lldb_private {
return (m_set.count(e) > 0);
}
+ void
+ Clear ()
+ {
+ Mutex::Locker locker(m_mutex);
+ m_set.clear();
+ }
+
protected:
LLVMSetType m_set;
Mutex m_mutex;
diff --git a/include/lldb/Core/Timer.h b/include/lldb/Core/Timer.h
index e354d91be442..ffaeba6fce9b 100644
--- a/include/lldb/Core/Timer.h
+++ b/include/lldb/Core/Timer.h
@@ -9,11 +9,17 @@
#ifndef liblldb_Timer_h_
#define liblldb_Timer_h_
-#if defined(__cplusplus)
+// C Includes
#include <stdarg.h>
#include <stdio.h>
-#include <string>
+
+// C++ Includes
+#include <atomic>
+#include <mutex>
+
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Host/TimeValue.h"
@@ -34,19 +40,19 @@ namespace lldb_private {
class Timer
{
public:
- static void
- Initialize ();
-
//--------------------------------------------------------------
/// Default constructor.
//--------------------------------------------------------------
Timer(const char *category, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
//--------------------------------------------------------------
- /// Desstructor
+ /// Destructor
//--------------------------------------------------------------
~Timer();
+ static void
+ Initialize ();
+
void
Dump ();
@@ -63,7 +69,6 @@ public:
ResetCategoryTimes ();
protected:
-
void
ChildStarted (const TimeValue& time);
@@ -76,17 +81,17 @@ protected:
uint64_t
GetTimerElapsedNanoSeconds();
- //--------------------------------------------------------------
- /// Member variables
- //--------------------------------------------------------------
const char *m_category;
TimeValue m_total_start;
TimeValue m_timer_start;
uint64_t m_total_ticks; // Total running time for this timer including when other timers below this are running
uint64_t m_timer_ticks; // Ticks for this timer that do not include when other timers below this one are running
- static uint32_t g_depth;
- static uint32_t g_display_depth;
- static FILE * g_file;
+
+ static std::atomic<bool> g_quiet;
+ static std::atomic<unsigned> g_display_depth;
+ static std::mutex g_file_mutex;
+ static FILE* g_file;
+
private:
Timer();
DISALLOW_COPY_AND_ASSIGN (Timer);
@@ -99,10 +104,8 @@ public:
m_start (TimeValue::Now())
{
}
-
- ~IntervalTimer()
- {
- }
+
+ ~IntervalTimer() = default;
uint64_t
GetElapsedNanoSeconds() const
@@ -121,7 +124,7 @@ public:
{
TimeValue now (TimeValue::Now());
const uint64_t elapsed_nsec = now - m_start;
- const char *unit = NULL;
+ const char *unit = nullptr;
float elapsed_value;
if (elapsed_nsec < 1000)
{
@@ -150,11 +153,11 @@ public:
va_end (args);
return result;
}
+
protected:
TimeValue m_start;
};
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // #ifndef liblldb_Timer_h_
+#endif // liblldb_Timer_h_
diff --git a/include/lldb/Core/UUID.h b/include/lldb/Core/UUID.h
index 3bb14421b1e9..88426cfb6c75 100644
--- a/include/lldb/Core/UUID.h
+++ b/include/lldb/Core/UUID.h
@@ -16,7 +16,6 @@
// Other libraries and framework includes
// Project includes
-
#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -58,7 +57,7 @@ public:
SetBytes (const void *uuid_bytes, uint32_t num_uuid_bytes = 16);
std::string
- GetAsString (const char *separator = NULL) const;
+ GetAsString(const char *separator = nullptr) const;
size_t
SetFromCString (const char *c_str, uint32_t num_uuid_bytes = 16);
@@ -80,7 +79,7 @@ public:
/// decoded UUID.
///
/// @param[out] end
- /// If \a end is not NULL, it will be filled in with the a
+ /// If \a end is not nullptr, it will be filled in with the a
/// pointer to the character after the last successfully decoded
/// byte.
///
diff --git a/include/lldb/Core/UniqueCStringMap.h b/include/lldb/Core/UniqueCStringMap.h
index 972c0d53ea99..1e50f747f2a8 100644
--- a/include/lldb/Core/UniqueCStringMap.h
+++ b/include/lldb/Core/UniqueCStringMap.h
@@ -9,18 +9,18 @@
#ifndef liblldb_UniqueCStringMap_h_
#define liblldb_UniqueCStringMap_h_
-#if defined(__cplusplus)
-#include <assert.h>
+// C Includes
+// C++ Includes
#include <algorithm>
#include <vector>
+// Other libraries and framework includes
+// Project includes
#include "lldb/Core/RegularExpression.h"
namespace lldb_private {
-
-
//----------------------------------------------------------------------
// Templatized uniqued string map.
//
@@ -37,7 +37,7 @@ public:
struct Entry
{
Entry () :
- cstring(NULL),
+ cstring(nullptr),
value()
{
}
@@ -146,9 +146,7 @@ public:
const char *
GetCStringAtIndex (uint32_t idx) const
{
- if (idx < m_map.size())
- return m_map[idx].cstring;
- return NULL;
+ return ((idx < m_map.size()) ? m_map[idx].cstring : nullptr);
}
//------------------------------------------------------------------
@@ -172,8 +170,9 @@ public:
}
return fail_value;
}
+
//------------------------------------------------------------------
- // Get a pointer to the first entry that matches "name". NULL will
+ // 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
@@ -191,12 +190,12 @@ public:
if (pos_cstr == unique_cstr)
return &(*pos);
}
- return NULL;
+ return nullptr;
}
//------------------------------------------------------------------
// Get a pointer to the next entry that matches "name" from a
- // previously returned Entry pointer. NULL will be returned if there
+ // 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
@@ -216,7 +215,7 @@ public:
return next_entry;
}
}
- return NULL;
+ return nullptr;
}
size_t
@@ -261,7 +260,6 @@ public:
return m_map.size();
}
-
//------------------------------------------------------------------
// Returns true if this map is empty.
//------------------------------------------------------------------
@@ -346,6 +344,7 @@ public:
}
return num_removed;
}
+
protected:
typedef std::vector<Entry> collection;
typedef typename collection::iterator iterator;
@@ -353,9 +352,6 @@ protected:
collection m_map;
};
-
-
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // liblldb_UniqueCStringMap_h_
+#endif // liblldb_UniqueCStringMap_h_
diff --git a/include/lldb/Core/Value.h b/include/lldb/Core/Value.h
index 957cedeb0dcc..a6d934afd294 100644
--- a/include/lldb/Core/Value.h
+++ b/include/lldb/Core/Value.h
@@ -12,23 +12,21 @@
// C Includes
// C++ Includes
-#include <string>
#include <vector>
+
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
-#include "lldb/Core/ClangForward.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Scalar.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
namespace lldb_private {
class Value
{
public:
-
// Values Less than zero are an error, greater than or equal to zero
// returns what the Scalar result is.
enum ValueType
@@ -101,6 +99,7 @@ public:
// Casts a vector, if valid, to an unsigned int of matching or largest supported size.
// Truncates to the beginning of the vector if required.
// Returns a default constructed Scalar if the Vector data is internally inconsistent.
+ llvm::APInt rhs = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)bytes)->x);
Scalar
GetAsScalar() const
{
@@ -111,11 +110,7 @@ public:
else if (length == 2) scalar = *(const uint16_t *)bytes;
else if (length == 4) scalar = *(const uint32_t *)bytes;
else if (length == 8) scalar = *(const uint64_t *)bytes;
-#if defined (ENABLE_128_BIT_SUPPORT)
- else if (length >= 16) scalar = *(const __uint128_t *)bytes;
-#else
- else if (length >= 16) scalar = *(const uint64_t *)bytes;
-#endif
+ else if (length >= 16) scalar = rhs;
}
return scalar;
}
@@ -136,11 +131,11 @@ public:
Value &
operator=(const Value &rhs);
- const ClangASTType &
- GetClangType();
+ const CompilerType &
+ GetCompilerType();
void
- SetClangType (const ClangASTType &clang_type);
+ SetCompilerType (const CompilerType &compiler_type);
ValueType
GetValueType() const;
@@ -163,7 +158,7 @@ public:
void
ClearContext ()
{
- m_context = NULL;
+ m_context = nullptr;
m_context_type = eContextTypeInvalid;
}
@@ -269,13 +264,13 @@ public:
GetValueDefaultFormat ();
uint64_t
- GetValueByteSize (Error *error_ptr);
+ GetValueByteSize (Error *error_ptr, ExecutionContext *exe_ctx);
Error
- GetValueAsData (ExecutionContext *exe_ctx,
- DataExtractor &data,
- uint32_t data_offset,
- Module *module); // Can be NULL
+ GetValueAsData(ExecutionContext *exe_ctx,
+ DataExtractor &data,
+ uint32_t data_offset,
+ Module *module); // Can be nullptr
static const char *
GetValueTypeAsCString (ValueType context_type);
@@ -292,7 +287,7 @@ public:
protected:
Scalar m_value;
Vector m_vector;
- ClangASTType m_clang_type;
+ CompilerType m_compiler_type;
void * m_context;
ValueType m_value_type;
ContextType m_context_type;
@@ -309,9 +304,7 @@ public:
ValueList (const ValueList &rhs);
- ~ValueList ()
- {
- }
+ ~ValueList() = default;
const ValueList & operator= (const ValueList &rhs);
@@ -322,8 +315,6 @@ public:
Value *GetValueAtIndex(size_t idx);
void Clear();
-protected:
-
private:
typedef std::vector<Value> collection;
@@ -332,4 +323,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_Value_h_
+#endif // liblldb_Value_h_
diff --git a/include/lldb/Core/ValueObject.h b/include/lldb/Core/ValueObject.h
index cdc507093b28..c066cc7d3661 100644
--- a/include/lldb/Core/ValueObject.h
+++ b/include/lldb/Core/ValueObject.h
@@ -12,6 +12,8 @@
// C Includes
// C++ Includes
+#include <functional>
+#include <initializer_list>
#include <map>
#include <vector>
@@ -27,7 +29,7 @@
#include "lldb/Core/ConstString.h"
#include "lldb/Core/UserID.h"
#include "lldb/Core/Value.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/ExecutionContextScope.h"
#include "lldb/Target/Process.h"
@@ -69,7 +71,6 @@ namespace lldb_private {
class ValueObject : public UserID
{
public:
-
enum GetExpressionPathFormat
{
eGetExpressionPathFormatDereferencePointers = 1,
@@ -221,13 +222,11 @@ public:
return g_default_options;
}
-
};
class EvaluationPoint
{
public:
-
EvaluationPoint ();
EvaluationPoint (ExecutionContextScope *exe_scope, bool use_selected = false);
@@ -326,6 +325,8 @@ public:
bool m_needs_update;
};
+ virtual ~ValueObject();
+
const EvaluationPoint &
GetUpdatePoint () const
{
@@ -371,10 +372,8 @@ public:
void
SetNeedsUpdate ();
- virtual ~ValueObject();
-
- ClangASTType
- GetClangType ();
+ CompilerType
+ GetCompilerType ();
// this vends a TypeImpl that is useful at the SB API layer
virtual TypeImpl
@@ -408,7 +407,7 @@ public:
GetObjectRuntimeLanguage();
virtual uint32_t
- GetTypeInfo (ClangASTType *pointee_or_element_clang_type = NULL);
+ GetTypeInfo(CompilerType *pointee_or_element_compiler_type = nullptr);
virtual bool
IsPointerType ();
@@ -425,8 +424,11 @@ public:
virtual bool
IsPossibleDynamicType ();
- virtual bool
- IsObjCNil ();
+ bool
+ IsNilReference ();
+
+ bool
+ IsUninitializedReference ();
virtual bool
IsBaseClass ()
@@ -454,20 +456,20 @@ public:
lldb::ValueObjectSP
GetValueForExpressionPath(const char* expression,
- const char** first_unparsed = NULL,
- ExpressionPathScanEndReason* reason_to_stop = NULL,
- ExpressionPathEndResultType* final_value_type = NULL,
+ const char** first_unparsed = nullptr,
+ ExpressionPathScanEndReason* reason_to_stop = nullptr,
+ ExpressionPathEndResultType* final_value_type = nullptr,
const GetValueForExpressionPathOptions& options = GetValueForExpressionPathOptions::DefaultOptions(),
- ExpressionPathAftermath* final_task_on_target = NULL);
+ ExpressionPathAftermath* final_task_on_target = nullptr);
int
GetValuesForExpressionPath(const char* expression,
lldb::ValueObjectListSP& list,
- const char** first_unparsed = NULL,
- ExpressionPathScanEndReason* reason_to_stop = NULL,
- ExpressionPathEndResultType* final_value_type = NULL,
+ const char** first_unparsed = nullptr,
+ ExpressionPathScanEndReason* reason_to_stop = nullptr,
+ ExpressionPathEndResultType* final_value_type = nullptr,
const GetValueForExpressionPathOptions& options = GetValueForExpressionPathOptions::DefaultOptions(),
- ExpressionPathAftermath* final_task_on_target = NULL);
+ ExpressionPathAftermath* final_task_on_target = nullptr);
virtual bool
IsInScope ()
@@ -517,10 +519,10 @@ public:
std::string& destination);
virtual uint64_t
- GetValueAsUnsigned (uint64_t fail_value, bool *success = NULL);
+ GetValueAsUnsigned(uint64_t fail_value, bool *success = nullptr);
virtual int64_t
- GetValueAsSigned (int64_t fail_value, bool *success = NULL);
+ GetValueAsSigned(int64_t fail_value, bool *success = nullptr);
virtual bool
SetValueFromCString (const char *value_str, Error& error);
@@ -556,37 +558,37 @@ public:
// this will always create the children if necessary
lldb::ValueObjectSP
- GetChildAtIndexPath (const std::initializer_list<size_t> &idxs,
- size_t* index_of_error = NULL);
+ GetChildAtIndexPath(const std::initializer_list<size_t> &idxs,
+ size_t* index_of_error = nullptr);
lldb::ValueObjectSP
- GetChildAtIndexPath (const std::vector<size_t> &idxs,
- size_t* index_of_error = NULL);
+ GetChildAtIndexPath(const std::vector<size_t> &idxs,
+ size_t* index_of_error = nullptr);
lldb::ValueObjectSP
- GetChildAtIndexPath (const std::initializer_list< std::pair<size_t, bool> > &idxs,
- size_t* index_of_error = NULL);
+ GetChildAtIndexPath(const std::initializer_list< std::pair<size_t, bool> > &idxs,
+ size_t* index_of_error = nullptr);
lldb::ValueObjectSP
- GetChildAtIndexPath (const std::vector< std::pair<size_t, bool> > &idxs,
- size_t* index_of_error = NULL);
+ GetChildAtIndexPath(const std::vector< std::pair<size_t, bool> > &idxs,
+ size_t* index_of_error = nullptr);
// this will always create the children if necessary
lldb::ValueObjectSP
- GetChildAtNamePath (const std::initializer_list<ConstString> &names,
- ConstString* name_of_error = NULL);
+ GetChildAtNamePath(const std::initializer_list<ConstString> &names,
+ ConstString* name_of_error = nullptr);
lldb::ValueObjectSP
- GetChildAtNamePath (const std::vector<ConstString> &names,
- ConstString* name_of_error = NULL);
+ GetChildAtNamePath(const std::vector<ConstString> &names,
+ ConstString* name_of_error = nullptr);
lldb::ValueObjectSP
- GetChildAtNamePath (const std::initializer_list< std::pair<ConstString, bool> > &names,
- ConstString* name_of_error = NULL);
+ GetChildAtNamePath(const std::initializer_list< std::pair<ConstString, bool> > &names,
+ ConstString* name_of_error = nullptr);
lldb::ValueObjectSP
- GetChildAtNamePath (const std::vector< std::pair<ConstString, bool> > &names,
- ConstString* name_of_error = NULL);
+ GetChildAtNamePath(const std::vector< std::pair<ConstString, bool> > &names,
+ ConstString* name_of_error = nullptr);
virtual lldb::ValueObjectSP
GetChildMemberWithName (const ConstString &name, bool can_create);
@@ -595,7 +597,7 @@ public:
GetIndexOfChildWithName (const ConstString &name);
size_t
- GetNumChildren ();
+ GetNumChildren (uint32_t max=UINT32_MAX);
const Value &
GetValue() const;
@@ -606,15 +608,22 @@ public:
virtual bool
ResolveValue (Scalar &scalar);
+ // return 'false' whenever you set the error, otherwise
+ // callers may assume true means everything is OK - this will
+ // break breakpoint conditions among potentially a few others
+ virtual bool
+ IsLogicalTrue (Error& error);
+
virtual const char *
GetLocationAsCString ();
const char *
- GetSummaryAsCString ();
+ GetSummaryAsCString (lldb::LanguageType lang = lldb::eLanguageTypeUnknown);
bool
GetSummaryAsCString (TypeSummaryImpl* summary_ptr,
- std::string& destination);
+ std::string& destination,
+ lldb::LanguageType lang = lldb::eLanguageTypeUnknown);
bool
GetSummaryAsCString (std::string& destination,
@@ -671,11 +680,11 @@ public:
SetName (const ConstString &name);
virtual lldb::addr_t
- GetAddressOf (bool scalar_is_load_address = true,
- AddressType *address_type = NULL);
+ GetAddressOf(bool scalar_is_load_address = true,
+ AddressType *address_type = nullptr);
lldb::addr_t
- GetPointerValue (AddressType *address_type = NULL);
+ GetPointerValue(AddressType *address_type = nullptr);
lldb::ValueObjectSP
GetSyntheticChild (const ConstString &key) const;
@@ -690,10 +699,10 @@ public:
GetSyntheticExpressionPathChild(const char* expression, bool can_create);
virtual lldb::ValueObjectSP
- GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create);
+ GetSyntheticChildAtOffset(uint32_t offset, const CompilerType& type, bool can_create);
virtual lldb::ValueObjectSP
- GetSyntheticBase (uint32_t offset, const ClangASTType& type, bool can_create);
+ GetSyntheticBase (uint32_t offset, const CompilerType& type, bool can_create);
virtual lldb::ValueObjectSP
GetDynamicValue (lldb::DynamicValueType valueType);
@@ -746,11 +755,11 @@ public:
GetCPPVTableAddress(AddressType &address_type);
virtual lldb::ValueObjectSP
- Cast (const ClangASTType &clang_ast_type);
+ Cast (const CompilerType &compiler_type);
virtual lldb::ValueObjectSP
CastPointerType (const char *name,
- ClangASTType &ast_type);
+ CompilerType &ast_type);
virtual lldb::ValueObjectSP
CastPointerType (const char *name,
@@ -809,13 +818,13 @@ public:
CreateValueObjectFromAddress (const char* name,
uint64_t address,
const ExecutionContext& exe_ctx,
- ClangASTType type);
+ CompilerType type);
static lldb::ValueObjectSP
CreateValueObjectFromData (const char* name,
const DataExtractor& data,
const ExecutionContext& exe_ctx,
- ClangASTType type);
+ CompilerType type);
void
LogValueObject (Log *log);
@@ -834,7 +843,7 @@ public:
bool
IsCStringContainer (bool check_pointer = false);
- size_t
+ std::pair<size_t,bool>
ReadPointedString (lldb::DataBufferSP& buffer_sp,
Error& error,
uint32_t max_length = 0,
@@ -861,7 +870,7 @@ public:
bool
NeedsUpdating ()
{
- const bool accept_invalid_exe_ctx = CanUpdateWithInvalidExecutionContext();
+ const bool accept_invalid_exe_ctx = (CanUpdateWithInvalidExecutionContext() == eLazyBoolYes);
return m_update_point.NeedsUpdating(accept_invalid_exe_ctx);
}
@@ -881,8 +890,7 @@ public:
ClearUserVisibleData(eClearUserVisibleDataItemsValue);
m_format = format;
}
-
-
+
virtual lldb::LanguageType
GetPreferredDisplayLanguage ();
@@ -999,8 +1007,20 @@ public:
virtual bool
MightHaveChildren();
+ virtual lldb::VariableSP
+ GetVariable ()
+ {
+ return nullptr;
+ }
+
virtual bool
IsRuntimeSupportValue ();
+
+ virtual uint64_t
+ GetLanguageFlags ();
+
+ virtual void
+ SetLanguageFlags (uint64_t flags);
protected:
typedef ClusterManager<ValueObject> ValueObjectManager;
@@ -1018,21 +1038,15 @@ protected:
HasChildAtIndex (size_t idx)
{
Mutex::Locker locker(m_mutex);
- ChildrenIterator iter = m_children.find(idx);
- ChildrenIterator end = m_children.end();
- return (iter != end);
+ return (m_children.find(idx) != m_children.end());
}
ValueObject*
GetChildAtIndex (size_t idx)
{
Mutex::Locker locker(m_mutex);
- ChildrenIterator iter = m_children.find(idx);
- ChildrenIterator end = m_children.end();
- if (iter == end)
- return NULL;
- else
- return iter->second;
+ const auto iter = m_children.find(idx);
+ return ((iter == m_children.end()) ? nullptr : iter->second);
}
void
@@ -1075,8 +1089,8 @@ protected:
//------------------------------------------------------------------
// Classes that inherit from ValueObject can see and modify these
//------------------------------------------------------------------
- ValueObject * m_parent; // The parent value object, or NULL if this has no parent
- ValueObject * m_root; // The root of the hierarchy for this ValueObject (or NULL if never calculated)
+ ValueObject * m_parent; // The parent value object, or nullptr if this has no parent
+ ValueObject * m_root; // The root of the hierarchy for this ValueObject (or nullptr if never calculated)
EvaluationPoint m_update_point; // Stores both the stop id and the full context at which this value was last
// updated. When we are asked to update the value object, we check whether
// the context & stop id are the same before updating.
@@ -1093,7 +1107,7 @@ protected:
llvm::Optional<std::pair<TypeValidatorResult, std::string>> m_validation_result;
- ClangASTType m_override_type;// If the type of the value object should be overridden, the type to impose.
+ CompilerType m_override_type;// If the type of the value object should be overridden, the type to impose.
ValueObjectManager *m_manager; // This object is managed by the root object (any ValueObject that gets created
// without a parent.) The manager gets passed through all the generations of
@@ -1125,6 +1139,8 @@ protected:
lldb::LanguageType m_preferred_display_language;
+ uint64_t m_language_flags;
+
bool m_value_is_valid:1,
m_value_did_change:1,
m_children_count_valid:1,
@@ -1139,7 +1155,7 @@ protected:
friend class ValueObjectChild;
friend class ClangExpressionDeclMap; // For GetValue
- friend class ClangExpressionVariable; // For SetName
+ friend class ExpressionVariable; // For SetName
friend class Target; // For SetName
friend class ValueObjectConstResultImpl;
friend class ValueObjectSynthetic; // For ClearUserVisibleData
@@ -1172,10 +1188,10 @@ protected:
virtual bool
UpdateValue () = 0;
- virtual bool
+ virtual LazyBool
CanUpdateWithInvalidExecutionContext ()
{
- return false;
+ return eLazyBoolCalculate;
}
virtual void
@@ -1203,7 +1219,7 @@ protected:
// Should only be called by ValueObject::GetNumChildren()
virtual size_t
- CalculateNumChildren() = 0;
+ CalculateNumChildren(uint32_t max=UINT32_MAX) = 0;
void
SetNumChildren (size_t num_children);
@@ -1231,8 +1247,8 @@ protected:
// Subclasses must implement the functions below.
//------------------------------------------------------------------
- virtual ClangASTType
- GetClangTypeImpl () = 0;
+ virtual CompilerType
+ GetCompilerTypeImpl () = 0;
const char *
GetLocationAsCStringImpl (const Value& value,
@@ -1241,12 +1257,11 @@ protected:
bool
IsChecksumEmpty ();
-private:
- //------------------------------------------------------------------
- // For ValueObject only
- //------------------------------------------------------------------
+ void
+ SetPreferredDisplayLanguageIfNeeded (lldb::LanguageType);
- virtual ClangASTType
+private:
+ virtual CompilerType
MaybeCalculateCompleteType ();
lldb::ValueObjectSP
@@ -1270,12 +1285,10 @@ private:
ExpressionPathEndResultType* final_value_type,
const GetValueForExpressionPathOptions& options,
ExpressionPathAftermath* final_task_on_target);
-
-
- DISALLOW_COPY_AND_ASSIGN (ValueObject);
+ DISALLOW_COPY_AND_ASSIGN (ValueObject);
};
} // namespace lldb_private
-#endif // liblldb_ValueObject_h_
+#endif // liblldb_ValueObject_h_
diff --git a/include/lldb/Core/ValueObjectCast.h b/include/lldb/Core/ValueObjectCast.h
index 1538d7a55639..8c7ffe5ec5e2 100644
--- a/include/lldb/Core/ValueObjectCast.h
+++ b/include/lldb/Core/ValueObjectCast.h
@@ -1,4 +1,4 @@
-//===-- ValueObjectDynamicValue.h -----------------------------------*- C++ -*-===//
+//===-- ValueObjectDynamicValue.h -------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -24,64 +24,54 @@ namespace lldb_private {
class ValueObjectCast : public ValueObject
{
public:
+ ~ValueObjectCast() override;
+
static lldb::ValueObjectSP
Create (ValueObject &parent,
const ConstString &name,
- const ClangASTType &cast_type);
+ const CompilerType &cast_type);
- virtual
- ~ValueObjectCast();
-
- virtual uint64_t
- GetByteSize();
+ uint64_t
+ GetByteSize() override;
- virtual size_t
- CalculateNumChildren();
+ size_t
+ CalculateNumChildren(uint32_t max) override;
- virtual lldb::ValueType
- GetValueType() const;
+ lldb::ValueType
+ GetValueType() const override;
- virtual bool
- IsInScope ();
+ bool
+ IsInScope() override;
- virtual ValueObject *
- GetParent()
+ ValueObject *
+ GetParent() override
{
- if (m_parent)
- return m_parent->GetParent();
- else
- return NULL;
+ return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
}
- virtual const ValueObject *
- GetParent() const
+ const ValueObject *
+ GetParent() const override
{
- if (m_parent)
- return m_parent->GetParent();
- else
- return NULL;
+ return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
}
protected:
- virtual bool
- UpdateValue ();
+ ValueObjectCast(ValueObject &parent,
+ const ConstString &name,
+ const CompilerType &cast_type);
+
+ bool
+ UpdateValue () override;
- virtual ClangASTType
- GetClangTypeImpl ();
+ CompilerType
+ GetCompilerTypeImpl () override;
- ClangASTType m_cast_type;
+ CompilerType m_cast_type;
private:
- ValueObjectCast (ValueObject &parent,
- const ConstString &name,
- const ClangASTType &cast_type);
-
- //------------------------------------------------------------------
- // For ValueObject only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (ValueObjectCast);
};
} // namespace lldb_private
-#endif // liblldb_ValueObjectCast_h_
+#endif // liblldb_ValueObjectCast_h_
diff --git a/include/lldb/Core/ValueObjectChild.h b/include/lldb/Core/ValueObjectChild.h
index bf8707ea3b05..13e26c6ab0c1 100644
--- a/include/lldb/Core/ValueObjectChild.h
+++ b/include/lldb/Core/ValueObjectChild.h
@@ -16,6 +16,8 @@
// Project includes
#include "lldb/Core/ValueObject.h"
+#include "llvm/ADT/Optional.h"
+
namespace lldb_private {
//----------------------------------------------------------------------
@@ -24,76 +26,76 @@ namespace lldb_private {
class ValueObjectChild : public ValueObject
{
public:
- virtual ~ValueObjectChild();
+ ~ValueObjectChild() override;
- virtual uint64_t
- GetByteSize()
+ uint64_t
+ GetByteSize() override
{
return m_byte_size;
}
- virtual lldb::offset_t
- GetByteOffset()
+ lldb::offset_t
+ GetByteOffset() override
{
return m_byte_offset;
}
- virtual uint32_t
- GetBitfieldBitSize()
+ uint32_t
+ GetBitfieldBitSize() override
{
return m_bitfield_bit_size;
}
- virtual uint32_t
- GetBitfieldBitOffset()
+ uint32_t
+ GetBitfieldBitOffset() override
{
return m_bitfield_bit_offset;
}
- virtual lldb::ValueType
- GetValueType() const;
+ lldb::ValueType
+ GetValueType() const override;
- virtual size_t
- CalculateNumChildren();
+ size_t
+ CalculateNumChildren(uint32_t max) override;
- virtual ConstString
- GetTypeName();
+ ConstString
+ GetTypeName() override;
- virtual ConstString
- GetQualifiedTypeName();
+ ConstString
+ GetQualifiedTypeName() override;
- virtual ConstString
- GetDisplayTypeName();
+ ConstString
+ GetDisplayTypeName() override;
- virtual bool
- IsInScope ();
+ bool
+ IsInScope() override;
- virtual bool
- IsBaseClass ()
+ bool
+ IsBaseClass() override
{
return m_is_base_class;
}
- virtual bool
- IsDereferenceOfParent ()
+ bool
+ IsDereferenceOfParent() override
{
return m_is_deref_of_parent;
}
protected:
- virtual bool
- UpdateValue ();
+ bool
+ UpdateValue() override;
- virtual bool
- CanUpdateWithInvalidExecutionContext ();
+ LazyBool
+ CanUpdateWithInvalidExecutionContext() override;
- virtual ClangASTType
- GetClangTypeImpl ()
+ CompilerType
+ GetCompilerTypeImpl() override
{
- return m_clang_type;
+ return m_compiler_type;
}
- ClangASTType m_clang_type;
+ CompilerType m_compiler_type;
ConstString m_type_name;
uint64_t m_byte_size;
int32_t m_byte_offset;
@@ -101,6 +103,7 @@ protected:
uint8_t m_bitfield_bit_offset;
bool m_is_base_class;
bool m_is_deref_of_parent;
+ llvm::Optional<LazyBool> m_can_update_with_invalid_exe_ctx;
//
// void
@@ -110,8 +113,9 @@ protected:
friend class ValueObject;
friend class ValueObjectConstResult;
friend class ValueObjectConstResultImpl;
+
ValueObjectChild (ValueObject &parent,
- const ClangASTType &clang_type,
+ const CompilerType &compiler_type,
const ConstString &name,
uint64_t byte_size,
int32_t byte_offset,
@@ -119,11 +123,12 @@ protected:
uint32_t bitfield_bit_offset,
bool is_base_class,
bool is_deref_of_parent,
- AddressType child_ptr_or_ref_addr_type);
+ AddressType child_ptr_or_ref_addr_type,
+ uint64_t language_flags);
DISALLOW_COPY_AND_ASSIGN (ValueObjectChild);
};
} // namespace lldb_private
-#endif // liblldb_ValueObjectChild_h_
+#endif // liblldb_ValueObjectChild_h_
diff --git a/include/lldb/Core/ValueObjectConstResult.h b/include/lldb/Core/ValueObjectConstResult.h
index 4e05d50132ec..f63ee83284df 100644
--- a/include/lldb/Core/ValueObjectConstResult.h
+++ b/include/lldb/Core/ValueObjectConstResult.h
@@ -26,6 +26,8 @@ namespace lldb_private {
class ValueObjectConstResult : public ValueObject
{
public:
+ ~ValueObjectConstResult() override;
+
static lldb::ValueObjectSP
Create (ExecutionContextScope *exe_scope,
lldb::ByteOrder byte_order,
@@ -34,14 +36,14 @@ public:
static lldb::ValueObjectSP
Create (ExecutionContextScope *exe_scope,
- const ClangASTType &clang_type,
+ const CompilerType &compiler_type,
const ConstString &name,
const DataExtractor &data,
lldb::addr_t address = LLDB_INVALID_ADDRESS);
static lldb::ValueObjectSP
Create (ExecutionContextScope *exe_scope,
- const ClangASTType &clang_type,
+ const CompilerType &compiler_type,
const ConstString &name,
const lldb::DataBufferSP &result_data_sp,
lldb::ByteOrder byte_order,
@@ -50,7 +52,7 @@ public:
static lldb::ValueObjectSP
Create (ExecutionContextScope *exe_scope,
- const ClangASTType &clang_type,
+ const CompilerType &compiler_type,
const ConstString &name,
lldb::addr_t address,
AddressType address_type,
@@ -67,76 +69,76 @@ public:
Create (ExecutionContextScope *exe_scope,
const Error& error);
- virtual ~ValueObjectConstResult();
-
- virtual uint64_t
- GetByteSize();
+ uint64_t
+ GetByteSize() override;
- virtual lldb::ValueType
- GetValueType() const;
+ lldb::ValueType
+ GetValueType() const override;
- virtual size_t
- CalculateNumChildren();
+ size_t
+ CalculateNumChildren(uint32_t max) override;
- virtual ConstString
- GetTypeName();
+ ConstString
+ GetTypeName() override;
- virtual ConstString
- GetDisplayTypeName();
+ ConstString
+ GetDisplayTypeName() override;
- virtual bool
- IsInScope ();
+ bool
+ IsInScope() override;
void
SetByteSize (size_t size);
- virtual lldb::ValueObjectSP
- Dereference (Error &error);
+ lldb::ValueObjectSP
+ Dereference(Error &error) override;
- virtual ValueObject *
- CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index);
+ ValueObject *
+ CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index) override;
- virtual lldb::ValueObjectSP
- GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create);
+ lldb::ValueObjectSP
+ GetSyntheticChildAtOffset(uint32_t offset, const CompilerType& type, bool can_create) override;
- virtual lldb::ValueObjectSP
- AddressOf (Error &error);
+ lldb::ValueObjectSP
+ AddressOf(Error &error) override;
- virtual lldb::addr_t
- GetAddressOf (bool scalar_is_load_address = true,
- AddressType *address_type = NULL);
+ lldb::addr_t
+ GetAddressOf(bool scalar_is_load_address = true,
+ AddressType *address_type = nullptr) override;
- virtual size_t
- GetPointeeData (DataExtractor& data,
- uint32_t item_idx = 0,
- uint32_t item_count = 1);
+ size_t
+ GetPointeeData(DataExtractor& data,
+ uint32_t item_idx = 0,
+ uint32_t item_count = 1) override;
- virtual lldb::addr_t
- GetLiveAddress()
+ lldb::addr_t
+ GetLiveAddress() override
{
return m_impl.GetLiveAddress();
}
- virtual void
+ void
SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS,
- AddressType address_type = eAddressTypeLoad)
+ AddressType address_type = eAddressTypeLoad) override
{
- m_impl.SetLiveAddress(addr,
- address_type);
+ m_impl.SetLiveAddress(addr, address_type);
}
- virtual lldb::ValueObjectSP
- GetDynamicValue (lldb::DynamicValueType valueType);
+ lldb::ValueObjectSP
+ GetDynamicValue(lldb::DynamicValueType valueType) override;
- virtual lldb::LanguageType
- GetPreferredDisplayLanguage ();
+ lldb::LanguageType
+ GetPreferredDisplayLanguage() override;
+
+ lldb::ValueObjectSP
+ Cast(const CompilerType &compiler_type) override;
protected:
- virtual bool
- UpdateValue ();
+ bool
+ UpdateValue() override;
- virtual ClangASTType
- GetClangTypeImpl ();
+ CompilerType
+ GetCompilerTypeImpl() override;
ConstString m_type_name;
uint64_t m_byte_size;
@@ -145,19 +147,20 @@ protected:
private:
friend class ValueObjectConstResultImpl;
+
ValueObjectConstResult (ExecutionContextScope *exe_scope,
lldb::ByteOrder byte_order,
uint32_t addr_byte_size,
lldb::addr_t address);
ValueObjectConstResult (ExecutionContextScope *exe_scope,
- const ClangASTType &clang_type,
+ const CompilerType &compiler_type,
const ConstString &name,
const DataExtractor &data,
lldb::addr_t address);
ValueObjectConstResult (ExecutionContextScope *exe_scope,
- const ClangASTType &clang_type,
+ const CompilerType &compiler_type,
const ConstString &name,
const lldb::DataBufferSP &result_data_sp,
lldb::ByteOrder byte_order,
@@ -165,7 +168,7 @@ private:
lldb::addr_t address);
ValueObjectConstResult (ExecutionContextScope *exe_scope,
- const ClangASTType &clang_type,
+ const CompilerType &compiler_type,
const ConstString &name,
lldb::addr_t address,
AddressType address_type,
@@ -184,4 +187,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ValueObjectConstResult_h_
+#endif // liblldb_ValueObjectConstResult_h_
diff --git a/include/lldb/Core/ValueObjectConstResultCast.h b/include/lldb/Core/ValueObjectConstResultCast.h
new file mode 100644
index 000000000000..395820dad6c7
--- /dev/null
+++ b/include/lldb/Core/ValueObjectConstResultCast.h
@@ -0,0 +1,76 @@
+//===-- ValueObjectConstResultCast.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_ValueObjectConstResultCast_h_
+#define liblldb_ValueObjectConstResultCast_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/ValueObjectCast.h"
+#include "lldb/Core/ValueObjectConstResultImpl.h"
+
+namespace lldb_private {
+
+class ValueObjectConstResultCast : public ValueObjectCast
+{
+public:
+ ValueObjectConstResultCast (
+ ValueObject &parent,
+ const ConstString &name,
+ const CompilerType &cast_type,
+ lldb::addr_t live_address = LLDB_INVALID_ADDRESS);
+
+ ~ValueObjectConstResultCast() override;
+
+ lldb::ValueObjectSP
+ Dereference(Error &error) override;
+
+ ValueObject *
+ CreateChildAtIndex(size_t idx,
+ bool synthetic_array_member,
+ int32_t synthetic_index) override;
+
+ virtual CompilerType
+ GetCompilerType ()
+ {
+ return ValueObjectCast::GetCompilerType();
+ }
+
+ lldb::ValueObjectSP
+ GetSyntheticChildAtOffset(uint32_t offset,
+ const CompilerType& type,
+ bool can_create) override;
+
+ lldb::ValueObjectSP
+ AddressOf (Error &error) override;
+
+ size_t
+ GetPointeeData (DataExtractor& data,
+ uint32_t item_idx = 0,
+ uint32_t item_count = 1) override;
+
+ lldb::ValueObjectSP
+ Cast (const CompilerType &compiler_type) override;
+
+protected:
+ ValueObjectConstResultImpl m_impl;
+
+private:
+ friend class ValueObject;
+ friend class ValueObjectConstResult;
+ friend class ValueObjectConstResultImpl;
+
+ DISALLOW_COPY_AND_ASSIGN (ValueObjectConstResultCast);
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_ValueObjectConstResultCast_h_
diff --git a/include/lldb/Core/ValueObjectConstResultChild.h b/include/lldb/Core/ValueObjectConstResultChild.h
index 9063276b0198..356d175a64ae 100644
--- a/include/lldb/Core/ValueObjectConstResultChild.h
+++ b/include/lldb/Core/ValueObjectConstResultChild.h
@@ -27,39 +27,44 @@ class ValueObjectConstResultChild : public ValueObjectChild
public:
ValueObjectConstResultChild (ValueObject &parent,
- const ClangASTType &clang_type,
+ const CompilerType &compiler_type,
const ConstString &name,
uint32_t byte_size,
int32_t byte_offset,
uint32_t bitfield_bit_size,
uint32_t bitfield_bit_offset,
bool is_base_class,
- bool is_deref_of_parent);
+ bool is_deref_of_parent,
+ lldb::addr_t live_address,
+ uint64_t language_flags);
- virtual ~ValueObjectConstResultChild();
+ ~ValueObjectConstResultChild() override;
- virtual lldb::ValueObjectSP
- Dereference (Error &error);
+ lldb::ValueObjectSP
+ Dereference(Error &error) override;
- virtual ValueObject *
- CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index);
+ ValueObject *
+ CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index) override;
- virtual ClangASTType
- GetClangType ()
+ virtual CompilerType
+ GetCompilerType ()
{
- return ValueObjectChild::GetClangType();
+ return ValueObjectChild::GetCompilerType();
}
- virtual lldb::ValueObjectSP
- GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create);
+ lldb::ValueObjectSP
+ GetSyntheticChildAtOffset(uint32_t offset, const CompilerType& type, bool can_create) override;
- virtual lldb::ValueObjectSP
- AddressOf (Error &error);
+ lldb::ValueObjectSP
+ AddressOf (Error &error) override;
- virtual size_t
+ size_t
GetPointeeData (DataExtractor& data,
uint32_t item_idx = 0,
- uint32_t item_count = 1);
+ uint32_t item_count = 1) override;
+
+ lldb::ValueObjectSP
+ Cast (const CompilerType &compiler_type) override;
protected:
ValueObjectConstResultImpl m_impl;
@@ -74,4 +79,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ValueObjectConstResultChild_h_
+#endif // liblldb_ValueObjectConstResultChild_h_
diff --git a/include/lldb/Core/ValueObjectConstResultImpl.h b/include/lldb/Core/ValueObjectConstResultImpl.h
index e3574e8a4d4e..36b82f00a240 100644
--- a/include/lldb/Core/ValueObjectConstResultImpl.h
+++ b/include/lldb/Core/ValueObjectConstResultImpl.h
@@ -1,4 +1,4 @@
-//===-- ValueObjectConstResultImpl.h -----------------------------*- C++ -*-===//
+//===-- ValueObjectConstResultImpl.h ----------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -26,15 +26,12 @@ namespace lldb_private {
class ValueObjectConstResultImpl
{
public:
-
ValueObjectConstResultImpl (ValueObject* valobj,
lldb::addr_t live_address = LLDB_INVALID_ADDRESS);
-
+
virtual
- ~ValueObjectConstResultImpl()
- {
- }
-
+ ~ValueObjectConstResultImpl() = default;
+
lldb::ValueObjectSP
Dereference (Error &error);
@@ -42,7 +39,7 @@ public:
CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index);
lldb::ValueObjectSP
- GetSyntheticChildAtOffset (uint32_t offset, const ClangASTType& type, bool can_create);
+ GetSyntheticChildAtOffset (uint32_t offset, const CompilerType& type, bool can_create);
lldb::ValueObjectSP
AddressOf (Error &error);
@@ -52,6 +49,9 @@ public:
{
return m_live_address;
}
+
+ lldb::ValueObjectSP
+ Cast (const CompilerType &compiler_type);
void
SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS,
@@ -62,16 +62,15 @@ public:
}
virtual lldb::addr_t
- GetAddressOf (bool scalar_is_load_address = true,
- AddressType *address_type = NULL);
+ GetAddressOf(bool scalar_is_load_address = true,
+ AddressType *address_type = nullptr);
virtual size_t
- GetPointeeData (DataExtractor& data,
- uint32_t item_idx = 0,
- uint32_t item_count = 1);
+ GetPointeeData(DataExtractor& data,
+ uint32_t item_idx = 0,
+ uint32_t item_count = 1);
private:
-
ValueObject *m_impl_backend;
lldb::addr_t m_live_address;
AddressType m_live_address_type;
@@ -83,4 +82,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ValueObjectConstResultImpl_h_
+#endif // liblldb_ValueObjectConstResultImpl_h_
diff --git a/include/lldb/Core/ValueObjectDynamicValue.h b/include/lldb/Core/ValueObjectDynamicValue.h
index 8d42706be166..80f37f104765 100644
--- a/include/lldb/Core/ValueObjectDynamicValue.h
+++ b/include/lldb/Core/ValueObjectDynamicValue.h
@@ -1,4 +1,4 @@
-//===-- ValueObjectDynamicValue.h -----------------------------------*- C++ -*-===//
+//===-- ValueObjectDynamicValue.h -------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -26,109 +26,131 @@ namespace lldb_private {
class ValueObjectDynamicValue : public ValueObject
{
public:
- virtual
- ~ValueObjectDynamicValue();
+ ~ValueObjectDynamicValue() override;
- virtual uint64_t
- GetByteSize();
+ uint64_t
+ GetByteSize() override;
- virtual ConstString
- GetTypeName();
+ ConstString
+ GetTypeName() override;
- virtual ConstString
- GetQualifiedTypeName();
+ ConstString
+ GetQualifiedTypeName() override;
- virtual ConstString
- GetDisplayTypeName();
+ ConstString
+ GetDisplayTypeName() override;
- virtual size_t
- CalculateNumChildren();
+ size_t
+ CalculateNumChildren(uint32_t max) override;
- virtual lldb::ValueType
- GetValueType() const;
+ lldb::ValueType
+ GetValueType() const override;
- virtual bool
- IsInScope ();
+ bool
+ IsInScope() override;
- virtual bool
- IsDynamic ()
+ bool
+ IsDynamic() override
{
return true;
}
- virtual bool
- GetIsConstant () const
+ bool
+ IsBaseClass () override
{
+ if (m_parent)
+ return m_parent->IsBaseClass();
return false;
}
- virtual ValueObject *
- GetParent()
+ bool
+ GetIsConstant() const override
{
- if (m_parent)
- return m_parent->GetParent();
- else
- return NULL;
+ return false;
+ }
+
+ ValueObject *
+ GetParent() override
+ {
+ return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
}
- virtual const ValueObject *
- GetParent() const
+ const ValueObject *
+ GetParent() const override
{
- if (m_parent)
- return m_parent->GetParent();
- else
- return NULL;
+ return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
}
- virtual lldb::ValueObjectSP
- GetStaticValue ()
+ lldb::ValueObjectSP
+ GetStaticValue() override
{
return m_parent->GetSP();
}
-
+
void
SetOwningSP (lldb::ValueObjectSP &owning_sp)
{
if (m_owning_valobj_sp == owning_sp)
return;
- assert (m_owning_valobj_sp.get() == NULL);
+ assert (m_owning_valobj_sp.get() == nullptr);
m_owning_valobj_sp = owning_sp;
}
- virtual bool
- SetValueFromCString (const char *value_str, Error& error);
+ bool
+ SetValueFromCString(const char *value_str, Error& error) override;
+
+ bool
+ SetData(DataExtractor &data, Error &error) override;
+
+ TypeImpl
+ GetTypeImpl() override;
+
+ lldb::VariableSP
+ GetVariable () override
+ {
+ return m_parent ? m_parent->GetVariable() : nullptr;
+ }
+
+ lldb::LanguageType
+ GetPreferredDisplayLanguage() override;
- virtual bool
- SetData (DataExtractor &data, Error &error);
+ void
+ SetPreferredDisplayLanguage (lldb::LanguageType);
+
+ bool
+ GetDeclaration(Declaration &decl) override;
- virtual TypeImpl
- GetTypeImpl ();
+ uint64_t
+ GetLanguageFlags () override;
+ void
+ SetLanguageFlags (uint64_t flags) override;
+
protected:
- virtual bool
- UpdateValue ();
+ bool
+ UpdateValue() override;
- virtual bool
- CanUpdateWithInvalidExecutionContext ()
+ LazyBool
+ CanUpdateWithInvalidExecutionContext() override
{
- return true;
+ return eLazyBoolYes;
}
- virtual lldb::DynamicValueType
- GetDynamicValueTypeImpl ()
+ lldb::DynamicValueType
+ GetDynamicValueTypeImpl() override
{
return m_use_dynamic;
}
- virtual bool
- HasDynamicValueTypeInfo ()
+ bool
+ HasDynamicValueTypeInfo() override
{
return true;
}
- virtual ClangASTType
- GetClangTypeImpl ();
+ CompilerType
+ GetCompilerTypeImpl() override;
Address m_address; ///< The variable that this value object is based upon
TypeAndOrName m_dynamic_type_info; // We can have a type_sp or just a name
@@ -141,12 +163,9 @@ private:
friend class ValueObjectConstResult;
ValueObjectDynamicValue (ValueObject &parent, lldb::DynamicValueType use_dynamic);
- //------------------------------------------------------------------
- // For ValueObject only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (ValueObjectDynamicValue);
};
} // namespace lldb_private
-#endif // liblldb_ValueObjectDynamicValue_h_
+#endif // liblldb_ValueObjectDynamicValue_h_
diff --git a/include/lldb/Core/ValueObjectList.h b/include/lldb/Core/ValueObjectList.h
index 6565367cc61c..4f5e7b246fbd 100644
--- a/include/lldb/Core/ValueObjectList.h
+++ b/include/lldb/Core/ValueObjectList.h
@@ -17,7 +17,6 @@
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
-#include "lldb/Core/ClangForward.h"
#include "lldb/Core/UserID.h"
#include "lldb/Target/ExecutionContextScope.h"
diff --git a/include/lldb/Core/ValueObjectMemory.h b/include/lldb/Core/ValueObjectMemory.h
index 41b43188a46a..0e12fc7e3f28 100644
--- a/include/lldb/Core/ValueObjectMemory.h
+++ b/include/lldb/Core/ValueObjectMemory.h
@@ -15,7 +15,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/ValueObject.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
namespace lldb_private {
@@ -26,6 +26,8 @@ namespace lldb_private {
class ValueObjectMemory : public ValueObject
{
public:
+ ~ValueObjectMemory() override;
+
static lldb::ValueObjectSP
Create (ExecutionContextScope *exe_scope,
const char *name,
@@ -36,42 +38,39 @@ public:
Create (ExecutionContextScope *exe_scope,
const char *name,
const Address &address,
- const ClangASTType &ast_type);
-
- virtual
- ~ValueObjectMemory();
+ const CompilerType &ast_type);
- virtual uint64_t
- GetByteSize();
+ uint64_t
+ GetByteSize() override;
- virtual ConstString
- GetTypeName();
+ ConstString
+ GetTypeName() override;
- virtual ConstString
- GetDisplayTypeName();
+ ConstString
+ GetDisplayTypeName() override;
- virtual size_t
- CalculateNumChildren();
+ size_t
+ CalculateNumChildren(uint32_t max) override;
- virtual lldb::ValueType
- GetValueType() const;
+ lldb::ValueType
+ GetValueType() const override;
- virtual bool
- IsInScope ();
+ bool
+ IsInScope() override;
- virtual lldb::ModuleSP
- GetModule();
+ lldb::ModuleSP
+ GetModule() override;
protected:
- virtual bool
- UpdateValue ();
+ bool
+ UpdateValue() override;
- virtual ClangASTType
- GetClangTypeImpl ();
+ CompilerType
+ GetCompilerTypeImpl() override;
Address m_address; ///< The variable that this value object is based upon
lldb::TypeSP m_type_sp;
- ClangASTType m_clang_type;
+ CompilerType m_compiler_type;
private:
ValueObjectMemory (ExecutionContextScope *exe_scope,
@@ -82,7 +81,7 @@ private:
ValueObjectMemory (ExecutionContextScope *exe_scope,
const char *name,
const Address &address,
- const ClangASTType &ast_type);
+ const CompilerType &ast_type);
//------------------------------------------------------------------
// For ValueObject only
//------------------------------------------------------------------
@@ -91,4 +90,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ValueObjectMemory_h_
+#endif // liblldb_ValueObjectMemory_h_
diff --git a/include/lldb/Core/ValueObjectRegister.h b/include/lldb/Core/ValueObjectRegister.h
index f7c7683d60bc..ac76f9e4280b 100644
--- a/include/lldb/Core/ValueObjectRegister.h
+++ b/include/lldb/Core/ValueObjectRegister.h
@@ -27,40 +27,38 @@ namespace lldb_private {
class ValueObjectRegisterContext : public ValueObject
{
public:
+ ~ValueObjectRegisterContext() override;
- virtual
- ~ValueObjectRegisterContext();
+ uint64_t
+ GetByteSize() override;
- virtual uint64_t
- GetByteSize();
-
- virtual lldb::ValueType
- GetValueType () const
+ lldb::ValueType
+ GetValueType() const override
{
return lldb::eValueTypeRegisterSet;
}
- virtual ConstString
- GetTypeName();
+ ConstString
+ GetTypeName() override;
- virtual ConstString
- GetQualifiedTypeName();
+ ConstString
+ GetQualifiedTypeName() override;
- virtual ConstString
- GetDisplayTypeName();
+ ConstString
+ GetDisplayTypeName() override;
- virtual size_t
- CalculateNumChildren();
+ size_t
+ CalculateNumChildren(uint32_t max) override;
- virtual ValueObject *
- CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index);
+ ValueObject *
+ CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index) override;
protected:
- virtual bool
- UpdateValue ();
+ bool
+ UpdateValue() override;
- virtual ClangASTType
- GetClangTypeImpl ();
+ CompilerType
+ GetCompilerTypeImpl() override;
lldb::RegisterContextSP m_reg_ctx_sp;
@@ -75,46 +73,44 @@ private:
class ValueObjectRegisterSet : public ValueObject
{
public:
+ ~ValueObjectRegisterSet() override;
+
static lldb::ValueObjectSP
Create (ExecutionContextScope *exe_scope, lldb::RegisterContextSP &reg_ctx_sp, uint32_t set_idx);
- virtual
- ~ValueObjectRegisterSet();
-
- virtual uint64_t
- GetByteSize();
+ uint64_t
+ GetByteSize() override;
- virtual lldb::ValueType
- GetValueType () const
+ lldb::ValueType
+ GetValueType() const override
{
return lldb::eValueTypeRegisterSet;
}
- virtual ConstString
- GetTypeName();
+ ConstString
+ GetTypeName() override;
- virtual ConstString
- GetQualifiedTypeName();
+ ConstString
+ GetQualifiedTypeName() override;
- virtual size_t
- CalculateNumChildren();
+ size_t
+ CalculateNumChildren(uint32_t max) override;
- virtual ValueObject *
- CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index);
+ ValueObject *
+ CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index) override;
- virtual lldb::ValueObjectSP
- GetChildMemberWithName (const ConstString &name, bool can_create);
-
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
+ lldb::ValueObjectSP
+ GetChildMemberWithName(const ConstString &name, bool can_create) override;
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
protected:
- virtual bool
- UpdateValue ();
+ bool
+ UpdateValue() override;
- virtual ClangASTType
- GetClangTypeImpl ();
+ CompilerType
+ GetCompilerTypeImpl() override;
lldb::RegisterContextSP m_reg_ctx_sp;
const RegisterSet *m_reg_set;
@@ -122,6 +118,7 @@ protected:
private:
friend class ValueObjectRegisterContext;
+
ValueObjectRegisterSet (ExecutionContextScope *exe_scope, lldb::RegisterContextSP &reg_ctx_sp, uint32_t set_idx);
//------------------------------------------------------------------
@@ -133,57 +130,58 @@ private:
class ValueObjectRegister : public ValueObject
{
public:
+ ~ValueObjectRegister() override;
+
static lldb::ValueObjectSP
Create (ExecutionContextScope *exe_scope, lldb::RegisterContextSP &reg_ctx_sp, uint32_t reg_num);
- virtual
- ~ValueObjectRegister();
-
- virtual uint64_t
- GetByteSize();
+ uint64_t
+ GetByteSize() override;
- virtual lldb::ValueType
- GetValueType () const
+ lldb::ValueType
+ GetValueType() const override
{
return lldb::eValueTypeRegister;
}
- virtual ConstString
- GetTypeName();
+ ConstString
+ GetTypeName() override;
- virtual size_t
- CalculateNumChildren();
+ size_t
+ CalculateNumChildren(uint32_t max) override;
- virtual bool
- SetValueFromCString (const char *value_str, Error& error);
+ bool
+ SetValueFromCString(const char *value_str, Error& error) override;
- virtual bool
- SetData (DataExtractor &data, Error &error);
+ bool
+ SetData(DataExtractor &data, Error &error) override;
- virtual bool
- ResolveValue (Scalar &scalar);
+ bool
+ ResolveValue(Scalar &scalar) override;
- virtual void
- GetExpressionPath (Stream &s, bool qualify_cxx_base_classes, GetExpressionPathFormat epformat = eGetExpressionPathFormatDereferencePointers);
+ void
+ GetExpressionPath(Stream &s, bool qualify_cxx_base_classes,
+ GetExpressionPathFormat epformat = eGetExpressionPathFormatDereferencePointers) override;
protected:
- virtual bool
- UpdateValue ();
+ bool
+ UpdateValue() override;
- virtual ClangASTType
- GetClangTypeImpl ();
+ CompilerType
+ GetCompilerTypeImpl() override;
lldb::RegisterContextSP m_reg_ctx_sp;
RegisterInfo m_reg_info;
RegisterValue m_reg_value;
ConstString m_type_name;
- ClangASTType m_clang_type;
+ CompilerType m_compiler_type;
private:
void
ConstructObject (uint32_t reg_num);
friend class ValueObjectRegisterSet;
+
ValueObjectRegister (ValueObject &parent, lldb::RegisterContextSP &reg_ctx_sp, uint32_t reg_num);
ValueObjectRegister (ExecutionContextScope *exe_scope, lldb::RegisterContextSP &reg_ctx_sp, uint32_t reg_num);
@@ -195,4 +193,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ValueObjectRegister_h_
+#endif // liblldb_ValueObjectRegister_h_
diff --git a/include/lldb/Core/ValueObjectSyntheticFilter.h b/include/lldb/Core/ValueObjectSyntheticFilter.h
index 88824ef4fa54..05bc3781a3cc 100644
--- a/include/lldb/Core/ValueObjectSyntheticFilter.h
+++ b/include/lldb/Core/ValueObjectSyntheticFilter.h
@@ -1,4 +1,4 @@
-//===-- ValueObjectSyntheticFilter.h -------------------------------*- C++ -*-===//
+//===-- ValueObjectSyntheticFilter.h ----------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -12,7 +12,8 @@
// C Includes
// C++ Includes
-#include <vector>
+#include <memory>
+
// Other libraries and framework includes
// Project includes
#include "lldb/Core/ThreadSafeSTLMap.h"
@@ -30,140 +31,142 @@ namespace lldb_private {
class ValueObjectSynthetic : public ValueObject
{
public:
- virtual
- ~ValueObjectSynthetic();
+ ~ValueObjectSynthetic() override;
- virtual uint64_t
- GetByteSize();
+ uint64_t
+ GetByteSize() override;
- virtual ConstString
- GetTypeName();
+ ConstString
+ GetTypeName() override;
- virtual ConstString
- GetQualifiedTypeName();
+ ConstString
+ GetQualifiedTypeName() override;
- virtual ConstString
- GetDisplayTypeName();
+ ConstString
+ GetDisplayTypeName() override;
- virtual bool
- MightHaveChildren();
+ bool
+ MightHaveChildren() override;
- virtual size_t
- CalculateNumChildren();
+ size_t
+ CalculateNumChildren(uint32_t max) override;
- virtual lldb::ValueType
- GetValueType() const;
+ lldb::ValueType
+ GetValueType() const override;
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx, bool can_create);
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx, bool can_create) override;
- virtual lldb::ValueObjectSP
- GetChildMemberWithName (const ConstString &name, bool can_create);
+ lldb::ValueObjectSP
+ GetChildMemberWithName(const ConstString &name, bool can_create) override;
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
- virtual lldb::ValueObjectSP
- GetDynamicValue (lldb::DynamicValueType valueType);
+ lldb::ValueObjectSP
+ GetDynamicValue(lldb::DynamicValueType valueType) override;
- virtual bool
- IsInScope ();
+ bool
+ IsInScope() override;
- virtual bool
- HasSyntheticValue()
+ bool
+ HasSyntheticValue() override
{
return false;
}
- virtual bool
- IsSynthetic() { return true; }
+ bool
+ IsSynthetic() override
+ {
+ return true;
+ }
- virtual void
- CalculateSyntheticValue (bool use_synthetic)
+ void
+ CalculateSyntheticValue(bool use_synthetic) override
{
}
- virtual bool
- IsDynamic ()
+ bool
+ IsDynamic() override
{
- if (m_parent)
- return m_parent->IsDynamic();
- else
- return false;
+ return ((m_parent != nullptr) ? m_parent->IsDynamic() : false);
}
- virtual lldb::ValueObjectSP
- GetStaticValue ()
+ lldb::ValueObjectSP
+ GetStaticValue() override
{
- if (m_parent)
- return m_parent->GetStaticValue();
- else
- return GetSP();
+ return ((m_parent != nullptr) ? m_parent->GetStaticValue() : GetSP());
}
virtual lldb::DynamicValueType
GetDynamicValueType ()
{
- if (m_parent)
- return m_parent->GetDynamicValueType();
- else
- return lldb::eNoDynamicValues;
+ return ((m_parent != nullptr) ? m_parent->GetDynamicValueType() : lldb::eNoDynamicValues);
}
- virtual ValueObject *
- GetParent()
+ ValueObject *
+ GetParent() override
{
- if (m_parent)
- return m_parent->GetParent();
- else
- return NULL;
+ return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
}
- virtual const ValueObject *
- GetParent() const
+ const ValueObject *
+ GetParent() const override
{
- if (m_parent)
- return m_parent->GetParent();
- else
- return NULL;
+ return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
}
- virtual lldb::ValueObjectSP
- GetNonSyntheticValue ();
+ lldb::ValueObjectSP
+ GetNonSyntheticValue() override;
- virtual bool
- CanProvideValue ();
+ bool
+ CanProvideValue() override;
- virtual bool
- DoesProvideSyntheticValue ()
+ bool
+ DoesProvideSyntheticValue() override
{
return (UpdateValueIfNeeded(), m_provides_value == eLazyBoolYes);
}
- virtual bool
- GetIsConstant () const
+ bool
+ GetIsConstant() const override
{
return false;
}
- virtual bool
- SetValueFromCString (const char *value_str, Error& error);
+ bool
+ SetValueFromCString(const char *value_str, Error& error) override;
- virtual void
- SetFormat (lldb::Format format);
+ void
+ SetFormat(lldb::Format format) override;
+
+ lldb::LanguageType
+ GetPreferredDisplayLanguage() override;
+
+ void
+ SetPreferredDisplayLanguage (lldb::LanguageType);
+
+ bool
+ GetDeclaration(Declaration &decl) override;
+
+ uint64_t
+ GetLanguageFlags () override;
+
+ void
+ SetLanguageFlags (uint64_t flags) override;
protected:
- virtual bool
- UpdateValue ();
+ bool
+ UpdateValue() override;
- virtual bool
- CanUpdateWithInvalidExecutionContext ()
+ LazyBool
+ CanUpdateWithInvalidExecutionContext() override
{
- return true;
+ return eLazyBoolYes;
}
- virtual ClangASTType
- GetClangTypeImpl ();
+ CompilerType
+ GetCompilerTypeImpl() override;
virtual void
CreateSynthFilter ();
@@ -195,12 +198,9 @@ private:
void
CopyValueData (ValueObject *source);
- //------------------------------------------------------------------
- // For ValueObject only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (ValueObjectSynthetic);
};
} // namespace lldb_private
-#endif // liblldb_ValueObjectSyntheticFilter_h_
+#endif // liblldb_ValueObjectSyntheticFilter_h_
diff --git a/include/lldb/Core/ValueObjectVariable.h b/include/lldb/Core/ValueObjectVariable.h
index 0e32d09057dc..4adb6bad0ada 100644
--- a/include/lldb/Core/ValueObjectVariable.h
+++ b/include/lldb/Core/ValueObjectVariable.h
@@ -25,61 +25,66 @@ namespace lldb_private {
class ValueObjectVariable : public ValueObject
{
public:
+ ~ValueObjectVariable() override;
+
static lldb::ValueObjectSP
Create (ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp);
- virtual
- ~ValueObjectVariable();
-
- virtual uint64_t
- GetByteSize();
+ uint64_t
+ GetByteSize() override;
- virtual ConstString
- GetTypeName();
+ ConstString
+ GetTypeName() override;
- virtual ConstString
- GetQualifiedTypeName();
+ ConstString
+ GetQualifiedTypeName() override;
- virtual ConstString
- GetDisplayTypeName();
+ ConstString
+ GetDisplayTypeName() override;
- virtual size_t
- CalculateNumChildren();
+ size_t
+ CalculateNumChildren(uint32_t max) override;
- virtual lldb::ValueType
- GetValueType() const;
+ lldb::ValueType
+ GetValueType() const override;
- virtual bool
- IsInScope ();
+ bool
+ IsInScope() override;
- virtual lldb::ModuleSP
- GetModule();
+ lldb::ModuleSP
+ GetModule() override;
- virtual SymbolContextScope *
- GetSymbolContextScope();
+ SymbolContextScope *
+ GetSymbolContextScope() override;
- virtual bool
- GetDeclaration (Declaration &decl);
+ bool
+ GetDeclaration(Declaration &decl) override;
- virtual const char *
- GetLocationAsCString ();
+ const char *
+ GetLocationAsCString() override;
- virtual bool
- SetValueFromCString (const char *value_str, Error& error);
+ bool
+ SetValueFromCString(const char *value_str, Error& error) override;
- virtual bool
- SetData (DataExtractor &data, Error &error);
+ bool
+ SetData(DataExtractor &data, Error &error) override;
+
+ virtual lldb::VariableSP
+ GetVariable () override
+ {
+ return m_variable_sp;
+ }
protected:
- virtual bool
- UpdateValue ();
+ bool
+ UpdateValue() override;
- virtual ClangASTType
- GetClangTypeImpl ();
+ CompilerType
+ GetCompilerTypeImpl() override;
lldb::VariableSP m_variable_sp; ///< The variable that this value object is based upon
Value m_resolved_value; ///< The value that DWARFExpression resolves this variable to before we patch it up
-
+
private:
ValueObjectVariable (ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp);
//------------------------------------------------------------------
@@ -90,4 +95,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ValueObjectVariable_h_
+#endif // liblldb_ValueObjectVariable_h_
diff --git a/include/lldb/Core/dwarf.h b/include/lldb/Core/dwarf.h
index 9fa8816229a9..649a93154b3f 100644
--- a/include/lldb/Core/dwarf.h
+++ b/include/lldb/Core/dwarf.h
@@ -14,13 +14,16 @@
// Get the DWARF constant definitions from llvm
#include "llvm/Support/Dwarf.h"
+
+#include "lldb/Core/RangeMap.h"
+
// and stuff them in our default namespace
using namespace llvm::dwarf;
typedef uint32_t dw_uleb128_t;
typedef int32_t dw_sleb128_t;
typedef uint16_t dw_attr_t;
-typedef uint8_t dw_form_t;
+typedef uint16_t dw_form_t;
typedef uint16_t dw_tag_t;
typedef uint64_t dw_addr_t; // Dwarf address define that must be big enough for any addresses in the compile units that get parsed
@@ -59,5 +62,6 @@ typedef uint32_t dw_offset_t; // Dwarf Debug Information Entry offset for
//#define DW_OP_APPLE_clear 0xFE // clears the entire expression stack, ok if the stack is empty
//#define DW_OP_APPLE_error 0xFF // Stops expression evaluation and returns an error (no args)
+typedef lldb_private::RangeArray<dw_addr_t, dw_addr_t, 2> DWARFRangeList;
#endif // DebugBase_dwarf_h_
diff --git a/include/lldb/DataFormatters/CXXFormatterFunctions.h b/include/lldb/DataFormatters/CXXFormatterFunctions.h
deleted file mode 100644
index a175e1a4d164..000000000000
--- a/include/lldb/DataFormatters/CXXFormatterFunctions.h
+++ /dev/null
@@ -1,375 +0,0 @@
-//===-- CXXFormatterFunctions.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_CXXFormatterFunctions_h_
-#define liblldb_CXXFormatterFunctions_h_
-
-#include <stdint.h>
-#include <time.h>
-
-#include "lldb/lldb-forward.h"
-
-#include "lldb/Core/ConstString.h"
-#include "lldb/DataFormatters/FormatClasses.h"
-#include "lldb/DataFormatters/TypeSynthetic.h"
-#include "lldb/DataFormatters/VectorType.h"
-#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
-#include "lldb/Target/Target.h"
-
-#include "clang/AST/ASTContext.h"
-
-namespace lldb_private {
- namespace formatters
- {
- StackFrame*
- GetViableFrame (ExecutionContext exe_ctx);
-
- bool
- ExtractValueFromObjCExpression (ValueObject &valobj,
- const char* target_type,
- const char* selector,
- uint64_t &value);
-
- bool
- ExtractSummaryFromObjCExpression (ValueObject &valobj,
- const char* target_type,
- const char* selector,
- Stream &stream);
-
- lldb::ValueObjectSP
- CallSelectorOnObject (ValueObject &valobj,
- const char* return_type,
- const char* selector,
- uint64_t index);
-
- lldb::ValueObjectSP
- CallSelectorOnObject (ValueObject &valobj,
- const char* return_type,
- const char* selector,
- const char* key);
-
- size_t
- ExtractIndexFromString (const char* item_name);
-
- time_t
- GetOSXEpoch ();
-
- bool
- FunctionPointerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // C++ function pointer
-
- bool
- Char16StringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char16_t* and unichar*
-
- bool
- Char32StringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char32_t*
-
- bool
- WCharStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // wchar_t*
-
- bool
- Char16SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char16_t and unichar
-
- bool
- Char32SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char32_t
-
- bool
- WCharSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // wchar_t
-
- bool
- LibcxxStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libc++ std::string
-
- bool
- LibcxxWStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libc++ std::wstring
-
- bool
- LibcxxSmartPointerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libc++ std::shared_ptr<> and std::weak_ptr<>
-
- bool
- ObjCClassSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- SyntheticChildrenFrontEnd* ObjCClassSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- template<bool name_entries>
- bool
- NSDictionarySummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- bool
- NSIndexSetSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- bool
- NSArraySummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- template<bool cf_style>
- bool
- NSSetSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- template<bool needs_at>
- bool
- NSDataSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- bool
- NSNumberSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- bool
- NSNotificationSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- bool
- NSTimeZoneSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- bool
- NSMachPortSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- bool
- CFBagSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- bool
- CFBinaryHeapSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- bool
- CFBitVectorSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- bool
- NSDateSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- bool
- CFAbsoluteTimeSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- bool
- NSBundleSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- bool
- NSStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- bool
- NSTaggedString_SummaryProvider (ObjCLanguageRuntime::ClassDescriptorSP descriptor, Stream& stream);
-
- bool
- NSAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- bool
- NSMutableAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- bool
- NSURLSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- bool
- ObjCBOOLSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- template <bool is_sel_ptr>
- bool
- ObjCSELSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- bool
- RuntimeSpecificDescriptionSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- extern template bool
- NSDictionarySummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&) ;
-
- extern template bool
- NSDictionarySummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&) ;
-
- extern template bool
- NSDataSummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&) ;
-
- extern template bool
- NSDataSummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&) ;
-
- extern template bool
- ObjCSELSummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&);
-
- extern template bool
- ObjCSELSummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&);
-
- bool
- CMTimeSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- SyntheticChildrenFrontEnd* NSArraySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- SyntheticChildrenFrontEnd* NSDictionarySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- SyntheticChildrenFrontEnd* NSSetSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- SyntheticChildrenFrontEnd* NSIndexPathSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- class LibcxxVectorBoolSyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- LibcxxVectorBoolSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
-
- virtual bool
- MightHaveChildren ();
-
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
-
- virtual
- ~LibcxxVectorBoolSyntheticFrontEnd ();
- private:
- ClangASTType m_bool_type;
- ExecutionContextRef m_exe_ctx_ref;
- uint64_t m_count;
- lldb::addr_t m_base_data_address;
- std::map<size_t,lldb::ValueObjectSP> m_children;
- };
-
- SyntheticChildrenFrontEnd* LibcxxVectorBoolSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- bool
- LibcxxContainerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- class LibstdcppMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- LibstdcppMapIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
-
- virtual bool
- MightHaveChildren ();
-
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
-
- virtual
- ~LibstdcppMapIteratorSyntheticFrontEnd ();
- private:
- ExecutionContextRef m_exe_ctx_ref;
- lldb::addr_t m_pair_address;
- ClangASTType m_pair_type;
- EvaluateExpressionOptions m_options;
- lldb::ValueObjectSP m_pair_sp;
- };
-
- SyntheticChildrenFrontEnd* LibstdcppMapIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- class LibCxxMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- LibCxxMapIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
-
- virtual bool
- MightHaveChildren ();
-
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
-
- virtual
- ~LibCxxMapIteratorSyntheticFrontEnd ();
- private:
- ValueObject *m_pair_ptr;
- };
-
- SyntheticChildrenFrontEnd* LibCxxMapIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- class VectorIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- VectorIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp,
- ConstString item_name);
-
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
-
- virtual bool
- MightHaveChildren ();
-
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
-
- virtual
- ~VectorIteratorSyntheticFrontEnd ();
- private:
- ExecutionContextRef m_exe_ctx_ref;
- ConstString m_item_name;
- lldb::ValueObjectSP m_item_sp;
- };
-
- SyntheticChildrenFrontEnd* LibCxxVectorIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- SyntheticChildrenFrontEnd* LibStdcppVectorIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- LibcxxSharedPtrSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
-
- virtual bool
- MightHaveChildren ();
-
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
-
- virtual
- ~LibcxxSharedPtrSyntheticFrontEnd ();
- private:
- ValueObject* m_cntrl;
- lldb::ValueObjectSP m_count_sp;
- lldb::ValueObjectSP m_weak_count_sp;
- uint8_t m_ptr_size;
- lldb::ByteOrder m_byte_order;
- };
-
- SyntheticChildrenFrontEnd* LibcxxSharedPtrSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- SyntheticChildrenFrontEnd* LibcxxStdVectorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- SyntheticChildrenFrontEnd* LibcxxStdListSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- SyntheticChildrenFrontEnd* LibcxxStdMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- SyntheticChildrenFrontEnd* LibcxxStdUnorderedMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- SyntheticChildrenFrontEnd* LibcxxInitializerListSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- SyntheticChildrenFrontEnd* VectorTypeSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
- } // namespace formatters
-} // namespace lldb_private
-
-#endif // liblldb_CXXFormatterFunctions_h_
diff --git a/include/lldb/DataFormatters/CXXFunctionPointer.h b/include/lldb/DataFormatters/CXXFunctionPointer.h
new file mode 100644
index 000000000000..eaa39582eaaa
--- /dev/null
+++ b/include/lldb/DataFormatters/CXXFunctionPointer.h
@@ -0,0 +1,23 @@
+//===-- CXXFunctionPointer.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_CXXFunctionPointer_h_
+#define liblldb_CXXFunctionPointer_h_
+
+#include "lldb/lldb-forward.h"
+
+namespace lldb_private {
+ namespace formatters
+ {
+ bool
+ CXXFunctionPointerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+ } // namespace formatters
+} // namespace lldb_private
+
+#endif // liblldb_CXXFunctionPointer_h_
diff --git a/include/lldb/DataFormatters/DataVisualization.h b/include/lldb/DataFormatters/DataVisualization.h
index a0b2e58bba28..856156670c96 100644
--- a/include/lldb/DataFormatters/DataVisualization.h
+++ b/include/lldb/DataFormatters/DataVisualization.h
@@ -1,4 +1,4 @@
-//===-- DataVisualization.h ----------------------------------------*- C++ -*-===//
+//===-- DataVisualization.h -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -28,7 +28,6 @@ namespace lldb_private {
class DataVisualization
{
public:
-
// use this call to force the FM to consider itself updated even when there is no apparent reason for that
static void
ForceUpdate();
@@ -83,8 +82,8 @@ public:
AnyMatches(ConstString type_name,
TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES,
bool only_enabled = true,
- const char** matching_category = NULL,
- TypeCategoryImpl::FormatCategoryItems* matching_type = NULL);
+ const char** matching_category = nullptr,
+ TypeCategoryImpl::FormatCategoryItems* matching_type = nullptr);
class NamedSummaryFormats
{
@@ -102,7 +101,7 @@ public:
Clear ();
static void
- LoopThrough (TypeSummaryImpl::SummaryCallback callback, void* callback_baton);
+ ForEach (std::function<bool(ConstString, const lldb::TypeSummaryImplSP&)> callback);
static uint32_t
GetCount ();
@@ -111,12 +110,15 @@ public:
class Categories
{
public:
-
static bool
GetCategory (const ConstString &category,
lldb::TypeCategoryImplSP &entry,
bool allow_create = true);
+ static bool
+ GetCategory (lldb::LanguageType language,
+ lldb::TypeCategoryImplSP &entry);
+
static void
Add (const ConstString &category);
@@ -134,7 +136,13 @@ public:
TypeCategoryMap::Position = TypeCategoryMap::Default);
static void
+ Enable (lldb::LanguageType lang_type);
+
+ static void
Disable (const ConstString& category);
+
+ static void
+ Disable (lldb::LanguageType lang_type);
static void
Enable (const lldb::TypeCategoryImplSP& category,
@@ -150,7 +158,7 @@ public:
DisableStar ();
static void
- LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton);
+ ForEach (TypeCategoryMap::ForEachCallback callback);
static uint32_t
GetCount ();
@@ -160,7 +168,6 @@ public:
};
};
-
} // namespace lldb_private
-#endif // lldb_DataVisualization_h_
+#endif// lldb_DataVisualization_h_
diff --git a/include/lldb/DataFormatters/DumpValueObjectOptions.h b/include/lldb/DataFormatters/DumpValueObjectOptions.h
new file mode 100644
index 000000000000..f65ee7b95845
--- /dev/null
+++ b/include/lldb/DataFormatters/DumpValueObjectOptions.h
@@ -0,0 +1,185 @@
+//===-- DumpValueObjectOptions.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_DumpValueObjectOptions_h_
+#define lldb_DumpValueObjectOptions_h_
+
+// C Includes
+// C++ Includes
+#include <string>
+
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-private.h"
+#include "lldb/lldb-public.h"
+
+#include <functional>
+#include <string>
+
+namespace lldb_private {
+
+class DumpValueObjectOptions
+{
+public:
+ struct PointerDepth
+ {
+ enum class Mode
+ {
+ Always,
+ Formatters,
+ Default,
+ Never
+ } m_mode;
+ uint32_t m_count;
+
+ PointerDepth
+ operator --() const
+ {
+ if (m_count > 0)
+ return PointerDepth {m_mode,m_count-1};
+ return PointerDepth {m_mode,m_count};
+ }
+
+ bool
+ CanAllowExpansion () const;
+
+ bool
+ CanAllowExpansion (bool is_root,
+ TypeSummaryImpl* entry,
+ ValueObject *valobj,
+ const std::string& summary);
+ };
+
+ typedef std::function<bool(ConstString,
+ ConstString,
+ const DumpValueObjectOptions &,
+ Stream&)> DeclPrintingHelper;
+
+ static const DumpValueObjectOptions
+ DefaultOptions()
+ {
+ static DumpValueObjectOptions g_default_options;
+
+ return g_default_options;
+ }
+
+ DumpValueObjectOptions();
+
+ DumpValueObjectOptions (const DumpValueObjectOptions& rhs) = default;
+
+ DumpValueObjectOptions (ValueObject& valobj);
+
+ DumpValueObjectOptions&
+ SetMaximumPointerDepth(PointerDepth depth = {PointerDepth::Mode::Never,0});
+
+ DumpValueObjectOptions&
+ SetMaximumDepth(uint32_t depth = 0);
+
+ DumpValueObjectOptions&
+ SetDeclPrintingHelper(DeclPrintingHelper helper);
+
+ DumpValueObjectOptions&
+ SetShowTypes(bool show = false);
+
+ DumpValueObjectOptions&
+ SetShowLocation(bool show = false);
+
+ DumpValueObjectOptions&
+ SetUseObjectiveC(bool use = false);
+
+ DumpValueObjectOptions&
+ SetShowSummary(bool show = true);
+
+ DumpValueObjectOptions&
+ SetUseDynamicType(lldb::DynamicValueType dyn = lldb::eNoDynamicValues);
+
+ DumpValueObjectOptions&
+ SetUseSyntheticValue(bool use_synthetic = true);
+
+ DumpValueObjectOptions&
+ SetScopeChecked(bool check = true);
+
+ DumpValueObjectOptions&
+ SetFlatOutput(bool flat = false);
+
+ DumpValueObjectOptions&
+ SetOmitSummaryDepth(uint32_t depth = 0);
+
+ DumpValueObjectOptions&
+ SetIgnoreCap(bool ignore = false);
+
+ DumpValueObjectOptions&
+ SetRawDisplay();
+
+ DumpValueObjectOptions&
+ SetFormat (lldb::Format format = lldb::eFormatDefault);
+
+ DumpValueObjectOptions&
+ SetSummary (lldb::TypeSummaryImplSP summary = lldb::TypeSummaryImplSP());
+
+ DumpValueObjectOptions&
+ SetRootValueObjectName(const char* name = nullptr);
+
+ DumpValueObjectOptions&
+ SetHideRootType (bool hide_root_type = false);
+
+ DumpValueObjectOptions&
+ SetHideName (bool hide_name = false);
+
+ DumpValueObjectOptions&
+ SetHideValue (bool hide_value = false);
+
+ DumpValueObjectOptions&
+ SetHidePointerValue (bool hide = false);
+
+ DumpValueObjectOptions&
+ SetVariableFormatDisplayLanguage (lldb::LanguageType lang = lldb::eLanguageTypeUnknown);
+
+ DumpValueObjectOptions&
+ SetRunValidator (bool run = true);
+
+ DumpValueObjectOptions&
+ SetUseTypeDisplayName (bool dis = false);
+
+ DumpValueObjectOptions&
+ SetAllowOnelinerMode (bool oneliner = false);
+
+ DumpValueObjectOptions&
+ SetRevealEmptyAggregates (bool reveal = true);
+
+public:
+ uint32_t m_max_depth = UINT32_MAX;
+ lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues;
+ uint32_t m_omit_summary_depth = 0;
+ lldb::Format m_format = lldb::eFormatDefault;
+ lldb::TypeSummaryImplSP m_summary_sp;
+ std::string m_root_valobj_name;
+ lldb::LanguageType m_varformat_language = lldb::eLanguageTypeUnknown;
+ PointerDepth m_max_ptr_depth;
+ DeclPrintingHelper m_decl_printing_helper;
+ bool m_use_synthetic : 1;
+ bool m_scope_already_checked : 1;
+ bool m_flat_output : 1;
+ bool m_ignore_cap : 1;
+ bool m_show_types : 1;
+ bool m_show_location : 1;
+ bool m_use_objc : 1;
+ bool m_hide_root_type : 1;
+ bool m_hide_name : 1;
+ bool m_hide_value : 1;
+ bool m_run_validator : 1;
+ bool m_use_type_display_name : 1;
+ bool m_allow_oneliner_mode : 1;
+ bool m_hide_pointer_value : 1;
+ bool m_reveal_empty_aggregates : 1;
+};
+
+} // namespace lldb_private
+
+#endif // lldb_DumpValueObjectOptions_h_
diff --git a/include/lldb/DataFormatters/FormatCache.h b/include/lldb/DataFormatters/FormatCache.h
index fa46306e5404..9f1e078f7199 100644
--- a/include/lldb/DataFormatters/FormatCache.h
+++ b/include/lldb/DataFormatters/FormatCache.h
@@ -19,7 +19,6 @@
#include "lldb/lldb-public.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Host/Mutex.h"
-#include "lldb/DataFormatters/FormatClasses.h"
namespace lldb_private {
class FormatCache
diff --git a/include/lldb/DataFormatters/FormatClasses.h b/include/lldb/DataFormatters/FormatClasses.h
index 651160371c69..b5ac41c2bd6e 100644
--- a/include/lldb/DataFormatters/FormatClasses.h
+++ b/include/lldb/DataFormatters/FormatClasses.h
@@ -10,25 +10,45 @@
#ifndef lldb_FormatClasses_h_
#define lldb_FormatClasses_h_
+// C Includes
// C++ Includes
+#include <functional>
+#include <memory>
#include <string>
#include <vector>
// Other libraries and framework includes
-
// Project includes
#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
-
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/DataFormatters/TypeFormat.h"
+#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
+#include "lldb/DataFormatters/TypeValidator.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/Type.h"
namespace lldb_private {
+class HardcodedFormatters {
+public:
+ template <typename FormatterType>
+ using HardcodedFormatterFinder = std::function<typename FormatterType::SharedPointer (lldb_private::ValueObject&,
+ lldb::DynamicValueType,
+ FormatManager&)>;
+
+ template <typename FormatterType>
+ using HardcodedFormatterFinders = std::vector<HardcodedFormatterFinder<FormatterType>>;
+
+ typedef HardcodedFormatterFinders<TypeFormatImpl> HardcodedFormatFinder;
+ typedef HardcodedFormatterFinders<TypeSummaryImpl> HardcodedSummaryFinder;
+ typedef HardcodedFormatterFinders<SyntheticChildren> HardcodedSyntheticFinder;
+ typedef HardcodedFormatterFinders<TypeValidatorImpl> HardcodedValidatorFinder;
+};
+
class FormattersMatchCandidate
{
public:
-
FormattersMatchCandidate (ConstString name,
uint32_t reason,
bool strip_ptr,
@@ -41,10 +61,9 @@ public:
m_stripped_typedef(strip_tydef)
{
}
-
- ~FormattersMatchCandidate ()
- {}
-
+
+ ~FormattersMatchCandidate() = default;
+
ConstString
GetTypeName () const
{
@@ -99,6 +118,36 @@ private:
};
typedef std::vector<FormattersMatchCandidate> FormattersMatchVector;
+typedef std::vector<lldb::LanguageType> CandidateLanguagesVector;
+
+class FormattersMatchData
+{
+public:
+ FormattersMatchData (ValueObject&,
+ lldb::DynamicValueType);
+
+ FormattersMatchVector
+ GetMatchesVector ();
+
+ ConstString
+ GetTypeForCache ();
+
+ CandidateLanguagesVector
+ GetCandidateLanguages ();
+
+ ValueObject&
+ GetValueObject ();
+
+ lldb::DynamicValueType
+ GetDynamicValueType ();
+
+private:
+ ValueObject& m_valobj;
+ lldb::DynamicValueType m_dynamic_value_type;
+ std::pair<FormattersMatchVector,bool> m_formatters_match_vector;
+ ConstString m_type_for_cache;
+ CandidateLanguagesVector m_candidate_languages;
+};
class TypeNameSpecifierImpl
{
@@ -130,7 +179,7 @@ public:
}
}
- TypeNameSpecifierImpl (ClangASTType type) :
+ TypeNameSpecifierImpl (CompilerType type) :
m_is_regex(false),
m_type()
{
@@ -146,7 +195,7 @@ public:
{
if (m_type.m_type_name.size())
return m_type.m_type_name.c_str();
- return NULL;
+ return nullptr;
}
lldb::TypeSP
@@ -157,12 +206,12 @@ public:
return lldb::TypeSP();
}
- ClangASTType
- GetClangASTType ()
+ CompilerType
+ GetCompilerType ()
{
if (m_type.m_type_pair.IsValid())
- return m_type.m_type_pair.GetClangASTType();
- return ClangASTType();
+ return m_type.m_type_pair.GetCompilerType();
+ return CompilerType();
}
bool
@@ -174,19 +223,18 @@ 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 ClangASTType
+ // whereas TypePair can also be backed by a CompilerType
struct TypeOrName
{
std::string m_type_name;
TypePair m_type_pair;
};
TypeOrName m_type;
-
-
+
private:
DISALLOW_COPY_AND_ASSIGN(TypeNameSpecifierImpl);
};
} // namespace lldb_private
-#endif // lldb_FormatClasses_h_
+#endif // lldb_FormatClasses_h_
diff --git a/include/lldb/DataFormatters/FormatManager.h b/include/lldb/DataFormatters/FormatManager.h
index a1f4b59fb344..24ba5a7f0aa5 100644
--- a/include/lldb/DataFormatters/FormatManager.h
+++ b/include/lldb/DataFormatters/FormatManager.h
@@ -1,4 +1,4 @@
-//===-- FormatManager.h -------------------------------------------*- C++ -*-===//
+//===-- FormatManager.h -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -12,6 +12,10 @@
// C Includes
// C++ Includes
+#include <atomic>
+#include <initializer_list>
+#include <map>
+#include <vector>
// Other libraries and framework includes
// Project includes
@@ -21,12 +25,10 @@
#include "lldb/DataFormatters/FormatCache.h"
#include "lldb/DataFormatters/FormatClasses.h"
#include "lldb/DataFormatters/FormattersContainer.h"
+#include "lldb/DataFormatters/LanguageCategory.h"
#include "lldb/DataFormatters/TypeCategory.h"
#include "lldb/DataFormatters/TypeCategoryMap.h"
-#include <atomic>
-#include <functional>
-
namespace lldb_private {
// this file (and its. cpp) contain the low-level implementation of LLDB Data Visualization
@@ -39,19 +41,12 @@ class FormatManager : public IFormatChangeListener
typedef FormatMap<ConstString, TypeSummaryImpl> NamedSummariesMap;
typedef TypeCategoryMap::MapType::iterator CategoryMapIterator;
public:
+ typedef std::map<lldb::LanguageType, LanguageCategory::UniquePointer> LanguageCategories;
- template <typename FormatterType>
- using HardcodedFormatterFinder = std::function<typename FormatterType::SharedPointer (lldb_private::ValueObject&,
- lldb::DynamicValueType,
- FormatManager&)>;
-
- template <typename FormatterType>
- using HardcodedFormatterFinders = std::vector<HardcodedFormatterFinder<FormatterType>>;
-
- typedef TypeCategoryMap::CallbackType CategoryCallback;
-
- FormatManager ();
+ FormatManager();
+ ~FormatManager() override = default;
+
NamedSummariesMap&
GetNamedSummaryContainer ()
{
@@ -62,8 +57,34 @@ public:
EnableCategory (const ConstString& category_name,
TypeCategoryMap::Position pos = TypeCategoryMap::Default)
{
- m_categories_map.Enable(category_name,
- pos);
+ EnableCategory(category_name,
+ pos,
+ std::initializer_list<lldb::LanguageType>());
+ }
+
+ void
+ EnableCategory (const ConstString& category_name,
+ TypeCategoryMap::Position pos,
+ lldb::LanguageType lang)
+ {
+ std::initializer_list<lldb::LanguageType> langs = {lang};
+ EnableCategory(category_name,
+ pos,
+ langs);
+ }
+
+ void
+ EnableCategory (const ConstString& category_name,
+ TypeCategoryMap::Position pos = TypeCategoryMap::Default,
+ std::initializer_list<lldb::LanguageType> langs = {})
+ {
+ TypeCategoryMap::ValueSP category_sp;
+ if (m_categories_map.Get(category_name, category_sp) && category_sp)
+ {
+ m_categories_map.Enable(category_sp, pos);
+ for (const lldb::LanguageType lang : langs)
+ category_sp->AddLanguage(lang);
+ }
}
void
@@ -87,16 +108,10 @@ public:
}
void
- EnableAllCategories ()
- {
- m_categories_map.EnableAllCategories ();
- }
+ EnableAllCategories ();
void
- DisableAllCategories ()
- {
- m_categories_map.DisableAllCategories ();
- }
+ DisableAllCategories ();
bool
DeleteCategory (const ConstString& category_name)
@@ -123,14 +138,11 @@ public:
}
void
- LoopThroughCategories (CategoryCallback callback, void* param)
- {
- m_categories_map.LoopThrough(callback, param);
- }
+ ForEachCategory (TypeCategoryMap::ForEachCallback callback);
lldb::TypeCategoryImplSP
- GetCategory (const char* category_name = NULL,
- bool can_create = true)
+ GetCategory(const char* category_name = nullptr,
+ bool can_create = true)
{
if (!category_name)
return GetCategory(m_default_category_name);
@@ -182,11 +194,11 @@ public:
lldb::DynamicValueType use_dynamic);
bool
- AnyMatches (ConstString type_name,
- TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES,
- bool only_enabled = true,
- const char** matching_category = NULL,
- TypeCategoryImpl::FormatCategoryItems* matching_type = NULL)
+ AnyMatches(ConstString type_name,
+ TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES,
+ bool only_enabled = true,
+ const char** matching_category = nullptr,
+ TypeCategoryImpl::FormatCategoryItems* matching_type = nullptr)
{
return m_categories_map.AnyMatches(type_name,
items,
@@ -226,29 +238,21 @@ public:
ShouldPrintAsOneLiner (ValueObject& valobj);
void
- Changed ()
- {
- ++m_last_revision;
- m_format_cache.Clear ();
- }
+ Changed () override;
uint32_t
- GetCurrentRevision ()
+ GetCurrentRevision () override
{
return m_last_revision;
}
-
- ~FormatManager ()
- {
- }
-
+
static FormattersMatchVector
GetPossibleMatches (ValueObject& valobj,
lldb::DynamicValueType use_dynamic)
{
FormattersMatchVector matches;
GetPossibleMatches (valobj,
- valobj.GetClangType(),
+ valobj.GetCompilerType(),
lldb_private::eFormatterChoiceCriterionDirectChoice,
use_dynamic,
matches,
@@ -258,12 +262,23 @@ public:
true);
return matches;
}
+
+ static ConstString
+ GetTypeForCache (ValueObject&, lldb::DynamicValueType);
+
+ LanguageCategory*
+ GetCategoryForLanguage (lldb::LanguageType lang_type);
+
+ static std::vector<lldb::LanguageType>
+ GetCandidateLanguages (lldb::LanguageType lang_type);
private:
+ static std::vector<lldb::LanguageType>
+ GetCandidateLanguages (ValueObject& valobj);
static void
GetPossibleMatches (ValueObject& valobj,
- ClangASTType clang_type,
+ CompilerType compiler_type,
uint32_t reason,
lldb::DynamicValueType use_dynamic,
FormattersMatchVector& entries,
@@ -271,40 +286,29 @@ private:
bool did_strip_ref,
bool did_strip_typedef,
bool root_level = false);
-
+
+ std::atomic<uint32_t> m_last_revision;
FormatCache m_format_cache;
+ Mutex m_language_categories_mutex;
+ LanguageCategories m_language_categories_map;
NamedSummariesMap m_named_summaries_map;
- std::atomic<uint32_t> m_last_revision;
TypeCategoryMap m_categories_map;
ConstString m_default_category_name;
ConstString m_system_category_name;
- ConstString m_gnu_cpp_category_name;
- ConstString m_libcxx_category_name;
- ConstString m_objc_category_name;
- ConstString m_corefoundation_category_name;
- ConstString m_coregraphics_category_name;
- ConstString m_coreservices_category_name;
ConstString m_vectortypes_category_name;
- ConstString m_appkit_category_name;
- ConstString m_coremedia_category_name;
-
- HardcodedFormatterFinders<TypeFormatImpl> m_hardcoded_formats;
- HardcodedFormatterFinders<TypeSummaryImpl> m_hardcoded_summaries;
- HardcodedFormatterFinders<SyntheticChildren> m_hardcoded_synthetics;
- HardcodedFormatterFinders<TypeValidatorImpl> m_hardcoded_validators;
lldb::TypeFormatImplSP
- GetHardcodedFormat (ValueObject&,lldb::DynamicValueType);
+ GetHardcodedFormat (FormattersMatchData&);
lldb::TypeSummaryImplSP
- GetHardcodedSummaryFormat (ValueObject&,lldb::DynamicValueType);
+ GetHardcodedSummaryFormat (FormattersMatchData&);
lldb::SyntheticChildrenSP
- GetHardcodedSyntheticChildren (ValueObject&,lldb::DynamicValueType);
+ GetHardcodedSyntheticChildren (FormattersMatchData&);
lldb::TypeValidatorImplSP
- GetHardcodedValidator (ValueObject&,lldb::DynamicValueType);
+ GetHardcodedValidator (FormattersMatchData&);
TypeCategoryMap&
GetCategories ()
@@ -312,29 +316,20 @@ private:
return m_categories_map;
}
- // WARNING: these are temporary functions that setup formatters
- // while a few of these actually should be globally available and setup by LLDB itself
- // most would actually belong to the users' lldbinit file or to some other form of configurable
- // storage
- void
- LoadLibStdcppFormatters ();
-
- void
- LoadLibcxxFormatters ();
-
+ // These functions are meant to initialize formatters that are very low-level/global in nature
+ // and do not naturally belong in any language. The intent is that most formatters go in
+ // language-specific categories. Eventually, the runtimes should also be allowed to vend their
+ // own formatters, and then one could put formatters that depend on specific library load events
+ // in the language runtimes, on an as-needed basis
void
LoadSystemFormatters ();
void
- LoadObjCFormatters ();
-
- void
- LoadCoreMediaFormatters ();
+ LoadVectorFormatters ();
- void
- LoadHardcodedFormatters ();
+ friend class FormattersMatchData;
};
} // namespace lldb_private
-#endif // lldb_FormatManager_h_
+#endif // lldb_FormatManager_h_
diff --git a/include/lldb/DataFormatters/FormattersContainer.h b/include/lldb/DataFormatters/FormattersContainer.h
index daf2f24ae3e5..dcd08211f19b 100644
--- a/include/lldb/DataFormatters/FormattersContainer.h
+++ b/include/lldb/DataFormatters/FormattersContainer.h
@@ -1,4 +1,4 @@
-//===-- FormattersContainer.h ----------------------------------------*- C++ -*-===//
+//===-- FormattersContainer.h -----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -12,53 +12,38 @@
// C Includes
// C++ Includes
+#include <functional>
+#include <map>
+#include <memory>
+#include <string>
// Other libraries and framework includes
-#include "clang/AST/DeclCXX.h"
-#include "clang/AST/Type.h"
-#include "clang/AST/DeclObjC.h"
-
// Project includes
#include "lldb/lldb-public.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/ValueObject.h"
-
#include "lldb/DataFormatters/FormatClasses.h"
#include "lldb/DataFormatters/TypeFormat.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
#include "lldb/DataFormatters/TypeValidator.h"
-
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangASTType.h"
-
-#include "lldb/Target/ObjCLanguageRuntime.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/StackFrame.h"
-#include "lldb/Target/TargetList.h"
-
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Utility/StringLexer.h"
namespace lldb_private {
-// this file (and its. cpp) contain the low-level implementation of LLDB Data Visualization
-// class DataVisualization is the high-level front-end of this feature
-// clients should refer to that class as the entry-point into the data formatters
-// unless they have a good reason to bypass it and prefer to use this file's objects directly
class IFormatChangeListener
{
public:
+ virtual
+ ~IFormatChangeListener() = default;
+
virtual void
Changed () = 0;
-
- virtual
- ~IFormatChangeListener () {}
-
+
virtual uint32_t
GetCurrentRevision () = 0;
-
};
// if the user tries to add formatters for, say, "struct Foo"
@@ -92,11 +77,10 @@ template<typename KeyType, typename ValueType>
class FormatMap
{
public:
-
typedef typename ValueType::SharedPointer ValueSP;
typedef std::map<KeyType, ValueSP> MapType;
typedef typename MapType::iterator MapIterator;
- typedef bool(*CallbackType)(void*, KeyType, const ValueSP&);
+ typedef std::function<bool(KeyType, const ValueSP&)> ForEachCallback;
FormatMap(IFormatChangeListener* lst) :
m_map(),
@@ -155,7 +139,7 @@ public:
}
void
- LoopThrough (CallbackType callback, void* param)
+ ForEach (ForEachCallback callback)
{
if (callback)
{
@@ -164,7 +148,7 @@ public:
for (pos = m_map.begin(); pos != end; pos++)
{
KeyType type = pos->first;
- if (!callback(param, type, pos->second))
+ if (!callback(type, pos->second))
break;
}
}
@@ -227,7 +211,6 @@ protected:
friend class FormattersContainer<KeyType, ValueType>;
friend class FormatManager;
-
};
template<typename KeyType, typename ValueType>
@@ -241,7 +224,7 @@ public:
typedef typename MapType::iterator MapIterator;
typedef typename MapType::key_type MapKeyType;
typedef typename MapType::mapped_type MapValueType;
- typedef typename BackEndType::CallbackType CallbackType;
+ typedef typename BackEndType::ForEachCallback ForEachCallback;
typedef typename std::shared_ptr<FormattersContainer<KeyType, ValueType> > SharedPointer;
friend class TypeCategoryImpl;
@@ -256,23 +239,23 @@ public:
void
Add (const MapKeyType &type, const MapValueType& entry)
{
- Add_Impl(type, entry, (KeyType*)NULL);
+ Add_Impl(type, entry, static_cast<KeyType*>(nullptr));
}
bool
Delete (ConstString type)
{
- return Delete_Impl(type, (KeyType*)NULL);
+ return Delete_Impl(type, static_cast<KeyType*>(nullptr));
}
bool
Get(ValueObject& valobj,
MapValueType& entry,
lldb::DynamicValueType use_dynamic,
- uint32_t* why = NULL)
+ uint32_t* why = nullptr)
{
uint32_t value = lldb_private::eFormatterChoiceCriterionDirectChoice;
- ClangASTType ast_type(valobj.GetClangType());
+ CompilerType ast_type(valobj.GetCompilerType());
bool ret = Get(valobj, ast_type, entry, use_dynamic, value);
if (ret)
entry = MapValueType(entry);
@@ -286,13 +269,13 @@ public:
bool
Get (ConstString type, MapValueType& entry)
{
- return Get_Impl(type, entry, (KeyType*)NULL);
+ return Get_Impl(type, entry, static_cast<KeyType*>(nullptr));
}
bool
GetExact (ConstString type, MapValueType& entry)
{
- return GetExact_Impl(type, entry, (KeyType*)NULL);
+ return GetExact_Impl(type, entry, static_cast<KeyType*>(nullptr));
}
MapValueType
@@ -304,7 +287,7 @@ public:
lldb::TypeNameSpecifierImplSP
GetTypeNameSpecifierAtIndex (size_t index)
{
- return GetTypeNameSpecifierAtIndex_Impl(index, (KeyType*)NULL);
+ return GetTypeNameSpecifierAtIndex_Impl(index, static_cast<KeyType*>(nullptr));
}
void
@@ -314,9 +297,9 @@ public:
}
void
- LoopThrough (CallbackType callback, void* param)
+ ForEach (ForEachCallback callback)
{
- m_format_map.LoopThrough(callback,param);
+ m_format_map.ForEach(callback);
}
uint32_t
@@ -377,7 +360,7 @@ protected:
bool
GetExact_Impl (ConstString type, MapValueType& entry, ConstString *dummy)
{
- return Get_Impl(type,entry, (KeyType*)0);
+ return Get_Impl(type, entry, static_cast<KeyType*>(nullptr));
}
lldb::TypeNameSpecifierImplSP
@@ -395,7 +378,7 @@ protected:
GetTypeNameSpecifierAtIndex_Impl (size_t index, lldb::RegularExpressionSP *dummy)
{
lldb::RegularExpressionSP regex = m_format_map.GetKeyAtIndex(index);
- if (regex.get() == NULL)
+ if (regex.get() == nullptr)
return lldb::TypeNameSpecifierImplSP();
return lldb::TypeNameSpecifierImplSP(new TypeNameSpecifierImpl(regex->GetText(),
true));
@@ -447,7 +430,6 @@ protected:
{
for (const FormattersMatchCandidate& candidate : candidates)
{
- // FIXME: could we do the IsMatch() check first?
if (Get(candidate.GetTypeName(),entry))
{
if (candidate.IsMatch(entry) == false)
@@ -469,4 +451,4 @@ protected:
} // namespace lldb_private
-#endif // lldb_FormattersContainer_h_
+#endif // lldb_FormattersContainer_h_
diff --git a/include/lldb/DataFormatters/FormattersHelpers.h b/include/lldb/DataFormatters/FormattersHelpers.h
new file mode 100644
index 000000000000..4627a61e94f1
--- /dev/null
+++ b/include/lldb/DataFormatters/FormattersHelpers.h
@@ -0,0 +1,279 @@
+//===-- FormattersHelpers.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_FormattersHelpers_h_
+#define lldb_FormattersHelpers_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-forward.h"
+#include "lldb/lldb-enumerations.h"
+
+#include "lldb/DataFormatters/TypeCategory.h"
+#include "lldb/DataFormatters/TypeFormat.h"
+#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
+
+namespace lldb_private {
+ namespace formatters {
+ void
+ AddFormat (TypeCategoryImpl::SharedPointer category_sp,
+ lldb::Format format,
+ ConstString type_name,
+ TypeFormatImpl::Flags flags,
+ bool regex = false);
+
+ void
+ AddSummary(TypeCategoryImpl::SharedPointer category_sp,
+ lldb::TypeSummaryImplSP summary_sp,
+ ConstString type_name,
+ bool regex = false);
+
+ void
+ AddStringSummary(TypeCategoryImpl::SharedPointer category_sp,
+ const char* string,
+ ConstString type_name,
+ TypeSummaryImpl::Flags flags,
+ bool regex = false);
+
+ void
+ AddOneLineSummary (TypeCategoryImpl::SharedPointer category_sp,
+ ConstString type_name,
+ TypeSummaryImpl::Flags flags,
+ bool regex = false);
+
+#ifndef LLDB_DISABLE_PYTHON
+ void
+ AddCXXSummary (TypeCategoryImpl::SharedPointer category_sp,
+ CXXFunctionSummaryFormat::Callback funct,
+ const char* description,
+ ConstString type_name,
+ TypeSummaryImpl::Flags flags,
+ bool regex = false);
+
+ void
+ AddCXXSynthetic (TypeCategoryImpl::SharedPointer category_sp,
+ CXXSyntheticChildren::CreateFrontEndCallback generator,
+ const char* description,
+ ConstString type_name,
+ ScriptedSyntheticChildren::Flags flags,
+ bool regex = false);
+
+ void
+ AddFilter (TypeCategoryImpl::SharedPointer category_sp,
+ std::vector<std::string> children,
+ const char* description,
+ ConstString type_name,
+ ScriptedSyntheticChildren::Flags flags,
+ bool regex = false);
+#endif
+
+ StackFrame*
+ GetViableFrame (ExecutionContext exe_ctx);
+
+ bool
+ ExtractValueFromObjCExpression (ValueObject &valobj,
+ const char* target_type,
+ const char* selector,
+ uint64_t &value);
+
+ bool
+ ExtractSummaryFromObjCExpression (ValueObject &valobj,
+ const char* target_type,
+ const char* selector,
+ Stream &stream,
+ lldb::LanguageType lang_type);
+
+ lldb::ValueObjectSP
+ CallSelectorOnObject (ValueObject &valobj,
+ const char* return_type,
+ const char* selector,
+ uint64_t index);
+
+ lldb::ValueObjectSP
+ CallSelectorOnObject (ValueObject &valobj,
+ const char* return_type,
+ const char* selector,
+ const char* key);
+
+ size_t
+ ExtractIndexFromString (const char* item_name);
+
+ lldb::addr_t
+ GetArrayAddressOrPointerValue (ValueObject& valobj);
+
+ time_t
+ GetOSXEpoch ();
+
+ struct InferiorSizedWord {
+
+ InferiorSizedWord(const InferiorSizedWord& word) : ptr_size(word.ptr_size)
+ {
+ if (ptr_size == 4)
+ thirty_two = word.thirty_two;
+ else
+ sixty_four = word.sixty_four;
+ }
+
+ InferiorSizedWord
+ operator = (const InferiorSizedWord& word)
+ {
+ ptr_size = word.ptr_size;
+ if (ptr_size == 4)
+ thirty_two = word.thirty_two;
+ else
+ sixty_four = word.sixty_four;
+ return *this;
+ }
+
+ InferiorSizedWord(uint64_t val, Process& process) : ptr_size(process.GetAddressByteSize())
+ {
+ if (ptr_size == 4)
+ thirty_two = (uint32_t)val;
+ else if (ptr_size == 8)
+ sixty_four = val;
+ else
+ assert (false && "new pointer size is unknown");
+ }
+
+ bool
+ IsNegative () const
+ {
+ if (ptr_size == 4)
+ return ((int32_t)thirty_two) < 0;
+ else
+ return ((int64_t)sixty_four) < 0;
+ }
+
+ bool
+ IsZero () const
+ {
+ if (ptr_size == 4)
+ return thirty_two == 0;
+ else
+ return sixty_four == 0;
+ }
+
+ static InferiorSizedWord
+ GetMaximum (Process& process)
+ {
+ if (process.GetAddressByteSize() == 4)
+ return InferiorSizedWord(UINT32_MAX,4);
+ else
+ return InferiorSizedWord(UINT64_MAX,8);
+ }
+
+ InferiorSizedWord
+ operator >> (int rhs) const
+ {
+ if (ptr_size == 4)
+ return InferiorSizedWord(thirty_two >> rhs,4);
+ return InferiorSizedWord(sixty_four>>rhs,8);
+ }
+
+ InferiorSizedWord
+ operator << (int rhs) const
+ {
+ if (ptr_size == 4)
+ return InferiorSizedWord(thirty_two << rhs,4);
+ return InferiorSizedWord(sixty_four << rhs,8);
+ }
+
+ InferiorSizedWord
+ operator & (const InferiorSizedWord& word) const
+ {
+ if (ptr_size != word.ptr_size)
+ return InferiorSizedWord(0,ptr_size);
+ if (ptr_size == 4)
+ return InferiorSizedWord(thirty_two & word.thirty_two,4);
+ return InferiorSizedWord(sixty_four & word.sixty_four,8);
+ }
+
+ InferiorSizedWord
+ operator & (int x) const
+ {
+ if (ptr_size == 4)
+ return InferiorSizedWord(thirty_two & x,4);
+ return InferiorSizedWord(sixty_four & x,8);
+ }
+
+ size_t
+ GetBitSize () const
+ {
+ return ptr_size << 3;
+ }
+
+ size_t
+ GetByteSize () const
+ {
+ return ptr_size;
+ }
+
+ uint64_t
+ GetValue () const
+ {
+ if (ptr_size == 4)
+ return (uint64_t)thirty_two;
+ return sixty_four;
+ }
+
+ InferiorSizedWord
+ SignExtend () const
+ {
+ if (ptr_size == 4)
+ return InferiorSizedWord ((int32_t)thirty_two,4);
+ return InferiorSizedWord((int64_t)sixty_four,8);
+ }
+
+ uint8_t*
+ CopyToBuffer (uint8_t* buffer) const
+ {
+ if (ptr_size == 4)
+ {
+ memcpy(buffer, &thirty_two, 4);
+ return buffer + 4;
+ }
+ else
+ {
+ memcpy(buffer, &sixty_four, 8);
+ return buffer + 8;
+ }
+ }
+
+ DataExtractor
+ GetAsData (lldb::ByteOrder byte_order = lldb::eByteOrderInvalid) const
+ {
+ if (ptr_size == 4)
+ return DataExtractor(&thirty_two, 4, byte_order, 4);
+ else
+ return DataExtractor(&sixty_four, 8, byte_order, 8);
+ }
+
+ private:
+
+ InferiorSizedWord(uint64_t val, size_t psz) : ptr_size(psz)
+ {
+ if (ptr_size == 4)
+ thirty_two = (uint32_t)val;
+ else
+ sixty_four = val;
+ }
+
+ size_t ptr_size;
+ union {
+ uint32_t thirty_two;
+ uint64_t sixty_four;
+ };
+ };
+ } // namespace formatters
+} // namespace lldb_private
+
+#endif // lldb_FormattersHelpers_h_
diff --git a/include/lldb/DataFormatters/LanguageCategory.h b/include/lldb/DataFormatters/LanguageCategory.h
new file mode 100644
index 000000000000..a7040099f213
--- /dev/null
+++ b/include/lldb/DataFormatters/LanguageCategory.h
@@ -0,0 +1,99 @@
+//===-- LanguageCategory.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_LanguageCategory_h_
+#define lldb_LanguageCategory_h_
+
+// C Includes
+// C++ Includes
+
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-public.h"
+#include "lldb/DataFormatters/FormatCache.h"
+#include "lldb/DataFormatters/FormatClasses.h"
+
+#include <memory>
+
+namespace lldb_private {
+
+class LanguageCategory
+{
+public:
+ typedef std::unique_ptr<LanguageCategory> UniquePointer;
+
+ LanguageCategory (lldb::LanguageType lang_type);
+
+ bool
+ Get (FormattersMatchData& match_data,
+ lldb::TypeFormatImplSP& format_sp);
+
+ bool
+ Get (FormattersMatchData& match_data,
+ lldb::TypeSummaryImplSP& format_sp);
+
+ bool
+ Get (FormattersMatchData& match_data,
+ lldb::SyntheticChildrenSP& format_sp);
+
+ bool
+ Get (FormattersMatchData& match_data,
+ lldb::TypeValidatorImplSP& format_sp);
+
+ bool
+ GetHardcoded (FormatManager& fmt_mgr,
+ FormattersMatchData& match_data,
+ lldb::TypeFormatImplSP& format_sp);
+
+ bool
+ GetHardcoded (FormatManager& fmt_mgr,
+ FormattersMatchData& match_data,
+ lldb::TypeSummaryImplSP& format_sp);
+
+ bool
+ GetHardcoded (FormatManager& fmt_mgr,
+ FormattersMatchData& match_data,
+ lldb::SyntheticChildrenSP& format_sp);
+
+ bool
+ GetHardcoded (FormatManager& fmt_mgr,
+ FormattersMatchData& match_data,
+ lldb::TypeValidatorImplSP& format_sp);
+
+ lldb::TypeCategoryImplSP
+ GetCategory () const;
+
+ FormatCache&
+ GetFormatCache ();
+
+ void
+ Enable ();
+
+ void
+ Disable ();
+
+ bool
+ IsEnabled ();
+
+private:
+ lldb::TypeCategoryImplSP m_category_sp;
+
+ HardcodedFormatters::HardcodedFormatFinder m_hardcoded_formats;
+ HardcodedFormatters::HardcodedSummaryFinder m_hardcoded_summaries;
+ HardcodedFormatters::HardcodedSyntheticFinder m_hardcoded_synthetics;
+ HardcodedFormatters::HardcodedValidatorFinder m_hardcoded_validators;
+
+ lldb_private::FormatCache m_format_cache;
+
+ bool m_enabled;
+};
+
+} // namespace lldb_private
+
+#endif // lldb_LanguageCategory_h_
diff --git a/include/lldb/DataFormatters/StringPrinter.h b/include/lldb/DataFormatters/StringPrinter.h
index 48e27ace5d92..a849c4e01109 100644
--- a/include/lldb/DataFormatters/StringPrinter.h
+++ b/include/lldb/DataFormatters/StringPrinter.h
@@ -10,6 +10,13 @@
#ifndef liblldb_StringPrinter_h_
#define liblldb_StringPrinter_h_
+// C Includes
+// C++ Includes
+#include <functional>
+#include <string>
+
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-forward.h"
#include "lldb/Core/DataExtractor.h"
@@ -17,273 +24,505 @@
namespace lldb_private {
namespace formatters
{
-
- enum class StringElementType {
- ASCII,
- UTF8,
- UTF16,
- UTF32
- };
-
- class ReadStringAndDumpToStreamOptions
+ class StringPrinter
{
public:
-
- ReadStringAndDumpToStreamOptions () :
- m_location(0),
- m_process_sp(),
- m_stream(NULL),
- m_prefix_token(0),
- m_quote('"'),
- m_source_size(0),
- m_needs_zero_termination(true),
- m_escape_non_printables(true),
- m_ignore_max_length(false)
- {
- }
-
- ReadStringAndDumpToStreamOptions (ValueObject& valobj);
-
- ReadStringAndDumpToStreamOptions&
- SetLocation (uint64_t l)
- {
- m_location = l;
- return *this;
- }
-
- uint64_t
- GetLocation () const
- {
- return m_location;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetProcessSP (lldb::ProcessSP p)
- {
- m_process_sp = p;
- return *this;
- }
-
- lldb::ProcessSP
- GetProcessSP () const
- {
- return m_process_sp;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetStream (Stream* s)
- {
- m_stream = s;
- return *this;
- }
-
- Stream*
- GetStream () const
- {
- return m_stream;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetPrefixToken (char p)
- {
- m_prefix_token = p;
- return *this;
- }
-
- char
- GetPrefixToken () const
- {
- return m_prefix_token;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetQuote (char q)
- {
- m_quote = q;
- return *this;
- }
-
- char
- GetQuote () const
- {
- return m_quote;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetSourceSize (uint32_t s)
- {
- m_source_size = s;
- return *this;
- }
-
- uint32_t
- GetSourceSize () const
- {
- return m_source_size;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetNeedsZeroTermination (bool z)
- {
- m_needs_zero_termination = z;
- return *this;
- }
-
- bool
- GetNeedsZeroTermination () const
- {
- return m_needs_zero_termination;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetEscapeNonPrintables (bool e)
- {
- m_escape_non_printables = e;
- return *this;
- }
-
- bool
- GetEscapeNonPrintables () const
- {
- return m_escape_non_printables;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetIgnoreMaxLength (bool e)
- {
- m_ignore_max_length = e;
- return *this;
- }
-
- bool
- GetIgnoreMaxLength () const
- {
- return m_ignore_max_length;
- }
-
- private:
- uint64_t m_location;
- lldb::ProcessSP m_process_sp;
- Stream* m_stream;
- char m_prefix_token;
- char m_quote;
- uint32_t m_source_size;
- bool m_needs_zero_termination;
- bool m_escape_non_printables;
- bool m_ignore_max_length;
- };
-
- class ReadBufferAndDumpToStreamOptions
- {
- public:
-
- ReadBufferAndDumpToStreamOptions () :
- m_data(),
- m_stream(NULL),
- m_prefix_token(0),
- m_quote('"'),
- m_source_size(0),
- m_escape_non_printables(true)
- {
- }
-
- ReadBufferAndDumpToStreamOptions (ValueObject& valobj);
-
- ReadBufferAndDumpToStreamOptions&
- SetData (DataExtractor d)
- {
- m_data = d;
- return *this;
- }
-
- lldb_private::DataExtractor
- GetData () const
- {
- return m_data;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetStream (Stream* s)
- {
- m_stream = s;
- return *this;
- }
-
- Stream*
- GetStream () const
- {
- return m_stream;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetPrefixToken (char p)
- {
- m_prefix_token = p;
- return *this;
- }
-
- char
- GetPrefixToken () const
- {
- return m_prefix_token;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetQuote (char q)
- {
- m_quote = q;
- return *this;
- }
-
- char
- GetQuote () const
- {
- return m_quote;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetSourceSize (uint32_t s)
- {
- m_source_size = s;
- return *this;
- }
-
- uint32_t
- GetSourceSize () const
- {
- return m_source_size;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetEscapeNonPrintables (bool e)
- {
- m_escape_non_printables = e;
- return *this;
- }
-
- bool
- GetEscapeNonPrintables () const
- {
- return m_escape_non_printables;
- }
-
- private:
- DataExtractor m_data;
- Stream* m_stream;
- char m_prefix_token;
- char m_quote;
- uint32_t m_source_size;
- bool m_escape_non_printables;
+ enum class StringElementType
+ {
+ ASCII,
+ UTF8,
+ UTF16,
+ UTF32
+ };
+
+ enum class GetPrintableElementType
+ {
+ ASCII,
+ UTF8
+ };
+
+ class ReadStringAndDumpToStreamOptions
+ {
+ public:
+ ReadStringAndDumpToStreamOptions () :
+ m_location(0),
+ m_process_sp(),
+ m_stream(nullptr),
+ m_prefix_token(),
+ m_suffix_token(),
+ m_quote('"'),
+ m_source_size(0),
+ m_needs_zero_termination(true),
+ m_escape_non_printables(true),
+ m_ignore_max_length(false),
+ m_zero_is_terminator(true),
+ m_language_type(lldb::eLanguageTypeUnknown)
+ {
+ }
+
+ ReadStringAndDumpToStreamOptions (ValueObject& valobj);
+
+ ReadStringAndDumpToStreamOptions&
+ SetLocation (uint64_t l)
+ {
+ m_location = l;
+ return *this;
+ }
+
+ uint64_t
+ GetLocation () const
+ {
+ return m_location;
+ }
+
+ ReadStringAndDumpToStreamOptions&
+ SetProcessSP (lldb::ProcessSP p)
+ {
+ m_process_sp = p;
+ return *this;
+ }
+
+ lldb::ProcessSP
+ GetProcessSP () const
+ {
+ return m_process_sp;
+ }
+
+ ReadStringAndDumpToStreamOptions&
+ SetStream (Stream* s)
+ {
+ m_stream = s;
+ return *this;
+ }
+
+ Stream*
+ GetStream () const
+ {
+ return m_stream;
+ }
+
+ ReadStringAndDumpToStreamOptions&
+ SetPrefixToken (const std::string& p)
+ {
+ m_prefix_token = p;
+ return *this;
+ }
+
+ ReadStringAndDumpToStreamOptions&
+ SetPrefixToken (std::nullptr_t)
+ {
+ m_prefix_token.clear();
+ return *this;
+ }
+
+ const char*
+ GetPrefixToken () const
+ {
+ return m_prefix_token.c_str();
+ }
+
+ ReadStringAndDumpToStreamOptions&
+ SetSuffixToken (const std::string& p)
+ {
+ m_suffix_token = p;
+ return *this;
+ }
+
+ ReadStringAndDumpToStreamOptions&
+ SetSuffixToken (std::nullptr_t)
+ {
+ m_suffix_token.clear();
+ return *this;
+ }
+
+ const char*
+ GetSuffixToken () const
+ {
+ return m_suffix_token.c_str();
+ }
+
+ ReadStringAndDumpToStreamOptions&
+ SetQuote (char q)
+ {
+ m_quote = q;
+ return *this;
+ }
+
+ char
+ GetQuote () const
+ {
+ return m_quote;
+ }
+
+ ReadStringAndDumpToStreamOptions&
+ SetSourceSize (uint32_t s)
+ {
+ m_source_size = s;
+ return *this;
+ }
+
+ uint32_t
+ GetSourceSize () const
+ {
+ return m_source_size;
+ }
+
+ ReadStringAndDumpToStreamOptions&
+ SetNeedsZeroTermination (bool z)
+ {
+ m_needs_zero_termination = z;
+ return *this;
+ }
+
+ bool
+ GetNeedsZeroTermination () const
+ {
+ return m_needs_zero_termination;
+ }
+
+ ReadStringAndDumpToStreamOptions&
+ SetBinaryZeroIsTerminator (bool e)
+ {
+ m_zero_is_terminator = e;
+ return *this;
+ }
+
+ bool
+ GetBinaryZeroIsTerminator () const
+ {
+ return m_zero_is_terminator;
+ }
+
+ ReadStringAndDumpToStreamOptions&
+ SetEscapeNonPrintables (bool e)
+ {
+ m_escape_non_printables = e;
+ return *this;
+ }
+
+ bool
+ GetEscapeNonPrintables () const
+ {
+ return m_escape_non_printables;
+ }
+
+ ReadStringAndDumpToStreamOptions&
+ SetIgnoreMaxLength (bool e)
+ {
+ m_ignore_max_length = e;
+ return *this;
+ }
+
+ bool
+ GetIgnoreMaxLength () const
+ {
+ return m_ignore_max_length;
+ }
+
+ ReadStringAndDumpToStreamOptions&
+ SetLanguage (lldb::LanguageType l)
+ {
+ m_language_type = l;
+ return *this;
+ }
+
+ lldb::LanguageType
+ GetLanguage () const
+
+ {
+ return m_language_type;
+ }
+
+ private:
+ uint64_t m_location;
+ lldb::ProcessSP m_process_sp;
+ Stream* m_stream;
+ std::string m_prefix_token;
+ std::string m_suffix_token;
+ char m_quote;
+ uint32_t m_source_size;
+ bool m_needs_zero_termination;
+ bool m_escape_non_printables;
+ bool m_ignore_max_length;
+ bool m_zero_is_terminator;
+ lldb::LanguageType m_language_type;
+ };
+
+ class ReadBufferAndDumpToStreamOptions
+ {
+ public:
+ ReadBufferAndDumpToStreamOptions () :
+ m_data(),
+ m_stream(nullptr),
+ m_prefix_token(),
+ m_suffix_token(),
+ m_quote('"'),
+ m_source_size(0),
+ m_escape_non_printables(true),
+ m_zero_is_terminator(true),
+ m_is_truncated(false),
+ m_language_type(lldb::eLanguageTypeUnknown)
+ {
+ }
+
+ ReadBufferAndDumpToStreamOptions (ValueObject& valobj);
+
+ ReadBufferAndDumpToStreamOptions (const ReadStringAndDumpToStreamOptions& options);
+
+ ReadBufferAndDumpToStreamOptions&
+ SetData (DataExtractor d)
+ {
+ m_data = d;
+ return *this;
+ }
+
+ lldb_private::DataExtractor
+ GetData () const
+ {
+ return m_data;
+ }
+
+ ReadBufferAndDumpToStreamOptions&
+ SetStream (Stream* s)
+ {
+ m_stream = s;
+ return *this;
+ }
+
+ Stream*
+ GetStream () const
+ {
+ return m_stream;
+ }
+
+ ReadBufferAndDumpToStreamOptions&
+ SetPrefixToken (const std::string& p)
+ {
+ m_prefix_token = p;
+ return *this;
+ }
+
+ ReadBufferAndDumpToStreamOptions&
+ SetPrefixToken (std::nullptr_t)
+ {
+ m_prefix_token.clear();
+ return *this;
+ }
+
+ const char*
+ GetPrefixToken () const
+ {
+ return m_prefix_token.c_str();
+ }
+
+ ReadBufferAndDumpToStreamOptions&
+ SetSuffixToken (const std::string& p)
+ {
+ m_suffix_token = p;
+ return *this;
+ }
+
+ ReadBufferAndDumpToStreamOptions&
+ SetSuffixToken (std::nullptr_t)
+ {
+ m_suffix_token.clear();
+ return *this;
+ }
+
+ const char*
+ GetSuffixToken () const
+ {
+ return m_suffix_token.c_str();
+ }
+
+ ReadBufferAndDumpToStreamOptions&
+ SetQuote (char q)
+ {
+ m_quote = q;
+ return *this;
+ }
+
+ char
+ GetQuote () const
+ {
+ return m_quote;
+ }
+
+ ReadBufferAndDumpToStreamOptions&
+ SetSourceSize (uint32_t s)
+ {
+ m_source_size = s;
+ return *this;
+ }
+
+ uint32_t
+ GetSourceSize () const
+ {
+ return m_source_size;
+ }
+
+ ReadBufferAndDumpToStreamOptions&
+ SetEscapeNonPrintables (bool e)
+ {
+ m_escape_non_printables = e;
+ return *this;
+ }
+
+ bool
+ GetEscapeNonPrintables () const
+ {
+ return m_escape_non_printables;
+ }
+
+ ReadBufferAndDumpToStreamOptions&
+ SetBinaryZeroIsTerminator (bool e)
+ {
+ m_zero_is_terminator = e;
+ return *this;
+ }
+
+ bool
+ GetBinaryZeroIsTerminator () const
+ {
+ return m_zero_is_terminator;
+ }
+
+ ReadBufferAndDumpToStreamOptions&
+ SetIsTruncated (bool t)
+ {
+ m_is_truncated = t;
+ return *this;
+ }
+
+ bool
+ GetIsTruncated () const
+ {
+ return m_is_truncated;
+ }
+
+ ReadBufferAndDumpToStreamOptions&
+ SetLanguage (lldb::LanguageType l)
+ {
+ m_language_type = l;
+ return *this;
+ }
+
+ lldb::LanguageType
+ GetLanguage () const
+
+ {
+ return m_language_type;
+ }
+
+ private:
+ DataExtractor m_data;
+ Stream* m_stream;
+ std::string m_prefix_token;
+ std::string m_suffix_token;
+ char m_quote;
+ uint32_t m_source_size;
+ bool m_escape_non_printables;
+ bool m_zero_is_terminator;
+ bool m_is_truncated;
+ lldb::LanguageType m_language_type;
+ };
+
+ // I can't use a std::unique_ptr for this because the Deleter is a template argument there
+ // and I want the same type to represent both pointers I want to free and pointers I don't need
+ // to free - which is what this class essentially is
+ // It's very specialized to the needs of this file, and not suggested for general use
+ template <typename T = uint8_t, typename U = char, typename S = size_t>
+ struct StringPrinterBufferPointer
+ {
+ public:
+ typedef std::function<void(const T*)> Deleter;
+
+ StringPrinterBufferPointer (std::nullptr_t ptr) :
+ m_data(nullptr),
+ m_size(0),
+ m_deleter()
+ {}
+
+ StringPrinterBufferPointer(const T* bytes, S size, Deleter deleter = nullptr) :
+ m_data(bytes),
+ m_size(size),
+ m_deleter(deleter)
+ {}
+
+ StringPrinterBufferPointer(const U* bytes, S size, Deleter deleter = nullptr) :
+ m_data(reinterpret_cast<const T*>(bytes)),
+ m_size(size),
+ m_deleter(deleter)
+ {}
+
+ StringPrinterBufferPointer(StringPrinterBufferPointer&& rhs) :
+ m_data(rhs.m_data),
+ m_size(rhs.m_size),
+ m_deleter(rhs.m_deleter)
+ {
+ rhs.m_data = nullptr;
+ }
+
+ StringPrinterBufferPointer(const StringPrinterBufferPointer& rhs) :
+ m_data(rhs.m_data),
+ m_size(rhs.m_size),
+ m_deleter(rhs.m_deleter)
+ {
+ rhs.m_data = nullptr; // this is why m_data has to be mutable
+ }
+
+ ~StringPrinterBufferPointer()
+ {
+ if (m_data && m_deleter)
+ m_deleter(m_data);
+ m_data = nullptr;
+ }
+
+ const T*
+ GetBytes () const
+ {
+ return m_data;
+ }
+
+ const S
+ GetSize () const
+ {
+ return m_size;
+ }
+
+ StringPrinterBufferPointer&
+ operator = (const StringPrinterBufferPointer& rhs)
+ {
+ if (m_data && m_deleter)
+ m_deleter(m_data);
+ m_data = rhs.m_data;
+ m_size = rhs.m_size;
+ m_deleter = rhs.m_deleter;
+ rhs.m_data = nullptr;
+ return *this;
+ }
+
+ private:
+ mutable const T* m_data;
+ size_t m_size;
+ Deleter m_deleter;
+ };
+
+ typedef std::function<StringPrinter::StringPrinterBufferPointer<uint8_t,char,size_t>(uint8_t*, uint8_t*, uint8_t*&)> EscapingHelper;
+ typedef std::function<EscapingHelper(GetPrintableElementType)> EscapingHelperGenerator;
+
+ static EscapingHelper
+ GetDefaultEscapingHelper (GetPrintableElementType elem_type);
+
+ template <StringElementType element_type>
+ static bool
+ ReadStringAndDumpToStream (const ReadStringAndDumpToStreamOptions& options);
+
+ template <StringElementType element_type>
+ static bool
+ ReadBufferAndDumpToStream (const ReadBufferAndDumpToStreamOptions& options);
};
- template <StringElementType element_type>
- bool
- ReadStringAndDumpToStream (ReadStringAndDumpToStreamOptions options);
-
- template <StringElementType element_type>
- bool
- ReadBufferAndDumpToStream (ReadBufferAndDumpToStreamOptions options);
-
} // namespace formatters
} // namespace lldb_private
diff --git a/include/lldb/DataFormatters/TypeCategory.h b/include/lldb/DataFormatters/TypeCategory.h
index e32efa420a55..075d31d1cf6f 100644
--- a/include/lldb/DataFormatters/TypeCategory.h
+++ b/include/lldb/DataFormatters/TypeCategory.h
@@ -1,4 +1,4 @@
-//===-- TypeCategory.h -------------------------------------------*- C++ -*-===//
+//===-- TypeCategory.h ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -12,6 +12,10 @@
// C Includes
// C++ Includes
+#include <initializer_list>
+#include <memory>
+#include <string>
+#include <vector>
// Other libraries and framework includes
// Project includes
@@ -38,6 +42,9 @@ namespace lldb_private {
typedef typename ExactMatchContainer::SharedPointer ExactMatchContainerSP;
typedef typename RegexMatchContainer::SharedPointer RegexMatchContainerSP;
+ typedef typename ExactMatchContainer::ForEachCallback ExactMatchForEachCallback;
+ typedef typename RegexMatchContainer::ForEachCallback RegexMatchForEachCallback;
+
FormatterContainerPair (const char* exact_name,
const char* regex_name,
IFormatChangeListener* clist) :
@@ -60,6 +67,12 @@ namespace lldb_private {
return m_regex_sp;
}
+ uint32_t
+ GetCount ()
+ {
+ return GetExactMatch()->GetCount() + GetRegexMatch()->GetCount();
+ }
+
private:
ExactMatchContainerSP m_exact_sp;
RegexMatchContainerSP m_regex_sp;
@@ -74,11 +87,10 @@ namespace lldb_private {
typedef FormatterContainerPair<TypeValidatorImpl> ValidatorContainer;
#ifndef LLDB_DISABLE_PYTHON
- typedef FormatterContainerPair<ScriptedSyntheticChildren> SynthContainer;
-#endif // #ifndef LLDB_DISABLE_PYTHON
+ typedef FormatterContainerPair<SyntheticChildren> SynthContainer;
+#endif // LLDB_DISABLE_PYTHON
public:
-
typedef uint16_t FormatCategoryItems;
static const uint16_t ALL_ITEM_TYPES = UINT16_MAX;
@@ -93,13 +105,195 @@ namespace lldb_private {
#ifndef LLDB_DISABLE_PYTHON
typedef SynthContainer::ExactMatchContainerSP SynthContainerSP;
typedef SynthContainer::RegexMatchContainerSP RegexSynthContainerSP;
-#endif // #ifndef LLDB_DISABLE_PYTHON
+#endif // LLDB_DISABLE_PYTHON
typedef ValidatorContainer::ExactMatchContainerSP ValidatorContainerSP;
typedef ValidatorContainer::RegexMatchContainerSP RegexValidatorContainerSP;
+ template <typename T>
+ class ForEachCallbacks
+ {
+ public:
+ ForEachCallbacks () = default;
+ ~ForEachCallbacks () = default;
+
+ template<typename U = TypeFormatImpl>
+ typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
+ SetExact (FormatContainer::ExactMatchForEachCallback callback)
+ {
+ m_format_exact = callback;
+ return *this;
+ }
+ template<typename U = TypeFormatImpl>
+ typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
+ SetWithRegex (FormatContainer::RegexMatchForEachCallback callback)
+ {
+ m_format_regex = callback;
+ return *this;
+ }
+
+ template<typename U = TypeSummaryImpl>
+ typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
+ SetExact (SummaryContainer::ExactMatchForEachCallback callback)
+ {
+ m_summary_exact = callback;
+ return *this;
+ }
+ template<typename U = TypeSummaryImpl>
+ typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
+ SetWithRegex (SummaryContainer::RegexMatchForEachCallback callback)
+ {
+ m_summary_regex = callback;
+ return *this;
+ }
+
+ template<typename U = TypeFilterImpl>
+ typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
+ SetExact (FilterContainer::ExactMatchForEachCallback callback)
+ {
+ m_filter_exact = callback;
+ return *this;
+ }
+ template<typename U = TypeFilterImpl>
+ typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
+ SetWithRegex (FilterContainer::RegexMatchForEachCallback callback)
+ {
+ m_filter_regex = callback;
+ return *this;
+ }
+
+#ifndef LLDB_DISABLE_PYTHON
+ template<typename U = SyntheticChildren>
+ typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
+ SetExact (SynthContainer::ExactMatchForEachCallback callback)
+ {
+ m_synth_exact = callback;
+ return *this;
+ }
+ template<typename U = SyntheticChildren>
+ typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
+ SetWithRegex (SynthContainer::RegexMatchForEachCallback callback)
+ {
+ m_synth_regex = callback;
+ return *this;
+ }
+#endif // LLDB_DISABLE_PYTHON
+ template<typename U = TypeValidatorImpl>
+ typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
+ SetExact (ValidatorContainer::ExactMatchForEachCallback callback)
+ {
+ m_validator_exact = callback;
+ return *this;
+ }
+ template<typename U = TypeValidatorImpl>
+ typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
+ SetWithRegex (ValidatorContainer::RegexMatchForEachCallback callback)
+ {
+ m_validator_regex = callback;
+ return *this;
+ }
+
+ FormatContainer::ExactMatchForEachCallback
+ GetFormatExactCallback () const
+ {
+ return m_format_exact;
+ }
+ FormatContainer::RegexMatchForEachCallback
+ GetFormatRegexCallback () const
+ {
+ return m_format_regex;
+ }
+
+ SummaryContainer::ExactMatchForEachCallback
+ GetSummaryExactCallback () const
+ {
+ return m_summary_exact;
+ }
+ SummaryContainer::RegexMatchForEachCallback
+ GetSummaryRegexCallback () const
+ {
+ return m_summary_regex;
+ }
+
+ FilterContainer::ExactMatchForEachCallback
+ GetFilterExactCallback () const
+ {
+ return m_filter_exact;
+ }
+ FilterContainer::RegexMatchForEachCallback
+ GetFilterRegexCallback () const
+ {
+ return m_filter_regex;
+ }
+
+#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
+ {
+ return m_validator_exact;
+ }
+ ValidatorContainer::RegexMatchForEachCallback
+ GetValidatorRegexCallback () const
+ {
+ return m_validator_regex;
+ }
+
+ private:
+ FormatContainer::ExactMatchForEachCallback m_format_exact;
+ FormatContainer::RegexMatchForEachCallback m_format_regex;
+
+ SummaryContainer::ExactMatchForEachCallback m_summary_exact;
+ SummaryContainer::RegexMatchForEachCallback m_summary_regex;
+
+ FilterContainer::ExactMatchForEachCallback m_filter_exact;
+ FilterContainer::RegexMatchForEachCallback m_filter_regex;
+
+#ifndef LLDB_DISABLE_PYTHON
+ SynthContainer::ExactMatchForEachCallback m_synth_exact;
+ SynthContainer::RegexMatchForEachCallback m_synth_regex;
+#endif // LLDB_DISABLE_PYTHON
+
+ ValidatorContainer::ExactMatchForEachCallback m_validator_exact;
+ ValidatorContainer::RegexMatchForEachCallback m_validator_regex;
+ };
+
TypeCategoryImpl (IFormatChangeListener* clist,
- ConstString name);
+ ConstString name,
+ std::initializer_list<lldb::LanguageType> langs = {});
+
+ template <typename T>
+ void
+ ForEach (const ForEachCallbacks<T> &foreach)
+ {
+ GetTypeFormatsContainer()->ForEach(foreach.GetFormatExactCallback());
+ GetRegexTypeFormatsContainer()->ForEach(foreach.GetFormatRegexCallback());
+
+ GetTypeSummariesContainer()->ForEach(foreach.GetSummaryExactCallback());
+ GetRegexTypeSummariesContainer()->ForEach(foreach.GetSummaryRegexCallback());
+
+ GetTypeFiltersContainer()->ForEach(foreach.GetFilterExactCallback());
+ GetRegexTypeFiltersContainer()->ForEach(foreach.GetFilterRegexCallback());
+
+#ifndef LLDB_DISABLE_PYTHON
+ GetTypeSyntheticsContainer()->ForEach(foreach.GetSynthExactCallback());
+ GetRegexTypeSyntheticsContainer()->ForEach(foreach.GetSynthRegexCallback());
+#endif // LLDB_DISABLE_PYTHON
+
+ GetTypeValidatorsContainer()->ForEach(foreach.GetValidatorExactCallback());
+ GetRegexTypeValidatorsContainer()->ForEach(foreach.GetValidatorRegexCallback());
+ }
FormatContainerSP
GetTypeFormatsContainer ()
@@ -113,6 +307,12 @@ namespace lldb_private {
return m_format_cont.GetRegexMatch();
}
+ FormatContainer&
+ GetFormatContainer ()
+ {
+ return m_format_cont;
+ }
+
SummaryContainerSP
GetTypeSummariesContainer ()
{
@@ -125,6 +325,12 @@ namespace lldb_private {
return m_summary_cont.GetRegexMatch();
}
+ SummaryContainer&
+ GetSummaryContainer ()
+ {
+ return m_summary_cont;
+ }
+
FilterContainerSP
GetTypeFiltersContainer ()
{
@@ -136,6 +342,12 @@ namespace lldb_private {
{
return m_filter_cont.GetRegexMatch();
}
+
+ FilterContainer&
+ GetFilterContainer ()
+ {
+ return m_filter_cont;
+ }
FormatContainer::MapValueType
GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp);
@@ -185,12 +397,18 @@ namespace lldb_private {
return m_synth_cont.GetRegexMatch();
}
+ SynthContainer&
+ GetSyntheticsContainer ()
+ {
+ return m_synth_cont;
+ }
+
SynthContainer::MapValueType
GetSyntheticAtIndex (size_t index);
lldb::TypeNameSpecifierImplSP
GetTypeNameSpecifierForSyntheticAtIndex (size_t index);
-#endif // #ifndef LLDB_DISABLE_PYTHON
+#endif // LLDB_DISABLE_PYTHON
ValidatorContainerSP
GetTypeValidatorsContainer ()
@@ -226,28 +444,28 @@ namespace lldb_private {
}
bool
- Get (ValueObject& valobj,
- const FormattersMatchVector& candidates,
- lldb::TypeFormatImplSP& entry,
- uint32_t* reason = NULL);
+ Get(ValueObject& valobj,
+ const FormattersMatchVector& candidates,
+ lldb::TypeFormatImplSP& entry,
+ uint32_t* reason = nullptr);
bool
- Get (ValueObject& valobj,
- const FormattersMatchVector& candidates,
- lldb::TypeSummaryImplSP& entry,
- uint32_t* reason = NULL);
+ Get(ValueObject& valobj,
+ const FormattersMatchVector& candidates,
+ lldb::TypeSummaryImplSP& entry,
+ uint32_t* reason = nullptr);
bool
- Get (ValueObject& valobj,
- const FormattersMatchVector& candidates,
- lldb::SyntheticChildrenSP& entry,
- uint32_t* reason = NULL);
+ Get(ValueObject& valobj,
+ const FormattersMatchVector& candidates,
+ lldb::SyntheticChildrenSP& entry,
+ uint32_t* reason = nullptr);
bool
- Get (ValueObject& valobj,
- const FormattersMatchVector& candidates,
- lldb::TypeValidatorImplSP& entry,
- uint32_t* reason = NULL);
+ Get(ValueObject& valobj,
+ const FormattersMatchVector& candidates,
+ lldb::TypeValidatorImplSP& entry,
+ uint32_t* reason = nullptr);
void
Clear (FormatCategoryItems items = ALL_ITEM_TYPES);
@@ -264,13 +482,28 @@ namespace lldb_private {
{
return m_name.GetCString();
}
+
+ size_t
+ GetNumLanguages ();
+
+ lldb::LanguageType
+ GetLanguageAtIndex (size_t idx);
+
+ void
+ AddLanguage (lldb::LanguageType lang);
bool
- AnyMatches (ConstString type_name,
- FormatCategoryItems items = ALL_ITEM_TYPES,
- bool only_enabled = true,
- const char** matching_category = NULL,
- FormatCategoryItems* matching_type = NULL);
+ HasLanguage (lldb::LanguageType lang);
+
+ std::string
+ GetDescription ();
+
+ bool
+ AnyMatches(ConstString type_name,
+ FormatCategoryItems items = ALL_ITEM_TYPES,
+ bool only_enabled = true,
+ const char** matching_category = nullptr,
+ FormatCategoryItems* matching_type = nullptr);
typedef std::shared_ptr<TypeCategoryImpl> SharedPointer;
@@ -280,7 +513,7 @@ namespace lldb_private {
FilterContainer m_filter_cont;
#ifndef LLDB_DISABLE_PYTHON
SynthContainer m_synth_cont;
-#endif // #ifndef LLDB_DISABLE_PYTHON
+#endif // LLDB_DISABLE_PYTHON
ValidatorContainer m_validator_cont;
bool m_enabled;
@@ -291,6 +524,8 @@ namespace lldb_private {
ConstString m_name;
+ std::vector<lldb::LanguageType> m_languages;
+
uint32_t m_enabled_position;
void
@@ -302,6 +537,9 @@ namespace lldb_private {
Enable(false, UINT32_MAX);
}
+ bool
+ IsApplicable (ValueObject& valobj);
+
uint32_t
GetLastEnabledPosition ()
{
@@ -314,6 +552,8 @@ namespace lldb_private {
m_enabled_position = p;
}
+ friend class FormatManager;
+ friend class LanguageCategory;
friend class TypeCategoryMap;
friend class FormattersContainer<ConstString, TypeFormatImpl>;
@@ -328,7 +568,7 @@ namespace lldb_private {
#ifndef LLDB_DISABLE_PYTHON
friend class FormattersContainer<ConstString, ScriptedSyntheticChildren>;
friend class FormattersContainer<lldb::RegularExpressionSP, ScriptedSyntheticChildren>;
-#endif // #ifndef LLDB_DISABLE_PYTHON
+#endif // LLDB_DISABLE_PYTHON
friend class FormattersContainer<ConstString, TypeValidatorImpl>;
friend class FormattersContainer<lldb::RegularExpressionSP, TypeValidatorImpl>;
@@ -336,4 +576,4 @@ namespace lldb_private {
} // namespace lldb_private
-#endif // lldb_TypeCategory_h_
+#endif // lldb_TypeCategory_h_
diff --git a/include/lldb/DataFormatters/TypeCategoryMap.h b/include/lldb/DataFormatters/TypeCategoryMap.h
index 41b170d5335e..8afeaf87cec5 100644
--- a/include/lldb/DataFormatters/TypeCategoryMap.h
+++ b/include/lldb/DataFormatters/TypeCategoryMap.h
@@ -1,4 +1,4 @@
-//===-- TypeCategoryMap.h ----------------------------------------*- C++ -*-===//
+//===-- TypeCategoryMap.h ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -12,6 +12,9 @@
// C Includes
// C++ Includes
+#include <functional>
+#include <list>
+#include <map>
// Other libraries and framework includes
// Project includes
@@ -34,7 +37,8 @@ namespace lldb_private {
public:
typedef std::map<KeyType, ValueSP> MapType;
typedef MapType::iterator MapIterator;
- typedef bool(*CallbackType)(void*, const ValueSP&);
+ typedef std::function<bool(const ValueSP&)> ForEachCallback;
+
typedef uint32_t Position;
static const Position First = 0;
@@ -82,17 +86,17 @@ namespace lldb_private {
ValueSP& entry);
void
- LoopThrough (CallbackType callback, void* param);
+ ForEach (ForEachCallback callback);
lldb::TypeCategoryImplSP
GetAtIndex (uint32_t);
bool
- AnyMatches (ConstString type_name,
- TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES,
- bool only_enabled = true,
- const char** matching_category = NULL,
- TypeCategoryImpl::FormatCategoryItems* matching_type = NULL);
+ AnyMatches(ConstString type_name,
+ TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES,
+ bool only_enabled = true,
+ const char** matching_category = nullptr,
+ TypeCategoryImpl::FormatCategoryItems* matching_type = nullptr);
uint32_t
GetCount ()
@@ -101,25 +105,20 @@ namespace lldb_private {
}
lldb::TypeFormatImplSP
- GetFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
+ GetFormat (FormattersMatchData& match_data);
lldb::TypeSummaryImplSP
- GetSummaryFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
+ GetSummaryFormat (FormattersMatchData& match_data);
#ifndef LLDB_DISABLE_PYTHON
lldb::SyntheticChildrenSP
- GetSyntheticChildren (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
+ GetSyntheticChildren (FormattersMatchData& match_data);
#endif
- lldb::TypeValidatorImplSP
- GetValidator (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
+ lldb::TypeValidatorImplSP
+ GetValidator(FormattersMatchData& match_data);
private:
-
class delete_matching_categories
{
lldb::TypeCategoryImplSP ptr;
@@ -159,4 +158,4 @@ namespace lldb_private {
};
} // namespace lldb_private
-#endif // lldb_TypeCategoryMap_h_
+#endif // lldb_TypeCategoryMap_h_
diff --git a/include/lldb/DataFormatters/TypeFormat.h b/include/lldb/DataFormatters/TypeFormat.h
index 8aa7c60b4938..4ed28b692061 100644
--- a/include/lldb/DataFormatters/TypeFormat.h
+++ b/include/lldb/DataFormatters/TypeFormat.h
@@ -13,6 +13,7 @@
// C Includes
// C++ Includes
+#include <functional>
#include <string>
#include <unordered_map>
@@ -150,7 +151,6 @@ namespace lldb_private {
TypeFormatImpl (const Flags& flags = Flags());
typedef std::shared_ptr<TypeFormatImpl> SharedPointer;
- typedef bool(*ValueCallback)(void*, ConstString, const lldb::TypeFormatImplSP&);
virtual ~TypeFormatImpl ();
@@ -159,16 +159,19 @@ namespace lldb_private {
{
return m_flags.GetCascades();
}
+
bool
SkipsPointers () const
{
return m_flags.GetSkipPointers();
}
+
bool
SkipsReferences () const
{
return m_flags.GetSkipReferences();
}
+
bool
NonCacheable () const
{
@@ -255,9 +258,8 @@ namespace lldb_private {
const TypeFormatImpl::Flags& flags = Flags());
typedef std::shared_ptr<TypeFormatImpl_Format> SharedPointer;
- typedef bool(*ValueCallback)(void*, ConstString, const TypeFormatImpl_Format::SharedPointer&);
- virtual ~TypeFormatImpl_Format ();
+ ~TypeFormatImpl_Format() override;
lldb::Format
GetFormat () const
@@ -271,18 +273,18 @@ namespace lldb_private {
m_format = fmt;
}
- virtual TypeFormatImpl::Type
- GetType ()
+ TypeFormatImpl::Type
+ GetType() override
{
return TypeFormatImpl::Type::eTypeFormat;
}
- virtual bool
- FormatObject (ValueObject *valobj,
- std::string& dest) const;
+ bool
+ FormatObject(ValueObject *valobj,
+ std::string& dest) const override;
- virtual std::string
- GetDescription();
+ std::string
+ GetDescription() override;
protected:
lldb::Format m_format;
@@ -298,9 +300,8 @@ namespace lldb_private {
const TypeFormatImpl::Flags& flags = Flags());
typedef std::shared_ptr<TypeFormatImpl_EnumType> SharedPointer;
- typedef bool(*ValueCallback)(void*, ConstString, const TypeFormatImpl_EnumType::SharedPointer&);
- ~TypeFormatImpl_EnumType ();
+ ~TypeFormatImpl_EnumType() override;
ConstString
GetTypeName ()
@@ -314,26 +315,26 @@ namespace lldb_private {
m_enum_type = enum_type;
}
- virtual TypeFormatImpl::Type
- GetType ()
+ TypeFormatImpl::Type
+ GetType() override
{
return TypeFormatImpl::Type::eTypeEnum;
}
- virtual bool
- FormatObject (ValueObject *valobj,
- std::string& dest) const;
+ bool
+ FormatObject(ValueObject *valobj,
+ std::string& dest) const override;
- virtual std::string
- GetDescription();
+ std::string
+ GetDescription() override;
protected:
ConstString m_enum_type;
- mutable std::unordered_map<void*,ClangASTType> m_types;
+ mutable std::unordered_map<void*,CompilerType> m_types;
private:
DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl_EnumType);
};
} // namespace lldb_private
-#endif // lldb_TypeFormat_h_
+#endif // lldb_TypeFormat_h_
diff --git a/include/lldb/DataFormatters/TypeSummary.h b/include/lldb/DataFormatters/TypeSummary.h
index c2838eac27f1..e5bf4ecadfdf 100644
--- a/include/lldb/DataFormatters/TypeSummary.h
+++ b/include/lldb/DataFormatters/TypeSummary.h
@@ -1,4 +1,4 @@
-//===-- TypeSummary.h --------------------------------------------*- C++ -*-===//
+//===-- TypeSummary.h -------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,11 +14,11 @@
#include <stdint.h>
// C++ Includes
+#include <functional>
+#include <memory>
#include <string>
-#include <vector>
// Other libraries and framework includes
-
// Project includes
#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
@@ -26,8 +26,6 @@
#include "lldb/Core/Error.h"
#include "lldb/Core/FormatEntity.h"
#include "lldb/Core/StructuredData.h"
-#include "lldb/Core/ValueObject.h"
-#include "lldb/Symbol/Type.h"
namespace lldb_private {
class TypeSummaryOptions
@@ -36,6 +34,8 @@ namespace lldb_private {
TypeSummaryOptions ();
TypeSummaryOptions (const TypeSummaryOptions& rhs);
+ ~TypeSummaryOptions() = default;
+
TypeSummaryOptions&
operator = (const TypeSummaryOptions& rhs);
@@ -50,8 +50,7 @@ namespace lldb_private {
TypeSummaryOptions&
SetCapping (lldb::TypeSummaryCapping);
-
- ~TypeSummaryOptions() = default;
+
private:
lldb::LanguageType m_lang;
lldb::TypeSummaryCapping m_capping;
@@ -60,10 +59,26 @@ namespace lldb_private {
class TypeSummaryImpl
{
public:
+ enum class Kind
+ {
+ eSummaryString,
+ eScript,
+ eCallback,
+ eInternal
+ };
+
+ virtual
+ ~TypeSummaryImpl() = default;
+
+ Kind
+ GetKind () const
+ {
+ return m_kind;
+ }
+
class Flags
{
public:
-
Flags () :
m_flags (lldb::eTypeOptionCascade)
{}
@@ -162,6 +177,22 @@ namespace lldb_private {
m_flags &= ~lldb::eTypeOptionHideChildren;
return *this;
}
+
+ bool
+ GetHideEmptyAggregates () const
+ {
+ return (m_flags & lldb::eTypeOptionHideEmptyAggregates) == lldb::eTypeOptionHideEmptyAggregates;
+ }
+
+ Flags&
+ SetHideEmptyAggregates (bool value = true)
+ {
+ if (value)
+ m_flags |= lldb::eTypeOptionHideEmptyAggregates;
+ else
+ m_flags &= ~lldb::eTypeOptionHideEmptyAggregates;
+ return *this;
+ }
bool
GetDontShowValue () const
@@ -243,31 +274,24 @@ namespace lldb_private {
uint32_t m_flags;
};
- typedef enum Type
- {
- eTypeUnknown,
- eTypeString,
- eTypeScript,
- eTypeCallback
- } Type;
-
- TypeSummaryImpl (const TypeSummaryImpl::Flags& flags);
-
bool
Cascades () const
{
return m_flags.GetCascades();
}
+
bool
SkipsPointers () const
{
return m_flags.GetSkipPointers();
}
+
bool
SkipsReferences () const
{
return m_flags.GetSkipReferences();
}
+
bool
NonCacheable () const
{
@@ -279,6 +303,12 @@ namespace lldb_private {
{
return !m_flags.GetDontShowChildren();
}
+
+ virtual bool
+ DoesPrintEmptyAggregates () const
+ {
+ return !m_flags.GetHideEmptyAggregates();
+ }
virtual bool
DoesPrintValue (ValueObject* valobj) const
@@ -358,11 +388,6 @@ namespace lldb_private {
m_flags.SetValue(value);
}
- virtual
- ~TypeSummaryImpl ()
- {
- }
-
// we are using a ValueObject* instead of a ValueObjectSP because we do not need to hold on to this for
// extended periods of time and we trust the ValueObject to stay around for as long as it is required
// for us to generate its summary
@@ -374,12 +399,6 @@ namespace lldb_private {
virtual std::string
GetDescription () = 0;
- virtual bool
- IsScripted () = 0;
-
- virtual Type
- GetType () = 0;
-
uint32_t&
GetRevision ()
{
@@ -387,14 +406,16 @@ namespace lldb_private {
}
typedef std::shared_ptr<TypeSummaryImpl> SharedPointer;
- typedef bool(*SummaryCallback)(void*, ConstString, const lldb::TypeSummaryImplSP&);
- typedef bool(*RegexSummaryCallback)(void*, lldb::RegularExpressionSP, const lldb::TypeSummaryImplSP&);
protected:
uint32_t m_my_revision;
Flags m_flags;
+ TypeSummaryImpl (Kind kind,
+ const TypeSummaryImpl::Flags& flags);
+
private:
+ Kind m_kind;
DISALLOW_COPY_AND_ASSIGN(TypeSummaryImpl);
};
@@ -407,11 +428,8 @@ namespace lldb_private {
StringSummaryFormat(const TypeSummaryImpl::Flags& flags,
const char* f);
-
- virtual
- ~StringSummaryFormat()
- {
- }
+
+ ~StringSummaryFormat() override = default;
const char*
GetSummaryString () const
@@ -422,25 +440,17 @@ namespace lldb_private {
void
SetSummaryString (const char* f);
- virtual bool
+ bool
FormatObject(ValueObject *valobj,
std::string& dest,
- const TypeSummaryOptions& options);
-
- virtual std::string
- GetDescription();
-
- virtual bool
- IsScripted ()
- {
- return false;
- }
+ const TypeSummaryOptions& options) override;
+ std::string
+ GetDescription() override;
- virtual Type
- GetType ()
+ static bool classof(const TypeSummaryImpl* S)
{
- return TypeSummaryImpl::eTypeString;
+ return S->GetKind() == Kind::eSummaryString;
}
private:
@@ -452,9 +462,9 @@ namespace lldb_private {
{
// we should convert these to SBValue and SBStream if we ever cross
// the boundary towards the external world
- typedef bool (*Callback)(ValueObject&,
- Stream&,
- const TypeSummaryOptions&);
+ typedef std::function<bool(ValueObject&,
+ Stream&,
+ const TypeSummaryOptions&)> Callback;
Callback m_impl;
std::string m_description;
@@ -462,7 +472,9 @@ namespace lldb_private {
CXXFunctionSummaryFormat (const TypeSummaryImpl::Flags& flags,
Callback impl,
const char* description);
-
+
+ ~CXXFunctionSummaryFormat() override = default;
+
Callback
GetBackendFunction () const
{
@@ -489,30 +501,18 @@ namespace lldb_private {
else
m_description.clear();
}
+
+ bool
+ FormatObject(ValueObject *valobj,
+ std::string& dest,
+ const TypeSummaryOptions& options) override;
- virtual
- ~CXXFunctionSummaryFormat ()
- {
- }
-
- virtual bool
- FormatObject (ValueObject *valobj,
- std::string& dest,
- const TypeSummaryOptions& options);
-
- virtual std::string
- GetDescription ();
-
- virtual bool
- IsScripted ()
- {
- return false;
- }
+ std::string
+ GetDescription() override;
- virtual Type
- GetType ()
+ static bool classof(const TypeSummaryImpl* S)
{
- return TypeSummaryImpl::eTypeCallback;
+ return S->GetKind() == Kind::eCallback;
}
typedef std::shared_ptr<CXXFunctionSummaryFormat> SharedPointer;
@@ -521,8 +521,6 @@ namespace lldb_private {
DISALLOW_COPY_AND_ASSIGN(CXXFunctionSummaryFormat);
};
-#ifndef LLDB_DISABLE_PYTHON
-
// Python-based summaries, running script code to show data
struct ScriptSummaryFormat : public TypeSummaryImpl
{
@@ -532,8 +530,10 @@ namespace lldb_private {
ScriptSummaryFormat(const TypeSummaryImpl::Flags& flags,
const char *function_name,
- const char* python_script = NULL);
-
+ const char* python_script = nullptr);
+
+ ~ScriptSummaryFormat() override = default;
+
const char*
GetFunctionName () const
{
@@ -565,38 +565,24 @@ namespace lldb_private {
m_python_script.clear();
}
- virtual
- ~ScriptSummaryFormat ()
- {
- }
-
- virtual bool
- FormatObject (ValueObject *valobj,
- std::string& dest,
- const TypeSummaryOptions& options);
-
- virtual std::string
- GetDescription ();
+ bool
+ FormatObject(ValueObject *valobj,
+ std::string& dest,
+ const TypeSummaryOptions& options) override;
- virtual bool
- IsScripted ()
- {
- return true;
- }
+ std::string
+ GetDescription() override;
- virtual Type
- GetType ()
+ static bool classof(const TypeSummaryImpl* S)
{
- return TypeSummaryImpl::eTypeScript;
+ return S->GetKind() == Kind::eScript;
}
typedef std::shared_ptr<ScriptSummaryFormat> SharedPointer;
-
private:
DISALLOW_COPY_AND_ASSIGN(ScriptSummaryFormat);
};
-#endif
} // namespace lldb_private
-#endif // lldb_TypeSummary_h_
+#endif // lldb_TypeSummary_h_
diff --git a/include/lldb/DataFormatters/TypeSynthetic.h b/include/lldb/DataFormatters/TypeSynthetic.h
index ff6691c9a1b8..90e5730288c4 100644
--- a/include/lldb/DataFormatters/TypeSynthetic.h
+++ b/include/lldb/DataFormatters/TypeSynthetic.h
@@ -1,4 +1,4 @@
-//===-- TypeSynthetic.h -------------------------------------------*- C++ -*-===//
+//===-- TypeSynthetic.h -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,11 +14,13 @@
#include <stdint.h>
// C++ Includes
+#include <initializer_list>
+#include <functional>
+#include <memory>
#include <string>
#include <vector>
// Other libraries and framework includes
-
// Project includes
#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
@@ -45,23 +47,27 @@ namespace lldb_private {
}
public:
-
SyntheticChildrenFrontEnd (ValueObject &backend) :
m_backend(backend),
m_valid(true)
{}
-
+
virtual
- ~SyntheticChildrenFrontEnd ()
- {
- }
-
+ ~SyntheticChildrenFrontEnd() = default;
+
virtual size_t
CalculateNumChildren () = 0;
+
+ virtual size_t
+ CalculateNumChildren (uint32_t max)
+ {
+ auto count = CalculateNumChildren ();
+ return count <= max ? count : max;
+ }
virtual lldb::ValueObjectSP
GetChildAtIndex (size_t idx) = 0;
-
+
virtual size_t
GetIndexOfChildWithName (const ConstString &name) = 0;
@@ -98,13 +104,13 @@ namespace lldb_private {
CreateValueObjectFromAddress (const char* name,
uint64_t address,
const ExecutionContext& exe_ctx,
- ClangASTType type);
+ CompilerType type);
lldb::ValueObjectSP
CreateValueObjectFromData (const char* name,
const DataExtractor& data,
const ExecutionContext& exe_ctx,
- ClangASTType type);
+ CompilerType type);
private:
bool m_valid;
@@ -117,29 +123,26 @@ namespace lldb_private {
SyntheticValueProviderFrontEnd (ValueObject &backend) :
SyntheticChildrenFrontEnd(backend)
{}
+
+ ~SyntheticValueProviderFrontEnd() override = default;
+
+ size_t
+ CalculateNumChildren() override { return 0; }
- virtual
- ~SyntheticValueProviderFrontEnd ()
- {
- }
-
- virtual size_t
- CalculateNumChildren () { return 0; }
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx) { return nullptr; }
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override { return nullptr; }
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name) { return UINT32_MAX; }
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override { return UINT32_MAX; }
- virtual bool
- Update () { return false; }
+ bool
+ Update() override { return false; }
- virtual bool
- MightHaveChildren () { return false; }
+ bool
+ MightHaveChildren () override { return false; }
- virtual lldb::ValueObjectSP
- GetSyntheticValue () = 0;
+ lldb::ValueObjectSP
+ GetSyntheticValue() override = 0;
private:
DISALLOW_COPY_AND_ASSIGN(SyntheticValueProviderFrontEnd);
@@ -148,7 +151,6 @@ namespace lldb_private {
class SyntheticChildren
{
public:
-
class Flags
{
public:
@@ -272,27 +274,28 @@ namespace lldb_private {
m_flags(flags)
{
}
-
+
virtual
- ~SyntheticChildren ()
- {
- }
-
+ ~SyntheticChildren() = default;
+
bool
Cascades () const
{
return m_flags.GetCascades();
}
+
bool
SkipsPointers () const
{
return m_flags.GetSkipPointers();
}
+
bool
SkipsReferences () const
{
return m_flags.GetSkipReferences();
}
+
bool
NonCacheable () const
{
@@ -345,7 +348,6 @@ namespace lldb_private {
GetFrontEnd (ValueObject &backend) = 0;
typedef std::shared_ptr<SyntheticChildren> SharedPointer;
- typedef bool(*SyntheticChildrenCallback)(void*, ConstString, const SyntheticChildren::SharedPointer&);
uint32_t&
GetRevision ()
@@ -417,69 +419,67 @@ namespace lldb_private {
SetExpressionPathAtIndex (size_t i, const std::string& path);
bool
- IsScripted ()
+ IsScripted() override
{
return false;
}
std::string
- GetDescription ();
+ GetDescription() override;
class FrontEnd : public SyntheticChildrenFrontEnd
{
- private:
- TypeFilterImpl* filter;
public:
-
FrontEnd(TypeFilterImpl* flt,
ValueObject &backend) :
SyntheticChildrenFrontEnd(backend),
filter(flt)
{}
-
- virtual
- ~FrontEnd ()
- {
- }
-
- virtual size_t
- CalculateNumChildren ()
+
+ ~FrontEnd() override = default;
+
+ size_t
+ CalculateNumChildren() override
{
return filter->GetCount();
}
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx)
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override
{
if (idx >= filter->GetCount())
return lldb::ValueObjectSP();
return m_backend.GetSyntheticExpressionPathChild(filter->GetExpressionPathAtIndex(idx), true);
}
+
+ bool
+ Update() override { return false; }
- virtual bool
- Update() { return false; }
-
- virtual bool
- MightHaveChildren ()
+ bool
+ MightHaveChildren() override
{
return filter->GetCount() > 0;
}
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
typedef std::shared_ptr<SyntheticChildrenFrontEnd> SharedPointer;
private:
+ TypeFilterImpl* filter;
+
DISALLOW_COPY_AND_ASSIGN(FrontEnd);
};
- virtual SyntheticChildrenFrontEnd::AutoPointer
- GetFrontEnd(ValueObject &backend)
+ SyntheticChildrenFrontEnd::AutoPointer
+ GetFrontEnd(ValueObject &backend) override
{
return SyntheticChildrenFrontEnd::AutoPointer(new FrontEnd(this, backend));
}
+ typedef std::shared_ptr<TypeFilterImpl> SharedPointer;
+
private:
DISALLOW_COPY_AND_ASSIGN(TypeFilterImpl);
};
@@ -487,11 +487,7 @@ namespace lldb_private {
class CXXSyntheticChildren : public SyntheticChildren
{
public:
- typedef SyntheticChildrenFrontEnd* (*CreateFrontEndCallback) (CXXSyntheticChildren*, lldb::ValueObjectSP);
- protected:
- CreateFrontEndCallback m_create_callback;
- std::string m_description;
- public:
+ typedef std::function<SyntheticChildrenFrontEnd*(CXXSyntheticChildren*, lldb::ValueObjectSP)> CreateFrontEndCallback;
CXXSyntheticChildren (const SyntheticChildren::Flags& flags,
const char* description,
CreateFrontEndCallback callback) :
@@ -502,20 +498,24 @@ namespace lldb_private {
}
bool
- IsScripted ()
+ IsScripted() override
{
return false;
}
std::string
- GetDescription ();
+ GetDescription() override;
- virtual SyntheticChildrenFrontEnd::AutoPointer
- GetFrontEnd (ValueObject &backend)
+ SyntheticChildrenFrontEnd::AutoPointer
+ GetFrontEnd(ValueObject &backend) override
{
return SyntheticChildrenFrontEnd::AutoPointer(m_create_callback(this, backend.GetSP()));
}
+ protected:
+ CreateFrontEndCallback m_create_callback;
+ std::string m_description;
+
private:
DISALLOW_COPY_AND_ASSIGN(CXXSyntheticChildren);
};
@@ -528,9 +528,9 @@ namespace lldb_private {
std::string m_python_code;
public:
- ScriptedSyntheticChildren (const SyntheticChildren::Flags& flags,
- const char* pclass,
- const char* pcode = NULL) :
+ ScriptedSyntheticChildren(const SyntheticChildren::Flags& flags,
+ const char* pclass,
+ const char* pcode = nullptr) :
SyntheticChildren(flags),
m_python_class(),
m_python_code()
@@ -567,62 +567,63 @@ namespace lldb_private {
}
std::string
- GetDescription ();
+ GetDescription() override;
bool
- IsScripted ()
+ IsScripted() override
{
return true;
}
class FrontEnd : public SyntheticChildrenFrontEnd
{
- private:
- std::string m_python_class;
- StructuredData::ObjectSP m_wrapper_sp;
- ScriptInterpreter *m_interpreter;
public:
-
FrontEnd (std::string pclass,
ValueObject &backend);
+ ~FrontEnd() override;
+
bool
IsValid ();
- virtual
- ~FrontEnd ();
-
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
+ size_t
+ CalculateNumChildren() override;
+
+ size_t
+ CalculateNumChildren(uint32_t max) override;
- virtual bool
- Update ();
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
+
+ bool
+ Update() override;
- virtual bool
- MightHaveChildren ();
+ bool
+ MightHaveChildren() override;
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
- virtual lldb::ValueObjectSP
- GetSyntheticValue ();
+ lldb::ValueObjectSP
+ GetSyntheticValue() override;
typedef std::shared_ptr<SyntheticChildrenFrontEnd> SharedPointer;
private:
+ std::string m_python_class;
+ StructuredData::ObjectSP m_wrapper_sp;
+ ScriptInterpreter *m_interpreter;
+
DISALLOW_COPY_AND_ASSIGN(FrontEnd);
};
- virtual SyntheticChildrenFrontEnd::AutoPointer
- GetFrontEnd(ValueObject &backend)
+ SyntheticChildrenFrontEnd::AutoPointer
+ GetFrontEnd(ValueObject &backend) override
{
auto synth_ptr = SyntheticChildrenFrontEnd::AutoPointer(new FrontEnd(m_python_class, backend));
if (synth_ptr && ((FrontEnd*)synth_ptr.get())->IsValid())
return synth_ptr;
- return NULL;
+ return nullptr;
}
private:
@@ -631,4 +632,4 @@ namespace lldb_private {
#endif
} // namespace lldb_private
-#endif // lldb_TypeSynthetic_h_
+#endif // lldb_TypeSynthetic_h_
diff --git a/include/lldb/DataFormatters/TypeValidator.h b/include/lldb/DataFormatters/TypeValidator.h
index d06fac01f824..f1f9a11049db 100644
--- a/include/lldb/DataFormatters/TypeValidator.h
+++ b/include/lldb/DataFormatters/TypeValidator.h
@@ -13,8 +13,8 @@
// C Includes
// C++ Includes
-#include <string>
#include <functional>
+#include <string>
// Other libraries and framework includes
@@ -150,7 +150,6 @@ public:
TypeValidatorImpl (const Flags& flags = Flags());
typedef std::shared_ptr<TypeValidatorImpl> SharedPointer;
- typedef bool(*ValueCallback)(void*, ConstString, const lldb::TypeValidatorImplSP&);
virtual ~TypeValidatorImpl ();
@@ -265,9 +264,8 @@ public:
TypeValidatorImpl_CXX (ValidatorFunction f, std::string d, const TypeValidatorImpl::Flags& flags = Flags());
typedef std::shared_ptr<TypeValidatorImpl_CXX> SharedPointer;
- typedef bool(*ValueCallback)(void*, ConstString, const TypeValidatorImpl_CXX::SharedPointer&);
- virtual ~TypeValidatorImpl_CXX ();
+ ~TypeValidatorImpl_CXX() override;
ValidatorFunction
GetValidatorFunction () const
@@ -281,17 +279,17 @@ public:
m_validator_function = f;
}
- virtual TypeValidatorImpl::Type
- GetType ()
+ TypeValidatorImpl::Type
+ GetType() override
{
return TypeValidatorImpl::Type::eTypeCXX;
}
- virtual ValidationResult
- FormatObject (ValueObject *valobj) const;
+ ValidationResult
+ FormatObject(ValueObject *valobj) const override;
- virtual std::string
- GetDescription();
+ std::string
+ GetDescription() override;
protected:
std::string m_description;
@@ -304,4 +302,4 @@ private:
} // namespace lldb_private
-#endif // lldb_TypeValidator_h_
+#endif // lldb_TypeValidator_h_
diff --git a/include/lldb/DataFormatters/ValueObjectPrinter.h b/include/lldb/DataFormatters/ValueObjectPrinter.h
index dc05fd482676..23d7ee2edf50 100644
--- a/include/lldb/DataFormatters/ValueObjectPrinter.h
+++ b/include/lldb/DataFormatters/ValueObjectPrinter.h
@@ -18,232 +18,15 @@
#include "lldb/lldb-private.h"
#include "lldb/lldb-public.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/ValueObject.h"
-#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/Core/Flags.h"
+#include "lldb/DataFormatters/DumpValueObjectOptions.h"
+#include "lldb/Symbol/CompilerType.h"
-namespace lldb_private {
+//#include <functional>
+//#include <memory>
+//#include <set>
-struct DumpValueObjectOptions
-{
- uint32_t m_max_ptr_depth = 0;
- uint32_t m_max_depth = UINT32_MAX;
- lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues;
- uint32_t m_omit_summary_depth = 0;
- lldb::Format m_format = lldb::eFormatDefault;
- lldb::TypeSummaryImplSP m_summary_sp;
- std::string m_root_valobj_name;
- bool m_use_synthetic : 1;
- bool m_scope_already_checked : 1;
- bool m_flat_output : 1;
- bool m_ignore_cap : 1;
- bool m_show_types : 1;
- bool m_show_location : 1;
- bool m_use_objc : 1;
- bool m_hide_root_type : 1;
- bool m_hide_name : 1;
- bool m_hide_value : 1;
- bool m_run_validator : 1;
- bool m_use_type_display_name : 1;
- bool m_allow_oneliner_mode : 1;
-
- DumpValueObjectOptions() :
- m_summary_sp(),
- m_root_valobj_name(),
- m_use_synthetic(true),
- m_scope_already_checked(false),
- m_flat_output(false),
- m_ignore_cap(false),
- m_show_types(false),
- m_show_location(false),
- m_use_objc(false),
- m_hide_root_type(false),
- m_hide_name(false),
- m_hide_value(false),
- m_run_validator(false),
- m_use_type_display_name(true),
- m_allow_oneliner_mode(true)
- {}
-
- static const DumpValueObjectOptions
- DefaultOptions()
- {
- static DumpValueObjectOptions g_default_options;
-
- return g_default_options;
- }
-
- DumpValueObjectOptions (const DumpValueObjectOptions& rhs) = default;
-
- DumpValueObjectOptions (ValueObject& valobj);
-
- DumpValueObjectOptions&
- SetMaximumPointerDepth(uint32_t depth = 0)
- {
- m_max_ptr_depth = depth;
- return *this;
- }
-
- DumpValueObjectOptions&
- SetMaximumDepth(uint32_t depth = 0)
- {
- m_max_depth = depth;
- return *this;
- }
-
- DumpValueObjectOptions&
- SetShowTypes(bool show = false)
- {
- m_show_types = show;
- return *this;
- }
-
- DumpValueObjectOptions&
- SetShowLocation(bool show = false)
- {
- m_show_location = show;
- return *this;
- }
-
- DumpValueObjectOptions&
- SetUseObjectiveC(bool use = false)
- {
- m_use_objc = use;
- return *this;
- }
-
- DumpValueObjectOptions&
- SetShowSummary(bool show = true)
- {
- if (show == false)
- SetOmitSummaryDepth(UINT32_MAX);
- else
- SetOmitSummaryDepth(0);
- return *this;
- }
-
- DumpValueObjectOptions&
- SetUseDynamicType(lldb::DynamicValueType dyn = lldb::eNoDynamicValues)
- {
- m_use_dynamic = dyn;
- return *this;
- }
-
- DumpValueObjectOptions&
- SetUseSyntheticValue(bool use_synthetic = true)
- {
- m_use_synthetic = use_synthetic;
- return *this;
- }
-
- DumpValueObjectOptions&
- SetScopeChecked(bool check = true)
- {
- m_scope_already_checked = check;
- return *this;
- }
-
- DumpValueObjectOptions&
- SetFlatOutput(bool flat = false)
- {
- m_flat_output = flat;
- return *this;
- }
-
- DumpValueObjectOptions&
- SetOmitSummaryDepth(uint32_t depth = 0)
- {
- m_omit_summary_depth = depth;
- return *this;
- }
-
- DumpValueObjectOptions&
- SetIgnoreCap(bool ignore = false)
- {
- m_ignore_cap = ignore;
- return *this;
- }
-
- DumpValueObjectOptions&
- SetRawDisplay()
- {
- SetUseSyntheticValue(false);
- SetOmitSummaryDepth(UINT32_MAX);
- SetIgnoreCap(true);
- SetHideName(false);
- SetHideValue(false);
- SetUseTypeDisplayName(false);
- SetAllowOnelinerMode(false);
- return *this;
- }
-
- DumpValueObjectOptions&
- SetFormat (lldb::Format format = lldb::eFormatDefault)
- {
- m_format = format;
- return *this;
- }
-
- DumpValueObjectOptions&
- SetSummary (lldb::TypeSummaryImplSP summary = lldb::TypeSummaryImplSP())
- {
- m_summary_sp = summary;
- return *this;
- }
-
- DumpValueObjectOptions&
- SetRootValueObjectName (const char* name = NULL)
- {
- if (name)
- m_root_valobj_name.assign(name);
- else
- m_root_valobj_name.clear();
- return *this;
- }
-
- DumpValueObjectOptions&
- SetHideRootType (bool hide_root_type = false)
- {
- m_hide_root_type = hide_root_type;
- return *this;
- }
-
- DumpValueObjectOptions&
- SetHideName (bool hide_name = false)
- {
- m_hide_name = hide_name;
- return *this;
- }
-
- DumpValueObjectOptions&
- SetHideValue (bool hide_value = false)
- {
- m_hide_value = hide_value;
- return *this;
- }
-
- DumpValueObjectOptions&
- SetRunValidator (bool run = true)
- {
- m_run_validator = run;
- return *this;
- }
-
- DumpValueObjectOptions&
- SetUseTypeDisplayName (bool dis = false)
- {
- m_use_type_display_name = dis;
- return *this;
- }
-
- DumpValueObjectOptions&
- SetAllowOnelinerMode (bool oneliner = false)
- {
- m_allow_oneliner_mode = oneliner;
- return *this;
- }
-
-};
+namespace lldb_private {
class ValueObjectPrinter
{
@@ -262,14 +45,19 @@ public:
PrintValueObject ();
protected:
+ typedef std::set<uint64_t> InstancePointersSet;
+ typedef std::shared_ptr<InstancePointersSet> InstancePointersSetSP;
+ InstancePointersSetSP m_printed_instance_pointers;
+
// only this class (and subclasses, if any) should ever be concerned with
// the depth mechanism
ValueObjectPrinter (ValueObject* valobj,
Stream* s,
const DumpValueObjectOptions& options,
- uint32_t ptr_depth,
- uint32_t curr_depth);
+ const DumpValueObjectOptions::PointerDepth& ptr_depth,
+ uint32_t curr_depth,
+ InstancePointersSetSP printed_instance_pointers);
// we should actually be using delegating constructors here
// but some versions of GCC still have trouble with those
@@ -277,8 +65,9 @@ protected:
Init (ValueObject* valobj,
Stream* s,
const DumpValueObjectOptions& options,
- uint32_t ptr_depth,
- uint32_t curr_depth);
+ const DumpValueObjectOptions::PointerDepth& ptr_depth,
+ uint32_t curr_depth,
+ InstancePointersSetSP printed_instance_pointers);
bool
GetMostSpecializedValue ();
@@ -299,12 +88,18 @@ protected:
IsNil ();
bool
+ IsUninitialized ();
+
+ bool
IsPtr ();
bool
IsRef ();
bool
+ IsInstancePointer ();
+
+ bool
IsAggregate ();
bool
@@ -316,17 +111,18 @@ protected:
bool
PrintLocationIfNeeded ();
- bool
- PrintTypeIfNeeded ();
+ void
+ PrintDecl ();
bool
- PrintNameIfNeeded (bool show_type);
+ CheckScopeIfNeeded ();
bool
- CheckScopeIfNeeded ();
+ ShouldPrintEmptyBrackets (bool value_printed,
+ bool summary_printed);
TypeSummaryImpl*
- GetSummaryFormatter ();
+ GetSummaryFormatter (bool null_if_omitted = true);
void
GetValueSummaryError (std::string& value,
@@ -343,7 +139,10 @@ protected:
bool
ShouldPrintChildren (bool is_failed_description,
- uint32_t& curr_ptr_depth);
+ DumpValueObjectOptions::PointerDepth& curr_ptr_depth);
+
+ bool
+ ShouldExpandEmptyAggregates ();
ValueObject*
GetValueObjectForChildrenGeneration ();
@@ -356,13 +155,15 @@ protected:
void
PrintChild (lldb::ValueObjectSP child_sp,
- uint32_t curr_ptr_depth);
+ const DumpValueObjectOptions::PointerDepth& curr_ptr_depth);
uint32_t
GetMaxNumChildrenToPrint (bool& print_dotdotdot);
void
- PrintChildren (uint32_t curr_ptr_depth);
+ PrintChildren (bool value_printed,
+ bool summary_printed,
+ const DumpValueObjectOptions::PointerDepth& curr_ptr_depth);
void
PrintChildrenIfNeeded (bool value_printed,
@@ -376,20 +177,23 @@ private:
ValueObject *m_orig_valobj;
ValueObject *m_valobj;
Stream *m_stream;
- DumpValueObjectOptions options;
+ DumpValueObjectOptions m_options;
Flags m_type_flags;
- ClangASTType m_clang_type;
- uint32_t m_ptr_depth;
+ CompilerType m_compiler_type;
+ DumpValueObjectOptions::PointerDepth m_ptr_depth;
uint32_t m_curr_depth;
LazyBool m_should_print;
LazyBool m_is_nil;
+ LazyBool m_is_uninit;
LazyBool m_is_ptr;
LazyBool m_is_ref;
LazyBool m_is_aggregate;
+ LazyBool m_is_instance_ptr;
std::pair<TypeSummaryImpl*,bool> m_summary_formatter;
std::string m_value;
std::string m_summary;
std::string m_error;
+ bool m_val_summary_ok;
std::pair<TypeValidatorResult,std::string> m_validation;
friend struct StringSummaryFormat;
diff --git a/include/lldb/DataFormatters/VectorIterator.h b/include/lldb/DataFormatters/VectorIterator.h
new file mode 100644
index 000000000000..3d96ee4c093b
--- /dev/null
+++ b/include/lldb/DataFormatters/VectorIterator.h
@@ -0,0 +1,53 @@
+//===-- VectorIterator.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_VectorIterator_h_
+#define liblldb_VectorIterator_h_
+
+#include "lldb/lldb-forward.h"
+
+#include "lldb/Core/ConstString.h"
+#include "lldb/Target/ExecutionContext.h"
+
+namespace lldb_private {
+ namespace formatters
+ {
+ class VectorIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd
+ {
+ public:
+ VectorIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp,
+ ConstString item_name);
+
+ size_t
+ CalculateNumChildren() override;
+
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
+
+ bool
+ Update() override;
+
+ bool
+ MightHaveChildren() override;
+
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
+
+ ~VectorIteratorSyntheticFrontEnd() override;
+
+ private:
+ ExecutionContextRef m_exe_ctx_ref;
+ ConstString m_item_name;
+ lldb::ValueObjectSP m_item_sp;
+ };
+
+ } // namespace formatters
+} // namespace lldb_private
+
+#endif // liblldb_CF_h_
diff --git a/include/lldb/Expression/DWARFExpression.h b/include/lldb/Expression/DWARFExpression.h
index 9ddecc053e00..3527c3b4b153 100644
--- a/include/lldb/Expression/DWARFExpression.h
+++ b/include/lldb/Expression/DWARFExpression.h
@@ -11,18 +11,19 @@
#define liblldb_DWARFExpression_h_
#include "lldb/lldb-private.h"
-#include "lldb/Core/ClangForward.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Scalar.h"
+class DWARFCompileUnit;
+
namespace lldb_private {
+class ClangExpressionDeclMap;
class ClangExpressionVariable;
class ClangExpressionVariableList;
-class ClangExpressionDeclMap;
//----------------------------------------------------------------------
/// @class DWARFExpression DWARFExpression.h "lldb/Expression/DWARFExpression.h"
@@ -40,10 +41,17 @@ class ClangExpressionDeclMap;
class DWARFExpression
{
public:
+ enum LocationListFormat : uint8_t
+ {
+ NonLocationList, // Not a location list
+ RegularLocationList, // Location list format used in non-split dwarf files
+ SplitDwarfLocationList, // Location list format used in split dwarf files
+ };
+
//------------------------------------------------------------------
/// Constructor
//------------------------------------------------------------------
- DWARFExpression();
+ explicit DWARFExpression(DWARFCompileUnit* dwarf_cu);
//------------------------------------------------------------------
/// Constructor
@@ -60,6 +68,7 @@ public:
//------------------------------------------------------------------
DWARFExpression(lldb::ModuleSP module,
const DataExtractor& data,
+ DWARFCompileUnit* dwarf_cu,
lldb::offset_t data_offset,
lldb::offset_t data_length);
@@ -356,6 +365,7 @@ public:
RegisterContext *reg_ctx,
lldb::ModuleSP opcode_ctx,
const DataExtractor& opcodes,
+ DWARFCompileUnit* dwarf_cu,
const lldb::offset_t offset,
const lldb::offset_t length,
const lldb::RegisterKind reg_set,
@@ -397,6 +407,24 @@ public:
lldb::addr_t address,
ABI *abi);
+ static size_t
+ LocationListSize(const DWARFCompileUnit* dwarf_cu,
+ const DataExtractor& debug_loc_data,
+ lldb::offset_t offset);
+
+ static bool
+ PrintDWARFExpression(Stream &s,
+ const DataExtractor& data,
+ int address_size,
+ int dwarf_ref_size,
+ bool location_expression);
+
+ static void
+ PrintDWARFLocationList(Stream &s,
+ const DWARFCompileUnit* cu,
+ const DataExtractor& debug_loc_data,
+ lldb::offset_t offset);
+
protected:
//------------------------------------------------------------------
/// Pretty-prints the location expression to a stream
@@ -430,17 +458,26 @@ protected:
lldb::offset_t &offset,
lldb::offset_t &len);
+ static bool
+ AddressRangeForLocationListEntry(const DWARFCompileUnit* dwarf_cu,
+ const DataExtractor& debug_loc_data,
+ lldb::offset_t* offset_ptr,
+ lldb::addr_t& low_pc,
+ lldb::addr_t& high_pc);
+
//------------------------------------------------------------------
/// Classes that inherit from DWARFExpression can see and modify these
//------------------------------------------------------------------
lldb::ModuleWP m_module_wp; ///< Module which defined this expression.
DataExtractor m_data; ///< A data extractor capable of reading opcode bytes
+ DWARFCompileUnit* m_dwarf_cu; ///< The DWARF compile unit this expression belongs to. It is used
+ ///< to evaluate values indexing into the .debug_addr section (e.g.
+ ///< DW_OP_GNU_addr_index, DW_OP_GNU_const_index)
lldb::RegisterKind m_reg_kind; ///< One of the defines that starts with LLDB_REGKIND_
lldb::addr_t m_loclist_slide; ///< A value used to slide the location list offsets so that
///< they are relative to the object that owns the location list
///< (the function for frame base and variable location lists)
-
};
} // namespace lldb_private
diff --git a/include/lldb/Expression/ClangExpression.h b/include/lldb/Expression/Expression.h
index 6e831e4471e8..b5c2d575ae04 100644
--- a/include/lldb/Expression/ClangExpression.h
+++ b/include/lldb/Expression/Expression.h
@@ -1,4 +1,4 @@
-//===-- ClangExpression.h ---------------------------------------*- C++ -*-===//
+//===-- Expression.h --------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ClangExpression_h_
-#define liblldb_ClangExpression_h_
+#ifndef liblldb_Expression_h_
+#define liblldb_Expression_h_
// C Includes
// C++ Includes
@@ -21,23 +21,23 @@
#include "lldb/lldb-forward.h"
#include "lldb/lldb-private.h"
-#include "lldb/Core/ClangForward.h"
-#include "lldb/Target/Process.h"
+#include "lldb/Expression/ExpressionTypeSystemHelper.h"
namespace lldb_private {
class RecordingMemoryManager;
//----------------------------------------------------------------------
-/// @class ClangExpression ClangExpression.h "lldb/Expression/ClangExpression.h"
-/// @brief Encapsulates a single expression for use with Clang
+/// @class Expression Expression.h "lldb/Expression/Expression.h"
+/// @brief Encapsulates a single expression for use in lldb
///
/// LLDB uses expressions for various purposes, notably to call functions
-/// and as a backend for the expr command. ClangExpression encapsulates
+/// and as a backend for the expr command. Expression encapsulates
/// the objects needed to parse and interpret or JIT an expression. It
-/// uses the Clang parser to produce LLVM IR from the expression.
+/// uses the expression parser appropriate to the language of the expression
+/// to produce LLVM IR from the expression.
//----------------------------------------------------------------------
-class ClangExpression
+class Expression
{
public:
enum ResultType {
@@ -45,17 +45,14 @@ public:
eResultTypeId
};
- ClangExpression () :
- m_jit_process_wp(),
- m_jit_start_addr (LLDB_INVALID_ADDRESS),
- m_jit_end_addr (LLDB_INVALID_ADDRESS)
- {
- }
-
+ Expression (Target &target);
+
+ Expression (ExecutionContextScope &exe_scope);
+
//------------------------------------------------------------------
/// Destructor
//------------------------------------------------------------------
- virtual ~ClangExpression ()
+ virtual ~Expression ()
{
}
@@ -85,24 +82,6 @@ public:
}
//------------------------------------------------------------------
- /// 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
- /// The ASTConsumer that the returned transformer should send
- /// the ASTs to after transformation.
- //------------------------------------------------------------------
- virtual clang::ASTConsumer *
- ASTTransformer (clang::ASTConsumer *passthrough) = 0;
-
- //------------------------------------------------------------------
/// Return the desired result type of the function, or
/// eResultTypeAny if indifferent.
//------------------------------------------------------------------
@@ -130,6 +109,8 @@ public:
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
@@ -139,10 +120,17 @@ public:
{
return m_jit_start_addr;
}
+
+ virtual ExpressionTypeSystemHelper *
+ GetTypeSystemHelper ()
+ {
+ return nullptr;
+ }
protected:
- lldb::ProcessWP m_jit_process_wp;
+ lldb::TargetWP m_target_wp; /// Expression's always have to have a target...
+ lldb::ProcessWP m_jit_process_wp; /// An expression might have a process, but it doesn't need to (e.g. calculator mode.)
lldb::addr_t m_jit_start_addr; ///< The address of the JITted function within the JIT allocation. LLDB_INVALID_ADDRESS if invalid.
lldb::addr_t m_jit_end_addr; ///< The address of the JITted function within the JIT allocation. LLDB_INVALID_ADDRESS if invalid.
@@ -150,4 +138,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_ClangExpression_h_
+#endif // liblldb_Expression_h_
diff --git a/include/lldb/Expression/ExpressionParser.h b/include/lldb/Expression/ExpressionParser.h
new file mode 100644
index 000000000000..49333e79bf5e
--- /dev/null
+++ b/include/lldb/Expression/ExpressionParser.h
@@ -0,0 +1,123 @@
+//===-- ExpressionParser.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_ExpressionParser_h_
+#define liblldb_ExpressionParser_h_
+
+#include "lldb/lldb-public.h"
+#include "lldb/Core/Error.h"
+
+namespace lldb_private
+{
+
+class IRExecutionUnit;
+
+//----------------------------------------------------------------------
+/// @class ExpressionParser ExpressionParser.h "lldb/Expression/ExpressionParser.h"
+/// @brief Encapsulates an instance of a compiler that can parse expressions.
+///
+/// ExpressionParser is the base class for llvm based Expression parsers.
+//----------------------------------------------------------------------
+class ExpressionParser
+{
+public:
+ //------------------------------------------------------------------
+ /// Constructor
+ ///
+ /// Initializes class variables.
+ ///
+ /// @param[in] exe_scope,
+ /// If non-NULL, an execution context scope that can help to
+ /// correctly create an expression with a valid process for
+ /// optional tuning Objective-C runtime support. Can be NULL.
+ ///
+ /// @param[in] expr
+ /// The expression to be parsed.
+ //------------------------------------------------------------------
+ ExpressionParser (ExecutionContextScope *exe_scope,
+ Expression &expr,
+ bool generate_debug_info) :
+ m_expr(expr),
+ m_generate_debug_info(generate_debug_info)
+ {
+ }
+
+ //------------------------------------------------------------------
+ /// Destructor
+ //------------------------------------------------------------------
+ virtual ~ExpressionParser () {};
+
+ //------------------------------------------------------------------
+ /// Parse a single expression and convert it to IR using Clang. Don't
+ /// wrap the expression in anything at all.
+ ///
+ /// @param[in] stream
+ /// The stream to print errors to.
+ ///
+ /// @return
+ /// The number of errors encountered during parsing. 0 means
+ /// success.
+ //------------------------------------------------------------------
+ virtual unsigned
+ Parse (Stream &stream) = 0;
+
+ //------------------------------------------------------------------
+ /// Ready an already-parsed expression for execution, possibly
+ /// evaluating it statically.
+ ///
+ /// @param[out] func_addr
+ /// The address to which the function has been written.
+ ///
+ /// @param[out] func_end
+ /// The end of the function's allocated memory region. (func_addr
+ /// and func_end do not delimit an allocated region; the allocated
+ /// region may begin before func_addr.)
+ ///
+ /// @param[in] execution_unit_sp
+ /// After parsing, ownership of the execution unit for
+ /// for the expression is handed to this shared pointer.
+ ///
+ /// @param[in] exe_ctx
+ /// The execution context to write the function into.
+ ///
+ /// @param[out] can_interpret
+ /// Set to true if the expression could be interpreted statically;
+ /// untouched otherwise.
+ ///
+ /// @param[in] execution_policy
+ /// Determines whether the expression must be JIT-compiled, must be
+ /// evaluated statically, or whether this decision may be made
+ /// opportunistically.
+ ///
+ /// @return
+ /// An error code indicating the success or failure of the operation.
+ /// Test with Success().
+ //------------------------------------------------------------------
+ virtual Error
+ PrepareForExecution (lldb::addr_t &func_addr,
+ lldb::addr_t &func_end,
+ std::shared_ptr<IRExecutionUnit> &execution_unit_sp,
+ ExecutionContext &exe_ctx,
+ bool &can_interpret,
+ lldb_private::ExecutionPolicy execution_policy) = 0;
+
+ bool
+ GetGenerateDebugInfo () const
+ {
+ return m_generate_debug_info;
+ }
+
+protected:
+ Expression & m_expr; ///< The expression to be parsed
+ bool m_generate_debug_info;
+};
+
+}
+
+#endif // liblldb_ExpressionParser_h_
diff --git a/include/lldb/Expression/ExpressionTypeSystemHelper.h b/include/lldb/Expression/ExpressionTypeSystemHelper.h
new file mode 100644
index 000000000000..cb560c9b5a42
--- /dev/null
+++ b/include/lldb/Expression/ExpressionTypeSystemHelper.h
@@ -0,0 +1,54 @@
+//===-- ExpressionTypeSystemHelper.h ---------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef ExpressionTypeSystemHelper_h
+#define ExpressionTypeSystemHelper_h
+
+#include "llvm/Support/Casting.h"
+
+namespace lldb_private
+{
+
+//----------------------------------------------------------------------
+/// @class ExpressionTypeSystemHelper ExpressionTypeSystemHelper.h "lldb/Expression/ExpressionTypeSystemHelper.h"
+/// @brief A helper object that the Expression can pass to its ExpressionParser to provide generic information that
+/// any type of expression will need to supply. It's only job is to support dyn_cast so that the expression parser
+/// can cast it back to the requisite specific type.
+///
+//----------------------------------------------------------------------
+
+class ExpressionTypeSystemHelper
+{
+public:
+ enum LLVMCastKind {
+ eKindClangHelper,
+ eKindSwiftHelper,
+ eKindGoHelper,
+ kNumKinds
+ };
+
+ LLVMCastKind getKind() const { return m_kind; }
+
+ ExpressionTypeSystemHelper (LLVMCastKind kind) :
+ m_kind(kind)
+ {
+ }
+
+ ~ExpressionTypeSystemHelper () {}
+
+protected:
+ LLVMCastKind m_kind;
+};
+
+
+
+
+} // namespace lldb_private
+
+#endif /* ExpressionTypeSystemHelper_h */
diff --git a/include/lldb/Expression/ExpressionVariable.h b/include/lldb/Expression/ExpressionVariable.h
new file mode 100644
index 000000000000..d8030ba1c257
--- /dev/null
+++ b/include/lldb/Expression/ExpressionVariable.h
@@ -0,0 +1,320 @@
+//===-- ExpressionVariable.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_ExpressionVariable_h_
+#define liblldb_ExpressionVariable_h_
+
+// C Includes
+// C++ Includes
+#include <memory>
+#include <vector>
+
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-public.h"
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/ValueObject.h"
+
+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; }
+
+ ExpressionVariable(LLVMCastKind kind) :
+ m_flags(0),
+ m_kind(kind)
+ {
+ }
+
+ virtual ~ExpressionVariable();
+
+ size_t
+ GetByteSize ()
+ {
+ return m_frozen_sp->GetByteSize();
+ }
+
+ const ConstString &
+ GetName ()
+ {
+ return m_frozen_sp->GetName();
+ }
+
+ lldb::ValueObjectSP
+ GetValueObject()
+ {
+ return m_frozen_sp;
+ }
+
+ uint8_t *GetValueBytes();
+
+ void
+ ValueUpdated ()
+ {
+ m_frozen_sp->ValueUpdated ();
+ }
+
+ RegisterInfo *
+ GetRegisterInfo()
+ {
+ return m_frozen_sp->GetValue().GetRegisterInfo();
+ }
+
+ void
+ SetRegisterInfo (const RegisterInfo *reg_info)
+ {
+ return m_frozen_sp->GetValue().SetContext (Value::eContextTypeRegisterInfo, const_cast<RegisterInfo *>(reg_info));
+ }
+
+ CompilerType
+ GetCompilerType()
+ {
+ return m_frozen_sp->GetCompilerType();
+ }
+
+ void
+ SetCompilerType(const CompilerType &compiler_type)
+ {
+ m_frozen_sp->GetValue().SetCompilerType(compiler_type);
+ }
+
+ void
+ SetName (const ConstString &name)
+ {
+ m_frozen_sp->SetName (name);
+ }
+
+ // this function is used to copy the address-of m_live_sp into m_frozen_sp
+ // this is necessary because the results of certain cast and pointer-arithmetic
+ // operations (such as those described in bugzilla issues 11588 and 11618) generate
+ // frozen objects that do not have a valid address-of, which can be troublesome when
+ // using synthetic children providers. Transferring the address-of the live object
+ // solves these issues and provides the expected user-level behavior
+ void
+ TransferAddress (bool force = false)
+ {
+ if (m_live_sp.get() == nullptr)
+ return;
+
+ if (m_frozen_sp.get() == nullptr)
+ return;
+
+ if (force || (m_frozen_sp->GetLiveAddress() == LLDB_INVALID_ADDRESS))
+ m_frozen_sp->SetLiveAddress(m_live_sp->GetLiveAddress());
+ }
+
+ enum Flags
+ {
+ EVNone = 0,
+ EVIsLLDBAllocated = 1 << 0, ///< This variable is resident in a location specifically allocated for it by LLDB in the target process
+ EVIsProgramReference = 1 << 1, ///< This variable is a reference to a (possibly invalid) area managed by the target program
+ EVNeedsAllocation = 1 << 2, ///< Space for this variable has yet to be allocated in the target process
+ EVIsFreezeDried = 1 << 3, ///< This variable's authoritative version is in m_frozen_sp (for example, for statically-computed results)
+ EVNeedsFreezeDry = 1 << 4, ///< Copy from m_live_sp to m_frozen_sp during dematerialization
+ EVKeepInTarget = 1 << 5, ///< Keep the allocation after the expression is complete rather than freeze drying its contents and freeing it
+ EVTypeIsReference = 1 << 6, ///< The original type of this variable is a reference, so materialize the value rather than the location
+ EVUnknownType = 1 << 7, ///< This is a symbol of unknown type, and the type must be resolved after parsing is complete
+ EVBareRegister = 1 << 8 ///< This variable is a direct reference to $pc or some other entity.
+ };
+
+ typedef uint16_t FlagType;
+
+ FlagType m_flags; // takes elements of Flags
+
+ // these should be private
+ lldb::ValueObjectSP m_frozen_sp;
+ lldb::ValueObjectSP m_live_sp;
+ LLVMCastKind m_kind;
+};
+
+//----------------------------------------------------------------------
+/// @class ExpressionVariableList ExpressionVariable.h "lldb/Expression/ExpressionVariable.h"
+/// @brief 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)
+ {
+ lldb::ExpressionVariableSP var_sp;
+ if (index < m_variables.size())
+ var_sp = m_variables[index];
+ return var_sp;
+ }
+
+ size_t
+ AddVariable (const lldb::ExpressionVariableSP &var_sp)
+ {
+ m_variables.push_back(var_sp);
+ return m_variables.size() - 1;
+ }
+
+ lldb::ExpressionVariableSP
+ AddNewlyConstructedVariable (ExpressionVariable *var)
+ {
+ lldb::ExpressionVariableSP var_sp(var);
+ m_variables.push_back(var_sp);
+ return m_variables.back();
+ }
+
+ bool
+ ContainsVariable (const lldb::ExpressionVariableSP &var_sp)
+ {
+ const size_t size = m_variables.size();
+ for (size_t index = 0; index < size; ++index)
+ {
+ if (m_variables[index].get() == var_sp.get())
+ return true;
+ }
+ return false;
+ }
+
+ //----------------------------------------------------------------------
+ /// Finds a variable by name in the list.
+ ///
+ /// @param[in] name
+ /// The name of the requested variable.
+ ///
+ /// @return
+ /// The variable requested, or nullptr if that variable is not in the list.
+ //----------------------------------------------------------------------
+ lldb::ExpressionVariableSP
+ GetVariable (const ConstString &name)
+ {
+ lldb::ExpressionVariableSP var_sp;
+ for (size_t index = 0, size = GetSize(); index < size; ++index)
+ {
+ var_sp = GetVariableAtIndex(index);
+ if (var_sp->GetName() == name)
+ return var_sp;
+ }
+ var_sp.reset();
+ return var_sp;
+ }
+
+ lldb::ExpressionVariableSP
+ GetVariable (const char *name)
+ {
+ lldb::ExpressionVariableSP var_sp;
+ if (name && name[0])
+ {
+ for (size_t index = 0, size = GetSize(); index < size; ++index)
+ {
+ var_sp = GetVariableAtIndex(index);
+ const char *var_name_cstr = var_sp->GetName().GetCString();
+ if (!var_name_cstr || !name)
+ continue;
+ if (::strcmp (var_name_cstr, name) == 0)
+ return var_sp;
+ }
+ var_sp.reset();
+ }
+ return var_sp;
+ }
+
+ void
+ RemoveVariable (lldb::ExpressionVariableSP var_sp)
+ {
+ for (std::vector<lldb::ExpressionVariableSP>::iterator vi = m_variables.begin(), ve = m_variables.end();
+ vi != ve;
+ ++vi)
+ {
+ if (vi->get() == var_sp.get())
+ {
+ m_variables.erase(vi);
+ return;
+ }
+ }
+ }
+
+ void
+ Clear()
+ {
+ m_variables.clear();
+ }
+
+private:
+ std::vector <lldb::ExpressionVariableSP> m_variables;
+};
+
+class PersistentExpressionState : public ExpressionVariableList {
+public:
+ //----------------------------------------------------------------------
+ // See TypeSystem.h for how to add subclasses to this.
+ //----------------------------------------------------------------------
+ enum LLVMCastKind {
+ eKindClang,
+ eKindSwift,
+ eKindGo,
+ kNumKinds
+ };
+
+ LLVMCastKind getKind() const { return m_kind; }
+
+ PersistentExpressionState(LLVMCastKind kind) :
+ m_kind(kind)
+ {
+ }
+
+ virtual ~PersistentExpressionState();
+
+ virtual lldb::ExpressionVariableSP
+ CreatePersistentVariable (const lldb::ValueObjectSP &valobj_sp) = 0;
+
+ virtual lldb::ExpressionVariableSP
+ CreatePersistentVariable (ExecutionContextScope *exe_scope,
+ const ConstString &name,
+ const CompilerType &type,
+ lldb::ByteOrder byte_order,
+ uint32_t addr_byte_size) = 0;
+
+ virtual ConstString
+ GetNextPersistentVariableName () = 0;
+
+ virtual void
+ RemovePersistentVariable (lldb::ExpressionVariableSP variable) = 0;
+
+ virtual lldb::addr_t
+ LookupSymbol (const ConstString &name) = 0;
+
+private:
+ LLVMCastKind m_kind;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_ExpressionVariable_h_
diff --git a/include/lldb/Expression/ClangFunction.h b/include/lldb/Expression/FunctionCaller.h
index cf7e2592021f..c9a45811670f 100644
--- a/include/lldb/Expression/ClangFunction.h
+++ b/include/lldb/Expression/FunctionCaller.h
@@ -1,4 +1,4 @@
-//===-- ClangFunction.h -----------------------------------------*- C++ -*-===//
+//===-- FunctionCaller.h ----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,35 +7,32 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_ClangFunction_h_
-#define lldb_ClangFunction_h_
+#ifndef liblldb_FunctionCaller_h_
+#define liblldb_FunctionCaller_h_
// C Includes
// C++ Includes
-#include <vector>
#include <list>
+#include <memory>
+#include <string>
+#include <vector>
+
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ClangForward.h"
#include "lldb/Core/Address.h"
-#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Value.h"
-#include "lldb/Core/ValueObjectList.h"
-#include "lldb/Expression/ClangExpression.h"
-#include "lldb/Symbol/ClangASTType.h"
-#include "lldb/Target/Process.h"
+#include "lldb/Expression/Expression.h"
+#include "lldb/Expression/ExpressionParser.h"
+#include "lldb/Symbol/CompilerType.h"
namespace lldb_private
{
-class ASTStructExtractor;
-class ClangExpressionParser;
-
//----------------------------------------------------------------------
-/// @class ClangFunction ClangFunction.h "lldb/Expression/ClangFunction.h"
+/// @class FunctionCaller FunctionCaller.h "lldb/Expression/FunctionCaller.h"
/// @brief Encapsulates a function that can be called.
///
-/// A given ClangFunction object can handle a single function signature.
+/// A given FunctionCaller object can handle a single function signature.
/// Once constructed, it can set up any number of concurrent calls to
/// functions with that signature.
///
@@ -46,7 +43,7 @@ class ClangExpressionParser;
/// struct with the written arguments. This method lets Clang handle the
/// vagaries of function calling conventions.
///
-/// The simplest use of the ClangFunction is to construct it with a
+/// The simplest use of the FunctionCaller is to construct it with a
/// function representative of the signature you want to use, then call
/// ExecuteFunction(ExecutionContext &, Stream &, Value &).
///
@@ -61,12 +58,11 @@ class ClangExpressionParser;
/// a pointer set to LLDB_INVALID_ADDRESS and new structure will be allocated
/// and its address returned in that variable.
///
-/// Any of the methods that take arg_addr_ptr can be passed NULL, and the
+/// Any of the methods that take arg_addr_ptr can be passed nullptr, and the
/// argument space will be managed for you.
//----------------------------------------------------------------------
-class ClangFunction : public ClangExpression
+class FunctionCaller : public Expression
{
- friend class ASTStructExtractor;
public:
//------------------------------------------------------------------
/// Constructor
@@ -75,30 +71,6 @@ public:
/// An execution context scope that gets us at least a target and
/// process.
///
- /// @param[in] function_ptr
- /// The default function to be called. Can be overridden using
- /// WriteFunctionArguments().
- ///
- /// @param[in] ast_context
- /// The AST context to evaluate argument types in.
- ///
- /// @param[in] arg_value_list
- /// The default values to use when calling this function. Can
- /// be overridden using WriteFunctionArguments().
- //------------------------------------------------------------------
- ClangFunction (ExecutionContextScope &exe_scope,
- Function &function_ptr,
- ClangASTContext *ast_context,
- const ValueList &arg_value_list,
- const char *name);
-
- //------------------------------------------------------------------
- /// Constructor
- ///
- /// @param[in] exe_scope
- /// An execution context scope that gets us at least a target and
- /// process.
- ///
/// @param[in] ast_context
/// The AST context to evaluate argument types in.
///
@@ -113,8 +85,8 @@ public:
/// The default values to use when calling this function. Can
/// be overridden using WriteFunctionArguments().
//------------------------------------------------------------------
- ClangFunction (ExecutionContextScope &exe_scope,
- const ClangASTType &return_type,
+ FunctionCaller (ExecutionContextScope &exe_scope,
+ const CompilerType &return_type,
const Address& function_address,
const ValueList &arg_value_list,
const char *name);
@@ -122,8 +94,7 @@ public:
//------------------------------------------------------------------
/// Destructor
//------------------------------------------------------------------
- virtual
- ~ClangFunction();
+ ~FunctionCaller() override;
//------------------------------------------------------------------
/// Compile the wrapper function
@@ -134,8 +105,8 @@ public:
/// @return
/// The number of errors.
//------------------------------------------------------------------
- unsigned
- CompileFunction (Stream &errors);
+ virtual unsigned
+ CompileFunction (Stream &errors) = 0;
//------------------------------------------------------------------
/// Insert the default function wrapper and its default argument struct
@@ -209,10 +180,7 @@ public:
/// @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] function_address
- /// The address of the function to call.
+ /// and args_addr_ref is pointed at it.
///
/// @param[in] arg_values
/// The values of the function's arguments.
@@ -225,12 +193,11 @@ public:
//------------------------------------------------------------------
bool WriteFunctionArguments (ExecutionContext &exe_ctx,
lldb::addr_t &args_addr_ref,
- Address function_address,
- ValueList &arg_values,
+ ValueList &arg_values,
Stream &errors);
//------------------------------------------------------------------
- /// Run the function this ClangFunction was created with.
+ /// Run the function this FunctionCaller was created with.
///
/// This is the full version.
///
@@ -238,7 +205,7 @@ public:
/// The thread & process in which this function will run.
///
/// @param[in] args_addr_ptr
- /// If NULL, the function will take care of allocating & deallocating the wrapper
+ /// If nullptr, the function will take care of allocating & deallocating the wrapper
/// args structure. Otherwise, if set to LLDB_INVALID_ADDRESS, a new structure
/// will be allocated, filled and the address returned to you. You are responsible
/// for deallocating it. And if passed in with a value other than LLDB_INVALID_ADDRESS,
@@ -264,7 +231,7 @@ public:
Value &results);
//------------------------------------------------------------------
- /// Get a thread plan to run the function this ClangFunction was created with.
+ /// Get a thread plan to run the function this FunctionCaller was created with.
///
/// @param[in] exe_ctx
/// The execution context to insert the function and its arguments
@@ -335,7 +302,7 @@ public:
/// translation unit.
//------------------------------------------------------------------
const char *
- Text ()
+ Text() override
{
return m_wrapper_function_text.c_str();
}
@@ -346,48 +313,27 @@ public:
/// function.
//------------------------------------------------------------------
const char *
- FunctionName ()
+ FunctionName() override
{
return m_wrapper_function_name.c_str();
}
//------------------------------------------------------------------
- /// Return the object that the parser should use when resolving external
- /// values. May be NULL if everything should be self-contained.
- //------------------------------------------------------------------
- ClangExpressionDeclMap *
- DeclMap ()
- {
- return NULL;
- }
-
- //------------------------------------------------------------------
/// Return the object that the parser should use when registering
- /// local variables. May be NULL if the Expression doesn't care.
+ /// local variables. May be nullptr if the Expression doesn't care.
//------------------------------------------------------------------
- ClangExpressionVariableList *
+ ExpressionVariableList *
LocalVariables ()
{
- return NULL;
+ 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
- /// The ASTConsumer that the returned transformer should send
- /// the ASTs to after transformation.
- //------------------------------------------------------------------
- clang::ASTConsumer *
- ASTTransformer (clang::ASTConsumer *passthrough);
-
- //------------------------------------------------------------------
/// Return true if validation code should be inserted into the
/// expression.
//------------------------------------------------------------------
bool
- NeedsValidation ()
+ NeedsValidation() override
{
return false;
}
@@ -397,7 +343,7 @@ public:
/// resolved.
//------------------------------------------------------------------
bool
- NeedsVariableResolution ()
+ NeedsVariableResolution() override
{
return false;
}
@@ -407,29 +353,27 @@ public:
{
return m_arg_values;
}
-private:
- //------------------------------------------------------------------
- // For ClangFunction only
- //------------------------------------------------------------------
+protected:
// Note: the parser needs to be destructed before the execution unit, so
// declare the execution unit first.
std::shared_ptr<IRExecutionUnit> m_execution_unit_sp;
- std::unique_ptr<ClangExpressionParser> m_parser; ///< The parser responsible for compiling the function.
+ std::unique_ptr<ExpressionParser> m_parser; ///< The parser responsible for compiling the function.
+ ///< This will get made in CompileFunction, so it is
+ ///< safe to access it after that.
+
lldb::ModuleWP m_jit_module_wp;
std::string m_name; ///< The name of this clang function - for debugging purposes.
- Function *m_function_ptr; ///< The function we're going to call. May be NULL if we don't have debug info for the function.
+ Function *m_function_ptr; ///< The function we're going to call. May be nullptr if we don't have debug info for the function.
Address m_function_addr; ///< If we don't have the FunctionSP, we at least need the address & return type.
- ClangASTType m_function_return_type; ///< The opaque clang qual type for the function return type.
+ CompilerType m_function_return_type; ///< The opaque clang qual type for the function return type.
std::string m_wrapper_function_name; ///< The name of the wrapper function.
std::string m_wrapper_function_text; ///< The contents of the wrapper function.
std::string m_wrapper_struct_name; ///< The name of the struct that contains the target function address, arguments, and result.
std::list<lldb::addr_t> m_wrapper_args_addrs; ///< The addresses of the arguments to the wrapper function.
- std::unique_ptr<ASTStructExtractor> m_struct_extractor; ///< The class that generates the argument struct below.
-
bool m_struct_valid; ///< True if the ASTStructExtractor has populated the variables below.
//------------------------------------------------------------------
@@ -446,6 +390,6 @@ private:
bool m_JITted; ///< True if the wrapper function has already been JIT-compiled.
};
-} // Namespace lldb_private
+} // namespace lldb_private
-#endif // lldb_ClangFunction_h_
+#endif // liblldb_FunctionCaller_h_
diff --git a/include/lldb/Expression/IRDynamicChecks.h b/include/lldb/Expression/IRDynamicChecks.h
index 226f5c94e98c..ef77d55f4b34 100644
--- a/include/lldb/Expression/IRDynamicChecks.h
+++ b/include/lldb/Expression/IRDynamicChecks.h
@@ -24,11 +24,10 @@ namespace llvm {
class Value;
}
-namespace lldb_private
+namespace lldb_private
{
class ClangExpressionDeclMap;
-class ClangUtilityFunction;
class ExecutionContext;
class Stream;
@@ -77,8 +76,8 @@ public:
bool DoCheckersExplainStop (lldb::addr_t addr, Stream &message);
- std::unique_ptr<ClangUtilityFunction> m_valid_pointer_check;
- std::unique_ptr<ClangUtilityFunction> m_objc_object_check;
+ std::unique_ptr<UtilityFunction> m_valid_pointer_check;
+ std::unique_ptr<UtilityFunction> m_objc_object_check;
};
//----------------------------------------------------------------------
@@ -114,7 +113,7 @@ public:
//------------------------------------------------------------------
/// Destructor
//------------------------------------------------------------------
- virtual ~IRDynamicChecks();
+ ~IRDynamicChecks() override;
//------------------------------------------------------------------
/// Run this IR transformer on a single module
@@ -127,18 +126,19 @@ public:
/// @return
/// True on success; false otherwise
//------------------------------------------------------------------
- bool runOnModule(llvm::Module &M);
+ bool runOnModule(llvm::Module &M) override;
//------------------------------------------------------------------
/// Interface stub
//------------------------------------------------------------------
void assignPassManager(llvm::PMStack &PMS,
- llvm::PassManagerType T = llvm::PMT_ModulePassManager);
+ llvm::PassManagerType T = llvm::PMT_ModulePassManager) override;
//------------------------------------------------------------------
/// Returns PMT_ModulePassManager
//------------------------------------------------------------------
- llvm::PassManagerType getPotentialPassManagerType() const;
+ llvm::PassManagerType getPotentialPassManagerType() const override;
+
private:
//------------------------------------------------------------------
/// A basic block-level pass to find all pointer dereferences and
@@ -164,6 +164,6 @@ private:
DynamicCheckerFunctions &m_checker_functions; ///< The checker functions for the process
};
-}
+} // namespace lldb_private
-#endif
+#endif // liblldb_IRDynamicChecks_h_
diff --git a/include/lldb/Expression/IRExecutionUnit.h b/include/lldb/Expression/IRExecutionUnit.h
index bd1a795a158e..86744b7b9726 100644
--- a/include/lldb/Expression/IRExecutionUnit.h
+++ b/include/lldb/Expression/IRExecutionUnit.h
@@ -7,27 +7,24 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_IRExecutionUnit_h_
-#define lldb_IRExecutionUnit_h_
+#ifndef liblldb_IRExecutionUnit_h_
+#define liblldb_IRExecutionUnit_h_
// C Includes
// C++ Includes
#include <atomic>
+#include <memory>
#include <string>
#include <vector>
-#include <map>
// Other libraries and framework includes
#include "llvm/IR/Module.h"
+#include "llvm/ExecutionEngine/SectionMemoryManager.h"
// Project includes
#include "lldb/lldb-forward.h"
#include "lldb/lldb-private.h"
-#include "lldb/Core/ClangForward.h"
#include "lldb/Core/DataBufferHeap.h"
-#include "llvm/ExecutionEngine/SectionMemoryManager.h"
-#include "lldb/Expression/ClangExpression.h"
-#include "lldb/Expression/ClangExpressionParser.h"
#include "lldb/Expression/IRMemoryMap.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -37,7 +34,7 @@ namespace llvm {
class Module;
class ExecutionEngine;
-}
+} // namespace llvm
namespace lldb_private {
@@ -79,7 +76,7 @@ public:
//------------------------------------------------------------------
/// Destructor
//------------------------------------------------------------------
- ~IRExecutionUnit();
+ ~IRExecutionUnit() override;
llvm::Module *
GetModule()
@@ -90,10 +87,7 @@ public:
llvm::Function *
GetFunction()
{
- if (m_module)
- return m_module->getFunction (m_name.AsCString());
- else
- return NULL;
+ return ((m_module != nullptr) ? m_module->getFunction(m_name.AsCString()) : nullptr);
}
void
@@ -118,22 +112,22 @@ public:
//------------------------------------------------------------------
/// ObjectFileJITDelegate overrides
//------------------------------------------------------------------
- virtual lldb::ByteOrder
- GetByteOrder () const;
+ lldb::ByteOrder
+ GetByteOrder() const override;
- virtual uint32_t
- GetAddressByteSize () const;
+ uint32_t
+ GetAddressByteSize() const override;
- virtual void
- PopulateSymtab (lldb_private::ObjectFile *obj_file,
- lldb_private::Symtab &symtab);
+ void
+ PopulateSymtab(lldb_private::ObjectFile *obj_file,
+ lldb_private::Symtab &symtab) override;
- virtual void
- PopulateSectionList (lldb_private::ObjectFile *obj_file,
- lldb_private::SectionList &section_list);
+ void
+ PopulateSectionList(lldb_private::ObjectFile *obj_file,
+ lldb_private::SectionList &section_list) override;
- virtual bool
- GetArchitecture (lldb_private::ArchSpec &arch);
+ bool
+ GetArchitecture(lldb_private::ArchSpec &arch) override;
lldb::ModuleSP
GetJITModule ();
@@ -215,7 +209,7 @@ private:
public:
MemoryManager (IRExecutionUnit &parent);
- virtual ~MemoryManager();
+ ~MemoryManager() override;
//------------------------------------------------------------------
/// Allocate space for executable code, and add it to the
@@ -233,9 +227,9 @@ private:
/// @return
/// Allocated space.
//------------------------------------------------------------------
- virtual uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
- unsigned SectionID,
- llvm::StringRef SectionName);
+ 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
@@ -255,10 +249,10 @@ private:
/// @return
/// Allocated space.
//------------------------------------------------------------------
- virtual uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
- unsigned SectionID,
- llvm::StringRef SectionName,
- bool IsReadOnly);
+ 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
@@ -270,7 +264,7 @@ private:
/// @return
/// True in case of failure, false in case of success.
//------------------------------------------------------------------
- virtual bool finalizeMemory(std::string *ErrMsg) {
+ bool finalizeMemory(std::string *ErrMsg) override {
// TODO: Ensure that the instruction cache is flushed because
// relocations are updated by dy-load. See:
// sys::Memory::InvalidateInstructionCache
@@ -278,17 +272,17 @@ private:
return false;
}
- virtual void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) {
- return;
+ void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) override {
}
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
- virtual uint64_t getSymbolAddress(const std::string &Name);
+ uint64_t getSymbolAddress(const std::string &Name) override;
+
+ void *getPointerToNamedFunction(const std::string &Name,
+ bool AbortOnFailure = true) override;
- virtual void *getPointerToNamedFunction(const std::string &Name,
- bool AbortOnFailure = true);
private:
std::unique_ptr<SectionMemoryManager> m_default_mm_ap; ///< The memory allocator to use in actually creating space. All calls are passed through to it.
IRExecutionUnit &m_parent; ///< The execution unit this is a proxy for.
@@ -403,4 +397,4 @@ private:
} // namespace lldb_private
-#endif // lldb_IRExecutionUnit_h_
+#endif // liblldb_IRExecutionUnit_h_
diff --git a/include/lldb/Expression/IRInterpreter.h b/include/lldb/Expression/IRInterpreter.h
index c314bf1099ea..4eb81bc68d19 100644
--- a/include/lldb/Expression/IRInterpreter.h
+++ b/include/lldb/Expression/IRInterpreter.h
@@ -13,7 +13,6 @@
#include "lldb/lldb-public.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Stream.h"
-#include "lldb/Symbol/TaggedASTType.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Pass.h"
diff --git a/include/lldb/Expression/IRMemoryMap.h b/include/lldb/Expression/IRMemoryMap.h
index 80add46ef0da..6fb718a341f7 100644
--- a/include/lldb/Expression/IRMemoryMap.h
+++ b/include/lldb/Expression/IRMemoryMap.h
@@ -50,7 +50,12 @@ public:
eAllocationPolicyProcessOnly ///< The intent is that this allocation exist only in the process.
};
- lldb::addr_t Malloc (size_t size, uint8_t alignment, uint32_t permissions, AllocationPolicy policy, Error &error);
+ lldb::addr_t Malloc (size_t size,
+ uint8_t alignment,
+ uint32_t permissions,
+ AllocationPolicy policy,
+ bool zero_memory,
+ Error &error);
void Leak (lldb::addr_t process_address, Error &error);
void Free (lldb::addr_t process_address, Error &error);
@@ -124,7 +129,7 @@ private:
typedef std::map<lldb::addr_t, Allocation> AllocationMap;
AllocationMap m_allocations;
- lldb::addr_t FindSpace (size_t size);
+ lldb::addr_t FindSpace (size_t size, bool zero_memory = false);
bool ContainsHostOnlyAllocations ();
AllocationMap::iterator FindAllocation (lldb::addr_t addr, size_t size);
diff --git a/include/lldb/Expression/IRToDWARF.h b/include/lldb/Expression/IRToDWARF.h
deleted file mode 100644
index a4ae9b7ebfae..000000000000
--- a/include/lldb/Expression/IRToDWARF.h
+++ /dev/null
@@ -1,111 +0,0 @@
-//===-- IRToDWARF.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_IRToDWARF_h_
-#define liblldb_IRToDWARF_h_
-
-#include "llvm/Pass.h"
-#include "llvm/IR/LegacyPassManager.h"
-
-#include "lldb/lldb-public.h"
-
-class Relocator;
-//----------------------------------------------------------------------
-/// @class IRToDWARF IRToDWARF.h "lldb/Expression/IRToDWARF.h"
-/// @brief Transforms the IR for a function into a DWARF location expression
-///
-/// Once an expression has been parsed and converted to IR, it can run
-/// in two contexts: interpreted by LLDB as a DWARF location expression,
-/// or compiled by the JIT and inserted into the target process for
-/// execution.
-///
-/// IRToDWARF makes the first possible, by traversing the control flow
-/// graph and writing the code for each basic block out as location
-/// expression bytecode. To ensure that the links between the basic blocks
-/// remain intact, it uses a relocator that records the location of every
-/// location expression instruction that has a relocatable operand, the
-/// target of that operand (as a basic block), and the mapping of each basic
-/// block to an actual location. After all code has been written out, the
-/// relocator post-processes it and performs all necessary relocations.
-//----------------------------------------------------------------------
-class IRToDWARF : public llvm::ModulePass
-{
-public:
- //------------------------------------------------------------------
- /// Constructor
- ///
- /// @param[in] local_vars
- /// A list of variables to populate with the local variables this
- /// expression uses.
- ///
- /// @param[in] decl_map
- /// The list of externally-referenced variables for the expression,
- /// for use in looking up globals.
- ///
- /// @param[in] stream
- /// The stream to dump DWARF bytecode onto.
- ///
- /// @param[in] func_name
- /// The name of the function to translate to DWARF.
- //------------------------------------------------------------------
- IRToDWARF(lldb_private::ClangExpressionVariableList &local_vars,
- lldb_private::ClangExpressionDeclMap *decl_map,
- lldb_private::StreamString &strm,
- const char* func_name = "$__lldb_expr");
-
- //------------------------------------------------------------------
- /// Destructor
- //------------------------------------------------------------------
- virtual ~IRToDWARF();
-
- //------------------------------------------------------------------
- /// 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 converted to a location
- /// expression.
- ///
- /// @return
- /// True on success; false otherwise
- //------------------------------------------------------------------
- bool runOnModule(llvm::Module &M);
-
- //------------------------------------------------------------------
- /// Interface stub
- //------------------------------------------------------------------
- void assignPassManager(llvm::PMStack &PMS,
- llvm::PassManagerType T = llvm::PMT_ModulePassManager);
-
- //------------------------------------------------------------------
- /// Returns PMT_ModulePassManager
- //------------------------------------------------------------------
- llvm::PassManagerType getPotentialPassManagerType() const;
-private:
- //------------------------------------------------------------------
- /// Run this IR transformer on a single basic block
- ///
- /// @param[in] BB
- /// The basic block to transform.
- ///
- /// @param[in] Relocator
- /// The relocator to use when registering branches.
- ///
- /// @return
- /// True on success; false otherwise
- //------------------------------------------------------------------
- bool runOnBasicBlock(llvm::BasicBlock &BB, Relocator &Relocator);
-
- std::string m_func_name; ///< The name of the function to translate
- lldb_private::ClangExpressionVariableList &m_local_vars; ///< The list of local variables to populate while transforming
- lldb_private::ClangExpressionDeclMap *m_decl_map; ///< The list of external variables
- lldb_private::StreamString &m_strm; ///< The stream to write bytecode to
-};
-
-#endif
diff --git a/include/lldb/Expression/LLVMUserExpression.h b/include/lldb/Expression/LLVMUserExpression.h
new file mode 100644
index 000000000000..e3d17986f4b3
--- /dev/null
+++ b/include/lldb/Expression/LLVMUserExpression.h
@@ -0,0 +1,118 @@
+//===-- LLVMUserExpression.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_LLVMUserExpression_h
+#define liblldb_LLVMUserExpression_h
+
+// C Includes
+// C++ Includes
+#include <string>
+#include <map>
+#include <vector>
+
+// Project includes
+#include "lldb/Expression/UserExpression.h"
+
+namespace lldb_private
+{
+
+//----------------------------------------------------------------------
+/// @class LLVMUserExpression LLVMUserExpression.h "lldb/Expression/LLVMUserExpression.h"
+/// @brief Encapsulates a one-time expression for use in lldb.
+///
+/// LLDB uses expressions for various purposes, notably to call functions
+/// and as a backend for the expr command. LLVMUserExpression is a virtual base
+/// class that encapsulates the objects needed to parse and JIT an expression.
+/// The actual parsing part will be provided by the specific implementations
+/// of LLVMUserExpression - which will be vended through the appropriate TypeSystem.
+//----------------------------------------------------------------------
+class LLVMUserExpression : public UserExpression
+{
+ public:
+ LLVMUserExpression(ExecutionContextScope &exe_scope,
+ const char *expr,
+ const char *expr_prefix,
+ lldb::LanguageType language,
+ ResultType desired_type,
+ const EvaluateExpressionOptions &options);
+ ~LLVMUserExpression() override;
+
+ lldb::ExpressionResults Execute(Stream &error_stream,
+ ExecutionContext &exe_ctx,
+ const EvaluateExpressionOptions &options,
+ lldb::UserExpressionSP &shared_ptr_to_me,
+ lldb::ExpressionVariableSP &result) override;
+
+ bool FinalizeJITExecution(Stream &error_stream,
+ ExecutionContext &exe_ctx,
+ lldb::ExpressionVariableSP &result,
+ lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS,
+ lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS) override;
+
+ bool
+ CanInterpret() override
+ {
+ return m_can_interpret;
+ }
+
+ //------------------------------------------------------------------
+ /// Return the string that the parser should parse. Must be a full
+ /// translation unit.
+ //------------------------------------------------------------------
+ const char *
+ Text() override
+ {
+ return m_transformed_text.c_str();
+ }
+
+ lldb::ModuleSP GetJITModule() override;
+
+ protected:
+ virtual void ScanContext(ExecutionContext &exe_ctx, lldb_private::Error &err) = 0;
+
+ bool PrepareToExecuteJITExpression(Stream &error_stream, ExecutionContext &exe_ctx, lldb::addr_t &struct_address);
+
+ virtual bool
+ AddArguments (ExecutionContext &exe_ctx,
+ std::vector<lldb::addr_t> &args,
+ lldb::addr_t struct_address,
+ Stream &error_stream) = 0;
+
+
+ lldb::addr_t m_stack_frame_bottom; ///< The bottom of the allocated stack frame.
+ lldb::addr_t m_stack_frame_top; ///< The top of the allocated stack frame.
+
+ bool m_allow_cxx; ///< True if the language allows C++.
+ bool m_allow_objc; ///< True if the language allows Objective-C.
+ std::string m_transformed_text; ///< The text of the expression, as send to the parser
+
+ std::shared_ptr<IRExecutionUnit> m_execution_unit_sp; ///< The execution unit the expression is stored in.
+ std::unique_ptr<Materializer> m_materializer_ap; ///< The materializer to use when running the expression.
+ lldb::ModuleWP m_jit_module_wp;
+ bool m_enforce_valid_object; ///< True if the expression parser should enforce the presence of a valid class pointer
+ ///in order to generate the expression as a method.
+ bool m_in_cplusplus_method; ///< True if the expression is compiled as a C++ member function (true if it was parsed
+ ///when exe_ctx was in a C++ method).
+ bool m_in_objectivec_method; ///< True if the expression is compiled as an Objective-C method (true if it was parsed
+ ///when exe_ctx was in an Objective-C method).
+ bool m_in_static_method; ///< True if the expression is compiled as a static (or class) method (currently true if it
+ ///was parsed when exe_ctx was in an Objective-C class method).
+ bool m_needs_object_ptr; ///< True if "this" or "self" must be looked up and passed in. False if the expression
+ ///doesn't really use them and they can be NULL.
+ bool m_const_object; ///< True if "this" is const.
+ Target *m_target; ///< The target for storing persistent data like types and variables.
+
+ bool m_can_interpret; ///< True if the expression could be evaluated statically; false otherwise.
+ lldb::addr_t
+ m_materialized_address; ///< The address at which the arguments to the expression have been materialized.
+ Materializer::DematerializerSP m_dematerializer_sp; ///< The dematerializer.
+};
+
+} // namespace lldb_private
+#endif
diff --git a/include/lldb/Expression/Materializer.h b/include/lldb/Expression/Materializer.h
index 208a08133923..f293fddc1022 100644
--- a/include/lldb/Expression/Materializer.h
+++ b/include/lldb/Expression/Materializer.h
@@ -7,18 +7,22 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Materializer_h
-#define lldb_Materializer_h
+#ifndef liblldb_Materializer_h
+#define liblldb_Materializer_h
+// C Includes
+// C++ Includes
+#include <memory>
+#include <vector>
+
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private-types.h"
#include "lldb/Core/Error.h"
#include "lldb/Expression/IRMemoryMap.h"
-#include "lldb/Host/Mutex.h"
-#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Symbol/TaggedASTType.h"
#include "lldb/Target/StackFrame.h"
-#include <vector>
-
namespace lldb_private
{
@@ -32,8 +36,8 @@ public:
{
public:
Dematerializer () :
- m_materializer(NULL),
- m_map(NULL),
+ m_materializer(nullptr),
+ m_map(nullptr),
m_process_address(LLDB_INVALID_ADDRESS)
{
}
@@ -44,7 +48,6 @@ public:
}
void Dematerialize (Error &err,
- lldb::ClangExpressionVariableSP &result_sp,
lldb::addr_t frame_top,
lldb::addr_t frame_bottom);
@@ -54,6 +57,7 @@ public:
{
return m_materializer && m_map && (m_process_address != LLDB_INVALID_ADDRESS);
}
+
private:
friend class Materializer;
@@ -84,11 +88,28 @@ public:
DematerializerSP Materialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Error &err);
- uint32_t AddPersistentVariable (lldb::ClangExpressionVariableSP &persistent_variable_sp, Error &err);
- uint32_t AddVariable (lldb::VariableSP &variable_sp, Error &err);
- uint32_t AddResultVariable (const TypeFromUser &type, bool is_lvalue, bool keep_in_memory, Error &err);
- uint32_t AddSymbol (const Symbol &symbol_sp, Error &err);
- uint32_t AddRegister (const RegisterInfo &register_info, Error &err);
+ class PersistentVariableDelegate
+ {
+ public:
+ virtual ~PersistentVariableDelegate();
+ virtual ConstString GetName() = 0;
+ virtual void DidDematerialize(lldb::ExpressionVariableSP &variable) = 0;
+ };
+
+ uint32_t AddPersistentVariable (lldb::ExpressionVariableSP &persistent_variable_sp,
+ PersistentVariableDelegate *delegate,
+ Error &err);
+ uint32_t AddVariable (lldb::VariableSP &variable_sp,
+ Error &err);
+ uint32_t AddResultVariable (const CompilerType &type,
+ bool is_lvalue,
+ bool keep_in_memory,
+ PersistentVariableDelegate *delegate,
+ Error &err);
+ uint32_t AddSymbol (const Symbol &symbol_sp,
+ Error &err);
+ uint32_t AddRegister (const RegisterInfo &register_info,
+ Error &err);
uint32_t GetStructAlignment ()
{
@@ -100,14 +121,6 @@ public:
return m_current_offset;
}
- uint32_t GetResultOffset ()
- {
- if (m_result_entity)
- return m_result_entity->GetOffset();
- else
- return UINT32_MAX;
- }
-
class Entity
{
public:
@@ -117,11 +130,9 @@ public:
m_offset(0)
{
}
-
- virtual ~Entity ()
- {
- }
-
+
+ virtual ~Entity() = default;
+
virtual void Materialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Error &err) = 0;
virtual void Dematerialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address,
lldb::addr_t frame_top, lldb::addr_t frame_bottom, Error &err) = 0;
@@ -147,8 +158,9 @@ public:
{
m_offset = offset;
}
+
protected:
- void SetSizeAndAlignmentFromType (ClangASTType &type);
+ void SetSizeAndAlignmentFromType (CompilerType &type);
uint32_t m_alignment;
uint32_t m_size;
@@ -163,11 +175,10 @@ private:
DematerializerWP m_dematerializer_wp;
EntityVector m_entities;
- Entity *m_result_entity;
uint32_t m_current_offset;
uint32_t m_struct_alignment;
};
-}
+} // namespace lldb_private
-#endif
+#endif // liblldb_Materializer_h
diff --git a/include/lldb/Expression/REPL.h b/include/lldb/Expression/REPL.h
new file mode 100644
index 000000000000..21d22de8e0d7
--- /dev/null
+++ b/include/lldb/Expression/REPL.h
@@ -0,0 +1,211 @@
+//===-- REPL.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_REPL_h
+#define lldb_REPL_h
+
+// C Includes
+// C++ Includes
+#include <string>
+
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Interpreter/OptionGroupFormat.h"
+#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
+#include "lldb/../../source/Commands/CommandObjectExpression.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; }
+
+ REPL(LLVMCastKind kind, Target &target);
+
+ ~REPL() override;
+
+ //------------------------------------------------------------------
+ /// Get a REPL with an existing target (or, failing that, a debugger to use), and (optional) extra arguments for the compiler.
+ ///
+ /// @param[out] error
+ /// If this language is supported but the REPL couldn't be created, this error is populated with the reason.
+ ///
+ /// @param[in] language
+ /// The language to create a REPL for.
+ ///
+ /// @param[in] debugger
+ /// If provided, and target is nullptr, the debugger to use when setting up a top-level REPL.
+ ///
+ /// @param[in] target
+ /// If provided, the target to put the REPL inside.
+ ///
+ /// @param[in] repl_options
+ /// If provided, additional options for the compiler when parsing REPL expressions.
+ ///
+ /// @return
+ /// The range of the containing object in the target process.
+ //------------------------------------------------------------------
+ static lldb::REPLSP
+ Create (Error &Error, lldb::LanguageType language, Debugger *debugger, Target *target, const char *repl_options);
+
+ void
+ SetFormatOptions (const OptionGroupFormat &options)
+ {
+ m_format_options = options;
+ }
+
+ void
+ SetValueObjectDisplayOptions (const OptionGroupValueObjectDisplay &options)
+ {
+ m_varobj_options = options;
+ }
+
+ void
+ SetCommandOptions (const CommandObjectExpression::CommandOptions &options)
+ {
+ m_command_options = options;
+ }
+
+ void
+ SetCompilerOptions (const char *options)
+ {
+ if (options)
+ m_compiler_options = options;
+ }
+
+ lldb::IOHandlerSP
+ GetIOHandler ();
+
+ Error
+ RunLoop ();
+
+ //------------------------------------------------------------------
+ // IOHandler::Delegate functions
+ //------------------------------------------------------------------
+ void
+ IOHandlerActivated (IOHandler &io_handler) override;
+
+ bool
+ IOHandlerInterrupt (IOHandler &io_handler) override;
+
+ void
+ IOHandlerInputInterrupted (IOHandler &io_handler,
+ std::string &line) override;
+
+ const char *
+ IOHandlerGetFixIndentationCharacters () override;
+
+ ConstString
+ IOHandlerGetControlSequence (char ch) override;
+
+ const char *
+ IOHandlerGetCommandPrefix () override;
+
+ const char *
+ IOHandlerGetHelpPrologue () override;
+
+ bool
+ IOHandlerIsInputComplete (IOHandler &io_handler,
+ StringList &lines) override;
+
+ int
+ IOHandlerFixIndentation (IOHandler &io_handler,
+ const StringList &lines,
+ int cursor_position) override;
+
+ void
+ IOHandlerInputComplete (IOHandler &io_handler,
+ std::string &line) override;
+
+ int
+ IOHandlerComplete (IOHandler &io_handler,
+ const char *current_line,
+ const char *cursor,
+ const char *last_char,
+ int skip_first_n_matches,
+ int max_matches,
+ StringList &matches) override;
+
+protected:
+ static int
+ CalculateActualIndentation (const StringList &lines);
+
+ //----------------------------------------------------------------------
+ // Subclasses should override these functions to implement a functional REPL.
+ //----------------------------------------------------------------------
+
+ virtual Error
+ DoInitialization () = 0;
+
+ virtual ConstString
+ GetSourceFileBasename () = 0;
+
+ virtual const char *
+ GetAutoIndentCharacters () = 0;
+
+ virtual bool
+ SourceIsComplete (const std::string &source) = 0;
+
+ virtual lldb::offset_t
+ GetDesiredIndentation (const StringList &lines,
+ int cursor_position,
+ int tab_size) = 0; // LLDB_INVALID_OFFSET means no change
+
+ virtual lldb::LanguageType
+ GetLanguage () = 0;
+
+ virtual bool
+ PrintOneVariable (Debugger &debugger,
+ lldb::StreamFileSP &output_sp,
+ lldb::ValueObjectSP &valobj_sp,
+ ExpressionVariable *var = nullptr) = 0;
+
+ virtual int
+ CompleteCode(const std::string &current_code,
+ StringList &matches) = 0;
+
+ OptionGroupFormat m_format_options = OptionGroupFormat(lldb::eFormatDefault);
+ OptionGroupValueObjectDisplay m_varobj_options;
+ CommandObjectExpression::CommandOptions m_command_options;
+ std::string m_compiler_options;
+
+ bool m_enable_auto_indent = true;
+ std::string m_indent_str; // Use this string for each level of indentation
+ std::string m_current_indent_str;
+ uint32_t m_current_indent_level = 0;
+
+ std::string m_repl_source_path;
+ bool m_dedicated_repl_mode = false;
+
+ StringList m_code; // All accumulated REPL statements are saved here
+
+ Target &m_target;
+ lldb::IOHandlerSP m_io_handler_sp;
+ LLVMCastKind m_kind;
+
+private:
+ std::string
+ GetSourcePath();
+};
+
+} // namespace lldb_private
+
+#endif // lldb_REPL_h
diff --git a/include/lldb/Expression/ClangUserExpression.h b/include/lldb/Expression/UserExpression.h
index a549f5e8a547..517dfcd1dc47 100644
--- a/include/lldb/Expression/ClangUserExpression.h
+++ b/include/lldb/Expression/UserExpression.h
@@ -1,4 +1,4 @@
-//===-- ClangUserExpression.h -----------------------------------*- C++ -*-===//
+//===-- UserExpression.h ----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,46 +7,44 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ClangUserExpression_h_
-#define liblldb_ClangUserExpression_h_
+#ifndef liblldb_UserExpression_h_
+#define liblldb_UserExpression_h_
// C Includes
// C++ Includes
+#include <memory>
#include <string>
-#include <map>
#include <vector>
// Other libraries and framework includes
// Project includes
-
#include "lldb/lldb-forward.h"
#include "lldb/lldb-private.h"
#include "lldb/Core/Address.h"
-#include "lldb/Core/ClangForward.h"
-#include "lldb/Expression/ClangExpression.h"
-#include "lldb/Expression/ClangExpressionVariable.h"
-#include "lldb/Expression/IRForTarget.h"
+#include "lldb/Expression/Expression.h"
#include "lldb/Expression/Materializer.h"
-#include "lldb/Symbol/TaggedASTType.h"
#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Target.h"
namespace lldb_private
{
//----------------------------------------------------------------------
-/// @class ClangUserExpression ClangUserExpression.h "lldb/Expression/ClangUserExpression.h"
-/// @brief Encapsulates a single expression for use with Clang
+/// @class UserExpression UserExpression.h "lldb/Expression/UserExpression.h"
+/// @brief Encapsulates a one-time expression for use in lldb.
///
/// LLDB uses expressions for various purposes, notably to call functions
-/// and as a backend for the expr command. 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.
+/// and as a backend for the expr command. UserExpression is a virtual base
+/// class that encapsulates the objects needed to parse and interpret or
+/// 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 ClangUserExpression : public ClangExpression
+class UserExpression : public Expression
{
public:
-
enum { kDefaultTimeout = 500000u };
+
//------------------------------------------------------------------
/// Constructor
///
@@ -54,7 +52,7 @@ public:
/// The expression to parse.
///
/// @param[in] expr_prefix
- /// If non-NULL, a C string containing translation-unit level
+ /// If non-nullptr, a C string containing translation-unit level
/// definitions to be included when the expression is parsed.
///
/// @param[in] language
@@ -66,16 +64,17 @@ public:
/// If not eResultTypeAny, the type to use for the expression
/// result.
//------------------------------------------------------------------
- ClangUserExpression (const char *expr,
- const char *expr_prefix,
- lldb::LanguageType language,
- ResultType desired_type);
+ UserExpression (ExecutionContextScope &exe_scope,
+ const char *expr,
+ const char *expr_prefix,
+ lldb::LanguageType language,
+ ResultType desired_type,
+ const EvaluateExpressionOptions &options);
//------------------------------------------------------------------
/// Destructor
//------------------------------------------------------------------
- virtual
- ~ClangUserExpression ();
+ ~UserExpression() override;
//------------------------------------------------------------------
/// Parse the expression
@@ -98,18 +97,14 @@ public:
/// @return
/// True on success (no errors); false otherwise.
//------------------------------------------------------------------
- bool
+ virtual bool
Parse (Stream &error_stream,
ExecutionContext &exe_ctx,
lldb_private::ExecutionPolicy execution_policy,
bool keep_result_in_memory,
- bool generate_debug_info);
+ bool generate_debug_info) = 0;
- bool
- CanInterpret ()
- {
- return m_can_interpret;
- }
+ virtual bool CanInterpret() = 0;
bool
MatchesContext (ExecutionContext &exe_ctx);
@@ -128,9 +123,9 @@ public:
/// Expression evaluation options.
///
/// @param[in] shared_ptr_to_me
- /// This is a shared pointer to this ClangUserExpression. This is
+ /// This is a shared pointer to this UserExpression. This is
/// needed because Execute can push a thread plan that will hold onto
- /// the ClangUserExpression for an unbounded period of time. So you
+ /// 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.
///
@@ -141,12 +136,10 @@ public:
/// @return
/// A Process::Execution results value.
//------------------------------------------------------------------
- lldb::ExpressionResults
- Execute (Stream &error_stream,
- ExecutionContext &exe_ctx,
- const EvaluateExpressionOptions& options,
- lldb::ClangUserExpressionSP &shared_ptr_to_me,
- lldb::ClangExpressionVariableSP &result);
+ virtual lldb::ExpressionResults Execute(Stream &error_stream, ExecutionContext &exe_ctx,
+ const EvaluateExpressionOptions &options,
+ lldb::UserExpressionSP &shared_ptr_to_me,
+ lldb::ExpressionVariableSP &result) = 0;
//------------------------------------------------------------------
/// Apply the side effects of the function to program state.
@@ -171,21 +164,18 @@ public:
/// @return
/// A Process::Execution results value.
//------------------------------------------------------------------
- bool
- FinalizeJITExecution (Stream &error_stream,
- ExecutionContext &exe_ctx,
- lldb::ClangExpressionVariableSP &result,
- lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS,
- lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS);
+ virtual bool FinalizeJITExecution(Stream &error_stream, 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. Must be a full
- /// translation unit.
+ /// Return the string that the parser should parse.
//------------------------------------------------------------------
const char *
- Text ()
+ Text() override
{
- return m_transformed_text.c_str();
+ return m_expr_text.c_str();
}
//------------------------------------------------------------------
@@ -203,7 +193,7 @@ public:
/// function.
//------------------------------------------------------------------
const char *
- FunctionName ()
+ FunctionName() override
{
return "$__lldb_expr";
}
@@ -212,39 +202,18 @@ public:
/// Return the language that should be used when parsing. To use
/// the default, return eLanguageTypeUnknown.
//------------------------------------------------------------------
- virtual lldb::LanguageType
- Language ()
+ lldb::LanguageType
+ Language() override
{
return m_language;
}
//------------------------------------------------------------------
- /// Return the object that the parser should use when resolving external
- /// values. May be NULL if everything should be self-contained.
- //------------------------------------------------------------------
- ClangExpressionDeclMap *
- DeclMap ()
- {
- return m_expr_decl_map.get();
- }
-
- //------------------------------------------------------------------
- /// 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
- /// The ASTConsumer that the returned transformer should send
- /// the ASTs to after transformation.
- //------------------------------------------------------------------
- clang::ASTConsumer *
- ASTTransformer (clang::ASTConsumer *passthrough);
-
- //------------------------------------------------------------------
/// Return the desired result type of the function, or
/// eResultTypeAny if indifferent.
//------------------------------------------------------------------
- virtual ResultType
- DesiredResultType ()
+ ResultType
+ DesiredResultType() override
{
return m_desired_type;
}
@@ -254,7 +223,7 @@ public:
/// expression.
//------------------------------------------------------------------
bool
- NeedsValidation ()
+ NeedsValidation() override
{
return true;
}
@@ -264,63 +233,87 @@ public:
/// resolved.
//------------------------------------------------------------------
bool
- NeedsVariableResolution ()
+ NeedsVariableResolution() override
{
return true;
}
+
+ EvaluateExpressionOptions *
+ GetOptions() override
+ {
+ return &m_options;
+ }
+
+ virtual lldb::ExpressionVariableSP
+ GetResultAfterDematerialization(ExecutionContextScope *exe_scope)
+ {
+ return lldb::ExpressionVariableSP();
+ }
+
+ virtual lldb::ModuleSP
+ GetJITModule()
+ {
+ return lldb::ModuleSP();
+ }
//------------------------------------------------------------------
- /// Evaluate one expression and return its result.
+ /// Evaluate one expression in the scratch context of the
+ /// target passed in the exe_ctx and return its result.
///
/// @param[in] exe_ctx
/// The execution context to use when evaluating the expression.
///
/// @param[in] options
- /// Expression evaluation options.
+ /// Expression evaluation options. N.B. The language in the
+ /// evaluation options will be used to determine the language used for
+ /// expression evaluation.
///
/// @param[in] expr_cstr
/// A C string containing the expression to be evaluated.
///
/// @param[in] expr_prefix
- /// If non-NULL, a C string containing translation-unit level
+ /// 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]
+ /// @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] jit_module_sp_ptr
+ /// If non-nullptr, used to persist the generated IR module.
+ ///
/// @result
/// A Process::ExpressionResults value. eExpressionCompleted for success.
//------------------------------------------------------------------
static lldb::ExpressionResults
- Evaluate (ExecutionContext &exe_ctx,
- const EvaluateExpressionOptions& options,
- const char *expr_cstr,
- const char *expr_prefix,
- lldb::ValueObjectSP &result_valobj_sp,
- Error &error);
+ Evaluate(ExecutionContext &exe_ctx,
+ const EvaluateExpressionOptions& options,
+ const char *expr_cstr,
+ const char *expr_prefix,
+ lldb::ValueObjectSP &result_valobj_sp,
+ Error &error,
+ uint32_t line_offset = 0,
+ lldb::ModuleSP *jit_module_sp_ptr = nullptr);
static const Error::ValueType kNoResult = 0x1001; ///< ValueObject::GetError() returns this if there is no result from the expression.
-private:
+
+protected:
+ static lldb::addr_t
+ GetObjectPointer (lldb::StackFrameSP frame_sp,
+ ConstString &object_name,
+ Error &err);
+
//------------------------------------------------------------------
/// Populate m_in_cplusplus_method and m_in_objectivec_method based on the environment.
//------------------------------------------------------------------
void
- ScanContext (ExecutionContext &exe_ctx,
- lldb_private::Error &err);
-
- bool
- PrepareToExecuteJITExpression (Stream &error_stream,
- ExecutionContext &exe_ctx,
- lldb::addr_t &struct_address,
- lldb::addr_t &object_ptr,
- lldb::addr_t &cmd_ptr);
-
- void
InstallContext (ExecutionContext &exe_ctx);
bool
@@ -329,37 +322,14 @@ private:
lldb::ProcessSP &process_sp,
lldb::StackFrameSP &frame_sp);
- lldb::ProcessWP m_process_wp; ///< The process used as the context for the expression.
Address m_address; ///< The address the process is stopped in.
- lldb::addr_t m_stack_frame_bottom; ///< The bottom of the allocated stack frame.
- lldb::addr_t m_stack_frame_top; ///< The top of the allocated stack frame.
-
std::string m_expr_text; ///< The text of the expression, as typed by the user
std::string m_expr_prefix; ///< The text of the translation-level definitions, as provided by the user
lldb::LanguageType m_language; ///< The language to use when parsing (eLanguageTypeUnknown means use defaults)
- bool m_allow_cxx; ///< True if the language allows C++.
- bool m_allow_objc; ///< True if the language allows Objective-C.
- std::string m_transformed_text; ///< The text of the expression, as send to the parser
ResultType m_desired_type; ///< The type to coerce the expression's result to. If eResultTypeAny, inferred from the expression.
-
- std::unique_ptr<ClangExpressionDeclMap> m_expr_decl_map; ///< The map to use when parsing the expression.
- 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<ASTResultSynthesizer> m_result_synthesizer; ///< The result synthesizer, if one is needed.
- lldb::ModuleWP m_jit_module_wp;
- bool m_enforce_valid_object; ///< True if the expression parser should enforce the presence of a valid class pointer in order to generate the expression as a method.
- bool m_in_cplusplus_method; ///< True if the expression is compiled as a C++ member function (true if it was parsed when exe_ctx was in a C++ method).
- bool m_in_objectivec_method; ///< True if the expression is compiled as an Objective-C method (true if it was parsed when exe_ctx was in an Objective-C method).
- bool m_in_static_method; ///< True if the expression is compiled as a static (or class) method (currently true if it was parsed when exe_ctx was in an Objective-C class method).
- bool m_needs_object_ptr; ///< True if "this" or "self" must be looked up and passed in. False if the expression doesn't really use them and they can be NULL.
- bool m_const_object; ///< True if "this" is const.
- Target *m_target; ///< The target for storing persistent data like types and variables.
-
- bool m_can_interpret; ///< True if the expression could be evaluated statically; false otherwise.
- lldb::addr_t m_materialized_address; ///< The address at which the arguments to the expression have been materialized.
- Materializer::DematerializerSP m_dematerializer_sp; ///< The dematerializer.
+ EvaluateExpressionOptions m_options; ///< Additional options provided by the user.
};
} // namespace lldb_private
-#endif // liblldb_ClangUserExpression_h_
+#endif // liblldb_UserExpression_h_
diff --git a/include/lldb/Expression/ClangUtilityFunction.h b/include/lldb/Expression/UtilityFunction.h
index bb5601fa2914..bee83d8111e4 100644
--- a/include/lldb/Expression/ClangUtilityFunction.h
+++ b/include/lldb/Expression/UtilityFunction.h
@@ -1,4 +1,4 @@
-//===-- ClangUtilityFunction.h ----------------------------------*- C++ -*-===//
+//===-- UtilityFunction.h ----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,36 +7,33 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ClangUtilityFunction_h_
-#define liblldb_ClangUtilityFunction_h_
+#ifndef liblldb_UtilityFunction_h_
+#define liblldb_UtilityFunction_h_
// C Includes
// C++ Includes
+#include <memory>
#include <string>
-#include <map>
-#include <vector>
// Other libraries and framework includes
// Project includes
-
#include "lldb/lldb-forward.h"
#include "lldb/lldb-private.h"
-#include "lldb/Core/ClangForward.h"
-#include "lldb/Expression/ClangExpression.h"
+#include "lldb/Expression/Expression.h"
namespace lldb_private
{
//----------------------------------------------------------------------
-/// @class ClangUtilityFunction ClangUtilityFunction.h "lldb/Expression/ClangUtilityFunction.h"
-/// @brief Encapsulates a single expression for use with Clang
+/// @class UtilityFunction UtilityFunction.h "lldb/Expression/UtilityFunction.h"
+/// @brief Encapsulates a bit of source code that provides a function that is callable
///
/// LLDB uses expressions for various purposes, notably to call functions
-/// and as a backend for the expr command. ClangUtilityFunction encapsulates
+/// 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 ClangUtilityFunction : public ClangExpression
+class UtilityFunction : public Expression
{
public:
//------------------------------------------------------------------
@@ -48,11 +45,11 @@ public:
/// @param[in] name
/// The name of the function, as used in the text.
//------------------------------------------------------------------
- ClangUtilityFunction (const char *text,
- const char *name);
+ UtilityFunction (ExecutionContextScope &exe_scope,
+ const char *text,
+ const char *name);
- virtual
- ~ClangUtilityFunction ();
+ ~UtilityFunction() override;
//------------------------------------------------------------------
/// Install the utility function into a process
@@ -66,13 +63,13 @@ public:
/// @return
/// True on success (no errors); false otherwise.
//------------------------------------------------------------------
- bool
- Install (Stream &error_stream, ExecutionContext &exe_ctx);
+ virtual bool
+ Install (Stream &error_stream, ExecutionContext &exe_ctx) = 0;
//------------------------------------------------------------------
/// Check whether the given PC is inside the function
///
- /// Especially useful if the function dereferences NULL to indicate a failed
+ /// Especially useful if the function dereferences nullptr to indicate a failed
/// assert.
///
/// @param[in] pc
@@ -89,14 +86,13 @@ public:
// 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 ()
+ Text() override
{
return m_function_text.c_str();
}
@@ -107,43 +103,19 @@ public:
/// function.
//------------------------------------------------------------------
const char *
- FunctionName ()
+ FunctionName() override
{
return m_function_name.c_str();
}
//------------------------------------------------------------------
- /// Return the object that the parser should use when resolving external
- /// values. May be NULL if everything should be self-contained.
- //------------------------------------------------------------------
- ClangExpressionDeclMap *
- DeclMap ()
- {
- return m_expr_decl_map.get();
- }
-
- //------------------------------------------------------------------
/// Return the object that the parser should use when registering
- /// local variables. May be NULL if the Expression doesn't care.
+ /// local variables. May be nullptr if the Expression doesn't care.
//------------------------------------------------------------------
- ClangExpressionVariableList *
+ ExpressionVariableList *
LocalVariables ()
{
- return NULL;
- }
-
- //------------------------------------------------------------------
- /// 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
- /// The ASTConsumer that the returned transformer should send
- /// the ASTs to after transformation.
- //------------------------------------------------------------------
- clang::ASTConsumer *
- ASTTransformer (clang::ASTConsumer *passthrough)
- {
- return NULL;
+ return nullptr;
}
//------------------------------------------------------------------
@@ -151,7 +123,7 @@ public:
/// expression.
//------------------------------------------------------------------
bool
- NeedsValidation ()
+ NeedsValidation() override
{
return false;
}
@@ -161,19 +133,30 @@ public:
/// resolved.
//------------------------------------------------------------------
bool
- NeedsVariableResolution ()
+ NeedsVariableResolution() override
{
return false;
}
-private:
- std::unique_ptr<ClangExpressionDeclMap> m_expr_decl_map; ///< The map to use when parsing and materializing the expression.
+ // This makes the function caller function.
+ FunctionCaller *
+ MakeFunctionCaller(const CompilerType &return_type, const ValueList &arg_value_list, Error &error);
+
+ // This one retrieves the function caller that is already made. If you haven't made it yet, this returns nullptr
+ FunctionCaller *
+ GetFunctionCaller()
+ {
+ return m_caller_up.get();
+ }
+
+protected:
std::shared_ptr<IRExecutionUnit> m_execution_unit_sp;
lldb::ModuleWP m_jit_module_wp;
std::string m_function_text; ///< The text of the function. Must be a well-formed translation unit.
std::string m_function_name; ///< The name of the function.
+ std::unique_ptr<FunctionCaller> m_caller_up;
};
} // namespace lldb_private
-#endif // liblldb_ClangUtilityFunction_h_
+#endif // liblldb_UtilityFunction_h_
diff --git a/include/lldb/Host/Condition.h b/include/lldb/Host/Condition.h
index 7431315c37a0..bd793c65e0f4 100644
--- a/include/lldb/Host/Condition.h
+++ b/include/lldb/Host/Condition.h
@@ -7,11 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DBCondition_h_
-#define liblldb_DBCondition_h_
-#if defined(__cplusplus)
-
+#ifndef liblldb_Condition_h_
+#define liblldb_Condition_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-types.h"
#include "lldb/Host/Mutex.h"
@@ -31,7 +33,6 @@ class TimeValue;
class Condition
{
public:
-
//------------------------------------------------------------------
/// Default constructor
///
@@ -73,9 +74,9 @@ public:
/// \a mutex. The waiting thread unblocks only after another thread
/// signals or broadcasts this object's condition variable.
///
- /// If \a abstime is non-NULL, this function will return when the
+ /// If \a abstime is non-nullptr, this function will return when the
/// system time reaches the time specified in \a abstime if the
- /// condition variable doesn't get unblocked. If \a abstime is NULL
+ /// condition variable doesn't get unblocked. If \a abstime is nullptr
/// this function will wait for an infinite amount of time for the
/// condition variable to be unblocked.
///
@@ -87,19 +88,19 @@ public:
/// \c pthread_cond_wait() calls.
///
/// @param[in] abstime
- /// An absolute time at which to stop waiting if non-NULL, else
+ /// An absolute time at which to stop waiting if non-nullptr, else
/// wait an infinite amount of time for the condition variable
/// toget signaled.
///
/// @param[out] timed_out
- /// If not NULL, will be set to true if the wait timed out, and
+ /// If not nullptr, will be set to true if the wait timed out, and
// false otherwise.
///
/// @see Condition::Broadcast()
/// @see Condition::Signal()
//------------------------------------------------------------------
int
- Wait (Mutex &mutex, const TimeValue *abstime = NULL, bool *timed_out = NULL);
+ Wait(Mutex &mutex, const TimeValue *abstime = nullptr, bool *timed_out = nullptr);
protected:
//------------------------------------------------------------------
@@ -119,6 +120,4 @@ protected:
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif
-
+#endif // liblldb_Condition_h_
diff --git a/include/lldb/Host/Config.h b/include/lldb/Host/Config.h
index 7872eb95aab6..f70f4de0819d 100644
--- a/include/lldb/Host/Config.h
+++ b/include/lldb/Host/Config.h
@@ -22,10 +22,14 @@
#include "lldb/Host/linux/Config.h"
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__NetBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
#include "lldb/Host/freebsd/Config.h"
+#elif defined(__NetBSD__)
+
+#include "lldb/Host/netbsd/Config.h"
+
#elif defined(__MINGW__) || defined (__MINGW32__)
#include "lldb/Host/mingw/Config.h"
diff --git a/include/lldb/Host/Debug.h b/include/lldb/Host/Debug.h
index 87dffb9865c2..7954ee0b6b3f 100644
--- a/include/lldb/Host/Debug.h
+++ b/include/lldb/Host/Debug.h
@@ -10,7 +10,12 @@
#ifndef liblldb_Debug_h_
#define liblldb_Debug_h_
+// C Includes
+// C++ Includes
#include <vector>
+
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -59,9 +64,7 @@ namespace lldb_private {
}
}
- ~ResumeActionList()
- {
- }
+ ~ResumeActionList() = default;
bool
IsEmpty() const
@@ -114,7 +117,7 @@ namespace lldb_private {
}
if (default_ok && tid != LLDB_INVALID_THREAD_ID)
return GetActionForThread (LLDB_INVALID_THREAD_ID, false);
- return NULL;
+ return nullptr;
}
size_t
@@ -133,7 +136,7 @@ namespace lldb_private {
bool
SetDefaultThreadActionIfNeeded (lldb::StateType action, int signal)
{
- if (GetActionForThread (LLDB_INVALID_THREAD_ID, true) == NULL)
+ if (GetActionForThread (LLDB_INVALID_THREAD_ID, true) == nullptr)
{
// There isn't a default action so we do need to set it.
ResumeAction default_action = {LLDB_INVALID_THREAD_ID, action, signal };
@@ -203,4 +206,5 @@ namespace lldb_private {
} details;
};
}
-#endif // #ifndef liblldb_Debug_h_
+
+#endif // liblldb_Debug_h_
diff --git a/include/lldb/Host/Endian.h b/include/lldb/Host/Endian.h
index 1ae3c40b5ca4..df0796b7baf1 100644
--- a/include/lldb/Host/Endian.h
+++ b/include/lldb/Host/Endian.h
@@ -12,7 +12,7 @@
#include "lldb/lldb-enumerations.h"
-namespace lldb {
+namespace lldb_private {
namespace endian {
@@ -22,7 +22,7 @@ namespace endian {
uint8_t bytes[sizeof(uint32_t)];
} const endianTest = { 0x01020304 };
- inline ByteOrder InlHostByteOrder() { return (ByteOrder)endianTest.bytes[0]; }
+ inline lldb::ByteOrder InlHostByteOrder() { return (lldb::ByteOrder)endianTest.bytes[0]; }
// ByteOrder const InlHostByteOrder = (ByteOrder)endianTest.bytes[0];
}
diff --git a/include/lldb/Host/File.h b/include/lldb/Host/File.h
index 5747cb5adcfd..27f3f405ffd3 100644
--- a/include/lldb/Host/File.h
+++ b/include/lldb/Host/File.h
@@ -9,12 +9,15 @@
#ifndef liblldb_File_h_
#define liblldb_File_h_
-#if defined(__cplusplus)
+// C Includes
+// C++ Includes
#include <stdarg.h>
#include <stdio.h>
#include <sys/types.h>
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Host/IOObject.h"
@@ -73,13 +76,11 @@ public:
File (const File &rhs);
- File &
- operator= (const File &rhs);
//------------------------------------------------------------------
/// Constructor with path.
///
/// Takes a path to a file which can be just a filename, or a full
- /// path. If \a path is not NULL or empty, this function will call
+ /// path. If \a path is not nullptr or empty, this function will call
/// File::Open (const char *path, uint32_t options, uint32_t permissions).
///
/// @param[in] path
@@ -101,10 +102,10 @@ public:
/// Constructor with FileSpec.
///
/// Takes a FileSpec pointing to a file which can be just a filename, or a full
- /// path. If \a path is not NULL or empty, this function will call
+ /// path. If \a path is not nullptr or empty, this function will call
/// File::Open (const char *path, uint32_t options, uint32_t permissions).
///
- /// @param[in] path
+ /// @param[in] filespec
/// The FileSpec for this file.
///
/// @param[in] options
@@ -124,7 +125,9 @@ public:
m_descriptor (fd),
m_stream (kInvalidStream),
m_options (0),
- m_own_stream (false)
+ m_own_stream (false),
+ m_is_interactive (eLazyBoolCalculate),
+ m_is_real_terminal (eLazyBoolCalculate)
{
}
@@ -133,11 +136,13 @@ public:
///
/// The destructor is virtual in case this class is subclassed.
//------------------------------------------------------------------
- virtual
- ~File ();
+ ~File() override;
+
+ File &
+ operator= (const File &rhs);
bool
- IsValid () const
+ IsValid() const override
{
return DescriptorIsValid() || StreamIsValid();
}
@@ -156,7 +161,7 @@ public:
///
/// @return
/// A pointer to this object if either the directory or filename
- /// is valid, NULL otherwise.
+ /// is valid, nullptr otherwise.
//------------------------------------------------------------------
operator
bool () const
@@ -216,7 +221,7 @@ public:
uint32_t permissions = lldb::eFilePermissionsFileDefault);
Error
- Close ();
+ Close() override;
Error
Duplicate (const File &rhs);
@@ -225,8 +230,7 @@ public:
GetDescriptor() const;
WaitableHandle
- GetWaitableHandle();
-
+ GetWaitableHandle() override;
void
SetDescriptor(int fd, bool transfer_ownership);
@@ -247,7 +251,7 @@ public:
/// @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.
///
@@ -256,7 +260,7 @@ public:
/// failure.
//------------------------------------------------------------------
Error
- Read (void *buf, size_t &num_bytes);
+ Read(void *buf, size_t &num_bytes) override;
//------------------------------------------------------------------
/// Write bytes to a file at the current file position.
@@ -268,7 +272,7 @@ public:
/// @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.
@@ -278,7 +282,7 @@ public:
/// failure.
//------------------------------------------------------------------
Error
- Write (const void *buf, size_t &num_bytes);
+ Write(const void *buf, size_t &num_bytes) override;
//------------------------------------------------------------------
/// Seek to an offset relative to the beginning of the file.
@@ -295,13 +299,13 @@ public:
///
/// @param[in] error_ptr
/// A pointer to a lldb_private::Error object that will be
- /// filled in if non-NULL.
+ /// filled in if non-nullptr.
///
/// @return
/// The resulting seek offset, or -1 on error.
//------------------------------------------------------------------
off_t
- SeekFromStart (off_t offset, Error *error_ptr = NULL);
+ SeekFromStart(off_t offset, Error *error_ptr = nullptr);
//------------------------------------------------------------------
/// Seek to an offset relative to the current file position.
@@ -318,13 +322,13 @@ public:
///
/// @param[in] error_ptr
/// A pointer to a lldb_private::Error object that will be
- /// filled in if non-NULL.
+ /// filled in if non-nullptr.
///
/// @return
/// The resulting seek offset, or -1 on error.
//------------------------------------------------------------------
off_t
- SeekFromCurrent (off_t offset, Error *error_ptr = NULL);
+ SeekFromCurrent(off_t offset, Error *error_ptr = nullptr);
//------------------------------------------------------------------
/// Seek to an offset relative to the end of the file.
@@ -335,20 +339,20 @@ public:
/// @see 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
/// A pointer to a lldb_private::Error object that will be
- /// filled in if non-NULL.
+ /// filled in if non-nullptr.
///
/// @return
/// The resulting seek offset, or -1 on error.
//------------------------------------------------------------------
off_t
- SeekFromEnd (off_t offset, Error *error_ptr = NULL);
+ SeekFromEnd(off_t offset, Error *error_ptr = nullptr);
//------------------------------------------------------------------
/// Read bytes from a file from the specified file offset.
@@ -357,14 +361,14 @@ public:
/// own file position markers and reads on other threads won't mess
/// up the current read.
///
- /// @param[in] buf
+ /// @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.
@@ -383,11 +387,11 @@ public:
/// 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.
@@ -419,15 +423,15 @@ public:
/// their own locking externally to avoid multiple people writing
/// to the file at the same time.
///
- /// @param[in] buf
+ /// @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.
@@ -472,7 +476,6 @@ public:
static uint32_t
GetPermissions(const FileSpec &file_spec, Error &error);
-
//------------------------------------------------------------------
/// Return true if this file is interactive.
///
@@ -497,6 +500,9 @@ public:
//------------------------------------------------------------------
bool
GetIsRealTerminal ();
+
+ bool
+ GetIsTerminalWithColors ();
//------------------------------------------------------------------
/// Output printf formatted output to the stream.
@@ -516,15 +522,13 @@ public:
size_t
PrintfVarArg(const char *format, va_list args);
-
void
SetOptions (uint32_t options)
{
m_options = options;
}
+
protected:
-
-
bool
DescriptorIsValid () const
{
@@ -549,9 +553,9 @@ protected:
bool m_own_stream;
LazyBool m_is_interactive;
LazyBool m_is_real_terminal;
+ LazyBool m_supports_colors;
};
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // liblldb_File_h_
+#endif // liblldb_File_h_
diff --git a/include/lldb/Host/FileSpec.h b/include/lldb/Host/FileSpec.h
index d0338d41db1b..0ff1bc9d2f44 100644
--- a/include/lldb/Host/FileSpec.h
+++ b/include/lldb/Host/FileSpec.h
@@ -9,10 +9,14 @@
#ifndef liblldb_FileSpec_h_
#define liblldb_FileSpec_h_
-#if defined(__cplusplus)
+// C Includes
+// C++ Includes
#include <functional>
+#include <string>
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/STLUtils.h"
@@ -66,14 +70,14 @@ public:
/// Constructor with path.
///
/// Takes a path to a file which can be just a filename, or a full
- /// path. If \a path is not NULL or empty, this function will call
+ /// path. If \a path is not nullptr or empty, this function will call
/// FileSpec::SetFile (const char *path, bool resolve).
///
/// @param[in] path
/// The full or partial path to a file.
///
/// @param[in] resolve_path
- /// If \b true, then we resolve the path with realpath,
+ /// If \b true, then we resolve the path, removing stray ../.. and so forth,
/// if \b false we trust the path is in canonical form already.
///
/// @see FileSpec::SetFile (const char *path, bool resolve)
@@ -101,10 +105,10 @@ public:
/// Copy constructor
///
/// Makes a copy of the uniqued directory and filename strings from
- /// \a rhs if it is not NULL.
+ /// \a rhs if it is not nullptr.
///
/// @param[in] rhs
- /// A const FileSpec object pointer to copy if non-NULL.
+ /// A const FileSpec object pointer to copy if non-nullptr.
//------------------------------------------------------------------
FileSpec (const FileSpec* rhs);
@@ -190,7 +194,7 @@ public:
///
/// @return
/// A pointer to this object if either the directory or filename
- /// is valid, NULL otherwise.
+ /// is valid, nullptr otherwise.
//------------------------------------------------------------------
explicit operator bool() const;
@@ -444,7 +448,7 @@ public:
///
/// Returns a ConstString that represents the extension of the filename
/// for this FileSpec object. If this object does not represent a file,
- /// or the filename has no extension, ConstString(NULL) is returned.
+ /// or the filename has no extension, ConstString(nullptr) is returned.
/// The dot ('.') character is not returned as part of the extension
///
/// @return
@@ -510,10 +514,7 @@ public:
}
bool
- IsSymbolicLink () const
- {
- return GetFileType() == FileSpec::eFileTypeSymbolicLink;
- }
+ IsSymbolicLink () const;
//------------------------------------------------------------------
/// Get the memory cost of this object.
@@ -555,13 +556,12 @@ public:
///
/// @return
/// A shared pointer to the memory mapped data. This shared
- /// pointer can contain a NULL DataBuffer pointer, so the contained
+ /// pointer can contain a nullptr DataBuffer pointer, so the contained
/// pointer must be checked prior to using it.
//------------------------------------------------------------------
lldb::DataBufferSP
MemoryMapFileContents (off_t offset = 0, size_t length = SIZE_MAX) const;
-
//------------------------------------------------------------------
/// Memory map part of, or the entire contents of, a file only if
/// the file is local (not on a network mount).
@@ -594,7 +594,7 @@ public:
///
/// @return
/// A shared pointer to the memory mapped data. This shared
- /// pointer can contain a NULL DataBuffer pointer, so the contained
+ /// pointer can contain a nullptr DataBuffer pointer, so the contained
/// pointer must be checked prior to using it.
//------------------------------------------------------------------
lldb::DataBufferSP
@@ -624,16 +624,15 @@ public:
///
/// @return
/// A shared pointer to the memory mapped data. This shared
- /// pointer can contain a NULL DataBuffer pointer, so the contained
+ /// pointer can contain a nullptr DataBuffer pointer, so the contained
/// pointer must be checked prior to using it.
//------------------------------------------------------------------
lldb::DataBufferSP
- ReadFileContents (off_t offset = 0, size_t length = SIZE_MAX, Error *error_ptr = NULL) const;
+ ReadFileContents(off_t offset = 0, size_t length = SIZE_MAX, Error *error_ptr = nullptr) const;
size_t
ReadFileContents (off_t file_offset, void *dst, size_t dst_len, Error *error_ptr) const;
-
//------------------------------------------------------------------
/// Read the entire contents of a file as data that can be used
/// as a C string.
@@ -643,11 +642,11 @@ public:
///
/// @return
/// A shared pointer to the data. This shared pointer can
- /// contain a NULL DataBuffer pointer, so the contained pointer
+ /// contain a nullptr DataBuffer pointer, so the contained pointer
/// must be checked prior to using it.
//------------------------------------------------------------------
lldb::DataBufferSP
- ReadFileContentsAsCString(Error *error_ptr = NULL);
+ ReadFileContentsAsCString(Error *error_ptr = nullptr);
//------------------------------------------------------------------
/// Normalize a pathname by collapsing redundant separators and
@@ -719,6 +718,7 @@ public:
{
m_is_resolved = is_resolved;
}
+
//------------------------------------------------------------------
/// Read the file into an array of strings, one per line.
///
@@ -835,5 +835,4 @@ Stream& operator << (Stream& s, const FileSpec& f);
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // liblldb_FileSpec_h_
+#endif // liblldb_FileSpec_h_
diff --git a/include/lldb/Host/FileSystem.h b/include/lldb/Host/FileSystem.h
index bea1ec80172e..465ad451bdd6 100644
--- a/include/lldb/Host/FileSystem.h
+++ b/include/lldb/Host/FileSystem.h
@@ -22,6 +22,8 @@ namespace lldb_private
class FileSystem
{
public:
+ static const char *DEV_NULL;
+
static FileSpec::PathSyntax GetNativePathSyntax();
static Error MakeDirectory(const FileSpec &file_spec, uint32_t mode);
@@ -35,9 +37,12 @@ class FileSystem
static bool GetFileExists(const FileSpec &file_spec);
static Error Hardlink(const FileSpec &src, const FileSpec &dst);
+ static int GetHardlinkCount(const FileSpec &file_spec);
static Error Symlink(const FileSpec &src, const FileSpec &dst);
static Error Readlink(const FileSpec &src, FileSpec &dst);
static Error Unlink(const FileSpec &file_spec);
+
+ static Error ResolveSymbolicLink(const FileSpec &src, FileSpec &dst);
static bool CalculateMD5(const FileSpec &file_spec, uint64_t &low, uint64_t &high);
static bool CalculateMD5(const FileSpec &file_spec,
diff --git a/include/lldb/Host/HostGetOpt.h b/include/lldb/Host/HostGetOpt.h
index 761c1a118600..6f512915d33c 100644
--- a/include/lldb/Host/HostGetOpt.h
+++ b/include/lldb/Host/HostGetOpt.h
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
#pragma once
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(__NetBSD__)
#ifdef _WIN32
#define _BSD_SOURCE // Required so that getopt.h defines optreset
@@ -19,6 +19,6 @@
#else
-#include <lldb/Host/windows/getopt/GetOptInc.h>
+#include <lldb/Host/common/GetOptInc.h>
#endif
diff --git a/include/lldb/Host/HostInfo.h b/include/lldb/Host/HostInfo.h
index 6bb009997896..96094389c703 100644
--- a/include/lldb/Host/HostInfo.h
+++ b/include/lldb/Host/HostInfo.h
@@ -48,6 +48,9 @@
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include "lldb/Host/freebsd/HostInfoFreeBSD.h"
#define HOST_INFO_TYPE HostInfoFreeBSD
+#elif defined(__NetBSD__)
+#include "lldb/Host/netbsd/HostInfoNetBSD.h"
+#define HOST_INFO_TYPE HostInfoNetBSD
#elif defined(__APPLE__)
#include "lldb/Host/macosx/HostInfoMacOSX.h"
#define HOST_INFO_TYPE HostInfoMacOSX
diff --git a/include/lldb/Host/HostNativeThread.h b/include/lldb/Host/HostNativeThread.h
index f39c775df8e3..b0411cad7a3e 100644
--- a/include/lldb/Host/HostNativeThread.h
+++ b/include/lldb/Host/HostNativeThread.h
@@ -18,6 +18,8 @@
#include "lldb/Host/linux/HostThreadLinux.h"
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include "lldb/Host/freebsd/HostThreadFreeBSD.h"
+#elif defined(__NetBSD__)
+#include "lldb/Host/netbsd/HostThreadNetBSD.h"
#elif defined(__APPLE__)
#include "lldb/Host/macosx/HostThreadMacOSX.h"
#endif
diff --git a/include/lldb/Host/HostNativeThreadForward.h b/include/lldb/Host/HostNativeThreadForward.h
index e6bd426673b3..520031af6488 100644
--- a/include/lldb/Host/HostNativeThreadForward.h
+++ b/include/lldb/Host/HostNativeThreadForward.h
@@ -21,6 +21,9 @@ typedef HostThreadLinux HostNativeThread;
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
class HostThreadFreeBSD;
typedef HostThreadFreeBSD HostNativeThread;
+#elif defined(__NetBSD__)
+class HostThreadNetBSD;
+typedef HostThreadNetBSD HostNativeThread;
#elif defined(__APPLE__)
class HostThreadMacOSX;
typedef HostThreadMacOSX HostNativeThread;
diff --git a/include/lldb/Host/MainLoopBase.h b/include/lldb/Host/MainLoopBase.h
index bff2ce78110d..da14349cf82e 100644
--- a/include/lldb/Host/MainLoopBase.h
+++ b/include/lldb/Host/MainLoopBase.h
@@ -60,25 +60,25 @@ public:
protected:
ReadHandleUP
CreateReadHandle(const lldb::IOObjectSP &object_sp)
- { return ReadHandleUP(new ReadHandle(*this, object_sp)); }
+ { return ReadHandleUP(new ReadHandle(*this, object_sp->GetWaitableHandle())); }
virtual void
- UnregisterReadObject(const lldb::IOObjectSP &object_sp)
+ UnregisterReadObject(IOObject::WaitableHandle handle)
{ llvm_unreachable("Not implemented"); }
private:
class ReadHandle
{
public:
- ~ReadHandle() { m_mainloop.UnregisterReadObject(m_object_sp); }
+ ~ReadHandle() { m_mainloop.UnregisterReadObject(m_handle); }
private:
- ReadHandle(MainLoopBase &mainloop, const lldb::IOObjectSP &object_sp)
- : m_mainloop(mainloop), m_object_sp(object_sp)
+ ReadHandle(MainLoopBase &mainloop, IOObject::WaitableHandle handle)
+ : m_mainloop(mainloop), m_handle(handle)
{ }
MainLoopBase &m_mainloop;
- lldb::IOObjectSP m_object_sp;
+ IOObject::WaitableHandle m_handle;
friend class MainLoopBase;
DISALLOW_COPY_AND_ASSIGN(ReadHandle);
diff --git a/include/lldb/Host/MonitoringProcessLauncher.h b/include/lldb/Host/MonitoringProcessLauncher.h
index 3c3e66108f8a..f5d0a92aa8de 100644
--- a/include/lldb/Host/MonitoringProcessLauncher.h
+++ b/include/lldb/Host/MonitoringProcessLauncher.h
@@ -10,6 +10,10 @@
#ifndef lldb_Host_MonitoringProcessLauncher_h_
#define lldb_Host_MonitoringProcessLauncher_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Host/ProcessLauncher.h"
namespace lldb_private
@@ -20,11 +24,12 @@ class MonitoringProcessLauncher : public ProcessLauncher
public:
explicit MonitoringProcessLauncher(std::unique_ptr<ProcessLauncher> delegate_launcher);
- virtual HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info, Error &error);
+ HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info, Error &error) override;
private:
std::unique_ptr<ProcessLauncher> m_delegate_launcher;
};
-}
-#endif
+} // namespace lldb_private
+
+#endif // lldb_Host_MonitoringProcessLauncher_h_
diff --git a/include/lldb/Host/Mutex.h b/include/lldb/Host/Mutex.h
index 496dd0496c13..5a529fb4554d 100644
--- a/include/lldb/Host/Mutex.h
+++ b/include/lldb/Host/Mutex.h
@@ -9,15 +9,17 @@
#ifndef liblldb_Mutex_h_
#define liblldb_Mutex_h_
-#if defined(__cplusplus)
-
-#include "lldb/lldb-types.h"
-#include <assert.h>
+// C Includes
+// C++ Includes
#ifdef LLDB_CONFIGURATION_DEBUG
#include <string>
#endif
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-types.h"
+
namespace lldb_private {
//----------------------------------------------------------------------
@@ -85,7 +87,7 @@ public:
Locker(Mutex* m);
//--------------------------------------------------------------
- /// Desstructor
+ /// Destructor
///
/// Unlocks any valid pthread_mutex_t that this object may
/// contain.
@@ -97,7 +99,7 @@ public:
///
/// Unlock the current mutex in this object (if it contains a
/// valid mutex) and lock the new \a mutex object if it is
- /// non-NULL.
+ /// non-nullptr.
//--------------------------------------------------------------
void
Lock (Mutex &mutex);
@@ -120,15 +122,15 @@ public:
/// will not take ownership of the mutex.
///
/// @return
- /// Returns \b true if the lock was aquired and the this
+ /// Returns \b true if the lock was acquired and the this
/// object will unlock the mutex when it goes out of scope,
/// returns \b false otherwise.
//--------------------------------------------------------------
bool
- TryLock (Mutex &mutex, const char *failure_message = NULL);
+ TryLock(Mutex &mutex, const char *failure_message = nullptr);
bool
- TryLock (Mutex *mutex, const char *failure_message = NULL)
+ TryLock(Mutex *mutex, const char *failure_message = nullptr)
{
if (mutex)
return TryLock(*mutex, failure_message);
@@ -150,7 +152,6 @@ public:
const Locker& operator=(const Locker&);
};
-
//------------------------------------------------------------------
/// Default constructor.
///
@@ -213,7 +214,7 @@ public:
virtual
#endif
int
- TryLock(const char *failure_message = NULL);
+ TryLock(const char *failure_message = nullptr);
//------------------------------------------------------------------
/// Unlock the mutex.
@@ -262,16 +263,16 @@ public:
TrackingMutex(Mutex::Type type) : Mutex (type) {}
virtual
- ~TrackingMutex() {}
+ ~TrackingMutex() = default;
virtual int
Unlock ();
virtual int
- TryLock (const char *failure_message = NULL)
+ TryLock(const char *failure_message = nullptr)
{
int return_value = Mutex::TryLock();
- if (return_value != 0 && failure_message != NULL)
+ if (return_value != 0 && failure_message != nullptr)
{
m_failure_message.assign(failure_message);
m_thread_that_tried = pthread_self();
@@ -291,7 +292,7 @@ public:
LoggingMutex(Mutex::Type type) : Mutex (type),m_locked(false) {}
virtual
- ~LoggingMutex() {}
+ ~LoggingMutex() = default;
virtual int
Lock ();
@@ -300,13 +301,13 @@ public:
Unlock ();
virtual int
- TryLock (const char *failure_message = NULL);
+ TryLock(const char *failure_message = nullptr);
+
protected:
bool m_locked;
};
-#endif
+#endif // LLDB_CONFIGURATION_DEBUG
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif
+#endif // liblldb_Mutex_h_
diff --git a/include/lldb/Host/OptionParser.h b/include/lldb/Host/OptionParser.h
index 5aa7db5d34bf..175a1973c7af 100644
--- a/include/lldb/Host/OptionParser.h
+++ b/include/lldb/Host/OptionParser.h
@@ -11,6 +11,7 @@
#define liblldb_OptionParser_h_
#include <string>
+#include "lldb/Host/Mutex.h"
struct option;
@@ -38,7 +39,7 @@ public:
eOptionalArgument
};
- static void Prepare();
+ static void Prepare(Mutex::Locker &locker);
static void EnableError(bool error);
diff --git a/include/lldb/Host/Predicate.h b/include/lldb/Host/Predicate.h
index ae6c99155fe0..4f386dc1dd0b 100644
--- a/include/lldb/Host/Predicate.h
+++ b/include/lldb/Host/Predicate.h
@@ -9,13 +9,17 @@
#ifndef liblldb_Predicate_h_
#define liblldb_Predicate_h_
-#if defined(__cplusplus)
+// C Includes
+#include <stdint.h>
+#include <time.h>
+
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-defines.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/Condition.h"
-#include <stdint.h>
-#include <time.h>
//#define DB_PTHREAD_LOG_EVENTS
@@ -29,7 +33,6 @@ typedef enum
eBroadcastNever, ///< No broadcast will be sent when the value is modified.
eBroadcastAlways, ///< Always send a broadcast when the value is modified.
eBroadcastOnChange ///< Only broadcast if the value changes when the value is modified.
-
} PredicateBroadcastType;
//----------------------------------------------------------------------
@@ -46,7 +49,6 @@ template <class T>
class Predicate
{
public:
-
//------------------------------------------------------------------
/// Default constructor.
///
@@ -81,10 +83,7 @@ public:
///
/// Destroy the condition, mutex, and T objects.
//------------------------------------------------------------------
- ~Predicate ()
- {
- }
-
+ ~Predicate() = default;
//------------------------------------------------------------------
/// Value get accessor.
@@ -205,7 +204,7 @@ public:
/// The bits we are waiting to be set in \a m_value.
///
/// @param[in] abstime
- /// If non-NULL, the absolute time at which we should stop
+ /// If non-nullptr, the absolute time at which we should stop
/// waiting, else wait an infinite amount of time.
///
/// @return
@@ -214,7 +213,7 @@ public:
/// occurred.
//------------------------------------------------------------------
T
- WaitForSetValueBits (T bits, const TimeValue *abstime = NULL)
+ WaitForSetValueBits(T bits, const TimeValue *abstime = nullptr)
{
int err = 0;
// pthread_cond_timedwait() or pthread_cond_wait() will atomically
@@ -255,7 +254,7 @@ public:
/// The bits we are waiting to be reset in \a m_value.
///
/// @param[in] abstime
- /// If non-NULL, the absolute time at which we should stop
+ /// If non-nullptr, the absolute time at which we should stop
/// waiting, else wait an infinite amount of time.
///
/// @return
@@ -263,7 +262,7 @@ public:
/// unrecoverable error occurs.
//------------------------------------------------------------------
T
- WaitForResetValueBits (T bits, const TimeValue *abstime = NULL)
+ WaitForResetValueBits(T bits, const TimeValue *abstime = nullptr)
{
int err = 0;
@@ -306,7 +305,7 @@ public:
/// The value we want \a m_value to be equal to.
///
/// @param[in] abstime
- /// If non-NULL, the absolute time at which we should stop
+ /// If non-nullptr, the absolute time at which we should stop
/// waiting, else wait an infinite amount of time.
///
/// @param[out] timed_out
@@ -318,7 +317,7 @@ public:
/// @li \b false otherwise
//------------------------------------------------------------------
bool
- WaitForValueEqualTo (T value, const TimeValue *abstime = NULL, bool *timed_out = NULL)
+ WaitForValueEqualTo(T value, const TimeValue *abstime = nullptr, bool *timed_out = nullptr)
{
int err = 0;
// pthread_cond_timedwait() or pthread_cond_wait() will atomically
@@ -366,7 +365,7 @@ public:
/// returned.
///
/// @param[in] abstime
- /// If non-NULL, the absolute time at which we should stop
+ /// If non-nullptr, the absolute time at which we should stop
/// waiting, else wait an infinite amount of time.
///
/// @param[out] timed_out
@@ -378,7 +377,9 @@ public:
/// @li \b false otherwise
//------------------------------------------------------------------
bool
- WaitForValueEqualToAndSetValueTo (T wait_value, T new_value, const TimeValue *abstime = NULL, bool *timed_out = NULL)
+ WaitForValueEqualToAndSetValueTo(T wait_value, T new_value,
+ const TimeValue *abstime = nullptr,
+ bool *timed_out = nullptr)
{
int err = 0;
// pthread_cond_timedwait() or pthread_cond_wait() will atomically
@@ -408,7 +409,6 @@ public:
return false;
}
-
//------------------------------------------------------------------
/// Wait for \a m_value to not be equal to \a value.
///
@@ -430,7 +430,7 @@ public:
/// The new value if \b true is returned.
///
/// @param[in] abstime
- /// If non-NULL, the absolute time at which we should stop
+ /// If non-nullptr, the absolute time at which we should stop
/// waiting, else wait an infinite amount of time.
///
/// @return
@@ -438,7 +438,7 @@ public:
/// @li \b false otherwise
//------------------------------------------------------------------
bool
- WaitForValueNotEqualTo (T value, T &new_value, const TimeValue *abstime = NULL)
+ WaitForValueNotEqualTo(T value, T &new_value, const TimeValue *abstime = nullptr)
{
int err = 0;
// pthread_cond_timedwait() or pthread_cond_wait() will atomically
@@ -473,7 +473,6 @@ protected:
Condition m_condition; ///< The pthread condition variable to use for signaling that data available or changed.
private:
-
//------------------------------------------------------------------
/// Broadcast if needed.
///
@@ -500,11 +499,9 @@ private:
m_condition.Broadcast();
}
-
DISALLOW_COPY_AND_ASSIGN(Predicate);
};
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // #ifndef liblldb_Predicate_h_
+#endif // liblldb_Predicate_h_
diff --git a/include/lldb/Host/ProcessRunLock.h b/include/lldb/Host/ProcessRunLock.h
index eca1ad375fc6..ceb1e90be757 100644
--- a/include/lldb/Host/ProcessRunLock.h
+++ b/include/lldb/Host/ProcessRunLock.h
@@ -9,13 +9,17 @@
#ifndef liblldb_ProcessRunLock_h_
#define liblldb_ProcessRunLock_h_
-#if defined(__cplusplus)
+// C Includes
+#include <stdint.h>
+#include <time.h>
+
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-defines.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/Condition.h"
-#include <stdint.h>
-#include <time.h>
//----------------------------------------------------------------------
/// Enumerations for broadcasting.
@@ -34,17 +38,18 @@ class ProcessRunLock
public:
ProcessRunLock();
~ProcessRunLock();
+
bool ReadTryLock ();
bool ReadUnlock ();
bool SetRunning ();
bool TrySetRunning ();
bool SetStopped ();
-public:
+
class ProcessRunLocker
{
public:
ProcessRunLocker () :
- m_lock (NULL)
+ m_lock (nullptr)
{
}
@@ -82,11 +87,12 @@ public:
if (m_lock)
{
m_lock->ReadUnlock();
- m_lock = NULL;
+ m_lock = nullptr;
}
}
ProcessRunLock *m_lock;
+
private:
DISALLOW_COPY_AND_ASSIGN(ProcessRunLocker);
};
@@ -94,11 +100,11 @@ public:
protected:
lldb::rwlock_t m_rwlock;
bool m_running;
+
private:
DISALLOW_COPY_AND_ASSIGN(ProcessRunLock);
};
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // #ifndef liblldb_ProcessRunLock_h_
+#endif // liblldb_ProcessRunLock_h_
diff --git a/include/lldb/Host/Socket.h b/include/lldb/Host/Socket.h
index f4599b5ab87b..a38b42f817c6 100644
--- a/include/lldb/Host/Socket.h
+++ b/include/lldb/Host/Socket.h
@@ -10,6 +10,7 @@
#ifndef liblldb_Host_Socket_h_
#define liblldb_Host_Socket_h_
+#include <memory>
#include <string>
#include "lldb/lldb-private.h"
@@ -45,13 +46,19 @@ public:
{
ProtocolTcp,
ProtocolUdp,
- ProtocolUnixDomain
+ ProtocolUnixDomain,
+ ProtocolUnixAbstract
} SocketProtocol;
static const NativeSocket kInvalidSocketValue;
- Socket(NativeSocket socket, SocketProtocol protocol, bool should_close);
- ~Socket();
+ ~Socket() override;
+
+ static std::unique_ptr<Socket> Create(const SocketProtocol protocol, bool child_processes_inherit, Error &error);
+
+ virtual Error Connect(llvm::StringRef name) = 0;
+ virtual Error Listen(llvm::StringRef name, int backlog) = 0;
+ virtual Error Accept(llvm::StringRef name, bool child_processes_inherit, Socket *&socket) = 0;
// Initialize a Tcp Socket object in listening mode. listen and accept are implemented
// separately because the caller may wish to manipulate or query the socket after it is
@@ -66,43 +73,23 @@ public:
static Error UdpConnect(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&send_socket, Socket *&recv_socket);
static Error UnixDomainConnect(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&socket);
static Error UnixDomainAccept(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&socket);
-
- // Blocks on a listening socket until a connection is received. This method assumes that
- // |this->m_socket| is a listening socket, created via either TcpListen() or via the native
- // constructor that takes a NativeSocket, which itself was created via a call to |listen()|
- Error BlockingAccept(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&socket);
+ static Error UnixAbstractConnect(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&socket);
+ static Error UnixAbstractAccept(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&socket);
int GetOption (int level, int option_name, int &option_value);
int SetOption (int level, int option_name, int option_value);
- // returns port number or 0 if error
- static uint16_t GetLocalPortNumber (const NativeSocket& socket);
-
- // returns port number or 0 if error
- uint16_t GetLocalPortNumber () const;
-
- // returns ip address string or empty string if error
- std::string GetLocalIPAddress () const;
-
- // must be connected
- // returns port number or 0 if error
- uint16_t GetRemotePortNumber () const;
-
- // must be connected
- // returns ip address string or empty string if error
- std::string GetRemoteIPAddress () const;
-
NativeSocket GetNativeSocket () const { return m_socket; }
SocketProtocol GetSocketProtocol () const { return m_protocol; }
- virtual Error Read (void *buf, size_t &num_bytes);
- virtual Error Write (const void *buf, size_t &num_bytes);
+ Error Read (void *buf, size_t &num_bytes) override;
+ Error Write (const void *buf, size_t &num_bytes) override;
virtual Error PreDisconnect ();
- virtual Error Close ();
+ Error Close() override;
- virtual bool IsValid () const { return m_socket != kInvalidSocketValue; }
- virtual WaitableHandle GetWaitableHandle ();
+ bool IsValid () const override { return m_socket != kInvalidSocketValue; }
+ WaitableHandle GetWaitableHandle () override;
static bool
DecodeHostAndPort (llvm::StringRef host_and_port,
@@ -112,10 +99,20 @@ public:
Error *error_ptr);
protected:
+ Socket(NativeSocket socket, SocketProtocol protocol, bool should_close);
+
+ virtual size_t Send(const void *buf, const size_t num_bytes);
+
+ static void SetLastError(Error &error);
+ static NativeSocket CreateSocket(
+ const int domain, const int type, const int protocol, bool child_processes_inherit, Error& error);
+ static NativeSocket AcceptSocket(
+ NativeSocket sockfd, struct sockaddr *addr, socklen_t *addrlen, bool child_processes_inherit, Error& error);
+
SocketProtocol m_protocol;
NativeSocket m_socket;
- SocketAddress m_udp_send_sockaddr; // Send address used for UDP connections.
};
-}
-#endif
+} // namespace lldb_private
+
+#endif // liblldb_Host_Socket_h_
diff --git a/include/lldb/Host/Symbols.h b/include/lldb/Host/Symbols.h
index d6c86333d709..0ca864c8c85c 100644
--- a/include/lldb/Host/Symbols.h
+++ b/include/lldb/Host/Symbols.h
@@ -29,7 +29,7 @@ public:
// Locating the file should happen only on the local computer or using
// the current computers global settings.
//----------------------------------------------------------------------
- static FileSpec
+ static ModuleSpec
LocateExecutableObjectFile (const ModuleSpec &module_spec);
//----------------------------------------------------------------------
diff --git a/include/lldb/Host/XML.h b/include/lldb/Host/XML.h
index e3547d834635..3ebd2c6f79ec 100644
--- a/include/lldb/Host/XML.h
+++ b/include/lldb/Host/XML.h
@@ -11,25 +11,23 @@
#define liblldb_XML_h_
// C Includes
-
#if defined( LIBXML2_DEFINED )
#include <libxml/xmlreader.h>
#endif
// C++ Includes
-
#include <functional>
#include <string>
#include <vector>
// Other libraries and framework includes
+#include "llvm/ADT/StringRef.h"
+
// Project includes
#include "lldb/lldb-private.h"
-#include "llvm/ADT/StringRef.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/StructuredData.h"
-
namespace lldb_private {
#if defined( LIBXML2_DEFINED )
@@ -94,7 +92,7 @@ namespace lldb_private {
GetChild () const;
llvm::StringRef
- GetAttributeValue(const char *name, const char *fail_value = NULL) const;
+ GetAttributeValue(const char *name, const char *fail_value = nullptr) const;
XMLNode
FindFirstChildElementWithName (const char *name) const;
@@ -140,7 +138,6 @@ namespace lldb_private {
class XMLDocument
{
public:
-
XMLDocument ();
~XMLDocument ();
@@ -163,7 +160,7 @@ namespace lldb_private {
ParseMemory (const char *xml, size_t xml_length, const char *url = "untitled.xml");
//----------------------------------------------------------------------
- // If \a name is NULL, just get the root element node, else only return
+ // 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
@@ -216,7 +213,6 @@ namespace lldb_private {
GetStructuredData();
protected:
-
// Using a node returned from GetValueNode() extract its value as a
// string (if possible). Array and dictionary nodes will return false
// as they have no string value. Boolean nodes will return true and
@@ -229,6 +225,7 @@ namespace lldb_private {
XMLDocument m_xml_doc;
XMLNode m_dict_node;
};
+
} // namespace lldb_private
#endif // liblldb_XML_h_
diff --git a/include/lldb/Host/common/GetOptInc.h b/include/lldb/Host/common/GetOptInc.h
new file mode 100644
index 000000000000..f79644017ca5
--- /dev/null
+++ b/include/lldb/Host/common/GetOptInc.h
@@ -0,0 +1,65 @@
+#pragma once
+
+#include "lldb/lldb-defines.h"
+
+#if defined(_MSC_VER)
+#define REPLACE_GETOPT
+#define REPLACE_GETOPT_LONG
+#endif
+#if defined(_MSC_VER) || defined(__NetBSD__)
+#define REPLACE_GETOPT_LONG_ONLY
+#endif
+
+#if defined(REPLACE_GETOPT)
+// from getopt.h
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
+
+// option structure
+struct option
+{
+ const char *name;
+ // has_arg can't be an enum because some compilers complain about
+ // type mismatches in all the code that assumes it is an int.
+ int has_arg;
+ int *flag;
+ int val;
+};
+
+int getopt( int argc, char * const argv[], const char *optstring );
+
+// from getopt.h
+extern char * optarg;
+extern int optind;
+extern int opterr;
+extern int optopt;
+
+// defined in unistd.h
+extern int optreset;
+#else
+# include <unistd.h>
+# include <getopt.h>
+#endif
+
+#if defined(REPLACE_GETOPT_LONG)
+int getopt_long
+(
+ int argc,
+ char * const *argv,
+ const char *optstring,
+ const struct option *longopts,
+ int *longindex
+);
+#endif
+
+#if defined(REPLACE_GETOPT_LONG_ONLY)
+int getopt_long_only
+(
+ int argc,
+ char * const *argv,
+ const char *optstring,
+ const struct option *longopts,
+ int *longindex
+);
+#endif
diff --git a/include/lldb/Host/common/NativeProcessProtocol.h b/include/lldb/Host/common/NativeProcessProtocol.h
index 4f0f3a962d32..7236bf659042 100644
--- a/include/lldb/Host/common/NativeProcessProtocol.h
+++ b/include/lldb/Host/common/NativeProcessProtocol.h
@@ -16,6 +16,7 @@
#include "lldb/lldb-types.h"
#include "lldb/Core/Error.h"
#include "lldb/Host/Mutex.h"
+#include "lldb/Host/MainLoop.h"
#include "llvm/ADT/StringRef.h"
#include "NativeBreakpointList.h"
@@ -284,10 +285,6 @@ namespace lldb_private
bool
UnregisterNativeDelegate (NativeDelegate &native_delegate);
- // Called before termination of NativeProcessProtocol's instance.
- virtual void
- Terminate ();
-
virtual Error
GetLoadedModuleFileSpec(const char* module_path, FileSpec& file_spec) = 0;
@@ -307,6 +304,11 @@ namespace lldb_private
/// inferior. Must outlive the NativeProcessProtocol
/// instance.
///
+ /// @param[in] mainloop
+ /// The mainloop instance with which the process can register
+ /// callbacks. Must outlive the NativeProcessProtocol
+ /// instance.
+ ///
/// @param[out] process_sp
/// On successful return from the method, this parameter
/// contains the shared pointer to the
@@ -320,6 +322,7 @@ namespace lldb_private
static Error
Launch (ProcessLaunchInfo &launch_info,
NativeDelegate &native_delegate,
+ MainLoop &mainloop,
NativeProcessProtocolSP &process_sp);
//------------------------------------------------------------------
@@ -335,6 +338,11 @@ namespace lldb_private
/// inferior. Must outlive the NativeProcessProtocol
/// instance.
///
+ /// @param[in] mainloop
+ /// The mainloop instance with which the process can register
+ /// callbacks. Must outlive the NativeProcessProtocol
+ /// instance.
+ ///
/// @param[out] process_sp
/// On successful return from the method, this parameter
/// contains the shared pointer to the
@@ -348,6 +356,7 @@ namespace lldb_private
static Error
Attach (lldb::pid_t pid,
NativeDelegate &native_delegate,
+ MainLoop &mainloop,
NativeProcessProtocolSP &process_sp);
protected:
diff --git a/include/lldb/Host/common/TCPSocket.h b/include/lldb/Host/common/TCPSocket.h
new file mode 100644
index 000000000000..0ffe9c87bfa4
--- /dev/null
+++ b/include/lldb/Host/common/TCPSocket.h
@@ -0,0 +1,46 @@
+//===-- TCPSocket.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_TCPSocket_h_
+#define liblldb_TCPSocket_h_
+
+#include "lldb/Host/Socket.h"
+
+namespace lldb_private
+{
+ class TCPSocket: public Socket
+ {
+ public:
+ TCPSocket(NativeSocket socket, bool should_close);
+ TCPSocket(bool child_processes_inherit, Error &error);
+
+ // returns port number or 0 if error
+ uint16_t GetLocalPortNumber () const;
+
+ // returns ip address string or empty string if error
+ std::string GetLocalIPAddress () const;
+
+ // must be connected
+ // returns port number or 0 if error
+ uint16_t GetRemotePortNumber () const;
+
+ // must be connected
+ // returns ip address string or empty string if error
+ std::string GetRemoteIPAddress () const;
+
+ int SetOptionNoDelay();
+ int SetOptionReuseAddress();
+
+ Error Connect(llvm::StringRef name) override;
+ Error Listen(llvm::StringRef name, int backlog) override;
+ Error Accept(llvm::StringRef name, bool child_processes_inherit, Socket *&conn_socket) override;
+ };
+}
+
+#endif // ifndef liblldb_TCPSocket_h_
diff --git a/include/lldb/Host/common/UDPSocket.h b/include/lldb/Host/common/UDPSocket.h
new file mode 100644
index 000000000000..afc1ec719626
--- /dev/null
+++ b/include/lldb/Host/common/UDPSocket.h
@@ -0,0 +1,35 @@
+//===-- UDPSocket.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_UDPSocket_h_
+#define liblldb_UDPSocket_h_
+
+#include "lldb/Host/Socket.h"
+
+namespace lldb_private
+{
+ class UDPSocket: public Socket
+ {
+ public:
+ UDPSocket(bool child_processes_inherit, Error &error);
+
+ static Error Connect(llvm::StringRef name, bool child_processes_inherit, Socket *&send_socket, Socket *&recv_socket);
+ private:
+ UDPSocket(NativeSocket socket);
+
+ size_t Send(const void *buf, const size_t num_bytes) override;
+ Error Connect(llvm::StringRef name) override;
+ Error Listen(llvm::StringRef name, int backlog) override;
+ Error Accept(llvm::StringRef name, bool child_processes_inherit, Socket *&socket) override;
+
+ SocketAddress m_send_sockaddr;
+ };
+}
+
+#endif // ifndef liblldb_UDPSocket_h_
diff --git a/include/lldb/Host/netbsd/Config.h b/include/lldb/Host/netbsd/Config.h
new file mode 100644
index 000000000000..1e9f55299d52
--- /dev/null
+++ b/include/lldb/Host/netbsd/Config.h
@@ -0,0 +1,28 @@
+//===-- Config.h -----------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+//----------------------------------------------------------------------
+// LLDB currently doesn't have a dynamic configuration mechanism, so we
+// are going to hardcode things for now. Eventually these files will
+// be auto generated by some configuration script that can detect
+// platform functionality availability.
+//----------------------------------------------------------------------
+
+#ifndef liblldb_Platform_Config_h_
+#define liblldb_Platform_Config_h_
+
+#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
+
+#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
+
+//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
+
+//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
+
+#endif // #ifndef liblldb_Platform_Config_h_
diff --git a/include/lldb/Host/netbsd/HostInfoNetBSD.h b/include/lldb/Host/netbsd/HostInfoNetBSD.h
new file mode 100644
index 000000000000..34a29346c2ef
--- /dev/null
+++ b/include/lldb/Host/netbsd/HostInfoNetBSD.h
@@ -0,0 +1,30 @@
+//===-- HostInfoNetBSD.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_Host_netbsd_HostInfoNetBSD_h_
+#define lldb_Host_netbsd_HostInfoNetBSD_h_
+
+#include "lldb/Host/FileSpec.h"
+#include "lldb/Host/posix/HostInfoPosix.h"
+
+namespace lldb_private
+{
+
+class HostInfoNetBSD : public HostInfoPosix
+{
+ public:
+ static uint32_t GetMaxThreadNameLength();
+ static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update);
+ static bool GetOSBuildString(std::string &s);
+ static bool GetOSKernelDescription(std::string &s);
+ static FileSpec GetProgramFileSpec();
+};
+}
+
+#endif
diff --git a/include/lldb/Host/netbsd/HostThreadNetBSD.h b/include/lldb/Host/netbsd/HostThreadNetBSD.h
new file mode 100644
index 000000000000..2ce1e48fa045
--- /dev/null
+++ b/include/lldb/Host/netbsd/HostThreadNetBSD.h
@@ -0,0 +1,32 @@
+//===-- HostThreadNetBSD.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_Host_netbsd_HostThreadNetBSD_h_
+#define lldb_Host_netbsd_HostThreadNetBSD_h_
+
+#include "lldb/Host/posix/HostThreadPosix.h"
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/SmallString.h"
+
+namespace lldb_private
+{
+
+class HostThreadNetBSD : public HostThreadPosix
+{
+ public:
+ HostThreadNetBSD();
+ HostThreadNetBSD(lldb::thread_t thread);
+
+ static void SetName(lldb::thread_t tid, llvm::StringRef &name);
+ static void GetName(lldb::thread_t tid, llvm::SmallVectorImpl<char> &name);
+};
+}
+
+#endif
diff --git a/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h b/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
index 2e0fd705b2a8..7e7904cd5fa8 100644
--- a/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
+++ b/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
@@ -34,13 +34,24 @@ class SocketAddress;
class ConnectionFileDescriptor : public Connection
{
public:
+ static const char* LISTEN_SCHEME;
+ static const char* ACCEPT_SCHEME;
+ static const char* UNIX_ACCEPT_SCHEME;
+ static const char* CONNECT_SCHEME;
+ static const char* TCP_CONNECT_SCHEME;
+ static const char* UDP_SCHEME;
+ static const char* UNIX_CONNECT_SCHEME;
+ static const char* UNIX_ABSTRACT_CONNECT_SCHEME;
+ static const char* FD_SCHEME;
+ static const char* FILE_SCHEME;
+
ConnectionFileDescriptor(bool child_processes_inherit = false);
ConnectionFileDescriptor(int fd, bool owns_fd);
ConnectionFileDescriptor(Socket* socket);
- virtual ~ConnectionFileDescriptor();
+ ~ConnectionFileDescriptor() override;
bool IsConnected() const override;
@@ -84,6 +95,8 @@ class ConnectionFileDescriptor : public Connection
lldb::ConnectionStatus NamedSocketAccept(const char *socket_name, Error *error_ptr);
+ lldb::ConnectionStatus UnixAbstractSocketConnect(const char *socket_name, Error *error_ptr);
+
lldb::IOObjectSP m_read_sp;
lldb::IOObjectSP m_write_sp;
diff --git a/include/lldb/Host/posix/DomainSocket.h b/include/lldb/Host/posix/DomainSocket.h
new file mode 100644
index 000000000000..76f58e4f03b2
--- /dev/null
+++ b/include/lldb/Host/posix/DomainSocket.h
@@ -0,0 +1,37 @@
+//===-- DomainSocket.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_DomainSocket_h_
+#define liblldb_DomainSocket_h_
+
+#include "lldb/Host/Socket.h"
+
+namespace lldb_private
+{
+ class DomainSocket: public Socket
+ {
+ public:
+ DomainSocket(bool child_processes_inherit, Error &error);
+
+ Error Connect(llvm::StringRef name) override;
+ Error Listen(llvm::StringRef name, int backlog) override;
+ Error Accept(llvm::StringRef name, bool child_processes_inherit, Socket *&socket) override;
+
+ protected:
+ DomainSocket(SocketProtocol protocol, bool child_processes_inherit, Error &error);
+
+ virtual size_t GetNameOffset() const;
+ virtual void DeleteSocketFile(llvm::StringRef name);
+
+ private:
+ DomainSocket(NativeSocket socket);
+ };
+}
+
+#endif // ifndef liblldb_DomainSocket_h_
diff --git a/include/lldb/Host/posix/HostProcessPosix.h b/include/lldb/Host/posix/HostProcessPosix.h
index c9534991361b..5db49d17d757 100644
--- a/include/lldb/Host/posix/HostProcessPosix.h
+++ b/include/lldb/Host/posix/HostProcessPosix.h
@@ -10,6 +10,10 @@
#ifndef lldb_Host_HostProcesPosix_h_
#define lldb_Host_HostProcesPosix_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-types.h"
#include "lldb/Core/Error.h"
#include "lldb/Host/HostNativeProcessBase.h"
@@ -24,7 +28,7 @@ class HostProcessPosix : public HostNativeProcessBase
public:
HostProcessPosix();
HostProcessPosix(lldb::process_t process);
- virtual ~HostProcessPosix();
+ ~HostProcessPosix() override;
virtual Error Signal(int signo) const;
static Error Signal(lldb::process_t process, int signo);
@@ -37,6 +41,7 @@ class HostProcessPosix : public HostNativeProcessBase
HostThread StartMonitoring(HostProcess::MonitorCallback callback, void *callback_baton, bool monitor_signals) override;
};
-}
-#endif
+} // namespace lldb_private
+
+#endif // lldb_Host_HostProcesPosix_h_
diff --git a/include/lldb/Host/posix/HostThreadPosix.h b/include/lldb/Host/posix/HostThreadPosix.h
index 8839b8d4068b..e044313cd7dc 100644
--- a/include/lldb/Host/posix/HostThreadPosix.h
+++ b/include/lldb/Host/posix/HostThreadPosix.h
@@ -22,13 +22,14 @@ class HostThreadPosix : public HostNativeThreadBase
public:
HostThreadPosix();
HostThreadPosix(lldb::thread_t thread);
- virtual ~HostThreadPosix();
+ ~HostThreadPosix() override;
Error Join(lldb::thread_result_t *result) override;
Error Cancel() override;
Error Detach();
};
-}
-#endif
+} // namespace lldb_private
+
+#endif // lldb_Host_posix_HostThreadPosix_h_
diff --git a/include/lldb/Host/posix/LockFilePosix.h b/include/lldb/Host/posix/LockFilePosix.h
index 999397ec2bb5..628571c8dacd 100644
--- a/include/lldb/Host/posix/LockFilePosix.h
+++ b/include/lldb/Host/posix/LockFilePosix.h
@@ -18,7 +18,7 @@ class LockFilePosix : public LockFileBase
{
public:
explicit LockFilePosix (int fd);
- ~LockFilePosix ();
+ ~LockFilePosix () override;
protected:
Error
@@ -37,6 +37,6 @@ protected:
DoUnlock () override;
};
-} // namespace lldb_private
+} // namespace lldb_private
-#endif // liblldb_Host_posix_LockFilePosix_h_
+#endif // liblldb_Host_posix_LockFilePosix_h_
diff --git a/include/lldb/Host/posix/MainLoopPosix.h b/include/lldb/Host/posix/MainLoopPosix.h
index 9a665ded295e..225cebde4bce 100644
--- a/include/lldb/Host/posix/MainLoopPosix.h
+++ b/include/lldb/Host/posix/MainLoopPosix.h
@@ -60,7 +60,7 @@ public:
protected:
void
- UnregisterReadObject(const lldb::IOObjectSP &object_sp) override;
+ UnregisterReadObject(IOObject::WaitableHandle handle) override;
void
UnregisterSignal(int signo);
diff --git a/include/lldb/Initialization/SystemInitializerCommon.h b/include/lldb/Initialization/SystemInitializerCommon.h
index af66c93a5e48..b46bf506998b 100644
--- a/include/lldb/Initialization/SystemInitializerCommon.h
+++ b/include/lldb/Initialization/SystemInitializerCommon.h
@@ -28,11 +28,12 @@ class SystemInitializerCommon : public SystemInitializer
{
public:
SystemInitializerCommon();
- virtual ~SystemInitializerCommon();
+ ~SystemInitializerCommon() override;
void Initialize() override;
void Terminate() override;
};
-}
-#endif
+} // namespace lldb_private
+
+#endif // LLDB_INITIALIZATION_SYSTEM_INITIALIZER_COMMON_H
diff --git a/include/lldb/Interpreter/Args.h b/include/lldb/Interpreter/Args.h
index e11636b63f17..e79318ba5626 100644
--- a/include/lldb/Interpreter/Args.h
+++ b/include/lldb/Interpreter/Args.h
@@ -424,6 +424,9 @@ public:
static void
ExpandEscapedCharacters (const char *src, std::string &dst);
+ static std::string
+ EscapeLLDBCommandArgument (const std::string& arg, char quote_char);
+
// This one isn't really relevant to Arguments per se, but we're using the Args as a
// general strings container, so...
void
diff --git a/include/lldb/Interpreter/CommandCompletions.h b/include/lldb/Interpreter/CommandCompletions.h
index 9df3041584ea..27ab45b3fa1f 100644
--- a/include/lldb/Interpreter/CommandCompletions.h
+++ b/include/lldb/Interpreter/CommandCompletions.h
@@ -54,7 +54,6 @@ public:
// so you can add custom enums starting from here in your Option class.
// Also if you & in this bit the base code will not process the option.
eCustomCompletion = (1u << 9)
-
} CommonCompletionTypes;
struct CommonCompletionElement
@@ -83,6 +82,7 @@ public:
SearchFilter *searcher,
bool &word_complete,
StringList &matches);
+
static int
DiskDirectories (CommandInterpreter &interpreter,
const char *partial_file_name,
@@ -170,16 +170,16 @@ public:
int max_return_elements,
StringList &matches);
- virtual ~Completer ();
+ ~Completer() override;
- virtual CallbackReturn
- SearchCallback (SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool complete) = 0;
+ CallbackReturn
+ SearchCallback(SearchFilter &filter,
+ SymbolContext &context,
+ Address *addr,
+ bool complete) override = 0;
- virtual Depth
- GetDepth () = 0;
+ Depth
+ GetDepth() override = 0;
virtual size_t
DoCompletion (SearchFilter *filter) = 0;
@@ -190,8 +190,9 @@ public:
int m_match_start_point;
int m_max_return_elements;
StringList &m_matches;
+
private:
- DISALLOW_COPY_AND_ASSIGN (Completer);
+ DISALLOW_COPY_AND_ASSIGN(Completer);
};
//----------------------------------------------------------------------
@@ -200,7 +201,6 @@ public:
class SourceFileCompleter : public Completer
{
public:
-
SourceFileCompleter (CommandInterpreter &interpreter,
bool include_support_files,
const char *completion_str,
@@ -208,24 +208,24 @@ public:
int max_return_elements,
StringList &matches);
- virtual Searcher::Depth GetDepth ();
+ Searcher::Depth GetDepth() override;
- virtual Searcher::CallbackReturn
- SearchCallback (SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool complete);
+ Searcher::CallbackReturn
+ SearchCallback(SearchFilter &filter,
+ SymbolContext &context,
+ Address *addr,
+ bool complete) override;
size_t
- DoCompletion (SearchFilter *filter);
+ DoCompletion(SearchFilter *filter) override;
private:
bool m_include_support_files;
FileSpecList m_matching_files;
const char *m_file_name;
const char *m_dir_name;
- DISALLOW_COPY_AND_ASSIGN (SourceFileCompleter);
+ DISALLOW_COPY_AND_ASSIGN(SourceFileCompleter);
};
//----------------------------------------------------------------------
@@ -234,29 +234,28 @@ public:
class ModuleCompleter : public Completer
{
public:
-
ModuleCompleter (CommandInterpreter &interpreter,
const char *completion_str,
int match_start_point,
int max_return_elements,
StringList &matches);
- virtual Searcher::Depth GetDepth ();
+ Searcher::Depth GetDepth() override;
- virtual Searcher::CallbackReturn
- SearchCallback (SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool complete);
+ Searcher::CallbackReturn
+ SearchCallback(SearchFilter &filter,
+ SymbolContext &context,
+ Address *addr,
+ bool complete) override;
size_t
- DoCompletion (SearchFilter *filter);
+ DoCompletion(SearchFilter *filter) override;
private:
const char *m_file_name;
const char *m_dir_name;
- DISALLOW_COPY_AND_ASSIGN (ModuleCompleter);
+ DISALLOW_COPY_AND_ASSIGN(ModuleCompleter);
};
//----------------------------------------------------------------------
@@ -265,23 +264,22 @@ public:
class SymbolCompleter : public Completer
{
public:
-
SymbolCompleter (CommandInterpreter &interpreter,
const char *completion_str,
int match_start_point,
int max_return_elements,
StringList &matches);
- virtual Searcher::Depth GetDepth ();
+ Searcher::Depth GetDepth() override;
- virtual Searcher::CallbackReturn
- SearchCallback (SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool complete);
+ Searcher::CallbackReturn
+ SearchCallback(SearchFilter &filter,
+ SymbolContext &context,
+ Address *addr,
+ bool complete) override;
size_t
- DoCompletion (SearchFilter *filter);
+ DoCompletion(SearchFilter *filter) override;
private:
// struct NameCmp {
@@ -294,14 +292,14 @@ public:
RegularExpression m_regex;
typedef std::set<ConstString> collection;
collection m_match_set;
- DISALLOW_COPY_AND_ASSIGN (SymbolCompleter);
+ DISALLOW_COPY_AND_ASSIGN(SymbolCompleter);
};
private:
static CommonCompletionElement g_common_completions[];
-
};
} // namespace lldb_private
-#endif // lldb_CommandCompletions_h_
+
+#endif // lldb_CommandCompletions_h_
diff --git a/include/lldb/Interpreter/CommandHistory.h b/include/lldb/Interpreter/CommandHistory.h
index dbe6e99bb5b1..db5db15fc1e5 100644
--- a/include/lldb/Interpreter/CommandHistory.h
+++ b/include/lldb/Interpreter/CommandHistory.h
@@ -17,7 +17,6 @@
// Other libraries and framework includes
// Project includes
-
#include "lldb/lldb-private.h"
#include "lldb/Core/Stream.h"
#include "lldb/Host/Mutex.h"
diff --git a/include/lldb/Interpreter/CommandInterpreter.h b/include/lldb/Interpreter/CommandInterpreter.h
index 1962050dffcb..dd5c189d0ab9 100644
--- a/include/lldb/Interpreter/CommandInterpreter.h
+++ b/include/lldb/Interpreter/CommandInterpreter.h
@@ -14,6 +14,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/lldb-forward.h"
#include "lldb/lldb-private.h"
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Debugger.h"
@@ -199,8 +200,6 @@ class CommandInterpreter :
public IOHandlerDelegate
{
public:
-
-
typedef std::map<std::string, OptionArgVectorSP> OptionArgMap;
enum
@@ -228,11 +227,17 @@ public:
eCommandTypesAllThem = 0xFFFF // all commands
};
+ CommandInterpreter(Debugger &debugger,
+ lldb::ScriptLanguage script_language,
+ bool synchronous_execution);
+
+ ~CommandInterpreter() override;
+
// These two functions fill out the Broadcaster interface:
static ConstString &GetStaticBroadcasterClass ();
- virtual ConstString &GetBroadcasterClass() const
+ ConstString &GetBroadcasterClass() const override
{
return GetStaticBroadcasterClass();
}
@@ -241,13 +246,6 @@ public:
SourceInitFile (bool in_cwd,
CommandReturnObject &result);
- CommandInterpreter (Debugger &debugger,
- lldb::ScriptLanguage script_language,
- bool synchronous_execution);
-
- virtual
- ~CommandInterpreter ();
-
bool
AddCommand (const char *name,
const lldb::CommandObjectSP &cmd_sp,
@@ -267,8 +265,8 @@ public:
bool include_aliases);
CommandObject *
- GetCommandObject (const char *cmd,
- StringList *matches = NULL);
+ GetCommandObject(const char *cmd,
+ StringList *matches = nullptr);
bool
CommandExists (const char *cmd);
@@ -305,7 +303,6 @@ public:
OptionArgVectorSP
GetAliasOptions (const char *alias_name);
-
bool
ProcessAliasOptionsArgs (lldb::CommandObjectSP &cmd_obj_sp,
const char *options_args,
@@ -325,20 +322,20 @@ public:
CommandReturnObject &result);
bool
- HandleCommand (const char *command_line,
- LazyBool add_to_history,
- CommandReturnObject &result,
- ExecutionContext *override_context = NULL,
- bool repeat_on_empty_command = true,
- bool no_context_switching = false);
+ HandleCommand(const char *command_line,
+ LazyBool add_to_history,
+ CommandReturnObject &result,
+ ExecutionContext *override_context = nullptr,
+ bool repeat_on_empty_command = true,
+ bool no_context_switching = false);
//------------------------------------------------------------------
/// Execute a list of commands in sequence.
///
/// @param[in] commands
/// The list of commands to execute.
- /// @param[in/out] context
- /// The execution context in which to run the commands. Can be NULL in which case the default
+ /// @param[in,out] context
+ /// The execution context in which to run the commands. Can be nullptr in which case the default
/// context will be used.
/// @param[in] options
/// This object holds the options used to control when to stop, whether to execute commands,
@@ -358,8 +355,8 @@ public:
///
/// @param[in] file
/// The file from which to read in commands.
- /// @param[in/out] context
- /// The execution context in which to run the commands. Can be NULL in which case the default
+ /// @param[in,out] context
+ /// The execution context in which to run the commands. Can be nullptr in which case the default
/// context will be used.
/// @param[in] options
/// This object holds the options used to control when to stop, whether to execute commands,
@@ -393,7 +390,6 @@ public:
// Otherwise, returns the number of matches.
//
// FIXME: Only max_return_elements == -1 is supported at present.
-
int
HandleCompletion (const char *current_line,
const char *cursor,
@@ -406,7 +402,6 @@ public:
// Help command can call it for the first argument.
// word_complete tells whether the completions are considered a "complete" response (so the
// completer should complete the quote & put a space after the word.
-
int
HandleCompletionMatches (Args &input,
int &cursor_index,
@@ -416,7 +411,6 @@ public:
bool &word_complete,
StringList &matches);
-
int
GetCommandNamesMatchingPartialString (const char *cmd_cstr,
bool include_aliases,
@@ -496,7 +490,6 @@ public:
void
SetScriptLanguage (lldb::ScriptLanguage lang);
-
bool
HasCommands ();
@@ -520,7 +513,10 @@ public:
GetOptionArgumentPosition (const char *in_string);
ScriptInterpreter *
- GetScriptInterpreter (bool can_create = true);
+ GetScriptInterpreter(bool can_create = true);
+
+ void
+ SetScriptInterpreter();
void
SkipLLDBInitFiles (bool skip_lldbinit_files)
@@ -647,7 +643,7 @@ public:
}
lldb::IOHandlerSP
- GetIOHandler(bool force_create = false, CommandInterpreterRunOptions *options = NULL);
+ GetIOHandler(bool force_create = false, CommandInterpreterRunOptions *options = nullptr);
bool
GetStoppedForCrash () const
@@ -655,26 +651,29 @@ public:
return m_stopped_for_crash;
}
+ bool
+ GetSpaceReplPrompts () const;
+
protected:
friend class Debugger;
//------------------------------------------------------------------
// IOHandlerDelegate functions
//------------------------------------------------------------------
- virtual void
- IOHandlerInputComplete (IOHandler &io_handler,
- std::string &line);
+ void
+ IOHandlerInputComplete(IOHandler &io_handler,
+ std::string &line) override;
- virtual ConstString
- IOHandlerGetControlSequence (char ch)
+ ConstString
+ IOHandlerGetControlSequence(char ch) override
{
if (ch == 'd')
return ConstString("quit\n");
return ConstString();
}
- virtual bool
- IOHandlerInterrupt (IOHandler &io_handler);
+ bool
+ IOHandlerInterrupt(IOHandler &io_handler) override;
size_t
GetProcessOutput ();
@@ -683,11 +682,9 @@ protected:
SetSynchronous (bool value);
lldb::CommandObjectSP
- GetCommandSP (const char *cmd, bool include_aliases = true, bool exact = true, StringList *matches = NULL);
-
+ GetCommandSP(const char *cmd, bool include_aliases = true, bool exact = true, StringList *matches = nullptr);
private:
-
Error
PreprocessCommand (std::string &command);
@@ -697,7 +694,6 @@ private:
CommandObject *
ResolveCommandImpl(std::string &command_line, CommandReturnObject &result);
-
Debugger &m_debugger; // The debugger session that this interpreter is associated with
ExecutionContextRef m_exe_ctx_ref; // The current execution context to use when handling commands
bool m_synchronous_execution;
@@ -709,7 +705,7 @@ private:
OptionArgMap m_alias_options; // Stores any options (with or without arguments) that go with any alias.
CommandHistory m_command_history;
std::string m_repeat_command; // Stores the command that will be executed for an empty command string.
- std::unique_ptr<ScriptInterpreter> m_script_interpreter_ap;
+ lldb::ScriptInterpreterSP m_script_interpreter_sp;
lldb::IOHandlerSP m_command_io_handler_sp;
char m_comment_char;
bool m_batch_command_mode;
@@ -719,10 +715,8 @@ private:
uint32_t m_num_errors;
bool m_quit_requested;
bool m_stopped_for_crash;
-
};
-
} // namespace lldb_private
-#endif // liblldb_CommandInterpreter_h_
+#endif // liblldb_CommandInterpreter_h_
diff --git a/include/lldb/Interpreter/CommandObject.h b/include/lldb/Interpreter/CommandObject.h
index 023de29c7b6c..8015fec41cd2 100644
--- a/include/lldb/Interpreter/CommandObject.h
+++ b/include/lldb/Interpreter/CommandObject.h
@@ -10,11 +10,14 @@
#ifndef liblldb_CommandObject_h_
#define liblldb_CommandObject_h_
+// C Includes
+// C++ Includes
#include <map>
-#include <set>
#include <string>
#include <vector>
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandCompletions.h"
@@ -28,7 +31,6 @@ namespace lldb_private {
class CommandObject
{
public:
-
typedef const char *(ArgumentHelpCallbackFunction) ();
struct ArgumentHelpCallback
@@ -44,9 +46,8 @@ public:
explicit operator bool() const
{
- return (help_callback != NULL);
+ return (help_callback != nullptr);
}
-
};
struct ArgumentTableEntry // Entries in the main argument information table
@@ -76,16 +77,15 @@ public:
typedef std::map<std::string, lldb::CommandObjectSP> CommandMap;
- CommandObject (CommandInterpreter &interpreter,
- const char *name,
- const char *help = NULL,
- const char *syntax = NULL,
- uint32_t flags = 0);
+ CommandObject(CommandInterpreter &interpreter,
+ const char *name,
+ const char *help = nullptr,
+ const char *syntax = nullptr,
+ uint32_t flags = 0);
virtual
~CommandObject ();
-
static const char *
GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type);
@@ -141,15 +141,15 @@ public:
IsMultiwordObject () { return false; }
virtual lldb::CommandObjectSP
- GetSubcommandSP (const char *sub_cmd, StringList *matches = NULL)
+ GetSubcommandSP(const char *sub_cmd, StringList *matches = nullptr)
{
return lldb::CommandObjectSP();
}
virtual CommandObject *
- GetSubcommandObject (const char *sub_cmd, StringList *matches = NULL)
+ GetSubcommandObject(const char *sub_cmd, StringList *matches = nullptr)
{
- return NULL;
+ return nullptr;
}
virtual void
@@ -326,7 +326,6 @@ public:
/// @return
/// The number of completions.
//------------------------------------------------------------------
-
virtual int
HandleArgumentCompletion (Args &input,
int &cursor_index,
@@ -374,13 +373,13 @@ public:
/// The complete current command line.
///
/// @return
- /// NULL if there is no special repeat command - it will use the current command line.
+ /// 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 NULL;
+ return nullptr;
}
bool
@@ -488,62 +487,61 @@ protected:
// to the specified command argument entry.
static void
AddIDsArgumentData(CommandArgumentEntry &arg, lldb::CommandArgumentType ID, lldb::CommandArgumentType IDRange);
-
};
class CommandObjectParsed : public CommandObject
{
public:
-
- CommandObjectParsed (CommandInterpreter &interpreter,
- const char *name,
- const char *help = NULL,
- const char *syntax = NULL,
- uint32_t flags = 0) :
+ CommandObjectParsed(CommandInterpreter &interpreter,
+ const char *name,
+ const char *help = nullptr,
+ const char *syntax = nullptr,
+ uint32_t flags = 0) :
CommandObject (interpreter, name, help, syntax, flags) {}
- virtual
- ~CommandObjectParsed () {};
+ ~CommandObjectParsed() override = default;
- virtual bool
- Execute (const char *args_string, CommandReturnObject &result);
+ bool
+ Execute(const char *args_string, CommandReturnObject &result) override;
protected:
virtual bool
DoExecute (Args& command,
CommandReturnObject &result) = 0;
- virtual bool
- WantsRawCommandString() { return false; };
+ bool
+ WantsRawCommandString() override
+ {
+ return false;
+ }
};
class CommandObjectRaw : public CommandObject
{
public:
-
- CommandObjectRaw (CommandInterpreter &interpreter,
- const char *name,
- const char *help = NULL,
- const char *syntax = NULL,
- uint32_t flags = 0) :
+ CommandObjectRaw(CommandInterpreter &interpreter,
+ const char *name,
+ const char *help = nullptr,
+ const char *syntax = nullptr,
+ uint32_t flags = 0) :
CommandObject (interpreter, name, help, syntax, flags) {}
- virtual
- ~CommandObjectRaw () {};
+ ~CommandObjectRaw() override = default;
- virtual bool
- Execute (const char *args_string, CommandReturnObject &result);
+ bool
+ Execute(const char *args_string, CommandReturnObject &result) override;
protected:
virtual bool
DoExecute (const char *command, CommandReturnObject &result) = 0;
- virtual bool
- WantsRawCommandString() { return true; };
+ bool
+ WantsRawCommandString() override
+ {
+ return true;
+ }
};
-
} // namespace lldb_private
-
-#endif // liblldb_CommandObject_h_
+#endif // liblldb_CommandObject_h_
diff --git a/include/lldb/Interpreter/CommandObjectMultiword.h b/include/lldb/Interpreter/CommandObjectMultiword.h
index 491d43c4bd9d..e1ad2940c383 100644
--- a/include/lldb/Interpreter/CommandObjectMultiword.h
+++ b/include/lldb/Interpreter/CommandObjectMultiword.h
@@ -12,8 +12,6 @@
// C Includes
// C++ Includes
-#include <map>
-
// Other libraries and framework includes
// Project includes
#include "lldb/Interpreter/CommandObject.h"
@@ -30,57 +28,66 @@ class CommandObjectMultiword : public CommandObject
friend class CommandInterpreter;
friend class CommandObjectSyntax;
public:
- CommandObjectMultiword (CommandInterpreter &interpreter,
- const char *name,
- const char *help = NULL,
- const char *syntax = NULL,
- uint32_t flags = 0);
+ CommandObjectMultiword(CommandInterpreter &interpreter,
+ const char *name,
+ const char *help = nullptr,
+ const char *syntax = nullptr,
+ uint32_t flags = 0);
- virtual
- ~CommandObjectMultiword ();
+ ~CommandObjectMultiword() override;
- virtual bool
- IsMultiwordObject () { return true; }
+ bool
+ IsMultiwordObject() override
+ {
+ return true;
+ }
- virtual bool
- LoadSubCommand (const char *cmd_name,
- const lldb::CommandObjectSP& command_obj);
+ bool
+ LoadSubCommand(const char *cmd_name,
+ const lldb::CommandObjectSP& command_obj) override;
- virtual void
- GenerateHelpText (Stream &output_stream);
+ void
+ GenerateHelpText(Stream &output_stream) override;
- virtual lldb::CommandObjectSP
- GetSubcommandSP (const char *sub_cmd, StringList *matches = NULL);
+ lldb::CommandObjectSP
+ GetSubcommandSP(const char *sub_cmd, StringList *matches = nullptr) override;
- virtual CommandObject *
- GetSubcommandObject (const char *sub_cmd, StringList *matches = NULL);
-
- virtual void
- AproposAllSubCommands (const char *prefix,
- const char *search_word,
- StringList &commands_found,
- StringList &commands_help);
-
- virtual bool
- WantsRawCommandString() { return false; };
-
- virtual int
- HandleCompletion (Args &input,
- int &cursor_index,
- int &cursor_char_position,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches);
-
- virtual const char *GetRepeatCommand (Args &current_command_args, uint32_t index);
-
- virtual bool
- Execute (const char *args_string,
- CommandReturnObject &result);
+ CommandObject *
+ GetSubcommandObject(const char *sub_cmd, StringList *matches = nullptr) override;
+
+ void
+ AproposAllSubCommands(const char *prefix,
+ const char *search_word,
+ StringList &commands_found,
+ StringList &commands_help) override;
+
+ bool
+ WantsRawCommandString() override
+ {
+ return false;
+ }
+
+ int
+ HandleCompletion(Args &input,
+ int &cursor_index,
+ int &cursor_char_position,
+ int match_start_point,
+ int max_return_elements,
+ bool &word_complete,
+ StringList &matches) override;
+
+ const char *
+ GetRepeatCommand (Args &current_command_args, uint32_t index) override;
+
+ bool
+ Execute(const char *args_string,
+ CommandReturnObject &result) override;
- virtual bool
- IsRemovable() const { return m_can_be_removed; }
+ bool
+ IsRemovable() const override
+ {
+ return m_can_be_removed;
+ }
void
SetRemovable (bool removable)
@@ -93,95 +100,93 @@ protected:
CommandObject::CommandMap m_subcommand_dict;
bool m_can_be_removed;
};
-
class CommandObjectProxy : public CommandObject
{
public:
- CommandObjectProxy (CommandInterpreter &interpreter,
- const char *name,
- const char *help = NULL,
- const char *syntax = NULL,
- uint32_t flags = 0);
+ CommandObjectProxy(CommandInterpreter &interpreter,
+ const char *name,
+ const char *help = nullptr,
+ const char *syntax = nullptr,
+ uint32_t flags = 0);
- virtual
- ~CommandObjectProxy ();
+ ~CommandObjectProxy() override;
// Subclasses must provide a command object that will be transparently
// used for this object.
virtual CommandObject *
GetProxyCommandObject() = 0;
- virtual const char *
- GetHelpLong ();
+ const char *
+ GetHelpLong() override;
- virtual bool
- IsRemovable() const;
+ bool
+ IsRemovable() const override;
- virtual bool
- IsMultiwordObject ();
-
- virtual lldb::CommandObjectSP
- GetSubcommandSP (const char *sub_cmd, StringList *matches = NULL);
-
- virtual CommandObject *
- GetSubcommandObject (const char *sub_cmd, StringList *matches = NULL);
+ bool
+ IsMultiwordObject() override;
- virtual void
- AproposAllSubCommands (const char *prefix,
- const char *search_word,
- StringList &commands_found,
- StringList &commands_help);
-
- virtual bool
- LoadSubCommand (const char *cmd_name,
- const lldb::CommandObjectSP& command_obj);
-
- virtual bool
- WantsRawCommandString();
+ void
+ GenerateHelpText (Stream &result) override;
- virtual bool
- WantsCompletion();
+ lldb::CommandObjectSP
+ GetSubcommandSP(const char *sub_cmd, StringList *matches = nullptr) override;
- virtual Options *
- GetOptions ();
+ CommandObject *
+ GetSubcommandObject(const char *sub_cmd, StringList *matches = nullptr) override;
-
- virtual int
- HandleCompletion (Args &input,
- int &cursor_index,
- int &cursor_char_position,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches);
-
- virtual int
- HandleArgumentCompletion (Args &input,
- int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches);
-
- virtual const char *
- GetRepeatCommand (Args &current_command_args,
- uint32_t index);
-
- virtual bool
- Execute (const char *args_string,
- CommandReturnObject &result);
+ void
+ AproposAllSubCommands(const char *prefix,
+ const char *search_word,
+ StringList &commands_found,
+ StringList &commands_help) override;
+
+ bool
+ LoadSubCommand(const char *cmd_name,
+ const lldb::CommandObjectSP& command_obj) override;
+
+ bool
+ WantsRawCommandString() override;
+
+ bool
+ WantsCompletion() override;
+
+ Options *
+ GetOptions() override;
+
+ int
+ HandleCompletion(Args &input,
+ int &cursor_index,
+ int &cursor_char_position,
+ int match_start_point,
+ int max_return_elements,
+ bool &word_complete,
+ StringList &matches) override;
+
+ int
+ HandleArgumentCompletion(Args &input,
+ int &cursor_index,
+ int &cursor_char_position,
+ OptionElementVector &opt_element_vector,
+ int match_start_point,
+ int max_return_elements,
+ bool &word_complete,
+ StringList &matches) override;
+
+ const char *
+ GetRepeatCommand(Args &current_command_args,
+ uint32_t index) override;
+
+ bool
+ Execute(const char *args_string,
+ CommandReturnObject &result) override;
protected:
-
// These two want to iterate over the subcommand dictionary.
friend class CommandInterpreter;
friend class CommandObjectSyntax;
-
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectMultiword_h_
+#endif // liblldb_CommandObjectMultiword_h_
diff --git a/include/lldb/Interpreter/CommandObjectRegexCommand.h b/include/lldb/Interpreter/CommandObjectRegexCommand.h
index d86544638776..9f8974a32bb2 100644
--- a/include/lldb/Interpreter/CommandObjectRegexCommand.h
+++ b/include/lldb/Interpreter/CommandObjectRegexCommand.h
@@ -28,7 +28,6 @@ namespace lldb_private {
class CommandObjectRegexCommand : public CommandObjectRaw
{
public:
-
CommandObjectRegexCommand (CommandInterpreter &interpreter,
const char *name,
const char *help,
@@ -37,8 +36,7 @@ public:
uint32_t completion_type_mask,
bool is_removable);
- virtual
- ~CommandObjectRegexCommand ();
+ ~CommandObjectRegexCommand() override;
bool
IsRemovable () const override { return m_is_removable; }
@@ -83,4 +81,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_CommandObjectRegexCommand_h_
+#endif // liblldb_CommandObjectRegexCommand_h_
diff --git a/include/lldb/Interpreter/CommandOptionValidators.h b/include/lldb/Interpreter/CommandOptionValidators.h
index 6be247ad4b65..395cb8ed3d9e 100644
--- a/include/lldb/Interpreter/CommandOptionValidators.h
+++ b/include/lldb/Interpreter/CommandOptionValidators.h
@@ -10,6 +10,10 @@
#ifndef liblldb_CommandOptionValidators_h_
#define liblldb_CommandOptionValidators_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private-types.h"
namespace lldb_private {
@@ -19,12 +23,11 @@ class ExecutionContext;
class PosixPlatformCommandOptionValidator : public OptionValidator
{
- virtual bool IsValid(Platform &platform, const ExecutionContext &target) const;
- virtual const char* ShortConditionString() const;
- virtual const char* LongConditionString() const;
+ bool IsValid(Platform &platform, const ExecutionContext &target) const override;
+ const char* ShortConditionString() const override;
+ const char* LongConditionString() const override;
};
} // namespace lldb_private
-
-#endif // liblldb_CommandOptionValidators_h_
+#endif // liblldb_CommandOptionValidators_h_
diff --git a/include/lldb/Interpreter/CommandReturnObject.h b/include/lldb/Interpreter/CommandReturnObject.h
index b922e1731d7e..424ac800d14c 100644
--- a/include/lldb/Interpreter/CommandReturnObject.h
+++ b/include/lldb/Interpreter/CommandReturnObject.h
@@ -22,11 +22,9 @@
namespace lldb_private {
-
class CommandReturnObject
{
public:
-
CommandReturnObject ();
~CommandReturnObject ();
@@ -142,8 +140,8 @@ public:
AppendErrorWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
void
- SetError (const Error &error,
- const char *fallback_error_cstr = NULL);
+ SetError(const Error &error,
+ const char *fallback_error_cstr = nullptr);
void
SetError (const char *error_cstr);
@@ -189,4 +187,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_CommandReturnObject_h_
+#endif // liblldb_CommandReturnObject_h_
diff --git a/include/lldb/Interpreter/OptionGroupArchitecture.h b/include/lldb/Interpreter/OptionGroupArchitecture.h
index 7cd1ca3d710d..5ee608506c04 100644
--- a/include/lldb/Interpreter/OptionGroupArchitecture.h
+++ b/include/lldb/Interpreter/OptionGroupArchitecture.h
@@ -26,26 +26,23 @@ namespace lldb_private {
class OptionGroupArchitecture : public OptionGroup
{
public:
-
OptionGroupArchitecture ();
- virtual
- ~OptionGroupArchitecture ();
+ ~OptionGroupArchitecture() override;
+ uint32_t
+ GetNumDefinitions() override;
- virtual uint32_t
- GetNumDefinitions ();
-
- virtual const OptionDefinition*
- GetDefinitions ();
+ const OptionDefinition*
+ GetDefinitions() override;
- virtual Error
- SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value);
+ Error
+ SetOptionValue(CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_value) override;
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter);
+ void
+ OptionParsingStarting(CommandInterpreter &interpreter) override;
bool
GetArchitecture (Platform *platform, ArchSpec &arch);
@@ -55,19 +52,17 @@ public:
{
return !m_arch_str.empty();
}
+
const char *
- GetArchitectureName ()
+ GetArchitectureName()
{
- if (m_arch_str.empty())
- return NULL;
- return m_arch_str.c_str();
+ return (m_arch_str.empty() ? nullptr : m_arch_str.c_str());
}
protected:
-
std::string m_arch_str; // Save the arch triple in case a platform is specified after the architecture
};
} // namespace lldb_private
-#endif // liblldb_OptionGroupArchitecture_h_
+#endif // liblldb_OptionGroupArchitecture_h_
diff --git a/include/lldb/Interpreter/OptionGroupBoolean.h b/include/lldb/Interpreter/OptionGroupBoolean.h
index 0d861b241694..881a1bdf4be6 100644
--- a/include/lldb/Interpreter/OptionGroupBoolean.h
+++ b/include/lldb/Interpreter/OptionGroupBoolean.h
@@ -36,29 +36,27 @@ namespace lldb_private {
bool default_value,
bool no_argument_toggle_default);
- virtual
- ~OptionGroupBoolean ();
-
-
- virtual uint32_t
- GetNumDefinitions ()
+ ~OptionGroupBoolean() override;
+
+ uint32_t
+ GetNumDefinitions() override
{
return 1;
}
- virtual const OptionDefinition*
- GetDefinitions ()
+ const OptionDefinition*
+ GetDefinitions() override
{
return &m_option_definition;
}
- virtual Error
- SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value);
+ Error
+ SetOptionValue(CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_value) override;
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter);
+ void
+ OptionParsingStarting(CommandInterpreter &interpreter) override;
OptionValueBoolean &
GetOptionValue ()
@@ -75,9 +73,8 @@ namespace lldb_private {
protected:
OptionValueBoolean m_value;
OptionDefinition m_option_definition;
-
};
} // namespace lldb_private
-#endif // liblldb_OptionGroupBoolean_h_
+#endif // liblldb_OptionGroupBoolean_h_
diff --git a/include/lldb/Interpreter/OptionGroupFile.h b/include/lldb/Interpreter/OptionGroupFile.h
index 632a2dbdf220..9e35dd43ab7a 100644
--- a/include/lldb/Interpreter/OptionGroupFile.h
+++ b/include/lldb/Interpreter/OptionGroupFile.h
@@ -1,4 +1,4 @@
-//===-- OptionGroupFile.h -------------------------------*- C++ -*-===//
+//===-- OptionGroupFile.h ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -27,7 +27,6 @@ namespace lldb_private {
class OptionGroupFile : public OptionGroup
{
public:
-
OptionGroupFile (uint32_t usage_mask,
bool required,
const char *long_option,
@@ -36,29 +35,27 @@ public:
lldb::CommandArgumentType argument_type,
const char *usage_text);
- virtual
- ~OptionGroupFile ();
+ ~OptionGroupFile() override;
-
- virtual uint32_t
- GetNumDefinitions ()
+ uint32_t
+ GetNumDefinitions() override
{
return 1;
}
- virtual const OptionDefinition*
- GetDefinitions ()
+ const OptionDefinition*
+ GetDefinitions() override
{
return &m_option_definition;
}
- virtual Error
- SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value);
+ Error
+ SetOptionValue(CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_value) override;
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter);
+ void
+ OptionParsingStarting(CommandInterpreter &interpreter) override;
OptionValueFileSpec &
GetOptionValue ()
@@ -75,7 +72,6 @@ public:
protected:
OptionValueFileSpec m_file;
OptionDefinition m_option_definition;
-
};
//-------------------------------------------------------------------------
@@ -94,30 +90,27 @@ public:
lldb::CommandArgumentType argument_type,
const char *usage_text);
- virtual
- ~OptionGroupFileList ();
+ ~OptionGroupFileList() override;
-
- virtual uint32_t
- GetNumDefinitions ()
+ uint32_t
+ GetNumDefinitions() override
{
return 1;
}
- virtual const OptionDefinition*
- GetDefinitions ()
+ const OptionDefinition*
+ GetDefinitions() override
{
return &m_option_definition;
}
- virtual Error
- SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value);
-
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter);
+ Error
+ SetOptionValue(CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_value) override;
+ void
+ OptionParsingStarting(CommandInterpreter &interpreter) override;
OptionValueFileSpecList &
GetOptionValue ()
@@ -134,9 +127,8 @@ public:
protected:
OptionValueFileSpecList m_file_list;
OptionDefinition m_option_definition;
-
};
} // namespace lldb_private
-#endif // liblldb_OptionGroupFile_h_
+#endif // liblldb_OptionGroupFile_h_
diff --git a/include/lldb/Interpreter/OptionGroupFormat.h b/include/lldb/Interpreter/OptionGroupFormat.h
index 7419b0496668..9a96cc505de4 100644
--- a/include/lldb/Interpreter/OptionGroupFormat.h
+++ b/include/lldb/Interpreter/OptionGroupFormat.h
@@ -1,4 +1,4 @@
-//===-- OptionGroupFormat.h -------------------------------*- C++ -*-===//
+//===-- OptionGroupFormat.h -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -37,23 +37,21 @@ public:
uint64_t default_byte_size = UINT64_MAX, // Pass UINT64_MAX to disable the "--size" option
uint64_t default_count = UINT64_MAX); // Pass UINT64_MAX to disable the "--count" option
- virtual
- ~OptionGroupFormat ();
+ ~OptionGroupFormat() override;
+ uint32_t
+ GetNumDefinitions() override;
- virtual uint32_t
- GetNumDefinitions ();
+ const OptionDefinition*
+ GetDefinitions() override;
- virtual const OptionDefinition*
- GetDefinitions ();
+ Error
+ SetOptionValue(CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_value) override;
- virtual Error
- SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value);
-
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter);
+ void
+ OptionParsingStarting(CommandInterpreter &interpreter) override;
lldb::Format
GetFormat () const
@@ -112,7 +110,6 @@ public:
}
protected:
-
bool
ParserGDBFormatLetter (CommandInterpreter &interpreter,
char format_letter,
@@ -124,10 +121,9 @@ protected:
OptionValueUInt64 m_count;
char m_prev_gdb_format;
char m_prev_gdb_size;
-
bool m_has_gdb_format;
};
} // namespace lldb_private
-#endif // liblldb_OptionGroupFormat_h_
+#endif // liblldb_OptionGroupFormat_h_
diff --git a/include/lldb/Interpreter/OptionGroupOutputFile.h b/include/lldb/Interpreter/OptionGroupOutputFile.h
index 533cd6ee8eb3..e6083714c48d 100644
--- a/include/lldb/Interpreter/OptionGroupOutputFile.h
+++ b/include/lldb/Interpreter/OptionGroupOutputFile.h
@@ -1,4 +1,4 @@
-//===-- OptionGroupOutputFile.h -------------------------------*- C++ -*-===//
+//===-- OptionGroupOutputFile.h ---------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -26,26 +26,23 @@ namespace lldb_private {
class OptionGroupOutputFile : public OptionGroup
{
public:
-
OptionGroupOutputFile ();
- virtual
- ~OptionGroupOutputFile ();
+ ~OptionGroupOutputFile() override;
+ uint32_t
+ GetNumDefinitions() override;
- virtual uint32_t
- GetNumDefinitions ();
-
- virtual const OptionDefinition*
- GetDefinitions ();
+ const OptionDefinition*
+ GetDefinitions() override;
- virtual Error
- SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value);
+ Error
+ SetOptionValue(CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_value) override;
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter);
+ void
+ OptionParsingStarting(CommandInterpreter &interpreter) override;
const OptionValueFileSpec &
GetFile ()
@@ -68,9 +65,8 @@ public:
protected:
OptionValueFileSpec m_file;
OptionValueBoolean m_append;
-
};
} // namespace lldb_private
-#endif // liblldb_OptionGroupOutputFile_h_
+#endif // liblldb_OptionGroupOutputFile_h_
diff --git a/include/lldb/Interpreter/OptionGroupPlatform.h b/include/lldb/Interpreter/OptionGroupPlatform.h
index f7de50c86a56..68880236accc 100644
--- a/include/lldb/Interpreter/OptionGroupPlatform.h
+++ b/include/lldb/Interpreter/OptionGroupPlatform.h
@@ -27,7 +27,6 @@ namespace lldb_private {
class OptionGroupPlatform : public OptionGroup
{
public:
-
OptionGroupPlatform (bool include_platform_option) :
OptionGroup(),
m_platform_name (),
@@ -39,24 +38,21 @@ public:
{
}
- virtual
- ~OptionGroupPlatform ()
- {
- }
+ ~OptionGroupPlatform() override = default;
- virtual uint32_t
- GetNumDefinitions ();
+ uint32_t
+ GetNumDefinitions() override;
- virtual const OptionDefinition*
- GetDefinitions ();
+ const OptionDefinition*
+ GetDefinitions() override;
- virtual Error
- SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value);
+ Error
+ SetOptionValue(CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_value) override;
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter);
+ void
+ OptionParsingStarting(CommandInterpreter &interpreter) override;
lldb::PlatformSP
CreatePlatformWithOptions (CommandInterpreter &interpreter,
@@ -119,4 +115,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionGroupPlatform_h_
+#endif // liblldb_OptionGroupPlatform_h_
diff --git a/include/lldb/Interpreter/OptionGroupString.h b/include/lldb/Interpreter/OptionGroupString.h
index e62a81bc4118..6f46bdb79408 100644
--- a/include/lldb/Interpreter/OptionGroupString.h
+++ b/include/lldb/Interpreter/OptionGroupString.h
@@ -1,4 +1,4 @@
-//===-- OptionGroupString.h ------------------------------------*- C++ -*-===//
+//===-- OptionGroupString.h -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -25,7 +25,6 @@ namespace lldb_private {
class OptionGroupString : public OptionGroup
{
public:
-
OptionGroupString (uint32_t usage_mask,
bool required,
const char *long_option,
@@ -35,29 +34,27 @@ namespace lldb_private {
const char *usage_text,
const char *default_value);
- virtual
- ~OptionGroupString ();
-
-
- virtual uint32_t
- GetNumDefinitions ()
+ ~OptionGroupString() override;
+
+ uint32_t
+ GetNumDefinitions() override
{
return 1;
}
- virtual const OptionDefinition*
- GetDefinitions ()
+ const OptionDefinition*
+ GetDefinitions() override
{
return &m_option_definition;
}
- virtual Error
- SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value);
+ Error
+ SetOptionValue(CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_value) override;
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter);
+ void
+ OptionParsingStarting(CommandInterpreter &interpreter) override;
OptionValueString &
GetOptionValue ()
@@ -74,9 +71,8 @@ namespace lldb_private {
protected:
OptionValueString m_value;
OptionDefinition m_option_definition;
-
};
} // namespace lldb_private
-#endif // liblldb_OptionGroupString_h_
+#endif // liblldb_OptionGroupString_h_
diff --git a/include/lldb/Interpreter/OptionGroupUInt64.h b/include/lldb/Interpreter/OptionGroupUInt64.h
index c5f9e85d2f8f..b03c1ff889a1 100644
--- a/include/lldb/Interpreter/OptionGroupUInt64.h
+++ b/include/lldb/Interpreter/OptionGroupUInt64.h
@@ -1,4 +1,4 @@
-//===-- OptionGroupUInt64.h ------------------------------------*- C++ -*-===//
+//===-- OptionGroupUInt64.h -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -18,6 +18,7 @@
#include "lldb/Interpreter/OptionValueUInt64.h"
namespace lldb_private {
+
//-------------------------------------------------------------------------
// OptionGroupUInt64
//-------------------------------------------------------------------------
@@ -25,7 +26,6 @@ namespace lldb_private {
class OptionGroupUInt64 : public OptionGroup
{
public:
-
OptionGroupUInt64 (uint32_t usage_mask,
bool required,
const char *long_option,
@@ -35,29 +35,27 @@ namespace lldb_private {
const char *usage_text,
uint64_t default_value);
- virtual
- ~OptionGroupUInt64 ();
-
-
- virtual uint32_t
- GetNumDefinitions ()
+ ~OptionGroupUInt64() override;
+
+ uint32_t
+ GetNumDefinitions() override
{
return 1;
}
- virtual const OptionDefinition*
- GetDefinitions ()
+ const OptionDefinition*
+ GetDefinitions() override
{
return &m_option_definition;
}
- virtual Error
- SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value);
+ Error
+ SetOptionValue(CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_value) override;
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter);
+ void
+ OptionParsingStarting(CommandInterpreter &interpreter) override;
OptionValueUInt64 &
GetOptionValue ()
@@ -74,9 +72,8 @@ namespace lldb_private {
protected:
OptionValueUInt64 m_value;
OptionDefinition m_option_definition;
-
};
} // namespace lldb_private
-#endif // liblldb_OptionGroupUInt64_h_
+#endif // liblldb_OptionGroupUInt64_h_
diff --git a/include/lldb/Interpreter/OptionGroupUUID.h b/include/lldb/Interpreter/OptionGroupUUID.h
index ea968d737969..6495699dce75 100644
--- a/include/lldb/Interpreter/OptionGroupUUID.h
+++ b/include/lldb/Interpreter/OptionGroupUUID.h
@@ -18,6 +18,7 @@
#include "lldb/Interpreter/OptionValueUUID.h"
namespace lldb_private {
+
//-------------------------------------------------------------------------
// OptionGroupUUID
//-------------------------------------------------------------------------
@@ -25,26 +26,23 @@ namespace lldb_private {
class OptionGroupUUID : public OptionGroup
{
public:
-
OptionGroupUUID ();
- virtual
- ~OptionGroupUUID ();
+ ~OptionGroupUUID() override;
+ uint32_t
+ GetNumDefinitions() override;
- virtual uint32_t
- GetNumDefinitions ();
-
- virtual const OptionDefinition*
- GetDefinitions ();
+ const OptionDefinition*
+ GetDefinitions() override;
- virtual Error
- SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value);
+ Error
+ SetOptionValue(CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_value) override;
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter);
+ void
+ OptionParsingStarting(CommandInterpreter &interpreter) override;
const OptionValueUUID &
GetOptionValue () const
@@ -58,4 +56,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionGroupUUID_h_
+#endif // liblldb_OptionGroupUUID_h_
diff --git a/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h b/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h
index 5cce126f89bf..53c8550da81e 100644
--- a/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h
+++ b/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h
@@ -1,4 +1,4 @@
-//===-- OptionGroupValueObjectDisplay.h -------------------------------*- C++ -*-===//
+//===-- OptionGroupValueObjectDisplay.h -------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -26,41 +26,38 @@ namespace lldb_private {
class OptionGroupValueObjectDisplay : public OptionGroup
{
public:
-
OptionGroupValueObjectDisplay ();
- virtual
- ~OptionGroupValueObjectDisplay ();
+ ~OptionGroupValueObjectDisplay() override;
+ uint32_t
+ GetNumDefinitions() override;
- virtual uint32_t
- GetNumDefinitions ();
-
- virtual const OptionDefinition*
- GetDefinitions ();
+ const OptionDefinition*
+ GetDefinitions() override;
- virtual Error
- SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value);
+ Error
+ SetOptionValue(CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_value) override;
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter);
+ void
+ OptionParsingStarting(CommandInterpreter &interpreter) override;
bool
AnyOptionWasSet () const
{
- return show_types == true ||
- no_summary_depth != 0 ||
- show_location == true ||
- flat_output == true ||
- use_objc == true ||
+ return show_types ||
+ no_summary_depth != 0 ||
+ show_location ||
+ flat_output ||
+ use_objc ||
max_depth != UINT32_MAX ||
ptr_depth != 0 ||
- use_synth == false ||
- be_raw == true ||
- ignore_cap == true ||
- run_validator == true;
+ !use_synth ||
+ be_raw ||
+ ignore_cap ||
+ run_validator;
}
DumpValueObjectOptions
@@ -85,4 +82,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_OptionGroupValueObjectDisplay_h_
+#endif // liblldb_OptionGroupValueObjectDisplay_h_
diff --git a/include/lldb/Interpreter/OptionGroupVariable.h b/include/lldb/Interpreter/OptionGroupVariable.h
index 40f4d436bc69..fd338f1ba8cb 100644
--- a/include/lldb/Interpreter/OptionGroupVariable.h
+++ b/include/lldb/Interpreter/OptionGroupVariable.h
@@ -26,25 +26,23 @@ namespace lldb_private {
class OptionGroupVariable : public OptionGroup
{
public:
-
OptionGroupVariable (bool show_frame_options);
- virtual
- ~OptionGroupVariable ();
-
- virtual uint32_t
- GetNumDefinitions ();
+ ~OptionGroupVariable() override;
+
+ uint32_t
+ GetNumDefinitions() override;
- virtual const OptionDefinition*
- GetDefinitions ();
+ const OptionDefinition*
+ GetDefinitions() override;
- virtual Error
- SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_arg);
+ Error
+ SetOptionValue(CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_arg) override;
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter);
+ void
+ OptionParsingStarting(CommandInterpreter &interpreter) override;
bool include_frame_options:1,
show_args:1, // Frame option only (include_frame_options == true)
@@ -62,4 +60,4 @@ namespace lldb_private {
} // namespace lldb_private
-#endif // liblldb_OptionGroupVariable_h_
+#endif // liblldb_OptionGroupVariable_h_
diff --git a/include/lldb/Interpreter/OptionGroupWatchpoint.h b/include/lldb/Interpreter/OptionGroupWatchpoint.h
index 1298da80750e..ddc4393bdc25 100644
--- a/include/lldb/Interpreter/OptionGroupWatchpoint.h
+++ b/include/lldb/Interpreter/OptionGroupWatchpoint.h
@@ -25,28 +25,26 @@ namespace lldb_private {
class OptionGroupWatchpoint : public OptionGroup
{
public:
-
+ OptionGroupWatchpoint ();
+
+ ~OptionGroupWatchpoint() override;
+
static bool
IsWatchSizeSupported(uint32_t watch_size);
- OptionGroupWatchpoint ();
-
- virtual
- ~OptionGroupWatchpoint ();
-
- virtual uint32_t
- GetNumDefinitions ();
+ uint32_t
+ GetNumDefinitions() override;
- virtual const OptionDefinition*
- GetDefinitions ();
+ const OptionDefinition*
+ GetDefinitions() override;
- virtual Error
- SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_arg);
+ Error
+ SetOptionValue(CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_arg) override;
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter);
+ void
+ OptionParsingStarting(CommandInterpreter &interpreter) override;
// Note:
// eWatchRead == LLDB_WATCH_TYPE_READ; and
@@ -68,4 +66,4 @@ namespace lldb_private {
} // namespace lldb_private
-#endif // liblldb_OptionGroupWatchpoint_h_
+#endif // liblldb_OptionGroupWatchpoint_h_
diff --git a/include/lldb/Interpreter/OptionValue.h b/include/lldb/Interpreter/OptionValue.h
index fd751f744de6..a05a0fb0b64f 100644
--- a/include/lldb/Interpreter/OptionValue.h
+++ b/include/lldb/Interpreter/OptionValue.h
@@ -1,4 +1,4 @@
-//===-- OptionValue.h --------------------------------------*- C++ -*-===//
+//===-- OptionValue.h -------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -61,7 +61,6 @@ namespace lldb_private {
eDumpGroupHelp = (eDumpOptionName | eDumpOptionType | eDumpOptionDescription)
};
-
OptionValue () :
m_callback (nullptr),
m_baton(nullptr),
@@ -76,9 +75,8 @@ namespace lldb_private {
{
}
- virtual ~OptionValue ()
- {
- }
+ virtual ~OptionValue() = default;
+
//-----------------------------------------------------------------
// Subclasses should override these functions
//-----------------------------------------------------------------
@@ -99,7 +97,6 @@ namespace lldb_private {
return GetBuiltinTypeAsCString(GetType());
}
-
static const char *
GetBuiltinTypeAsCString (Type t);
@@ -156,6 +153,7 @@ namespace lldb_private {
virtual bool
DumpQualifiedName (Stream &strm) const;
+
//-----------------------------------------------------------------
// Subclasses should NOT override these functions as they use the
// above functions to implement functionality
@@ -376,7 +374,7 @@ namespace lldb_private {
SetSInt64Value (int64_t new_value);
const char *
- GetStringValue (const char *fail_value = NULL) const;
+ GetStringValue(const char *fail_value = nullptr) const;
bool
SetStringValue (const char *new_value);
@@ -415,7 +413,7 @@ namespace lldb_private {
SetValueChangedCallback (OptionValueChangedCallback callback,
void *baton)
{
- assert (m_callback == NULL);
+ assert (m_callback == nullptr);
m_callback = callback;
m_baton = baton;
}
@@ -426,6 +424,7 @@ namespace lldb_private {
if (m_callback)
m_callback (m_baton, this);
}
+
protected:
lldb::OptionValueWP m_parent_wp;
OptionValueChangedCallback m_callback;
@@ -436,9 +435,8 @@ namespace lldb_private {
// the command line or as a setting, versus if we
// just have the default value that was already
// populated in the option value.
-
};
} // namespace lldb_private
-#endif // liblldb_OptionValue_h_
+#endif // liblldb_OptionValue_h_
diff --git a/include/lldb/Interpreter/OptionValueArch.h b/include/lldb/Interpreter/OptionValueArch.h
index 3d5d72619efc..c83dc8558084 100644
--- a/include/lldb/Interpreter/OptionValueArch.h
+++ b/include/lldb/Interpreter/OptionValueArch.h
@@ -52,8 +52,7 @@ public:
{
}
- virtual
- ~OptionValueArch()
+ ~OptionValueArch() override
{
}
@@ -61,37 +60,37 @@ public:
// Virtual subclass pure virtual overrides
//---------------------------------------------------------------------
- virtual OptionValue::Type
- GetType () const
+ OptionValue::Type
+ GetType() const override
{
return eTypeArch;
}
- virtual void
- DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask);
+ void
+ DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
- virtual Error
- SetValueFromString (llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign);
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
- virtual bool
- Clear ()
+ bool
+ Clear() override
{
m_current_value = m_default_value;
m_value_was_set = false;
return true;
}
- virtual lldb::OptionValueSP
- DeepCopy () const;
+ lldb::OptionValueSP
+ DeepCopy() const override;
- virtual size_t
- AutoComplete (CommandInterpreter &interpreter,
- const char *s,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches);
+ size_t
+ AutoComplete(CommandInterpreter &interpreter,
+ const char *s,
+ int match_start_point,
+ int max_return_elements,
+ bool &word_complete,
+ StringList &matches) override;
//---------------------------------------------------------------------
// Subclass specific functions
@@ -136,4 +135,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueArch_h_
+#endif // liblldb_OptionValueArch_h_
diff --git a/include/lldb/Interpreter/OptionValueArgs.h b/include/lldb/Interpreter/OptionValueArgs.h
index 365a52a8b39f..ad9505af3015 100644
--- a/include/lldb/Interpreter/OptionValueArgs.h
+++ b/include/lldb/Interpreter/OptionValueArgs.h
@@ -26,16 +26,15 @@ public:
{
}
- virtual
- ~OptionValueArgs()
+ ~OptionValueArgs() override
{
}
size_t
GetArgs (Args &args);
- virtual Type
- GetType() const
+ Type
+ GetType() const override
{
return eTypeArgs;
}
@@ -43,4 +42,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_OptionValueArgs_h_
+#endif // liblldb_OptionValueArgs_h_
diff --git a/include/lldb/Interpreter/OptionValueArray.h b/include/lldb/Interpreter/OptionValueArray.h
index 2e44f9f07438..38b9e3c3ee97 100644
--- a/include/lldb/Interpreter/OptionValueArray.h
+++ b/include/lldb/Interpreter/OptionValueArray.h
@@ -30,8 +30,7 @@ public:
{
}
- virtual
- ~OptionValueArray()
+ ~OptionValueArray() override
{
}
@@ -39,41 +38,41 @@ public:
// Virtual subclass pure virtual overrides
//---------------------------------------------------------------------
- virtual OptionValue::Type
- GetType () const
+ OptionValue::Type
+ GetType() const override
{
return eTypeArray;
}
- virtual void
- DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask);
+ void
+ DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
- virtual Error
- SetValueFromString (llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign);
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
- virtual bool
- Clear ()
+ bool
+ Clear() override
{
m_values.clear();
m_value_was_set = false;
return true;
}
- virtual lldb::OptionValueSP
- DeepCopy () const;
+ lldb::OptionValueSP
+ DeepCopy() const override;
- virtual bool
- IsAggregateValue () const
+ bool
+ IsAggregateValue() const override
{
return true;
}
- virtual lldb::OptionValueSP
- GetSubValue (const ExecutionContext *exe_ctx,
- const char *name,
- bool will_modify,
- Error &error) const;
+ lldb::OptionValueSP
+ GetSubValue(const ExecutionContext *exe_ctx,
+ const char *name,
+ bool will_modify,
+ Error &error) const override;
//---------------------------------------------------------------------
// Subclass specific functions
@@ -175,4 +174,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueArray_h_
+#endif // liblldb_OptionValueArray_h_
diff --git a/include/lldb/Interpreter/OptionValueBoolean.h b/include/lldb/Interpreter/OptionValueBoolean.h
index 214fd1649d39..52d39a9b8d27 100644
--- a/include/lldb/Interpreter/OptionValueBoolean.h
+++ b/include/lldb/Interpreter/OptionValueBoolean.h
@@ -35,8 +35,7 @@ public:
{
}
- virtual
- ~OptionValueBoolean()
+ ~OptionValueBoolean() override
{
}
@@ -44,34 +43,34 @@ public:
// Virtual subclass pure virtual overrides
//---------------------------------------------------------------------
- virtual OptionValue::Type
- GetType () const
+ OptionValue::Type
+ GetType() const override
{
return eTypeBoolean;
}
- virtual void
- DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask);
+ void
+ DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
- virtual Error
- SetValueFromString (llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign);
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
- virtual bool
- Clear ()
+ bool
+ Clear() override
{
m_current_value = m_default_value;
m_value_was_set = false;
return true;
}
- virtual size_t
- AutoComplete (CommandInterpreter &interpreter,
- const char *s,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches);
+ size_t
+ AutoComplete(CommandInterpreter &interpreter,
+ const char *s,
+ int match_start_point,
+ int max_return_elements,
+ bool &word_complete,
+ StringList &matches) override;
//---------------------------------------------------------------------
// Subclass specific functions
@@ -128,8 +127,8 @@ public:
m_default_value = value;
}
- virtual lldb::OptionValueSP
- DeepCopy () const;
+ lldb::OptionValueSP
+ DeepCopy() const override;
protected:
bool m_current_value;
@@ -138,4 +137,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueBoolean_h_
+#endif // liblldb_OptionValueBoolean_h_
diff --git a/include/lldb/Interpreter/OptionValueChar.h b/include/lldb/Interpreter/OptionValueChar.h
index 8fc02093e3d9..b05d9ca098b2 100644
--- a/include/lldb/Interpreter/OptionValueChar.h
+++ b/include/lldb/Interpreter/OptionValueChar.h
@@ -27,6 +27,7 @@ public:
m_default_value (value)
{
}
+
OptionValueChar (char current_value,
char default_value) :
OptionValue(),
@@ -35,8 +36,7 @@ public:
{
}
- virtual
- ~OptionValueChar()
+ ~OptionValueChar() override
{
}
@@ -44,21 +44,21 @@ public:
// Virtual subclass pure virtual overrides
//---------------------------------------------------------------------
- virtual OptionValue::Type
- GetType () const
+ OptionValue::Type
+ GetType() const override
{
return eTypeChar;
}
- virtual void
- DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask);
+ void
+ DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
- virtual Error
- SetValueFromString (llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign);
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
- virtual bool
- Clear ()
+ bool
+ Clear() override
{
m_current_value = m_default_value;
m_value_was_set = false;
@@ -100,8 +100,8 @@ public:
m_default_value = value;
}
- virtual lldb::OptionValueSP
- DeepCopy () const;
+ lldb::OptionValueSP
+ DeepCopy() const override;
protected:
char m_current_value;
@@ -110,4 +110,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueChar_h_
+#endif // liblldb_OptionValueChar_h_
diff --git a/include/lldb/Interpreter/OptionValueDictionary.h b/include/lldb/Interpreter/OptionValueDictionary.h
index efa15dd6ef88..8ee839775646 100644
--- a/include/lldb/Interpreter/OptionValueDictionary.h
+++ b/include/lldb/Interpreter/OptionValueDictionary.h
@@ -31,8 +31,7 @@ public:
{
}
- virtual
- ~OptionValueDictionary()
+ ~OptionValueDictionary() override
{
}
@@ -40,32 +39,32 @@ public:
// Virtual subclass pure virtual overrides
//---------------------------------------------------------------------
- virtual OptionValue::Type
- GetType () const
+ OptionValue::Type
+ GetType() const override
{
return eTypeDictionary;
}
- virtual void
- DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask);
+ void
+ DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
- virtual Error
- SetValueFromString (llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign);
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
- virtual bool
- Clear ()
+ bool
+ Clear() override
{
m_values.clear();
m_value_was_set = false;
return true;
}
- virtual lldb::OptionValueSP
- DeepCopy () const;
+ lldb::OptionValueSP
+ DeepCopy() const override;
- virtual bool
- IsAggregateValue () const
+ bool
+ IsAggregateValue() const override
{
return true;
}
@@ -89,17 +88,17 @@ public:
lldb::OptionValueSP
GetValueForKey (const ConstString &key) const;
- virtual lldb::OptionValueSP
- GetSubValue (const ExecutionContext *exe_ctx,
- const char *name,
- bool will_modify,
- Error &error) const;
-
- virtual Error
- SetSubValue (const ExecutionContext *exe_ctx,
- VarSetOperationType op,
- const char *name,
- const char *value);
+ lldb::OptionValueSP
+ GetSubValue(const ExecutionContext *exe_ctx,
+ const char *name,
+ bool will_modify,
+ Error &error) const override;
+
+ Error
+ SetSubValue(const ExecutionContext *exe_ctx,
+ VarSetOperationType op,
+ const char *name,
+ const char *value) override;
//---------------------------------------------------------------------
// String value getters and setters
@@ -136,4 +135,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueDictionary_h_
+#endif // liblldb_OptionValueDictionary_h_
diff --git a/include/lldb/Interpreter/OptionValueEnumeration.h b/include/lldb/Interpreter/OptionValueEnumeration.h
index e820729385de..b3fc481dd7fa 100644
--- a/include/lldb/Interpreter/OptionValueEnumeration.h
+++ b/include/lldb/Interpreter/OptionValueEnumeration.h
@@ -23,7 +23,6 @@
namespace lldb_private {
-
class OptionValueEnumeration : public OptionValue
{
public:
@@ -38,44 +37,43 @@ public:
OptionValueEnumeration (const OptionEnumValueElement *enumerators, enum_type value);
- virtual
- ~OptionValueEnumeration();
+ ~OptionValueEnumeration() override;
//---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
//---------------------------------------------------------------------
- virtual OptionValue::Type
- GetType () const
+ OptionValue::Type
+ GetType() const override
{
return eTypeEnum;
}
- virtual void
- DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask);
+ void
+ DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
- virtual Error
- SetValueFromString (llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign);
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
- virtual bool
- Clear ()
+ bool
+ Clear() override
{
m_current_value = m_default_value;
m_value_was_set = false;
return true;
}
- virtual lldb::OptionValueSP
- DeepCopy () const;
+ lldb::OptionValueSP
+ DeepCopy() const override;
- virtual size_t
- AutoComplete (CommandInterpreter &interpreter,
- const char *s,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches);
+ size_t
+ AutoComplete(CommandInterpreter &interpreter,
+ const char *s,
+ int match_start_point,
+ int max_return_elements,
+ bool &word_complete,
+ StringList &matches) override;
//---------------------------------------------------------------------
// Subclass specific functions
@@ -123,4 +121,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueEnumeration_h_
+#endif // liblldb_OptionValueEnumeration_h_
diff --git a/include/lldb/Interpreter/OptionValueFileSpec.h b/include/lldb/Interpreter/OptionValueFileSpec.h
index 80dd77ecef2a..274c4d064e51 100644
--- a/include/lldb/Interpreter/OptionValueFileSpec.h
+++ b/include/lldb/Interpreter/OptionValueFileSpec.h
@@ -31,8 +31,7 @@ public:
const FileSpec &default_value,
bool resolve = true);
- virtual
- ~OptionValueFileSpec()
+ ~OptionValueFileSpec() override
{
}
@@ -40,21 +39,21 @@ public:
// Virtual subclass pure virtual overrides
//---------------------------------------------------------------------
- virtual OptionValue::Type
- GetType () const
+ OptionValue::Type
+ GetType() const override
{
return eTypeFileSpec;
}
- virtual void
- DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask);
+ void
+ DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
- virtual Error
- SetValueFromString (llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign);
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
- virtual bool
- Clear ()
+ bool
+ Clear() override
{
m_current_value = m_default_value;
m_value_was_set = false;
@@ -63,16 +62,16 @@ public:
return true;
}
- virtual lldb::OptionValueSP
- DeepCopy () const;
+ lldb::OptionValueSP
+ DeepCopy() const override;
- virtual size_t
- AutoComplete (CommandInterpreter &interpreter,
- const char *s,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches);
+ size_t
+ AutoComplete(CommandInterpreter &interpreter,
+ const char *s,
+ int match_start_point,
+ int max_return_elements,
+ bool &word_complete,
+ StringList &matches) override;
//---------------------------------------------------------------------
// Subclass specific functions
@@ -131,4 +130,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueFileSpec_h_
+#endif // liblldb_OptionValueFileSpec_h_
diff --git a/include/lldb/Interpreter/OptionValueFileSpecList.h b/include/lldb/Interpreter/OptionValueFileSpecList.h
index a105d22e45f9..205132358024 100644
--- a/include/lldb/Interpreter/OptionValueFileSpecList.h
+++ b/include/lldb/Interpreter/OptionValueFileSpecList.h
@@ -34,9 +34,7 @@ public:
{
}
-
- virtual
- ~OptionValueFileSpecList()
+ ~OptionValueFileSpecList() override
{
}
@@ -44,32 +42,32 @@ public:
// Virtual subclass pure virtual overrides
//---------------------------------------------------------------------
- virtual OptionValue::Type
- GetType () const
+ OptionValue::Type
+ GetType() const override
{
return eTypeFileSpecList;
}
- virtual void
- DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask);
+ void
+ DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
- virtual Error
- SetValueFromString (llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign);
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
- virtual bool
- Clear ()
+ bool
+ Clear() override
{
m_current_value.Clear();
m_value_was_set = false;
return true;
}
- virtual lldb::OptionValueSP
- DeepCopy () const;
+ lldb::OptionValueSP
+ DeepCopy() const override;
- virtual bool
- IsAggregateValue () const
+ bool
+ IsAggregateValue() const override
{
return true;
}
@@ -102,4 +100,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueFileSpecList_h_
+#endif // liblldb_OptionValueFileSpecList_h_
diff --git a/include/lldb/Interpreter/OptionValueFormat.h b/include/lldb/Interpreter/OptionValueFormat.h
index 06ed12854318..1c2909459911 100644
--- a/include/lldb/Interpreter/OptionValueFormat.h
+++ b/include/lldb/Interpreter/OptionValueFormat.h
@@ -36,8 +36,7 @@ public:
{
}
- virtual
- ~OptionValueFormat()
+ ~OptionValueFormat() override
{
}
@@ -45,29 +44,29 @@ public:
// Virtual subclass pure virtual overrides
//---------------------------------------------------------------------
- virtual OptionValue::Type
- GetType () const
+ OptionValue::Type
+ GetType() const override
{
return eTypeFormat;
}
- virtual void
- DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask);
+ void
+ DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
- virtual Error
- SetValueFromString (llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign);
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
- virtual bool
- Clear ()
+ bool
+ Clear() override
{
m_current_value = m_default_value;
m_value_was_set = false;
return true;
}
- virtual lldb::OptionValueSP
- DeepCopy () const;
+ lldb::OptionValueSP
+ DeepCopy() const override;
//---------------------------------------------------------------------
// Subclass specific functions
@@ -104,4 +103,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueFormat_h_
+#endif // liblldb_OptionValueFormat_h_
diff --git a/include/lldb/Interpreter/OptionValueFormatEntity.h b/include/lldb/Interpreter/OptionValueFormatEntity.h
index 18ace3a6a1b6..10a456a1b994 100644
--- a/include/lldb/Interpreter/OptionValueFormatEntity.h
+++ b/include/lldb/Interpreter/OptionValueFormatEntity.h
@@ -24,8 +24,7 @@ class OptionValueFormatEntity : public OptionValue
public:
OptionValueFormatEntity (const char *default_format);
- virtual
- ~OptionValueFormatEntity()
+ ~OptionValueFormatEntity() override
{
}
@@ -94,7 +93,6 @@ public:
return m_default_entry;
}
-
protected:
std::string m_current_format;
std::string m_default_format;
@@ -104,4 +102,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueFormatEntity_h_
+#endif // liblldb_OptionValueFormatEntity_h_
diff --git a/include/lldb/Interpreter/OptionValueLanguage.h b/include/lldb/Interpreter/OptionValueLanguage.h
index fba5e22821e0..bd6df3ea4943 100644
--- a/include/lldb/Interpreter/OptionValueLanguage.h
+++ b/include/lldb/Interpreter/OptionValueLanguage.h
@@ -37,8 +37,7 @@ public:
{
}
- virtual
- ~OptionValueLanguage ()
+ ~OptionValueLanguage() override
{
}
@@ -104,4 +103,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueLanguage_h_
+#endif // liblldb_OptionValueLanguage_h_
diff --git a/include/lldb/Interpreter/OptionValuePathMappings.h b/include/lldb/Interpreter/OptionValuePathMappings.h
index 7b476a9cd366..4ed1c8c848d6 100644
--- a/include/lldb/Interpreter/OptionValuePathMappings.h
+++ b/include/lldb/Interpreter/OptionValuePathMappings.h
@@ -29,8 +29,7 @@ public:
{
}
- virtual
- ~OptionValuePathMappings()
+ ~OptionValuePathMappings() override
{
}
@@ -38,32 +37,32 @@ public:
// Virtual subclass pure virtual overrides
//---------------------------------------------------------------------
- virtual OptionValue::Type
- GetType () const
+ OptionValue::Type
+ GetType() const override
{
return eTypePathMap;
}
- virtual void
- DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask);
+ void
+ DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
- virtual Error
- SetValueFromString (llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign);
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
- virtual bool
- Clear ()
+ bool
+ Clear() override
{
m_path_mappings.Clear(m_notify_changes);
m_value_was_set = false;
return true;
}
- virtual lldb::OptionValueSP
- DeepCopy () const;
+ lldb::OptionValueSP
+ DeepCopy() const override;
- virtual bool
- IsAggregateValue () const
+ bool
+ IsAggregateValue() const override
{
return true;
}
@@ -91,4 +90,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValuePathMappings_h_
+#endif // liblldb_OptionValuePathMappings_h_
diff --git a/include/lldb/Interpreter/OptionValueProperties.h b/include/lldb/Interpreter/OptionValueProperties.h
index 405beefff6d1..c8783bcf36eb 100644
--- a/include/lldb/Interpreter/OptionValueProperties.h
+++ b/include/lldb/Interpreter/OptionValueProperties.h
@@ -1,4 +1,4 @@
-//===-- OptionValueProperties.h --------------------------------------*- C++ -*-===//
+//===-- OptionValueProperties.h ---------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -12,6 +12,8 @@
// C Includes
// C++ Includes
+#include <vector>
+
// Other libraries and framework includes
// Project includes
#include "lldb/Core/ConstString.h"
@@ -27,10 +29,6 @@ class OptionValueProperties :
public std::enable_shared_from_this<OptionValueProperties>
{
public:
-
- //---------------------------------------------------------------------
- // OptionValueProperties
- //---------------------------------------------------------------------
OptionValueProperties () :
OptionValue(),
m_name (),
@@ -42,34 +40,32 @@ public:
OptionValueProperties (const ConstString &name);
OptionValueProperties (const OptionValueProperties &global_properties);
-
- virtual
- ~OptionValueProperties()
- {
- }
-
- virtual Type
- GetType () const
+
+ ~OptionValueProperties() override = default;
+
+ Type
+ GetType() const override
{
return eTypeProperties;
}
- virtual bool
- Clear ();
+ bool
+ Clear() override;
- virtual lldb::OptionValueSP
- DeepCopy () const;
+ lldb::OptionValueSP
+ DeepCopy() const override;
- virtual Error
- SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign);
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
- virtual void
- DumpValue (const ExecutionContext *exe_ctx,
- Stream &strm,
- uint32_t dump_mask);
+ void
+ DumpValue(const ExecutionContext *exe_ctx,
+ Stream &strm,
+ uint32_t dump_mask) override;
- virtual ConstString
- GetName () const
+ ConstString
+ GetName() const override
{
return m_name;
}
@@ -149,16 +145,16 @@ public:
bool value_will_be_modified) const;
lldb::OptionValueSP
- GetSubValue (const ExecutionContext *exe_ctx,
- const char *name,
- bool value_will_be_modified,
- Error &error) const;
+ GetSubValue(const ExecutionContext *exe_ctx,
+ const char *name,
+ bool value_will_be_modified,
+ Error &error) const override;
- virtual Error
- SetSubValue (const ExecutionContext *exe_ctx,
- VarSetOperationType op,
- const char *path,
- const char *value);
+ Error
+ SetSubValue(const ExecutionContext *exe_ctx,
+ VarSetOperationType op,
+ const char *path,
+ const char *value) override;
virtual bool
PredicateMatches (const ExecutionContext *exe_ctx,
@@ -171,6 +167,9 @@ public:
OptionValueArch *
GetPropertyAtIndexAsOptionValueArch (const ExecutionContext *exe_ctx, uint32_t idx) const;
+ OptionValueLanguage *
+ GetPropertyAtIndexAsOptionValueLanguage (const ExecutionContext *exe_ctx, uint32_t idx) const;
+
bool
GetPropertyAtIndexAsArgs (const ExecutionContext *exe_ctx, uint32_t idx, Args &args) const;
@@ -251,22 +250,18 @@ public:
SetValueChangedCallback (uint32_t property_idx,
OptionValueChangedCallback callback,
void *baton);
-protected:
+protected:
Property *
- ProtectedGetPropertyAtIndex (uint32_t idx)
+ ProtectedGetPropertyAtIndex(uint32_t idx)
{
- if (idx < m_properties.size())
- return &m_properties[idx];
- return NULL;
+ return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
}
const Property *
- ProtectedGetPropertyAtIndex (uint32_t idx) const
+ ProtectedGetPropertyAtIndex(uint32_t idx) const
{
- if (idx < m_properties.size())
- return &m_properties[idx];
- return NULL;
+ return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
}
typedef UniqueCStringMap<size_t> NameToIndex;
@@ -278,4 +273,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueProperties_h_
+#endif // liblldb_OptionValueProperties_h_
diff --git a/include/lldb/Interpreter/OptionValueRegex.h b/include/lldb/Interpreter/OptionValueRegex.h
index 5e04218dbfdf..a094a402b1a9 100644
--- a/include/lldb/Interpreter/OptionValueRegex.h
+++ b/include/lldb/Interpreter/OptionValueRegex.h
@@ -12,8 +12,6 @@
// C Includes
// C++ Includes
-#include <string>
-
// Other libraries and framework includes
// Project includes
#include "lldb/Core/RegularExpression.h"
@@ -24,44 +22,41 @@ namespace lldb_private {
class OptionValueRegex : public OptionValue
{
public:
- OptionValueRegex (const char *value = NULL) :
+ OptionValueRegex(const char *value = nullptr) :
OptionValue(),
m_regex (value)
{
}
- virtual
- ~OptionValueRegex()
- {
- }
-
+ ~OptionValueRegex() override = default;
+
//---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
//---------------------------------------------------------------------
- virtual OptionValue::Type
- GetType () const
+ OptionValue::Type
+ GetType() const override
{
return eTypeRegex;
}
- virtual void
- DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask);
+ void
+ DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
- virtual Error
- SetValueFromString (llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign);
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
- virtual bool
- Clear ()
+ bool
+ Clear() override
{
m_regex.Clear();
m_value_was_set = false;
return true;
}
- virtual lldb::OptionValueSP
- DeepCopy () const;
+ lldb::OptionValueSP
+ DeepCopy() const override;
//---------------------------------------------------------------------
// Subclass specific functions
@@ -69,9 +64,7 @@ public:
const RegularExpression *
GetCurrentValue() const
{
- if (m_regex.IsValid())
- return &m_regex;
- return NULL;
+ return (m_regex.IsValid() ? &m_regex : nullptr);
}
void
@@ -95,4 +88,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueRegex_h_
+#endif // liblldb_OptionValueRegex_h_
diff --git a/include/lldb/Interpreter/OptionValueSInt64.h b/include/lldb/Interpreter/OptionValueSInt64.h
index 36ae97ccfcf8..8c8b201b6e82 100644
--- a/include/lldb/Interpreter/OptionValueSInt64.h
+++ b/include/lldb/Interpreter/OptionValueSInt64.h
@@ -58,8 +58,7 @@ public:
{
}
- virtual
- ~OptionValueSInt64()
+ ~OptionValueSInt64() override
{
}
@@ -67,29 +66,29 @@ public:
// Virtual subclass pure virtual overrides
//---------------------------------------------------------------------
- virtual OptionValue::Type
- GetType () const
+ OptionValue::Type
+ GetType() const override
{
return eTypeSInt64;
}
- virtual void
- DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask);
+ void
+ DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
- virtual Error
- SetValueFromString (llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign);
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
- virtual bool
- Clear ()
+ bool
+ Clear() override
{
m_current_value = m_default_value;
m_value_was_set = false;
return true;
}
- virtual lldb::OptionValueSP
- DeepCopy () const;
+ lldb::OptionValueSP
+ DeepCopy() const override;
//---------------------------------------------------------------------
// Subclass specific functions
@@ -169,4 +168,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueSInt64_h_
+#endif // liblldb_OptionValueSInt64_h_
diff --git a/include/lldb/Interpreter/OptionValueString.h b/include/lldb/Interpreter/OptionValueString.h
index c75745d402be..bbdd0c8ba55c 100644
--- a/include/lldb/Interpreter/OptionValueString.h
+++ b/include/lldb/Interpreter/OptionValueString.h
@@ -1,4 +1,4 @@
-//===-- OptionValueString.h --------------------------------------*- C++ -*-===//
+//===-- OptionValueString.h -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -24,7 +24,6 @@ namespace lldb_private {
class OptionValueString : public OptionValue
{
public:
-
typedef Error (*ValidatorCallback) (const char* string,
void* baton);
@@ -43,8 +42,8 @@ public:
{
}
- OptionValueString (ValidatorCallback validator,
- void* baton = NULL) :
+ OptionValueString(ValidatorCallback validator,
+ void* baton = nullptr) :
OptionValue(),
m_current_value (),
m_default_value (),
@@ -84,9 +83,9 @@ public:
m_default_value.assign (default_value);
}
- OptionValueString (const char *value,
- ValidatorCallback validator,
- void* baton = NULL) :
+ OptionValueString(const char *value,
+ ValidatorCallback validator,
+ void* baton = nullptr) :
OptionValue(),
m_current_value (),
m_default_value (),
@@ -101,10 +100,10 @@ public:
}
}
- OptionValueString (const char *current_value,
- const char *default_value,
- ValidatorCallback validator,
- void* baton = NULL) :
+ OptionValueString(const char *current_value,
+ const char *default_value,
+ ValidatorCallback validator,
+ void* baton = nullptr) :
OptionValue(),
m_current_value (),
m_default_value (),
@@ -118,38 +117,35 @@ public:
m_default_value.assign (default_value);
}
- virtual
- ~OptionValueString()
- {
- }
-
+ ~OptionValueString() override = default;
+
//---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
//---------------------------------------------------------------------
- virtual OptionValue::Type
- GetType () const
+ OptionValue::Type
+ GetType() const override
{
return eTypeString;
}
- virtual void
- DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask);
+ void
+ DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
- virtual Error
- SetValueFromString (llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign);
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
- virtual bool
- Clear ()
+ bool
+ Clear() override
{
m_current_value = m_default_value;
m_value_was_set = false;
return true;
}
- virtual lldb::OptionValueSP
- DeepCopy () const;
+ lldb::OptionValueSP
+ DeepCopy() const override;
//---------------------------------------------------------------------
// Subclass specific functions
@@ -213,7 +209,6 @@ public:
return m_default_value.empty();
}
-
protected:
std::string m_current_value;
std::string m_default_value;
@@ -224,4 +219,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueString_h_
+#endif // liblldb_OptionValueString_h_
diff --git a/include/lldb/Interpreter/OptionValueUInt64.h b/include/lldb/Interpreter/OptionValueUInt64.h
index 51ff8818dcff..874e8ca16665 100644
--- a/include/lldb/Interpreter/OptionValueUInt64.h
+++ b/include/lldb/Interpreter/OptionValueUInt64.h
@@ -43,8 +43,7 @@ public:
{
}
- virtual
- ~OptionValueUInt64()
+ ~OptionValueUInt64() override
{
}
@@ -60,29 +59,29 @@ public:
// Virtual subclass pure virtual overrides
//---------------------------------------------------------------------
- virtual OptionValue::Type
- GetType () const
+ OptionValue::Type
+ GetType() const override
{
return eTypeUInt64;
}
- virtual void
- DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask);
+ void
+ DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
- virtual Error
- SetValueFromString (llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign);
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
- virtual bool
- Clear ()
+ bool
+ Clear() override
{
m_current_value = m_default_value;
m_value_was_set = false;
return true;
}
- virtual lldb::OptionValueSP
- DeepCopy () const;
+ lldb::OptionValueSP
+ DeepCopy() const override;
//---------------------------------------------------------------------
// Subclass specific functions
@@ -131,4 +130,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueUInt64_h_
+#endif // liblldb_OptionValueUInt64_h_
diff --git a/include/lldb/Interpreter/OptionValueUUID.h b/include/lldb/Interpreter/OptionValueUUID.h
index c6ab48a627f6..4aecc39bc8c4 100644
--- a/include/lldb/Interpreter/OptionValueUUID.h
+++ b/include/lldb/Interpreter/OptionValueUUID.h
@@ -34,8 +34,7 @@ public:
{
}
- virtual
- ~OptionValueUUID()
+ ~OptionValueUUID() override
{
}
@@ -43,29 +42,29 @@ public:
// Virtual subclass pure virtual overrides
//---------------------------------------------------------------------
- virtual OptionValue::Type
- GetType () const
+ OptionValue::Type
+ GetType() const override
{
return eTypeUUID;
}
- virtual void
- DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask);
+ void
+ DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
- virtual Error
- SetValueFromString (llvm::StringRef value,
- VarSetOperationType op = eVarSetOperationAssign);
+ Error
+ SetValueFromString(llvm::StringRef value,
+ VarSetOperationType op = eVarSetOperationAssign) override;
- virtual bool
- Clear ()
+ bool
+ Clear() override
{
m_uuid.Clear();
m_value_was_set = false;
return true;
}
- virtual lldb::OptionValueSP
- DeepCopy () const;
+ lldb::OptionValueSP
+ DeepCopy() const override;
//---------------------------------------------------------------------
// Subclass specific functions
@@ -89,13 +88,13 @@ public:
m_uuid = value;
}
- virtual size_t
- AutoComplete (CommandInterpreter &interpreter,
- const char *s,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches);
+ size_t
+ AutoComplete(CommandInterpreter &interpreter,
+ const char *s,
+ int match_start_point,
+ int max_return_elements,
+ bool &word_complete,
+ StringList &matches) override;
protected:
UUID m_uuid;
@@ -103,4 +102,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueUUID_h_
+#endif // liblldb_OptionValueUUID_h_
diff --git a/include/lldb/Interpreter/Options.h b/include/lldb/Interpreter/Options.h
index 6ecf08d28e75..bac26308a8d1 100644
--- a/include/lldb/Interpreter/Options.h
+++ b/include/lldb/Interpreter/Options.h
@@ -11,7 +11,6 @@
#define liblldb_Options_h_
// C Includes
-
// C++ Includes
#include <set>
#include <vector>
@@ -32,7 +31,6 @@ namespace lldb_private {
return isprint(ch);
}
-
//----------------------------------------------------------------------
/// @class Options Options.h "lldb/Interpreter/Options.h"
/// @brief A command line option parsing protocol class.
@@ -72,7 +70,7 @@ namespace lldb_private {
/// case 'g': debug = true; break;
/// case 'v': verbose = true; break;
/// case 'l': log_file = option_arg; break;
-/// case 'f': log_flags = strtoull(option_arg, NULL, 0); break;
+/// case 'f': log_flags = strtoull(option_arg, nullptr, 0); break;
/// default:
/// error.SetErrorStringWithFormat("unrecognized short option %c", option_val);
/// break;
@@ -95,11 +93,11 @@ namespace lldb_private {
///
/// struct option CommandOptions::g_options[] =
/// {
-/// { "debug", no_argument, NULL, 'g' },
-/// { "log-file", required_argument, NULL, 'l' },
-/// { "log-flags", required_argument, NULL, 'f' },
-/// { "verbose", no_argument, NULL, 'v' },
-/// { NULL, 0, NULL, 0 }
+/// { "debug", no_argument, nullptr, 'g' },
+/// { "log-file", required_argument, nullptr, 'l' },
+/// { "log-flags", required_argument, nullptr, 'f' },
+/// { "verbose", no_argument, nullptr, 'v' },
+/// { nullptr, 0, nullptr, 0 }
/// };
///
/// int main (int argc, const char **argv, const char **envp)
@@ -119,7 +117,6 @@ namespace lldb_private {
class Options
{
public:
-
Options (CommandInterpreter &interpreter);
virtual
@@ -153,7 +150,6 @@ public:
// Verify that the options given are in the options table and can
// be used together, but there may be some required options that are
// missing (used to verify options that get folded into command aliases).
-
bool
VerifyPartialOptions (CommandReturnObject &result);
@@ -173,7 +169,10 @@ public:
// class that inherits from this class.
virtual const OptionDefinition*
- GetDefinitions () { return NULL; }
+ GetDefinitions()
+ {
+ return nullptr;
+ }
// Call this prior to parsing any options. This call will call the
// subclass OptionParsingStarting() and will avoid the need for all
@@ -195,7 +194,7 @@ public:
///
/// @param[in] option_arg
/// The argument value for the option that the user entered, or
- /// NULL if there is no argument for the current option.
+ /// nullptr if there is no argument for the current option.
///
///
/// @see Args::ParseOptions (Options&)
@@ -359,15 +358,11 @@ protected:
class OptionGroup
{
public:
- OptionGroup ()
- {
- }
-
+ OptionGroup() = default;
+
virtual
- ~OptionGroup ()
- {
- }
-
+ ~OptionGroup() = default;
+
virtual uint32_t
GetNumDefinitions () = 0;
@@ -395,7 +390,6 @@ protected:
class OptionGroupOptions : public Options
{
public:
-
OptionGroupOptions (CommandInterpreter &interpreter) :
Options (interpreter),
m_option_defs (),
@@ -404,12 +398,8 @@ protected:
{
}
- virtual
- ~OptionGroupOptions ()
- {
- }
-
-
+ ~OptionGroupOptions() override = default;
+
//----------------------------------------------------------------------
/// Append options from a OptionGroup class.
///
@@ -459,18 +449,18 @@ protected:
return m_did_finalize;
}
- virtual Error
- SetOptionValue (uint32_t option_idx,
- const char *option_arg);
+ Error
+ SetOptionValue(uint32_t option_idx,
+ const char *option_arg) override;
- virtual void
- OptionParsingStarting ();
+ void
+ OptionParsingStarting() override;
- virtual Error
- OptionParsingFinished ();
+ Error
+ OptionParsingFinished() override;
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions() override
{
assert (m_did_finalize);
return &m_option_defs[0];
@@ -495,8 +485,7 @@ protected:
OptionInfos m_option_infos;
bool m_did_finalize;
};
-
} // namespace lldb_private
-#endif // liblldb_Options_h_
+#endif // liblldb_Options_h_
diff --git a/include/lldb/Interpreter/PythonDataObjects.h b/include/lldb/Interpreter/PythonDataObjects.h
deleted file mode 100644
index df281b533cba..000000000000
--- a/include/lldb/Interpreter/PythonDataObjects.h
+++ /dev/null
@@ -1,280 +0,0 @@
-//===-- PythonDataObjects.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_PythonDataObjects_h_
-#define liblldb_PythonDataObjects_h_
-
-// C Includes
-// C++ Includes
-
-// Other libraries and framework includes
-// Project includes
-#include "lldb/lldb-defines.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/StructuredData.h"
-#include "lldb/Core/Flags.h"
-#include "lldb/Interpreter/OptionValue.h"
-#include "lldb/lldb-python.h"
-
-namespace lldb_private {
-class PythonString;
-class PythonList;
-class PythonDictionary;
-class PythonObject;
-class PythonInteger;
-
-class StructuredPythonObject : public StructuredData::Generic
-{
- public:
- StructuredPythonObject()
- : StructuredData::Generic()
- {
- }
-
- StructuredPythonObject(void *obj)
- : StructuredData::Generic(obj)
- {
- Py_XINCREF(GetValue());
- }
-
- virtual ~StructuredPythonObject()
- {
- if (Py_IsInitialized())
- Py_XDECREF(GetValue());
- SetValue(nullptr);
- }
-
- bool
- IsValid() const override
- {
- return GetValue() && GetValue() != Py_None;
- }
-
- void Dump(Stream &s) const override;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(StructuredPythonObject);
-};
-
-enum class PyObjectType
-{
- Unknown,
- None,
- Integer,
- Dictionary,
- List,
- String
-};
-
- class PythonObject
- {
- public:
- PythonObject () :
- m_py_obj(NULL)
- {
- }
-
- explicit PythonObject (PyObject* py_obj) :
- m_py_obj(NULL)
- {
- Reset (py_obj);
- }
-
- PythonObject (const PythonObject &rhs) :
- m_py_obj(NULL)
- {
- Reset (rhs.m_py_obj);
- }
-
- virtual
- ~PythonObject ()
- {
- Reset (NULL);
- }
-
- bool
- Reset (const PythonObject &object)
- {
- return Reset(object.get());
- }
-
- virtual bool
- Reset (PyObject* py_obj = NULL)
- {
- if (py_obj != m_py_obj)
- {
- if (Py_IsInitialized())
- Py_XDECREF(m_py_obj);
- m_py_obj = py_obj;
- if (Py_IsInitialized())
- Py_XINCREF(m_py_obj);
- }
- return true;
- }
-
- void
- Dump () const
- {
- if (m_py_obj)
- _PyObject_Dump (m_py_obj);
- else
- puts ("NULL");
- }
-
- void
- Dump (Stream &strm) const;
-
- PyObject*
- get () const
- {
- return m_py_obj;
- }
-
- PyObjectType GetObjectType() const;
-
- PythonString
- Repr ();
-
- PythonString
- Str ();
-
- explicit operator bool () const
- {
- return m_py_obj != NULL;
- }
-
- bool
- IsNULLOrNone () const;
-
- StructuredData::ObjectSP CreateStructuredObject() const;
-
- protected:
- PyObject* m_py_obj;
- };
-
- class PythonString: public PythonObject
- {
- public:
- PythonString ();
- PythonString (PyObject *o);
- PythonString (const PythonObject &object);
- PythonString (llvm::StringRef string);
- PythonString (const char *string);
- virtual ~PythonString ();
-
- virtual bool
- Reset (PyObject* py_obj = NULL);
-
- llvm::StringRef
- GetString() const;
-
- size_t
- GetSize() const;
-
- void SetString(llvm::StringRef string);
-
- StructuredData::StringSP CreateStructuredString() const;
- };
-
- class PythonInteger: public PythonObject
- {
- public:
-
- PythonInteger ();
- PythonInteger (PyObject* py_obj);
- PythonInteger (const PythonObject &object);
- PythonInteger (int64_t value);
- virtual ~PythonInteger ();
-
- virtual bool
- Reset (PyObject* py_obj = NULL);
-
- int64_t GetInteger() const;
-
- void
- SetInteger (int64_t value);
-
- StructuredData::IntegerSP CreateStructuredInteger() const;
- };
-
- class PythonList: public PythonObject
- {
- public:
-
- PythonList (bool create_empty);
- PythonList (PyObject* py_obj);
- PythonList (const PythonObject &object);
- PythonList (uint32_t count);
- virtual ~PythonList ();
-
- virtual bool
- Reset (PyObject* py_obj = NULL);
-
- uint32_t GetSize() const;
-
- PythonObject GetItemAtIndex(uint32_t index) const;
-
- void
- SetItemAtIndex (uint32_t index, const PythonObject &object);
-
- void
- AppendItem (const PythonObject &object);
-
- StructuredData::ArraySP CreateStructuredArray() const;
- };
-
- class PythonDictionary: public PythonObject
- {
- public:
-
- explicit PythonDictionary (bool create_empty);
- PythonDictionary (PyObject* object);
- PythonDictionary (const PythonObject &object);
- virtual ~PythonDictionary ();
-
- virtual bool
- Reset (PyObject* object = NULL);
-
- uint32_t GetSize() const;
-
- PythonObject
- GetItemForKey (const PythonString &key) const;
-
- const char *
- GetItemForKeyAsString (const PythonString &key, const char *fail_value = NULL) const;
-
- int64_t
- GetItemForKeyAsInteger (const PythonString &key, int64_t fail_value = 0) const;
-
- PythonObject
- GetItemForKey (const char *key) const;
-
- typedef bool (*DictionaryIteratorCallback)(PythonString* key, PythonDictionary* dict);
-
- PythonList
- GetKeys () const;
-
- PythonString
- GetKeyAtPosition (uint32_t pos) const;
-
- PythonObject
- GetValueAtPosition (uint32_t pos) const;
-
- void
- SetItemForKey (const PythonString &key, PyObject *value);
-
- void
- SetItemForKey (const PythonString &key, const PythonObject& value);
-
- StructuredData::DictionarySP CreateStructuredDictionary() const;
- };
-
-} // namespace lldb_private
-
-#endif // liblldb_PythonDataObjects_h_
diff --git a/include/lldb/Interpreter/ScriptInterpreter.h b/include/lldb/Interpreter/ScriptInterpreter.h
index 0f45dd8245e9..eafc03a00cca 100644
--- a/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/include/lldb/Interpreter/ScriptInterpreter.h
@@ -10,37 +10,36 @@
#ifndef liblldb_ScriptInterpreter_h_
#define liblldb_ScriptInterpreter_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Error.h"
+#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Utility/PseudoTerminal.h"
-
namespace lldb_private {
class ScriptInterpreterLocker
{
public:
- ScriptInterpreterLocker ()
- {
- }
+ ScriptInterpreterLocker() = default;
- virtual ~ScriptInterpreterLocker ()
- {
- }
+ virtual ~ScriptInterpreterLocker() = default;
+
private:
DISALLOW_COPY_AND_ASSIGN (ScriptInterpreterLocker);
};
-
-class ScriptInterpreter
+class ScriptInterpreter : public PluginInterface
{
public:
-
typedef enum
{
eScriptReturnTypeCharPtr,
@@ -62,7 +61,7 @@ public:
ScriptInterpreter (CommandInterpreter &interpreter, lldb::ScriptLanguage script_lang);
- virtual ~ScriptInterpreter ();
+ ~ScriptInterpreter() override;
struct ExecuteScriptOptions
{
@@ -174,13 +173,13 @@ public:
}
virtual bool
- GenerateTypeScriptFunction (const char* oneliner, std::string& output, const void* name_token = NULL)
+ GenerateTypeScriptFunction(const char* oneliner, std::string& output, const void* name_token = nullptr)
{
return false;
}
virtual bool
- GenerateTypeScriptFunction (StringList &input, std::string& output, const void* name_token = NULL)
+ GenerateTypeScriptFunction(StringList &input, std::string& output, const void* name_token = nullptr)
{
return false;
}
@@ -192,13 +191,13 @@ public:
}
virtual bool
- GenerateTypeSynthClass (StringList &input, std::string& output, const void* name_token = NULL)
+ GenerateTypeSynthClass(StringList &input, std::string& output, const void* name_token = nullptr)
{
return false;
}
virtual bool
- GenerateTypeSynthClass (const char* oneliner, std::string& output, const void* name_token = NULL)
+ GenerateTypeSynthClass(const char* oneliner, std::string& output, const void* name_token = nullptr)
{
return false;
}
@@ -324,7 +323,6 @@ public:
SetBreakpointCommandCallbackFunction (BreakpointOptions *bp_options,
const char *function_name)
{
- return;
}
/// Set a one-liner as the callback for the watchpoint.
@@ -332,7 +330,6 @@ public:
SetWatchpointCommandCallback (WatchpointOptions *wp_options,
const char *oneliner)
{
- return;
}
virtual bool
@@ -349,7 +346,7 @@ public:
}
virtual size_t
- CalculateNumChildren(const StructuredData::ObjectSP &implementor)
+ CalculateNumChildren(const StructuredData::ObjectSP &implementor, uint32_t max)
{
return 0;
}
@@ -459,7 +456,7 @@ public:
virtual bool
GetDocumentationForItem (const char* item, std::string& dest)
{
- dest.clear();
+ dest.clear();
return false;
}
@@ -514,8 +511,8 @@ public:
int
GetMasterFileDescriptor ();
- CommandInterpreter &
- GetCommandInterpreter ();
+ CommandInterpreter &
+ GetCommandInterpreter();
static std::string
LanguageToString (lldb::ScriptLanguage language);
@@ -530,4 +527,4 @@ protected:
} // namespace lldb_private
-#endif // #ifndef liblldb_ScriptInterpreter_h_
+#endif // liblldb_ScriptInterpreter_h_
diff --git a/include/lldb/Interpreter/ScriptInterpreterNone.h b/include/lldb/Interpreter/ScriptInterpreterNone.h
deleted file mode 100644
index 6c82b60b0bcd..000000000000
--- a/include/lldb/Interpreter/ScriptInterpreterNone.h
+++ /dev/null
@@ -1,35 +0,0 @@
-//===-- ScriptInterpreterNone.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_ScriptInterpreterNone_h_
-#define liblldb_ScriptInterpreterNone_h_
-
-#include "lldb/Interpreter/ScriptInterpreter.h"
-
-namespace lldb_private {
-
-class ScriptInterpreterNone : public ScriptInterpreter
-{
-public:
-
- ScriptInterpreterNone (CommandInterpreter &interpreter);
-
- ~ScriptInterpreterNone ();
-
- bool
- ExecuteOneLine (const char *command, CommandReturnObject *result, const ExecuteScriptOptions &options = ExecuteScriptOptions());
-
- void
- ExecuteInterpreterLoop ();
-
-};
-
-} // namespace lldb_private
-
-#endif // #ifndef liblldb_ScriptInterpreterNone_h_
diff --git a/include/lldb/Symbol/ArmUnwindInfo.h b/include/lldb/Symbol/ArmUnwindInfo.h
new file mode 100644
index 000000000000..b19af23744a4
--- /dev/null
+++ b/include/lldb/Symbol/ArmUnwindInfo.h
@@ -0,0 +1,77 @@
+//===-- ArmUnwindInfo.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_ArmUnwindInfo_h_
+#define liblldb_ArmUnwindInfo_h_
+
+#include <vector>
+
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/RangeMap.h"
+#include "lldb/Host/Mutex.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/lldb-private.h"
+
+/*
+ * Unwind information reader and parser for the ARM exception handling ABI
+ *
+ * Implemented based on:
+ * Exception Handling ABI for the ARM Architecture
+ * Document number: ARM IHI 0038A (current through ABI r2.09)
+ * Date of Issue: 25th January 2007, reissued 30th November 2012
+ * http://infocenter.arm.com/help/topic/com.arm.doc.ihi0038a/IHI0038A_ehabi.pdf
+ */
+
+namespace lldb_private {
+
+class ArmUnwindInfo
+{
+public:
+ ArmUnwindInfo(const ObjectFile& objfile,
+ lldb::SectionSP& arm_exidx,
+ lldb::SectionSP& arm_extab);
+
+ ~ArmUnwindInfo();
+
+ bool
+ GetUnwindPlan(Target &target, const Address& addr, UnwindPlan& unwind_plan);
+
+private:
+ struct ArmExidxEntry
+ {
+ ArmExidxEntry(uint32_t f, lldb::addr_t a, uint32_t d);
+
+ bool
+ operator<(const ArmExidxEntry& other) const;
+
+ uint32_t file_address;
+ lldb::addr_t address;
+ uint32_t data;
+ };
+
+ const uint8_t*
+ GetExceptionHandlingTableEntry(const Address& addr);
+
+ uint8_t
+ GetByteAtOffset(const uint32_t* data, uint16_t offset) const;
+
+ uint64_t
+ GetULEB128(const uint32_t* data, uint16_t& offset, uint16_t max_offset) const;
+
+ const lldb::ByteOrder m_byte_order;
+ lldb::SectionSP m_arm_exidx_sp; // .ARM.exidx section
+ lldb::SectionSP m_arm_extab_sp; // .ARM.extab section
+ DataExtractor m_arm_exidx_data; // .ARM.exidx section data
+ DataExtractor m_arm_extab_data; // .ARM.extab section data
+ std::vector<ArmExidxEntry> m_exidx_entries;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_ArmUnwindInfo_h_
diff --git a/include/lldb/Symbol/Block.h b/include/lldb/Symbol/Block.h
index 59671b00b3b8..6c0793dda80f 100644
--- a/include/lldb/Symbol/Block.h
+++ b/include/lldb/Symbol/Block.h
@@ -10,6 +10,12 @@
#ifndef liblldb_Block_h_
#define liblldb_Block_h_
+// C Includes
+// C++ Includes
+#include <vector>
+
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/RangeMap.h"
@@ -17,7 +23,7 @@
#include "lldb/Core/UserID.h"
#include "lldb/Symbol/LineEntry.h"
#include "lldb/Symbol/SymbolContext.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
namespace lldb_private {
@@ -76,7 +82,7 @@ public:
//------------------------------------------------------------------
/// Destructor.
//------------------------------------------------------------------
- virtual ~Block ();
+ ~Block() override;
//------------------------------------------------------------------
/// Add a child to this object.
@@ -110,20 +116,20 @@ public:
///
/// @see SymbolContextScope
//------------------------------------------------------------------
- virtual void
- CalculateSymbolContext(SymbolContext* sc);
+ void
+ CalculateSymbolContext(SymbolContext* sc) override;
- virtual lldb::ModuleSP
- CalculateSymbolContextModule ();
+ lldb::ModuleSP
+ CalculateSymbolContextModule() override;
- virtual CompileUnit *
- CalculateSymbolContextCompileUnit ();
+ CompileUnit *
+ CalculateSymbolContextCompileUnit() override;
- virtual Function *
- CalculateSymbolContextFunction ();
+ Function *
+ CalculateSymbolContextFunction() override;
- virtual Block *
- CalculateSymbolContextBlock ();
+ Block *
+ CalculateSymbolContextBlock() override;
//------------------------------------------------------------------
/// Check if an offset is in one of the block offset ranges.
@@ -192,8 +198,8 @@ public:
///
/// @see SymbolContextScope
//------------------------------------------------------------------
- virtual void
- DumpSymbolContext(Stream *s);
+ void
+ DumpSymbolContext(Stream *s) override;
void
DumpAddressRanges (Stream *s,
@@ -209,20 +215,19 @@ public:
/// Get the parent block.
///
/// @return
- /// The parent block pointer, or NULL if this block has no
+ /// The parent block pointer, or nullptr if this block has no
/// parent.
//------------------------------------------------------------------
Block *
GetParent () const;
-
//------------------------------------------------------------------
/// Get the inlined block that contains this block.
///
/// @return
/// If this block contains inlined function info, it will return
/// this block, else parent blocks will be searched to see if
- /// any contain this block. NULL will be returned if this block
+ /// any contain this block. nullptr will be returned if this block
/// nor any parent blocks are inlined function blocks.
//------------------------------------------------------------------
Block *
@@ -232,7 +237,7 @@ public:
/// Get the inlined parent block for this block.
///
/// @return
- /// The parent block pointer, or NULL if this block has no
+ /// The parent block pointer, or nullptr if this block has no
/// parent.
//------------------------------------------------------------------
Block *
@@ -242,7 +247,7 @@ public:
/// Get the sibling block for this block.
///
/// @return
- /// The sibling block pointer, or NULL if this block has no
+ /// The sibling block pointer, or nullptr if this block has no
/// sibling.
//------------------------------------------------------------------
Block *
@@ -252,15 +257,13 @@ public:
/// Get the first child block.
///
/// @return
- /// The first child block pointer, or NULL if this block has no
+ /// The first child block pointer, or nullptr if this block has no
/// children.
//------------------------------------------------------------------
Block *
GetFirstChild () const
{
- if (m_children.empty())
- return NULL;
- return m_children.front().get();
+ return (m_children.empty() ? nullptr : m_children.front().get());
}
//------------------------------------------------------------------
@@ -278,7 +281,6 @@ public:
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.
@@ -330,7 +332,7 @@ public:
/// 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.
///
@@ -348,7 +350,7 @@ public:
/// Get const accessor for any inlined function information.
///
/// @return
- /// A const pointer to any inlined function information, or NULL
+ /// A const pointer to any inlined function information, or nullptr
/// if this is a regular block.
//------------------------------------------------------------------
const InlineFunctionInfo*
@@ -357,8 +359,8 @@ public:
return m_inlineInfoSP.get();
}
- clang::DeclContext *
- GetClangDeclContext();
+ CompilerDeclContext
+ GetDeclContext();
//------------------------------------------------------------------
/// Get the memory cost of this object.
@@ -377,16 +379,16 @@ public:
///
/// @param[in] name
/// The method name for the inlined function. This value should
- /// not be NULL.
+ /// not be nullptr.
///
/// @param[in] mangled
/// The mangled method name for the inlined function. This can
- /// be NULL if there is no mangled name for an inlined function
+ /// be nullptr if there is no mangled name for an inlined function
/// or if the name is the same as \a name.
///
/// @param[in] decl_ptr
/// A optional pointer to declaration information for the
- /// inlined function information. This value can be NULL to
+ /// inlined function information. This value can be nullptr to
/// indicate that no declaration information is available.
///
/// @param[in] call_decl_ptr
@@ -399,7 +401,6 @@ public:
const Declaration *decl_ptr,
const Declaration *call_decl_ptr);
-
void
SetParentScope (SymbolContextScope *parent_scope)
{
@@ -422,8 +423,6 @@ public:
m_variable_list_sp = variable_list_sp;
}
-
-
bool
BlockInfoHasBeenParsed() const
{
@@ -491,7 +490,6 @@ private:
DISALLOW_COPY_AND_ASSIGN (Block);
};
-
} // namespace lldb_private
-#endif // liblldb_Block_h_
+#endif // liblldb_Block_h_
diff --git a/include/lldb/Symbol/ClangASTContext.h b/include/lldb/Symbol/ClangASTContext.h
index a411e42fe0c5..0314ce060e38 100644
--- a/include/lldb/Symbol/ClangASTContext.h
+++ b/include/lldb/Symbol/ClangASTContext.h
@@ -14,7 +14,11 @@
#include <stdint.h>
// C++ Includes
+#include <functional>
#include <initializer_list>
+#include <map>
+#include <memory>
+#include <set>
#include <string>
#include <vector>
#include <utility>
@@ -24,36 +28,71 @@
#include "clang/AST/ASTContext.h"
#include "clang/AST/TemplateBase.h"
-
// Project includes
+#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/Core/ClangForward.h"
#include "lldb/Core/ConstString.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Symbol/TypeSystem.h"
namespace lldb_private {
class Declaration;
-class ClangASTContext
+class ClangASTContext : public TypeSystem
{
public:
typedef void (*CompleteTagDeclCallback)(void *baton, clang::TagDecl *);
typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton, clang::ObjCInterfaceDecl *);
-
+
+ //------------------------------------------------------------------
+ // llvm casting support
+ //------------------------------------------------------------------
+ static bool classof(const TypeSystem *ts)
+ {
+ return ts->getKind() == TypeSystem::eKindClang;
+ }
+
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
- ClangASTContext (const char *triple = NULL);
+ ClangASTContext(const char *triple = nullptr);
+
+ ~ClangASTContext() override;
+
+ //------------------------------------------------------------------
+ // PluginInterface functions
+ //------------------------------------------------------------------
+ ConstString
+ GetPluginName() override;
+
+ uint32_t
+ GetPluginVersion() override;
+
+ static ConstString
+ GetPluginNameStatic ();
- ~ClangASTContext();
+ static lldb::TypeSystemSP
+ CreateInstance (lldb::LanguageType language, Module *module, Target *target);
+ static void
+ EnumerateSupportedLanguages(std::set<lldb::LanguageType> &languages_for_types, std::set<lldb::LanguageType> &languages_for_expressions);
+
+ static void
+ Initialize ();
+
+ static void
+ Terminate ();
+
static ClangASTContext*
GetASTContext (clang::ASTContext* ast_ctx);
clang::ASTContext *
getASTContext();
-
+
+ void setASTContext(clang::ASTContext* ast_ctx);
+
clang::Builtin::Context *
getBuiltinContext();
@@ -78,6 +117,9 @@ public:
clang::DiagnosticConsumer *
getDiagnosticConsumer();
+ clang::MangleContext *
+ getMangleContext();
+
std::shared_ptr<clang::TargetOptions> &getTargetOptions();
clang::TargetInfo *
@@ -109,7 +151,16 @@ public:
{
return ClangASTContext::GetCompleteDecl(getASTContext(), decl);
}
-
+
+ static void
+ DumpDeclHiearchy (clang::Decl *decl);
+
+ static void
+ DumpDeclContextHiearchy (clang::DeclContext *decl_ctx);
+
+ static bool
+ DeclsAreEquivalent (clang::Decl *lhs_decl, clang::Decl *rhs_decl);
+
static bool
GetCompleteDecl (clang::ASTContext *ast,
clang::Decl *decl);
@@ -141,47 +192,53 @@ public:
//------------------------------------------------------------------
// Basic Types
//------------------------------------------------------------------
- ClangASTType
+ CompilerType
GetBuiltinTypeForEncodingAndBitSize (lldb::Encoding encoding,
- uint32_t bit_size);
+ size_t bit_size) override;
- static ClangASTType
+ static CompilerType
GetBuiltinTypeForEncodingAndBitSize (clang::ASTContext *ast,
lldb::Encoding encoding,
uint32_t bit_size);
- ClangASTType
+ CompilerType
GetBasicType (lldb::BasicType type);
- static ClangASTType
+ static CompilerType
GetBasicType (clang::ASTContext *ast, lldb::BasicType type);
- static ClangASTType
+ static CompilerType
GetBasicType (clang::ASTContext *ast, const ConstString &name);
static lldb::BasicType
GetBasicTypeEnumeration (const ConstString &name);
- ClangASTType
+ CompilerType
GetBuiltinTypeForDWARFEncodingAndBitSize (
const char *type_name,
uint32_t dw_ate,
uint32_t bit_size);
- ClangASTType
+ CompilerType
GetCStringType(bool is_const);
- static ClangASTType
+ static CompilerType
GetUnknownAnyType(clang::ASTContext *ast);
- ClangASTType
+ CompilerType
GetUnknownAnyType()
{
return ClangASTContext::GetUnknownAnyType(getASTContext());
}
+ static clang::DeclContext *
+ GetDeclContextForType (clang::QualType type);
+
+ static clang::DeclContext *
+ GetDeclContextForType (const CompilerType& type);
+
uint32_t
- GetPointerByteSize ();
+ GetPointerByteSize () override;
static clang::DeclContext *
GetTranslationUnitDecl (clang::ASTContext *ast);
@@ -192,40 +249,30 @@ public:
return GetTranslationUnitDecl (getASTContext());
}
- static bool
- GetClassMethodInfoForDeclContext (clang::DeclContext *decl_ctx,
- lldb::LanguageType &language,
- bool &is_instance_method,
- ConstString &language_object_name);
-
- static ClangASTType
- CopyType(clang::ASTContext *dest_context,
- ClangASTType source_type);
-
static clang::Decl *
CopyDecl (clang::ASTContext *dest_context,
clang::ASTContext *source_context,
clang::Decl *source_decl);
static bool
- AreTypesSame(ClangASTType type1,
- ClangASTType type2,
+ AreTypesSame(CompilerType type1,
+ CompilerType type2,
bool ignore_qualifiers = false);
- static ClangASTType
+ static CompilerType
GetTypeForDecl (clang::NamedDecl *decl);
- static ClangASTType
+ static CompilerType
GetTypeForDecl (clang::TagDecl *decl);
- static ClangASTType
+ static CompilerType
GetTypeForDecl (clang::ObjCInterfaceDecl *objc_decl);
template <typename RecordDeclType>
- ClangASTType
+ CompilerType
GetTypeForIdentifier (const ConstString &type_name)
{
- ClangASTType clang_type;
+ CompilerType compiler_type;
if (type_name.GetLength())
{
@@ -241,17 +288,17 @@ public:
{
clang::NamedDecl *named_decl = result[0];
if (const RecordDeclType *record_decl = llvm::dyn_cast<RecordDeclType>(named_decl))
- clang_type.SetClangType(ast, clang::QualType(record_decl->getTypeForDecl(), 0));
+ compiler_type.SetCompilerType(ast, clang::QualType(record_decl->getTypeForDecl(), 0));
}
}
}
- return clang_type;
+ return compiler_type;
}
- ClangASTType
+ CompilerType
GetOrCreateStructForIdentifier (const ConstString &type_name,
- const std::initializer_list< std::pair < const char *, ClangASTType > >& type_fields,
+ const std::initializer_list< std::pair < const char *, CompilerType > >& type_fields,
bool packed = false);
//------------------------------------------------------------------
@@ -268,18 +315,13 @@ public:
GetNumBaseClasses (const clang::CXXRecordDecl *cxx_record_decl,
bool omit_empty_base_classes);
- static uint32_t
- GetIndexForRecordBase (const clang::RecordDecl *record_decl,
- const clang::CXXBaseSpecifier *base_spec,
- bool omit_empty_base_classes);
-
- ClangASTType
- CreateRecordType (clang::DeclContext *decl_ctx,
- lldb::AccessType access_type,
- const char *name,
- int kind,
- lldb::LanguageType language,
- ClangASTMetadata *metadata = NULL);
+ CompilerType
+ CreateRecordType(clang::DeclContext *decl_ctx,
+ lldb::AccessType access_type,
+ const char *name,
+ int kind,
+ lldb::LanguageType language,
+ ClangASTMetadata *metadata = nullptr);
class TemplateParameterInfos
{
@@ -328,7 +370,7 @@ public:
int kind,
const TemplateParameterInfos &infos);
- ClangASTType
+ CompilerType
CreateClassTemplateSpecializationType (clang::ClassTemplateSpecializationDecl *class_template_specialization_decl);
static clang::DeclContext *
@@ -354,17 +396,24 @@ public:
static bool
RecordHasFields (const clang::RecordDecl *record_decl);
-
- ClangASTType
- CreateObjCClass (const char *name,
- clang::DeclContext *decl_ctx,
- bool isForwardDecl,
- bool isInternal,
- ClangASTMetadata *metadata = NULL);
+ CompilerType
+ CreateObjCClass(const char *name,
+ clang::DeclContext *decl_ctx,
+ bool isForwardDecl,
+ bool isInternal,
+ ClangASTMetadata *metadata = nullptr);
+
+ bool
+ SetTagTypeKind (clang::QualType type, int kind) const;
+
+ bool
+ SetDefaultAccessForRecordFields (clang::RecordDecl* record_decl,
+ int default_accessibility,
+ int *assigned_accessibilities,
+ size_t num_assigned_accessibilities);
// Returns a mask containing bits from the ClangASTContext::eTypeXXX enumerations
-
//------------------------------------------------------------------
// Namespace Declarations
//------------------------------------------------------------------
@@ -380,21 +429,21 @@ public:
clang::FunctionDecl *
CreateFunctionDeclaration (clang::DeclContext *decl_ctx,
const char *name,
- const ClangASTType &function_Type,
+ const CompilerType &function_Type,
int storage,
bool is_inline);
- static ClangASTType
+ static CompilerType
CreateFunctionType (clang::ASTContext *ast,
- const ClangASTType &result_type,
- const ClangASTType *args,
+ const CompilerType &result_type,
+ const CompilerType *args,
unsigned num_args,
bool is_variadic,
unsigned type_quals);
- ClangASTType
- CreateFunctionType (const ClangASTType &result_type,
- const ClangASTType *args,
+ CompilerType
+ CreateFunctionType (const CompilerType &result_type,
+ const CompilerType *args,
unsigned num_args,
bool is_variadic,
unsigned type_quals)
@@ -409,7 +458,7 @@ public:
clang::ParmVarDecl *
CreateParameterDeclaration (const char *name,
- const ClangASTType &param_type,
+ const CompilerType &param_type,
int storage);
void
@@ -421,57 +470,732 @@ public:
// Array Types
//------------------------------------------------------------------
- ClangASTType
- CreateArrayType (const ClangASTType &element_type,
+ CompilerType
+ CreateArrayType (const CompilerType &element_type,
size_t element_count,
bool is_vector);
//------------------------------------------------------------------
// Enumeration Types
//------------------------------------------------------------------
- ClangASTType
+ CompilerType
CreateEnumerationType (const char *name,
clang::DeclContext *decl_ctx,
const Declaration &decl,
- const ClangASTType &integer_qual_type);
+ const CompilerType &integer_qual_type);
//------------------------------------------------------------------
// Integer type functions
//------------------------------------------------------------------
-
- ClangASTType
- GetIntTypeFromBitSize (size_t bit_size, bool is_signed)
- {
- return GetIntTypeFromBitSize (getASTContext(), bit_size, is_signed);
- }
-
- static ClangASTType
+
+ static CompilerType
GetIntTypeFromBitSize (clang::ASTContext *ast,
size_t bit_size, bool is_signed);
- ClangASTType
+ CompilerType
GetPointerSizedIntType (bool is_signed)
{
return GetPointerSizedIntType (getASTContext(), is_signed);
}
- static ClangASTType
+ 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;
+
+ //------------------------------------------------------------------
+ // ClangASTContext callbacks for external source lookups.
+ //------------------------------------------------------------------
+ static void
+ CompleteTagDecl (void *baton, clang::TagDecl *);
+
+ static void
+ CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *);
+
+ static bool
+ LayoutRecordType(void *baton,
+ const clang::RecordDecl *record_decl,
+ uint64_t &size,
+ uint64_t &alignment,
+ llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets);
+
+ //----------------------------------------------------------------------
+ // CompilerDecl override functions
+ //----------------------------------------------------------------------
+ lldb::VariableSP
+ DeclGetVariable (void *opaque_decl) override;
+
+ void
+ DeclLinkToObject (void *opaque_decl, std::shared_ptr<void> object) override;
- ClangASTType
- GetFloatTypeFromBitSize (size_t bit_size)
+ ConstString
+ DeclGetName (void *opaque_decl) override;
+
+ ConstString
+ DeclGetMangledName (void *opaque_decl) override;
+
+ CompilerDeclContext
+ DeclGetDeclContext (void *opaque_decl) override;
+
+ CompilerType
+ DeclGetFunctionReturnType(void *opaque_decl) override;
+
+ size_t
+ DeclGetFunctionNumArguments(void *opaque_decl) override;
+
+ CompilerType
+ DeclGetFunctionArgumentType (void *opaque_decl, size_t arg_idx) override;
+
+ //----------------------------------------------------------------------
+ // CompilerDeclContext override functions
+ //----------------------------------------------------------------------
+
+ std::vector<CompilerDecl>
+ DeclContextFindDeclByName (void *opaque_decl_ctx, ConstString name) override;
+
+ bool
+ DeclContextIsStructUnionOrClass (void *opaque_decl_ctx) override;
+
+ ConstString
+ DeclContextGetName (void *opaque_decl_ctx) override;
+
+ bool
+ DeclContextIsClassMethod (void *opaque_decl_ctx,
+ lldb::LanguageType *language_ptr,
+ bool *is_instance_method_ptr,
+ ConstString *language_object_name_ptr) override;
+
+ //----------------------------------------------------------------------
+ // Clang specific CompilerType predicates
+ //----------------------------------------------------------------------
+
+ static bool
+ IsClangType (const CompilerType &ct)
{
- return GetFloatTypeFromBitSize (getASTContext(), bit_size);
+ return llvm::dyn_cast_or_null<ClangASTContext>(ct.GetTypeSystem()) != nullptr && ct.GetOpaqueQualType() != nullptr;
}
- static ClangASTType
- GetFloatTypeFromBitSize (clang::ASTContext *ast,
- size_t bit_size);
+ //----------------------------------------------------------------------
+ // Clang specific clang::DeclContext functions
+ //----------------------------------------------------------------------
+
+ static clang::DeclContext *
+ DeclContextGetAsDeclContext (const CompilerDeclContext &dc);
+
+ static clang::ObjCMethodDecl *
+ DeclContextGetAsObjCMethodDecl (const CompilerDeclContext &dc);
+
+ static clang::CXXMethodDecl *
+ DeclContextGetAsCXXMethodDecl (const CompilerDeclContext &dc);
+
+ static clang::FunctionDecl *
+ DeclContextGetAsFunctionDecl (const CompilerDeclContext &dc);
+
+ static clang::NamespaceDecl *
+ DeclContextGetAsNamespaceDecl (const CompilerDeclContext &dc);
+
+ static ClangASTMetadata *
+ DeclContextGetMetaData (const CompilerDeclContext &dc, const void *object);
+
+ static clang::ASTContext *
+ DeclContextGetClangASTContext (const CompilerDeclContext &dc);
+
+ //----------------------------------------------------------------------
+ // Tests
+ //----------------------------------------------------------------------
+
+ bool
+ IsArrayType (lldb::opaque_compiler_type_t type,
+ CompilerType *element_type,
+ uint64_t *size,
+ bool *is_incomplete) override;
+
+ bool
+ IsVectorType (lldb::opaque_compiler_type_t type,
+ CompilerType *element_type,
+ uint64_t *size) override;
+
+ bool
+ IsAggregateType (lldb::opaque_compiler_type_t type) override;
+
+ bool
+ IsAnonymousType (lldb::opaque_compiler_type_t type) override;
+
+ bool
+ IsBeingDefined (lldb::opaque_compiler_type_t type) override;
+
+ bool
+ IsCharType (lldb::opaque_compiler_type_t type) override;
+
+ bool
+ IsCompleteType (lldb::opaque_compiler_type_t type) override;
+
+ bool
+ IsConst(lldb::opaque_compiler_type_t type) override;
+
+ bool
+ IsCStringType (lldb::opaque_compiler_type_t type, uint32_t &length) override;
+
+ static bool
+ IsCXXClassType (const CompilerType& type);
+
+ bool
+ IsDefined(lldb::opaque_compiler_type_t type) override;
+
+ bool
+ IsFloatingPointType (lldb::opaque_compiler_type_t type, uint32_t &count, bool &is_complex) override;
+
+ bool
+ IsFunctionType (lldb::opaque_compiler_type_t type, bool *is_variadic_ptr) override;
+
+ uint32_t
+ IsHomogeneousAggregate (lldb::opaque_compiler_type_t type, CompilerType* base_type_ptr) override;
+
+ size_t
+ GetNumberOfFunctionArguments (lldb::opaque_compiler_type_t type) override;
+
+ CompilerType
+ GetFunctionArgumentAtIndex (lldb::opaque_compiler_type_t type, const size_t index) override;
+
+ bool
+ IsFunctionPointerType (lldb::opaque_compiler_type_t type) override;
+
+ bool
+ IsIntegerType (lldb::opaque_compiler_type_t type, bool &is_signed) override;
+
+ static bool
+ IsObjCClassType (const CompilerType& type);
+
+ static bool
+ IsObjCClassTypeAndHasIVars (const CompilerType& type, bool check_superclass);
+
+ static bool
+ IsObjCObjectOrInterfaceType (const CompilerType& type);
+
+ static bool
+ IsObjCObjectPointerType(const CompilerType& type, CompilerType *target_type = nullptr);
+
+ bool
+ IsPolymorphicClass (lldb::opaque_compiler_type_t type) override;
+
+ bool
+ IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
+ CompilerType *target_type, // Can pass nullptr
+ bool check_cplusplus,
+ bool check_objc) override;
+
+ bool
+ IsRuntimeGeneratedType (lldb::opaque_compiler_type_t type) override;
+
+ bool
+ IsPointerType (lldb::opaque_compiler_type_t type, CompilerType *pointee_type) override;
+
+ bool
+ IsPointerOrReferenceType (lldb::opaque_compiler_type_t type, CompilerType *pointee_type) override;
+
+ bool
+ IsReferenceType (lldb::opaque_compiler_type_t type, CompilerType *pointee_type, bool* is_rvalue) override;
+
+ bool
+ IsScalarType (lldb::opaque_compiler_type_t type) override;
+
+ bool
+ IsTypedefType (lldb::opaque_compiler_type_t type) override;
+
+ bool
+ IsVoidType (lldb::opaque_compiler_type_t type) override;
+
+ bool
+ SupportsLanguage (lldb::LanguageType language) override;
+
+ static bool
+ GetCXXClassName (const CompilerType& type, std::string &class_name);
+
+ static bool
+ GetObjCClassName (const CompilerType& type, std::string &class_name);
+
+ //----------------------------------------------------------------------
+ // Type Completion
+ //----------------------------------------------------------------------
+
+ bool
+ GetCompleteType (lldb::opaque_compiler_type_t type) override;
+
+ //----------------------------------------------------------------------
+ // Accessors
+ //----------------------------------------------------------------------
+
+ ConstString
+ GetTypeName (lldb::opaque_compiler_type_t type) override;
+
+ uint32_t
+ GetTypeInfo (lldb::opaque_compiler_type_t type, CompilerType *pointee_or_element_compiler_type) override;
+
+ lldb::LanguageType
+ GetMinimumLanguage (lldb::opaque_compiler_type_t type) override;
+
+ lldb::TypeClass
+ GetTypeClass (lldb::opaque_compiler_type_t type) override;
+
+ unsigned
+ GetTypeQualifiers(lldb::opaque_compiler_type_t type) override;
+
+ //----------------------------------------------------------------------
+ // Creating related types
+ //----------------------------------------------------------------------
+
+ // Using the current type, create a new typedef to that type using "typedef_name"
+ // as the name and "decl_ctx" as the decl context.
+ static CompilerType
+ CreateTypedefType (const CompilerType& type,
+ const char *typedef_name,
+ const CompilerDeclContext &compiler_decl_ctx);
+
+ CompilerType
+ GetArrayElementType (lldb::opaque_compiler_type_t type, uint64_t *stride) override;
+
+ CompilerType
+ GetCanonicalType (lldb::opaque_compiler_type_t type) override;
+
+ CompilerType
+ GetFullyUnqualifiedType (lldb::opaque_compiler_type_t type) override;
+
+ // Returns -1 if this isn't a function of if the function doesn't have a prototype
+ // Returns a value >= 0 if there is a prototype.
+ int
+ GetFunctionArgumentCount (lldb::opaque_compiler_type_t type) override;
+
+ CompilerType
+ GetFunctionArgumentTypeAtIndex (lldb::opaque_compiler_type_t type, size_t idx) override;
+
+ CompilerType
+ GetFunctionReturnType (lldb::opaque_compiler_type_t type) override;
+
+ size_t
+ GetNumMemberFunctions (lldb::opaque_compiler_type_t type) override;
+
+ TypeMemberFunctionImpl
+ GetMemberFunctionAtIndex (lldb::opaque_compiler_type_t type, size_t idx) override;
+
+ CompilerType
+ GetNonReferenceType (lldb::opaque_compiler_type_t type) override;
+
+ CompilerType
+ GetPointeeType (lldb::opaque_compiler_type_t type) override;
+
+ CompilerType
+ GetPointerType (lldb::opaque_compiler_type_t type) override;
+
+ CompilerType
+ GetLValueReferenceType (lldb::opaque_compiler_type_t type) override;
+
+ CompilerType
+ GetRValueReferenceType (lldb::opaque_compiler_type_t type) override;
+
+ CompilerType
+ AddConstModifier (lldb::opaque_compiler_type_t type) override;
+
+ CompilerType
+ AddVolatileModifier (lldb::opaque_compiler_type_t type) override;
+
+ CompilerType
+ AddRestrictModifier (lldb::opaque_compiler_type_t type) override;
+
+ CompilerType
+ CreateTypedef (lldb::opaque_compiler_type_t type, const char *name, const CompilerDeclContext &decl_ctx) override;
+
+ // If the current object represents a typedef type, get the underlying type
+ CompilerType
+ GetTypedefedType (lldb::opaque_compiler_type_t type) override;
+
+ static CompilerType
+ RemoveFastQualifiers (const CompilerType& type);
+
+ //----------------------------------------------------------------------
+ // Create related types using the current type's AST
+ //----------------------------------------------------------------------
+ CompilerType
+ GetBasicTypeFromAST (lldb::BasicType basic_type) override;
+
+ //----------------------------------------------------------------------
+ // Exploring the type
+ //----------------------------------------------------------------------
+
+ uint64_t
+ GetByteSize (lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope)
+ {
+ return (GetBitSize (type, exe_scope) + 7) / 8;
+ }
+
+ uint64_t
+ GetBitSize (lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override;
+
+ lldb::Encoding
+ GetEncoding (lldb::opaque_compiler_type_t type, uint64_t &count) override;
+
+ lldb::Format
+ GetFormat (lldb::opaque_compiler_type_t type) override;
+
+ size_t
+ GetTypeBitAlign (lldb::opaque_compiler_type_t type) override;
+
+ uint32_t
+ GetNumChildren (lldb::opaque_compiler_type_t type, bool omit_empty_base_classes) override;
+
+ CompilerType
+ GetBuiltinTypeByName (const ConstString &name) override;
+
+ lldb::BasicType
+ GetBasicTypeEnumeration (lldb::opaque_compiler_type_t type) override;
+
+ static lldb::BasicType
+ GetBasicTypeEnumeration (lldb::opaque_compiler_type_t type, const ConstString &name);
+
+ void
+ ForEachEnumerator (lldb::opaque_compiler_type_t type, std::function <bool (const CompilerType &integer_type, const ConstString &name, const llvm::APSInt &value)> const &callback) override;
+
+ uint32_t
+ GetNumFields (lldb::opaque_compiler_type_t type) override;
+
+ CompilerType
+ GetFieldAtIndex (lldb::opaque_compiler_type_t type,
+ size_t idx,
+ std::string& name,
+ uint64_t *bit_offset_ptr,
+ uint32_t *bitfield_bit_size_ptr,
+ bool *is_bitfield_ptr) override;
+
+ uint32_t
+ GetNumDirectBaseClasses (lldb::opaque_compiler_type_t type) override;
+
+ uint32_t
+ GetNumVirtualBaseClasses (lldb::opaque_compiler_type_t type) override;
+
+ CompilerType
+ GetDirectBaseClassAtIndex (lldb::opaque_compiler_type_t type,
+ size_t idx,
+ uint32_t *bit_offset_ptr) override;
+
+ CompilerType
+ GetVirtualBaseClassAtIndex (lldb::opaque_compiler_type_t type,
+ size_t idx,
+ uint32_t *bit_offset_ptr) override;
+
+ static uint32_t
+ GetNumPointeeChildren (clang::QualType type);
+
+ CompilerType
+ GetChildCompilerTypeAtIndex (lldb::opaque_compiler_type_t type,
+ ExecutionContext *exe_ctx,
+ size_t idx,
+ bool transparent_pointers,
+ bool omit_empty_base_classes,
+ bool ignore_array_bounds,
+ std::string& child_name,
+ uint32_t &child_byte_size,
+ int32_t &child_byte_offset,
+ uint32_t &child_bitfield_bit_size,
+ uint32_t &child_bitfield_bit_offset,
+ bool &child_is_base_class,
+ bool &child_is_deref_of_parent,
+ ValueObject *valobj,
+ uint64_t &language_flags) override;
+
+ // Lookup a child given a name. This function will match base class names
+ // and member member names in "clang_type" only, not descendants.
+ uint32_t
+ GetIndexOfChildWithName (lldb::opaque_compiler_type_t type,
+ const char *name,
+ bool omit_empty_base_classes) override;
+
+ // Lookup a child member given a name. This function will match member names
+ // only and will descend into "clang_type" children in search for the first
+ // member in this class, or any base class that matches "name".
+ // TODO: Return all matches for a given name by returning a vector<vector<uint32_t>>
+ // so we catch all names that match a given child name, not just the first.
+ size_t
+ GetIndexOfChildMemberWithName (lldb::opaque_compiler_type_t type,
+ const char *name,
+ bool omit_empty_base_classes,
+ std::vector<uint32_t>& child_indexes) override;
+
+ size_t
+ GetNumTemplateArguments (lldb::opaque_compiler_type_t type) override;
+
+ CompilerType
+ GetTemplateArgument (lldb::opaque_compiler_type_t type,
+ size_t idx,
+ lldb::TemplateArgumentKind &kind) override;
+
+ CompilerType
+ GetTypeForFormatters (void* type) override;
+
+#define LLDB_INVALID_DECL_LEVEL UINT32_MAX
+ // LLDB_INVALID_DECL_LEVEL is returned by CountDeclLevels if
+ // child_decl_ctx could not be found in decl_ctx.
+ uint32_t
+ CountDeclLevels (clang::DeclContext *frame_decl_ctx,
+ clang::DeclContext *child_decl_ctx,
+ ConstString *child_name = nullptr,
+ CompilerType *child_type = nullptr);
+
+ //----------------------------------------------------------------------
+ // Modifying RecordType
+ //----------------------------------------------------------------------
+ static clang::FieldDecl *
+ AddFieldToRecordType (const CompilerType& type,
+ const char *name,
+ const CompilerType &field_type,
+ lldb::AccessType access,
+ uint32_t bitfield_bit_size);
+
+ static void
+ BuildIndirectFields (const CompilerType& type);
+
+ static void
+ SetIsPacked (const CompilerType& type);
+
+ static clang::VarDecl *
+ AddVariableToRecordType (const CompilerType& type,
+ const char *name,
+ const CompilerType &var_type,
+ lldb::AccessType access);
+
+ clang::CXXMethodDecl *
+ AddMethodToCXXRecordType (lldb::opaque_compiler_type_t type,
+ const char *name,
+ const CompilerType &method_type,
+ lldb::AccessType access,
+ bool is_virtual,
+ bool is_static,
+ bool is_inline,
+ bool is_explicit,
+ bool is_attr_used,
+ bool is_artificial);
+
+ // C++ Base Classes
+ clang::CXXBaseSpecifier *
+ CreateBaseClassSpecifier (lldb::opaque_compiler_type_t type,
+ lldb::AccessType access,
+ bool is_virtual,
+ bool base_of_class);
+
+ static void
+ DeleteBaseClassSpecifiers (clang::CXXBaseSpecifier **base_classes,
+ unsigned num_base_classes);
+
+ bool
+ SetBaseClassesForClassType (lldb::opaque_compiler_type_t type,
+ clang::CXXBaseSpecifier const * const *base_classes,
+ unsigned num_base_classes);
+
+ static bool
+ SetObjCSuperClass (const CompilerType& type,
+ const CompilerType &superclass_compiler_type);
+
+ static bool
+ AddObjCClassProperty (const CompilerType& type,
+ const char *property_name,
+ const CompilerType &property_compiler_type,
+ clang::ObjCIvarDecl *ivar_decl,
+ const char *property_setter_name,
+ const char *property_getter_name,
+ uint32_t property_attributes,
+ ClangASTMetadata *metadata);
+
+ static clang::ObjCMethodDecl *
+ AddMethodToObjCObjectType (const CompilerType& type,
+ const char *name, // the full symbol name as seen in the symbol table (lldb::opaque_compiler_type_t type, "-[NString stringWithCString:]")
+ const CompilerType &method_compiler_type,
+ lldb::AccessType access,
+ bool is_artificial);
+
+ static bool
+ SetHasExternalStorage (lldb::opaque_compiler_type_t type, bool has_extern);
+
+
+ static bool
+ CanImport (const CompilerType &type, lldb_private::ClangASTImporter &importer);
+
+ static bool
+ Import (const CompilerType &type, lldb_private::ClangASTImporter &importer);
+
+ static bool
+ GetHasExternalStorage (const CompilerType &type);
+ //------------------------------------------------------------------
+ // Tag Declarations
+ //------------------------------------------------------------------
+ static bool
+ StartTagDeclarationDefinition (const CompilerType &type);
+
+ static bool
+ CompleteTagDeclarationDefinition (const CompilerType &type);
+
+ //----------------------------------------------------------------------
+ // Modifying Enumeration types
+ //----------------------------------------------------------------------
+ bool
+ AddEnumerationValueToEnumerationType (lldb::opaque_compiler_type_t type,
+ const CompilerType &enumerator_qual_type,
+ const Declaration &decl,
+ const char *name,
+ int64_t enum_value,
+ uint32_t enum_value_bit_size);
+
+ CompilerType
+ GetEnumerationIntegerType (lldb::opaque_compiler_type_t type);
+
+ //------------------------------------------------------------------
+ // Pointers & References
+ //------------------------------------------------------------------
+
+ // Call this function using the class type when you want to make a
+ // member pointer type to pointee_type.
+ static CompilerType
+ CreateMemberPointerType (const CompilerType& type, const CompilerType &pointee_type);
+
+ // Converts "s" to a floating point value and place resulting floating
+ // point bytes in the "dst" buffer.
+ size_t
+ ConvertStringToFloatValue (lldb::opaque_compiler_type_t type,
+ const char *s,
+ uint8_t *dst,
+ size_t dst_size) override;
+
+ //----------------------------------------------------------------------
+ // Dumping types
+ //----------------------------------------------------------------------
+ void
+ DumpValue (lldb::opaque_compiler_type_t type,
+ ExecutionContext *exe_ctx,
+ Stream *s,
+ lldb::Format format,
+ const DataExtractor &data,
+ lldb::offset_t data_offset,
+ size_t data_byte_size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset,
+ bool show_types,
+ bool show_summary,
+ bool verbose,
+ uint32_t depth) override;
+
+ bool
+ DumpTypeValue (lldb::opaque_compiler_type_t type,
+ Stream *s,
+ lldb::Format format,
+ const DataExtractor &data,
+ lldb::offset_t data_offset,
+ size_t data_byte_size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset,
+ ExecutionContextScope *exe_scope) override;
+
+ void
+ DumpSummary (lldb::opaque_compiler_type_t type,
+ ExecutionContext *exe_ctx,
+ Stream *s,
+ const DataExtractor &data,
+ lldb::offset_t data_offset,
+ size_t data_byte_size) override;
+
+ void
+ DumpTypeDescription (lldb::opaque_compiler_type_t type) override; // Dump to stdout
+
+ void
+ DumpTypeDescription (lldb::opaque_compiler_type_t type, Stream *s) override;
+
+ static void
+ DumpTypeName (const CompilerType &type);
+
+ static clang::EnumDecl *
+ GetAsEnumDecl (const CompilerType& type);
+
+ static clang::RecordDecl *
+ GetAsRecordDecl (const CompilerType& type);
+
+ static clang::TagDecl *
+ GetAsTagDecl (const CompilerType& type);
+
+ clang::CXXRecordDecl *
+ GetAsCXXRecordDecl (lldb::opaque_compiler_type_t type);
+
+ static clang::ObjCInterfaceDecl *
+ GetAsObjCInterfaceDecl (const CompilerType& type);
+
+ static clang::QualType
+ GetQualType (const CompilerType& type)
+ {
+ // Make sure we have a clang type before making a clang::QualType
+ if (type.GetOpaqueQualType())
+ {
+ ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(type.GetTypeSystem());
+ if (ast)
+ return clang::QualType::getFromOpaquePtr(type.GetOpaqueQualType());
+ }
+ return clang::QualType();
+ }
+
+ static clang::QualType
+ GetCanonicalQualType (const CompilerType& type)
+ {
+ // Make sure we have a clang type before making a clang::QualType
+ ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(type.GetTypeSystem());
+ if (ast)
+ return clang::QualType::getFromOpaquePtr(type.GetOpaqueQualType()).getCanonicalType();
+ return clang::QualType();
+ }
+
+ clang::ClassTemplateDecl *
+ ParseClassTemplateDecl (clang::DeclContext *decl_ctx,
+ lldb::AccessType access_type,
+ const char *parent_name,
+ int tag_decl_kind,
+ const ClangASTContext::TemplateParameterInfos &template_param_infos);
+
+ clang::BlockDecl *
+ CreateBlockDeclaration (clang::DeclContext *ctx);
+
+ clang::UsingDirectiveDecl *
+ CreateUsingDirectiveDeclaration (clang::DeclContext *decl_ctx, clang::NamespaceDecl *ns_decl);
+
+ clang::UsingDecl *
+ CreateUsingDeclaration (clang::DeclContext *current_decl_ctx, clang::NamedDecl *target);
+
+ clang::VarDecl *
+ CreateVariableDeclaration (clang::DeclContext *decl_context, const char *name, clang::QualType type);
+
protected:
+ static clang::QualType
+ GetQualType (lldb::opaque_compiler_type_t type)
+ {
+ if (type)
+ return clang::QualType::getFromOpaquePtr(type);
+ return clang::QualType();
+ }
+
+ static clang::QualType
+ GetCanonicalQualType (lldb::opaque_compiler_type_t type)
+ {
+ if (type)
+ return clang::QualType::getFromOpaquePtr(type).getCanonicalType();
+ return clang::QualType();
+ }
+
//------------------------------------------------------------------
// Classes that inherit from ClangASTContext can see and modify these
//------------------------------------------------------------------
@@ -488,10 +1212,17 @@ protected:
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<DWARFASTParser> m_dwarf_ast_parser_ap;
+ std::unique_ptr<ClangASTSource> m_scratch_ast_source_ap;
+ std::unique_ptr<clang::MangleContext> m_mangle_ctx_ap;
CompleteTagDeclCallback m_callback_tag_decl;
CompleteObjCInterfaceDeclCallback m_callback_objc_decl;
void * m_callback_baton;
uint32_t m_pointer_byte_size;
+ bool m_ast_owned;
+ bool m_can_evaluate_expressions;
+ std::map<void *, std::shared_ptr<void>> m_decl_objects;
+
private:
//------------------------------------------------------------------
// For ClangASTContext only
@@ -500,6 +1231,36 @@ private:
const ClangASTContext& operator=(const ClangASTContext&);
};
+class ClangASTContextForExpressions : public ClangASTContext
+{
+public:
+ ClangASTContextForExpressions (Target &target);
+
+ ~ClangASTContextForExpressions() override = default;
+
+ UserExpression *
+ GetUserExpression (const char *expr,
+ const char *expr_prefix,
+ lldb::LanguageType language,
+ Expression::ResultType desired_type,
+ const EvaluateExpressionOptions &options) override;
+
+ FunctionCaller *
+ GetFunctionCaller (const CompilerType &return_type,
+ const Address& function_address,
+ const ValueList &arg_value_list,
+ const char *name) override;
+
+ UtilityFunction *
+ GetUtilityFunction(const char *text, const char *name) override;
+
+ PersistentExpressionState *
+ GetPersistentExpressionState() override;
+private:
+ lldb::TargetWP m_target_wp;
+ lldb::ClangPersistentVariablesUP m_persistent_variables; ///< These are the persistent variables associated with this process for the expression parser.
+};
+
} // namespace lldb_private
-#endif // liblldb_ClangASTContext_h_
+#endif // liblldb_ClangASTContext_h_
diff --git a/include/lldb/Symbol/ClangASTImporter.h b/include/lldb/Symbol/ClangASTImporter.h
index ee4fcada8a6d..8c3f8735c2e1 100644
--- a/include/lldb/Symbol/ClangASTImporter.h
+++ b/include/lldb/Symbol/ClangASTImporter.h
@@ -10,14 +10,21 @@
#ifndef liblldb_ClangASTImporter_h_
#define liblldb_ClangASTImporter_h_
+// C Includes
+// C++ Includes
#include <map>
+#include <memory>
#include <set>
+#include <vector>
-#include "lldb/lldb-types.h"
+// Other libraries and framework includes
#include "clang/AST/ASTImporter.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/FileSystemOptions.h"
-#include "lldb/Symbol/ClangNamespaceDecl.h"
+
+// Project includes
+#include "lldb/lldb-types.h"
+#include "lldb/Symbol/CompilerDeclContext.h"
namespace lldb_private {
@@ -96,20 +103,24 @@ public:
clang::ASTContext *src_ctx,
clang::QualType type);
- lldb::clang_type_t
+ lldb::opaque_compiler_type_t
CopyType (clang::ASTContext *dst_ctx,
clang::ASTContext *src_ctx,
- lldb::clang_type_t type);
-
+ lldb::opaque_compiler_type_t type);
+
+ CompilerType
+ CopyType (ClangASTContext &dst,
+ const CompilerType &src_type);
+
clang::Decl *
CopyDecl (clang::ASTContext *dst_ctx,
clang::ASTContext *src_ctx,
clang::Decl *decl);
- lldb::clang_type_t
+ lldb::opaque_compiler_type_t
DeportType (clang::ASTContext *dst_ctx,
clang::ASTContext *src_ctx,
- lldb::clang_type_t type);
+ lldb::opaque_compiler_type_t type);
clang::Decl *
DeportDecl (clang::ASTContext *dst_ctx,
@@ -127,7 +138,10 @@ public:
bool
CompleteObjCInterfaceDecl (clang::ObjCInterfaceDecl *interface_decl);
-
+
+ bool
+ CompleteAndFetchChildren (clang::QualType type);
+
bool
RequireCompleteType (clang::QualType type);
@@ -155,7 +169,7 @@ public:
// Namespace maps
//
- typedef std::vector < std::pair<lldb::ModuleSP, ClangNamespaceDecl> > NamespaceMap;
+ typedef std::vector < std::pair<lldb::ModuleSP, CompilerDeclContext> > NamespaceMap;
typedef std::shared_ptr<NamespaceMap> NamespaceMapSP;
void RegisterNamespaceMap (const clang::NamespaceDecl *decl,
@@ -199,12 +213,13 @@ public:
void ForgetDestination (clang::ASTContext *dst_ctx);
void ForgetSource (clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx);
+
private:
struct DeclOrigin
{
DeclOrigin () :
- ctx(NULL),
- decl(NULL)
+ ctx(nullptr),
+ decl(nullptr)
{
}
@@ -230,7 +245,7 @@ private:
bool
Valid ()
{
- return (ctx != NULL || decl != NULL);
+ return (ctx != nullptr || decl != nullptr);
}
clang::ASTContext *ctx;
@@ -250,8 +265,8 @@ private:
*source_ctx,
master.m_file_manager,
true /*minimal*/),
- m_decls_to_deport(NULL),
- m_decls_already_deported(NULL),
+ m_decls_to_deport(nullptr),
+ m_decls_already_deported(nullptr),
m_master(master),
m_source_ctx(source_ctx)
{
@@ -276,9 +291,9 @@ private:
void ImportDefinitionTo (clang::Decl *to, clang::Decl *from);
- clang::Decl *Imported (clang::Decl *from, clang::Decl *to);
+ clang::Decl *Imported(clang::Decl *from, clang::Decl *to) override;
- clang::Decl *GetOriginalDecl (clang::Decl *To);
+ clang::Decl *GetOriginalDecl(clang::Decl *To) override;
std::set<clang::NamedDecl *> *m_decls_to_deport;
std::set<clang::NamedDecl *> *m_decls_already_deported;
@@ -297,7 +312,7 @@ private:
m_minions (),
m_origins (),
m_namespace_maps (),
- m_map_completer (NULL)
+ m_map_completer (nullptr)
{
}
@@ -368,6 +383,6 @@ private:
clang::FileManager m_file_manager;
};
-}
+} // namespace lldb_private
-#endif
+#endif // liblldb_ClangASTImporter_h_
diff --git a/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h b/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
index 41bb235636f0..5a00aa0072ab 100644
--- a/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
+++ b/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
@@ -11,18 +11,17 @@
#define liblldb_ClangExternalASTSourceCallbacks_h_
// C Includes
-// C++ Includes
-#include <string>
-#include <vector>
#include <stdint.h>
+// C++ Includes
// Other libraries and framework includes
+#include "llvm/ADT/DenseMap.h"
#include "clang/AST/CharUnits.h"
// Project includes
#include "lldb/lldb-enumerations.h"
#include "lldb/Core/ClangForward.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
namespace lldb_private {
@@ -30,7 +29,6 @@ namespace lldb_private {
class ClangExternalASTSourceCallbacks : public ClangExternalASTSourceCommon
{
public:
-
typedef void (*CompleteTagDeclCallback)(void *baton, clang::TagDecl *);
typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton, clang::ObjCInterfaceDecl *);
typedef void (*FindExternalVisibleDeclsByNameCallback)(void *baton, const clang::DeclContext *DC, clang::DeclarationName Name, llvm::SmallVectorImpl <clang::NamedDecl *> *results);
@@ -62,7 +60,7 @@ public:
{
// This method only needs to be implemented if the AST source ever
// passes back decl sets as VisibleDeclaration objects.
- return 0;
+ return nullptr;
}
clang::Stmt *
@@ -71,7 +69,7 @@ public:
// This operation is meant to be used via a LazyOffsetPtr. It only
// needs to be implemented if the AST source uses methods like
// FunctionDecl::setLazyBody when building decls.
- return 0;
+ return nullptr;
}
clang::Selector
@@ -91,23 +89,18 @@ public:
clang::CXXBaseSpecifier *
GetExternalCXXBaseSpecifiers(uint64_t Offset) override
{
- return NULL;
+ return nullptr;
}
virtual void
MaterializeVisibleDecls (const clang::DeclContext *decl_ctx)
{
- return;
}
- clang::ExternalLoadResult
- FindExternalLexicalDecls(const clang::DeclContext *decl_ctx, bool (*isKindWeWant)(clang::Decl::Kind),
- llvm::SmallVectorImpl<clang::Decl *> &decls) override
- {
- // This is used to support iterating through an entire lexical context,
- // which isn't something the debugger should ever need to do.
- return clang::ELR_Failure;
- }
+ void
+ FindExternalLexicalDecls(const clang::DeclContext *DC,
+ llvm::function_ref<bool(clang::Decl::Kind)> IsKindWeWant,
+ llvm::SmallVectorImpl<clang::Decl *> &Result) override;
bool FindExternalVisibleDeclsByName(const clang::DeclContext *decl_ctx, clang::DeclarationName decl_name) override;
@@ -119,6 +112,7 @@ public:
llvm::DenseMap<const clang::FieldDecl *, uint64_t> &FieldOffsets,
llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &BaseOffsets,
llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &VirtualBaseOffsets) override;
+
void
SetExternalSourceCallbacks (CompleteTagDeclCallback tag_decl_callback,
CompleteObjCInterfaceDeclCallback objc_decl_callback,
@@ -138,10 +132,10 @@ public:
{
if (callback_baton == m_callback_baton)
{
- m_callback_tag_decl = NULL;
- m_callback_objc_decl = NULL;
- m_callback_find_by_name = NULL;
- m_callback_layout_record_type = NULL;
+ m_callback_tag_decl = nullptr;
+ m_callback_objc_decl = nullptr;
+ m_callback_find_by_name = nullptr;
+ m_callback_layout_record_type = nullptr;
}
}
@@ -158,4 +152,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_ClangExternalASTSourceCallbacks_h_
+#endif // liblldb_ClangExternalASTSourceCallbacks_h_
diff --git a/include/lldb/Symbol/ClangExternalASTSourceCommon.h b/include/lldb/Symbol/ClangExternalASTSourceCommon.h
index 17650f7f14fd..711be42c15fb 100644
--- a/include/lldb/Symbol/ClangExternalASTSourceCommon.h
+++ b/include/lldb/Symbol/ClangExternalASTSourceCommon.h
@@ -20,6 +20,7 @@
// file. So we have to define NDEBUG when including clang headers to avoid any
// mismatches. This is covered by rdar://problem/8691220
+// C Includes
#if !defined(NDEBUG) && !defined(LLVM_NDEBUG_OFF)
#define LLDB_DEFINED_NDEBUG_FOR_CLANG
#define NDEBUG
@@ -27,8 +28,6 @@
#include <assert.h>
#endif
-#include "clang/AST/ExternalASTSource.h"
-
#ifdef LLDB_DEFINED_NDEBUG_FOR_CLANG
#undef NDEBUG
#undef LLDB_DEFINED_NDEBUG_FOR_CLANG
@@ -36,6 +35,11 @@
#include <assert.h>
#endif
+// C++ Includes
+// Other libraries and framework includes
+#include "clang/AST/ExternalASTSource.h"
+
+// Project includes
#include "lldb/lldb-defines.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/Core/dwarf.h"
@@ -124,8 +128,8 @@ public:
return lldb::eLanguageTypeC_plus_plus;
}
return lldb::eLanguageTypeUnknown;
-
}
+
const char *
GetObjectPtrName() const
{
@@ -137,7 +141,7 @@ public:
return "this";
}
else
- return NULL;
+ return nullptr;
}
bool
@@ -155,19 +159,19 @@ private:
lldb::user_id_t m_user_id;
uint64_t m_isa_ptr;
};
+
bool m_union_is_user_id : 1,
m_union_is_isa_ptr : 1,
m_has_object_ptr : 1,
m_is_self : 1,
m_is_dynamic_cxx : 1;
-
};
class ClangExternalASTSourceCommon : public clang::ExternalASTSource
{
public:
ClangExternalASTSourceCommon();
- ~ClangExternalASTSourceCommon();
+ ~ClangExternalASTSourceCommon() override;
ClangASTMetadata *GetMetadata(const void *object);
void SetMetadata(const void *object, ClangASTMetadata &metadata);
@@ -175,12 +179,13 @@ public:
static ClangExternalASTSourceCommon *
Lookup(clang::ExternalASTSource *source);
+
private:
typedef llvm::DenseMap<const void *, ClangASTMetadata> MetadataMap;
MetadataMap m_metadata;
};
-}
+} // namespace lldb_private
-#endif
+#endif // liblldb_ClangExternalASTSourceCommon_h
diff --git a/include/lldb/Symbol/ClangNamespaceDecl.h b/include/lldb/Symbol/ClangNamespaceDecl.h
deleted file mode 100644
index 13a4c0011aff..000000000000
--- a/include/lldb/Symbol/ClangNamespaceDecl.h
+++ /dev/null
@@ -1,105 +0,0 @@
-//===-- ClangNamespaceDecl.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_ClangNamespaceDecl_h_
-#define liblldb_ClangNamespaceDecl_h_
-
-#include <string>
-
-#include "lldb/lldb-public.h"
-#include "lldb/Core/ClangForward.h"
-
-namespace lldb_private {
-
-class ClangNamespaceDecl
-{
-public:
- ClangNamespaceDecl () :
- m_ast (NULL),
- m_namespace_decl (NULL)
- {
- }
-
- ClangNamespaceDecl (clang::ASTContext *ast, clang::NamespaceDecl *namespace_decl) :
- m_ast (ast),
- m_namespace_decl (namespace_decl)
- {
- }
-
- ClangNamespaceDecl (const ClangNamespaceDecl &rhs) :
- m_ast (rhs.m_ast),
- m_namespace_decl (rhs.m_namespace_decl)
- {
- }
-
- const ClangNamespaceDecl &
- operator = (const ClangNamespaceDecl &rhs)
- {
- m_ast = rhs.m_ast;
- m_namespace_decl = rhs.m_namespace_decl;
- return *this;
- }
-
- //------------------------------------------------------------------
- /// Convert to bool operator.
- ///
- /// This allows code to check a ClangNamespaceDecl object to see if
- /// it contains a valid namespace decl using code such as:
- ///
- /// @code
- /// ClangNamespaceDecl ns_decl(...);
- /// if (ns_decl)
- /// { ...
- /// @endcode
- ///
- /// @return
- /// /b True this object contains a valid namespace decl, \b
- /// false otherwise.
- //------------------------------------------------------------------
- explicit operator bool() const
- {
- return m_ast != NULL && m_namespace_decl != NULL;
- }
-
- clang::ASTContext *
- GetASTContext() const
- {
- return m_ast;
- }
-
- void
- SetASTContext (clang::ASTContext *ast)
- {
- m_ast = ast;
- }
-
- clang::NamespaceDecl *
- GetNamespaceDecl () const
- {
- return m_namespace_decl;
- }
-
- void
- SetNamespaceDecl (clang::NamespaceDecl *namespace_decl)
- {
- m_namespace_decl = namespace_decl;
- }
-
- std::string
- GetQualifiedName () const;
-
-protected:
- clang::ASTContext *m_ast;
- clang::NamespaceDecl *m_namespace_decl;
-};
-
-
-} // namespace lldb_private
-
-#endif // #ifndef liblldb_ClangNamespaceDecl_h_
diff --git a/include/lldb/Symbol/CompileUnit.h b/include/lldb/Symbol/CompileUnit.h
index e0c069352bf4..0c331c38f8c6 100644
--- a/include/lldb/Symbol/CompileUnit.h
+++ b/include/lldb/Symbol/CompileUnit.h
@@ -11,6 +11,7 @@
#define liblldb_CompUnit_h_
#include "lldb/lldb-enumerations.h"
+#include "lldb/Symbol/DebugMacros.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Core/FileSpecList.h"
#include "lldb/Core/ModuleChild.h"
@@ -66,9 +67,12 @@ public:
/// A language enumeration type that describes the main language
/// of this compile unit.
///
+ /// @param[in] is_optimized
+ /// true if this compile unit was compiled with optimization.
+ ///
/// @see lldb::LanguageType
//------------------------------------------------------------------
- CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const char *pathname, lldb::user_id_t uid, lldb::LanguageType language);
+ CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const char *pathname, lldb::user_id_t uid, lldb::LanguageType language, bool is_optimized);
//------------------------------------------------------------------
/// Construct with a module, file spec, UID and language.
@@ -98,15 +102,17 @@ public:
/// A language enumeration type that describes the main language
/// of this compile unit.
///
+ /// @param[in] is_optimized
+ /// true if this compile unit was compiled with optimization.
+ ///
/// @see lldb::LanguageType
//------------------------------------------------------------------
- CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const FileSpec &file_spec, lldb::user_id_t uid, lldb::LanguageType language);
+ CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const FileSpec &file_spec, lldb::user_id_t uid, lldb::LanguageType language, bool is_optimized);
//------------------------------------------------------------------
/// Destructor
//------------------------------------------------------------------
- virtual
- ~CompileUnit();
+ ~CompileUnit() override;
//------------------------------------------------------------------
/// Add a function to this compile unit.
@@ -125,22 +131,22 @@ public:
///
/// @see SymbolContextScope
//------------------------------------------------------------------
- virtual void
- CalculateSymbolContext(SymbolContext* sc);
+ void
+ CalculateSymbolContext(SymbolContext* sc) override;
- virtual lldb::ModuleSP
- CalculateSymbolContextModule ();
+ lldb::ModuleSP
+ CalculateSymbolContextModule() override;
- virtual CompileUnit *
- CalculateSymbolContextCompileUnit ();
+ CompileUnit *
+ CalculateSymbolContextCompileUnit() override;
//------------------------------------------------------------------
/// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
///
/// @see SymbolContextScope
//------------------------------------------------------------------
- virtual void
- DumpSymbolContext(Stream *s);
+ void
+ DumpSymbolContext(Stream *s) override;
lldb::LanguageType
GetLanguage();
@@ -245,6 +251,9 @@ public:
LineTable*
GetLineTable ();
+ DebugMacros*
+ GetDebugMacros ();
+
//------------------------------------------------------------------
/// Get the compile unit's support file list.
///
@@ -339,6 +348,9 @@ public:
void
SetLineTable(LineTable* line_table);
+ void
+ SetDebugMacros(const DebugMacrosSP &debug_macros);
+
//------------------------------------------------------------------
/// Set accessor for the variable list.
///
@@ -406,6 +418,22 @@ public:
SymbolContextList &sc_list);
+ //------------------------------------------------------------------
+ /// Get whether compiler optimizations were enabled for this compile unit
+ ///
+ /// "optimized" means that the debug experience may be difficult
+ /// for the user to understand. Variables may not be available when
+ /// the developer would expect them, stepping through the source lines
+ /// in the function may appear strange, etc.
+ ///
+ /// @return
+ /// Returns 'true' if this compile unit was compiled with
+ /// optimization. 'false' indicates that either the optimization
+ /// is unknown, or this compile unit was built without optimization.
+ //------------------------------------------------------------------
+ bool
+ GetIsOptimized ();
+
protected:
void *m_user_data; ///< User data for the SymbolFile parser to store information into.
lldb::LanguageType m_language; ///< The programming language enumeration value.
@@ -416,7 +444,9 @@ protected:
///< 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.
+ bool m_is_optimized; /// eLazyBoolYes if this compile unit was compiled with optimization.
private:
enum
@@ -425,8 +455,9 @@ private:
flagsParsedVariables = (1u << 1), ///< Have we already parsed globals and statics?
flagsParsedSupportFiles = (1u << 2), ///< Have we already parsed the support files for this compile unit?
flagsParsedLineTable = (1u << 3), ///< Have we parsed the line table already?
- flagsParsedLanguage = (1u << 4), ///< Have we parsed the line table already?
- flagsParsedImportedModules = (1u << 5) ///< Have we parsed the imported modules already?
+ flagsParsedLanguage = (1u << 4), ///< Have we parsed the language already?
+ flagsParsedImportedModules = (1u << 5), ///< Have we parsed the imported modules already?
+ flagsParsedDebugMacros = (1u << 6) ///< Have we parsed the debug macros already?
};
DISALLOW_COPY_AND_ASSIGN (CompileUnit);
@@ -434,4 +465,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_CompUnit_h_
+#endif // liblldb_CompUnit_h_
diff --git a/include/lldb/Symbol/CompilerDecl.h b/include/lldb/Symbol/CompilerDecl.h
new file mode 100644
index 000000000000..b749e79b459a
--- /dev/null
+++ b/include/lldb/Symbol/CompilerDecl.h
@@ -0,0 +1,135 @@
+//===-- CompilerDecl.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_CompilerDecl_h_
+#define liblldb_CompilerDecl_h_
+
+#include "lldb/lldb-private.h"
+#include "lldb/Core/ConstString.h"
+#include "lldb/Symbol/CompilerType.h"
+
+namespace lldb_private {
+
+class CompilerDecl
+{
+public:
+ //----------------------------------------------------------------------
+ // Constructors and Destructors
+ //----------------------------------------------------------------------
+ CompilerDecl () :
+ m_type_system (nullptr),
+ m_opaque_decl (nullptr)
+ {
+ }
+
+ CompilerDecl (TypeSystem *type_system, void *decl) :
+ m_type_system (type_system),
+ m_opaque_decl (decl)
+ {
+ }
+
+ ~CompilerDecl ()
+ {
+ }
+
+ //----------------------------------------------------------------------
+ // Tests
+ //----------------------------------------------------------------------
+
+ explicit operator bool () const
+ {
+ return IsValid ();
+ }
+
+ bool
+ operator < (const CompilerDecl &rhs) const
+ {
+ if (m_type_system == rhs.m_type_system)
+ return m_opaque_decl < rhs.m_opaque_decl;
+ return m_type_system < rhs.m_type_system;
+ }
+
+ bool
+ IsValid () const
+ {
+ return m_type_system != nullptr && m_opaque_decl != nullptr;
+ }
+
+ bool
+ IsClang () const;
+
+ //----------------------------------------------------------------------
+ // Object linked to the decl
+ //----------------------------------------------------------------------
+ lldb::VariableSP
+ GetAsVariable ();
+
+ //----------------------------------------------------------------------
+ // Accessors
+ //----------------------------------------------------------------------
+
+ TypeSystem *
+ GetTypeSystem() const
+ {
+ return m_type_system;
+ }
+
+ void *
+ GetOpaqueDecl() const
+ {
+ return m_opaque_decl;
+ }
+
+ void
+ SetDecl (TypeSystem* type_system, void* decl)
+ {
+ m_type_system = type_system;
+ m_opaque_decl = decl;
+ }
+
+ void
+ Clear()
+ {
+ m_type_system = nullptr;
+ m_opaque_decl = nullptr;
+ }
+
+ ConstString
+ GetName () const;
+
+ ConstString
+ GetMangledName () const;
+
+ CompilerDeclContext
+ GetDeclContext() const;
+
+ // If this decl represents a function, return the return type
+ CompilerType
+ GetFunctionReturnType() const;
+
+ // If this decl represents a function, return the number of arguments for the function
+ size_t
+ GetNumFunctionArguments() const;
+
+ // If this decl represents a function, return the argument type given a zero based argument index
+ CompilerType
+ GetFunctionArgumentType (size_t arg_idx) const;
+
+private:
+ TypeSystem *m_type_system;
+ void *m_opaque_decl;
+};
+
+bool operator == (const CompilerDecl &lhs, const CompilerDecl &rhs);
+bool operator != (const CompilerDecl &lhs, const CompilerDecl &rhs);
+
+
+} // namespace lldb_private
+
+#endif // #ifndef liblldb_CompilerDecl_h_
diff --git a/include/lldb/Symbol/CompilerDeclContext.h b/include/lldb/Symbol/CompilerDeclContext.h
new file mode 100644
index 000000000000..70399b2dbb37
--- /dev/null
+++ b/include/lldb/Symbol/CompilerDeclContext.h
@@ -0,0 +1,146 @@
+//===-- CompilerDeclContext.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_CompilerDeclContext_h_
+#define liblldb_CompilerDeclContext_h_
+
+#include <vector>
+
+#include "lldb/lldb-private.h"
+#include "lldb/Core/ConstString.h"
+
+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) :
+ m_type_system (type_system),
+ m_opaque_decl_ctx (decl_ctx)
+ {
+ }
+
+ ~CompilerDeclContext()
+ {
+ }
+
+ //----------------------------------------------------------------------
+ // Tests
+ //----------------------------------------------------------------------
+
+ explicit operator bool () const
+ {
+ return IsValid ();
+ }
+
+ bool
+ operator < (const CompilerDeclContext &rhs) const
+ {
+ if (m_type_system == rhs.m_type_system)
+ return m_opaque_decl_ctx < rhs.m_opaque_decl_ctx;
+ return m_type_system < rhs.m_type_system;
+ }
+
+ bool
+ IsValid () const
+ {
+ return m_type_system != nullptr && m_opaque_decl_ctx != nullptr;
+ }
+
+ bool
+ IsClang () const;
+
+ std::vector<CompilerDecl>
+ FindDeclByName (ConstString name);
+
+ //----------------------------------------------------------------------
+ /// Checks if this decl context represents a method of a class.
+ ///
+ /// @param[out] language_ptr
+ /// If non NULL and \b true is returned from this function,
+ /// this will indicate if the language that respresents the method.
+ ///
+ /// @param[out] is_instance_method_ptr
+ /// If non NULL and \b true is returned from this function,
+ /// this will indicate if the method is an instance function (true)
+ /// or a class method (false indicating the function is static, or
+ /// doesn't require an instance of the class to be called).
+ ///
+ /// @param[out] language_object_name_ptr
+ /// If non NULL and \b true is returned from this function,
+ /// this will indicate if implicit object name for the language
+ /// like "this" for C++, and "self" for Objective C.
+ ///
+ /// @return
+ /// Returns true if this is a decl context that represents a method
+ /// in a struct, union or class.
+ //----------------------------------------------------------------------
+ bool
+ IsClassMethod (lldb::LanguageType *language_ptr,
+ bool *is_instance_method_ptr,
+ ConstString *language_object_name_ptr);
+
+ //----------------------------------------------------------------------
+ // Accessors
+ //----------------------------------------------------------------------
+
+ TypeSystem *
+ GetTypeSystem() const
+ {
+ return m_type_system;
+ }
+
+ void *
+ GetOpaqueDeclContext() const
+ {
+ return m_opaque_decl_ctx;
+ }
+
+ void
+ SetDeclContext (TypeSystem* type_system, void* decl_ctx)
+ {
+ m_type_system = type_system;
+ m_opaque_decl_ctx = decl_ctx;
+ }
+
+ void
+ Clear()
+ {
+ m_type_system = nullptr;
+ m_opaque_decl_ctx = nullptr;
+ }
+
+ ConstString
+ GetName () const;
+
+ bool
+ IsStructUnionOrClass () const;
+
+private:
+ TypeSystem *m_type_system;
+ void *m_opaque_decl_ctx;
+
+};
+
+bool operator == (const CompilerDeclContext &lhs, const CompilerDeclContext &rhs);
+bool operator != (const CompilerDeclContext &lhs, const CompilerDeclContext &rhs);
+
+
+} // namespace lldb_private
+
+#endif // #ifndef liblldb_CompilerDeclContext_h_
diff --git a/include/lldb/Symbol/ClangASTType.h b/include/lldb/Symbol/CompilerType.h
index 2524751e092e..4f3ecc54ba1a 100644
--- a/include/lldb/Symbol/ClangASTType.h
+++ b/include/lldb/Symbol/CompilerType.h
@@ -1,4 +1,4 @@
-//===-- ClangASTType.h ------------------------------------------*- C++ -*-===//
+//===-- CompilerType.h ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,13 +7,19 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ClangASTType_h_
-#define liblldb_ClangASTType_h_
+#ifndef liblldb_CompilerType_h_
+#define liblldb_CompilerType_h_
+// C Includes
+// C++ Includes
+#include <functional>
#include <string>
+#include <vector>
+
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/ClangForward.h"
-#include "clang/AST/Type.h"
namespace lldb_private {
@@ -27,46 +33,40 @@ namespace lldb_private {
// and the opaque clang QualType to be specified for ease of use and
// to avoid code duplication.
//----------------------------------------------------------------------
-class ClangASTType
+class CompilerType
{
public:
//----------------------------------------------------------------------
// Constructors and Destructors
//----------------------------------------------------------------------
- ClangASTType (clang::ASTContext *ast_context, lldb::clang_type_t type) :
- m_type (type),
- m_ast (ast_context)
- {
- }
+ CompilerType (TypeSystem *type_system, lldb::opaque_compiler_type_t type);
+ CompilerType (clang::ASTContext *ast_context, clang::QualType qual_type);
- ClangASTType (clang::ASTContext *ast_context, clang::QualType qual_type);
-
- ClangASTType (const ClangASTType &rhs) :
+ CompilerType (const CompilerType &rhs) :
m_type (rhs.m_type),
- m_ast (rhs.m_ast)
+ m_type_system (rhs.m_type_system)
{
}
- ClangASTType () :
- m_type (0),
- m_ast (0)
+ CompilerType () :
+ m_type (nullptr),
+ m_type_system (nullptr)
{
}
- ~ClangASTType();
+ ~CompilerType();
//----------------------------------------------------------------------
// Operators
//----------------------------------------------------------------------
- const ClangASTType &
- operator= (const ClangASTType &rhs)
+ const CompilerType &
+ operator= (const CompilerType &rhs)
{
m_type = rhs.m_type;
- m_ast = rhs.m_ast;
+ m_type_system = rhs.m_type_system;
return *this;
}
-
//----------------------------------------------------------------------
// Tests
@@ -74,30 +74,30 @@ public:
explicit operator bool () const
{
- return m_type != NULL && m_ast != NULL;
+ return m_type != nullptr && m_type_system != nullptr;
}
bool
- operator < (const ClangASTType &rhs) const
+ operator < (const CompilerType &rhs) const
{
- if (m_ast == rhs.m_ast)
+ if (m_type_system == rhs.m_type_system)
return m_type < rhs.m_type;
- return m_ast < rhs.m_ast;
+ return m_type_system < rhs.m_type_system;
}
bool
IsValid () const
{
- return m_type != NULL && m_ast != NULL;
+ return m_type != nullptr && m_type_system != nullptr;
}
bool
- IsArrayType (ClangASTType *element_type,
+ IsArrayType (CompilerType *element_type,
uint64_t *size,
bool *is_incomplete) const;
bool
- IsVectorType (ClangASTType *element_type,
+ IsVectorType (CompilerType *element_type,
uint64_t *size) const;
bool
@@ -107,6 +107,9 @@ public:
IsAggregateType () const;
bool
+ IsAnonymousType () const;
+
+ bool
IsBeingDefined () const;
bool
@@ -122,24 +125,21 @@ public:
IsCStringType (uint32_t &length) const;
bool
- IsCXXClassType () const;
-
- bool
IsDefined() const;
bool
IsFloatingPointType (uint32_t &count, bool &is_complex) const;
bool
- IsFunctionType (bool *is_variadic_ptr = NULL) const;
+ IsFunctionType(bool *is_variadic_ptr = nullptr) const;
uint32_t
- IsHomogeneousAggregate (ClangASTType* base_type_ptr) const;
+ IsHomogeneousAggregate (CompilerType* base_type_ptr) const;
size_t
GetNumberOfFunctionArguments () const;
- ClangASTType
+ CompilerType
GetFunctionArgumentAtIndex (const size_t index) const;
bool
@@ -150,33 +150,20 @@ public:
bool
IsIntegerType (bool &is_signed) const;
-
- bool
- IsObjCClassType () const;
-
- bool
- IsObjCClassTypeAndHasIVars (bool check_superclass) const;
-
- bool
- IsObjCObjectOrInterfaceType () const;
-
- bool
- IsObjCObjectPointerType (ClangASTType *target_type = NULL);
bool
IsPolymorphicClass () const;
bool
- IsPossibleCPlusPlusDynamicType (ClangASTType *target_type = NULL) const
+ IsPossibleCPlusPlusDynamicType(CompilerType *target_type = nullptr) const
{
return IsPossibleDynamicType (target_type, true, false);
}
bool
- IsPossibleDynamicType (ClangASTType *target_type, // Can pass NULL
- bool check_cplusplus,
- bool check_objc) const;
-
+ IsPossibleDynamicType(CompilerType *target_type, // Can pass nullptr
+ bool check_cplusplus,
+ bool check_objc) const;
bool
IsPointerToScalarType () const;
@@ -185,13 +172,16 @@ public:
IsRuntimeGeneratedType () const;
bool
- IsPointerType (ClangASTType *pointee_type = NULL) const;
+ IsPointerType(CompilerType *pointee_type = nullptr) const;
bool
- IsPointerOrReferenceType (ClangASTType *pointee_type = NULL) const;
+ IsPointerOrReferenceType(CompilerType *pointee_type = nullptr) const;
bool
- IsReferenceType (ClangASTType *pointee_type = nullptr, bool* is_rvalue = nullptr) const;
+ IsReferenceType(CompilerType *pointee_type = nullptr, bool* is_rvalue = nullptr) const;
+
+ bool
+ ShouldTreatScalarValueAsAddress () const;
bool
IsScalarType () const;
@@ -202,13 +192,6 @@ public:
bool
IsVoidType () const;
- bool
- GetCXXClassName (std::string &class_name) const;
-
- bool
- GetObjCClassName (std::string &class_name);
-
-
//----------------------------------------------------------------------
// Type Completion
//----------------------------------------------------------------------
@@ -227,10 +210,10 @@ public:
// Accessors
//----------------------------------------------------------------------
- clang::ASTContext *
- GetASTContext() const
+ TypeSystem *
+ GetTypeSystem() const
{
- return m_ast;
+ return m_type_system;
}
ConstString
@@ -246,12 +229,12 @@ public:
GetDisplayTypeName () const;
uint32_t
- GetTypeInfo (ClangASTType *pointee_or_element_clang_type = NULL) const;
+ GetTypeInfo(CompilerType *pointee_or_element_compiler_type = nullptr) const;
lldb::LanguageType
GetMinimumLanguage ();
- lldb::clang_type_t
+ lldb::opaque_compiler_type_t
GetOpaqueQualType() const
{
return m_type;
@@ -261,14 +244,10 @@ public:
GetTypeClass () const;
void
- SetClangType (clang::ASTContext *ast, lldb::clang_type_t type)
- {
- m_ast = ast;
- m_type = type;
- }
+ SetCompilerType (TypeSystem* type_system, lldb::opaque_compiler_type_t type);
void
- SetClangType (clang::ASTContext *ast, clang::QualType qual_type);
+ SetCompilerType (clang::ASTContext *ast, clang::QualType qual_type);
unsigned
GetTypeQualifiers() const;
@@ -276,29 +255,14 @@ public:
//----------------------------------------------------------------------
// Creating related types
//----------------------------------------------------------------------
-
- ClangASTType
- AddConstModifier () const;
-
- ClangASTType
- AddRestrictModifier () const;
-
- ClangASTType
- AddVolatileModifier () const;
- // Using the current type, create a new typedef to that type using "typedef_name"
- // as the name and "decl_ctx" as the decl context.
- ClangASTType
- CreateTypedefType (const char *typedef_name,
- clang::DeclContext *decl_ctx) const;
+ CompilerType
+ GetArrayElementType(uint64_t *stride = nullptr) const;
- ClangASTType
- GetArrayElementType (uint64_t *stride = nullptr) const;
-
- ClangASTType
+ CompilerType
GetCanonicalType () const;
- ClangASTType
+ CompilerType
GetFullyUnqualifiedType () const;
// Returns -1 if this isn't a function of if the function doesn't have a prototype
@@ -306,10 +270,10 @@ public:
int
GetFunctionArgumentCount () const;
- ClangASTType
+ CompilerType
GetFunctionArgumentTypeAtIndex (size_t idx) const;
- ClangASTType
+ CompilerType
GetFunctionReturnType () const;
size_t
@@ -318,32 +282,83 @@ public:
TypeMemberFunctionImpl
GetMemberFunctionAtIndex (size_t idx);
- ClangASTType
- GetLValueReferenceType () const;
-
- ClangASTType
+ //----------------------------------------------------------------------
+ // 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;
- ClangASTType
+ //----------------------------------------------------------------------
+ // If this type is a pointer type, return the type that the pointer
+ // points to, else return an invalid type.
+ //----------------------------------------------------------------------
+ CompilerType
GetPointeeType () const;
- ClangASTType
+ //----------------------------------------------------------------------
+ // Return a new CompilerType that is a pointer to this type
+ //----------------------------------------------------------------------
+ CompilerType
GetPointerType () const;
-
- ClangASTType
+
+ //----------------------------------------------------------------------
+ // 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
- ClangASTType
+ CompilerType
GetTypedefedType () const;
-
- ClangASTType
- RemoveFastQualifiers () const;
//----------------------------------------------------------------------
// Create related types using the current type's AST
//----------------------------------------------------------------------
- ClangASTType
+ CompilerType
GetBasicTypeFromAST (lldb::BasicType basic_type) const;
//----------------------------------------------------------------------
@@ -374,54 +389,62 @@ public:
static lldb::BasicType
GetBasicTypeEnumeration (const ConstString &name);
- uint32_t
- GetNumDirectBaseClasses () const;
-
- uint32_t
- GetNumVirtualBaseClasses () const;
-
+ //----------------------------------------------------------------------
+ // If this type is an enumeration, iterate through all of its enumerators
+ // using a callback. If the callback returns true, keep iterating, else
+ // abort the iteration.
+ //----------------------------------------------------------------------
+ void
+ ForEachEnumerator (std::function <bool (const CompilerType &integer_type,
+ const ConstString &name,
+ const llvm::APSInt &value)> const &callback) const;
+
uint32_t
GetNumFields () const;
- ClangASTType
- GetDirectBaseClassAtIndex (size_t idx,
- uint32_t *bit_offset_ptr) const;
-
- ClangASTType
- GetVirtualBaseClassAtIndex (size_t idx,
- uint32_t *bit_offset_ptr) const;
-
- ClangASTType
+ CompilerType
GetFieldAtIndex (size_t idx,
std::string& name,
uint64_t *bit_offset_ptr,
uint32_t *bitfield_bit_size_ptr,
bool *is_bitfield_ptr) const;
-
+
uint32_t
- GetIndexOfFieldWithName (const char* name,
- ClangASTType* field_clang_type = NULL,
- uint64_t *bit_offset_ptr = NULL,
- uint32_t *bitfield_bit_size_ptr = NULL,
- bool *is_bitfield_ptr = NULL) const;
-
+ GetNumDirectBaseClasses () const;
+
+ uint32_t
+ GetNumVirtualBaseClasses () const;
+
+ CompilerType
+ GetDirectBaseClassAtIndex (size_t idx,
+ uint32_t *bit_offset_ptr) const;
+
+ CompilerType
+ GetVirtualBaseClassAtIndex (size_t idx,
+ uint32_t *bit_offset_ptr) const;
+
uint32_t
- GetNumPointeeChildren () const;
-
- ClangASTType
- GetChildClangTypeAtIndex (ExecutionContext *exe_ctx,
- size_t idx,
- bool transparent_pointers,
- bool omit_empty_base_classes,
- bool ignore_array_bounds,
- std::string& child_name,
- uint32_t &child_byte_size,
- int32_t &child_byte_offset,
- uint32_t &child_bitfield_bit_size,
- uint32_t &child_bitfield_bit_offset,
- bool &child_is_base_class,
- bool &child_is_deref_of_parent,
- ValueObject *valobj) const;
+ GetIndexOfFieldWithName(const char* name,
+ CompilerType* field_compiler_type = nullptr,
+ uint64_t *bit_offset_ptr = nullptr,
+ uint32_t *bitfield_bit_size_ptr = nullptr,
+ bool *is_bitfield_ptr = nullptr) const;
+
+ CompilerType
+ GetChildCompilerTypeAtIndex (ExecutionContext *exe_ctx,
+ size_t idx,
+ bool transparent_pointers,
+ bool omit_empty_base_classes,
+ bool ignore_array_bounds,
+ std::string& child_name,
+ uint32_t &child_byte_size,
+ int32_t &child_byte_offset,
+ uint32_t &child_bitfield_bit_size,
+ uint32_t &child_bitfield_bit_offset,
+ bool &child_is_base_class,
+ bool &child_is_deref_of_parent,
+ ValueObject *valobj,
+ uint64_t &language_flags) const;
// Lookup a child given a name. This function will match base class names
// and member member names in "clang_type" only, not descendants.
@@ -442,136 +465,30 @@ public:
size_t
GetNumTemplateArguments () const;
- ClangASTType
+ CompilerType
GetTemplateArgument (size_t idx,
lldb::TemplateArgumentKind &kind) const;
-
-
- //----------------------------------------------------------------------
- // Modifying RecordType
- //----------------------------------------------------------------------
- clang::FieldDecl *
- AddFieldToRecordType (const char *name,
- const ClangASTType &field_type,
- lldb::AccessType access,
- uint32_t bitfield_bit_size);
-
- void
- BuildIndirectFields ();
-
- void
- SetIsPacked ();
-
- clang::VarDecl *
- AddVariableToRecordType (const char *name,
- const ClangASTType &var_type,
- lldb::AccessType access);
-
- clang::CXXMethodDecl *
- AddMethodToCXXRecordType (const char *name,
- const ClangASTType &method_type,
- lldb::AccessType access,
- bool is_virtual,
- bool is_static,
- bool is_inline,
- bool is_explicit,
- bool is_attr_used,
- bool is_artificial);
-
- // C++ Base Classes
- clang::CXXBaseSpecifier *
- CreateBaseClassSpecifier (lldb::AccessType access,
- bool is_virtual,
- bool base_of_class);
-
- static void
- DeleteBaseClassSpecifiers (clang::CXXBaseSpecifier **base_classes,
- unsigned num_base_classes);
-
- bool
- SetBaseClassesForClassType (clang::CXXBaseSpecifier const * const *base_classes,
- unsigned num_base_classes);
-
-
- bool
- SetObjCSuperClass (const ClangASTType &superclass_clang_type);
-
- bool
- AddObjCClassProperty (const char *property_name,
- const ClangASTType &property_clang_type,
- clang::ObjCIvarDecl *ivar_decl,
- const char *property_setter_name,
- const char *property_getter_name,
- uint32_t property_attributes,
- ClangASTMetadata *metadata);
-
- clang::ObjCMethodDecl *
- AddMethodToObjCObjectType (const char *name, // the full symbol name as seen in the symbol table ("-[NString stringWithCString:]")
- const ClangASTType &method_clang_type,
- lldb::AccessType access,
- bool is_artificial);
-
- clang::DeclContext *
- GetDeclContextForType () const;
-
-
- bool
- SetDefaultAccessForRecordFields (int default_accessibility,
- int *assigned_accessibilities,
- size_t num_assigned_accessibilities);
- bool
- SetHasExternalStorage (bool has_extern);
+ CompilerType
+ GetTypeForFormatters () const;
+ LazyBool
+ ShouldPrintAsOneLiner (ValueObject* valobj) const;
- //------------------------------------------------------------------
- // clang::TagType
- //------------------------------------------------------------------
-
- bool
- SetTagTypeKind (int kind) const;
-
- //------------------------------------------------------------------
- // Tag Declarations
- //------------------------------------------------------------------
- bool
- StartTagDeclarationDefinition ();
-
- bool
- CompleteTagDeclarationDefinition ();
-
- //----------------------------------------------------------------------
- // Modifying Enumeration types
- //----------------------------------------------------------------------
bool
- AddEnumerationValueToEnumerationType (const ClangASTType &enumerator_qual_type,
- const Declaration &decl,
- const char *name,
- int64_t enum_value,
- uint32_t enum_value_bit_size);
-
-
-
- ClangASTType
- GetEnumerationIntegerType () const;
-
+ IsMeaninglessWithoutDynamicResolution () const;
//------------------------------------------------------------------
// Pointers & References
//------------------------------------------------------------------
- // Call this function using the class type when you want to make a
- // member pointer type to pointee_type.
- ClangASTType
- CreateMemberPointerType (const ClangASTType &pointee_type) const;
-
-
// 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
//----------------------------------------------------------------------
@@ -633,52 +550,22 @@ public:
lldb::addr_t addr,
AddressType address_type,
StreamString &new_value);
-
- clang::EnumDecl *
- GetAsEnumDecl () const;
-
-
- clang::RecordDecl *
- GetAsRecordDecl () const;
- clang::CXXRecordDecl *
- GetAsCXXRecordDecl () const;
-
- clang::ObjCInterfaceDecl *
- GetAsObjCInterfaceDecl () const;
-
void
Clear()
{
- m_type = NULL;
- m_ast = NULL;
- }
-
- clang::QualType
- GetQualType () const
- {
- if (m_type)
- return clang::QualType::getFromOpaquePtr(m_type);
- return clang::QualType();
- }
- clang::QualType
- GetCanonicalQualType () const
- {
- if (m_type)
- return clang::QualType::getFromOpaquePtr(m_type).getCanonicalType();
- return clang::QualType();
+ m_type = nullptr;
+ m_type_system = nullptr;
}
private:
- lldb::clang_type_t m_type;
- clang::ASTContext *m_ast;
-
+ lldb::opaque_compiler_type_t m_type;
+ TypeSystem *m_type_system;
};
-bool operator == (const ClangASTType &lhs, const ClangASTType &rhs);
-bool operator != (const ClangASTType &lhs, const ClangASTType &rhs);
+bool operator == (const CompilerType &lhs, const CompilerType &rhs);
+bool operator != (const CompilerType &lhs, const CompilerType &rhs);
-
} // namespace lldb_private
-#endif // #ifndef liblldb_ClangASTType_h_
+#endif // liblldb_CompilerType_h_
diff --git a/include/lldb/Symbol/DebugMacros.h b/include/lldb/Symbol/DebugMacros.h
new file mode 100644
index 000000000000..24bf03a8c3b1
--- /dev/null
+++ b/include/lldb/Symbol/DebugMacros.h
@@ -0,0 +1,140 @@
+//===-- DebugMacros.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_DebugMacros_h_
+#define liblldb_DebugMacros_h_
+
+// C Includes
+// C++ Includes
+#include <memory>
+#include <vector>
+
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-private.h"
+#include "lldb/Core/ConstString.h"
+
+namespace lldb_private {
+
+class CompileUnit;
+class DebugMacros;
+typedef std::shared_ptr<DebugMacros> DebugMacrosSP;
+
+class DebugMacroEntry
+{
+public:
+ enum EntryType
+ {
+ INVALID,
+ DEFINE,
+ UNDEF,
+ START_FILE,
+ END_FILE,
+ INDIRECT
+ };
+
+public:
+ static DebugMacroEntry
+ CreateDefineEntry(uint32_t line, const char *str);
+
+ static DebugMacroEntry
+ CreateUndefEntry(uint32_t line, const char *str);
+
+ static DebugMacroEntry
+ CreateStartFileEntry(uint32_t line, uint32_t debug_line_file_idx);
+
+ static DebugMacroEntry
+ CreateEndFileEntry();
+
+ static DebugMacroEntry
+ CreateIndirectEntry(const DebugMacrosSP &debug_macros_sp);
+
+ DebugMacroEntry() : m_type(INVALID) { }
+
+ ~DebugMacroEntry() = default;
+
+ EntryType
+ GetType() const
+ {
+ return m_type;
+ }
+
+ uint64_t
+ GetLineNumber() const
+ {
+ return m_line;
+ }
+
+ ConstString
+ GetMacroString() const
+ {
+ return m_str;
+ }
+
+ const FileSpec& GetFileSpec(CompileUnit *comp_unit) const;
+
+ DebugMacros *
+ GetIndirectDebugMacros() const
+ {
+ return m_debug_macros_sp.get();
+ }
+
+private:
+ DebugMacroEntry(EntryType type,
+ uint32_t line,
+ uint32_t debug_line_file_idx,
+ const char *str);
+
+ DebugMacroEntry(EntryType type,
+ const DebugMacrosSP &debug_macros_sp);
+
+ EntryType m_type:3;
+ uint32_t m_line:29;
+ uint32_t m_debug_line_file_idx;
+ ConstString m_str;
+ DebugMacrosSP m_debug_macros_sp;
+};
+
+class DebugMacros
+{
+public:
+ DebugMacros() = default;
+
+ ~DebugMacros() = default;
+
+ void
+ AddMacroEntry(const DebugMacroEntry &entry)
+ {
+ m_macro_entries.push_back(entry);
+ }
+
+ size_t
+ GetNumMacroEntries() const
+ {
+ return m_macro_entries.size();
+ }
+
+ DebugMacroEntry
+ GetMacroEntryAtIndex(const size_t index) const
+ {
+ if (index < m_macro_entries.size())
+ return m_macro_entries[index];
+ else
+ return DebugMacroEntry();
+ }
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(DebugMacros);
+
+ std::vector<DebugMacroEntry> m_macro_entries;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_DebugMacros_h_
diff --git a/include/lldb/Symbol/FuncUnwinders.h b/include/lldb/Symbol/FuncUnwinders.h
index 0d4aabb5fd57..728b4c6fcb32 100644
--- a/include/lldb/Symbol/FuncUnwinders.h
+++ b/include/lldb/Symbol/FuncUnwinders.h
@@ -103,6 +103,9 @@ public:
GetCompactUnwindUnwindPlan (Target &target, int current_offset);
lldb::UnwindPlanSP
+ GetArmUnwindUnwindPlan (Target &target, int current_offset);
+
+ lldb::UnwindPlanSP
GetArchDefaultUnwindPlan (Thread &thread);
lldb::UnwindPlanSP
@@ -122,6 +125,7 @@ private:
lldb::UnwindPlanSP m_unwind_plan_eh_frame_sp;
lldb::UnwindPlanSP m_unwind_plan_eh_frame_augmented_sp; // augmented by assembly inspection so it's valid everywhere
std::vector<lldb::UnwindPlanSP> m_unwind_plan_compact_unwind;
+ lldb::UnwindPlanSP m_unwind_plan_arm_unwind_sp;
lldb::UnwindPlanSP m_unwind_plan_fast_sp;
lldb::UnwindPlanSP m_unwind_plan_arch_default_sp;
lldb::UnwindPlanSP m_unwind_plan_arch_default_at_func_entry_sp;
@@ -132,6 +136,7 @@ private:
m_tried_unwind_plan_eh_frame:1,
m_tried_unwind_plan_eh_frame_augmented:1,
m_tried_unwind_plan_compact_unwind:1,
+ m_tried_unwind_plan_arm_unwind:1,
m_tried_unwind_fast:1,
m_tried_unwind_arch_default:1,
m_tried_unwind_arch_default_at_func_entry:1;
diff --git a/include/lldb/Symbol/Function.h b/include/lldb/Symbol/Function.h
index 30c8f168e5f1..cd2df9b6078f 100644
--- a/include/lldb/Symbol/Function.h
+++ b/include/lldb/Symbol/Function.h
@@ -10,7 +10,6 @@
#ifndef liblldb_Function_h_
#define liblldb_Function_h_
-#include "lldb/Core/ClangForward.h"
#include "lldb/Core/AddressRange.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/Declaration.h"
@@ -147,7 +146,6 @@ protected:
Declaration m_declaration; ///< Information describing where this function information was defined.
};
-
//----------------------------------------------------------------------
/// @class InlineFunctionInfo Function.h "lldb/Symbol/Function.h"
/// @brief A class that describes information for an inlined function.
@@ -203,7 +201,7 @@ public:
//------------------------------------------------------------------
/// Destructor.
//------------------------------------------------------------------
- ~InlineFunctionInfo();
+ ~InlineFunctionInfo() override;
//------------------------------------------------------------------
/// Compare two inlined function information objects.
@@ -294,8 +292,8 @@ public:
///
/// @see ConstString::StaticMemorySize ()
//------------------------------------------------------------------
- virtual size_t
- MemorySize() const;
+ size_t
+ MemorySize() const override;
private:
//------------------------------------------------------------------
@@ -415,24 +413,24 @@ public:
//------------------------------------------------------------------
/// Destructor.
//------------------------------------------------------------------
- ~Function ();
+ ~Function() override;
//------------------------------------------------------------------
/// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
///
/// @see SymbolContextScope
//------------------------------------------------------------------
- virtual void
- CalculateSymbolContext(SymbolContext* sc);
+ void
+ CalculateSymbolContext(SymbolContext* sc) override;
- virtual lldb::ModuleSP
- CalculateSymbolContextModule ();
+ lldb::ModuleSP
+ CalculateSymbolContextModule() override;
- virtual CompileUnit *
- CalculateSymbolContextCompileUnit ();
+ CompileUnit *
+ CalculateSymbolContextCompileUnit() override;
- virtual Function *
- CalculateSymbolContextFunction ();
+ Function *
+ CalculateSymbolContextFunction() override;
const AddressRange &
GetAddressRange()
@@ -550,8 +548,8 @@ public:
/// @return
/// The DeclContext, or NULL if none exists.
//------------------------------------------------------------------
- clang::DeclContext *
- GetClangDeclContext();
+ CompilerDeclContext
+ GetDeclContext();
//------------------------------------------------------------------
/// Get accessor for the type that describes the function
@@ -573,8 +571,8 @@ public:
const Type*
GetType() const;
- ClangASTType
- GetClangType ();
+ CompilerType
+ GetCompilerType ();
uint32_t
GetPrologueByteSize ();
@@ -600,8 +598,8 @@ public:
///
/// @see SymbolContextScope
//------------------------------------------------------------------
- virtual void
- DumpSymbolContext(Stream *s);
+ void
+ DumpSymbolContext(Stream *s) override;
//------------------------------------------------------------------
/// Get the memory cost of this object.
@@ -616,6 +614,42 @@ public:
size_t
MemorySize () const;
+ //------------------------------------------------------------------
+ /// Get whether compiler optimizations were enabled for this function
+ ///
+ /// The debug information may provide information about whether this
+ /// function was compiled with optimization or not. In this case,
+ /// "optimized" means that the debug experience may be difficult
+ /// for the user to understand. Variables may not be available when
+ /// the developer would expect them, stepping through the source lines
+ /// in the function may appear strange, etc.
+ ///
+ /// @return
+ /// Returns 'true' if this function was compiled with
+ /// optimization. 'false' indicates that either the optimization
+ /// is unknown, or this function was built without optimization.
+ //------------------------------------------------------------------
+ bool
+ GetIsOptimized ();
+
+ //------------------------------------------------------------------
+ /// Get whether this function represents a 'top-level' function
+ ///
+ /// The concept of a top-level function is language-specific, mostly
+ /// meant to represent the notion of scripting-style code that has
+ /// global visibility of the variables/symbols/functions/...
+ /// defined within the containing file/module
+ ///
+ /// If stopped in a top-level function, LLDB will expose global variables
+ /// as-if locals in the 'frame variable' command
+ ///
+ /// @return
+ /// Returns 'true' if this function is a top-level function,
+ /// 'false' otherwise.
+ //------------------------------------------------------------------
+ bool
+ IsTopLevelFunction ();
+
lldb::DisassemblerSP
GetInstructions (const ExecutionContext &exe_ctx,
const char *flavor,
@@ -634,8 +668,6 @@ protected:
flagsCalculatedPrologueSize = (1 << 0) ///< Have we already tried to calculate the prologue size?
};
-
-
//------------------------------------------------------------------
// Member variables.
//------------------------------------------------------------------
@@ -654,4 +686,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_Function_h_
+#endif // liblldb_Function_h_
diff --git a/include/lldb/Symbol/GoASTContext.h b/include/lldb/Symbol/GoASTContext.h
new file mode 100644
index 000000000000..3de98da59958
--- /dev/null
+++ b/include/lldb/Symbol/GoASTContext.h
@@ -0,0 +1,402 @@
+//===-- GoASTContext.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_GoASTContext_h_
+#define liblldb_GoASTContext_h_
+
+// C Includes
+// C++ Includes
+#include <map>
+#include <memory>
+#include <set>
+#include <string>
+#include <vector>
+
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/ConstString.h"
+#include "lldb/Symbol/TypeSystem.h"
+#include "lldb/Symbol/CompilerType.h"
+
+namespace lldb_private
+{
+
+class Declaration;
+class GoType;
+
+class GoASTContext : public TypeSystem
+{
+ public:
+ GoASTContext();
+ ~GoASTContext() override;
+
+ //------------------------------------------------------------------
+ // PluginInterface functions
+ //------------------------------------------------------------------
+ ConstString
+ GetPluginName() override;
+
+ uint32_t
+ GetPluginVersion() override;
+
+ static ConstString
+ GetPluginNameStatic ();
+
+ static lldb::TypeSystemSP
+ CreateInstance (lldb::LanguageType language, Module *module, Target *target);
+
+ static void
+ EnumerateSupportedLanguages(std::set<lldb::LanguageType> &languages_for_types, std::set<lldb::LanguageType> &languages_for_expressions);
+
+ static void
+ Initialize ();
+
+ static void
+ Terminate ();
+
+ DWARFASTParser *GetDWARFParser() override;
+
+ void
+ SetAddressByteSize(int byte_size)
+ {
+ m_pointer_byte_size = byte_size;
+ }
+
+ //------------------------------------------------------------------
+ // llvm casting support
+ //------------------------------------------------------------------
+ static bool classof(const TypeSystem *ts)
+ {
+ return ts->getKind() == TypeSystem::eKindGo;
+ }
+
+ //----------------------------------------------------------------------
+ // CompilerDecl functions
+ //----------------------------------------------------------------------
+ ConstString
+ DeclGetName (void *opaque_decl) override
+ {
+ return ConstString();
+ }
+
+ lldb::VariableSP
+ DeclGetVariable (void *opaque_decl) override
+ {
+ return lldb::VariableSP();
+ }
+
+ void
+ DeclLinkToObject (void *opaque_decl, std::shared_ptr<void> object) override
+ {
+ }
+
+ //----------------------------------------------------------------------
+ // CompilerDeclContext functions
+ //----------------------------------------------------------------------
+
+ bool
+ DeclContextIsStructUnionOrClass(void *opaque_decl_ctx) override
+ {
+ return false;
+ }
+
+ ConstString
+ DeclContextGetName(void *opaque_decl_ctx) override
+ {
+ return ConstString();
+ }
+
+ bool
+ DeclContextIsClassMethod(void *opaque_decl_ctx, lldb::LanguageType *language_ptr, bool *is_instance_method_ptr,
+ ConstString *language_object_name_ptr) override
+ {
+ return false;
+ }
+
+ //----------------------------------------------------------------------
+ // Creating Types
+ //----------------------------------------------------------------------
+
+ CompilerType CreateArrayType(const ConstString &name, const CompilerType &element_type, uint64_t length);
+
+ CompilerType CreateBaseType(int go_kind, const ConstString &type_name_const_str, uint64_t byte_size);
+
+ // For interface, map, chan.
+ CompilerType CreateTypedefType(int kind, const ConstString &name, CompilerType impl);
+
+ CompilerType CreateVoidType(const ConstString &name);
+ CompilerType CreateFunctionType(const lldb_private::ConstString &name, CompilerType *params, size_t params_count,
+ bool is_variadic);
+
+ CompilerType CreateStructType(int kind, const ConstString &name, uint32_t byte_size);
+
+ void CompleteStructType(const CompilerType &type);
+
+ void AddFieldToStruct(const CompilerType &struct_type, const ConstString &name, const CompilerType &field_type,
+ uint32_t byte_offset);
+
+ //----------------------------------------------------------------------
+ // Tests
+ //----------------------------------------------------------------------
+
+ static bool IsGoString(const CompilerType &type);
+ static bool IsGoSlice(const CompilerType &type);
+ static bool IsGoInterface(const CompilerType &type);
+ static bool IsDirectIface(uint8_t kind);
+ static bool IsPointerKind(uint8_t kind);
+
+ bool IsArrayType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size, bool *is_incomplete) override;
+
+ bool IsAggregateType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsCharType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsCompleteType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsDefined(lldb::opaque_compiler_type_t type) override;
+
+ bool IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count, bool &is_complex) override;
+
+ bool IsFunctionType(lldb::opaque_compiler_type_t type, bool *is_variadic_ptr = nullptr) override;
+
+ size_t GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type, const size_t index) override;
+
+ bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsIntegerType(lldb::opaque_compiler_type_t type, bool &is_signed) override;
+
+ bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
+ CompilerType *target_type, // Can pass nullptr
+ bool check_cplusplus, bool check_objc) override;
+
+ bool IsPointerType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type = nullptr) override;
+
+ bool IsScalarType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsVoidType(lldb::opaque_compiler_type_t type) override;
+
+ bool SupportsLanguage (lldb::LanguageType language) override;
+
+ //----------------------------------------------------------------------
+ // Type Completion
+ //----------------------------------------------------------------------
+
+ bool GetCompleteType(lldb::opaque_compiler_type_t type) override;
+
+ //----------------------------------------------------------------------
+ // AST related queries
+ //----------------------------------------------------------------------
+
+ uint32_t GetPointerByteSize() override;
+
+ //----------------------------------------------------------------------
+ // Accessors
+ //----------------------------------------------------------------------
+
+ ConstString GetTypeName(lldb::opaque_compiler_type_t type) override;
+
+ uint32_t GetTypeInfo(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_or_element_compiler_type = nullptr) override;
+
+ lldb::LanguageType GetMinimumLanguage(lldb::opaque_compiler_type_t type) override;
+
+ lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override;
+
+ //----------------------------------------------------------------------
+ // Creating related types
+ //----------------------------------------------------------------------
+
+ CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type, uint64_t *stride = nullptr) override;
+
+ CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override;
+
+ // Returns -1 if this isn't a function of if the function doesn't have a prototype
+ // Returns a value >= 0 if there is a prototype.
+ int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override;
+
+ CompilerType GetFunctionReturnType(lldb::opaque_compiler_type_t type) override;
+
+ size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override;
+
+ TypeMemberFunctionImpl GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override;
+
+ CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override;
+
+ //----------------------------------------------------------------------
+ // Exploring the type
+ //----------------------------------------------------------------------
+
+ uint64_t GetBitSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override;
+
+ lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type, uint64_t &count) override;
+
+ lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override;
+
+ uint32_t GetNumChildren(lldb::opaque_compiler_type_t type, bool omit_empty_base_classes) override;
+
+ lldb::BasicType GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override;
+
+ uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx, std::string &name, uint64_t *bit_offset_ptr,
+ uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) override;
+
+ uint32_t
+ GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) override
+ {
+ return 0;
+ }
+
+ uint32_t
+ GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) override
+ {
+ return 0;
+ }
+
+ CompilerType
+ GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) override
+ {
+ return CompilerType();
+ }
+
+ CompilerType
+ GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) override
+ {
+ return CompilerType();
+ }
+
+ CompilerType GetChildCompilerTypeAtIndex(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
+ bool transparent_pointers, bool omit_empty_base_classes,
+ bool ignore_array_bounds, std::string &child_name,
+ uint32_t &child_byte_size, int32_t &child_byte_offset,
+ uint32_t &child_bitfield_bit_size,
+ uint32_t &child_bitfield_bit_offset, bool &child_is_base_class,
+ bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) override;
+
+ // Lookup a child given a name. This function will match base class names
+ // and member member names in "clang_type" only, not descendants.
+ uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, const char *name, bool omit_empty_base_classes) override;
+
+ // Lookup a child member given a name. This function will match member names
+ // only and will descend into "clang_type" children in search for the first
+ // member in this class, or any base class that matches "name".
+ // TODO: Return all matches for a given name by returning a vector<vector<uint32_t>>
+ // so we catch all names that match a given child name, not just the first.
+ size_t GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type, const char *name, bool omit_empty_base_classes,
+ std::vector<uint32_t> &child_indexes) override;
+
+ size_t
+ GetNumTemplateArguments(lldb::opaque_compiler_type_t type) override
+ {
+ return 0;
+ }
+
+ CompilerType
+ GetTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, lldb::TemplateArgumentKind &kind) override
+ {
+ return CompilerType();
+ }
+
+ //----------------------------------------------------------------------
+ // Dumping types
+ //----------------------------------------------------------------------
+ void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, lldb::Format format,
+ const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size,
+ uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, bool show_types, bool show_summary,
+ bool verbose, uint32_t depth) override;
+
+ bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s, lldb::Format format, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) override;
+
+ void DumpTypeDescription(lldb::opaque_compiler_type_t type) override; // Dump to stdout
+
+ void DumpTypeDescription(lldb::opaque_compiler_type_t type, Stream *s) override;
+
+ //----------------------------------------------------------------------
+ // TODO: These methods appear unused. Should they be removed?
+ //----------------------------------------------------------------------
+
+ bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) override;
+
+ void DumpSummary(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size) override;
+
+ // Converts "s" to a floating point value and place resulting floating
+ // point bytes in the "dst" buffer.
+ size_t ConvertStringToFloatValue(lldb::opaque_compiler_type_t type, const char *s, uint8_t *dst, size_t dst_size) override;
+
+ //----------------------------------------------------------------------
+ // TODO: Determine if these methods should move to ClangASTContext.
+ //----------------------------------------------------------------------
+
+ bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_type = nullptr) override;
+
+ unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override;
+
+ bool IsCStringType(lldb::opaque_compiler_type_t type, uint32_t &length) override;
+
+ size_t GetTypeBitAlign(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override;
+
+ bool IsBeingDefined(lldb::opaque_compiler_type_t type) override;
+
+ bool IsConst(lldb::opaque_compiler_type_t type) override;
+
+ uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type, CompilerType *base_type_ptr) override;
+
+ bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) override;
+
+ bool IsTypedefType(lldb::opaque_compiler_type_t type) override;
+
+ // If the current object represents a typedef type, get the underlying type
+ CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsVectorType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size) override;
+
+ CompilerType GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetNonReferenceType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type = nullptr, bool *is_rvalue = nullptr) override;
+
+ private:
+ typedef std::map<ConstString, std::unique_ptr<GoType>> TypeMap;
+ int m_pointer_byte_size;
+ int m_int_byte_size;
+ std::unique_ptr<TypeMap> m_types;
+ std::unique_ptr<DWARFASTParser> m_dwarf_ast_parser_ap;
+
+ GoASTContext(const GoASTContext &) = delete;
+ const GoASTContext &operator=(const GoASTContext &) = delete;
+};
+
+class GoASTContextForExpr : public GoASTContext
+{
+ public:
+ GoASTContextForExpr(lldb::TargetSP target) : m_target_wp(target) {}
+ UserExpression *GetUserExpression(const char *expr, const char *expr_prefix, lldb::LanguageType language,
+ Expression::ResultType desired_type,
+ const EvaluateExpressionOptions &options) override;
+
+ private:
+ lldb::TargetWP m_target_wp;
+};
+}
+#endif // liblldb_GoASTContext_h_
diff --git a/include/lldb/Symbol/LineEntry.h b/include/lldb/Symbol/LineEntry.h
index 082caea3b12f..374c04a7fcec 100644
--- a/include/lldb/Symbol/LineEntry.h
+++ b/include/lldb/Symbol/LineEntry.h
@@ -140,6 +140,32 @@ struct LineEntry
static int
Compare (const LineEntry& lhs, const LineEntry& rhs);
+ //------------------------------------------------------------------
+ /// Give the range for this LineEntry + any additional LineEntries for
+ /// this same source line that are contiguous.
+ ///
+ /// A compiler may emit multiple line entries for a single source line,
+ /// e.g. to indicate subexpressions at different columns. This method
+ /// will get the AddressRange for all of the LineEntries for this source
+ /// line that are contiguous.
+ //
+ /// Line entries with a line number of 0 are treated specially - these
+ /// are compiler-generated line table entries that the user did not
+ /// write in their source code, and we want to skip past in the debugger.
+ /// If this LineEntry is for line 32, and the following LineEntry is for
+ /// line 0, we will extend the range to include the AddressRange of the
+ /// line 0 LineEntry (and it will include the range of the following
+ /// LineEntries that match either 32 or 0.)
+ ///
+ /// If the initial LineEntry this method is called on is a line #0, only
+ /// the range of contiuous LineEntries with line #0 will be included in
+ /// the complete range.
+ ///
+ /// @return
+ /// The contiguous AddressRange for this source line.
+ //------------------------------------------------------------------
+ AddressRange
+ GetSameLineContiguousAddressRange () const;
//------------------------------------------------------------------
// Member variables.
diff --git a/include/lldb/Symbol/LineTable.h b/include/lldb/Symbol/LineTable.h
index 3e25ad17e94e..cbad9bf590c2 100644
--- a/include/lldb/Symbol/LineTable.h
+++ b/include/lldb/Symbol/LineTable.h
@@ -10,8 +10,12 @@
#ifndef liblldb_LineTable_h_
#define liblldb_LineTable_h_
+// C Includes
+// C++ Includes
#include <vector>
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Symbol/LineEntry.h"
#include "lldb/Core/ModuleChild.h"
@@ -30,7 +34,7 @@ public:
LineSequence ();
virtual
- ~LineSequence() {}
+ ~LineSequence() = default;
virtual void
Clear() = 0;
@@ -143,14 +147,14 @@ public:
///
/// @param[out] index_ptr
/// A pointer to a 32 bit integer that will get the actual line
- /// entry index if it is not NULL.
+ /// entry index if it is not nullptr.
///
/// @return
/// Returns \b true if \a so_addr is contained in a line entry
/// in this line table, \b false otherwise.
//------------------------------------------------------------------
bool
- FindLineEntryByAddress (const Address &so_addr, LineEntry& line_entry, uint32_t *index_ptr = NULL);
+ 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
@@ -269,7 +273,6 @@ public:
LinkLineTable (const FileRangeMap &file_range_map);
protected:
-
struct Entry
{
Entry () :
@@ -343,12 +346,12 @@ protected:
return 0;
}
-
class LessThanBinaryPredicate
{
public:
LessThanBinaryPredicate(LineTable *line_table);
bool operator() (const LineTable::Entry&, const LineTable::Entry&) const;
+
protected:
LineTable *m_line_table;
};
@@ -396,16 +399,12 @@ protected:
class LineSequenceImpl : public LineSequence
{
public:
- LineSequenceImpl() :
- LineSequence()
- {}
+ LineSequenceImpl() = default;
- virtual
- ~LineSequenceImpl()
- {}
+ ~LineSequenceImpl() override = default;
- virtual void
- Clear();
+ void
+ Clear() override;
entry_collection m_entries; ///< The collection of line entries in this sequence.
};
@@ -419,4 +418,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_LineTable_h_
+#endif // liblldb_LineTable_h_
diff --git a/include/lldb/Symbol/ObjectContainer.h b/include/lldb/Symbol/ObjectContainer.h
index 679e8f03b67a..eeda1c4ae19d 100644
--- a/include/lldb/Symbol/ObjectContainer.h
+++ b/include/lldb/Symbol/ObjectContainer.h
@@ -14,7 +14,6 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-
#include "lldb/lldb-private.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Host/FileSpec.h"
@@ -71,10 +70,7 @@ public:
/// The destructor is virtual since this class is designed to be
/// inherited from by the plug-in instance.
//------------------------------------------------------------------
- virtual
- ~ObjectContainer()
- {
- }
+ ~ObjectContainer() override = default;
//------------------------------------------------------------------
/// Dump a description of this object to a Stream.
@@ -188,7 +184,7 @@ public:
///
/// @return
/// Returns a pointer to the object file of the requested \a
- /// arch and optional \a name. Returns NULL of no such object
+ /// arch and optional \a name. Returns nullptr of no such object
/// file exists in the container.
//------------------------------------------------------------------
virtual lldb::ObjectFileSP
@@ -203,19 +199,19 @@ public:
virtual ObjectFile *
GetObjectFileAtIndex (uint32_t object_idx)
{
- return NULL;
+ return nullptr;
}
virtual ObjectContainer *
GetObjectContainerAtIndex (uint32_t object_idx)
{
- return NULL;
+ return nullptr;
}
virtual const char *
GetObjectNameAtIndex (uint32_t object_idx) const
{
- return NULL;
+ return nullptr;
}
protected:
@@ -233,4 +229,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ObjectContainer_h_
+#endif // liblldb_ObjectContainer_h_
diff --git a/include/lldb/Symbol/ObjectFile.h b/include/lldb/Symbol/ObjectFile.h
index ff00ac26e67e..4b0a2f9ff936 100644
--- a/include/lldb/Symbol/ObjectFile.h
+++ b/include/lldb/Symbol/ObjectFile.h
@@ -125,8 +125,7 @@ public:
/// The destructor is virtual since this class is designed to be
/// inherited from by the plug-in instance.
//------------------------------------------------------------------
- virtual
- ~ObjectFile();
+ ~ObjectFile() override;
//------------------------------------------------------------------
/// Dump a description of this object to a Stream.
@@ -369,12 +368,11 @@ public:
/// The list of sections contained in this object file.
//------------------------------------------------------------------
virtual SectionList *
- GetSectionList ();
+ 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.
@@ -595,7 +593,6 @@ public:
virtual lldb_private::Address
GetHeaderAddress () { return Address(m_memory_addr);}
-
virtual uint32_t
GetNumThreadContexts ()
{
@@ -767,7 +764,6 @@ public:
return 0;
}
-
//------------------------------------------------------------------
/// Return true if this file is a dynamic link editor (dyld)
///
@@ -823,6 +819,7 @@ public:
lldb::offset_t section_offset,
void *dst,
size_t dst_len) const;
+
virtual size_t
ReadSectionData (const Section *section,
DataExtractor& section_data) const;
@@ -843,7 +840,11 @@ public:
{
return symbol_name.str();
}
-
+
+ static lldb::SymbolType
+ GetSymbolTypeFromName (llvm::StringRef name,
+ lldb::SymbolType symbol_type_hint = lldb::eSymbolTypeUndefined);
+
protected:
//------------------------------------------------------------------
// Member variables.
@@ -880,5 +881,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ObjectFile_h_
-
+#endif // liblldb_ObjectFile_h_
diff --git a/include/lldb/Symbol/Symbol.h b/include/lldb/Symbol/Symbol.h
index f9438b006c4e..c77d3dea4bd2 100644
--- a/include/lldb/Symbol/Symbol.h
+++ b/include/lldb/Symbol/Symbol.h
@@ -333,6 +333,7 @@ public:
{
return m_demangled_is_synthesized;
}
+
void
SetDemangledNameIsSynthesized(bool b)
{
@@ -354,22 +355,22 @@ public:
///
/// @see SymbolContextScope
//------------------------------------------------------------------
- virtual void
- CalculateSymbolContext (SymbolContext *sc);
+ void
+ CalculateSymbolContext(SymbolContext *sc) override;
- virtual lldb::ModuleSP
- CalculateSymbolContextModule ();
+ lldb::ModuleSP
+ CalculateSymbolContextModule() override;
- virtual Symbol *
- CalculateSymbolContextSymbol ();
+ Symbol *
+ CalculateSymbolContextSymbol() override;
//------------------------------------------------------------------
/// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
///
/// @see SymbolContextScope
//------------------------------------------------------------------
- virtual void
- DumpSymbolContext (Stream *s);
+ void
+ DumpSymbolContext(Stream *s) override;
lldb::DisassemblerSP
GetInstructions (const ExecutionContext &exe_ctx,
@@ -411,4 +412,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_Symbol_h_
+#endif // liblldb_Symbol_h_
diff --git a/include/lldb/Symbol/SymbolContext.h b/include/lldb/Symbol/SymbolContext.h
index c48505e1064a..9cb709d24011 100644
--- a/include/lldb/Symbol/SymbolContext.h
+++ b/include/lldb/Symbol/SymbolContext.h
@@ -7,12 +7,17 @@
//
//===----------------------------------------------------------------------===//
-
#ifndef liblldb_SymbolContext_h_
#define liblldb_SymbolContext_h_
+// C Includes
+// C++ Includes
+#include <memory>
+#include <string>
#include <vector>
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/Mangled.h"
@@ -22,6 +27,7 @@
namespace lldb_private {
class SymbolContextScope;
+
//----------------------------------------------------------------------
/// @class SymbolContext SymbolContext.h "lldb/Symbol/SymbolContext.h"
/// @brief Defines a symbol context baton that can be handed other debug
@@ -36,11 +42,10 @@ class SymbolContextScope;
class SymbolContext
{
public:
-
//------------------------------------------------------------------
/// Default constructor.
///
- /// Initialize all pointer members to NULL and all struct members
+ /// Initialize all pointer members to nullptr and all struct members
/// to their default state.
//------------------------------------------------------------------
SymbolContext ();
@@ -81,24 +86,23 @@ public:
/// A Symbol pointer to the symbol for this context.
//------------------------------------------------------------------
explicit
- SymbolContext (const lldb::TargetSP &target_sp,
- const lldb::ModuleSP &module_sp,
- CompileUnit *comp_unit = NULL,
- Function *function = NULL,
- Block *block = NULL,
- LineEntry *line_entry = NULL,
- Symbol *symbol = NULL);
+ SymbolContext(const lldb::TargetSP &target_sp,
+ const lldb::ModuleSP &module_sp,
+ CompileUnit *comp_unit = nullptr,
+ Function *function = nullptr,
+ Block *block = nullptr,
+ LineEntry *line_entry = nullptr,
+ Symbol *symbol = nullptr);
// This version sets the target to a NULL TargetSP if you don't know it.
explicit
- SymbolContext (const lldb::ModuleSP &module_sp,
- CompileUnit *comp_unit = NULL,
- Function *function = NULL,
- Block *block = NULL,
- LineEntry *line_entry = NULL,
- Symbol *symbol = NULL);
+ SymbolContext(const lldb::ModuleSP &module_sp,
+ CompileUnit *comp_unit = nullptr,
+ Function *function = nullptr,
+ Block *block = nullptr,
+ LineEntry *line_entry = nullptr,
+ Symbol *symbol = nullptr);
- ~SymbolContext ();
//------------------------------------------------------------------
/// Copy constructor
///
@@ -109,6 +113,8 @@ public:
//------------------------------------------------------------------
SymbolContext (const SymbolContext& rhs);
+ ~SymbolContext ();
+
//------------------------------------------------------------------
/// Assignment operator.
///
@@ -127,7 +133,7 @@ public:
//------------------------------------------------------------------
/// Clear the object's state.
///
- /// Resets all pointer members to NULL, and clears any class objects
+ /// Resets all pointer members to nullptr, and clears any class objects
/// to their default state.
//------------------------------------------------------------------
void
@@ -203,14 +209,14 @@ public:
///
/// Address range priority is as follows:
/// - line_entry address range if line_entry is valid and eSymbolContextLineEntry is set in \a scope
- /// - block address range if block is not NULL and eSymbolContextBlock is set in \a scope
- /// - function address range if function is not NULL and eSymbolContextFunction is set in \a scope
- /// - symbol address range if symbol is not NULL and eSymbolContextSymbol is set in \a scope
+ /// - block address range if block is not nullptr and eSymbolContextBlock is set in \a scope
+ /// - function address range if function is not nullptr and eSymbolContextFunction is set in \a scope
+ /// - symbol address range if symbol is not nullptr and eSymbolContextSymbol is set in \a scope
///
/// @param[in] scope
/// A mask of symbol context bits telling this function which
/// address ranges it can use when trying to extract one from
- /// the valid (non-NULL) symbol context classes.
+ /// the valid (non-nullptr) symbol context classes.
///
/// @param[in] range_idx
/// The address range index to grab. Since many functions and
@@ -239,7 +245,6 @@ public:
bool use_inline_block_range,
AddressRange &range) const;
-
void
GetDescription(Stream *s,
lldb::DescriptionLevel level,
@@ -248,7 +253,9 @@ public:
uint32_t
GetResolvedMask () const;
-
+ lldb::LanguageType
+ GetLanguage () const;
+
//------------------------------------------------------------------
/// Find a block that defines the function represented by this
/// symbol context.
@@ -268,12 +275,11 @@ public:
///
/// @return
/// The block object pointer that defines the function that is
- /// represented by this symbol context object, NULL otherwise.
+ /// 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.
@@ -299,6 +305,14 @@ public:
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,
@@ -315,7 +329,6 @@ public:
ConstString
GetFunctionName (Mangled::NamePreference preference = Mangled::ePreferDemangled) const;
-
//------------------------------------------------------------------
/// Get the line entry that corresponds to the function.
///
@@ -377,7 +390,6 @@ public:
Variable * variable; ///< The global variable matching the given query
};
-
class SymbolContextSpecifier
{
public:
@@ -427,7 +439,6 @@ private:
std::string m_class_name;
std::unique_ptr<AddressRange> m_address_range_ap;
uint32_t m_type; // Or'ed bits from SpecificationType
-
};
//----------------------------------------------------------------------
@@ -479,6 +490,7 @@ public:
uint32_t
AppendIfUnique (const SymbolContextList& sc_list,
bool merge_symbol_into_function);
+
//------------------------------------------------------------------
/// Clear the object's state.
///
@@ -558,6 +570,7 @@ public:
bool
RemoveContextAtIndex (size_t idx);
+
//------------------------------------------------------------------
/// Get accessor for a symbol context list size.
///
@@ -600,4 +613,4 @@ bool operator!= (const SymbolContextList& lhs, const SymbolContextList& rhs);
} // namespace lldb_private
-#endif // liblldb_SymbolContext_h_
+#endif // liblldb_SymbolContext_h_
diff --git a/include/lldb/Symbol/SymbolContextScope.h b/include/lldb/Symbol/SymbolContextScope.h
index a02b4523a4c0..212d8e6df233 100644
--- a/include/lldb/Symbol/SymbolContextScope.h
+++ b/include/lldb/Symbol/SymbolContextScope.h
@@ -72,7 +72,7 @@ class SymbolContextScope
{
public:
virtual
- ~SymbolContextScope () {}
+ ~SymbolContextScope() = default;
//------------------------------------------------------------------
/// Reconstruct the object's symbol context into \a sc.
@@ -87,7 +87,6 @@ public:
virtual void
CalculateSymbolContext (SymbolContext *sc) = 0;
-
virtual lldb::ModuleSP
CalculateSymbolContextModule ()
{
@@ -97,25 +96,25 @@ public:
virtual CompileUnit *
CalculateSymbolContextCompileUnit ()
{
- return NULL;
+ return nullptr;
}
virtual Function *
CalculateSymbolContextFunction ()
{
- return NULL;
+ return nullptr;
}
virtual Block *
CalculateSymbolContextBlock ()
{
- return NULL;
+ return nullptr;
}
virtual Symbol *
CalculateSymbolContextSymbol ()
{
- return NULL;
+ return nullptr;
}
//------------------------------------------------------------------
@@ -134,4 +133,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_SymbolContextScope_h_
+#endif // liblldb_SymbolContextScope_h_
diff --git a/include/lldb/Symbol/SymbolFile.h b/include/lldb/Symbol/SymbolFile.h
index 0efe034235d5..e27b32d01f68 100644
--- a/include/lldb/Symbol/SymbolFile.h
+++ b/include/lldb/Symbol/SymbolFile.h
@@ -12,8 +12,9 @@
#include "lldb/lldb-private.h"
#include "lldb/Core/PluginInterface.h"
-#include "lldb/Symbol/ClangASTType.h"
-#include "lldb/Symbol/ClangNamespaceDecl.h"
+#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Symbol/CompilerDecl.h"
+#include "lldb/Symbol/CompilerDeclContext.h"
#include "lldb/Symbol/Type.h"
namespace lldb_private {
@@ -55,8 +56,7 @@ public:
{
}
- virtual
- ~SymbolFile()
+ ~SymbolFile() override
{
}
@@ -123,33 +123,43 @@ public:
virtual lldb::LanguageType ParseCompileUnitLanguage (const SymbolContext& sc) = 0;
virtual size_t ParseCompileUnitFunctions (const SymbolContext& sc) = 0;
virtual bool ParseCompileUnitLineTable (const SymbolContext& sc) = 0;
+ virtual bool ParseCompileUnitDebugMacros (const SymbolContext& sc) = 0;
virtual bool ParseCompileUnitSupportFiles (const SymbolContext& sc, FileSpecList& support_files) = 0;
virtual bool ParseImportedModules (const SymbolContext &sc, std::vector<ConstString> &imported_modules) = 0;
virtual size_t ParseFunctionBlocks (const SymbolContext& sc) = 0;
virtual size_t ParseTypes (const SymbolContext& sc) = 0;
virtual size_t ParseVariablesForContext (const SymbolContext& sc) = 0;
virtual Type* ResolveTypeUID (lldb::user_id_t type_uid) = 0;
- virtual bool ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type) = 0;
- virtual clang::DeclContext* GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid) { return NULL; }
- virtual clang::DeclContext* GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid) { return NULL; }
+ virtual bool CompleteType (CompilerType &compiler_type) = 0;
+ virtual void ParseDeclsForContext (CompilerDeclContext decl_ctx) {}
+ virtual CompilerDecl GetDeclForUID (lldb::user_id_t uid) { return CompilerDecl(); }
+ virtual CompilerDeclContext GetDeclContextForUID (lldb::user_id_t uid) { return CompilerDeclContext(); }
+ virtual CompilerDeclContext GetDeclContextContainingUID (lldb::user_id_t uid) { return CompilerDeclContext(); }
virtual uint32_t ResolveSymbolContext (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc) = 0;
- virtual uint32_t ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) = 0;
- virtual uint32_t FindGlobalVariables (const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, VariableList& variables) = 0;
- virtual uint32_t FindGlobalVariables (const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables) = 0;
- virtual uint32_t FindFunctions (const ConstString &name, const ClangNamespaceDecl *namespace_decl, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list) = 0;
- virtual uint32_t FindFunctions (const RegularExpression& regex, bool include_inlines, bool append, SymbolContextList& sc_list) = 0;
- virtual uint32_t FindTypes (const SymbolContext& sc, const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, TypeList& types) = 0;
+ virtual uint32_t ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list);
+ virtual uint32_t FindGlobalVariables (const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, VariableList& variables);
+ virtual uint32_t FindGlobalVariables (const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables);
+ virtual uint32_t FindFunctions (const ConstString &name, const CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list);
+ virtual uint32_t FindFunctions (const RegularExpression& regex, bool include_inlines, bool append, SymbolContextList& sc_list);
+ virtual uint32_t FindTypes (const SymbolContext& sc, const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, TypeMap& types);
+ virtual size_t FindTypes (const std::vector<CompilerContext> &context, bool append, TypeMap& types);
+
// virtual uint32_t FindTypes (const SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, TypeList& types) = 0;
virtual TypeList * GetTypeList ();
virtual size_t GetTypes (lldb_private::SymbolContextScope *sc_scope,
uint32_t type_mask,
lldb_private::TypeList &type_list) = 0;
- virtual ClangASTContext &
- GetClangASTContext ();
- virtual ClangNamespaceDecl
+
+ virtual lldb_private::TypeSystem *
+ GetTypeSystemForLanguage (lldb::LanguageType language);
+
+ virtual CompilerDeclContext
FindNamespace (const SymbolContext& sc,
const ConstString &name,
- const ClangNamespaceDecl *parent_namespace_decl) = 0;
+ const CompilerDeclContext *parent_decl_ctx)
+ {
+ return CompilerDeclContext();
+ }
ObjectFile* GetObjectFile() { return m_obj_file; }
const ObjectFile* GetObjectFile() const { return m_obj_file; }
@@ -163,16 +173,15 @@ public:
{
}
-
protected:
ObjectFile* m_obj_file; // The object file that symbols can be extracted from.
uint32_t m_abilities;
bool m_calculated_abilities;
+
private:
DISALLOW_COPY_AND_ASSIGN (SymbolFile);
};
-
} // namespace lldb_private
-#endif // liblldb_SymbolFile_h_
+#endif // liblldb_SymbolFile_h_
diff --git a/include/lldb/Symbol/SymbolVendor.h b/include/lldb/Symbol/SymbolVendor.h
index 248918af2833..19461718ed13 100644
--- a/include/lldb/Symbol/SymbolVendor.h
+++ b/include/lldb/Symbol/SymbolVendor.h
@@ -15,9 +15,8 @@
#include "lldb/lldb-private.h"
#include "lldb/Core/ModuleChild.h"
#include "lldb/Core/PluginInterface.h"
-#include "lldb/Symbol/ClangNamespaceDecl.h"
#include "lldb/Symbol/TypeList.h"
-
+#include "lldb/Symbol/TypeMap.h"
namespace lldb_private {
@@ -45,8 +44,7 @@ public:
//------------------------------------------------------------------
SymbolVendor(const lldb::ModuleSP &module_sp);
- virtual
- ~SymbolVendor();
+ ~SymbolVendor() override;
void
AddSymbolFileRepresentation(const lldb::ObjectFileSP &objfile_sp);
@@ -64,6 +62,9 @@ public:
ParseCompileUnitLineTable (const SymbolContext& sc);
virtual bool
+ ParseCompileUnitDebugMacros (const SymbolContext& sc);
+
+ virtual bool
ParseCompileUnitSupportFiles (const SymbolContext& sc,
FileSpecList& support_files);
@@ -97,7 +98,7 @@ public:
virtual size_t
FindGlobalVariables (const ConstString &name,
- const ClangNamespaceDecl *namespace_decl,
+ const CompilerDeclContext *parent_decl_ctx,
bool append,
size_t max_matches,
VariableList& variables);
@@ -110,7 +111,7 @@ public:
virtual size_t
FindFunctions (const ConstString &name,
- const ClangNamespaceDecl *namespace_decl,
+ const CompilerDeclContext *parent_decl_ctx,
uint32_t name_type_mask,
bool include_inlines,
bool append,
@@ -125,15 +126,18 @@ public:
virtual size_t
FindTypes (const SymbolContext& sc,
const ConstString &name,
- const ClangNamespaceDecl *namespace_decl,
+ const CompilerDeclContext *parent_decl_ctx,
bool append,
size_t max_matches,
- TypeList& types);
+ TypeMap& types);
- virtual ClangNamespaceDecl
+ virtual size_t
+ FindTypes (const std::vector<CompilerContext> &context, bool append, TypeMap& types);
+
+ virtual CompilerDeclContext
FindNamespace (const SymbolContext& sc,
const ConstString &name,
- const ClangNamespaceDecl *parent_namespace_decl);
+ const CompilerDeclContext *parent_decl_ctx);
virtual size_t
GetNumCompileUnits();
@@ -189,11 +193,11 @@ public:
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
- virtual ConstString
- GetPluginName();
+ ConstString
+ GetPluginName() override;
- virtual uint32_t
- GetPluginVersion();
+ uint32_t
+ GetPluginVersion() override;
protected:
//------------------------------------------------------------------
@@ -215,7 +219,6 @@ private:
DISALLOW_COPY_AND_ASSIGN (SymbolVendor);
};
-
} // namespace lldb_private
-#endif // liblldb_SymbolVendor_h_
+#endif // liblldb_SymbolVendor_h_
diff --git a/include/lldb/Symbol/TaggedASTType.h b/include/lldb/Symbol/TaggedASTType.h
index c44a5356f86d..82431a562287 100644
--- a/include/lldb/Symbol/TaggedASTType.h
+++ b/include/lldb/Symbol/TaggedASTType.h
@@ -10,33 +10,33 @@
#ifndef liblldb_TaggedASTType_h_
#define liblldb_TaggedASTType_h_
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
namespace lldb_private
{
// For cases in which there are multiple classes of types that are not
// interchangeable, to allow static type checking.
-template <unsigned int C> class TaggedASTType : public ClangASTType
+template <unsigned int C> class TaggedASTType : public CompilerType
{
public:
- TaggedASTType (const ClangASTType &clang_type) :
- ClangASTType(clang_type)
+ TaggedASTType (const CompilerType &compiler_type) :
+ CompilerType(compiler_type)
{
}
- TaggedASTType (lldb::clang_type_t type, clang::ASTContext *ast_context) :
- ClangASTType(ast_context, type)
+ TaggedASTType (lldb::opaque_compiler_type_t type, TypeSystem * type_system) :
+ CompilerType(type_system, type)
{
}
TaggedASTType (const TaggedASTType<C> &tw) :
- ClangASTType(tw)
+ CompilerType(tw)
{
}
TaggedASTType () :
- ClangASTType()
+ CompilerType()
{
}
@@ -47,7 +47,7 @@ public:
TaggedASTType<C> &operator= (const TaggedASTType<C> &tw)
{
- ClangASTType::operator= (tw);
+ CompilerType::operator= (tw);
return *this;
}
};
diff --git a/include/lldb/Symbol/Type.h b/include/lldb/Symbol/Type.h
index c1784cb364a8..224e0a112df3 100644
--- a/include/lldb/Symbol/Type.h
+++ b/include/lldb/Symbol/Type.h
@@ -14,7 +14,8 @@
#include "lldb/Core/ClangForward.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/UserID.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerDecl.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/Declaration.h"
#include "llvm/ADT/APSInt.h"
@@ -23,6 +24,31 @@
namespace lldb_private {
+//----------------------------------------------------------------------
+// CompilerContext allows an array of these items to be passed to
+// perform detailed lookups in SymbolVendor and SymbolFile functions.
+//----------------------------------------------------------------------
+struct CompilerContext
+{
+ CompilerContext (CompilerContextKind t, const ConstString &n) :
+ type(t),
+ name(n)
+ {
+ }
+
+ bool
+ operator == (const CompilerContext &rhs) const
+ {
+ return type == rhs.type && name == rhs.name;
+ }
+
+ void
+ Dump () const;
+
+ CompilerContextKind type;
+ ConstString name;
+};
+
class SymbolFileType :
public std::enable_shared_from_this<SymbolFileType>,
public UserID
@@ -34,6 +60,9 @@ class SymbolFileType :
{
}
+ SymbolFileType (SymbolFile &symbol_file, const lldb::TypeSP &type_sp);
+
+
~SymbolFileType ()
{
}
@@ -92,8 +121,8 @@ public:
lldb::user_id_t encoding_uid,
EncodingDataType encoding_uid_type,
const Declaration& decl,
- const ClangASTType &clang_qual_type,
- ResolveState clang_type_resolve_state);
+ const CompilerType &compiler_qual_type,
+ ResolveState compiler_type_resolve_state);
// This makes an invalid type. Used for functions that return a Type when they
// get an error.
@@ -239,22 +268,19 @@ public:
// Get the clang type, and resolve definitions for any
// class/struct/union/enum types completely.
- ClangASTType
- GetClangFullType ();
+ CompilerType
+ GetFullCompilerType ();
// Get the clang type, and resolve definitions enough so that the type could
// have layout performed. This allows ptrs and refs to class/struct/union/enum
// types remain forward declarations.
- ClangASTType
- GetClangLayoutType ();
+ CompilerType
+ GetLayoutCompilerType ();
// Get the clang type and leave class/struct/union/enum types as forward
// declarations if they haven't already been fully defined.
- ClangASTType
- GetClangForwardType ();
-
- ClangASTContext &
- GetClangASTContext ();
+ CompilerType
+ GetForwardCompilerType ();
static int
Compare(const Type &a, const Type &b);
@@ -275,12 +301,6 @@ public:
uint32_t
GetEncodingMask ();
- ClangASTType
- CreateClangTypedefType (Type *typedef_type, Type *base_type);
-
- bool
- IsRealObjCClass();
-
bool
IsCompleteObjCClass()
{
@@ -302,14 +322,14 @@ protected:
EncodingDataType m_encoding_uid_type;
uint64_t m_byte_size;
Declaration m_decl;
- ClangASTType m_clang_type;
+ CompilerType m_compiler_type;
struct Flags {
#ifdef __GNUC__
// using unsigned type here to work around a very noisy gcc warning
- unsigned clang_type_resolve_state : 2;
+ unsigned compiler_type_resolve_state : 2;
#else
- ResolveState clang_type_resolve_state : 2;
+ ResolveState compiler_type_resolve_state : 2;
#endif
bool is_complete_objc_class : 1;
} m_flags;
@@ -318,7 +338,7 @@ protected:
GetEncodingType ();
bool
- ResolveClangType (ResolveState clang_type_resolve_state);
+ ResolveClangType (ResolveState compiler_type_resolve_state);
};
// these classes are used to back the SBType* objects
@@ -327,28 +347,28 @@ class TypePair
{
public:
TypePair () :
- clang_type(),
+ compiler_type(),
type_sp()
{
}
- TypePair (ClangASTType type) :
- clang_type(type),
+ TypePair (CompilerType type) :
+ compiler_type(type),
type_sp()
{
}
TypePair (lldb::TypeSP type) :
- clang_type(),
- type_sp(type)
+ compiler_type(),
+ type_sp(type)
{
- clang_type = type_sp->GetClangForwardType();
+ compiler_type = type_sp->GetForwardCompilerType ();
}
bool
IsValid () const
{
- return clang_type.IsValid() || (type_sp.get() != nullptr);
+ return compiler_type.IsValid() || (type_sp.get() != nullptr);
}
explicit operator bool () const
@@ -359,21 +379,21 @@ public:
bool
operator == (const TypePair& rhs) const
{
- return clang_type == rhs.clang_type &&
+ return compiler_type == rhs.compiler_type &&
type_sp.get() == rhs.type_sp.get();
}
bool
operator != (const TypePair& rhs) const
{
- return clang_type != rhs.clang_type ||
+ return compiler_type != rhs.compiler_type ||
type_sp.get() != rhs.type_sp.get();
}
void
Clear ()
{
- clang_type.Clear();
+ compiler_type.Clear();
type_sp.reset();
}
@@ -382,8 +402,8 @@ public:
{
if (type_sp)
return type_sp->GetName();
- if (clang_type)
- return clang_type.GetTypeName();
+ if (compiler_type)
+ return compiler_type.GetTypeName();
return ConstString ();
}
@@ -391,24 +411,24 @@ public:
GetDisplayTypeName () const
{
if (type_sp)
- return type_sp->GetClangForwardType().GetDisplayTypeName();
- if (clang_type)
- return clang_type.GetDisplayTypeName();
+ return type_sp->GetForwardCompilerType ().GetDisplayTypeName();
+ if (compiler_type)
+ return compiler_type.GetDisplayTypeName();
return ConstString();
}
void
- SetType (ClangASTType type)
+ SetType (CompilerType type)
{
type_sp.reset();
- clang_type = type;
+ compiler_type = type;
}
void
SetType (lldb::TypeSP type)
{
type_sp = type;
- clang_type = type_sp->GetClangForwardType();
+ compiler_type = type_sp->GetForwardCompilerType ();
}
lldb::TypeSP
@@ -417,72 +437,76 @@ public:
return type_sp;
}
- ClangASTType
- GetClangASTType () const
+ CompilerType
+ GetCompilerType () const
{
- return clang_type;
+ return compiler_type;
}
- ClangASTType
+ CompilerType
GetPointerType () const
{
if (type_sp)
- return type_sp->GetClangLayoutType().GetPointerType();
- return clang_type.GetPointerType();
+ return type_sp->GetForwardCompilerType().GetPointerType();
+ return compiler_type.GetPointerType();
}
- ClangASTType
+ CompilerType
GetPointeeType () const
{
if (type_sp)
- return type_sp->GetClangFullType().GetPointeeType();
- return clang_type.GetPointeeType();
+ return type_sp->GetForwardCompilerType ().GetPointeeType();
+ return compiler_type.GetPointeeType();
}
- ClangASTType
+ CompilerType
GetReferenceType () const
{
if (type_sp)
- return type_sp->GetClangLayoutType().GetLValueReferenceType();
- return clang_type.GetLValueReferenceType();
+ return type_sp->GetForwardCompilerType ().GetLValueReferenceType();
+ else
+ return compiler_type.GetLValueReferenceType();
}
- ClangASTType
+ CompilerType
GetTypedefedType () const
{
if (type_sp)
- return type_sp->GetClangFullType().GetTypedefedType();
- return clang_type.GetTypedefedType();
+ return type_sp->GetForwardCompilerType ().GetTypedefedType();
+ else
+ return compiler_type.GetTypedefedType();
}
- ClangASTType
+ CompilerType
GetDereferencedType () const
{
if (type_sp)
- return type_sp->GetClangFullType().GetNonReferenceType();
- return clang_type.GetNonReferenceType();
+ return type_sp->GetForwardCompilerType ().GetNonReferenceType();
+ else
+ return compiler_type.GetNonReferenceType();
}
- ClangASTType
+ CompilerType
GetUnqualifiedType () const
{
if (type_sp)
- return type_sp->GetClangLayoutType().GetFullyUnqualifiedType();
- return clang_type.GetFullyUnqualifiedType();
+ return type_sp->GetForwardCompilerType ().GetFullyUnqualifiedType();
+ else
+ return compiler_type.GetFullyUnqualifiedType();
}
- ClangASTType
+ CompilerType
GetCanonicalType () const
{
if (type_sp)
- return type_sp->GetClangFullType().GetCanonicalType();
- return clang_type.GetCanonicalType();
+ return type_sp->GetForwardCompilerType ().GetCanonicalType();
+ return compiler_type.GetCanonicalType();
}
- clang::ASTContext *
- GetClangASTContext () const
+ TypeSystem *
+ GetTypeSystem () const
{
- return clang_type.GetASTContext();
+ return compiler_type.GetTypeSystem();
}
lldb::ModuleSP
@@ -493,10 +517,13 @@ public:
return lldb::ModuleSP();
}
protected:
- ClangASTType clang_type;
+ 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:
@@ -509,28 +536,28 @@ public:
TypeImpl (const lldb::TypeSP &type_sp);
- TypeImpl (const ClangASTType &clang_type);
+ TypeImpl (const CompilerType &compiler_type);
- TypeImpl (const lldb::TypeSP &type_sp, const ClangASTType &dynamic);
+ TypeImpl (const lldb::TypeSP &type_sp, const CompilerType &dynamic);
- TypeImpl (const ClangASTType &clang_type, const ClangASTType &dynamic);
+ TypeImpl (const CompilerType &compiler_type, const CompilerType &dynamic);
- TypeImpl (const TypePair &pair, const ClangASTType &dynamic);
+ TypeImpl (const TypePair &pair, const CompilerType &dynamic);
void
SetType (const lldb::TypeSP &type_sp);
void
- SetType (const ClangASTType &clang_type);
+ SetType (const CompilerType &compiler_type);
void
- SetType (const lldb::TypeSP &type_sp, const ClangASTType &dynamic);
+ SetType (const lldb::TypeSP &type_sp, const CompilerType &dynamic);
void
- SetType (const ClangASTType &clang_type, const ClangASTType &dynamic);
+ SetType (const CompilerType &compiler_type, const CompilerType &dynamic);
void
- SetType (const TypePair &pair, const ClangASTType &dynamic);
+ SetType (const TypePair &pair, const CompilerType &dynamic);
TypeImpl&
operator = (const TypeImpl& rhs);
@@ -575,11 +602,11 @@ public:
TypeImpl
GetCanonicalType() const;
- ClangASTType
- GetClangASTType (bool prefer_dynamic);
+ CompilerType
+ GetCompilerType (bool prefer_dynamic);
- clang::ASTContext *
- GetClangASTContext (bool prefer_dynamic);
+ TypeSystem *
+ GetTypeSystem (bool prefer_dynamic);
bool
GetDescription (lldb_private::Stream &strm,
@@ -592,7 +619,7 @@ private:
lldb::ModuleWP m_module_wp;
TypePair m_static_type;
- ClangASTType m_dynamic_type;
+ CompilerType m_dynamic_type;
};
class TypeListImpl
@@ -750,7 +777,7 @@ class TypeAndOrName
public:
TypeAndOrName ();
TypeAndOrName (lldb::TypeSP &type_sp);
- TypeAndOrName (const ClangASTType &clang_type);
+ TypeAndOrName (const CompilerType &compiler_type);
TypeAndOrName (const char *type_str);
TypeAndOrName (const TypeAndOrName &rhs);
TypeAndOrName (ConstString &type_const_string);
@@ -772,10 +799,10 @@ public:
return m_type_pair.GetTypeSP();
}
- ClangASTType
- GetClangASTType () const
+ CompilerType
+ GetCompilerType () const
{
- return m_type_pair.GetClangASTType();
+ return m_type_pair.GetCompilerType();
}
void
@@ -788,7 +815,7 @@ public:
SetTypeSP (lldb::TypeSP type_sp);
void
- SetClangASTType (ClangASTType clang_type);
+ SetCompilerType (CompilerType compiler_type);
bool
IsEmpty () const;
@@ -800,12 +827,12 @@ public:
HasTypeSP () const;
bool
- HasClangASTType () const;
+ HasCompilerType () const;
bool
HasType () const
{
- return HasTypeSP() || HasClangASTType();
+ return HasTypeSP() || HasCompilerType();
}
void
@@ -825,60 +852,43 @@ class TypeMemberFunctionImpl
{
public:
TypeMemberFunctionImpl() :
- m_type(),
- m_objc_method_decl(nullptr),
+ m_type (),
+ m_decl (),
m_name(),
- m_kind(lldb::eMemberFunctionKindUnknown)
+ m_kind (lldb::eMemberFunctionKindUnknown)
{
}
- TypeMemberFunctionImpl (const ClangASTType& type,
+ TypeMemberFunctionImpl (const CompilerType& type,
+ const CompilerDecl& decl,
const std::string& name,
const lldb::MemberFunctionKind& kind) :
- m_type(type),
- m_objc_method_decl(nullptr),
+ m_type (type),
+ m_decl (decl),
m_name(name),
- m_kind(kind)
- {
- }
-
- TypeMemberFunctionImpl (clang::ObjCMethodDecl *method,
- const std::string& name,
- const lldb::MemberFunctionKind& kind) :
- m_type(),
- m_objc_method_decl(method),
- m_name(name),
- m_kind(kind)
- {
- }
-
- TypeMemberFunctionImpl (const TypeMemberFunctionImpl& rhs) :
- m_type(rhs.m_type),
- m_objc_method_decl(rhs.m_objc_method_decl),
- m_name(rhs.m_name),
- m_kind(rhs.m_kind)
+ m_kind (kind)
{
}
- TypeMemberFunctionImpl&
- operator = (const TypeMemberFunctionImpl& rhs);
-
bool
IsValid ();
ConstString
GetName () const;
-
- ClangASTType
+
+ ConstString
+ GetMangledName () const;
+
+ CompilerType
GetType () const;
- ClangASTType
+ CompilerType
GetReturnType () const;
size_t
GetNumArguments () const;
- ClangASTType
+ CompilerType
GetArgumentAtIndex (size_t idx) const;
lldb::MemberFunctionKind
@@ -892,8 +902,8 @@ protected:
GetPrintableTypeName ();
private:
- ClangASTType m_type;
- clang::ObjCMethodDecl *m_objc_method_decl;
+ CompilerType m_type;
+ CompilerDecl m_decl;
ConstString m_name;
lldb::MemberFunctionKind m_kind;
};
@@ -909,8 +919,9 @@ public:
{
}
- TypeEnumMemberImpl (const clang::EnumConstantDecl* enum_member_decl,
- const lldb_private::ClangASTType& integer_type);
+ TypeEnumMemberImpl (const lldb::TypeImplSP &integer_type_sp,
+ const ConstString &name,
+ const llvm::APSInt &value);
TypeEnumMemberImpl (const TypeEnumMemberImpl& rhs) :
m_integer_type_sp(rhs.m_integer_type_sp),
diff --git a/include/lldb/Symbol/TypeList.h b/include/lldb/Symbol/TypeList.h
index 4f3f2c9bdbeb..f3642576ddcb 100644
--- a/include/lldb/Symbol/TypeList.h
+++ b/include/lldb/Symbol/TypeList.h
@@ -13,7 +13,7 @@
#include "lldb/lldb-private.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Utility/Iterable.h"
-#include <map>
+#include <vector>
#include <functional>
namespace lldb_private {
@@ -24,7 +24,7 @@ public:
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
- TypeList();
+ TypeList();
virtual
~TypeList();
@@ -44,17 +44,14 @@ public:
void
Insert (const lldb::TypeSP& type);
- bool
- InsertUnique (const lldb::TypeSP& type);
-
uint32_t
GetSize() const;
lldb::TypeSP
GetTypeAtIndex(uint32_t idx);
- typedef std::multimap<lldb::user_id_t, lldb::TypeSP> collection;
- typedef AdaptedIterable<collection, lldb::TypeSP, map_adapter> TypeIterable;
+ typedef std::vector<lldb::TypeSP> collection;
+ typedef AdaptedIterable<collection, lldb::TypeSP, vector_adapter> TypeIterable;
TypeIterable
Types ()
@@ -68,8 +65,6 @@ public:
void
ForEach (std::function <bool(lldb::TypeSP &type_sp)> const &callback);
- bool
- RemoveTypeWithUID (lldb::user_id_t uid);
void
RemoveMismatchedTypes (const char *qualified_typename,
diff --git a/include/lldb/Symbol/TypeMap.h b/include/lldb/Symbol/TypeMap.h
new file mode 100644
index 000000000000..4398acd789ae
--- /dev/null
+++ b/include/lldb/Symbol/TypeMap.h
@@ -0,0 +1,98 @@
+//===-- TypeMap.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_TypeMap_h_
+#define liblldb_TypeMap_h_
+
+#include "lldb/lldb-private.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Utility/Iterable.h"
+#include <map>
+#include <functional>
+
+namespace lldb_private {
+
+class TypeMap
+{
+public:
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ TypeMap();
+
+ virtual
+ ~TypeMap();
+
+ void
+ Clear();
+
+ void
+ Dump(Stream *s, bool show_context);
+
+ TypeMap
+ FindTypes(const ConstString &name);
+
+ void
+ Insert (const lldb::TypeSP& type);
+
+ bool
+ Empty() const;
+
+ bool
+ InsertUnique (const lldb::TypeSP& type);
+
+ uint32_t
+ GetSize() const;
+
+ lldb::TypeSP
+ GetTypeAtIndex(uint32_t idx);
+
+ typedef std::multimap<lldb::user_id_t, lldb::TypeSP> collection;
+ typedef AdaptedIterable<collection, lldb::TypeSP, map_adapter> TypeIterable;
+
+ TypeIterable
+ Types ()
+ {
+ return TypeIterable(m_types);
+ }
+
+ void
+ ForEach (std::function <bool(const lldb::TypeSP &type_sp)> const &callback) const;
+
+ void
+ ForEach (std::function <bool(lldb::TypeSP &type_sp)> const &callback);
+
+ bool
+ Remove (const lldb::TypeSP &type_sp);
+
+ void
+ RemoveMismatchedTypes (const char *qualified_typename,
+ bool exact_match);
+
+ void
+ RemoveMismatchedTypes (const std::string &type_scope,
+ const std::string &type_basename,
+ lldb::TypeClass type_class,
+ bool exact_match);
+
+ void
+ RemoveMismatchedTypes (lldb::TypeClass type_class);
+
+private:
+ typedef collection::iterator iterator;
+ typedef collection::const_iterator const_iterator;
+
+ collection m_types;
+
+ DISALLOW_COPY_AND_ASSIGN (TypeMap);
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_TypeMap_h_
diff --git a/include/lldb/Symbol/TypeSystem.h b/include/lldb/Symbol/TypeSystem.h
new file mode 100644
index 000000000000..d367bcdc0b14
--- /dev/null
+++ b/include/lldb/Symbol/TypeSystem.h
@@ -0,0 +1,604 @@
+//===-- TypeSystem.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_TypeSystem_h_
+#define liblldb_TypeSystem_h_
+
+// C Includes
+// C++ Includes
+#include <functional>
+#include <map>
+#include <string>
+
+// Other libraries and framework includes
+#include "llvm/ADT/APSInt.h"
+#include "llvm/Support/Casting.h"
+
+// Project includes
+#include "lldb/lldb-private.h"
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Expression/Expression.h"
+#include "lldb/Host/Mutex.h"
+#include "lldb/Symbol/CompilerDecl.h"
+#include "lldb/Symbol/CompilerDeclContext.h"
+
+class DWARFDIE;
+class DWARFASTParser;
+
+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:
+ //
+ // 1 - Add a new enumeration for llvm casting below for your TypeSystem
+ // subclass, here we will use eKindFoo
+ //
+ // 2 - Your TypeSystem subclass will inherit from TypeSystem and needs
+ // to implement a static classof() function that returns your
+ // enumeration:
+ //
+ // class Foo : public lldb_private::TypeSystem
+ // {
+ // static bool classof(const TypeSystem *ts)
+ // {
+ // return ts->getKind() == TypeSystem::eKindFoo;
+ // }
+ // };
+ //
+ // 3 - Contruct your TypeSystem subclass with the enumeration from below
+ //
+ // Foo() :
+ // TypeSystem(TypeSystem::eKindFoo),
+ // ...
+ // {
+ // }
+ //
+ // Then you can use the llvm casting on any "TypeSystem *" to get an
+ // instance of your subclass.
+ //----------------------------------------------------------------------
+ enum LLVMCastKind {
+ eKindClang,
+ eKindSwift,
+ eKindGo,
+ kNumKinds
+ };
+
+ //----------------------------------------------------------------------
+ // Constructors and Destructors
+ //----------------------------------------------------------------------
+ TypeSystem(LLVMCastKind kind);
+
+ ~TypeSystem() override;
+
+ LLVMCastKind getKind() const { return m_kind; }
+
+ static lldb::TypeSystemSP
+ CreateInstance (lldb::LanguageType language, Module *module);
+
+ static lldb::TypeSystemSP
+ CreateInstance (lldb::LanguageType language, Target *target);
+
+ virtual DWARFASTParser *
+ GetDWARFParser ()
+ {
+ return nullptr;
+ }
+
+ virtual SymbolFile *
+ GetSymbolFile () const
+ {
+ return m_sym_file;
+ }
+
+ // Returns true if the symbol file changed during the set accessor.
+ virtual void
+ SetSymbolFile (SymbolFile *sym_file)
+ {
+ m_sym_file = sym_file;
+ }
+
+ //----------------------------------------------------------------------
+ // CompilerDecl functions
+ //----------------------------------------------------------------------
+ virtual ConstString
+ DeclGetName (void *opaque_decl) = 0;
+
+ virtual ConstString
+ DeclGetMangledName (void *opaque_decl);
+
+ virtual lldb::VariableSP
+ DeclGetVariable (void *opaque_decl) = 0;
+
+ virtual void
+ DeclLinkToObject (void *opaque_decl, std::shared_ptr<void> object) = 0;
+
+ virtual CompilerDeclContext
+ DeclGetDeclContext (void *opaque_decl);
+
+ virtual CompilerType
+ DeclGetFunctionReturnType(void *opaque_decl);
+
+ virtual size_t
+ DeclGetFunctionNumArguments(void *opaque_decl);
+
+ virtual CompilerType
+ DeclGetFunctionArgumentType (void *opaque_decl, size_t arg_idx);
+
+ //----------------------------------------------------------------------
+ // CompilerDeclContext functions
+ //----------------------------------------------------------------------
+
+ virtual std::vector<CompilerDecl>
+ DeclContextFindDeclByName (void *opaque_decl_ctx, ConstString name);
+
+ virtual bool
+ DeclContextIsStructUnionOrClass (void *opaque_decl_ctx) = 0;
+
+ virtual ConstString
+ DeclContextGetName (void *opaque_decl_ctx) = 0;
+
+ virtual bool
+ DeclContextIsClassMethod (void *opaque_decl_ctx,
+ lldb::LanguageType *language_ptr,
+ bool *is_instance_method_ptr,
+ ConstString *language_object_name_ptr) = 0;
+
+ //----------------------------------------------------------------------
+ // Tests
+ //----------------------------------------------------------------------
+
+ virtual bool
+ IsArrayType (lldb::opaque_compiler_type_t type,
+ CompilerType *element_type,
+ uint64_t *size,
+ bool *is_incomplete) = 0;
+
+ virtual bool
+ IsAggregateType (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool
+ IsAnonymousType (lldb::opaque_compiler_type_t type);
+
+ virtual bool
+ IsCharType (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool
+ IsCompleteType (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool
+ IsDefined(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool
+ IsFloatingPointType (lldb::opaque_compiler_type_t type, uint32_t &count, bool &is_complex) = 0;
+
+ virtual bool
+ IsFunctionType (lldb::opaque_compiler_type_t type, bool *is_variadic_ptr) = 0;
+
+ virtual size_t
+ GetNumberOfFunctionArguments (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual CompilerType
+ GetFunctionArgumentAtIndex (lldb::opaque_compiler_type_t type, const size_t index) = 0;
+
+ virtual bool
+ IsFunctionPointerType (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool
+ IsIntegerType (lldb::opaque_compiler_type_t type, bool &is_signed) = 0;
+
+ virtual bool
+ IsPossibleDynamicType (lldb::opaque_compiler_type_t type,
+ CompilerType *target_type, // Can pass NULL
+ bool check_cplusplus,
+ bool check_objc) = 0;
+
+ virtual bool
+ IsPointerType (lldb::opaque_compiler_type_t type, CompilerType *pointee_type) = 0;
+
+ virtual bool
+ IsScalarType (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool
+ IsVoidType (lldb::opaque_compiler_type_t type) = 0;
+
+ // TypeSystems can support more than one language
+ virtual bool
+ SupportsLanguage (lldb::LanguageType language) = 0;
+
+ //----------------------------------------------------------------------
+ // Type Completion
+ //----------------------------------------------------------------------
+
+ virtual bool
+ GetCompleteType (lldb::opaque_compiler_type_t type) = 0;
+
+ //----------------------------------------------------------------------
+ // AST related queries
+ //----------------------------------------------------------------------
+
+ virtual uint32_t
+ GetPointerByteSize () = 0;
+
+ //----------------------------------------------------------------------
+ // Accessors
+ //----------------------------------------------------------------------
+
+ virtual ConstString
+ GetTypeName (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual uint32_t
+ GetTypeInfo (lldb::opaque_compiler_type_t type, CompilerType *pointee_or_element_compiler_type) = 0;
+
+ virtual lldb::LanguageType
+ GetMinimumLanguage (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual lldb::TypeClass
+ GetTypeClass (lldb::opaque_compiler_type_t type) = 0;
+
+ //----------------------------------------------------------------------
+ // Creating related types
+ //----------------------------------------------------------------------
+
+ virtual CompilerType
+ GetArrayElementType (lldb::opaque_compiler_type_t type, uint64_t *stride) = 0;
+
+ virtual CompilerType
+ GetCanonicalType (lldb::opaque_compiler_type_t type) = 0;
+
+ // Returns -1 if this isn't a function of if the function doesn't have a prototype
+ // Returns a value >= 0 if there is a prototype.
+ virtual int
+ GetFunctionArgumentCount (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual CompilerType
+ GetFunctionArgumentTypeAtIndex (lldb::opaque_compiler_type_t type, size_t idx) = 0;
+
+ virtual CompilerType
+ GetFunctionReturnType (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual size_t
+ GetNumMemberFunctions (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual TypeMemberFunctionImpl
+ GetMemberFunctionAtIndex (lldb::opaque_compiler_type_t type, size_t idx) = 0;
+
+ virtual CompilerType
+ GetPointeeType (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual CompilerType
+ GetPointerType (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual CompilerType
+ GetLValueReferenceType (lldb::opaque_compiler_type_t type);
+
+ virtual CompilerType
+ GetRValueReferenceType (lldb::opaque_compiler_type_t type);
+
+ virtual CompilerType
+ AddConstModifier (lldb::opaque_compiler_type_t type);
+
+ virtual CompilerType
+ AddVolatileModifier (lldb::opaque_compiler_type_t type);
+
+ virtual CompilerType
+ AddRestrictModifier (lldb::opaque_compiler_type_t type);
+
+ virtual CompilerType
+ CreateTypedef (lldb::opaque_compiler_type_t type, const char *name, const CompilerDeclContext &decl_ctx);
+
+ //----------------------------------------------------------------------
+ // Exploring the type
+ //----------------------------------------------------------------------
+
+ virtual uint64_t
+ GetBitSize (lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) = 0;
+
+ virtual lldb::Encoding
+ GetEncoding (lldb::opaque_compiler_type_t type, uint64_t &count) = 0;
+
+ virtual lldb::Format
+ GetFormat (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual uint32_t
+ GetNumChildren (lldb::opaque_compiler_type_t type, bool omit_empty_base_classes) = 0;
+
+ virtual CompilerType
+ GetBuiltinTypeByName (const ConstString &name);
+
+ virtual lldb::BasicType
+ GetBasicTypeEnumeration (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual void
+ ForEachEnumerator (lldb::opaque_compiler_type_t type, std::function <bool (const CompilerType &integer_type, const ConstString &name, const llvm::APSInt &value)> const &callback)
+ {
+ }
+
+ virtual uint32_t
+ GetNumFields (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual CompilerType
+ GetFieldAtIndex (lldb::opaque_compiler_type_t type,
+ size_t idx,
+ std::string& name,
+ uint64_t *bit_offset_ptr,
+ uint32_t *bitfield_bit_size_ptr,
+ bool *is_bitfield_ptr) = 0;
+
+ virtual uint32_t
+ GetNumDirectBaseClasses (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual uint32_t
+ GetNumVirtualBaseClasses (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual CompilerType
+ GetDirectBaseClassAtIndex (lldb::opaque_compiler_type_t type,
+ size_t idx,
+ uint32_t *bit_offset_ptr) = 0;
+
+ virtual CompilerType
+ GetVirtualBaseClassAtIndex (lldb::opaque_compiler_type_t type,
+ size_t idx,
+ uint32_t *bit_offset_ptr) = 0;
+
+ virtual CompilerType
+ GetChildCompilerTypeAtIndex (lldb::opaque_compiler_type_t type,
+ ExecutionContext *exe_ctx,
+ size_t idx,
+ bool transparent_pointers,
+ bool omit_empty_base_classes,
+ bool ignore_array_bounds,
+ std::string& child_name,
+ uint32_t &child_byte_size,
+ int32_t &child_byte_offset,
+ uint32_t &child_bitfield_bit_size,
+ uint32_t &child_bitfield_bit_offset,
+ bool &child_is_base_class,
+ bool &child_is_deref_of_parent,
+ ValueObject *valobj,
+ uint64_t &language_flags) = 0;
+
+ // Lookup a child given a name. This function will match base class names
+ // and member member names in "clang_type" only, not descendants.
+ virtual uint32_t
+ GetIndexOfChildWithName (lldb::opaque_compiler_type_t type,
+ const char *name,
+ bool omit_empty_base_classes) = 0;
+
+ // Lookup a child member given a name. This function will match member names
+ // only and will descend into "clang_type" children in search for the first
+ // member in this class, or any base class that matches "name".
+ // TODO: Return all matches for a given name by returning a vector<vector<uint32_t>>
+ // so we catch all names that match a given child name, not just the first.
+ virtual size_t
+ GetIndexOfChildMemberWithName (lldb::opaque_compiler_type_t type,
+ const char *name,
+ bool omit_empty_base_classes,
+ std::vector<uint32_t>& child_indexes) = 0;
+
+ virtual size_t
+ GetNumTemplateArguments (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual CompilerType
+ GetTemplateArgument (lldb::opaque_compiler_type_t type,
+ size_t idx,
+ lldb::TemplateArgumentKind &kind) = 0;
+
+ //----------------------------------------------------------------------
+ // Dumping types
+ //----------------------------------------------------------------------
+
+ virtual void
+ DumpValue (lldb::opaque_compiler_type_t type,
+ ExecutionContext *exe_ctx,
+ Stream *s,
+ lldb::Format format,
+ const DataExtractor &data,
+ lldb::offset_t data_offset,
+ size_t data_byte_size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset,
+ bool show_types,
+ bool show_summary,
+ bool verbose,
+ uint32_t depth) = 0;
+
+ virtual bool
+ DumpTypeValue (lldb::opaque_compiler_type_t type,
+ Stream *s,
+ lldb::Format format,
+ const DataExtractor &data,
+ lldb::offset_t data_offset,
+ size_t data_byte_size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset,
+ ExecutionContextScope *exe_scope) = 0;
+
+ virtual void
+ DumpTypeDescription (lldb::opaque_compiler_type_t type) = 0; // Dump to stdout
+
+ virtual void
+ DumpTypeDescription (lldb::opaque_compiler_type_t type, Stream *s) = 0;
+
+ //----------------------------------------------------------------------
+ // TODO: These methods appear unused. Should they be removed?
+ //----------------------------------------------------------------------
+
+ virtual bool
+ IsRuntimeGeneratedType (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual void
+ DumpSummary (lldb::opaque_compiler_type_t type,
+ ExecutionContext *exe_ctx,
+ Stream *s,
+ const DataExtractor &data,
+ lldb::offset_t data_offset,
+ size_t data_byte_size) = 0;
+
+ // Converts "s" to a floating point value and place resulting floating
+ // point bytes in the "dst" buffer.
+ virtual size_t
+ ConvertStringToFloatValue (lldb::opaque_compiler_type_t type,
+ const char *s,
+ uint8_t *dst,
+ size_t dst_size) = 0;
+
+ //----------------------------------------------------------------------
+ // TODO: Determine if these methods should move to ClangASTContext.
+ //----------------------------------------------------------------------
+
+ virtual bool
+ IsPointerOrReferenceType (lldb::opaque_compiler_type_t type, CompilerType *pointee_type) = 0;
+
+ virtual unsigned
+ GetTypeQualifiers(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool
+ IsCStringType (lldb::opaque_compiler_type_t type, uint32_t &length) = 0;
+
+ virtual size_t
+ GetTypeBitAlign (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual CompilerType
+ GetBasicTypeFromAST (lldb::BasicType basic_type) = 0;
+
+ virtual CompilerType
+ GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding,
+ size_t bit_size) = 0;
+
+ virtual bool
+ IsBeingDefined (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool
+ IsConst(lldb::opaque_compiler_type_t type) = 0;
+
+ virtual uint32_t
+ IsHomogeneousAggregate (lldb::opaque_compiler_type_t type, CompilerType* base_type_ptr) = 0;
+
+ virtual bool
+ IsPolymorphicClass (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool
+ IsTypedefType (lldb::opaque_compiler_type_t type) = 0;
+
+ // If the current object represents a typedef type, get the underlying type
+ virtual CompilerType
+ GetTypedefedType (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool
+ IsVectorType (lldb::opaque_compiler_type_t type,
+ CompilerType *element_type,
+ uint64_t *size) = 0;
+
+ virtual CompilerType
+ GetFullyUnqualifiedType (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual CompilerType
+ GetNonReferenceType (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool
+ IsReferenceType (lldb::opaque_compiler_type_t type, CompilerType *pointee_type, bool* is_rvalue) = 0;
+
+ virtual bool
+ ShouldTreatScalarValueAsAddress (lldb::opaque_compiler_type_t type)
+ {
+ return IsPointerOrReferenceType(type, nullptr);
+ }
+
+ virtual UserExpression *
+ GetUserExpression (const char *expr,
+ const char *expr_prefix,
+ lldb::LanguageType language,
+ Expression::ResultType desired_type,
+ const EvaluateExpressionOptions &options)
+ {
+ return nullptr;
+ }
+
+ virtual FunctionCaller *
+ GetFunctionCaller (const CompilerType &return_type,
+ const Address& function_address,
+ const ValueList &arg_value_list,
+ const char *name)
+ {
+ return nullptr;
+ }
+
+ virtual UtilityFunction *
+ GetUtilityFunction(const char *text, const char *name)
+ {
+ return nullptr;
+ }
+
+ virtual PersistentExpressionState *
+ GetPersistentExpressionState()
+ {
+ return nullptr;
+ }
+
+ virtual CompilerType
+ GetTypeForFormatters (void* type);
+
+ virtual LazyBool
+ ShouldPrintAsOneLiner (void* type, ValueObject* valobj);
+
+ // Type systems can have types that are placeholder types, which are meant to indicate
+ // the presence of a type, but offer no actual information about said types, and leave
+ // the burden of actually figuring type information out to dynamic type resolution. For instance
+ // a language with a generics system, can use placeholder types to indicate "type argument goes here",
+ // without promising uniqueness of the placeholder, nor attaching any actually idenfiable information
+ // to said placeholder. This API allows type systems to tell LLDB when such a type has been encountered
+ // In response, the debugger can react by not using this type as a cache entry in any type-specific way
+ // For instance, LLDB will currently not cache any formatters that are discovered on such a type as
+ // attributable to the meaningless type itself, instead preferring to use the dynamic type
+ virtual bool
+ IsMeaninglessWithoutDynamicResolution (void* type);
+
+protected:
+ const LLVMCastKind m_kind; // Support for llvm casting
+ SymbolFile *m_sym_file;
+
+};
+
+ class TypeSystemMap
+ {
+ public:
+ TypeSystemMap ();
+ ~TypeSystemMap();
+
+ void
+ Clear ();
+
+ // Iterate through all of the type systems that are created. Return true
+ // from callback to keep iterating, false to stop iterating.
+ void
+ ForEach (std::function <bool(TypeSystem *)> const &callback);
+
+ TypeSystem *
+ GetTypeSystemForLanguage (lldb::LanguageType language, Module *module, bool can_create);
+
+ TypeSystem *
+ GetTypeSystemForLanguage (lldb::LanguageType language, Target *target, bool can_create);
+
+ protected:
+ typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> collection;
+ mutable Mutex m_mutex; ///< A mutex to keep this object happy in multi-threaded environments.
+ collection m_map;
+ };
+
+} // namespace lldb_private
+
+#endif // liblldb_TypeSystem_h_
diff --git a/include/lldb/Symbol/UnwindPlan.h b/include/lldb/Symbol/UnwindPlan.h
index bfc008a5b6bc..71100138413d 100644
--- a/include/lldb/Symbol/UnwindPlan.h
+++ b/include/lldb/Symbol/UnwindPlan.h
@@ -1,14 +1,28 @@
+//===-- UnwindPlan.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_UnwindPlan_h
#define liblldb_UnwindPlan_h
+// C Includes
+// C++ Includes
+#include <map>
+#include <memory>
+#include <vector>
+
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/ConstString.h"
-#include <map>
-#include <vector>
-
namespace lldb_private {
// The UnwindPlan object specifies how to unwind out of a function - where
@@ -38,13 +52,11 @@ namespace lldb_private {
class UnwindPlan {
public:
-
class Row {
public:
class RegisterLocation
{
public:
-
enum RestoreType
{
unspecified, // not specified, we may be able to assume this
@@ -187,7 +199,7 @@ public:
}
else
{
- *opcodes = NULL;
+ *opcodes = nullptr;
len = 0;
}
}
@@ -203,7 +215,7 @@ public:
{
if (m_type == atDWARFExpression || m_type == isDWARFExpression)
return m_location.expr.opcodes;
- return NULL;
+ return nullptr;
}
int
@@ -240,7 +252,6 @@ public:
class CFAValue
{
public:
-
enum ValueType
{
unspecified, // not specified
@@ -361,7 +372,7 @@ public:
}
else
{
- *opcodes = NULL;
+ *opcodes = nullptr;
len = 0;
}
}
@@ -371,7 +382,7 @@ public:
{
if (m_type == isDWARFExpression)
return m_value.expr.opcodes;
- return NULL;
+ return nullptr;
}
int
@@ -488,7 +499,6 @@ public:
}; // class Row
public:
-
typedef std::shared_ptr<Row> RowSP;
UnwindPlan (lldb::RegisterKind reg_kind) :
@@ -520,9 +530,7 @@ public:
m_row_list.emplace_back (new Row (*row_sp));
}
- ~UnwindPlan ()
- {
- }
+ ~UnwindPlan() = default;
void
Dump (Stream& s, Thread* thread, lldb::addr_t base_addr) const;
@@ -676,8 +684,6 @@ public:
}
private:
-
-
typedef std::vector<RowSP> collection;
collection m_row_list;
AddressRange m_plan_valid_address_range;
@@ -697,4 +703,4 @@ private:
} // namespace lldb_private
-#endif //liblldb_UnwindPlan_h
+#endif // liblldb_UnwindPlan_h
diff --git a/include/lldb/Symbol/UnwindTable.h b/include/lldb/Symbol/UnwindTable.h
index 38d3ff6dd3c9..f69e4660de24 100644
--- a/include/lldb/Symbol/UnwindTable.h
+++ b/include/lldb/Symbol/UnwindTable.h
@@ -34,6 +34,9 @@ public:
lldb_private::CompactUnwindInfo *
GetCompactUnwindInfo ();
+ ArmUnwindInfo *
+ GetArmUnwindInfo ();
+
lldb::FuncUnwindersSP
GetFuncUnwindersContainingAddress (const Address& addr, SymbolContext &sc);
@@ -65,9 +68,10 @@ private:
bool m_initialized; // delay some initialization until ObjectFile is set up
Mutex m_mutex;
- DWARFCallFrameInfo* m_eh_frame;
- CompactUnwindInfo *m_compact_unwind;
-
+ std::unique_ptr<DWARFCallFrameInfo> m_eh_frame_up;
+ std::unique_ptr<CompactUnwindInfo> m_compact_unwind_up;
+ std::unique_ptr<ArmUnwindInfo> m_arm_unwind_up;
+
DISALLOW_COPY_AND_ASSIGN (UnwindTable);
};
diff --git a/include/lldb/Symbol/Variable.h b/include/lldb/Symbol/Variable.h
index 8d413cac3d7d..1cac5d0c5649 100644
--- a/include/lldb/Symbol/Variable.h
+++ b/include/lldb/Symbol/Variable.h
@@ -1,4 +1,5 @@
-//===-- Variable.h ----------------------------------------------*- C++ -*-===//
+//===-- Variable.h ----------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,6 +11,7 @@
#ifndef liblldb_Variable_h_
#define liblldb_Variable_h_
+#include <memory>
#include <vector>
#include "lldb/lldb-private.h"
@@ -21,7 +23,8 @@
namespace lldb_private {
-class Variable : public UserID
+class Variable : public UserID,
+ public std::enable_shared_from_this<Variable>
{
public:
//------------------------------------------------------------------
@@ -36,7 +39,8 @@ public:
Declaration* decl,
const DWARFExpression& location,
bool external,
- bool artificial);
+ bool artificial,
+ bool static_member = false);
virtual
~Variable();
@@ -58,6 +62,9 @@ public:
ConstString
GetName() const;
+ ConstString
+ GetUnqualifiedName() const;
+
SymbolContextScope *
GetSymbolContextScope() const
{
@@ -99,6 +106,11 @@ public:
return m_artificial;
}
+ bool IsStaticMember() const
+ {
+ return m_static_member;
+ }
+
DWARFExpression &
LocationExpression()
{
@@ -161,6 +173,11 @@ public:
StringList &matches,
bool &word_complete);
+ CompilerDeclContext
+ GetDeclContext ();
+
+ CompilerDecl
+ GetDecl ();
protected:
ConstString m_name; // The basename of the variable (no namespaces)
Mangled m_mangled; // The mangled name of the variable
@@ -171,7 +188,8 @@ protected:
DWARFExpression m_location; // The location of this variable that can be fed to DWARFExpression::Evaluate()
uint8_t m_external:1, // Visible outside the containing compile unit?
m_artificial:1, // Non-zero if the variable is not explicitly declared in source
- m_loc_is_const_data:1; // The m_location expression contains the constant variable value data, not a DWARF location
+ m_loc_is_const_data:1, // The m_location expression contains the constant variable value data, not a DWARF location
+ m_static_member:1; // Non-zero if variable is static member of a class or struct.
private:
Variable(const Variable& rhs);
Variable& operator=(const Variable& rhs);
diff --git a/include/lldb/Symbol/VariableList.h b/include/lldb/Symbol/VariableList.h
index 5f8f2a225650..1c1d5dfefb9e 100644
--- a/include/lldb/Symbol/VariableList.h
+++ b/include/lldb/Symbol/VariableList.h
@@ -48,10 +48,10 @@ public:
RemoveVariableAtIndex (size_t idx);
lldb::VariableSP
- FindVariable (const ConstString& name);
+ FindVariable (const ConstString& name, bool include_static_members = true);
lldb::VariableSP
- FindVariable (const ConstString& name, lldb::ValueType value_type);
+ FindVariable (const ConstString& name, lldb::ValueType value_type, bool include_static_members = true);
uint32_t
FindVariableIndex (const lldb::VariableSP &var_sp);
diff --git a/include/lldb/Target/ABI.h b/include/lldb/Target/ABI.h
index 89d4f6bdba6c..94826d173500 100644
--- a/include/lldb/Target/ABI.h
+++ b/include/lldb/Target/ABI.h
@@ -44,8 +44,7 @@ public:
std::unique_ptr<uint8_t[]> data_ap; /* host data pointer */
};
- virtual
- ~ABI();
+ ~ABI() override;
virtual size_t
GetRedZoneSize () const = 0;
@@ -78,7 +77,7 @@ public:
lldb::ValueObjectSP
GetReturnValueObject (Thread &thread,
- ClangASTType &type,
+ CompilerType &type,
bool persistent = true) const;
// specialized to work with llvm IR types
@@ -95,7 +94,7 @@ protected:
// This is the method the ABI will call to actually calculate the return value.
// Don't put it in a persistent value object, that will be done by the ABI::GetReturnValueObject.
virtual lldb::ValueObjectSP
- GetReturnValueObjectImpl (Thread &thread, ClangASTType &ast_type) const = 0;
+ GetReturnValueObjectImpl (Thread &thread, CompilerType &ast_type) const = 0;
// specialized to work with llvm IR types
virtual lldb::ValueObjectSP
@@ -148,14 +147,17 @@ public:
FindPlugin (const ArchSpec &arch);
protected:
+
//------------------------------------------------------------------
// Classes that inherit from ABI can see and modify these
//------------------------------------------------------------------
ABI();
+
private:
+
DISALLOW_COPY_AND_ASSIGN (ABI);
};
} // namespace lldb_private
-#endif // liblldb_ABI_h_
+#endif // liblldb_ABI_h_
diff --git a/include/lldb/Target/CPPLanguageRuntime.h b/include/lldb/Target/CPPLanguageRuntime.h
index 3e51453566b3..ac537d0ad1e5 100644
--- a/include/lldb/Target/CPPLanguageRuntime.h
+++ b/include/lldb/Target/CPPLanguageRuntime.h
@@ -25,100 +25,10 @@ class CPPLanguageRuntime :
public LanguageRuntime
{
public:
+ ~CPPLanguageRuntime() override;
- class MethodName
- {
- public:
- enum Type
- {
- eTypeInvalid,
- eTypeUnknownMethod,
- eTypeClassMethod,
- eTypeInstanceMethod
- };
-
- MethodName () :
- m_full(),
- m_basename(),
- m_context(),
- m_arguments(),
- m_qualifiers(),
- m_type (eTypeInvalid),
- m_parsed (false),
- m_parse_error (false)
- {
- }
-
- MethodName (const ConstString &s) :
- m_full(s),
- m_basename(),
- m_context(),
- m_arguments(),
- m_qualifiers(),
- m_type (eTypeInvalid),
- m_parsed (false),
- m_parse_error (false)
- {
- }
-
- void
- Clear();
-
- bool
- IsValid ()
- {
- if (!m_parsed)
- Parse();
- if (m_parse_error)
- return false;
- if (m_type == eTypeInvalid)
- return false;
- return (bool)m_full;
- }
-
- Type
- GetType () const
- {
- return m_type;
- }
-
- const ConstString &
- GetFullName () const
- {
- return m_full;
- }
-
- llvm::StringRef
- GetBasename ();
-
- llvm::StringRef
- GetContext ();
-
- llvm::StringRef
- GetArguments ();
-
- llvm::StringRef
- GetQualifiers ();
-
- protected:
- void
- Parse();
-
- ConstString m_full; // Full name: "lldb::SBTarget::GetBreakpointAtIndex(unsigned int) const"
- llvm::StringRef m_basename; // Basename: "GetBreakpointAtIndex"
- llvm::StringRef m_context; // Decl context: "lldb::SBTarget"
- llvm::StringRef m_arguments; // Arguments: "(unsigned int)"
- llvm::StringRef m_qualifiers; // Qualifiers: "const"
- Type m_type;
- bool m_parsed;
- bool m_parse_error;
- };
-
- virtual
- ~CPPLanguageRuntime();
-
- virtual lldb::LanguageType
- GetLanguageType () const
+ lldb::LanguageType
+ GetLanguageType() const override
{
return lldb::eLanguageTypeC_plus_plus;
}
@@ -126,45 +36,27 @@ public:
virtual bool
IsVTableName (const char *name) = 0;
- virtual bool
- GetObjectDescription (Stream &str, ValueObject &object);
-
- virtual bool
- GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope);
+ bool
+ GetObjectDescription(Stream &str, ValueObject &object) override;
- static bool
- IsCPPMangledName(const char *name);
-
- // Extract C++ context and identifier from a string using heuristic matching (as opposed to
- // CPPLanguageRuntime::MethodName which has to have a fully qualified C++ name with parens and arguments.
- // If the name is a lone C identifier (e.g. C) or a qualified C identifier (e.g. A::B::C) it will return true,
- // and identifier will be the identifier (C and C respectively) and the context will be "" and "A::B::" respectively.
- // If the name fails the heuristic matching for a qualified or unqualified C/C++ identifier, then it will return false
- // and identifier and context will be unchanged.
-
- static bool
- ExtractContextAndIdentifier (const char *name, llvm::StringRef &context, llvm::StringRef &identifier);
+ bool
+ GetObjectDescription(Stream &str, Value &value, ExecutionContextScope *exe_scope) override;
- // in some cases, compilers will output different names for one same type. when that happens, it might be impossible
- // to construct SBType objects for a valid type, because the name that is available is not the same as the name that
- // can be used as a search key in FindTypes(). the equivalents map here is meant to return possible alternative names
- // for a type through which a search can be conducted. Currently, this is only enabled for C++ but can be extended
- // to ObjC or other languages if necessary
- static uint32_t
- FindEquivalentNames(ConstString type_name, std::vector<ConstString>& equivalents);
-
virtual size_t
GetAlternateManglings(const ConstString &mangled, std::vector<ConstString> &alternates) = 0;
protected:
+
//------------------------------------------------------------------
// Classes that inherit from CPPLanguageRuntime can see and modify these
//------------------------------------------------------------------
CPPLanguageRuntime(Process *process);
+
private:
+
DISALLOW_COPY_AND_ASSIGN (CPPLanguageRuntime);
};
} // namespace lldb_private
-#endif // liblldb_CPPLanguageRuntime_h_
+#endif // liblldb_CPPLanguageRuntime_h_
diff --git a/include/lldb/Target/DynamicLoader.h b/include/lldb/Target/DynamicLoader.h
index 6652a5ec144f..5eada0342a21 100644
--- a/include/lldb/Target/DynamicLoader.h
+++ b/include/lldb/Target/DynamicLoader.h
@@ -71,8 +71,7 @@ public:
/// The destructor is virtual since this class is designed to be
/// inherited from by the plug-in instance.
//------------------------------------------------------------------
- virtual
- ~DynamicLoader ();
+ ~DynamicLoader() override;
//------------------------------------------------------------------
/// Called after attaching a process.
@@ -264,12 +263,14 @@ protected:
virtual void
UpdateLoadedSections(lldb::ModuleSP module,
lldb::addr_t link_map_addr,
- lldb::addr_t base_addr);
+ lldb::addr_t base_addr,
+ bool base_addr_is_offset);
// Utility method so base classes can share implementation of UpdateLoadedSections
void
UpdateLoadedSectionsCommon(lldb::ModuleSP module,
- lldb::addr_t base_addr);
+ lldb::addr_t base_addr,
+ bool base_addr_is_offset);
/// Removes the loaded sections from the target in @p module.
///
@@ -283,8 +284,11 @@ protected:
/// Locates or creates a module given by @p file and updates/loads the
/// resulting module at the virtual base address @p base_addr.
- lldb::ModuleSP
- LoadModuleAtAddress(const lldb_private::FileSpec &file, lldb::addr_t link_map_addr, lldb::addr_t 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);
const lldb_private::SectionList *
GetSectionListFromModule(const lldb::ModuleSP module) const;
@@ -303,11 +307,12 @@ protected:
// Member variables.
//------------------------------------------------------------------
Process* m_process; ///< The process that this dynamic loader plug-in is tracking.
+
private:
- DISALLOW_COPY_AND_ASSIGN (DynamicLoader);
+ DISALLOW_COPY_AND_ASSIGN (DynamicLoader);
};
} // namespace lldb_private
-#endif // liblldb_DynamicLoader_h_
+#endif // liblldb_DynamicLoader_h_
diff --git a/include/lldb/Target/ExecutionContext.h b/include/lldb/Target/ExecutionContext.h
index 50f2beaf949b..cdf55e3b744c 100644
--- a/include/lldb/Target/ExecutionContext.h
+++ b/include/lldb/Target/ExecutionContext.h
@@ -6,6 +6,21 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_ExecutionContext_h_
+#define liblldb_ExecutionContext_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-private.h"
+#include "lldb/Target/StackID.h"
+#include "lldb/Host/Mutex.h"
+
+namespace lldb_private {
+
+//===----------------------------------------------------------------------===//
/// Execution context objects refer to objects in the execution of the
/// program that is being debugged. The consist of one or more of the
/// following objects: target, process, thread, and frame. Many objects
@@ -30,17 +45,6 @@
/// to a wide variety of functions that require execution contexts.
//===----------------------------------------------------------------------===//
-
-
-#ifndef liblldb_ExecutionContext_h_
-#define liblldb_ExecutionContext_h_
-
-#include "lldb/lldb-private.h"
-#include "lldb/Target/StackID.h"
-#include "lldb/Host/Mutex.h"
-
-namespace lldb_private {
-
//----------------------------------------------------------------------
/// @class ExecutionContextRef ExecutionContext.h "lldb/Target/ExecutionContext.h"
/// @brief A class that holds a weak reference to an execution context.
@@ -86,7 +90,7 @@ public:
ExecutionContextRef (const ExecutionContextRef &rhs);
//------------------------------------------------------------------
- /// Construct using an ExecutionContext object that might be NULL.
+ /// 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
@@ -102,22 +106,6 @@ public:
ExecutionContextRef (const ExecutionContext &exe_ctx);
//------------------------------------------------------------------
- /// 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);
-
- //------------------------------------------------------------------
/// 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
@@ -154,10 +142,27 @@ public:
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 NULL, and the frame index to an
+ /// Sets the process and thread to nullptr, and the frame index to an
/// invalid value.
//------------------------------------------------------------------
void
@@ -394,6 +399,7 @@ public:
ExecutionContext (const lldb::ProcessSP &process_sp);
ExecutionContext (const lldb::ThreadSP &thread_sp);
ExecutionContext (const lldb::StackFrameSP &frame_sp);
+
//------------------------------------------------------------------
// Create execution contexts from weak pointers
//------------------------------------------------------------------
@@ -413,16 +419,6 @@ public:
//------------------------------------------------------------------
ExecutionContext (ExecutionContextScope *exe_scope);
ExecutionContext (ExecutionContextScope &exe_scope);
-
-
- ExecutionContext &
- operator =(const ExecutionContext &rhs);
-
- bool
- operator ==(const ExecutionContext &rhs) const;
-
- bool
- operator !=(const ExecutionContext &rhs) const;
//------------------------------------------------------------------
/// Construct with process, thread, and frame index.
@@ -438,16 +434,26 @@ public:
/// @param[in] frame
/// The frame index for this execution context.
//------------------------------------------------------------------
- ExecutionContext (Process* process,
- Thread *thread = NULL,
- StackFrame * frame = NULL);
+ ExecutionContext(Process* process,
+ Thread *thread = nullptr,
+ StackFrame * frame = nullptr);
~ExecutionContext();
+
+ ExecutionContext &
+ operator =(const ExecutionContext &rhs);
+
+ bool
+ operator ==(const ExecutionContext &rhs) const;
+
+ bool
+ operator !=(const ExecutionContext &rhs) const;
+
//------------------------------------------------------------------
/// Clear the object's state.
///
- /// Sets the process and thread to NULL, and the frame index to an
+ /// Sets the process and thread to nullptr, and the frame index to an
/// invalid value.
//------------------------------------------------------------------
void
@@ -468,10 +474,10 @@ public:
//------------------------------------------------------------------
/// Returns a pointer to the target object.
///
- /// The returned pointer might be NULL. Calling HasTargetScope(),
+ /// The returned pointer might be nullptr. Calling HasTargetScope(),
/// HasProcessScope(), HasThreadScope(), or HasFrameScope()
/// can help to pre-validate this pointer so that this accessor can
- /// freely be used without having to check for NULL each time.
+ /// freely be used without having to check for nullptr each time.
///
/// @see ExecutionContext::HasTargetScope() const
/// @see ExecutionContext::HasProcessScope() const
@@ -484,10 +490,10 @@ public:
//------------------------------------------------------------------
/// Returns a pointer to the process object.
///
- /// The returned pointer might be NULL. Calling HasProcessScope(),
+ /// The returned pointer might be nullptr. Calling HasProcessScope(),
/// HasThreadScope(), or HasFrameScope() can help to pre-validate
/// this pointer so that this accessor can freely be used without
- /// having to check for NULL each time.
+ /// having to check for nullptr each time.
///
/// @see ExecutionContext::HasProcessScope() const
/// @see ExecutionContext::HasThreadScope() const
@@ -499,10 +505,10 @@ public:
//------------------------------------------------------------------
/// Returns a pointer to the thread object.
///
- /// The returned pointer might be NULL. Calling HasThreadScope() or
+ /// The returned pointer might be nullptr. Calling HasThreadScope() or
/// HasFrameScope() can help to pre-validate this pointer so that
/// this accessor can freely be used without having to check for
- /// NULL each time.
+ /// nullptr each time.
///
/// @see ExecutionContext::HasThreadScope() const
/// @see ExecutionContext::HasFrameScope() const
@@ -516,9 +522,9 @@ public:
//------------------------------------------------------------------
/// Returns a pointer to the frame object.
///
- /// The returned pointer might be NULL. Calling HasFrameScope(),
+ /// 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 NULL each time.
+ /// freely be used without having to check for nullptr each time.
///
/// @see ExecutionContext::HasFrameScope() const
//------------------------------------------------------------------
@@ -776,6 +782,7 @@ protected:
lldb::ThreadSP m_thread_sp; ///< The thread that owns the frame
lldb::StackFrameSP m_frame_sp; ///< The stack frame in thread.
};
+
} // namespace lldb_private
-#endif // liblldb_ExecutionContext_h_
+#endif // liblldb_ExecutionContext_h_
diff --git a/include/lldb/Target/InstrumentationRuntimeStopInfo.h b/include/lldb/Target/InstrumentationRuntimeStopInfo.h
index 624267ce8221..df1b937e6e26 100644
--- a/include/lldb/Target/InstrumentationRuntimeStopInfo.h
+++ b/include/lldb/Target/InstrumentationRuntimeStopInfo.h
@@ -25,18 +25,24 @@ class InstrumentationRuntimeStopInfo : public StopInfo
{
public:
- virtual ~InstrumentationRuntimeStopInfo()
+ ~InstrumentationRuntimeStopInfo() override
{
}
- virtual lldb::StopReason
- GetStopReason () const
+ lldb::StopReason
+ GetStopReason() const override
{
return lldb::eStopReasonInstrumentation;
}
- virtual const char *
- GetDescription ();
+ const char *
+ GetDescription() override;
+
+ bool
+ DoShouldNotify(Event *event_ptr) override
+ {
+ return true;
+ }
static lldb::StopInfoSP
CreateStopReasonWithInstrumentationData (Thread &thread, std::string description, StructuredData::ObjectSP additional_data);
@@ -44,9 +50,8 @@ public:
private:
InstrumentationRuntimeStopInfo(Thread &thread, std::string description, StructuredData::ObjectSP additional_data);
-
};
} // namespace lldb_private
-#endif // liblldb_InstrumentationRuntimeStopInfo_h_
+#endif // liblldb_InstrumentationRuntimeStopInfo_h_
diff --git a/include/lldb/Target/JITLoader.h b/include/lldb/Target/JITLoader.h
index c15ae5a876f1..8a2d6828db2f 100644
--- a/include/lldb/Target/JITLoader.h
+++ b/include/lldb/Target/JITLoader.h
@@ -50,8 +50,7 @@ public:
//------------------------------------------------------------------
JITLoader (Process *process);
- virtual
- ~JITLoader ();
+ ~JITLoader() override;
//------------------------------------------------------------------
/// Called after attaching a process.
diff --git a/include/lldb/Target/Language.h b/include/lldb/Target/Language.h
new file mode 100644
index 000000000000..492425ec088b
--- /dev/null
+++ b/include/lldb/Target/Language.h
@@ -0,0 +1,206 @@
+//===-- Language.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_Language_h_
+#define liblldb_Language_h_
+
+// C Includes
+// C++ Includes
+#include <functional>
+#include <memory>
+#include <set>
+#include <vector>
+
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-public.h"
+#include "lldb/lldb-private.h"
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/DataFormatters/DumpValueObjectOptions.h"
+#include "lldb/DataFormatters/FormatClasses.h"
+#include "lldb/DataFormatters/StringPrinter.h"
+
+namespace lldb_private {
+
+class Language :
+public PluginInterface
+{
+public:
+ class TypeScavenger
+ {
+ public:
+ class Result
+ {
+ public:
+ virtual bool
+ IsValid () = 0;
+
+ virtual bool
+ DumpToStream (Stream& stream,
+ bool print_help_if_available) = 0;
+
+ virtual ~Result() = default;
+ };
+
+ typedef std::set<std::unique_ptr<Result>> ResultSet;
+
+ virtual ~TypeScavenger () = default;
+
+ size_t
+ Find (ExecutionContextScope *exe_scope,
+ const char *key,
+ ResultSet &results,
+ bool append = true);
+
+ protected:
+ TypeScavenger () = default;
+
+ virtual bool
+ Find_Impl (ExecutionContextScope *exe_scope,
+ const char *key,
+ ResultSet &results) = 0;
+ };
+
+ enum class FunctionNameRepresentation
+ {
+ eName,
+ eNameWithArgs,
+ eNameWithNoArgs
+ };
+
+ ~Language() override;
+
+ static Language*
+ FindPlugin (lldb::LanguageType language);
+
+ // return false from callback to stop iterating
+ static void
+ ForEach (std::function<bool(Language*)> callback);
+
+ virtual lldb::LanguageType
+ GetLanguageType () const = 0;
+
+ virtual bool
+ IsTopLevelFunction (Function& function);
+
+ virtual lldb::TypeCategoryImplSP
+ GetFormatters ();
+
+ virtual HardcodedFormatters::HardcodedFormatFinder
+ GetHardcodedFormats ();
+
+ virtual HardcodedFormatters::HardcodedSummaryFinder
+ GetHardcodedSummaries ();
+
+ virtual HardcodedFormatters::HardcodedSyntheticFinder
+ GetHardcodedSynthetics ();
+
+ virtual HardcodedFormatters::HardcodedValidatorFinder
+ GetHardcodedValidators ();
+
+ virtual std::vector<ConstString>
+ GetPossibleFormattersMatches (ValueObject& valobj, lldb::DynamicValueType use_dynamic);
+
+ virtual lldb_private::formatters::StringPrinter::EscapingHelper
+ GetStringPrinterEscapingHelper (lldb_private::formatters::StringPrinter::GetPrintableElementType);
+
+ virtual std::unique_ptr<TypeScavenger>
+ GetTypeScavenger ();
+
+ // if an individual data formatter can apply to several types and cross a language boundary
+ // it makes sense for individual languages to want to customize the printing of values of that
+ // type by appending proper prefix/suffix information in language-specific ways
+ virtual bool
+ GetFormatterPrefixSuffix (ValueObject& valobj, ConstString type_hint,
+ std::string& prefix, std::string& suffix);
+
+ // if a language has a custom format for printing variable declarations that it wants LLDB to honor
+ // it should return an appropriate closure here
+ virtual DumpValueObjectOptions::DeclPrintingHelper
+ GetDeclPrintingHelper ();
+
+ virtual LazyBool
+ IsLogicalTrue (ValueObject& valobj,
+ Error& error);
+
+ // for a ValueObject of some "reference type", if the value points to the
+ // nil/null object, this method returns true
+ virtual bool
+ IsNilReference (ValueObject& valobj);
+
+ // for a ValueObject of some "reference type", if the language provides a technique
+ // to decide whether the reference has ever been assigned to some object, this method
+ // will return true if such detection is possible, and if the reference has never been assigned
+ virtual bool
+ IsUninitializedReference (ValueObject& valobj);
+
+ virtual bool
+ GetFunctionDisplayName (const SymbolContext *sc,
+ const ExecutionContext *exe_ctx,
+ FunctionNameRepresentation representation,
+ Stream& s);
+
+ virtual void
+ GetExceptionResolverDescription(bool catch_on, bool throw_on, Stream &s);
+
+ static void
+ GetDefaultExceptionResolverDescription(bool catch_on, bool throw_on, Stream &s);
+
+ // These are accessors for general information about the Languages lldb knows about:
+
+ static lldb::LanguageType
+ GetLanguageTypeFromString (const char *string);
+
+ static const char *
+ GetNameForLanguageType (lldb::LanguageType language);
+
+ static void
+ PrintAllLanguages (Stream &s, const char *prefix, const char *suffix);
+
+ // return false from callback to stop iterating
+ static void
+ ForAllLanguages (std::function<bool(lldb::LanguageType)> callback);
+
+ static bool
+ LanguageIsCPlusPlus (lldb::LanguageType language);
+
+ static bool
+ LanguageIsObjC (lldb::LanguageType language);
+
+ static bool
+ LanguageIsC (lldb::LanguageType language);
+
+ static bool
+ LanguageIsPascal (lldb::LanguageType language);
+
+ // return the primary language, so if LanguageIsC(l), return eLanguageTypeC, etc.
+ static lldb::LanguageType
+ GetPrimaryLanguage (lldb::LanguageType language);
+
+ static void
+ GetLanguagesSupportingTypeSystems (std::set<lldb::LanguageType> &languages,
+ std::set<lldb::LanguageType> &languages_for_expressions);
+
+ static void
+ GetLanguagesSupportingREPLs (std::set<lldb::LanguageType> &languages);
+
+protected:
+ //------------------------------------------------------------------
+ // Classes that inherit from Language can see and modify these
+ //------------------------------------------------------------------
+
+ Language();
+private:
+
+ DISALLOW_COPY_AND_ASSIGN (Language);
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_Language_h_
diff --git a/include/lldb/Target/LanguageRuntime.h b/include/lldb/Target/LanguageRuntime.h
index d8e5ada6c96f..686ec5ea3479 100644
--- a/include/lldb/Target/LanguageRuntime.h
+++ b/include/lldb/Target/LanguageRuntime.h
@@ -29,8 +29,8 @@ class LanguageRuntime :
public PluginInterface
{
public:
- virtual
- ~LanguageRuntime();
+
+ ~LanguageRuntime() override;
static LanguageRuntime*
FindPlugin (Process *process, lldb::LanguageType language);
@@ -52,12 +52,31 @@ public:
GetDynamicTypeAndAddress (ValueObject &in_value,
lldb::DynamicValueType use_dynamic,
TypeAndOrName &class_type_or_name,
- Address &address) = 0;
+ Address &address,
+ Value::ValueType &value_type) = 0;
+
+ // This call should return a CompilerType given a generic type name
+ // and an ExecutionContextScope in which one can actually fetch
+ // any specialization information required.
+ virtual CompilerType
+ GetConcreteType (ExecutionContextScope *exe_scope,
+ ConstString abstract_type_name)
+ {
+ return CompilerType();
+ }
// This should be a fast test to determine whether it is likely that this value would
// have a dynamic type.
virtual bool
CouldHaveDynamicValue (ValueObject &in_value) = 0;
+
+ // The contract for GetDynamicTypeAndAddress() is to return a "bare-bones" dynamic type
+ // For instance, given a Base* pointer, GetDynamicTypeAndAddress() will return the type of
+ // Derived, not Derived*. The job of this API is to correct this misalignment between the
+ // static type and the discovered dynamic type
+ virtual TypeAndOrName
+ FixUpDynamicType (const TypeAndOrName& type_and_or_name,
+ ValueObject& static_value) = 0;
virtual void
SetExceptionBreakpoints ()
@@ -92,24 +111,17 @@ public:
CreateExceptionPrecondition (lldb::LanguageType language,
bool catch_bp,
bool throw_bp);
-
- static lldb::LanguageType
- GetLanguageTypeFromString (const char *string);
-
- static const char *
- GetNameForLanguageType (lldb::LanguageType language);
-
- static void
- PrintAllLanguages (Stream &s, const char *prefix, const char *suffix);
-
- static bool
- LanguageIsCPlusPlus (lldb::LanguageType language);
-
Process *
GetProcess()
{
return m_process;
}
+
+ Target&
+ GetTargetRef()
+ {
+ return m_process->GetTarget();
+ }
virtual lldb::BreakpointResolverSP
CreateExceptionResolver (Breakpoint *bkpt, bool catch_bp, bool throw_bp) = 0;
@@ -118,7 +130,7 @@ public:
CreateExceptionSearchFilter ();
virtual bool
- GetTypeBitSize (const ClangASTType& clang_type,
+ GetTypeBitSize (const CompilerType& compiler_type,
uint64_t &size)
{
return false;
@@ -133,7 +145,6 @@ public:
virtual void
ModulesDidLoad (const ModuleList &module_list)
{
- return;
}
protected:
@@ -144,9 +155,10 @@ protected:
LanguageRuntime(Process *process);
Process *m_process;
private:
+
DISALLOW_COPY_AND_ASSIGN (LanguageRuntime);
};
} // namespace lldb_private
-#endif // liblldb_LanguageRuntime_h_
+#endif // liblldb_LanguageRuntime_h_
diff --git a/include/lldb/Target/ObjCLanguageRuntime.h b/include/lldb/Target/ObjCLanguageRuntime.h
index 88874c767a1b..75f096fdedfe 100644
--- a/include/lldb/Target/ObjCLanguageRuntime.h
+++ b/include/lldb/Target/ObjCLanguageRuntime.h
@@ -1,4 +1,4 @@
-//===-- ObjCLanguageRuntime.h ---------------------------------------------------*- C++ -*-===//
+//===-- ObjCLanguageRuntime.h -----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,14 +14,17 @@
// C++ Includes
#include <functional>
#include <map>
+#include <memory>
#include <unordered_set>
// Other libraries and framework includes
+#include "llvm/Support/Casting.h"
+
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/ThreadSafeDenseMap.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/DeclVendor.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Target/LanguageRuntime.h"
@@ -30,115 +33,19 @@ class CommandObjectObjC_ClassTable_Dump;
namespace lldb_private {
-class ClangUtilityFunction;
+class UtilityFunction;
class ObjCLanguageRuntime :
public LanguageRuntime
{
public:
- class MethodName
+ enum class ObjCRuntimeVersions
{
- public:
- enum Type
- {
- eTypeUnspecified,
- eTypeClassMethod,
- eTypeInstanceMethod
- };
-
- MethodName () :
- m_full(),
- m_class(),
- m_category(),
- m_selector(),
- m_type (eTypeUnspecified),
- m_category_is_valid (false)
- {
- }
-
- MethodName (const char *name, bool strict) :
- m_full(),
- m_class(),
- m_category(),
- m_selector(),
- m_type (eTypeUnspecified),
- m_category_is_valid (false)
- {
- SetName (name, strict);
- }
-
- void
- Clear();
-
- bool
- IsValid (bool strict) const
- {
- // If "strict" is true, the name must have everything specified including
- // the leading "+" or "-" on the method name
- if (strict && m_type == eTypeUnspecified)
- return false;
- // Other than that, m_full will only be filled in if the objective C
- // name is valid.
- return (bool)m_full;
- }
-
- bool
- HasCategory()
- {
- return (bool)GetCategory();
- }
-
- Type
- GetType () const
- {
- return m_type;
- }
-
- const ConstString &
- GetFullName () const
- {
- return m_full;
- }
-
- ConstString
- GetFullNameWithoutCategory (bool empty_if_no_category);
-
- bool
- SetName (const char *name, bool strict);
-
- const ConstString &
- GetClassName ();
-
- const ConstString &
- GetClassNameWithCategory ();
-
- const ConstString &
- GetCategory ();
-
- const ConstString &
- GetSelector ();
-
- // 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);
- protected:
- ConstString m_full; // Full name: "+[NSString(my_additions) myStringWithCString:]"
- ConstString m_class; // Class name: "NSString"
- ConstString m_class_category; // Class with category: "NSString(my_additions)"
- ConstString m_category; // Category: "my_additions"
- ConstString m_selector; // Selector: "myStringWithCString:"
- Type m_type;
- bool m_category_is_valid;
-
+ eObjC_VersionUnknown = 0,
+ eAppleObjC_V1 = 1,
+ eAppleObjC_V2 = 2
};
+
typedef lldb::addr_t ObjCISA;
class ClassDescriptor;
@@ -150,7 +57,6 @@ public:
class ClassDescriptor
{
public:
-
ClassDescriptor() :
m_is_kvo (eLazyBoolCalculate),
m_is_cf (eLazyBoolCalculate),
@@ -159,10 +65,8 @@ public:
}
virtual
- ~ClassDescriptor ()
- {
- }
-
+ ~ClassDescriptor() = default;
+
virtual ConstString
GetClassName () = 0;
@@ -203,12 +107,12 @@ public:
virtual bool
IsValid () = 0;
-
+
virtual bool
- GetTaggedPointerInfo (uint64_t* info_bits = NULL,
- uint64_t* value_bits = NULL,
- uint64_t* payload = NULL) = 0;
-
+ GetTaggedPointerInfo(uint64_t* info_bits = nullptr,
+ uint64_t* value_bits = nullptr,
+ uint64_t* payload = nullptr) = 0;
+
virtual uint64_t
GetInstanceSize () = 0;
@@ -247,7 +151,7 @@ public:
struct iVarDescriptor {
ConstString m_name;
- ClangASTType m_type;
+ CompilerType m_type;
uint64_t m_size;
int32_t m_offset;
};
@@ -281,12 +185,12 @@ public:
class EncodingToType
{
public:
- virtual ClangASTType RealizeType (ClangASTContext& ast_ctx, const char* name, bool for_expression);
- virtual ClangASTType RealizeType (const char* name, bool for_expression);
-
- virtual ClangASTType RealizeType (clang::ASTContext& ast_ctx, const char* name, bool for_expression) = 0;
-
virtual ~EncodingToType();
+
+ virtual CompilerType RealizeType (ClangASTContext& ast_ctx, const char* name, bool for_expression);
+ virtual CompilerType RealizeType (const char* name, bool for_expression);
+
+ virtual CompilerType RealizeType (clang::ASTContext& ast_ctx, const char* name, bool for_expression) = 0;
protected:
std::unique_ptr<ClangASTContext> m_scratch_ast_ctx_ap;
@@ -297,10 +201,10 @@ public:
public:
ObjCExceptionPrecondition();
- virtual ~ObjCExceptionPrecondition() {}
+ ~ObjCExceptionPrecondition() override = default;
bool EvaluatePrecondition(StoppointCallbackContext &context) override;
- void DescribePrecondition(Stream &stream, lldb::DescriptionLevel level) override;
+ void GetDescription(Stream &stream, lldb::DescriptionLevel level) override;
Error ConfigurePrecondition(Args &args) override;
protected:
@@ -313,21 +217,24 @@ public:
class TaggedPointerVendor
{
public:
+ virtual
+ ~TaggedPointerVendor() = default;
+
virtual bool
IsPossibleTaggedPointer (lldb::addr_t ptr) = 0;
virtual ObjCLanguageRuntime::ClassDescriptorSP
GetClassDescriptor (lldb::addr_t ptr) = 0;
-
- virtual
- ~TaggedPointerVendor () { }
+
protected:
- TaggedPointerVendor () = default;
+ TaggedPointerVendor() = default;
private:
DISALLOW_COPY_AND_ASSIGN(TaggedPointerVendor);
};
+ ~ObjCLanguageRuntime() override;
+
virtual TaggedPointerVendor*
GetTaggedPointerVendor ()
{
@@ -354,9 +261,6 @@ public:
ClassDescriptorSP
GetNonKVOClassDescriptor (ObjCISA isa);
- virtual
- ~ObjCLanguageRuntime();
-
lldb::LanguageType
GetLanguageType () const override
{
@@ -393,13 +297,13 @@ public:
lldb::TypeSP
LookupInCompleteClassCache (ConstString &name);
- virtual ClangUtilityFunction *
+ virtual UtilityFunction *
CreateObjectChecker (const char *) = 0;
virtual ObjCRuntimeVersions
- GetRuntimeVersion ()
+ GetRuntimeVersion () const
{
- return eObjC_VersionUnknown;
+ return ObjCRuntimeVersions::eObjC_VersionUnknown;
}
bool
@@ -433,14 +337,14 @@ public:
virtual DeclVendor *
GetDeclVendor()
{
- return NULL;
+ 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 (ClangASTType &parent_qual_type, const char *ivar_name);
+ 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.
@@ -451,94 +355,6 @@ public:
return LLDB_INVALID_ADDRESS;
}
- //------------------------------------------------------------------
- /// Chop up an objective C function prototype.
- ///
- /// Chop up an objective C function fullname and optionally fill in
- /// any non-NULL ConstString objects. If a ConstString * is NULL,
- /// then this name doesn't get filled in
- ///
- /// @param[in] name
- /// A fully specified objective C function name. The string might
- /// contain a category and it includes the leading "+" or "-" and
- /// the square brackets, no types for the arguments, just the plain
- /// selector. A few examples:
- /// "-[NSStringDrawingContext init]"
- /// "-[NSStringDrawingContext addString:inRect:]"
- /// "-[NSString(NSStringDrawing) sizeWithAttributes:]"
- /// "+[NSString(NSStringDrawing) usesFontLeading]"
- ///
- /// @param[out] class_name
- /// If non-NULL, this string will be filled in with the class
- /// name including the category. The examples above would return:
- /// "NSStringDrawingContext"
- /// "NSStringDrawingContext"
- /// "NSString(NSStringDrawing)"
- /// "NSString(NSStringDrawing)"
- ///
- /// @param[out] selector_name
- /// If non-NULL, this string will be filled in with the selector
- /// name. The examples above would return:
- /// "init"
- /// "addString:inRect:"
- /// "sizeWithAttributes:"
- /// "usesFontLeading"
- ///
- /// @param[out] name_sans_category
- /// If non-NULL, this string will be filled in with the class
- /// name _without_ the category. If there is no category, and empty
- /// string will be returned (as the result would be normally returned
- /// in the "class_name" argument). The examples above would return:
- /// <empty>
- /// <empty>
- /// "-[NSString sizeWithAttributes:]"
- /// "+[NSString usesFontLeading]"
- ///
- /// @param[out] class_name_sans_category
- /// If non-NULL, this string will be filled in with the prototype
- /// name _without_ the category. If there is no category, and empty
- /// string will be returned (as this is already the value that was
- /// passed in). The examples above would return:
- /// <empty>
- /// <empty>
- /// "NSString"
- /// "NSString"
- ///
- /// @return
- /// Returns the number of strings that were successfully filled
- /// in.
- //------------------------------------------------------------------
-// static uint32_t
-// ParseMethodName (const char *name,
-// ConstString *class_name, // Class name (with category if there is one)
-// ConstString *selector_name, // selector only
-// ConstString *name_sans_category, // full function name with no category (empty if no category)
-// ConstString *class_name_sans_category);// Class name without category (empty if no category)
-
- static bool
- IsPossibleObjCMethodName (const char *name)
- {
- if (!name)
- return false;
- bool starts_right = (name[0] == '+' || name[0] == '-') && name[1] == '[';
- bool ends_right = (name[strlen(name) - 1] == ']');
- return (starts_right && ends_right);
- }
-
- static bool
- IsPossibleObjCSelector (const char *name)
- {
- if (!name)
- return false;
-
- if (strchr(name, ':') == NULL)
- return true;
- else if (name[strlen(name) - 1] == ':')
- return true;
- else
- return false;
- }
-
bool
HasNewLiteralsAndIndexing ()
{
@@ -560,7 +376,7 @@ public:
}
bool
- GetTypeBitSize (const ClangASTType& clang_type,
+ GetTypeBitSize (const CompilerType& compiler_type,
uint64_t &size) override;
protected:
@@ -568,13 +384,12 @@ protected:
// Classes that inherit from ObjCLanguageRuntime can see and modify these
//------------------------------------------------------------------
ObjCLanguageRuntime(Process *process);
-
+
virtual bool CalculateHasNewLiteralsAndIndexing()
{
return false;
}
-
bool
ISAIsCached (ObjCISA isa) const
{
@@ -621,11 +436,13 @@ private:
sel_addr = LLDB_INVALID_ADDRESS;
class_addr = LLDB_INVALID_ADDRESS;
}
+
ClassAndSel (lldb::addr_t in_sel_addr, lldb::addr_t in_class_addr) :
class_addr (in_class_addr),
sel_addr(in_sel_addr)
{
}
+
bool operator== (const ClassAndSel &rhs)
{
if (class_addr == rhs.class_addr
@@ -702,4 +519,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_ObjCLanguageRuntime_h_
+#endif // liblldb_ObjCLanguageRuntime_h_
diff --git a/include/lldb/Target/OperatingSystem.h b/include/lldb/Target/OperatingSystem.h
index f1c0eb06026f..74de5645da5a 100644
--- a/include/lldb/Target/OperatingSystem.h
+++ b/include/lldb/Target/OperatingSystem.h
@@ -32,7 +32,6 @@ namespace lldb_private {
class OperatingSystem :
public PluginInterface
-
{
public:
//------------------------------------------------------------------
@@ -58,8 +57,7 @@ public:
//------------------------------------------------------------------
OperatingSystem (Process *process);
- virtual
- ~OperatingSystem();
+ ~OperatingSystem() override;
//------------------------------------------------------------------
// Plug-in Methods
@@ -98,4 +96,4 @@ private:
} // namespace lldb_private
-#endif // #ifndef liblldb_OperatingSystem_h_
+#endif // liblldb_OperatingSystem_h_
diff --git a/include/lldb/Target/Platform.h b/include/lldb/Target/Platform.h
index feaac57b128a..53c17a6a66cf 100644
--- a/include/lldb/Target/Platform.h
+++ b/include/lldb/Target/Platform.h
@@ -37,7 +37,6 @@
namespace lldb_private {
class ModuleCache;
-
enum MmapFlags {
eMmapFlagsPrivate = 1,
eMmapFlagsAnon = 2
@@ -46,11 +45,11 @@ class ModuleCache;
class PlatformProperties : public Properties
{
public:
+ PlatformProperties();
+
static ConstString
GetSettingName ();
- PlatformProperties();
-
bool
GetUseModuleCache () const;
bool
@@ -81,6 +80,19 @@ class ModuleCache;
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 ();
@@ -131,20 +143,6 @@ class ModuleCache;
GetConnectedRemotePlatformAtIndex (uint32_t idx);
//------------------------------------------------------------------
- /// 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.
- //------------------------------------------------------------------
- virtual
- ~Platform();
-
- //------------------------------------------------------------------
/// Find a platform plugin for a given process.
///
/// Scans the installed Platform plug-ins and tries to find
@@ -156,7 +154,7 @@ class ModuleCache;
///
/// @param[in] plugin_name
/// An optional name of a specific platform plug-in that
- /// should be used. If NULL, pick the best plug-in.
+ /// should be used. If nullptr, pick the best plug-in.
//------------------------------------------------------------------
// static lldb::PlatformSP
// FindPlugin (Process *process, const ConstString &plugin_name);
@@ -185,7 +183,6 @@ class ModuleCache;
lldb::ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr);
-
//------------------------------------------------------------------
/// Find a symbol file given a symbol file module specification.
///
@@ -247,10 +244,21 @@ class ModuleCache;
ResolveRemotePath (const FileSpec &platform_path,
FileSpec &resolved_platform_path);
- bool
+ //------------------------------------------------------------------
+ /// Get the OS version from a connected platform.
+ ///
+ /// Some platforms might not be connected to a remote platform, but
+ /// can figure out the OS version for a process. This is common for
+ /// simulator platforms that will run native programs on the current
+ /// host, but the simulator might be simulating a different OS. The
+ /// \a process parameter might be specified to help to determine
+ /// the OS version.
+ //------------------------------------------------------------------
+ virtual bool
GetOSVersion (uint32_t &major,
uint32_t &minor,
- uint32_t &update);
+ uint32_t &update,
+ Process *process = nullptr);
bool
SetOSVersion (uint32_t major,
@@ -269,6 +277,9 @@ class ModuleCache;
virtual const char *
GetHostname ();
+
+ virtual ConstString
+ GetFullNameForDylib (ConstString basename);
virtual const char *
GetDescription () = 0;
@@ -473,9 +484,16 @@ class ModuleCache;
virtual lldb::ProcessSP
DebugProcess (ProcessLaunchInfo &launch_info,
Debugger &debugger,
- Target *target, // Can be NULL, if NULL create a new target, else use existing one
+ Target *target, // Can be nullptr, if nullptr create a new target, else use existing one
Error &error);
+ virtual lldb::ProcessSP
+ ConnectProcess (const char* connect_url,
+ const char* plugin_name,
+ lldb_private::Debugger &debugger,
+ lldb_private::Target *target,
+ lldb_private::Error &error);
+
//------------------------------------------------------------------
/// Attach to an existing process using a process ID.
///
@@ -497,7 +515,7 @@ class ModuleCache;
virtual lldb::ProcessSP
Attach (ProcessAttachInfo &attach_info,
Debugger &debugger,
- Target *target, // Can be NULL, if NULL create a new target, else use existing one
+ Target *target, // Can be nullptr, if nullptr create a new target, else use existing one
Error &error) = 0;
//------------------------------------------------------------------
@@ -593,6 +611,7 @@ class ModuleCache;
{
return m_max_uid_name_len;
}
+
// Used for column widths
size_t
GetMaxGroupIDNameLength() const
@@ -829,15 +848,15 @@ class ModuleCache;
virtual lldb_private::OptionGroupOptions *
GetConnectionOptions (CommandInterpreter& interpreter)
{
- return NULL;
+ return nullptr;
}
virtual lldb_private::Error
- RunShellCommand(const char *command, // Shouldn't be NULL
+ RunShellCommand(const char *command, // Shouldn't be nullptr
const FileSpec &working_dir, // Pass empty FileSpec to use the current working directory
- int *status_ptr, // Pass 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
+ int *status_ptr, // Pass nullptr if you don't want the process exit status
+ int *signo_ptr, // Pass nullptr if you don't want the signal that caused the process to exit
+ std::string *command_output, // Pass nullptr if you don't want the command output
uint32_t timeout_sec); // Timeout in seconds to wait for shell program to finish
virtual void
@@ -945,9 +964,105 @@ class ModuleCache;
virtual const std::vector<ConstString> &
GetTrapHandlerSymbolNames ();
+ //------------------------------------------------------------------
+ /// Find a support executable that may not live within in the
+ /// standard locations related to LLDB.
+ ///
+ /// Executable might exist within the Platform SDK directories, or
+ /// in standard tool directories within the current IDE that is
+ /// running LLDB.
+ ///
+ /// @param[in] basename
+ /// The basename of the executable to locate in the current
+ /// platform.
+ ///
+ /// @return
+ /// A FileSpec pointing to the executable on disk, or an invalid
+ /// FileSpec if the executable cannot be found.
+ //------------------------------------------------------------------
+ virtual FileSpec
+ LocateExecutable (const char *basename)
+ {
+ return FileSpec();
+ }
+
+ //------------------------------------------------------------------
+ /// Allow the platform to set preferred memory cache line size. If non-zero (and the user
+ /// has not set cache line size explicitly), this value will be used as the cache line
+ /// size for memory reads.
+ //------------------------------------------------------------------
+ virtual uint32_t
+ GetDefaultMemoryCacheLineSize() { return 0; }
+
+ //------------------------------------------------------------------
+ /// Load a shared library into this process.
+ ///
+ /// Try and load a shared library into the current process. This
+ /// call might fail in the dynamic loader plug-in says it isn't safe
+ /// to try and load shared libraries at the moment.
+ ///
+ /// @param[in] process
+ /// The process to load the image.
+ ///
+ /// @param[in] local_file
+ /// The file spec that points to the shared library that you want
+ /// to load if the library is located on the host. The library will
+ /// be copied over to the location specified by remote_file or into
+ /// the current working directory with the same filename if the
+ /// remote_file isn't specified.
+ ///
+ /// @param[in] remote_file
+ /// If local_file is specified then the location where the library
+ /// should be copied over from the host. If local_file isn't
+ /// specified, then the path for the shared library on the target
+ /// what you want to load.
+ ///
+ /// @param[out] error
+ /// An error object that gets filled in with any errors that
+ /// might occur when trying to load the shared library.
+ ///
+ /// @return
+ /// A token that represents the shared library that can be
+ /// later used to unload the shared library. A value of
+ /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared
+ /// library can't be opened.
+ //------------------------------------------------------------------
+ uint32_t
+ LoadImage (lldb_private::Process* process,
+ const lldb_private::FileSpec& local_file,
+ const lldb_private::FileSpec& remote_file,
+ lldb_private::Error& error);
+
+ virtual uint32_t
+ DoLoadImage (lldb_private::Process* process,
+ const lldb_private::FileSpec& remote_file,
+ lldb_private::Error& error);
+
+ virtual Error
+ UnloadImage (lldb_private::Process* process, uint32_t image_token);
+
+ //------------------------------------------------------------------
+ /// Connect to all processes waiting for a debugger to attach
+ ///
+ /// If the platform have a list of processes waiting for a debugger
+ /// to connect to them then connect to all of these pending processes.
+ ///
+ /// @param[in] debugger
+ /// The debugger used for the connect.
+ ///
+ /// @param[out] error
+ /// If an error occurred during the connect then this object will
+ /// contain the error message.
+ ///
+ /// @return
+ /// The number of processes we are succesfully connected to.
+ //------------------------------------------------------------------
+ virtual size_t
+ ConnectToWaitingProcesses(lldb_private::Debugger& debugger, lldb_private::Error& error);
+
protected:
bool m_is_host;
- // Set to true when we are able to actually set the OS version while
+ // Set to true when we are able to actually set the OS version while
// being connected. For remote platforms, we might set the version ahead
// of time before we actually connect and this version might change when
// we actually connect to a remote platform. For the host platform this
@@ -1000,16 +1115,12 @@ class ModuleCache;
GetCachedUserName (uint32_t uid)
{
Mutex::Locker locker (m_mutex);
- IDToNameMap::iterator pos = m_uid_map.find (uid);
- if (pos != m_uid_map.end())
- {
- // 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)
- return pos->second.AsCString("");
- }
- return NULL;
+ // 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 *
@@ -1030,7 +1141,6 @@ class ModuleCache;
Mutex::Locker locker (m_mutex);
m_uid_map[uid] = ConstString();
}
-
void
ClearCachedUserNames ()
@@ -1043,16 +1153,12 @@ class ModuleCache;
GetCachedGroupName (uint32_t gid)
{
Mutex::Locker locker (m_mutex);
- IDToNameMap::iterator pos = m_gid_map.find (gid);
- if (pos != m_gid_map.end())
- {
- // 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)
- return pos->second.AsCString("");
- }
- return NULL;
+ // 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 *
@@ -1092,6 +1198,10 @@ class ModuleCache;
const uint64_t src_offset,
const uint64_t src_size,
const FileSpec& dst_file_spec);
+
+ virtual Error
+ DownloadSymbolFile (const lldb::ModuleSP& module_sp,
+ const FileSpec& dst_file_spec);
virtual const char *
GetCacheHostname ();
@@ -1123,7 +1233,6 @@ class ModuleCache;
DISALLOW_COPY_AND_ASSIGN (Platform);
};
-
class PlatformList
{
public:
@@ -1133,11 +1242,9 @@ class ModuleCache;
m_selected_platform_sp()
{
}
-
- ~PlatformList()
- {
- }
-
+
+ ~PlatformList() = default;
+
void
Append (const lldb::PlatformSP &platform_sp, bool set_selected)
{
@@ -1220,22 +1327,21 @@ class ModuleCache;
public:
OptionGroupPlatformRSync ();
- virtual
- ~OptionGroupPlatformRSync ();
+ ~OptionGroupPlatformRSync() override;
- virtual lldb_private::Error
- SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value);
+ lldb_private::Error
+ SetOptionValue(CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_value) override;
void
- OptionParsingStarting (CommandInterpreter &interpreter);
+ OptionParsingStarting(CommandInterpreter &interpreter) override;
const lldb_private::OptionDefinition*
- GetDefinitions ();
+ GetDefinitions() override;
- virtual uint32_t
- GetNumDefinitions ();
+ uint32_t
+ GetNumDefinitions() override;
// Options table: Required for subclasses of Options.
@@ -1256,22 +1362,21 @@ class ModuleCache;
public:
OptionGroupPlatformSSH ();
- virtual
- ~OptionGroupPlatformSSH ();
+ ~OptionGroupPlatformSSH() override;
- virtual lldb_private::Error
- SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value);
+ lldb_private::Error
+ SetOptionValue(CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_value) override;
void
- OptionParsingStarting (CommandInterpreter &interpreter);
+ OptionParsingStarting(CommandInterpreter &interpreter) override;
- virtual uint32_t
- GetNumDefinitions ();
+ uint32_t
+ GetNumDefinitions() override;
const lldb_private::OptionDefinition*
- GetDefinitions ();
+ GetDefinitions() override;
// Options table: Required for subclasses of Options.
@@ -1283,7 +1388,6 @@ class ModuleCache;
std::string m_ssh_opts;
private:
-
DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformSSH);
};
@@ -1292,22 +1396,21 @@ class ModuleCache;
public:
OptionGroupPlatformCaching ();
- virtual
- ~OptionGroupPlatformCaching ();
+ ~OptionGroupPlatformCaching() override;
- virtual lldb_private::Error
- SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value);
+ lldb_private::Error
+ SetOptionValue(CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_value) override;
void
- OptionParsingStarting (CommandInterpreter &interpreter);
+ OptionParsingStarting(CommandInterpreter &interpreter) override;
- virtual uint32_t
- GetNumDefinitions ();
+ uint32_t
+ GetNumDefinitions() override;
const lldb_private::OptionDefinition*
- GetDefinitions ();
+ GetDefinitions() override;
// Options table: Required for subclasses of Options.
@@ -1316,10 +1419,11 @@ class ModuleCache;
// Instance variables to hold the values for command options.
std::string m_cache_dir;
+
private:
DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformCaching);
};
} // namespace lldb_private
-#endif // liblldb_Platform_h_
+#endif // liblldb_Platform_h_
diff --git a/include/lldb/Target/Process.h b/include/lldb/Target/Process.h
index f75b3cd5683d..2e063c5bbccc 100644
--- a/include/lldb/Target/Process.h
+++ b/include/lldb/Target/Process.h
@@ -17,8 +17,10 @@
// C++ Includes
#include <list>
-#include <iosfwd>
+#include <memory>
+#include <string>
#include <vector>
+#include <unordered_set>
// Other libraries and framework includes
// Project includes
@@ -55,11 +57,10 @@ struct Range;
class ProcessProperties : public Properties
{
public:
- // Pass NULL for "process" if the ProcessProperties are to be the global copy
+ // Pass nullptr for "process" if the ProcessProperties are to be the global copy
ProcessProperties (lldb_private::Process *process);
- virtual
- ~ProcessProperties();
+ ~ProcessProperties() override;
bool
GetDisableMemoryCache() const;
@@ -103,12 +104,14 @@ public:
void
SetDetachKeepsStopped (bool keep_stopped);
-protected:
+ bool
+ GetWarningsOptimization () const;
+protected:
static void
OptionValueChangedCallback (void *baton, OptionValue *option_value);
- Process * m_process; // Can be NULL for global ProcessProperties
+ Process * m_process; // Can be nullptr for global ProcessProperties
};
typedef std::shared_ptr<ProcessProperties> ProcessPropertiesSP;
@@ -236,7 +239,8 @@ public:
m_wait_for_launch (false),
m_ignore_existing (true),
m_continue_once_attached (false),
- m_detach_on_error (true)
+ m_detach_on_error (true),
+ m_async (false)
{
}
@@ -249,7 +253,8 @@ public:
m_wait_for_launch (false),
m_ignore_existing (true),
m_continue_once_attached (false),
- m_detach_on_error(true)
+ m_detach_on_error (true),
+ m_async (false)
{
ProcessInfo::operator= (launch_info);
SetProcessPluginName (launch_info.GetProcessPluginName());
@@ -272,6 +277,18 @@ public:
}
bool
+ GetAsync () const
+ {
+ return m_async;
+ }
+
+ void
+ SetAsync (bool b)
+ {
+ m_async = b;
+ }
+
+ bool
GetIgnoreExisting () const
{
return m_ignore_existing;
@@ -310,9 +327,7 @@ public:
const char *
GetProcessPluginName () const
{
- if (m_plugin_name.empty())
- return NULL;
- return m_plugin_name.c_str();
+ return (m_plugin_name.empty() ? nullptr : m_plugin_name.c_str());
}
void
@@ -384,7 +399,6 @@ public:
m_listener_sp = listener_sp;
}
-
Listener &
GetListenerForProcess (Debugger &debugger);
@@ -397,35 +411,33 @@ protected:
bool m_ignore_existing;
bool m_continue_once_attached; // Supports the use-case scenario of immediately continuing the process once attached.
bool m_detach_on_error; // If we are debugging remotely, instruct the stub to detach rather than killing the target on error.
+ bool m_async; // Use an async attach where we start the attach and return immediately (used by GUI programs with --waitfor so they can call SBProcess::Stop() to cancel attach)
};
class ProcessLaunchCommandOptions : public Options
{
public:
-
ProcessLaunchCommandOptions (CommandInterpreter &interpreter) :
Options(interpreter)
{
// Keep default values of all options in one place: OptionParsingStarting ()
OptionParsingStarting ();
}
-
- ~ProcessLaunchCommandOptions ()
- {
- }
-
+
+ ~ProcessLaunchCommandOptions() override = default;
+
Error
- SetOptionValue (uint32_t option_idx, const char *option_arg);
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override;
void
- OptionParsingStarting ()
+ OptionParsingStarting() override
{
launch_info.Clear();
disable_aslr = eLazyBoolCalculate;
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions() override
{
return g_option_table;
}
@@ -521,11 +533,8 @@ protected:
class ProcessInstanceInfoList
{
public:
- ProcessInstanceInfoList () :
- m_infos()
- {
- }
-
+ ProcessInstanceInfoList() = default;
+
void
Clear()
{
@@ -547,25 +556,19 @@ public:
const char *
GetProcessNameAtIndex (size_t idx)
{
- if (idx < m_infos.size())
- return m_infos[idx].GetName();
- return NULL;
+ return ((idx < m_infos.size()) ? m_infos[idx].GetName() : nullptr);
}
size_t
GetProcessNameLengthAtIndex (size_t idx)
{
- if (idx < m_infos.size())
- return m_infos[idx].GetNameLength();
- return 0;
+ return ((idx < m_infos.size()) ? m_infos[idx].GetNameLength() : 0);
}
lldb::pid_t
GetProcessIDAtIndex (size_t idx)
{
- if (idx < m_infos.size())
- return m_infos[idx].GetProcessID();
- return 0;
+ return ((idx < m_infos.size()) ? m_infos[idx].GetProcessID() : 0);
}
bool
@@ -592,7 +595,6 @@ protected:
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.)
@@ -600,7 +602,7 @@ protected:
class ProcessModID
{
-friend bool operator== (const ProcessModID &lhs, const ProcessModID &rhs);
+ friend bool operator== (const ProcessModID &lhs, const ProcessModID &rhs);
public:
ProcessModID () :
m_stop_id (0),
@@ -626,7 +628,7 @@ public:
return *this;
}
- ~ProcessModID () {}
+ ~ProcessModID() = default;
void BumpStopID () {
m_stop_id++;
@@ -709,6 +711,7 @@ private:
uint32_t m_running_user_expression;
lldb::EventSP m_last_natural_stop_event;
};
+
inline bool operator== (const ProcessModID &lhs, const ProcessModID &rhs)
{
if (lhs.StopIDEqual (rhs)
@@ -720,11 +723,7 @@ inline bool operator== (const ProcessModID &lhs, const ProcessModID &rhs)
inline bool operator!= (const ProcessModID &lhs, const ProcessModID &rhs)
{
- if (!lhs.StopIDEqual (rhs)
- || !lhs.MemoryIDEqual (rhs))
- return true;
- else
- return false;
+ return (!lhs.StopIDEqual (rhs) || !lhs.MemoryIDEqual (rhs));
}
//----------------------------------------------------------------------
@@ -739,7 +738,7 @@ class Process :
public ExecutionContextScope,
public PluginInterface
{
- friend class ClangFunction; // For WaitForStateChangeEventsPrivate
+ friend class FunctionCaller; // For WaitForStateChangeEventsPrivate
friend class Debugger; // For PopProcessIOHandler and ProcessIOHandlerIsActive
friend class ProcessEventData;
friend class StopInfo;
@@ -747,7 +746,6 @@ class Process :
friend class ThreadList;
public:
-
//------------------------------------------------------------------
/// Broadcaster event bits definitions.
//------------------------------------------------------------------
@@ -766,6 +764,14 @@ public:
eBroadcastInternalStateControlPause = (1<<1),
eBroadcastInternalStateControlResume = (1<<2)
};
+
+ //------------------------------------------------------------------
+ /// Process warning types.
+ //------------------------------------------------------------------
+ enum Warnings
+ {
+ eWarningsOptimization = 1
+ };
typedef Range<lldb::addr_t, lldb::addr_t> LoadRange;
// We use a read/write lock to allow on or more clients to
@@ -781,12 +787,11 @@ public:
static ConstString &GetStaticBroadcasterClass ();
- virtual ConstString &GetBroadcasterClass() const
+ ConstString &GetBroadcasterClass() const override
{
return GetStaticBroadcasterClass();
}
-
//------------------------------------------------------------------
/// A notification structure that can be used by clients to listen
/// for changes in a process's lifetime.
@@ -811,13 +816,13 @@ public:
ProcessEventData ();
ProcessEventData (const lldb::ProcessSP &process, lldb::StateType state);
- virtual ~ProcessEventData();
+ ~ProcessEventData() override;
static const ConstString &
GetFlavorString ();
- virtual const ConstString &
- GetFlavor () const;
+ const ConstString &
+ GetFlavor() const override;
lldb::ProcessSP
GetProcessSP() const
@@ -845,10 +850,7 @@ public:
const char *
GetRestartedReasonAtIndex(size_t idx)
{
- if (idx > m_restarted_reasons.size())
- return NULL;
- else
- return m_restarted_reasons[idx].c_str();
+ return ((idx < m_restarted_reasons.size()) ? m_restarted_reasons[idx].c_str() : nullptr);
}
bool
@@ -857,11 +859,11 @@ public:
return m_interrupted;
}
- virtual void
- Dump (Stream *s) const;
+ void
+ Dump(Stream *s) const override;
- virtual void
- DoOnRemoval (Event *event_ptr);
+ void
+ DoOnRemoval(Event *event_ptr) override;
static const Process::ProcessEventData *
GetEventDataFromEvent (const Event *event_ptr);
@@ -897,22 +899,24 @@ public:
SetUpdateStateOnRemoval (Event *event_ptr);
private:
-
void
SetUpdateStateOnRemoval()
{
m_update_state++;
}
+
void
SetRestarted (bool new_value)
{
m_restarted = new_value;
}
+
void
SetInterrupted (bool new_value)
{
m_interrupted = new_value;
}
+
void
AddRestartedReason (const char *reason)
{
@@ -925,32 +929,22 @@ public:
bool m_restarted; // For "eStateStopped" events, this is true if the target was automatically restarted.
int m_update_state;
bool m_interrupted;
- DISALLOW_COPY_AND_ASSIGN (ProcessEventData);
+ DISALLOW_COPY_AND_ASSIGN (ProcessEventData);
};
-
-#endif
-
- static void
- SettingsInitialize ();
-
- static void
- SettingsTerminate ();
-
- static const ProcessPropertiesSP &
- GetGlobalProperties();
+#endif // SWIG
//------------------------------------------------------------------
/// Construct with a shared pointer to a target, and the Process listener.
/// Uses the Host UnixSignalsSP by default.
//------------------------------------------------------------------
- Process(Target &target, Listener &listener);
+ Process(lldb::TargetSP target_sp, Listener &listener);
//------------------------------------------------------------------
/// Construct with a shared pointer to a target, the Process listener,
/// and the appropriate UnixSignalsSP for the process.
//------------------------------------------------------------------
- Process(Target &target, Listener &listener, const lldb::UnixSignalsSP &unix_signals_sp);
+ Process(lldb::TargetSP target_sp, Listener &listener, const lldb::UnixSignalsSP &unix_signals_sp);
//------------------------------------------------------------------
/// Destructor.
@@ -958,8 +952,16 @@ public:
/// The destructor is virtual since this class is designed to be
/// inherited from by the plug-in instance.
//------------------------------------------------------------------
- virtual
- ~Process();
+ ~Process() override;
+
+ static void
+ SettingsInitialize ();
+
+ static void
+ SettingsTerminate ();
+
+ static const ProcessPropertiesSP &
+ GetGlobalProperties();
//------------------------------------------------------------------
/// Find a Process plug-in that can debug \a module using the
@@ -973,20 +975,18 @@ public:
/// The module shared pointer that this process will debug.
///
/// @param[in] plugin_name
- /// If NULL, select the best plug-in for the binary. If non-NULL
+ /// If nullptr, select the best plug-in for the binary. If non-nullptr
/// then look for a plugin whose PluginInfo's name matches
/// this string.
///
/// @see Process::CanDebug ()
//------------------------------------------------------------------
static lldb::ProcessSP
- FindPlugin (Target &target,
+ FindPlugin (lldb::TargetSP target_sp,
const char *plugin_name,
Listener &listener,
const FileSpec *crash_file_path);
-
-
//------------------------------------------------------------------
/// Static function that can be used with the \b host function
/// Host::StartMonitoringChildProcess ().
@@ -997,16 +997,16 @@ public:
/// Subclasses should call Host::StartMonitoringChildProcess ()
/// with:
/// callback = Process::SetHostProcessExitStatus
- /// callback_baton = NULL
+ /// callback_baton = nullptr
/// pid = Process::GetID()
/// monitor_signals = false
//------------------------------------------------------------------
static bool
- SetProcessExitStatus (void *callback_baton, // The callback baton which should be set to NULL
- lldb::pid_t pid, // The process ID we want to monitor
- bool exited,
- int signo, // Zero for no signal
- int status); // Exit value of process if signal is zero
+ SetProcessExitStatus(void *callback_baton, // The callback baton which should be set to nullptr
+ lldb::pid_t pid, // The process ID we want to monitor
+ bool exited,
+ int signo, // Zero for no signal
+ int status); // Exit value of process if signal is zero
lldb::ByteOrder
GetByteOrder () const;
@@ -1019,6 +1019,7 @@ public:
{
return m_process_unique_id;
}
+
//------------------------------------------------------------------
/// Check if a plug-in instance can debug the file in \a module.
///
@@ -1031,10 +1032,9 @@ public:
/// debug the executable, \b false otherwise.
//------------------------------------------------------------------
virtual bool
- CanDebug (Target &target,
+ CanDebug (lldb::TargetSP target,
bool plugin_specified_by_name) = 0;
-
//------------------------------------------------------------------
/// This object is about to be destroyed, do any necessary cleanup.
///
@@ -1043,8 +1043,7 @@ public:
//------------------------------------------------------------------
virtual void
Finalize();
-
-
+
//------------------------------------------------------------------
/// Return whether this object is valid (i.e. has not been finalized.)
///
@@ -1075,7 +1074,7 @@ public:
virtual CommandObject *
GetPluginCommandObject()
{
- return NULL;
+ return nullptr;
}
//------------------------------------------------------------------
@@ -1163,7 +1162,7 @@ public:
///
/// @return
/// Returns a pointer to the SystemRuntime plugin for this Process
- /// if one is available. Else returns NULL.
+ /// if one is available. Else returns nullptr.
//------------------------------------------------------------------
virtual SystemRuntime *
GetSystemRuntime ();
@@ -1194,7 +1193,7 @@ public:
/// @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 NULL if no output is needed.A
+ /// the connection. This may be nullptr if no output is needed.A
///
/// @param[in] remote_url
/// The URL format that we are connecting to.
@@ -1236,31 +1235,24 @@ public:
GetImageInfoAddress ();
//------------------------------------------------------------------
- /// 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] image_spec
- /// The image file spec that points to the shared library that
- /// you want to load.
+ /// Called when the process is about to broadcast a public stop.
///
- /// @param[out] error
- /// An error object that gets filled in with any errors that
- /// might occur when trying to load the shared library.
- ///
- /// @return
- /// A token that represents the shared library that can be
- /// later used to unload the shared library. A value of
- /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared
- /// library can't be opened.
+ /// There are public and private stops. Private stops are when the
+ /// process is doing things like stepping and the client doesn't
+ /// need to know about starts and stop that implement a thread plan.
+ /// Single stepping over a source line in code might end up being
+ /// implemented by one or more process starts and stops. Public stops
+ /// are when clients will be notified that the process is stopped.
+ /// These events typically trigger UI updates (thread stack frames to
+ /// be displayed, variables to be displayed, and more). This function
+ /// can be overriden and allows process subclasses to do something
+ /// before the eBroadcastBitStateChanged event is sent to public
+ /// clients.
//------------------------------------------------------------------
- virtual uint32_t
- LoadImage (const FileSpec &image_spec, Error &error);
-
- virtual Error
- UnloadImage (uint32_t image_token);
+ virtual void
+ WillPublicStop ()
+ {
+ }
//------------------------------------------------------------------
/// Register for process and thread notifications.
@@ -1278,6 +1270,7 @@ public:
void
RegisterNotificationCallbacks (const Process::Notifications& callbacks);
#endif
+
//------------------------------------------------------------------
/// Unregister for process and thread notifications.
///
@@ -1298,6 +1291,7 @@ public:
bool
UnregisterNotificationCallbacks (const Process::Notifications& callbacks);
#endif
+
//==================================================================
// Built in Process Control functions
//==================================================================
@@ -1334,6 +1328,7 @@ public:
Error
ResumeSynchronous (Stream *stream);
+
//------------------------------------------------------------------
/// Halts a running process.
///
@@ -1346,12 +1341,15 @@ public:
/// @param[in] clear_thread_plans
/// If true, when the process stops, clear all thread plans.
///
+ /// @param[in] use_run_lock
+ /// Whether to release the run lock after the stop.
+ ///
/// @return
/// Returns an error object. If the error is empty, the process is halted.
/// otherwise the halt has failed.
//------------------------------------------------------------------
Error
- Halt (bool clear_thread_plans = false);
+ Halt (bool clear_thread_plans = false, bool use_run_lock = true);
//------------------------------------------------------------------
/// Detaches from a running or stopped process.
@@ -1402,7 +1400,7 @@ public:
Signal (int signal);
void
- SetUnixSignals(const lldb::UnixSignalsSP &signals_sp);
+ SetUnixSignals(lldb::UnixSignalsSP &&signals_sp);
const lldb::UnixSignalsSP &
GetUnixSignals();
@@ -1447,7 +1445,7 @@ public:
/// @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 NULL if no output is needed.A
+ /// the connection. This may be nullptr if no output is needed.A
///
/// @param[in] remote_url
/// The URL format that we are connecting to.
@@ -1525,7 +1523,6 @@ public:
process_arch.Clear();
}
-
//------------------------------------------------------------------
/// Called after a process re-execs itself.
///
@@ -1590,7 +1587,6 @@ public:
return error;
}
-
//------------------------------------------------------------------
/// Called after launching a process.
///
@@ -1600,8 +1596,6 @@ public:
virtual void
DidLaunch () {}
-
-
//------------------------------------------------------------------
/// Called before resuming to a process.
///
@@ -1639,7 +1633,6 @@ public:
return error;
}
-
//------------------------------------------------------------------
/// Called after resuming a process.
///
@@ -1649,7 +1642,6 @@ public:
virtual void
DidResume () {}
-
//------------------------------------------------------------------
/// Called before halting to a process.
///
@@ -1668,9 +1660,8 @@ public:
/// DoHalt must produce one and only one stop StateChanged event if it actually
/// stops the process. If the stop happens through some natural event (for
/// instance a SIGSTOP), then forwarding that event will do. Otherwise, you must
- /// generate the event manually. Note also, the private event thread is stopped when
- /// DoHalt is run to prevent the events generated while halting to trigger
- /// other state changes before the halt is complete.
+ /// generate the event manually. This function is called from the context of the
+ /// private state thread.
///
/// @param[out] caused_stop
/// If true, then this Halt caused the stop, otherwise, the
@@ -1688,7 +1679,6 @@ public:
return error;
}
-
//------------------------------------------------------------------
/// Called after halting a process.
///
@@ -1728,7 +1718,6 @@ public:
return error;
}
-
//------------------------------------------------------------------
/// Called after detaching from a process.
///
@@ -1781,7 +1770,6 @@ public:
virtual bool
DestroyRequiresHalt() { return true; }
-
//------------------------------------------------------------------
/// Called after sending a signal to a process.
///
@@ -1808,6 +1796,41 @@ public:
RefreshStateAfterStop () = 0;
//------------------------------------------------------------------
+ /// Sometimes the connection to a process can detect the host OS
+ /// version that the process is running on. The current platform
+ /// should be checked first in case the platform is connected, but
+ /// clients can fall back onto this function if the platform fails
+ /// to identify the host OS version. The platform should be checked
+ /// first in case you are running a simulator platform that might
+ /// itself be running natively, but have different heuristics for
+ /// figuring out which OS is is emulating.
+ ///
+ /// @param[out] major
+ /// The major OS version, or UINT32_MAX if it can't be determined
+ ///
+ /// @param[out] minor
+ /// The minor OS version, or UINT32_MAX if it can't be determined
+ ///
+ /// @param[out] update
+ /// The update OS version, or UINT32_MAX if it can't be determined
+ ///
+ /// @return
+ /// Returns \b true if the host OS version info was filled in
+ /// and \b false otherwise.
+ //------------------------------------------------------------------
+ virtual bool
+ GetHostOSVersion(uint32_t &major,
+ uint32_t &minor,
+ uint32_t &update)
+ {
+ major = UINT32_MAX;
+ minor = UINT32_MAX;
+ update = UINT32_MAX;
+ return false;
+ }
+
+
+ //------------------------------------------------------------------
/// Get the target object pointer for this module.
///
/// @return
@@ -1817,7 +1840,7 @@ public:
Target &
GetTarget ()
{
- return m_target;
+ return *m_target_sp.lock();
}
//------------------------------------------------------------------
@@ -1830,7 +1853,7 @@ public:
const Target &
GetTarget () const
{
- return m_target;
+ return *m_target_sp.lock();
}
//------------------------------------------------------------------
@@ -1888,7 +1911,6 @@ public:
virtual void
ModulesDidLoad (ModuleList &module_list);
-
//------------------------------------------------------------------
/// Retrieve the list of shared libraries that are loaded for this process
///
@@ -1919,30 +1941,20 @@ public:
return StructuredData::ObjectSP();
}
-protected:
-
- void
- SetState (lldb::EventSP &event_sp);
-
- lldb::StateType
- GetPrivateState ();
-
//------------------------------------------------------------------
- /// The "private" side of resuming a process. This doesn't alter the
- /// state of m_run_lock, but just causes the process to resume.
+ /// Print a user-visible warning about a module being built with optimization
///
- /// @return
- /// An Error object describing the success or failure of the resume.
- //------------------------------------------------------------------
- Error
- PrivateResume ();
-
- //------------------------------------------------------------------
- // Called internally
+ /// Prints a async warning message to the user one time per Module
+ /// where a function is found that was compiled with optimization, per
+ /// Process.
+ ///
+ /// @param [in] sc
+ /// A SymbolContext with eSymbolContextFunction and eSymbolContextModule
+ /// pre-computed.
//------------------------------------------------------------------
void
- CompleteAttach ();
-
+ PrintWarningOptimization (const SymbolContext &sc);
+
public:
//------------------------------------------------------------------
/// Get the exit status for a process.
@@ -1958,13 +1970,12 @@ public:
/// Get a textual description of what the process exited.
///
/// @return
- /// The textual description of why the process exited, or NULL
+ /// The textual description of why the process exited, or nullptr
/// if there is no description available.
//------------------------------------------------------------------
const char *
GetExitDescription ();
-
virtual void
DidExit ()
{
@@ -2045,7 +2056,7 @@ public:
/// otherwise.
//------------------------------------------------------------------
virtual bool
- IsAlive () = 0;
+ IsAlive ();
//------------------------------------------------------------------
/// Before lldb detaches from a process, it warns the user that they are about to lose their debug session.
@@ -2255,7 +2266,6 @@ public:
return 0;
}
-
//------------------------------------------------------------------
/// Write all or part of a scalar value to memory.
///
@@ -2329,7 +2339,6 @@ public:
size_t
WriteMemory (lldb::addr_t vm_addr, const void *buf, size_t size, Error &error);
-
//------------------------------------------------------------------
/// Actually allocate memory in the process.
///
@@ -2352,7 +2361,6 @@ public:
return LLDB_INVALID_ADDRESS;
}
-
//------------------------------------------------------------------
/// The public interface to allocating memory in the process.
///
@@ -2369,16 +2377,41 @@ public:
/// 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
/// The address of the allocated buffer in the process, or
/// LLDB_INVALID_ADDRESS if the allocation failed.
//------------------------------------------------------------------
-
lldb::addr_t
AllocateMemory (size_t size, uint32_t permissions, Error &error);
+ //------------------------------------------------------------------
+ /// The public interface to allocating memory in the process, this also
+ /// clears the allocated memory.
+ ///
+ /// This function will allocate memory in the process's address
+ /// space. This can't rely on the generic function calling mechanism,
+ /// since that requires this function.
+ ///
+ /// @param[in] size
+ /// The size of the allocation requested.
+ ///
+ /// @param[in] permissions
+ /// Or together any of the lldb::Permissions bits. The permissions on
+ /// a given memory allocation can't be changed after allocation. Note
+ /// that a block that isn't set writable can still be written on from lldb,
+ /// just not by the process itself.
+ ///
+ /// @param[in/out] error
+ /// An error object to fill in if things go wrong.
+ /// @return
+ /// The address of the allocated buffer in the process, or
+ /// LLDB_INVALID_ADDRESS if the allocation failed.
+ //------------------------------------------------------------------
+
+ lldb::addr_t
+ CallocateMemory (size_t size, uint32_t permissions, Error &error);
//------------------------------------------------------------------
/// Resolve dynamically loaded indirect functions.
@@ -2393,7 +2426,6 @@ public:
/// The address of the resolved function.
/// LLDB_INVALID_ADDRESS if the resolution failed.
//------------------------------------------------------------------
-
virtual lldb::addr_t
ResolveIndirectFunction(const Address *address, Error &error);
@@ -2518,7 +2550,6 @@ public:
/// @return
/// \btrue if the memory was deallocated, \bfalse otherwise.
//------------------------------------------------------------------
-
virtual Error
DoDeallocateMemory (lldb::addr_t ptr)
{
@@ -2527,7 +2558,6 @@ public:
return error;
}
-
//------------------------------------------------------------------
/// The public interface to deallocating memory in the process.
///
@@ -2541,7 +2571,6 @@ public:
/// @return
/// \btrue if the memory was deallocated, \bfalse otherwise.
//------------------------------------------------------------------
-
Error
DeallocateMemory (lldb::addr_t ptr);
@@ -2671,7 +2700,6 @@ public:
return error;
}
-
virtual Error
DisableBreakpointSite (BreakpointSite *bp_site)
{
@@ -2680,7 +2708,6 @@ public:
return error;
}
-
// This is implemented completely using the lldb::Process API. Subclasses
// don't need to implement this function unless the standard flow of
// read existing opcode, write breakpoint opcode, verify breakpoint opcode
@@ -2717,7 +2744,6 @@ public:
Error
EnableBreakpointSiteByID (lldb::user_id_t break_id);
-
// BreakpointLocations use RemoveOwnerFromBreakpointSite to remove
// themselves from the owner's list of this breakpoint sites.
void
@@ -2811,12 +2837,16 @@ public:
// Returns the process state when it is stopped. If specified, event_sp_ptr
// is set to the event which triggered the stop. If wait_always = false,
// and the process is already stopped, this function returns immediately.
+ // If the process is hijacked and use_run_lock is true (the default), then this
+ // function releases the run lock after the stop. Setting use_run_lock to false
+ // will avoid this behavior.
lldb::StateType
- WaitForProcessToStop (const TimeValue *timeout,
- lldb::EventSP *event_sp_ptr = NULL,
- bool wait_always = true,
- Listener *hijack_listener = NULL,
- Stream *stream = NULL);
+ WaitForProcessToStop(const TimeValue *timeout,
+ lldb::EventSP *event_sp_ptr = nullptr,
+ bool wait_always = true,
+ Listener *hijack_listener = nullptr,
+ Stream *stream = nullptr,
+ bool use_run_lock = true);
uint32_t
GetIOHandlerID () const
@@ -2838,9 +2868,9 @@ public:
SyncIOHandler (uint32_t iohandler_id, uint64_t timeout_msec);
lldb::StateType
- WaitForStateChangedEvents (const TimeValue *timeout,
- lldb::EventSP &event_sp,
- Listener *hijack_listener); // Pass NULL to use builtin listener
+ WaitForStateChangedEvents(const TimeValue *timeout,
+ lldb::EventSP &event_sp,
+ Listener *hijack_listener); // Pass nullptr to use builtin listener
//--------------------------------------------------------------------------------------
/// Centralize the code that handles and prints descriptions for process state changes.
@@ -2851,7 +2881,7 @@ public:
/// @param[in] stream
/// The output stream to get the state change description
///
- /// @param[inout] 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.
@@ -2863,9 +2893,9 @@ public:
HandleProcessStateChangedEvent (const lldb::EventSP &event_sp,
Stream *stream,
bool &pop_process_io_handler);
+
Event *
PeekAtStateChangedEvents ();
-
class
ProcessEventHijacker
@@ -2876,6 +2906,7 @@ public:
{
m_process.HijackProcessEvents (listener);
}
+
~ProcessEventHijacker ()
{
m_process.RestoreProcessEvents();
@@ -2884,6 +2915,7 @@ public:
private:
Process &m_process;
};
+
friend class ProcessEventHijacker;
friend class ProcessProperties;
//------------------------------------------------------------------
@@ -2910,27 +2942,6 @@ public:
void
RestoreProcessEvents ();
-private:
- //------------------------------------------------------------------
- /// This is the part of the event handling that for a process event.
- /// It decides what to do with the event and returns true if the
- /// event needs to be propagated to the user, and false otherwise.
- /// If the event is not propagated, this call will most likely set
- /// the target to executing again.
- /// There is only one place where this call should be called, HandlePrivateEvent.
- /// Don't call it from anywhere else...
- ///
- /// @param[in] event_ptr
- /// This is the event we are handling.
- ///
- /// @return
- /// Returns \b true if the event should be reported to the
- /// user, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ShouldBroadcastEvent (Event *event_ptr);
-
-public:
const lldb::ABISP &
GetABI ();
@@ -3004,29 +3015,29 @@ public:
//------------------------------------------------------------------
// lldb::ExecutionContextScope pure virtual functions
//------------------------------------------------------------------
- virtual lldb::TargetSP
- CalculateTarget ();
+ lldb::TargetSP
+ CalculateTarget() override;
- virtual lldb::ProcessSP
- CalculateProcess ()
+ lldb::ProcessSP
+ CalculateProcess() override
{
return shared_from_this();
}
- virtual lldb::ThreadSP
- CalculateThread ()
+ lldb::ThreadSP
+ CalculateThread() override
{
return lldb::ThreadSP();
}
- virtual lldb::StackFrameSP
- CalculateStackFrame ()
+ lldb::StackFrameSP
+ CalculateStackFrame() override
{
return lldb::StackFrameSP();
}
- virtual void
- CalculateExecutionContext (ExecutionContext &exe_ctx);
+ void
+ CalculateExecutionContext(ExecutionContext &exe_ctx) override;
void
SetSTDIOFileDescriptor (int file_descriptor);
@@ -3129,9 +3140,70 @@ public:
return Error("Not supported");
}
+ size_t
+ AddImageToken(lldb::addr_t image_ptr);
+
+ lldb::addr_t
+ GetImagePtrFromToken(size_t token) const;
+
+ void
+ ResetImageToken(size_t token);
+
protected:
+ void
+ SetState (lldb::EventSP &event_sp);
+
+ lldb::StateType
+ GetPrivateState ();
+
+ //------------------------------------------------------------------
+ /// The "private" side of resuming a process. This doesn't alter the
+ /// state of m_run_lock, but just causes the process to resume.
+ ///
+ /// @return
+ /// An Error object describing the success or failure of the resume.
+ //------------------------------------------------------------------
+ Error
+ PrivateResume ();
//------------------------------------------------------------------
+ // Called internally
+ //------------------------------------------------------------------
+ void
+ CompleteAttach ();
+
+ //------------------------------------------------------------------
+ /// Print a user-visible warning one time per Process
+ ///
+ /// A facility for printing a warning to the user once per repeat_key.
+ ///
+ /// warning_type is from the Process::Warnings enums.
+ /// repeat_key is a pointer value that will be used to ensure that the
+ /// warning message is not printed multiple times. For instance, with a
+ /// warning about a function being optimized, you can pass the CompileUnit
+ /// pointer to have the warning issued for only the first function in a
+ /// CU, or the Function pointer to have it issued once for every function,
+ /// or a Module pointer to have it issued once per Module.
+ ///
+ /// Classes outside Process should call a specific PrintWarning method
+ /// so that the warning strings are all centralized in Process, instead of
+ /// calling PrintWarning() directly.
+ ///
+ /// @param [in] warning_type
+ /// One of the types defined in Process::Warnings.
+ ///
+ /// @param [in] repeat_key
+ /// A pointer value used to ensure that the warning is only printed once.
+ /// May be nullptr, indicating that the warning is printed unconditionally
+ /// every time.
+ ///
+ /// @param [in] fmt
+ /// printf style format string
+ //------------------------------------------------------------------
+ void
+ PrintWarning (uint64_t warning_type, const void *repeat_key, const char *fmt, ...) __attribute__((format(printf, 4, 5)));
+
+ //------------------------------------------------------------------
// NextEventAction provides a way to register an action on the next
// event that is delivered to this process. There is currently only
// one next event action allowed in the process at one time. If a
@@ -3158,10 +3230,8 @@ protected:
}
virtual
- ~NextEventAction()
- {
- }
-
+ ~NextEventAction() = default;
+
virtual EventActionResult PerformAction (lldb::EventSP &event_sp) = 0;
virtual void HandleBeingUnshipped () {}
virtual EventActionResult HandleBeingInterrupted () = 0;
@@ -3170,6 +3240,7 @@ protected:
{
m_process->m_resume_requested = true;
}
+
protected:
Process *m_process;
};
@@ -3188,25 +3259,17 @@ protected:
public:
AttachCompletionHandler (Process *process, uint32_t exec_count);
- virtual
- ~AttachCompletionHandler()
- {
- }
-
- virtual EventActionResult PerformAction (lldb::EventSP &event_sp);
- virtual EventActionResult HandleBeingInterrupted ();
- virtual const char *GetExitString();
+ ~AttachCompletionHandler() override = default;
+
+ EventActionResult PerformAction(lldb::EventSP &event_sp) override;
+ EventActionResult HandleBeingInterrupted() override;
+ const char *GetExitString() override;
+
private:
uint32_t m_exec_count;
std::string m_exit_string;
};
- bool
- HijackPrivateProcessEvents (Listener *listener);
-
- void
- RestorePrivateProcessEvents ();
-
bool
PrivateStateThreadIsValid () const
{
@@ -3223,6 +3286,8 @@ protected:
// Type definitions
//------------------------------------------------------------------
typedef std::map<lldb::LanguageType, lldb::LanguageRuntimeSP> LanguageRuntimeCollection;
+ typedef std::unordered_set<const void *> WarningsPointerSet;
+ typedef std::map<uint64_t, WarningsPointerSet> WarningsCollection;
struct PreResumeCallbackAndBaton
{
@@ -3238,7 +3303,7 @@ protected:
//------------------------------------------------------------------
// Member variables
//------------------------------------------------------------------
- Target & m_target; ///< The target that owns this process.
+ std::weak_ptr<Target> m_target_sp; ///< The target that owns this process.
ThreadSafeValue<lldb::StateType> m_public_state;
ThreadSafeValue<lldb::StateType> m_private_state; // The actual state of our process
Broadcaster m_private_state_broadcaster; // This broadcaster feeds state changed events into the private state thread's listener.
@@ -3290,7 +3355,6 @@ protected:
std::vector<PreResumeCallbackAndBaton> m_pre_resume_actions;
ProcessRunLock m_public_run_lock;
ProcessRunLock m_private_run_lock;
- Predicate<bool> m_currently_handling_event; // This predicate is set in HandlePrivateEvent while all its business is being done.
ArchSpec::StopInfoOverrideCallbackType m_stop_info_override_callback;
bool m_currently_handling_do_on_removals;
bool m_resume_requested; // If m_currently_handling_event or m_currently_handling_do_on_removals are true, Resume will only request a resume, using this flag to check.
@@ -3302,6 +3366,7 @@ protected:
std::map<lldb::addr_t,lldb::addr_t> m_resolved_indirect_addresses;
bool m_destroy_in_process;
bool m_can_interpret_function_calls; // Some targets, e.g the OSX kernel, don't support the ability to modify the stack.
+ WarningsCollection m_warnings_issued; // A set of object pointers which have already had warnings printed
enum {
eCanJITDontKnow= 0,
@@ -3353,6 +3418,9 @@ protected:
void
HandlePrivateEvent (lldb::EventSP &event_sp);
+ Error
+ HaltPrivate();
+
lldb::StateType
WaitForProcessStopPrivate (const TimeValue *timeout, lldb::EventSP &event_sp);
@@ -3401,23 +3469,39 @@ protected:
}
Error
- HaltForDestroyOrDetach(lldb::EventSP &exit_event_sp);
+ StopForDestroyOrDetach(lldb::EventSP &exit_event_sp);
bool
StateChangedIsExternallyHijacked();
void
LoadOperatingSystemPlugin(bool flush);
+
private:
//------------------------------------------------------------------
- // For Process only
+ /// This is the part of the event handling that for a process event.
+ /// It decides what to do with the event and returns true if the
+ /// event needs to be propagated to the user, and false otherwise.
+ /// If the event is not propagated, this call will most likely set
+ /// the target to executing again.
+ /// There is only one place where this call should be called, HandlePrivateEvent.
+ /// Don't call it from anywhere else...
+ ///
+ /// @param[in] event_ptr
+ /// This is the event we are handling.
+ ///
+ /// @return
+ /// Returns \b true if the event should be reported to the
+ /// user, \b false otherwise.
//------------------------------------------------------------------
+ bool
+ ShouldBroadcastEvent (Event *event_ptr);
+
void ControlPrivateStateThread (uint32_t signal);
DISALLOW_COPY_AND_ASSIGN (Process);
-
};
} // namespace lldb_private
-#endif // liblldb_Process_h_
+#endif // liblldb_Process_h_
diff --git a/include/lldb/Target/QueueItem.h b/include/lldb/Target/QueueItem.h
index c69c825a7976..aea506644c37 100644
--- a/include/lldb/Target/QueueItem.h
+++ b/include/lldb/Target/QueueItem.h
@@ -10,8 +10,14 @@
#ifndef liblldb_QueueItem_h_
#define liblldb_QueueItem_h_
+// C Includes
+// C++ Includes
+#include <memory>
+#include <string>
#include <vector>
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-forward.h"
@@ -19,7 +25,6 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/ConstString.h"
-
namespace lldb_private {
//------------------------------------------------------------------
@@ -32,12 +37,10 @@ namespace lldb_private {
// execution of the item begins.
//------------------------------------------------------------------
-
class QueueItem :
public std::enable_shared_from_this<QueueItem>
{
public:
-
QueueItem (lldb::QueueSP queue_sp, lldb::ProcessSP process_sp, lldb::addr_t item_ref, lldb_private::Address address);
~QueueItem ();
@@ -98,7 +101,7 @@ public:
bool
IsValid ()
{
- return m_queue_wp.lock() != NULL;
+ return m_queue_wp.lock() != nullptr;
}
//------------------------------------------------------------------
@@ -200,7 +203,6 @@ protected:
void
FetchEntireItem ();
-
lldb::QueueWP m_queue_wp;
lldb::ProcessWP m_process_wp;
@@ -220,16 +222,10 @@ protected:
std::string m_queue_label;
std::string m_target_queue_label;
-
private:
- //------------------------------------------------------------------
- // For QueueItem only
- //------------------------------------------------------------------
-
DISALLOW_COPY_AND_ASSIGN (QueueItem);
-
};
} // namespace lldb_private
-#endif // liblldb_QueueItem_h_
+#endif // liblldb_QueueItem_h_
diff --git a/include/lldb/Target/RegisterContext.h b/include/lldb/Target/RegisterContext.h
index 9108d4575259..037c27adaf10 100644
--- a/include/lldb/Target/RegisterContext.h
+++ b/include/lldb/Target/RegisterContext.h
@@ -29,8 +29,7 @@ public:
//------------------------------------------------------------------
RegisterContext (Thread &thread, uint32_t concrete_frame_idx);
- virtual
- ~RegisterContext ();
+ ~RegisterContext() override;
void
InvalidateIfNeeded (bool force);
@@ -93,7 +92,7 @@ public:
///
/// There may be multiple ways to enumerate the registers for a given
/// architecture. ABI references will specify one to be used with
- /// DWARF, the register numberings from stabs (aka "gcc"), there may
+ /// DWARF, the register numberings from process plugin, there may
/// be a variation used for eh_frame unwind instructions (e.g. on Darwin),
/// and so on. Register 5 by itself is meaningless - RegisterKind
/// enumeration tells you what context that number should be translated as.
@@ -213,26 +212,27 @@ public:
bool
WriteRegisterFromUnsigned (const RegisterInfo *reg_info, uint64_t uval);
+
bool
ConvertBetweenRegisterKinds (lldb::RegisterKind source_rk, uint32_t source_regnum, lldb::RegisterKind target_rk, uint32_t& target_regnum);
//------------------------------------------------------------------
// lldb::ExecutionContextScope pure virtual functions
//------------------------------------------------------------------
- virtual lldb::TargetSP
- CalculateTarget ();
+ lldb::TargetSP
+ CalculateTarget() override;
- virtual lldb::ProcessSP
- CalculateProcess ();
+ lldb::ProcessSP
+ CalculateProcess() override;
- virtual lldb::ThreadSP
- CalculateThread ();
+ lldb::ThreadSP
+ CalculateThread() override;
- virtual lldb::StackFrameSP
- CalculateStackFrame ();
+ lldb::StackFrameSP
+ CalculateStackFrame() override;
- virtual void
- CalculateExecutionContext (ExecutionContext &exe_ctx);
+ void
+ CalculateExecutionContext(ExecutionContext &exe_ctx) override;
uint32_t
GetStopID () const
@@ -262,4 +262,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_RegisterContext_h_
+#endif // liblldb_RegisterContext_h_
diff --git a/include/lldb/Target/SectionLoadList.h b/include/lldb/Target/SectionLoadList.h
index 6a9bbab93c98..5f5d39e2b24b 100644
--- a/include/lldb/Target/SectionLoadList.h
+++ b/include/lldb/Target/SectionLoadList.h
@@ -18,6 +18,7 @@
#include "llvm/ADT/DenseMap.h"
// Project includes
#include "lldb/lldb-public.h"
+#include "lldb/Core/Section.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private {
diff --git a/include/lldb/Target/StackFrame.h b/include/lldb/Target/StackFrame.h
index 95e21445be04..b65b01810176 100644
--- a/include/lldb/Target/StackFrame.h
+++ b/include/lldb/Target/StackFrame.h
@@ -12,6 +12,8 @@
// C Includes
// C++ Includes
+#include <memory>
+
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Error.h"
@@ -45,11 +47,12 @@ class StackFrame :
public:
enum ExpressionPathOption
{
- eExpressionPathOptionCheckPtrVsMember = (1u << 0),
- eExpressionPathOptionsNoFragileObjcIvar = (1u << 1),
- eExpressionPathOptionsNoSyntheticChildren = (1u << 2),
- eExpressionPathOptionsNoSyntheticArrayRange = (1u << 3),
- eExpressionPathOptionsAllowDirectIVarAccess = (1u << 4)
+ eExpressionPathOptionCheckPtrVsMember = (1u << 0),
+ eExpressionPathOptionsNoFragileObjcIvar = (1u << 1),
+ eExpressionPathOptionsNoSyntheticChildren = (1u << 2),
+ eExpressionPathOptionsNoSyntheticArrayRange = (1u << 3),
+ eExpressionPathOptionsAllowDirectIVarAccess = (1u << 4),
+ eExpressionPathOptionsInspectAnonymousUnions = (1u << 5)
};
//------------------------------------------------------------------
@@ -135,7 +138,7 @@ public:
const Address& pc,
const SymbolContext *sc_ptr);
- virtual ~StackFrame ();
+ ~StackFrame() override;
lldb::ThreadSP
GetThread () const
@@ -223,7 +226,7 @@ public:
/// executing.
///
/// @return
- /// A pointer to the current Block. NULL is returned if this can
+ /// A pointer to the current Block. nullptr is returned if this can
/// not be provided.
//------------------------------------------------------------------
Block *
@@ -351,7 +354,7 @@ public:
/// Optional string that will be prepended to the frame output description.
//------------------------------------------------------------------
void
- DumpUsingSettingsFormat (Stream *strm, const char *frame_marker = NULL);
+ DumpUsingSettingsFormat(Stream *strm, const char *frame_marker = nullptr);
//------------------------------------------------------------------
/// Print a description for this frame using a default format.
@@ -388,10 +391,10 @@ public:
/// Returns true if successful.
//------------------------------------------------------------------
bool
- GetStatus (Stream &strm,
- bool show_frame_info,
- bool show_source,
- const char *frame_marker = NULL);
+ GetStatus(Stream &strm,
+ bool show_frame_info,
+ bool show_source,
+ const char *frame_marker = nullptr);
//------------------------------------------------------------------
/// Query whether this frame is a concrete frame on the call stack,
@@ -466,22 +469,32 @@ public:
TrackGlobalVariable (const lldb::VariableSP &variable_sp, lldb::DynamicValueType use_dynamic);
//------------------------------------------------------------------
+ /// Query this frame to determine what the default language should be
+ /// when parsing expressions given the execution context.
+ ///
+ /// @return
+ /// The language of the frame if known, else lldb::eLanguageTypeUnknown.
+ //------------------------------------------------------------------
+ lldb::LanguageType
+ GetLanguage ();
+
+ //------------------------------------------------------------------
// lldb::ExecutionContextScope pure virtual functions
//------------------------------------------------------------------
- virtual lldb::TargetSP
- CalculateTarget ();
+ lldb::TargetSP
+ CalculateTarget() override;
- virtual lldb::ProcessSP
- CalculateProcess ();
+ lldb::ProcessSP
+ CalculateProcess() override;
- virtual lldb::ThreadSP
- CalculateThread ();
+ lldb::ThreadSP
+ CalculateThread() override;
- virtual lldb::StackFrameSP
- CalculateStackFrame ();
+ lldb::StackFrameSP
+ CalculateStackFrame() override;
void
- CalculateExecutionContext (ExecutionContext &exe_ctx);
+ CalculateExecutionContext(ExecutionContext &exe_ctx) override;
protected:
friend class StackFrameList;
@@ -520,9 +533,10 @@ private:
ValueObjectList m_variable_list_value_objects; // Value objects for each variable in m_variable_list_sp
StreamString m_disassembly;
Mutex m_mutex;
+
DISALLOW_COPY_AND_ASSIGN (StackFrame);
};
} // namespace lldb_private
-#endif // liblldb_StackFrame_h_
+#endif // liblldb_StackFrame_h_
diff --git a/include/lldb/Target/StackFrameList.h b/include/lldb/Target/StackFrameList.h
index 2680be3e5a68..50a656de9e69 100644
--- a/include/lldb/Target/StackFrameList.h
+++ b/include/lldb/Target/StackFrameList.h
@@ -12,6 +12,7 @@
// C Includes
// C++ Includes
+#include <memory>
#include <vector>
// Other libraries and framework includes
@@ -84,15 +85,14 @@ public:
GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr);
size_t
- GetStatus (Stream &strm,
- uint32_t first_frame,
- uint32_t num_frames,
- bool show_frame_info,
- uint32_t num_frames_with_source,
- const char *frame_marker = NULL);
+ GetStatus(Stream &strm,
+ uint32_t first_frame,
+ uint32_t num_frames,
+ bool show_frame_info,
+ uint32_t num_frames_with_source,
+ const char *frame_marker = nullptr);
protected:
-
friend class Thread;
bool
@@ -129,9 +129,6 @@ protected:
void
SetCurrentInlinedDepth (uint32_t new_depth);
- //------------------------------------------------------------------
- // Classes that inherit from StackFrameList can see and modify these
- //------------------------------------------------------------------
typedef std::vector<lldb::StackFrameSP> collection;
typedef collection::iterator iterator;
typedef collection::const_iterator const_iterator;
@@ -147,12 +144,9 @@ protected:
bool m_show_inlined_frames;
private:
- //------------------------------------------------------------------
- // For StackFrameList only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (StackFrameList);
};
} // namespace lldb_private
-#endif // liblldb_StackFrameList_h_
+#endif // liblldb_StackFrameList_h_
diff --git a/include/lldb/Target/StackID.h b/include/lldb/Target/StackID.h
index 75ad8ab38903..aad9d0cfc25c 100644
--- a/include/lldb/Target/StackID.h
+++ b/include/lldb/Target/StackID.h
@@ -28,7 +28,7 @@ public:
StackID () :
m_pc (LLDB_INVALID_ADDRESS),
m_cfa (LLDB_INVALID_ADDRESS),
- m_symbol_scope (NULL)
+ m_symbol_scope (nullptr)
{
}
@@ -47,9 +47,7 @@ public:
{
}
- ~StackID()
- {
- }
+ ~StackID() = default;
lldb::addr_t
GetPC() const
@@ -80,7 +78,7 @@ public:
{
m_pc = LLDB_INVALID_ADDRESS;
m_cfa = LLDB_INVALID_ADDRESS;
- m_symbol_scope = NULL;
+ m_symbol_scope = nullptr;
}
bool
@@ -108,7 +106,6 @@ public:
}
protected:
-
friend class StackFrame;
void
@@ -123,18 +120,15 @@ protected:
m_cfa = cfa;
}
- //------------------------------------------------------------------
- // Classes that inherit from StackID can see and modify these
- //------------------------------------------------------------------
lldb::addr_t m_pc; // The pc value for the function/symbol for this frame. This will
- // only get used if the symbol scope is NULL (the code where we are
+ // only get used if the symbol scope is nullptr (the code where we are
// stopped is not represented by any function or symbol in any
// shared library).
lldb::addr_t m_cfa; // The call frame address (stack pointer) value
// at the beginning of the function that uniquely
// identifies this frame (along with m_symbol_scope below)
- SymbolContextScope *m_symbol_scope; // If NULL, there is no block or symbol for this frame.
- // If not NULL, this will either be the scope for the
+ SymbolContextScope *m_symbol_scope; // If nullptr, there is no block or symbol for this frame.
+ // If not nullptr, this will either be the scope for the
// lexical block for the frame, or the scope
// for the symbol. Symbol context scopes are
// always be unique pointers since the are part
@@ -151,4 +145,4 @@ bool operator< (const StackID& lhs, const StackID& rhs);
} // namespace lldb_private
-#endif // liblldb_StackID_h_
+#endif // liblldb_StackID_h_
diff --git a/include/lldb/Target/StopInfo.h b/include/lldb/Target/StopInfo.h
index 2553887fa3d9..dfc9860b604a 100644
--- a/include/lldb/Target/StopInfo.h
+++ b/include/lldb/Target/StopInfo.h
@@ -172,7 +172,7 @@ public:
static lldb::StopInfoSP
CreateStopReasonWithPlan (lldb::ThreadPlanSP &plan,
lldb::ValueObjectSP return_valobj_sp,
- lldb::ClangExpressionVariableSP expression_variable_sp);
+ lldb::ExpressionVariableSP expression_variable_sp);
static lldb::StopInfoSP
CreateStopReasonWithException (Thread &thread, const char *description);
@@ -183,7 +183,7 @@ public:
static lldb::ValueObjectSP
GetReturnValueObject (lldb::StopInfoSP &stop_info_sp);
- static lldb::ClangExpressionVariableSP
+ static lldb::ExpressionVariableSP
GetExpressionVariable (lldb::StopInfoSP &stop_info_sp);
protected:
diff --git a/include/lldb/Target/SystemRuntime.h b/include/lldb/Target/SystemRuntime.h
index 18f38f79bdbd..54fde88c8d12 100644
--- a/include/lldb/Target/SystemRuntime.h
+++ b/include/lldb/Target/SystemRuntime.h
@@ -75,8 +75,7 @@ public:
/// The destructor is virtual since this class is designed to be
/// inherited by the plug-in instance.
//------------------------------------------------------------------
- virtual
- ~SystemRuntime();
+ ~SystemRuntime() override;
//------------------------------------------------------------------
/// Called after attaching to a process.
@@ -354,9 +353,10 @@ protected:
std::vector<ConstString> m_types;
private:
+
DISALLOW_COPY_AND_ASSIGN (SystemRuntime);
};
} // namespace lldb_private
-#endif // liblldb_SystemRuntime_h_
+#endif // liblldb_SystemRuntime_h_
diff --git a/include/lldb/Target/Target.h b/include/lldb/Target/Target.h
index 427f68e4c5d4..0cdb248a9b44 100644
--- a/include/lldb/Target/Target.h
+++ b/include/lldb/Target/Target.h
@@ -13,6 +13,10 @@
// C Includes
// C++ Includes
#include <list>
+#include <map>
+#include <memory>
+#include <string>
+#include <vector>
// Other libraries and framework includes
// Project includes
@@ -24,6 +28,8 @@
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/UserSettingsController.h"
+#include "lldb/Expression/Expression.h"
+#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/ExecutionContextScope.h"
#include "lldb/Target/PathMappingList.h"
#include "lldb/Target/ProcessLaunchInfo.h"
@@ -55,8 +61,7 @@ class TargetProperties : public Properties
public:
TargetProperties(Target *target);
- virtual
- ~TargetProperties();
+ ~TargetProperties() override;
ArchSpec
GetDefaultArchitecture () const;
@@ -169,6 +174,9 @@ public:
bool
GetBreakpointsConsultPlatformAvoidList ();
+ lldb::LanguageType
+ GetLanguage () const;
+
const char *
GetExpressionPrefixContentsAsCString ();
@@ -229,7 +237,6 @@ private:
static void DisableASLRValueChangedCallback(void *target_property_ptr, OptionValue *);
static void DisableSTDIOValueChangedCallback(void *target_property_ptr, OptionValue *);
-private:
//------------------------------------------------------------------
// Member variables.
//------------------------------------------------------------------
@@ -295,9 +302,7 @@ public:
const char *
GetPrefix () const
{
- if (m_prefix.empty())
- return NULL;
- return m_prefix.c_str();
+ return (m_prefix.empty() ? nullptr : m_prefix.c_str());
}
void
@@ -438,6 +443,18 @@ public:
}
bool
+ GetColorizeErrors () const
+ {
+ return m_ansi_color_errors;
+ }
+
+ void
+ SetColorizeErrors (bool b)
+ {
+ m_ansi_color_errors = b;
+ }
+
+ bool
GetTrapExceptions() const
{
return m_trap_exceptions;
@@ -449,6 +466,18 @@ public:
m_trap_exceptions = b;
}
+ bool
+ GetREPLEnabled() const
+ {
+ return m_repl;
+ }
+
+ void
+ SetREPLEnabled (bool b)
+ {
+ m_repl = b;
+ }
+
void
SetCancelCallback (lldb::ExpressionCancelCallback callback, void *baton)
{
@@ -459,10 +488,36 @@ public:
bool
InvokeCancelCallback (lldb::ExpressionEvaluationPhase phase) const
{
- if (m_cancel_callback == nullptr)
- return false;
+ return ((m_cancel_callback != nullptr) ? m_cancel_callback(phase, m_cancel_callback_baton) : false);
+ }
+
+ // Allows the expression contents to be remapped to point to the specified file and line
+ // using #line directives.
+ void
+ SetPoundLine (const char *path, uint32_t line) const
+ {
+ if (path && path[0])
+ {
+ m_pound_line_file = path;
+ m_pound_line_line = line;
+ }
else
- return m_cancel_callback (phase, m_cancel_callback_baton);
+ {
+ m_pound_line_file.clear();
+ m_pound_line_line = 0;
+ }
+ }
+
+ const char *
+ GetPoundLineFilePath () const
+ {
+ return (m_pound_line_file.empty() ? nullptr : m_pound_line_file.c_str());
+ }
+
+ uint32_t
+ GetPoundLineLine () const
+ {
+ return m_pound_line_line;
}
void
@@ -489,13 +544,20 @@ private:
bool m_stop_others;
bool m_debug;
bool m_trap_exceptions;
+ bool m_repl;
bool m_generate_debug_info;
+ bool m_ansi_color_errors;
bool m_result_is_internal;
lldb::DynamicValueType m_use_dynamic;
uint32_t m_timeout_usec;
uint32_t m_one_thread_timeout_usec;
lldb::ExpressionCancelCallback m_cancel_callback;
void *m_cancel_callback_baton;
+ // If m_pound_line_file is not empty and m_pound_line_line is non-zero,
+ // use #line %u "%s" before the expression content to remap where the source
+ // originates
+ mutable std::string m_pound_line_file;
+ mutable uint32_t m_pound_line_line;
};
//----------------------------------------------------------------------
@@ -527,7 +589,7 @@ public:
static ConstString &GetStaticBroadcasterClass ();
- virtual ConstString &GetBroadcasterClass() const
+ ConstString &GetBroadcasterClass() const override
{
return GetStaticBroadcasterClass();
}
@@ -540,20 +602,19 @@ public:
TargetEventData (const lldb::TargetSP &target_sp, const ModuleList &module_list);
- virtual
- ~TargetEventData();
+ ~TargetEventData() override;
static const ConstString &
GetFlavorString ();
- virtual const ConstString &
- GetFlavor () const
+ const ConstString &
+ GetFlavor() const override
{
return TargetEventData::GetFlavorString ();
}
- virtual void
- Dump (Stream *s) const;
+ void
+ Dump(Stream *s) const override;
static const TargetEventData *
GetEventDataFromEvent (const Event *event_ptr);
@@ -583,6 +644,8 @@ public:
DISALLOW_COPY_AND_ASSIGN (TargetEventData);
};
+ ~Target() override;
+
static void
SettingsInitialize ();
@@ -608,8 +671,8 @@ public:
// UpdateInstanceName ();
lldb::ModuleSP
- GetSharedModule (const ModuleSpec &module_spec,
- Error *error_ptr = NULL);
+ GetSharedModule(const ModuleSpec &module_spec,
+ Error *error_ptr = nullptr);
//----------------------------------------------------------------------
// Settings accessors
@@ -618,36 +681,6 @@ public:
static const lldb::TargetPropertiesSP &
GetGlobalProperties();
-
-private:
- //------------------------------------------------------------------
- /// Construct with optional file and arch.
- ///
- /// This member is private. Clients must use
- /// TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
- /// so all targets can be tracked from the central target list.
- ///
- /// @see TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
- //------------------------------------------------------------------
- Target (Debugger &debugger,
- const ArchSpec &target_arch,
- const lldb::PlatformSP &platform_sp,
- bool is_dummy_target);
-
- // Helper function.
- bool
- ProcessIsValid ();
-
- // Copy breakpoints, stop hooks and so forth from the dummy target:
- void
- PrimeFromDummyTarget(Target *dummy_target);
-
- void
- AddBreakpoint(lldb::BreakpointSP breakpoint_sp, bool internal);
-
-public:
- ~Target();
-
Mutex &
GetAPIMutex ()
{
@@ -659,6 +692,7 @@ public:
void
CleanupProcess ();
+
//------------------------------------------------------------------
/// Dump a description of this object to a Stream.
///
@@ -718,7 +752,7 @@ public:
lldb::BreakpointSP
GetBreakpointByID (lldb::break_id_t break_id);
- // Use this to create a file and line breakpoint to a given module or all module it is NULL
+ // Use this to create a file and line breakpoint to a given module or all module it is nullptr
lldb::BreakpointSP
CreateBreakpoint (const FileSpecList *containingModules,
const FileSpec &file,
@@ -744,24 +778,32 @@ public:
bool internal,
bool request_hardware);
+ // Use this to create a breakpoint from a load address and a module file spec
+ lldb::BreakpointSP
+ CreateAddressInModuleBreakpoint (lldb::addr_t file_addr,
+ bool internal,
+ const FileSpec *file_spec,
+ bool request_hardware);
+
// Use this to create Address breakpoints:
lldb::BreakpointSP
- CreateBreakpoint (Address &addr,
+ CreateBreakpoint (const Address &addr,
bool internal,
bool request_hardware);
- // Use this to create a function breakpoint by regexp in containingModule/containingSourceFiles, or all modules if it is NULL
+ // Use this to create a function breakpoint by regexp in containingModule/containingSourceFiles, or all modules if it is nullptr
// When "skip_prologue is set to eLazyBoolCalculate, we use the current target
// setting, else we use the values passed in
lldb::BreakpointSP
CreateFuncRegexBreakpoint (const FileSpecList *containingModules,
const FileSpecList *containingSourceFiles,
RegularExpression &func_regexp,
+ lldb::LanguageType requested_language,
LazyBool skip_prologue,
bool internal,
bool request_hardware);
- // Use this to create a function breakpoint by name in containingModule, or all modules if it is NULL
+ // Use this to create a function breakpoint by name in containingModule, or all modules if it is nullptr
// When "skip_prologue is set to eLazyBoolCalculate, we use the current target
// setting, else we use the values passed in.
// func_name_type_mask is or'ed values from the FunctionNameType enum.
@@ -770,17 +812,18 @@ public:
const FileSpecList *containingSourceFiles,
const char *func_name,
uint32_t func_name_type_mask,
+ lldb::LanguageType language,
LazyBool skip_prologue,
bool internal,
bool request_hardware);
lldb::BreakpointSP
- CreateExceptionBreakpoint (enum lldb::LanguageType language,
- bool catch_bp,
- bool throw_bp,
- bool internal,
- Args *additional_args = nullptr,
- Error *additional_args_error = nullptr);
+ CreateExceptionBreakpoint(enum lldb::LanguageType language,
+ bool catch_bp,
+ bool throw_bp,
+ bool internal,
+ Args *additional_args = nullptr,
+ Error *additional_args_error = nullptr);
// This is the same as the func_name breakpoint except that you can specify a vector of names. This is cheaper
// than a regular expression breakpoint in the case where you just want to set a breakpoint on a set of names
@@ -792,6 +835,7 @@ public:
const char *func_names[],
size_t num_names,
uint32_t func_name_type_mask,
+ lldb::LanguageType language,
LazyBool skip_prologue,
bool internal,
bool request_hardware);
@@ -801,11 +845,11 @@ public:
const FileSpecList *containingSourceFiles,
const std::vector<std::string> &func_names,
uint32_t func_name_type_mask,
+ lldb::LanguageType language,
LazyBool skip_prologue,
bool internal,
bool request_hardware);
-
// Use this to create a general breakpoint:
lldb::BreakpointSP
CreateBreakpoint (lldb::SearchFilterSP &filter_sp,
@@ -818,7 +862,7 @@ public:
lldb::WatchpointSP
CreateWatchpoint (lldb::addr_t addr,
size_t size,
- const ClangASTType *type,
+ const CompilerType *type,
uint32_t kind,
Error &error);
@@ -914,26 +958,14 @@ public:
lldb::addr_t
GetOpcodeLoadAddress (lldb::addr_t load_addr, lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const;
-protected:
- //------------------------------------------------------------------
- /// Implementing of ModuleList::Notifier.
- //------------------------------------------------------------------
-
- virtual void
- ModuleAdded (const ModuleList& module_list, const lldb::ModuleSP& module_sp);
-
- virtual void
- ModuleRemoved (const ModuleList& module_list, const lldb::ModuleSP& module_sp);
-
- virtual void
- ModuleUpdated (const ModuleList& module_list,
- const lldb::ModuleSP& old_module_sp,
- const lldb::ModuleSP& new_module_sp);
- virtual void
- WillClearList (const ModuleList& module_list);
+ // Get load_addr as breakable load address for this target.
+ // Take a addr and check if for any reason there is a better address than this to put a breakpoint on.
+ // If there is then return that address.
+ // For MIPS, if instruction at addr is a delay slot instruction then this method will find the address of its
+ // previous instruction and return that address.
+ lldb::addr_t
+ GetBreakableLoadAddress (lldb::addr_t addr);
-public:
-
void
ModulesDidLoad (ModuleList &module_list);
@@ -970,7 +1002,7 @@ public:
///
/// @return
/// The shared pointer to the executable module which can
- /// contains a NULL Module object if no executable has been
+ /// contains a nullptr Module object if no executable has been
/// set.
///
/// @see DynamicLoader
@@ -1014,9 +1046,9 @@ public:
SetExecutableModule (lldb::ModuleSP& module_sp, bool get_dependent_files);
bool
- LoadScriptingResources (std::list<Error>& errors,
- Stream* feedback_stream = NULL,
- bool continue_on_error = true)
+ LoadScriptingResources(std::list<Error>& errors,
+ Stream* feedback_stream = nullptr,
+ bool continue_on_error = true)
{
return m_images.LoadScriptingResourcesInTarget(this,errors,feedback_stream,continue_on_error);
}
@@ -1146,12 +1178,12 @@ public:
// 2 - if there is a valid process, try and read from its memory
// 3 - if (prefer_file_cache == false) then read from object file cache
size_t
- ReadMemory (const Address& addr,
- bool prefer_file_cache,
- void *dst,
- size_t dst_len,
- Error &error,
- lldb::addr_t *load_addr_ptr = NULL);
+ ReadMemory(const Address& addr,
+ bool prefer_file_cache,
+ void *dst,
+ size_t dst_len,
+ Error &error,
+ lldb::addr_t *load_addr_ptr = nullptr);
size_t
ReadCStringFromMemory (const Address& addr, std::string &out_str, Error &error);
@@ -1199,28 +1231,70 @@ public:
//------------------------------------------------------------------
// lldb::ExecutionContextScope pure virtual functions
//------------------------------------------------------------------
- virtual lldb::TargetSP
- CalculateTarget ();
+ lldb::TargetSP
+ CalculateTarget() override;
- virtual lldb::ProcessSP
- CalculateProcess ();
+ lldb::ProcessSP
+ CalculateProcess() override;
- virtual lldb::ThreadSP
- CalculateThread ();
+ lldb::ThreadSP
+ CalculateThread() override;
- virtual lldb::StackFrameSP
- CalculateStackFrame ();
+ lldb::StackFrameSP
+ CalculateStackFrame() override;
- virtual void
- CalculateExecutionContext (ExecutionContext &exe_ctx);
+ void
+ CalculateExecutionContext(ExecutionContext &exe_ctx) override;
PathMappingList &
GetImageSearchPathList ();
+ TypeSystem *
+ GetScratchTypeSystemForLanguage (Error *error, lldb::LanguageType language, bool create_on_demand = true);
+
+ PersistentExpressionState *
+ GetPersistentExpressionStateForLanguage (lldb::LanguageType language);
+
+ // Creates a UserExpression for the given language, the rest of the parameters have the
+ // same meaning as for the UserExpression constructor.
+ // Returns a new-ed object which the caller owns.
+
+ UserExpression *
+ GetUserExpressionForLanguage(const char *expr,
+ const char *expr_prefix,
+ lldb::LanguageType language,
+ Expression::ResultType desired_type,
+ const EvaluateExpressionOptions &options,
+ Error &error);
+
+ // Creates a FunctionCaller for the given language, the rest of the parameters have the
+ // same meaning as for the FunctionCaller constructor. Since a FunctionCaller can't be
+ // IR Interpreted, it makes no sense to call this with an ExecutionContextScope that lacks
+ // a Process.
+ // Returns a new-ed object which the caller owns.
+
+ FunctionCaller *
+ GetFunctionCallerForLanguage (lldb::LanguageType language,
+ const CompilerType &return_type,
+ const Address& function_address,
+ const ValueList &arg_value_list,
+ const char *name,
+ Error &error);
+
+ // Creates a UtilityFunction for the given language, the rest of the parameters have the
+ // same meaning as for the UtilityFunction constructor.
+ // Returns a new-ed object which the caller owns.
+
+ UtilityFunction *
+ GetUtilityFunctionForLanguage (const char *expr,
+ lldb::LanguageType language,
+ const char *name,
+ Error &error);
+
ClangASTContext *
GetScratchClangASTContext(bool create_on_demand=true);
- ClangASTImporter *
+ lldb::ClangASTImporterSP
GetClangASTImporter();
//----------------------------------------------------------------------
@@ -1266,23 +1340,26 @@ public:
// in in th execution context.
lldb::ExpressionResults
EvaluateExpression (const char *expression,
- StackFrame *frame,
+ ExecutionContextScope *exe_scope,
lldb::ValueObjectSP &result_valobj_sp,
const EvaluateExpressionOptions& options = EvaluateExpressionOptions());
- ClangPersistentVariables &
- GetPersistentVariables();
-
+ lldb::ExpressionVariableSP
+ GetPersistentVariable(const ConstString &name);
+
+ lldb::addr_t
+ GetPersistentSymbol(const ConstString &name);
+
//------------------------------------------------------------------
// Target Stop Hooks
//------------------------------------------------------------------
class StopHook : public UserID
{
public:
- ~StopHook ();
-
StopHook (const StopHook &rhs);
-
+
+ ~StopHook ();
+
StringList *
GetCommandPointer ()
{
@@ -1448,9 +1525,32 @@ public:
lldb::SearchFilterSP
GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules, const FileSpecList *containingSourceFiles);
+
+ lldb::REPLSP
+ GetREPL (Error &err, lldb::LanguageType language, const char *repl_options, bool can_create);
+
+ void
+ SetREPL (lldb::LanguageType language, lldb::REPLSP repl_sp);
protected:
//------------------------------------------------------------------
+ /// Implementing of ModuleList::Notifier.
+ //------------------------------------------------------------------
+
+ void
+ ModuleAdded(const ModuleList& module_list, const lldb::ModuleSP& module_sp) override;
+
+ void
+ ModuleRemoved(const ModuleList& module_list, const lldb::ModuleSP& module_sp) override;
+
+ void
+ ModuleUpdated(const ModuleList& module_list,
+ const lldb::ModuleSP& old_module_sp,
+ const lldb::ModuleSP& new_module_sp) override;
+ void
+ WillClearList(const ModuleList& module_list) override;
+
+ //------------------------------------------------------------------
// Member variables.
//------------------------------------------------------------------
Debugger & m_debugger;
@@ -1470,11 +1570,13 @@ protected:
lldb::ProcessSP m_process_sp;
lldb::SearchFilterSP m_search_filter_sp;
PathMappingList m_image_search_paths;
- lldb::ClangASTContextUP m_scratch_ast_context_ap;
- lldb::ClangASTSourceUP m_scratch_ast_source_ap;
- lldb::ClangASTImporterUP m_ast_importer_ap;
+ TypeSystemMap m_scratch_type_system_map;
+
+ typedef std::map<lldb::LanguageType, lldb::REPLSP> REPLMap;
+ REPLMap m_repl_map;
+
+ lldb::ClangASTImporterSP m_ast_importer_sp;
lldb::ClangModulesDeclVendorUP m_clang_modules_decl_vendor_ap;
- lldb::ClangPersistentVariablesUP m_persistent_variables; ///< These are the persistent variables associated with this process for the expression parser.
lldb::SourceManagerUP m_source_manager_ap;
@@ -1490,9 +1592,34 @@ protected:
void *baton);
private:
+ //------------------------------------------------------------------
+ /// Construct with optional file and arch.
+ ///
+ /// This member is private. Clients must use
+ /// TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
+ /// so all targets can be tracked from the central target list.
+ ///
+ /// @see TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
+ //------------------------------------------------------------------
+ Target (Debugger &debugger,
+ const ArchSpec &target_arch,
+ const lldb::PlatformSP &platform_sp,
+ bool is_dummy_target);
+
+ // Helper function.
+ bool
+ ProcessIsValid ();
+
+ // Copy breakpoints, stop hooks and so forth from the dummy target:
+ void
+ PrimeFromDummyTarget(Target *dummy_target);
+
+ void
+ AddBreakpoint(lldb::BreakpointSP breakpoint_sp, bool internal);
+
DISALLOW_COPY_AND_ASSIGN (Target);
};
} // namespace lldb_private
-#endif // liblldb_Target_h_
+#endif // liblldb_Target_h_
diff --git a/include/lldb/Target/TargetList.h b/include/lldb/Target/TargetList.h
index 27e46ba81a70..fddb715b46f3 100644
--- a/include/lldb/Target/TargetList.h
+++ b/include/lldb/Target/TargetList.h
@@ -12,6 +12,8 @@
// C Includes
// C++ Includes
+#include <vector>
+
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Broadcaster.h"
@@ -37,7 +39,6 @@ private:
TargetList(Debugger &debugger);
public:
-
//------------------------------------------------------------------
/// Broadcaster event bits definitions.
//------------------------------------------------------------------
@@ -51,12 +52,12 @@ public:
static ConstString &GetStaticBroadcasterClass ();
- virtual ConstString &GetBroadcasterClass() const
+ ConstString &GetBroadcasterClass() const override
{
return GetStaticBroadcasterClass();
}
- virtual ~TargetList();
+ ~TargetList() override;
//------------------------------------------------------------------
/// Create a new Target.
@@ -72,12 +73,12 @@ public:
///
/// @param[in] file_spec
/// The main executable file for a debug target. This value
- /// can be NULL and the file can be set later using:
+ /// can be nullptr and the file can be set later using:
/// Target::SetExecutableModule (ModuleSP&)
///
/// @param[in] triple_cstr
/// A target triple string to be used for the target. This can
- /// be NULL if the triple is not known or when attaching to a
+ /// be nullptr if the triple is not known or when attaching to a
/// process.
///
/// @param[in] get_dependent_modules
@@ -86,7 +87,7 @@ public:
///
/// @param[in] platform_options
/// A pointer to the platform options to use when creating this
- /// target. If this value is NULL, then the currently selected
+ /// target. If this value is nullptr, then the currently selected
/// platform will be used.
///
/// @param[out] target_sp
@@ -149,7 +150,7 @@ public:
//------------------------------------------------------------------
/// 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 NULL.
+ /// \a arch_ptr if arch_ptr is not nullptr.
///
/// @param[in] exe_file_spec
/// A file spec containing a basename, or a full path (directory
@@ -160,18 +161,18 @@ public:
/// directory, then both must match.
///
/// @param[in] exe_arch_ptr
- /// If not NULL then the architecture also needs to match, else
+ /// If not nullptr then the architecture also needs to match, else
/// the architectures will be compared.
///
/// @return
/// A shared pointer to a target object. The returned shared
- /// pointer will contain NULL if no target objects have a
+ /// 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 = NULL) const;
+ FindTargetWithExecutableAndArchitecture(const FileSpec &exe_file_spec,
+ const ArchSpec *exe_arch_ptr = nullptr) const;
//------------------------------------------------------------------
/// Find the target that contains a process with process ID \a
@@ -182,7 +183,7 @@ public:
///
/// @return
/// A shared pointer to a target object. The returned shared
- /// pointer will contain NULL if no target objects own a process
+ /// pointer will contain nullptr if no target objects own a process
/// with a matching process ID.
//------------------------------------------------------------------
lldb::TargetSP
@@ -230,6 +231,7 @@ protected:
lldb::TargetSP m_dummy_target_sp;
mutable Mutex m_target_list_mutex;
uint32_t m_selected_target_idx;
+
private:
lldb::TargetSP
GetDummyTarget (lldb_private::Debugger &debugger);
@@ -262,4 +264,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_TargetList_h_
+#endif // liblldb_TargetList_h_
diff --git a/include/lldb/Target/Thread.h b/include/lldb/Target/Thread.h
index c6a3c8e9851a..7aff77bd16f4 100644
--- a/include/lldb/Target/Thread.h
+++ b/include/lldb/Target/Thread.h
@@ -10,6 +10,14 @@
#ifndef liblldb_Thread_h_
#define liblldb_Thread_h_
+// C Includes
+// C++ Includes
+#include <memory>
+#include <string>
+#include <vector>
+
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Core/Broadcaster.h"
@@ -30,8 +38,7 @@ class ThreadProperties : public Properties
public:
ThreadProperties(bool is_global);
- virtual
- ~ThreadProperties();
+ ~ThreadProperties() override;
//------------------------------------------------------------------
/// The regular expression returned determines symbols that this
@@ -39,7 +46,7 @@ public:
///
/// @return
/// A pointer to a regular expression to compare against symbols,
- /// or NULL if all symbols are allowed.
+ /// or nullptr if all symbols are allowed.
///
//------------------------------------------------------------------
const RegularExpression *
@@ -82,7 +89,7 @@ public:
static ConstString &GetStaticBroadcasterClass ();
- virtual ConstString &GetBroadcasterClass() const
+ ConstString &GetBroadcasterClass() const override
{
return GetStaticBroadcasterClass();
}
@@ -97,19 +104,19 @@ public:
ThreadEventData();
- virtual ~ThreadEventData();
+ ~ThreadEventData() override;
static const ConstString &
GetFlavorString ();
- virtual const ConstString &
- GetFlavor () const
+ const ConstString &
+ GetFlavor() const override
{
return ThreadEventData::GetFlavorString ();
}
- virtual void
- Dump (Stream *s) const;
+ void
+ Dump(Stream *s) const override;
static const ThreadEventData *
GetEventDataFromEvent (const Event *event_ptr);
@@ -138,9 +145,9 @@ public:
private:
lldb::ThreadSP m_thread_sp;
StackID m_stack_id;
- DISALLOW_COPY_AND_ASSIGN (ThreadEventData);
+
+ DISALLOW_COPY_AND_ASSIGN (ThreadEventData);
};
-
struct ThreadStateCheckpoint
{
@@ -151,15 +158,6 @@ public:
lldb::addr_t current_inlined_pc;
};
- static void
- SettingsInitialize ();
-
- static void
- SettingsTerminate ();
-
- static const ThreadPropertiesSP &
- GetGlobalProperties();
-
//------------------------------------------------------------------
/// Constructor
///
@@ -179,7 +177,16 @@ public:
//------------------------------------------------------------------
Thread (Process &process, lldb::tid_t tid, bool use_invalid_index_id = false);
- virtual ~Thread();
+ ~Thread() override;
+
+ static void
+ SettingsInitialize ();
+
+ static void
+ SettingsTerminate ();
+
+ static const ThreadPropertiesSP &
+ GetGlobalProperties();
lldb::ProcessSP
GetProcess() const
@@ -303,6 +310,9 @@ public:
lldb::StopReason
GetStopReason();
+ bool
+ StopInfoIsUpToDate() const;
+
// This sets the stop reason to a "blank" stop reason, so you can call functions on the thread
// without having the called function run with whatever stop reason you stopped with.
void
@@ -320,7 +330,7 @@ public:
virtual const char *
GetInfo ()
{
- return NULL;
+ return nullptr;
}
//------------------------------------------------------------------
@@ -348,7 +358,7 @@ public:
virtual const char *
GetName ()
{
- return NULL;
+ return nullptr;
}
virtual void
@@ -390,12 +400,12 @@ public:
///
/// @return
/// The Queue name, if the Thread subclass implements this, else
- /// NULL.
+ /// nullptr.
//------------------------------------------------------------------
virtual const char *
GetQueueName ()
{
- return NULL;
+ return nullptr;
}
virtual void
@@ -475,7 +485,7 @@ public:
ReturnFromFrame (lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return_value_sp, bool broadcast = false);
Error
- JumpToLine (const FileSpec &file, uint32_t line, bool can_leave_function, std::string *warnings = NULL);
+ JumpToLine(const FileSpec &file, uint32_t line, bool can_leave_function, std::string *warnings = nullptr);
virtual lldb::StackFrameSP
GetFrameWithStackID (const StackID &stack_id)
@@ -492,16 +502,11 @@ public:
}
lldb::StackFrameSP
- GetSelectedFrame ()
- {
- lldb::StackFrameListSP stack_frame_list_sp(GetStackFrameList());
- return stack_frame_list_sp->GetFrameAtIndex (stack_frame_list_sp->GetSelectedFrameIndex());
- }
+ GetSelectedFrame ();
uint32_t
SetSelectedFrame (lldb_private::StackFrame *frame, bool broadcast = false);
-
bool
SetSelectedFrameByIndex (uint32_t frame_idx, bool broadcast = false);
@@ -608,6 +613,7 @@ public:
//------------------------------------------------------------------
virtual Error
StepOut ();
+
//------------------------------------------------------------------
/// Retrieves the per-thread data area.
/// Most OSs maintain a per-thread pointer (e.g. the FS register on
@@ -684,7 +690,7 @@ public:
/// Otherwise this plan will go on the end of the plan stack.
///
/// @return
- /// A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
+ /// 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);
@@ -703,7 +709,7 @@ public:
/// \b true if we will stop other threads while we single step this one.
///
/// @return
- /// A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
+ /// 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,
@@ -739,7 +745,7 @@ public:
/// If eLazyBoolCalculate, we will consult the default set in the thread.
///
/// @return
- /// A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
+ /// 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,
@@ -748,6 +754,15 @@ public:
lldb::RunMode stop_other_threads,
LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
+ // Helper function that takes a LineEntry to step, insted of an AddressRange. This may combine multiple
+ // LineEntries of the same source line number to step over a longer address range in a single operation.
+ virtual lldb::ThreadPlanSP
+ QueueThreadPlanForStepOverRange (bool abort_other_plans,
+ const LineEntry &line_entry,
+ const SymbolContext &addr_context,
+ lldb::RunMode stop_other_threads,
+ LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
+
//------------------------------------------------------------------
/// Queues the plan used to step through an address range, stepping into functions.
///
@@ -783,7 +798,7 @@ public:
/// If eLazyBoolCalculate, it will consult the default set in the thread.
///
/// @return
- /// A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
+ /// 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,
@@ -794,6 +809,17 @@ public:
LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate,
LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
+ // Helper function that takes a LineEntry to step, insted of an AddressRange. This may combine multiple
+ // LineEntries of the same source line number to step over a longer address range in a single operation.
+ virtual lldb::ThreadPlanSP
+ QueueThreadPlanForStepInRange (bool abort_other_plans,
+ const LineEntry &line_entry,
+ const SymbolContext &addr_context,
+ const char *step_in_target,
+ lldb::RunMode stop_other_threads,
+ LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate,
+ LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
+
//------------------------------------------------------------------
/// Queue the plan used to step out of the function at the current PC of
/// \a thread.
@@ -824,7 +850,7 @@ public:
/// If eLazyBoolCalculate, it will consult the default set in the thread.
///
/// @return
- /// A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
+ /// 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,
@@ -863,7 +889,7 @@ public:
/// See standard meanings for the stop & run votes in ThreadPlan.h.
///
/// @return
- /// A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
+ /// 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,
@@ -891,7 +917,7 @@ public:
/// \b true if we will stop other threads while we single step this one.
///
/// @return
- /// A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
+ /// 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,
@@ -914,7 +940,7 @@ public:
/// \b true if we will stop other threads while we single step this one.
///
/// @return
- /// A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
+ /// 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,
@@ -957,15 +983,6 @@ public:
Error
UnwindInnermostExpression();
-private:
- bool
- PlanIsBasePlan (ThreadPlan *plan_ptr);
-
- void
- BroadcastSelectedFrameChange(StackID &new_frame_id);
-
-public:
-
//------------------------------------------------------------------
/// Gets the outer-most plan that was popped off the plan stack in the
/// most recent stop. Useful for printing the stop reason accurately.
@@ -990,11 +1007,11 @@ public:
/// Gets the outer-most expression variable from the completed plans
///
/// @return
- /// A ClangExpressionVariableSP, either empty if there is no
+ /// 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::ClangExpressionVariableSP
+ lldb::ExpressionVariableSP
GetExpressionVariable ();
//------------------------------------------------------------------
@@ -1041,7 +1058,6 @@ public:
void
QueueThreadPlan (lldb::ThreadPlanSP &plan_sp, bool abort_other_plans);
-
//------------------------------------------------------------------
/// Discards the plans queued on the plan stack of the current thread. This is
/// arbitrated by the "Master" ThreadPlans, using the "OkayToDiscard" call.
@@ -1147,20 +1163,20 @@ public:
//------------------------------------------------------------------
// lldb::ExecutionContextScope pure virtual functions
//------------------------------------------------------------------
- virtual lldb::TargetSP
- CalculateTarget ();
+ lldb::TargetSP
+ CalculateTarget() override;
- virtual lldb::ProcessSP
- CalculateProcess ();
+ lldb::ProcessSP
+ CalculateProcess() override;
- virtual lldb::ThreadSP
- CalculateThread ();
+ lldb::ThreadSP
+ CalculateThread() override;
- virtual lldb::StackFrameSP
- CalculateStackFrame ();
+ lldb::StackFrameSP
+ CalculateStackFrame() override;
- virtual void
- CalculateExecutionContext (ExecutionContext &exe_ctx);
+ void
+ CalculateExecutionContext(ExecutionContext &exe_ctx) override;
lldb::StackFrameSP
GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr);
@@ -1271,7 +1287,6 @@ public:
}
protected:
-
friend class ThreadPlan;
friend class ThreadList;
friend class ThreadEventData;
@@ -1323,7 +1338,15 @@ protected:
lldb::StackFrameListSP
GetStackFrameList ();
-
+
+ void
+ SetTemporaryResumeState(lldb::StateType new_state)
+ {
+ m_temporary_resume_state = new_state;
+ }
+
+ void
+ FunctionOptimizationWarning (lldb_private::StackFrame *frame);
//------------------------------------------------------------------
// Classes that inherit from Process can see and modify these
@@ -1353,14 +1376,17 @@ protected:
private:
bool m_extended_info_fetched; // Have we tried to retrieve the m_extended_info for this thread?
StructuredData::ObjectSP m_extended_info; // The extended info for this thread
- //------------------------------------------------------------------
- // For Thread only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (Thread);
+private:
+ bool
+ PlanIsBasePlan (ThreadPlan *plan_ptr);
+ void
+ BroadcastSelectedFrameChange(StackID &new_frame_id);
+
+ DISALLOW_COPY_AND_ASSIGN (Thread);
};
} // namespace lldb_private
-#endif // liblldb_Thread_h_
+#endif // liblldb_Thread_h_
diff --git a/include/lldb/Target/ThreadList.h b/include/lldb/Target/ThreadList.h
index 12c430c9c8d8..e6489b25e558 100644
--- a/include/lldb/Target/ThreadList.h
+++ b/include/lldb/Target/ThreadList.h
@@ -32,8 +32,7 @@ public:
ThreadList (const ThreadList &rhs);
- virtual
- ~ThreadList ();
+ ~ThreadList() override;
const ThreadList&
operator = (const ThreadList& rhs);
@@ -128,8 +127,8 @@ public:
void
SetStopID (uint32_t stop_id);
- virtual Mutex &
- GetMutex ();
+ Mutex &
+ GetMutex() override;
void
Update (ThreadList &rhs);
@@ -150,9 +149,10 @@ protected:
lldb::tid_t m_selected_tid; ///< For targets that need the notion of a current thread.
private:
+
ThreadList ();
};
} // namespace lldb_private
-#endif // liblldb_ThreadList_h_
+#endif // liblldb_ThreadList_h_
diff --git a/include/lldb/Target/ThreadPlan.h b/include/lldb/Target/ThreadPlan.h
index db2e79894057..e6f9aeb78dd6 100644
--- a/include/lldb/Target/ThreadPlan.h
+++ b/include/lldb/Target/ThreadPlan.h
@@ -13,6 +13,7 @@
// C Includes
// C++ Includes
#include <string>
+
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
@@ -518,10 +519,10 @@ public:
// the user regained control at that point) a subsequent process control command step/continue/etc. might
// complete the expression evaluations. If so, the result of the expression evaluation will show up here.
- virtual lldb::ClangExpressionVariableSP
+ virtual lldb::ExpressionVariableSP
GetExpressionVariable ()
{
- return lldb::ClangExpressionVariableSP();
+ return lldb::ExpressionVariableSP();
}
// If a thread plan stores the state before it was run, then you might
@@ -562,13 +563,14 @@ public:
else
return m_iteration_count;
}
+
protected:
//------------------------------------------------------------------
// Classes that inherit from ThreadPlan can see and modify these
//------------------------------------------------------------------
virtual bool
- DoWillResume (lldb::StateType resume_state, bool current_plan) { return true; };
+ DoWillResume (lldb::StateType resume_state, bool current_plan) { return true; }
virtual bool
DoPlanExplainsStop (Event *event_ptr) = 0;
@@ -613,6 +615,9 @@ protected:
virtual lldb::StateType
GetPlanRunState () = 0;
+ bool
+ IsUsuallyUnexplainedStopReason(lldb::StopReason);
+
Thread &m_thread;
Vote m_stop_vote;
Vote m_run_vote;
@@ -653,47 +658,46 @@ class ThreadPlanNull : public ThreadPlan
{
public:
ThreadPlanNull (Thread &thread);
- virtual ~ThreadPlanNull ();
+ ~ThreadPlanNull() override;
- virtual void
- GetDescription (Stream *s,
- lldb::DescriptionLevel level);
+ void
+ GetDescription(Stream *s,
+ lldb::DescriptionLevel level) override;
- virtual bool
- ValidatePlan (Stream *error);
+ bool
+ ValidatePlan(Stream *error) override;
- virtual bool
- ShouldStop (Event *event_ptr);
+ bool
+ ShouldStop(Event *event_ptr) override;
- virtual bool
- MischiefManaged ();
+ bool
+ MischiefManaged() override;
- virtual bool
- WillStop ();
+ bool
+ WillStop() override;
- virtual bool
- IsBasePlan()
+ bool
+ IsBasePlan() override
{
return true;
}
- virtual bool
- OkayToDiscard ()
+ bool
+ OkayToDiscard() override
{
return false;
}
protected:
- virtual bool
- DoPlanExplainsStop (Event *event_ptr);
+ bool
+ DoPlanExplainsStop(Event *event_ptr) override;
- virtual lldb::StateType
- GetPlanRunState ();
+ lldb::StateType
+ GetPlanRunState() override;
DISALLOW_COPY_AND_ASSIGN(ThreadPlanNull);
};
-
} // namespace lldb_private
-#endif // liblldb_ThreadPlan_h_
+#endif // liblldb_ThreadPlan_h_
diff --git a/include/lldb/Target/ThreadPlanBase.h b/include/lldb/Target/ThreadPlanBase.h
index 69959e12f848..a0d30b5f0b67 100644
--- a/include/lldb/Target/ThreadPlanBase.h
+++ b/include/lldb/Target/ThreadPlanBase.h
@@ -31,31 +31,32 @@ class ThreadPlanBase : public ThreadPlan
{
friend class Process; // RunThreadPlan manages "stopper" base plans.
public:
- virtual ~ThreadPlanBase ();
+ ~ThreadPlanBase() override;
- virtual void GetDescription (Stream *s, lldb::DescriptionLevel level);
- virtual bool ValidatePlan (Stream *error);
- virtual bool ShouldStop (Event *event_ptr);
- virtual Vote ShouldReportStop (Event *event_ptr);
- virtual bool StopOthers ();
- virtual lldb::StateType GetPlanRunState ();
- virtual bool WillStop ();
- virtual bool MischiefManaged ();
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
+ bool ValidatePlan(Stream *error) override;
+ bool ShouldStop(Event *event_ptr) override;
+ Vote ShouldReportStop(Event *event_ptr) override;
+ bool StopOthers() override;
+ lldb::StateType GetPlanRunState() override;
+ bool WillStop() override;
+ bool MischiefManaged() override;
- virtual bool OkayToDiscard()
+ bool
+ OkayToDiscard() override
{
return false;
}
- virtual bool
- IsBasePlan()
+ bool
+ IsBasePlan() override
{
return true;
}
protected:
- virtual bool DoWillResume (lldb::StateType resume_state, bool current_plan);
- virtual bool DoPlanExplainsStop (Event *event_ptr);
+ bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
+ bool DoPlanExplainsStop(Event *event_ptr) override;
ThreadPlanBase (Thread &thread);
private:
@@ -65,7 +66,6 @@ private:
DISALLOW_COPY_AND_ASSIGN (ThreadPlanBase);
};
-
} // namespace lldb_private
-#endif // liblldb_ThreadPlanFundamental_h_
+#endif // liblldb_ThreadPlanFundamental_h_
diff --git a/include/lldb/Target/ThreadPlanCallFunction.h b/include/lldb/Target/ThreadPlanCallFunction.h
index 36e4d6e71c79..47eee2808f1e 100644
--- a/include/lldb/Target/ThreadPlanCallFunction.h
+++ b/include/lldb/Target/ThreadPlanCallFunction.h
@@ -26,11 +26,11 @@ class ThreadPlanCallFunction : public ThreadPlan
{
// Create a thread plan to call a function at the address passed in the "function"
// argument. If you plan to call GetReturnValueObject, then pass in the
- // return type, otherwise just pass in an invalid ClangASTType.
+ // return type, otherwise just pass in an invalid CompilerType.
public:
ThreadPlanCallFunction (Thread &thread,
const Address &function,
- const ClangASTType &return_type,
+ const CompilerType &return_type,
llvm::ArrayRef<lldb::addr_t> args,
const EvaluateExpressionOptions &options);
@@ -38,35 +38,34 @@ public:
const Address &function,
const EvaluateExpressionOptions &options);
- virtual
- ~ThreadPlanCallFunction ();
+ ~ThreadPlanCallFunction() override;
- virtual void
- GetDescription (Stream *s, lldb::DescriptionLevel level);
+ void
+ GetDescription(Stream *s, lldb::DescriptionLevel level) override;
- virtual bool
- ValidatePlan (Stream *error);
+ bool
+ ValidatePlan(Stream *error) override;
- virtual bool
- ShouldStop (Event *event_ptr);
+ bool
+ ShouldStop(Event *event_ptr) override;
- virtual Vote
- ShouldReportStop(Event *event_ptr);
+ Vote
+ ShouldReportStop(Event *event_ptr) override;
- virtual bool
- StopOthers ();
+ bool
+ StopOthers() override;
- virtual lldb::StateType
- GetPlanRunState ();
+ lldb::StateType
+ GetPlanRunState() override;
- virtual void
- DidPush ();
+ void
+ DidPush() override;
- virtual bool
- WillStop ();
+ bool
+ WillStop() override;
- virtual bool
- MischiefManaged ();
+ bool
+ MischiefManaged() override;
// To get the return value from a function call you must create a
// lldb::ValueSP that contains a valid clang type in its context and call
@@ -77,8 +76,8 @@ public:
// plan is complete, you can call "GetReturnValue()" to retrieve the value
// that was extracted.
- virtual lldb::ValueObjectSP
- GetReturnValueObject ()
+ lldb::ValueObjectSP
+ GetReturnValueObject() override
{
return m_return_valobj_sp;
}
@@ -93,11 +92,11 @@ public:
return m_function_sp;
}
- // Classes that derive from ClangFunction, and implement
+ // Classes that derive from FunctionCaller, and implement
// their own WillPop methods should call this so that the
// thread state gets restored if the plan gets discarded.
- virtual void
- WillPop ();
+ void
+ WillPop() override;
// If the thread plan stops mid-course, this will be the stop reason that interrupted us.
// Once DoTakedown is called, this will be the real stop reason at the end of the function call.
@@ -105,8 +104,8 @@ public:
// This is needed because we want the CallFunction thread plans not to show up as the stop reason.
// But if something bad goes wrong, it is nice to be able to tell the user what really happened.
- virtual lldb::StopInfoSP
- GetRealStopInfo()
+ lldb::StopInfoSP
+ GetRealStopInfo() override
{
if (m_real_stop_info_sp)
return m_real_stop_info_sp;
@@ -120,23 +119,23 @@ public:
return m_stop_address;
}
- virtual bool
- RestoreThreadState();
+ bool
+ RestoreThreadState() override;
- virtual void
- ThreadDestroyed ()
+ void
+ ThreadDestroyed() override
{
m_takedown_done = true;
}
- virtual void
- SetStopOthers (bool new_value);
+ void
+ SetStopOthers(bool new_value) override;
protected:
void ReportRegisterState (const char *message);
- virtual bool
- DoPlanExplainsStop (Event *event_ptr);
+ bool
+ DoPlanExplainsStop(Event *event_ptr) override;
virtual void
SetReturnValue();
@@ -184,10 +183,10 @@ protected:
lldb::addr_t m_stop_address; // This is the address we stopped at. Also set in DoTakedown;
private:
- ClangASTType m_return_type;
+ CompilerType m_return_type;
DISALLOW_COPY_AND_ASSIGN (ThreadPlanCallFunction);
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanCallFunction_h_
+#endif // liblldb_ThreadPlanCallFunction_h_
diff --git a/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h b/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h
index 83d78a5dca08..529057175287 100644
--- a/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h
+++ b/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h
@@ -38,7 +38,7 @@ public:
llvm::ArrayRef<ABI::CallArgument> args,
const EvaluateExpressionOptions &options);
- ~ThreadPlanCallFunctionUsingABI ();
+ ~ThreadPlanCallFunctionUsingABI() override;
void
GetDescription (Stream *s, lldb::DescriptionLevel level) override;
@@ -47,7 +47,6 @@ protected:
void
SetReturnValue () override;
-
private:
llvm::Type &m_return_type;
DISALLOW_COPY_AND_ASSIGN (ThreadPlanCallFunctionUsingABI);
@@ -55,4 +54,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ThreadPlanCallFunctionUsingABI_h_
+#endif // liblldb_ThreadPlanCallFunctionUsingABI_h_
diff --git a/include/lldb/Target/ThreadPlanCallUserExpression.h b/include/lldb/Target/ThreadPlanCallUserExpression.h
index e40762c928b5..bb261d9c96b4 100644
--- a/include/lldb/Target/ThreadPlanCallUserExpression.h
+++ b/include/lldb/Target/ThreadPlanCallUserExpression.h
@@ -30,22 +30,21 @@ public:
Address &function,
llvm::ArrayRef<lldb::addr_t> args,
const EvaluateExpressionOptions &options,
- lldb::ClangUserExpressionSP &user_expression_sp);
+ lldb::UserExpressionSP &user_expression_sp);
- virtual
- ~ThreadPlanCallUserExpression ();
+ ~ThreadPlanCallUserExpression() override;
- virtual void
- GetDescription (Stream *s, lldb::DescriptionLevel level);
+ void
+ GetDescription(Stream *s, lldb::DescriptionLevel level) override;
- virtual void
- WillPop ();
+ void
+ WillPop() override;
- virtual lldb::StopInfoSP
- GetRealStopInfo();
+ lldb::StopInfoSP
+ GetRealStopInfo() override;
- virtual bool
- MischiefManaged ();
+ bool
+ MischiefManaged() override;
void
TransferExpressionOwnership ()
@@ -53,19 +52,19 @@ public:
m_manage_materialization = true;
}
- virtual lldb::ClangExpressionVariableSP
- GetExpressionVariable ()
+ lldb::ExpressionVariableSP
+ GetExpressionVariable() override
{
return m_result_var_sp;
}
protected:
private:
- lldb::ClangUserExpressionSP m_user_expression_sp; // This is currently just used to ensure the
+ lldb::UserExpressionSP m_user_expression_sp; // This is currently just used to ensure the
// User expression the initiated this ThreadPlan
// lives as long as the thread plan does.
bool m_manage_materialization = false;
- lldb::ClangExpressionVariableSP m_result_var_sp; // If we are left to manage the materialization,
+ lldb::ExpressionVariableSP m_result_var_sp; // If we are left to manage the materialization,
// then stuff the result expression variable here.
DISALLOW_COPY_AND_ASSIGN (ThreadPlanCallUserExpression);
@@ -73,4 +72,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ThreadPlanCallUserExpression_h_
+#endif // liblldb_ThreadPlanCallUserExpression_h_
diff --git a/include/lldb/Target/ThreadPlanPython.h b/include/lldb/Target/ThreadPlanPython.h
index ffcee018a5fb..ab3fbbdf6fb5 100644
--- a/include/lldb/Target/ThreadPlanPython.h
+++ b/include/lldb/Target/ThreadPlanPython.h
@@ -13,6 +13,7 @@
// C Includes
// C++ Includes
#include <string>
+
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
@@ -37,45 +38,44 @@ class ThreadPlanPython : public ThreadPlan
{
public:
ThreadPlanPython (Thread &thread, const char *class_name);
- virtual ~ThreadPlanPython ();
+ ~ThreadPlanPython() override;
- virtual void
- GetDescription (Stream *s,
- lldb::DescriptionLevel level);
+ void
+ GetDescription(Stream *s,
+ lldb::DescriptionLevel level) override;
- virtual bool
- ValidatePlan (Stream *error);
+ bool
+ ValidatePlan(Stream *error) override;
- virtual bool
- ShouldStop (Event *event_ptr);
+ bool
+ ShouldStop(Event *event_ptr) override;
- virtual bool
- MischiefManaged ();
+ bool
+ MischiefManaged() override;
- virtual bool
- WillStop ();
+ bool
+ WillStop() override;
- virtual bool
- StopOthers ();
+ bool
+ StopOthers() override;
- virtual void
- DidPush ();
+ void
+ DidPush() override;
protected:
- virtual bool
- DoPlanExplainsStop (Event *event_ptr);
+ bool
+ DoPlanExplainsStop(Event *event_ptr) override;
- virtual lldb::StateType
- GetPlanRunState ();
+ lldb::StateType
+ GetPlanRunState() override;
private:
- std::string m_class_name;
- StructuredData::ObjectSP m_implementation_sp;
+ std::string m_class_name;
+ StructuredData::ObjectSP m_implementation_sp;
DISALLOW_COPY_AND_ASSIGN(ThreadPlanPython);
};
-
} // namespace lldb_private
-#endif // liblldb_ThreadPlan_Python_h_
+#endif // liblldb_ThreadPlan_Python_h_
diff --git a/include/lldb/Target/ThreadPlanRunToAddress.h b/include/lldb/Target/ThreadPlanRunToAddress.h
index d94820668017..a1b974605ffb 100644
--- a/include/lldb/Target/ThreadPlanRunToAddress.h
+++ b/include/lldb/Target/ThreadPlanRunToAddress.h
@@ -36,37 +36,35 @@ public:
const std::vector<lldb::addr_t> &addresses,
bool stop_others);
+ ~ThreadPlanRunToAddress() override;
- virtual
- ~ThreadPlanRunToAddress ();
+ void
+ GetDescription(Stream *s, lldb::DescriptionLevel level) override;
- virtual void
- GetDescription (Stream *s, lldb::DescriptionLevel level);
+ bool
+ ValidatePlan(Stream *error) override;
- virtual bool
- ValidatePlan (Stream *error);
+ bool
+ ShouldStop(Event *event_ptr) override;
- virtual bool
- ShouldStop (Event *event_ptr);
-
- virtual bool
- StopOthers ();
+ bool
+ StopOthers() override;
- virtual void
- SetStopOthers (bool new_value);
+ void
+ SetStopOthers(bool new_value) override;
- virtual lldb::StateType
- GetPlanRunState ();
+ lldb::StateType
+ GetPlanRunState() override;
- virtual bool
- WillStop ();
+ bool
+ WillStop() override;
- virtual bool
- MischiefManaged ();
+ bool
+ MischiefManaged() override;
protected:
- virtual bool
- DoPlanExplainsStop (Event *event_ptr);
+ bool
+ DoPlanExplainsStop(Event *event_ptr) override;
void SetInitialBreakpoints();
bool AtOurAddress();
@@ -77,9 +75,8 @@ private:
std::vector<lldb::break_id_t> m_break_ids; // This is the breakpoint we are using to stop us at m_address.
DISALLOW_COPY_AND_ASSIGN (ThreadPlanRunToAddress);
-
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanRunToAddress_h_
+#endif // liblldb_ThreadPlanRunToAddress_h_
diff --git a/include/lldb/Target/ThreadPlanShouldStopHere.h b/include/lldb/Target/ThreadPlanShouldStopHere.h
index 26e4a1ec4fe7..a52d9e42effd 100644
--- a/include/lldb/Target/ThreadPlanShouldStopHere.h
+++ b/include/lldb/Target/ThreadPlanShouldStopHere.h
@@ -74,9 +74,9 @@ public:
//------------------------------------------------------------------
ThreadPlanShouldStopHere (ThreadPlan *owner);
- ThreadPlanShouldStopHere (ThreadPlan *owner,
- const ThreadPlanShouldStopHereCallbacks *callbacks,
- void *baton = NULL);
+ ThreadPlanShouldStopHere(ThreadPlan *owner,
+ const ThreadPlanShouldStopHereCallbacks *callbacks,
+ void *baton = nullptr);
virtual
~ThreadPlanShouldStopHere();
@@ -139,23 +139,15 @@ protected:
// Implement this, and call it in the plan's constructor to set the default flags.
virtual void SetFlagsToDefault () = 0;
- //------------------------------------------------------------------
- // Classes that inherit from ThreadPlanShouldStopHere can see and modify these
- //------------------------------------------------------------------
ThreadPlanShouldStopHereCallbacks m_callbacks;
void * m_baton;
ThreadPlan *m_owner;
lldb_private::Flags m_flags;
private:
- //------------------------------------------------------------------
- // For ThreadPlanShouldStopHere only
- //------------------------------------------------------------------
-
DISALLOW_COPY_AND_ASSIGN (ThreadPlanShouldStopHere);
-
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanShouldStopHere_h_
+#endif // liblldb_ThreadPlanShouldStopHere_h_
diff --git a/include/lldb/Target/ThreadPlanStepInRange.h b/include/lldb/Target/ThreadPlanStepInRange.h
index 3a22e97e30d0..b31d35508271 100644
--- a/include/lldb/Target/ThreadPlanStepInRange.h
+++ b/include/lldb/Target/ThreadPlanStepInRange.h
@@ -42,14 +42,13 @@ public:
LazyBool step_in_avoids_code_without_debug_info,
LazyBool step_out_avoids_code_without_debug_info);
- virtual
- ~ThreadPlanStepInRange ();
+ ~ThreadPlanStepInRange() override;
- virtual void
- GetDescription (Stream *s, lldb::DescriptionLevel level);
+ void
+ GetDescription(Stream *s, lldb::DescriptionLevel level) override;
- virtual bool
- ShouldStop (Event *event_ptr);
+ bool
+ ShouldStop(Event *event_ptr) override;
void SetAvoidRegexp(const char *name);
@@ -62,19 +61,19 @@ public:
SetDefaultFlagValue (uint32_t new_value);
bool
- IsVirtualStep();
+ IsVirtualStep() override;
protected:
static bool
DefaultShouldStopHereCallback (ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, void *baton);
- virtual bool DoWillResume (lldb::StateType resume_state, bool current_plan);
+ bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
- virtual bool
- DoPlanExplainsStop (Event *event_ptr);
+ bool
+ DoPlanExplainsStop(Event *event_ptr) override;
- virtual void
- SetFlagsToDefault ()
+ void
+ SetFlagsToDefault() override
{
GetFlags().Set(ThreadPlanStepInRange::s_default_flag_values);
}
@@ -119,9 +118,8 @@ private:
bool m_virtual_step; // true if we've just done a "virtual step", i.e. just moved the inline stack depth.
ConstString m_step_into_target;
DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepInRange);
-
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanStepInRange_h_
+#endif // liblldb_ThreadPlanStepInRange_h_
diff --git a/include/lldb/Target/ThreadPlanStepInstruction.h b/include/lldb/Target/ThreadPlanStepInstruction.h
index 86069ffd9eb5..da83ecadcae6 100644
--- a/include/lldb/Target/ThreadPlanStepInstruction.h
+++ b/include/lldb/Target/ThreadPlanStepInstruction.h
@@ -23,19 +23,19 @@ namespace lldb_private {
class ThreadPlanStepInstruction : public ThreadPlan
{
public:
- virtual ~ThreadPlanStepInstruction ();
+ ~ThreadPlanStepInstruction() override;
- virtual void GetDescription (Stream *s, lldb::DescriptionLevel level);
- virtual bool ValidatePlan (Stream *error);
- virtual bool ShouldStop (Event *event_ptr);
- virtual bool StopOthers ();
- virtual lldb::StateType GetPlanRunState ();
- virtual bool WillStop ();
- virtual bool MischiefManaged ();
- virtual bool IsPlanStale ();
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
+ bool ValidatePlan(Stream *error) override;
+ bool ShouldStop(Event *event_ptr) override;
+ bool StopOthers() override;
+ lldb::StateType GetPlanRunState() override;
+ bool WillStop() override;
+ bool MischiefManaged() override;
+ bool IsPlanStale() override;
protected:
- virtual bool DoPlanExplainsStop (Event *event_ptr);
+ bool DoPlanExplainsStop(Event *event_ptr) override;
ThreadPlanStepInstruction (Thread &thread,
bool step_over,
@@ -57,10 +57,8 @@ private:
StackID m_parent_frame_id;
DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepInstruction);
-
};
-
} // namespace lldb_private
-#endif // liblldb_ThreadPlanStepInstruction_h_
+#endif // liblldb_ThreadPlanStepInstruction_h_
diff --git a/include/lldb/Target/ThreadPlanStepOut.h b/include/lldb/Target/ThreadPlanStepOut.h
index 8c140dc9d95d..ac5696357e9b 100644
--- a/include/lldb/Target/ThreadPlanStepOut.h
+++ b/include/lldb/Target/ThreadPlanStepOut.h
@@ -33,32 +33,32 @@ public:
uint32_t frame_idx,
LazyBool step_out_avoids_code_without_debug_info);
- virtual ~ThreadPlanStepOut ();
+ ~ThreadPlanStepOut() override;
- virtual void GetDescription (Stream *s, lldb::DescriptionLevel level);
- virtual bool ValidatePlan (Stream *error);
- virtual bool ShouldStop (Event *event_ptr);
- virtual bool StopOthers ();
- virtual lldb::StateType GetPlanRunState ();
- virtual bool WillStop ();
- virtual bool MischiefManaged ();
- virtual void DidPush();
- virtual bool IsPlanStale();
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
+ bool ValidatePlan(Stream *error) override;
+ bool ShouldStop(Event *event_ptr) override;
+ bool StopOthers() override;
+ lldb::StateType GetPlanRunState() override;
+ bool WillStop() override;
+ bool MischiefManaged() override;
+ void DidPush() override;
+ bool IsPlanStale() override;
- virtual lldb::ValueObjectSP GetReturnValueObject()
+ lldb::ValueObjectSP GetReturnValueObject() override
{
return m_return_valobj_sp;
}
protected:
- virtual void
- SetFlagsToDefault ()
+ void
+ SetFlagsToDefault() override
{
GetFlags().Set(ThreadPlanStepOut::s_default_flag_values);
}
- virtual bool DoPlanExplainsStop (Event *event_ptr);
- virtual bool DoWillResume (lldb::StateType resume_state, bool current_plan);
+ bool DoPlanExplainsStop (Event *event_ptr) override;
+ bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
bool QueueInlinedStepPlan (bool queue_now);
private:
@@ -95,9 +95,8 @@ private:
CalculateReturnValue();
DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepOut);
-
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanStepOut_h_
+#endif // liblldb_ThreadPlanStepOut_h_
diff --git a/include/lldb/Target/ThreadPlanStepOverBreakpoint.h b/include/lldb/Target/ThreadPlanStepOverBreakpoint.h
index a4806056afb9..944f0e0455ee 100644
--- a/include/lldb/Target/ThreadPlanStepOverBreakpoint.h
+++ b/include/lldb/Target/ThreadPlanStepOverBreakpoint.h
@@ -22,29 +22,31 @@ namespace lldb_private {
class ThreadPlanStepOverBreakpoint : public ThreadPlan
{
public:
- virtual ~ThreadPlanStepOverBreakpoint ();
-
ThreadPlanStepOverBreakpoint (Thread &thread);
- virtual void GetDescription (Stream *s, lldb::DescriptionLevel level);
- virtual bool ValidatePlan (Stream *error);
- virtual bool ShouldStop (Event *event_ptr);
- virtual bool StopOthers ();
- virtual lldb::StateType GetPlanRunState ();
- virtual bool WillStop ();
- virtual bool MischiefManaged ();
- virtual void ThreadDestroyed ();
- void SetAutoContinue (bool do_it);
- virtual bool ShouldAutoContinue(Event *event_ptr);
- virtual bool IsPlanStale();
+
+ ~ThreadPlanStepOverBreakpoint() override;
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
+ bool ValidatePlan(Stream *error) override;
+ bool ShouldStop(Event *event_ptr) override;
+ bool StopOthers() override;
+ lldb::StateType GetPlanRunState() override;
+ bool WillStop() override;
+ bool MischiefManaged() override;
+ void ThreadDestroyed() override;
+ void SetAutoContinue(bool do_it);
+ bool ShouldAutoContinue(Event *event_ptr) override;
+ bool IsPlanStale() override;
lldb::addr_t
GetBreakpointLoadAddress() const
{
return m_breakpoint_addr;
}
+
protected:
- virtual bool DoPlanExplainsStop (Event *event_ptr);
- virtual bool DoWillResume (lldb::StateType resume_state, bool current_plan);
+ bool DoPlanExplainsStop(Event *event_ptr) override;
+ bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
void ReenableBreakpointSite ();
private:
@@ -55,9 +57,8 @@ private:
bool m_reenabled_breakpoint_site;
DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepOverBreakpoint);
-
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanStepOverBreakpoint_h_
+#endif // liblldb_ThreadPlanStepOverBreakpoint_h_
diff --git a/include/lldb/Target/ThreadPlanStepOverRange.h b/include/lldb/Target/ThreadPlanStepOverRange.h
index d47c6c9429d5..7defaef7d07d 100644
--- a/include/lldb/Target/ThreadPlanStepOverRange.h
+++ b/include/lldb/Target/ThreadPlanStepOverRange.h
@@ -25,32 +25,28 @@ class ThreadPlanStepOverRange : public ThreadPlanStepRange,
ThreadPlanShouldStopHere
{
public:
-
ThreadPlanStepOverRange (Thread &thread,
const AddressRange &range,
const SymbolContext &addr_context,
lldb::RunMode stop_others,
LazyBool step_out_avoids_no_debug);
- virtual ~ThreadPlanStepOverRange ();
+ ~ThreadPlanStepOverRange() override;
- virtual void GetDescription (Stream *s, lldb::DescriptionLevel level);
- virtual bool ShouldStop (Event *event_ptr);
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
+ bool ShouldStop(Event *event_ptr) override;
protected:
- virtual bool DoPlanExplainsStop (Event *event_ptr);
- virtual bool DoWillResume (lldb::StateType resume_state, bool current_plan);
+ bool DoPlanExplainsStop(Event *event_ptr) override;
+ bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
- virtual void
- SetFlagsToDefault ()
+ void
+ SetFlagsToDefault() override
{
GetFlags().Set(ThreadPlanStepOverRange::s_default_flag_values);
}
-
-
-
-private:
+private:
static uint32_t s_default_flag_values;
void SetupAvoidNoDebug(LazyBool step_out_avoids_code_without_debug_info);
@@ -59,9 +55,8 @@ private:
bool m_first_resume;
DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepOverRange);
-
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanStepOverRange_h_
+#endif // liblldb_ThreadPlanStepOverRange_h_
diff --git a/include/lldb/Target/ThreadPlanStepRange.h b/include/lldb/Target/ThreadPlanStepRange.h
index 43c55c2aa411..8f6685f82aab 100644
--- a/include/lldb/Target/ThreadPlanStepRange.h
+++ b/include/lldb/Target/ThreadPlanStepRange.h
@@ -33,24 +33,22 @@ public:
lldb::RunMode stop_others,
bool given_ranges_only = false);
- virtual ~ThreadPlanStepRange ();
-
- virtual void GetDescription (Stream *s, lldb::DescriptionLevel level) = 0;
- virtual bool ValidatePlan (Stream *error);
- virtual bool ShouldStop (Event *event_ptr) = 0;
- virtual Vote ShouldReportStop (Event *event_ptr);
- virtual bool StopOthers ();
- virtual lldb::StateType GetPlanRunState ();
- virtual bool WillStop ();
- virtual bool MischiefManaged ();
- virtual void DidPush ();
- virtual bool IsPlanStale ();
+ ~ThreadPlanStepRange() override;
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override = 0;
+ bool ValidatePlan(Stream *error) override;
+ bool ShouldStop(Event *event_ptr) override = 0;
+ Vote ShouldReportStop(Event *event_ptr) override;
+ bool StopOthers() override;
+ lldb::StateType GetPlanRunState() override;
+ bool WillStop() override;
+ bool MischiefManaged() override;
+ void DidPush() override;
+ bool IsPlanStale() override;
void AddRange(const AddressRange &new_range);
protected:
-
bool InRange();
lldb::FrameComparison CompareCurrentFrameToStartFrame();
bool InSymbol();
@@ -88,10 +86,10 @@ protected:
private:
std::vector<lldb::DisassemblerSP> m_instruction_ranges;
- DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepRange);
+ DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepRange);
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanStepRange_h_
+#endif // liblldb_ThreadPlanStepRange_h_
diff --git a/include/lldb/Target/ThreadPlanStepThrough.h b/include/lldb/Target/ThreadPlanStepThrough.h
index 16979663eb1b..43af37c84a06 100644
--- a/include/lldb/Target/ThreadPlanStepThrough.h
+++ b/include/lldb/Target/ThreadPlanStepThrough.h
@@ -22,20 +22,20 @@ namespace lldb_private {
class ThreadPlanStepThrough : public ThreadPlan
{
public:
- virtual ~ThreadPlanStepThrough ();
+ ~ThreadPlanStepThrough() override;
- virtual void GetDescription (Stream *s, lldb::DescriptionLevel level);
- virtual bool ValidatePlan (Stream *error);
- virtual bool ShouldStop (Event *event_ptr);
- virtual bool StopOthers ();
- virtual lldb::StateType GetPlanRunState ();
- virtual bool WillStop ();
- virtual bool MischiefManaged ();
- virtual void DidPush();
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
+ bool ValidatePlan(Stream *error) override;
+ bool ShouldStop(Event *event_ptr) override;
+ bool StopOthers() override;
+ lldb::StateType GetPlanRunState() override;
+ bool WillStop() override;
+ bool MischiefManaged() override;
+ void DidPush() override;
protected:
- virtual bool DoPlanExplainsStop (Event *event_ptr);
- virtual bool DoWillResume (lldb::StateType resume_state, bool current_plan);
+ bool DoPlanExplainsStop(Event *event_ptr) override;
+ bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
ThreadPlanStepThrough (Thread &thread,
StackID &return_stack_id,
@@ -49,6 +49,7 @@ protected:
private:
friend lldb::ThreadPlanSP
+
Thread::QueueThreadPlanForStepThrough (StackID &return_stack_id,
bool abort_other_plans,
bool stop_others);
@@ -63,9 +64,8 @@ private:
bool m_stop_others;
DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepThrough);
-
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanStepThrough_h_
+#endif // liblldb_ThreadPlanStepThrough_h_
diff --git a/include/lldb/Target/ThreadPlanStepUntil.h b/include/lldb/Target/ThreadPlanStepUntil.h
index 5aa3876df53c..3c1bd8c6665d 100644
--- a/include/lldb/Target/ThreadPlanStepUntil.h
+++ b/include/lldb/Target/ThreadPlanStepUntil.h
@@ -19,33 +19,32 @@
namespace lldb_private {
-
class ThreadPlanStepUntil : public ThreadPlan
{
public:
- virtual ~ThreadPlanStepUntil ();
+ ~ThreadPlanStepUntil() override;
- virtual void GetDescription (Stream *s, lldb::DescriptionLevel level);
- virtual bool ValidatePlan (Stream *error);
- virtual bool ShouldStop (Event *event_ptr);
- virtual bool StopOthers ();
- virtual lldb::StateType GetPlanRunState ();
- virtual bool WillStop ();
- virtual bool MischiefManaged ();
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
+ bool ValidatePlan(Stream *error) override;
+ bool ShouldStop(Event *event_ptr) override;
+ bool StopOthers() override;
+ lldb::StateType GetPlanRunState() override;
+ bool WillStop() override;
+ bool MischiefManaged() override;
protected:
- virtual bool DoWillResume (lldb::StateType resume_state, bool current_plan);
- virtual bool DoPlanExplainsStop (Event *event_ptr);
+ bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
+ bool DoPlanExplainsStop(Event *event_ptr) override;
ThreadPlanStepUntil (Thread &thread,
lldb::addr_t *address_list,
size_t num_addresses,
bool stop_others,
uint32_t frame_idx = 0);
- void AnalyzeStop(void);
-private:
+ void AnalyzeStop();
+private:
StackID m_stack_id;
lldb::addr_t m_step_from_insn;
lldb::break_id_t m_return_bp_id;
@@ -72,9 +71,8 @@ private:
// from step in.
DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepUntil);
-
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanStepUntil_h_
+#endif // liblldb_ThreadPlanStepUntil_h_
diff --git a/include/lldb/Target/ThreadPlanTracer.h b/include/lldb/Target/ThreadPlanTracer.h
index 4eb0c783e57d..6d064133fa91 100644
--- a/include/lldb/Target/ThreadPlanTracer.h
+++ b/include/lldb/Target/ThreadPlanTracer.h
@@ -26,7 +26,6 @@ class ThreadPlanTracer
friend class ThreadPlan;
public:
-
typedef enum ThreadPlanTracerStyle
{
eLocation = 0,
@@ -34,21 +33,18 @@ public:
eCheckFrames,
ePython
} ThreadPlanTracerStyle;
+
ThreadPlanTracer (Thread &thread, lldb::StreamSP &stream_sp);
ThreadPlanTracer (Thread &thread);
- virtual ~ThreadPlanTracer()
- {
- }
+ virtual ~ThreadPlanTracer() = default;
virtual void TracingStarted ()
{
-
}
virtual void TracingEnded ()
{
-
}
bool
@@ -90,8 +86,6 @@ protected:
Stream *
GetLogStream ();
-
-
virtual void Log();
private:
@@ -108,12 +102,13 @@ class ThreadPlanAssemblyTracer : public ThreadPlanTracer
public:
ThreadPlanAssemblyTracer (Thread &thread, lldb::StreamSP &stream_sp);
ThreadPlanAssemblyTracer (Thread &thread);
- virtual ~ThreadPlanAssemblyTracer ();
- virtual void TracingStarted ();
- virtual void TracingEnded ();
- virtual void Log();
+ ~ThreadPlanAssemblyTracer() override;
+
+ void TracingStarted() override;
+ void TracingEnded() override;
+ void Log() override;
+
private:
-
Disassembler *
GetDisassembler ();
@@ -128,4 +123,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ThreadPlanTracer_h_
+#endif // liblldb_ThreadPlanTracer_h_
diff --git a/include/lldb/Target/ThreadSpec.h b/include/lldb/Target/ThreadSpec.h
index e0d30934f373..95f509a5cb9d 100644
--- a/include/lldb/Target/ThreadSpec.h
+++ b/include/lldb/Target/ThreadSpec.h
@@ -1,4 +1,4 @@
-//===-- ThreadSpec.h ------------------------------------------------*- C++ -*-===//
+//===-- ThreadSpec.h --------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,9 +10,12 @@
#ifndef liblldb_ThreadSpec_h_
#define liblldb_ThreadSpec_h_
-#include <map>
+// C Includes
+// C++ Includes
#include <string>
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -110,7 +113,7 @@ public:
{
if (m_name.empty())
return true;
- else if (name == NULL)
+ else if (name == nullptr)
return false;
else
return m_name == name;
@@ -124,7 +127,7 @@ public:
{
if (m_queue_name.empty())
return true;
- else if (queue_name == NULL)
+ else if (queue_name == nullptr)
return false;
else
return m_queue_name == queue_name;
@@ -142,7 +145,6 @@ public:
void
GetDescription (Stream *s, lldb::DescriptionLevel level) const;
-protected:
private:
uint32_t m_index;
lldb::tid_t m_tid;
@@ -152,4 +154,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ThreadSpec_h_
+#endif // liblldb_ThreadSpec_h_
diff --git a/include/lldb/Target/UnixSignals.h b/include/lldb/Target/UnixSignals.h
index 76955deabc78..7a02f557067b 100644
--- a/include/lldb/Target/UnixSignals.h
+++ b/include/lldb/Target/UnixSignals.h
@@ -98,6 +98,9 @@ public:
int32_t
GetSignalAtIndex(int32_t index) const;
+ ConstString
+ GetShortName(ConstString name) const;
+
// We assume that the elements of this object are constant once it is constructed,
// since a process should never need to add or remove symbols as it runs. So don't
// call these functions anywhere but the constructor of your subclass of UnixSignals or in
@@ -106,11 +109,11 @@ public:
void
AddSignal (int signo,
const char *name,
- const char *short_name,
bool default_suppress,
bool default_stop,
bool default_notify,
- const char *description);
+ const char *description,
+ const char *alias = nullptr);
void
RemoveSignal (int signo);
@@ -123,18 +126,18 @@ protected:
struct Signal
{
ConstString m_name;
- ConstString m_short_name;
+ ConstString m_alias;
std::string m_description;
bool m_suppress:1,
m_stop:1,
m_notify:1;
Signal (const char *name,
- const char *short_name,
bool default_suppress,
bool default_stop,
bool default_notify,
- const char *description);
+ const char *description,
+ const char *alias);
~Signal () {}
};
diff --git a/include/lldb/Target/UnwindAssembly.h b/include/lldb/Target/UnwindAssembly.h
index 963949cf07d5..6f53e7e710f5 100644
--- a/include/lldb/Target/UnwindAssembly.h
+++ b/include/lldb/Target/UnwindAssembly.h
@@ -24,8 +24,7 @@ public:
static lldb::UnwindAssemblySP
FindPlugin (const ArchSpec &arch);
- virtual
- ~UnwindAssembly();
+ ~UnwindAssembly() override;
virtual bool
GetNonCallSiteUnwindPlanFromAssembly (AddressRange& func,
@@ -59,6 +58,4 @@ private:
} // namespace lldb_private
-#endif //utility_UnwindAssembly_h_
-
-
+#endif // utility_UnwindAssembly_h_
diff --git a/include/lldb/Utility/AnsiTerminal.h b/include/lldb/Utility/AnsiTerminal.h
index 9a5117ae74ea..a43dd1ba4325 100644
--- a/include/lldb/Utility/AnsiTerminal.h
+++ b/include/lldb/Utility/AnsiTerminal.h
@@ -41,8 +41,13 @@
#define ANSI_CTRL_CONCEAL 8
#define ANSI_CTRL_CROSSED_OUT 9
-#define ANSI_ESC_START "\033["
-#define ANSI_ESC_END "m"
+#define ANSI_ESC_START "\033["
+#define ANSI_ESC_END "m"
+
+#define ANSI_STR(s) #s
+#define ANSI_DEF_STR(s) ANSI_STR(s)
+
+#define ANSI_ESCAPE1(s) ANSI_ESC_START ANSI_DEF_STR(s) ANSI_ESC_END
#define ANSI_1_CTRL(ctrl1) "\033["##ctrl1 ANSI_ESC_END
#define ANSI_2_CTRL(ctrl1,ctrl2) "\033["##ctrl1";"##ctrl2 ANSI_ESC_END
diff --git a/include/lldb/Utility/Either.h b/include/lldb/Utility/Either.h
new file mode 100644
index 000000000000..ae647363512d
--- /dev/null
+++ b/include/lldb/Utility/Either.h
@@ -0,0 +1,154 @@
+//===-- Either.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_Either_h_
+#define liblldb_Either_h_
+
+#include "llvm/ADT/Optional.h"
+
+#include <functional>
+
+namespace lldb_utility {
+ template <typename T1, typename T2>
+ class Either
+ {
+ private:
+ enum class Selected
+ {
+ One, Two
+ };
+
+ Selected m_selected;
+ union
+ {
+ T1 m_t1;
+ T2 m_t2;
+ };
+
+ public:
+ Either (const T1& t1)
+ {
+ m_t1 = t1;
+ m_selected = Selected::One;
+ }
+
+ Either (const T2& t2)
+ {
+ m_t2 = t2;
+ m_selected = Selected::Two;
+ }
+
+ Either (const Either<T1,T2>& rhs)
+ {
+ switch (rhs.m_selected)
+ {
+ case Selected::One:
+ m_t1 = rhs.GetAs<T1>().getValue();
+ m_selected = Selected::One;
+ break;
+ case Selected::Two:
+ m_t2 = rhs.GetAs<T2>().getValue();
+ m_selected = Selected::Two;
+ break;
+ }
+ }
+
+ template <class X, typename std::enable_if<std::is_same<T1,X>::value>::type * = nullptr>
+ llvm::Optional<T1>
+ GetAs() const
+ {
+ switch (m_selected)
+ {
+ case Selected::One:
+ return m_t1;
+ default:
+ return llvm::Optional<T1>();
+ }
+ }
+
+ template <class X, typename std::enable_if<std::is_same<T2,X>::value>::type * = nullptr>
+ llvm::Optional<T2>
+ GetAs() const
+ {
+ switch (m_selected)
+ {
+ case Selected::Two:
+ return m_t2;
+ default:
+ return llvm::Optional<T2>();
+ }
+ }
+
+ template <class ResultType>
+ ResultType
+ Apply (std::function<ResultType(T1)> if_T1,
+ std::function<ResultType(T2)> if_T2) const
+ {
+ switch (m_selected)
+ {
+ case Selected::One:
+ return if_T1(m_t1);
+ case Selected::Two:
+ return if_T2(m_t2);
+ }
+ }
+
+ bool
+ operator == (const Either<T1,T2>& rhs)
+ {
+ return (GetAs<T1>() == rhs.GetAs<T1>()) && (GetAs<T2>() == rhs.GetAs<T2>());
+ }
+
+ explicit
+ operator bool ()
+ {
+ switch (m_selected)
+ {
+ case Selected::One:
+ return (bool)m_t1;
+ case Selected::Two:
+ return (bool)m_t2;
+ }
+ }
+
+ Either<T1,T2>&
+ operator = (const Either<T1,T2>& rhs)
+ {
+ switch (rhs.m_selected)
+ {
+ case Selected::One:
+ m_t1 = rhs.GetAs<T1>().getValue();
+ m_selected = Selected::One;
+ break;
+ case Selected::Two:
+ m_t2 = rhs.GetAs<T2>().getValue();
+ m_selected = Selected::Two;
+ break;
+ }
+ return *this;
+ }
+
+ ~Either ()
+ {
+ switch (m_selected)
+ {
+ case Selected::One:
+ m_t1.T1::~T1();
+ break;
+ case Selected::Two:
+ m_t2.T2::~T2();
+ break;
+ }
+ }
+ };
+
+} // namespace lldb_utility
+
+#endif // #ifndef liblldb_Either_h_
+
diff --git a/include/lldb/Utility/Iterable.h b/include/lldb/Utility/Iterable.h
index 17c8cf4d2319..2317225d126f 100644
--- a/include/lldb/Utility/Iterable.h
+++ b/include/lldb/Utility/Iterable.h
@@ -10,6 +10,12 @@
#ifndef liblldb_Iterable_h_
#define liblldb_Iterable_h_
+// C Includes
+// C++ Includes
+#include <utility>
+
+// Other libraries and framework includes
+// Project includes
#include "lldb/Host/Mutex.h"
namespace lldb_private
@@ -34,9 +40,7 @@ template <typename C, typename E, E (*A)(typename C::const_iterator &)> class Ad
{
public:
typedef typename C::const_iterator BackingIterator;
-private:
- BackingIterator m_iter;
-public:
+
// Wrapping constructor
AdaptedConstIterator (BackingIterator backing_iterator) :
m_iter(backing_iterator)
@@ -63,7 +67,7 @@ public:
}
// Destructible
- ~AdaptedConstIterator () { }
+ ~AdaptedConstIterator() = default;
// Comparable
bool operator== (const AdaptedConstIterator &rhs)
@@ -160,6 +164,9 @@ public:
template <typename C1, typename E1, E1 (*A1)(typename C1::const_iterator &)>
friend void swap(AdaptedConstIterator<C1, E1, A1> &, AdaptedConstIterator<C1, E1, A1> &);
+
+private:
+ BackingIterator m_iter;
};
template <typename C, typename E, E (*A)(typename C::const_iterator &)>
@@ -203,8 +210,6 @@ public:
template <typename C, typename E, E (*A)(typename C::const_iterator &)> class LockingAdaptedIterable : public AdaptedIterable<C, E, A>
{
-private:
- Mutex *m_mutex = nullptr;
public:
LockingAdaptedIterable (C &container, Mutex &mutex) :
AdaptedIterable<C,E,A>(container),
@@ -217,7 +222,7 @@ public:
AdaptedIterable<C,E,A>(rhs),
m_mutex(rhs.m_mutex)
{
- rhs.m_mutex = NULL;
+ rhs.m_mutex = nullptr;
}
~LockingAdaptedIterable ()
@@ -227,9 +232,11 @@ public:
}
private:
+ Mutex *m_mutex = nullptr;
+
DISALLOW_COPY_AND_ASSIGN(LockingAdaptedIterable);
};
-}
+} // namespace lldb_private
-#endif
+#endif // liblldb_Iterable_h_
diff --git a/include/lldb/Utility/JSON.h b/include/lldb/Utility/JSON.h
index da5e26dbda28..e61c5ee85017 100644
--- a/include/lldb/Utility/JSON.h
+++ b/include/lldb/Utility/JSON.h
@@ -71,8 +71,8 @@ namespace lldb_private {
JSONString&
operator = (const JSONString& s) = delete;
- virtual void
- Write (Stream& s);
+ void
+ Write(Stream& s) override;
typedef std::shared_ptr<JSONString> SP;
@@ -84,8 +84,7 @@ namespace lldb_private {
return V->GetKind() == JSONValue::Kind::String;
}
- virtual
- ~JSONString () = default;
+ ~JSONString() override = default;
private:
@@ -98,43 +97,79 @@ namespace lldb_private {
class JSONNumber : public JSONValue
{
public:
- JSONNumber ();
- explicit JSONNumber (uint64_t i);
- explicit JSONNumber (double d);
+ typedef std::shared_ptr<JSONNumber> SP;
+
+ // We cretae a constructor for all integer and floating point type with using templates and
+ // SFINAE to avoid having ambiguous overloads because of the implicit type promotion. If we
+ // would have constructors only with int64_t, uint64_t and double types then constructing a
+ // JSONNumber from an int32_t (or any other similar type) would fail to compile.
+
+ template <typename T,
+ typename std::enable_if<std::is_integral<T>::value &&
+ std::is_unsigned<T>::value>::type* = nullptr>
+ explicit JSONNumber (T u) :
+ JSONValue(JSONValue::Kind::Number),
+ m_data_type(DataType::Unsigned)
+ {
+ m_data.m_unsigned = u;
+ }
+
+ template <typename T,
+ typename std::enable_if<std::is_integral<T>::value &&
+ std::is_signed<T>::value>::type* = nullptr>
+ explicit JSONNumber (T s) :
+ JSONValue(JSONValue::Kind::Number),
+ m_data_type(DataType::Signed)
+ {
+ m_data.m_signed = s;
+ }
+
+ template <typename T,
+ typename std::enable_if<std::is_floating_point<T>::value>::type* = nullptr>
+ explicit JSONNumber (T d) :
+ JSONValue(JSONValue::Kind::Number),
+ m_data_type(DataType::Double)
+ {
+ m_data.m_double = d;
+ }
+
+ ~JSONNumber() override = default;
JSONNumber (const JSONNumber& s) = delete;
JSONNumber&
operator = (const JSONNumber& s) = delete;
- virtual void
- Write (Stream& s);
-
- typedef std::shared_ptr<JSONNumber> SP;
+ void
+ Write(Stream& s) override;
uint64_t
- GetData () { return m_data; }
+ GetAsUnsigned() const;
+
+ int64_t
+ GetAsSigned() const;
double
- GetAsDouble()
- {
- if (m_is_integer)
- return (double)m_data;
- else
- return m_double;
- }
+ GetAsDouble() const;
static bool classof(const JSONValue *V)
{
return V->GetKind() == JSONValue::Kind::Number;
}
-
- virtual
- ~JSONNumber () = default;
-
+
private:
- bool m_is_integer;
- uint64_t m_data;
- double m_double;
+ enum class DataType : uint8_t
+ {
+ Unsigned,
+ Signed,
+ Double
+ } m_data_type;
+
+ union
+ {
+ uint64_t m_unsigned;
+ int64_t m_signed;
+ double m_double;
+ } m_data;
};
class JSONTrue : public JSONValue
@@ -146,8 +181,8 @@ namespace lldb_private {
JSONTrue&
operator = (const JSONTrue& s) = delete;
- virtual void
- Write (Stream& s);
+ void
+ Write(Stream& s) override;
typedef std::shared_ptr<JSONTrue> SP;
@@ -156,8 +191,7 @@ namespace lldb_private {
return V->GetKind() == JSONValue::Kind::True;
}
- virtual
- ~JSONTrue () = default;
+ ~JSONTrue() override = default;
};
class JSONFalse : public JSONValue
@@ -169,8 +203,8 @@ namespace lldb_private {
JSONFalse&
operator = (const JSONFalse& s) = delete;
- virtual void
- Write (Stream& s);
+ void
+ Write(Stream& s) override;
typedef std::shared_ptr<JSONFalse> SP;
@@ -179,8 +213,7 @@ namespace lldb_private {
return V->GetKind() == JSONValue::Kind::False;
}
- virtual
- ~JSONFalse () = default;
+ ~JSONFalse() override = default;
};
class JSONNull : public JSONValue
@@ -192,8 +225,8 @@ namespace lldb_private {
JSONNull&
operator = (const JSONNull& s) = delete;
- virtual void
- Write (Stream& s);
+ void
+ Write(Stream& s) override;
typedef std::shared_ptr<JSONNull> SP;
@@ -202,8 +235,7 @@ namespace lldb_private {
return V->GetKind() == JSONValue::Kind::Null;
}
- virtual
- ~JSONNull () = default;
+ ~JSONNull() override = default;
};
class JSONObject : public JSONValue
@@ -215,8 +247,8 @@ namespace lldb_private {
JSONObject&
operator = (const JSONObject& s) = delete;
- virtual void
- Write (Stream& s);
+ void
+ Write(Stream& s) override;
typedef std::shared_ptr<JSONObject> SP;
@@ -232,8 +264,7 @@ namespace lldb_private {
JSONValue::SP
GetObject (const std::string& key);
- virtual
- ~JSONObject () = default;
+ ~JSONObject() override = default;
private:
typedef std::map<std::string, JSONValue::SP> Map;
@@ -250,8 +281,8 @@ namespace lldb_private {
JSONArray&
operator = (const JSONArray& s) = delete;
- virtual void
- Write (Stream& s);
+ void
+ Write(Stream& s) override;
typedef std::shared_ptr<JSONArray> SP;
@@ -280,13 +311,11 @@ namespace lldb_private {
Size
GetNumElements ();
- virtual
- ~JSONArray () = default;
+ ~JSONArray() override = default;
Vector m_elements;
};
-
class JSONParser : public StringExtractor
{
public:
@@ -327,6 +356,6 @@ namespace lldb_private {
JSONValue::SP
ParseJSONArray ();
};
-}
+} // namespace lldb_private
-#endif // utility_ProcessStructReader_h_
+#endif // utility_JSON_h_
diff --git a/include/lldb/Utility/ProcessStructReader.h b/include/lldb/Utility/ProcessStructReader.h
index d053b702462e..80f90feb87ab 100644
--- a/include/lldb/Utility/ProcessStructReader.h
+++ b/include/lldb/Utility/ProcessStructReader.h
@@ -16,7 +16,7 @@
#include "lldb/Core/ConstString.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Error.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/Process.h"
#include <initializer_list>
@@ -29,7 +29,7 @@ namespace lldb_private {
protected:
struct FieldImpl
{
- ClangASTType type;
+ CompilerType type;
size_t offset;
size_t size;
};
@@ -40,7 +40,7 @@ namespace lldb_private {
size_t m_addr_byte_size;
public:
- ProcessStructReader (Process *process, lldb::addr_t base_addr, ClangASTType struct_type)
+ ProcessStructReader (Process *process, lldb::addr_t base_addr, CompilerType struct_type)
{
if (!process)
return;
@@ -55,7 +55,7 @@ namespace lldb_private {
uint64_t bit_offset;
uint32_t bitfield_bit_size;
bool is_bitfield;
- ClangASTType field_type = struct_type.GetFieldAtIndex(idx,name,&bit_offset,&bitfield_bit_size,&is_bitfield);
+ CompilerType field_type = struct_type.GetFieldAtIndex(idx,name,&bit_offset,&bitfield_bit_size,&is_bitfield);
// no support for bitfields in here (yet)
if (is_bitfield)
return;
diff --git a/include/lldb/Utility/PseudoTerminal.h b/include/lldb/Utility/PseudoTerminal.h
index 595b2fc19bfd..d73253497746 100644
--- a/include/lldb/Utility/PseudoTerminal.h
+++ b/include/lldb/Utility/PseudoTerminal.h
@@ -260,7 +260,7 @@ private:
};
-} // namespace lldb
+} // namespace lldb_utility
#endif // #if defined(__cplusplus)
#endif // #ifndef liblldb_PseudoTerminal_h_
diff --git a/include/lldb/Utility/PythonPointer.h b/include/lldb/Utility/PythonPointer.h
deleted file mode 100644
index fe90670fd2e1..000000000000
--- a/include/lldb/Utility/PythonPointer.h
+++ /dev/null
@@ -1,73 +0,0 @@
-//===---------------------PythonPointer.h ------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef utility_PythonPointer_h_
-#define utility_PythonPointer_h_
-
-#include <algorithm>
-
-#include "lldb/lldb-python.h"
-
-namespace lldb_private {
-
-template<class T>
-class PythonPointer
-{
-public:
- typedef PyObject* element_type;
-private:
- element_type* ptr_;
- bool my_ref;
-public:
-
- PythonPointer(element_type p, bool steal_ref = false) :
- ptr_(p),
- my_ref(!steal_ref)
- {
- if (my_ref)
- Py_INCREF(ptr_);
- }
-
- PythonPointer(const PythonPointer& r, bool steal_ref = false) :
- ptr_(r.ptr_),
- my_ref(!steal_ref)
- {
- if (my_ref)
- Py_INCREF(ptr_);
- }
-
- ~PythonPointer()
- {
- if (my_ref)
- Py_XDECREF(ptr_);
- }
-
- PythonPointer
- StealReference()
- {
- return PythonPointer(ptr_,true);
- }
-
- PythonPointer
- DuplicateReference()
- {
- return PythonPointer(ptr_, false);
- }
-
- element_type get() const {return ptr_;}
-
- bool IsNull() { return ptr_ == NULL; }
- bool IsNone() { return ptr_ == Py_None; }
-
- operator PyObject* () { return ptr_; }
-};
-
-} // namespace lldb
-
-#endif // utility_PythonPointer_h_
diff --git a/include/lldb/Utility/SharedCluster.h b/include/lldb/Utility/SharedCluster.h
index 3a34d8ddb415..2c03c409d97e 100644
--- a/include/lldb/Utility/SharedCluster.h
+++ b/include/lldb/Utility/SharedCluster.h
@@ -27,14 +27,15 @@ namespace imp
shared_ptr_refcount() : shared_count (0) {}
- virtual ~shared_ptr_refcount ()
+ ~shared_ptr_refcount() override
{
}
- virtual void on_zero_shared ()
+ void on_zero_shared() override
{
manager->DecrementRefCount();
}
+
private:
T *manager;
};
@@ -100,4 +101,5 @@ private:
};
} // namespace lldb_private
+
#endif // utility_SharedCluster_h_
diff --git a/include/lldb/Utility/SharingPtr.h b/include/lldb/Utility/SharingPtr.h
index 5c77dad9f7ff..29538bc7dc03 100644
--- a/include/lldb/Utility/SharingPtr.h
+++ b/include/lldb/Utility/SharingPtr.h
@@ -10,6 +10,8 @@
#ifndef utility_SharingPtr_h_
#define utility_SharingPtr_h_
+// C Includes
+// C++ Includes
#include <algorithm>
#include <memory>
@@ -22,6 +24,9 @@
#include <atomic>
#endif
+// Other libraries and framework includes
+// Project includes
+
//#define ENABLE_SP_LOGGING 1 // DON'T CHECK THIS LINE IN UNLESS COMMENTED OUT
#if defined (ENABLE_SP_LOGGING)
@@ -38,6 +43,13 @@ class shared_count
shared_count(const shared_count&);
shared_count& operator=(const shared_count&);
+public:
+ explicit shared_count(long refs = 0)
+ : shared_owners_(refs) {}
+
+ void add_shared();
+ void release_shared();
+ long use_count() const {return shared_owners_ + 1;}
protected:
#ifdef _MSC_VER
long shared_owners_;
@@ -45,16 +57,9 @@ protected:
std::atomic<long> shared_owners_;
#endif
virtual ~shared_count();
+
private:
virtual void on_zero_shared() = 0;
-
-public:
- explicit shared_count(long refs = 0)
- : shared_owners_(refs) {}
-
- void add_shared();
- void release_shared();
- long use_count() const {return shared_owners_ + 1;}
};
template <class T>
@@ -67,7 +72,7 @@ public:
: data_(p) {}
private:
- virtual void on_zero_shared();
+ void on_zero_shared() override;
// Outlaw copy constructor and assignment operator to keep effective C++
// warnings down to a minimum
@@ -113,7 +118,8 @@ public:
: data_(a0, a1, a2, a3, a4) {}
private:
- virtual void on_zero_shared();
+ void on_zero_shared() override;
+
public:
T* get() {return &data_;}
};
@@ -124,18 +130,20 @@ shared_ptr_emplace<T>::on_zero_shared()
{
}
-} // namespace
+} // namespace imp
template<class T>
class SharingPtr
{
public:
typedef T element_type;
+
private:
element_type* ptr_;
imp::shared_count* cntrl_;
struct nat {int for_bool_;};
+
public:
SharingPtr();
SharingPtr(std::nullptr_t);
@@ -161,7 +169,7 @@ public:
element_type* operator->() const {return ptr_;}
long use_count() const {return cntrl_ ? cntrl_->use_count() : 0;}
bool unique() const {return use_count() == 1;}
- bool empty() const {return cntrl_ == 0;}
+ bool empty() const {return cntrl_ == nullptr;}
operator nat*() const {return (nat*)get();}
static SharingPtr<T> make_shared();
@@ -182,30 +190,29 @@ public:
static SharingPtr<T> make_shared(A0&, A1&, A2&, A3&, A4&);
private:
-
template <class U> friend class SharingPtr;
};
template<class T>
inline
SharingPtr<T>::SharingPtr()
- : ptr_(0),
- cntrl_(0)
+ : ptr_(nullptr),
+ cntrl_(nullptr)
{
}
template<class T>
inline
SharingPtr<T>::SharingPtr(std::nullptr_t)
-: ptr_(0),
-cntrl_(0)
+: ptr_(nullptr),
+cntrl_(nullptr)
{
}
template<class T>
template<class Y>
SharingPtr<T>::SharingPtr(Y* p)
- : ptr_(p), cntrl_(0)
+ : ptr_(p), cntrl_(nullptr)
{
std::unique_ptr<Y> hold(p);
typedef imp::shared_ptr_pointer<Y*> _CntrlBlk;
@@ -431,7 +438,6 @@ make_shared(A0& a0, A1& a1, A2& a2, A3& a3, A4& a4)
return SharingPtr<T>::make_shared(a0, a1, a2, a3, a4);
}
-
template<class T, class U>
inline
bool
@@ -490,12 +496,8 @@ public:
// action: false means increment just happened
// true means decrement is about to happen
-private:
- Callback cb_;
- void* baton_;
+ LoggingSharingPtr() : cb_(0), baton_(nullptr) {}
-public:
- LoggingSharingPtr() : cb_(0), baton_(0) {}
LoggingSharingPtr(Callback cb, void* baton)
: cb_(cb), baton_(baton)
{
@@ -505,7 +507,7 @@ public:
template <class Y>
LoggingSharingPtr(Y* p)
- : base(p), cb_(0), baton_(0) {}
+ : base(p), cb_(0), baton_(nullptr) {}
template <class Y>
LoggingSharingPtr(Y* p, Callback cb, void* baton)
@@ -568,9 +570,12 @@ public:
cb_ = 0;
baton_ = 0;
}
+
+private:
+ Callback cb_;
+ void* baton_;
};
-
-
+
template <class T>
class IntrusiveSharingPtr;
@@ -637,14 +642,10 @@ public:
imp::shared_count(-1)
{
}
-
- virtual
- ~ReferenceCountedBaseVirtual ()
- {
- }
-
- virtual void on_zero_shared ();
-
+
+ ~ReferenceCountedBaseVirtual() override = default;
+
+ void on_zero_shared() override;
};
template <class T>
@@ -716,7 +717,7 @@ public:
// those would be builds for release. But for debug and release builds
// that are for development, we NULL out the pointers to catch potential
// issues.
- ptr_ = NULL;
+ ptr_ = nullptr;
#endif // #if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE)
}
@@ -754,7 +755,7 @@ public:
}
void
- reset(T* ptr = NULL)
+ reset(T* ptr = nullptr)
{
IntrusiveSharingPtr(ptr).swap(*this);
}
@@ -793,7 +794,7 @@ private:
if (ptr_)
{
#if defined (ENABLE_SP_LOGGING)
- track_sp (this, NULL, ptr_->use_count() - 1);
+ track_sp (this, nullptr, ptr_->use_count() - 1);
#endif
ptr_->release_shared();
}
@@ -838,4 +839,4 @@ inline bool operator!= (T* lhs, const IntrusiveSharingPtr<U>& rhs)
} // namespace lldb_private
-#endif // utility_SharingPtr_h_
+#endif // utility_SharingPtr_h_
diff --git a/include/lldb/Utility/StringExtractor.h b/include/lldb/Utility/StringExtractor.h
index 0f2dbb166be1..db1b83b07694 100644
--- a/include/lldb/Utility/StringExtractor.h
+++ b/include/lldb/Utility/StringExtractor.h
@@ -115,6 +115,9 @@ public:
GetHexU8 (uint8_t fail_value = 0, bool set_eof_on_fail = true);
bool
+ GetHexU8Ex (uint8_t& ch, bool set_eof_on_fail = true);
+
+ bool
GetNameColonValue (std::string &name, std::string &value);
int32_t
diff --git a/include/lldb/Utility/TaskPool.h b/include/lldb/Utility/TaskPool.h
new file mode 100644
index 000000000000..443e2a5853e2
--- /dev/null
+++ b/include/lldb/Utility/TaskPool.h
@@ -0,0 +1,221 @@
+//===--------------------- TaskPool.h ---------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef utility_TaskPool_h_
+#define utility_TaskPool_h_
+
+#if defined(__cplusplus) && defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0)
+// Compiling MSVC libraries with _HAS_EXCEPTIONS=0, eliminates most but not all
+// calls to __uncaught_exception. Unfortunately, it does seem to eliminate
+// the delcaration of __uncaught_excpeiton. Including <eh.h> ensures that it is
+// declared. This may not be necessary after MSVC 12.
+#include <eh.h>
+#endif
+
+#if defined(_MSC_VER)
+// Due to another bug in MSVC 2013, including <future> will generate hundreds of
+// warnings in the Concurrency Runtime. This can be removed when we switch to
+// MSVC 2015
+#pragma warning(push)
+#pragma warning(disable:4062)
+#endif
+
+#include <cassert>
+#include <cstdint>
+#include <future>
+#include <list>
+#include <queue>
+#include <thread>
+#include <vector>
+
+// Global TaskPool class for running tasks in parallel on a set of worker thread created the first
+// time the task pool is used. The TaskPool provide no gurantee about the order the task will be run
+// and about what tasks will run in parrallel. None of the task added to the task pool should block
+// on something (mutex, future, condition variable) what will be set only by the completion of an
+// other task on the task pool as they may run on the same thread sequentally.
+class TaskPool
+{
+public:
+ // Add a new task to the task pool and return a std::future belonging to the newly created task.
+ // The caller of this function has to wait on the future for this task to complete.
+ template<typename F, typename... Args>
+ static std::future<typename std::result_of<F(Args...)>::type>
+ AddTask(F&& f, Args&&... args);
+
+ // Run all of the specified tasks on the task pool and wait until all of them are finished
+ // before returning. This method is intended to be used for small number tasks where listing
+ // them as function arguments is acceptable. For running large number of tasks you should use
+ // AddTask for each task and then call wait() on each returned future.
+ template<typename... T>
+ static void
+ RunTasks(T&&... tasks);
+
+private:
+ TaskPool() = delete;
+
+ template<typename... T>
+ struct RunTaskImpl;
+
+ static void
+ AddTaskImpl(std::function<void()>&& task_fn);
+};
+
+// Wrapper class around the global TaskPool implementation to make it possible to create a set of
+// tasks and then wait for the tasks to be completed by the WaitForNextCompletedTask call. This
+// class should be used when WaitForNextCompletedTask is needed because this class add no other
+// extra functionality to the TaskPool class and it have a very minor performance overhead.
+template <typename T> // The return type of the tasks what will be added to this task runner
+class TaskRunner
+{
+public:
+ // Add a task to the task runner what will also add the task to the global TaskPool. The
+ // function doesn't return the std::future for the task because it will be supplied by the
+ // WaitForNextCompletedTask after the task is completed.
+ template<typename F, typename... Args>
+ void
+ AddTask(F&& f, Args&&... args);
+
+ // Wait for the next task in this task runner to finish and then return the std::future what
+ // belongs to the finished task. If there is no task in this task runner (neither pending nor
+ // comleted) then this function will return an invalid future. Usually this function should be
+ // called in a loop processing the results of the tasks until it returns an invalid std::future
+ // what means that all task in this task runner is completed.
+ std::future<T>
+ WaitForNextCompletedTask();
+
+ // Convenience method to wait for all task in this TaskRunner to finish. Do NOT use this class
+ // just because of this method. Use TaskPool instead and wait for each std::future returned by
+ // AddTask in a loop.
+ void
+ WaitForAllTasks();
+
+private:
+ std::list<std::future<T>> m_ready;
+ std::list<std::future<T>> m_pending;
+ std::mutex m_mutex;
+ std::condition_variable m_cv;
+};
+
+template<typename F, typename... Args>
+std::future<typename std::result_of<F(Args...)>::type>
+TaskPool::AddTask(F&& f, Args&&... args)
+{
+ auto task_sp = std::make_shared<std::packaged_task<typename std::result_of<F(Args...)>::type()>>(
+ std::bind(std::forward<F>(f), std::forward<Args>(args)...));
+
+ AddTaskImpl([task_sp]() { (*task_sp)(); });
+
+ return task_sp->get_future();
+}
+
+template<typename... T>
+void
+TaskPool::RunTasks(T&&... tasks)
+{
+ RunTaskImpl<T...>::Run(std::forward<T>(tasks)...);
+}
+
+template<typename Head, typename... Tail>
+struct TaskPool::RunTaskImpl<Head, Tail...>
+{
+ static void
+ Run(Head&& h, Tail&&... t)
+ {
+ auto f = AddTask(std::forward<Head>(h));
+ RunTaskImpl<Tail...>::Run(std::forward<Tail>(t)...);
+ f.wait();
+ }
+};
+
+template<>
+struct TaskPool::RunTaskImpl<>
+{
+ static void
+ Run() {}
+};
+
+template <typename T>
+template<typename F, typename... Args>
+void
+TaskRunner<T>::AddTask(F&& f, Args&&... args)
+{
+ std::unique_lock<std::mutex> lock(m_mutex);
+ auto it = m_pending.emplace(m_pending.end());
+ *it = std::move(TaskPool::AddTask(
+ [this, it](F f, Args... args)
+ {
+ T&& r = f(std::forward<Args>(args)...);
+
+ std::unique_lock<std::mutex> lock(this->m_mutex);
+ this->m_ready.splice(this->m_ready.end(), this->m_pending, it);
+ lock.unlock();
+
+ this->m_cv.notify_one();
+ return r;
+ },
+ std::forward<F>(f),
+ std::forward<Args>(args)...));
+}
+
+template <>
+template<typename F, typename... Args>
+void
+TaskRunner<void>::AddTask(F&& f, Args&&... args)
+{
+ std::unique_lock<std::mutex> lock(m_mutex);
+ auto it = m_pending.emplace(m_pending.end());
+ *it = std::move(TaskPool::AddTask(
+ [this, it](F f, Args... args)
+ {
+ f(std::forward<Args>(args)...);
+
+ std::unique_lock<std::mutex> lock(this->m_mutex);
+ this->m_ready.emplace_back(std::move(*it));
+ this->m_pending.erase(it);
+ lock.unlock();
+
+ this->m_cv.notify_one();
+ },
+ std::forward<F>(f),
+ std::forward<Args>(args)...));
+}
+
+template <typename T>
+std::future<T>
+TaskRunner<T>::WaitForNextCompletedTask()
+{
+ std::unique_lock<std::mutex> lock(m_mutex);
+ if (m_ready.empty() && m_pending.empty())
+ return std::future<T>(); // No more tasks
+
+ if (m_ready.empty())
+ m_cv.wait(lock, [this](){ return !this->m_ready.empty(); });
+
+ std::future<T> res = std::move(m_ready.front());
+ m_ready.pop_front();
+
+ lock.unlock();
+ res.wait();
+
+ return std::move(res);
+}
+
+template <typename T>
+void
+TaskRunner<T>::WaitForAllTasks()
+{
+ while (WaitForNextCompletedTask().valid());
+}
+
+
+#if defined(_MSC_VER)
+#pragma warning(pop)
+#endif
+
+#endif // #ifndef utility_TaskPool_h_
diff --git a/include/lldb/lldb-defines.h b/include/lldb/lldb-defines.h
index 9dce69aef32b..175cecd7e322 100644
--- a/include/lldb/lldb-defines.h
+++ b/include/lldb/lldb-defines.h
@@ -137,6 +137,8 @@
#define __attribute__(X)
#endif
+#define UNUSED_IF_ASSERT_DISABLED(x) ((void)(x))
+
#if defined(__cplusplus)
//----------------------------------------------------------------------
diff --git a/include/lldb/lldb-enumerations.h b/include/lldb/lldb-enumerations.h
index 28614ffb23e1..ea31752b09be 100644
--- a/include/lldb/lldb-enumerations.h
+++ b/include/lldb/lldb-enumerations.h
@@ -146,6 +146,7 @@ namespace lldb {
eFormatVectorOfUInt32,
eFormatVectorOfSInt64,
eFormatVectorOfUInt64,
+ eFormatVectorOfFloat16,
eFormatVectorOfFloat32,
eFormatVectorOfFloat64,
eFormatVectorOfUInt128,
@@ -188,11 +189,11 @@ namespace lldb {
//----------------------------------------------------------------------
enum RegisterKind
{
- eRegisterKindGCC = 0, // the register numbers seen in eh_frame
- eRegisterKindDWARF, // the register numbers seen DWARF
- eRegisterKindGeneric, // insn ptr reg, stack ptr reg, etc not specific to any particular target
- eRegisterKindGDB, // the register numbers gdb uses (matches stabs numbers)
- eRegisterKindLLDB, // lldb's internal register numbers
+ eRegisterKindEHFrame = 0, // the register numbers seen in eh_frame
+ eRegisterKindDWARF, // the register numbers seen DWARF
+ eRegisterKindGeneric, // insn ptr reg, stack ptr reg, etc not specific to any particular target
+ eRegisterKindProcessPlugin, // num used by the process plugin - e.g. by the remote gdb-protocol stub program
+ eRegisterKindLLDB, // lldb's internal register numbers
kNumRegisterKinds
};
@@ -421,7 +422,7 @@ namespace lldb {
eLanguageTypeFortran03 = 0x0022, ///< ISO Fortran 2003.
eLanguageTypeFortran08 = 0x0023, ///< ISO Fortran 2008.
// Vendor Extensions
- // Note: LanguageRuntime::GetNameForLanguageType
+ // Note: Language::GetNameForLanguageType
// assumes these can be used as indexes into array language_names, and
// Language::SetLanguageFromCString and Language::AsCString
// assume these can be used as indexes into array g_languages.
@@ -595,16 +596,19 @@ namespace lldb {
eSectionTypeDataObjCMessageRefs, // Pointer to function pointer + selector
eSectionTypeDataObjCCFStrings, // Objective C const CFString/NSString objects
eSectionTypeDWARFDebugAbbrev,
+ eSectionTypeDWARFDebugAddr,
eSectionTypeDWARFDebugAranges,
eSectionTypeDWARFDebugFrame,
eSectionTypeDWARFDebugInfo,
eSectionTypeDWARFDebugLine,
eSectionTypeDWARFDebugLoc,
eSectionTypeDWARFDebugMacInfo,
+ eSectionTypeDWARFDebugMacro,
eSectionTypeDWARFDebugPubNames,
eSectionTypeDWARFDebugPubTypes,
eSectionTypeDWARFDebugRanges,
eSectionTypeDWARFDebugStr,
+ eSectionTypeDWARFDebugStrOffsets,
eSectionTypeDWARFAppleNames,
eSectionTypeDWARFAppleTypes,
eSectionTypeDWARFAppleNamespaces,
@@ -614,7 +618,10 @@ namespace lldb {
eSectionTypeELFRelocationEntries, // Elf SHT_REL or SHT_REL section
eSectionTypeELFDynamicLinkInfo, // Elf SHT_DYNAMIC section
eSectionTypeEHFrame,
+ eSectionTypeARMexidx,
+ eSectionTypeARMextab,
eSectionTypeCompactUnwind, // compact unwind section in Mach-O, __TEXT,__unwind_info
+ eSectionTypeGoSymtab,
eSectionTypeOther
};
@@ -729,15 +736,16 @@ namespace lldb {
//----------------------------------------------------------------------
FLAGS_ENUM(TypeOptions)
{
- eTypeOptionNone = (0u),
- eTypeOptionCascade = (1u << 0),
- eTypeOptionSkipPointers = (1u << 1),
- eTypeOptionSkipReferences = (1u << 2),
- eTypeOptionHideChildren = (1u << 3),
- eTypeOptionHideValue = (1u << 4),
- eTypeOptionShowOneLiner = (1u << 5),
- eTypeOptionHideNames = (1u << 6),
- eTypeOptionNonCacheable = (1u << 7)
+ eTypeOptionNone = (0u),
+ eTypeOptionCascade = (1u << 0),
+ eTypeOptionSkipPointers = (1u << 1),
+ eTypeOptionSkipReferences = (1u << 2),
+ eTypeOptionHideChildren = (1u << 3),
+ eTypeOptionHideValue = (1u << 4),
+ eTypeOptionShowOneLiner = (1u << 5),
+ eTypeOptionHideNames = (1u << 6),
+ eTypeOptionNonCacheable = (1u << 7),
+ eTypeOptionHideEmptyAggregates = (1u << 8)
};
//----------------------------------------------------------------------
@@ -953,7 +961,8 @@ namespace lldb {
eTypeIsInteger = (1u << 18),
eTypeIsFloat = (1u << 19),
eTypeIsComplex = (1u << 20),
- eTypeIsSigned = (1u << 21)
+ eTypeIsSigned = (1u << 21),
+ eTypeInstanceIsPointer = (1u << 22)
};
FLAGS_ENUM(CommandFlags)
diff --git a/include/lldb/lldb-forward.h b/include/lldb/lldb-forward.h
index da90ac4775ee..516f31911c2b 100644
--- a/include/lldb/lldb-forward.h
+++ b/include/lldb/lldb-forward.h
@@ -25,8 +25,10 @@ class AddressImpl;
class AddressRange;
class AddressResolver;
class ArchSpec;
+class ArmUnwindInfo;
class Args;
class ASTResultSynthesizer;
+class ASTStructExtractor;
class Baton;
class Block;
class Breakpoint;
@@ -48,26 +50,22 @@ class ClangASTContext;
class ClangASTImporter;
class ClangASTMetadata;
class ClangASTSource;
-class ClangASTType;
-class ClangNamespaceDecl;
-class ClangExpression;
class ClangExpressionDeclMap;
class ClangExpressionParser;
class ClangExpressionVariable;
-class ClangExpressionVariableList;
-class ClangExpressionVariableList;
class ClangExpressionVariables;
-class ClangFunction;
class ClangModulesDeclVendor;
class ClangPersistentVariables;
-class ClangUserExpression;
-class ClangUtilityFunction;
class CommandInterpreter;
class CommandInterpreterRunOptions;
class CommandObject;
class CommandReturnObject;
class Communication;
class CompactUnwindInfo;
+struct CompilerContext;
+class CompilerDecl;
+class CompilerDeclContext;
+class CompilerType;
class CompileUnit;
class Condition;
class Connection;
@@ -82,7 +80,7 @@ class DataExtractor;
class Debugger;
class Declaration;
class Disassembler;
-struct DumpValueObjectOptions;
+class DumpValueObjectOptions;
class DynamicCheckerFunctions;
class DynamicLoader;
class Editline;
@@ -95,10 +93,15 @@ class ExecutionContext;
class ExecutionContextRef;
class ExecutionContextRefLocker;
class ExecutionContextScope;
+class Expression;
+class ExpressionVariable;
+class ExpressionVariableList;
+class ExpressionTypeSystemHelper;
class File;
class FileSpec;
class FileSpecList;
class Flags;
+class GoASTContext;
class TypeCategoryImpl;
class FormatManager;
class FormattersMatchCandidate;
@@ -114,6 +117,8 @@ class IOObject;
class IRExecutionUnit;
class JITLoader;
class JITLoaderList;
+class Language;
+class LanguageCategory;
class LanguageRuntime;
class MemoryRegionInfo;
class LineTable;
@@ -130,6 +135,7 @@ class ModuleSpecList;
class Mutex;
struct NameSearchContext;
class ObjCLanguageRuntime;
+class ObjCRuntimeSyntheticProvider;
class ObjectContainer;
class OptionGroup;
class OptionGroupOptions;
@@ -160,6 +166,8 @@ class OptionValueUInt64;
class OptionValueUUID;
class NamedOption;
class PathMappingList;
+class FunctionCaller;
+class PersistentExpressionState;
class Platform;
class Process;
class ProcessAttachInfo;
@@ -177,12 +185,11 @@ class RegisterLocation;
class RegisterLocationList;
class RegisterValue;
class RegularExpression;
+class REPL;
class Scalar;
class ScriptInterpreter;
class ScriptInterpreterLocker;
-#ifndef LLDB_DISABLE_PYTHON
struct ScriptSummaryFormat;
-#endif
class SearchFilter;
class Section;
class SectionImpl;
@@ -221,6 +228,7 @@ class Symtab;
class SyntheticChildren;
class SyntheticChildrenFrontEnd;
class TypeFilterImpl;
+class TypeSystem;
#ifndef LLDB_DISABLE_PYTHON
class ScriptedSyntheticChildren;
#endif
@@ -249,6 +257,7 @@ class TypeAndOrName;
class TypeCategoryMap;
class TypeImpl;
class TypeList;
+class TypeMap;
class TypeListImpl;
class TypeMemberImpl;
class TypeMemberFunctionImpl;
@@ -264,6 +273,8 @@ class Unwind;
class UnwindAssembly;
class UnwindPlan;
class UnwindTable;
+class UserExpression;
+class UtilityFunction;
class VMRange;
class Value;
class ValueList;
@@ -300,12 +311,10 @@ namespace lldb {
typedef std::shared_ptr<lldb_private::BreakpointResolver> BreakpointResolverSP;
typedef std::shared_ptr<lldb_private::Broadcaster> BroadcasterSP;
typedef std::unique_ptr<lldb_private::ClangASTContext> ClangASTContextUP;
- typedef std::unique_ptr<lldb_private::ClangASTImporter> ClangASTImporterUP;
- typedef std::unique_ptr<lldb_private::ClangASTSource> ClangASTSourceUP;
- typedef std::shared_ptr<lldb_private::ClangExpressionVariable> ClangExpressionVariableSP;
+ typedef std::shared_ptr<lldb_private::ClangASTImporter> ClangASTImporterSP;
typedef std::unique_ptr<lldb_private::ClangModulesDeclVendor> ClangModulesDeclVendorUP;
typedef std::unique_ptr<lldb_private::ClangPersistentVariables> ClangPersistentVariablesUP;
- typedef std::shared_ptr<lldb_private::ClangUserExpression> ClangUserExpressionSP;
+ typedef std::shared_ptr<lldb_private::UserExpression> UserExpressionSP;
typedef std::shared_ptr<lldb_private::CommandObject> CommandObjectSP;
typedef std::shared_ptr<lldb_private::Communication> CommunicationSP;
typedef std::shared_ptr<lldb_private::Connection> ConnectionSP;
@@ -320,14 +329,18 @@ namespace lldb {
typedef std::unique_ptr<lldb_private::DynamicLoader> DynamicLoaderUP;
typedef std::shared_ptr<lldb_private::Event> EventSP;
typedef std::shared_ptr<lldb_private::ExecutionContextRef> ExecutionContextRefSP;
+ typedef std::shared_ptr<lldb_private::ExpressionVariable> ExpressionVariableSP;
typedef std::shared_ptr<lldb_private::File> FileSP;
typedef std::shared_ptr<lldb_private::Function> FunctionSP;
+ typedef std::shared_ptr<lldb_private::FunctionCaller> FunctionCallerSP;
typedef std::shared_ptr<lldb_private::FuncUnwinders> FuncUnwindersSP;
+ typedef std::unique_ptr<lldb_private::GoASTContext> GoASTContextUP;
typedef std::shared_ptr<lldb_private::InlineFunctionInfo> InlineFunctionInfoSP;
typedef std::shared_ptr<lldb_private::Instruction> InstructionSP;
typedef std::shared_ptr<lldb_private::InstrumentationRuntime> InstrumentationRuntimeSP;
typedef std::shared_ptr<lldb_private::IOHandler> IOHandlerSP;
typedef std::shared_ptr<lldb_private::IOObject> IOObjectSP;
+ typedef std::shared_ptr<lldb_private::IRExecutionUnit> IRExecutionUnitSP;
typedef std::shared_ptr<lldb_private::JITLoader> JITLoaderSP;
typedef std::unique_ptr<lldb_private::JITLoaderList> JITLoaderListUP;
typedef std::shared_ptr<lldb_private::LanguageRuntime> LanguageRuntimeSP;
@@ -373,9 +386,10 @@ namespace lldb {
typedef std::shared_ptr<lldb_private::Queue> QueueSP;
typedef std::weak_ptr<lldb_private::Queue> QueueWP;
typedef std::shared_ptr<lldb_private::QueueItem> QueueItemSP;
-#ifndef LLDB_DISABLE_PYTHON
+ typedef std::shared_ptr<lldb_private::REPL> REPLSP;
typedef std::shared_ptr<lldb_private::ScriptSummaryFormat> ScriptSummaryFormatSP;
-#endif // #ifndef LLDB_DISABLE_PYTHON
+ typedef std::shared_ptr<lldb_private::ScriptInterpreter> ScriptInterpreterSP;
+ typedef std::unique_ptr<lldb_private::ScriptInterpreter> ScriptInterpreterUP;
typedef std::shared_ptr<lldb_private::Section> SectionSP;
typedef std::unique_ptr<lldb_private::SectionList> SectionListUP;
typedef std::weak_ptr<lldb_private::Section> SectionWP;
@@ -415,6 +429,7 @@ namespace lldb {
typedef std::shared_ptr<lldb_private::TypeMemberFunctionImpl> TypeMemberFunctionImplSP;
typedef std::shared_ptr<lldb_private::TypeEnumMemberImpl> TypeEnumMemberImplSP;
typedef std::shared_ptr<lldb_private::TypeFilterImpl> TypeFilterImplSP;
+ typedef std::shared_ptr<lldb_private::TypeSystem> TypeSystemSP;
typedef std::shared_ptr<lldb_private::TypeFormatImpl> TypeFormatImplSP;
typedef std::shared_ptr<lldb_private::TypeNameSpecifierImpl> TypeNameSpecifierImplSP;
typedef std::shared_ptr<lldb_private::TypeSummaryImpl> TypeSummaryImplSP;
@@ -427,6 +442,7 @@ namespace lldb {
typedef std::weak_ptr<lldb_private::UnixSignals> UnixSignalsWP;
typedef std::shared_ptr<lldb_private::UnwindAssembly> UnwindAssemblySP;
typedef std::shared_ptr<lldb_private::UnwindPlan> UnwindPlanSP;
+ typedef std::shared_ptr<lldb_private::UtilityFunction> UtilityFunctionSP;
typedef lldb_private::SharingPtr<lldb_private::ValueObject> ValueObjectSP;
typedef std::shared_ptr<lldb_private::Value> ValueSP;
typedef std::shared_ptr<lldb_private::ValueList> ValueListSP;
diff --git a/include/lldb/lldb-private-enumerations.h b/include/lldb/lldb-private-enumerations.h
index c62863d744c7..5f8f96c6da46 100644
--- a/include/lldb/lldb-private-enumerations.h
+++ b/include/lldb/lldb-private-enumerations.h
@@ -106,13 +106,6 @@ typedef enum SortOrder
eSortOrderByName
} SortOrder;
-typedef enum ObjCRuntimeVersions {
- eObjC_VersionUnknown = 0,
- eAppleObjC_V1 = 1,
- eAppleObjC_V2 = 2
-} ObjCRuntimeVersions;
-
-
//----------------------------------------------------------------------
// LazyBool is for boolean values that need to be calculated lazily.
// Values start off set to eLazyBoolCalculate, and then they can be
@@ -188,7 +181,7 @@ typedef enum FormatterChoiceCriterion
eFormatterChoiceCriterionNavigatedTypedefs = 0x00000002,
eFormatterChoiceCriterionRegularExpressionSummary = 0x00000004,
eFormatterChoiceCriterionRegularExpressionFilter = 0x00000004,
- eFormatterChoiceCriterionDynamicObjCDiscovery = 0x00000008,
+ eFormatterChoiceCriterionLanguagePlugin = 0x00000008,
eFormatterChoiceCriterionStrippedBitField = 0x00000010,
eFormatterChoiceCriterionWentToStaticValue = 0x00000020
} FormatterChoiceCriterion;
@@ -248,6 +241,25 @@ enum class TypeValidatorResult : bool {
Success = true,
Failure = false
};
+
+//----------------------------------------------------------------------
+// Enumerations that can be used to specify scopes types when looking up
+// types.
+//----------------------------------------------------------------------
+enum class CompilerContextKind
+{
+ Invalid = 0,
+ TranslationUnit,
+ Module,
+ Namespace,
+ Class,
+ Structure,
+ Union,
+ Function,
+ Variable,
+ Enumeration,
+ Typedef
+};
} // namespace lldb_private
diff --git a/include/lldb/lldb-private-interfaces.h b/include/lldb/lldb-private-interfaces.h
index 7b5c1c9d2c05..6bc8dadaebff 100644
--- a/include/lldb/lldb-private-interfaces.h
+++ b/include/lldb/lldb-private-interfaces.h
@@ -14,6 +14,8 @@
#include "lldb/lldb-private.h"
+#include <set>
+
namespace lldb_private
{
typedef lldb::ABISP (*ABICreateInstance) (const ArchSpec &arch);
@@ -28,11 +30,13 @@ namespace lldb_private
typedef LogChannel* (*LogChannelCreateInstance) ();
typedef EmulateInstruction * (*EmulateInstructionCreateInstance) (const ArchSpec &arch, InstructionType inst_type);
typedef OperatingSystem* (*OperatingSystemCreateInstance) (Process *process, bool force);
+ typedef Language *(*LanguageCreateInstance) (lldb::LanguageType language);
typedef LanguageRuntime *(*LanguageRuntimeCreateInstance) (Process *process, lldb::LanguageType language);
typedef lldb::CommandObjectSP (*LanguageRuntimeGetCommandObject) (CommandInterpreter& interpreter);
typedef SystemRuntime *(*SystemRuntimeCreateInstance) (Process *process);
typedef lldb::PlatformSP (*PlatformCreateInstance) (bool force, const ArchSpec *arch);
- typedef lldb::ProcessSP (*ProcessCreateInstance) (Target &target, Listener &listener, const FileSpec *crash_file_path);
+ typedef lldb::ProcessSP (*ProcessCreateInstance) (lldb::TargetSP target_sp, Listener &listener, const FileSpec *crash_file_path);
+ typedef lldb::ScriptInterpreterSP (*ScriptInterpreterCreateInstance)(CommandInterpreter &interpreter);
typedef SymbolFile* (*SymbolFileCreateInstance) (ObjectFile* obj_file);
typedef SymbolVendor* (*SymbolVendorCreateInstance) (const lldb::ModuleSP &module_sp, lldb_private::Stream *feedback_strm); // Module can be NULL for default system symbol vendor
typedef bool (*BreakpointHitCallback) (void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
@@ -44,6 +48,10 @@ namespace lldb_private
typedef lldb::MemoryHistorySP (*MemoryHistoryCreateInstance) (const lldb::ProcessSP &process_sp);
typedef lldb::InstrumentationRuntimeType (*InstrumentationRuntimeGetType) ();
typedef lldb::InstrumentationRuntimeSP (*InstrumentationRuntimeCreateInstance) (const lldb::ProcessSP &process_sp);
+ typedef lldb::TypeSystemSP (*TypeSystemCreateInstance) (lldb::LanguageType language, Module *module, Target *target);
+ typedef lldb::REPLSP (*REPLCreateInstance) (Error &error, lldb::LanguageType language, Debugger *debugger, Target *target, const char *repl_options);
+ typedef void (*TypeSystemEnumerateSupportedLanguages) (std::set<lldb::LanguageType> &languages_for_types, std::set<lldb::LanguageType> &languages_for_expressions);
+ typedef void (*REPLEnumerateSupportedLanguages) (std::set<lldb::LanguageType> &languages);
typedef int (*ComparisonFunction)(const void *, const void *);
typedef void (*DebuggerInitializeCallback)(Debugger &debugger);
diff --git a/include/lldb/lldb-private-types.h b/include/lldb/lldb-private-types.h
index cce637fce279..685034a1fee3 100644
--- a/include/lldb/lldb-private-types.h
+++ b/include/lldb/lldb-private-types.h
@@ -35,7 +35,7 @@ namespace lldb_private
// name (optional), encoding, size in bytes and the default display
// format.
//----------------------------------------------------------------------
- typedef struct
+ 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
@@ -51,15 +51,15 @@ namespace lldb_private
// for this register will be valid. For example, the value list for ah
// would be eax (x86) or rax (x64).
uint32_t *invalidate_regs; // List of registers (terminated with LLDB_INVALID_REGNUM). If this value is not
- // null, all registers in this list will be invalidateed when the value of this
+ // null, all registers in this list will be invalidated when the value of this
// register changes. For example, the invalidate list for eax would be rax
// ax, ah, and al.
- } RegisterInfo;
+ };
//----------------------------------------------------------------------
// Registers are grouped into register sets
//----------------------------------------------------------------------
- typedef struct
+ struct RegisterSet
{
const char *name; // Name of this register set
const char *short_name; // A short name for this register set
@@ -69,14 +69,14 @@ namespace lldb_private
// register array. For example, if eax is defined at index 4 for a
// particular RegisterContext, eax would be included in this RegisterSet
// by adding the value 4. Not by adding the value lldb_eax_i386.
- } RegisterSet;
+ };
- typedef struct
+ struct OptionEnumValueElement
{
int64_t value;
const char *string_value;
const char *usage;
- } OptionEnumValueElement;
+ };
struct OptionValidator
{
@@ -85,7 +85,7 @@ namespace lldb_private
virtual const char * ShortConditionString() const = 0;
virtual const char * LongConditionString() const = 0;
};
-
+
struct OptionDefinition
{
uint32_t usage_mask; // Used to mark options that can be used together. If (1 << n & usage_mask) != 0
@@ -102,6 +102,8 @@ namespace lldb_private
// pass it.
};
+ typedef struct type128 { uint64_t x[2]; } type128;
+
} // namespace lldb_private
#endif // #if defined(__cplusplus)
diff --git a/include/lldb/lldb-python.h b/include/lldb/lldb-python.h
deleted file mode 100644
index c8ef054f60e1..000000000000
--- a/include/lldb/lldb-python.h
+++ /dev/null
@@ -1,31 +0,0 @@
-//===-- 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.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLDB_lldb_python_h_
-#define LLDB_lldb_python_h_
-
-// Python.h needs to be included before any system headers in order to avoid redefinition of macros
-
-#ifdef LLDB_DISABLE_PYTHON
-// Python is disabled in this build
-#else
- #if defined(__linux__)
- // features.h will define _POSIX_C_SOURCE if _GNU_SOURCE is defined. This value
- // may be different from the value that Python defines it to be which results
- // in a warning. Undefine _POSIX_C_SOURCE before including Python.h The same
- // holds for _XOPEN_SOURCE.
- #undef _POSIX_C_SOURCE
- #undef _XOPEN_SOURCE
- #endif
-
- // Include python for non windows machines
- #include <Python.h>
-#endif // LLDB_DISABLE_PYTHON
-
-#endif // LLDB_lldb_python_h_
diff --git a/include/lldb/lldb-types.h b/include/lldb/lldb-types.h
index fe902073698d..2cf9904bd9d3 100644
--- a/include/lldb/lldb-types.h
+++ b/include/lldb/lldb-types.h
@@ -110,7 +110,7 @@ namespace lldb
typedef uint64_t offset_t;
typedef int32_t break_id_t;
typedef int32_t watch_id_t;
- typedef void * clang_type_t;
+ typedef void * opaque_compiler_type_t;
typedef uint64_t queue_id_t;
}
diff --git a/source/API/SBAttachInfo.cpp b/source/API/SBAttachInfo.cpp
index 07446df27dff..0f2ab7afc9c2 100644
--- a/source/API/SBAttachInfo.cpp
+++ b/source/API/SBAttachInfo.cpp
@@ -36,6 +36,15 @@ SBAttachInfo::SBAttachInfo (const char *path, bool wait_for) :
m_opaque_sp->SetWaitForLaunch (wait_for);
}
+SBAttachInfo::SBAttachInfo (const char *path, bool wait_for, bool async) :
+ m_opaque_sp (new ProcessAttachInfo())
+{
+ if (path && path[0])
+ m_opaque_sp->GetExecutableFile().SetFile(path, false);
+ m_opaque_sp->SetWaitForLaunch (wait_for);
+ m_opaque_sp->SetAsync(async);
+}
+
SBAttachInfo::SBAttachInfo (const SBAttachInfo &rhs) :
m_opaque_sp (new ProcessAttachInfo())
{
@@ -127,6 +136,13 @@ SBAttachInfo::SetWaitForLaunch (bool b)
m_opaque_sp->SetWaitForLaunch (b);
}
+void
+SBAttachInfo::SetWaitForLaunch (bool b, bool async)
+{
+ m_opaque_sp->SetWaitForLaunch (b);
+ m_opaque_sp->SetAsync(async);
+}
+
bool
SBAttachInfo::GetIgnoreExisting ()
{
diff --git a/source/API/SBBreakpoint.cpp b/source/API/SBBreakpoint.cpp
index dd4c80caf45d..1f58ddb7152a 100644
--- a/source/API/SBBreakpoint.cpp
+++ b/source/API/SBBreakpoint.cpp
@@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/API/SBBreakpoint.h"
#include "lldb/API/SBBreakpointLocation.h"
#include "lldb/API/SBDebugger.h"
@@ -32,7 +36,6 @@
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadSpec.h"
-
#include "lldb/lldb-enumerations.h"
using namespace lldb;
@@ -47,7 +50,6 @@ struct CallbackData
class SBBreakpointCallbackBaton : public Baton
{
public:
-
SBBreakpointCallbackBaton (SBBreakpoint::BreakpointHitCallback callback, void *baton) :
Baton (new CallbackData)
{
@@ -56,19 +58,18 @@ public:
data->callback_baton = baton;
}
- virtual ~SBBreakpointCallbackBaton()
+ ~SBBreakpointCallbackBaton() override
{
CallbackData *data = (CallbackData *)m_data;
if (data)
{
delete data;
- m_data = NULL;
+ m_data = nullptr;
}
}
};
-
SBBreakpoint::SBBreakpoint () :
m_opaque_sp ()
{
@@ -79,15 +80,12 @@ SBBreakpoint::SBBreakpoint (const SBBreakpoint& rhs) :
{
}
-
SBBreakpoint::SBBreakpoint (const lldb::BreakpointSP &bp_sp) :
m_opaque_sp (bp_sp)
{
}
-SBBreakpoint::~SBBreakpoint()
-{
-}
+SBBreakpoint::~SBBreakpoint() = default;
const SBBreakpoint &
SBBreakpoint::operator = (const SBBreakpoint& rhs)
@@ -135,7 +133,6 @@ SBBreakpoint::GetID () const
return break_id;
}
-
bool
SBBreakpoint::IsValid() const
{
@@ -169,7 +166,7 @@ SBBreakpoint::FindLocationByAddress (addr_t vm_addr)
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
Address address;
Target &target = m_opaque_sp->GetTarget();
- if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false)
+ if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address))
{
address.SetRawAddress (vm_addr);
}
@@ -189,7 +186,7 @@ SBBreakpoint::FindLocationIDByAddress (addr_t vm_addr)
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
Address address;
Target &target = m_opaque_sp->GetTarget();
- if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false)
+ if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address))
{
address.SetRawAddress (vm_addr);
}
@@ -329,7 +326,7 @@ SBBreakpoint::GetCondition ()
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
return m_opaque_sp->GetConditionText ();
}
- return NULL;
+ return nullptr;
}
uint32_t
@@ -380,7 +377,6 @@ SBBreakpoint::SetThreadID (tid_t tid)
if (log)
log->Printf ("SBBreakpoint(%p)::SetThreadID (tid=0x%4.4" PRIx64 ")",
static_cast<void*>(m_opaque_sp.get()), tid);
-
}
tid_t
@@ -422,7 +418,7 @@ SBBreakpoint::GetThreadIndex() const
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate();
- if (thread_spec != NULL)
+ if (thread_spec != nullptr)
thread_idx = thread_spec->GetIndex();
}
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@@ -451,12 +447,12 @@ SBBreakpoint::SetThreadName (const char *thread_name)
const char *
SBBreakpoint::GetThreadName () const
{
- const char *name = NULL;
+ const char *name = nullptr;
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate();
- if (thread_spec != NULL)
+ if (thread_spec != nullptr)
name = thread_spec->GetName();
}
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@@ -484,7 +480,7 @@ SBBreakpoint::SetQueueName (const char *queue_name)
const char *
SBBreakpoint::GetQueueName () const
{
- const char *name = NULL;
+ const char *name = nullptr;
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
@@ -552,13 +548,10 @@ SBBreakpoint::GetDescription (SBStream &s)
}
bool
-SBBreakpoint::PrivateBreakpointHitCallback
-(
- void *baton,
- StoppointCallbackContext *ctx,
- lldb::user_id_t break_id,
- lldb::user_id_t break_loc_id
-)
+SBBreakpoint::PrivateBreakpointHitCallback(void *baton,
+ StoppointCallbackContext *ctx,
+ lldb::user_id_t break_id,
+ lldb::user_id_t break_loc_id)
{
ExecutionContext exe_ctx (ctx->exe_ctx_ref);
BreakpointSP bp_sp(exe_ctx.GetTargetRef().GetBreakpointList().FindBreakpointByID(break_id));
@@ -758,8 +751,7 @@ SBBreakpoint::operator *() const
bool
SBBreakpoint::EventIsBreakpointEvent (const lldb::SBEvent &event)
{
- return Breakpoint::BreakpointEventData::GetEventDataFromEvent(event.get()) != NULL;
-
+ return Breakpoint::BreakpointEventData::GetEventDataFromEvent(event.get()) != nullptr;
}
BreakpointEventType
@@ -796,5 +788,3 @@ SBBreakpoint::GetNumBreakpointLocationsFromEvent (const lldb::SBEvent &event)
num_locations = (Breakpoint::BreakpointEventData::GetNumBreakpointLocationsFromEvent (event.GetSP()));
return num_locations;
}
-
-
diff --git a/source/API/SBCommandInterpreter.cpp b/source/API/SBCommandInterpreter.cpp
index d901e728105b..21f431dac6a3 100644
--- a/source/API/SBCommandInterpreter.cpp
+++ b/source/API/SBCommandInterpreter.cpp
@@ -7,8 +7,12 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-types.h"
-#include "lldb/Core/SourceManager.h"
+
#include "lldb/Core/Listener.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -34,10 +38,7 @@ SBCommandInterpreterRunOptions::SBCommandInterpreterRunOptions()
m_opaque_up.reset(new CommandInterpreterRunOptions());
}
-SBCommandInterpreterRunOptions::~SBCommandInterpreterRunOptions()
-{
-
-}
+SBCommandInterpreterRunOptions::~SBCommandInterpreterRunOptions() = default;
bool
SBCommandInterpreterRunOptions::GetStopOnContinue () const
@@ -126,21 +127,24 @@ SBCommandInterpreterRunOptions::ref () const
class CommandPluginInterfaceImplementation : public CommandObjectParsed
{
public:
- CommandPluginInterfaceImplementation (CommandInterpreter &interpreter,
- const char *name,
- lldb::SBCommandPluginInterface* backend,
- const char *help = NULL,
- const char *syntax = NULL,
- uint32_t flags = 0) :
+ CommandPluginInterfaceImplementation(CommandInterpreter &interpreter,
+ const char *name,
+ lldb::SBCommandPluginInterface* backend,
+ const char *help = nullptr,
+ const char *syntax = nullptr,
+ uint32_t flags = 0) :
CommandObjectParsed (interpreter, name, help, syntax, flags),
m_backend(backend) {}
- virtual bool
- IsRemovable() const { return true; }
+ bool
+ IsRemovable() const override
+ {
+ return true;
+ }
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute(Args& command, CommandReturnObject &result) override
{
SBCommandReturnObject sb_return(&result);
SBCommandInterpreter sb_interpreter(&m_interpreter);
@@ -169,6 +173,8 @@ SBCommandInterpreter::SBCommandInterpreter(const SBCommandInterpreter &rhs) :
{
}
+SBCommandInterpreter::~SBCommandInterpreter() = default;
+
const SBCommandInterpreter &
SBCommandInterpreter::operator = (const SBCommandInterpreter &rhs)
{
@@ -176,47 +182,34 @@ SBCommandInterpreter::operator = (const SBCommandInterpreter &rhs)
return *this;
}
-SBCommandInterpreter::~SBCommandInterpreter ()
-{
-}
-
bool
SBCommandInterpreter::IsValid() const
{
- return m_opaque_ptr != NULL;
+ return m_opaque_ptr != nullptr;
}
-
bool
-SBCommandInterpreter::CommandExists (const char *cmd)
+SBCommandInterpreter::CommandExists(const char *cmd)
{
- if (cmd && m_opaque_ptr)
- return m_opaque_ptr->CommandExists (cmd);
- return false;
+ return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->CommandExists(cmd) : false);
}
bool
SBCommandInterpreter::AliasExists (const char *cmd)
{
- if (cmd && m_opaque_ptr)
- return m_opaque_ptr->AliasExists (cmd);
- return false;
+ return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->AliasExists(cmd) : false);
}
bool
-SBCommandInterpreter::IsActive ()
+SBCommandInterpreter::IsActive()
{
- if (m_opaque_ptr)
- return m_opaque_ptr->IsActive ();
- return false;
+ return (IsValid() ? m_opaque_ptr->IsActive() : false);
}
const char *
SBCommandInterpreter::GetIOHandlerControlSequence(char ch)
{
- if (m_opaque_ptr)
- return m_opaque_ptr->GetDebugger().GetTopIOHandlerControlSequence (ch).GetCString();
- return NULL;
+ return (IsValid() ? m_opaque_ptr->GetDebugger().GetTopIOHandlerControlSequence(ch).GetCString() : nullptr);
}
lldb::ReturnStatus
@@ -247,7 +240,7 @@ SBCommandInterpreter::HandleCommand (const char *command_line, SBExecutionContex
result.Clear();
- if (command_line && m_opaque_ptr)
+ if (command_line && IsValid())
{
result.ref().SetInteractive(false);
m_opaque_ptr->HandleCommand (command_line, add_to_history ? eLazyBoolYes : eLazyBoolNo, result.ref(), ctx_ptr);
@@ -290,7 +283,7 @@ SBCommandInterpreter::HandleCommandsFromFile (lldb::SBFileSpec &file,
static_cast<void*>(result.get()));
}
- if (!m_opaque_ptr)
+ if (!IsValid())
{
result->AppendError ("SBCommandInterpreter is not valid.");
result->SetStatus (eReturnStatusFailed);
@@ -315,12 +308,9 @@ SBCommandInterpreter::HandleCommandsFromFile (lldb::SBFileSpec &file,
else
ctx_ptr = nullptr;
-
m_opaque_ptr->HandleCommandsFromFile (tmp_spec, ctx_ptr, options.ref(), result.ref());
-
}
-
int
SBCommandInterpreter::HandleCompletion (const char *current_line,
const char *cursor,
@@ -334,7 +324,7 @@ SBCommandInterpreter::HandleCompletion (const char *current_line,
// Sanity check the arguments that are passed in:
// cursor & last_char have to be within the current_line.
- if (current_line == NULL || cursor == NULL || last_char == NULL)
+ if (current_line == nullptr || cursor == nullptr || last_char == nullptr)
return 0;
if (cursor < current_line || last_char < current_line)
@@ -352,11 +342,11 @@ SBCommandInterpreter::HandleCompletion (const char *current_line,
static_cast<uint64_t>(last_char - current_line),
match_start_point, max_return_elements);
- if (m_opaque_ptr)
+ if (IsValid())
{
lldb_private::StringList lldb_matches;
- num_completions = m_opaque_ptr->HandleCompletion (current_line, cursor, last_char, match_start_point,
- max_return_elements, lldb_matches);
+ num_completions = m_opaque_ptr->HandleCompletion(current_line, cursor, last_char, match_start_point,
+ max_return_elements, lldb_matches);
SBStringList temp_list (&lldb_matches);
matches.AppendList (temp_list);
@@ -381,27 +371,21 @@ SBCommandInterpreter::HandleCompletion (const char *current_line,
}
bool
-SBCommandInterpreter::HasCommands ()
+SBCommandInterpreter::HasCommands()
{
- if (m_opaque_ptr)
- return m_opaque_ptr->HasCommands();
- return false;
+ return (IsValid() ? m_opaque_ptr->HasCommands() : false);
}
bool
-SBCommandInterpreter::HasAliases ()
+SBCommandInterpreter::HasAliases()
{
- if (m_opaque_ptr)
- return m_opaque_ptr->HasAliases();
- return false;
+ return (IsValid() ? m_opaque_ptr->HasAliases() : false);
}
bool
-SBCommandInterpreter::HasAliasOptions ()
+SBCommandInterpreter::HasAliasOptions()
{
- if (m_opaque_ptr)
- return m_opaque_ptr->HasAliasOptions ();
- return false;
+ return (IsValid() ? m_opaque_ptr->HasAliasOptions() : false);
}
SBProcess
@@ -409,7 +393,7 @@ SBCommandInterpreter::GetProcess ()
{
SBProcess sb_process;
ProcessSP process_sp;
- if (m_opaque_ptr)
+ if (IsValid())
{
TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
if (target_sp)
@@ -433,7 +417,7 @@ SBDebugger
SBCommandInterpreter::GetDebugger ()
{
SBDebugger sb_debugger;
- if (m_opaque_ptr)
+ if (IsValid())
sb_debugger.reset(m_opaque_ptr->GetDebugger().shared_from_this());
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@@ -448,15 +432,13 @@ SBCommandInterpreter::GetDebugger ()
bool
SBCommandInterpreter::GetPromptOnQuit()
{
- if (m_opaque_ptr)
- return m_opaque_ptr->GetPromptOnQuit();
- return false;
+ return (IsValid() ? m_opaque_ptr->GetPromptOnQuit() : false);
}
void
SBCommandInterpreter::SetPromptOnQuit (bool b)
{
- if (m_opaque_ptr)
+ if (IsValid())
m_opaque_ptr->SetPromptOnQuit(b);
}
@@ -464,7 +446,7 @@ void
SBCommandInterpreter::ResolveCommand(const char *command_line, SBCommandReturnObject &result)
{
result.Clear();
- if (command_line && m_opaque_ptr)
+ if (command_line && IsValid())
{
m_opaque_ptr->ResolveCommand(command_line, result.ref());
}
@@ -475,7 +457,6 @@ SBCommandInterpreter::ResolveCommand(const char *command_line, SBCommandReturnOb
}
}
-
CommandInterpreter *
SBCommandInterpreter::get ()
{
@@ -499,7 +480,7 @@ void
SBCommandInterpreter::SourceInitFileInHomeDirectory (SBCommandReturnObject &result)
{
result.Clear();
- if (m_opaque_ptr)
+ if (IsValid())
{
TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
Mutex::Locker api_locker;
@@ -524,7 +505,7 @@ void
SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory (SBCommandReturnObject &result)
{
result.Clear();
- if (m_opaque_ptr)
+ if (IsValid())
{
TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
Mutex::Locker api_locker;
@@ -588,7 +569,7 @@ SBCommandInterpreter::SetCommandOverrideCallback (const char *command_name,
lldb::CommandOverrideCallback callback,
void *baton)
{
- if (command_name && command_name[0] && m_opaque_ptr)
+ if (command_name && command_name[0] && IsValid())
{
std::string command_name_str (command_name);
CommandObject *cmd_obj = m_opaque_ptr->GetCommandObjectForCommand(command_name_str);
@@ -605,7 +586,7 @@ SBCommandInterpreter::SetCommandOverrideCallback (const char *command_name,
lldb::SBCommand
SBCommandInterpreter::AddMultiwordCommand (const char* name, const char* help)
{
- CommandObjectMultiword *new_command = new CommandObjectMultiword(*m_opaque_ptr,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))
@@ -617,47 +598,40 @@ lldb::SBCommand
SBCommandInterpreter::AddCommand (const char* name, lldb::SBCommandPluginInterface* impl, const char* help)
{
lldb::CommandObjectSP new_command_sp;
- new_command_sp.reset(new CommandPluginInterfaceImplementation(*m_opaque_ptr,name,impl,help));
+ new_command_sp.reset(new 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();
}
-SBCommand::SBCommand ()
-{}
+SBCommand::SBCommand() = default;
SBCommand::SBCommand (lldb::CommandObjectSP cmd_sp) : m_opaque_sp (cmd_sp)
{}
bool
-SBCommand::IsValid ()
+SBCommand::IsValid()
{
- return (bool)m_opaque_sp;
+ return m_opaque_sp.get() != nullptr;
}
const char*
-SBCommand::GetName ()
+SBCommand::GetName()
{
- if (IsValid ())
- return m_opaque_sp->GetCommandName ();
- return NULL;
+ return (IsValid() ? m_opaque_sp->GetCommandName() : nullptr);
}
const char*
-SBCommand::GetHelp ()
+SBCommand::GetHelp()
{
- if (IsValid ())
- return m_opaque_sp->GetHelp ();
- return NULL;
+ return (IsValid() ? m_opaque_sp->GetHelp() : nullptr);
}
const char*
-SBCommand::GetHelpLong ()
+SBCommand::GetHelpLong()
{
- if (IsValid ())
- return m_opaque_sp->GetHelpLong ();
- return NULL;
+ return (IsValid() ? m_opaque_sp->GetHelpLong() : nullptr);
}
void
@@ -679,7 +653,7 @@ SBCommand::AddMultiwordCommand (const char* name, const char* help)
{
if (!IsValid ())
return lldb::SBCommand();
- if (m_opaque_sp->IsMultiwordObject() == false)
+ if (!m_opaque_sp->IsMultiwordObject())
return lldb::SBCommand();
CommandObjectMultiword *new_command = new CommandObjectMultiword(m_opaque_sp->GetCommandInterpreter(),name,help);
new_command->SetRemovable (true);
@@ -694,7 +668,7 @@ SBCommand::AddCommand (const char* name, lldb::SBCommandPluginInterface *impl, c
{
if (!IsValid ())
return lldb::SBCommand();
- if (m_opaque_sp->IsMultiwordObject() == false)
+ if (!m_opaque_sp->IsMultiwordObject())
return lldb::SBCommand();
lldb::CommandObjectSP new_command_sp;
new_command_sp.reset(new CommandPluginInterfaceImplementation(m_opaque_sp->GetCommandInterpreter(),name,impl,help));
@@ -706,9 +680,7 @@ SBCommand::AddCommand (const char* name, lldb::SBCommandPluginInterface *impl, c
uint32_t
SBCommand::GetFlags ()
{
- if (!IsValid())
- return 0;
- return m_opaque_sp->GetFlags().Get();
+ return (IsValid() ? m_opaque_sp->GetFlags().Get() : 0);
}
void
diff --git a/source/API/SBCommandReturnObject.cpp b/source/API/SBCommandReturnObject.cpp
index 1ae2df76c979..a2ed4d6e8c26 100644
--- a/source/API/SBCommandReturnObject.cpp
+++ b/source/API/SBCommandReturnObject.cpp
@@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/API/SBCommandReturnObject.h"
#include "lldb/API/SBError.h"
#include "lldb/API/SBStream.h"
@@ -26,7 +30,7 @@ SBCommandReturnObject::SBCommandReturnObject () :
SBCommandReturnObject::SBCommandReturnObject (const SBCommandReturnObject &rhs):
m_opaque_ap ()
{
- if (rhs.m_opaque_ap.get())
+ if (rhs.m_opaque_ap)
m_opaque_ap.reset (new CommandReturnObject (*rhs.m_opaque_ap));
}
@@ -35,6 +39,8 @@ SBCommandReturnObject::SBCommandReturnObject (CommandReturnObject *ptr) :
{
}
+SBCommandReturnObject::~SBCommandReturnObject() = default;
+
CommandReturnObject *
SBCommandReturnObject::Release ()
{
@@ -46,7 +52,7 @@ SBCommandReturnObject::operator = (const SBCommandReturnObject &rhs)
{
if (this != &rhs)
{
- if (rhs.m_opaque_ap.get())
+ if (rhs.m_opaque_ap)
m_opaque_ap.reset (new CommandReturnObject (*rhs.m_opaque_ap));
else
m_opaque_ap.reset();
@@ -54,25 +60,18 @@ SBCommandReturnObject::operator = (const SBCommandReturnObject &rhs)
return *this;
}
-
-SBCommandReturnObject::~SBCommandReturnObject ()
-{
- // m_opaque_ap will automatically delete any pointer it owns
-}
-
bool
SBCommandReturnObject::IsValid() const
{
- return m_opaque_ap.get() != NULL;
+ return m_opaque_ap.get() != nullptr;
}
-
const char *
SBCommandReturnObject::GetOutput ()
{
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (m_opaque_ap.get())
+ if (m_opaque_ap)
{
if (log)
log->Printf ("SBCommandReturnObject(%p)::GetOutput () => \"%s\"",
@@ -83,10 +82,10 @@ SBCommandReturnObject::GetOutput ()
}
if (log)
- log->Printf ("SBCommandReturnObject(%p)::GetOutput () => NULL",
+ log->Printf ("SBCommandReturnObject(%p)::GetOutput () => nullptr",
static_cast<void*>(m_opaque_ap.get()));
- return NULL;
+ return nullptr;
}
const char *
@@ -94,7 +93,7 @@ SBCommandReturnObject::GetError ()
{
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (m_opaque_ap.get())
+ if (m_opaque_ap)
{
if (log)
log->Printf ("SBCommandReturnObject(%p)::GetError () => \"%s\"",
@@ -105,26 +104,22 @@ SBCommandReturnObject::GetError ()
}
if (log)
- log->Printf ("SBCommandReturnObject(%p)::GetError () => NULL",
+ log->Printf ("SBCommandReturnObject(%p)::GetError () => nullptr",
static_cast<void*>(m_opaque_ap.get()));
- return NULL;
+ return nullptr;
}
size_t
-SBCommandReturnObject::GetOutputSize ()
+SBCommandReturnObject::GetOutputSize()
{
- if (m_opaque_ap.get())
- return strlen (m_opaque_ap->GetOutputData());
- return 0;
+ return (m_opaque_ap ? strlen(m_opaque_ap->GetOutputData()) : 0);
}
size_t
-SBCommandReturnObject::GetErrorSize ()
+SBCommandReturnObject::GetErrorSize()
{
- if (m_opaque_ap.get())
- return strlen(m_opaque_ap->GetErrorData());
- return 0;
+ return (m_opaque_ap ? strlen(m_opaque_ap->GetErrorData()) : 0);
}
size_t
@@ -154,52 +149,46 @@ SBCommandReturnObject::PutError (FILE *fh)
void
SBCommandReturnObject::Clear()
{
- if (m_opaque_ap.get())
+ if (m_opaque_ap)
m_opaque_ap->Clear();
}
lldb::ReturnStatus
SBCommandReturnObject::GetStatus()
{
- if (m_opaque_ap.get())
- return m_opaque_ap->GetStatus();
- return lldb::eReturnStatusInvalid;
+ return (m_opaque_ap ? m_opaque_ap->GetStatus() : lldb::eReturnStatusInvalid);
}
void
SBCommandReturnObject::SetStatus(lldb::ReturnStatus status)
{
- if (m_opaque_ap.get())
+ if (m_opaque_ap)
m_opaque_ap->SetStatus(status);
}
bool
-SBCommandReturnObject::Succeeded ()
+SBCommandReturnObject::Succeeded()
{
- if (m_opaque_ap.get())
- return m_opaque_ap->Succeeded();
- return false;
+ return (m_opaque_ap ? m_opaque_ap->Succeeded() : false);
}
bool
-SBCommandReturnObject::HasResult ()
+SBCommandReturnObject::HasResult()
{
- if (m_opaque_ap.get())
- return m_opaque_ap->HasResult();
- return false;
+ return (m_opaque_ap ? m_opaque_ap->HasResult() : false);
}
void
SBCommandReturnObject::AppendMessage (const char *message)
{
- if (m_opaque_ap.get())
+ if (m_opaque_ap)
m_opaque_ap->AppendMessage (message);
}
void
SBCommandReturnObject::AppendWarning (const char *message)
{
- if (m_opaque_ap.get())
+ if (m_opaque_ap)
m_opaque_ap->AppendWarning (message);
}
@@ -222,7 +211,6 @@ SBCommandReturnObject::operator *() const
return *(m_opaque_ap.get());
}
-
CommandReturnObject &
SBCommandReturnObject::ref() const
{
@@ -230,11 +218,10 @@ SBCommandReturnObject::ref() const
return *(m_opaque_ap.get());
}
-
void
SBCommandReturnObject::SetLLDBObjectPtr (CommandReturnObject *ptr)
{
- if (m_opaque_ap.get())
+ if (m_opaque_ap)
m_opaque_ap.reset (ptr);
}
@@ -243,7 +230,7 @@ SBCommandReturnObject::GetDescription (SBStream &description)
{
Stream &strm = description.ref();
- if (m_opaque_ap.get())
+ if (m_opaque_ap)
{
description.Printf ("Status: ");
lldb::ReturnStatus status = m_opaque_ap->GetStatus();
@@ -269,25 +256,25 @@ SBCommandReturnObject::GetDescription (SBStream &description)
}
void
-SBCommandReturnObject::SetImmediateOutputFile (FILE *fh)
+SBCommandReturnObject::SetImmediateOutputFile(FILE *fh)
{
- if (m_opaque_ap.get())
- m_opaque_ap->SetImmediateOutputFile (fh);
+ if (m_opaque_ap)
+ m_opaque_ap->SetImmediateOutputFile(fh);
}
void
-SBCommandReturnObject::SetImmediateErrorFile (FILE *fh)
+SBCommandReturnObject::SetImmediateErrorFile(FILE *fh)
{
- if (m_opaque_ap.get())
- m_opaque_ap->SetImmediateErrorFile (fh);
+ if (m_opaque_ap)
+ m_opaque_ap->SetImmediateErrorFile(fh);
}
void
SBCommandReturnObject::PutCString(const char* string, int len)
{
- if (m_opaque_ap.get())
+ if (m_opaque_ap)
{
- if (len == 0 || string == NULL || *string == 0)
+ if (len == 0 || string == nullptr || *string == 0)
{
return;
}
@@ -304,27 +291,27 @@ SBCommandReturnObject::PutCString(const char* string, int len)
const char *
SBCommandReturnObject::GetOutput (bool only_if_no_immediate)
{
- if (!m_opaque_ap.get())
- return NULL;
- if (only_if_no_immediate == false || m_opaque_ap->GetImmediateOutputStream().get() == NULL)
+ if (!m_opaque_ap)
+ return nullptr;
+ if (!only_if_no_immediate || m_opaque_ap->GetImmediateOutputStream().get() == nullptr)
return GetOutput();
- return NULL;
+ return nullptr;
}
const char *
SBCommandReturnObject::GetError (bool only_if_no_immediate)
{
- if (!m_opaque_ap.get())
- return NULL;
- if (only_if_no_immediate == false || m_opaque_ap->GetImmediateErrorStream().get() == NULL)
+ if (!m_opaque_ap)
+ return nullptr;
+ if (!only_if_no_immediate || m_opaque_ap->GetImmediateErrorStream().get() == nullptr)
return GetError();
- return NULL;
+ return nullptr;
}
size_t
SBCommandReturnObject::Printf(const char* format, ...)
{
- if (m_opaque_ap.get())
+ if (m_opaque_ap)
{
va_list args;
va_start (args, format);
@@ -338,7 +325,7 @@ SBCommandReturnObject::Printf(const char* format, ...)
void
SBCommandReturnObject::SetError (lldb::SBError &error, const char *fallback_error_cstr)
{
- if (m_opaque_ap.get())
+ if (m_opaque_ap)
{
if (error.IsValid())
m_opaque_ap->SetError(error.ref(), fallback_error_cstr);
@@ -350,7 +337,6 @@ SBCommandReturnObject::SetError (lldb::SBError &error, const char *fallback_erro
void
SBCommandReturnObject::SetError (const char *error_cstr)
{
- if (m_opaque_ap.get() && error_cstr)
+ if (m_opaque_ap && error_cstr)
m_opaque_ap->SetError(error_cstr);
}
-
diff --git a/source/API/SBDebugger.cpp b/source/API/SBDebugger.cpp
index df2019f5a46b..1645294b5a3f 100644
--- a/source/API/SBDebugger.cpp
+++ b/source/API/SBDebugger.cpp
@@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/API/SBDebugger.h"
#include "lldb/lldb-private.h"
@@ -43,13 +47,13 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/TargetList.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/DynamicLibrary.h"
using namespace lldb;
using namespace lldb_private;
-
static llvm::sys::DynamicLibrary
LoadPlugin (const lldb::DebuggerSP &debugger_sp, const FileSpec& spec, Error& error)
{
@@ -86,13 +90,6 @@ LoadPlugin (const lldb::DebuggerSP &debugger_sp, const FileSpec& spec, Error& er
static llvm::ManagedStatic<SystemLifetimeManager> g_debugger_lifetime;
-SBInputReader::SBInputReader()
-{
-}
-SBInputReader::~SBInputReader()
-{
-}
-
SBError
SBInputReader::Initialize(lldb::SBDebugger &sb_debugger,
unsigned long (*)(void *, lldb::SBInputReader *, lldb::InputReaderAction, char const *,
@@ -106,12 +103,37 @@ void
SBInputReader::SetIsDone(bool)
{
}
+
bool
SBInputReader::IsActive() const
{
return false;
}
+SBDebugger::SBDebugger() = default;
+
+SBDebugger::SBDebugger(const lldb::DebuggerSP &debugger_sp) :
+ m_opaque_sp(debugger_sp)
+{
+}
+
+SBDebugger::SBDebugger(const SBDebugger &rhs) :
+ m_opaque_sp (rhs.m_opaque_sp)
+{
+}
+
+SBDebugger::~SBDebugger() = default;
+
+SBDebugger &
+SBDebugger::operator = (const SBDebugger &rhs)
+{
+ if (this != &rhs)
+ {
+ m_opaque_sp = rhs.m_opaque_sp;
+ }
+ return *this;
+}
+
void
SBDebugger::Initialize ()
{
@@ -147,13 +169,13 @@ SBDebugger::Clear ()
SBDebugger
SBDebugger::Create()
{
- return SBDebugger::Create(false, NULL, NULL);
+ return SBDebugger::Create(false, nullptr, nullptr);
}
SBDebugger
SBDebugger::Create(bool source_init_files)
{
- return SBDebugger::Create (source_init_files, NULL, NULL);
+ return SBDebugger::Create (source_init_files, nullptr, nullptr);
}
SBDebugger
@@ -215,7 +237,7 @@ SBDebugger::Destroy (SBDebugger &debugger)
Debugger::Destroy (debugger.m_opaque_sp);
- if (debugger.m_opaque_sp.get() != NULL)
+ if (debugger.m_opaque_sp.get() != nullptr)
debugger.m_opaque_sp.reset();
}
@@ -237,42 +259,12 @@ SBDebugger::MemoryPressureDetected ()
ModuleList::RemoveOrphanSharedModules(mandatory);
}
-SBDebugger::SBDebugger () :
- m_opaque_sp ()
-{
-}
-
-SBDebugger::SBDebugger(const lldb::DebuggerSP &debugger_sp) :
- m_opaque_sp(debugger_sp)
-{
-}
-
-SBDebugger::SBDebugger(const SBDebugger &rhs) :
- m_opaque_sp (rhs.m_opaque_sp)
-{
-}
-
-SBDebugger &
-SBDebugger::operator = (const SBDebugger &rhs)
-{
- if (this != &rhs)
- {
- m_opaque_sp = rhs.m_opaque_sp;
- }
- return *this;
-}
-
-SBDebugger::~SBDebugger ()
-{
-}
-
bool
SBDebugger::IsValid() const
{
- return m_opaque_sp.get() != NULL;
+ return m_opaque_sp.get() != nullptr;
}
-
void
SBDebugger::SetAsync (bool b)
{
@@ -281,12 +273,9 @@ SBDebugger::SetAsync (bool b)
}
bool
-SBDebugger::GetAsync ()
+SBDebugger::GetAsync()
{
- if (m_opaque_sp)
- return m_opaque_sp->GetAsyncExecution();
- else
- return false;
+ return (m_opaque_sp ? m_opaque_sp->GetAsyncExecution() : false);
}
void
@@ -358,7 +347,7 @@ SBDebugger::GetInputFileHandle ()
if (stream_file_sp)
return stream_file_sp->GetFile().GetStream();
}
- return NULL;
+ return nullptr;
}
FILE *
@@ -370,20 +359,19 @@ SBDebugger::GetOutputFileHandle ()
if (stream_file_sp)
return stream_file_sp->GetFile().GetStream();
}
- return NULL;
+ return nullptr;
}
FILE *
SBDebugger::GetErrorFileHandle ()
{
if (m_opaque_sp)
- if (m_opaque_sp)
- {
- StreamFileSP stream_file_sp (m_opaque_sp->GetErrorFile());
- if (stream_file_sp)
- return stream_file_sp->GetFile().GetStream();
- }
- return NULL;
+ {
+ StreamFileSP stream_file_sp(m_opaque_sp->GetErrorFile());
+ if (stream_file_sp)
+ return stream_file_sp->GetFile().GetStream();
+ }
+ return nullptr;
}
void
@@ -432,12 +420,12 @@ SBDebugger::HandleCommand (const char *command)
sb_interpreter.HandleCommand (command, result, false);
- if (GetErrorFileHandle() != NULL)
+ if (GetErrorFileHandle() != nullptr)
result.PutError (GetErrorFileHandle());
- if (GetOutputFileHandle() != NULL)
+ if (GetOutputFileHandle() != nullptr)
result.PutOutput (GetOutputFileHandle());
- if (m_opaque_sp->GetAsyncExecution() == false)
+ if (!m_opaque_sp->GetAsyncExecution())
{
SBProcess process(GetCommandInterpreter().GetProcess ());
ProcessSP process_sp (process.GetSP());
@@ -492,7 +480,7 @@ SBDebugger::HandleProcessEvent (const SBProcess &process, const SBEvent &event,
{
// Drain stdout when we stop just in case we have any bytes
while ((len = process.GetSTDOUT (stdio_buffer, sizeof (stdio_buffer))) > 0)
- if (out != NULL)
+ if (out != nullptr)
::fwrite (stdio_buffer, 1, len, out);
}
@@ -500,7 +488,7 @@ SBDebugger::HandleProcessEvent (const SBProcess &process, const SBEvent &event,
{
// Drain stderr when we stop just in case we have any bytes
while ((len = process.GetSTDERR (stdio_buffer, sizeof (stdio_buffer))) > 0)
- if (err != NULL)
+ if (err != nullptr)
::fwrite (stdio_buffer, 1, len, err);
}
@@ -524,7 +512,6 @@ SBDebugger::GetSourceManager ()
return sb_source_manager;
}
-
bool
SBDebugger::GetDefaultArchitecture (char *arch_name, size_t arch_name_len)
{
@@ -547,7 +534,6 @@ SBDebugger::GetDefaultArchitecture (char *arch_name, size_t arch_name_len)
return false;
}
-
bool
SBDebugger::SetDefaultArchitecture (const char *arch_name)
{
@@ -564,12 +550,11 @@ SBDebugger::SetDefaultArchitecture (const char *arch_name)
}
ScriptLanguage
-SBDebugger::GetScriptingLanguage (const char *script_language_name)
+SBDebugger::GetScriptingLanguage(const char *script_language_name)
{
-
- return Args::StringToScriptLanguage (script_language_name,
- eScriptLanguageDefault,
- NULL);
+ return Args::StringToScriptLanguage(script_language_name,
+ eScriptLanguageDefault,
+ nullptr);
}
const char *
@@ -637,7 +622,7 @@ SBDebugger::CreateTarget (const char *filename,
}
else
{
- sb_error.SetErrorString("invalid target");
+ sb_error.SetErrorString("invalid debugger");
}
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@@ -659,12 +644,12 @@ SBDebugger::CreateTargetWithFileAndTargetTriple (const char *filename,
if (m_opaque_sp)
{
const bool add_dependent_modules = true;
- Error error (m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp,
- filename,
- target_triple,
- add_dependent_modules,
- NULL,
- target_sp));
+ Error error (m_opaque_sp->GetTargetList().CreateTarget(*m_opaque_sp,
+ filename,
+ target_triple,
+ add_dependent_modules,
+ nullptr,
+ target_sp));
sb_target.SetSP (target_sp);
}
@@ -689,12 +674,12 @@ SBDebugger::CreateTargetWithFileAndArch (const char *filename, const char *arch_
Error error;
const bool add_dependent_modules = true;
- error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp,
- filename,
- arch_cstr,
- add_dependent_modules,
- NULL,
- target_sp);
+ error = m_opaque_sp->GetTargetList().CreateTarget(*m_opaque_sp,
+ filename,
+ arch_cstr,
+ add_dependent_modules,
+ nullptr,
+ target_sp);
if (error.Success())
{
@@ -720,12 +705,12 @@ SBDebugger::CreateTarget (const char *filename)
{
Error error;
const bool add_dependent_modules = true;
- error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp,
- filename,
- NULL,
- add_dependent_modules,
- NULL,
- target_sp);
+ error = m_opaque_sp->GetTargetList().CreateTarget(*m_opaque_sp,
+ filename,
+ nullptr,
+ add_dependent_modules,
+ nullptr,
+ target_sp);
if (error.Success())
{
@@ -767,6 +752,7 @@ SBDebugger::DeleteTarget (lldb::SBTarget &target)
return result;
}
+
SBTarget
SBDebugger::GetTargetAtIndex (uint32_t idx)
{
@@ -813,7 +799,7 @@ SBDebugger::FindTargetWithFileAndArch (const char *filename, const char *arch_na
{
// No need to lock, the target list is thread safe
ArchSpec arch (arch_name, m_opaque_sp->GetPlatformList().GetSelectedPlatform().get());
- TargetSP target_sp (m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture (FileSpec(filename, false), arch_name ? &arch : NULL));
+ TargetSP target_sp (m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture(FileSpec(filename, false), arch_name ? &arch : nullptr));
sb_target.SetSP (target_sp);
}
return sb_target;
@@ -831,7 +817,6 @@ SBDebugger::FindTargetWithLLDBProcess (const ProcessSP &process_sp)
return sb_target;
}
-
uint32_t
SBDebugger::GetNumTargets ()
{
@@ -1000,6 +985,17 @@ SBDebugger::RunCommandInterpreter (bool auto_handle_events,
}
}
+SBError
+SBDebugger::RunREPL (lldb::LanguageType language, const char *repl_options)
+{
+ SBError error;
+ if (m_opaque_sp)
+ error.ref() = m_opaque_sp->RunREPL(language, repl_options);
+ else
+ error.SetErrorString ("invalid debugger");
+ return error;
+}
+
void
SBDebugger::reset (const DebuggerSP &debugger_sp)
{
@@ -1039,10 +1035,7 @@ SBDebugger::FindDebuggerWithID (int id)
const char *
SBDebugger::GetInstanceName()
{
- if (m_opaque_sp)
- return m_opaque_sp->GetInstanceName().AsCString();
- else
- return NULL;
+ return (m_opaque_sp ? m_opaque_sp->GetInstanceName().AsCString() : nullptr);
}
SBError
@@ -1098,11 +1091,9 @@ SBDebugger::GetInternalVariableValue (const char *var_name, const char *debugger
}
uint32_t
-SBDebugger::GetTerminalWidth () const
+SBDebugger::GetTerminalWidth() const
{
- if (m_opaque_sp)
- return m_opaque_sp->GetTerminalWidth ();
- return 0;
+ return (m_opaque_sp ? m_opaque_sp->GetTerminalWidth() : 0);
}
void
@@ -1122,9 +1113,7 @@ SBDebugger::GetPrompt() const
static_cast<void*>(m_opaque_sp.get()),
(m_opaque_sp ? m_opaque_sp->GetPrompt() : ""));
- if (m_opaque_sp)
- return m_opaque_sp->GetPrompt ();
- return 0;
+ return (m_opaque_sp ? m_opaque_sp->GetPrompt() : nullptr);
}
void
@@ -1133,14 +1122,11 @@ SBDebugger::SetPrompt (const char *prompt)
if (m_opaque_sp)
m_opaque_sp->SetPrompt (prompt);
}
-
ScriptLanguage
SBDebugger::GetScriptLanguage() const
{
- if (m_opaque_sp)
- return m_opaque_sp->GetScriptLanguage ();
- return eScriptLanguageNone;
+ return (m_opaque_sp ? m_opaque_sp->GetScriptLanguage() : eScriptLanguageNone);
}
void
@@ -1153,35 +1139,27 @@ SBDebugger::SetScriptLanguage (ScriptLanguage script_lang)
}
bool
-SBDebugger::SetUseExternalEditor (bool value)
+SBDebugger::SetUseExternalEditor(bool value)
{
- if (m_opaque_sp)
- return m_opaque_sp->SetUseExternalEditor (value);
- return false;
+ return (m_opaque_sp ? m_opaque_sp->SetUseExternalEditor(value) : false);
}
bool
-SBDebugger::GetUseExternalEditor ()
+SBDebugger::GetUseExternalEditor()
{
- if (m_opaque_sp)
- return m_opaque_sp->GetUseExternalEditor ();
- return false;
+ return (m_opaque_sp ? m_opaque_sp->GetUseExternalEditor() : false);
}
bool
-SBDebugger::SetUseColor (bool value)
+SBDebugger::SetUseColor(bool value)
{
- if (m_opaque_sp)
- return m_opaque_sp->SetUseColor (value);
- return false;
+ return (m_opaque_sp ? m_opaque_sp->SetUseColor(value) : false);
}
bool
-SBDebugger::GetUseColor () const
+SBDebugger::GetUseColor() const
{
- if (m_opaque_sp)
- return m_opaque_sp->GetUseColor ();
- return false;
+ return (m_opaque_sp ? m_opaque_sp->GetUseColor() : false);
}
bool
@@ -1204,12 +1182,9 @@ SBDebugger::GetDescription (SBStream &description)
user_id_t
SBDebugger::GetID()
{
- if (m_opaque_sp)
- return m_opaque_sp->GetID();
- return LLDB_INVALID_UID;
+ return (m_opaque_sp ? m_opaque_sp->GetID() : LLDB_INVALID_UID);
}
-
SBError
SBDebugger::SetCurrentPlatform (const char *platform_name_cstr)
{
@@ -1267,11 +1242,9 @@ SBDebugger::SetCurrentPlatformSDKRoot (const char *sysroot)
}
bool
-SBDebugger::GetCloseInputOnEOF () const
+SBDebugger::GetCloseInputOnEOF() const
{
- if (m_opaque_sp)
- return m_opaque_sp->GetCloseInputOnEOF ();
- return false;
+ return (m_opaque_sp ? m_opaque_sp->GetCloseInputOnEOF() : false);
}
void
@@ -1296,6 +1269,16 @@ SBDebugger::GetCategory (const char* category_name)
}
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();
+}
+
+SBTypeCategory
SBDebugger::CreateCategory (const char* category_name)
{
if (!category_name || *category_name == 0)
@@ -1349,7 +1332,7 @@ SBDebugger::GetFormatForType (SBTypeNameSpecifier type_name)
SBTypeSummary
SBDebugger::GetSummaryForType (SBTypeNameSpecifier type_name)
{
- if (type_name.IsValid() == false)
+ if (!type_name.IsValid())
return SBTypeSummary();
return SBTypeSummary(DataVisualization::GetSummaryForType(type_name.GetSP()));
}
@@ -1358,7 +1341,7 @@ SBDebugger::GetSummaryForType (SBTypeNameSpecifier type_name)
SBTypeFilter
SBDebugger::GetFilterForType (SBTypeNameSpecifier type_name)
{
- if (type_name.IsValid() == false)
+ if (!type_name.IsValid())
return SBTypeFilter();
return SBTypeFilter(DataVisualization::GetFilterForType(type_name.GetSP()));
}
@@ -1367,7 +1350,7 @@ SBDebugger::GetFilterForType (SBTypeNameSpecifier type_name)
SBTypeSynthetic
SBDebugger::GetSyntheticForType (SBTypeNameSpecifier type_name)
{
- if (type_name.IsValid() == false)
+ if (!type_name.IsValid())
return SBTypeSynthetic();
return SBTypeSynthetic(DataVisualization::GetSyntheticForType(type_name.GetSP()));
}
@@ -1380,8 +1363,7 @@ SBDebugger::EnableLog (const char *channel, const char **categories)
{
uint32_t log_options = LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME;
StreamString errors;
- return m_opaque_sp->EnableLog (channel, categories, NULL, log_options, errors);
-
+ return m_opaque_sp->EnableLog(channel, categories, nullptr, log_options, errors);
}
else
return false;
@@ -1395,5 +1377,3 @@ SBDebugger::SetLoggingCallback (lldb::LogOutputCallback log_callback, void *bato
return m_opaque_sp->SetLoggingCallback (log_callback, baton);
}
}
-
-
diff --git a/source/API/SBFrame.cpp b/source/API/SBFrame.cpp
index 08a5822cb781..02a215beb07d 100644
--- a/source/API/SBFrame.cpp
+++ b/source/API/SBFrame.cpp
@@ -7,10 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/API/SBFrame.h"
-
-#include <string>
+// C Includes
+// C++ Includes
#include <algorithm>
+#include <string>
+
+// Other libraries and framework includes
+// Project includes
+#include "lldb/API/SBFrame.h"
#include "lldb/lldb-types.h"
@@ -21,8 +25,8 @@
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/ValueObjectRegister.h"
#include "lldb/Core/ValueObjectVariable.h"
-#include "lldb/Expression/ClangPersistentVariables.h"
-#include "lldb/Expression/ClangUserExpression.h"
+#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
+#include "lldb/Expression/UserExpression.h"
#include "lldb/Host/Host.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/Function.h"
@@ -50,7 +54,6 @@
using namespace lldb;
using namespace lldb_private;
-
SBFrame::SBFrame () :
m_opaque_sp (new ExecutionContextRef())
{
@@ -76,6 +79,8 @@ SBFrame::SBFrame(const SBFrame &rhs) :
{
}
+SBFrame::~SBFrame() = default;
+
const SBFrame &
SBFrame::operator = (const SBFrame &rhs)
{
@@ -84,16 +89,10 @@ SBFrame::operator = (const SBFrame &rhs)
return *this;
}
-SBFrame::~SBFrame()
-{
-}
-
StackFrameSP
SBFrame::GetFrameSP() const
{
- if (m_opaque_sp)
- return m_opaque_sp->GetFrameSP();
- return StackFrameSP();
+ return (m_opaque_sp ? m_opaque_sp->GetFrameSP() : StackFrameSP());
}
void
@@ -105,7 +104,7 @@ SBFrame::SetFrameSP (const StackFrameSP &lldb_object_sp)
bool
SBFrame::IsValid() const
{
- return GetFrameSP().get() != NULL;
+ return GetFrameSP().get() != nullptr;
}
SBSymbolContext
@@ -116,7 +115,7 @@ SBFrame::GetSymbolContext (uint32_t resolve_scope) const
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
@@ -159,7 +158,7 @@ SBFrame::GetModule () const
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
@@ -202,7 +201,7 @@ SBFrame::GetCompileUnit () const
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
@@ -243,7 +242,7 @@ SBFrame::GetFunction () const
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
@@ -284,7 +283,7 @@ SBFrame::GetSymbol () const
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
@@ -324,7 +323,7 @@ SBFrame::GetBlock () const
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
@@ -364,7 +363,7 @@ SBFrame::GetFrameBlock () const
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Process *process = exe_ctx.GetProcessPtr();
@@ -405,7 +404,7 @@ SBFrame::GetLineEntry () const
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
@@ -464,7 +463,6 @@ SBFrame::GetCFA () const
return LLDB_INVALID_ADDRESS;
}
-
addr_t
SBFrame::GetPC () const
{
@@ -473,7 +471,7 @@ SBFrame::GetPC () const
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
@@ -484,7 +482,7 @@ SBFrame::GetPC () const
frame = exe_ctx.GetFramePtr();
if (frame)
{
- addr = frame->GetFrameCodeAddress().GetOpcodeLoadAddress (target);
+ addr = frame->GetFrameCodeAddress().GetOpcodeLoadAddress (target, eAddressClassCode);
}
else
{
@@ -514,7 +512,7 @@ SBFrame::SetPC (addr_t new_pc)
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
@@ -555,7 +553,7 @@ SBFrame::GetSP () const
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
@@ -587,7 +585,6 @@ SBFrame::GetSP () const
return addr;
}
-
addr_t
SBFrame::GetFP () const
{
@@ -596,7 +593,7 @@ SBFrame::GetFP () const
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
@@ -628,7 +625,6 @@ SBFrame::GetFP () const
return addr;
}
-
SBAddress
SBFrame::GetPCAddress () const
{
@@ -696,7 +692,7 @@ SBFrame::GetValueForVariablePath (const char *var_path, DynamicValueType use_dyn
SBValue sb_value;
Mutex::Locker api_locker;
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (var_path == NULL || var_path[0] == '\0')
+ if (var_path == nullptr || var_path[0] == '\0')
{
if (log)
log->Printf ("SBFrame::GetValueForVariablePath called with empty variable path.");
@@ -705,7 +701,7 @@ SBFrame::GetValueForVariablePath (const char *var_path, DynamicValueType use_dyn
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
@@ -762,7 +758,7 @@ SBFrame::FindVariable (const char *name, lldb::DynamicValueType use_dynamic)
VariableSP var_sp;
SBValue sb_value;
- if (name == NULL || name[0] == '\0')
+ if (name == nullptr || name[0] == '\0')
{
if (log)
log->Printf ("SBFrame::FindVariable called with empty name");
@@ -773,7 +769,7 @@ SBFrame::FindVariable (const char *name, lldb::DynamicValueType use_dynamic)
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
@@ -850,7 +846,7 @@ SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueTy
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBValue sb_value;
- if (name == NULL || name[0] == '\0')
+ if (name == nullptr || name[0] == '\0')
{
if (log)
log->Printf ("SBFrame::FindValue called with empty name.");
@@ -861,7 +857,7 @@ SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueTy
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
@@ -956,7 +952,7 @@ SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueTy
case eValueTypeConstResult: // constant result variables
{
ConstString const_name(name);
- ClangExpressionVariableSP expr_var_sp (target->GetPersistentVariables().GetVariable (const_name));
+ ExpressionVariableSP expr_var_sp (target->GetPersistentVariable (const_name));
if (expr_var_sp)
{
value_sp = expr_var_sp->GetValueObject();
@@ -1035,11 +1031,11 @@ const char *
SBFrame::Disassemble () const
{
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- const char *disassembly = NULL;
+ const char *disassembly = nullptr;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
@@ -1072,7 +1068,6 @@ SBFrame::Disassemble () const
return disassembly;
}
-
SBValueList
SBFrame::GetVariables (bool arguments,
bool locals,
@@ -1130,7 +1125,7 @@ SBFrame::GetVariables (const lldb::SBVariablesOptions& options)
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
const bool statics = options.GetIncludeStatics();
@@ -1156,7 +1151,7 @@ SBFrame::GetVariables (const lldb::SBVariablesOptions& options)
if (frame)
{
size_t i;
- VariableList *variable_list = NULL;
+ VariableList *variable_list = nullptr;
variable_list = frame->GetVariableList(true);
if (variable_list)
{
@@ -1194,9 +1189,9 @@ SBFrame::GetVariables (const lldb::SBVariablesOptions& options)
ValueObjectSP valobj_sp(frame->GetValueObjectForFrameVariable (variable_sp, eNoDynamicValues));
- if (false == include_runtime_support_values &&
- valobj_sp &&
- true == valobj_sp->IsRuntimeSupportValue())
+ if (!include_runtime_support_values &&
+ valobj_sp != nullptr &&
+ valobj_sp->IsRuntimeSupportValue())
continue;
SBValue value_sb;
@@ -1238,7 +1233,7 @@ SBFrame::GetRegisters ()
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
@@ -1290,7 +1285,7 @@ SBFrame::FindRegister (const char *name)
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
@@ -1394,6 +1389,10 @@ SBFrame::EvaluateExpression (const char *expr)
lldb::DynamicValueType fetch_dynamic_value = frame->CalculateTarget()->GetPreferDynamicValue();
options.SetFetchDynamicValue (fetch_dynamic_value);
options.SetUnwindOnError (true);
+ if (target->GetLanguage() != eLanguageTypeUnknown)
+ options.SetLanguage(target->GetLanguage());
+ else
+ options.SetLanguage(frame->GetLanguage());
return EvaluateExpression (expr, options);
}
return result;
@@ -1405,6 +1404,13 @@ SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dyna
SBExpressionOptions options;
options.SetFetchDynamicValue (fetch_dynamic_value);
options.SetUnwindOnError (true);
+ ExecutionContext exe_ctx(m_opaque_sp.get());
+ StackFrame *frame = exe_ctx.GetFramePtr();
+ Target *target = exe_ctx.GetTargetPtr();
+ if (target && target->GetLanguage() != eLanguageTypeUnknown)
+ options.SetLanguage(target->GetLanguage());
+ else if (frame)
+ options.SetLanguage(frame->GetLanguage());
return EvaluateExpression (expr, options);
}
@@ -1412,8 +1418,15 @@ SBValue
SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value, bool unwind_on_error)
{
SBExpressionOptions options;
+ ExecutionContext exe_ctx(m_opaque_sp.get());
options.SetFetchDynamicValue (fetch_dynamic_value);
options.SetUnwindOnError (unwind_on_error);
+ StackFrame *frame = exe_ctx.GetFramePtr();
+ Target *target = exe_ctx.GetTargetPtr();
+ if (target && target->GetLanguage() != eLanguageTypeUnknown)
+ options.SetLanguage(target->GetLanguage());
+ else if (frame)
+ options.SetLanguage(frame->GetLanguage());
return EvaluateExpression (expr, options);
}
@@ -1427,7 +1440,7 @@ SBFrame::EvaluateExpression (const char *expr, const SBExpressionOptions &option
ExpressionResults exe_results = eExpressionSetupError;
SBValue expr_result;
- if (expr == NULL || expr[0] == '\0')
+ if (expr == nullptr || expr[0] == '\0')
{
if (log)
log->Printf ("SBFrame::EvaluateExpression called with an empty expression");
@@ -1442,7 +1455,7 @@ SBFrame::EvaluateExpression (const char *expr, const SBExpressionOptions &option
if (log)
log->Printf ("SBFrame()::EvaluateExpression (expr=\"%s\")...", expr);
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
@@ -1469,7 +1482,7 @@ SBFrame::EvaluateExpression (const char *expr, const SBExpressionOptions &option
expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
if (target->GetDisplayExpressionsInCrashlogs())
- Host::SetCrashDescription (NULL);
+ Host::SetCrashDescription(nullptr);
}
else
{
@@ -1509,7 +1522,7 @@ SBFrame::IsInlined() const
{
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
ExecutionContext exe_ctx(m_opaque_sp.get());
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
@@ -1523,7 +1536,7 @@ SBFrame::IsInlined() const
Block *block = frame->GetSymbolContext(eSymbolContextBlock).block;
if (block)
- return block->GetContainingInlinedBlock () != NULL;
+ return block->GetContainingInlinedBlock() != nullptr;
}
else
{
@@ -1551,9 +1564,9 @@ const char *
SBFrame::GetFunctionName() const
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- const char *name = NULL;
+ const char *name = nullptr;
ExecutionContext exe_ctx(m_opaque_sp.get());
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
@@ -1575,13 +1588,13 @@ SBFrame::GetFunctionName() const
}
}
- if (name == NULL)
+ if (name == nullptr)
{
if (sc.function)
name = sc.function->GetName().GetCString();
}
- if (name == NULL)
+ if (name == nullptr)
{
if (sc.symbol)
name = sc.symbol->GetName().GetCString();
@@ -1607,9 +1620,9 @@ const char *
SBFrame::GetDisplayFunctionName()
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- const char *name = NULL;
+ const char *name = nullptr;
ExecutionContext exe_ctx(m_opaque_sp.get());
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
@@ -1631,13 +1644,13 @@ SBFrame::GetDisplayFunctionName()
}
}
- if (name == NULL)
+ if (name == nullptr)
{
if (sc.function)
name = sc.function->GetDisplayName().GetCString();
}
- if (name == NULL)
+ if (name == nullptr)
{
if (sc.symbol)
name = sc.symbol->GetDisplayName().GetCString();
diff --git a/source/API/SBFunction.cpp b/source/API/SBFunction.cpp
index 2ec6072b51eb..2d03d53fd9f7 100644
--- a/source/API/SBFunction.cpp
+++ b/source/API/SBFunction.cpp
@@ -16,6 +16,7 @@
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Target.h"
@@ -216,6 +217,24 @@ SBFunction::GetEndAddress ()
return addr;
}
+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);
+ if (variable_list_sp)
+ {
+ VariableList arguments;
+ variable_list_sp->AppendVariablesWithScope (eValueTypeVariableArgument, arguments, true);
+ lldb::VariableSP variable_sp = arguments.GetVariableAtIndex(arg_idx);
+ if (variable_sp)
+ return variable_sp->GetName().GetCString();
+ }
+ }
+ return nullptr;
+}
uint32_t
SBFunction::GetPrologueByteSize ()
@@ -258,4 +277,13 @@ SBFunction::GetLanguage ()
return lldb::eLanguageTypeUnknown;
}
-
+bool
+SBFunction::GetIsOptimized ()
+{
+ if (m_opaque_ptr)
+ {
+ if (m_opaque_ptr->GetCompileUnit())
+ return m_opaque_ptr->GetCompileUnit()->GetIsOptimized();
+ }
+ return false;
+}
diff --git a/source/API/SBLanguageRuntime.cpp b/source/API/SBLanguageRuntime.cpp
index 93a54cd76dff..743343e48589 100644
--- a/source/API/SBLanguageRuntime.cpp
+++ b/source/API/SBLanguageRuntime.cpp
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/API/SBLanguageRuntime.h"
-#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Target/Language.h"
using namespace lldb;
using namespace lldb_private;
@@ -16,11 +16,11 @@ using namespace lldb_private;
lldb::LanguageType
SBLanguageRuntime::GetLanguageTypeFromString (const char *string)
{
- return LanguageRuntime::GetLanguageTypeFromString(string);
+ return Language::GetLanguageTypeFromString(string);
}
const char *
SBLanguageRuntime::GetNameForLanguageType (lldb::LanguageType language)
{
- return LanguageRuntime::GetNameForLanguageType(language);
+ return Language::GetNameForLanguageType(language);
}
diff --git a/source/API/SBModule.cpp b/source/API/SBModule.cpp
index 0249a7edcd2b..a810940f301f 100644
--- a/source/API/SBModule.cpp
+++ b/source/API/SBModule.cpp
@@ -20,10 +20,10 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Core/ValueObjectVariable.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/Symtab.h"
+#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/Target.h"
@@ -521,7 +521,11 @@ SBModule::FindFirstType (const char *name_cstr)
sb_type = SBType (module_sp->FindFirstType(sc, name, exact_match));
if (!sb_type.IsValid())
- sb_type = SBType (ClangASTContext::GetBasicType (module_sp->GetClangASTContext().getASTContext(), name));
+ {
+ TypeSystem *type_system = module_sp->GetTypeSystemForLanguage(eLanguageTypeC);
+ if (type_system)
+ sb_type = SBType (type_system->GetBuiltinTypeByName(name));
+ }
}
return sb_type;
}
@@ -531,7 +535,11 @@ SBModule::GetBasicType(lldb::BasicType type)
{
ModuleSP module_sp (GetSP ());
if (module_sp)
- return SBType (ClangASTContext::GetBasicType (module_sp->GetClangASTContext().getASTContext(), type));
+ {
+ TypeSystem *type_system = module_sp->GetTypeSystemForLanguage(eLanguageTypeC);
+ if (type_system)
+ return SBType (type_system->GetBasicTypeFromAST(type));
+ }
return SBType();
}
@@ -564,9 +572,13 @@ SBModule::FindTypes (const char *type)
}
else
{
- SBType sb_type(ClangASTContext::GetBasicType (module_sp->GetClangASTContext().getASTContext(), name));
- if (sb_type.IsValid())
- retval.Append(sb_type);
+ TypeSystem *type_system = module_sp->GetTypeSystemForLanguage(eLanguageTypeC);
+ if (type_system)
+ {
+ CompilerType compiler_type = type_system->GetBuiltinTypeByName(name);
+ if (compiler_type)
+ retval.Append(SBType(compiler_type));
+ }
}
}
diff --git a/source/API/SBPlatform.cpp b/source/API/SBPlatform.cpp
index 97ffcf149750..b8dc01ba7811 100644
--- a/source/API/SBPlatform.cpp
+++ b/source/API/SBPlatform.cpp
@@ -189,7 +189,7 @@ SBPlatformShellCommand::~SBPlatformShellCommand()
void
SBPlatformShellCommand::Clear()
{
- m_opaque_ptr->m_output = std::move(std::string());
+ m_opaque_ptr->m_output = std::string();
m_opaque_ptr->m_status = 0;
m_opaque_ptr->m_signo = 0;
}
diff --git a/source/API/SBProcess.cpp b/source/API/SBProcess.cpp
index 01bfaf9aff01..dceadeca69e5 100644
--- a/source/API/SBProcess.cpp
+++ b/source/API/SBProcess.cpp
@@ -19,6 +19,7 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
+#include "lldb/Core/PluginManager.h"
#include "lldb/Core/State.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
@@ -409,7 +410,7 @@ SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
- log->Printf ("SBProcess(%p)::GetProfileData (dst=\"%.*s\", dst_len=%" PRIu64 ") => %" PRIu64,
+ 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),
@@ -1287,7 +1288,15 @@ SBProcess::GetNumSupportedHardwareWatchpoints (lldb::SBError &sb_error) const
}
uint32_t
-SBProcess::LoadImage (lldb::SBFileSpec &sb_image_spec, lldb::SBError &sb_error)
+SBProcess::LoadImage (lldb::SBFileSpec &sb_remote_image_spec, lldb::SBError &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)
{
ProcessSP process_sp(GetSP());
if (process_sp)
@@ -1296,7 +1305,11 @@ SBProcess::LoadImage (lldb::SBFileSpec &sb_image_spec, lldb::SBError &sb_error)
if (stop_locker.TryLock(&process_sp->GetRunLock()))
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
- return process_sp->LoadImage (*sb_image_spec, sb_error.ref());
+ 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
{
@@ -1321,7 +1334,8 @@ SBProcess::UnloadImage (uint32_t image_token)
if (stop_locker.TryLock(&process_sp->GetRunLock()))
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
- sb_error.SetError (process_sp->UnloadImage (image_token));
+ PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
+ sb_error.SetError (platform_sp->UnloadImage (process_sp.get(), image_token));
}
else
{
@@ -1425,3 +1439,27 @@ SBProcess::IsInstrumentationRuntimePresent(InstrumentationRuntimeType type)
return runtime_sp->IsActive();
}
+
+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;
+ }
+
+ Mutex::Locker api_locker(process_sp->GetTarget().GetAPIMutex());
+
+ if (process_sp->GetState() != eStateStopped)
+ {
+ error.SetErrorString("the process is not stopped");
+ return error;
+ }
+
+ FileSpec core_file(file_name, false);
+ error.ref() = PluginManager::SaveCore(process_sp, core_file);
+ return error;
+}
diff --git a/source/API/SBStream.cpp b/source/API/SBStream.cpp
index f50334f74189..f3be3be6a10d 100644
--- a/source/API/SBStream.cpp
+++ b/source/API/SBStream.cpp
@@ -23,6 +23,13 @@ SBStream::SBStream () :
{
}
+SBStream::SBStream (SBStream &&rhs) :
+ m_opaque_ap (std::move(rhs.m_opaque_ap)),
+ m_is_file (rhs.m_is_file)
+{
+}
+
+
SBStream::~SBStream ()
{
}
diff --git a/source/API/SBTarget.cpp b/source/API/SBTarget.cpp
index 6597d4e77c73..c7595c3c39fb 100644
--- a/source/API/SBTarget.cpp
+++ b/source/API/SBTarget.cpp
@@ -52,6 +52,7 @@
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/VariableList.h"
#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"
@@ -847,11 +848,11 @@ SBTarget::BreakpointCreateByName (const char *symbol_name,
{
FileSpecList module_spec_list;
module_spec_list.Append (FileSpec (module_name, false));
- *sb_bp = target_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, skip_prologue, internal, hardware);
+ *sb_bp = target_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown, skip_prologue, internal, hardware);
}
else
{
- *sb_bp = target_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, skip_prologue, internal, hardware);
+ *sb_bp = target_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown, skip_prologue, internal, hardware);
}
}
@@ -869,7 +870,7 @@ SBTarget::BreakpointCreateByName (const char *symbol_name,
const SBFileSpecList &comp_unit_list)
{
uint32_t name_type_mask = eFunctionNameTypeAuto;
- return BreakpointCreateByName (symbol_name, name_type_mask, module_list, comp_unit_list);
+ return BreakpointCreateByName (symbol_name, name_type_mask, eLanguageTypeUnknown, module_list, comp_unit_list);
}
lldb::SBBreakpoint
@@ -878,6 +879,16 @@ SBTarget::BreakpointCreateByName (const char *symbol_name,
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list)
{
+ return 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));
SBBreakpoint sb_bp;
@@ -892,6 +903,7 @@ SBTarget::BreakpointCreateByName (const char *symbol_name,
comp_unit_list.get(),
symbol_name,
name_type_mask,
+ symbol_language,
skip_prologue,
internal,
hardware);
@@ -912,6 +924,17 @@ SBTarget::BreakpointCreateByNames (const char *symbol_names[],
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::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)
+{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBBreakpoint sb_bp;
@@ -923,13 +946,14 @@ SBTarget::BreakpointCreateByNames (const char *symbol_names[],
const bool hardware = false;
const LazyBool skip_prologue = eLazyBoolCalculate;
*sb_bp = target_sp->CreateBreakpoint (module_list.get(),
- comp_unit_list.get(),
- symbol_names,
- num_names,
- name_type_mask,
- skip_prologue,
- internal,
- hardware);
+ comp_unit_list.get(),
+ symbol_names,
+ num_names,
+ name_type_mask,
+ symbol_language,
+ skip_prologue,
+ internal,
+ hardware);
}
if (log)
@@ -959,6 +983,30 @@ SBBreakpoint
SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex,
const char *module_name)
{
+ SBFileSpecList module_spec_list;
+ SBFileSpecList comp_unit_list;
+ if (module_name && module_name[0])
+ {
+ module_spec_list.Append (FileSpec (module_name, false));
+
+ }
+ return 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::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));
SBBreakpoint sb_bp;
@@ -970,75 +1018,72 @@ SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex,
const bool internal = false;
const bool hardware = false;
const LazyBool skip_prologue = eLazyBoolCalculate;
-
- if (module_name && module_name[0])
- {
- FileSpecList module_spec_list;
- module_spec_list.Append (FileSpec (module_name, false));
-
- *sb_bp = target_sp->CreateFuncRegexBreakpoint (&module_spec_list, NULL, regexp, skip_prologue, internal, hardware);
- }
- else
- {
- *sb_bp = target_sp->CreateFuncRegexBreakpoint (NULL, NULL, regexp, skip_prologue, internal, hardware);
- }
+
+ *sb_bp = target_sp->CreateFuncRegexBreakpoint (module_list.get(), comp_unit_list.get(), regexp, symbol_language, skip_prologue, internal, hardware);
}
if (log)
- log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\", module_name=\"%s\") => SBBreakpoint(%p)",
+ log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\") => SBBreakpoint(%p)",
static_cast<void*>(target_sp.get()), symbol_name_regex,
- module_name, static_cast<void*>(sb_bp.get()));
+ static_cast<void*>(sb_bp.get()));
return sb_bp;
}
-lldb::SBBreakpoint
-SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex,
- const SBFileSpecList &module_list,
- const SBFileSpecList &comp_unit_list)
+SBBreakpoint
+SBTarget::BreakpointCreateByAddress (addr_t address)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBBreakpoint sb_bp;
TargetSP target_sp(GetSP());
- if (target_sp && symbol_name_regex && symbol_name_regex[0])
+ if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
- RegularExpression regexp(symbol_name_regex);
- const bool internal = false;
const bool hardware = false;
- const LazyBool skip_prologue = eLazyBoolCalculate;
-
- *sb_bp = target_sp->CreateFuncRegexBreakpoint (module_list.get(), comp_unit_list.get(), regexp, skip_prologue, internal, hardware);
+ *sb_bp = target_sp->CreateBreakpoint (address, false, hardware);
}
if (log)
- log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\") => SBBreakpoint(%p)",
- static_cast<void*>(target_sp.get()), symbol_name_regex,
+ 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.get()));
return sb_bp;
}
SBBreakpoint
-SBTarget::BreakpointCreateByAddress (addr_t address)
+SBTarget::BreakpointCreateBySBAddress (SBAddress &sb_address)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
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;
+ }
+
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
const bool hardware = false;
- *sb_bp = target_sp->CreateBreakpoint (address, false, hardware);
+ *sb_bp = target_sp->CreateBreakpoint (sb_address.ref(), false, hardware);
}
if (log)
- log->Printf ("SBTarget(%p)::BreakpointCreateByAddress (address=%" PRIu64 ") => SBBreakpoint(%p)",
+ {
+ SBStream s;
+ sb_address.GetDescription(s);
+ log->Printf ("SBTarget(%p)::BreakpointCreateBySBAddress (address=%s) => SBBreakpoint(%p)",
static_cast<void*>(target_sp.get()),
- static_cast<uint64_t>(address),
+ s.GetData(),
static_cast<void*>(sb_bp.get()));
+ }
return sb_bp;
}
@@ -1131,7 +1176,7 @@ SBTarget::BreakpointCreateForException (lldb::LanguageType language,
if (log)
log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (Language: %s, catch: %s throw: %s) => SBBreakpoint(%p)",
static_cast<void*>(target_sp.get()),
- LanguageRuntime::GetNameForLanguageType(language),
+ Language::GetNameForLanguageType(language),
catch_bp ? "on" : "off", throw_bp ? "on" : "off",
static_cast<void*>(sb_bp.get()));
@@ -1344,7 +1389,7 @@ SBTarget::WatchAddress (lldb::addr_t addr, size_t size, bool read, bool write, S
// Target::CreateWatchpoint() is thread safe.
Error cw_error;
// This API doesn't take in a type, so we can't figure out what it is.
- ClangASTType *type = NULL;
+ CompilerType *type = NULL;
watchpoint_sp = target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error);
error.SetError(cw_error);
sb_watchpoint.SetSP (watchpoint_sp);
@@ -1398,7 +1443,7 @@ SBTarget::CreateValueFromAddress (const char *name, SBAddress addr, SBType type)
{
lldb::addr_t load_addr(addr.GetLoadAddress(*this));
ExecutionContext exe_ctx (ExecutionContextRef(ExecutionContext(m_opaque_sp.get(),false)));
- ClangASTType ast_type(type.GetSP()->GetClangASTType(true));
+ CompilerType ast_type(type.GetSP()->GetCompilerType(true));
new_value_sp = ValueObject::CreateValueObjectFromAddress(name, load_addr, exe_ctx, ast_type);
}
sb_value.SetSP(new_value_sp);
@@ -1425,7 +1470,7 @@ SBTarget::CreateValueFromData (const char *name, lldb::SBData data, lldb::SBType
{
DataExtractorSP extractor(*data);
ExecutionContext exe_ctx (ExecutionContextRef(ExecutionContext(m_opaque_sp.get(),false)));
- ClangASTType ast_type(type.GetSP()->GetClangASTType(true));
+ CompilerType ast_type(type.GetSP()->GetCompilerType(true));
new_value_sp = ValueObject::CreateValueObjectFromData(name, *extractor, exe_ctx, ast_type);
}
sb_value.SetSP(new_value_sp);
@@ -1806,7 +1851,7 @@ SBTarget::FindFirstType (const char* typename_cstr)
if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0)
{
- if (ClangASTType type = ClangASTContext::GetTypeForDecl(decls[0]))
+ if (CompilerType type = ClangASTContext::GetTypeForDecl(decls[0]))
{
return SBType(type);
}
@@ -1886,7 +1931,7 @@ SBTarget::FindTypes (const char* typename_cstr)
{
for (clang::NamedDecl *decl : decls)
{
- if (ClangASTType type = ClangASTContext::GetTypeForDecl(decl))
+ if (CompilerType type = ClangASTContext::GetTypeForDecl(decl))
{
sb_type_list.Append(SBType(type));
}
diff --git a/source/API/SBThread.cpp b/source/API/SBThread.cpp
index 42b5c9affe50..2f3887ebce3a 100644
--- a/source/API/SBThread.cpp
+++ b/source/API/SBThread.cpp
@@ -747,7 +747,7 @@ SBThread::StepOver (lldb::RunMode stop_other_threads)
const LazyBool avoid_no_debug = eLazyBoolCalculate;
SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
new_plan_sp = thread->QueueThreadPlanForStepOverRange (abort_other_plans,
- sc.line_entry.range,
+ sc.line_entry,
sc,
stop_other_threads,
avoid_no_debug);
@@ -799,7 +799,7 @@ SBThread::StepInto (const char *target_name, lldb::RunMode stop_other_threads)
const LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate;
SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
new_plan_sp = thread->QueueThreadPlanForStepInRange (abort_other_plans,
- sc.line_entry.range,
+ sc.line_entry,
sc,
target_name,
stop_other_threads,
@@ -826,7 +826,6 @@ SBThread::StepOut ()
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
-
if (log)
log->Printf ("SBThread(%p)::StepOut ()",
static_cast<void*>(exe_ctx.GetThreadPtr()));
@@ -861,6 +860,14 @@ SBThread::StepOutOfFrame (lldb::SBFrame &sb_frame)
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
+ if (!sb_frame.IsValid())
+ {
+ if (log)
+ log->Printf("SBThread(%p)::StepOutOfFrame passed an invalid frame, returning.",
+ static_cast<void*>(exe_ctx.GetThreadPtr()));
+ return;
+ }
+
StackFrameSP frame_sp (sb_frame.GetFrameSP());
if (log)
{
@@ -877,6 +884,13 @@ SBThread::StepOutOfFrame (lldb::SBFrame &sb_frame)
bool abort_other_plans = false;
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());
+ }
ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut (abort_other_plans,
NULL,
diff --git a/source/API/SBType.cpp b/source/API/SBType.cpp
index 31a4eba8bf33..4922b491a227 100644
--- a/source/API/SBType.cpp
+++ b/source/API/SBType.cpp
@@ -13,24 +13,24 @@
#include "lldb/API/SBStream.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Log.h"
+#include "lldb/Core/Mangled.h"
#include "lldb/Core/Stream.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/TypeSystem.h"
-#include "clang/AST/Decl.h"
+#include "llvm/ADT/APSInt.h"
using namespace lldb;
using namespace lldb_private;
-using namespace clang;
SBType::SBType() :
m_opaque_sp()
{
}
-SBType::SBType (const ClangASTType &type) :
- m_opaque_sp(new TypeImpl(ClangASTType(type.GetASTContext(),
+SBType::SBType (const CompilerType &type) :
+ m_opaque_sp(new TypeImpl(CompilerType(type.GetTypeSystem(),
type.GetOpaqueQualType())))
{
}
@@ -143,7 +143,7 @@ SBType::GetByteSize()
if (!IsValid())
return 0;
- return m_opaque_sp->GetClangASTType(false).GetByteSize(nullptr);
+ return m_opaque_sp->GetCompilerType(false).GetByteSize(nullptr);
}
@@ -152,7 +152,7 @@ SBType::IsPointerType()
{
if (!IsValid())
return false;
- return m_opaque_sp->GetClangASTType(true).IsPointerType();
+ return m_opaque_sp->GetCompilerType(true).IsPointerType();
}
bool
@@ -160,7 +160,7 @@ SBType::IsArrayType()
{
if (!IsValid())
return false;
- return m_opaque_sp->GetClangASTType(true).IsArrayType(nullptr, nullptr, nullptr);
+ return m_opaque_sp->GetCompilerType(true).IsArrayType(nullptr, nullptr, nullptr);
}
bool
@@ -168,7 +168,7 @@ SBType::IsVectorType()
{
if (!IsValid())
return false;
- return m_opaque_sp->GetClangASTType(true).IsVectorType(nullptr, nullptr);
+ return m_opaque_sp->GetCompilerType(true).IsVectorType(nullptr, nullptr);
}
bool
@@ -176,7 +176,7 @@ SBType::IsReferenceType()
{
if (!IsValid())
return false;
- return m_opaque_sp->GetClangASTType(true).IsReferenceType();
+ return m_opaque_sp->GetCompilerType(true).IsReferenceType();
}
SBType
@@ -225,7 +225,7 @@ SBType::GetArrayElementType()
{
if (!IsValid())
return SBType();
- return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetClangASTType(true).GetArrayElementType())));
+ return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetCompilerType(true).GetArrayElementType())));
}
SBType
@@ -234,8 +234,8 @@ SBType::GetVectorElementType ()
SBType type_sb;
if (IsValid())
{
- ClangASTType vector_element_type;
- if (m_opaque_sp->GetClangASTType(true).IsVectorType(&vector_element_type, nullptr))
+ CompilerType vector_element_type;
+ if (m_opaque_sp->GetCompilerType(true).IsVectorType(&vector_element_type, nullptr))
type_sb.SetSP(TypeImplSP(new TypeImpl(vector_element_type)));
}
return type_sb;
@@ -246,7 +246,7 @@ SBType::IsFunctionType ()
{
if (!IsValid())
return false;
- return m_opaque_sp->GetClangASTType(true).IsFunctionType();
+ return m_opaque_sp->GetCompilerType(true).IsFunctionType();
}
bool
@@ -254,7 +254,7 @@ SBType::IsPolymorphicClass ()
{
if (!IsValid())
return false;
- return m_opaque_sp->GetClangASTType(true).IsPolymorphicClass();
+ return m_opaque_sp->GetCompilerType(true).IsPolymorphicClass();
}
bool
@@ -262,7 +262,15 @@ SBType::IsTypedefType ()
{
if (!IsValid())
return false;
- return m_opaque_sp->GetClangASTType(true).IsTypedefType();
+ return m_opaque_sp->GetCompilerType(true).IsTypedefType();
+}
+
+bool
+SBType::IsAnonymousType ()
+{
+ if (!IsValid())
+ return false;
+ return m_opaque_sp->GetCompilerType(true).IsAnonymousType();
}
lldb::SBType
@@ -270,9 +278,9 @@ SBType::GetFunctionReturnType ()
{
if (IsValid())
{
- ClangASTType return_clang_type (m_opaque_sp->GetClangASTType(true).GetFunctionReturnType());
- if (return_clang_type.IsValid())
- return SBType(return_clang_type);
+ CompilerType return_type (m_opaque_sp->GetCompilerType(true).GetFunctionReturnType());
+ if (return_type.IsValid())
+ return SBType(return_type);
}
return lldb::SBType();
}
@@ -283,7 +291,7 @@ SBType::GetFunctionArgumentTypes ()
SBTypeList sb_type_list;
if (IsValid())
{
- ClangASTType func_type(m_opaque_sp->GetClangASTType(true));
+ CompilerType func_type(m_opaque_sp->GetCompilerType(true));
size_t count = func_type.GetNumberOfFunctionArguments();
for (size_t i = 0;
i < count;
@@ -300,7 +308,7 @@ SBType::GetNumberOfMemberFunctions ()
{
if (IsValid())
{
- return m_opaque_sp->GetClangASTType(true).GetNumMemberFunctions();
+ return m_opaque_sp->GetCompilerType(true).GetNumMemberFunctions();
}
return 0;
}
@@ -310,7 +318,7 @@ SBType::GetMemberFunctionAtIndex (uint32_t idx)
{
SBTypeMemberFunction sb_func_type;
if (IsValid())
- sb_func_type.reset(new TypeMemberFunctionImpl(m_opaque_sp->GetClangASTType(true).GetMemberFunctionAtIndex(idx)));
+ sb_func_type.reset(new TypeMemberFunctionImpl(m_opaque_sp->GetCompilerType(true).GetMemberFunctionAtIndex(idx)));
return sb_func_type;
}
@@ -335,15 +343,15 @@ lldb::BasicType
SBType::GetBasicType()
{
if (IsValid())
- return m_opaque_sp->GetClangASTType(false).GetBasicTypeEnumeration ();
+ return m_opaque_sp->GetCompilerType(false).GetBasicTypeEnumeration ();
return eBasicTypeInvalid;
}
SBType
SBType::GetBasicType(lldb::BasicType basic_type)
{
- if (IsValid())
- return SBType (ClangASTContext::GetBasicType (m_opaque_sp->GetClangASTContext(false), basic_type));
+ if (IsValid() && m_opaque_sp->IsValid())
+ return SBType(m_opaque_sp->GetTypeSystem(false)->GetBasicTypeFromAST(basic_type));
return SBType();
}
@@ -351,7 +359,7 @@ uint32_t
SBType::GetNumberOfDirectBaseClasses ()
{
if (IsValid())
- return m_opaque_sp->GetClangASTType(true).GetNumDirectBaseClasses();
+ return m_opaque_sp->GetCompilerType(true).GetNumDirectBaseClasses();
return 0;
}
@@ -359,7 +367,7 @@ uint32_t
SBType::GetNumberOfVirtualBaseClasses ()
{
if (IsValid())
- return m_opaque_sp->GetClangASTType(true).GetNumVirtualBaseClasses();
+ return m_opaque_sp->GetCompilerType(true).GetNumVirtualBaseClasses();
return 0;
}
@@ -367,7 +375,7 @@ uint32_t
SBType::GetNumberOfFields ()
{
if (IsValid())
- return m_opaque_sp->GetClangASTType(true).GetNumFields();
+ return m_opaque_sp->GetCompilerType(true).GetNumFields();
return 0;
}
@@ -394,16 +402,10 @@ SBType::GetDirectBaseClassAtIndex (uint32_t idx)
SBTypeMember sb_type_member;
if (IsValid())
{
- ClangASTType this_type (m_opaque_sp->GetClangASTType (true));
- if (this_type.IsValid())
- {
- uint32_t bit_offset = 0;
- ClangASTType base_class_type (this_type.GetDirectBaseClassAtIndex(idx, &bit_offset));
- if (base_class_type.IsValid())
- {
- sb_type_member.reset (new TypeMemberImpl (TypeImplSP(new TypeImpl(base_class_type)), bit_offset));
- }
- }
+ uint32_t bit_offset = 0;
+ CompilerType base_class_type = m_opaque_sp->GetCompilerType (true).GetDirectBaseClassAtIndex(idx, &bit_offset);
+ if (base_class_type.IsValid())
+ sb_type_member.reset (new TypeMemberImpl (TypeImplSP(new TypeImpl(base_class_type)), bit_offset));
}
return sb_type_member;
@@ -415,16 +417,10 @@ SBType::GetVirtualBaseClassAtIndex (uint32_t idx)
SBTypeMember sb_type_member;
if (IsValid())
{
- ClangASTType this_type (m_opaque_sp->GetClangASTType (true));
- if (this_type.IsValid())
- {
- uint32_t bit_offset = 0;
- ClangASTType base_class_type (this_type.GetVirtualBaseClassAtIndex(idx, &bit_offset));
- if (base_class_type.IsValid())
- {
- sb_type_member.reset (new TypeMemberImpl (TypeImplSP(new TypeImpl(base_class_type)), bit_offset));
- }
- }
+ uint32_t bit_offset = 0;
+ CompilerType base_class_type = m_opaque_sp->GetCompilerType (true).GetVirtualBaseClassAtIndex(idx, &bit_offset);
+ if (base_class_type.IsValid())
+ sb_type_member.reset (new TypeMemberImpl (TypeImplSP(new TypeImpl(base_class_type)), bit_offset));
}
return sb_type_member;
}
@@ -435,16 +431,14 @@ SBType::GetEnumMembers ()
SBTypeEnumMemberList sb_enum_member_list;
if (IsValid())
{
- const clang::EnumDecl *enum_decl = m_opaque_sp->GetClangASTType(true).GetFullyUnqualifiedType().GetAsEnumDecl();
- if (enum_decl)
+ CompilerType this_type (m_opaque_sp->GetCompilerType (true));
+ if (this_type.IsValid())
{
- clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
- for (enum_pos = enum_decl->enumerator_begin(), enum_end_pos = enum_decl->enumerator_end(); enum_pos != enum_end_pos; ++enum_pos)
- {
- SBTypeEnumMember enum_member;
- enum_member.reset(new TypeEnumMemberImpl(*enum_pos, ClangASTType(m_opaque_sp->GetClangASTContext(true), enum_decl->getIntegerType())));
+ this_type.ForEachEnumerator([&sb_enum_member_list] (const CompilerType &integer_type, const ConstString &name, const llvm::APSInt &value) -> bool {
+ SBTypeEnumMember enum_member (lldb::TypeEnumMemberImplSP (new TypeEnumMemberImpl(lldb::TypeImplSP(new TypeImpl(integer_type)), name, value)));
sb_enum_member_list.Append(enum_member);
- }
+ return true; // Keep iterating
+ });
}
}
return sb_enum_member_list;
@@ -456,14 +450,14 @@ SBType::GetFieldAtIndex (uint32_t idx)
SBTypeMember sb_type_member;
if (IsValid())
{
- ClangASTType this_type (m_opaque_sp->GetClangASTType (false));
+ CompilerType this_type (m_opaque_sp->GetCompilerType (false));
if (this_type.IsValid())
{
uint64_t bit_offset = 0;
uint32_t bitfield_bit_size = 0;
bool is_bitfield = false;
std::string name_sstr;
- ClangASTType field_type (this_type.GetFieldAtIndex (idx,
+ CompilerType field_type (this_type.GetFieldAtIndex (idx,
name_sstr,
&bit_offset,
&bitfield_bit_size,
@@ -489,7 +483,7 @@ SBType::IsTypeComplete()
{
if (!IsValid())
return false;
- return m_opaque_sp->GetClangASTType(false).IsCompleteType();
+ return m_opaque_sp->GetCompilerType(false).IsCompleteType();
}
uint32_t
@@ -497,7 +491,7 @@ SBType::GetTypeFlags ()
{
if (!IsValid())
return 0;
- return m_opaque_sp->GetClangASTType(true).GetTypeInfo();
+ return m_opaque_sp->GetCompilerType(true).GetTypeInfo();
}
const char*
@@ -520,7 +514,7 @@ lldb::TypeClass
SBType::GetTypeClass ()
{
if (IsValid())
- return m_opaque_sp->GetClangASTType(true).GetTypeClass();
+ return m_opaque_sp->GetCompilerType(true).GetTypeClass();
return lldb::eTypeClassInvalid;
}
@@ -528,7 +522,7 @@ uint32_t
SBType::GetNumberOfTemplateArguments ()
{
if (IsValid())
- return m_opaque_sp->GetClangASTType(false).GetNumTemplateArguments();
+ return m_opaque_sp->GetCompilerType(false).GetNumTemplateArguments();
return 0;
}
@@ -538,7 +532,7 @@ SBType::GetTemplateArgumentType (uint32_t idx)
if (IsValid())
{
TemplateArgumentKind kind = eTemplateArgumentKindNull;
- ClangASTType template_arg_type = m_opaque_sp->GetClangASTType(false).GetTemplateArgument (idx, kind);
+ CompilerType template_arg_type = m_opaque_sp->GetCompilerType(false).GetTemplateArgument(idx, kind);
if (template_arg_type.IsValid())
return SBType(template_arg_type);
}
@@ -551,7 +545,7 @@ SBType::GetTemplateArgumentKind (uint32_t idx)
{
TemplateArgumentKind kind = eTemplateArgumentKindNull;
if (IsValid())
- m_opaque_sp->GetClangASTType(false).GetTemplateArgument (idx, kind);
+ m_opaque_sp->GetCompilerType(false).GetTemplateArgument(idx, kind);
return kind;
}
@@ -791,6 +785,30 @@ SBTypeMemberFunction::GetName ()
return NULL;
}
+const char *
+SBTypeMemberFunction::GetDemangledName ()
+{
+ if (m_opaque_sp)
+ {
+ ConstString mangled_str = m_opaque_sp->GetMangledName();
+ if (mangled_str)
+ {
+ Mangled mangled(mangled_str, true);
+ return mangled.GetDemangledName(mangled.GuessLanguage()).GetCString();
+ }
+ }
+ return NULL;
+}
+
+const char *
+SBTypeMemberFunction::GetMangledName()
+{
+ if (m_opaque_sp)
+ return m_opaque_sp->GetMangledName().GetCString();
+ return NULL;
+}
+
+
SBType
SBTypeMemberFunction::GetType ()
{
diff --git a/source/API/SBTypeCategory.cpp b/source/API/SBTypeCategory.cpp
index ee9553ca6abd..33dada8da39d 100644
--- a/source/API/SBTypeCategory.cpp
+++ b/source/API/SBTypeCategory.cpp
@@ -79,6 +79,29 @@ SBTypeCategory::GetName()
return m_opaque_sp->GetName();
}
+lldb::LanguageType
+SBTypeCategory::GetLanguageAtIndex (uint32_t idx)
+{
+ if (IsValid())
+ return m_opaque_sp->GetLanguageAtIndex(idx);
+ return lldb::eLanguageTypeUnknown;
+}
+
+uint32_t
+SBTypeCategory::GetNumLanguages ()
+{
+ if (IsValid())
+ return m_opaque_sp->GetNumLanguages();
+ return 0;
+}
+
+void
+SBTypeCategory::AddLanguage (lldb::LanguageType language)
+{
+ if (IsValid())
+ m_opaque_sp->AddLanguage(language);
+}
+
uint32_t
SBTypeCategory::GetNumFormats ()
{
@@ -157,7 +180,7 @@ SBTypeCategory::GetFilterForType (SBTypeNameSpecifier spec)
if (!spec.IsValid())
return SBTypeFilter();
- lldb::SyntheticChildrenSP children_sp;
+ lldb::TypeFilterImplSP children_sp;
if (spec.IsRegex())
m_opaque_sp->GetRegexTypeFiltersContainer()->GetExact(ConstString(spec.GetName()), children_sp);
diff --git a/source/API/SBTypeEnumMember.cpp b/source/API/SBTypeEnumMember.cpp
index 47c57dd213fb..c23f7ea8c6ce 100644
--- a/source/API/SBTypeEnumMember.cpp
+++ b/source/API/SBTypeEnumMember.cpp
@@ -12,12 +12,11 @@
#include "lldb/API/SBTypeEnumMember.h"
#include "lldb/API/SBStream.h"
#include "lldb/Core/Stream.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/Type.h"
using namespace lldb;
using namespace lldb_private;
-using namespace clang;
SBTypeEnumMember::SBTypeEnumMember() :
m_opaque_sp()
diff --git a/source/API/SBTypeNameSpecifier.cpp b/source/API/SBTypeNameSpecifier.cpp
index c58747170b5a..6f6801099b7c 100644
--- a/source/API/SBTypeNameSpecifier.cpp
+++ b/source/API/SBTypeNameSpecifier.cpp
@@ -34,7 +34,7 @@ SBTypeNameSpecifier::SBTypeNameSpecifier (SBType type) :
m_opaque_sp()
{
if (type.IsValid())
- m_opaque_sp = TypeNameSpecifierImplSP(new TypeNameSpecifierImpl(type.m_opaque_sp->GetClangASTType(true)));
+ m_opaque_sp = TypeNameSpecifierImplSP(new TypeNameSpecifierImpl(type.m_opaque_sp->GetCompilerType(true)));
}
SBTypeNameSpecifier::SBTypeNameSpecifier (const lldb::SBTypeNameSpecifier &rhs) :
@@ -65,7 +65,7 @@ SBTypeNameSpecifier::GetType ()
{
if (!IsValid())
return SBType();
- lldb_private::ClangASTType c_type = m_opaque_sp->GetClangASTType();
+ lldb_private::CompilerType c_type = m_opaque_sp->GetCompilerType();
if (c_type.IsValid())
return SBType(c_type);
return SBType();
diff --git a/source/API/SBTypeSummary.cpp b/source/API/SBTypeSummary.cpp
index 2c114545419c..2985b7659547 100644
--- a/source/API/SBTypeSummary.cpp
+++ b/source/API/SBTypeSummary.cpp
@@ -8,16 +8,15 @@
//===----------------------------------------------------------------------===//
#include "lldb/API/SBTypeSummary.h"
-
#include "lldb/API/SBStream.h"
-
+#include "lldb/API/SBValue.h"
#include "lldb/DataFormatters/DataVisualization.h"
+#include "llvm/Support/Casting.h"
+
using namespace lldb;
using namespace lldb_private;
-#ifndef LLDB_DISABLE_PYTHON
-
SBTypeSummaryOptions::SBTypeSummaryOptions()
{
m_opaque_ap.reset(new TypeSummaryOptions());
@@ -147,6 +146,28 @@ SBTypeSummary::CreateWithScriptCode (const char* data, uint32_t options)
return SBTypeSummary(TypeSummaryImplSP(new ScriptSummaryFormat(options, "", data)));
}
+SBTypeSummary
+SBTypeSummary::CreateWithCallback (FormatCallback cb, uint32_t options, const char* description)
+{
+ SBTypeSummary retval;
+ if (cb)
+ {
+ retval.SetSP(TypeSummaryImplSP(new CXXFunctionSummaryFormat(options,
+ [cb] (ValueObject& valobj, Stream& stm, const TypeSummaryOptions& opt) -> bool {
+ SBStream stream;
+ SBValue sb_value(valobj.GetSP());
+ SBTypeSummaryOptions options(&opt);
+ if (!cb(sb_value, options, stream))
+ return false;
+ stm.Write(stream.GetData(), stream.GetSize());
+ return true;
+ },
+ description ? description : "callback summary formatter")));
+ }
+
+ return retval;
+}
+
SBTypeSummary::SBTypeSummary (const lldb::SBTypeSummary &rhs) :
m_opaque_sp(rhs.m_opaque_sp)
{
@@ -167,9 +188,8 @@ SBTypeSummary::IsFunctionCode()
{
if (!IsValid())
return false;
- if (m_opaque_sp->IsScripted())
+ if (ScriptSummaryFormat* script_summary_ptr = llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get()))
{
- ScriptSummaryFormat* script_summary_ptr = (ScriptSummaryFormat*)m_opaque_sp.get();
const char* ftext = script_summary_ptr->GetPythonScript();
return (ftext && *ftext != 0);
}
@@ -181,9 +201,8 @@ SBTypeSummary::IsFunctionName()
{
if (!IsValid())
return false;
- if (m_opaque_sp->IsScripted())
+ if (ScriptSummaryFormat* script_summary_ptr = llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get()))
{
- ScriptSummaryFormat* script_summary_ptr = (ScriptSummaryFormat*)m_opaque_sp.get();
const char* ftext = script_summary_ptr->GetPythonScript();
return (!ftext || *ftext == 0);
}
@@ -196,10 +215,7 @@ SBTypeSummary::IsSummaryString()
if (!IsValid())
return false;
- if (m_opaque_sp->GetType() == lldb_private::TypeSummaryImpl::eTypeCallback)
- return false;
-
- return !m_opaque_sp->IsScripted();
+ return m_opaque_sp->GetKind() == TypeSummaryImpl::Kind::eSummaryString;
}
const char*
@@ -207,22 +223,17 @@ SBTypeSummary::GetData ()
{
if (!IsValid())
return NULL;
- if (m_opaque_sp->GetType() == lldb_private::TypeSummaryImpl::eTypeCallback)
- return NULL;
- if (m_opaque_sp->IsScripted())
+ if (ScriptSummaryFormat* script_summary_ptr = llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get()))
{
- ScriptSummaryFormat* script_summary_ptr = (ScriptSummaryFormat*)m_opaque_sp.get();
const char* fname = script_summary_ptr->GetFunctionName();
const char* ftext = script_summary_ptr->GetPythonScript();
if (ftext && *ftext)
return ftext;
return fname;
}
- else
- {
- StringSummaryFormat* string_summary_ptr = (StringSummaryFormat*)m_opaque_sp.get();
+ else if (StringSummaryFormat* string_summary_ptr = llvm::dyn_cast<StringSummaryFormat>(m_opaque_sp.get()))
return string_summary_ptr->GetSummaryString();
- }
+ return nullptr;
}
uint32_t
@@ -246,9 +257,10 @@ SBTypeSummary::SetSummaryString (const char* data)
{
if (!IsValid())
return;
- if (m_opaque_sp->IsScripted() || (m_opaque_sp->GetType() == lldb_private::TypeSummaryImpl::eTypeCallback))
+ if (!llvm::isa<StringSummaryFormat>(m_opaque_sp.get()))
ChangeSummaryType(false);
- ((StringSummaryFormat*)m_opaque_sp.get())->SetSummaryString(data);
+ if (StringSummaryFormat* string_summary_ptr = llvm::dyn_cast<StringSummaryFormat>(m_opaque_sp.get()))
+ string_summary_ptr->SetSummaryString(data);
}
void
@@ -256,9 +268,10 @@ SBTypeSummary::SetFunctionName (const char* data)
{
if (!IsValid())
return;
- if (!m_opaque_sp->IsScripted())
+ if (!llvm::isa<ScriptSummaryFormat>(m_opaque_sp.get()))
ChangeSummaryType(true);
- ((ScriptSummaryFormat*)m_opaque_sp.get())->SetFunctionName(data);
+ if (ScriptSummaryFormat* script_summary_ptr = llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get()))
+ script_summary_ptr->SetFunctionName(data);
}
void
@@ -266,9 +279,10 @@ SBTypeSummary::SetFunctionCode (const char* data)
{
if (!IsValid())
return;
- if (!m_opaque_sp->IsScripted())
+ if (!llvm::isa<ScriptSummaryFormat>(m_opaque_sp.get()))
ChangeSummaryType(true);
- ((ScriptSummaryFormat*)m_opaque_sp.get())->SetPythonScript(data);
+ if (ScriptSummaryFormat* script_summary_ptr = llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get()))
+ script_summary_ptr->SetPythonScript(data);
}
bool
@@ -284,6 +298,15 @@ SBTypeSummary::GetDescription (lldb::SBStream &description,
}
}
+bool
+SBTypeSummary::DoesPrintValue (lldb::SBValue value)
+{
+ if (!IsValid())
+ return false;
+ lldb::ValueObjectSP value_sp = value.GetSP();
+ return m_opaque_sp->DoesPrintValue(value_sp.get());
+}
+
lldb::SBTypeSummary &
SBTypeSummary::operator = (const lldb::SBTypeSummary &rhs)
{
@@ -305,36 +328,44 @@ SBTypeSummary::operator == (lldb::SBTypeSummary &rhs)
bool
SBTypeSummary::IsEqualTo (lldb::SBTypeSummary &rhs)
{
- if (IsValid() == false)
- return !rhs.IsValid();
-
- if (m_opaque_sp->GetType() != rhs.m_opaque_sp->GetType())
- return false;
-
- if (m_opaque_sp->GetType() == lldb_private::TypeSummaryImpl::eTypeCallback)
+ if (IsValid())
{
- lldb_private::CXXFunctionSummaryFormat *self_cxx = (lldb_private::CXXFunctionSummaryFormat*)m_opaque_sp.get();
- lldb_private::CXXFunctionSummaryFormat *other_cxx = (lldb_private::CXXFunctionSummaryFormat*)rhs.m_opaque_sp.get();
- return (self_cxx->m_impl == other_cxx->m_impl);
+ // valid and invalid are different
+ if (!rhs.IsValid())
+ return false;
+ }
+ else
+ {
+ // invalid and valid are different
+ if (rhs.IsValid())
+ return false;
+ else
+ // both invalid are the same
+ return true;
}
-
- if (m_opaque_sp->IsScripted() != rhs.m_opaque_sp->IsScripted())
- return false;
-
- if (IsFunctionCode() != rhs.IsFunctionCode())
- return false;
-
- if (IsSummaryString() != rhs.IsSummaryString())
- return false;
- if (IsFunctionName() != rhs.IsFunctionName())
- return false;
-
- if ( GetData() == NULL || rhs.GetData() == NULL || strcmp(GetData(), rhs.GetData()) )
+ if (m_opaque_sp->GetKind() != rhs.m_opaque_sp->GetKind())
return false;
- return GetOptions() == rhs.GetOptions();
+ switch (m_opaque_sp->GetKind())
+ {
+ case TypeSummaryImpl::Kind::eCallback:
+ return llvm::dyn_cast<CXXFunctionSummaryFormat>(m_opaque_sp.get()) == llvm::dyn_cast<CXXFunctionSummaryFormat>(rhs.m_opaque_sp.get());
+ case TypeSummaryImpl::Kind::eScript:
+ if (IsFunctionCode() != rhs.IsFunctionCode())
+ return false;
+ if (IsFunctionName() != rhs.IsFunctionName())
+ return false;
+ return GetOptions() == rhs.GetOptions();
+ case TypeSummaryImpl::Kind::eSummaryString:
+ if (IsSummaryString() != rhs.IsSummaryString())
+ return false;
+ return GetOptions() == rhs.GetOptions();
+ case TypeSummaryImpl::Kind::eInternal:
+ return (m_opaque_sp.get() == rhs.m_opaque_sp.get());
+ }
+ return false;
}
bool
@@ -373,29 +404,27 @@ SBTypeSummary::CopyOnWrite_Impl()
TypeSummaryImplSP new_sp;
- if (m_opaque_sp->GetType() == lldb_private::TypeSummaryImpl::eTypeCallback)
+ if (CXXFunctionSummaryFormat* current_summary_ptr = llvm::dyn_cast<CXXFunctionSummaryFormat>(m_opaque_sp.get()))
{
- CXXFunctionSummaryFormat* current_summary_ptr = (CXXFunctionSummaryFormat*)m_opaque_sp.get();
new_sp = TypeSummaryImplSP(new CXXFunctionSummaryFormat(GetOptions(),
current_summary_ptr->m_impl,
current_summary_ptr->m_description.c_str()));
}
- else if (m_opaque_sp->IsScripted())
+ else if (ScriptSummaryFormat* current_summary_ptr = llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get()))
{
- ScriptSummaryFormat* current_summary_ptr = (ScriptSummaryFormat*)m_opaque_sp.get();
new_sp = TypeSummaryImplSP(new ScriptSummaryFormat(GetOptions(),
current_summary_ptr->GetFunctionName(),
current_summary_ptr->GetPythonScript()));
}
- else {
- StringSummaryFormat* current_summary_ptr = (StringSummaryFormat*)m_opaque_sp.get();
+ else if (StringSummaryFormat* current_summary_ptr = llvm::dyn_cast<StringSummaryFormat>(m_opaque_sp.get()))
+ {
new_sp = TypeSummaryImplSP(new StringSummaryFormat(GetOptions(),
current_summary_ptr->GetSummaryString()));
}
-
+
SetSP(new_sp);
- return true;
+ return nullptr != new_sp.get();
}
bool
@@ -406,9 +435,9 @@ SBTypeSummary::ChangeSummaryType (bool want_script)
TypeSummaryImplSP new_sp;
- if (want_script == m_opaque_sp->IsScripted())
+ if (want_script == (m_opaque_sp->GetKind() == TypeSummaryImpl::Kind::eScript))
{
- if (m_opaque_sp->GetType() == lldb_private::TypeSummaryImpl::eTypeCallback && !want_script)
+ if (m_opaque_sp->GetKind() == lldb_private::TypeSummaryImpl::Kind::eCallback && !want_script)
new_sp = TypeSummaryImplSP(new StringSummaryFormat(GetOptions(), ""));
else
return CopyOnWrite_Impl();
@@ -426,5 +455,3 @@ SBTypeSummary::ChangeSummaryType (bool want_script)
return true;
}
-
-#endif // LLDB_DISABLE_PYTHON
diff --git a/source/API/SBValue.cpp b/source/API/SBValue.cpp
index ef62c30e42cf..a8584c5d38c9 100644
--- a/source/API/SBValue.cpp
+++ b/source/API/SBValue.cpp
@@ -632,7 +632,6 @@ SBValue::GetValueDidChange ()
return result;
}
-#ifndef LLDB_DISABLE_PYTHON
const char *
SBValue::GetSummary ()
{
@@ -681,7 +680,6 @@ SBValue::GetSummary (lldb::SBStream& stream,
}
return cstr;
}
-#endif // LLDB_DISABLE_PYTHON
const char *
SBValue::GetLocation ()
@@ -753,7 +751,6 @@ SBValue::GetTypeFormat ()
return format;
}
-#ifndef LLDB_DISABLE_PYTHON
lldb::SBTypeSummary
SBValue::GetTypeSummary ()
{
@@ -771,7 +768,6 @@ SBValue::GetTypeSummary ()
}
return summary;
}
-#endif // LLDB_DISABLE_PYTHON
lldb::SBTypeFilter
SBValue::GetTypeFilter ()
@@ -831,7 +827,7 @@ SBValue::CreateChildAtOffset (const char *name, uint32_t offset, SBType type)
TypeImplSP type_sp (type.GetSP());
if (type.IsValid())
{
- sb_value.SetSP(value_sp->GetSyntheticChildAtOffset(offset, type_sp->GetClangASTType(false), true),GetPreferDynamicValue(),GetPreferSyntheticValue(), name);
+ sb_value.SetSP(value_sp->GetSyntheticChildAtOffset(offset, type_sp->GetCompilerType(false), true),GetPreferDynamicValue(),GetPreferSyntheticValue(), name);
}
}
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@@ -856,7 +852,7 @@ SBValue::Cast (SBType type)
lldb::ValueObjectSP value_sp(GetSP(locker));
TypeImplSP type_sp (type.GetSP());
if (value_sp && type_sp)
- sb_value.SetSP(value_sp->Cast(type_sp->GetClangASTType(false)),GetPreferDynamicValue(),GetPreferSyntheticValue());
+ sb_value.SetSP(value_sp->Cast(type_sp->GetCompilerType(false)),GetPreferDynamicValue(),GetPreferSyntheticValue());
return sb_value;
}
@@ -907,7 +903,7 @@ SBValue::CreateValueFromAddress(const char* name, lldb::addr_t address, SBType s
lldb::TypeImplSP type_impl_sp (sb_type.GetSP());
if (value_sp && type_impl_sp)
{
- ClangASTType ast_type(type_impl_sp->GetClangASTType(true));
+ CompilerType ast_type(type_impl_sp->GetCompilerType(true));
ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
new_value_sp = ValueObject::CreateValueObjectFromAddress(name, address, exe_ctx, ast_type);
}
@@ -936,7 +932,7 @@ SBValue::CreateValueFromData (const char* name, SBData data, SBType type)
if (value_sp)
{
ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
- new_value_sp = ValueObject::CreateValueObjectFromData(name, **data, exe_ctx, type.GetSP()->GetClangASTType(true));
+ new_value_sp = ValueObject::CreateValueObjectFromData(name, **data, exe_ctx, type.GetSP()->GetCompilerType(true));
new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad);
}
sb_value.SetSP(new_value_sp);
@@ -1270,22 +1266,27 @@ SBValue::IsRuntimeSupportValue ()
uint32_t
SBValue::GetNumChildren ()
{
+ return GetNumChildren (UINT32_MAX);
+}
+
+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();
+ num_children = value_sp->GetNumChildren(max);
if (log)
- log->Printf ("SBValue(%p)::GetNumChildren () => %u",
- static_cast<void*>(value_sp.get()), num_children);
+ log->Printf ("SBValue(%p)::GetNumChildren (%u) => %u",
+ static_cast<void*>(value_sp.get()), max, num_children);
return num_children;
}
-
SBValue
SBValue::Dereference ()
{
@@ -1306,22 +1307,11 @@ SBValue::Dereference ()
return sb_value;
}
+// Deprecated - please use GetType().IsPointerType() instead.
bool
SBValue::TypeIsPointerType ()
{
- bool is_ptr_type = false;
-
- ValueLocker locker;
- lldb::ValueObjectSP value_sp(GetSP(locker));
- if (value_sp)
- is_ptr_type = value_sp->IsPointerType();
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- if (log)
- log->Printf ("SBValue(%p)::TypeIsPointerType () => %i",
- static_cast<void*>(value_sp.get()), is_ptr_type);
-
- return is_ptr_type;
+ return GetType().IsPointerType();
}
void *
@@ -1330,7 +1320,7 @@ SBValue::GetOpaqueType()
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp)
- return value_sp->GetClangType().GetOpaqueQualType();
+ return value_sp->GetCompilerType().GetOpaqueQualType();
return NULL;
}
@@ -1435,7 +1425,10 @@ lldb::ValueObjectSP
SBValue::GetSP (ValueLocker &locker) const
{
if (!m_opaque_sp || !m_opaque_sp->IsValid())
+ {
+ locker.GetError().SetErrorString("No value");
return ValueObjectSP();
+ }
return locker.GetLockedSP(*m_opaque_sp.get());
}
@@ -1823,7 +1816,7 @@ SBValue::Watch (bool resolve_location, bool read, bool write, SBError &error)
watch_type |= LLDB_WATCH_TYPE_WRITE;
Error rc;
- ClangASTType type (value_sp->GetClangType());
+ CompilerType type (value_sp->GetCompilerType());
WatchpointSP watchpoint_sp = target_sp->CreateWatchpoint(addr, byte_size, &type, watch_type, rc);
error.SetError(rc);
diff --git a/source/API/SBValueList.cpp b/source/API/SBValueList.cpp
index 71fabe0dfc0a..5461b05fb196 100644
--- a/source/API/SBValueList.cpp
+++ b/source/API/SBValueList.cpp
@@ -39,7 +39,7 @@ public:
return *this;
m_values = rhs.m_values;
return *this;
- };
+ }
uint32_t
GetSize ()
@@ -297,5 +297,3 @@ SBValueList::ref ()
CreateIfNeeded();
return *m_opaque_ap.get();
}
-
-
diff --git a/source/API/SystemInitializerFull.cpp b/source/API/SystemInitializerFull.cpp
index 01ad8157646e..f223357824e8 100644
--- a/source/API/SystemInitializerFull.cpp
+++ b/source/API/SystemInitializerFull.cpp
@@ -7,18 +7,32 @@
//
//===----------------------------------------------------------------------===//
+#if !defined(LLDB_DISABLE_PYTHON)
+#include "Plugins/ScriptInterpreter/Python/lldb-python.h"
+#endif
+
#include "lldb/API/SystemInitializerFull.h"
+#include "lldb/API/SBCommandInterpreter.h"
+
+#if !defined(LLDB_DISABLE_PYTHON)
+#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h"
+#endif
+
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Timer.h"
#include "lldb/Host/Host.h"
#include "lldb/Initialization/SystemInitializerCommon.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/GoASTContext.h"
#include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h"
#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h"
#include "Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h"
#include "Plugins/ABI/SysV-arm/ABISysV_arm.h"
#include "Plugins/ABI/SysV-arm64/ABISysV_arm64.h"
+#include "Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h"
#include "Plugins/ABI/SysV-i386/ABISysV_i386.h"
#include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h"
#include "Plugins/ABI/SysV-ppc/ABISysV_ppc.h"
@@ -30,14 +44,20 @@
#include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
#include "Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h"
#include "Plugins/JITLoader/GDB/JITLoaderGDB.h"
+#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
+#include "Plugins/Language/Go/GoLanguage.h"
+#include "Plugins/Language/ObjC/ObjCLanguage.h"
+#include "Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h"
#include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h"
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h"
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h"
+#include "Plugins/LanguageRuntime/Go/GoLanguageRuntime.h"
#include "Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h"
#include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h"
#include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h"
#include "Plugins/Process/elf-core/ProcessElfCore.h"
#include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
+#include "Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h"
#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h"
#include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h"
@@ -50,6 +70,10 @@
#include "Plugins/Process/mach-core/ProcessMachCore.h"
#include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h"
#include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h"
+#include "Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h"
#endif
#if defined(__FreeBSD__)
@@ -58,11 +82,8 @@
#if defined(_MSC_VER)
#include "lldb/Host/windows/windows.h"
-#include "Plugins/Process/Windows/ProcessWindows.h"
-#endif
-
-#if !defined(LLDB_DISABLE_PYTHON)
-#include "lldb/Interpreter/ScriptInterpreterPython.h"
+#include "Plugins/Process/Windows/Live/ProcessWindowsLive.h"
+#include "Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h"
#endif
#include "llvm/Support/TargetSelect.h"
@@ -74,9 +95,19 @@ 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
@@ -124,7 +155,7 @@ LLDBSWIGPythonCallThreadPlan (void *implementor,
bool &got_error);
extern "C" size_t
-LLDBSwigPython_CalculateNumChildren (void *implementor);
+LLDBSwigPython_CalculateNumChildren (void *implementor, uint32_t max);
extern "C" void *
LLDBSwigPython_GetChildAtIndex (void *implementor, uint32_t idx);
@@ -221,9 +252,17 @@ SystemInitializerFull::~SystemInitializerFull()
void
SystemInitializerFull::Initialize()
{
+ SystemInitializerCommon::Initialize();
+ ScriptInterpreterNone::Initialize();
+
+#if !defined(LLDB_DISABLE_PYTHON)
InitializeSWIG();
- SystemInitializerCommon::Initialize();
+ // 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
// Initialize LLVM and Clang
llvm::InitializeAllTargets();
@@ -231,11 +270,15 @@ SystemInitializerFull::Initialize()
llvm::InitializeAllTargetMCs();
llvm::InitializeAllDisassemblers();
+ ClangASTContext::Initialize();
+ GoASTContext::Initialize();
+
ABIMacOSX_i386::Initialize();
ABIMacOSX_arm::Initialize();
ABIMacOSX_arm64::Initialize();
ABISysV_arm::Initialize();
ABISysV_arm64::Initialize();
+ ABISysV_hexagon::Initialize();
ABISysV_i386::Initialize();
ABISysV_x86_64::Initialize();
ABISysV_ppc::Initialize();
@@ -246,6 +289,9 @@ SystemInitializerFull::Initialize()
JITLoaderGDB::Initialize();
ProcessElfCore::Initialize();
+#if defined(_MSC_VER)
+ ProcessWinMiniDump::Initialize();
+#endif
MemoryHistoryASan::Initialize();
AddressSanitizerRuntime::Initialize();
@@ -261,9 +307,15 @@ SystemInitializerFull::Initialize()
AppleObjCRuntimeV1::Initialize();
SystemRuntimeMacOSX::Initialize();
RenderScriptRuntime::Initialize();
+ GoLanguageRuntime::Initialize();
+
+ CPlusPlusLanguage::Initialize();
+ GoLanguage::Initialize();
+ ObjCLanguage::Initialize();
+ ObjCPlusPlusLanguage::Initialize();
#if defined(_MSC_VER)
- ProcessWindows::Initialize();
+ ProcessWindowsLive::Initialize();
#endif
#if defined(__FreeBSD__)
ProcessFreeBSD::Initialize();
@@ -272,6 +324,10 @@ SystemInitializerFull::Initialize()
SymbolVendorMacOSX::Initialize();
ProcessKDP::Initialize();
ProcessMachCore::Initialize();
+ PlatformAppleTVSimulator::Initialize();
+ PlatformAppleWatchSimulator::Initialize();
+ PlatformRemoteAppleTV::Initialize();
+ PlatformRemoteAppleWatch::Initialize();
#endif
//----------------------------------------------------------------------
// Platform agnostic plugins
@@ -294,7 +350,7 @@ void SystemInitializerFull::InitializeSWIG()
{
#if !defined(LLDB_DISABLE_PYTHON)
ScriptInterpreterPython::InitializeInterpreter(
- init_lldb,
+ LLDBSwigPyInit,
LLDBSwigPythonBreakpointCallbackFunction,
LLDBSwigPythonWatchpointCallbackFunction,
LLDBSwigPythonCallTypeScript,
@@ -332,11 +388,16 @@ SystemInitializerFull::Terminate()
// Terminate and unload and loaded system or user LLDB plug-ins
PluginManager::Terminate();
+
+ ClangASTContext::Terminate();
+ GoASTContext::Terminate();
+
ABIMacOSX_i386::Terminate();
ABIMacOSX_arm::Terminate();
ABIMacOSX_arm64::Terminate();
ABISysV_arm::Terminate();
ABISysV_arm64::Terminate();
+ ABISysV_hexagon::Terminate();
ABISysV_i386::Terminate();
ABISysV_x86_64::Terminate();
ABISysV_ppc::Terminate();
@@ -347,6 +408,9 @@ SystemInitializerFull::Terminate()
JITLoaderGDB::Terminate();
ProcessElfCore::Terminate();
+#if defined(_MSC_VER)
+ ProcessWinMiniDump::Terminate();
+#endif
MemoryHistoryASan::Terminate();
AddressSanitizerRuntime::Terminate();
SymbolVendorELF::Terminate();
@@ -362,10 +426,19 @@ SystemInitializerFull::Terminate()
SystemRuntimeMacOSX::Terminate();
RenderScriptRuntime::Terminate();
+ CPlusPlusLanguage::Terminate();
+ GoLanguage::Terminate();
+ ObjCLanguage::Terminate();
+ ObjCPlusPlusLanguage::Terminate();
+
#if defined(__APPLE__)
ProcessMachCore::Terminate();
ProcessKDP::Terminate();
SymbolVendorMacOSX::Terminate();
+ PlatformAppleTVSimulator::Terminate();
+ PlatformAppleWatchSimulator::Terminate();
+ PlatformRemoteAppleTV::Terminate();
+ PlatformRemoteAppleWatch::Terminate();
#endif
#if defined(__FreeBSD__)
@@ -380,8 +453,3 @@ SystemInitializerFull::Terminate()
// Now shutdown the common parts, in reverse order.
SystemInitializerCommon::Terminate();
}
-
-void SystemInitializerFull::TerminateSWIG()
-{
-
-}
diff --git a/source/API/liblldb.exports b/source/API/liblldb.exports
new file mode 100644
index 000000000000..fd234d11c40c
--- /dev/null
+++ b/source/API/liblldb.exports
@@ -0,0 +1,3 @@
+_ZN4lldb*
+_ZNK4lldb*
+init_lld*
diff --git a/source/API/liblldb.xcode.exports b/source/API/liblldb.xcode.exports
new file mode 100644
index 000000000000..9c194fa6ff67
--- /dev/null
+++ b/source/API/liblldb.xcode.exports
@@ -0,0 +1,3 @@
+__ZN4lldb*
+__ZNK4lldb*
+_init_lld*
diff --git a/source/Breakpoint/Breakpoint.cpp b/source/Breakpoint/Breakpoint.cpp
index 23d484f0f68a..54f67b90220a 100644
--- a/source/Breakpoint/Breakpoint.cpp
+++ b/source/Breakpoint/Breakpoint.cpp
@@ -7,12 +7,12 @@
//
//===----------------------------------------------------------------------===//
-
// C Includes
// C++ Includes
// Other libraries and framework includes
-// Project includes
+#include "llvm/Support/Casting.h"
+// Project includes
#include "lldb/Core/Address.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
@@ -31,7 +31,6 @@
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadSpec.h"
-#include "llvm/Support/Casting.h"
using namespace lldb;
using namespace lldb_private;
@@ -83,9 +82,7 @@ Breakpoint::Breakpoint (Target &new_target, Breakpoint &source_bp) :
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-Breakpoint::~Breakpoint()
-{
-}
+Breakpoint::~Breakpoint() = default;
const lldb::TargetSP
Breakpoint::GetTargetSP ()
@@ -236,7 +233,7 @@ Breakpoint::SetThreadID (lldb::tid_t thread_id)
lldb::tid_t
Breakpoint::GetThreadID () const
{
- if (m_options.GetThreadSpecNoCreate() == NULL)
+ if (m_options.GetThreadSpecNoCreate() == nullptr)
return LLDB_INVALID_THREAD_ID;
else
return m_options.GetThreadSpecNoCreate()->GetTID();
@@ -255,7 +252,7 @@ Breakpoint::SetThreadIndex (uint32_t index)
uint32_t
Breakpoint::GetThreadIndex() const
{
- if (m_options.GetThreadSpecNoCreate() == NULL)
+ if (m_options.GetThreadSpecNoCreate() == nullptr)
return 0;
else
return m_options.GetThreadSpecNoCreate()->GetIndex();
@@ -264,7 +261,7 @@ Breakpoint::GetThreadIndex() const
void
Breakpoint::SetThreadName (const char *thread_name)
{
- if (m_options.GetThreadSpec()->GetName() != NULL
+ if (m_options.GetThreadSpec()->GetName() != nullptr
&& ::strcmp (m_options.GetThreadSpec()->GetName(), thread_name) == 0)
return;
@@ -275,8 +272,8 @@ Breakpoint::SetThreadName (const char *thread_name)
const char *
Breakpoint::GetThreadName () const
{
- if (m_options.GetThreadSpecNoCreate() == NULL)
- return NULL;
+ if (m_options.GetThreadSpecNoCreate() == nullptr)
+ return nullptr;
else
return m_options.GetThreadSpecNoCreate()->GetName();
}
@@ -284,7 +281,7 @@ Breakpoint::GetThreadName () const
void
Breakpoint::SetQueueName (const char *queue_name)
{
- if (m_options.GetThreadSpec()->GetQueueName() != NULL
+ if (m_options.GetThreadSpec()->GetQueueName() != nullptr
&& ::strcmp (m_options.GetThreadSpec()->GetQueueName(), queue_name) == 0)
return;
@@ -295,8 +292,8 @@ Breakpoint::SetQueueName (const char *queue_name)
const char *
Breakpoint::GetQueueName () const
{
- if (m_options.GetThreadSpecNoCreate() == NULL)
- return NULL;
+ if (m_options.GetThreadSpecNoCreate() == nullptr)
+ return nullptr;
else
return m_options.GetThreadSpecNoCreate()->GetQueueName();
}
@@ -456,7 +453,6 @@ Breakpoint::ModulesChanged (ModuleList &module_list, bool load, bool delete_loca
if (!seen)
new_modules.AppendIfNeeded (module_sp);
-
}
if (new_modules.GetSize() > 0)
@@ -474,7 +470,7 @@ Breakpoint::ModulesChanged (ModuleList &module_list, bool load, bool delete_loca
removed_locations_event = new BreakpointEventData (eBreakpointEventTypeLocationsRemoved,
shared_from_this());
else
- removed_locations_event = NULL;
+ removed_locations_event = nullptr;
size_t num_modules = module_list.GetSize();
for (size_t i = 0; i < num_modules; i++)
@@ -502,7 +498,6 @@ Breakpoint::ModulesChanged (ModuleList &module_list, bool load, bool delete_loca
}
if (delete_locations)
locations_to_remove.Add (break_loc_sp);
-
}
}
@@ -568,7 +563,7 @@ SymbolContextsMightBeEquivalent(SymbolContext &old_sc, SymbolContext &new_sc)
}
return equivalent_scs;
}
-}
+} // anonymous namespace
void
Breakpoint::ModuleReplaced (ModuleSP old_module_sp, ModuleSP new_module_sp)
@@ -740,7 +735,7 @@ Breakpoint::ModuleReplaced (ModuleSP old_module_sp, ModuleSP new_module_sp)
locations_event = new BreakpointEventData (eBreakpointEventTypeLocationsRemoved,
shared_from_this());
else
- locations_event = NULL;
+ locations_event = nullptr;
for (BreakpointLocationSP loc_sp : locations_to_remove.BreakpointLocations())
{
@@ -804,7 +799,7 @@ Breakpoint::AddName (const char *new_name, Error &error)
void
Breakpoint::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_locations)
{
- assert (s != NULL);
+ assert (s != nullptr);
if (!m_kind_description.empty())
{
@@ -849,6 +844,9 @@ Breakpoint::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_l
GetOptions()->GetDescription(s, level);
+ if (m_precondition_sp)
+ m_precondition_sp->GetDescription(*s, level);
+
if (level == lldb::eDescriptionLevelFull)
{
if (!m_name_list.empty())
@@ -876,7 +874,7 @@ Breakpoint::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_l
{
s->Printf ("no locations (pending).");
}
- else if (num_locations == 1 && show_locations == false)
+ else if (num_locations == 1 && !show_locations)
{
// There is only one location, so we'll just print that location information.
GetLocationAtIndex(0)->GetDescription(s, level);
@@ -922,7 +920,6 @@ Breakpoint::GetResolverDescription (Stream *s)
m_resolver_sp->GetDescription (s);
}
-
bool
Breakpoint::GetMatchingFileLine (const ConstString &filename, uint32_t line_number, BreakpointLocationCollection &loc_coll)
{
@@ -965,7 +962,7 @@ Breakpoint::BreakpointPrecondition::EvaluatePrecondition(StoppointCallbackContex
}
void
-Breakpoint::BreakpointPrecondition::DescribePrecondition(Stream &stream, lldb::DescriptionLevel level)
+Breakpoint::BreakpointPrecondition::GetDescription(Stream &stream, lldb::DescriptionLevel level)
{
}
@@ -993,8 +990,7 @@ Breakpoint::SendBreakpointChangedEvent (lldb::BreakpointEventType eventKind)
void
Breakpoint::SendBreakpointChangedEvent (BreakpointEventData *data)
{
-
- if (data == NULL)
+ if (data == nullptr)
return;
if (!m_being_created
@@ -1013,9 +1009,7 @@ Breakpoint::BreakpointEventData::BreakpointEventData (BreakpointEventType sub_ty
{
}
-Breakpoint::BreakpointEventData::~BreakpointEventData ()
-{
-}
+Breakpoint::BreakpointEventData::~BreakpointEventData() = default;
const ConstString &
Breakpoint::BreakpointEventData::GetFlavorString ()
@@ -1030,7 +1024,6 @@ Breakpoint::BreakpointEventData::GetFlavor () const
return BreakpointEventData::GetFlavorString ();
}
-
BreakpointSP &
Breakpoint::BreakpointEventData::GetBreakpoint ()
{
@@ -1057,7 +1050,7 @@ Breakpoint::BreakpointEventData::GetEventDataFromEvent (const Event *event)
if (event_data && event_data->GetFlavor() == BreakpointEventData::GetFlavorString())
return static_cast <const BreakpointEventData *> (event->GetData());
}
- return NULL;
+ return nullptr;
}
BreakpointEventType
@@ -1065,7 +1058,7 @@ Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent (const EventSP
{
const BreakpointEventData *data = GetEventDataFromEvent (event_sp.get());
- if (data == NULL)
+ if (data == nullptr)
return eBreakpointEventTypeInvalidType;
else
return data->GetBreakpointEventType();
diff --git a/source/Breakpoint/BreakpointID.cpp b/source/Breakpoint/BreakpointID.cpp
index 31823886dd9f..81a3dfe50d9b 100644
--- a/source/Breakpoint/BreakpointID.cpp
+++ b/source/Breakpoint/BreakpointID.cpp
@@ -7,14 +7,12 @@
//
//===----------------------------------------------------------------------===//
-
// C Includes
#include <stdio.h>
// C++ Includes
// Other libraries and framework includes
// Project includes
-
#include "lldb/Breakpoint/BreakpointID.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Core/Stream.h"
@@ -29,11 +27,9 @@ BreakpointID::BreakpointID (break_id_t bp_id, break_id_t loc_id) :
{
}
-BreakpointID::~BreakpointID ()
-{
-}
+BreakpointID::~BreakpointID() = default;
-const char *BreakpointID::g_range_specifiers[] = { "-", "to", "To", "TO", NULL };
+const char *BreakpointID::g_range_specifiers[] = { "-", "to", "To", "TO", nullptr };
// Tells whether or not STR is valid to use between two strings representing breakpoint IDs, to
// indicate a range of breakpoint IDs. This is broken out into a separate function so that we can
@@ -43,7 +39,7 @@ bool
BreakpointID::IsRangeIdentifier (const char *str)
{
int specifier_count = 0;
- for (int i = 0; g_range_specifiers[i] != NULL; ++i)
+ for (int i = 0; g_range_specifiers[i] != nullptr; ++i)
++specifier_count;
for (int i = 0; i < specifier_count; ++i)
@@ -62,10 +58,7 @@ BreakpointID::IsValidIDExpression (const char *str)
break_id_t loc_id;
BreakpointID::ParseCanonicalReference (str, &bp_id, &loc_id);
- if (bp_id == LLDB_INVALID_BREAK_ID)
- return false;
- else
- return true;
+ return (bp_id != LLDB_INVALID_BREAK_ID);
}
void
@@ -99,7 +92,7 @@ BreakpointID::ParseCanonicalReference (const char *input, break_id_t *break_id_p
*break_id_ptr = LLDB_INVALID_BREAK_ID;
*break_loc_id_ptr = LLDB_INVALID_BREAK_ID;
- if (input == NULL || *input == '\0')
+ if (input == nullptr || *input == '\0')
return false;
const char *format = "%i%n.%i%n";
diff --git a/source/Breakpoint/BreakpointIDList.cpp b/source/Breakpoint/BreakpointIDList.cpp
index b8b506750b34..ebf0697c271b 100644
--- a/source/Breakpoint/BreakpointIDList.cpp
+++ b/source/Breakpoint/BreakpointIDList.cpp
@@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Breakpoint/BreakpointIDList.h"
#include "lldb/Breakpoint/Breakpoint.h"
@@ -27,9 +31,7 @@ m_invalid_id (LLDB_INVALID_BREAK_ID, LLDB_INVALID_BREAK_ID)
{
}
-BreakpointIDList::~BreakpointIDList ()
-{
-}
+BreakpointIDList::~BreakpointIDList() = default;
size_t
BreakpointIDList::GetSize()
@@ -38,12 +40,9 @@ BreakpointIDList::GetSize()
}
BreakpointID &
-BreakpointIDList::GetBreakpointIDAtIndex (size_t index)
+BreakpointIDList::GetBreakpointIDAtIndex(size_t index)
{
- if (index < m_breakpoint_ids.size())
- return m_breakpoint_ids[index];
- else
- return m_invalid_id;
+ return ((index < m_breakpoint_ids.size()) ? m_breakpoint_ids[index] : m_invalid_id);
}
bool
@@ -124,7 +123,7 @@ BreakpointIDList::FindBreakpointID (const char *bp_id_str, size_t *position)
void
BreakpointIDList::InsertStringArray (const char **string_array, size_t array_size, CommandReturnObject &result)
{
- if (string_array == NULL)
+ if (string_array == nullptr)
return;
for (uint32_t i = 0; i < array_size; ++i)
@@ -385,7 +384,6 @@ BreakpointIDList::FindAndReplaceIDRanges (Args &old_args,
}
result.SetStatus (eReturnStatusSuccessFinishNoResult);
- return;
}
bool
@@ -402,7 +400,7 @@ BreakpointIDList::StringContainsIDRangeExpression (const char *in_string,
*range_end_pos = 0;
int specifiers_size = 0;
- for (int i = 0; BreakpointID::g_range_specifiers[i] != NULL; ++i)
+ for (int i = 0; BreakpointID::g_range_specifiers[i] != nullptr; ++i)
++specifiers_size;
for (int i = 0; i < specifiers_size && !is_range_expression; ++i)
diff --git a/source/Breakpoint/BreakpointLocation.cpp b/source/Breakpoint/BreakpointLocation.cpp
index a199d390803b..5ff91102aadd 100644
--- a/source/Breakpoint/BreakpointLocation.cpp
+++ b/source/Breakpoint/BreakpointLocation.cpp
@@ -9,8 +9,6 @@
// C Includes
// C++ Includes
-#include <string>
-
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointLocation.h"
@@ -21,9 +19,11 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObject.h"
-#include "lldb/Expression/ClangUserExpression.h"
+#include "lldb/Expression/ExpressionVariable.h"
+#include "lldb/Expression/UserExpression.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Symbol.h"
+#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Thread.h"
@@ -88,12 +88,18 @@ BreakpointLocation::GetBreakpoint ()
return m_owner;
}
+Target &
+BreakpointLocation::GetTarget()
+{
+ return m_owner.GetTarget();
+}
+
bool
BreakpointLocation::IsEnabled () const
{
if (!m_owner.IsEnabled())
return false;
- else if (m_options_ap.get() != NULL)
+ else if (m_options_ap.get() != nullptr)
return m_options_ap->IsEnabled();
else
return true;
@@ -123,7 +129,7 @@ BreakpointLocation::SetThreadID (lldb::tid_t thread_id)
{
// 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() != NULL)
+ if (m_options_ap.get() != nullptr)
m_options_ap->SetThreadID (thread_id);
}
SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged);
@@ -147,11 +153,10 @@ BreakpointLocation::SetThreadIndex (uint32_t index)
{
// 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() != NULL)
+ if (m_options_ap.get() != nullptr)
m_options_ap->GetThreadSpec()->SetIndex(index);
}
SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged);
-
}
uint32_t
@@ -166,13 +171,13 @@ BreakpointLocation::GetThreadIndex() const
void
BreakpointLocation::SetThreadName (const char *thread_name)
{
- if (thread_name != NULL)
+ if (thread_name != nullptr)
GetLocationOptions()->GetThreadSpec()->SetName(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() != NULL)
+ if (m_options_ap.get() != nullptr)
m_options_ap->GetThreadSpec()->SetName(thread_name);
}
SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged);
@@ -184,19 +189,19 @@ BreakpointLocation::GetThreadName () const
if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetName();
else
- return NULL;
+ return nullptr;
}
void
BreakpointLocation::SetQueueName (const char *queue_name)
{
- if (queue_name != NULL)
+ if (queue_name != nullptr)
GetLocationOptions()->GetThreadSpec()->SetQueueName(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() != NULL)
+ if (m_options_ap.get() != nullptr)
m_options_ap->GetThreadSpec()->SetQueueName(queue_name);
}
SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged);
@@ -208,13 +213,13 @@ BreakpointLocation::GetQueueName () const
if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetQueueName();
else
- return NULL;
+ return nullptr;
}
bool
BreakpointLocation::InvokeCallback (StoppointCallbackContext *context)
{
- if (m_options_ap.get() != NULL && m_options_ap->HasCallback())
+ if (m_options_ap.get() != nullptr && m_options_ap->HasCallback())
return m_options_ap->InvokeCallback (context, m_owner.GetID(), GetID());
else
return m_owner.InvokeCallback (context, GetID());
@@ -238,7 +243,6 @@ BreakpointLocation::SetCallback (BreakpointHitCallback callback, const BatonSP &
SendBreakpointLocationChangedEvent (eBreakpointEventTypeCommandChanged);
}
-
void
BreakpointLocation::ClearCallback ()
{
@@ -278,11 +282,27 @@ BreakpointLocation::ConditionSaysStop (ExecutionContext &exe_ctx, Error &error)
!m_user_expression_sp ||
!m_user_expression_sp->MatchesContext(exe_ctx))
{
- m_user_expression_sp.reset(new ClangUserExpression(condition_text,
- NULL,
- lldb::eLanguageTypeUnknown,
- ClangUserExpression::eResultTypeAny));
+ LanguageType language = eLanguageTypeUnknown;
+ // See if we can figure out the language from the frame, otherwise use the default language:
+ CompileUnit *comp_unit = m_address.CalculateSymbolContextCompileUnit();
+ if (comp_unit)
+ language = comp_unit->GetLanguage();
+ Error error;
+ m_user_expression_sp.reset(GetTarget().GetUserExpressionForLanguage(condition_text,
+ nullptr,
+ language,
+ Expression::eResultTypeAny,
+ EvaluateExpressionOptions(),
+ error));
+ if (error.Fail())
+ {
+ if (log)
+ log->Printf("Error getting condition expression: %s.", error.AsCString());
+ m_user_expression_sp.reset();
+ return true;
+ }
+
StreamString errors;
if (!m_user_expression_sp->Parse(errors,
@@ -314,7 +334,7 @@ BreakpointLocation::ConditionSaysStop (ExecutionContext &exe_ctx, Error &error)
StreamString execution_errors;
- ClangExpressionVariableSP result_variable_sp;
+ ExpressionVariableSP result_variable_sp;
ExpressionResults result_code =
m_user_expression_sp->Execute(execution_errors,
@@ -337,21 +357,20 @@ BreakpointLocation::ConditionSaysStop (ExecutionContext &exe_ctx, Error &error)
if (result_value_sp)
{
- Scalar scalar_value;
- if (result_value_sp->ResolveValue (scalar_value))
+ ret = result_value_sp->IsLogicalTrue(error);
+ if (log)
{
- if (scalar_value.ULongLong(1) == 0)
- ret = false;
- else
- ret = true;
- if (log)
+ if (error.Success())
+ {
log->Printf("Condition successfully evaluated, result is %s.\n",
ret ? "true" : "false");
- }
- else
- {
- ret = false;
- error.SetErrorString("Failed to get an integer result from the expression");
+ }
+ else
+ {
+ error.SetErrorString("Failed to get an integer result from the expression");
+ ret = false;
+ }
+
}
}
else
@@ -385,7 +404,7 @@ BreakpointLocation::SetIgnoreCount (uint32_t n)
void
BreakpointLocation::DecrementIgnoreCount()
{
- if (m_options_ap.get() != NULL)
+ if (m_options_ap.get() != nullptr)
{
uint32_t loc_ignore = m_options_ap->GetIgnoreCount();
if (loc_ignore != 0)
@@ -396,7 +415,7 @@ BreakpointLocation::DecrementIgnoreCount()
bool
BreakpointLocation::IgnoreCountShouldStop()
{
- if (m_options_ap.get() != NULL)
+ if (m_options_ap.get() != nullptr)
{
uint32_t loc_ignore = m_options_ap->GetIgnoreCount();
if (loc_ignore != 0)
@@ -413,7 +432,7 @@ BreakpointLocation::IgnoreCountShouldStop()
const BreakpointOptions *
BreakpointLocation::GetOptionsNoCreate () const
{
- if (m_options_ap.get() != NULL)
+ if (m_options_ap.get() != nullptr)
return m_options_ap.get();
else
return m_owner.GetOptions ();
@@ -425,7 +444,7 @@ 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() == NULL)
+ if (m_options_ap.get() == nullptr)
m_options_ap.reset(BreakpointOptions::CopyOptionsNoCallback(*m_owner.GetOptions ()));
return m_options_ap.get();
@@ -497,7 +516,7 @@ BreakpointLocation::UndoBumpHitCount()
bool
BreakpointLocation::IsResolved () const
{
- return m_bp_site_sp.get() != NULL;
+ return m_bp_site_sp.get() != nullptr;
}
lldb::BreakpointSiteSP
@@ -513,7 +532,7 @@ BreakpointLocation::ResolveBreakpointSite ()
return true;
Process *process = m_owner.GetTarget().GetProcessSP().get();
- if (process == NULL)
+ if (process == nullptr)
return false;
lldb::break_id_t new_id = process->CreateBreakpointSite (shared_from_this(), m_owner.IsHardware());
@@ -601,13 +620,13 @@ BreakpointLocation::GetDescription (Stream *s, lldb::DescriptionLevel level)
sc.module_sp->GetFileSpec().Dump (s);
}
- if (sc.comp_unit != NULL)
+ if (sc.comp_unit != nullptr)
{
s->EOL();
s->Indent("compile unit = ");
static_cast<FileSpec*>(sc.comp_unit)->GetFilename().Dump (s);
- if (sc.function != NULL)
+ if (sc.function != nullptr)
{
s->EOL();
s->Indent("function = ");
@@ -648,11 +667,11 @@ BreakpointLocation::GetDescription (Stream *s, lldb::DescriptionLevel level)
s->Printf (", ");
s->Printf ("address = ");
- ExecutionContextScope *exe_scope = NULL;
+ ExecutionContextScope *exe_scope = nullptr;
Target *target = &m_owner.GetTarget();
if (target)
exe_scope = target->GetProcessSP().get();
- if (exe_scope == NULL)
+ if (exe_scope == nullptr)
exe_scope = target;
if (level == eDescriptionLevelInitial)
@@ -710,7 +729,7 @@ BreakpointLocation::GetDescription (Stream *s, lldb::DescriptionLevel level)
void
BreakpointLocation::Dump(Stream *s) const
{
- if (s == NULL)
+ if (s == nullptr)
return;
s->Printf("BreakpointLocation %u: tid = %4.4" PRIx64 " load addr = 0x%8.8" PRIx64 " state = %s type = %s breakpoint "
diff --git a/source/Breakpoint/BreakpointLocationList.cpp b/source/Breakpoint/BreakpointLocationList.cpp
index 06b270a08ce9..d57cfa68fb80 100644
--- a/source/Breakpoint/BreakpointLocationList.cpp
+++ b/source/Breakpoint/BreakpointLocationList.cpp
@@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
-
// C Includes
// C++ Includes
// Other libraries and framework includes
@@ -22,7 +21,6 @@
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
-
using namespace lldb;
using namespace lldb_private;
@@ -32,13 +30,11 @@ BreakpointLocationList::BreakpointLocationList(Breakpoint &owner) :
m_address_to_location (),
m_mutex (Mutex::eMutexTypeRecursive),
m_next_id (0),
- m_new_location_recorder (NULL)
+ m_new_location_recorder (nullptr)
{
}
-BreakpointLocationList::~BreakpointLocationList()
-{
-}
+BreakpointLocationList::~BreakpointLocationList() = default;
BreakpointLocationSP
BreakpointLocationList::Create (const Address &addr, bool resolve_indirect_symbols)
@@ -163,7 +159,6 @@ BreakpointLocationList::Dump (Stream *s) const
s->IndentLess();
}
-
BreakpointLocationSP
BreakpointLocationList::GetByIndex (size_t i)
{
@@ -285,7 +280,6 @@ BreakpointLocationList::SwapLocation (BreakpointLocationSP to_location_sp, Break
to_location_sp->ResolveBreakpointSite();
}
-
bool
BreakpointLocationList::RemoveLocation (const lldb::BreakpointLocationSP &bp_loc_sp)
{
@@ -304,7 +298,7 @@ BreakpointLocationList::RemoveLocation (const lldb::BreakpointLocationSP &bp_loc
return true;
}
}
- }
+ }
return false;
}
@@ -348,7 +342,7 @@ void
BreakpointLocationList::StartRecordingNewLocations (BreakpointLocationCollection &new_locations)
{
Mutex::Locker locker (m_mutex);
- assert (m_new_location_recorder == NULL);
+ assert(m_new_location_recorder == nullptr);
m_new_location_recorder = &new_locations;
}
@@ -356,7 +350,7 @@ void
BreakpointLocationList::StopRecordingNewLocations ()
{
Mutex::Locker locker (m_mutex);
- m_new_location_recorder = NULL;
+ m_new_location_recorder = nullptr;
}
void
diff --git a/source/Breakpoint/BreakpointOptions.cpp b/source/Breakpoint/BreakpointOptions.cpp
index db76ffb8685c..d2a919756857 100644
--- a/source/Breakpoint/BreakpointOptions.cpp
+++ b/source/Breakpoint/BreakpointOptions.cpp
@@ -7,12 +7,12 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Breakpoint/BreakpointOptions.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Breakpoint/BreakpointOptions.h"
+
#include "lldb/Core/Stream.h"
#include "lldb/Core/StringList.h"
#include "lldb/Core/Value.h"
@@ -20,7 +20,6 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadSpec.h"
-#include "lldb/Expression/ClangUserExpression.h"
using namespace lldb;
using namespace lldb_private;
@@ -59,7 +58,7 @@ BreakpointOptions::BreakpointOptions(const BreakpointOptions& rhs) :
m_ignore_count (rhs.m_ignore_count),
m_thread_spec_ap ()
{
- if (rhs.m_thread_spec_ap.get() != NULL)
+ if (rhs.m_thread_spec_ap.get() != nullptr)
m_thread_spec_ap.reset (new ThreadSpec(*rhs.m_thread_spec_ap.get()));
m_condition_text = rhs.m_condition_text;
m_condition_text_hash = rhs.m_condition_text_hash;
@@ -77,7 +76,7 @@ BreakpointOptions::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() != NULL)
+ if (rhs.m_thread_spec_ap.get() != nullptr)
m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get()));
m_condition_text = rhs.m_condition_text;
m_condition_text_hash = rhs.m_condition_text_hash;
@@ -102,9 +101,7 @@ BreakpointOptions::CopyOptionsNoCallback (BreakpointOptions &orig)
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-BreakpointOptions::~BreakpointOptions()
-{
-}
+BreakpointOptions::~BreakpointOptions() = default;
//------------------------------------------------------------------
// Callbacks
@@ -144,10 +141,10 @@ BreakpointOptions::InvokeCallback (StoppointCallbackContext *context,
{
if (m_callback && context->is_synchronous == IsCallbackSynchronous())
{
- return m_callback (m_callback_baton_sp ? m_callback_baton_sp->m_data : NULL,
- context,
- break_id,
- break_loc_id);
+ return m_callback(m_callback_baton_sp ? m_callback_baton_sp->m_data : nullptr,
+ context,
+ break_id,
+ break_loc_id);
}
else
return true;
@@ -182,7 +179,7 @@ BreakpointOptions::GetConditionText (size_t *hash) const
}
else
{
- return NULL;
+ return nullptr;
}
}
@@ -195,7 +192,7 @@ BreakpointOptions::GetThreadSpecNoCreate () const
ThreadSpec *
BreakpointOptions::GetThreadSpec ()
{
- if (m_thread_spec_ap.get() == NULL)
+ if (m_thread_spec_ap.get() == nullptr)
m_thread_spec_ap.reset (new ThreadSpec());
return m_thread_spec_ap.get();
@@ -210,11 +207,10 @@ BreakpointOptions::SetThreadID (lldb::tid_t thread_id)
void
BreakpointOptions::GetDescription (Stream *s, lldb::DescriptionLevel level) const
{
-
// Figure out if there are any options not at their default value, and only print
// anything if there are:
- if (m_ignore_count != 0 || !m_enabled || m_one_shot || (GetThreadSpecNoCreate() != NULL && GetThreadSpecNoCreate()->HasSpecification ()))
+ if (m_ignore_count != 0 || !m_enabled || m_one_shot || (GetThreadSpecNoCreate() != nullptr && GetThreadSpecNoCreate()->HasSpecification ()))
{
if (level == lldb::eDescriptionLevelVerbose)
{
@@ -294,4 +290,3 @@ BreakpointOptions::CommandBaton::GetDescription (Stream *s, lldb::DescriptionLev
s->IndentLess ();
s->IndentLess ();
}
-
diff --git a/source/Breakpoint/BreakpointResolverAddress.cpp b/source/Breakpoint/BreakpointResolverAddress.cpp
index 193bc413af05..8a0469a07e46 100644
--- a/source/Breakpoint/BreakpointResolverAddress.cpp
+++ b/source/Breakpoint/BreakpointResolverAddress.cpp
@@ -16,6 +16,7 @@
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
@@ -29,10 +30,25 @@ using namespace lldb_private;
BreakpointResolverAddress::BreakpointResolverAddress
(
Breakpoint *bkpt,
+ const Address &addr,
+ const FileSpec &module_spec
+) :
+ BreakpointResolver (bkpt, BreakpointResolver::AddressResolver),
+ m_addr (addr),
+ m_resolved_addr(LLDB_INVALID_ADDRESS),
+ m_module_filespec(module_spec)
+{
+}
+
+BreakpointResolverAddress::BreakpointResolverAddress
+(
+ Breakpoint *bkpt,
const Address &addr
) :
BreakpointResolver (bkpt, BreakpointResolver::AddressResolver),
- m_addr (addr)
+ m_addr (addr),
+ m_resolved_addr(LLDB_INVALID_ADDRESS),
+ m_module_filespec()
{
}
@@ -44,10 +60,16 @@ BreakpointResolverAddress::~BreakpointResolverAddress ()
void
BreakpointResolverAddress::ResolveBreakpoint (SearchFilter &filter)
{
- // The address breakpoint only takes once, so if we've already set it we're done.
- if (m_breakpoint->GetNumLocations() > 0)
- return;
- else
+ // If the address is not section relative, then we should not try to re-resolve it, it is just some
+ // random address and we wouldn't know what to do on reload. But if it is section relative, we need to
+ // re-resolve it since the section it's in may have shifted on re-run.
+ bool re_resolve = false;
+ if (m_addr.GetSection() || m_module_filespec)
+ re_resolve = true;
+ else if (m_breakpoint->GetNumLocations() == 0)
+ re_resolve = true;
+
+ if (re_resolve)
BreakpointResolver::ResolveBreakpoint(filter);
}
@@ -58,10 +80,14 @@ BreakpointResolverAddress::ResolveBreakpointInModules
ModuleList &modules
)
{
- // The address breakpoint only takes once, so if we've already set it we're done.
- if (m_breakpoint->GetNumLocations() > 0)
- return;
- else
+ // See comment in ResolveBreakpoint.
+ bool re_resolve = false;
+ if (m_addr.GetSection())
+ re_resolve = true;
+ else if (m_breakpoint->GetNumLocations() == 0)
+ re_resolve = true;
+
+ if (re_resolve)
BreakpointResolver::ResolveBreakpointInModules (filter, modules);
}
@@ -78,14 +104,44 @@ BreakpointResolverAddress::SearchCallback
if (filter.AddressPasses (m_addr))
{
- BreakpointLocationSP bp_loc_sp(m_breakpoint->AddLocation(m_addr));
- if (bp_loc_sp && !m_breakpoint->IsInternal())
+ if (m_breakpoint->GetNumLocations() == 0)
+ {
+ // If the address is just an offset, and we're given a module, see if we can find the appropriate module
+ // loaded in the binary, and fix up m_addr to use that.
+ if (!m_addr.IsSectionOffset() && m_module_filespec)
+ {
+ Target &target = m_breakpoint->GetTarget();
+ ModuleSpec module_spec(m_module_filespec);
+ ModuleSP module_sp = target.GetImages().FindFirstModule(module_spec);
+ if (module_sp)
+ {
+ Address tmp_address;
+ if (module_sp->ResolveFileAddress(m_addr.GetOffset(), tmp_address))
+ m_addr = tmp_address;
+ }
+ }
+
+ BreakpointLocationSP bp_loc_sp(m_breakpoint->AddLocation(m_addr));
+ m_resolved_addr = m_addr.GetLoadAddress(&m_breakpoint->GetTarget());
+ if (bp_loc_sp && !m_breakpoint->IsInternal())
+ {
+ StreamString s;
+ bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+ if (log)
+ log->Printf ("Added location: %s\n", s.GetData());
+ }
+ }
+ else
{
- StreamString s;
- bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
- if (log)
- log->Printf ("Added location: %s\n", s.GetData());
+ BreakpointLocationSP loc_sp = m_breakpoint->GetLocationAtIndex(0);
+ lldb::addr_t cur_load_location = m_addr.GetLoadAddress(&m_breakpoint->GetTarget());
+ if (cur_load_location != m_resolved_addr)
+ {
+ m_resolved_addr = cur_load_location;
+ loc_sp->ClearBreakpointSite();
+ loc_sp->ResolveBreakpointSite();
+ }
}
}
return Searcher::eCallbackReturnStop;
@@ -101,7 +157,7 @@ void
BreakpointResolverAddress::GetDescription (Stream *s)
{
s->PutCString ("address = ");
- m_addr.Dump(s, m_breakpoint->GetTarget().GetProcessSP().get(), Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress);
+ m_addr.Dump(s, m_breakpoint->GetTarget().GetProcessSP().get(), Address::DumpStyleModuleWithFileAddress, Address::DumpStyleLoadAddress);
}
void
diff --git a/source/Breakpoint/BreakpointResolverName.cpp b/source/Breakpoint/BreakpointResolverName.cpp
index 581f7b016173..9ae3fe5256d4 100644
--- a/source/Breakpoint/BreakpointResolverName.cpp
+++ b/source/Breakpoint/BreakpointResolverName.cpp
@@ -7,22 +7,21 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Breakpoint/BreakpointResolverName.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Breakpoint/BreakpointResolverName.h"
+
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamString.h"
-#include "lldb/Symbol/ClangNamespaceDecl.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "Plugins/Language/ObjC/ObjCLanguage.h"
using namespace lldb;
using namespace lldb_private;
@@ -30,15 +29,16 @@ using namespace lldb_private;
BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt,
const char *name_cstr,
uint32_t name_type_mask,
+ LanguageType language,
Breakpoint::MatchType type,
bool skip_prologue) :
BreakpointResolver (bkpt, BreakpointResolver::NameResolver),
m_class_name (),
m_regex (),
m_match_type (type),
+ m_language (language),
m_skip_prologue (skip_prologue)
{
-
if (m_match_type == Breakpoint::Regexp)
{
if (!m_regex.Compile (name_cstr))
@@ -59,9 +59,11 @@ BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt,
const char *names[],
size_t num_names,
uint32_t name_type_mask,
+ LanguageType language,
bool skip_prologue) :
BreakpointResolver (bkpt, BreakpointResolver::NameResolver),
m_match_type (Breakpoint::Exact),
+ m_language (language),
m_skip_prologue (skip_prologue)
{
for (size_t i = 0; i < num_names; i++)
@@ -73,9 +75,11 @@ BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt,
BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt,
std::vector<std::string> names,
uint32_t name_type_mask,
+ LanguageType language,
bool skip_prologue) :
BreakpointResolver (bkpt, BreakpointResolver::NameResolver),
m_match_type (Breakpoint::Exact),
+ m_language (language),
m_skip_prologue (skip_prologue)
{
for (const std::string& name : names)
@@ -86,27 +90,27 @@ BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt,
BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt,
RegularExpression &func_regex,
+ lldb::LanguageType language,
bool skip_prologue) :
BreakpointResolver (bkpt, BreakpointResolver::NameResolver),
- m_class_name (NULL),
+ m_class_name (nullptr),
m_regex (func_regex),
m_match_type (Breakpoint::Regexp),
+ m_language (language),
m_skip_prologue (skip_prologue)
{
}
-BreakpointResolverName::BreakpointResolverName
-(
- Breakpoint *bkpt,
- const char *class_name,
- const char *method,
- Breakpoint::MatchType type,
- bool skip_prologue
-) :
+BreakpointResolverName::BreakpointResolverName(Breakpoint *bkpt,
+ const char *class_name,
+ const char *method,
+ Breakpoint::MatchType type,
+ bool skip_prologue ) :
BreakpointResolver (bkpt, BreakpointResolver::NameResolver),
m_class_name (class_name),
m_regex (),
m_match_type (type),
+ m_language (eLanguageTypeUnknown),
m_skip_prologue (skip_prologue)
{
LookupInfo lookup;
@@ -117,9 +121,7 @@ BreakpointResolverName::BreakpointResolverName
m_lookups.push_back (lookup);
}
-BreakpointResolverName::~BreakpointResolverName ()
-{
-}
+BreakpointResolverName::~BreakpointResolverName() = default;
BreakpointResolverName::BreakpointResolverName(const BreakpointResolverName &rhs) :
BreakpointResolver(rhs.m_breakpoint, BreakpointResolver::NameResolver),
@@ -127,15 +129,15 @@ BreakpointResolverName::BreakpointResolverName(const BreakpointResolverName &rhs
m_class_name(rhs.m_class_name),
m_regex(rhs.m_regex),
m_match_type (rhs.m_match_type),
+ m_language (rhs.m_language),
m_skip_prologue (rhs.m_skip_prologue)
{
-
}
void
BreakpointResolverName::AddNameLookup (const ConstString &name, uint32_t name_type_mask)
{
- ObjCLanguageRuntime::MethodName objc_method(name.GetCString(), false);
+ ObjCLanguage::MethodName objc_method(name.GetCString(), false);
if (objc_method.IsValid(false))
{
std::vector<ConstString> objc_names;
@@ -154,12 +156,11 @@ BreakpointResolverName::AddNameLookup (const ConstString &name, uint32_t name_ty
{
LookupInfo lookup;
lookup.name = name;
- Module::PrepareForFunctionNameLookup(lookup.name, name_type_mask, lookup.lookup_name, lookup.name_type_mask, lookup.match_name_after_lookup);
+ Module::PrepareForFunctionNameLookup(lookup.name, name_type_mask, m_language, lookup.lookup_name, lookup.name_type_mask, lookup.match_name_after_lookup);
m_lookups.push_back (lookup);
}
}
-
void
BreakpointResolverName::LookupInfo::Prune (SymbolContextList &sc_list, size_t start_idx) const
{
@@ -172,7 +173,7 @@ BreakpointResolverName::LookupInfo::Prune (SymbolContextList &sc_list, size_t st
if (!sc_list.GetContextAtIndex(i, sc))
break;
ConstString full_name (sc.GetFunctionName());
- if (full_name && ::strstr(full_name.GetCString(), name.GetCString()) == NULL)
+ if (full_name && ::strstr(full_name.GetCString(), name.GetCString()) == nullptr)
{
sc_list.RemoveContextAtIndex(i);
}
@@ -184,19 +185,15 @@ BreakpointResolverName::LookupInfo::Prune (SymbolContextList &sc_list, size_t st
}
}
-
// FIXME: Right now we look at the module level, and call the module's "FindFunctions".
// Greg says he will add function tables, maybe at the CompileUnit level to accelerate function
// lookup. At that point, we should switch the depth to CompileUnit, and look in these tables.
Searcher::CallbackReturn
-BreakpointResolverName::SearchCallback
-(
- SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool containing
-)
+BreakpointResolverName::SearchCallback(SearchFilter &filter,
+ SymbolContext &context,
+ Address *addr,
+ bool containing)
{
SymbolContextList func_list;
//SymbolContextList sym_list;
@@ -204,7 +201,7 @@ BreakpointResolverName::SearchCallback
uint32_t i;
bool new_location;
Address break_addr;
- assert (m_breakpoint != NULL);
+ assert (m_breakpoint != nullptr);
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
@@ -215,7 +212,8 @@ BreakpointResolverName::SearchCallback
return Searcher::eCallbackReturnStop;
}
bool filter_by_cu = (filter.GetFilterRequiredItems() & eSymbolContextCompUnit) != 0;
- const bool include_symbols = filter_by_cu == false;
+ bool filter_by_language = (m_language != eLanguageTypeUnknown);
+ const bool include_symbols = !filter_by_cu;
const bool include_inlines = true;
const bool append = true;
@@ -227,13 +225,13 @@ BreakpointResolverName::SearchCallback
for (const LookupInfo &lookup : m_lookups)
{
const size_t start_func_idx = func_list.GetSize();
- context.module_sp->FindFunctions (lookup.lookup_name,
- NULL,
- lookup.name_type_mask,
- include_symbols,
- include_inlines,
- append,
- func_list);
+ context.module_sp->FindFunctions(lookup.lookup_name,
+ nullptr,
+ lookup.name_type_mask,
+ include_symbols,
+ include_inlines,
+ append,
+ func_list);
const size_t end_func_idx = func_list.GetSize();
if (start_func_idx < end_func_idx)
@@ -258,15 +256,33 @@ BreakpointResolverName::SearchCallback
}
// If the filter specifies a Compilation Unit, remove the ones that don't pass at this point.
- if (filter_by_cu)
+ if (filter_by_cu || filter_by_language)
{
uint32_t num_functions = func_list.GetSize();
for (size_t idx = 0; idx < num_functions; idx++)
{
+ bool remove_it = false;
SymbolContext sc;
func_list.GetContextAtIndex(idx, sc);
- if (!sc.comp_unit || !filter.CompUnitPasses(*sc.comp_unit))
+ if (filter_by_cu)
+ {
+ if (!sc.comp_unit || !filter.CompUnitPasses(*sc.comp_unit))
+ remove_it = true;
+ }
+
+ if (filter_by_language)
+ {
+ LanguageType sym_language = sc.GetLanguage();
+ if ((Language::GetPrimaryLanguage(sym_language) !=
+ Language::GetPrimaryLanguage(m_language)) &&
+ (sym_language != eLanguageTypeUnknown))
+ {
+ remove_it = true;
+ }
+ }
+
+ if (remove_it)
{
func_list.RemoveContextAtIndex(idx);
num_functions--;
@@ -374,12 +390,15 @@ BreakpointResolverName::GetDescription (Stream *s)
s->Printf ("'%s'}", m_lookups[num_names - 1].name.GetCString());
}
}
+ if (m_language != eLanguageTypeUnknown)
+ {
+ s->Printf (", language = %s", Language::GetNameForLanguageType(m_language));
+ }
}
void
BreakpointResolverName::Dump (Stream *s) const
{
-
}
lldb::BreakpointResolverSP
diff --git a/source/Breakpoint/BreakpointSite.cpp b/source/Breakpoint/BreakpointSite.cpp
index e9ce812e7732..d2aaea098cdb 100644
--- a/source/Breakpoint/BreakpointSite.cpp
+++ b/source/Breakpoint/BreakpointSite.cpp
@@ -7,14 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Breakpoint/BreakpointSite.h"
-
// C Includes
// C++ Includes
#include <inttypes.h>
// Other libraries and framework includes
// Project includes
+#include "lldb/Breakpoint/BreakpointSite.h"
+
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/BreakpointSiteList.h"
@@ -23,13 +23,10 @@
using namespace lldb;
using namespace lldb_private;
-BreakpointSite::BreakpointSite
-(
- BreakpointSiteList *list,
- const BreakpointLocationSP& owner,
- lldb::addr_t addr,
- bool use_hardware
-) :
+BreakpointSite::BreakpointSite(BreakpointSiteList *list,
+ const BreakpointLocationSP& owner,
+ lldb::addr_t addr,
+ bool use_hardware) :
StoppointLocation(GetNextID(), addr, 0, use_hardware),
m_type (eSoftware), // Process subclasses need to set this correctly using SetType()
m_saved_opcode(),
@@ -85,7 +82,7 @@ BreakpointSite::IsBreakpointAtThisSite (lldb::break_id_t bp_id)
void
BreakpointSite::Dump(Stream *s) const
{
- if (s == NULL)
+ if (s == nullptr)
return;
s->Printf("BreakpointSite %u: addr = 0x%8.8" PRIx64 " type = %s breakpoint hw_index = %i hit_count = %-4u",
@@ -205,6 +202,7 @@ BreakpointSite::ValidForThisThread (Thread *thread)
void
BreakpointSite::BumpHitCounts()
{
+ Mutex::Locker locker(m_owners_mutex);
for (BreakpointLocationSP loc_sp : m_owners.BreakpointLocations())
{
loc_sp->BumpHitCount();
@@ -253,3 +251,14 @@ BreakpointSite::IntersectsRange(lldb::addr_t addr, size_t size, lldb::addr_t *in
}
return false;
}
+
+size_t
+BreakpointSite::CopyOwnersList (BreakpointLocationCollection &out_collection)
+{
+ Mutex::Locker locker(m_owners_mutex);
+ for (BreakpointLocationSP loc_sp : m_owners.BreakpointLocations())
+ {
+ out_collection.Add(loc_sp);
+ }
+ return out_collection.GetSize();
+}
diff --git a/source/Breakpoint/StoppointCallbackContext.cpp b/source/Breakpoint/StoppointCallbackContext.cpp
index 2266c3e429c6..9932843714f8 100644
--- a/source/Breakpoint/StoppointCallbackContext.cpp
+++ b/source/Breakpoint/StoppointCallbackContext.cpp
@@ -7,17 +7,16 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Breakpoint/StoppointCallbackContext.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Breakpoint/StoppointCallbackContext.h"
using namespace lldb_private;
StoppointCallbackContext::StoppointCallbackContext() :
- event (NULL),
+ event (nullptr),
exe_ctx_ref (),
is_synchronous (false)
{
@@ -33,7 +32,7 @@ StoppointCallbackContext::StoppointCallbackContext(Event *e, const ExecutionCont
void
StoppointCallbackContext::Clear()
{
- event = NULL;
+ event = nullptr;
exe_ctx_ref.Clear();
is_synchronous = false;
}
diff --git a/source/Breakpoint/Watchpoint.cpp b/source/Breakpoint/Watchpoint.cpp
index 45559b1901ad..00a328e3039f 100644
--- a/source/Breakpoint/Watchpoint.cpp
+++ b/source/Breakpoint/Watchpoint.cpp
@@ -7,12 +7,12 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Breakpoint/Watchpoint.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Breakpoint/Watchpoint.h"
+
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/Value.h"
@@ -22,12 +22,12 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadSpec.h"
-#include "lldb/Expression/ClangUserExpression.h"
+#include "lldb/Expression/UserExpression.h"
using namespace lldb;
using namespace lldb_private;
-Watchpoint::Watchpoint (Target& target, lldb::addr_t addr, uint32_t size, const ClangASTType *type, bool hardware) :
+Watchpoint::Watchpoint (Target& target, lldb::addr_t addr, uint32_t size, const CompilerType *type, bool hardware) :
StoppointLocation (0, addr, size, hardware),
m_target(target),
m_enabled(false),
@@ -67,9 +67,7 @@ Watchpoint::Watchpoint (Target& target, lldb::addr_t addr, uint32_t size, const
m_being_created = false;
}
-Watchpoint::~Watchpoint()
-{
-}
+Watchpoint::~Watchpoint() = default;
// This function is used when "baton" doesn't need to be freed
void
@@ -102,7 +100,6 @@ void
Watchpoint::SetDeclInfo (const std::string &str)
{
m_decl_str = str;
- return;
}
std::string
@@ -115,7 +112,6 @@ void
Watchpoint::SetWatchSpec (const std::string &str)
{
m_watch_spec_str = str;
- return;
}
// Override default impl of StoppointLocation::IsHardware() since m_is_hardware
@@ -154,10 +150,7 @@ Watchpoint::CaptureWatchedValue (const ExecutionContext &exe_ctx)
}
m_new_value_sp = ValueObjectMemory::Create (exe_ctx.GetBestExecutionContextScope(), watch_name.AsCString(), watch_address, m_type);
m_new_value_sp = m_new_value_sp->CreateConstantValue(watch_name);
- if (m_new_value_sp && m_new_value_sp->GetError().Success())
- return true;
- else
- return false;
+ return (m_new_value_sp && m_new_value_sp->GetError().Success());
}
void
@@ -190,9 +183,6 @@ Watchpoint::ShouldStop (StoppointCallbackContext *context)
if (!IsEnabled())
return false;
- if (GetHitCount() <= GetIgnoreCount())
- return false;
-
return true;
}
@@ -200,7 +190,6 @@ void
Watchpoint::GetDescription (Stream *s, lldb::DescriptionLevel level)
{
DumpWithLevel(s, level);
- return;
}
void
@@ -209,7 +198,7 @@ Watchpoint::Dump(Stream *s) const
DumpWithLevel(s, lldb::eDescriptionLevelBrief);
}
-// If prefix is NULL, we display the watch id and ignore the prefix altogether.
+// If prefix is nullptr, we display the watch id and ignore the prefix altogether.
void
Watchpoint::DumpSnapshots(Stream *s, const char *prefix) const
{
@@ -218,21 +207,38 @@ Watchpoint::DumpSnapshots(Stream *s, const char *prefix) const
s->Printf("\nWatchpoint %u hit:", GetID());
prefix = "";
}
-
+
if (m_old_value_sp)
{
- s->Printf("\n%sold value: %s", prefix, m_old_value_sp->GetValueAsCString());
+ const char *old_value_cstr = m_old_value_sp->GetValueAsCString();
+ if (old_value_cstr && old_value_cstr[0])
+ s->Printf("\n%sold value: %s", prefix, old_value_cstr);
+ else
+ {
+ const char *old_summary_cstr = m_old_value_sp-> GetSummaryAsCString();
+ if (old_summary_cstr && old_summary_cstr[0])
+ s->Printf("\n%sold value: %s", prefix, old_summary_cstr);
+ }
}
+
if (m_new_value_sp)
{
- s->Printf("\n%snew value: %s", prefix, m_new_value_sp->GetValueAsCString());
+ const char *new_value_cstr = m_new_value_sp->GetValueAsCString();
+ if (new_value_cstr && new_value_cstr[0])
+ s->Printf("\n%snew value: %s", prefix, new_value_cstr);
+ else
+ {
+ const char *new_summary_cstr = m_new_value_sp-> GetSummaryAsCString();
+ if (new_summary_cstr && new_summary_cstr[0])
+ s->Printf("\n%snew value: %s", prefix, new_summary_cstr);
+ }
}
}
void
Watchpoint::DumpWithLevel(Stream *s, lldb::DescriptionLevel description_level) const
{
- if (s == NULL)
+ if (s == nullptr)
return;
assert(description_level >= lldb::eDescriptionLevelBrief &&
@@ -334,11 +340,13 @@ Watchpoint::WatchpointRead () const
{
return m_watch_read != 0;
}
+
bool
Watchpoint::WatchpointWrite () const
{
return m_watch_write != 0;
}
+
uint32_t
Watchpoint::GetIgnoreCount () const
{
@@ -363,15 +371,26 @@ Watchpoint::InvokeCallback (StoppointCallbackContext *context)
void
Watchpoint::SetCondition (const char *condition)
{
- if (condition == NULL || condition[0] == '\0')
+ if (condition == nullptr || condition[0] == '\0')
{
if (m_condition_ap.get())
m_condition_ap.reset();
}
else
{
- // Pass NULL for expr_prefix (no translation-unit level definitions).
- m_condition_ap.reset(new ClangUserExpression (condition, NULL, lldb::eLanguageTypeUnknown, ClangUserExpression::eResultTypeAny));
+ // Pass nullptr for expr_prefix (no translation-unit level definitions).
+ Error error;
+ m_condition_ap.reset(m_target.GetUserExpressionForLanguage(condition,
+ nullptr,
+ lldb::eLanguageTypeUnknown,
+ UserExpression::eResultTypeAny,
+ EvaluateExpressionOptions(),
+ error));
+ if (error.Fail())
+ {
+ // FIXME: Log something...
+ m_condition_ap.reset();
+ }
}
SendWatchpointChangedEvent (eWatchpointEventTypeConditionChanged);
}
@@ -382,7 +401,7 @@ Watchpoint::GetConditionText () const
if (m_condition_ap.get())
return m_condition_ap->GetUserText();
else
- return NULL;
+ return nullptr;
}
void
@@ -399,8 +418,7 @@ Watchpoint::SendWatchpointChangedEvent (lldb::WatchpointEventType eventKind)
void
Watchpoint::SendWatchpointChangedEvent (WatchpointEventData *data)
{
-
- if (data == NULL)
+ if (data == nullptr)
return;
if (!m_being_created
@@ -418,9 +436,7 @@ Watchpoint::WatchpointEventData::WatchpointEventData (WatchpointEventType sub_ty
{
}
-Watchpoint::WatchpointEventData::~WatchpointEventData ()
-{
-}
+Watchpoint::WatchpointEventData::~WatchpointEventData() = default;
const ConstString &
Watchpoint::WatchpointEventData::GetFlavorString ()
@@ -435,7 +451,6 @@ Watchpoint::WatchpointEventData::GetFlavor () const
return WatchpointEventData::GetFlavorString ();
}
-
WatchpointSP &
Watchpoint::WatchpointEventData::GetWatchpoint ()
{
@@ -462,7 +477,7 @@ Watchpoint::WatchpointEventData::GetEventDataFromEvent (const Event *event)
if (event_data && event_data->GetFlavor() == WatchpointEventData::GetFlavorString())
return static_cast <const WatchpointEventData *> (event->GetData());
}
- return NULL;
+ return nullptr;
}
WatchpointEventType
@@ -470,7 +485,7 @@ Watchpoint::WatchpointEventData::GetWatchpointEventTypeFromEvent (const EventSP
{
const WatchpointEventData *data = GetEventDataFromEvent (event_sp.get());
- if (data == NULL)
+ if (data == nullptr)
return eWatchpointEventTypeInvalidType;
else
return data->GetWatchpointEventType();
diff --git a/source/Breakpoint/WatchpointList.cpp b/source/Breakpoint/WatchpointList.cpp
index 472bae06b441..64bf5cd63ed0 100644
--- a/source/Breakpoint/WatchpointList.cpp
+++ b/source/Breakpoint/WatchpointList.cpp
@@ -75,10 +75,15 @@ WatchpointList::FindByAddress (lldb::addr_t addr) const
{
wp_collection::const_iterator pos, end = m_watchpoints.end();
for (pos = m_watchpoints.begin(); pos != end; ++pos)
- if ((*pos)->GetLoadAddress() == addr) {
+ {
+ lldb::addr_t wp_addr = (*pos)->GetLoadAddress();
+ uint32_t wp_bytesize = (*pos)->GetByteSize();
+ if ((wp_addr <= addr) && ((wp_addr + wp_bytesize) > addr))
+ {
wp_sp = *pos;
break;
}
+ }
}
return wp_sp;
diff --git a/source/Breakpoint/WatchpointOptions.cpp b/source/Breakpoint/WatchpointOptions.cpp
index c2c9696c4ce7..365d884691ef 100644
--- a/source/Breakpoint/WatchpointOptions.cpp
+++ b/source/Breakpoint/WatchpointOptions.cpp
@@ -7,12 +7,12 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Breakpoint/WatchpointOptions.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Breakpoint/WatchpointOptions.h"
+
#include "lldb/Core/Stream.h"
#include "lldb/Core/StringList.h"
#include "lldb/Core/Value.h"
@@ -20,7 +20,6 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadSpec.h"
-#include "lldb/Expression/ClangUserExpression.h"
using namespace lldb;
using namespace lldb_private;
@@ -51,7 +50,7 @@ WatchpointOptions::WatchpointOptions(const WatchpointOptions& rhs) :
m_callback_is_synchronous (rhs.m_callback_is_synchronous),
m_thread_spec_ap ()
{
- if (rhs.m_thread_spec_ap.get() != NULL)
+ if (rhs.m_thread_spec_ap.get() != nullptr)
m_thread_spec_ap.reset (new ThreadSpec(*rhs.m_thread_spec_ap.get()));
}
@@ -64,7 +63,7 @@ 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() != NULL)
+ if (rhs.m_thread_spec_ap.get() != nullptr)
m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get()));
return *this;
}
@@ -87,9 +86,7 @@ WatchpointOptions::CopyOptionsNoCallback (WatchpointOptions &orig)
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-WatchpointOptions::~WatchpointOptions()
-{
-}
+WatchpointOptions::~WatchpointOptions() = default;
//------------------------------------------------------------------
// Callbacks
@@ -128,9 +125,9 @@ WatchpointOptions::InvokeCallback (StoppointCallbackContext *context,
{
if (m_callback && context->is_synchronous == IsCallbackSynchronous())
{
- return m_callback (m_callback_baton_sp ? m_callback_baton_sp->m_data : NULL,
- context,
- watch_id);
+ return m_callback(m_callback_baton_sp ? m_callback_baton_sp->m_data : nullptr,
+ context,
+ watch_id);
}
else
return true;
@@ -151,7 +148,7 @@ WatchpointOptions::GetThreadSpecNoCreate () const
ThreadSpec *
WatchpointOptions::GetThreadSpec ()
{
- if (m_thread_spec_ap.get() == NULL)
+ if (m_thread_spec_ap.get() == nullptr)
m_thread_spec_ap.reset (new ThreadSpec());
return m_thread_spec_ap.get();
@@ -172,14 +169,14 @@ WatchpointOptions::GetCallbackDescription (Stream *s, lldb::DescriptionLevel lev
m_callback_baton_sp->GetDescription (s, level);
}
}
+
void
WatchpointOptions::GetDescription (Stream *s, lldb::DescriptionLevel level) const
{
-
// Figure out if there are any options not at their default value, and only print
// anything if there are:
- if ((GetThreadSpecNoCreate() != NULL && GetThreadSpecNoCreate()->HasSpecification ()))
+ if ((GetThreadSpecNoCreate() != nullptr && GetThreadSpecNoCreate()->HasSpecification ()))
{
if (level == lldb::eDescriptionLevelVerbose)
{
@@ -238,4 +235,3 @@ WatchpointOptions::CommandBaton::GetDescription (Stream *s, lldb::DescriptionLev
s->IndentLess ();
s->IndentLess ();
}
-
diff --git a/source/Commands/CommandObjectApropos.h b/source/Commands/CommandObjectApropos.h
index f5154177bb29..d04620bc5f2d 100644
--- a/source/Commands/CommandObjectApropos.h
+++ b/source/Commands/CommandObjectApropos.h
@@ -28,17 +28,14 @@ public:
CommandObjectApropos (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectApropos ();
+ ~CommandObjectApropos() override;
protected:
- virtual bool
- DoExecute (Args& command,
- CommandReturnObject &result);
-
-
+ bool
+ DoExecute(Args& command,
+ CommandReturnObject &result) override;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectApropos_h_
+#endif // liblldb_CommandObjectApropos_h_
diff --git a/source/Commands/CommandObjectArgs.cpp b/source/Commands/CommandObjectArgs.cpp
index cf32d104911c..9f22bba78c55 100644
--- a/source/Commands/CommandObjectArgs.cpp
+++ b/source/Commands/CommandObjectArgs.cpp
@@ -17,9 +17,7 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Value.h"
-#include "lldb/Expression/ClangExpression.h"
-#include "lldb/Expression/ClangExpressionVariable.h"
-#include "lldb/Expression/ClangFunction.h"
+#include "Plugins/ExpressionParser/Clang/ClangExpressionVariable.h"
#include "lldb/Host/Host.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -148,8 +146,14 @@ CommandObjectArgs::DoExecute (Args& args, CommandReturnObject &result)
result.SetStatus (eReturnStatusFailed);
return false;
}
-
- ClangASTContext &ast_context = thread_module_sp->GetClangASTContext();
+
+ TypeSystem *type_system = thread_module_sp->GetTypeSystemForLanguage(eLanguageTypeC);
+ if (type_system == nullptr)
+ {
+ result.AppendError ("Unable to create C type system.");
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
ValueList value_list;
@@ -158,7 +162,7 @@ CommandObjectArgs::DoExecute (Args& args, CommandReturnObject &result)
const char *arg_type_cstr = args.GetArgumentAtIndex(arg_index);
Value value;
value.SetValueType(Value::eValueTypeScalar);
- ClangASTType clang_type;
+ CompilerType compiler_type;
char *int_pos;
if ((int_pos = strstr (const_cast<char*>(arg_type_cstr), "int")))
@@ -200,10 +204,9 @@ CommandObjectArgs::DoExecute (Args& args, CommandReturnObject &result)
result.SetStatus (eReturnStatusFailed);
return false;
}
+ compiler_type = type_system->GetBuiltinTypeForEncodingAndBitSize(encoding, width);
- clang_type = ast_context.GetBuiltinTypeForEncodingAndBitSize(encoding, width);
-
- if (!clang_type.IsValid())
+ if (!compiler_type.IsValid())
{
result.AppendErrorWithFormat ("Couldn't get Clang type for format %s (%s integer, width %d).\n",
arg_type_cstr,
@@ -217,9 +220,9 @@ CommandObjectArgs::DoExecute (Args& args, CommandReturnObject &result)
else if (strchr (arg_type_cstr, '*'))
{
if (!strcmp (arg_type_cstr, "void*"))
- clang_type = ast_context.GetBasicType(eBasicTypeVoid).GetPointerType();
+ compiler_type = type_system->GetBasicTypeFromAST(eBasicTypeVoid).GetPointerType();
else if (!strcmp (arg_type_cstr, "char*"))
- clang_type = ast_context.GetCStringType (false);
+ compiler_type = type_system->GetBasicTypeFromAST(eBasicTypeChar).GetPointerType();
else
{
result.AppendErrorWithFormat ("Invalid format: %s.\n", arg_type_cstr);
@@ -234,7 +237,7 @@ CommandObjectArgs::DoExecute (Args& args, CommandReturnObject &result)
return false;
}
- value.SetClangType (clang_type);
+ value.SetCompilerType (compiler_type);
value_list.PushValue(value);
}
diff --git a/source/Commands/CommandObjectArgs.h b/source/Commands/CommandObjectArgs.h
index 6691283ce099..4a4e1c35cf31 100644
--- a/source/Commands/CommandObjectArgs.h
+++ b/source/Commands/CommandObjectArgs.h
@@ -16,7 +16,6 @@
// Project includes
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/Options.h"
-#include "lldb/Core/Language.h"
namespace lldb_private {
@@ -30,17 +29,16 @@ namespace lldb_private {
CommandOptions (CommandInterpreter &interpreter);
- virtual
- ~CommandOptions ();
+ ~CommandOptions() override;
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg);
+ Error
+ SetOptionValue(uint32_t option_idx, const char *option_arg) override;
void
- OptionParsingStarting ();
+ OptionParsingStarting() override;
const OptionDefinition*
- GetDefinitions ();
+ GetDefinitions() override;
// Options table: Required for subclasses of Options.
@@ -49,24 +47,20 @@ namespace lldb_private {
CommandObjectArgs (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectArgs ();
+ ~CommandObjectArgs() override;
- virtual
Options *
- GetOptions ();
-
+ GetOptions() override;
protected:
CommandOptions m_options;
- virtual bool
- DoExecute ( Args& command,
- CommandReturnObject &result);
-
+ bool
+ DoExecute(Args& command,
+ CommandReturnObject &result) override;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectArgs_h_
+#endif // liblldb_CommandObjectArgs_h_
diff --git a/source/Commands/CommandObjectBreakpoint.cpp b/source/Commands/CommandObjectBreakpoint.cpp
index 162bfb4b5a76..bb59e1f82e8d 100644
--- a/source/Commands/CommandObjectBreakpoint.cpp
+++ b/source/Commands/CommandObjectBreakpoint.cpp
@@ -26,7 +26,7 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Target/Language.h"
#include "lldb/Target/Target.h"
#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Target/StackFrame.h"
@@ -77,11 +77,10 @@ public:
}
- virtual
- ~CommandObjectBreakpointSet () {}
+ ~CommandObjectBreakpointSet () override {}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -111,6 +110,7 @@ public:
m_throw_bp (true),
m_hardware (false),
m_exception_language (eLanguageTypeUnknown),
+ m_language (lldb::eLanguageTypeUnknown),
m_skip_prologue (eLazyBoolCalculate),
m_one_shot (false),
m_all_files (false),
@@ -119,11 +119,10 @@ public:
}
- virtual
- ~CommandOptions () {}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -164,7 +163,7 @@ public:
case 'E':
{
- LanguageType language = LanguageRuntime::GetLanguageTypeFromString (option_arg);
+ LanguageType language = Language::GetLanguageTypeFromString (option_arg);
switch (language)
{
@@ -249,6 +248,12 @@ public:
break;
}
+ case 'L':
+ m_language = Language::GetLanguageTypeFromString (option_arg);
+ if (m_language == eLanguageTypeUnknown)
+ error.SetErrorStringWithFormat ("Unknown language type: '%s' for breakpoint", option_arg);
+ break;
+
case 'm':
{
bool success;
@@ -349,7 +354,7 @@ public:
return error;
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_condition.clear();
m_filenames.Clear();
@@ -370,6 +375,7 @@ public:
m_throw_bp = true;
m_hardware = false;
m_exception_language = eLanguageTypeUnknown;
+ m_language = lldb::eLanguageTypeUnknown;
m_skip_prologue = eLazyBoolCalculate;
m_one_shot = false;
m_use_dummy = false;
@@ -380,7 +386,7 @@ public:
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -411,6 +417,7 @@ public:
bool m_throw_bp;
bool m_hardware; // Request to use hardware breakpoints
lldb::LanguageType m_exception_language;
+ lldb::LanguageType m_language;
LazyBool m_skip_prologue;
bool m_one_shot;
bool m_use_dummy;
@@ -421,9 +428,9 @@ public:
};
protected:
- virtual bool
+ bool
DoExecute (Args& command,
- CommandReturnObject &result)
+ CommandReturnObject &result) override
{
Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
@@ -500,11 +507,32 @@ protected:
break;
case eSetTypeAddress: // Breakpoint by address
- bp = target->CreateBreakpoint (m_options.m_load_addr,
- internal,
- m_options.m_hardware).get();
+ {
+ // If a shared library has been specified, make an lldb_private::Address with the library, and
+ // use that. That way the address breakpoint will track the load location of the library.
+ size_t num_modules_specified = m_options.m_modules.GetSize();
+ if (num_modules_specified == 1)
+ {
+ const FileSpec *file_spec = m_options.m_modules.GetFileSpecPointerAtIndex(0);
+ bp = target->CreateAddressInModuleBreakpoint (m_options.m_load_addr,
+ internal,
+ file_spec,
+ m_options.m_hardware).get();
+ }
+ else if (num_modules_specified == 0)
+ {
+ bp = target->CreateBreakpoint (m_options.m_load_addr,
+ internal,
+ m_options.m_hardware).get();
+ }
+ else
+ {
+ result.AppendError("Only one shared library can be specified for address breakpoints.");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
break;
-
+ }
case eSetTypeFunctionName: // Breakpoint by function name
{
uint32_t name_type_mask = m_options.m_func_name_type_mask;
@@ -516,6 +544,7 @@ protected:
&(m_options.m_filenames),
m_options.m_func_names,
name_type_mask,
+ m_options.m_language,
m_options.m_skip_prologue,
internal,
m_options.m_hardware).get();
@@ -538,6 +567,7 @@ protected:
bp = target->CreateFuncRegexBreakpoint (&(m_options.m_modules),
&(m_options.m_filenames),
regexp,
+ m_options.m_language,
m_options.m_skip_prologue,
internal,
m_options.m_hardware).get();
@@ -709,6 +739,7 @@ private:
#define LLDB_OPT_NOT_10 ( LLDB_OPT_SET_FROM_TO(1, 10) & ~LLDB_OPT_SET_10 )
#define LLDB_OPT_SKIP_PROLOGUE ( LLDB_OPT_SET_1 | LLDB_OPT_SET_FROM_TO(3,8) )
#define LLDB_OPT_MOVE_TO_NEAREST_CODE ( LLDB_OPT_SET_1 | LLDB_OPT_SET_9 )
+#define LLDB_OPT_EXPR_LANGUAGE ( LLDB_OPT_SET_FROM_TO(3, 8) )
OptionDefinition
CommandObjectBreakpointSet::CommandOptions::g_option_table[] =
@@ -756,14 +787,21 @@ CommandObjectBreakpointSet::CommandOptions::g_option_table[] =
// "Set the breakpoint by source location at this particular column."},
{ LLDB_OPT_SET_2, true, "address", 'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeAddressOrExpression,
- "Set the breakpoint by address, at the specified address."},
+ "Set the breakpoint at the specified address. "
+ "If the address maps uniquely to a particular "
+ "binary, then the address will be converted to a \"file\" address, so that the breakpoint will track that binary+offset no matter where "
+ "the binary eventually loads. "
+ "Alternately, if you also specify the module - with the -s option - then the address will be treated as "
+ "a file address in that module, and resolved accordingly. Again, this will allow lldb to track that offset on "
+ "subsequent reloads. The module need not have been loaded at the time you specify this breakpoint, and will "
+ "get resolved when the module is loaded."},
{ LLDB_OPT_SET_3, true, "name", 'n', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
"Set the breakpoint by function name. Can be repeated multiple times to make one breakpoint for multiple names" },
{ LLDB_OPT_SET_4, true, "fullname", 'F', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFullName,
"Set the breakpoint by fully qualified function names. For C++ this means namespaces and all arguments, and "
- "for Objective C this means a full function prototype with class and selector. "
+ "for Objective C this means a full function prototype with class and selector. "
"Can be repeated multiple times to make one breakpoint for multiple names." },
{ LLDB_OPT_SET_5, true, "selector", 'S', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeSelector,
@@ -800,6 +838,9 @@ CommandObjectBreakpointSet::CommandOptions::g_option_table[] =
// { LLDB_OPT_SET_10, false, "exception-typename", 'O', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeTypeName,
// "The breakpoint will only stop if an exception Object of this type is thrown. Can be repeated multiple times to stop for multiple object types" },
+ { LLDB_OPT_EXPR_LANGUAGE, false, "language", 'L', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage,
+ "Specifies the Language to use when interpreting the breakpoint's expression (note: currently only implemented for setting breakpoints on identifiers). If not set the target.language setting is used." },
+
{ LLDB_OPT_SKIP_PROLOGUE, false, "skip-prologue", 'K', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean,
"sKip the prologue if the breakpoint is at the beginning of a function. If not set the target.skip-prologue setting is used." },
@@ -840,11 +881,10 @@ public:
}
- virtual
- ~CommandObjectBreakpointModify () {}
+ ~CommandObjectBreakpointModify () override {}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -874,11 +914,10 @@ public:
{
}
- virtual
- ~CommandOptions () {}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -979,7 +1018,7 @@ public:
return error;
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_ignore_count = 0;
m_thread_id = LLDB_INVALID_THREAD_ID;
@@ -999,7 +1038,7 @@ public:
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -1031,8 +1070,8 @@ public:
};
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
if (target == NULL)
@@ -1159,12 +1198,11 @@ public:
}
- virtual
- ~CommandObjectBreakpointEnable () {}
+ ~CommandObjectBreakpointEnable () override {}
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = GetSelectedOrDummyTarget();
if (target == NULL)
@@ -1279,12 +1317,11 @@ the second re-enables the first location."
}
- virtual
- ~CommandObjectBreakpointDisable () {}
+ ~CommandObjectBreakpointDisable () override {}
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = GetSelectedOrDummyTarget();
if (target == NULL)
@@ -1389,11 +1426,10 @@ public:
}
- virtual
- ~CommandObjectBreakpointList () {}
+ ~CommandObjectBreakpointList () override {}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -1409,11 +1445,10 @@ public:
{
}
- virtual
- ~CommandOptions () {}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -1444,7 +1479,7 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_level = lldb::eDescriptionLevelFull;
m_internal = false;
@@ -1452,7 +1487,7 @@ public:
}
const OptionDefinition *
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -1470,8 +1505,8 @@ public:
};
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
@@ -1586,11 +1621,10 @@ public:
{
}
- virtual
- ~CommandObjectBreakpointClear () {}
+ ~CommandObjectBreakpointClear () override {}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -1606,11 +1640,10 @@ public:
{
}
- virtual
- ~CommandOptions () {}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -1634,14 +1667,14 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_filename.clear();
m_line_num = 0;
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -1658,8 +1691,8 @@ public:
};
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = GetSelectedOrDummyTarget();
if (target == NULL)
@@ -1786,11 +1819,10 @@ public:
m_arguments.push_back (arg);
}
- virtual
- ~CommandObjectBreakpointDelete () {}
+ ~CommandObjectBreakpointDelete () override {}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -1806,11 +1838,10 @@ public:
{
}
- virtual
- ~CommandOptions () {}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -1834,14 +1865,14 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_use_dummy = false;
m_force = false;
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -1856,8 +1887,8 @@ public:
};
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
@@ -1976,27 +2007,26 @@ public:
}
- virtual
- ~BreakpointNameOptionGroup ()
+ ~BreakpointNameOptionGroup () override
{
}
- virtual uint32_t
- GetNumDefinitions ()
+ uint32_t
+ GetNumDefinitions () override
{
return sizeof (g_breakpoint_name_options) / sizeof (OptionDefinition);
}
- virtual const OptionDefinition*
- GetDefinitions ()
+ const OptionDefinition*
+ GetDefinitions () override
{
return g_breakpoint_name_options;
}
- virtual Error
+ Error
SetOptionValue (CommandInterpreter &interpreter,
uint32_t option_idx,
- const char *option_value)
+ const char *option_value) override
{
Error error;
const int short_option = g_breakpoint_name_options[option_idx].short_option;
@@ -2024,8 +2054,8 @@ public:
return error;
}
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter)
+ void
+ OptionParsingStarting (CommandInterpreter &interpreter) override
{
m_name.Clear();
m_breakpoint.Clear();
@@ -2062,18 +2092,17 @@ public:
m_option_group.Finalize();
}
- virtual
- ~CommandObjectBreakpointNameAdd () {}
+ ~CommandObjectBreakpointNameAdd () override {}
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_option_group;
}
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
if (!m_name_options.m_name.OptionWasSet())
{
@@ -2158,18 +2187,17 @@ public:
m_option_group.Finalize();
}
- virtual
- ~CommandObjectBreakpointNameDelete () {}
+ ~CommandObjectBreakpointNameDelete () override {}
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_option_group;
}
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
if (!m_name_options.m_name.OptionWasSet())
{
@@ -2243,18 +2271,17 @@ public:
m_option_group.Finalize();
}
- virtual
- ~CommandObjectBreakpointNameList () {}
+ ~CommandObjectBreakpointNameList () override {}
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_option_group;
}
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = GetSelectedOrDummyTarget(m_name_options.m_use_dummy.GetCurrentValue());
@@ -2339,8 +2366,7 @@ public:
}
- virtual
- ~CommandObjectBreakpointName ()
+ ~CommandObjectBreakpointName () override
{
}
diff --git a/source/Commands/CommandObjectBreakpoint.h b/source/Commands/CommandObjectBreakpoint.h
index 3fdd2a5f56be..123e8232c987 100644
--- a/source/Commands/CommandObjectBreakpoint.h
+++ b/source/Commands/CommandObjectBreakpoint.h
@@ -34,8 +34,7 @@ class CommandObjectMultiwordBreakpoint : public CommandObjectMultiword
public:
CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectMultiwordBreakpoint ();
+ ~CommandObjectMultiwordBreakpoint() override;
static void
VerifyBreakpointOrLocationIDs (Args &args, Target *target, CommandReturnObject &result, BreakpointIDList *valid_ids)
@@ -56,4 +55,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_CommandObjectBreakpoint_h_
+#endif // liblldb_CommandObjectBreakpoint_h_
diff --git a/source/Commands/CommandObjectBreakpointCommand.cpp b/source/Commands/CommandObjectBreakpointCommand.cpp
index ac9c9a64188c..7b58bf9185bc 100644
--- a/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -178,17 +178,16 @@ are no syntax errors may indicate that a function was declared but never called.
m_arguments.push_back (arg);
}
- virtual
- ~CommandObjectBreakpointCommandAdd () {}
+ ~CommandObjectBreakpointCommandAdd () override {}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
- virtual void
- IOHandlerActivated (IOHandler &io_handler)
+ void
+ IOHandlerActivated (IOHandler &io_handler) override
{
StreamFileSP output_sp(io_handler.GetOutputStreamFile());
if (output_sp)
@@ -199,8 +198,8 @@ are no syntax errors may indicate that a function was declared but never called.
}
- virtual void
- IOHandlerInputComplete (IOHandler &io_handler, std::string &line)
+ void
+ IOHandlerInputComplete (IOHandler &io_handler, std::string &line) override
{
io_handler.SetIsDone(true);
@@ -315,11 +314,10 @@ are no syntax errors may indicate that a function was declared but never called.
{
}
- virtual
- ~CommandOptions () {}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -374,7 +372,7 @@ are no syntax errors may indicate that a function was declared but never called.
return error;
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_use_commands = true;
m_use_script_language = false;
@@ -388,7 +386,7 @@ are no syntax errors may indicate that a function was declared but never called.
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -412,8 +410,8 @@ are no syntax errors may indicate that a function was declared but never called.
};
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
@@ -596,11 +594,10 @@ public:
}
- virtual
- ~CommandObjectBreakpointCommandDelete () {}
+ ~CommandObjectBreakpointCommandDelete () override {}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -615,11 +612,10 @@ public:
{
}
- virtual
- ~CommandOptions () {}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -639,13 +635,13 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_use_dummy = false;
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -659,8 +655,8 @@ public:
};
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
@@ -764,13 +760,12 @@ public:
m_arguments.push_back (arg);
}
- virtual
- ~CommandObjectBreakpointCommandList () {}
+ ~CommandObjectBreakpointCommandList () override {}
protected:
- virtual bool
+ bool
DoExecute (Args& command,
- CommandReturnObject &result)
+ CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
diff --git a/source/Commands/CommandObjectBreakpointCommand.h b/source/Commands/CommandObjectBreakpointCommand.h
index e91790779510..94afc785c575 100644
--- a/source/Commands/CommandObjectBreakpointCommand.h
+++ b/source/Commands/CommandObjectBreakpointCommand.h
@@ -13,7 +13,6 @@
// C Includes
// C++ Includes
-
// Other libraries and framework includes
// Project includes
@@ -23,7 +22,6 @@
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/CommandObjectMultiword.h"
-
namespace lldb_private {
//-------------------------------------------------------------------------
@@ -35,11 +33,9 @@ class CommandObjectBreakpointCommand : public CommandObjectMultiword
public:
CommandObjectBreakpointCommand (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectBreakpointCommand ();
-
+ ~CommandObjectBreakpointCommand() override;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectBreakpointCommand_h_
+#endif // liblldb_CommandObjectBreakpointCommand_h_
diff --git a/source/Commands/CommandObjectBugreport.cpp b/source/Commands/CommandObjectBugreport.cpp
index f171d2f6267f..3d00cb817e3d 100644
--- a/source/Commands/CommandObjectBugreport.cpp
+++ b/source/Commands/CommandObjectBugreport.cpp
@@ -43,7 +43,7 @@ public:
m_option_group.Finalize();
}
- ~CommandObjectBugreportUnwind()
+ ~CommandObjectBugreportUnwind() override
{
}
diff --git a/source/Commands/CommandObjectBugreport.h b/source/Commands/CommandObjectBugreport.h
index d062e0d79373..3adde51e0274 100644
--- a/source/Commands/CommandObjectBugreport.h
+++ b/source/Commands/CommandObjectBugreport.h
@@ -27,10 +27,9 @@ class CommandObjectMultiwordBugreport : public CommandObjectMultiword
public:
CommandObjectMultiwordBugreport(CommandInterpreter &interpreter);
- virtual
- ~CommandObjectMultiwordBugreport();
+ ~CommandObjectMultiwordBugreport() override;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectBugreport_h_
+#endif // liblldb_CommandObjectBugreport_h_
diff --git a/source/Commands/CommandObjectCommands.cpp b/source/Commands/CommandObjectCommands.cpp
index f56d089877de..e859b5d64b11 100644
--- a/source/Commands/CommandObjectCommands.cpp
+++ b/source/Commands/CommandObjectCommands.cpp
@@ -47,10 +47,10 @@ public:
{
}
- ~CommandObjectCommandsHistory () {}
+ ~CommandObjectCommandsHistory () override {}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -70,11 +70,10 @@ protected:
{
}
- virtual
- ~CommandOptions (){}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -109,7 +108,7 @@ protected:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_start_idx.Clear();
m_stop_idx.Clear();
@@ -118,7 +117,7 @@ protected:
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -136,7 +135,7 @@ protected:
};
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
if (m_options.m_clear.GetCurrentValue() && m_options.m_clear.OptionWasSet())
{
@@ -259,15 +258,15 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectCommandsSource () {}
+ ~CommandObjectCommandsSource () override {}
- virtual const char*
- GetRepeatCommand (Args &current_command_args, uint32_t index)
+ const char*
+ GetRepeatCommand (Args &current_command_args, uint32_t index) override
{
return "";
}
- virtual int
+ int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -275,7 +274,7 @@ public:
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
completion_str.erase (cursor_char_position);
@@ -291,8 +290,8 @@ public:
return matches.GetSize();
}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -311,11 +310,10 @@ protected:
{
}
- virtual
- ~CommandOptions (){}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -343,7 +341,7 @@ protected:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_stop_on_error.Clear();
m_silent_run.Clear();
@@ -351,7 +349,7 @@ protected:
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -368,7 +366,7 @@ protected:
};
bool
- DoExecute(Args& command, CommandReturnObject &result)
+ DoExecute(Args& command, CommandReturnObject &result) override
{
const size_t argc = command.GetArgumentCount();
if (argc == 1)
@@ -553,13 +551,13 @@ rather than using a positional placeholder:" R"(
m_arguments.push_back (arg3);
}
- ~CommandObjectCommandsAlias ()
+ ~CommandObjectCommandsAlias () override
{
}
protected:
- virtual bool
- DoExecute (const char *raw_command_line, CommandReturnObject &result)
+ bool
+ DoExecute (const char *raw_command_line, CommandReturnObject &result) override
{
Args args (raw_command_line);
std::string raw_command_string (raw_command_line);
@@ -820,13 +818,13 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectCommandsUnalias()
+ ~CommandObjectCommandsUnalias() override
{
}
protected:
bool
- DoExecute (Args& args, CommandReturnObject &result)
+ DoExecute (Args& args, CommandReturnObject &result) override
{
CommandObject::CommandMap::iterator pos;
CommandObject *cmd_obj;
@@ -913,13 +911,13 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectCommandsDelete()
+ ~CommandObjectCommandsDelete() override
{
}
protected:
bool
- DoExecute (Args& args, CommandReturnObject &result)
+ DoExecute (Args& args, CommandReturnObject &result) override
{
CommandObject::CommandMap::iterator pos;
@@ -1000,7 +998,7 @@ a number follows 'f':" R"(
);
}
- ~CommandObjectCommandsAddRegex()
+ ~CommandObjectCommandsAddRegex() override
{
}
@@ -1250,11 +1248,10 @@ private:
{
}
- virtual
- ~CommandOptions (){}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -1277,14 +1274,14 @@ private:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_help.clear();
m_syntax.clear();
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -1363,13 +1360,12 @@ public:
}
}
- virtual
- ~CommandObjectPythonFunction ()
+ ~CommandObjectPythonFunction () override
{
}
- virtual bool
- IsRemovable () const
+ bool
+ IsRemovable () const override
{
return true;
}
@@ -1386,8 +1382,8 @@ public:
return m_synchro;
}
- virtual const char *
- GetHelpLong ()
+ const char *
+ GetHelpLong () override
{
if (!m_fetched_help_long)
{
@@ -1404,8 +1400,8 @@ public:
}
protected:
- virtual bool
- DoExecute (const char *raw_command_line, CommandReturnObject &result)
+ bool
+ DoExecute (const char *raw_command_line, CommandReturnObject &result) override
{
ScriptInterpreter* scripter = m_interpreter.GetScriptInterpreter();
@@ -1470,13 +1466,12 @@ public:
GetFlags().Set(scripter->GetFlagsForCommandObject(cmd_obj_sp));
}
- virtual
- ~CommandObjectScriptingObject ()
+ ~CommandObjectScriptingObject () override
{
}
- virtual bool
- IsRemovable () const
+ bool
+ IsRemovable () const override
{
return true;
}
@@ -1493,8 +1488,8 @@ public:
return m_synchro;
}
- virtual const char *
- GetHelp ()
+ const char *
+ GetHelp () override
{
if (!m_fetched_help_short)
{
@@ -1510,8 +1505,8 @@ public:
return CommandObjectRaw::GetHelp();
}
- virtual const char *
- GetHelpLong ()
+ const char *
+ GetHelpLong () override
{
if (!m_fetched_help_long)
{
@@ -1528,8 +1523,8 @@ public:
}
protected:
- virtual bool
- DoExecute (const char *raw_command_line, CommandReturnObject &result)
+ bool
+ DoExecute (const char *raw_command_line, CommandReturnObject &result) override
{
ScriptInterpreter* scripter = m_interpreter.GetScriptInterpreter();
@@ -1592,11 +1587,11 @@ public:
m_arguments.push_back (arg1);
}
- ~CommandObjectCommandsScriptImport ()
+ ~CommandObjectCommandsScriptImport () override
{
}
- virtual int
+ int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -1604,7 +1599,7 @@ public:
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
completion_str.erase (cursor_char_position);
@@ -1620,8 +1615,8 @@ public:
return matches.GetSize();
}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -1637,11 +1632,10 @@ protected:
{
}
- virtual
- ~CommandOptions (){}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -1660,13 +1654,13 @@ protected:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_allow_reload = true;
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -1681,7 +1675,7 @@ protected:
};
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
if (m_interpreter.GetDebugger().GetScriptLanguage() != lldb::eScriptLanguagePython)
{
@@ -1772,12 +1766,12 @@ public:
m_arguments.push_back (arg1);
}
- ~CommandObjectCommandsScriptAdd ()
+ ~CommandObjectCommandsScriptAdd () override
{
}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -1797,11 +1791,10 @@ protected:
{
}
- virtual
- ~CommandOptions (){}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -1834,7 +1827,7 @@ protected:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_class_name.clear();
m_funct_name.clear();
@@ -1843,7 +1836,7 @@ protected:
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -1860,8 +1853,8 @@ protected:
ScriptedCommandSynchronicity m_synchronicity;
};
- virtual void
- IOHandlerActivated (IOHandler &io_handler)
+ void
+ IOHandlerActivated (IOHandler &io_handler) override
{
StreamFileSP output_sp(io_handler.GetOutputStreamFile());
if (output_sp)
@@ -1872,8 +1865,8 @@ protected:
}
- virtual void
- IOHandlerInputComplete (IOHandler &io_handler, std::string &data)
+ void
+ IOHandlerInputComplete (IOHandler &io_handler, std::string &data) override
{
StreamFileSP error_sp = io_handler.GetErrorStreamFile();
@@ -1935,7 +1928,7 @@ protected:
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
if (m_interpreter.GetDebugger().GetScriptLanguage() != lldb::eScriptLanguagePython)
@@ -2064,12 +2057,12 @@ public:
{
}
- ~CommandObjectCommandsScriptList ()
+ ~CommandObjectCommandsScriptList () override
{
}
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
m_interpreter.GetHelp(result,
@@ -2100,13 +2093,13 @@ public:
{
}
- ~CommandObjectCommandsScriptClear ()
+ ~CommandObjectCommandsScriptClear () override
{
}
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
m_interpreter.RemoveAllUser();
@@ -2144,13 +2137,13 @@ public:
m_arguments.push_back (arg1);
}
- ~CommandObjectCommandsScriptDelete ()
+ ~CommandObjectCommandsScriptDelete () override
{
}
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
size_t argc = command.GetArgumentCount();
@@ -2202,7 +2195,7 @@ public:
LoadSubCommand ("import", CommandObjectSP (new CommandObjectCommandsScriptImport (interpreter)));
}
- ~CommandObjectMultiwordCommandsScript ()
+ ~CommandObjectMultiwordCommandsScript () override
{
}
diff --git a/source/Commands/CommandObjectCommands.h b/source/Commands/CommandObjectCommands.h
index 8a56e8dae6ff..c12c71051ffe 100644
--- a/source/Commands/CommandObjectCommands.h
+++ b/source/Commands/CommandObjectCommands.h
@@ -30,11 +30,9 @@ public:
CommandObjectMultiwordCommands (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectMultiwordCommands ();
-
+ ~CommandObjectMultiwordCommands() override;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectCommands_h_
+#endif // liblldb_CommandObjectCommands_h_
diff --git a/source/Commands/CommandObjectDisassemble.cpp b/source/Commands/CommandObjectDisassemble.cpp
index 1e575fe963f3..100d8692039f 100644
--- a/source/Commands/CommandObjectDisassemble.cpp
+++ b/source/Commands/CommandObjectDisassemble.cpp
@@ -289,7 +289,7 @@ CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result)
if (!m_options.arch.IsValid())
{
- result.AppendError ("use the --arch option or set the target architecure to disassemble");
+ result.AppendError ("use the --arch option or set the target architecture to disassemble");
result.SetStatus (eReturnStatusFailed);
return false;
}
diff --git a/source/Commands/CommandObjectDisassemble.h b/source/Commands/CommandObjectDisassemble.h
index 7a7509858b98..d892824d017d 100644
--- a/source/Commands/CommandObjectDisassemble.h
+++ b/source/Commands/CommandObjectDisassemble.h
@@ -33,17 +33,16 @@ public:
CommandOptions (CommandInterpreter &interpreter);
- virtual
- ~CommandOptions ();
+ ~CommandOptions() override;
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg);
+ Error
+ SetOptionValue(uint32_t option_idx, const char *option_arg) override;
void
- OptionParsingStarting ();
+ OptionParsingStarting() override;
const OptionDefinition*
- GetDefinitions ();
+ GetDefinitions() override;
const char *
GetPluginName ()
@@ -61,8 +60,8 @@ public:
return flavor_string.c_str();
}
- virtual Error
- OptionParsingFinished ();
+ Error
+ OptionParsingFinished() override;
bool show_mixed; // Show mixed source/assembly
bool show_bytes;
@@ -86,25 +85,22 @@ public:
CommandObjectDisassemble (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectDisassemble ();
+ ~CommandObjectDisassemble() override;
- virtual
Options *
- GetOptions ()
+ GetOptions() override
{
return &m_options;
}
protected:
- virtual bool
- DoExecute (Args& command,
- CommandReturnObject &result);
+ bool
+ DoExecute(Args& command,
+ CommandReturnObject &result) override;
CommandOptions m_options;
-
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectDisassemble_h_
+#endif // liblldb_CommandObjectDisassemble_h_
diff --git a/source/Commands/CommandObjectExpression.cpp b/source/Commands/CommandObjectExpression.cpp
index 1be17a0cfddc..7f0b03b37c20 100644
--- a/source/Commands/CommandObjectExpression.cpp
+++ b/source/Commands/CommandObjectExpression.cpp
@@ -16,16 +16,16 @@
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/DataFormatters/ValueObjectPrinter.h"
-#include "lldb/Expression/ClangExpressionVariable.h"
-#include "lldb/Expression/ClangUserExpression.h"
-#include "lldb/Expression/ClangFunction.h"
+#include "Plugins/ExpressionParser/Clang/ClangExpressionVariable.h"
+#include "lldb/Expression/UserExpression.h"
#include "lldb/Expression/DWARFExpression.h"
+#include "lldb/Expression/REPL.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Target/Language.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Variable.h"
#include "lldb/Target/Process.h"
@@ -63,6 +63,7 @@ CommandObjectExpression::CommandOptions::g_option_table[] =
{ LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "timeout", 't', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeUnsignedInteger, "Timeout value (in microseconds) for running the expression."},
{ LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "unwind-on-error", 'u', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "Clean up program state if the expression causes a crash, or raises a signal. Note, unlike gdb hitting a breakpoint is controlled by another option (-i)."},
{ LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "debug", 'g', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "When specified, debug the JIT code by setting a breakpoint on the first instruction and forcing breakpoints to not be ignored (-i0) and no unwinding to happen on error (-u0)."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "language", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage, "Specifies the Language to use when parsing the expression. If not set the target.language setting is used." },
{ LLDB_OPT_SET_1, false, "description-verbosity", 'v', OptionParser::eOptionalArgument, NULL, g_description_verbosity_type, 0, eArgTypeDescriptionVerbosity, "How verbose should the output of this expression be, if the object description is asked for."},
};
@@ -84,12 +85,11 @@ CommandObjectExpression::CommandOptions::SetOptionValue (CommandInterpreter &int
switch (short_option)
{
- //case 'l':
- //if (language.SetLanguageFromCString (option_arg) == false)
- //{
- // error.SetErrorStringWithFormat("invalid language option argument '%s'", option_arg);
- //}
- //break;
+ case 'l':
+ language = Language::GetLanguageTypeFromString (option_arg);
+ if (language == eLanguageTypeUnknown)
+ error.SetErrorStringWithFormat ("unknown language type: '%s' for expression", option_arg);
+ break;
case 'a':
{
@@ -180,6 +180,7 @@ CommandObjectExpression::CommandOptions::OptionParsingStarting (CommandInterpret
try_all_threads = true;
timeout = 0;
debug = false;
+ language = eLanguageTypeUnknown;
m_verbosity = eLanguageRuntimeDescriptionDisplayVerbosityCompact;
}
@@ -192,12 +193,13 @@ CommandObjectExpression::CommandOptions::GetDefinitions ()
CommandObjectExpression::CommandObjectExpression (CommandInterpreter &interpreter) :
CommandObjectRaw (interpreter,
"expression",
- "Evaluate a C/ObjC/C++ expression in the current program context, using user defined variables and variables currently in scope.",
+ "Evaluate an expression in the current program context, using user defined variables and variables currently in scope.",
NULL,
eCommandProcessMustBePaused | eCommandTryTargetAPILock),
IOHandlerDelegate (IOHandlerDelegate::Completion::Expression),
m_option_group (interpreter),
m_format_options (eFormatDefault),
+ m_repl_option (LLDB_OPT_SET_1, false, "repl", 'r', "Drop into REPL", false, true),
m_command_options (),
m_expr_line_count (0),
m_expr_lines ()
@@ -253,6 +255,7 @@ Examples:
m_option_group.Append (&m_format_options, OptionGroupFormat::OPTION_GROUP_FORMAT | OptionGroupFormat::OPTION_GROUP_GDB_FMT, LLDB_OPT_SET_1);
m_option_group.Append (&m_command_options);
m_option_group.Append (&m_varobj_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1 | LLDB_OPT_SET_2);
+ m_option_group.Append (&m_repl_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_3);
m_option_group.Finalize();
}
@@ -288,8 +291,8 @@ CommandObjectExpression::EvaluateExpression
if (target)
{
lldb::ValueObjectSP result_valobj_sp;
-
bool keep_in_memory = true;
+ StackFrame *frame = exe_ctx.GetFramePtr();
EvaluateExpressionOptions options;
options.SetCoerceToId(m_varobj_options.use_objc);
@@ -299,7 +302,8 @@ CommandObjectExpression::EvaluateExpression
options.SetUseDynamic(m_varobj_options.use_dynamic);
options.SetTryAllThreads(m_command_options.try_all_threads);
options.SetDebug(m_command_options.debug);
-
+ options.SetLanguage(m_command_options.language);
+
// If there is any chance we are going to stop and want to see
// what went wrong with our expression, we should generate debug info
if (!m_command_options.ignore_breakpoints ||
@@ -311,8 +315,7 @@ CommandObjectExpression::EvaluateExpression
else
options.SetTimeoutUsec(0);
- target->EvaluateExpression(expr, exe_ctx.GetFramePtr(),
- result_valobj_sp, options);
+ target->EvaluateExpression(expr, frame, result_valobj_sp, options);
if (result_valobj_sp)
{
@@ -326,6 +329,7 @@ CommandObjectExpression::EvaluateExpression
result_valobj_sp->SetFormat (format);
DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(m_command_options.m_verbosity,format));
+ options.SetVariableFormatDisplayLanguage(result_valobj_sp->GetPreferredDisplayLanguage());
result_valobj_sp->Dump(*output_stream,options);
@@ -335,7 +339,7 @@ CommandObjectExpression::EvaluateExpression
}
else
{
- if (result_valobj_sp->GetError().GetError() == ClangUserExpression::kNoResult)
+ if (result_valobj_sp->GetError().GetError() == UserExpression::kNoResult)
{
if (format != eFormatVoid && m_interpreter.GetDebugger().GetNotifyVoid())
{
@@ -501,8 +505,70 @@ CommandObjectExpression::DoExecute
return false;
}
+ if (m_repl_option.GetOptionValue().GetCurrentValue())
+ {
+ Target *target = m_interpreter.GetExecutionContext().GetTargetPtr();
+ if (target)
+ {
+ // Drop into REPL
+ m_expr_lines.clear();
+ m_expr_line_count = 0;
+
+ Debugger &debugger = target->GetDebugger();
+
+ // Check if the LLDB command interpreter is sitting on top of a REPL that
+ // launched it...
+ if (debugger.CheckTopIOHandlerTypes(IOHandler::Type::CommandInterpreter, IOHandler::Type::REPL))
+ {
+ // the LLDB command interpreter is sitting on top of a REPL that launched it,
+ // so just say the command interpreter is done and fall back to the existing REPL
+ m_interpreter.GetIOHandler(false)->SetIsDone(true);
+ }
+ else
+ {
+ // We are launching the REPL on top of the current LLDB command interpreter,
+ // so just push one
+ bool initialize = false;
+ Error repl_error;
+ REPLSP repl_sp (target->GetREPL(repl_error, m_command_options.language, nullptr, false));
+
+ if (!repl_sp)
+ {
+ initialize = true;
+ repl_sp = target->GetREPL(repl_error, m_command_options.language, nullptr, true);
+ if (!repl_error.Success())
+ {
+ result.SetError(repl_error);
+ return result.Succeeded();
+ }
+ }
+
+ if (repl_sp)
+ {
+ if (initialize)
+ {
+ repl_sp->SetCommandOptions(m_command_options);
+ repl_sp->SetFormatOptions(m_format_options);
+ repl_sp->SetValueObjectDisplayOptions(m_varobj_options);
+ }
+
+ IOHandlerSP io_handler_sp (repl_sp->GetIOHandler());
+
+ io_handler_sp->SetIsDone(false);
+
+ debugger.PushIOHandler(io_handler_sp);
+ }
+ else
+ {
+ repl_error.SetErrorStringWithFormat("Couldn't create a REPL for %s", Language::GetNameForLanguageType(m_command_options.language));
+ result.SetError(repl_error);
+ return result.Succeeded();
+ }
+ }
+ }
+ }
// No expression following options
- if (expr == NULL || expr[0] == '\0')
+ else if (expr == NULL || expr[0] == '\0')
{
GetMultilineExpression ();
return result.Succeeded();
diff --git a/source/Commands/CommandObjectExpression.h b/source/Commands/CommandObjectExpression.h
index 168140d7fe56..7103675f3992 100644
--- a/source/Commands/CommandObjectExpression.h
+++ b/source/Commands/CommandObjectExpression.h
@@ -16,6 +16,7 @@
// Project includes
#include "lldb/Core/IOHandler.h"
#include "lldb/Interpreter/CommandObject.h"
+#include "lldb/Interpreter/OptionGroupBoolean.h"
#include "lldb/Interpreter/OptionGroupFormat.h"
#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
#include "lldb/Target/ExecutionContext.h"
@@ -34,22 +35,21 @@ public:
CommandOptions ();
- virtual
- ~CommandOptions ();
+ ~CommandOptions() override;
- virtual uint32_t
- GetNumDefinitions ();
+ uint32_t
+ GetNumDefinitions() override;
- virtual const OptionDefinition*
- GetDefinitions ();
+ const OptionDefinition*
+ GetDefinitions() override;
- virtual Error
- SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value);
+ Error
+ SetOptionValue(CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_value) override;
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter);
+ void
+ OptionParsingStarting(CommandInterpreter &interpreter) override;
// Options table: Required for subclasses of Options.
@@ -61,35 +61,34 @@ public:
bool debug;
uint32_t timeout;
bool try_all_threads;
+ lldb::LanguageType language;
LanguageRuntimeDescriptionDisplayVerbosity m_verbosity;
};
CommandObjectExpression (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectExpression ();
+ ~CommandObjectExpression() override;
- virtual
Options *
- GetOptions ();
+ GetOptions() override;
protected:
//------------------------------------------------------------------
// IOHandler::Delegate functions
//------------------------------------------------------------------
- virtual void
- IOHandlerInputComplete (IOHandler &io_handler,
- std::string &line);
+ void
+ IOHandlerInputComplete(IOHandler &io_handler,
+ std::string &line) override;
virtual LineStatus
IOHandlerLinesUpdated (IOHandler &io_handler,
StringList &lines,
uint32_t line_idx,
Error &error);
- virtual bool
- DoExecute (const char *command,
- CommandReturnObject &result);
+ bool
+ DoExecute(const char *command,
+ CommandReturnObject &result) override;
bool
EvaluateExpression (const char *expr,
@@ -103,6 +102,7 @@ protected:
OptionGroupOptions m_option_group;
OptionGroupFormat m_format_options;
OptionGroupValueObjectDisplay m_varobj_options;
+ OptionGroupBoolean m_repl_option;
CommandOptions m_command_options;
uint32_t m_expr_line_count;
std::string m_expr_lines; // Multi-line expression support
@@ -110,4 +110,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_CommandObjectExpression_h_
+#endif // liblldb_CommandObjectExpression_h_
diff --git a/source/Commands/CommandObjectFrame.cpp b/source/Commands/CommandObjectFrame.cpp
index d8b65e3b551a..9477b50a58df 100644
--- a/source/Commands/CommandObjectFrame.cpp
+++ b/source/Commands/CommandObjectFrame.cpp
@@ -33,8 +33,9 @@
#include "lldb/Interpreter/OptionGroupFormat.h"
#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
#include "lldb/Interpreter/OptionGroupVariable.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/Type.h"
@@ -70,13 +71,13 @@ public:
{
}
- ~CommandObjectFrameInfo ()
+ ~CommandObjectFrameInfo () override
{
}
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
m_exe_ctx.GetFrameRef().DumpUsingSettingsFormat (&result.GetOutputStream());
result.SetStatus (eReturnStatusSuccessFinishResult);
@@ -104,13 +105,12 @@ public:
OptionParsingStarting ();
}
- virtual
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
bool success = false;
@@ -132,13 +132,13 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
relative_frame_offset = INT32_MIN;
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -174,13 +174,12 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectFrameSelect ()
+ ~CommandObjectFrameSelect () override
{
}
- virtual
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_options;
}
@@ -188,7 +187,7 @@ public:
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
// No need to check "thread" for validity as eCommandRequiresThread ensures it is valid
Thread *thread = m_exe_ctx.GetThreadPtr();
@@ -263,8 +262,10 @@ protected:
}
else
{
- result.AppendError ("invalid arguments.\n");
+ result.AppendErrorWithFormat ("too many arguments; expected frame-index, saw '%s'.\n",
+ command.GetArgumentAtIndex(0));
m_options.GenerateOptionUsage (result.GetErrorStream(), this);
+ return false;
}
}
@@ -341,20 +342,18 @@ public:
m_option_group.Finalize();
}
- virtual
- ~CommandObjectFrameVariable ()
+ ~CommandObjectFrameVariable () override
{
}
- virtual
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_option_group;
}
- virtual int
+ int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -362,7 +361,7 @@ public:
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
// Arguments are the standard source file completer.
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
@@ -380,8 +379,8 @@ public:
}
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
// No need to check "frame" for validity as eCommandRequiresFrame ensures it is valid
StackFrame *frame = m_exe_ctx.GetFramePtr();
@@ -409,6 +408,10 @@ protected:
DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(eLanguageRuntimeDescriptionDisplayVerbosityFull,eFormatDefault,summary_format_sp));
+ const SymbolContext& sym_ctx = frame->GetSymbolContext(eSymbolContextFunction);
+ if (sym_ctx.function && sym_ctx.function->IsTopLevelFunction())
+ m_option_variable.show_globals = true;
+
if (variable_list)
{
const Format format = m_option_format.GetFormat();
@@ -477,7 +480,8 @@ protected:
{
Error error;
uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember |
- StackFrame::eExpressionPathOptionsAllowDirectIVarAccess;
+ StackFrame::eExpressionPathOptionsAllowDirectIVarAccess |
+ StackFrame::eExpressionPathOptionsInspectAnonymousUnions;
lldb::VariableSP var_sp;
valobj_sp = frame->GetValueForVariableExpressionPath (name_cstr,
m_varobj_options.use_dynamic,
@@ -495,6 +499,7 @@ protected:
}
options.SetFormat(format);
+ options.SetVariableFormatDisplayLanguage(valobj_sp->GetPreferredDisplayLanguage());
Stream &output_stream = result.GetOutputStream();
options.SetRootValueObjectName(valobj_sp->GetParent() ? name_cstr : NULL);
@@ -581,6 +586,7 @@ protected:
}
options.SetFormat(format);
+ options.SetVariableFormatDisplayLanguage(valobj_sp->GetPreferredDisplayLanguage());
options.SetRootValueObjectName(name_cstr);
valobj_sp->Dump(result.GetOutputStream(),options);
}
diff --git a/source/Commands/CommandObjectFrame.h b/source/Commands/CommandObjectFrame.h
index ea7c808e84b1..a72988078f6d 100644
--- a/source/Commands/CommandObjectFrame.h
+++ b/source/Commands/CommandObjectFrame.h
@@ -30,11 +30,9 @@ public:
CommandObjectMultiwordFrame (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectMultiwordFrame ();
-
+ ~CommandObjectMultiwordFrame() override;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectFrame_h_
+#endif // liblldb_CommandObjectFrame_h_
diff --git a/source/Commands/CommandObjectGUI.h b/source/Commands/CommandObjectGUI.h
index 72ddb961c266..494bcc48e20e 100644
--- a/source/Commands/CommandObjectGUI.h
+++ b/source/Commands/CommandObjectGUI.h
@@ -28,16 +28,14 @@ public:
CommandObjectGUI (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectGUI ();
+ ~CommandObjectGUI() override;
protected:
- virtual bool
- DoExecute (Args& args,
- CommandReturnObject &result);
-
+ bool
+ DoExecute(Args& args,
+ CommandReturnObject &result) override;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectGUI_h_
+#endif // liblldb_CommandObjectGUI_h_
diff --git a/source/Commands/CommandObjectHelp.h b/source/Commands/CommandObjectHelp.h
index 7db659c472c9..1dd7b9b8d6a8 100644
--- a/source/Commands/CommandObjectHelp.h
+++ b/source/Commands/CommandObjectHelp.h
@@ -29,17 +29,16 @@ public:
CommandObjectHelp (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectHelp ();
+ ~CommandObjectHelp() override;
- virtual int
- HandleCompletion (Args &input,
- int &cursor_index,
- int &cursor_char_position,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches);
+ int
+ HandleCompletion(Args &input,
+ int &cursor_index,
+ int &cursor_char_position,
+ int match_start_point,
+ int max_return_elements,
+ bool &word_complete,
+ StringList &matches) override;
class CommandOptions : public Options
{
@@ -50,11 +49,10 @@ public:
{
}
- virtual
- ~CommandOptions (){}
+ ~CommandOptions() override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue(uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -79,7 +77,7 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting() override
{
m_show_aliases = true;
m_show_user_defined = true;
@@ -87,7 +85,7 @@ public:
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions() override
{
return g_option_table;
}
@@ -103,22 +101,21 @@ public:
bool m_show_hidden;
};
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions() override
{
return &m_options;
}
protected:
- virtual bool
- DoExecute (Args& command,
- CommandReturnObject &result);
+ bool
+ DoExecute(Args& command,
+ CommandReturnObject &result) override;
private:
CommandOptions m_options;
-
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectHelp_h_
+#endif // liblldb_CommandObjectHelp_h_
diff --git a/source/Commands/CommandObjectLanguage.cpp b/source/Commands/CommandObjectLanguage.cpp
index 9d4b85630a1f..5a8f166cb3a6 100644
--- a/source/Commands/CommandObjectLanguage.cpp
+++ b/source/Commands/CommandObjectLanguage.cpp
@@ -14,6 +14,7 @@
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Target/Language.h"
#include "lldb/Target/LanguageRuntime.h"
using namespace lldb;
@@ -33,10 +34,6 @@ CommandObjectMultiword (interpreter,
void
CommandObjectLanguage::GenerateHelpText (Stream &output_stream) {
CommandObjectMultiword::GenerateHelpText(output_stream);
-
- output_stream << "\nlanguage name can be one of the following:\n";
-
- LanguageRuntime::PrintAllLanguages(output_stream, " ", "\n");
}
CommandObjectLanguage::~CommandObjectLanguage ()
diff --git a/source/Commands/CommandObjectLanguage.h b/source/Commands/CommandObjectLanguage.h
index 751fe1440a8b..15902bb8ad4b 100644
--- a/source/Commands/CommandObjectLanguage.h
+++ b/source/Commands/CommandObjectLanguage.h
@@ -13,7 +13,6 @@
// C Includes
// C++ Includes
-
// Other libraries and framework includes
// Project includes
@@ -26,11 +25,10 @@ namespace lldb_private {
public:
CommandObjectLanguage (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectLanguage ();
+ ~CommandObjectLanguage() override;
- virtual void
- GenerateHelpText (Stream &output_stream);
+ void
+ GenerateHelpText(Stream &output_stream) override;
protected:
bool
@@ -38,4 +36,4 @@ namespace lldb_private {
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectLanguage_h_
+#endif // liblldb_CommandObjectLanguage_h_
diff --git a/source/Commands/CommandObjectLog.cpp b/source/Commands/CommandObjectLog.cpp
index e68eaf17bb9f..8e29cd5223b0 100644
--- a/source/Commands/CommandObjectLog.cpp
+++ b/source/Commands/CommandObjectLog.cpp
@@ -77,13 +77,12 @@ public:
m_arguments.push_back (arg2);
}
- virtual
- ~CommandObjectLogEnable()
+ ~CommandObjectLogEnable() override
{
}
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_options;
}
@@ -122,13 +121,12 @@ public:
}
- virtual
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -154,14 +152,14 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
log_file.Clear();
log_options = 0;
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -177,9 +175,9 @@ public:
};
protected:
- virtual bool
+ bool
DoExecute (Args& args,
- CommandReturnObject &result)
+ CommandReturnObject &result) override
{
if (args.GetArgumentCount() < 2)
{
@@ -260,15 +258,14 @@ public:
m_arguments.push_back (arg2);
}
- virtual
- ~CommandObjectLogDisable()
+ ~CommandObjectLogDisable() override
{
}
protected:
- virtual bool
+ bool
DoExecute (Args& args,
- CommandReturnObject &result)
+ CommandReturnObject &result) override
{
const size_t argc = args.GetArgumentCount();
if (argc == 0)
@@ -332,15 +329,14 @@ public:
m_arguments.push_back (arg);
}
- virtual
- ~CommandObjectLogList()
+ ~CommandObjectLogList() override
{
}
protected:
- virtual bool
+ bool
DoExecute (Args& args,
- CommandReturnObject &result)
+ CommandReturnObject &result) override
{
const size_t argc = args.GetArgumentCount();
if (argc == 0)
@@ -396,15 +392,14 @@ public:
{
}
- virtual
- ~CommandObjectLogTimer()
+ ~CommandObjectLogTimer() override
{
}
protected:
- virtual bool
+ bool
DoExecute (Args& args,
- CommandReturnObject &result)
+ CommandReturnObject &result) override
{
const size_t argc = args.GetArgumentCount();
result.SetStatus(eReturnStatusFailed);
diff --git a/source/Commands/CommandObjectLog.h b/source/Commands/CommandObjectLog.h
index 3e731fa1d186..be5215f2bdc3 100644
--- a/source/Commands/CommandObjectLog.h
+++ b/source/Commands/CommandObjectLog.h
@@ -33,8 +33,7 @@ public:
//------------------------------------------------------------------
CommandObjectLog(CommandInterpreter &interpreter);
- virtual
- ~CommandObjectLog();
+ ~CommandObjectLog() override;
private:
//------------------------------------------------------------------
@@ -45,4 +44,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_CommandObjectLog_h_
+#endif // liblldb_CommandObjectLog_h_
diff --git a/source/Commands/CommandObjectMemory.cpp b/source/Commands/CommandObjectMemory.cpp
index d589800299a3..f8fe456d4d46 100644
--- a/source/Commands/CommandObjectMemory.cpp
+++ b/source/Commands/CommandObjectMemory.cpp
@@ -23,7 +23,7 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObjectMemory.h"
#include "lldb/DataFormatters/ValueObjectPrinter.h"
-#include "lldb/Expression/ClangPersistentVariables.h"
+#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -33,6 +33,7 @@
#include "lldb/Interpreter/OptionGroupOutputFile.h"
#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
#include "lldb/Interpreter/OptionValueString.h"
+#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/TypeList.h"
#include "lldb/Target/MemoryHistory.h"
#include "lldb/Target/Process.h"
@@ -48,6 +49,7 @@ g_option_table[] =
{ LLDB_OPT_SET_1, false, "num-per-line" ,'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeNumberPerLine ,"The number of items per line to display."},
{ LLDB_OPT_SET_2, false, "binary" ,'b', OptionParser::eNoArgument , NULL, NULL, 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, NULL, NULL, 0, eArgTypeNone ,"The name of a type to view memory as."},
+ { LLDB_OPT_SET_3, false , "offset" ,'E', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeCount ,"How many elements of the specified type to skip before starting to display data."},
{ LLDB_OPT_SET_1|
LLDB_OPT_SET_2|
LLDB_OPT_SET_3, false, "force" ,'r', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone ,"Necessary if reading over target.max-memory-read-size bytes."},
@@ -62,32 +64,32 @@ public:
OptionGroupReadMemory () :
m_num_per_line (1,1),
m_output_as_binary (false),
- m_view_as_type()
+ m_view_as_type(),
+ m_offset(0,0)
{
}
- virtual
- ~OptionGroupReadMemory ()
+ ~OptionGroupReadMemory () override
{
}
- virtual uint32_t
- GetNumDefinitions ()
+ uint32_t
+ GetNumDefinitions () override
{
return sizeof (g_option_table) / sizeof (OptionDefinition);
}
- virtual const OptionDefinition*
- GetDefinitions ()
+ const OptionDefinition*
+ GetDefinitions () override
{
return g_option_table;
}
- virtual Error
+ Error
SetOptionValue (CommandInterpreter &interpreter,
uint32_t option_idx,
- const char *option_arg)
+ const char *option_arg) override
{
Error error;
const int short_option = g_option_table[option_idx].short_option;
@@ -112,6 +114,10 @@ public:
m_force = true;
break;
+ case 'E':
+ error = m_offset.SetValueFromString(option_arg);
+ break;
+
default:
error.SetErrorStringWithFormat("unrecognized short option '%c'", short_option);
break;
@@ -119,13 +125,14 @@ public:
return error;
}
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter)
+ void
+ OptionParsingStarting (CommandInterpreter &interpreter) override
{
m_num_per_line.Clear();
m_output_as_binary = false;
m_view_as_type.Clear();
m_force = false;
+ m_offset.Clear();
}
Error
@@ -271,6 +278,7 @@ public:
case eFormatVectorOfUInt32:
case eFormatVectorOfSInt64:
case eFormatVectorOfUInt64:
+ case eFormatVectorOfFloat16:
case eFormatVectorOfFloat32:
case eFormatVectorOfFloat64:
case eFormatVectorOfUInt128:
@@ -290,13 +298,15 @@ public:
{
return m_num_per_line.OptionWasSet() ||
m_output_as_binary ||
- m_view_as_type.OptionWasSet();
+ m_view_as_type.OptionWasSet() ||
+ m_offset.OptionWasSet();
}
OptionValueUInt64 m_num_per_line;
bool m_output_as_binary;
OptionValueString m_view_as_type;
bool m_force;
+ OptionValueUInt64 m_offset;
};
@@ -366,25 +376,25 @@ public:
m_option_group.Finalize();
}
- virtual
- ~CommandObjectMemoryRead ()
+ ~CommandObjectMemoryRead () override
{
}
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_option_group;
}
- virtual const char *GetRepeatCommand (Args &current_command_args, uint32_t index)
+ const char *
+ GetRepeatCommand (Args &current_command_args, uint32_t index) override
{
return m_cmd_name.c_str();
}
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
// No need to check "target" for validity as eCommandRequiresTarget ensures it is valid
Target *target = m_exe_ctx.GetTargetPtr();
@@ -399,7 +409,7 @@ protected:
return false;
}
- ClangASTType clang_ast_type;
+ CompilerType clang_ast_type;
Error error;
const char *view_as_type_cstr = m_memory_options.m_view_as_type.GetCurrentValue();
@@ -526,16 +536,21 @@ protected:
1,
type_list);
}
-
+
if (type_list.GetSize() == 0 && lookup_type_name.GetCString() && *lookup_type_name.GetCString() == '$')
{
- clang::TypeDecl *tdecl = target->GetPersistentVariables().GetPersistentType(ConstString(lookup_type_name));
- if (tdecl)
+ if (ClangPersistentVariables *persistent_vars = llvm::dyn_cast_or_null<ClangPersistentVariables>(target->GetPersistentExpressionStateForLanguage(lldb::eLanguageTypeC)))
{
- clang_ast_type.SetClangType(&tdecl->getASTContext(),(const lldb::clang_type_t)tdecl->getTypeForDecl());
+ clang::TypeDecl *tdecl = persistent_vars->GetPersistentType(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 (clang_ast_type.IsValid() == false)
{
if (type_list.GetSize() == 0)
@@ -549,13 +564,13 @@ protected:
else
{
TypeSP type_sp (type_list.GetTypeAtIndex(0));
- clang_ast_type = type_sp->GetClangFullType();
+ clang_ast_type = type_sp->GetFullCompilerType ();
}
}
while (pointer_count > 0)
{
- ClangASTType pointer_type = clang_ast_type.GetPointerType();
+ CompilerType pointer_type = clang_ast_type.GetPointerType();
if (pointer_type.IsValid())
clang_ast_type = pointer_type;
else
@@ -691,6 +706,9 @@ protected:
m_format_options.GetFormatValue().SetCurrentValue(eFormatDefault);
bytes_read = clang_ast_type.GetByteSize(nullptr) * m_format_options.GetCountValue().GetCurrentValue();
+
+ if (argc > 0)
+ addr = addr + (clang_ast_type.GetByteSize(nullptr) * m_memory_options.m_offset.GetCurrentValue());
}
else if (m_format_options.GetFormatValue().GetCurrentValue() != eFormatCString)
{
@@ -932,7 +950,7 @@ protected:
OptionGroupReadMemory m_prev_memory_options;
OptionGroupOutputFile m_prev_outfile_options;
OptionGroupValueObjectDisplay m_prev_varobj_options;
- ClangASTType m_prev_clang_ast_type;
+ CompilerType m_prev_clang_ast_type;
};
OptionDefinition
@@ -961,27 +979,26 @@ public:
{
}
- virtual
- ~OptionGroupFindMemory ()
+ ~OptionGroupFindMemory () override
{
}
- virtual uint32_t
- GetNumDefinitions ()
+ uint32_t
+ GetNumDefinitions () override
{
return sizeof (g_memory_find_option_table) / sizeof (OptionDefinition);
}
- virtual const OptionDefinition*
- GetDefinitions ()
+ const OptionDefinition*
+ GetDefinitions () override
{
return g_memory_find_option_table;
}
- virtual Error
+ Error
SetOptionValue (CommandInterpreter &interpreter,
uint32_t option_idx,
- const char *option_arg)
+ const char *option_arg) override
{
Error error;
const int short_option = g_memory_find_option_table[option_idx].short_option;
@@ -1013,8 +1030,8 @@ public:
return error;
}
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter)
+ void
+ OptionParsingStarting (CommandInterpreter &interpreter) override
{
m_expr.Clear();
m_string.Clear();
@@ -1042,15 +1059,15 @@ public:
CommandArgumentData value_arg;
// Define the first (and only) variant of this arg.
- addr_arg.arg_type = eArgTypeAddress;
+ addr_arg.arg_type = eArgTypeAddressOrExpression;
addr_arg.arg_repetition = eArgRepeatPlain;
// There is only one variant this argument could be; put it into the argument entry.
arg1.push_back (addr_arg);
// Define the first (and only) variant of this arg.
- value_arg.arg_type = eArgTypeValue;
- value_arg.arg_repetition = eArgRepeatPlus;
+ value_arg.arg_type = eArgTypeAddressOrExpression;
+ value_arg.arg_repetition = eArgRepeatPlain;
// There is only one variant this argument could be; put it into the argument entry.
arg2.push_back (value_arg);
@@ -1063,20 +1080,19 @@ public:
m_option_group.Finalize();
}
- virtual
- ~CommandObjectMemoryFind ()
+ ~CommandObjectMemoryFind () override
{
}
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_option_group;
}
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
// No need to check "process" for validity as eCommandRequiresProcess ensures it is valid
Process *process = m_exe_ctx.GetProcessPtr();
@@ -1119,10 +1135,11 @@ protected:
{
StackFrame* frame = m_exe_ctx.GetFramePtr();
ValueObjectSP result_sp;
- if (process->GetTarget().EvaluateExpression(m_memory_options.m_expr.GetStringValue(), frame, result_sp) && result_sp.get())
+ if ((eExpressionCompleted == process->GetTarget().EvaluateExpression(m_memory_options.m_expr.GetStringValue(), frame, result_sp)) &&
+ result_sp.get())
{
uint64_t value = result_sp->GetValueAsUnsigned(0);
- switch (result_sp->GetClangType().GetByteSize(nullptr))
+ switch (result_sp->GetCompilerType().GetByteSize(nullptr))
{
case 1: {
uint8_t byte = (uint8_t)value;
@@ -1150,13 +1167,13 @@ protected:
result.AppendError("unknown type. pass a string instead");
return false;
default:
- result.AppendError("do not know how to deal with larger than 8 byte result types. pass a string instead");
+ result.AppendError("result size larger than 8 bytes. pass a string instead");
return false;
}
}
else
{
- result.AppendError("expression evaluation failed. pass a string instead?");
+ result.AppendError("expression evaluation failed. pass a string instead");
return false;
}
}
@@ -1176,14 +1193,14 @@ protected:
{
if (!ever_found)
{
- result.AppendMessage("Your data was not found within the range.\n");
+ result.AppendMessage("data not found within the range.\n");
result.SetStatus(lldb::eReturnStatusSuccessFinishNoResult);
}
else
- result.AppendMessage("No more matches found within the range.\n");
+ result.AppendMessage("no more matches within the range.\n");
break;
}
- result.AppendMessageWithFormat("Your data was found at location: 0x%" PRIx64 "\n", found_location);
+ result.AppendMessageWithFormat("data found at location: 0x%" PRIx64 "\n", found_location);
DataBufferHeap dumpbuffer(32,0);
process->ReadMemory(found_location+m_memory_options.m_offset.GetCurrentValue(), dumpbuffer.GetBytes(), dumpbuffer.GetByteSize(), error);
@@ -1211,27 +1228,16 @@ protected:
{
Process *process = m_exe_ctx.GetProcessPtr();
DataBufferHeap heap(buffer_size, 0);
- lldb::addr_t fictional_ptr = low;
for (auto ptr = low;
- low < high;
- fictional_ptr++)
+ ptr < high;
+ ptr++)
{
Error error;
- if (ptr == low || buffer_size == 1)
- process->ReadMemory(ptr, heap.GetBytes(), buffer_size, error);
- else
- {
- memmove(heap.GetBytes(), heap.GetBytes()+1, buffer_size-1);
- process->ReadMemory(ptr, heap.GetBytes()+buffer_size-1, 1, error);
- }
+ process->ReadMemory(ptr, heap.GetBytes(), buffer_size, error);
if (error.Fail())
return LLDB_INVALID_ADDRESS;
if (memcmp(heap.GetBytes(), buffer, buffer_size) == 0)
- return fictional_ptr;
- if (ptr == low)
- ptr += buffer_size;
- else
- ptr += 1;
+ return ptr;
}
return LLDB_INVALID_ADDRESS;
}
@@ -1263,27 +1269,26 @@ public:
{
}
- virtual
- ~OptionGroupWriteMemory ()
+ ~OptionGroupWriteMemory () override
{
}
- virtual uint32_t
- GetNumDefinitions ()
+ uint32_t
+ GetNumDefinitions () override
{
return sizeof (g_memory_write_option_table) / sizeof (OptionDefinition);
}
- virtual const OptionDefinition*
- GetDefinitions ()
+ const OptionDefinition*
+ GetDefinitions () override
{
return g_memory_write_option_table;
}
- virtual Error
+ Error
SetOptionValue (CommandInterpreter &interpreter,
uint32_t option_idx,
- const char *option_arg)
+ const char *option_arg) override
{
Error error;
const int short_option = g_memory_write_option_table[option_idx].short_option;
@@ -1317,8 +1322,8 @@ public:
return error;
}
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter)
+ void
+ OptionParsingStarting (CommandInterpreter &interpreter) override
{
m_infile.Clear();
m_infile_offset = 0;
@@ -1368,13 +1373,12 @@ public:
}
- virtual
- ~CommandObjectMemoryWrite ()
+ ~CommandObjectMemoryWrite () override
{
}
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_option_group;
}
@@ -1407,8 +1411,8 @@ public:
}
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
// No need to check "process" for validity as eCommandRequiresProcess ensures it is valid
Process *process = m_exe_ctx.GetProcessPtr();
@@ -1528,6 +1532,7 @@ protected:
case eFormatVectorOfUInt32:
case eFormatVectorOfSInt64:
case eFormatVectorOfUInt64:
+ case eFormatVectorOfFloat16:
case eFormatVectorOfFloat32:
case eFormatVectorOfFloat64:
case eFormatVectorOfUInt128:
@@ -1716,19 +1721,19 @@ public:
m_arguments.push_back (arg1);
}
- virtual
- ~CommandObjectMemoryHistory ()
+ ~CommandObjectMemoryHistory () override
{
}
- virtual const char *GetRepeatCommand (Args &current_command_args, uint32_t index)
+ const char *
+ GetRepeatCommand (Args &current_command_args, uint32_t index) override
{
return m_cmd_name.c_str();
}
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
const size_t argc = command.GetArgumentCount();
diff --git a/source/Commands/CommandObjectMemory.h b/source/Commands/CommandObjectMemory.h
index b044921ae077..cf5b4419746c 100644
--- a/source/Commands/CommandObjectMemory.h
+++ b/source/Commands/CommandObjectMemory.h
@@ -23,11 +23,9 @@ class CommandObjectMemory : public CommandObjectMultiword
public:
CommandObjectMemory (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectMemory ();
+ ~CommandObjectMemory() override;
};
-
} // namespace lldb_private
-#endif // liblldb_CommandObjectMemory_h_
+#endif // liblldb_CommandObjectMemory_h_
diff --git a/source/Commands/CommandObjectMultiword.cpp b/source/Commands/CommandObjectMultiword.cpp
index 2f0e2a78a0cc..206f3b6fb7df 100644
--- a/source/Commands/CommandObjectMultiword.cpp
+++ b/source/Commands/CommandObjectMultiword.cpp
@@ -382,6 +382,14 @@ CommandObjectProxy::IsMultiwordObject ()
return false;
}
+void
+CommandObjectProxy::GenerateHelpText (Stream &result)
+{
+ CommandObject *proxy_command = GetProxyCommandObject();
+ if (proxy_command)
+ return proxy_command->GenerateHelpText(result);
+}
+
lldb::CommandObjectSP
CommandObjectProxy::GetSubcommandSP (const char *sub_cmd, StringList *matches)
{
diff --git a/source/Commands/CommandObjectPlatform.cpp b/source/Commands/CommandObjectPlatform.cpp
index a0979d059edb..aad8bea692e7 100644
--- a/source/Commands/CommandObjectPlatform.cpp
+++ b/source/Commands/CommandObjectPlatform.cpp
@@ -86,15 +86,14 @@ public:
{
}
- virtual
- ~OptionPermissions ()
+ ~OptionPermissions () override
{
}
- virtual lldb_private::Error
+ lldb_private::Error
SetOptionValue (CommandInterpreter &interpreter,
uint32_t option_idx,
- const char *option_arg)
+ const char *option_arg) override
{
Error error;
char short_option = (char) GetDefinitions()[option_idx].short_option;
@@ -155,19 +154,19 @@ public:
}
void
- OptionParsingStarting (CommandInterpreter &interpreter)
+ OptionParsingStarting (CommandInterpreter &interpreter) override
{
m_permissions = 0;
}
- virtual uint32_t
- GetNumDefinitions ()
+ uint32_t
+ GetNumDefinitions () override
{
return llvm::array_lengthof(g_permissions_options);
}
const lldb_private::OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_permissions_options;
}
@@ -198,19 +197,18 @@ public:
m_option_group.Finalize();
}
- virtual
- ~CommandObjectPlatformSelect ()
+ ~CommandObjectPlatformSelect () override
{
}
- virtual int
+ int
HandleCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
completion_str.erase (cursor_char_position);
@@ -225,15 +223,15 @@ public:
return matches.GetSize();
}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_option_group;
}
protected:
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
if (args.GetArgumentCount() == 1)
{
@@ -291,14 +289,13 @@ public:
{
}
- virtual
- ~CommandObjectPlatformList ()
+ ~CommandObjectPlatformList () override
{
}
protected:
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
Stream &ostrm = result.GetOutputStream();
ostrm.Printf("Available platforms:\n");
@@ -346,14 +343,13 @@ public:
{
}
- virtual
- ~CommandObjectPlatformStatus ()
+ ~CommandObjectPlatformStatus () override
{
}
protected:
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
Stream &ostrm = result.GetOutputStream();
@@ -396,14 +392,13 @@ public:
{
}
- virtual
- ~CommandObjectPlatformConnect ()
+ ~CommandObjectPlatformConnect () override
{
}
protected:
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
Stream &ostrm = result.GetOutputStream();
@@ -414,12 +409,19 @@ protected:
if (error.Success())
{
platform_sp->GetStatus (ostrm);
- result.SetStatus (eReturnStatusSuccessFinishResult);
+ result.SetStatus (eReturnStatusSuccessFinishResult);
+
+ platform_sp->ConnectToWaitingProcesses(m_interpreter.GetDebugger(), error);
+ if (error.Fail())
+ {
+ result.AppendError (error.AsCString());
+ result.SetStatus (eReturnStatusFailed);
+ }
}
else
{
result.AppendErrorWithFormat ("%s\n", error.AsCString());
- result.SetStatus (eReturnStatusFailed);
+ result.SetStatus (eReturnStatusFailed);
}
}
else
@@ -430,8 +432,8 @@ protected:
return result.Succeeded();
}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
OptionGroupOptions* m_platform_options = NULL;
@@ -461,14 +463,13 @@ public:
{
}
- virtual
- ~CommandObjectPlatformDisconnect ()
+ ~CommandObjectPlatformDisconnect () override
{
}
protected:
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp)
@@ -543,14 +544,13 @@ public:
m_options.Append (&m_option_working_dir, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
}
- virtual
- ~CommandObjectPlatformSettings ()
+ ~CommandObjectPlatformSettings () override
{
}
protected:
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp)
@@ -566,8 +566,8 @@ protected:
return result.Succeeded();
}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
if (m_options.DidFinalize() == false)
m_options.Finalize();
@@ -597,13 +597,12 @@ public:
{
}
- virtual
- ~CommandObjectPlatformMkDir ()
+ ~CommandObjectPlatformMkDir () override
{
}
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp)
@@ -635,8 +634,8 @@ public:
return result.Succeeded();
}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
if (m_options.DidFinalize() == false)
{
@@ -665,13 +664,12 @@ public:
{
}
- virtual
- ~CommandObjectPlatformFOpen ()
+ ~CommandObjectPlatformFOpen () override
{
}
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp)
@@ -708,8 +706,8 @@ public:
}
return result.Succeeded();
}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
if (m_options.DidFinalize() == false)
{
@@ -736,13 +734,12 @@ public:
{
}
- virtual
- ~CommandObjectPlatformFClose ()
+ ~CommandObjectPlatformFClose () override
{
}
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp)
@@ -788,13 +785,12 @@ public:
{
}
- virtual
- ~CommandObjectPlatformFRead ()
+ ~CommandObjectPlatformFRead () override
{
}
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp)
@@ -816,8 +812,8 @@ public:
}
return result.Succeeded();
}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -832,13 +828,12 @@ protected:
{
}
- virtual
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
char short_option = (char) m_getopt_table[option_idx].val;
@@ -866,14 +861,14 @@ protected:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_offset = 0;
m_count = 1;
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -914,13 +909,12 @@ public:
{
}
- virtual
- ~CommandObjectPlatformFWrite ()
+ ~CommandObjectPlatformFWrite () override
{
}
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp)
@@ -944,8 +938,8 @@ public:
}
return result.Succeeded();
}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -960,13 +954,12 @@ protected:
{
}
- virtual
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
char short_option = (char) m_getopt_table[option_idx].val;
@@ -992,14 +985,14 @@ protected:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_offset = 0;
m_data.clear();
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -1041,8 +1034,7 @@ public:
LoadSubCommand ("write", CommandObjectSP (new CommandObjectPlatformFWrite (interpreter)));
}
- virtual
- ~CommandObjectPlatformFile ()
+ ~CommandObjectPlatformFile () override
{
}
@@ -1094,13 +1086,12 @@ R"(Examples:
m_arguments.push_back (arg2);
}
- virtual
- ~CommandObjectPlatformGetFile ()
+ ~CommandObjectPlatformGetFile () override
{
}
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
// If the number of arguments is incorrect, issue an error message.
if (args.GetArgumentCount() != 2)
@@ -1172,13 +1163,12 @@ R"(Examples:
m_arguments.push_back (arg1);
}
- virtual
- ~CommandObjectPlatformGetSize ()
+ ~CommandObjectPlatformGetSize () override
{
}
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
// If the number of arguments is incorrect, issue an error message.
if (args.GetArgumentCount() != 1)
@@ -1228,13 +1218,12 @@ public:
{
}
- virtual
- ~CommandObjectPlatformPutFile ()
+ ~CommandObjectPlatformPutFile () override
{
}
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
const char* src = args.GetArgumentAtIndex(0);
const char* dst = args.GetArgumentAtIndex(1);
@@ -1281,20 +1270,19 @@ public:
{
}
- virtual
- ~CommandObjectPlatformProcessLaunch ()
+ ~CommandObjectPlatformProcessLaunch () override
{
}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
protected:
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
PlatformSP platform_sp;
@@ -1398,20 +1386,19 @@ public:
{
}
- virtual
- ~CommandObjectPlatformProcessList ()
+ ~CommandObjectPlatformProcessList () override
{
}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
protected:
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
PlatformSP platform_sp;
@@ -1524,13 +1511,12 @@ protected:
{
}
- virtual
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -1620,7 +1606,7 @@ protected:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
match_info.Clear();
show_args = false;
@@ -1628,7 +1614,7 @@ protected:
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -1698,14 +1684,13 @@ public:
m_arguments.push_back (arg);
}
- virtual
- ~CommandObjectPlatformProcessInfo ()
+ ~CommandObjectPlatformProcessInfo () override
{
}
protected:
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
PlatformSP platform_sp;
@@ -1793,12 +1778,12 @@ public:
OptionParsingStarting ();
}
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
char short_option = (char) m_getopt_table[option_idx].val;
@@ -1839,18 +1824,18 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
attach_info.Clear();
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
- virtual bool
+ bool
HandleOptionArgumentCompletion (Args &input,
int cursor_index,
int char_pos,
@@ -1859,7 +1844,7 @@ public:
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
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;
@@ -1921,13 +1906,13 @@ public:
{
}
- ~CommandObjectPlatformProcessAttach ()
+ ~CommandObjectPlatformProcessAttach () override
{
}
bool
DoExecute (Args& command,
- CommandReturnObject &result)
+ CommandReturnObject &result) override
{
PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp)
@@ -1957,7 +1942,7 @@ public:
}
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_options;
}
@@ -1998,8 +1983,7 @@ public:
}
- virtual
- ~CommandObjectPlatformProcess ()
+ ~CommandObjectPlatformProcess () override
{
}
@@ -2027,8 +2011,7 @@ public:
{
}
- virtual
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
@@ -2038,15 +2021,15 @@ public:
return 1;
}
- virtual const OptionDefinition*
- GetDefinitions ()
+ const OptionDefinition*
+ GetDefinitions () override
{
return g_option_table;
}
- virtual Error
+ Error
SetOptionValue (uint32_t option_idx,
- const char *option_value)
+ const char *option_value) override
{
Error error;
@@ -2070,8 +2053,8 @@ public:
return error;
}
- virtual void
- OptionParsingStarting ()
+ void
+ OptionParsingStarting () override
{
}
@@ -2091,20 +2074,18 @@ public:
{
}
- virtual
- ~CommandObjectPlatformShell ()
+ ~CommandObjectPlatformShell () override
{
}
- virtual
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_options;
}
- virtual bool
- DoExecute (const char *raw_command_line, CommandReturnObject &result)
+ bool
+ DoExecute (const char *raw_command_line, CommandReturnObject &result) override
{
m_options.NotifyOptionParsingStarting();
@@ -2218,13 +2199,12 @@ public:
{
}
- virtual
- ~CommandObjectPlatformInstall ()
+ ~CommandObjectPlatformInstall () override
{
}
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
if (args.GetArgumentCount() != 2)
{
diff --git a/source/Commands/CommandObjectPlatform.h b/source/Commands/CommandObjectPlatform.h
index f3bd75848649..023dff9f9827 100644
--- a/source/Commands/CommandObjectPlatform.h
+++ b/source/Commands/CommandObjectPlatform.h
@@ -28,13 +28,12 @@ class CommandObjectPlatform : public CommandObjectMultiword
public:
CommandObjectPlatform(CommandInterpreter &interpreter);
- virtual
- ~CommandObjectPlatform();
+ ~CommandObjectPlatform() override;
- private:
+private:
DISALLOW_COPY_AND_ASSIGN (CommandObjectPlatform);
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectPlatform_h_
+#endif // liblldb_CommandObjectPlatform_h_
diff --git a/source/Commands/CommandObjectPlugin.cpp b/source/Commands/CommandObjectPlugin.cpp
index 63fa4a82cf91..4c5a089dbcec 100644
--- a/source/Commands/CommandObjectPlugin.cpp
+++ b/source/Commands/CommandObjectPlugin.cpp
@@ -41,7 +41,7 @@ public:
m_arguments.push_back (arg1);
}
- ~CommandObjectPluginLoad ()
+ ~CommandObjectPluginLoad () override
{
}
@@ -53,7 +53,7 @@ public:
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
completion_str.erase (cursor_char_position);
@@ -71,7 +71,7 @@ public:
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
size_t argc = command.GetArgumentCount();
diff --git a/source/Commands/CommandObjectPlugin.h b/source/Commands/CommandObjectPlugin.h
index 9d0f0fcc1ed3..0a96041d2d31 100644
--- a/source/Commands/CommandObjectPlugin.h
+++ b/source/Commands/CommandObjectPlugin.h
@@ -13,7 +13,6 @@
// C Includes
// C++ Includes
-
// Other libraries and framework includes
// Project includes
@@ -27,10 +26,9 @@ namespace lldb_private {
public:
CommandObjectPlugin (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectPlugin ();
+ ~CommandObjectPlugin() override;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectPlugin_h_
+#endif // liblldb_CommandObjectPlugin_h_
diff --git a/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp
index e587eadfa3d6..b7f894f6dcf5 100644
--- a/source/Commands/CommandObjectProcess.cpp
+++ b/source/Commands/CommandObjectProcess.cpp
@@ -47,7 +47,7 @@ public:
CommandObjectParsed (interpreter, name, help, syntax, flags),
m_new_process_action (new_process_action) {}
- virtual ~CommandObjectProcessLaunchOrAttach () {}
+ ~CommandObjectProcessLaunchOrAttach () override {}
protected:
bool
StopProcessIfNecessary (Process *process, StateType &state, CommandReturnObject &result)
@@ -142,11 +142,11 @@ public:
}
- ~CommandObjectProcessLaunch ()
+ ~CommandObjectProcessLaunch () override
{
}
- virtual int
+ int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -154,7 +154,7 @@ public:
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
completion_str.erase (cursor_char_position);
@@ -171,12 +171,13 @@ public:
}
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_options;
}
- virtual const char *GetRepeatCommand (Args &current_command_args, uint32_t index)
+ const char *
+ GetRepeatCommand (Args &current_command_args, uint32_t index) override
{
// No repeat for "process launch"...
return "";
@@ -184,7 +185,7 @@ public:
protected:
bool
- DoExecute (Args& launch_args, CommandReturnObject &result)
+ DoExecute (Args& launch_args, CommandReturnObject &result) override
{
Debugger &debugger = m_interpreter.GetDebugger();
Target *target = debugger.GetSelectedTarget().get();
@@ -338,12 +339,12 @@ public:
OptionParsingStarting ();
}
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -392,18 +393,18 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
attach_info.Clear();
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
- virtual bool
+ bool
HandleOptionArgumentCompletion (Args &input,
int cursor_index,
int char_pos,
@@ -412,7 +413,7 @@ public:
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
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;
@@ -476,20 +477,19 @@ public:
{
}
- ~CommandObjectProcessAttach ()
+ ~CommandObjectProcessAttach () override
{
}
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_options;
}
protected:
bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
@@ -646,7 +646,7 @@ public:
}
- ~CommandObjectProcessContinue ()
+ ~CommandObjectProcessContinue () override
{
}
@@ -663,12 +663,12 @@ protected:
OptionParsingStarting ();
}
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -689,13 +689,13 @@ protected:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_ignore = 0;
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -708,7 +708,7 @@ protected:
};
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Process *process = m_exe_ctx.GetProcessPtr();
bool synchronous_execution = m_interpreter.GetSynchronous ();
@@ -807,7 +807,7 @@ protected:
}
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_options;
}
@@ -842,12 +842,12 @@ public:
OptionParsingStarting ();
}
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -876,13 +876,13 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_keep_stopped = eLazyBoolCalculate;
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -907,12 +907,12 @@ public:
{
}
- ~CommandObjectProcessDetach ()
+ ~CommandObjectProcessDetach () override
{
}
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_options;
}
@@ -920,7 +920,7 @@ public:
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Process *process = m_exe_ctx.GetProcessPtr();
// FIXME: This will be a Command Option:
@@ -982,12 +982,12 @@ public:
OptionParsingStarting ();
}
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -1006,13 +1006,13 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
plugin_name.clear();
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -1036,94 +1036,61 @@ public:
{
}
- ~CommandObjectProcessConnect ()
+ ~CommandObjectProcessConnect () override
{
}
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_options;
}
protected:
bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
-
- TargetSP target_sp (m_interpreter.GetDebugger().GetSelectedTarget());
- Error error;
- Process *process = m_exe_ctx.GetProcessPtr();
- if (process)
+ if (command.GetArgumentCount() != 1)
{
- if (process->IsAlive())
- {
- result.AppendErrorWithFormat ("Process %" PRIu64 " is currently being debugged, kill the process before connecting.\n",
- process->GetID());
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
+ result.AppendErrorWithFormat ("'%s' takes exactly one argument:\nUsage: %s\n",
+ m_cmd_name.c_str(),
+ m_cmd_syntax.c_str());
+ result.SetStatus (eReturnStatusFailed);
+ return false;
}
+
- if (!target_sp)
+ Process *process = m_exe_ctx.GetProcessPtr();
+ if (process && process->IsAlive())
{
- // If there isn't a current target create one.
-
- error = m_interpreter.GetDebugger().GetTargetList().CreateTarget (m_interpreter.GetDebugger(),
- NULL,
- NULL,
- false,
- NULL, // No platform options
- target_sp);
- if (!target_sp || error.Fail())
- {
- result.AppendError(error.AsCString("Error creating target"));
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
- m_interpreter.GetDebugger().GetTargetList().SetSelectedTarget(target_sp.get());
+ result.AppendErrorWithFormat ("Process %" PRIu64 " is currently being debugged, kill the process before connecting.\n",
+ process->GetID());
+ result.SetStatus (eReturnStatusFailed);
+ return false;
}
-
- if (command.GetArgumentCount() == 1)
- {
- const char *plugin_name = NULL;
- if (!m_options.plugin_name.empty())
- plugin_name = m_options.plugin_name.c_str();
- const char *remote_url = command.GetArgumentAtIndex(0);
- process = target_sp->CreateProcess (m_interpreter.GetDebugger().GetListener(), plugin_name, NULL).get();
-
- if (process)
- {
- error = process->ConnectRemote (process->GetTarget().GetDebugger().GetOutputFile().get(), remote_url);
+ const char *plugin_name = nullptr;
+ if (!m_options.plugin_name.empty())
+ plugin_name = m_options.plugin_name.c_str();
- if (error.Fail())
- {
- result.AppendError(error.AsCString("Remote connect failed"));
- result.SetStatus (eReturnStatusFailed);
- target_sp->DeleteCurrentProcess();
- return false;
- }
- }
- else
- {
- result.AppendErrorWithFormat ("Unable to find process plug-in for remote URL '%s'.\nPlease specify a process plug-in name with the --plugin option, or specify an object file using the \"file\" command.\n",
- remote_url);
- result.SetStatus (eReturnStatusFailed);
- }
- }
- else
+ Error error;
+ Debugger& debugger = m_interpreter.GetDebugger();
+ PlatformSP platform_sp = m_interpreter.GetPlatform(true);
+ ProcessSP process_sp = platform_sp->ConnectProcess(command.GetArgumentAtIndex(0),
+ plugin_name,
+ debugger,
+ debugger.GetSelectedTarget().get(),
+ error);
+ if (error.Fail() || process_sp == nullptr)
{
- result.AppendErrorWithFormat ("'%s' takes exactly one argument:\nUsage: %s\n",
- m_cmd_name.c_str(),
- m_cmd_syntax.c_str());
+ result.AppendError(error.AsCString("Error connecting to the process"));
result.SetStatus (eReturnStatusFailed);
+ return false;
}
- return result.Succeeded();
+ return true;
}
-
+
CommandOptions m_options;
};
@@ -1152,12 +1119,12 @@ public:
{
}
- ~CommandObjectProcessPlugin ()
+ ~CommandObjectProcessPlugin () override
{
}
- virtual CommandObject *
- GetProxyCommandObject()
+ CommandObject *
+ GetProxyCommandObject() override
{
Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
if (process)
@@ -1175,6 +1142,57 @@ public:
class CommandObjectProcessLoad : public CommandObjectParsed
{
public:
+ class CommandOptions : public Options
+ {
+ public:
+ CommandOptions (CommandInterpreter &interpreter) :
+ Options(interpreter)
+ {
+ // Keep default values of all options in one place: OptionParsingStarting ()
+ OptionParsingStarting ();
+ }
+
+ ~CommandOptions () override = default;
+
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
+ {
+ Error error;
+ const int short_option = m_getopt_table[option_idx].val;
+ switch (short_option)
+ {
+ case 'i':
+ do_install = true;
+ if (option_arg && option_arg[0])
+ install_path.SetFile(option_arg, false);
+ break;
+ default:
+ error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
+ break;
+ }
+ return error;
+ }
+
+ void
+ OptionParsingStarting () override
+ {
+ do_install = false;
+ install_path.Clear();
+ }
+
+ const OptionDefinition*
+ GetDefinitions () override
+ {
+ return g_option_table;
+ }
+
+ // Options table: Required for subclasses of Options.
+ static OptionDefinition g_option_table[];
+
+ // Instance variables to hold the values for command options.
+ bool do_install;
+ FileSpec install_path;
+ };
CommandObjectProcessLoad (CommandInterpreter &interpreter) :
CommandObjectParsed (interpreter,
@@ -1184,33 +1202,54 @@ public:
eCommandRequiresProcess |
eCommandTryTargetAPILock |
eCommandProcessMustBeLaunched |
- eCommandProcessMustBePaused )
+ eCommandProcessMustBePaused ),
+ m_options (interpreter)
{
}
- ~CommandObjectProcessLoad ()
+ ~CommandObjectProcessLoad () override = default;
+
+ Options *
+ GetOptions () override
{
+ return &m_options;
}
protected:
bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Process *process = m_exe_ctx.GetProcessPtr();
const size_t argc = command.GetArgumentCount();
-
for (uint32_t i=0; i<argc; ++i)
{
Error error;
+ PlatformSP platform = process->GetTarget().GetPlatform();
const char *image_path = command.GetArgumentAtIndex(i);
- FileSpec image_spec (image_path, false);
- process->GetTarget().GetPlatform()->ResolveRemotePath(image_spec, image_spec);
- uint32_t image_token = process->LoadImage(image_spec, error);
+ uint32_t image_token = LLDB_INVALID_IMAGE_TOKEN;
+
+ if (!m_options.do_install)
+ {
+ FileSpec image_spec (image_path, false);
+ platform->ResolveRemotePath(image_spec, image_spec);
+ image_token = platform->LoadImage(process, FileSpec(), image_spec, error);
+ }
+ else if (m_options.install_path)
+ {
+ FileSpec image_spec (image_path, true);
+ platform->ResolveRemotePath(m_options.install_path, m_options.install_path);
+ image_token = platform->LoadImage(process, image_spec, m_options.install_path, error);
+ }
+ else
+ {
+ FileSpec image_spec (image_path, true);
+ image_token = platform->LoadImage(process, image_spec, FileSpec(), error);
+ }
+
if (image_token != LLDB_INVALID_IMAGE_TOKEN)
{
- result.AppendMessageWithFormat ("Loading \"%s\"...ok\nImage %u loaded.\n", image_path, image_token);
+ result.AppendMessageWithFormat ("Loading \"%s\"...ok\nImage %u loaded.\n", image_path, image_token);
result.SetStatus (eReturnStatusSuccessFinishResult);
}
else
@@ -1221,8 +1260,16 @@ protected:
}
return result.Succeeded();
}
+
+ CommandOptions m_options;
};
+OptionDefinition
+CommandObjectProcessLoad::CommandOptions::g_option_table[] =
+{
+ { LLDB_OPT_SET_ALL, false, "install", 'i', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypePath, "Install the shared library to the target. If specified without an argument then the library will installed in the current working directory."},
+ { 0, false, nullptr, 0 , 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
+};
//-------------------------------------------------------------------------
// CommandObjectProcessUnload
@@ -1245,14 +1292,13 @@ public:
{
}
- ~CommandObjectProcessUnload ()
+ ~CommandObjectProcessUnload () override
{
}
protected:
bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Process *process = m_exe_ctx.GetProcessPtr();
@@ -1270,7 +1316,7 @@ protected:
}
else
{
- Error error (process->UnloadImage(image_token));
+ Error error (process->GetTarget().GetPlatform()->UnloadImage(process, image_token));
if (error.Success())
{
result.AppendMessageWithFormat ("Unloading shared library with index %u...ok\n", image_token);
@@ -1318,14 +1364,13 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectProcessSignal ()
+ ~CommandObjectProcessSignal () override
{
}
protected:
bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Process *process = m_exe_ctx.GetProcessPtr();
@@ -1390,14 +1435,13 @@ public:
{
}
- ~CommandObjectProcessInterrupt ()
+ ~CommandObjectProcessInterrupt () override
{
}
protected:
bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Process *process = m_exe_ctx.GetProcessPtr();
if (process == NULL)
@@ -1452,14 +1496,13 @@ public:
{
}
- ~CommandObjectProcessKill ()
+ ~CommandObjectProcessKill () override
{
}
protected:
bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Process *process = m_exe_ctx.GetProcessPtr();
if (process == NULL)
@@ -1513,14 +1556,14 @@ public:
{
}
- ~CommandObjectProcessSaveCore ()
+ ~CommandObjectProcessSaveCore () override
{
}
protected:
bool
DoExecute (Args& command,
- CommandReturnObject &result)
+ CommandReturnObject &result) override
{
ProcessSP process_sp = m_exe_ctx.GetProcessSP();
if (process_sp)
@@ -1575,13 +1618,13 @@ public:
{
}
- ~CommandObjectProcessStatus()
+ ~CommandObjectProcessStatus() override
{
}
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Stream &strm = result.GetOutputStream();
result.SetStatus (eReturnStatusSuccessFinishNoResult);
@@ -1620,12 +1663,12 @@ public:
OptionParsingStarting ();
}
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -1649,7 +1692,7 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
stop.clear();
notify.clear();
@@ -1657,7 +1700,7 @@ public:
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -1694,12 +1737,12 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectProcessHandle ()
+ ~CommandObjectProcessHandle () override
{
}
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_options;
}
@@ -1781,7 +1824,7 @@ public:
protected:
bool
- DoExecute (Args &signal_args, CommandReturnObject &result)
+ DoExecute (Args &signal_args, CommandReturnObject &result) override
{
TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget();
diff --git a/source/Commands/CommandObjectProcess.h b/source/Commands/CommandObjectProcess.h
index 0aaa74d28a07..804c34261bad 100644
--- a/source/Commands/CommandObjectProcess.h
+++ b/source/Commands/CommandObjectProcess.h
@@ -27,11 +27,9 @@ class CommandObjectMultiwordProcess : public CommandObjectMultiword
public:
CommandObjectMultiwordProcess (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectMultiwordProcess ();
-
+ ~CommandObjectMultiwordProcess() override;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectProcess_h_
+#endif // liblldb_CommandObjectProcess_h_
diff --git a/source/Commands/CommandObjectQuit.h b/source/Commands/CommandObjectQuit.h
index aab0e26cce59..df9216b7e7e3 100644
--- a/source/Commands/CommandObjectQuit.h
+++ b/source/Commands/CommandObjectQuit.h
@@ -28,19 +28,17 @@ public:
CommandObjectQuit (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectQuit ();
+ ~CommandObjectQuit() override;
protected:
- virtual bool
- DoExecute (Args& args,
- CommandReturnObject &result);
+ bool
+ DoExecute(Args& args,
+ CommandReturnObject &result) override;
bool
ShouldAskForConfirmation (bool& is_a_detach);
-
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectQuit_h_
+#endif // liblldb_CommandObjectQuit_h_
diff --git a/source/Commands/CommandObjectRegister.cpp b/source/Commands/CommandObjectRegister.cpp
index fae5af42f405..23a215763738 100644
--- a/source/Commands/CommandObjectRegister.cpp
+++ b/source/Commands/CommandObjectRegister.cpp
@@ -74,13 +74,12 @@ public:
}
- virtual
- ~CommandObjectRegisterRead ()
+ ~CommandObjectRegisterRead () override
{
}
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_option_group;
}
@@ -170,8 +169,8 @@ public:
}
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Stream &strm = result.GetOutputStream();
RegisterContext *reg_ctx = m_exe_ctx.GetRegisterContext ();
@@ -271,33 +270,32 @@ protected:
{
}
- virtual
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
- virtual uint32_t
- GetNumDefinitions ();
+ uint32_t
+ GetNumDefinitions () override;
- virtual const OptionDefinition*
- GetDefinitions ()
+ const OptionDefinition*
+ GetDefinitions () override
{
return g_option_table;
}
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter)
+ void
+ OptionParsingStarting (CommandInterpreter &interpreter) override
{
set_indexes.Clear();
dump_all_sets.Clear();
alternate_name.Clear();
}
- virtual Error
+ Error
SetOptionValue (CommandInterpreter &interpreter,
uint32_t option_idx,
- const char *option_value)
+ const char *option_value) override
{
Error error;
const int short_option = g_option_table[option_idx].short_option;
@@ -404,14 +402,13 @@ public:
m_arguments.push_back (arg2);
}
- virtual
- ~CommandObjectRegisterWrite ()
+ ~CommandObjectRegisterWrite () override
{
}
protected:
- virtual bool
- DoExecute(Args& command, CommandReturnObject &result)
+ bool
+ DoExecute(Args& command, CommandReturnObject &result) override
{
DataExtractor reg_data;
RegisterContext *reg_ctx = m_exe_ctx.GetRegisterContext ();
diff --git a/source/Commands/CommandObjectRegister.h b/source/Commands/CommandObjectRegister.h
index 7f856c2de529..e7b6974bc998 100644
--- a/source/Commands/CommandObjectRegister.h
+++ b/source/Commands/CommandObjectRegister.h
@@ -30,8 +30,7 @@ public:
//------------------------------------------------------------------
CommandObjectRegister(CommandInterpreter &interpreter);
- virtual
- ~CommandObjectRegister();
+ ~CommandObjectRegister() override;
private:
//------------------------------------------------------------------
@@ -42,4 +41,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_CommandObjectRegister_h_
+#endif // liblldb_CommandObjectRegister_h_
diff --git a/source/Commands/CommandObjectSettings.cpp b/source/Commands/CommandObjectSettings.cpp
index 8ed783b211f6..890d77028a99 100644
--- a/source/Commands/CommandObjectSettings.cpp
+++ b/source/Commands/CommandObjectSettings.cpp
@@ -83,15 +83,14 @@ insert-before or insert-after."
}
- virtual
- ~CommandObjectSettingsSet () {}
+ ~CommandObjectSettingsSet () override {}
// Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
- virtual bool
- WantsCompletion() { return true; }
+ bool
+ WantsCompletion() override { return true; }
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -106,11 +105,10 @@ insert-before or insert-after."
{
}
- virtual
- ~CommandOptions () {}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -129,13 +127,13 @@ insert-before or insert-after."
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_global = false;
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -149,7 +147,7 @@ insert-before or insert-after."
bool m_global;
};
- virtual int
+ int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -157,7 +155,7 @@ insert-before or insert-after."
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
@@ -215,8 +213,8 @@ insert-before or insert-after."
}
protected:
- virtual bool
- DoExecute (const char *command, CommandReturnObject &result)
+ bool
+ DoExecute (const char *command, CommandReturnObject &result) override
{
Args cmd_args(command);
@@ -321,11 +319,10 @@ public:
m_arguments.push_back (arg1);
}
- virtual
- ~CommandObjectSettingsShow () {}
+ ~CommandObjectSettingsShow () override {}
- virtual int
+ int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -333,7 +330,7 @@ public:
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
@@ -349,8 +346,8 @@ public:
}
protected:
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
result.SetStatus (eReturnStatusSuccessFinishResult);
@@ -414,10 +411,9 @@ public:
m_arguments.push_back (arg);
}
- virtual
- ~CommandObjectSettingsList () {}
+ ~CommandObjectSettingsList () override {}
- virtual int
+ int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -425,7 +421,7 @@ public:
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
@@ -441,8 +437,8 @@ public:
}
protected:
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
result.SetStatus (eReturnStatusSuccessFinishResult);
@@ -521,10 +517,9 @@ public:
m_arguments.push_back (arg2);
}
- virtual
- ~CommandObjectSettingsRemove () {}
+ ~CommandObjectSettingsRemove () override {}
- virtual int
+ int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -532,7 +527,7 @@ public:
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
@@ -551,8 +546,8 @@ public:
}
protected:
- virtual bool
- DoExecute (const char *command, CommandReturnObject &result)
+ bool
+ DoExecute (const char *command, CommandReturnObject &result) override
{
result.SetStatus (eReturnStatusSuccessFinishNoResult);
@@ -652,14 +647,13 @@ public:
}
- virtual
- ~CommandObjectSettingsReplace () {}
+ ~CommandObjectSettingsReplace () override {}
// Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
- virtual bool
- WantsCompletion() { return true; }
+ bool
+ WantsCompletion() override { return true; }
- virtual int
+ int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -667,7 +661,7 @@ public:
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
@@ -686,8 +680,8 @@ public:
}
protected:
- virtual bool
- DoExecute (const char *command, CommandReturnObject &result)
+ bool
+ DoExecute (const char *command, CommandReturnObject &result) override
{
result.SetStatus (eReturnStatusSuccessFinishNoResult);
@@ -773,14 +767,13 @@ public:
m_arguments.push_back (arg3);
}
- virtual
- ~CommandObjectSettingsInsertBefore () {}
+ ~CommandObjectSettingsInsertBefore () override {}
// Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
- virtual bool
- WantsCompletion() { return true; }
+ bool
+ WantsCompletion() override { return true; }
- virtual int
+ int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -788,7 +781,7 @@ public:
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
@@ -807,8 +800,8 @@ public:
}
protected:
- virtual bool
- DoExecute (const char *command, CommandReturnObject &result)
+ bool
+ DoExecute (const char *command, CommandReturnObject &result) override
{
result.SetStatus (eReturnStatusSuccessFinishNoResult);
@@ -897,14 +890,13 @@ public:
m_arguments.push_back (arg3);
}
- virtual
- ~CommandObjectSettingsInsertAfter () {}
+ ~CommandObjectSettingsInsertAfter () override {}
// Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
- virtual bool
- WantsCompletion() { return true; }
+ bool
+ WantsCompletion() override { return true; }
- virtual int
+ int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -912,7 +904,7 @@ public:
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
@@ -931,8 +923,8 @@ public:
}
protected:
- virtual bool
- DoExecute (const char *command, CommandReturnObject &result)
+ bool
+ DoExecute (const char *command, CommandReturnObject &result) override
{
result.SetStatus (eReturnStatusSuccessFinishNoResult);
@@ -1011,14 +1003,13 @@ public:
m_arguments.push_back (arg2);
}
- virtual
- ~CommandObjectSettingsAppend () {}
+ ~CommandObjectSettingsAppend () override {}
// Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
- virtual bool
- WantsCompletion() { return true; }
+ bool
+ WantsCompletion() override { return true; }
- virtual int
+ int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -1026,7 +1017,7 @@ public:
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
@@ -1045,8 +1036,8 @@ public:
}
protected:
- virtual bool
- DoExecute (const char *command, CommandReturnObject &result)
+ bool
+ DoExecute (const char *command, CommandReturnObject &result) override
{
result.SetStatus (eReturnStatusSuccessFinishNoResult);
Args cmd_args(command);
@@ -1117,10 +1108,9 @@ public:
m_arguments.push_back (arg);
}
- virtual
- ~CommandObjectSettingsClear () {}
+ ~CommandObjectSettingsClear () override {}
- virtual int
+ int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -1128,7 +1118,7 @@ public:
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
@@ -1147,8 +1137,8 @@ public:
}
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
result.SetStatus (eReturnStatusSuccessFinishNoResult);
const size_t argc = command.GetArgumentCount ();
diff --git a/source/Commands/CommandObjectSettings.h b/source/Commands/CommandObjectSettings.h
index eca7adeea76f..93ee91981c10 100644
--- a/source/Commands/CommandObjectSettings.h
+++ b/source/Commands/CommandObjectSettings.h
@@ -31,11 +31,9 @@ public:
CommandObjectMultiwordSettings (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectMultiwordSettings ();
-
+ ~CommandObjectMultiwordSettings() override;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectSettings_h_
+#endif // liblldb_CommandObjectSettings_h_
diff --git a/source/Commands/CommandObjectSource.cpp b/source/Commands/CommandObjectSource.cpp
index 7c5f127cb51a..08c8d46d1ee0 100644
--- a/source/Commands/CommandObjectSource.cpp
+++ b/source/Commands/CommandObjectSource.cpp
@@ -49,12 +49,12 @@ class CommandObjectSourceInfo : public CommandObjectParsed
{
}
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = g_option_table[option_idx].short_option;
@@ -79,7 +79,7 @@ class CommandObjectSourceInfo : public CommandObjectParsed
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
file_spec.Clear();
file_name.clear();
@@ -87,7 +87,7 @@ class CommandObjectSourceInfo : public CommandObjectParsed
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -110,20 +110,20 @@ public:
{
}
- ~CommandObjectSourceInfo ()
+ ~CommandObjectSourceInfo () override
{
}
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_options;
}
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
result.AppendError ("Not yet implemented");
result.SetStatus (eReturnStatusFailed);
@@ -157,12 +157,12 @@ class CommandObjectSourceList : public CommandObjectParsed
{
}
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = g_option_table[option_idx].short_option;
@@ -213,7 +213,7 @@ class CommandObjectSourceList : public CommandObjectParsed
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
file_spec.Clear();
file_name.clear();
@@ -227,7 +227,7 @@ class CommandObjectSourceList : public CommandObjectParsed
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -256,19 +256,19 @@ public:
{
}
- ~CommandObjectSourceList ()
+ ~CommandObjectSourceList () override
{
}
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_options;
}
- virtual const char *
- GetRepeatCommand (Args &current_command_args, uint32_t index)
+ const char *
+ GetRepeatCommand (Args &current_command_args, uint32_t index) override
{
// This is kind of gross, but the command hasn't been parsed yet so we can't look at the option
// values for this invocation... I have to scan the arguments directly.
@@ -507,7 +507,7 @@ protected:
}
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
const size_t argc = command.GetArgumentCount();
diff --git a/source/Commands/CommandObjectSource.h b/source/Commands/CommandObjectSource.h
index 0daef1385860..7ed08cdc9591 100644
--- a/source/Commands/CommandObjectSource.h
+++ b/source/Commands/CommandObjectSource.h
@@ -30,11 +30,9 @@ public:
CommandObjectMultiwordSource (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectMultiwordSource ();
-
+ ~CommandObjectMultiwordSource() override;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectSource.h_h_
+#endif // liblldb_CommandObjectSource_h_
diff --git a/source/Commands/CommandObjectSyntax.h b/source/Commands/CommandObjectSyntax.h
index 47bf85f8549e..1a3e4e04f01a 100644
--- a/source/Commands/CommandObjectSyntax.h
+++ b/source/Commands/CommandObjectSyntax.h
@@ -28,17 +28,14 @@ public:
CommandObjectSyntax (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectSyntax ();
+ ~CommandObjectSyntax() override;
protected:
- virtual bool
- DoExecute (Args& command,
- CommandReturnObject &result);
-
-
+ bool
+ DoExecute(Args& command,
+ CommandReturnObject &result) override;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectSyntax_h_
+#endif // liblldb_CommandObjectSyntax_h_
diff --git a/source/Commands/CommandObjectTarget.cpp b/source/Commands/CommandObjectTarget.cpp
index 448da0ede245..026ae3570854 100644
--- a/source/Commands/CommandObjectTarget.cpp
+++ b/source/Commands/CommandObjectTarget.cpp
@@ -79,7 +79,8 @@ DumpTargetInfo (uint32_t target_idx, Target *target, const char *prefix_cstr, bo
uint32_t properties = 0;
if (target_arch.IsValid())
{
- strm.Printf ("%sarch=%s", properties++ > 0 ? ", " : " ( ", target_arch.GetTriple().str().c_str());
+ strm.Printf ("%sarch=", properties++ > 0 ? ", " : " ( ");
+ target_arch.DumpTriple (strm);
properties++;
}
PlatformSP platform_sp (target->GetPlatform());
@@ -187,17 +188,17 @@ public:
m_option_group.Finalize();
}
- ~CommandObjectTargetCreate ()
+ ~CommandObjectTargetCreate () override
{
}
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_option_group;
}
- virtual int
+ int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -205,7 +206,7 @@ public:
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
completion_str.erase (cursor_char_position);
@@ -223,7 +224,7 @@ public:
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
const size_t argc = command.GetArgumentCount();
FileSpec core_file (m_core_file.GetOptionValue().GetCurrentValue());
@@ -255,7 +256,7 @@ protected:
{
if (!symfile.Readable())
{
- result.AppendErrorWithFormat("symbol file '%s' is not readable", core_file.GetPath().c_str());
+ result.AppendErrorWithFormat("symbol file '%s' is not readable", symfile.GetPath().c_str());
result.SetStatus (eReturnStatusFailed);
return false;
}
@@ -401,7 +402,7 @@ protected:
if (process_sp)
{
- // Seems wierd that we Launch a core file, but that is
+ // Seems weird that we Launch a core file, but that is
// what we do!
error = process_sp->LoadCore();
@@ -477,14 +478,13 @@ public:
{
}
- virtual
- ~CommandObjectTargetList ()
+ ~CommandObjectTargetList () override
{
}
protected:
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
if (args.GetArgumentCount() == 0)
{
@@ -525,14 +525,13 @@ public:
{
}
- virtual
- ~CommandObjectTargetSelect ()
+ ~CommandObjectTargetSelect () override
{
}
protected:
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
if (args.GetArgumentCount() == 1)
{
@@ -622,20 +621,19 @@ public:
m_option_group.Finalize();
}
- virtual
- ~CommandObjectTargetDelete ()
+ ~CommandObjectTargetDelete () override
{
}
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_option_group;
}
protected:
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
const size_t argc = args.GetArgumentCount();
std::vector<TargetSP> delete_target_list;
@@ -777,8 +775,7 @@ public:
m_option_group.Finalize();
}
- virtual
- ~CommandObjectTargetVariable ()
+ ~CommandObjectTargetVariable () override
{
}
@@ -850,7 +847,7 @@ public:
}
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_option_group;
}
@@ -896,8 +893,8 @@ protected:
}
}
- virtual bool
- DoExecute (Args& args, CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
Target *target = m_exe_ctx.GetTargetPtr();
const size_t argc = args.GetArgumentCount();
@@ -1134,14 +1131,13 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectTargetModulesSearchPathsAdd ()
+ ~CommandObjectTargetModulesSearchPathsAdd () override
{
}
protected:
bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (target)
@@ -1161,6 +1157,12 @@ protected:
if (from[0] && to[0])
{
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ if (log)
+ {
+ log->Printf ("target modules search path adding ImageSearchPath pair: '%s' -> '%s'",
+ from, to);
+ }
bool last_pair = ((argc - i) == 2);
target->GetImageSearchPathList().Append (ConstString(from),
ConstString(to),
@@ -1201,14 +1203,13 @@ public:
{
}
- ~CommandObjectTargetModulesSearchPathsClear ()
+ ~CommandObjectTargetModulesSearchPathsClear () override
{
}
protected:
bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (target)
@@ -1271,20 +1272,19 @@ public:
m_arguments.push_back (arg2);
}
- ~CommandObjectTargetModulesSearchPathsInsert ()
+ ~CommandObjectTargetModulesSearchPathsInsert () override
{
}
protected:
bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (target)
{
size_t argc = command.GetArgumentCount();
- // check for at least 3 arguments and an odd nubmer of parameters
+ // check for at least 3 arguments and an odd number of parameters
if (argc >= 3 && argc & 1)
{
bool success = false;
@@ -1360,14 +1360,13 @@ public:
{
}
- ~CommandObjectTargetModulesSearchPathsList ()
+ ~CommandObjectTargetModulesSearchPathsList () override
{
}
protected:
bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (target)
@@ -1417,14 +1416,13 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectTargetModulesSearchPathsQuery ()
+ ~CommandObjectTargetModulesSearchPathsQuery () override
{
}
protected:
bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (target)
@@ -1462,15 +1460,18 @@ DumpModuleArchitecture (Stream &strm, Module *module, bool full_triple, uint32_t
{
if (module)
{
- const char *arch_cstr;
+ StreamString arch_strm;
+
if (full_triple)
- arch_cstr = module->GetArchitecture().GetTriple().str().c_str();
+ module->GetArchitecture().DumpTriple(arch_strm);
else
- arch_cstr = module->GetArchitecture().GetArchitectureName();
+ arch_strm.PutCString(module->GetArchitecture().GetArchitectureName());
+ std::string arch_str = arch_strm.GetString();
+
if (width)
- strm.Printf("%-*s", width, arch_cstr);
+ strm.Printf("%-*s", width, arch_str.c_str());
else
- strm.PutCString(arch_cstr);
+ strm.PutCString(arch_str.c_str());
}
}
@@ -1865,7 +1866,7 @@ LookupTypeInModule (CommandInterpreter &interpreter,
{
// Resolve the clang type so that any forward references
// to types that haven't yet been parsed will get parsed.
- type_sp->GetClangFullType ();
+ type_sp->GetFullCompilerType ();
type_sp->GetDescription (&strm, eDescriptionLevelFull, true);
// Print all typedef chains
TypeSP typedef_type_sp (type_sp);
@@ -1874,7 +1875,7 @@ LookupTypeInModule (CommandInterpreter &interpreter,
{
strm.EOL();
strm.Printf(" typedef '%s': ", typedef_type_sp->GetName().GetCString());
- typedefed_type_sp->GetClangFullType ();
+ typedefed_type_sp->GetFullCompilerType ();
typedefed_type_sp->GetDescription (&strm, eDescriptionLevelFull, true);
typedef_type_sp = typedefed_type_sp;
typedefed_type_sp = typedef_type_sp->GetTypedefType();
@@ -1918,7 +1919,7 @@ LookupTypeHere (CommandInterpreter &interpreter,
{
// Resolve the clang type so that any forward references
// to types that haven't yet been parsed will get parsed.
- type_sp->GetClangFullType ();
+ type_sp->GetFullCompilerType ();
type_sp->GetDescription (&strm, eDescriptionLevelFull, true);
// Print all typedef chains
TypeSP typedef_type_sp (type_sp);
@@ -1927,7 +1928,7 @@ LookupTypeHere (CommandInterpreter &interpreter,
{
strm.EOL();
strm.Printf(" typedef '%s': ", typedef_type_sp->GetName().GetCString());
- typedefed_type_sp->GetClangFullType ();
+ typedefed_type_sp->GetFullCompilerType ();
typedefed_type_sp->GetDescription (&strm, eDescriptionLevelFull, true);
typedef_type_sp = typedefed_type_sp;
typedefed_type_sp = typedef_type_sp->GetTypedefType();
@@ -2056,12 +2057,11 @@ public:
m_arguments.push_back (arg);
}
- virtual
- ~CommandObjectTargetModulesModuleAutoComplete ()
+ ~CommandObjectTargetModulesModuleAutoComplete () override
{
}
- virtual int
+ int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -2069,7 +2069,7 @@ public:
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
// Arguments are the standard module completer.
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
@@ -2118,12 +2118,11 @@ public:
m_arguments.push_back (arg);
}
- virtual
- ~CommandObjectTargetModulesSourceFileAutoComplete ()
+ ~CommandObjectTargetModulesSourceFileAutoComplete () override
{
}
- virtual int
+ int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -2131,7 +2130,7 @@ public:
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
// Arguments are the standard source file completer.
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
@@ -2165,13 +2164,12 @@ public:
{
}
- virtual
- ~CommandObjectTargetModulesDumpSymtab ()
+ ~CommandObjectTargetModulesDumpSymtab () override
{
}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -2185,13 +2183,12 @@ public:
{
}
- virtual
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -2214,13 +2211,13 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_sort_order = eSortOrderNone;
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -2232,9 +2229,8 @@ public:
};
protected:
- virtual bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (target == NULL)
@@ -2359,15 +2355,13 @@ public:
{
}
- virtual
- ~CommandObjectTargetModulesDumpSections ()
+ ~CommandObjectTargetModulesDumpSections () override
{
}
protected:
- virtual bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (target == NULL)
@@ -2465,15 +2459,13 @@ public:
{
}
- virtual
- ~CommandObjectTargetModulesDumpSymfile ()
+ ~CommandObjectTargetModulesDumpSymfile () override
{
}
protected:
- virtual bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (target == NULL)
@@ -2568,15 +2560,13 @@ public:
{
}
- virtual
- ~CommandObjectTargetModulesDumpLineTable ()
+ ~CommandObjectTargetModulesDumpLineTable () override
{
}
protected:
- virtual bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_exe_ctx.GetTargetPtr();
uint32_t total_num_dumped = 0;
@@ -2657,8 +2647,7 @@ public:
LoadSubCommand ("line-table", CommandObjectSP (new CommandObjectTargetModulesDumpLineTable (interpreter)));
}
- virtual
- ~CommandObjectTargetModulesDump()
+ ~CommandObjectTargetModulesDump() override
{
}
};
@@ -2679,18 +2668,17 @@ public:
m_option_group.Finalize();
}
- virtual
- ~CommandObjectTargetModulesAdd ()
+ ~CommandObjectTargetModulesAdd () override
{
}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_option_group;
}
- virtual int
+ int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -2698,7 +2686,7 @@ public:
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
completion_str.erase (cursor_char_position);
@@ -2719,9 +2707,8 @@ protected:
OptionGroupUUID m_uuid_option_group;
OptionGroupFile m_symbol_file;
- virtual bool
- DoExecute (Args& args,
- CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (target == NULL)
@@ -2882,21 +2869,19 @@ public:
m_option_group.Finalize();
}
- virtual
- ~CommandObjectTargetModulesLoad ()
+ ~CommandObjectTargetModulesLoad () override
{
}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_option_group;
}
protected:
- virtual bool
- DoExecute (Args& args,
- CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (target == NULL)
@@ -3139,13 +3124,12 @@ public:
{
}
- virtual
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
@@ -3170,7 +3154,7 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_format_array.clear();
m_use_global_module_list = false;
@@ -3178,7 +3162,7 @@ public:
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -3203,22 +3187,19 @@ public:
{
}
- virtual
- ~CommandObjectTargetModulesList ()
+ ~CommandObjectTargetModulesList () override
{
}
- virtual
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_options;
}
protected:
- virtual bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
const bool use_global_module_list = m_options.m_use_global_module_list;
@@ -3584,13 +3565,12 @@ public:
{
}
- virtual
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
@@ -3625,7 +3605,7 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_type = eLookupTypeInvalid;
m_str.clear();
@@ -3633,7 +3613,7 @@ public:
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -3662,22 +3642,19 @@ public:
{
}
- virtual
- ~CommandObjectTargetModulesShowUnwind ()
+ ~CommandObjectTargetModulesShowUnwind () override
{
}
- virtual
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_options;
}
protected:
bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_exe_ctx.GetTargetPtr();
Process *process = m_exe_ctx.GetProcessPtr();
@@ -3813,6 +3790,14 @@ protected:
result.GetOutputStream().Printf("\n");
}
+ UnwindPlanSP arm_unwind_sp = func_unwinders_sp->GetArmUnwindUnwindPlan(*target, 0);
+ if (arm_unwind_sp)
+ {
+ result.GetOutputStream().Printf("ARM.exidx unwind UnwindPlan:\n");
+ arm_unwind_sp->Dump(result.GetOutputStream(), thread.get(), LLDB_INVALID_ADDRESS);
+ result.GetOutputStream().Printf("\n");
+ }
+
UnwindPlanSP compact_unwind_sp = func_unwinders_sp->GetCompactUnwindUnwindPlan(*target, 0);
if (compact_unwind_sp)
{
@@ -3891,13 +3876,12 @@ public:
OptionParsingStarting();
}
- virtual
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
@@ -3974,7 +3958,7 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_type = eLookupTypeInvalid;
m_str.clear();
@@ -3989,7 +3973,7 @@ public:
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -4031,13 +4015,12 @@ public:
m_arguments.push_back (arg);
}
- virtual
- ~CommandObjectTargetModulesLookup ()
+ ~CommandObjectTargetModulesLookup () override
{
}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -4191,9 +4174,8 @@ public:
}
protected:
- virtual bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (target == NULL)
@@ -4339,7 +4321,7 @@ public:
LoadSubCommand ("query", CommandObjectSP (new CommandObjectTargetModulesSearchPathsQuery (interpreter)));
}
- ~CommandObjectTargetModulesImageSearchPaths()
+ ~CommandObjectTargetModulesImageSearchPaths() override
{
}
};
@@ -4373,8 +4355,8 @@ public:
LoadSubCommand ("show-unwind", CommandObjectSP (new CommandObjectTargetModulesShowUnwind (interpreter)));
}
- virtual
- ~CommandObjectTargetModules()
+
+ ~CommandObjectTargetModules() override
{
}
@@ -4406,12 +4388,11 @@ public:
m_option_group.Finalize();
}
- virtual
- ~CommandObjectTargetSymbolsAdd ()
+ ~CommandObjectTargetSymbolsAdd () override
{
}
- virtual int
+ int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -4419,7 +4400,7 @@ public:
int match_start_point,
int max_return_elements,
bool &word_complete,
- StringList &matches)
+ StringList &matches) override
{
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
completion_str.erase (cursor_char_position);
@@ -4435,8 +4416,8 @@ public:
return matches.GetSize();
}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_option_group;
}
@@ -4614,9 +4595,8 @@ protected:
return false;
}
- virtual bool
- DoExecute (Args& args,
- CommandReturnObject &result)
+ bool
+ DoExecute (Args& args, CommandReturnObject &result) override
{
Target *target = m_exe_ctx.GetTargetPtr();
result.SetStatus (eReturnStatusFailed);
@@ -4834,8 +4814,8 @@ public:
LoadSubCommand ("add", CommandObjectSP (new CommandObjectTargetSymbolsAdd (interpreter)));
}
- virtual
- ~CommandObjectTargetSymbols()
+
+ ~CommandObjectTargetSymbols() override
{
}
@@ -4874,16 +4854,16 @@ public:
{
}
- ~CommandOptions () {}
+ ~CommandOptions () override {}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -4970,7 +4950,7 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_class_name.clear();
m_function_name.clear();
@@ -5015,7 +4995,7 @@ public:
};
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_options;
}
@@ -5030,13 +5010,13 @@ public:
{
}
- ~CommandObjectTargetStopHookAdd ()
+ ~CommandObjectTargetStopHookAdd () override
{
}
protected:
- virtual void
- IOHandlerActivated (IOHandler &io_handler)
+ void
+ IOHandlerActivated (IOHandler &io_handler) override
{
StreamFileSP output_sp(io_handler.GetOutputStreamFile());
if (output_sp)
@@ -5046,8 +5026,8 @@ protected:
}
}
- virtual void
- IOHandlerInputComplete (IOHandler &io_handler, std::string &line)
+ void
+ IOHandlerInputComplete (IOHandler &io_handler, std::string &line) override
{
if (m_stop_hook_sp)
{
@@ -5079,7 +5059,7 @@ protected:
}
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
m_stop_hook_sp.reset();
@@ -5227,13 +5207,13 @@ public:
{
}
- ~CommandObjectTargetStopHookDelete ()
+ ~CommandObjectTargetStopHookDelete () override
{
}
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = GetSelectedOrDummyTarget();
if (target)
@@ -5303,13 +5283,13 @@ public:
{
}
- ~CommandObjectTargetStopHookEnableDisable ()
+ ~CommandObjectTargetStopHookEnableDisable () override
{
}
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = GetSelectedOrDummyTarget();
if (target)
@@ -5373,13 +5353,13 @@ public:
{
}
- ~CommandObjectTargetStopHookList ()
+ ~CommandObjectTargetStopHookList () override
{
}
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = GetSelectedOrDummyTarget();
if (!target)
@@ -5439,7 +5419,7 @@ public:
LoadSubCommand ("list", CommandObjectSP (new CommandObjectTargetStopHookList (interpreter)));
}
- ~CommandObjectMultiwordTargetStopHooks()
+ ~CommandObjectMultiwordTargetStopHooks() override
{
}
};
diff --git a/source/Commands/CommandObjectTarget.h b/source/Commands/CommandObjectTarget.h
index 7b6637812c4c..d99a2b07f9a7 100644
--- a/source/Commands/CommandObjectTarget.h
+++ b/source/Commands/CommandObjectTarget.h
@@ -30,12 +30,9 @@ public:
CommandObjectMultiwordTarget (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectMultiwordTarget ();
-
-
+ ~CommandObjectMultiwordTarget() override;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectTarget_h_
+#endif // liblldb_CommandObjectTarget_h_
diff --git a/source/Commands/CommandObjectThread.cpp b/source/Commands/CommandObjectThread.cpp
index 5f38ad4900d6..e932c9d96c35 100644
--- a/source/Commands/CommandObjectThread.cpp
+++ b/source/Commands/CommandObjectThread.cpp
@@ -58,9 +58,10 @@ public:
{
}
- virtual ~CommandObjectIterateOverThreads() {}
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ ~CommandObjectIterateOverThreads() override {}
+
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
result.SetStatus (m_success_return);
@@ -162,13 +163,12 @@ public:
OptionParsingStarting ();
}
- virtual
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -211,7 +211,7 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_count = UINT32_MAX;
m_start = 0;
@@ -219,7 +219,7 @@ public:
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -248,12 +248,12 @@ public:
{
}
- ~CommandObjectThreadBacktrace()
+ ~CommandObjectThreadBacktrace() override
{
}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -285,8 +285,8 @@ protected:
}
}
- virtual bool
- HandleOneThread (Thread &thread, CommandReturnObject &result)
+ bool
+ HandleOneThread (Thread &thread, CommandReturnObject &result) override
{
Stream &strm = result.GetOutputStream();
@@ -343,13 +343,12 @@ public:
OptionParsingStarting ();
}
- virtual
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -426,7 +425,7 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_step_in_avoid_no_debug = eLazyBoolCalculate;
m_step_out_avoid_no_debug = eLazyBoolCalculate;
@@ -444,7 +443,7 @@ public:
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -493,21 +492,19 @@ public:
m_arguments.push_back (arg);
}
- virtual
- ~CommandObjectThreadStepWithTypeAndScope ()
+ ~CommandObjectThreadStepWithTypeAndScope () override
{
}
- virtual
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_options;
}
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Process *process = m_exe_ctx.GetProcessPtr();
bool synchronous_execution = m_interpreter.GetSynchronous();
@@ -589,7 +586,7 @@ protected:
if (frame->HasDebugInformation ())
{
new_plan_sp = thread->QueueThreadPlanForStepInRange (abort_other_plans,
- frame->GetSymbolContext(eSymbolContextEverything).line_entry.range,
+ frame->GetSymbolContext(eSymbolContextEverything).line_entry,
frame->GetSymbolContext(eSymbolContextEverything),
m_options.m_step_in_target.c_str(),
stop_other_threads,
@@ -612,7 +609,7 @@ protected:
if (frame->HasDebugInformation())
new_plan_sp = thread->QueueThreadPlanForStepOverRange (abort_other_plans,
- frame->GetSymbolContext(eSymbolContextEverything).line_entry.range,
+ frame->GetSymbolContext(eSymbolContextEverything).line_entry,
frame->GetSymbolContext(eSymbolContextEverything),
stop_other_threads,
m_options.m_step_out_avoid_no_debug);
@@ -780,13 +777,12 @@ public:
}
- virtual
- ~CommandObjectThreadContinue ()
+ ~CommandObjectThreadContinue () override
{
}
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
bool synchronous_execution = m_interpreter.GetSynchronous ();
@@ -980,13 +976,12 @@ public:
OptionParsingStarting ();
}
- virtual
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -1042,7 +1037,7 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_thread_idx = LLDB_INVALID_THREAD_ID;
m_frame_idx = 0;
@@ -1051,7 +1046,7 @@ public:
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -1093,21 +1088,19 @@ public:
}
- virtual
- ~CommandObjectThreadUntil ()
+ ~CommandObjectThreadUntil () override
{
}
- virtual
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_options;
}
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
bool synchronous_execution = m_interpreter.GetSynchronous ();
@@ -1371,14 +1364,13 @@ public:
}
- virtual
- ~CommandObjectThreadSelect ()
+ ~CommandObjectThreadSelect () override
{
}
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Process *process = m_exe_ctx.GetProcessPtr();
if (process == NULL)
@@ -1434,13 +1426,13 @@ public:
{
}
- ~CommandObjectThreadList()
+ ~CommandObjectThreadList() override
{
}
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Stream &strm = result.GetOutputStream();
result.SetStatus (eReturnStatusSuccessFinishNoResult);
@@ -1492,19 +1484,18 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_json_thread = false;
m_json_stopinfo = false;
}
- virtual
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
const int short_option = m_getopt_table[option_idx].val;
Error error;
@@ -1527,7 +1518,7 @@ public:
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -1538,21 +1529,18 @@ public:
static OptionDefinition g_option_table[];
};
- virtual
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_options;
}
-
- virtual
- ~CommandObjectThreadInfo ()
+ ~CommandObjectThreadInfo () override
{
}
- virtual bool
- HandleOneThread (Thread &thread, CommandReturnObject &result)
+ bool
+ HandleOneThread (Thread &thread, CommandReturnObject &result) override
{
Stream &strm = result.GetOutputStream();
if (!thread.GetDescription (strm, eDescriptionLevelFull, m_options.m_json_thread, m_options.m_json_stopinfo))
@@ -1597,13 +1585,12 @@ public:
OptionParsingStarting ();
}
- virtual
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -1631,13 +1618,13 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_from_expression = false;
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -1651,9 +1638,8 @@ public:
// Instance variables to hold the values for command options.
};
- virtual
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_options;
}
@@ -1686,17 +1672,14 @@ public:
}
- ~CommandObjectThreadReturn()
+ ~CommandObjectThreadReturn() override
{
}
protected:
- bool DoExecute
- (
- const char *command,
- CommandReturnObject &result
- )
+ bool
+ DoExecute (const char *command, CommandReturnObject &result) override
{
// I am going to handle this by hand, because I don't want you to have to say:
// "thread return -- -5".
@@ -1810,7 +1793,7 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_filenames.Clear();
m_line_num = 0;
@@ -1819,13 +1802,12 @@ public:
m_force = false;
}
- virtual
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
bool success;
const int short_option = m_getopt_table[option_idx].val;
@@ -1866,7 +1848,7 @@ public:
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -1880,9 +1862,8 @@ public:
static OptionDefinition g_option_table[];
};
- virtual
Options *
- GetOptions ()
+ GetOptions () override
{
return &m_options;
}
@@ -1900,13 +1881,13 @@ public:
{
}
- ~CommandObjectThreadJump()
+ ~CommandObjectThreadJump() override
{
}
protected:
- bool DoExecute (Args& args, CommandReturnObject &result)
+ bool DoExecute (Args& args, CommandReturnObject &result) override
{
RegisterContext *reg_ctx = m_exe_ctx.GetRegisterContext();
StackFrame *frame = m_exe_ctx.GetFramePtr();
@@ -2017,13 +1998,12 @@ public:
OptionParsingStarting ();
}
- virtual
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -2049,14 +2029,14 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_verbose = false;
m_internal = false;
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -2085,19 +2065,19 @@ public:
{
}
- ~CommandObjectThreadPlanList ()
+ ~CommandObjectThreadPlanList () override
{
}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
protected:
- virtual bool
- HandleOneThread (Thread &thread, CommandReturnObject &result)
+ bool
+ HandleOneThread (Thread &thread, CommandReturnObject &result) override
{
Stream &strm = result.GetOutputStream();
DescriptionLevel desc_level = eDescriptionLevelFull;
@@ -2148,10 +2128,10 @@ public:
m_arguments.push_back (arg);
}
- virtual ~CommandObjectThreadPlanDiscard () {}
+ ~CommandObjectThreadPlanDiscard () override {}
bool
- DoExecute (Args& args, CommandReturnObject &result)
+ DoExecute (Args& args, CommandReturnObject &result) override
{
Thread *thread = m_exe_ctx.GetThreadPtr();
if (args.GetArgumentCount() != 1)
@@ -2211,7 +2191,7 @@ public:
LoadSubCommand ("discard", CommandObjectSP (new CommandObjectThreadPlanDiscard (interpreter)));
}
- virtual ~CommandObjectMultiwordThreadPlan () {}
+ ~CommandObjectMultiwordThreadPlan () override {}
};
diff --git a/source/Commands/CommandObjectThread.h b/source/Commands/CommandObjectThread.h
index 52902ee36c76..90f8236b4428 100644
--- a/source/Commands/CommandObjectThread.h
+++ b/source/Commands/CommandObjectThread.h
@@ -24,11 +24,9 @@ public:
CommandObjectMultiwordThread (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectMultiwordThread ();
-
+ ~CommandObjectMultiwordThread() override;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectThread_h_
+#endif // liblldb_CommandObjectThread_h_
diff --git a/source/Commands/CommandObjectType.cpp b/source/Commands/CommandObjectType.cpp
index 584e94d0452d..b57ac70f8f1a 100644
--- a/source/Commands/CommandObjectType.cpp
+++ b/source/Commands/CommandObjectType.cpp
@@ -30,6 +30,10 @@
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/OptionGroupFormat.h"
+#include "lldb/Interpreter/OptionValueBoolean.h"
+#include "lldb/Interpreter/OptionValueLanguage.h"
+#include "lldb/Interpreter/OptionValueString.h"
+#include "lldb/Target/Language.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
@@ -144,17 +148,16 @@ private:
{
}
- virtual
- ~CommandOptions (){}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg);
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override;
void
- OptionParsingStarting ();
+ OptionParsingStarting () override;
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -177,8 +180,8 @@ private:
CommandOptions m_options;
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -200,12 +203,12 @@ public:
CommandObjectTypeSummaryAdd (CommandInterpreter &interpreter);
- ~CommandObjectTypeSummaryAdd ()
+ ~CommandObjectTypeSummaryAdd () override
{
}
- virtual void
- IOHandlerActivated (IOHandler &io_handler)
+ void
+ IOHandlerActivated (IOHandler &io_handler) override
{
static const char *g_summary_addreader_instructions = "Enter your Python command(s). Type 'DONE' to end.\n"
"def function (valobj,internal_dict):\n"
@@ -221,8 +224,8 @@ public:
}
- virtual void
- IOHandlerInputComplete (IOHandler &io_handler, std::string &data)
+ void
+ IOHandlerInputComplete (IOHandler &io_handler, std::string &data) override
{
StreamFileSP error_sp = io_handler.GetErrorStreamFile();
@@ -353,7 +356,7 @@ public:
Error* error = NULL);
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result);
+ DoExecute (Args& command, CommandReturnObject &result) override;
};
@@ -383,11 +386,10 @@ private:
{
}
- virtual
- ~CommandOptions (){}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -428,7 +430,7 @@ private:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_cascade = true;
m_class_name = "";
@@ -441,7 +443,7 @@ private:
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -469,8 +471,8 @@ private:
CommandOptions m_options;
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -483,7 +485,7 @@ private:
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
WarnOnPotentialUnquotedUnsignedType(command, result);
@@ -499,8 +501,8 @@ protected:
}
}
- virtual void
- IOHandlerActivated (IOHandler &io_handler)
+ void
+ IOHandlerActivated (IOHandler &io_handler) override
{
StreamFileSP output_sp(io_handler.GetOutputStreamFile());
if (output_sp)
@@ -511,8 +513,8 @@ protected:
}
- virtual void
- IOHandlerInputComplete (IOHandler &io_handler, std::string &data)
+ void
+ IOHandlerInputComplete (IOHandler &io_handler, std::string &data) override
{
StreamFileSP error_sp = io_handler.GetErrorStreamFile();
@@ -626,7 +628,7 @@ public:
CommandObjectTypeSynthAdd (CommandInterpreter &interpreter);
- ~CommandObjectTypeSynthAdd ()
+ ~CommandObjectTypeSynthAdd () override
{
}
@@ -656,22 +658,21 @@ private:
{
}
- virtual
- ~CommandOptions ()
+ ~CommandOptions () override
{
}
- virtual uint32_t
- GetNumDefinitions ();
+ uint32_t
+ GetNumDefinitions () override;
- virtual const OptionDefinition*
- GetDefinitions ()
+ const OptionDefinition*
+ GetDefinitions () override
{
return g_option_table;
}
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter)
+ void
+ OptionParsingStarting (CommandInterpreter &interpreter) override
{
m_cascade = true;
m_skip_pointers = false;
@@ -680,10 +681,10 @@ private:
m_category.assign("default");
m_custom_type_name.clear();
}
- virtual Error
+ Error
SetOptionValue (CommandInterpreter &interpreter,
uint32_t option_idx,
- const char *option_value)
+ const char *option_value) override
{
Error error;
const int short_option = g_option_table[option_idx].short_option;
@@ -737,8 +738,8 @@ private:
OptionGroupFormat m_format_options;
CommandOptions m_command_options;
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_option_group;
}
@@ -806,13 +807,13 @@ pointers to floats. Nor will it change the default display for Afloat and Bfloa
}
- ~CommandObjectTypeFormatAdd ()
+ ~CommandObjectTypeFormatAdd () override
{
}
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
const size_t argc = command.GetArgumentCount();
@@ -906,14 +907,9 @@ CommandObjectTypeFormatAdd::CommandOptions::GetNumDefinitions ()
return sizeof(g_option_table) / sizeof (OptionDefinition);
}
-
-//-------------------------------------------------------------------------
-// CommandObjectTypeFormatDelete
-//-------------------------------------------------------------------------
-
-class CommandObjectTypeFormatDelete : public CommandObjectParsed
+class CommandObjectTypeFormatterDelete : public CommandObjectParsed
{
-private:
+protected:
class CommandOptions : public Options
{
public:
@@ -923,11 +919,10 @@ private:
{
}
- virtual
- ~CommandOptions (){}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -940,6 +935,9 @@ private:
case 'w':
m_category = std::string(option_arg);
break;
+ case 'l':
+ m_language = Language::GetLanguageTypeFromString(option_arg);
+ break;
default:
error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
break;
@@ -949,14 +947,15 @@ private:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_delete_all = false;
m_category = "default";
+ m_language = lldb::eLanguageTypeUnknown;
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -969,33 +968,29 @@ private:
bool m_delete_all;
std::string m_category;
-
+ lldb::LanguageType m_language;
};
CommandOptions m_options;
+ uint32_t m_formatter_kind_mask;
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
- static bool
- PerCategoryCallback(void* param,
- const lldb::TypeCategoryImplSP& category_sp)
- {
- ConstString *name = (ConstString*)param;
- category_sp->Delete(*name, eFormatCategoryItemValue | eFormatCategoryItemRegexValue);
- return true;
- }
-
public:
- CommandObjectTypeFormatDelete (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "type format delete",
- "Delete an existing formatting style for a type.",
- NULL),
- m_options(interpreter)
+ CommandObjectTypeFormatterDelete (CommandInterpreter &interpreter,
+ uint32_t formatter_kind_mask,
+ const char* name,
+ const char* help) :
+ CommandObjectParsed (interpreter,
+ name,
+ help,
+ NULL),
+ m_options(interpreter),
+ m_formatter_kind_mask(formatter_kind_mask)
{
CommandArgumentEntry type_arg;
CommandArgumentData type_style_arg;
@@ -1009,13 +1004,17 @@ public:
}
- ~CommandObjectTypeFormatDelete ()
+ ~CommandObjectTypeFormatterDelete () override = default;
+
+protected:
+ virtual bool
+ FormatterSpecificDeletion (ConstString typeCS)
{
+ return false;
}
-protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
const size_t argc = command.GetArgumentCount();
@@ -1038,25 +1037,42 @@ protected:
if (m_options.m_delete_all)
{
- DataVisualization::Categories::LoopThrough(PerCategoryCallback, &typeCS);
+ DataVisualization::Categories::ForEach( [this, typeCS] (const lldb::TypeCategoryImplSP& category_sp) -> bool {
+ category_sp->Delete(typeCS, m_formatter_kind_mask);
+ return true;
+ });
result.SetStatus(eReturnStatusSuccessFinishNoResult);
return result.Succeeded();
}
- lldb::TypeCategoryImplSP category;
- DataVisualization::Categories::GetCategory(ConstString(m_options.m_category.c_str()), category);
+ bool delete_category = false;
+ bool extra_deletion = false;
- bool delete_category = category->Delete(typeCS,
- eFormatCategoryItemValue | eFormatCategoryItemRegexValue);
+ if (m_options.m_language != lldb::eLanguageTypeUnknown)
+ {
+ lldb::TypeCategoryImplSP category;
+ DataVisualization::Categories::GetCategory(m_options.m_language, category);
+ if (category)
+ delete_category = category->Delete(typeCS, m_formatter_kind_mask);
+ extra_deletion = FormatterSpecificDeletion(typeCS);
+ }
+ else
+ {
+ lldb::TypeCategoryImplSP category;
+ DataVisualization::Categories::GetCategory(ConstString(m_options.m_category.c_str()), category);
+ if (category)
+ delete_category = category->Delete(typeCS, m_formatter_kind_mask);
+ extra_deletion = FormatterSpecificDeletion(typeCS);
+ }
- if (delete_category)
+ if (delete_category || extra_deletion)
{
result.SetStatus(eReturnStatusSuccessFinishNoResult);
return result.Succeeded();
}
else
{
- result.AppendErrorWithFormat ("no custom format for %s.\n", typeA);
+ result.AppendErrorWithFormat ("no custom formatter for %s.\n", typeA);
result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -1066,18 +1082,15 @@ protected:
};
OptionDefinition
-CommandObjectTypeFormatDelete::CommandOptions::g_option_table[] =
+CommandObjectTypeFormatterDelete::CommandOptions::g_option_table[] =
{
{ LLDB_OPT_SET_1, false, "all", 'a', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Delete from every category."},
{ LLDB_OPT_SET_2, false, "category", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Delete from given category."},
+ { LLDB_OPT_SET_3, false, "language", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage, "Delete from given language's category."},
{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
};
-//-------------------------------------------------------------------------
-// CommandObjectTypeFormatClear
-//-------------------------------------------------------------------------
-
-class CommandObjectTypeFormatClear : public CommandObjectParsed
+class CommandObjectTypeFormatterClear : public CommandObjectParsed
{
private:
@@ -1090,11 +1103,10 @@ private:
{
}
- virtual
- ~CommandOptions (){}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -1113,13 +1125,13 @@ private:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_delete_all = false;
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -1129,50 +1141,52 @@ private:
static OptionDefinition g_option_table[];
// Instance variables to hold the values for command options.
-
bool m_delete_all;
- bool m_delete_named;
};
CommandOptions m_options;
-
- virtual Options *
- GetOptions ()
+ uint32_t m_formatter_kind_mask;
+
+ Options *
+ GetOptions () override
{
return &m_options;
}
- static bool
- PerCategoryCallback(void* param,
- const lldb::TypeCategoryImplSP& cate)
+public:
+ CommandObjectTypeFormatterClear (CommandInterpreter &interpreter,
+ uint32_t formatter_kind_mask,
+ const char* name,
+ const char* help) :
+ CommandObjectParsed (interpreter,
+ name,
+ help,
+ NULL),
+ m_options(interpreter),
+ m_formatter_kind_mask(formatter_kind_mask)
{
- cate->GetTypeFormatsContainer()->Clear();
- cate->GetRegexTypeFormatsContainer()->Clear();
- return true;
-
}
-public:
- CommandObjectTypeFormatClear (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "type format clear",
- "Delete all existing format styles.",
- NULL),
- m_options(interpreter)
+ ~CommandObjectTypeFormatterClear () override
{
}
- ~CommandObjectTypeFormatClear ()
+protected:
+ virtual void
+ FormatterSpecificDeletion ()
{
}
-protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
if (m_options.m_delete_all)
- DataVisualization::Categories::LoopThrough(PerCategoryCallback, NULL);
-
+ {
+ DataVisualization::Categories::ForEach( [this] (const TypeCategoryImplSP& category_sp) -> bool {
+ category_sp->Clear(m_formatter_kind_mask);
+ return true;
+ });
+ }
else
{
lldb::TypeCategoryImplSP category;
@@ -1183,10 +1197,14 @@ protected:
DataVisualization::Categories::GetCategory(cat_nameCS, category);
}
else
+ {
DataVisualization::Categories::GetCategory(ConstString(NULL), category);
- category->Clear(eFormatCategoryItemValue | eFormatCategoryItemRegexValue);
+ }
+ category->Clear(m_formatter_kind_mask);
}
+ FormatterSpecificDeletion();
+
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
}
@@ -1194,46 +1212,68 @@ protected:
};
OptionDefinition
-CommandObjectTypeFormatClear::CommandOptions::g_option_table[] =
+CommandObjectTypeFormatterClear::CommandOptions::g_option_table[] =
{
{ LLDB_OPT_SET_ALL, false, "all", 'a', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Clear every category."},
{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
};
//-------------------------------------------------------------------------
-// CommandObjectTypeFormatList
+// CommandObjectTypeFormatDelete
//-------------------------------------------------------------------------
-bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const lldb::TypeFormatImplSP& entry);
-bool CommandObjectTypeRXFormatList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const lldb::TypeFormatImplSP& entry);
+class CommandObjectTypeFormatDelete : public CommandObjectTypeFormatterDelete
+{
+public:
+ CommandObjectTypeFormatDelete (CommandInterpreter &interpreter) :
+ CommandObjectTypeFormatterDelete (interpreter,
+ eFormatCategoryItemValue | eFormatCategoryItemRegexValue,
+ "type format delete",
+ "Delete an existing formatting style for a type.")
+ {
+ }
+
+ ~CommandObjectTypeFormatDelete () override
+ {
+ }
+};
-class CommandObjectTypeFormatList;
+//-------------------------------------------------------------------------
+// CommandObjectTypeFormatClear
+//-------------------------------------------------------------------------
-struct CommandObjectTypeFormatList_LoopCallbackParam {
- CommandObjectTypeFormatList* self;
- CommandReturnObject* result;
- RegularExpression* regex;
- RegularExpression* cate_regex;
- CommandObjectTypeFormatList_LoopCallbackParam(CommandObjectTypeFormatList* S, CommandReturnObject* R,
- RegularExpression* X = NULL, RegularExpression* CX = NULL) : self(S), result(R), regex(X), cate_regex(CX) {}
+class CommandObjectTypeFormatClear : public CommandObjectTypeFormatterClear
+{
+public:
+ CommandObjectTypeFormatClear (CommandInterpreter &interpreter) :
+ CommandObjectTypeFormatterClear (interpreter,
+ eFormatCategoryItemValue | eFormatCategoryItemRegexValue,
+ "type format clear",
+ "Delete all existing format styles.")
+ {
+ }
};
-class CommandObjectTypeFormatList : public CommandObjectParsed
+template <typename FormatterType>
+class CommandObjectTypeFormatterList : public CommandObjectParsed
{
+ typedef typename FormatterType::SharedPointer FormatterSharedPointer;
+
class CommandOptions : public Options
{
public:
CommandOptions (CommandInterpreter &interpreter) :
- Options (interpreter)
+ Options (interpreter),
+ m_category_regex("",""),
+ m_category_language(lldb::eLanguageTypeUnknown, lldb::eLanguageTypeUnknown)
{
}
- virtual
- ~CommandOptions (){}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -1241,7 +1281,10 @@ class CommandObjectTypeFormatList : public CommandObjectParsed
switch (short_option)
{
case 'w':
- m_category_regex = std::string(option_arg);
+ m_category_regex.SetCurrentValue(option_arg);
+ break;
+ case 'l':
+ error = m_category_language.SetValueFromString(option_arg);
break;
default:
error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
@@ -1252,14 +1295,22 @@ class CommandObjectTypeFormatList : public CommandObjectParsed
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
- m_category_regex = "";
+ m_category_regex.Clear();
+ m_category_language.Clear();
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
+ static OptionDefinition g_option_table[] =
+ {
+ { LLDB_OPT_SET_1, false, "category-regex", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Only show categories matching this filter."},
+ { LLDB_OPT_SET_2, false, "language", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage, "Only show the category for a specific language."},
+ { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ };
+
return g_option_table;
}
@@ -1269,23 +1320,25 @@ class CommandObjectTypeFormatList : public CommandObjectParsed
// Instance variables to hold the values for command options.
- std::string m_category_regex;
-
+ OptionValueString m_category_regex;
+ OptionValueLanguage m_category_language;
};
CommandOptions m_options;
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
public:
- CommandObjectTypeFormatList (CommandInterpreter &interpreter) :
+ CommandObjectTypeFormatterList (CommandInterpreter &interpreter,
+ const char* name,
+ const char* help) :
CommandObjectParsed (interpreter,
- "type format list",
- "Show a list of current formatting styles.",
+ name,
+ help,
NULL),
m_options(interpreter)
{
@@ -1300,117 +1353,155 @@ public:
m_arguments.push_back (type_arg);
}
- ~CommandObjectTypeFormatList ()
+ ~CommandObjectTypeFormatterList () override
{
}
protected:
+ virtual void
+ FormatterSpecificList (CommandReturnObject &result)
+ {
+ }
+
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
const size_t argc = command.GetArgumentCount();
- CommandObjectTypeFormatList_LoopCallbackParam *param;
- RegularExpression* cate_regex =
- m_options.m_category_regex.empty() ? NULL :
- new RegularExpression(m_options.m_category_regex.c_str());
+ std::unique_ptr<RegularExpression> category_regex;
+ std::unique_ptr<RegularExpression> formatter_regex;
- if (argc == 1)
+ if (m_options.m_category_regex.OptionWasSet())
{
- RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0));
- regex->Compile(command.GetArgumentAtIndex(0));
- param = new CommandObjectTypeFormatList_LoopCallbackParam(this,&result,regex,cate_regex);
+ category_regex.reset(new RegularExpression());
+ if (!category_regex->Compile(m_options.m_category_regex.GetCurrentValue()))
+ {
+ result.AppendErrorWithFormat("syntax error in category regular expression '%s'", m_options.m_category_regex.GetCurrentValue());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
}
- else
- param = new CommandObjectTypeFormatList_LoopCallbackParam(this,&result,NULL,cate_regex);
-
- DataVisualization::Categories::LoopThrough(PerCategoryCallback,param);
- delete param;
-
- if (cate_regex)
- delete cate_regex;
- result.SetStatus(eReturnStatusSuccessFinishResult);
- return result.Succeeded();
- }
-
-private:
-
- static bool
- PerCategoryCallback(void* param_vp,
- const lldb::TypeCategoryImplSP& cate)
- {
-
- CommandObjectTypeFormatList_LoopCallbackParam* param =
- (CommandObjectTypeFormatList_LoopCallbackParam*)param_vp;
- CommandReturnObject* result = param->result;
-
- const char* cate_name = cate->GetName();
-
- // if the category is disabled or empty and there is no regex, just skip it
- if ((cate->IsEnabled() == false || cate->GetCount(eFormatCategoryItemValue | eFormatCategoryItemRegexValue) == 0) && param->cate_regex == NULL)
- return true;
-
- // if we have a regex and this category does not match it, just skip it
- if(param->cate_regex != NULL && strcmp(cate_name,param->cate_regex->GetText()) != 0 && param->cate_regex->Execute(cate_name) == false)
- return true;
-
- result->GetOutputStream().Printf("-----------------------\nCategory: %s (%s)\n-----------------------\n",
- cate_name,
- (cate->IsEnabled() ? "enabled" : "disabled"));
+ if (argc == 1)
+ {
+ const char* arg = command.GetArgumentAtIndex(1);
+ formatter_regex.reset(new RegularExpression());
+ if (!formatter_regex->Compile(arg))
+ {
+ result.AppendErrorWithFormat("syntax error in regular expression '%s'", arg);
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ }
- cate->GetTypeFormatsContainer()->LoopThrough(CommandObjectTypeFormatList_LoopCallback, param_vp);
+ auto category_closure = [&result, &formatter_regex] (const lldb::TypeCategoryImplSP& category) -> void {
+ result.GetOutputStream().Printf("-----------------------\nCategory: %s\n-----------------------\n", category->GetName());
+
+ typedef const std::shared_ptr<FormatterType> Bar;
+ typedef std::function<bool(ConstString,Bar)> Func1Type;
+ typedef std::function<bool(RegularExpressionSP,Bar)> Func2Type;
+
+ TypeCategoryImpl::ForEachCallbacks<FormatterType> foreach;
+ foreach.SetExact([&result, &formatter_regex] (ConstString name, const FormatterSharedPointer& format_sp) -> bool {
+ if (formatter_regex)
+ {
+ bool escape = true;
+ if (0 == strcmp(name.AsCString(), formatter_regex->GetText()))
+ {
+ escape = false;
+ }
+ else if (formatter_regex->Execute(name.AsCString()))
+ {
+ escape = false;
+ }
+
+ if (escape)
+ return true;
+ }
+
+ result.GetOutputStream().Printf ("%s: %s\n", name.AsCString(), format_sp->GetDescription().c_str());
+
+ return true;
+ });
+
+ foreach.SetWithRegex( [&result, &formatter_regex] (RegularExpressionSP regex_sp, const FormatterSharedPointer& format_sp) -> bool {
+ if (formatter_regex)
+ {
+ bool escape = true;
+ if (0 == strcmp(regex_sp->GetText(), formatter_regex->GetText()))
+ {
+ escape = false;
+ }
+ else if (formatter_regex->Execute(regex_sp->GetText()))
+ {
+ escape = false;
+ }
+
+ if (escape)
+ return true;
+ }
+
+ result.GetOutputStream().Printf ("%s: %s\n", regex_sp->GetText(), format_sp->GetDescription().c_str());
+
+ return true;
+ });
+
+ category->ForEach(foreach);
+ };
- if (cate->GetRegexTypeSummariesContainer()->GetCount() > 0)
+ if (m_options.m_category_language.OptionWasSet())
{
- result->GetOutputStream().Printf("Regex-based summaries (slower):\n");
- cate->GetRegexTypeFormatsContainer()->LoopThrough(CommandObjectTypeRXFormatList_LoopCallback, param_vp);
+ lldb::TypeCategoryImplSP category_sp;
+ DataVisualization::Categories::GetCategory(m_options.m_category_language.GetCurrentValue(), category_sp);
+ if (category_sp)
+ category_closure(category_sp);
}
- return true;
- }
-
-
- bool
- LoopCallback (const char* type,
- const lldb::TypeFormatImplSP& entry,
- RegularExpression* regex,
- CommandReturnObject *result)
- {
- if (regex == NULL || strcmp(type,regex->GetText()) == 0 || regex->Execute(type))
- result->GetOutputStream().Printf ("%s: %s\n", type, entry->GetDescription().c_str());
- return true;
+ else
+ {
+ DataVisualization::Categories::ForEach( [this, &command, &result, &category_regex, &formatter_regex, &category_closure] (const lldb::TypeCategoryImplSP& category) -> bool {
+ if (category_regex)
+ {
+ bool escape = true;
+ if (0 == strcmp(category->GetName(), category_regex->GetText()))
+ {
+ escape = false;
+ }
+ else if (category_regex->Execute(category->GetName()))
+ {
+ escape = false;
+ }
+
+ if (escape)
+ return true;
+ }
+
+ category_closure(category);
+
+ return true;
+ });
+
+ FormatterSpecificList(result);
+ }
+
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ return result.Succeeded();
}
-
- friend bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const lldb::TypeFormatImplSP& entry);
- friend bool CommandObjectTypeRXFormatList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const lldb::TypeFormatImplSP& entry);
-
};
-bool
-CommandObjectTypeFormatList_LoopCallback (
- void* pt2self,
- ConstString type,
- const lldb::TypeFormatImplSP& entry)
-{
- CommandObjectTypeFormatList_LoopCallbackParam* param = (CommandObjectTypeFormatList_LoopCallbackParam*)pt2self;
- return param->self->LoopCallback(type.AsCString(), entry, param->regex, param->result);
-}
-
-bool
-CommandObjectTypeRXFormatList_LoopCallback (
- void* pt2self,
- lldb::RegularExpressionSP regex,
- const lldb::TypeFormatImplSP& entry)
-{
- CommandObjectTypeFormatList_LoopCallbackParam* param = (CommandObjectTypeFormatList_LoopCallbackParam*)pt2self;
- return param->self->LoopCallback(regex->GetText(), entry, param->regex, param->result);
-}
+//-------------------------------------------------------------------------
+// CommandObjectTypeFormatList
+//-------------------------------------------------------------------------
-OptionDefinition
-CommandObjectTypeFormatList::CommandOptions::g_option_table[] =
+class CommandObjectTypeFormatList : public CommandObjectTypeFormatterList<TypeFormatImpl>
{
- { LLDB_OPT_SET_ALL, false, "category-regex", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Only show categories matching this filter."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+public:
+
+ CommandObjectTypeFormatList (CommandInterpreter &interpreter) :
+ CommandObjectTypeFormatterList(interpreter,
+ "type format list",
+ "Show a list of current formats.")
+ {
+ }
};
#ifndef LLDB_DISABLE_PYTHON
@@ -1438,6 +1529,9 @@ CommandObjectTypeSummaryAdd::CommandOptions::SetOptionValue (uint32_t option_idx
case 'e':
m_flags.SetDontShowChildren(false);
break;
+ case 'h':
+ m_flags.SetHideEmptyAggregates(true);
+ break;
case 'v':
m_flags.SetDontShowValue(true);
break;
@@ -1924,6 +2018,7 @@ CommandObjectTypeSummaryAdd::CommandOptions::g_option_table[] =
{ LLDB_OPT_SET_3, false, "python-function", 'F', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePythonFunction, "Give the name of a Python function to use for this type."},
{ LLDB_OPT_SET_3, false, "input-python", 'P', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Input Python code to use for this type manually."},
{ LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "expand", 'e', OptionParser::eNoArgument, NULL, NULL, 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, NULL, NULL, 0, eArgTypeNone, "Do not expand aggregate data types with no children."},
{ LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "name", 'n', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "A name for this summary string."},
{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
};
@@ -1933,194 +2028,113 @@ CommandObjectTypeSummaryAdd::CommandOptions::g_option_table[] =
// CommandObjectTypeSummaryDelete
//-------------------------------------------------------------------------
-class CommandObjectTypeSummaryDelete : public CommandObjectParsed
+class CommandObjectTypeSummaryDelete : public CommandObjectTypeFormatterDelete
{
-private:
- class CommandOptions : public Options
+public:
+ CommandObjectTypeSummaryDelete (CommandInterpreter &interpreter) :
+ CommandObjectTypeFormatterDelete (interpreter,
+ eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary,
+ "type summary delete",
+ "Delete an existing summary for a type.")
{
- public:
-
- CommandOptions (CommandInterpreter &interpreter) :
- Options (interpreter)
- {
- }
-
- virtual
- ~CommandOptions (){}
-
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
- {
- Error error;
- const int short_option = m_getopt_table[option_idx].val;
-
- switch (short_option)
- {
- case 'a':
- m_delete_all = true;
- break;
- case 'w':
- m_category = std::string(option_arg);
- break;
- default:
- error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
- break;
- }
-
- return error;
- }
-
- void
- OptionParsingStarting ()
- {
- m_delete_all = false;
- m_category = "default";
- }
-
- const OptionDefinition*
- GetDefinitions ()
- {
- return g_option_table;
- }
-
- // Options table: Required for subclasses of Options.
-
- static OptionDefinition g_option_table[];
-
- // Instance variables to hold the values for command options.
-
- bool m_delete_all;
- std::string m_category;
-
- };
-
- CommandOptions m_options;
+ }
- virtual Options *
- GetOptions ()
+ ~CommandObjectTypeSummaryDelete () override
{
- return &m_options;
}
- static bool
- PerCategoryCallback(void* param,
- const lldb::TypeCategoryImplSP& category_sp)
+protected:
+ bool
+ FormatterSpecificDeletion (ConstString typeCS) override
{
- ConstString *name = (ConstString*)param;
- category_sp->Delete(*name, eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary);
- return true;
+ if (m_options.m_language != lldb::eLanguageTypeUnknown)
+ return false;
+ return DataVisualization::NamedSummaryFormats::Delete(typeCS);
}
+};
+class CommandObjectTypeSummaryClear : public CommandObjectTypeFormatterClear
+{
public:
- CommandObjectTypeSummaryDelete (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "type summary delete",
- "Delete an existing summary style for a type.",
- NULL),
- m_options(interpreter)
+ CommandObjectTypeSummaryClear (CommandInterpreter &interpreter) :
+ CommandObjectTypeFormatterClear (interpreter,
+ eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary,
+ "type summary clear",
+ "Delete all existing summaries.")
{
- CommandArgumentEntry type_arg;
- CommandArgumentData type_style_arg;
-
- type_style_arg.arg_type = eArgTypeName;
- type_style_arg.arg_repetition = eArgRepeatPlain;
-
- type_arg.push_back (type_style_arg);
-
- m_arguments.push_back (type_arg);
-
}
- ~CommandObjectTypeSummaryDelete ()
+protected:
+ void
+ FormatterSpecificDeletion () override
+ {
+ DataVisualization::NamedSummaryFormats::Clear();
+ }
+};
+
+//-------------------------------------------------------------------------
+// CommandObjectTypeSummaryList
+//-------------------------------------------------------------------------
+
+class CommandObjectTypeSummaryList : public CommandObjectTypeFormatterList<TypeSummaryImpl>
+{
+public:
+
+ CommandObjectTypeSummaryList (CommandInterpreter &interpreter) :
+ CommandObjectTypeFormatterList(interpreter,
+ "type summary list",
+ "Show a list of current summaries.")
{
}
protected:
- bool
- DoExecute (Args& command, CommandReturnObject &result)
+ void
+ FormatterSpecificList (CommandReturnObject &result) override
{
- const size_t argc = command.GetArgumentCount();
-
- if (argc != 1)
- {
- result.AppendErrorWithFormat ("%s takes 1 arg.\n", m_cmd_name.c_str());
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
-
- const char* typeA = command.GetArgumentAtIndex(0);
- ConstString typeCS(typeA);
-
- if (!typeCS)
- {
- result.AppendError("empty typenames not allowed");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
-
- if (m_options.m_delete_all)
- {
- DataVisualization::Categories::LoopThrough(PerCategoryCallback, &typeCS);
- result.SetStatus(eReturnStatusSuccessFinishNoResult);
- return result.Succeeded();
- }
-
- lldb::TypeCategoryImplSP category;
- DataVisualization::Categories::GetCategory(ConstString(m_options.m_category.c_str()), category);
-
- bool delete_category = category->Delete(typeCS,
- eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary);
- bool delete_named = DataVisualization::NamedSummaryFormats::Delete(typeCS);
-
- if (delete_category || delete_named)
- {
- result.SetStatus(eReturnStatusSuccessFinishNoResult);
- return result.Succeeded();
- }
- else
+ if (DataVisualization::NamedSummaryFormats::GetCount() > 0)
{
- result.AppendErrorWithFormat ("no custom summary for %s.\n", typeA);
- result.SetStatus(eReturnStatusFailed);
- return false;
+ result.GetOutputStream().Printf("Named summaries:\n");
+ DataVisualization::NamedSummaryFormats::ForEach( [&result] (ConstString name, const TypeSummaryImplSP& summary_sp) -> bool {
+ result.GetOutputStream().Printf ("%s: %s\n", name.AsCString(), summary_sp->GetDescription().c_str());
+ return true;
+ });
}
-
}
};
-OptionDefinition
-CommandObjectTypeSummaryDelete::CommandOptions::g_option_table[] =
-{
- { LLDB_OPT_SET_1, false, "all", 'a', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Delete from every category."},
- { LLDB_OPT_SET_2, false, "category", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Delete from given category."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
-};
+//-------------------------------------------------------------------------
+// CommandObjectTypeCategoryDefine
+//-------------------------------------------------------------------------
-class CommandObjectTypeSummaryClear : public CommandObjectParsed
+class CommandObjectTypeCategoryDefine : public CommandObjectParsed
{
-private:
class CommandOptions : public Options
{
public:
CommandOptions (CommandInterpreter &interpreter) :
- Options (interpreter)
+ Options (interpreter),
+ m_define_enabled(false,false),
+ m_cate_language(eLanguageTypeUnknown,eLanguageTypeUnknown)
{
}
- virtual
- ~CommandOptions (){}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
- case 'a':
- m_delete_all = true;
+ case 'e':
+ m_define_enabled.SetValueFromString("true");
+ break;
+ case 'l':
+ error = m_cate_language.SetValueFromString(option_arg);
break;
default:
error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
@@ -2131,13 +2145,14 @@ private:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
- m_delete_all = false;
+ m_define_enabled.Clear();
+ m_cate_language.Clear();
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -2148,66 +2163,69 @@ private:
// Instance variables to hold the values for command options.
- bool m_delete_all;
- bool m_delete_named;
+ OptionValueBoolean m_define_enabled;
+ OptionValueLanguage m_cate_language;
+
+
};
CommandOptions m_options;
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
-
- static bool
- PerCategoryCallback(void* param,
- const lldb::TypeCategoryImplSP& cate)
- {
- cate->GetTypeSummariesContainer()->Clear();
- cate->GetRegexTypeSummariesContainer()->Clear();
- return true;
-
- }
-
+
public:
- CommandObjectTypeSummaryClear (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "type summary clear",
- "Delete all existing summary styles.",
- NULL),
- m_options(interpreter)
+ CommandObjectTypeCategoryDefine (CommandInterpreter &interpreter) :
+ CommandObjectParsed (interpreter,
+ "type category define",
+ "Define a new category as a source of formatters.",
+ NULL),
+ m_options(interpreter)
{
+ CommandArgumentEntry type_arg;
+ CommandArgumentData type_style_arg;
+
+ type_style_arg.arg_type = eArgTypeName;
+ type_style_arg.arg_repetition = eArgRepeatPlus;
+
+ type_arg.push_back (type_style_arg);
+
+ m_arguments.push_back (type_arg);
+
}
- ~CommandObjectTypeSummaryClear ()
+ ~CommandObjectTypeCategoryDefine () override
{
}
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
+ const size_t argc = command.GetArgumentCount();
- if (m_options.m_delete_all)
- DataVisualization::Categories::LoopThrough(PerCategoryCallback, NULL);
+ if (argc < 1)
+ {
+ result.AppendErrorWithFormat ("%s takes 1 or more args.\n", m_cmd_name.c_str());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
- else
- {
- lldb::TypeCategoryImplSP category;
- if (command.GetArgumentCount() > 0)
+ for (size_t i = 0; i < argc; i++)
+ {
+ const char* cateName = command.GetArgumentAtIndex(i);
+ TypeCategoryImplSP category_sp;
+ if (DataVisualization::Categories::GetCategory(ConstString(cateName), category_sp) && category_sp)
{
- const char* cat_name = command.GetArgumentAtIndex(0);
- ConstString cat_nameCS(cat_name);
- DataVisualization::Categories::GetCategory(cat_nameCS, category);
+ category_sp->AddLanguage(m_options.m_cate_language.GetCurrentValue());
+ if (m_options.m_define_enabled.GetCurrentValue())
+ DataVisualization::Categories::Enable(category_sp, TypeCategoryMap::Default);
}
- else
- DataVisualization::Categories::GetCategory(ConstString(NULL), category);
- category->Clear(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary);
}
- DataVisualization::NamedSummaryFormats::Clear();
-
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
}
@@ -2215,34 +2233,19 @@ protected:
};
OptionDefinition
-CommandObjectTypeSummaryClear::CommandOptions::g_option_table[] =
+CommandObjectTypeCategoryDefine::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "all", 'a', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Clear every category."},
+ { LLDB_OPT_SET_ALL, false, "enabled", 'e', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "If specified, this category will be created enabled."},
+ { LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage, "Specify the language that this category is supported for."},
{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
};
//-------------------------------------------------------------------------
-// CommandObjectTypeSummaryList
+// CommandObjectTypeCategoryEnable
//-------------------------------------------------------------------------
-bool CommandObjectTypeSummaryList_LoopCallback(void* pt2self, ConstString type, const StringSummaryFormat::SharedPointer& entry);
-bool CommandObjectTypeRXSummaryList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const StringSummaryFormat::SharedPointer& entry);
-
-class CommandObjectTypeSummaryList;
-
-struct CommandObjectTypeSummaryList_LoopCallbackParam {
- CommandObjectTypeSummaryList* self;
- CommandReturnObject* result;
- RegularExpression* regex;
- RegularExpression* cate_regex;
- CommandObjectTypeSummaryList_LoopCallbackParam(CommandObjectTypeSummaryList* S, CommandReturnObject* R,
- RegularExpression* X = NULL,
- RegularExpression* CX = NULL) : self(S), result(R), regex(X), cate_regex(CX) {}
-};
-
-class CommandObjectTypeSummaryList : public CommandObjectParsed
+class CommandObjectTypeCategoryEnable : public CommandObjectParsed
{
-
class CommandOptions : public Options
{
public:
@@ -2252,19 +2255,23 @@ class CommandObjectTypeSummaryList : public CommandObjectParsed
{
}
- virtual
- ~CommandOptions (){}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
- case 'w':
- m_category_regex = std::string(option_arg);
+ case 'l':
+ if (option_arg)
+ {
+ m_language = Language::GetLanguageTypeFromString(option_arg);
+ if (m_language == lldb::eLanguageTypeUnknown)
+ error.SetErrorStringWithFormat ("unrecognized language '%s'", option_arg);
+ }
break;
default:
error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
@@ -2275,13 +2282,13 @@ class CommandObjectTypeSummaryList : public CommandObjectParsed
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
- m_category_regex = "";
+ m_language = lldb::eLanguageTypeUnknown;
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -2292,176 +2299,25 @@ class CommandObjectTypeSummaryList : public CommandObjectParsed
// Instance variables to hold the values for command options.
- std::string m_category_regex;
+ lldb::LanguageType m_language;
};
CommandOptions m_options;
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
public:
- CommandObjectTypeSummaryList (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "type summary list",
- "Show a list of current summary styles.",
- NULL),
- m_options(interpreter)
- {
- CommandArgumentEntry type_arg;
- CommandArgumentData type_style_arg;
-
- type_style_arg.arg_type = eArgTypeName;
- type_style_arg.arg_repetition = eArgRepeatOptional;
-
- type_arg.push_back (type_style_arg);
-
- m_arguments.push_back (type_arg);
- }
-
- ~CommandObjectTypeSummaryList ()
- {
- }
-
-protected:
- bool
- DoExecute (Args& command, CommandReturnObject &result)
- {
- const size_t argc = command.GetArgumentCount();
-
- CommandObjectTypeSummaryList_LoopCallbackParam *param;
- RegularExpression* cate_regex =
- m_options.m_category_regex.empty() ? NULL :
- new RegularExpression(m_options.m_category_regex.c_str());
-
- if (argc == 1)
- {
- RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0));
- regex->Compile(command.GetArgumentAtIndex(0));
- param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result,regex,cate_regex);
- }
- else
- param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result,NULL,cate_regex);
-
- DataVisualization::Categories::LoopThrough(PerCategoryCallback,param);
- delete param;
-
- if (DataVisualization::NamedSummaryFormats::GetCount() > 0)
- {
- result.GetOutputStream().Printf("Named summaries:\n");
- if (argc == 1)
- {
- RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0));
- regex->Compile(command.GetArgumentAtIndex(0));
- param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result,regex);
- }
- else
- param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result);
- DataVisualization::NamedSummaryFormats::LoopThrough(CommandObjectTypeSummaryList_LoopCallback, param);
- delete param;
- }
-
- if (cate_regex)
- delete cate_regex;
-
- result.SetStatus(eReturnStatusSuccessFinishResult);
- return result.Succeeded();
- }
-
-private:
-
- static bool
- PerCategoryCallback(void* param_vp,
- const lldb::TypeCategoryImplSP& cate)
- {
-
- CommandObjectTypeSummaryList_LoopCallbackParam* param =
- (CommandObjectTypeSummaryList_LoopCallbackParam*)param_vp;
- CommandReturnObject* result = param->result;
-
- const char* cate_name = cate->GetName();
-
- // if the category is disabled or empty and there is no regex, just skip it
- if ((cate->IsEnabled() == false || cate->GetCount(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary) == 0) && param->cate_regex == NULL)
- return true;
-
- // if we have a regex and this category does not match it, just skip it
- if(param->cate_regex != NULL && strcmp(cate_name,param->cate_regex->GetText()) != 0 && param->cate_regex->Execute(cate_name) == false)
- return true;
-
- result->GetOutputStream().Printf("-----------------------\nCategory: %s (%s)\n-----------------------\n",
- cate_name,
- (cate->IsEnabled() ? "enabled" : "disabled"));
-
- cate->GetTypeSummariesContainer()->LoopThrough(CommandObjectTypeSummaryList_LoopCallback, param_vp);
-
- if (cate->GetRegexTypeSummariesContainer()->GetCount() > 0)
- {
- result->GetOutputStream().Printf("Regex-based summaries (slower):\n");
- cate->GetRegexTypeSummariesContainer()->LoopThrough(CommandObjectTypeRXSummaryList_LoopCallback, param_vp);
- }
- return true;
- }
-
-
- bool
- LoopCallback (const char* type,
- const lldb::TypeSummaryImplSP& entry,
- RegularExpression* regex,
- CommandReturnObject *result)
- {
- if (regex == NULL || strcmp(type,regex->GetText()) == 0 || regex->Execute(type))
- result->GetOutputStream().Printf ("%s: %s\n", type, entry->GetDescription().c_str());
- return true;
- }
-
- friend bool CommandObjectTypeSummaryList_LoopCallback(void* pt2self, ConstString type, const lldb::TypeSummaryImplSP& entry);
- friend bool CommandObjectTypeRXSummaryList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const lldb::TypeSummaryImplSP& entry);
-};
-
-bool
-CommandObjectTypeSummaryList_LoopCallback (
- void* pt2self,
- ConstString type,
- const lldb::TypeSummaryImplSP& entry)
-{
- CommandObjectTypeSummaryList_LoopCallbackParam* param = (CommandObjectTypeSummaryList_LoopCallbackParam*)pt2self;
- return param->self->LoopCallback(type.AsCString(), entry, param->regex, param->result);
-}
-
-bool
-CommandObjectTypeRXSummaryList_LoopCallback (
- void* pt2self,
- lldb::RegularExpressionSP regex,
- const lldb::TypeSummaryImplSP& entry)
-{
- CommandObjectTypeSummaryList_LoopCallbackParam* param = (CommandObjectTypeSummaryList_LoopCallbackParam*)pt2self;
- return param->self->LoopCallback(regex->GetText(), entry, param->regex, param->result);
-}
-
-OptionDefinition
-CommandObjectTypeSummaryList::CommandOptions::g_option_table[] =
-{
- { LLDB_OPT_SET_ALL, false, "category-regex", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Only show categories matching this filter."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectTypeCategoryEnable
-//-------------------------------------------------------------------------
-
-class CommandObjectTypeCategoryEnable : public CommandObjectParsed
-{
-public:
CommandObjectTypeCategoryEnable (CommandInterpreter &interpreter) :
CommandObjectParsed (interpreter,
"type category enable",
"Enable a category as a source of formatters.",
- NULL)
+ NULL),
+ m_options(interpreter)
{
CommandArgumentEntry type_arg;
CommandArgumentData type_style_arg;
@@ -2475,19 +2331,20 @@ public:
}
- ~CommandObjectTypeCategoryEnable ()
+ ~CommandObjectTypeCategoryEnable () override
{
}
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
const size_t argc = command.GetArgumentCount();
- if (argc < 1)
+ if (argc < 1 &&
+ m_options.m_language == lldb::eLanguageTypeUnknown)
{
- result.AppendErrorWithFormat ("%s takes 1 or more args.\n", m_cmd_name.c_str());
+ result.AppendErrorWithFormat ("%s takes arguments and/or a language", m_cmd_name.c_str());
result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -2496,7 +2353,7 @@ protected:
{
DataVisualization::Categories::EnableStar();
}
- else
+ else if (argc > 0)
{
for (int i = argc - 1; i >= 0; i--)
{
@@ -2521,12 +2378,22 @@ protected:
}
}
+ if (m_options.m_language != lldb::eLanguageTypeUnknown)
+ DataVisualization::Categories::Enable(m_options.m_language);
+
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
}
};
+OptionDefinition
+CommandObjectTypeCategoryEnable::CommandOptions::g_option_table[] =
+{
+ { LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage, "Enable the category for this language."},
+ { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+};
+
//-------------------------------------------------------------------------
// CommandObjectTypeCategoryDelete
//-------------------------------------------------------------------------
@@ -2552,13 +2419,13 @@ public:
}
- ~CommandObjectTypeCategoryDelete ()
+ ~CommandObjectTypeCategoryDelete () override
{
}
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
const size_t argc = command.GetArgumentCount();
@@ -2606,185 +2473,6 @@ protected:
class CommandObjectTypeCategoryDisable : public CommandObjectParsed
{
-public:
- CommandObjectTypeCategoryDisable (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "type category disable",
- "Disable a category as a source of formatters.",
- NULL)
- {
- CommandArgumentEntry type_arg;
- CommandArgumentData type_style_arg;
-
- type_style_arg.arg_type = eArgTypeName;
- type_style_arg.arg_repetition = eArgRepeatPlus;
-
- type_arg.push_back (type_style_arg);
-
- m_arguments.push_back (type_arg);
-
- }
-
- ~CommandObjectTypeCategoryDisable ()
- {
- }
-
-protected:
- bool
- DoExecute (Args& command, CommandReturnObject &result)
- {
- const size_t argc = command.GetArgumentCount();
-
- if (argc < 1)
- {
- result.AppendErrorWithFormat ("%s takes 1 or more args.\n", m_cmd_name.c_str());
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
-
- if (argc == 1 && strcmp(command.GetArgumentAtIndex(0),"*") == 0)
- {
- DataVisualization::Categories::DisableStar();
- }
- else
- {
- // the order is not relevant here
- for (int i = argc - 1; i >= 0; i--)
- {
- const char* typeA = command.GetArgumentAtIndex(i);
- ConstString typeCS(typeA);
-
- if (!typeCS)
- {
- result.AppendError("empty category name not allowed");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
- DataVisualization::Categories::Disable(typeCS);
- }
- }
-
- result.SetStatus(eReturnStatusSuccessFinishResult);
- return result.Succeeded();
- }
-
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectTypeCategoryList
-//-------------------------------------------------------------------------
-
-class CommandObjectTypeCategoryList : public CommandObjectParsed
-{
-private:
-
- struct CommandObjectTypeCategoryList_CallbackParam
- {
- CommandReturnObject* result;
- RegularExpression* regex;
-
- CommandObjectTypeCategoryList_CallbackParam(CommandReturnObject* res,
- RegularExpression* rex = NULL) :
- result(res),
- regex(rex)
- {
- }
-
- };
-
- static bool
- PerCategoryCallback(void* param_vp,
- const lldb::TypeCategoryImplSP& cate)
- {
- CommandObjectTypeCategoryList_CallbackParam* param =
- (CommandObjectTypeCategoryList_CallbackParam*)param_vp;
- CommandReturnObject* result = param->result;
- RegularExpression* regex = param->regex;
-
- const char* cate_name = cate->GetName();
-
- if (regex == NULL || strcmp(cate_name, regex->GetText()) == 0 || regex->Execute(cate_name))
- result->GetOutputStream().Printf("Category %s is%s enabled\n",
- cate_name,
- (cate->IsEnabled() ? "" : " not"));
- return true;
- }
-public:
- CommandObjectTypeCategoryList (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "type category list",
- "Provide a list of all existing categories.",
- NULL)
- {
- CommandArgumentEntry type_arg;
- CommandArgumentData type_style_arg;
-
- type_style_arg.arg_type = eArgTypeName;
- type_style_arg.arg_repetition = eArgRepeatOptional;
-
- type_arg.push_back (type_style_arg);
-
- m_arguments.push_back (type_arg);
- }
-
- ~CommandObjectTypeCategoryList ()
- {
- }
-
-protected:
- bool
- DoExecute (Args& command, CommandReturnObject &result)
- {
- const size_t argc = command.GetArgumentCount();
- RegularExpression* regex = NULL;
-
- if (argc == 0)
- ;
- else if (argc == 1)
- regex = new RegularExpression(command.GetArgumentAtIndex(0));
- else
- {
- result.AppendErrorWithFormat ("%s takes 0 or one arg.\n", m_cmd_name.c_str());
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
-
- CommandObjectTypeCategoryList_CallbackParam param(&result,
- regex);
-
- DataVisualization::Categories::LoopThrough(PerCategoryCallback, &param);
-
- if (regex)
- delete regex;
-
- result.SetStatus(eReturnStatusSuccessFinishResult);
- return result.Succeeded();
- }
-
-};
-
-//-------------------------------------------------------------------------
-// CommandObjectTypeFilterList
-//-------------------------------------------------------------------------
-
-bool CommandObjectTypeFilterList_LoopCallback(void* pt2self, ConstString type, const SyntheticChildren::SharedPointer& entry);
-bool CommandObjectTypeFilterRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticChildren::SharedPointer& entry);
-
-class CommandObjectTypeFilterList;
-
-struct CommandObjectTypeFilterList_LoopCallbackParam {
- CommandObjectTypeFilterList* self;
- CommandReturnObject* result;
- RegularExpression* regex;
- RegularExpression* cate_regex;
- CommandObjectTypeFilterList_LoopCallbackParam(CommandObjectTypeFilterList* S, CommandReturnObject* R,
- RegularExpression* X = NULL,
- RegularExpression* CX = NULL) : self(S), result(R), regex(X), cate_regex(CX) {}
-};
-
-class CommandObjectTypeFilterList : public CommandObjectParsed
-{
-
class CommandOptions : public Options
{
public:
@@ -2794,19 +2482,23 @@ class CommandObjectTypeFilterList : public CommandObjectParsed
{
}
- virtual
- ~CommandOptions (){}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
- case 'w':
- m_category_regex = std::string(option_arg);
+ case 'l':
+ if (option_arg)
+ {
+ m_language = Language::GetLanguageTypeFromString(option_arg);
+ if (m_language == lldb::eLanguageTypeUnknown)
+ error.SetErrorStringWithFormat ("unrecognized language '%s'", option_arg);
+ }
break;
default:
error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
@@ -2817,13 +2509,13 @@ class CommandObjectTypeFilterList : public CommandObjectParsed
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
- m_category_regex = "";
+ m_language = lldb::eLanguageTypeUnknown;
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -2834,23 +2526,23 @@ class CommandObjectTypeFilterList : public CommandObjectParsed
// Instance variables to hold the values for command options.
- std::string m_category_regex;
+ lldb::LanguageType m_language;
};
CommandOptions m_options;
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
-
+
public:
- CommandObjectTypeFilterList (CommandInterpreter &interpreter) :
+ CommandObjectTypeCategoryDisable (CommandInterpreter &interpreter) :
CommandObjectParsed (interpreter,
- "type filter list",
- "Show a list of current filters.",
+ "type category disable",
+ "Disable a category as a source of formatters.",
NULL),
m_options(interpreter)
{
@@ -2858,216 +2550,82 @@ public:
CommandArgumentData type_style_arg;
type_style_arg.arg_type = eArgTypeName;
- type_style_arg.arg_repetition = eArgRepeatOptional;
+ type_style_arg.arg_repetition = eArgRepeatPlus;
type_arg.push_back (type_style_arg);
m_arguments.push_back (type_arg);
+
}
- ~CommandObjectTypeFilterList ()
+ ~CommandObjectTypeCategoryDisable () override
{
}
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
const size_t argc = command.GetArgumentCount();
- CommandObjectTypeFilterList_LoopCallbackParam *param;
- RegularExpression* cate_regex =
- m_options.m_category_regex.empty() ? NULL :
- new RegularExpression(m_options.m_category_regex.c_str());
-
- if (argc == 1)
+ if (argc < 1 &&
+ m_options.m_language == lldb::eLanguageTypeUnknown)
{
- RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0));
- regex->Compile(command.GetArgumentAtIndex(0));
- param = new CommandObjectTypeFilterList_LoopCallbackParam(this,&result,regex,cate_regex);
+ result.AppendErrorWithFormat ("%s takes arguments and/or a language", m_cmd_name.c_str());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
}
- else
- param = new CommandObjectTypeFilterList_LoopCallbackParam(this,&result,NULL,cate_regex);
-
- DataVisualization::Categories::LoopThrough(PerCategoryCallback,param);
- delete param;
-
- if (cate_regex)
- delete cate_regex;
-
- result.SetStatus(eReturnStatusSuccessFinishResult);
- return result.Succeeded();
- }
-
-private:
-
- static bool
- PerCategoryCallback(void* param_vp,
- const lldb::TypeCategoryImplSP& cate)
- {
- const char* cate_name = cate->GetName();
-
- CommandObjectTypeFilterList_LoopCallbackParam* param =
- (CommandObjectTypeFilterList_LoopCallbackParam*)param_vp;
- CommandReturnObject* result = param->result;
-
- // if the category is disabled or empty and there is no regex, just skip it
- if ((cate->IsEnabled() == false || cate->GetCount(eFormatCategoryItemFilter | eFormatCategoryItemRegexFilter) == 0) && param->cate_regex == NULL)
- return true;
-
- // if we have a regex and this category does not match it, just skip it
- if(param->cate_regex != NULL && strcmp(cate_name,param->cate_regex->GetText()) != 0 && param->cate_regex->Execute(cate_name) == false)
- return true;
-
- result->GetOutputStream().Printf("-----------------------\nCategory: %s (%s)\n-----------------------\n",
- cate_name,
- (cate->IsEnabled() ? "enabled" : "disabled"));
-
- cate->GetTypeFiltersContainer()->LoopThrough(CommandObjectTypeFilterList_LoopCallback, param_vp);
-
- if (cate->GetRegexTypeFiltersContainer()->GetCount() > 0)
+ if (argc == 1 && strcmp(command.GetArgumentAtIndex(0),"*") == 0)
+ {
+ DataVisualization::Categories::DisableStar();
+ }
+ else if (argc > 0)
{
- result->GetOutputStream().Printf("Regex-based filters (slower):\n");
- cate->GetRegexTypeFiltersContainer()->LoopThrough(CommandObjectTypeFilterRXList_LoopCallback, param_vp);
+ // the order is not relevant here
+ for (int i = argc - 1; i >= 0; i--)
+ {
+ const char* typeA = command.GetArgumentAtIndex(i);
+ ConstString typeCS(typeA);
+
+ if (!typeCS)
+ {
+ result.AppendError("empty category name not allowed");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ DataVisualization::Categories::Disable(typeCS);
+ }
}
- return true;
- }
-
- bool
- LoopCallback (const char* type,
- const SyntheticChildren::SharedPointer& entry,
- RegularExpression* regex,
- CommandReturnObject *result)
- {
- if (regex == NULL || regex->Execute(type))
- result->GetOutputStream().Printf ("%s: %s\n", type, entry->GetDescription().c_str());
- return true;
+ if (m_options.m_language != lldb::eLanguageTypeUnknown)
+ DataVisualization::Categories::Disable(m_options.m_language);
+
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ return result.Succeeded();
}
- friend bool CommandObjectTypeFilterList_LoopCallback(void* pt2self, ConstString type, const SyntheticChildren::SharedPointer& entry);
- friend bool CommandObjectTypeFilterRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticChildren::SharedPointer& entry);
};
-bool
-CommandObjectTypeFilterList_LoopCallback (void* pt2self,
- ConstString type,
- const SyntheticChildren::SharedPointer& entry)
-{
- CommandObjectTypeFilterList_LoopCallbackParam* param = (CommandObjectTypeFilterList_LoopCallbackParam*)pt2self;
- return param->self->LoopCallback(type.AsCString(), entry, param->regex, param->result);
-}
-
-bool
-CommandObjectTypeFilterRXList_LoopCallback (void* pt2self,
- lldb::RegularExpressionSP regex,
- const SyntheticChildren::SharedPointer& entry)
-{
- CommandObjectTypeFilterList_LoopCallbackParam* param = (CommandObjectTypeFilterList_LoopCallbackParam*)pt2self;
- return param->self->LoopCallback(regex->GetText(), entry, param->regex, param->result);
-}
-
-
OptionDefinition
-CommandObjectTypeFilterList::CommandOptions::g_option_table[] =
+CommandObjectTypeCategoryDisable::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "category-regex", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Only show categories matching this filter."},
+ { LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage, "Enable the category for this language."},
{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
};
-#ifndef LLDB_DISABLE_PYTHON
-
//-------------------------------------------------------------------------
-// CommandObjectTypeSynthList
+// CommandObjectTypeCategoryList
//-------------------------------------------------------------------------
-bool CommandObjectTypeSynthList_LoopCallback(void* pt2self, ConstString type, const SyntheticChildren::SharedPointer& entry);
-bool CommandObjectTypeSynthRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticChildren::SharedPointer& entry);
-
-class CommandObjectTypeSynthList;
-
-struct CommandObjectTypeSynthList_LoopCallbackParam {
- CommandObjectTypeSynthList* self;
- CommandReturnObject* result;
- RegularExpression* regex;
- RegularExpression* cate_regex;
- CommandObjectTypeSynthList_LoopCallbackParam(CommandObjectTypeSynthList* S, CommandReturnObject* R,
- RegularExpression* X = NULL,
- RegularExpression* CX = NULL) : self(S), result(R), regex(X), cate_regex(CX) {}
-};
-
-class CommandObjectTypeSynthList : public CommandObjectParsed
+class CommandObjectTypeCategoryList : public CommandObjectParsed
{
-
- class CommandOptions : public Options
- {
- public:
-
- CommandOptions (CommandInterpreter &interpreter) :
- Options (interpreter)
- {
- }
-
- virtual
- ~CommandOptions (){}
-
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
- {
- Error error;
- const int short_option = m_getopt_table[option_idx].val;
-
- switch (short_option)
- {
- case 'w':
- m_category_regex = std::string(option_arg);
- break;
- default:
- error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
- break;
- }
-
- return error;
- }
-
- void
- OptionParsingStarting ()
- {
- m_category_regex = "";
- }
-
- const OptionDefinition*
- GetDefinitions ()
- {
- return g_option_table;
- }
-
- // Options table: Required for subclasses of Options.
-
- static OptionDefinition g_option_table[];
-
- // Instance variables to hold the values for command options.
-
- std::string m_category_regex;
-
- };
-
- CommandOptions m_options;
-
- virtual Options *
- GetOptions ()
- {
- return &m_options;
- }
-
public:
- CommandObjectTypeSynthList (CommandInterpreter &interpreter) :
+ CommandObjectTypeCategoryList (CommandInterpreter &interpreter) :
CommandObjectParsed (interpreter,
- "type synthetic list",
- "Show a list of current synthetic providers.",
- NULL),
- m_options(interpreter)
+ "type category list",
+ "Provide a list of all existing categories.",
+ NULL)
{
CommandArgumentEntry type_arg;
CommandArgumentData type_style_arg;
@@ -3080,115 +2638,96 @@ public:
m_arguments.push_back (type_arg);
}
- ~CommandObjectTypeSynthList ()
+ ~CommandObjectTypeCategoryList () override
{
}
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
const size_t argc = command.GetArgumentCount();
-
- CommandObjectTypeSynthList_LoopCallbackParam *param;
- RegularExpression* cate_regex =
- m_options.m_category_regex.empty() ? NULL :
- new RegularExpression(m_options.m_category_regex.c_str());
+
+ std::unique_ptr<RegularExpression> regex;
if (argc == 1)
{
- RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0));
- regex->Compile(command.GetArgumentAtIndex(0));
- param = new CommandObjectTypeSynthList_LoopCallbackParam(this,&result,regex,cate_regex);
+ regex.reset(new RegularExpression());
+ const char* arg = command.GetArgumentAtIndex(0);
+ if (!regex->Compile(arg))
+ {
+ result.AppendErrorWithFormat("syntax error in category regular expression '%s'", arg);
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ }
+ else if (argc != 0)
+ {
+ result.AppendErrorWithFormat ("%s takes 0 or one arg.\n", m_cmd_name.c_str());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
}
- else
- param = new CommandObjectTypeSynthList_LoopCallbackParam(this,&result,NULL,cate_regex);
- DataVisualization::Categories::LoopThrough(PerCategoryCallback,param);
- delete param;
-
- if (cate_regex)
- delete cate_regex;
+ DataVisualization::Categories::ForEach( [&regex, &result] (const lldb::TypeCategoryImplSP& category_sp) -> bool {
+ if (regex)
+ {
+ bool escape = true;
+ if (0 == strcmp(category_sp->GetName(), regex->GetText()))
+ {
+ escape = false;
+ }
+ else if (regex->Execute(category_sp->GetName()))
+ {
+ escape = false;
+ }
+
+ if (escape)
+ return true;
+ }
+
+ result.GetOutputStream().Printf("Category: %s\n", category_sp->GetDescription().c_str());
+
+ return true;
+ });
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
}
-private:
-
- static bool
- PerCategoryCallback(void* param_vp,
- const lldb::TypeCategoryImplSP& cate)
- {
-
- CommandObjectTypeSynthList_LoopCallbackParam* param =
- (CommandObjectTypeSynthList_LoopCallbackParam*)param_vp;
- CommandReturnObject* result = param->result;
-
- const char* cate_name = cate->GetName();
-
- // if the category is disabled or empty and there is no regex, just skip it
- if ((cate->IsEnabled() == false || cate->GetCount(eFormatCategoryItemSynth | eFormatCategoryItemRegexSynth) == 0) && param->cate_regex == NULL)
- return true;
-
- // if we have a regex and this category does not match it, just skip it
- if(param->cate_regex != NULL && strcmp(cate_name,param->cate_regex->GetText()) != 0 && param->cate_regex->Execute(cate_name) == false)
- return true;
-
- result->GetOutputStream().Printf("-----------------------\nCategory: %s (%s)\n-----------------------\n",
- cate_name,
- (cate->IsEnabled() ? "enabled" : "disabled"));
-
- cate->GetTypeSyntheticsContainer()->LoopThrough(CommandObjectTypeSynthList_LoopCallback, param_vp);
-
- if (cate->GetRegexTypeSyntheticsContainer()->GetCount() > 0)
- {
- result->GetOutputStream().Printf("Regex-based synthetic providers (slower):\n");
- cate->GetRegexTypeSyntheticsContainer()->LoopThrough(CommandObjectTypeSynthRXList_LoopCallback, param_vp);
- }
-
- return true;
- }
+};
+
+//-------------------------------------------------------------------------
+// CommandObjectTypeFilterList
+//-------------------------------------------------------------------------
+
+class CommandObjectTypeFilterList : public CommandObjectTypeFormatterList<TypeFilterImpl>
+{
+public:
- bool
- LoopCallback (const char* type,
- const SyntheticChildren::SharedPointer& entry,
- RegularExpression* regex,
- CommandReturnObject *result)
+ CommandObjectTypeFilterList (CommandInterpreter &interpreter) :
+ CommandObjectTypeFormatterList(interpreter,
+ "type filter list",
+ "Show a list of current filters.")
{
- if (regex == NULL || regex->Execute(type))
- result->GetOutputStream().Printf ("%s: %s\n", type, entry->GetDescription().c_str());
- return true;
}
-
- friend bool CommandObjectTypeSynthList_LoopCallback(void* pt2self, ConstString type, const SyntheticChildren::SharedPointer& entry);
- friend bool CommandObjectTypeSynthRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticChildren::SharedPointer& entry);
};
-bool
-CommandObjectTypeSynthList_LoopCallback (void* pt2self,
- ConstString type,
- const SyntheticChildren::SharedPointer& entry)
-{
- CommandObjectTypeSynthList_LoopCallbackParam* param = (CommandObjectTypeSynthList_LoopCallbackParam*)pt2self;
- return param->self->LoopCallback(type.AsCString(), entry, param->regex, param->result);
-}
-
-bool
-CommandObjectTypeSynthRXList_LoopCallback (void* pt2self,
- lldb::RegularExpressionSP regex,
- const SyntheticChildren::SharedPointer& entry)
-{
- CommandObjectTypeSynthList_LoopCallbackParam* param = (CommandObjectTypeSynthList_LoopCallbackParam*)pt2self;
- return param->self->LoopCallback(regex->GetText(), entry, param->regex, param->result);
-}
+#ifndef LLDB_DISABLE_PYTHON
+//-------------------------------------------------------------------------
+// CommandObjectTypeSynthList
+//-------------------------------------------------------------------------
-OptionDefinition
-CommandObjectTypeSynthList::CommandOptions::g_option_table[] =
+class CommandObjectTypeSynthList : public CommandObjectTypeFormatterList<SyntheticChildren>
{
- { LLDB_OPT_SET_ALL, false, "category-regex", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Only show categories matching this filter."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+public:
+
+ CommandObjectTypeSynthList (CommandInterpreter &interpreter) :
+ CommandObjectTypeFormatterList(interpreter,
+ "type synthetic list",
+ "Show a list of current synthetic providers.")
+ {
+ }
};
#endif // #ifndef LLDB_DISABLE_PYTHON
@@ -3196,164 +2735,20 @@ CommandObjectTypeSynthList::CommandOptions::g_option_table[] =
// CommandObjectTypeFilterDelete
//-------------------------------------------------------------------------
-class CommandObjectTypeFilterDelete : public CommandObjectParsed
+class CommandObjectTypeFilterDelete : public CommandObjectTypeFormatterDelete
{
-private:
- class CommandOptions : public Options
- {
- public:
-
- CommandOptions (CommandInterpreter &interpreter) :
- Options (interpreter)
- {
- }
-
- virtual
- ~CommandOptions (){}
-
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
- {
- Error error;
- const int short_option = m_getopt_table[option_idx].val;
-
- switch (short_option)
- {
- case 'a':
- m_delete_all = true;
- break;
- case 'w':
- m_category = std::string(option_arg);
- break;
- default:
- error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
- break;
- }
-
- return error;
- }
-
- void
- OptionParsingStarting ()
- {
- m_delete_all = false;
- m_category = "default";
- }
-
- const OptionDefinition*
- GetDefinitions ()
- {
- return g_option_table;
- }
-
- // Options table: Required for subclasses of Options.
-
- static OptionDefinition g_option_table[];
-
- // Instance variables to hold the values for command options.
-
- bool m_delete_all;
- std::string m_category;
-
- };
-
- CommandOptions m_options;
-
- virtual Options *
- GetOptions ()
- {
- return &m_options;
- }
-
- static bool
- PerCategoryCallback(void* param,
- const lldb::TypeCategoryImplSP& cate)
- {
- ConstString *name = (ConstString*)param;
- return cate->Delete(*name, eFormatCategoryItemFilter | eFormatCategoryItemRegexFilter);
- }
-
public:
CommandObjectTypeFilterDelete (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "type filter delete",
- "Delete an existing filter for a type.",
- NULL),
- m_options(interpreter)
+ CommandObjectTypeFormatterDelete (interpreter,
+ eFormatCategoryItemFilter | eFormatCategoryItemRegexFilter,
+ "type filter delete",
+ "Delete an existing filter for a type.")
{
- CommandArgumentEntry type_arg;
- CommandArgumentData type_style_arg;
-
- type_style_arg.arg_type = eArgTypeName;
- type_style_arg.arg_repetition = eArgRepeatPlain;
-
- type_arg.push_back (type_style_arg);
-
- m_arguments.push_back (type_arg);
-
}
- ~CommandObjectTypeFilterDelete ()
+ ~CommandObjectTypeFilterDelete () override
{
}
-
-protected:
- bool
- DoExecute (Args& command, CommandReturnObject &result)
- {
- const size_t argc = command.GetArgumentCount();
-
- if (argc != 1)
- {
- result.AppendErrorWithFormat ("%s takes 1 arg.\n", m_cmd_name.c_str());
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
-
- const char* typeA = command.GetArgumentAtIndex(0);
- ConstString typeCS(typeA);
-
- if (!typeCS)
- {
- result.AppendError("empty typenames not allowed");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
-
- if (m_options.m_delete_all)
- {
- DataVisualization::Categories::LoopThrough(PerCategoryCallback, (void*)&typeCS);
- result.SetStatus(eReturnStatusSuccessFinishNoResult);
- return result.Succeeded();
- }
-
- lldb::TypeCategoryImplSP category;
- DataVisualization::Categories::GetCategory(ConstString(m_options.m_category.c_str()), category);
-
- bool delete_category = category->GetTypeFiltersContainer()->Delete(typeCS);
- delete_category = category->GetRegexTypeFiltersContainer()->Delete(typeCS) || delete_category;
-
- if (delete_category)
- {
- result.SetStatus(eReturnStatusSuccessFinishNoResult);
- return result.Succeeded();
- }
- else
- {
- result.AppendErrorWithFormat ("no custom synthetic provider for %s.\n", typeA);
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
-
- }
-};
-
-OptionDefinition
-CommandObjectTypeFilterDelete::CommandOptions::g_option_table[] =
-{
- { LLDB_OPT_SET_1, false, "all", 'a', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Delete from every category."},
- { LLDB_OPT_SET_2, false, "category", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Delete from given category."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
};
#ifndef LLDB_DISABLE_PYTHON
@@ -3362,164 +2757,20 @@ CommandObjectTypeFilterDelete::CommandOptions::g_option_table[] =
// CommandObjectTypeSynthDelete
//-------------------------------------------------------------------------
-class CommandObjectTypeSynthDelete : public CommandObjectParsed
+class CommandObjectTypeSynthDelete : public CommandObjectTypeFormatterDelete
{
-private:
- class CommandOptions : public Options
- {
- public:
-
- CommandOptions (CommandInterpreter &interpreter) :
- Options (interpreter)
- {
- }
-
- virtual
- ~CommandOptions (){}
-
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
- {
- Error error;
- const int short_option = m_getopt_table[option_idx].val;
-
- switch (short_option)
- {
- case 'a':
- m_delete_all = true;
- break;
- case 'w':
- m_category = std::string(option_arg);
- break;
- default:
- error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
- break;
- }
-
- return error;
- }
-
- void
- OptionParsingStarting ()
- {
- m_delete_all = false;
- m_category = "default";
- }
-
- const OptionDefinition*
- GetDefinitions ()
- {
- return g_option_table;
- }
-
- // Options table: Required for subclasses of Options.
-
- static OptionDefinition g_option_table[];
-
- // Instance variables to hold the values for command options.
-
- bool m_delete_all;
- std::string m_category;
-
- };
-
- CommandOptions m_options;
-
- virtual Options *
- GetOptions ()
- {
- return &m_options;
- }
-
- static bool
- PerCategoryCallback(void* param,
- const lldb::TypeCategoryImplSP& cate)
- {
- ConstString* name = (ConstString*)param;
- return cate->Delete(*name, eFormatCategoryItemSynth | eFormatCategoryItemRegexSynth);
- }
-
public:
CommandObjectTypeSynthDelete (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "type synthetic delete",
- "Delete an existing synthetic provider for a type.",
- NULL),
- m_options(interpreter)
+ CommandObjectTypeFormatterDelete (interpreter,
+ eFormatCategoryItemSynth | eFormatCategoryItemRegexSynth,
+ "type synthetic delete",
+ "Delete an existing synthetic provider for a type.")
{
- CommandArgumentEntry type_arg;
- CommandArgumentData type_style_arg;
-
- type_style_arg.arg_type = eArgTypeName;
- type_style_arg.arg_repetition = eArgRepeatPlain;
-
- type_arg.push_back (type_style_arg);
-
- m_arguments.push_back (type_arg);
-
}
- ~CommandObjectTypeSynthDelete ()
+ ~CommandObjectTypeSynthDelete () override
{
}
-
-protected:
- bool
- DoExecute (Args& command, CommandReturnObject &result)
- {
- const size_t argc = command.GetArgumentCount();
-
- if (argc != 1)
- {
- result.AppendErrorWithFormat ("%s takes 1 arg.\n", m_cmd_name.c_str());
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
-
- const char* typeA = command.GetArgumentAtIndex(0);
- ConstString typeCS(typeA);
-
- if (!typeCS)
- {
- result.AppendError("empty typenames not allowed");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
-
- if (m_options.m_delete_all)
- {
- DataVisualization::Categories::LoopThrough(PerCategoryCallback, (void*)&typeCS);
- result.SetStatus(eReturnStatusSuccessFinishNoResult);
- return result.Succeeded();
- }
-
- lldb::TypeCategoryImplSP category;
- DataVisualization::Categories::GetCategory(ConstString(m_options.m_category.c_str()), category);
-
- bool delete_category = category->GetTypeSyntheticsContainer()->Delete(typeCS);
- delete_category = category->GetRegexTypeSyntheticsContainer()->Delete(typeCS) || delete_category;
-
- if (delete_category)
- {
- result.SetStatus(eReturnStatusSuccessFinishNoResult);
- return result.Succeeded();
- }
- else
- {
- result.AppendErrorWithFormat ("no custom synthetic provider for %s.\n", typeA);
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
-
- }
-};
-
-OptionDefinition
-CommandObjectTypeSynthDelete::CommandOptions::g_option_table[] =
-{
- { LLDB_OPT_SET_1, false, "all", 'a', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Delete from every category."},
- { LLDB_OPT_SET_2, false, "category", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Delete from given category."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
};
#endif // #ifndef LLDB_DISABLE_PYTHON
@@ -3528,128 +2779,16 @@ CommandObjectTypeSynthDelete::CommandOptions::g_option_table[] =
// CommandObjectTypeFilterClear
//-------------------------------------------------------------------------
-class CommandObjectTypeFilterClear : public CommandObjectParsed
+class CommandObjectTypeFilterClear : public CommandObjectTypeFormatterClear
{
-private:
-
- class CommandOptions : public Options
- {
- public:
-
- CommandOptions (CommandInterpreter &interpreter) :
- Options (interpreter)
- {
- }
-
- virtual
- ~CommandOptions (){}
-
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
- {
- Error error;
- const int short_option = m_getopt_table[option_idx].val;
-
- switch (short_option)
- {
- case 'a':
- m_delete_all = true;
- break;
- default:
- error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
- break;
- }
-
- return error;
- }
-
- void
- OptionParsingStarting ()
- {
- m_delete_all = false;
- }
-
- const OptionDefinition*
- GetDefinitions ()
- {
- return g_option_table;
- }
-
- // Options table: Required for subclasses of Options.
-
- static OptionDefinition g_option_table[];
-
- // Instance variables to hold the values for command options.
-
- bool m_delete_all;
- bool m_delete_named;
- };
-
- CommandOptions m_options;
-
- virtual Options *
- GetOptions ()
- {
- return &m_options;
- }
-
- static bool
- PerCategoryCallback(void* param,
- const lldb::TypeCategoryImplSP& cate)
- {
- cate->Clear(eFormatCategoryItemFilter | eFormatCategoryItemRegexFilter);
- return true;
-
- }
-
public:
CommandObjectTypeFilterClear (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "type filter clear",
- "Delete all existing filters.",
- NULL),
- m_options(interpreter)
+ CommandObjectTypeFormatterClear (interpreter,
+ eFormatCategoryItemFilter | eFormatCategoryItemRegexFilter,
+ "type filter clear",
+ "Delete all existing filter.")
{
}
-
- ~CommandObjectTypeFilterClear ()
- {
- }
-
-protected:
- bool
- DoExecute (Args& command, CommandReturnObject &result)
- {
-
- if (m_options.m_delete_all)
- DataVisualization::Categories::LoopThrough(PerCategoryCallback, NULL);
-
- else
- {
- lldb::TypeCategoryImplSP category;
- if (command.GetArgumentCount() > 0)
- {
- const char* cat_name = command.GetArgumentAtIndex(0);
- ConstString cat_nameCS(cat_name);
- DataVisualization::Categories::GetCategory(cat_nameCS, category);
- }
- else
- DataVisualization::Categories::GetCategory(ConstString(NULL), category);
- category->GetTypeFiltersContainer()->Clear();
- category->GetRegexTypeFiltersContainer()->Clear();
- }
-
- result.SetStatus(eReturnStatusSuccessFinishResult);
- return result.Succeeded();
- }
-
-};
-
-OptionDefinition
-CommandObjectTypeFilterClear::CommandOptions::g_option_table[] =
-{
- { LLDB_OPT_SET_ALL, false, "all", 'a', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Clear every category."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
};
#ifndef LLDB_DISABLE_PYTHON
@@ -3657,131 +2796,18 @@ CommandObjectTypeFilterClear::CommandOptions::g_option_table[] =
// CommandObjectTypeSynthClear
//-------------------------------------------------------------------------
-class CommandObjectTypeSynthClear : public CommandObjectParsed
+class CommandObjectTypeSynthClear : public CommandObjectTypeFormatterClear
{
-private:
-
- class CommandOptions : public Options
- {
- public:
-
- CommandOptions (CommandInterpreter &interpreter) :
- Options (interpreter)
- {
- }
-
- virtual
- ~CommandOptions (){}
-
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
- {
- Error error;
- const int short_option = m_getopt_table[option_idx].val;
-
- switch (short_option)
- {
- case 'a':
- m_delete_all = true;
- break;
- default:
- error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
- break;
- }
-
- return error;
- }
-
- void
- OptionParsingStarting ()
- {
- m_delete_all = false;
- }
-
- const OptionDefinition*
- GetDefinitions ()
- {
- return g_option_table;
- }
-
- // Options table: Required for subclasses of Options.
-
- static OptionDefinition g_option_table[];
-
- // Instance variables to hold the values for command options.
-
- bool m_delete_all;
- bool m_delete_named;
- };
-
- CommandOptions m_options;
-
- virtual Options *
- GetOptions ()
- {
- return &m_options;
- }
-
- static bool
- PerCategoryCallback(void* param,
- const lldb::TypeCategoryImplSP& cate)
- {
- cate->Clear(eFormatCategoryItemSynth | eFormatCategoryItemRegexSynth);
- return true;
-
- }
-
public:
CommandObjectTypeSynthClear (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "type synthetic clear",
- "Delete all existing synthetic providers.",
- NULL),
- m_options(interpreter)
+ CommandObjectTypeFormatterClear (interpreter,
+ eFormatCategoryItemSynth | eFormatCategoryItemRegexSynth,
+ "type synthetic clear",
+ "Delete all existing synthetic providers.")
{
}
-
- ~CommandObjectTypeSynthClear ()
- {
- }
-
-protected:
- bool
- DoExecute (Args& command, CommandReturnObject &result)
- {
-
- if (m_options.m_delete_all)
- DataVisualization::Categories::LoopThrough(PerCategoryCallback, NULL);
-
- else
- {
- lldb::TypeCategoryImplSP category;
- if (command.GetArgumentCount() > 0)
- {
- const char* cat_name = command.GetArgumentAtIndex(0);
- ConstString cat_nameCS(cat_name);
- DataVisualization::Categories::GetCategory(cat_nameCS, category);
- }
- else
- DataVisualization::Categories::GetCategory(ConstString(NULL), category);
- category->GetTypeSyntheticsContainer()->Clear();
- category->GetRegexTypeSyntheticsContainer()->Clear();
- }
-
- result.SetStatus(eReturnStatusSuccessFinishResult);
- return result.Succeeded();
- }
-
};
-OptionDefinition
-CommandObjectTypeSynthClear::CommandOptions::g_option_table[] =
-{
- { LLDB_OPT_SET_ALL, false, "all", 'a', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Clear every category."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
-};
-
-
bool
CommandObjectTypeSynthAdd::Execute_HandwritePython (Args& command, CommandReturnObject &result)
{
@@ -3956,10 +2982,10 @@ CommandObjectTypeSynthAdd::CommandOptions::g_option_table[] =
{
{ LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "If true, cascade through typedef chains."},
{ LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects."},
- { LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Don't use this format for references-to-tNULL, ype objects."},
+ { LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Don't use this format for references-to-type objects."},
{ LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Add this to the given category instead of the default one."},
{ LLDB_OPT_SET_2, false, "python-class", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePythonClass, "Use this Python class to produce synthetic children."},
- { LLDB_OPT_SET_3, false, "input-python", 'P', OptionParser::eNoArgument,NULL, NULL, 0, eArgTypeNone, "Type Python code to generate a class that NULL, provides synthetic children."},
+ { LLDB_OPT_SET_3, false, "input-python", 'P', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Type Python code to generate a class that provides synthetic children."},
{ LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Type names are actually regular expressions."},
{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
};
@@ -3981,11 +3007,10 @@ private:
{
}
- virtual
- ~CommandOptions (){}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -4023,7 +3048,7 @@ private:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_cascade = true;
m_skip_pointers = false;
@@ -4035,7 +3060,7 @@ private:
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -4062,8 +3087,8 @@ private:
CommandOptions m_options;
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -4076,7 +3101,7 @@ private:
bool
AddFilter(ConstString type_name,
- SyntheticChildrenSP entry,
+ TypeFilterImplSP entry,
FilterFormatType type,
std::string category_name,
Error* error)
@@ -4175,13 +3200,13 @@ all children of my_foo as if no filter was defined:" R"(
);
}
- ~CommandObjectTypeFilterAdd ()
+ ~CommandObjectTypeFilterAdd () override
{
}
protected:
bool
- DoExecute (Args& command, CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result) override
{
const size_t argc = command.GetArgumentCount();
@@ -4199,19 +3224,15 @@ protected:
return false;
}
- SyntheticChildrenSP entry;
-
- TypeFilterImpl* impl = new TypeFilterImpl(SyntheticChildren::Flags().SetCascades(m_options.m_cascade).
- SetSkipPointers(m_options.m_skip_pointers).
- SetSkipReferences(m_options.m_skip_references));
-
- entry.reset(impl);
+ TypeFilterImplSP entry(new TypeFilterImpl(SyntheticChildren::Flags().SetCascades(m_options.m_cascade).
+ SetSkipPointers(m_options.m_skip_pointers).
+ SetSkipReferences(m_options.m_skip_references)));
// go through the expression paths
CommandOptions::ExpressionPathsIterator begin, end = m_options.m_expr_paths.end();
for (begin = m_options.m_expr_paths.begin(); begin != end; begin++)
- impl->AddExpressionPath(*begin);
+ entry->AddExpressionPath(*begin);
// now I have a valid provider, let's add it to every type
@@ -4266,6 +3287,215 @@ CommandObjectTypeFilterAdd::CommandOptions::g_option_table[] =
{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
};
+//----------------------------------------------------------------------
+// "type lookup"
+//----------------------------------------------------------------------
+class CommandObjectTypeLookup : public CommandObjectRaw
+{
+protected:
+
+ class CommandOptions : public OptionGroup
+ {
+ public:
+
+ CommandOptions () :
+ OptionGroup(),
+ m_show_help(false),
+ m_language(eLanguageTypeUnknown)
+ {}
+
+ ~CommandOptions () override {}
+
+ uint32_t
+ GetNumDefinitions () override
+ {
+ return 3;
+ }
+
+ const OptionDefinition*
+ GetDefinitions () override
+ {
+ return g_option_table;
+ }
+
+ Error
+ SetOptionValue (CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_value) override
+ {
+ Error error;
+
+ const int short_option = g_option_table[option_idx].short_option;
+
+ switch (short_option)
+ {
+ case 'h':
+ m_show_help = true;
+ break;
+
+ case 'l':
+ m_language = Language::GetLanguageTypeFromString(option_value);
+ break;
+
+ default:
+ error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
+ break;
+ }
+
+ return error;
+ }
+
+ void
+ OptionParsingStarting (CommandInterpreter &interpreter) override
+ {
+ m_show_help = false;
+ m_language = eLanguageTypeUnknown;
+ }
+
+ // Options table: Required for subclasses of Options.
+
+ static OptionDefinition g_option_table[];
+ bool m_show_help;
+ lldb::LanguageType m_language;
+ };
+
+ OptionGroupOptions m_option_group;
+ CommandOptions m_command_options;
+
+public:
+
+ CommandObjectTypeLookup (CommandInterpreter &interpreter) :
+ CommandObjectRaw (interpreter,
+ "type lookup",
+ "Lookup a type by name in the select target.",
+ "type lookup <typename>",
+ eCommandRequiresTarget),
+ m_option_group(interpreter),
+ m_command_options()
+ {
+ m_option_group.Append(&m_command_options);
+ m_option_group.Finalize();
+ }
+
+ ~CommandObjectTypeLookup () override
+ {
+ }
+
+ Options *
+ GetOptions () override
+ {
+ return &m_option_group;
+ }
+
+ bool
+ DoExecute (const char *raw_command_line, CommandReturnObject &result) override
+ {
+ if (!raw_command_line || !raw_command_line[0])
+ {
+ result.SetError("type lookup cannot be invoked without a type name as argument");
+ return false;
+ }
+
+ m_option_group.NotifyOptionParsingStarting();
+
+ const char * name_of_type = NULL;
+
+ if (raw_command_line[0] == '-')
+ {
+ // We have some options and these options MUST end with --.
+ const char *end_options = NULL;
+ const char *s = raw_command_line;
+ while (s && s[0])
+ {
+ end_options = ::strstr (s, "--");
+ if (end_options)
+ {
+ end_options += 2; // Get past the "--"
+ if (::isspace (end_options[0]))
+ {
+ name_of_type = end_options;
+ while (::isspace (*name_of_type))
+ ++name_of_type;
+ break;
+ }
+ }
+ s = end_options;
+ }
+
+ if (end_options)
+ {
+ Args args (llvm::StringRef(raw_command_line, end_options - raw_command_line));
+ if (!ParseOptions (args, result))
+ return false;
+
+ Error error (m_option_group.NotifyOptionParsingFinished());
+ if (error.Fail())
+ {
+ result.AppendError (error.AsCString());
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ }
+ }
+ if (nullptr == name_of_type)
+ name_of_type = raw_command_line;
+
+ 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;
+
+ std::vector<Language*> languages;
+
+ if (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));
+ }
+ else
+ {
+ languages.push_back(Language::FindPlugin(m_command_options.m_language));
+ }
+
+ for (Language* language : languages)
+ {
+ if (!language)
+ continue;
+
+ if (auto scavenger = language->GetTypeScavenger())
+ {
+ Language::TypeScavenger::ResultSet search_results;
+ if (scavenger->Find(best_scope, name_of_type, search_results) > 0)
+ {
+ for (const auto& search_result : search_results)
+ {
+ if (search_result && search_result->IsValid())
+ {
+ any_found = true;
+ search_result->DumpToStream(result.GetOutputStream(), this->m_command_options.m_show_help);
+ }
+ }
+ }
+ }
+ }
+
+ result.SetStatus (any_found ? lldb::eReturnStatusSuccessFinishResult : lldb::eReturnStatusSuccessFinishNoResult);
+ return true;
+ }
+
+};
+
+OptionDefinition
+CommandObjectTypeLookup::CommandOptions::g_option_table[] =
+{
+ { LLDB_OPT_SET_ALL, false, "show-help", 'h', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Display available help for types"},
+ { LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage, "Which language's types should the search scope be"},
+ { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+};
+
template <typename FormatterType>
class CommandObjectFormatterInfo : public CommandObjectRaw
{
@@ -4293,14 +3523,13 @@ public:
SetSyntax(syntax.GetData());
}
- virtual
- ~CommandObjectFormatterInfo ()
+ ~CommandObjectFormatterInfo () override
{
}
protected:
- virtual bool
- DoExecute (const char *command, CommandReturnObject &result)
+ bool
+ DoExecute (const char *command, CommandReturnObject &result) override
{
auto target_sp = m_interpreter.GetDebugger().GetSelectedTarget();
auto frame_sp = target_sp->GetProcessSP()->GetThreadList().GetSelectedThread()->GetSelectedFrame();
@@ -4365,7 +3594,7 @@ public:
}
- ~CommandObjectTypeFormat ()
+ ~CommandObjectTypeFormat () override
{
}
};
@@ -4393,7 +3622,7 @@ public:
}
- ~CommandObjectTypeSynth ()
+ ~CommandObjectTypeSynth () override
{
}
};
@@ -4416,7 +3645,7 @@ public:
}
- ~CommandObjectTypeFilter ()
+ ~CommandObjectTypeFilter () override
{
}
};
@@ -4430,6 +3659,7 @@ public:
"A set of commands for operating on categories",
"type category [<sub-command-options>] ")
{
+ LoadSubCommand ("define", CommandObjectSP (new CommandObjectTypeCategoryDefine (interpreter)));
LoadSubCommand ("enable", CommandObjectSP (new CommandObjectTypeCategoryEnable (interpreter)));
LoadSubCommand ("disable", CommandObjectSP (new CommandObjectTypeCategoryDisable (interpreter)));
LoadSubCommand ("delete", CommandObjectSP (new CommandObjectTypeCategoryDelete (interpreter)));
@@ -4437,7 +3667,7 @@ public:
}
- ~CommandObjectTypeCategory ()
+ ~CommandObjectTypeCategory () override
{
}
};
@@ -4463,7 +3693,7 @@ public:
}
- ~CommandObjectTypeSummary ()
+ ~CommandObjectTypeSummary () override
{
}
};
@@ -4485,11 +3715,10 @@ CommandObjectType::CommandObjectType (CommandInterpreter &interpreter) :
#ifndef LLDB_DISABLE_PYTHON
LoadSubCommand ("synthetic", CommandObjectSP (new CommandObjectTypeSynth (interpreter)));
#endif
+ LoadSubCommand ("lookup", CommandObjectSP (new CommandObjectTypeLookup (interpreter)));
}
CommandObjectType::~CommandObjectType ()
{
}
-
-
diff --git a/source/Commands/CommandObjectType.h b/source/Commands/CommandObjectType.h
index c796902cf3bd..54f4a33c6f65 100644
--- a/source/Commands/CommandObjectType.h
+++ b/source/Commands/CommandObjectType.h
@@ -13,7 +13,6 @@
// C Includes
// C++ Includes
-
// Other libraries and framework includes
// Project includes
@@ -28,10 +27,9 @@ class CommandObjectType : public CommandObjectMultiword
public:
CommandObjectType (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectType ();
+ ~CommandObjectType() override;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectType_h_
+#endif // liblldb_CommandObjectType_h_
diff --git a/source/Commands/CommandObjectVersion.h b/source/Commands/CommandObjectVersion.h
index 1fdbed60c65d..30ba9d1235d9 100644
--- a/source/Commands/CommandObjectVersion.h
+++ b/source/Commands/CommandObjectVersion.h
@@ -28,16 +28,14 @@ public:
CommandObjectVersion (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectVersion ();
+ ~CommandObjectVersion() override;
protected:
- virtual bool
- DoExecute (Args& args,
- CommandReturnObject &result);
-
+ bool
+ DoExecute(Args& args,
+ CommandReturnObject &result) override;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectVersion_h_
+#endif // liblldb_CommandObjectVersion_h_
diff --git a/source/Commands/CommandObjectWatchpoint.cpp b/source/Commands/CommandObjectWatchpoint.cpp
index 414e78403cc8..a97f5ade6460 100644
--- a/source/Commands/CommandObjectWatchpoint.cpp
+++ b/source/Commands/CommandObjectWatchpoint.cpp
@@ -104,7 +104,7 @@ CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(Target *target, Args &args
std::pair<llvm::StringRef, llvm::StringRef> Pair;
size_t i;
int32_t idx;
- // Go through the argments and make a canonical form of arg list containing
+ // Go through the arguments and make a canonical form of arg list containing
// only numbers with possible "-" in between.
for (i = 0; i < args.GetArgumentCount(); ++i) {
llvm::StringRef Arg(args.GetArgumentAtIndex(i));
@@ -178,11 +178,10 @@ public:
m_arguments.push_back(arg);
}
- virtual
- ~CommandObjectWatchpointList () {}
+ ~CommandObjectWatchpointList () override {}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -197,11 +196,10 @@ public:
{
}
- virtual
- ~CommandOptions () {}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -226,13 +224,13 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_level = lldb::eDescriptionLevelFull;
}
const OptionDefinition *
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -248,8 +246,8 @@ public:
};
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (target == NULL)
@@ -361,13 +359,12 @@ public:
m_arguments.push_back(arg);
}
- virtual
- ~CommandObjectWatchpointEnable () {}
+ ~CommandObjectWatchpointEnable () override {}
protected:
- virtual bool
+ bool
DoExecute (Args& command,
- CommandReturnObject &result)
+ CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (!CheckTargetForWatchpointOperations(target, result))
@@ -441,12 +438,11 @@ public:
}
- virtual
- ~CommandObjectWatchpointDisable () {}
+ ~CommandObjectWatchpointDisable () override {}
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (!CheckTargetForWatchpointOperations(target, result))
@@ -524,12 +520,11 @@ public:
m_arguments.push_back(arg);
}
- virtual
- ~CommandObjectWatchpointDelete () {}
+ ~CommandObjectWatchpointDelete () override {}
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (!CheckTargetForWatchpointOperations(target, result))
@@ -607,11 +602,10 @@ public:
m_arguments.push_back(arg);
}
- virtual
- ~CommandObjectWatchpointIgnore () {}
+ ~CommandObjectWatchpointIgnore () override {}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -626,11 +620,10 @@ public:
{
}
- virtual
- ~CommandOptions () {}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -653,13 +646,13 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_ignore_count = 0;
}
const OptionDefinition *
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -675,9 +668,9 @@ public:
};
protected:
- virtual bool
+ bool
DoExecute (Args& command,
- CommandReturnObject &result)
+ CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (!CheckTargetForWatchpointOperations(target, result))
@@ -763,11 +756,10 @@ public:
m_arguments.push_back (arg);
}
- virtual
- ~CommandObjectWatchpointModify () {}
+ ~CommandObjectWatchpointModify () override {}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
@@ -783,11 +775,10 @@ public:
{
}
- virtual
- ~CommandOptions () {}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -810,14 +801,14 @@ public:
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_condition.clear();
m_condition_passed = false;
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -833,8 +824,8 @@ public:
};
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (!CheckTargetForWatchpointOperations(target, result))
@@ -958,11 +949,10 @@ corresponding to the byte size of the data type."
m_option_group.Finalize();
}
- virtual
- ~CommandObjectWatchpointSetVariable () {}
+ ~CommandObjectWatchpointSetVariable () override {}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_option_group;
}
@@ -983,8 +973,8 @@ protected:
return 0;
}
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
StackFrame *frame = m_exe_ctx.GetFramePtr();
@@ -1048,7 +1038,7 @@ protected:
valobj_sp = valobj_list.GetValueObjectAtIndex(0);
}
- ClangASTType clang_type;
+ CompilerType compiler_type;
if (valobj_sp)
{
@@ -1061,7 +1051,7 @@ protected:
size = m_option_watchpoint.watch_size == 0 ? valobj_sp->GetByteSize()
: m_option_watchpoint.watch_size;
}
- clang_type = valobj_sp->GetClangType();
+ compiler_type = valobj_sp->GetCompilerType();
}
else
{
@@ -1078,7 +1068,7 @@ protected:
uint32_t watch_type = m_option_watchpoint.watch_type;
error.Clear();
- Watchpoint *wp = target->CreateWatchpoint(addr, size, &clang_type, watch_type, error).get();
+ Watchpoint *wp = target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error).get();
if (wp)
{
wp->SetWatchSpec(command.GetArgumentAtIndex(0));
@@ -1169,22 +1159,21 @@ Examples:
}
- virtual
- ~CommandObjectWatchpointSetExpression () {}
+ ~CommandObjectWatchpointSetExpression () override {}
// Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
- virtual bool
- WantsCompletion() { return true; }
+ bool
+ WantsCompletion() override { return true; }
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_option_group;
}
protected:
- virtual bool
- DoExecute (const char *raw_command, CommandReturnObject &result)
+ bool
+ DoExecute (const char *raw_command, CommandReturnObject &result) override
{
m_option_group.NotifyOptionParsingStarting(); // This is a raw command, so notify the option group
@@ -1295,10 +1284,10 @@ protected:
// Fetch the type from the value object, the type of the watched object is the pointee type
/// of the expression, so convert to that if we found a valid type.
- ClangASTType clang_type(valobj_sp->GetClangType());
+ CompilerType compiler_type(valobj_sp->GetCompilerType());
Error error;
- Watchpoint *wp = target->CreateWatchpoint(addr, size, &clang_type, watch_type, error).get();
+ Watchpoint *wp = target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error).get();
if (wp)
{
Stream &output_stream = result.GetOutputStream();
@@ -1345,8 +1334,7 @@ public:
}
- virtual
- ~CommandObjectWatchpointSet () {}
+ ~CommandObjectWatchpointSet () override {}
};
diff --git a/source/Commands/CommandObjectWatchpoint.h b/source/Commands/CommandObjectWatchpoint.h
index 1b1ebd7764a3..b1926dc2ad7d 100644
--- a/source/Commands/CommandObjectWatchpoint.h
+++ b/source/Commands/CommandObjectWatchpoint.h
@@ -30,14 +30,12 @@ class CommandObjectMultiwordWatchpoint : public CommandObjectMultiword
public:
CommandObjectMultiwordWatchpoint (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectMultiwordWatchpoint ();
+ ~CommandObjectMultiwordWatchpoint() override;
static bool
VerifyWatchpointIDs(Target *target, Args &args, std::vector<uint32_t> &wp_ids);
-
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectWatchpoint_h_
+#endif // liblldb_CommandObjectWatchpoint_h_
diff --git a/source/Commands/CommandObjectWatchpointCommand.cpp b/source/Commands/CommandObjectWatchpointCommand.cpp
index 84342cc8ffdf..2fa849f97674 100644
--- a/source/Commands/CommandObjectWatchpointCommand.cpp
+++ b/source/Commands/CommandObjectWatchpointCommand.cpp
@@ -169,17 +169,16 @@ are no syntax errors may indicate that a function was declared but never called.
m_arguments.push_back (arg);
}
- virtual
- ~CommandObjectWatchpointCommandAdd () {}
+ ~CommandObjectWatchpointCommandAdd () override {}
- virtual Options *
- GetOptions ()
+ Options *
+ GetOptions () override
{
return &m_options;
}
- virtual void
- IOHandlerActivated (IOHandler &io_handler)
+ void
+ IOHandlerActivated (IOHandler &io_handler) override
{
StreamFileSP output_sp(io_handler.GetOutputStreamFile());
if (output_sp)
@@ -190,8 +189,8 @@ are no syntax errors may indicate that a function was declared but never called.
}
- virtual void
- IOHandlerInputComplete (IOHandler &io_handler, std::string &line)
+ void
+ IOHandlerInputComplete (IOHandler &io_handler, std::string &line) override
{
io_handler.SetIsDone(true);
@@ -301,11 +300,10 @@ are no syntax errors may indicate that a function was declared but never called.
{
}
- virtual
- ~CommandOptions () {}
+ ~CommandOptions () override {}
- virtual Error
- SetOptionValue (uint32_t option_idx, const char *option_arg)
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -356,7 +354,7 @@ are no syntax errors may indicate that a function was declared but never called.
return error;
}
void
- OptionParsingStarting ()
+ OptionParsingStarting () override
{
m_use_commands = true;
m_use_script_language = false;
@@ -369,7 +367,7 @@ are no syntax errors may indicate that a function was declared but never called.
}
const OptionDefinition*
- GetDefinitions ()
+ GetDefinitions () override
{
return g_option_table;
}
@@ -392,8 +390,8 @@ are no syntax errors may indicate that a function was declared but never called.
};
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
@@ -550,12 +548,11 @@ public:
}
- virtual
- ~CommandObjectWatchpointCommandDelete () {}
+ ~CommandObjectWatchpointCommandDelete () override {}
protected:
- virtual bool
- DoExecute (Args& command, CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
@@ -641,13 +638,11 @@ public:
m_arguments.push_back (arg);
}
- virtual
- ~CommandObjectWatchpointCommandList () {}
+ ~CommandObjectWatchpointCommandList () override {}
protected:
- virtual bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ bool
+ DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
diff --git a/source/Commands/CommandObjectWatchpointCommand.h b/source/Commands/CommandObjectWatchpointCommand.h
index 3bc9b3537db7..d77b32a2fd4d 100644
--- a/source/Commands/CommandObjectWatchpointCommand.h
+++ b/source/Commands/CommandObjectWatchpointCommand.h
@@ -13,7 +13,6 @@
// C Includes
// C++ Includes
-
// Other libraries and framework includes
// Project includes
@@ -33,11 +32,9 @@ class CommandObjectWatchpointCommand : public CommandObjectMultiword
public:
CommandObjectWatchpointCommand (CommandInterpreter &interpreter);
- virtual
- ~CommandObjectWatchpointCommand ();
-
+ ~CommandObjectWatchpointCommand() override;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectWatchpointCommand_h_
+#endif // liblldb_CommandObjectWatchpointCommand_h_
diff --git a/source/Core/Address.cpp b/source/Core/Address.cpp
index 1cd7a7447b7f..83100dea93bc 100644
--- a/source/Core/Address.cpp
+++ b/source/Core/Address.cpp
@@ -179,7 +179,7 @@ ReadCStringFromMemory (ExecutionContextScope *exe_scope, const Address &address,
buf[k_buf_len] = '\0'; // NULL terminate
// Byte order and address size don't matter for C string dumping..
- DataExtractor data (buf, sizeof(buf), lldb::endian::InlHostByteOrder(), 4);
+ DataExtractor data (buf, sizeof(buf), endian::InlHostByteOrder(), 4);
size_t total_len = 0;
size_t bytes_read;
Address curr_address(address);
@@ -367,21 +367,29 @@ Address::SetCallableLoadAddress (lldb::addr_t load_addr, Target *target)
}
addr_t
-Address::GetOpcodeLoadAddress (Target *target) const
+Address::GetOpcodeLoadAddress (Target *target, AddressClass addr_class) const
{
addr_t code_addr = GetLoadAddress (target);
if (code_addr != LLDB_INVALID_ADDRESS)
- code_addr = target->GetOpcodeLoadAddress (code_addr, GetAddressClass());
+ {
+ if (addr_class == eAddressClassInvalid)
+ addr_class = GetAddressClass();
+ code_addr = target->GetOpcodeLoadAddress (code_addr, addr_class);
+ }
return code_addr;
}
bool
-Address::SetOpcodeLoadAddress (lldb::addr_t load_addr, Target *target)
+Address::SetOpcodeLoadAddress (lldb::addr_t load_addr, Target *target, AddressClass addr_class)
{
if (SetLoadAddress (load_addr, target))
{
if (target)
- m_offset = target->GetOpcodeLoadAddress (m_offset, GetAddressClass());
+ {
+ if (addr_class == eAddressClassInvalid)
+ addr_class = GetAddressClass();
+ m_offset = target->GetOpcodeLoadAddress (m_offset, addr_class);
+ }
return true;
}
return false;
@@ -455,6 +463,20 @@ Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, Dum
case DumpStyleLoadAddress:
{
addr_t load_addr = GetLoadAddress (target);
+
+ /*
+ * MIPS:
+ * Display address in compressed form for MIPS16 or microMIPS
+ * if the address belongs to eAddressClassCodeAlternateISA.
+ */
+ if (target)
+ {
+ const llvm::Triple::ArchType llvm_arch = target->GetArchitecture().GetMachine();
+ if (llvm_arch == llvm::Triple::mips || llvm_arch == llvm::Triple::mipsel
+ || llvm_arch == llvm::Triple::mips64 || llvm_arch == llvm::Triple::mips64el)
+ load_addr = GetCallableLoadAddress (target);
+ }
+
if (load_addr == LLDB_INVALID_ADDRESS)
{
if (fallback_style != DumpStyleInvalid)
diff --git a/source/Core/AddressResolverName.cpp b/source/Core/AddressResolverName.cpp
index 1c6205fa6bdf..293002ad517f 100644
--- a/source/Core/AddressResolverName.cpp
+++ b/source/Core/AddressResolverName.cpp
@@ -13,7 +13,6 @@
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamString.h"
-#include "lldb/Symbol/ClangNamespaceDecl.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/Symbol.h"
diff --git a/source/Core/ArchSpec.cpp b/source/Core/ArchSpec.cpp
index 2dc001a9047f..ffe717f29c43 100644
--- a/source/Core/ArchSpec.cpp
+++ b/source/Core/ArchSpec.cpp
@@ -419,8 +419,8 @@ ArchSpec::ArchSpec() :
m_triple (),
m_core (kCore_invalid),
m_byte_order (eByteOrderInvalid),
- m_distribution_id (),
- m_flags (0)
+ m_flags (0),
+ m_distribution_id ()
{
}
@@ -428,8 +428,8 @@ ArchSpec::ArchSpec (const char *triple_cstr, Platform *platform) :
m_triple (),
m_core (kCore_invalid),
m_byte_order (eByteOrderInvalid),
- m_distribution_id (),
- m_flags (0)
+ m_flags (0),
+ m_distribution_id ()
{
if (triple_cstr)
SetTriple(triple_cstr, platform);
@@ -440,8 +440,8 @@ ArchSpec::ArchSpec (const char *triple_cstr) :
m_triple (),
m_core (kCore_invalid),
m_byte_order (eByteOrderInvalid),
- m_distribution_id (),
- m_flags (0)
+ m_flags (0),
+ m_distribution_id ()
{
if (triple_cstr)
SetTriple(triple_cstr);
@@ -451,8 +451,8 @@ ArchSpec::ArchSpec(const llvm::Triple &triple) :
m_triple (),
m_core (kCore_invalid),
m_byte_order (eByteOrderInvalid),
- m_distribution_id (),
- m_flags (0)
+ m_flags (0),
+ m_distribution_id ()
{
SetTriple(triple);
}
@@ -461,8 +461,8 @@ ArchSpec::ArchSpec (ArchitectureType arch_type, uint32_t cpu, uint32_t subtype)
m_triple (),
m_core (kCore_invalid),
m_byte_order (eByteOrderInvalid),
- m_distribution_id (),
- m_flags (0)
+ m_flags (0),
+ m_distribution_id ()
{
SetArchitecture (arch_type, cpu, subtype);
}
@@ -602,7 +602,15 @@ ArchSpec::GetAddressByteSize() const
{
const CoreDefinition *core_def = FindCoreDefinition (m_core);
if (core_def)
- return core_def->addr_byte_size;
+ {
+ if (core_def->machine == llvm::Triple::mips64 || core_def->machine == llvm::Triple::mips64el)
+ {
+ // For N32/O32 applications Address size is 4 bytes.
+ if (m_flags & (eMIPSABI_N32 | eMIPSABI_O32))
+ return 4;
+ }
+ return core_def->addr_byte_size;
+ }
return 0;
}
@@ -836,14 +844,17 @@ ArchSpec::SetTriple (const char *triple_cstr, Platform *platform)
void
ArchSpec::MergeFrom(const ArchSpec &other)
{
- if (GetTriple().getVendor() == llvm::Triple::UnknownVendor && !TripleVendorWasSpecified())
+ if (TripleVendorIsUnspecifiedUnknown() && !other.TripleVendorIsUnspecifiedUnknown())
GetTriple().setVendor(other.GetTriple().getVendor());
- if (GetTriple().getOS() == llvm::Triple::UnknownOS && !TripleOSWasSpecified())
+ if (TripleOSIsUnspecifiedUnknown() && !other.TripleOSIsUnspecifiedUnknown())
GetTriple().setOS(other.GetTriple().getOS());
if (GetTriple().getArch() == llvm::Triple::UnknownArch)
GetTriple().setArch(other.GetTriple().getArch());
- if (GetTriple().getEnvironment() == llvm::Triple::UnknownEnvironment)
- GetTriple().setEnvironment(other.GetTriple().getEnvironment());
+ if (GetTriple().getEnvironment() == llvm::Triple::UnknownEnvironment && !TripleVendorWasSpecified())
+ {
+ if (other.TripleVendorWasSpecified())
+ GetTriple().setEnvironment(other.GetTriple().getEnvironment());
+ }
}
bool
@@ -868,29 +879,14 @@ ArchSpec::SetArchitecture (ArchitectureType arch_type, uint32_t cpu, uint32_t su
if (arch_type == eArchTypeMachO)
{
m_triple.setVendor (llvm::Triple::Apple);
- switch (core_def->machine)
- {
- case llvm::Triple::aarch64:
- case llvm::Triple::arm:
- case llvm::Triple::thumb:
- m_triple.setOS (llvm::Triple::IOS);
- break;
-
- case llvm::Triple::x86:
- case llvm::Triple::x86_64:
- // Don't set the OS for x86_64 or for x86 as we want to leave it as an "unspecified unknown"
- // which means if we ask for the OS from the llvm::Triple we get back llvm::Triple::UnknownOS, but
- // if we ask for the string value for the OS it will come back empty (unspecified).
- // We do this because we now have iOS and MacOSX as the OS values for x86 and x86_64 for
- // normal desktop and simulator binaries. And if we compare a "x86_64-apple-ios" to a "x86_64-apple-"
- // triple, it will say it is compatible (because the OS is unspecified in the second one and will match
- // anything in the first
- break;
-
- default:
- m_triple.setOS (llvm::Triple::MacOSX);
- break;
- }
+
+ // Don't set the OS. It could be simulator, macosx, ios, watchos, tvos. 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)
{
@@ -904,6 +900,11 @@ ArchSpec::SetArchitecture (ArchitectureType arch_type, uint32_t cpu, uint32_t su
case llvm::ELF::ELFOSABI_SOLARIS: m_triple.setOS (llvm::Triple::OSType::Solaris); break;
}
}
+ else
+ {
+ m_triple.setVendor (llvm::Triple::UnknownVendor);
+ m_triple.setOS (llvm::Triple::UnknownOS);
+ }
// Fall back onto setting the machine type if the arch by name failed...
if (m_triple.getArch () == llvm::Triple::UnknownArch)
m_triple.setArch (core_def->machine);
@@ -966,15 +967,12 @@ ArchSpec::IsEqualTo (const ArchSpec& rhs, bool exact_match) const
const llvm::Triple::VendorType rhs_triple_vendor = rhs_triple.getVendor();
if (lhs_triple_vendor != rhs_triple_vendor)
{
- if (exact_match)
- {
- const bool rhs_vendor_specified = rhs.TripleVendorWasSpecified();
- const bool lhs_vendor_specified = TripleVendorWasSpecified();
- // Both architectures had the vendor specified, so if they aren't
- // equal then we return false
- if (rhs_vendor_specified && lhs_vendor_specified)
- return false;
- }
+ const bool rhs_vendor_specified = rhs.TripleVendorWasSpecified();
+ const bool lhs_vendor_specified = TripleVendorWasSpecified();
+ // Both architectures had the vendor specified, so if they aren't
+ // equal then we return false
+ if (rhs_vendor_specified && lhs_vendor_specified)
+ return false;
// Only fail if both vendor types are not unknown
if (lhs_triple_vendor != llvm::Triple::UnknownVendor &&
@@ -986,15 +984,12 @@ ArchSpec::IsEqualTo (const ArchSpec& rhs, bool exact_match) const
const llvm::Triple::OSType rhs_triple_os = rhs_triple.getOS();
if (lhs_triple_os != rhs_triple_os)
{
- if (exact_match)
- {
- const bool rhs_os_specified = rhs.TripleOSWasSpecified();
- const bool lhs_os_specified = TripleOSWasSpecified();
- // Both architectures had the OS specified, so if they aren't
- // equal then we return false
- if (rhs_os_specified && lhs_os_specified)
- return false;
- }
+ const bool rhs_os_specified = rhs.TripleOSWasSpecified();
+ const bool lhs_os_specified = TripleOSWasSpecified();
+ // Both architectures had the OS specified, so if they aren't
+ // equal then we return false
+ if (rhs_os_specified && lhs_os_specified)
+ return false;
// Only fail if both os types are not unknown
if (lhs_triple_os != llvm::Triple::UnknownOS &&
@@ -1103,6 +1098,10 @@ cores_match (const ArchSpec::Core core1, const ArchSpec::Core core2, bool try_in
return true;
break;
+ // v. https://en.wikipedia.org/wiki/ARM_Cortex-M#Silicon_customization
+ // Cortex-M0 - ARMv6-M - armv6m
+ // Cortex-M3 - ARMv7-M - armv7m
+ // Cortex-M4 - ARMv7E-M - armv7em
case ArchSpec::eCore_arm_armv7em:
if (!enforce_exact_match)
{
@@ -1118,6 +1117,10 @@ cores_match (const ArchSpec::Core core1, const ArchSpec::Core core2, bool try_in
}
break;
+ // v. https://en.wikipedia.org/wiki/ARM_Cortex-M#Silicon_customization
+ // Cortex-M0 - ARMv6-M - armv6m
+ // Cortex-M3 - ARMv7-M - armv7m
+ // Cortex-M4 - ARMv7E-M - armv7em
case ArchSpec::eCore_arm_armv7m:
if (!enforce_exact_match)
{
@@ -1428,3 +1431,62 @@ ArchSpec::GetStopInfoOverrideCallback () const
return StopInfoOverrideCallbackTypeARM;
return NULL;
}
+
+bool
+ArchSpec::IsFullySpecifiedTriple () const
+{
+ const auto& user_specified_triple = GetTriple();
+
+ bool user_triple_fully_specified = false;
+
+ if ((user_specified_triple.getOS() != llvm::Triple::UnknownOS) || TripleOSWasSpecified())
+ {
+ if ((user_specified_triple.getVendor() != llvm::Triple::UnknownVendor) || TripleVendorWasSpecified())
+ {
+ const unsigned unspecified = 0;
+ if (user_specified_triple.getOSMajorVersion() != unspecified)
+ {
+ user_triple_fully_specified = true;
+ }
+ }
+ }
+
+ return user_triple_fully_specified;
+}
+
+void
+ArchSpec::PiecewiseTripleCompare (const ArchSpec &other,
+ bool &arch_different,
+ bool &vendor_different,
+ bool &os_different,
+ bool &os_version_different,
+ bool &env_different)
+{
+ const llvm::Triple &me(GetTriple());
+ const llvm::Triple &them(other.GetTriple());
+
+ arch_different = (me.getArch() != them.getArch());
+
+ vendor_different = (me.getVendor() != them.getVendor());
+
+ os_different = (me.getOS() != them.getOS());
+
+ os_version_different = (me.getOSMajorVersion() != them.getOSMajorVersion());
+
+ env_different = (me.getEnvironment() != them.getEnvironment());
+}
+
+void
+ArchSpec::DumpTriple(Stream &s) const
+{
+ const llvm::Triple &triple = GetTriple();
+ llvm::StringRef arch_str = triple.getArchName();
+ llvm::StringRef vendor_str = triple.getVendorName();
+ llvm::StringRef os_str = triple.getOSName();
+
+ s.Printf("%s-%s-%s",
+ arch_str.empty() ? "*" : arch_str.str().c_str(),
+ vendor_str.empty() ? "*" : vendor_str.str().c_str(),
+ os_str.empty() ? "*" : os_str.str().c_str()
+ );
+}
diff --git a/source/Core/ConnectionSharedMemory.cpp b/source/Core/ConnectionSharedMemory.cpp
index 77daeb14840d..e417347579eb 100644
--- a/source/Core/ConnectionSharedMemory.cpp
+++ b/source/Core/ConnectionSharedMemory.cpp
@@ -16,10 +16,10 @@
#ifdef _WIN32
#include "lldb/Host/windows/windows.h"
#else
-#include <sys/file.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <fcntl.h>
#endif
// C++ Includes
diff --git a/source/Core/ConstString.cpp b/source/Core/ConstString.cpp
index 85f8d3c65cd9..c2e95d801723 100644
--- a/source/Core/ConstString.cpp
+++ b/source/Core/ConstString.cpp
@@ -8,39 +8,21 @@
//===----------------------------------------------------------------------===//
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Stream.h"
-#include "lldb/Host/Mutex.h"
#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/RWMutex.h"
-#include <mutex> // std::once
+#include <array>
+#include <mutex>
using namespace lldb_private;
-
class Pool
{
public:
typedef const char * StringPoolValueType;
typedef llvm::StringMap<StringPoolValueType, llvm::BumpPtrAllocator> StringPool;
typedef llvm::StringMapEntry<StringPoolValueType> StringPoolEntryType;
-
- //------------------------------------------------------------------
- // Default constructor
- //
- // Initialize the member variables and create the empty string.
- //------------------------------------------------------------------
- Pool () :
- m_mutex (Mutex::eMutexTypeRecursive),
- m_string_map ()
- {
- }
-
- //------------------------------------------------------------------
- // Destructor
- //------------------------------------------------------------------
- ~Pool ()
- {
- }
-
static StringPoolEntryType &
GetStringMapEntryFromKeyData (const char *keyData)
@@ -54,7 +36,9 @@ public:
{
if (ccstr)
{
- const StringPoolEntryType&entry = GetStringMapEntryFromKeyData (ccstr);
+ const uint8_t h = hash (llvm::StringRef(ccstr));
+ llvm::sys::SmartScopedReader<false> rlock(m_string_pools[h].m_mutex);
+ const StringPoolEntryType& entry = GetStringMapEntryFromKeyData (ccstr);
return entry.getKey().size();
}
return 0;
@@ -64,7 +48,11 @@ public:
GetMangledCounterpart (const char *ccstr) const
{
if (ccstr)
+ {
+ const uint8_t h = hash (llvm::StringRef(ccstr));
+ llvm::sys::SmartScopedReader<false> rlock(m_string_pools[h].m_mutex);
return GetStringMapEntryFromKeyData (ccstr).getValue();
+ }
return 0;
}
@@ -73,8 +61,16 @@ public:
{
if (key_ccstr && value_ccstr)
{
- GetStringMapEntryFromKeyData (key_ccstr).setValue(value_ccstr);
- GetStringMapEntryFromKeyData (value_ccstr).setValue(key_ccstr);
+ {
+ const uint8_t h = hash (llvm::StringRef(key_ccstr));
+ llvm::sys::SmartScopedWriter<false> wlock(m_string_pools[h].m_mutex);
+ GetStringMapEntryFromKeyData (key_ccstr).setValue(value_ccstr);
+ }
+ {
+ const uint8_t h = hash (llvm::StringRef(value_ccstr));
+ llvm::sys::SmartScopedWriter<false> wlock(m_string_pools[h].m_mutex);
+ GetStringMapEntryFromKeyData (value_ccstr).setValue(key_ccstr);
+ }
return true;
}
return false;
@@ -85,20 +81,15 @@ public:
{
if (cstr)
return GetConstCStringWithLength (cstr, strlen (cstr));
- return NULL;
+ return nullptr;
}
const char *
GetConstCStringWithLength (const char *cstr, size_t cstr_len)
{
if (cstr)
- {
- Mutex::Locker locker (m_mutex);
- llvm::StringRef string_ref (cstr, cstr_len);
- StringPoolEntryType& entry = *m_string_map.insert (std::make_pair (string_ref, (StringPoolValueType)NULL)).first;
- return entry.getKeyData();
- }
- return NULL;
+ return GetConstCStringWithStringRef(llvm::StringRef(cstr, cstr_len));
+ return nullptr;
}
const char *
@@ -106,11 +97,20 @@ public:
{
if (string_ref.data())
{
- Mutex::Locker locker (m_mutex);
- StringPoolEntryType& entry = *m_string_map.insert (std::make_pair (string_ref, (StringPoolValueType)NULL)).first;
+ const uint8_t h = hash (string_ref);
+
+ {
+ llvm::sys::SmartScopedReader<false> rlock(m_string_pools[h].m_mutex);
+ auto it = m_string_pools[h].m_string_map.find (string_ref);
+ if (it != m_string_pools[h].m_string_map.end())
+ return it->getKeyData();
+ }
+
+ llvm::sys::SmartScopedWriter<false> wlock(m_string_pools[h].m_mutex);
+ StringPoolEntryType& entry = *m_string_pools[h].m_string_map.insert (std::make_pair (string_ref, nullptr)).first;
return entry.getKeyData();
}
- return NULL;
+ return nullptr;
}
const char *
@@ -118,19 +118,33 @@ public:
{
if (demangled_cstr)
{
- Mutex::Locker locker (m_mutex);
- // Make string pool entry with the mangled counterpart already set
- StringPoolEntryType& entry = *m_string_map.insert (std::make_pair (llvm::StringRef (demangled_cstr), mangled_ccstr)).first;
-
- // Extract the const version of the demangled_cstr
- const char *demangled_ccstr = entry.getKeyData();
- // Now assign the demangled const string as the counterpart of the
- // mangled const string...
- GetStringMapEntryFromKeyData (mangled_ccstr).setValue(demangled_ccstr);
+ const char *demangled_ccstr = nullptr;
+
+ {
+ llvm::StringRef string_ref (demangled_cstr);
+ const uint8_t h = hash (string_ref);
+ llvm::sys::SmartScopedWriter<false> wlock(m_string_pools[h].m_mutex);
+
+ // Make string pool entry with the mangled counterpart already set
+ StringPoolEntryType& entry = *m_string_pools[h].m_string_map.insert (
+ std::make_pair (string_ref, mangled_ccstr)).first;
+
+ // Extract the const version of the demangled_cstr
+ demangled_ccstr = entry.getKeyData();
+ }
+
+ {
+ // Now assign the demangled const string as the counterpart of the
+ // mangled const string...
+ const uint8_t h = hash (llvm::StringRef(mangled_ccstr));
+ llvm::sys::SmartScopedWriter<false> wlock(m_string_pools[h].m_mutex);
+ GetStringMapEntryFromKeyData (mangled_ccstr).setValue(demangled_ccstr);
+ }
+
// Return the constant demangled C string
return demangled_ccstr;
}
- return NULL;
+ return nullptr;
}
const char *
@@ -141,7 +155,7 @@ public:
const size_t trimmed_len = std::min<size_t> (strlen (cstr), cstr_len);
return GetConstCStringWithLength (cstr, trimmed_len);
}
- return NULL;
+ return nullptr;
}
//------------------------------------------------------------------
@@ -152,28 +166,31 @@ public:
size_t
MemorySize() const
{
- Mutex::Locker locker (m_mutex);
size_t mem_size = sizeof(Pool);
- const_iterator end = m_string_map.end();
- for (const_iterator pos = m_string_map.begin(); pos != end; ++pos)
+ for (const auto& pool : m_string_pools)
{
- mem_size += sizeof(StringPoolEntryType) + pos->getKey().size();
+ llvm::sys::SmartScopedReader<false> rlock(pool.m_mutex);
+ for (const auto& entry : pool.m_string_map)
+ mem_size += sizeof(StringPoolEntryType) + entry.getKey().size();
}
return mem_size;
}
protected:
- //------------------------------------------------------------------
- // Typedefs
- //------------------------------------------------------------------
- typedef StringPool::iterator iterator;
- typedef StringPool::const_iterator const_iterator;
+ uint8_t
+ hash(const llvm::StringRef &s) const
+ {
+ uint32_t h = llvm::HashString(s);
+ return ((h >> 24) ^ (h >> 16) ^ (h >> 8) ^ h) & 0xff;
+ }
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- mutable Mutex m_mutex;
- StringPool m_string_map;
+ struct PoolEntry
+ {
+ mutable llvm::sys::SmartRWMutex<false> m_mutex;
+ StringPool m_string_map;
+ };
+
+ std::array<PoolEntry, 256> m_string_pools;
};
//----------------------------------------------------------------------
@@ -191,7 +208,7 @@ static Pool &
StringPool()
{
static std::once_flag g_pool_initialization_flag;
- static Pool *g_string_pool = NULL;
+ static Pool *g_string_pool = nullptr;
std::call_once(g_pool_initialization_flag, [] () {
g_string_pool = new Pool();
@@ -228,8 +245,8 @@ ConstString::operator < (const ConstString& rhs) const
if (lhs_string_ref.data() && rhs_string_ref.data())
return lhs_string_ref < rhs_string_ref;
- // Else one of them was NULL, so if LHS is NULL then it is less than
- return lhs_string_ref.data() == NULL;
+ // Else one of them was nullptr, so if LHS is nullptr then it is less than
+ return lhs_string_ref.data() == nullptr;
}
Stream&
diff --git a/source/Core/CxaDemangle.cpp b/source/Core/CxaDemangle.cpp
index bcc52ff39fe4..7d21138c2899 100644
--- a/source/Core/CxaDemangle.cpp
+++ b/source/Core/CxaDemangle.cpp
@@ -13,6 +13,7 @@
// - Included win32.h for snprintf implementation for MSVC
// - Removed constexpr member initialization for MSVC
// - Changed argument to alignas() to a literal for MSVC
+// - Include <cstdio> for fprintf, stderr like entities.
//----------------------------------------------------------------------
#if defined(_MSC_VER)
@@ -40,6 +41,7 @@
#include <cstdlib>
#include <cstring>
#include <cctype>
+#include <cstdio>
namespace lldb_private
{
diff --git a/source/Core/DataEncoder.cpp b/source/Core/DataEncoder.cpp
index d21ca423892f..040d09647562 100644
--- a/source/Core/DataEncoder.cpp
+++ b/source/Core/DataEncoder.cpp
@@ -61,7 +61,7 @@ WriteSwappedInt64(unsigned char* ptr, unsigned offset, uint64_t value)
DataEncoder::DataEncoder () :
m_start (NULL),
m_end (NULL),
- m_byte_order(lldb::endian::InlHostByteOrder()),
+ m_byte_order(endian::InlHostByteOrder()),
m_addr_size (sizeof(void*)),
m_data_sp ()
{
@@ -114,7 +114,7 @@ DataEncoder::Clear ()
{
m_start = NULL;
m_end = NULL;
- m_byte_order = lldb::endian::InlHostByteOrder();
+ m_byte_order = endian::InlHostByteOrder();
m_addr_size = sizeof(void*);
m_data_sp.reset();
}
@@ -240,7 +240,7 @@ DataEncoder::PutU16 (uint32_t offset, uint16_t value)
{
if (ValidOffsetForDataOfSize(offset, sizeof(value)))
{
- if (m_byte_order != lldb::endian::InlHostByteOrder())
+ if (m_byte_order != endian::InlHostByteOrder())
WriteSwappedInt16 (m_start, offset, value);
else
WriteInt16 (m_start, offset, value);
@@ -255,7 +255,7 @@ DataEncoder::PutU32 (uint32_t offset, uint32_t value)
{
if (ValidOffsetForDataOfSize(offset, sizeof(value)))
{
- if (m_byte_order != lldb::endian::InlHostByteOrder())
+ if (m_byte_order != endian::InlHostByteOrder())
WriteSwappedInt32 (m_start, offset, value);
else
WriteInt32 (m_start, offset, value);
@@ -270,7 +270,7 @@ DataEncoder::PutU64 (uint32_t offset, uint64_t value)
{
if (ValidOffsetForDataOfSize(offset, sizeof(value)))
{
- if (m_byte_order != lldb::endian::InlHostByteOrder())
+ if (m_byte_order != endian::InlHostByteOrder())
WriteSwappedInt64 (m_start, offset, value);
else
WriteInt64 (m_start, offset, value);
diff --git a/source/Core/DataExtractor.cpp b/source/Core/DataExtractor.cpp
index 861bece98da9..dc7857fe9cb7 100644
--- a/source/Core/DataExtractor.cpp
+++ b/source/Core/DataExtractor.cpp
@@ -14,6 +14,7 @@
#include <limits>
#include <sstream>
#include <string>
+#include <math.h>
#include "clang/AST/ASTContext.h"
@@ -130,8 +131,8 @@ ReadSwapInt64(const void* ptr)
DataExtractor::DataExtractor () :
m_start (NULL),
m_end (NULL),
- m_byte_order(lldb::endian::InlHostByteOrder()),
- m_addr_size (4),
+ m_byte_order(endian::InlHostByteOrder()),
+ m_addr_size (sizeof(void *)),
m_data_sp (),
m_target_byte_size(1)
{
@@ -142,13 +143,16 @@ DataExtractor::DataExtractor () :
// 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*/) :
- m_start ((uint8_t*)data),
- m_end ((uint8_t*)data + length),
+ m_start (const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(data))),
+ m_end (const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(data)) + 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
}
//----------------------------------------------------------------------
@@ -166,6 +170,9 @@ DataExtractor::DataExtractor (const DataBufferSP& data_sp, ByteOrder endian, uin
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);
}
@@ -184,6 +191,9 @@ DataExtractor::DataExtractor (const DataExtractor& data, offset_t offset, offset
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;
@@ -201,6 +211,9 @@ DataExtractor::DataExtractor (const DataExtractor& rhs) :
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
}
//----------------------------------------------------------------------
@@ -237,8 +250,8 @@ DataExtractor::Clear ()
{
m_start = NULL;
m_end = NULL;
- m_byte_order = lldb::endian::InlHostByteOrder();
- m_addr_size = 4;
+ m_byte_order = endian::InlHostByteOrder();
+ m_addr_size = sizeof(void *);
m_data_sp.reset();
}
@@ -287,7 +300,7 @@ DataExtractor::SetData (const void *bytes, offset_t length, ByteOrder endian)
}
else
{
- m_start = (uint8_t *)bytes;
+ m_start = const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(bytes));
m_end = m_start + length;
}
return GetByteSize();
@@ -311,6 +324,9 @@ 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.get())
{
@@ -427,7 +443,7 @@ DataExtractor::GetU16 (offset_t *offset_ptr) const
const uint8_t *data = (const uint8_t *)GetData (offset_ptr, sizeof(val));
if (data)
{
- if (m_byte_order != lldb::endian::InlHostByteOrder())
+ if (m_byte_order != endian::InlHostByteOrder())
val = ReadSwapInt16(data);
else
val = ReadInt16 (data);
@@ -439,7 +455,7 @@ uint16_t
DataExtractor::GetU16_unchecked (offset_t *offset_ptr) const
{
uint16_t val;
- if (m_byte_order == lldb::endian::InlHostByteOrder())
+ if (m_byte_order == endian::InlHostByteOrder())
val = ReadInt16 (m_start, *offset_ptr);
else
val = ReadSwapInt16(m_start, *offset_ptr);
@@ -451,7 +467,7 @@ uint32_t
DataExtractor::GetU32_unchecked (offset_t *offset_ptr) const
{
uint32_t val;
- if (m_byte_order == lldb::endian::InlHostByteOrder())
+ if (m_byte_order == endian::InlHostByteOrder())
val = ReadInt32 (m_start, *offset_ptr);
else
val = ReadSwapInt32 (m_start, *offset_ptr);
@@ -463,7 +479,7 @@ uint64_t
DataExtractor::GetU64_unchecked (offset_t *offset_ptr) const
{
uint64_t val;
- if (m_byte_order == lldb::endian::InlHostByteOrder())
+ if (m_byte_order == endian::InlHostByteOrder())
val = ReadInt64 (m_start, *offset_ptr);
else
val = ReadSwapInt64 (m_start, *offset_ptr);
@@ -488,7 +504,7 @@ DataExtractor::GetU16 (offset_t *offset_ptr, void *void_dst, uint32_t count) con
const uint16_t *src = (const uint16_t *)GetData (offset_ptr, src_size);
if (src)
{
- if (m_byte_order != lldb::endian::InlHostByteOrder())
+ if (m_byte_order != endian::InlHostByteOrder())
{
uint16_t *dst_pos = (uint16_t *)void_dst;
uint16_t *dst_end = dst_pos + count;
@@ -523,7 +539,7 @@ DataExtractor::GetU32 (offset_t *offset_ptr) const
const uint8_t *data = (const uint8_t *)GetData (offset_ptr, sizeof(val));
if (data)
{
- if (m_byte_order != lldb::endian::InlHostByteOrder())
+ if (m_byte_order != endian::InlHostByteOrder())
{
val = ReadSwapInt32 (data);
}
@@ -551,7 +567,7 @@ DataExtractor::GetU32 (offset_t *offset_ptr, void *void_dst, uint32_t count) con
const uint32_t *src = (const uint32_t *)GetData (offset_ptr, src_size);
if (src)
{
- if (m_byte_order != lldb::endian::InlHostByteOrder())
+ if (m_byte_order != endian::InlHostByteOrder())
{
uint32_t *dst_pos = (uint32_t *)void_dst;
uint32_t *dst_end = dst_pos + count;
@@ -586,7 +602,7 @@ DataExtractor::GetU64 (offset_t *offset_ptr) const
const uint8_t *data = (const uint8_t *)GetData (offset_ptr, sizeof(val));
if (data)
{
- if (m_byte_order != lldb::endian::InlHostByteOrder())
+ if (m_byte_order != endian::InlHostByteOrder())
{
val = ReadSwapInt64 (data);
}
@@ -612,7 +628,7 @@ DataExtractor::GetU64 (offset_t *offset_ptr, void *void_dst, uint32_t count) con
const uint64_t *src = (const uint64_t *)GetData (offset_ptr, src_size);
if (src)
{
- if (m_byte_order != lldb::endian::InlHostByteOrder())
+ if (m_byte_order != endian::InlHostByteOrder())
{
uint64_t *dst_pos = (uint64_t *)void_dst;
uint64_t *dst_end = dst_pos + count;
@@ -653,7 +669,7 @@ DataExtractor::GetMaxU32 (offset_t *offset_ptr, size_t byte_size) const
case 2: return GetU16(offset_ptr); break;
case 4: return GetU32(offset_ptr); break;
default:
- assert("GetMaxU32 unhandled case!" == NULL);
+ assert(false && "GetMaxU32 unhandled case!");
break;
}
return 0;
@@ -679,7 +695,7 @@ DataExtractor::GetMaxU64 (offset_t *offset_ptr, size_t size) const
case 4: return GetU32(offset_ptr); break;
case 8: return GetU64(offset_ptr); break;
default:
- assert("GetMax64 unhandled case!" == NULL);
+ assert(false && "GetMax64 unhandled case!");
break;
}
return 0;
@@ -695,7 +711,7 @@ DataExtractor::GetMaxU64_unchecked (offset_t *offset_ptr, size_t size) const
case 4: return GetU32_unchecked (offset_ptr); break;
case 8: return GetU64_unchecked (offset_ptr); break;
default:
- assert("GetMax64 unhandled case!" == NULL);
+ assert(false && "GetMax64 unhandled case!");
break;
}
return 0;
@@ -711,7 +727,7 @@ DataExtractor::GetMaxS64 (offset_t *offset_ptr, size_t size) const
case 4: return (int32_t)GetU32(offset_ptr); break;
case 8: return (int64_t)GetU64(offset_ptr); break;
default:
- assert("GetMax64 unhandled case!" == NULL);
+ assert(false && "GetMax64 unhandled case!");
break;
}
return 0;
@@ -760,7 +776,7 @@ DataExtractor::GetFloat (offset_t *offset_ptr) const
const float_type *src = (const float_type *)GetData (offset_ptr, src_size);
if (src)
{
- if (m_byte_order != lldb::endian::InlHostByteOrder())
+ if (m_byte_order != endian::InlHostByteOrder())
{
const uint8_t *src_data = (const uint8_t *)src;
uint8_t *dst_data = (uint8_t *)&val;
@@ -784,7 +800,7 @@ DataExtractor::GetDouble (offset_t *offset_ptr) const
const float_type *src = (const float_type *)GetData (offset_ptr, src_size);
if (src)
{
- if (m_byte_order != lldb::endian::InlHostByteOrder())
+ if (m_byte_order != endian::InlHostByteOrder())
{
const uint8_t *src_data = (const uint8_t *)src;
uint8_t *dst_data = (uint8_t *)&val;
@@ -805,9 +821,9 @@ DataExtractor::GetLongDouble (offset_t *offset_ptr) const
{
long double val = 0.0;
#if defined (__i386__) || defined (__amd64__) || defined (__x86_64__) || defined(_M_IX86) || defined(_M_IA64) || defined(_M_X64)
- *offset_ptr += CopyByteOrderedData (*offset_ptr, 10, &val, sizeof(val), lldb::endian::InlHostByteOrder());
+ *offset_ptr += CopyByteOrderedData (*offset_ptr, 10, &val, sizeof(val), endian::InlHostByteOrder());
#else
- *offset_ptr += CopyByteOrderedData (*offset_ptr, sizeof(val), &val, sizeof(val), lldb::endian::InlHostByteOrder());
+ *offset_ptr += CopyByteOrderedData (*offset_ptr, sizeof(val), &val, sizeof(val), endian::InlHostByteOrder());
#endif
return val;
}
@@ -824,12 +840,18 @@ DataExtractor::GetLongDouble (offset_t *offset_ptr) const
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);
}
@@ -844,6 +866,9 @@ DataExtractor::GetAddress_unchecked (offset_t *offset_ptr) const
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);
}
@@ -863,6 +888,9 @@ DataExtractor::GetGNUEHPointer (offset_t *offset_ptr, uint32_t eh_ptr_enc, lldb:
uint64_t baseAddress = 0;
uint64_t addressValue = 0;
const uint32_t addr_size = GetAddressByteSize();
+#ifdef LLDB_CONFIGURATION_DEBUG
+ assert (addr_size == 4 || addr_size == 8);
+#endif
bool signExtendValue = false;
// Decode the base part or adjust our offset
@@ -1378,24 +1406,21 @@ DumpAPInt (Stream *s, const DataExtractor &data, lldb::offset_t offset, lldb::of
return offset;
}
-static float half2float (uint16_t half)
+static float
+half2float (uint16_t half)
{
-#ifdef _MSC_VER
- llvm_unreachable("half2float not implemented for MSVC");
-#else
- union{ float f; uint32_t u;}u;
+ union { float f; uint32_t u; } u;
int32_t v = (int16_t) half;
-
- if( 0 == (v & 0x7c00))
+
+ if (0 == (v & 0x7c00))
{
u.u = v & 0x80007FFFU;
return u.f * ldexpf(1, 125);
}
-
+
v <<= 13;
u.u = v | 0x70000000U;
return u.f * ldexpf(1, -112);
-#endif
}
lldb::offset_t
@@ -2012,6 +2037,12 @@ DataExtractor::Dump (Stream *s,
s->PutChar('}');
break;
+ case eFormatVectorOfFloat16:
+ s->PutChar('{');
+ offset = Dump (s, offset, eFormatFloat, 2, item_byte_size / 2, item_byte_size / 2, LLDB_INVALID_ADDRESS, 0, 0);
+ s->PutChar('}');
+ break;
+
case eFormatVectorOfFloat32:
s->PutChar('{');
offset = Dump (s, offset, eFormatFloat, 4, item_byte_size / 4, item_byte_size / 4, LLDB_INVALID_ADDRESS, 0, 0);
diff --git a/source/Core/Debugger.cpp b/source/Core/Debugger.cpp
index cd41e5d65103..d36800e20bc0 100644
--- a/source/Core/Debugger.cpp
+++ b/source/Core/Debugger.cpp
@@ -11,13 +11,12 @@
#include <map>
-#include "clang/AST/DeclCXX.h"
-#include "clang/AST/Type.h"
#include "llvm/ADT/StringRef.h"
#include "lldb/lldb-private.h"
#include "lldb/Core/FormatEntity.h"
#include "lldb/Core/Module.h"
+#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/State.h"
@@ -32,6 +31,7 @@
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/Expression/REPL.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/Terminal.h"
@@ -40,14 +40,12 @@
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Interpreter/OptionValueSInt64.h"
#include "lldb/Interpreter/OptionValueString.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/VariableList.h"
-#include "lldb/Target/CPPLanguageRuntime.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/TargetList.h"
+#include "lldb/Target/Language.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/SectionLoadList.h"
@@ -88,9 +86,10 @@ GetDebuggerList()
OptionEnumValueElement
g_show_disassembly_enum_values[] =
{
- { Debugger::eStopDisassemblyTypeNever, "never", "Never show disassembly when displaying a stop context."},
- { Debugger::eStopDisassemblyTypeNoSource, "no-source", "Show disassembly when there is no source information, or the source file is missing when displaying a stop context."},
- { Debugger::eStopDisassemblyTypeAlways, "always", "Always show disassembly when displaying a stop context."},
+ { Debugger::eStopDisassemblyTypeNever, "never", "Never show disassembly when displaying a stop context."},
+ { Debugger::eStopDisassemblyTypeNoDebugInfo, "no-debuginfo", "Show disassembly when there is no debug information."},
+ { Debugger::eStopDisassemblyTypeNoSource, "no-source", "Show disassembly when there is no source information, or the source file is missing when displaying a stop context."},
+ { Debugger::eStopDisassemblyTypeAlways, "always", "Always show disassembly when displaying a stop context."},
{ 0, NULL, NULL }
};
@@ -105,6 +104,7 @@ g_language_enumerators[] =
#define MODULE_WITH_FUNC "{ ${module.file.basename}{`${function.name-with-args}${function.pc-offset}}}"
#define FILE_AND_LINE "{ at ${line.file.basename}:${line.number}}"
+#define IS_OPTIMIZED "{${function.is-optimized} [opt]}"
#define DEFAULT_THREAD_FORMAT "thread #${thread.index}: tid = ${thread.id%tid}"\
"{, ${frame.pc}}"\
@@ -122,6 +122,7 @@ g_language_enumerators[] =
#define DEFAULT_FRAME_FORMAT "frame #${frame.index}: ${frame.pc}"\
MODULE_WITH_FUNC\
FILE_AND_LINE\
+ IS_OPTIMIZED\
"\\n"
// Three parts to this disassembly format specification:
@@ -150,7 +151,7 @@ g_properties[] =
{ "prompt", OptionValue::eTypeString , true, OptionValueString::eOptionEncodeCharacterEscapeSequences, "(lldb) ", NULL, "The debugger command line prompt displayed for the user." },
{ "script-lang", OptionValue::eTypeEnum , true, eScriptLanguagePython, NULL, g_language_enumerators, "The script language to be used for evaluating user-written scripts." },
{ "stop-disassembly-count", OptionValue::eTypeSInt64 , true, 4 , NULL, NULL, "The number of disassembly lines to show when displaying a stopped context." },
-{ "stop-disassembly-display", OptionValue::eTypeEnum , true, Debugger::eStopDisassemblyTypeNoSource, NULL, g_show_disassembly_enum_values, "Control when to display disassembly when displaying a stopped context." },
+{ "stop-disassembly-display", OptionValue::eTypeEnum , true, Debugger::eStopDisassemblyTypeNoDebugInfo, NULL, g_show_disassembly_enum_values, "Control when to display disassembly when displaying a stopped context." },
{ "stop-line-count-after", OptionValue::eTypeSInt64 , true, 3 , NULL, NULL, "The number of sources lines to display that come after the current source line when displaying a stopped context." },
{ "stop-line-count-before", OptionValue::eTypeSInt64 , true, 3 , NULL, NULL, "The number of sources lines to display that come before the current source line when displaying a stopped context." },
{ "term-width", OptionValue::eTypeSInt64 , true, 80 , NULL, NULL, "The maximum number of columns to use for displaying text." },
@@ -158,6 +159,9 @@ g_properties[] =
{ "use-external-editor", OptionValue::eTypeBoolean , true, false, NULL, NULL, "Whether to use an external editor or not." },
{ "use-color", OptionValue::eTypeBoolean , true, true , NULL, NULL, "Whether to use Ansi color codes or not." },
{ "auto-one-line-summaries", OptionValue::eTypeBoolean , true, true, NULL, NULL, "If true, LLDB will automatically display small structs in one-liner format (default: true)." },
+{ "auto-indent", OptionValue::eTypeBoolean , true, true , NULL, NULL, "If true, LLDB will auto indent/outdent code. Currently only supported in the REPL (default: true)." },
+{ "print-decls", OptionValue::eTypeBoolean , true, true , NULL, NULL, "If true, LLDB will print the values of variables declared in an expression. Currently only supported in the REPL (default: true)." },
+{ "tab-size", OptionValue::eTypeUInt64 , true, 4 , NULL, NULL, "The tab size to use when indenting code in multi-line input mode (default: 4)." },
{ "escape-non-printables", OptionValue::eTypeBoolean , true, true, NULL, NULL, "If true, LLDB will automatically escape non-printable and escape characters when formatting strings." },
{ NULL, OptionValue::eTypeInvalid , true, 0 , NULL, NULL, NULL }
};
@@ -179,6 +183,9 @@ enum
ePropertyUseExternalEditor,
ePropertyUseColor,
ePropertyAutoOneLineSummaries,
+ ePropertyAutoIndent,
+ ePropertyPrintDecls,
+ ePropertyTabSize,
ePropertyEscapeNonPrintables
};
@@ -394,6 +401,49 @@ Debugger::GetEscapeNonPrintables () const
return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, true);
}
+bool
+Debugger::GetAutoIndent () const
+{
+ const uint32_t idx = ePropertyAutoIndent;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, true);
+}
+
+bool
+Debugger::SetAutoIndent (bool b)
+{
+ const uint32_t idx = ePropertyAutoIndent;
+ return m_collection_sp->SetPropertyAtIndexAsBoolean (NULL, idx, b);
+}
+
+bool
+Debugger::GetPrintDecls () const
+{
+ const uint32_t idx = ePropertyPrintDecls;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, true);
+}
+
+bool
+Debugger::SetPrintDecls (bool b)
+{
+ const uint32_t idx = ePropertyPrintDecls;
+ return m_collection_sp->SetPropertyAtIndexAsBoolean (NULL, idx, b);
+}
+
+uint32_t
+Debugger::GetTabSize () const
+{
+ const uint32_t idx = ePropertyTabSize;
+ return m_collection_sp->GetPropertyAtIndexAsUInt64 (NULL, idx, g_properties[idx].default_uint_value);
+}
+
+bool
+Debugger::SetTabSize (uint32_t tab_size)
+{
+ const uint32_t idx = ePropertyTabSize;
+ return m_collection_sp->SetPropertyAtIndexAsUInt64 (NULL, idx, tab_size);
+}
+
+
#pragma mark Debugger
//const DebuggerPropertiesSP &
@@ -420,7 +470,11 @@ Debugger::Terminate ()
// Clear our master list of debugger objects
Mutex::Locker locker (GetDebuggerListMutex ());
- GetDebuggerList().clear();
+ auto& debuggers = GetDebuggerList();
+ for (const auto& debugger: debuggers)
+ debugger->Clear();
+
+ debuggers.clear();
}
void
@@ -917,6 +971,12 @@ Debugger::IsTopIOHandler (const lldb::IOHandlerSP& reader_sp)
return m_input_reader_stack.IsTop (reader_sp);
}
+bool
+Debugger::CheckTopIOHandlerTypes (IOHandler::Type top_type, IOHandler::Type second_top_type)
+{
+ return m_input_reader_stack.CheckTopIOHandlerTypes (top_type, second_top_type);
+}
+
void
Debugger::PrintAsync (const char *s, size_t len, bool is_stdout)
{
@@ -1682,6 +1742,12 @@ Debugger::IOHandlerThread (lldb::thread_arg_t arg)
}
bool
+Debugger::HasIOHandlerThread()
+{
+ return m_io_handler_thread.IsJoinable();
+}
+
+bool
Debugger::StartIOHandlerThread()
{
if (!m_io_handler_thread.IsJoinable())
@@ -1704,6 +1770,17 @@ Debugger::StopIOHandlerThread()
}
}
+void
+Debugger::JoinIOHandlerThread()
+{
+ if (HasIOHandlerThread())
+ {
+ thread_result_t result;
+ m_io_handler_thread.Join(&result);
+ m_io_handler_thread = LLDB_INVALID_HOST_THREAD;
+ }
+}
+
Target *
Debugger::GetDummyTarget()
{
@@ -1724,3 +1801,52 @@ Debugger::GetSelectedOrDummyTarget(bool prefer_dummy)
return GetDummyTarget();
}
+Error
+Debugger::RunREPL (LanguageType language, const char *repl_options)
+{
+ Error err;
+ FileSpec repl_executable;
+
+ if (language == eLanguageTypeUnknown)
+ {
+ std::set<LanguageType> repl_languages;
+
+ Language::GetLanguagesSupportingREPLs(repl_languages);
+
+ if (repl_languages.size() == 1)
+ {
+ language = *repl_languages.begin();
+ }
+ else if (repl_languages.size() == 0)
+ {
+ err.SetErrorStringWithFormat("LLDB isn't configured with support support for any REPLs.");
+ return err;
+ }
+ else
+ {
+ err.SetErrorStringWithFormat("Multiple possible REPL languages. Please specify a language.");
+ return err;
+ }
+ }
+
+ Target *const target = nullptr; // passing in an empty target means the REPL must create one
+
+ REPLSP repl_sp(REPL::Create(err, language, this, target, repl_options));
+
+ if (!err.Success())
+ {
+ return err;
+ }
+
+ if (!repl_sp)
+ {
+ err.SetErrorStringWithFormat("couldn't find a REPL for %s", Language::GetNameForLanguageType(language));
+ return err;
+ }
+
+ repl_sp->SetCompilerOptions(repl_options);
+ repl_sp->RunLoop();
+
+ return err;
+}
+
diff --git a/source/Core/Disassembler.cpp b/source/Core/Disassembler.cpp
index f96232fcceeb..bb5f106ca611 100644
--- a/source/Core/Disassembler.cpp
+++ b/source/Core/Disassembler.cpp
@@ -28,7 +28,6 @@
#include "lldb/Interpreter/OptionValueDictionary.h"
#include "lldb/Interpreter/OptionValueString.h"
#include "lldb/Interpreter/OptionValueUInt64.h"
-#include "lldb/Symbol/ClangNamespaceDecl.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/ExecutionContext.h"
@@ -675,6 +674,13 @@ Instruction::DumpEmulation (const ArchSpec &arch)
return false;
}
+bool
+Instruction::HasDelaySlot ()
+{
+ // Default is false.
+ return false;
+}
+
OptionValueSP
Instruction::ReadArray (FILE *in_file, Stream *out_stream, OptionValue::Type data_type)
{
@@ -1264,7 +1270,7 @@ Disassembler::Disassembler(const ArchSpec& arch, const char *flavor) :
// If this is an arm variant that can only include thumb (T16, T32)
// instructions, force the arch triple to be "thumbv.." instead of
// "armv..."
- if (arch.GetTriple().getArch() == llvm::Triple::arm
+ if ((arch.GetTriple().getArch() == llvm::Triple::arm || arch.GetTriple().getArch() == llvm::Triple::thumb)
&& (arch.GetCore() == ArchSpec::Core::eCore_arm_armv7m
|| arch.GetCore() == ArchSpec::Core::eCore_arm_armv7em
|| arch.GetCore() == ArchSpec::Core::eCore_arm_armv6m))
@@ -1319,6 +1325,13 @@ PseudoInstruction::DoesBranch ()
return false;
}
+bool
+PseudoInstruction::HasDelaySlot ()
+{
+ // This is NOT a valid question for a pseudo instruction.
+ return false;
+}
+
size_t
PseudoInstruction::Decode (const lldb_private::Disassembler &disassembler,
const lldb_private::DataExtractor &data,
diff --git a/source/Core/DynamicLoader.cpp b/source/Core/DynamicLoader.cpp
index ffd7425f5231..4d2824c5f334 100644
--- a/source/Core/DynamicLoader.cpp
+++ b/source/Core/DynamicLoader.cpp
@@ -119,16 +119,20 @@ DynamicLoader::GetTargetExecutable()
}
void
-DynamicLoader::UpdateLoadedSections(ModuleSP module, addr_t link_map_addr, addr_t base_addr)
+DynamicLoader::UpdateLoadedSections(ModuleSP module,
+ addr_t link_map_addr,
+ addr_t base_addr,
+ bool base_addr_is_offset)
{
- UpdateLoadedSectionsCommon(module, base_addr);
+ UpdateLoadedSectionsCommon(module, base_addr, base_addr_is_offset);
}
void
-DynamicLoader::UpdateLoadedSectionsCommon(ModuleSP module, addr_t base_addr)
+DynamicLoader::UpdateLoadedSectionsCommon(ModuleSP module,
+ addr_t base_addr,
+ bool base_addr_is_offset)
{
bool changed;
- const bool base_addr_is_offset = true;
module->SetLoadAddress(m_process->GetTarget(), base_addr, base_addr_is_offset, changed);
}
@@ -171,7 +175,10 @@ DynamicLoader::GetSectionListFromModule(const ModuleSP module) const
}
ModuleSP
-DynamicLoader::LoadModuleAtAddress(const FileSpec &file, addr_t link_map_addr, addr_t base_addr)
+DynamicLoader::LoadModuleAtAddress(const FileSpec &file,
+ addr_t link_map_addr,
+ addr_t base_addr,
+ bool base_addr_is_offset)
{
Target &target = m_process->GetTarget();
ModuleList &modules = target.GetImages();
@@ -180,27 +187,28 @@ DynamicLoader::LoadModuleAtAddress(const FileSpec &file, addr_t link_map_addr, a
ModuleSpec module_spec (file, target.GetArchitecture());
if ((module_sp = modules.FindFirstModule (module_spec)))
{
- UpdateLoadedSections(module_sp, link_map_addr, base_addr);
+ UpdateLoadedSections(module_sp, link_map_addr, base_addr, base_addr_is_offset);
}
else if ((module_sp = target.GetSharedModule(module_spec)))
{
- UpdateLoadedSections(module_sp, link_map_addr, base_addr);
+ UpdateLoadedSections(module_sp, link_map_addr, base_addr, base_addr_is_offset);
}
else
{
- // Try to fetch the load address of the file from the process. It can be different from the
- // address reported by the linker in case of a file with fixed load address because the
- // linker reports the bias between the load address specified in the file and the actual
- // load address it loaded the file.
- bool is_loaded;
- lldb::addr_t load_addr;
- Error error = m_process->GetFileLoadAddress(file, is_loaded, load_addr);
- if (error.Fail() || !is_loaded)
- load_addr = base_addr;
-
- if ((module_sp = m_process->ReadModuleFromMemory(file, load_addr)))
+ if (base_addr_is_offset)
{
- UpdateLoadedSections(module_sp, link_map_addr, base_addr);
+ // Try to fetch the load address of the file from the process as we need absolute load
+ // address to read the file out of the memory instead of a load bias.
+ bool is_loaded;
+ lldb::addr_t load_addr;
+ Error error = m_process->GetFileLoadAddress(file, is_loaded, load_addr);
+ if (error.Success() && is_loaded)
+ base_addr = load_addr;
+ }
+
+ if ((module_sp = m_process->ReadModuleFromMemory(file, base_addr)))
+ {
+ UpdateLoadedSections(module_sp, link_map_addr, base_addr, false);
target.GetImages().AppendIfNeeded(module_sp);
}
}
diff --git a/source/Core/EmulateInstruction.cpp b/source/Core/EmulateInstruction.cpp
index 8349f54de4c7..9b6beeb8299a 100644
--- a/source/Core/EmulateInstruction.cpp
+++ b/source/Core/EmulateInstruction.cpp
@@ -635,17 +635,17 @@ EmulateInstruction::GetBestRegisterKindAndNumber (const RegisterInfo *reg_info,
return true;
}
- reg_num = reg_info->kinds[eRegisterKindGCC];
+ reg_num = reg_info->kinds[eRegisterKindEHFrame];
if (reg_num != LLDB_INVALID_REGNUM)
{
- reg_kind = eRegisterKindGCC;
+ reg_kind = eRegisterKindEHFrame;
return true;
}
- reg_num = reg_info->kinds[eRegisterKindGDB];
+ reg_num = reg_info->kinds[eRegisterKindProcessPlugin];
if (reg_num != LLDB_INVALID_REGNUM)
{
- reg_kind = eRegisterKindGDB;
+ reg_kind = eRegisterKindProcessPlugin;
return true;
}
return false;
diff --git a/source/Core/Event.cpp b/source/Core/Event.cpp
index bf5ff222a122..293a322257ef 100644
--- a/source/Core/Event.cpp
+++ b/source/Core/Event.cpp
@@ -147,7 +147,7 @@ EventDataBytes::Dump (Stream *s) const
else if (m_bytes.size() > 0)
{
DataExtractor data;
- data.SetData(&m_bytes[0], m_bytes.size(), lldb::endian::InlHostByteOrder());
+ data.SetData(&m_bytes[0], m_bytes.size(), endian::InlHostByteOrder());
data.Dump(s, 0, eFormatBytes, 1, m_bytes.size(), 32, LLDB_INVALID_ADDRESS, 0, 0);
}
}
diff --git a/source/Core/FastDemangle.cpp b/source/Core/FastDemangle.cpp
index 0f12af2783db..a27a2f1dbff1 100644
--- a/source/Core/FastDemangle.cpp
+++ b/source/Core/FastDemangle.cpp
@@ -161,7 +161,7 @@ public:
/// the Itanium C++ ABI mangling specification as implemented by Clang
///
/// @result Newly allocated null-terminated demangled name when demangling
- /// is succesful, and nullptr when demangling fails. The caller is
+ /// is successful, and nullptr when demangling fails. The caller is
/// responsible for freeing the allocated memory.
char *
diff --git a/source/Core/FormatEntity.cpp b/source/Core/FormatEntity.cpp
index e89d6c9cb4a9..804682f64bd3 100644
--- a/source/Core/FormatEntity.cpp
+++ b/source/Core/FormatEntity.cpp
@@ -7,13 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/ADT/StringRef.h"
-
#include "lldb/Core/FormatEntity.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+
#include "lldb/Core/Address.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Language.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamString.h"
@@ -21,7 +21,8 @@
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/DataFormatters/FormatManager.h"
-#include "lldb/Expression/ClangExpressionVariable.h"
+#include "lldb/DataFormatters/ValueObjectPrinter.h"
+#include "lldb/Expression/ExpressionVariable.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Symbol/Block.h"
@@ -31,6 +32,7 @@
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Language.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/SectionLoadList.h"
@@ -98,7 +100,8 @@ static FormatEntity::Entry::Definition g_function_child_entries[] =
ENTRY ("line-offset" , FunctionLineOffset , UInt64),
ENTRY ("pc-offset" , FunctionPCOffset , UInt64),
ENTRY ("initial-function" , FunctionInitial , None),
- ENTRY ("changed" , FunctionChanged , None)
+ ENTRY ("changed" , FunctionChanged , None),
+ ENTRY ("is-optimized" , FunctionIsOptimized , None)
};
static FormatEntity::Entry::Definition g_line_child_entries[] =
@@ -343,6 +346,7 @@ FormatEntity::Entry::TypeToCString (Type t)
ENUM_TO_CSTR(FunctionPCOffset);
ENUM_TO_CSTR(FunctionInitial);
ENUM_TO_CSTR(FunctionChanged);
+ ENUM_TO_CSTR(FunctionIsOptimized);
ENUM_TO_CSTR(LineEntryFile);
ENUM_TO_CSTR(LineEntryLineNumber);
ENUM_TO_CSTR(LineEntryStartAddress);
@@ -530,7 +534,7 @@ ScanBracketedRange (llvm::StringRef subpath,
int64_t& index_lower,
int64_t& index_higher)
{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_DATAFORMATTERS));
close_bracket_index = llvm::StringRef::npos;
const size_t open_bracket_index = subpath.find('[');
if (open_bracket_index == llvm::StringRef::npos)
@@ -667,7 +671,7 @@ ExpandIndexedExpression (ValueObject* valobj,
StackFrame* frame,
bool deref_pointer)
{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_DATAFORMATTERS));
const char* ptr_deref_format = "[%d]";
std::string ptr_deref_buffer(10,0);
::sprintf(&ptr_deref_buffer[0], ptr_deref_format, index);
@@ -728,7 +732,7 @@ DumpValue (Stream &s,
if (valobj == NULL)
return false;
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_DATAFORMATTERS));
Format custom_format = eFormatInvalid;
ValueObject::ValueObjectRepresentationStyle val_obj_display = entry.string.empty() ? ValueObject::eValueObjectRepresentationStyleValue : ValueObject::eValueObjectRepresentationStyleSummary;
@@ -883,10 +887,10 @@ DumpValue (Stream &s,
}
// TODO use flags for these
- const uint32_t type_info_flags = target->GetClangType().GetTypeInfo(NULL);
+ const uint32_t type_info_flags = target->GetCompilerType().GetTypeInfo(NULL);
bool is_array = (type_info_flags & eTypeIsArray) != 0;
bool is_pointer = (type_info_flags & eTypeIsPointer) != 0;
- bool is_aggregate = target->GetClangType().IsAggregateType();
+ bool is_aggregate = target->GetCompilerType().IsAggregateType();
if ((is_array || is_pointer) && (!is_array_range) && val_obj_display == ValueObject::eValueObjectRepresentationStyleValue) // this should be wrong, but there are some exceptions
{
@@ -1302,6 +1306,8 @@ FormatEntity::Format (const Entry &entry,
// Watch for the special "tid" format...
if (entry.printf_format == "tid")
{
+ // TODO(zturner): Rather than hardcoding this to be platform specific, it should be controlled by a
+ // setting and the default value of the setting can be different depending on the platform.
Target &target = thread->GetProcess()->GetTarget();
ArchSpec arch (target.GetArchitecture ());
llvm::Triple::OSType ostype = arch.IsValid() ? arch.GetTriple().getOS() : llvm::Triple::UnknownOS;
@@ -1432,7 +1438,7 @@ FormatEntity::Format (const Entry &entry,
StopInfoSP stop_info_sp = thread->GetStopInfo ();
if (stop_info_sp && stop_info_sp->IsValid())
{
- ClangExpressionVariableSP expression_var_sp = StopInfo::GetExpressionVariable (stop_info_sp);
+ ExpressionVariableSP expression_var_sp = StopInfo::GetExpressionVariable (stop_info_sp);
if (expression_var_sp && expression_var_sp->GetValueObject())
{
expression_var_sp->GetValueObject()->Dump(s);
@@ -1524,8 +1530,7 @@ FormatEntity::Format (const Entry &entry,
CompileUnit *cu = sc->comp_unit;
if (cu)
{
- Language lang(cu->GetLanguage());
- const char *lang_name = lang.AsCString();
+ const char *lang_name = Language::GetNameForLanguageType(cu->GetLanguage());
if (lang_name)
{
s.PutCString(lang_name);
@@ -1648,187 +1653,267 @@ FormatEntity::Format (const Entry &entry,
case Entry::Type::FunctionName:
{
- const char *name = NULL;
+ Language *language_plugin = nullptr;
+ bool language_plugin_handled = false;
+ StreamString ss;
if (sc->function)
- name = sc->function->GetName().AsCString (NULL);
+ language_plugin = Language::FindPlugin(sc->function->GetLanguage());
else if (sc->symbol)
- name = sc->symbol->GetName().AsCString (NULL);
- if (name)
+ language_plugin = Language::FindPlugin(sc->symbol->GetLanguage());
+ if (language_plugin)
{
- s.PutCString(name);
-
- if (sc->block)
+ language_plugin_handled = language_plugin->GetFunctionDisplayName(sc,
+ exe_ctx,
+ Language::FunctionNameRepresentation::eName,
+ ss);
+ }
+ if (language_plugin_handled)
+ {
+ s.PutCString(ss.GetData());
+ return true;
+ }
+ else
+ {
+ const char *name = NULL;
+ if (sc->function)
+ name = sc->function->GetName().AsCString (NULL);
+ else if (sc->symbol)
+ name = sc->symbol->GetName().AsCString (NULL);
+ if (name)
{
- Block *inline_block = sc->block->GetContainingInlinedBlock ();
- if (inline_block)
+ s.PutCString(name);
+
+ if (sc->block)
{
- const InlineFunctionInfo *inline_info = sc->block->GetInlinedFunctionInfo();
- if (inline_info)
+ Block *inline_block = sc->block->GetContainingInlinedBlock ();
+ if (inline_block)
{
- s.PutCString(" [inlined] ");
- inline_info->GetName(sc->function->GetLanguage()).Dump(&s);
+ const InlineFunctionInfo *inline_info = sc->block->GetInlinedFunctionInfo();
+ if (inline_info)
+ {
+ s.PutCString(" [inlined] ");
+ inline_info->GetName(sc->function->GetLanguage()).Dump(&s);
+ }
}
}
+ return true;
}
- return true;
}
}
return false;
case Entry::Type::FunctionNameNoArgs:
{
- ConstString name;
+ Language *language_plugin = nullptr;
+ bool language_plugin_handled = false;
+ StreamString ss;
if (sc->function)
- name = sc->function->GetNameNoArguments();
+ language_plugin = Language::FindPlugin(sc->function->GetLanguage());
else if (sc->symbol)
- name = sc->symbol->GetNameNoArguments();
- if (name)
+ language_plugin = Language::FindPlugin(sc->symbol->GetLanguage());
+ if (language_plugin)
+ {
+ language_plugin_handled = language_plugin->GetFunctionDisplayName(sc,
+ exe_ctx,
+ Language::FunctionNameRepresentation::eNameWithNoArgs,
+ ss);
+ }
+ if (language_plugin_handled)
{
- s.PutCString(name.GetCString());
+ s.PutCString(ss.GetData());
return true;
}
+ else
+ {
+ ConstString name;
+ if (sc->function)
+ name = sc->function->GetNameNoArguments();
+ else if (sc->symbol)
+ name = sc->symbol->GetNameNoArguments();
+ if (name)
+ {
+ s.PutCString(name.GetCString());
+ return true;
+ }
+ }
}
return false;
case Entry::Type::FunctionNameWithArgs:
{
- // Print the function name with arguments in it
+ Language *language_plugin = nullptr;
+ bool language_plugin_handled = false;
+ StreamString ss;
if (sc->function)
+ language_plugin = Language::FindPlugin(sc->function->GetLanguage());
+ else if (sc->symbol)
+ language_plugin = Language::FindPlugin(sc->symbol->GetLanguage());
+ if (language_plugin)
{
- ExecutionContextScope *exe_scope = exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL;
- const char *cstr = sc->function->GetName().AsCString (NULL);
- if (cstr)
+ language_plugin_handled = language_plugin->GetFunctionDisplayName(sc,
+ exe_ctx,
+ Language::FunctionNameRepresentation::eNameWithArgs,
+ ss);
+ }
+ if (language_plugin_handled)
+ {
+ s.PutCString(ss.GetData());
+ return true;
+ }
+ else
+ {
+ // Print the function name with arguments in it
+ if (sc->function)
{
- const InlineFunctionInfo *inline_info = NULL;
- VariableListSP variable_list_sp;
- bool get_function_vars = true;
- if (sc->block)
- {
- Block *inline_block = sc->block->GetContainingInlinedBlock ();
-
- if (inline_block)
- {
- get_function_vars = false;
- inline_info = sc->block->GetInlinedFunctionInfo();
- if (inline_info)
- variable_list_sp = inline_block->GetBlockVariableList (true);
- }
- }
-
- if (get_function_vars)
- {
- variable_list_sp = sc->function->GetBlock(true).GetBlockVariableList (true);
- }
-
- if (inline_info)
- {
- s.PutCString (cstr);
- s.PutCString (" [inlined] ");
- cstr = inline_info->GetName(sc->function->GetLanguage()).GetCString();
- }
-
- VariableList args;
- if (variable_list_sp)
- variable_list_sp->AppendVariablesWithScope(eValueTypeVariableArgument, args);
- if (args.GetSize() > 0)
+ ExecutionContextScope *exe_scope = exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL;
+ const char *cstr = sc->function->GetName().AsCString (NULL);
+ if (cstr)
{
- const char *open_paren = strchr (cstr, '(');
- const char *close_paren = nullptr;
- const char *generic = strchr(cstr, '<');
- // if before the arguments list begins there is a template sign
- // then scan to the end of the generic args before you try to find
- // the arguments list
- if (generic && open_paren && generic < open_paren)
+ const InlineFunctionInfo *inline_info = NULL;
+ VariableListSP variable_list_sp;
+ bool get_function_vars = true;
+ if (sc->block)
{
- int generic_depth = 1;
- ++generic;
- for (;
- *generic && generic_depth > 0;
- generic++)
+ Block *inline_block = sc->block->GetContainingInlinedBlock ();
+
+ if (inline_block)
{
- if (*generic == '<')
- generic_depth++;
- if (*generic == '>')
- generic_depth--;
+ get_function_vars = false;
+ inline_info = sc->block->GetInlinedFunctionInfo();
+ if (inline_info)
+ variable_list_sp = inline_block->GetBlockVariableList (true);
}
- if (*generic)
- open_paren = strchr(generic, '(');
- else
- open_paren = nullptr;
}
- if (open_paren)
+
+ if (get_function_vars)
{
- if (IsToken (open_paren, "(anonymous namespace)"))
- {
- open_paren = strchr (open_paren + strlen("(anonymous namespace)"), '(');
- if (open_paren)
- close_paren = strchr (open_paren, ')');
- }
- else
- close_paren = strchr (open_paren, ')');
+ variable_list_sp = sc->function->GetBlock(true).GetBlockVariableList (true);
}
-
- if (open_paren)
- s.Write(cstr, open_paren - cstr + 1);
- else
+
+ if (inline_info)
{
s.PutCString (cstr);
- s.PutChar ('(');
+ s.PutCString (" [inlined] ");
+ cstr = inline_info->GetName(sc->function->GetLanguage()).GetCString();
}
- const size_t num_args = args.GetSize();
- for (size_t arg_idx = 0; arg_idx < num_args; ++arg_idx)
+
+ VariableList args;
+ if (variable_list_sp)
+ variable_list_sp->AppendVariablesWithScope(eValueTypeVariableArgument, args);
+ if (args.GetSize() > 0)
{
- std::string buffer;
-
- VariableSP var_sp (args.GetVariableAtIndex (arg_idx));
- ValueObjectSP var_value_sp (ValueObjectVariable::Create (exe_scope, var_sp));
- const char *var_representation = nullptr;
- const char *var_name = var_value_sp->GetName().GetCString();
- if (var_value_sp->GetClangType().IsAggregateType() &&
- DataVisualization::ShouldPrintAsOneLiner(*var_value_sp.get()))
+ const char *open_paren = strchr (cstr, '(');
+ const char *close_paren = nullptr;
+ const char *generic = strchr(cstr, '<');
+ // if before the arguments list begins there is a template sign
+ // then scan to the end of the generic args before you try to find
+ // the arguments list
+ if (generic && open_paren && generic < open_paren)
+ {
+ int generic_depth = 1;
+ ++generic;
+ for (;
+ *generic && generic_depth > 0;
+ generic++)
+ {
+ if (*generic == '<')
+ generic_depth++;
+ if (*generic == '>')
+ generic_depth--;
+ }
+ if (*generic)
+ open_paren = strchr(generic, '(');
+ else
+ open_paren = nullptr;
+ }
+ if (open_paren)
{
- static StringSummaryFormat format(TypeSummaryImpl::Flags()
- .SetHideItemNames(false)
- .SetShowMembersOneLiner(true),
- "");
- format.FormatObject(var_value_sp.get(), buffer, TypeSummaryOptions());
- var_representation = buffer.c_str();
+ if (IsToken (open_paren, "(anonymous namespace)"))
+ {
+ open_paren = strchr (open_paren + strlen("(anonymous namespace)"), '(');
+ if (open_paren)
+ close_paren = strchr (open_paren, ')');
+ }
+ else
+ close_paren = strchr (open_paren, ')');
}
+
+ if (open_paren)
+ s.Write(cstr, open_paren - cstr + 1);
else
- var_representation = var_value_sp->GetValueAsCString();
- if (arg_idx > 0)
- s.PutCString (", ");
- if (var_value_sp->GetError().Success())
{
- if (var_representation)
- s.Printf ("%s=%s", var_name, var_representation);
+ s.PutCString (cstr);
+ s.PutChar ('(');
+ }
+ const size_t num_args = args.GetSize();
+ for (size_t arg_idx = 0; arg_idx < num_args; ++arg_idx)
+ {
+ std::string buffer;
+
+ VariableSP var_sp (args.GetVariableAtIndex (arg_idx));
+ ValueObjectSP var_value_sp (ValueObjectVariable::Create (exe_scope, var_sp));
+ StreamString ss;
+ const char *var_representation = nullptr;
+ const char *var_name = var_value_sp->GetName().GetCString();
+ if (var_value_sp->GetCompilerType().IsValid())
+ {
+ if (var_value_sp && exe_scope->CalculateTarget())
+ var_value_sp = var_value_sp->GetQualifiedRepresentationIfAvailable(exe_scope->CalculateTarget()->TargetProperties::GetPreferDynamicValue(),
+ exe_scope->CalculateTarget()->TargetProperties::GetEnableSyntheticValue());
+ if (var_value_sp->GetCompilerType().IsAggregateType() &&
+ DataVisualization::ShouldPrintAsOneLiner(*var_value_sp.get()))
+ {
+ static StringSummaryFormat format(TypeSummaryImpl::Flags()
+ .SetHideItemNames(false)
+ .SetShowMembersOneLiner(true),
+ "");
+ format.FormatObject(var_value_sp.get(), buffer, TypeSummaryOptions());
+ var_representation = buffer.c_str();
+ }
+ else
+ var_value_sp->DumpPrintableRepresentation(ss,
+ ValueObject::ValueObjectRepresentationStyle::eValueObjectRepresentationStyleSummary,
+ eFormatDefault,
+ ValueObject::PrintableRepresentationSpecialCases::ePrintableRepresentationSpecialCasesAllow,
+ false);
+ }
+
+ if (ss.GetData() && ss.GetSize())
+ var_representation = ss.GetData();
+ if (arg_idx > 0)
+ s.PutCString (", ");
+ if (var_value_sp->GetError().Success())
+ {
+ if (var_representation)
+ s.Printf ("%s=%s", var_name, var_representation);
+ else
+ s.Printf ("%s=%s at %s", var_name, var_value_sp->GetTypeName().GetCString(), var_value_sp->GetLocationAsCString());
+ }
else
- s.Printf ("%s=%s at %s", var_name, var_value_sp->GetTypeName().GetCString(), var_value_sp->GetLocationAsCString());
+ s.Printf ("%s=<unavailable>", var_name);
}
+
+ if (close_paren)
+ s.PutCString (close_paren);
else
- s.Printf ("%s=<unavailable>", var_name);
+ s.PutChar(')');
+
}
-
- if (close_paren)
- s.PutCString (close_paren);
else
- s.PutChar(')');
-
+ {
+ s.PutCString(cstr);
+ }
+ return true;
}
- else
+ }
+ else if (sc->symbol)
+ {
+ const char *cstr = sc->symbol->GetName().AsCString (NULL);
+ if (cstr)
{
s.PutCString(cstr);
+ return true;
}
- return true;
- }
- }
- else if (sc->symbol)
- {
- const char *cstr = sc->symbol->GetName().AsCString (NULL);
- if (cstr)
- {
- s.PutCString(cstr);
- return true;
}
}
}
@@ -1870,6 +1955,16 @@ FormatEntity::Format (const Entry &entry,
case Entry::Type::FunctionChanged:
return function_changed == true;
+ case Entry::Type::FunctionIsOptimized:
+ {
+ bool is_optimized = false;
+ if (sc->function && sc->function->GetIsOptimized())
+ {
+ is_optimized = true;
+ }
+ return is_optimized;
+ }
+
case Entry::Type::FunctionInitial:
return initial_function == true;
@@ -1976,7 +2071,7 @@ ParseEntry (const llvm::StringRef &format_str,
switch (entry_def->type)
{
case FormatEntity::Entry::Type::ParentString:
- entry.string = std::move(format_str.str());
+ entry.string = format_str.str();
return error; // Success
case FormatEntity::Entry::Type::ParentNumber:
@@ -2026,7 +2121,7 @@ ParseEntry (const llvm::StringRef &format_str,
{
// Any value whose separator is a with a ':' means this value has a string argument
// that needs to be stored in the entry (like "${script.var:modulename.function}")
- entry.string = std::move(value.str());
+ entry.string = value.str();
}
else
{
@@ -2247,7 +2342,7 @@ FormatEntity::ParseInternal (llvm::StringRef &format, Entry &parent_entry, uint3
Entry entry;
if (!variable_format.empty())
{
- entry.printf_format = std::move(variable_format.str());
+ entry.printf_format = variable_format.str();
// If the format contains a '%' we are going to assume this is
// a printf style format. So if you want to format your thread ID
@@ -2396,10 +2491,10 @@ FormatEntity::ExtractVariableInfo (llvm::StringRef &format_str, llvm::StringRef
variable_name = llvm::StringRef();
variable_format = llvm::StringRef();
- const size_t paren_pos = format_str.find_first_of('}');
+ const size_t paren_pos = format_str.find('}');
if (paren_pos != llvm::StringRef::npos)
{
- const size_t percent_pos = format_str.find_first_of('%');
+ const size_t percent_pos = format_str.find('%');
if (percent_pos < paren_pos)
{
if (percent_pos > 0)
@@ -2449,7 +2544,7 @@ MakeMatch (const llvm::StringRef &prefix, const char *suffix)
{
std::string match(prefix.str());
match.append(suffix);
- return std::move(match);
+ return match;
}
static void
@@ -2463,7 +2558,7 @@ AddMatches (const FormatEntity::Entry::Definition *def,
{
for (size_t i=0; i<n; ++i)
{
- std::string match = std::move(prefix.str());
+ std::string match = prefix.str();
if (match_prefix.empty())
matches.AppendString(MakeMatch (prefix, def->children[i].name));
else if (strncmp(def->children[i].name, match_prefix.data(), match_prefix.size()) == 0)
@@ -2488,7 +2583,7 @@ FormatEntity::AutoComplete (const char *s,
// Hitting TAB after $ at the end of the string add a "{"
if (dollar_pos == str.size() - 1)
{
- std::string match = std::move(str.str());
+ std::string match = str.str();
match.append("{");
matches.AppendString(std::move(match));
}
@@ -2521,12 +2616,12 @@ FormatEntity::AutoComplete (const char *s,
if (n > 0)
{
// "${thread.info" <TAB>
- matches.AppendString(std::move(MakeMatch (str, ".")));
+ matches.AppendString(MakeMatch(str, "."));
}
else
{
// "${thread.id" <TAB>
- matches.AppendString(std::move(MakeMatch (str, "}")));
+ matches.AppendString(MakeMatch (str, "}"));
word_complete = true;
}
}
diff --git a/source/Core/IOHandler.cpp b/source/Core/IOHandler.cpp
index 0246778b0654..47d00e9184cf 100644
--- a/source/Core/IOHandler.cpp
+++ b/source/Core/IOHandler.cpp
@@ -7,9 +7,20 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+#ifndef LLDB_DISABLE_CURSES
+#include <curses.h>
+#include <panel.h>
+#endif
+// C++ Includes
+#if defined(__APPLE__)
+#include <deque>
+#endif
#include <string>
+// Other libraries and framework includes
+// Project includes
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/IOHandler.h"
#include "lldb/Core/Debugger.h"
@@ -28,10 +39,7 @@
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/ThreadPlan.h"
-#ifndef LLDB_DISABLE_CURSES
-#include <ncurses.h>
-#include <panel.h>
-#endif
+
using namespace lldb;
using namespace lldb_private;
@@ -46,7 +54,6 @@ IOHandler::IOHandler (Debugger &debugger, IOHandler::Type type) :
{
}
-
IOHandler::IOHandler (Debugger &debugger,
IOHandler::Type type,
const lldb::StreamFileSP &input_sp,
@@ -71,10 +78,7 @@ IOHandler::IOHandler (Debugger &debugger,
m_error_sp);
}
-IOHandler::~IOHandler()
-{
-}
-
+IOHandler::~IOHandler() = default;
int
IOHandler::GetInputFD()
@@ -136,7 +140,6 @@ IOHandler::GetOutputStreamFile()
return m_output_sp;
}
-
StreamFileSP &
IOHandler::GetErrorStreamFile()
{
@@ -204,10 +207,7 @@ IOHandlerConfirm::IOHandlerConfirm (Debugger &debugger,
}
-
-IOHandlerConfirm::~IOHandlerConfirm ()
-{
-}
+IOHandlerConfirm::~IOHandlerConfirm() = default;
int
IOHandlerConfirm::IOHandlerComplete (IOHandler &io_handler,
@@ -334,11 +334,9 @@ IOHandlerDelegate::IOHandlerComplete (IOHandler &io_handler,
break;
}
-
return 0;
}
-
IOHandlerEditline::IOHandlerEditline (Debugger &debugger,
IOHandler::Type type,
const char *editline_name, // Used for saving history files
@@ -444,7 +442,6 @@ IOHandlerEditline::Deactivate ()
m_delegate.IOHandlerDeactivated(*this);
}
-
bool
IOHandlerEditline::GetLine (std::string &line, bool &interrupted)
{
@@ -619,7 +616,6 @@ IOHandlerEditline::GetContinuationPrompt ()
return m_continuation_prompt.c_str();
}
-
void
IOHandlerEditline::SetContinuationPrompt (const char *p)
{
@@ -634,7 +630,6 @@ IOHandlerEditline::SetContinuationPrompt (const char *p)
#endif
}
-
void
IOHandlerEditline::SetBaseLineNumber (uint32_t line)
{
@@ -824,6 +819,7 @@ type summary add -s "x=${var.x}, y=${var.y}" curses::Point
type summary add -s "w=${var.width}, h=${var.height}" curses::Size
type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
#endif
+
struct Point
{
int x;
@@ -855,13 +851,13 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
{
printf ("(x=%i, y=%i)\n", x, y);
}
-
};
bool operator == (const Point &lhs, const Point &rhs)
{
return lhs.x == rhs.x && lhs.y == rhs.y;
}
+
bool operator != (const Point &lhs, const Point &rhs)
{
return lhs.x != rhs.x || lhs.y != rhs.y;
@@ -889,13 +885,13 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
{
printf ("(w=%i, h=%i)\n", width, height);
}
-
};
bool operator == (const Size &lhs, const Size &rhs)
{
return lhs.width == rhs.width && lhs.height == rhs.height;
}
+
bool operator != (const Size &lhs, const Size &rhs)
{
return lhs.width != rhs.width || lhs.height != rhs.height;
@@ -942,6 +938,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
size.height -= h*2;
origin.y += h;
}
+
// Return a status bar rectangle which is the last line of
// this rectangle. This rectangle will be modified to not
// include the status bar area.
@@ -1011,7 +1008,6 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
VerticalSplit (left_width, left, right);
}
-
void
VerticalSplit (int left_width, Rect &left, Rect &right) const
{
@@ -1035,6 +1031,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
{
return lhs.origin == rhs.origin && lhs.size == rhs.size;
}
+
bool operator != (const Rect &lhs, const Rect &rhs)
{
return lhs.origin != rhs.origin || lhs.size != rhs.size;
@@ -1064,9 +1061,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
{
public:
virtual
- ~WindowDelegate()
- {
- }
+ ~WindowDelegate() = default;
virtual bool
WindowDelegateDraw (Window &window, bool force)
@@ -1098,9 +1093,9 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
{
public:
HelpDialogDelegate (const char *text, KeyHelp *key_help_array);
-
+
~HelpDialogDelegate() override;
-
+
bool
WindowDelegateDraw (Window &window, bool force) override;
@@ -1124,11 +1119,9 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
int m_first_visible_line;
};
-
class Window
{
public:
-
Window (const char *name) :
m_name (name),
m_window (NULL),
@@ -1726,6 +1719,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
{
return m_name.c_str();
}
+
protected:
std::string m_name;
WINDOW *m_window;
@@ -1747,8 +1741,8 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
class MenuDelegate
{
public:
- virtual ~MenuDelegate() {}
-
+ virtual ~MenuDelegate() = default;
+
virtual MenuActionResult
MenuDelegateAction (Menu &menu) = 0;
};
@@ -1772,10 +1766,8 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
const char *key_name,
int key_value,
uint64_t identifier);
-
- ~Menu () override
- {
- }
+
+ ~Menu() override = default;
const MenuDelegateSP &
GetDelegate () const
@@ -1912,7 +1904,6 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
return m_max_submenu_name_length + m_max_submenu_key_name_length + 8;
}
-
uint64_t
GetIdentifier() const
{
@@ -2223,7 +2214,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
{
// Run the action on this menu in case we need to populate the
// menu with dynamic content and also in case check marks, and
- // any other menu decorations need to be caclulated
+ // any other menu decorations need to be calculated
if (run_menu_sp->Action() == MenuActionResult::Quit)
return eQuitApplication;
@@ -2314,12 +2305,10 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
}
else if (menu_type == Menu::Type::Separator)
{
-
}
return result;
}
-
class Application
{
public:
@@ -2496,7 +2485,6 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
}
debugger.CancelForwardEvents (listener_sp);
-
}
WindowSP &
@@ -2520,11 +2508,9 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
FILE *m_in;
FILE *m_out;
};
-
} // namespace curses
-
using namespace curses;
struct Row
@@ -2661,11 +2647,13 @@ class TreeDelegate
{
public:
TreeDelegate() {}
- virtual ~TreeDelegate() {}
+ virtual ~TreeDelegate() = default;
+
virtual void TreeDelegateDrawTreeItem (TreeItem &item, Window &window) = 0;
virtual void TreeDelegateGenerateChildren (TreeItem &item) = 0;
virtual bool TreeDelegateItemSelected (TreeItem &item) = 0; // Return true if we need to update views
};
+
typedef std::shared_ptr<TreeDelegate> TreeDelegateSP;
class TreeItem
@@ -2751,6 +2739,7 @@ public:
{
m_delegate.TreeDelegateItemSelected(*this);
}
+
void
CalculateRowIndexes (int &row_idx)
{
@@ -2944,7 +2933,6 @@ public:
{
m_identifier = identifier;
}
-
void
SetMightHaveChildren (bool b)
@@ -2961,7 +2949,6 @@ protected:
std::vector<TreeItem> m_children;
bool m_might_have_children;
bool m_is_expanded;
-
};
class TreeWindowDelegate : public WindowDelegate
@@ -3052,8 +3039,7 @@ public:
return true; // Drawing handled
}
-
-
+
const char *
WindowDelegateGetHelpText () override
{
@@ -3125,6 +3111,7 @@ public:
m_selected_item->ItemWasSelected ();
}
return eKeyHandled;
+
case KEY_DOWN:
if (m_selected_row_idx + 1 < m_num_rows)
{
@@ -3191,7 +3178,6 @@ protected:
int m_min_y;
int m_max_x;
int m_max_y;
-
};
class FrameTreeDelegate : public TreeDelegate
@@ -3203,11 +3189,9 @@ public:
FormatEntity::Parse ("frame #${frame.index}: {${function.name}${function.pc-offset}}}",
m_format);
}
-
- ~FrameTreeDelegate() override
- {
- }
-
+
+ ~FrameTreeDelegate() override = default;
+
void
TreeDelegateDrawTreeItem (TreeItem &item, Window &window) override
{
@@ -3229,6 +3213,7 @@ public:
}
}
}
+
void
TreeDelegateGenerateChildren (TreeItem &item) override
{
@@ -3248,6 +3233,7 @@ public:
}
return false;
}
+
protected:
FormatEntity::Entry m_format;
};
@@ -3264,11 +3250,9 @@ public:
FormatEntity::Parse ("thread #${thread.index}: tid = ${thread.id}{, stop reason = ${thread.stop-reason}}",
m_format);
}
-
- ~ThreadTreeDelegate() override
- {
- }
-
+
+ ~ThreadTreeDelegate() override = default;
+
ProcessSP
GetProcess ()
{
@@ -3299,6 +3283,7 @@ public:
}
}
}
+
void
TreeDelegateGenerateChildren (TreeItem &item) override
{
@@ -3369,7 +3354,6 @@ protected:
lldb::user_id_t m_tid;
uint32_t m_stop_id;
FormatEntity::Entry m_format;
-
};
class ThreadsTreeDelegate : public TreeDelegate
@@ -3384,11 +3368,9 @@ public:
FormatEntity::Parse("process ${process.id}{, name = ${process.name}}",
m_format);
}
-
- ~ThreadsTreeDelegate() override
- {
- }
-
+
+ ~ThreadsTreeDelegate() override = default;
+
ProcessSP
GetProcess ()
{
@@ -3460,7 +3442,6 @@ protected:
Debugger &m_debugger;
uint32_t m_stop_id;
FormatEntity::Entry m_format;
-
};
class ValueObjectListDelegate : public WindowDelegate
@@ -3490,10 +3471,8 @@ public:
{
SetValues (valobj_list);
}
-
- ~ValueObjectListDelegate() override
- {
- }
+
+ ~ValueObjectListDelegate() override = default;
void
SetValues (ValueObjectList &valobj_list)
@@ -3586,7 +3565,6 @@ public:
return g_source_view_key_help;
}
-
HandleCharResult
WindowDelegateHandleChar (Window &window, int c) override
{
@@ -3646,6 +3624,7 @@ public:
if (m_selected_row_idx > 0)
--m_selected_row_idx;
return eKeyHandled;
+
case KEY_DOWN:
if (m_selected_row_idx + 1 < m_num_rows)
++m_selected_row_idx;
@@ -3784,6 +3763,7 @@ protected:
return true;
}
+
void
DisplayRows (Window &window,
std::vector<Row> &rows,
@@ -3845,6 +3825,7 @@ protected:
}
return row_count;
}
+
static Row *
GetRowForRowIndexImpl (std::vector<Row> &rows, size_t &row_index)
{
@@ -3890,11 +3871,9 @@ public:
m_frame_block (NULL)
{
}
-
- ~FrameVariablesWindowDelegate() override
- {
- }
-
+
+ ~FrameVariablesWindowDelegate() override = default;
+
const char *
WindowDelegateGetHelpText () override
{
@@ -3924,7 +3903,6 @@ public:
}
}
-
ValueObjectList local_values;
if (frame_block)
{
@@ -3964,7 +3942,6 @@ public:
}
return ValueObjectListDelegate::WindowDelegateDraw (window, force);
-
}
protected:
@@ -3972,7 +3949,6 @@ protected:
Block *m_frame_block;
};
-
class RegistersWindowDelegate : public ValueObjectListDelegate
{
public:
@@ -3982,10 +3958,8 @@ public:
{
}
- ~RegistersWindowDelegate()
- {
- }
-
+ ~RegistersWindowDelegate() override = default;
+
const char *
WindowDelegateGetHelpText () override
{
@@ -4133,7 +4107,9 @@ CursesKeyToCString (int ch)
case KEY_UNDO: return "undo key";
case KEY_MOUSE: return "Mouse event has occurred";
case KEY_RESIZE: return "Terminal resize event";
+#ifdef KEY_EVENT
case KEY_EVENT: return "We were interrupted by an event";
+#endif
case KEY_RETURN: return "return";
case ' ': return "space";
case '\t': return "tab";
@@ -4168,9 +4144,7 @@ HelpDialogDelegate::HelpDialogDelegate (const char *text, KeyHelp *key_help_arra
}
}
-HelpDialogDelegate::~HelpDialogDelegate()
-{
-}
+HelpDialogDelegate::~HelpDialogDelegate() = default;
bool
HelpDialogDelegate::WindowDelegateDraw (Window &window, bool force)
@@ -4235,6 +4209,7 @@ HelpDialogDelegate::WindowDelegateHandleChar (Window &window, int key)
m_first_visible_line = 0;
}
break;
+
case KEY_NPAGE:
case '.':
if (m_first_visible_line + num_visible_lines < num_lines)
@@ -4244,6 +4219,7 @@ HelpDialogDelegate::WindowDelegateHandleChar (Window &window, int key)
m_first_visible_line = num_lines - num_visible_lines;
}
break;
+
default:
done = true;
break;
@@ -4298,10 +4274,8 @@ public:
m_debugger (debugger)
{
}
-
- ~ApplicationDelegate ()
- {
- }
+
+ ~ApplicationDelegate() override = default;
bool
WindowDelegateDraw (Window &window, bool force) override
@@ -4330,8 +4304,7 @@ public:
}
return eKeyNotHandled;
}
-
-
+
const char *
WindowDelegateGetHelpText () override
{
@@ -4626,7 +4599,6 @@ protected:
Debugger &m_debugger;
};
-
class StatusBarWindowDelegate : public WindowDelegate
{
public:
@@ -4636,10 +4608,8 @@ public:
FormatEntity::Parse("Thread: ${thread.id%tid}",
m_format);
}
-
- ~StatusBarWindowDelegate ()
- {
- }
+
+ ~StatusBarWindowDelegate() override = default;
bool
WindowDelegateDraw (Window &window, bool force) override
@@ -4713,9 +4683,7 @@ public:
{
}
- ~SourceFileWindowDelegate() override
- {
- }
+ ~SourceFileWindowDelegate() override = default;
void
Update (const SymbolContext &sc)
@@ -5063,7 +5031,6 @@ public:
}
if (highlight_attr)
window.AttributeOff(highlight_attr);
-
}
else
{
@@ -5240,6 +5207,7 @@ public:
return m_file_sp->GetNumLines();
return 0;
}
+
size_t
GetNumDisassemblyLines () const
{
@@ -5404,6 +5372,7 @@ public:
}
}
return eKeyHandled;
+
case 'n': // 'n' == step over
case 'N': // 'N' == step over instruction
{
@@ -5415,6 +5384,7 @@ public:
}
}
return eKeyHandled;
+
case 's': // 's' == step into
case 'S': // 'S' == step into instruction
{
@@ -5460,7 +5430,6 @@ protected:
int m_min_y;
int m_max_x;
int m_max_y;
-
};
DisplayOptions ValueObjectListDelegate::g_options = { true };
@@ -5477,8 +5446,7 @@ IOHandlerCursesGUI::Activate ()
if (!m_app_ap)
{
m_app_ap.reset (new Application (GetInputFILE(), GetOutputFILE()));
-
-
+
// This is both a window and a menu delegate
std::shared_ptr<ApplicationDelegate> app_delegate_sp(new ApplicationDelegate(*m_app_ap, m_debugger));
@@ -5578,7 +5546,6 @@ IOHandlerCursesGUI::Activate ()
init_pair (3, COLOR_MAGENTA , COLOR_WHITE );
init_pair (4, COLOR_MAGENTA , COLOR_BLACK );
init_pair (5, COLOR_RED , COLOR_BLACK );
-
}
}
@@ -5595,11 +5562,7 @@ IOHandlerCursesGUI::Run ()
SetIsDone(true);
}
-
-IOHandlerCursesGUI::~IOHandlerCursesGUI ()
-{
-
-}
+IOHandlerCursesGUI::~IOHandlerCursesGUI() = default;
void
IOHandlerCursesGUI::Cancel ()
@@ -5612,10 +5575,9 @@ IOHandlerCursesGUI::Interrupt ()
return false;
}
-
void
IOHandlerCursesGUI::GotEOF()
{
}
-#endif // #ifndef LLDB_DISABLE_CURSES
+#endif // LLDB_DISABLE_CURSES
diff --git a/source/Core/Language.cpp b/source/Core/Language.cpp
deleted file mode 100644
index 1cc4b8a0dc9c..000000000000
--- a/source/Core/Language.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-//===-- Language.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/lldb-private.h"
-#include "lldb/Core/Language.h"
-#include "lldb/Core/Stream.h"
-#include "llvm/ADT/STLExtras.h"
-#include <string.h>
-
-using namespace lldb;
-using namespace lldb_private;
-
-#define ENUM_TO_DCSTREAM(x) case x: s->PutCString(#x); return
-
-struct LanguageStrings
-{
- const char * names[3];
-};
-
-static LanguageStrings
-g_languages[] =
-{
- { { "unknown" , NULL , NULL } },
- { { "c89" , NULL , "ISO C:1989" } },
- { { NULL , NULL , "K&R C" } },
- { { "ada83" , "Ada83" , "ISO Ada:1983" } },
- { { "c++" , "cxx" , "ISO C++:1998" } },
- { { "cobol74" , "Cobol74" , "ISO Cobol:1974" } },
- { { "cobol" , "Cobol85" , "ISO Cobol:1985." } },
- { { "f77" , "Fortran77" , "ISO Fortran 77." } },
- { { "f90" , "Fortran90" , "ISO Fortran 90" } },
- { { "pascal" , "Pascal83" , "ISO Pascal:1983" } },
- { { "modula2" , "Modula2" , "ISO Modula-2:1996" } },
- { { "java" , NULL , "Java" } },
- { { "c" , "C99" , "ISO C:1999" } },
- { { "ada" , "Ada95" , "ISO Ada:1995" } },
- { { "f95" , "Fortran95" , "ISO Fortran 95" } },
- { { "PLI" , NULL , "ANSI PL/I:1976" } },
- { { "objc" , NULL , "Objective-C" } },
- { { "objc++" , NULL , "Objective-C++" } },
- { { "upc" , NULL , "Unified Parallel C" } },
- { { "d" , NULL , "D" } },
- { { "python" , NULL , "Python" } },
- { { "opencl" , "OpenCL" , "OpenCL" } },
- { { "go" , "Go" , "Go" } },
- { { "modula3" , "Modula3" , "Modula 3" } },
- { { "haskell" , "Haskell" , "Haskell" } },
- { { "c++03" , "C_plus_plus_03" , "ISO C++:2003" } },
- { { "c++11" , "C_plus_plus_11" , "ISO C++:2011" } },
- { { "ocaml" , "OCaml" , "OCaml" } },
- { { "rust" , "Rust" , "Rust" } },
- { { "c11" , "C11" , "ISO C:2011" } },
- { { "swift" , "Swift" , "Swift" } },
- { { "julia" , "Julia" , "Julia" } },
- { { "dylan" , "Dylan" , "Dylan" } },
- { { "c++14" , "C_plus_plus_14" , "ISO C++:2014" } },
- { { "f03" , "Fortran03" , "ISO Fortran 2003" } },
- { { "f08" , "Fortran08" , "ISO Fortran 2008" } },
- // Vendor Extensions
- { { "mipsassem" , "Mips_Assembler" , "Mips Assembler" } },
- { { "renderscript" , "RenderScript" , "RenderScript" } }
-};
-
-static const size_t g_num_languages = llvm::array_lengthof(g_languages);
-
-Language::Language(LanguageType language) :
- m_language (language)
-{
-}
-
-Language::~Language()
-{
-}
-
-LanguageType
-Language::GetLanguage() const
-{
- return m_language;
-}
-
-void
-Language::Clear ()
-{
- m_language = eLanguageTypeUnknown;
-}
-
-void
-Language::SetLanguage(LanguageType language)
-{
- m_language = language;
-}
-
-bool
-Language::SetLanguageFromCString(const char *language_cstr)
-{
- size_t i, desc_idx;
- const char *name;
-
- // First check the most common name for the languages
- for (desc_idx=lldb::eDescriptionLevelBrief; desc_idx<kNumDescriptionLevels; ++desc_idx)
- {
- for (i=0; i<g_num_languages; ++i)
- {
- name = g_languages[i].names[desc_idx];
- if (name == NULL)
- continue;
-
- if (::strcasecmp (language_cstr, name) == 0)
- {
- m_language = (LanguageType)i;
- return true;
- }
- }
- }
-
- m_language = eLanguageTypeUnknown;
- return false;
-}
-
-
-const char *
-Language::AsCString (lldb::DescriptionLevel level) const
-{
- if (m_language < g_num_languages && level < kNumDescriptionLevels)
- {
- const char *name = g_languages[m_language].names[level];
- if (name)
- return name;
- else if (level + 1 < kNumDescriptionLevels)
- return AsCString ((lldb::DescriptionLevel)(level + 1));
- else
- return NULL;
- }
- return NULL;
-}
-
-void
-Language::Dump(Stream *s) const
-{
- GetDescription(s, lldb::eDescriptionLevelVerbose);
-}
-
-void
-Language::GetDescription (Stream *s, lldb::DescriptionLevel level) const
-{
- const char *lang_cstr = AsCString(level);
-
- if (lang_cstr)
- s->PutCString(lang_cstr);
- else
- s->Printf("Language(language = 0x%4.4x)", m_language);
-}
-
-
-
-
-Stream&
-lldb_private::operator << (Stream& s, const Language& language)
-{
- language.Dump(&s);
- return s;
-}
-
diff --git a/source/Core/Log.cpp b/source/Core/Log.cpp
index 6acd50eec76a..8d415bdc0e77 100644
--- a/source/Core/Log.cpp
+++ b/source/Core/Log.cpp
@@ -143,6 +143,7 @@ Log::VAPrintf(const char *format, va_list args)
std::string back_trace;
llvm::raw_string_ostream stream(back_trace);
llvm::sys::PrintStackTrace(stream);
+ stream.flush();
header.PutCString(back_trace.c_str());
}
@@ -449,7 +450,7 @@ Log::DisableAllLogChannels (Stream *feedback_strm)
{
CallbackMap &callback_map = GetCallbackMap ();
CallbackMapIter pos, end = callback_map.end();
- const char *categories[1] = {NULL};
+ const char *categories[] = {"all", nullptr};
for (pos = callback_map.begin(); pos != end; ++pos)
pos->second.disable (categories, feedback_strm);
diff --git a/source/Core/Logging.cpp b/source/Core/Logging.cpp
index 412536adbb34..d08d833ee469 100644
--- a/source/Core/Logging.cpp
+++ b/source/Core/Logging.cpp
@@ -148,6 +148,7 @@ lldb_private::DisableLog (const char **categories, Stream *feedback_strm)
else if (0 == ::strcasecmp(arg, "os")) flag_bits &= ~LIBLLDB_LOG_OS;
else if (0 == ::strcasecmp(arg, "jit")) flag_bits &= ~LIBLLDB_LOG_JIT_LOADER;
else if (0 == ::strcasecmp(arg, "language")) flag_bits &= ~LIBLLDB_LOG_LANGUAGE;
+ else if (0 == ::strncasecmp(arg, "formatters", 10)) flag_bits &= ~LIBLLDB_LOG_DATAFORMATTERS;
else
{
feedback_strm->Printf ("error: unrecognized log category '%s'\n", arg);
@@ -224,6 +225,7 @@ lldb_private::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, const ch
else if (0 == ::strncasecmp(arg, "watch", 5)) flag_bits |= LIBLLDB_LOG_WATCHPOINTS;
else if (0 == ::strcasecmp(arg, "jit")) flag_bits |= LIBLLDB_LOG_JIT_LOADER;
else if (0 == ::strcasecmp(arg, "language")) flag_bits |= LIBLLDB_LOG_LANGUAGE;
+ else if (0 == ::strncasecmp(arg, "formatters", 10)) flag_bits |= LIBLLDB_LOG_DATAFORMATTERS;
else
{
feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
@@ -254,6 +256,7 @@ lldb_private::ListLogCategories (Stream *strm)
" dyld - log shared library related activities\n"
" events - log broadcaster, listener and event queue activities\n"
" expr - log expressions\n"
+ " formatters - log data formatters related activities\n"
" host - log host activities\n"
" jit - log JIT events in the target\n"
" language - log language runtime events\n"
diff --git a/source/Core/Mangled.cpp b/source/Core/Mangled.cpp
index a1916fe913c4..bdc710c8f8e1 100644
--- a/source/Core/Mangled.cpp
+++ b/source/Core/Mangled.cpp
@@ -38,7 +38,8 @@
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/Timer.h"
-#include "lldb/Target/CPPLanguageRuntime.h"
+#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
+#include "Plugins/Language/ObjC/ObjCLanguage.h"
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
@@ -94,11 +95,12 @@ get_demangled_name_without_arguments (ConstString mangled, ConstString demangled
mangled_name_cstr[2] != 'G' && // avoid guard variables
mangled_name_cstr[2] != 'Z')) // named local entities (if we eventually handle eSymbolTypeData, we will want this back)
{
- CPPLanguageRuntime::MethodName cxx_method (demangled);
- if (!cxx_method.GetBasename().empty() && !cxx_method.GetContext().empty())
+ CPlusPlusLanguage::MethodName cxx_method (demangled);
+ if (!cxx_method.GetBasename().empty())
{
- std::string shortname = cxx_method.GetContext().str();
- shortname += "::";
+ std::string shortname;
+ if (!cxx_method.GetContext().empty())
+ shortname = cxx_method.GetContext().str() + "::";
shortname += cxx_method.GetBasename().str();
ConstString result(shortname.c_str());
g_most_recent_mangled_to_name_sans_args.first = mangled;
@@ -360,6 +362,9 @@ Mangled::NameMatches (const RegularExpression& regex, lldb::LanguageType languag
ConstString
Mangled::GetName (lldb::LanguageType language, Mangled::NamePreference preference) const
{
+ if (preference == ePreferMangled && m_mangled)
+ return m_mangled;
+
ConstString demangled = GetDemangledName(language);
if (preference == ePreferDemangledWithoutArguments)
@@ -374,12 +379,7 @@ Mangled::GetName (lldb::LanguageType language, Mangled::NamePreference preferenc
return demangled;
return m_mangled;
}
- else
- {
- if (m_mangled)
- return m_mangled;
- return demangled;
- }
+ return demangled;
}
//----------------------------------------------------------------------
@@ -425,6 +425,14 @@ 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
{
@@ -433,11 +441,14 @@ Mangled::GuessLanguage () const
{
if (GetDemangledName(lldb::eLanguageTypeUnknown))
{
- if (cstring_is_mangled(mangled.GetCString()))
+ 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;
}
}
- return lldb::eLanguageTypeUnknown;
+ return lldb::eLanguageTypeUnknown;
}
//----------------------------------------------------------------------
diff --git a/source/Core/Module.cpp b/source/Core/Module.cpp
index eb0359d02d5b..833540e1a309 100644
--- a/source/Core/Module.cpp
+++ b/source/Core/Module.cpp
@@ -15,6 +15,7 @@
#include "lldb/Core/Log.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/StreamString.h"
@@ -23,17 +24,19 @@
#include "lldb/Host/Symbols.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/SymbolVendor.h"
-#include "lldb/Target/CPPLanguageRuntime.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Symbol/TypeSystem.h"
+#include "lldb/Target/Language.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
-#include "lldb/Symbol/SymbolFile.h"
+#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
+#include "Plugins/Language/ObjC/ObjCLanguage.h"
+#include "lldb/Symbol/TypeMap.h"
#include "Plugins/ObjectFile/JIT/ObjectFileJIT.h"
@@ -146,13 +149,12 @@ Module::Module (const ModuleSpec &module_spec) :
m_object_mod_time (),
m_objfile_sp (),
m_symfile_ap (),
- m_ast (new ClangASTContext),
+ m_type_system_map(),
m_source_mappings (),
m_sections_ap(),
m_did_load_objfile (false),
m_did_load_symbol_vendor (false),
m_did_parse_uuid (false),
- m_did_init_ast (false),
m_file_has_changed (false),
m_first_file_changed_log (false)
{
@@ -250,13 +252,12 @@ Module::Module(const FileSpec& file_spec,
m_object_mod_time (),
m_objfile_sp (),
m_symfile_ap (),
- m_ast (new ClangASTContext),
+ m_type_system_map(),
m_source_mappings (),
m_sections_ap(),
m_did_load_objfile (false),
m_did_load_symbol_vendor (false),
m_did_parse_uuid (false),
- m_did_init_ast (false),
m_file_has_changed (false),
m_first_file_changed_log (false)
{
@@ -296,13 +297,12 @@ Module::Module () :
m_object_mod_time (),
m_objfile_sp (),
m_symfile_ap (),
- m_ast (new ClangASTContext),
+ m_type_system_map(),
m_source_mappings (),
m_sections_ap(),
m_did_load_objfile (false),
m_did_load_symbol_vendor (false),
m_did_parse_uuid (false),
- m_did_init_ast (false),
m_file_has_changed (false),
m_first_file_changed_log (false)
{
@@ -399,52 +399,27 @@ Module::GetMemoryObjectFile (const lldb::ProcessSP &process_sp, lldb::addr_t hea
const lldb_private::UUID&
Module::GetUUID()
{
- Mutex::Locker locker (m_mutex);
- if (m_did_parse_uuid == false)
+ if (m_did_parse_uuid.load() == false)
{
- ObjectFile * obj_file = GetObjectFile ();
-
- if (obj_file != NULL)
+ Mutex::Locker locker (m_mutex);
+ if (m_did_parse_uuid.load() == false)
{
- obj_file->GetUUID(&m_uuid);
- m_did_parse_uuid = true;
+ ObjectFile * obj_file = GetObjectFile ();
+
+ if (obj_file != NULL)
+ {
+ obj_file->GetUUID(&m_uuid);
+ m_did_parse_uuid = true;
+ }
}
}
return m_uuid;
}
-ClangASTContext &
-Module::GetClangASTContext ()
+TypeSystem *
+Module::GetTypeSystemForLanguage (LanguageType language)
{
- Mutex::Locker locker (m_mutex);
- if (m_did_init_ast == false)
- {
- ObjectFile * objfile = GetObjectFile();
- ArchSpec object_arch;
- if (objfile && objfile->GetArchitecture(object_arch))
- {
- m_did_init_ast = true;
-
- // LLVM wants this to be set to iOS or MacOSX; if we're working on
- // a bare-boards type image, change the triple for llvm's benefit.
- if (object_arch.GetTriple().getVendor() == llvm::Triple::Apple
- && object_arch.GetTriple().getOS() == llvm::Triple::UnknownOS)
- {
- if (object_arch.GetTriple().getArch() == llvm::Triple::arm ||
- object_arch.GetTriple().getArch() == llvm::Triple::aarch64 ||
- object_arch.GetTriple().getArch() == llvm::Triple::thumb)
- {
- object_arch.GetTriple().setOS(llvm::Triple::IOS);
- }
- else
- {
- object_arch.GetTriple().setOS(llvm::Triple::MacOSX);
- }
- }
- m_ast->SetArchitecture (object_arch);
- }
- }
- return *m_ast;
+ return m_type_system_map.GetTypeSystemForLanguage(language, this, true);
}
void
@@ -706,14 +681,14 @@ Module::ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t li
size_t
Module::FindGlobalVariables (const ConstString &name,
- const ClangNamespaceDecl *namespace_decl,
+ const CompilerDeclContext *parent_decl_ctx,
bool append,
size_t max_matches,
VariableList& variables)
{
SymbolVendor *symbols = GetSymbolVendor ();
if (symbols)
- return symbols->FindGlobalVariables(name, namespace_decl, append, max_matches, variables);
+ return symbols->FindGlobalVariables(name, parent_decl_ctx, append, max_matches, variables);
return 0;
}
@@ -756,7 +731,7 @@ Module::FindCompileUnits (const FileSpec &path,
size_t
Module::FindFunctions (const ConstString &name,
- const ClangNamespaceDecl *namespace_decl,
+ const CompilerDeclContext *parent_decl_ctx,
uint32_t name_type_mask,
bool include_symbols,
bool include_inlines,
@@ -778,6 +753,7 @@ Module::FindFunctions (const ConstString &name,
bool match_name_after_lookup = false;
Module::PrepareForFunctionNameLookup (name,
name_type_mask,
+ eLanguageTypeUnknown, // TODO: add support
lookup_name,
lookup_name_type_mask,
match_name_after_lookup);
@@ -785,7 +761,7 @@ Module::FindFunctions (const ConstString &name,
if (symbols)
{
symbols->FindFunctions(lookup_name,
- namespace_decl,
+ parent_decl_ctx,
lookup_name_type_mask,
include_inlines,
append,
@@ -825,7 +801,7 @@ Module::FindFunctions (const ConstString &name,
{
if (symbols)
{
- symbols->FindFunctions(name, namespace_decl, name_type_mask, include_inlines, append, sc_list);
+ symbols->FindFunctions(name, parent_decl_ctx, name_type_mask, include_inlines, append, sc_list);
// Now check our symbol table for symbols that are code symbols if requested
if (include_symbols)
@@ -943,17 +919,17 @@ Module::FindAddressesForLine (const lldb::TargetSP target_sp,
size_t
Module::FindTypes_Impl (const SymbolContext& sc,
const ConstString &name,
- const ClangNamespaceDecl *namespace_decl,
+ const CompilerDeclContext *parent_decl_ctx,
bool append,
size_t max_matches,
- TypeList& types)
+ TypeMap& types)
{
Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
if (sc.module_sp.get() == NULL || sc.module_sp.get() == this)
{
SymbolVendor *symbols = GetSymbolVendor ();
if (symbols)
- return symbols->FindTypes(sc, name, namespace_decl, append, max_matches, types);
+ return symbols->FindTypes(sc, name, parent_decl_ctx, append, max_matches, types);
}
return 0;
}
@@ -961,12 +937,16 @@ Module::FindTypes_Impl (const SymbolContext& sc,
size_t
Module::FindTypesInNamespace (const SymbolContext& sc,
const ConstString &type_name,
- const ClangNamespaceDecl *namespace_decl,
+ const CompilerDeclContext *parent_decl_ctx,
size_t max_matches,
TypeList& type_list)
{
const bool append = true;
- return FindTypes_Impl(sc, type_name, namespace_decl, append, max_matches, type_list);
+ TypeMap types_map;
+ size_t num_types = FindTypes_Impl(sc, type_name, parent_decl_ctx, append, max_matches, types_map);
+ if (num_types > 0)
+ sc.SortTypeList(types_map, type_list);
+ return num_types;
}
lldb::TypeSP
@@ -995,6 +975,7 @@ Module::FindTypes (const SymbolContext& sc,
std::string type_basename;
const bool append = true;
TypeClass type_class = eTypeClassAny;
+ TypeMap typesmap;
if (Type::GetTypeScopeAndBasename (type_name_cstr, type_scope, type_basename, type_class))
{
// Check if "name" starts with "::" which means the qualified type starts
@@ -1008,10 +989,10 @@ Module::FindTypes (const SymbolContext& sc,
exact_match = true;
}
ConstString type_basename_const_str (type_basename.c_str());
- if (FindTypes_Impl(sc, type_basename_const_str, NULL, append, max_matches, types))
+ if (FindTypes_Impl(sc, type_basename_const_str, NULL, append, max_matches, typesmap))
{
- types.RemoveMismatchedTypes (type_scope, type_basename, type_class, exact_match);
- num_matches = types.GetSize();
+ typesmap.RemoveMismatchedTypes (type_scope, type_basename, type_class, exact_match);
+ num_matches = typesmap.GetSize();
}
}
else
@@ -1021,32 +1002,35 @@ Module::FindTypes (const SymbolContext& sc,
{
// The "type_name_cstr" will have been modified if we have a valid type class
// prefix (like "struct", "class", "union", "typedef" etc).
- FindTypes_Impl(sc, ConstString(type_name_cstr), NULL, append, max_matches, types);
- types.RemoveMismatchedTypes (type_class);
- num_matches = types.GetSize();
+ FindTypes_Impl(sc, ConstString(type_name_cstr), NULL, append, max_matches, typesmap);
+ typesmap.RemoveMismatchedTypes (type_class);
+ num_matches = typesmap.GetSize();
}
else
{
- num_matches = FindTypes_Impl(sc, name, NULL, append, max_matches, types);
+ num_matches = FindTypes_Impl(sc, name, NULL, append, max_matches, typesmap);
}
}
-
+ if (num_matches > 0)
+ sc.SortTypeList(typesmap, types);
return num_matches;
-
}
SymbolVendor*
Module::GetSymbolVendor (bool can_create, lldb_private::Stream *feedback_strm)
{
- Mutex::Locker locker (m_mutex);
- if (m_did_load_symbol_vendor == false && can_create)
+ if (m_did_load_symbol_vendor.load() == false)
{
- ObjectFile *obj_file = GetObjectFile ();
- if (obj_file != NULL)
+ Mutex::Locker locker (m_mutex);
+ if (m_did_load_symbol_vendor.load() == false && can_create)
{
- Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
- m_symfile_ap.reset(SymbolVendor::FindPlugin(shared_from_this(), feedback_strm));
- m_did_load_symbol_vendor = true;
+ ObjectFile *obj_file = GetObjectFile ();
+ if (obj_file != NULL)
+ {
+ Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
+ m_symfile_ap.reset(SymbolVendor::FindPlugin(shared_from_this(), feedback_strm));
+ m_did_load_symbol_vendor = true;
+ }
}
}
return m_symfile_ap.get();
@@ -1287,37 +1271,40 @@ Module::GetObjectName() const
ObjectFile *
Module::GetObjectFile()
{
- Mutex::Locker locker (m_mutex);
- if (m_did_load_objfile == false)
+ if (m_did_load_objfile.load() == false)
{
- Timer scoped_timer(__PRETTY_FUNCTION__,
- "Module::GetObjectFile () module = %s", GetFileSpec().GetFilename().AsCString(""));
- DataBufferSP data_sp;
- lldb::offset_t data_offset = 0;
- const lldb::offset_t file_size = m_file.GetByteSize();
- if (file_size > m_object_offset)
+ Mutex::Locker locker (m_mutex);
+ if (m_did_load_objfile.load() == false)
{
- m_did_load_objfile = true;
- m_objfile_sp = ObjectFile::FindPlugin (shared_from_this(),
- &m_file,
- m_object_offset,
- file_size - m_object_offset,
- data_sp,
- data_offset);
- if (m_objfile_sp)
+ Timer scoped_timer(__PRETTY_FUNCTION__,
+ "Module::GetObjectFile () module = %s", GetFileSpec().GetFilename().AsCString(""));
+ DataBufferSP data_sp;
+ lldb::offset_t data_offset = 0;
+ const lldb::offset_t file_size = m_file.GetByteSize();
+ if (file_size > m_object_offset)
{
- // 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. But since the matching arch might already be more specific
- // than the generic COFF architecture, only merge in those values that
- // overwrite unspecified unknown values.
- ArchSpec new_arch;
- m_objfile_sp->GetArchitecture(new_arch);
- m_arch.MergeFrom(new_arch);
- }
- else
- {
- ReportError ("failed to load objfile for %s", GetFileSpec().GetPath().c_str());
+ m_did_load_objfile = true;
+ m_objfile_sp = ObjectFile::FindPlugin (shared_from_this(),
+ &m_file,
+ m_object_offset,
+ file_size - m_object_offset,
+ data_sp,
+ data_offset);
+ if (m_objfile_sp)
+ {
+ // 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. But since the matching arch might already be more specific
+ // than the generic COFF architecture, only merge in those values that
+ // overwrite unspecified unknown values.
+ ArchSpec new_arch;
+ m_objfile_sp->GetArchitecture(new_arch);
+ m_arch.MergeFrom(new_arch);
+ }
+ else
+ {
+ ReportError ("failed to load objfile for %s", GetFileSpec().GetPath().c_str());
+ }
}
}
}
@@ -1487,6 +1474,9 @@ Module::SetSymbolFileFileSpec (const FileSpec &file)
// we don't have to do anything.
return;
}
+
+ // Cleare the current symtab as we are going to replace it with a new one
+ obj_file->ClearSymtab();
// The symbol file might be a directory bundle ("/tmp/a.out.dSYM") instead
// of a full path to the symbol file within the bundle
@@ -1680,7 +1670,8 @@ Module::MatchesModuleSpec (const ModuleSpec &module_ref)
const FileSpec &file_spec = module_ref.GetFileSpec();
if (file_spec)
{
- if (!FileSpec::Equal (file_spec, m_file, (bool)file_spec.GetDirectory()))
+ if (!FileSpec::Equal (file_spec, m_file, (bool)file_spec.GetDirectory()) &&
+ !FileSpec::Equal (file_spec, m_platform_file, (bool)file_spec.GetDirectory()))
return false;
}
@@ -1739,6 +1730,7 @@ Module::GetVersion (uint32_t *versions, uint32_t num_versions)
void
Module::PrepareForFunctionNameLookup (const ConstString &name,
uint32_t name_type_mask,
+ LanguageType language,
ConstString &lookup_name,
uint32_t &lookup_name_type_mask,
bool &match_name_after_lookup)
@@ -1752,20 +1744,28 @@ Module::PrepareForFunctionNameLookup (const ConstString &name,
if (name_type_mask & eFunctionNameTypeAuto)
{
- if (CPPLanguageRuntime::IsCPPMangledName (name_cstr))
+ if (CPlusPlusLanguage::IsCPPMangledName (name_cstr))
lookup_name_type_mask = eFunctionNameTypeFull;
- else if (ObjCLanguageRuntime::IsPossibleObjCMethodName (name_cstr))
+ else if ((language == eLanguageTypeUnknown ||
+ Language::LanguageIsObjC(language)) &&
+ ObjCLanguage::IsPossibleObjCMethodName (name_cstr))
lookup_name_type_mask = eFunctionNameTypeFull;
+ else if (Language::LanguageIsC(language))
+ {
+ lookup_name_type_mask = eFunctionNameTypeFull;
+ }
else
{
- if (ObjCLanguageRuntime::IsPossibleObjCSelector(name_cstr))
+ if ((language == eLanguageTypeUnknown ||
+ Language::LanguageIsObjC(language)) &&
+ ObjCLanguage::IsPossibleObjCSelector(name_cstr))
lookup_name_type_mask |= eFunctionNameTypeSelector;
- CPPLanguageRuntime::MethodName cpp_method (name);
+ CPlusPlusLanguage::MethodName cpp_method (name);
basename = cpp_method.GetBasename();
if (basename.empty())
{
- if (CPPLanguageRuntime::ExtractContextAndIdentifier (name_cstr, context, basename))
+ if (CPlusPlusLanguage::ExtractContextAndIdentifier (name_cstr, context, basename))
lookup_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase);
else
lookup_name_type_mask |= eFunctionNameTypeFull;
@@ -1783,7 +1783,7 @@ Module::PrepareForFunctionNameLookup (const ConstString &name,
{
// If they've asked for a CPP method or function name and it can't be that, we don't
// even need to search for CPP methods or names.
- CPPLanguageRuntime::MethodName cpp_method (name);
+ CPlusPlusLanguage::MethodName cpp_method (name);
if (cpp_method.IsValid())
{
basename = cpp_method.GetBasename();
@@ -1801,13 +1801,13 @@ Module::PrepareForFunctionNameLookup (const ConstString &name,
{
// If the CPP method parser didn't manage to chop this up, try to fill in the base name if we can.
// If a::b::c is passed in, we need to just look up "c", and then we'll filter the result later.
- CPPLanguageRuntime::ExtractContextAndIdentifier (name_cstr, context, basename);
+ CPlusPlusLanguage::ExtractContextAndIdentifier (name_cstr, context, basename);
}
}
if (lookup_name_type_mask & eFunctionNameTypeSelector)
{
- if (!ObjCLanguageRuntime::IsPossibleObjCSelector(name_cstr))
+ if (!ObjCLanguage::IsPossibleObjCSelector(name_cstr))
{
lookup_name_type_mask &= ~(eFunctionNameTypeSelector);
if (lookup_name_type_mask == eFunctionNameTypeNone)
diff --git a/source/Core/ModuleList.cpp b/source/Core/ModuleList.cpp
index 669b3d9274cc..75b2ca11103a 100644
--- a/source/Core/ModuleList.cpp
+++ b/source/Core/ModuleList.cpp
@@ -22,7 +22,6 @@
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/Symbols.h"
-#include "lldb/Symbol/ClangNamespaceDecl.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/VariableList.h"
@@ -70,7 +69,7 @@ ModuleList::operator= (const ModuleList& rhs)
// That's probably me nit-picking, but in theoretical situation:
//
// * that two threads A B and
- // * two ModuleList's x y do opposite assignemnts ie.:
+ // * two ModuleList's x y do opposite assignments ie.:
//
// in thread A: | in thread B:
// x = y; | y = x;
@@ -372,6 +371,7 @@ ModuleList::FindFunctions (const ConstString &name,
uint32_t lookup_name_type_mask = 0;
bool match_name_after_lookup = false;
Module::PrepareForFunctionNameLookup (name, name_type_mask,
+ eLanguageTypeUnknown, // TODO: add support
lookup_name,
lookup_name_type_mask,
match_name_after_lookup);
@@ -436,6 +436,7 @@ ModuleList::FindFunctionSymbols (const ConstString &name,
uint32_t lookup_name_type_mask = 0;
bool match_name_after_lookup = false;
Module::PrepareForFunctionNameLookup (name, name_type_mask,
+ eLanguageTypeUnknown, // TODO: add support
lookup_name,
lookup_name_type_mask,
match_name_after_lookup);
@@ -682,7 +683,7 @@ ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool na
{
// Search the module if the module is not equal to the one in the symbol
// context "sc". If "sc" contains a empty module shared pointer, then
- // the comparisong will always be true (valid_module_ptr != NULL).
+ // the comparison will always be true (valid_module_ptr != NULL).
if (sc.module_sp.get() != (*pos).get())
total_matches += (*pos)->FindTypes (world_sc, name, name_is_fully_qualified, max_matches, types);
@@ -988,18 +989,31 @@ ModuleList::GetSharedModule
// If we get in here we got the correct arch, now we just need
// to verify the UUID if one was given
if (uuid_ptr && *uuid_ptr != module_sp->GetUUID())
+ {
module_sp.reset();
+ }
else
{
- if (did_create_ptr)
- *did_create_ptr = true;
+ if (module_sp->GetObjectFile() && module_sp->GetObjectFile()->GetType() == ObjectFile::eTypeStubLibrary)
+ {
+ module_sp.reset();
+ }
+ else
+ {
+ if (did_create_ptr)
+ {
+ *did_create_ptr = true;
+ }
- shared_module_list.ReplaceEquivalent(module_sp);
- return error;
+ shared_module_list.ReplaceEquivalent(module_sp);
+ return error;
+ }
}
}
else
+ {
module_sp.reset();
+ }
if (module_search_paths_ptr)
{
@@ -1023,18 +1037,29 @@ ModuleList::GetSharedModule
// If we get in here we got the correct arch, now we just need
// to verify the UUID if one was given
if (uuid_ptr && *uuid_ptr != module_sp->GetUUID())
+ {
module_sp.reset();
+ }
else
{
- if (did_create_ptr)
- *did_create_ptr = true;
-
- shared_module_list.ReplaceEquivalent(module_sp);
- return Error();
+ if (module_sp->GetObjectFile()->GetType() == ObjectFile::eTypeStubLibrary)
+ {
+ module_sp.reset();
+ }
+ else
+ {
+ if (did_create_ptr)
+ *did_create_ptr = true;
+
+ shared_module_list.ReplaceEquivalent(module_sp);
+ return Error();
+ }
}
}
else
+ {
module_sp.reset();
+ }
}
}
@@ -1044,19 +1069,19 @@ ModuleList::GetSharedModule
// Fixup the incoming path in case the path points to a valid file, yet
// the arch or UUID (if one was passed in) don't match.
- FileSpec file_spec = Symbols::LocateExecutableObjectFile (module_spec);
+ ModuleSpec located_binary_modulespec = Symbols::LocateExecutableObjectFile (module_spec);
// Don't look for the file if it appears to be the same one we already
// checked for above...
- if (file_spec != module_file_spec)
+ if (located_binary_modulespec.GetFileSpec() != module_file_spec)
{
- if (!file_spec.Exists())
+ if (!located_binary_modulespec.GetFileSpec().Exists())
{
- file_spec.GetPath(path, sizeof(path));
+ located_binary_modulespec.GetFileSpec().GetPath(path, sizeof(path));
if (path[0] == '\0')
module_file_spec.GetPath(path, sizeof(path));
// How can this check ever be true? This branch it is false, and we haven't modified file_spec.
- if (file_spec.Exists())
+ if (located_binary_modulespec.GetFileSpec().Exists())
{
std::string uuid_str;
if (uuid_ptr && uuid_ptr->IsValid())
@@ -1084,8 +1109,9 @@ ModuleList::GetSharedModule
// function is actively working on it by doing an extra lock on the
// global mutex list.
ModuleSpec platform_module_spec(module_spec);
- platform_module_spec.GetFileSpec() = file_spec;
- platform_module_spec.GetPlatformFileSpec() = file_spec;
+ platform_module_spec.GetFileSpec() = located_binary_modulespec.GetFileSpec();
+ platform_module_spec.GetPlatformFileSpec() = located_binary_modulespec.GetFileSpec();
+ platform_module_spec.GetSymbolFileSpec() = located_binary_modulespec.GetSymbolFileSpec();
ModuleList matching_module_list;
if (shared_module_list.FindModules (platform_module_spec, matching_module_list) > 0)
{
@@ -1095,7 +1121,7 @@ ModuleList::GetSharedModule
// then we should make sure the modification time hasn't changed!
if (platform_module_spec.GetUUIDPtr() == NULL)
{
- TimeValue file_spec_mod_time(file_spec.GetModificationTime());
+ TimeValue file_spec_mod_time(located_binary_modulespec.GetFileSpec().GetModificationTime());
if (file_spec_mod_time.IsValid())
{
if (file_spec_mod_time != module_sp->GetModificationTime())
@@ -1117,16 +1143,23 @@ ModuleList::GetSharedModule
// By getting the object file we can guarantee that the architecture matches
if (module_sp && module_sp->GetObjectFile())
{
- if (did_create_ptr)
- *did_create_ptr = true;
+ if (module_sp->GetObjectFile()->GetType() == ObjectFile::eTypeStubLibrary)
+ {
+ module_sp.reset();
+ }
+ else
+ {
+ if (did_create_ptr)
+ *did_create_ptr = true;
- shared_module_list.ReplaceEquivalent(module_sp);
+ shared_module_list.ReplaceEquivalent(module_sp);
+ }
}
else
{
- file_spec.GetPath(path, sizeof(path));
+ located_binary_modulespec.GetFileSpec().GetPath(path, sizeof(path));
- if (file_spec)
+ if (located_binary_modulespec.GetFileSpec())
{
if (arch.IsValid())
error.SetErrorStringWithFormat("unable to open %s architecture in '%s'", arch.GetArchitectureName(), path);
diff --git a/source/Core/Opcode.cpp b/source/Core/Opcode.cpp
index 73f5f85923c6..89eea2624cec 100644
--- a/source/Core/Opcode.cpp
+++ b/source/Core/Opcode.cpp
@@ -82,7 +82,7 @@ Opcode::GetDataByteOrder () const
case Opcode::eType16:
case Opcode::eType16_2:
case Opcode::eType32:
- case Opcode::eType64: return lldb::endian::InlHostByteOrder();
+ case Opcode::eType64: return endian::InlHostByteOrder();
case Opcode::eTypeBytes:
break;
}
diff --git a/source/Core/PluginManager.cpp b/source/Core/PluginManager.cpp
index e34b7fc3b17d..a90b57678b7a 100644
--- a/source/Core/PluginManager.cpp
+++ b/source/Core/PluginManager.cpp
@@ -771,16 +771,18 @@ PluginManager::GetEmulateInstructionCreateCallbackForPluginName (const ConstStri
struct OperatingSystemInstance
{
- OperatingSystemInstance() :
- name(),
- description(),
- create_callback(NULL)
+ OperatingSystemInstance () :
+ name (),
+ description (),
+ create_callback (nullptr),
+ debugger_init_callback (nullptr)
{
}
ConstString name;
std::string description;
OperatingSystemCreateInstance create_callback;
+ DebuggerInitializeCallback debugger_init_callback;
};
typedef std::vector<OperatingSystemInstance> OperatingSystemInstances;
@@ -800,9 +802,9 @@ GetOperatingSystemInstances ()
}
bool
-PluginManager::RegisterPlugin (const ConstString &name,
- const char *description,
- OperatingSystemCreateInstance create_callback)
+PluginManager::RegisterPlugin(const ConstString &name, const char *description,
+ OperatingSystemCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback)
{
if (create_callback)
{
@@ -812,6 +814,7 @@ PluginManager::RegisterPlugin (const ConstString &name,
if (description && description[0])
instance.description = description;
instance.create_callback = create_callback;
+ instance.debugger_init_callback = debugger_init_callback;
Mutex::Locker locker (GetOperatingSystemMutex ());
GetOperatingSystemInstances ().push_back (instance);
}
@@ -868,6 +871,111 @@ PluginManager::GetOperatingSystemCreateCallbackForPluginName (const ConstString
}
+#pragma mark Language
+
+
+struct LanguageInstance
+{
+ LanguageInstance() :
+ name(),
+ description(),
+ create_callback(NULL)
+ {
+ }
+
+ ConstString name;
+ std::string description;
+ LanguageCreateInstance create_callback;
+};
+
+typedef std::vector<LanguageInstance> LanguageInstances;
+
+static Mutex &
+GetLanguageMutex ()
+{
+ static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
+ return g_instances_mutex;
+}
+
+static LanguageInstances &
+GetLanguageInstances ()
+{
+ static LanguageInstances g_instances;
+ return g_instances;
+}
+
+bool
+PluginManager::RegisterPlugin
+(
+ const ConstString &name,
+ const char *description,
+ LanguageCreateInstance create_callback
+ )
+{
+ if (create_callback)
+ {
+ LanguageInstance instance;
+ assert ((bool)name);
+ instance.name = name;
+ if (description && description[0])
+ instance.description = description;
+ instance.create_callback = create_callback;
+ Mutex::Locker locker (GetLanguageMutex ());
+ GetLanguageInstances ().push_back (instance);
+ }
+ return false;
+}
+
+bool
+PluginManager::UnregisterPlugin (LanguageCreateInstance create_callback)
+{
+ if (create_callback)
+ {
+ Mutex::Locker locker (GetLanguageMutex ());
+ LanguageInstances &instances = GetLanguageInstances ();
+
+ LanguageInstances::iterator pos, end = instances.end();
+ for (pos = instances.begin(); pos != end; ++ pos)
+ {
+ if (pos->create_callback == create_callback)
+ {
+ instances.erase(pos);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+LanguageCreateInstance
+PluginManager::GetLanguageCreateCallbackAtIndex (uint32_t idx)
+{
+ Mutex::Locker locker (GetLanguageMutex ());
+ LanguageInstances &instances = GetLanguageInstances ();
+ if (idx < instances.size())
+ return instances[idx].create_callback;
+ return NULL;
+}
+
+LanguageCreateInstance
+PluginManager::GetLanguageCreateCallbackForPluginName (const ConstString &name)
+{
+ if (name)
+ {
+ Mutex::Locker locker (GetLanguageMutex ());
+ LanguageInstances &instances = GetLanguageInstances ();
+
+ LanguageInstances::iterator pos, end = instances.end();
+ for (pos = instances.begin(); pos != end; ++ pos)
+ {
+ if (name == pos->name)
+ return pos->create_callback;
+ }
+ }
+ return NULL;
+}
+
+
#pragma mark LanguageRuntime
@@ -1764,6 +1872,110 @@ PluginManager::GetProcessCreateCallbackForPluginName (const ConstString &name)
return NULL;
}
+#pragma mark ScriptInterpreter
+
+struct ScriptInterpreterInstance
+{
+ ScriptInterpreterInstance()
+ : name()
+ , language(lldb::eScriptLanguageNone)
+ , description()
+ , create_callback(NULL)
+ {
+ }
+
+ ConstString name;
+ lldb::ScriptLanguage language;
+ std::string description;
+ ScriptInterpreterCreateInstance create_callback;
+};
+
+typedef std::vector<ScriptInterpreterInstance> ScriptInterpreterInstances;
+
+static Mutex &
+GetScriptInterpreterMutex()
+{
+ static Mutex g_instances_mutex(Mutex::eMutexTypeRecursive);
+ return g_instances_mutex;
+}
+
+static ScriptInterpreterInstances &
+GetScriptInterpreterInstances()
+{
+ static ScriptInterpreterInstances g_instances;
+ return g_instances;
+}
+
+bool
+PluginManager::RegisterPlugin(const ConstString &name, const char *description, lldb::ScriptLanguage script_language,
+ ScriptInterpreterCreateInstance create_callback)
+{
+ if (!create_callback)
+ return false;
+ ScriptInterpreterInstance instance;
+ assert((bool)name);
+ instance.name = name;
+ if (description && description[0])
+ instance.description = description;
+ instance.create_callback = create_callback;
+ instance.language = script_language;
+ Mutex::Locker locker(GetScriptInterpreterMutex());
+ GetScriptInterpreterInstances().push_back(instance);
+ return false;
+}
+
+bool
+PluginManager::UnregisterPlugin(ScriptInterpreterCreateInstance create_callback)
+{
+ if (!create_callback)
+ return false;
+ Mutex::Locker locker(GetScriptInterpreterMutex());
+ ScriptInterpreterInstances &instances = GetScriptInterpreterInstances();
+
+ ScriptInterpreterInstances::iterator pos, end = instances.end();
+ for (pos = instances.begin(); pos != end; ++pos)
+ {
+ if (pos->create_callback != create_callback)
+ continue;
+
+ instances.erase(pos);
+ return true;
+ }
+ return false;
+}
+
+ScriptInterpreterCreateInstance
+PluginManager::GetScriptInterpreterCreateCallbackAtIndex(uint32_t idx)
+{
+ Mutex::Locker locker(GetScriptInterpreterMutex());
+ ScriptInterpreterInstances &instances = GetScriptInterpreterInstances();
+ if (idx < instances.size())
+ return instances[idx].create_callback;
+ return nullptr;
+}
+
+lldb::ScriptInterpreterSP
+PluginManager::GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang, CommandInterpreter &interpreter)
+{
+ Mutex::Locker locker(GetScriptInterpreterMutex());
+ ScriptInterpreterInstances &instances = GetScriptInterpreterInstances();
+
+ ScriptInterpreterInstances::iterator pos, end = instances.end();
+ ScriptInterpreterCreateInstance none_instance = nullptr;
+ for (pos = instances.begin(); pos != end; ++pos)
+ {
+ if (pos->language == lldb::eScriptLanguageNone)
+ none_instance = pos->create_callback;
+
+ if (script_lang == pos->language)
+ return pos->create_callback(interpreter);
+ }
+
+ // If we didn't find one, return the ScriptInterpreter for the null language.
+ assert(none_instance != nullptr);
+ return none_instance(interpreter);
+}
+
#pragma mark SymbolFile
struct SymbolFileInstance
@@ -1771,13 +1983,15 @@ struct SymbolFileInstance
SymbolFileInstance() :
name(),
description(),
- create_callback(NULL)
+ create_callback(nullptr),
+ debugger_init_callback(nullptr)
{
}
ConstString name;
std::string description;
SymbolFileCreateInstance create_callback;
+ DebuggerInitializeCallback debugger_init_callback;
};
typedef std::vector<SymbolFileInstance> SymbolFileInstances;
@@ -1802,7 +2016,8 @@ PluginManager::RegisterPlugin
(
const ConstString &name,
const char *description,
- SymbolFileCreateInstance create_callback
+ SymbolFileCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback
)
{
if (create_callback)
@@ -1813,6 +2028,7 @@ PluginManager::RegisterPlugin
if (description && description[0])
instance.description = description;
instance.create_callback = create_callback;
+ instance.debugger_init_callback = debugger_init_callback;
Mutex::Locker locker (GetSymbolFileMutex ());
GetSymbolFileInstances ().push_back (instance);
}
@@ -2300,6 +2516,270 @@ PluginManager::GetInstrumentationRuntimeCreateCallbackForPluginName (const Const
return NULL;
}
+#pragma mark TypeSystem
+
+
+struct TypeSystemInstance
+{
+ TypeSystemInstance() :
+ name(),
+ description(),
+ create_callback(NULL)
+ {
+ }
+
+ ConstString name;
+ std::string description;
+ TypeSystemCreateInstance create_callback;
+ TypeSystemEnumerateSupportedLanguages enumerate_callback;
+};
+
+typedef std::vector<TypeSystemInstance> TypeSystemInstances;
+
+static Mutex &
+GetTypeSystemMutex ()
+{
+ static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
+ return g_instances_mutex;
+}
+
+static TypeSystemInstances &
+GetTypeSystemInstances ()
+{
+ static TypeSystemInstances g_instances;
+ return g_instances;
+}
+
+bool
+PluginManager::RegisterPlugin (const ConstString &name,
+ const char *description,
+ TypeSystemCreateInstance create_callback,
+ TypeSystemEnumerateSupportedLanguages enumerate_supported_languages_callback)
+{
+ if (create_callback)
+ {
+ TypeSystemInstance instance;
+ assert ((bool)name);
+ instance.name = name;
+ if (description && description[0])
+ instance.description = description;
+ instance.create_callback = create_callback;
+ instance.enumerate_callback = enumerate_supported_languages_callback;
+ Mutex::Locker locker (GetTypeSystemMutex ());
+ GetTypeSystemInstances ().push_back (instance);
+ }
+ return false;
+}
+
+bool
+PluginManager::UnregisterPlugin (TypeSystemCreateInstance create_callback)
+{
+ if (create_callback)
+ {
+ Mutex::Locker locker (GetTypeSystemMutex ());
+ TypeSystemInstances &instances = GetTypeSystemInstances ();
+
+ TypeSystemInstances::iterator pos, end = instances.end();
+ for (pos = instances.begin(); pos != end; ++ pos)
+ {
+ if (pos->create_callback == create_callback)
+ {
+ instances.erase(pos);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+TypeSystemCreateInstance
+PluginManager::GetTypeSystemCreateCallbackAtIndex (uint32_t idx)
+{
+ Mutex::Locker locker (GetTypeSystemMutex ());
+ TypeSystemInstances &instances = GetTypeSystemInstances ();
+ if (idx < instances.size())
+ return instances[idx].create_callback;
+ return NULL;
+}
+
+TypeSystemCreateInstance
+PluginManager::GetTypeSystemCreateCallbackForPluginName (const ConstString &name)
+{
+ if (name)
+ {
+ Mutex::Locker locker (GetTypeSystemMutex ());
+ TypeSystemInstances &instances = GetTypeSystemInstances ();
+
+ TypeSystemInstances::iterator pos, end = instances.end();
+ for (pos = instances.begin(); pos != end; ++ pos)
+ {
+ if (name == pos->name)
+ return pos->create_callback;
+ }
+ }
+ return NULL;
+}
+
+TypeSystemEnumerateSupportedLanguages
+PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx)
+{
+ Mutex::Locker locker (GetTypeSystemMutex ());
+ TypeSystemInstances &instances = GetTypeSystemInstances ();
+ if (idx < instances.size())
+ return instances[idx].enumerate_callback;
+ return NULL;
+}
+
+TypeSystemEnumerateSupportedLanguages
+PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName (const ConstString &name)
+{
+ if (name)
+ {
+ Mutex::Locker locker (GetTypeSystemMutex ());
+ TypeSystemInstances &instances = GetTypeSystemInstances ();
+
+ TypeSystemInstances::iterator pos, end = instances.end();
+ for (pos = instances.begin(); pos != end; ++ pos)
+ {
+ if (name == pos->name)
+ return pos->enumerate_callback;
+ }
+ }
+ return NULL;
+}
+
+#pragma mark REPL
+
+struct REPLInstance
+{
+ REPLInstance() :
+ name(),
+ description(),
+ create_callback(NULL)
+ {
+ }
+
+ ConstString name;
+ std::string description;
+ REPLCreateInstance create_callback;
+ REPLEnumerateSupportedLanguages enumerate_languages_callback;
+};
+
+typedef std::vector<REPLInstance> REPLInstances;
+
+static Mutex &
+GetREPLMutex ()
+{
+ static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
+ return g_instances_mutex;
+}
+
+static REPLInstances &
+GetREPLInstances ()
+{
+ static REPLInstances g_instances;
+ return g_instances;
+}
+
+bool
+PluginManager::RegisterPlugin (const ConstString &name,
+ const char *description,
+ REPLCreateInstance create_callback,
+ REPLEnumerateSupportedLanguages enumerate_languages_callback)
+{
+ if (create_callback)
+ {
+ REPLInstance instance;
+ assert ((bool)name);
+ instance.name = name;
+ if (description && description[0])
+ instance.description = description;
+ instance.create_callback = create_callback;
+ instance.enumerate_languages_callback = enumerate_languages_callback;
+ Mutex::Locker locker (GetREPLMutex ());
+ GetREPLInstances ().push_back (instance);
+ }
+ return false;
+}
+
+bool
+PluginManager::UnregisterPlugin (REPLCreateInstance create_callback)
+{
+ if (create_callback)
+ {
+ Mutex::Locker locker (GetREPLMutex ());
+ REPLInstances &instances = GetREPLInstances ();
+
+ REPLInstances::iterator pos, end = instances.end();
+ for (pos = instances.begin(); pos != end; ++ pos)
+ {
+ if (pos->create_callback == create_callback)
+ {
+ instances.erase(pos);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+REPLCreateInstance
+PluginManager::GetREPLCreateCallbackAtIndex (uint32_t idx)
+{
+ Mutex::Locker locker (GetREPLMutex ());
+ REPLInstances &instances = GetREPLInstances ();
+ if (idx < instances.size())
+ return instances[idx].create_callback;
+ return NULL;
+}
+
+REPLCreateInstance
+PluginManager::GetREPLCreateCallbackForPluginName (const ConstString &name)
+{
+ if (name)
+ {
+ Mutex::Locker locker (GetREPLMutex ());
+ REPLInstances &instances = GetREPLInstances ();
+
+ REPLInstances::iterator pos, end = instances.end();
+ for (pos = instances.begin(); pos != end; ++ pos)
+ {
+ if (name == pos->name)
+ return pos->create_callback;
+ }
+ }
+ return NULL;
+}
+
+REPLEnumerateSupportedLanguages
+PluginManager::GetREPLEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx)
+{
+ Mutex::Locker locker (GetREPLMutex ());
+ REPLInstances &instances = GetREPLInstances ();
+ if (idx < instances.size())
+ return instances[idx].enumerate_languages_callback;
+ return NULL;
+}
+
+
+REPLEnumerateSupportedLanguages
+PluginManager::GetREPLSystemEnumerateSupportedLanguagesCallbackForPluginName (const ConstString &name)
+{
+ if (name)
+ {
+ Mutex::Locker locker (GetREPLMutex ());
+ REPLInstances &instances = GetREPLInstances ();
+
+ REPLInstances::iterator pos, end = instances.end();
+ for (pos = instances.begin(); pos != end; ++ pos)
+ {
+ if (name == pos->name)
+ return pos->enumerate_languages_callback;
+ }
+ }
+ return NULL;
+}
+
#pragma mark PluginManager
void
@@ -2343,7 +2823,7 @@ PluginManager::DebuggerInitialize (Debugger &debugger)
pos->debugger_init_callback (debugger);
}
}
-
+
// Initialize the Process plugins
{
Mutex::Locker locker (GetProcessMutex());
@@ -2357,6 +2837,25 @@ PluginManager::DebuggerInitialize (Debugger &debugger)
}
}
+ // Initialize the SymbolFile plugins
+ {
+ Mutex::Locker locker (GetSymbolFileMutex());
+ for (auto& sym_file: GetSymbolFileInstances())
+ {
+ if (sym_file.debugger_init_callback)
+ sym_file.debugger_init_callback (debugger);
+ }
+ }
+
+ // Initialize the OperatingSystem plugins
+ {
+ Mutex::Locker locker(GetOperatingSystemMutex());
+ for (auto &os : GetOperatingSystemInstances())
+ {
+ if (os.debugger_init_callback)
+ os.debugger_init_callback(debugger);
+ }
+ }
}
// This is the preferred new way to register plugin specific settings. e.g.
@@ -2439,32 +2938,40 @@ GetDebuggerPropertyForPluginsOldStyle (Debugger &debugger,
return lldb::OptionValuePropertiesSP();
}
+namespace {
+
+typedef lldb::OptionValuePropertiesSP
+GetDebuggerPropertyForPluginsPtr (Debugger&, const ConstString&, const ConstString&, bool can_create);
lldb::OptionValuePropertiesSP
-PluginManager::GetSettingForDynamicLoaderPlugin (Debugger &debugger, const ConstString &setting_name)
+GetSettingForPlugin (Debugger &debugger,
+ const ConstString &setting_name,
+ const ConstString &plugin_type_name,
+ GetDebuggerPropertyForPluginsPtr get_debugger_property= GetDebuggerPropertyForPlugins)
{
lldb::OptionValuePropertiesSP properties_sp;
- lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
- ConstString("dynamic-loader"),
- ConstString(), // not creating to so we don't need the description
- false));
+ lldb::OptionValuePropertiesSP plugin_type_properties_sp (get_debugger_property (debugger,
+ plugin_type_name,
+ ConstString(), // not creating to so we don't need the description
+ false));
if (plugin_type_properties_sp)
- properties_sp = plugin_type_properties_sp->GetSubProperty (NULL, setting_name);
+ properties_sp = plugin_type_properties_sp->GetSubProperty (nullptr, setting_name);
return properties_sp;
}
bool
-PluginManager::CreateSettingForDynamicLoaderPlugin (Debugger &debugger,
- const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description,
- bool is_global_property)
+CreateSettingForPlugin (Debugger &debugger,
+ const ConstString &plugin_type_name,
+ const ConstString &plugin_type_desc,
+ const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description,
+ bool is_global_property,
+ GetDebuggerPropertyForPluginsPtr get_debugger_property = GetDebuggerPropertyForPlugins)
{
if (properties_sp)
{
- lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
- ConstString("dynamic-loader"),
- ConstString("Settings for dynamic loader plug-ins"),
- true));
+ lldb::OptionValuePropertiesSP plugin_type_properties_sp (get_debugger_property (
+ debugger, plugin_type_name, plugin_type_desc, true));
if (plugin_type_properties_sp)
{
plugin_type_properties_sp->AppendProperty (properties_sp->GetName(),
@@ -2477,56 +2984,65 @@ PluginManager::CreateSettingForDynamicLoaderPlugin (Debugger &debugger,
return false;
}
+const char* kDynamicLoaderPluginName("dynamic-loader");
+const char* kPlatformPluginName("platform");
+const char* kProcessPluginName("process");
+const char* kSymbolFilePluginName("symbol-file");
+const char* kJITLoaderPluginName("jit-loader");
+
+}
lldb::OptionValuePropertiesSP
-PluginManager::GetSettingForPlatformPlugin (Debugger &debugger, const ConstString &setting_name)
+PluginManager::GetSettingForDynamicLoaderPlugin (Debugger &debugger,
+ const ConstString &setting_name)
{
- lldb::OptionValuePropertiesSP properties_sp;
- lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPluginsOldStyle (debugger,
- ConstString("platform"),
- ConstString(), // not creating to so we don't need the description
- false));
- if (plugin_type_properties_sp)
- properties_sp = plugin_type_properties_sp->GetSubProperty (NULL, setting_name);
- return properties_sp;
+ return GetSettingForPlugin(debugger, setting_name, ConstString(kDynamicLoaderPluginName));
}
bool
-PluginManager::CreateSettingForPlatformPlugin (Debugger &debugger,
+PluginManager::CreateSettingForDynamicLoaderPlugin (Debugger &debugger,
const lldb::OptionValuePropertiesSP &properties_sp,
const ConstString &description,
bool is_global_property)
{
- if (properties_sp)
- {
- lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPluginsOldStyle (debugger,
- ConstString("platform"),
- ConstString("Settings for platform plug-ins"),
- true));
- if (plugin_type_properties_sp)
- {
- plugin_type_properties_sp->AppendProperty (properties_sp->GetName(),
- description,
- is_global_property,
- properties_sp);
- return true;
- }
- }
- return false;
+ return CreateSettingForPlugin(debugger,
+ ConstString(kDynamicLoaderPluginName),
+ ConstString("Settings for dynamic loader plug-ins"),
+ properties_sp,
+ description,
+ is_global_property);
+}
+
+
+lldb::OptionValuePropertiesSP
+PluginManager::GetSettingForPlatformPlugin (Debugger &debugger, const ConstString &setting_name)
+{
+ return GetSettingForPlugin(debugger,
+ setting_name,
+ ConstString(kPlatformPluginName),
+ GetDebuggerPropertyForPluginsOldStyle);
+}
+
+bool
+PluginManager::CreateSettingForPlatformPlugin (Debugger &debugger,
+ const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description,
+ bool is_global_property)
+{
+ return CreateSettingForPlugin(debugger,
+ ConstString(kPlatformPluginName),
+ ConstString("Settings for platform plug-ins"),
+ properties_sp,
+ description,
+ is_global_property,
+ GetDebuggerPropertyForPluginsOldStyle);
}
lldb::OptionValuePropertiesSP
PluginManager::GetSettingForProcessPlugin (Debugger &debugger, const ConstString &setting_name)
{
- lldb::OptionValuePropertiesSP properties_sp;
- lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
- ConstString("process"),
- ConstString(), // not creating to so we don't need the description
- false));
- if (plugin_type_properties_sp)
- properties_sp = plugin_type_properties_sp->GetSubProperty (NULL, setting_name);
- return properties_sp;
+ return GetSettingForPlugin(debugger, setting_name, ConstString(kProcessPluginName));
}
bool
@@ -2535,21 +3051,87 @@ PluginManager::CreateSettingForProcessPlugin (Debugger &debugger,
const ConstString &description,
bool is_global_property)
{
+ return CreateSettingForPlugin(debugger,
+ ConstString(kProcessPluginName),
+ ConstString("Settings for process plug-ins"),
+ properties_sp,
+ description,
+ is_global_property);
+}
+
+lldb::OptionValuePropertiesSP
+PluginManager::GetSettingForSymbolFilePlugin (Debugger &debugger,
+ const 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)
+{
+ return CreateSettingForPlugin(debugger,
+ ConstString(kSymbolFilePluginName),
+ ConstString("Settings for symbol file plug-ins"),
+ properties_sp,
+ description,
+ is_global_property);
+}
+
+lldb::OptionValuePropertiesSP
+PluginManager::GetSettingForJITLoaderPlugin (Debugger &debugger,
+ const 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)
+{
+ return CreateSettingForPlugin(debugger,
+ ConstString(kJITLoaderPluginName),
+ ConstString("Settings for JIT loader plug-ins"),
+ properties_sp,
+ description,
+ is_global_property);
+}
+
+static const char *kOperatingSystemPluginName("os");
+
+lldb::OptionValuePropertiesSP
+PluginManager::GetSettingForOperatingSystemPlugin(Debugger &debugger, const ConstString &setting_name)
+{
+ lldb::OptionValuePropertiesSP properties_sp;
+ lldb::OptionValuePropertiesSP plugin_type_properties_sp(
+ GetDebuggerPropertyForPlugins(debugger, ConstString(kOperatingSystemPluginName),
+ ConstString(), // not creating to so we don't need the description
+ false));
+ if (plugin_type_properties_sp)
+ properties_sp = plugin_type_properties_sp->GetSubProperty(nullptr, setting_name);
+ return properties_sp;
+}
+
+bool
+PluginManager::CreateSettingForOperatingSystemPlugin(Debugger &debugger,
+ const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description, bool is_global_property)
+{
if (properties_sp)
{
- lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
- ConstString("process"),
- ConstString("Settings for process plug-ins"),
- true));
+ lldb::OptionValuePropertiesSP plugin_type_properties_sp(
+ GetDebuggerPropertyForPlugins(debugger, ConstString(kOperatingSystemPluginName),
+ ConstString("Settings for operating system plug-ins"), true));
if (plugin_type_properties_sp)
{
- plugin_type_properties_sp->AppendProperty (properties_sp->GetName(),
- description,
- is_global_property,
- properties_sp);
+ plugin_type_properties_sp->AppendProperty(properties_sp->GetName(), description, is_global_property,
+ properties_sp);
return true;
}
}
return false;
}
-
diff --git a/source/Core/RegisterValue.cpp b/source/Core/RegisterValue.cpp
index 272c1eecf920..d4ba9989c6a9 100644
--- a/source/Core/RegisterValue.cpp
+++ b/source/Core/RegisterValue.cpp
@@ -119,7 +119,7 @@ RegisterValue::GetAsMemoryData (const RegisterInfo *reg_info,
return 0;
}
- // ReadRegister should have already been called on tgus object prior to
+ // ReadRegister should have already been called on this object prior to
// calling this.
if (GetType() == eTypeInvalid)
{
@@ -215,10 +215,10 @@ RegisterValue::SetFromMemoryData (const RegisterInfo *reg_info,
}
else if (value_type == eTypeBytes)
{
- m_data.buffer.byte_order = src_byte_order;
+ buffer.byte_order = src_byte_order;
// Make sure to set the buffer length of the destination buffer to avoid
- // problems due to uninitalized variables.
- m_data.buffer.length = src_len;
+ // problems due to uninitialized variables.
+ buffer.length = src_len;
}
const uint32_t bytes_copied = src_data.CopyByteOrderedData (0, // src offset
@@ -240,25 +240,23 @@ RegisterValue::GetScalarValue (Scalar &scalar) const
case eTypeInvalid: break;
case eTypeBytes:
{
- switch (m_data.buffer.length)
+ switch (buffer.length)
{
default: break;
- case 1: scalar = m_data.uint8; return true;
- case 2: scalar = m_data.uint16; return true;
- case 4: scalar = m_data.uint32; return true;
- case 8: scalar = m_data.uint64; return true;
+ case 1: scalar = *(const uint8_t *)buffer.bytes; return true;
+ case 2: scalar = *(const uint16_t *)buffer.bytes; return true;
+ case 4: scalar = *(const uint32_t *)buffer.bytes; return true;
+ case 8: scalar = *(const uint64_t *)buffer.bytes; return true;
}
}
- case eTypeUInt8: scalar = m_data.uint8; return true;
- case eTypeUInt16: scalar = m_data.uint16; return true;
- case eTypeUInt32: scalar = m_data.uint32; return true;
- case eTypeUInt64: scalar = m_data.uint64; return true;
-#if defined (ENABLE_128_BIT_SUPPORT)
- case eTypeUInt128: break;
-#endif
- case eTypeFloat: scalar = m_data.ieee_float; return true;
- case eTypeDouble: scalar = m_data.ieee_double; return true;
- case eTypeLongDouble: scalar = m_data.ieee_long_double; return true;
+ case eTypeUInt8:
+ case eTypeUInt16:
+ case eTypeUInt32:
+ case eTypeUInt64:
+ case eTypeUInt128:
+ case eTypeFloat:
+ case eTypeDouble:
+ case eTypeLongDouble: scalar = m_scalar; return true;
}
return false;
}
@@ -289,10 +287,8 @@ RegisterValue::SetType (const RegisterInfo *reg_info)
m_type = eTypeUInt32;
else if (byte_size <= 8)
m_type = eTypeUInt64;
-#if defined (ENABLE_128_BIT_SUPPORT)
else if (byte_size <= 16)
m_type = eTypeUInt128;
-#endif
break;
case eEncodingIEEE754:
@@ -308,6 +304,7 @@ RegisterValue::SetType (const RegisterInfo *reg_info)
m_type = eTypeBytes;
break;
}
+ m_scalar.SetType(reg_info);
return m_type;
}
@@ -342,8 +339,9 @@ RegisterValue::SetValueFromData (const RegisterInfo *reg_info, DataExtractor &sr
src_len = reg_info->byte_size;
// Zero out the value in case we get partial data...
- memset (m_data.buffer.bytes, 0, sizeof (m_data.buffer.bytes));
-
+ memset (buffer.bytes, 0, sizeof (buffer.bytes));
+
+ type128 int128;
switch (SetType (reg_info))
{
case eTypeInvalid:
@@ -353,33 +351,38 @@ RegisterValue::SetValueFromData (const RegisterInfo *reg_info, DataExtractor &sr
case eTypeUInt16: SetUInt16 (src.GetMaxU32 (&src_offset, src_len)); break;
case eTypeUInt32: SetUInt32 (src.GetMaxU32 (&src_offset, src_len)); break;
case eTypeUInt64: SetUInt64 (src.GetMaxU64 (&src_offset, src_len)); break;
-#if defined (ENABLE_128_BIT_SUPPORT)
case eTypeUInt128:
{
- __uint128_t data1 = src.GetU64 (&src_offset);
- __uint128_t data2 = src.GetU64 (&src_offset);
+ uint64_t data1 = src.GetU64 (&src_offset);
+ uint64_t data2 = src.GetU64 (&src_offset);
if (src.GetByteSize() == eByteOrderBig)
- SetUInt128 (data1 << 64 + data2);
+ {
+ int128.x[0] = data1;
+ int128.x[1] = data2;
+ }
else
- SetUInt128 (data2 << 64 + data1);
+ {
+ int128.x[0] = data2;
+ int128.x[1] = data1;
+ }
+ SetUInt128 (llvm::APInt(128, 2, int128.x));
}
break;
-#endif
case eTypeFloat: SetFloat (src.GetFloat (&src_offset)); break;
case eTypeDouble: SetDouble(src.GetDouble (&src_offset)); break;
case eTypeLongDouble: SetFloat (src.GetLongDouble (&src_offset)); break;
case eTypeBytes:
{
- m_data.buffer.length = reg_info->byte_size;
- m_data.buffer.byte_order = src.GetByteOrder();
- assert (m_data.buffer.length <= kMaxRegisterByteSize);
- if (m_data.buffer.length > kMaxRegisterByteSize)
- m_data.buffer.length = kMaxRegisterByteSize;
+ buffer.length = reg_info->byte_size;
+ buffer.byte_order = src.GetByteOrder();
+ assert (buffer.length <= kMaxRegisterByteSize);
+ if (buffer.length > kMaxRegisterByteSize)
+ buffer.length = kMaxRegisterByteSize;
if (src.CopyByteOrderedData (src_offset, // offset within "src" to start extracting data
src_len, // src length
- m_data.buffer.bytes, // dst buffer
- m_data.buffer.length, // dst length
- m_data.buffer.byte_order) == 0)// dst byte order
+ buffer.bytes, // dst buffer
+ buffer.length, // dst length
+ buffer.byte_order) == 0)// dst byte order
{
error.SetErrorString ("data copy failed data.");
return error;
@@ -459,6 +462,9 @@ RegisterValue::SetValueFromCString (const RegisterInfo *reg_info, const char *va
}
bool success = false;
const uint32_t byte_size = reg_info->byte_size;
+ static float flt_val;
+ static double dbl_val;
+ static long double ldbl_val;
switch (reg_info->encoding)
{
case eEncodingInvalid:
@@ -510,22 +516,31 @@ RegisterValue::SetValueFromCString (const RegisterInfo *reg_info, const char *va
case eEncodingIEEE754:
if (byte_size == sizeof (float))
{
- if (::sscanf (value_str, "%f", &m_data.ieee_float) == 1)
+ if (::sscanf (value_str, "%f", &flt_val) == 1)
+ {
+ m_scalar = flt_val;
m_type = eTypeFloat;
+ }
else
error.SetErrorStringWithFormat ("'%s' is not a valid float string value", value_str);
}
else if (byte_size == sizeof (double))
{
- if (::sscanf (value_str, "%lf", &m_data.ieee_double) == 1)
+ if (::sscanf (value_str, "%lf", &dbl_val) == 1)
+ {
+ m_scalar = dbl_val;
m_type = eTypeDouble;
+ }
else
error.SetErrorStringWithFormat ("'%s' is not a valid float string value", value_str);
}
else if (byte_size == sizeof (long double))
{
- if (::sscanf (value_str, "%Lf", &m_data.ieee_long_double) == 1)
+ if (::sscanf (value_str, "%Lf", &ldbl_val) == 1)
+ {
+ m_scalar = ldbl_val;
m_type = eTypeLongDouble;
+ }
else
error.SetErrorStringWithFormat ("'%s' is not a valid float string value", value_str);
}
@@ -557,81 +572,11 @@ RegisterValue::SignExtend (uint32_t sign_bitpos)
break;
case eTypeUInt8:
- if (sign_bitpos == (8-1))
- return true;
- else if (sign_bitpos < (8-1))
- {
- uint8_t sign_bit = 1u << sign_bitpos;
- if (m_data.uint8 & sign_bit)
- {
- const uint8_t mask = ~(sign_bit) + 1u;
- m_data.uint8 |= mask;
- }
- return true;
- }
- break;
-
case eTypeUInt16:
- if (sign_bitpos == (16-1))
- return true;
- else if (sign_bitpos < (16-1))
- {
- uint16_t sign_bit = 1u << sign_bitpos;
- if (m_data.uint16 & sign_bit)
- {
- const uint16_t mask = ~(sign_bit) + 1u;
- m_data.uint16 |= mask;
- }
- return true;
- }
- break;
-
case eTypeUInt32:
- if (sign_bitpos == (32-1))
- return true;
- else if (sign_bitpos < (32-1))
- {
- uint32_t sign_bit = 1u << sign_bitpos;
- if (m_data.uint32 & sign_bit)
- {
- const uint32_t mask = ~(sign_bit) + 1u;
- m_data.uint32 |= mask;
- }
- return true;
- }
- break;
-
case eTypeUInt64:
- if (sign_bitpos == (64-1))
- return true;
- else if (sign_bitpos < (64-1))
- {
- uint64_t sign_bit = 1ull << sign_bitpos;
- if (m_data.uint64 & sign_bit)
- {
- const uint64_t mask = ~(sign_bit) + 1ull;
- m_data.uint64 |= mask;
- }
- return true;
- }
- break;
-
-#if defined (ENABLE_128_BIT_SUPPORT)
case eTypeUInt128:
- if (sign_bitpos == (128-1))
- return true;
- else if (sign_bitpos < (128-1))
- {
- __uint128_t sign_bit = (__uint128_t)1u << sign_bitpos;
- if (m_data.uint128 & sign_bit)
- {
- const uint128_t mask = ~(sign_bit) + 1u;
- m_data.uint128 |= mask;
- }
- return true;
- }
- break;
-#endif
+ return m_scalar.SignExtend(sign_bitpos);
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -649,21 +594,19 @@ RegisterValue::CopyValue (const RegisterValue &rhs)
{
case eTypeInvalid:
return false;
- case eTypeUInt8: m_data.uint8 = rhs.m_data.uint8; break;
- case eTypeUInt16: m_data.uint16 = rhs.m_data.uint16; break;
- case eTypeUInt32: m_data.uint32 = rhs.m_data.uint32; break;
- case eTypeUInt64: m_data.uint64 = rhs.m_data.uint64; break;
-#if defined (ENABLE_128_BIT_SUPPORT)
- case eTypeUInt128: m_data.uint128 = rhs.m_data.uint128; break;
-#endif
- case eTypeFloat: m_data.ieee_float = rhs.m_data.ieee_float; break;
- case eTypeDouble: m_data.ieee_double = rhs.m_data.ieee_double; break;
- case eTypeLongDouble: m_data.ieee_long_double = rhs.m_data.ieee_long_double; break;
+ case eTypeUInt8:
+ case eTypeUInt16:
+ case eTypeUInt32:
+ case eTypeUInt64:
+ case eTypeUInt128:
+ case eTypeFloat:
+ case eTypeDouble:
+ case eTypeLongDouble: m_scalar = rhs.m_scalar; break;
case eTypeBytes:
- assert (rhs.m_data.buffer.length <= kMaxRegisterByteSize);
- ::memcpy (m_data.buffer.bytes, rhs.m_data.buffer.bytes, kMaxRegisterByteSize);
- m_data.buffer.length = rhs.m_data.buffer.length;
- m_data.buffer.byte_order = rhs.m_data.buffer.byte_order;
+ assert (rhs.buffer.length <= kMaxRegisterByteSize);
+ ::memcpy (buffer.bytes, rhs.buffer.bytes, kMaxRegisterByteSize);
+ buffer.length = rhs.buffer.length;
+ buffer.byte_order = rhs.buffer.byte_order;
break;
}
return true;
@@ -678,15 +621,15 @@ RegisterValue::GetAsUInt16 (uint16_t fail_value, bool *success_ptr) const
switch (m_type)
{
default: break;
- case eTypeUInt8: return m_data.uint8;
- case eTypeUInt16: return m_data.uint16;
+ case eTypeUInt8:
+ case eTypeUInt16: return m_scalar.UShort(fail_value);
case eTypeBytes:
{
- switch (m_data.buffer.length)
+ switch (buffer.length)
{
default: break;
- case 1: return m_data.uint8;
- case 2: return m_data.uint16;
+ case 1:
+ case 2: return *(const uint16_t *)buffer.bytes;
}
}
break;
@@ -704,29 +647,20 @@ RegisterValue::GetAsUInt32 (uint32_t fail_value, bool *success_ptr) const
switch (m_type)
{
default: break;
- case eTypeUInt8: return m_data.uint8;
- case eTypeUInt16: return m_data.uint16;
- case eTypeUInt32: return m_data.uint32;
+ case eTypeUInt8:
+ case eTypeUInt16:
+ case eTypeUInt32:
case eTypeFloat:
- if (sizeof(float) == sizeof(uint32_t))
- return m_data.uint32;
- break;
case eTypeDouble:
- if (sizeof(double) == sizeof(uint32_t))
- return m_data.uint32;
- break;
- case eTypeLongDouble:
- if (sizeof(long double) == sizeof(uint32_t))
- return m_data.uint32;
- break;
+ case eTypeLongDouble: return m_scalar.UInt(fail_value);
case eTypeBytes:
{
- switch (m_data.buffer.length)
+ switch (buffer.length)
{
default: break;
- case 1: return m_data.uint8;
- case 2: return m_data.uint16;
- case 4: return m_data.uint32;
+ case 1:
+ case 2:
+ case 4: return *(const uint32_t *)buffer.bytes;
}
}
break;
@@ -744,31 +678,22 @@ RegisterValue::GetAsUInt64 (uint64_t fail_value, bool *success_ptr) const
switch (m_type)
{
default: break;
- case eTypeUInt8: return m_data.uint8;
- case eTypeUInt16: return m_data.uint16;
- case eTypeUInt32: return m_data.uint32;
- case eTypeUInt64: return m_data.uint64;
+ case eTypeUInt8:
+ case eTypeUInt16:
+ case eTypeUInt32:
+ case eTypeUInt64:
case eTypeFloat:
- if (sizeof(float) == sizeof(uint64_t))
- return m_data.uint64;
- break;
case eTypeDouble:
- if (sizeof(double) == sizeof(uint64_t))
- return m_data.uint64;
- break;
- case eTypeLongDouble:
- if (sizeof(long double) == sizeof(uint64_t))
- return m_data.uint64;
- break;
+ case eTypeLongDouble: return m_scalar.ULongLong(fail_value);
case eTypeBytes:
{
- switch (m_data.buffer.length)
+ switch (buffer.length)
{
default: break;
- case 1: return m_data.uint8;
- case 2: return m_data.uint16;
- case 4: return m_data.uint32;
- case 8: return m_data.uint64;
+ case 1:
+ case 2:
+ case 4:
+ case 8: return *(const uint64_t *)buffer.bytes;
}
}
break;
@@ -778,43 +703,36 @@ RegisterValue::GetAsUInt64 (uint64_t fail_value, bool *success_ptr) const
return fail_value;
}
-#if defined (ENABLE_128_BIT_SUPPORT)
-__uint128_t
-RegisterValue::GetAsUInt128 (__uint128_t fail_value, bool *success_ptr) const
+llvm::APInt
+RegisterValue::GetAsUInt128 (const llvm::APInt& fail_value, bool *success_ptr) const
{
if (success_ptr)
*success_ptr = true;
switch (m_type)
{
default: break;
- case eTypeUInt8: return m_data.uint8;
- case eTypeUInt16: return m_data.uint16;
- case eTypeUInt32: return m_data.uint32;
- case eTypeUInt64: return m_data.uint64;
- case eTypeUInt128: return m_data.uint128;
+ case eTypeUInt8:
+ case eTypeUInt16:
+ case eTypeUInt32:
+ case eTypeUInt64:
+ case eTypeUInt128:
case eTypeFloat:
- if (sizeof(float) == sizeof(__uint128_t))
- return m_data.uint128;
- break;
case eTypeDouble:
- if (sizeof(double) == sizeof(__uint128_t))
- return m_data.uint128;
- break;
- case eTypeLongDouble:
- if (sizeof(long double) == sizeof(__uint128_t))
- return m_data.uint128;
- break;
+ case eTypeLongDouble: return m_scalar.UInt128(fail_value);
case eTypeBytes:
{
- switch (m_data.buffer.length)
+ switch (buffer.length)
{
- default:
- break;
- case 1: return m_data.uint8;
- case 2: return m_data.uint16;
- case 4: return m_data.uint32;
- case 8: return m_data.uint64;
- case 16: return m_data.uint128;
+ default:
+ break;
+ case 1:
+ case 2:
+ case 4:
+ case 8:
+ case 16:
+ {
+ return llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((const type128 *)buffer.bytes)->x);
+ }
}
}
break;
@@ -823,7 +741,7 @@ RegisterValue::GetAsUInt128 (__uint128_t fail_value, bool *success_ptr) const
*success_ptr = false;
return fail_value;
}
-#endif
+
float
RegisterValue::GetAsFloat (float fail_value, bool *success_ptr) const
{
@@ -833,28 +751,12 @@ RegisterValue::GetAsFloat (float fail_value, bool *success_ptr) const
{
default: break;
case eTypeUInt32:
- if (sizeof(float) == sizeof(m_data.uint32))
- return m_data.ieee_float;
- break;
case eTypeUInt64:
- if (sizeof(float) == sizeof(m_data.uint64))
- return m_data.ieee_float;
- break;
-#if defined (ENABLE_128_BIT_SUPPORT)
case eTypeUInt128:
- if (sizeof(float) == sizeof(m_data.uint128))
- return m_data.ieee_float;
- break;
-#endif
- case eTypeFloat: return m_data.ieee_float;
+ case eTypeFloat:
case eTypeDouble:
- if (sizeof(float) == sizeof(double))
- return m_data.ieee_float;
- break;
case eTypeLongDouble:
- if (sizeof(float) == sizeof(long double))
- return m_data.ieee_float;
- break;
+ return m_scalar.Float(fail_value);
}
if (success_ptr)
*success_ptr = false;
@@ -872,27 +774,12 @@ RegisterValue::GetAsDouble (double fail_value, bool *success_ptr) const
break;
case eTypeUInt32:
- if (sizeof(double) == sizeof(m_data.uint32))
- return m_data.ieee_double;
- break;
-
case eTypeUInt64:
- if (sizeof(double) == sizeof(m_data.uint64))
- return m_data.ieee_double;
- break;
-
-#if defined (ENABLE_128_BIT_SUPPORT)
case eTypeUInt128:
- if (sizeof(double) == sizeof(m_data.uint128))
- return m_data.ieee_double;
-#endif
- case eTypeFloat: return m_data.ieee_float;
- case eTypeDouble: return m_data.ieee_double;
-
+ case eTypeFloat:
+ case eTypeDouble:
case eTypeLongDouble:
- if (sizeof(double) == sizeof(long double))
- return m_data.ieee_double;
- break;
+ return m_scalar.Double(fail_value);
}
if (success_ptr)
*success_ptr = false;
@@ -910,24 +797,12 @@ RegisterValue::GetAsLongDouble (long double fail_value, bool *success_ptr) const
break;
case eTypeUInt32:
- if (sizeof(long double) == sizeof(m_data.uint32))
- return m_data.ieee_long_double;
- break;
-
case eTypeUInt64:
- if (sizeof(long double) == sizeof(m_data.uint64))
- return m_data.ieee_long_double;
- break;
-
-#if defined (ENABLE_128_BIT_SUPPORT)
case eTypeUInt128:
- if (sizeof(long double) == sizeof(m_data.uint128))
- return m_data.ieee_long_double;
-#endif
- case eTypeFloat: return m_data.ieee_float;
- case eTypeDouble: return m_data.ieee_double;
- case eTypeLongDouble: return m_data.ieee_long_double;
- break;
+ case eTypeFloat:
+ case eTypeDouble:
+ case eTypeLongDouble:
+ return m_scalar.LongDouble();
}
if (success_ptr)
*success_ptr = false;
@@ -940,17 +815,15 @@ RegisterValue::GetBytes () const
switch (m_type)
{
case eTypeInvalid: break;
- case eTypeUInt8: return &m_data.uint8;
- case eTypeUInt16: return &m_data.uint16;
- case eTypeUInt32: return &m_data.uint32;
- case eTypeUInt64: return &m_data.uint64;
-#if defined (ENABLE_128_BIT_SUPPORT)
- case eTypeUInt128: return &m_data.uint128;
-#endif
- case eTypeFloat: return &m_data.ieee_float;
- case eTypeDouble: return &m_data.ieee_double;
- case eTypeLongDouble: return &m_data.ieee_long_double;
- case eTypeBytes: return m_data.buffer.bytes;
+ case eTypeUInt8:
+ case eTypeUInt16:
+ case eTypeUInt32:
+ case eTypeUInt64:
+ case eTypeUInt128:
+ case eTypeFloat:
+ case eTypeDouble:
+ case eTypeLongDouble: return m_scalar.GetBytes();
+ case eTypeBytes: return buffer.bytes;
}
return NULL;
}
@@ -961,17 +834,15 @@ RegisterValue::GetBytes ()
switch (m_type)
{
case eTypeInvalid: break;
- case eTypeUInt8: return &m_data.uint8;
- case eTypeUInt16: return &m_data.uint16;
- case eTypeUInt32: return &m_data.uint32;
- case eTypeUInt64: return &m_data.uint64;
-#if defined (ENABLE_128_BIT_SUPPORT)
- case eTypeUInt128: return &m_data.uint128;
-#endif
- case eTypeFloat: return &m_data.ieee_float;
- case eTypeDouble: return &m_data.ieee_double;
- case eTypeLongDouble: return &m_data.ieee_long_double;
- case eTypeBytes: return m_data.buffer.bytes;
+ case eTypeUInt8:
+ case eTypeUInt16:
+ case eTypeUInt32:
+ case eTypeUInt64:
+ case eTypeUInt128:
+ case eTypeFloat:
+ case eTypeDouble:
+ case eTypeLongDouble: return m_scalar.GetBytes();
+ case eTypeBytes: return buffer.bytes;
}
return NULL;
}
@@ -982,17 +853,15 @@ RegisterValue::GetByteSize () const
switch (m_type)
{
case eTypeInvalid: break;
- case eTypeUInt8: return sizeof(m_data.uint8);
- case eTypeUInt16: return sizeof(m_data.uint16);
- case eTypeUInt32: return sizeof(m_data.uint32);
- case eTypeUInt64: return sizeof(m_data.uint64);
-#if defined (ENABLE_128_BIT_SUPPORT)
- case eTypeUInt128: return sizeof(m_data.uint128);
-#endif
- case eTypeFloat: return sizeof(m_data.ieee_float);
- case eTypeDouble: return sizeof(m_data.ieee_double);
- case eTypeLongDouble: return sizeof(m_data.ieee_long_double);
- case eTypeBytes: return m_data.buffer.length;
+ case eTypeUInt8: return 1;
+ case eTypeUInt16: return 2;
+ case eTypeUInt32:
+ case eTypeUInt64:
+ case eTypeUInt128:
+ case eTypeFloat:
+ case eTypeDouble:
+ case eTypeLongDouble: return m_scalar.GetByteSize();
+ case eTypeBytes: return buffer.length;
}
return 0;
}
@@ -1021,12 +890,10 @@ RegisterValue::SetUInt (uint64_t uint, uint32_t byte_size)
{
SetUInt64 (uint);
}
-#if defined (ENABLE_128_BIT_SUPPORT)
else if (byte_size <= 16)
{
- SetUInt128 (uint);
+ SetUInt128 (llvm::APInt(128, uint));
}
-#endif
else
return false;
return true;
@@ -1036,21 +903,21 @@ void
RegisterValue::SetBytes (const void *bytes, size_t length, lldb::ByteOrder byte_order)
{
// If this assertion fires off we need to increase the size of
- // m_data.buffer.bytes, or make it something that is allocated on
+ // buffer.bytes, or make it something that is allocated on
// the heap. Since the data buffer is in a union, we can't make it
// a collection class like SmallVector...
if (bytes && length > 0)
{
- assert (length <= sizeof (m_data.buffer.bytes) && "Storing too many bytes in a RegisterValue.");
+ assert (length <= sizeof (buffer.bytes) && "Storing too many bytes in a RegisterValue.");
m_type = eTypeBytes;
- m_data.buffer.length = length;
- memcpy (m_data.buffer.bytes, bytes, length);
- m_data.buffer.byte_order = byte_order;
+ buffer.length = length;
+ memcpy (buffer.bytes, bytes, length);
+ buffer.byte_order = byte_order;
}
else
{
m_type = eTypeInvalid;
- m_data.buffer.length = 0;
+ buffer.length = 0;
}
}
@@ -1063,25 +930,23 @@ RegisterValue::operator == (const RegisterValue &rhs) const
switch (m_type)
{
case eTypeInvalid: return true;
- case eTypeUInt8: return m_data.uint8 == rhs.m_data.uint8;
- case eTypeUInt16: return m_data.uint16 == rhs.m_data.uint16;
- case eTypeUInt32: return m_data.uint32 == rhs.m_data.uint32;
- case eTypeUInt64: return m_data.uint64 == rhs.m_data.uint64;
-#if defined (ENABLE_128_BIT_SUPPORT)
- case eTypeUInt128: return m_data.uint128 == rhs.m_data.uint128;
-#endif
- case eTypeFloat: return m_data.ieee_float == rhs.m_data.ieee_float;
- case eTypeDouble: return m_data.ieee_double == rhs.m_data.ieee_double;
- case eTypeLongDouble: return m_data.ieee_long_double == rhs.m_data.ieee_long_double;
+ case eTypeUInt8:
+ case eTypeUInt16:
+ case eTypeUInt32:
+ case eTypeUInt64:
+ case eTypeUInt128:
+ case eTypeFloat:
+ case eTypeDouble:
+ case eTypeLongDouble: return m_scalar == rhs.m_scalar;
case eTypeBytes:
- if (m_data.buffer.length != rhs.m_data.buffer.length)
+ if (buffer.length != rhs.buffer.length)
return false;
else
{
- uint8_t length = m_data.buffer.length;
+ uint8_t length = buffer.length;
if (length > kMaxRegisterByteSize)
length = kMaxRegisterByteSize;
- return memcmp (m_data.buffer.bytes, rhs.m_data.buffer.bytes, length) == 0;
+ return memcmp (buffer.bytes, rhs.buffer.bytes, length) == 0;
}
break;
}
@@ -1097,27 +962,25 @@ RegisterValue::operator != (const RegisterValue &rhs) const
switch (m_type)
{
case eTypeInvalid: return false;
- case eTypeUInt8: return m_data.uint8 != rhs.m_data.uint8;
- case eTypeUInt16: return m_data.uint16 != rhs.m_data.uint16;
- case eTypeUInt32: return m_data.uint32 != rhs.m_data.uint32;
- case eTypeUInt64: return m_data.uint64 != rhs.m_data.uint64;
-#if defined (ENABLE_128_BIT_SUPPORT)
- case eTypeUInt128: return m_data.uint128 != rhs.m_data.uint128;
-#endif
- case eTypeFloat: return m_data.ieee_float != rhs.m_data.ieee_float;
- case eTypeDouble: return m_data.ieee_double != rhs.m_data.ieee_double;
- case eTypeLongDouble: return m_data.ieee_long_double != rhs.m_data.ieee_long_double;
+ case eTypeUInt8:
+ case eTypeUInt16:
+ case eTypeUInt32:
+ case eTypeUInt64:
+ case eTypeUInt128:
+ case eTypeFloat:
+ case eTypeDouble:
+ case eTypeLongDouble: return m_scalar != rhs.m_scalar;
case eTypeBytes:
- if (m_data.buffer.length != rhs.m_data.buffer.length)
+ if (buffer.length != rhs.buffer.length)
{
return true;
}
else
{
- uint8_t length = m_data.buffer.length;
+ uint8_t length = buffer.length;
if (length > kMaxRegisterByteSize)
length = kMaxRegisterByteSize;
- return memcmp (m_data.buffer.bytes, rhs.m_data.buffer.bytes, length) != 0;
+ return memcmp (buffer.bytes, rhs.buffer.bytes, length) != 0;
}
break;
}
@@ -1132,63 +995,35 @@ RegisterValue::ClearBit (uint32_t bit)
case eTypeInvalid:
break;
- case eTypeUInt8:
- if (bit < 8)
- {
- m_data.uint8 &= ~(1u << bit);
- return true;
- }
- break;
-
+ case eTypeUInt8:
case eTypeUInt16:
- if (bit < 16)
- {
- m_data.uint16 &= ~(1u << bit);
- return true;
- }
- break;
-
case eTypeUInt32:
- if (bit < 32)
- {
- m_data.uint32 &= ~(1u << bit);
- return true;
- }
- break;
-
case eTypeUInt64:
- if (bit < 64)
- {
- m_data.uint64 &= ~(1ull << (uint64_t)bit);
- return true;
- }
- break;
-#if defined (ENABLE_128_BIT_SUPPORT)
case eTypeUInt128:
- if (bit < 64)
+ if (bit < (GetByteSize() * 8))
{
- m_data.uint128 &= ~((__uint128_t)1ull << (__uint128_t)bit);
- return true;
+ return m_scalar.ClearBit(bit);
}
-#endif
+ break;
+
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
break;
case eTypeBytes:
- if (m_data.buffer.byte_order == eByteOrderBig || m_data.buffer.byte_order == eByteOrderLittle)
+ if (buffer.byte_order == eByteOrderBig || buffer.byte_order == eByteOrderLittle)
{
uint32_t byte_idx;
- if (m_data.buffer.byte_order == eByteOrderBig)
- byte_idx = m_data.buffer.length - (bit / 8) - 1;
+ if (buffer.byte_order == eByteOrderBig)
+ byte_idx = buffer.length - (bit / 8) - 1;
else
byte_idx = bit / 8;
const uint32_t byte_bit = bit % 8;
- if (byte_idx < m_data.buffer.length)
+ if (byte_idx < buffer.length)
{
- m_data.buffer.bytes[byte_idx] &= ~(1u << byte_bit);
+ buffer.bytes[byte_idx] &= ~(1u << byte_bit);
return true;
}
}
@@ -1207,62 +1042,34 @@ RegisterValue::SetBit (uint32_t bit)
break;
case eTypeUInt8:
- if (bit < 8)
- {
- m_data.uint8 |= (1u << bit);
- return true;
- }
- break;
-
case eTypeUInt16:
- if (bit < 16)
- {
- m_data.uint16 |= (1u << bit);
- return true;
- }
- break;
-
case eTypeUInt32:
- if (bit < 32)
- {
- m_data.uint32 |= (1u << bit);
- return true;
- }
- break;
-
case eTypeUInt64:
- if (bit < 64)
- {
- m_data.uint64 |= (1ull << (uint64_t)bit);
- return true;
- }
- break;
-#if defined (ENABLE_128_BIT_SUPPORT)
case eTypeUInt128:
- if (bit < 64)
+ if (bit < (GetByteSize() * 8))
{
- m_data.uint128 |= ((__uint128_t)1ull << (__uint128_t)bit);
- return true;
+ return m_scalar.SetBit(bit);
}
-#endif
+ break;
+
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
break;
case eTypeBytes:
- if (m_data.buffer.byte_order == eByteOrderBig || m_data.buffer.byte_order == eByteOrderLittle)
+ if (buffer.byte_order == eByteOrderBig || buffer.byte_order == eByteOrderLittle)
{
uint32_t byte_idx;
- if (m_data.buffer.byte_order == eByteOrderBig)
- byte_idx = m_data.buffer.length - (bit / 8) - 1;
+ if (buffer.byte_order == eByteOrderBig)
+ byte_idx = buffer.length - (bit / 8) - 1;
else
byte_idx = bit / 8;
const uint32_t byte_bit = bit % 8;
- if (byte_idx < m_data.buffer.length)
+ if (byte_idx < buffer.length)
{
- m_data.buffer.bytes[byte_idx] |= (1u << byte_bit);
+ buffer.bytes[byte_idx] |= (1u << byte_bit);
return true;
}
}
diff --git a/source/Core/RegularExpression.cpp b/source/Core/RegularExpression.cpp
index 3f712e1b2daa..767521500af8 100644
--- a/source/Core/RegularExpression.cpp
+++ b/source/Core/RegularExpression.cpp
@@ -153,7 +153,7 @@ RegularExpression::Match::GetMatchAtIndex (const char* s, uint32_t idx, std::str
llvm::StringRef match_str_ref;
if (GetMatchAtIndex(s, idx, match_str_ref))
{
- match_str = std::move(match_str_ref.str());
+ match_str = match_str_ref.str();
return true;
}
return false;
@@ -258,4 +258,3 @@ RegularExpression::operator < (const RegularExpression& rhs) const
{
return (m_re < rhs.m_re);
}
-
diff --git a/source/Core/Scalar.cpp b/source/Core/Scalar.cpp
index 0022c348bfee..586969b2d50a 100644
--- a/source/Core/Scalar.cpp
+++ b/source/Core/Scalar.cpp
@@ -11,6 +11,7 @@
#include <math.h>
#include <inttypes.h>
+#include <stdio.h>
#include "lldb/Interpreter/Args.h"
#include "lldb/Core/Error.h"
@@ -77,7 +78,7 @@ PromoteToMaxType
//----------------------------------------------------------------------
Scalar::Scalar() :
m_type(e_void),
- m_data()
+ m_float((float)0)
{
}
@@ -86,7 +87,8 @@ Scalar::Scalar() :
//----------------------------------------------------------------------
Scalar::Scalar(const Scalar& rhs) :
m_type(rhs.m_type),
- m_data(rhs.m_data) // TODO: verify that for C++ this will correctly copy the union??
+ m_integer(rhs.m_integer),
+ m_float(rhs.m_float)
{
}
@@ -135,29 +137,109 @@ bool
Scalar::GetData (DataExtractor &data, size_t limit_byte_size) const
{
size_t byte_size = GetByteSize();
+ static float f_val;
+ static double d_val;
if (byte_size > 0)
{
if (limit_byte_size < byte_size)
{
- if (lldb::endian::InlHostByteOrder() == eByteOrderLittle)
+ if (endian::InlHostByteOrder() == eByteOrderLittle)
{
// On little endian systems if we want fewer bytes from the
// current type we just specify fewer bytes since the LSByte
// is first...
- data.SetData((uint8_t*)&m_data, limit_byte_size, lldb::endian::InlHostByteOrder());
+ 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:
+ data.SetData((const uint8_t *)m_integer.getRawData(), limit_byte_size, endian::InlHostByteOrder());
+ return true;
+ case e_float:
+ f_val = m_float.convertToFloat();
+ data.SetData((uint8_t *)&f_val, limit_byte_size, endian::InlHostByteOrder());
+ return true;
+ case e_double:
+ d_val = m_float.convertToDouble();
+ data.SetData((uint8_t *)&d_val, limit_byte_size, endian::InlHostByteOrder());
+ return true;
+ case e_long_double:
+ static llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+ data.SetData((const uint8_t *)ldbl_val.getRawData(), limit_byte_size, endian::InlHostByteOrder());
+ return true;
+ }
}
- else if (lldb::endian::InlHostByteOrder() == eByteOrderBig)
+ else if (endian::InlHostByteOrder() == eByteOrderBig)
{
// On big endian systems if we want fewer bytes from the
// current type have to advance our initial byte pointer and
// trim down the number of bytes since the MSByte is first
- data.SetData(((uint8_t*)&m_data) + byte_size - limit_byte_size, limit_byte_size, lldb::endian::InlHostByteOrder());
+ 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:
+ data.SetData((const uint8_t *)m_integer.getRawData() + byte_size - limit_byte_size, limit_byte_size, endian::InlHostByteOrder());
+ return true;
+ case e_float:
+ f_val = m_float.convertToFloat();
+ data.SetData((uint8_t *)&f_val + byte_size - limit_byte_size, limit_byte_size, endian::InlHostByteOrder());
+ return true;
+ case e_double:
+ d_val = m_float.convertToDouble();
+ data.SetData((uint8_t *)&d_val + byte_size - limit_byte_size, limit_byte_size, endian::InlHostByteOrder());
+ return true;
+ case e_long_double:
+ static llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+ data.SetData((const uint8_t *)ldbl_val.getRawData() + byte_size - limit_byte_size, limit_byte_size, endian::InlHostByteOrder());
+ return true;
+ }
}
}
else
{
// We want all of the data
- data.SetData((uint8_t*)&m_data, byte_size, lldb::endian::InlHostByteOrder());
+ 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:
+ data.SetData((const uint8_t *)m_integer.getRawData(), byte_size, endian::InlHostByteOrder());
+ return true;
+ case e_float:
+ f_val = m_float.convertToFloat();
+ data.SetData((uint8_t *)&f_val, byte_size, endian::InlHostByteOrder());
+ return true;
+ case e_double:
+ d_val = m_float.convertToDouble();
+ data.SetData((uint8_t *)&d_val, byte_size, endian::InlHostByteOrder());
+ return true;
+ case e_long_double:
+ static llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+ data.SetData((const uint8_t *)ldbl_val.getRawData(), byte_size, endian::InlHostByteOrder());
+ return true;
+ }
}
return true;
}
@@ -165,6 +247,37 @@ Scalar::GetData (DataExtractor &data, size_t limit_byte_size) const
return false;
}
+void *
+Scalar::GetBytes() const
+{
+ static float_t flt_val;
+ static double_t dbl_val;
+ 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:
+ return const_cast<void *>(reinterpret_cast<const void *>(m_integer.getRawData()));
+ case e_float:
+ flt_val = m_float.convertToFloat();
+ return (void *)&flt_val;
+ case e_double:
+ dbl_val = m_float.convertToDouble();
+ return (void *)&dbl_val;
+ case e_long_double:
+ llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+ return const_cast<void *>(reinterpret_cast<const void *>(ldbl_val.getRawData()));
+ }
+ return NULL;
+}
+
size_t
Scalar::GetByteSize() const
{
@@ -172,15 +285,17 @@ Scalar::GetByteSize() const
{
case e_void:
break;
- case e_sint: return sizeof(m_data.sint);
- case e_uint: return sizeof(m_data.uint);
- case e_slong: return sizeof(m_data.slong);
- case e_ulong: return sizeof(m_data.ulong);
- case e_slonglong: return sizeof(m_data.slonglong);
- case e_ulonglong: return sizeof(m_data.ulonglong);
- case e_float: return sizeof(m_data.flt);
- case e_double: return sizeof(m_data.dbl);
- case e_long_double: return sizeof(m_data.ldbl);
+ case e_sint:
+ case e_uint:
+ case e_slong:
+ case e_ulong:
+ case e_slonglong:
+ case e_ulonglong:
+ case e_sint128:
+ case e_uint128: return (m_integer.getBitWidth() / 8);
+ case e_float: return sizeof(float_t);
+ case e_double: return sizeof(double_t);
+ case e_long_double: return sizeof(long_double_t);
}
return 0;
}
@@ -188,19 +303,24 @@ Scalar::GetByteSize() const
bool
Scalar::IsZero() const
{
+ llvm::APInt zero_int = llvm::APInt::getNullValue(m_integer.getBitWidth() / 8);
switch (m_type)
{
case e_void:
break;
- case e_sint: return m_data.sint == 0;
- case e_uint: return m_data.uint == 0;
- case e_slong: return m_data.slong == 0;
- case e_ulong: return m_data.ulong == 0;
- case e_slonglong: return m_data.slonglong == 0;
- case e_ulonglong: return m_data.ulonglong == 0;
- case e_float: return m_data.flt == 0.0f;
- case e_double: return m_data.dbl == 0.0;
- case e_long_double: return m_data.ldbl == 0.0;
+ case e_sint:
+ case e_uint:
+ case e_slong:
+ case e_ulong:
+ case e_slonglong:
+ case e_ulonglong:
+ case e_sint128:
+ case e_uint128:
+ return llvm::APInt::isSameValue(zero_int, m_integer);
+ case e_float:
+ case e_double:
+ case e_long_double:
+ return m_float.isZero();
}
return false;
}
@@ -208,6 +328,7 @@ Scalar::IsZero() const
void
Scalar::GetValue (Stream *s, bool show_type) const
{
+ const uint64_t *src;
if (show_type)
s->Printf("(%s) ", GetTypeAsCString());
@@ -215,15 +336,26 @@ Scalar::GetValue (Stream *s, bool show_type) const
{
case e_void:
break;
- case e_sint: s->Printf("%i", m_data.sint); break;
- case e_uint: s->Printf("0x%8.8x", m_data.uint); break;
- case e_slong: s->Printf("%li", m_data.slong); break;
- case e_ulong: s->Printf("0x%8.8lx", m_data.ulong); break;
- case e_slonglong: s->Printf("%lli", m_data.slonglong); break;
- case e_ulonglong: s->Printf("0x%16.16llx", m_data.ulonglong); break;
- case e_float: s->Printf("%f", m_data.flt); break;
- case e_double: s->Printf("%g", m_data.dbl); break;
- case e_long_double: s->Printf("%Lg", m_data.ldbl); break;
+ case e_sint: s->Printf("%i", *(const sint_t *) m_integer.getRawData()); break;
+ case e_uint: s->Printf("0x%8.8x", *(const uint_t *) m_integer.getRawData()); break;
+ case e_slong: s->Printf("%li", *(const slong_t *) m_integer.getRawData()); break;
+ case e_ulong: s->Printf("0x%8.8lx", *(const ulong_t *) m_integer.getRawData()); break;
+ case e_slonglong: s->Printf("%lli", *(const slonglong_t *) m_integer.getRawData()); break;
+ case e_ulonglong: s->Printf("0x%16.16llx", *(const ulonglong_t *) m_integer.getRawData()); break;
+ case e_sint128:
+ src = m_integer.getRawData();
+ s->Printf("%lli%lli", *(const slonglong_t *)src, *(const slonglong_t *)(src + 1));
+ break;
+ case e_uint128:
+ src = m_integer.getRawData();
+ s->Printf("0x%16.16llx%16.16llx", *(const ulonglong_t *)src, *(const ulonglong_t *)(src + 1));
+ break;
+ case e_float: s->Printf("%f", m_float.convertToFloat()); break;
+ case e_double: s->Printf("%g", m_float.convertToDouble()); break;
+ case e_long_double:
+ llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+ s->Printf("%Lg", *(const long_double_t *)ldbl_val.getRawData());
+ break;
}
}
@@ -239,6 +371,8 @@ Scalar::GetTypeAsCString() const
case e_ulong: return "unsigned long";
case e_slonglong: return "long long";
case e_ulonglong: return "unsigned long long";
+ case e_sint128: return "int128_t";
+ case e_uint128: return "unsigned int128_t";
case e_float: return "float";
case e_double: return "double";
case e_long_double: return "long double";
@@ -257,7 +391,8 @@ Scalar::operator=(const Scalar& rhs)
if (this != &rhs)
{
m_type = rhs.m_type;
- ::memcpy (&m_data, &rhs.m_data, sizeof(m_data));
+ m_integer = llvm::APInt(rhs.m_integer);
+ m_float = rhs.m_float;
}
return *this;
}
@@ -266,7 +401,7 @@ Scalar&
Scalar::operator= (const int v)
{
m_type = e_sint;
- m_data.sint = v;
+ m_integer = llvm::APInt(sizeof(int) * 8, v, true);
return *this;
}
@@ -275,7 +410,7 @@ Scalar&
Scalar::operator= (unsigned int v)
{
m_type = e_uint;
- m_data.uint = v;
+ m_integer = llvm::APInt(sizeof(int) * 8, v);
return *this;
}
@@ -283,7 +418,7 @@ Scalar&
Scalar::operator= (long v)
{
m_type = e_slong;
- m_data.slong = v;
+ m_integer = llvm::APInt(sizeof(long) * 8, v, true);
return *this;
}
@@ -291,7 +426,7 @@ Scalar&
Scalar::operator= (unsigned long v)
{
m_type = e_ulong;
- m_data.ulong = v;
+ m_integer = llvm::APInt(sizeof(long) * 8, v);
return *this;
}
@@ -299,7 +434,7 @@ Scalar&
Scalar::operator= (long long v)
{
m_type = e_slonglong;
- m_data.slonglong = v;
+ m_integer = llvm::APInt(sizeof(long) * 8, v, true);
return *this;
}
@@ -307,7 +442,7 @@ Scalar&
Scalar::operator= (unsigned long long v)
{
m_type = e_ulonglong;
- m_data.ulonglong = v;
+ m_integer = llvm::APInt(sizeof(long long) * 8, v);
return *this;
}
@@ -315,7 +450,7 @@ Scalar&
Scalar::operator= (float v)
{
m_type = e_float;
- m_data.flt = v;
+ m_float = llvm::APFloat(v);
return *this;
}
@@ -323,7 +458,7 @@ Scalar&
Scalar::operator= (double v)
{
m_type = e_double;
- m_data.dbl = v;
+ m_float = llvm::APFloat(v);
return *this;
}
@@ -331,7 +466,40 @@ Scalar&
Scalar::operator= (long double v)
{
m_type = e_long_double;
- m_data.ldbl = v;
+ if(m_ieee_quad)
+ m_float = llvm::APFloat(llvm::APFloat::IEEEquad, llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x));
+ else
+ m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x));
+ return *this;
+}
+
+Scalar&
+Scalar::operator= (llvm::APInt rhs)
+{
+ m_integer = llvm::APInt(rhs);
+ switch(m_integer.getBitWidth())
+ {
+ case 8:
+ case 16:
+ case 32:
+ if(m_integer.isSignedIntN(sizeof(sint_t) * 8))
+ m_type = e_sint;
+ else
+ m_type = e_uint;
+ break;
+ case 64:
+ if(m_integer.isSignedIntN(sizeof(slonglong_t) * 8))
+ m_type = e_slonglong;
+ else
+ m_type = e_ulonglong;
+ break;
+ case 128:
+ if(m_integer.isSignedIntN(BITWIDTH_INT128))
+ m_type = e_sint128;
+ else
+ m_type = e_uint128;
+ break;
+ }
return *this;
}
@@ -354,128 +522,455 @@ Scalar::Promote(Scalar::Type type)
case e_sint:
switch (type)
{
- case e_void: break;
- case e_sint: success = true; break;
- case e_uint: m_data.uint = m_data.sint; success = true; break;
- case e_slong: m_data.slong = m_data.sint; success = true; break;
- case e_ulong: m_data.ulong = m_data.sint; success = true; break;
- case e_slonglong: m_data.slonglong = m_data.sint; success = true; break;
- case e_ulonglong: m_data.ulonglong = m_data.sint; success = true; break;
- case e_float: m_data.flt = m_data.sint; success = true; break;
- case e_double: m_data.dbl = m_data.sint; success = true; break;
- case e_long_double: m_data.ldbl = m_data.sint; success = true; break;
+ case e_void: break;
+ case e_sint: success = true; break;
+ case e_uint:
+ {
+ m_integer = llvm::APInt(sizeof(uint_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+ success = true;
+ break;
+ }
+ case e_slong:
+ {
+ m_integer = llvm::APInt(sizeof(slong_t) * 8, *(const uint64_t *)m_integer.getRawData(), true);
+ success = true;
+ break;
+ }
+ case e_ulong:
+ {
+ m_integer = llvm::APInt(sizeof(ulong_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+ success = true;
+ break;
+ }
+ case e_slonglong:
+ {
+ m_integer = llvm::APInt(sizeof(slonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), true);
+ success = true;
+ break;
+ }
+ case e_ulonglong:
+ {
+ m_integer = llvm::APInt(sizeof(ulonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+ success = true;
+ break;
+ }
+ case e_sint128:
+ case e_uint128:
+ {
+ m_integer = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((const type128 *)m_integer.getRawData()));
+ success = true;
+ break;
+ }
+ case e_float:
+ {
+ m_float = llvm::APFloat(m_integer.bitsToFloat());
+ success = true;
+ break;
+ }
+ case e_double:
+ {
+ m_float = llvm::APFloat(m_integer.bitsToDouble());
+ success = true;
+ break;
+ }
+ case e_long_double:
+ {
+ if(m_ieee_quad)
+ m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_integer);
+ else
+ m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_integer);
+ success = true;
+ break;
+ }
}
break;
case e_uint:
switch (type)
{
- case e_void:
- case e_sint: break;
- case e_uint: success = true; break;
- case e_slong: m_data.slong = m_data.uint; success = true; break;
- case e_ulong: m_data.ulong = m_data.uint; success = true; break;
- case e_slonglong: m_data.slonglong = m_data.uint; success = true; break;
- case e_ulonglong: m_data.ulonglong = m_data.uint; success = true; break;
- case e_float: m_data.flt = m_data.uint; success = true; break;
- case e_double: m_data.dbl = m_data.uint; success = true; break;
- case e_long_double: m_data.ldbl = m_data.uint; success = true; break;
+ case e_void:
+ case e_sint: break;
+ case e_uint: success = true; break;
+ case e_slong:
+ {
+ m_integer = llvm::APInt(sizeof(slong_t) * 8, *(const uint64_t *)m_integer.getRawData(), true);
+ success = true;
+ break;
+ }
+ case e_ulong:
+ {
+ m_integer = llvm::APInt(sizeof(ulong_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+ success = true;
+ break;
+ }
+ case e_slonglong:
+ {
+ m_integer = llvm::APInt(sizeof(slonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), true);
+ success = true;
+ break;
+ }
+ case e_ulonglong:
+ {
+ m_integer = llvm::APInt(sizeof(ulonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+ success = true;
+ break;
+ }
+ case e_sint128:
+ case e_uint128:
+ {
+ m_integer = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((const type128 *)m_integer.getRawData()));
+ success = true;
+ break;
+ }
+ case e_float:
+ {
+ m_float = llvm::APFloat(m_integer.bitsToFloat());
+ success = true;
+ break;
+ }
+ case e_double:
+ {
+ m_float = llvm::APFloat(m_integer.bitsToDouble());
+ success = true;
+ break;
+ }
+ case e_long_double:
+ {
+ if(m_ieee_quad)
+ m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_integer);
+ else
+ m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_integer);
+ success = true;
+ break;
+ }
}
break;
case e_slong:
switch (type)
{
- case e_void:
- case e_sint:
- case e_uint: break;
- case e_slong: success = true; break;
- case e_ulong: m_data.ulong = m_data.slong; success = true; break;
- case e_slonglong: m_data.slonglong = m_data.slong; success = true; break;
- case e_ulonglong: m_data.ulonglong = m_data.slong; success = true; break;
- case e_float: m_data.flt = m_data.slong; success = true; break;
- case e_double: m_data.dbl = m_data.slong; success = true; break;
- case e_long_double: m_data.ldbl = m_data.slong; success = true; break;
+ case e_void:
+ case e_sint:
+ case e_uint: break;
+ case e_slong: success = true; break;
+ case e_ulong:
+ {
+ m_integer = llvm::APInt(sizeof(ulong_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+ success = true;
+ break;
+ }
+ case e_slonglong:
+ {
+ m_integer = llvm::APInt(sizeof(slonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), true);
+ success = true;
+ break;
+ }
+ case e_ulonglong:
+ {
+ m_integer = llvm::APInt(sizeof(ulonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+ success = true;
+ break;
+ }
+ case e_sint128:
+ case e_uint128:
+ {
+ m_integer = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((const type128 *)m_integer.getRawData()));
+ success = true;
+ break;
+ }
+ case e_float:
+ {
+ m_float = llvm::APFloat(m_integer.bitsToFloat());
+ success = true;
+ break;
+ }
+ case e_double:
+ {
+ m_float = llvm::APFloat(m_integer.bitsToDouble());
+ success = true;
+ break;
+ }
+ case e_long_double:
+ {
+ if(m_ieee_quad)
+ m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_integer);
+ else
+ m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_integer);
+ success = true;
+ break;
+ }
}
break;
case e_ulong:
switch (type)
{
- case e_void:
- case e_sint:
- case e_uint:
- case e_slong: break;
- case e_ulong: success = true; break;
- case e_slonglong: m_data.slonglong = m_data.ulong; success = true; break;
- case e_ulonglong: m_data.ulonglong = m_data.ulong; success = true; break;
- case e_float: m_data.flt = m_data.ulong; success = true; break;
- case e_double: m_data.dbl = m_data.ulong; success = true; break;
- case e_long_double: m_data.ldbl = m_data.ulong; success = true; break;
+ case e_void:
+ case e_sint:
+ case e_uint:
+ case e_slong: break;
+ case e_ulong: success = true; break;
+ case e_slonglong:
+ {
+ m_integer = llvm::APInt(sizeof(slonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), true);
+ success = true;
+ break;
+ }
+ case e_ulonglong:
+ {
+ m_integer = llvm::APInt(sizeof(ulonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+ success = true;
+ break;
+ }
+ case e_sint128:
+ case e_uint128:
+ {
+ m_integer = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((const type128 *)m_integer.getRawData()));
+ success = true;
+ break;
+ }
+ case e_float:
+ {
+ m_float = llvm::APFloat(m_integer.bitsToFloat());
+ success = true;
+ break;
+ }
+ case e_double:
+ {
+ m_float = llvm::APFloat(m_integer.bitsToDouble());
+ success = true;
+ break;
+ }
+ case e_long_double:
+ {
+ if(m_ieee_quad)
+ m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_integer);
+ else
+ m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_integer);
+ success = true;
+ break;
+ }
}
break;
case e_slonglong:
switch (type)
{
- case e_void:
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong: break;
- case e_slonglong: success = true; break;
- case e_ulonglong: m_data.ulonglong = m_data.slonglong; success = true; break;
- case e_float: m_data.flt = m_data.slonglong; success = true; break;
- case e_double: m_data.dbl = m_data.slonglong; success = true; break;
- case e_long_double: m_data.ldbl = m_data.slonglong; success = true; break;
+ case e_void:
+ case e_sint:
+ case e_uint:
+ case e_slong:
+ case e_ulong: break;
+ case e_slonglong: success = true; break;
+ case e_ulonglong:
+ {
+ m_integer = llvm::APInt(sizeof(ulonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+ success = true;
+ break;
+ }
+ case e_sint128:
+ case e_uint128:
+ {
+ m_integer = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((const type128 *)m_integer.getRawData()));
+ success = true;
+ break;
+ }
+ case e_float:
+ {
+ m_float = llvm::APFloat(m_integer.bitsToFloat());
+ success = true;
+ break;
+ }
+ case e_double:
+ {
+ m_float = llvm::APFloat(m_integer.bitsToDouble());
+ success = true;
+ break;
+ }
+ case e_long_double:
+ {
+ if(m_ieee_quad)
+ m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_integer);
+ else
+ m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_integer);
+ success = true;
+ break;
+ }
}
break;
case e_ulonglong:
switch (type)
{
- case e_void:
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong: break;
- case e_ulonglong: success = true; break;
- case e_float: m_data.flt = m_data.ulonglong; success = true; break;
- case e_double: m_data.dbl = m_data.ulonglong; success = true; break;
- case e_long_double: m_data.ldbl = m_data.ulonglong; success = true; break;
+ case e_void:
+ case e_sint:
+ case e_uint:
+ case e_slong:
+ case e_ulong:
+ case e_slonglong: break;
+ case e_ulonglong: success = true; break;
+ case e_sint128:
+ case e_uint128:
+ {
+ m_integer = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((const type128 *)m_integer.getRawData()));
+ success = true;
+ break;
+ }
+ case e_float:
+ {
+ m_float = llvm::APFloat(m_integer.bitsToFloat());
+ success = true;
+ break;
+ }
+ case e_double:
+ {
+ m_float = llvm::APFloat(m_integer.bitsToDouble());
+ success = true;
+ break;
+ }
+ case e_long_double:
+ {
+ if(m_ieee_quad)
+ m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_integer);
+ else
+ m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_integer);
+ success = true;
+ break;
+ }
+ }
+ break;
+
+ case e_sint128:
+ switch (type)
+ {
+ case e_void:
+ case e_sint:
+ case e_uint:
+ case e_slong:
+ case e_ulong:
+ case e_slonglong:
+ case e_ulonglong: break;
+ case e_sint128: success = true; break;
+ case e_uint128:
+ {
+ m_integer = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((const type128 *)m_integer.getRawData()));
+ success = true;
+ break;
+ }
+ case e_float:
+ {
+ m_float = llvm::APFloat(m_integer.bitsToFloat());
+ success = true;
+ break;
+ }
+ case e_double:
+ {
+ m_float = llvm::APFloat(m_integer.bitsToDouble());
+ success = true;
+ break;
+ }
+ case e_long_double:
+ {
+ if(m_ieee_quad)
+ m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_integer);
+ else
+ m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_integer);
+ success = true;
+ break;
+ }
+ }
+ break;
+
+ case e_uint128:
+ switch (type)
+ {
+ case e_void:
+ case e_sint:
+ case e_uint:
+ case e_slong:
+ case e_ulong:
+ case e_slonglong:
+ case e_ulonglong:
+ case e_sint128: break;
+ case e_uint128: success = true; break;
+ case e_float:
+ {
+ m_float = llvm::APFloat(m_integer.bitsToFloat());
+ success = true;
+ break;
+ }
+ case e_double:
+ {
+ m_float = llvm::APFloat(m_integer.bitsToDouble());
+ success = true;
+ break;
+ }
+ case e_long_double:
+ {
+ if(m_ieee_quad)
+ m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_integer);
+ else
+ m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_integer);
+ success = true;
+ break;
+ }
}
break;
case e_float:
switch (type)
{
- case e_void:
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong: break;
- case e_float: success = true; break;
- case e_double: m_data.dbl = m_data.flt; success = true; break;
- case e_long_double: m_data.ldbl = m_data.ulonglong; success = true; break;
+ case e_void:
+ case e_sint:
+ case e_uint:
+ case e_slong:
+ case e_ulong:
+ case e_slonglong:
+ case e_ulonglong:
+ case e_sint128:
+ case e_uint128: break;
+ case e_float: success = true; break;
+ case e_double:
+ {
+ m_float = llvm::APFloat((float_t)m_float.convertToFloat());
+ success = true;
+ break;
+ }
+ case e_long_double:
+ {
+ if(m_ieee_quad)
+ m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_float.bitcastToAPInt());
+ else
+ m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_float.bitcastToAPInt());
+ success = true;
+ break;
+ }
}
break;
case e_double:
switch (type)
{
- case e_void:
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_float: break;
- case e_double: success = true; break;
- case e_long_double: m_data.ldbl = m_data.dbl; success = true; break;
+ case e_void:
+ 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_float: break;
+ case e_double: success = true; break;
+ case e_long_double:
+ {
+ if(m_ieee_quad)
+ m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_float.bitcastToAPInt());
+ else
+ m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_float.bitcastToAPInt());
+ success = true;
+ break;
+ }
}
break;
@@ -489,6 +984,8 @@ Scalar::Promote(Scalar::Type type)
case e_ulong:
case e_slonglong:
case e_ulonglong:
+ case e_sint128:
+ case e_uint128:
case e_float:
case e_double: break;
case e_long_double: success = true; break;
@@ -516,6 +1013,8 @@ Scalar::GetValueTypeAsCString (Scalar::Type type)
case e_float: return "float";
case e_double: return "double";
case e_long_double: return "long double";
+ case e_sint128: return "int128_t";
+ case e_uint128: return "uint128_t";
}
return "???";
}
@@ -567,145 +1066,198 @@ Scalar::Cast(Scalar::Type type)
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:
switch (type)
{
- case e_void: break;
- case e_sint: success = true; break;
- case e_uint: m_data.uint = m_data.sint; success = true; break;
- case e_slong: m_data.slong = m_data.sint; success = true; break;
- case e_ulong: m_data.ulong = m_data.sint; success = true; break;
- case e_slonglong: m_data.slonglong = m_data.sint; success = true; break;
- case e_ulonglong: m_data.ulonglong = m_data.sint; success = true; break;
- case e_float: m_data.flt = m_data.sint; success = true; break;
- case e_double: m_data.dbl = m_data.sint; success = true; break;
- case e_long_double: m_data.ldbl = m_data.sint; success = true; break;
+ case e_void: break;
+ case e_sint:
+ {
+ m_integer = m_integer.sextOrTrunc(sizeof(sint_t) * 8);
+ success = true;
+ break;
+ }
+ case e_uint:
+ {
+ m_integer = m_integer.zextOrTrunc(sizeof(sint_t) * 8);
+ success = true;
+ break;
+ }
+ case e_slong:
+ {
+ m_integer = m_integer.sextOrTrunc(sizeof(slong_t) * 8);
+ success = true;
+ break;
+ }
+ case e_ulong:
+ {
+ m_integer = m_integer.zextOrTrunc(sizeof(slong_t) * 8);
+ success = true;
+ break;
+ }
+ case e_slonglong:
+ {
+ m_integer = m_integer.sextOrTrunc(sizeof(slonglong_t) * 8);
+ success = true;
+ break;
+ }
+ case e_ulonglong:
+ {
+ m_integer = m_integer.zextOrTrunc(sizeof(slonglong_t) * 8);
+ success = true;
+ break;
+ }
+ case e_sint128:
+ {
+ m_integer = m_integer.sextOrTrunc(BITWIDTH_INT128);
+ success = true;
+ break;
+ }
+ case e_uint128:
+ {
+ m_integer = m_integer.zextOrTrunc(BITWIDTH_INT128);
+ success = true;
+ break;
+ }
+ case e_float:
+ {
+ m_float = llvm::APFloat(m_integer.bitsToFloat());
+ success = true;
+ break;
+ }
+ case e_double:
+ {
+ m_float = llvm::APFloat(m_integer.bitsToDouble());
+ success = true;
+ break;
+ }
+ case e_long_double:
+ {
+ if(m_ieee_quad)
+ m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_integer);
+ else
+ m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_integer);
+ success = true;
+ break;
+ }
}
break;
- case e_uint:
+ case e_float:
switch (type)
{
- case e_void:
- case e_sint: m_data.sint = m_data.uint; success = true; break;
- case e_uint: success = true; break;
- case e_slong: m_data.slong = m_data.uint; success = true; break;
- case e_ulong: m_data.ulong = m_data.uint; success = true; break;
- case e_slonglong: m_data.slonglong = m_data.uint; success = true; break;
- case e_ulonglong: m_data.ulonglong = m_data.uint; success = true; break;
- case e_float: m_data.flt = m_data.uint; success = true; break;
- case e_double: m_data.dbl = m_data.uint; success = true; break;
- case e_long_double: m_data.ldbl = m_data.uint; success = true; break;
+ 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: m_integer = m_float.bitcastToAPInt(); success = true; break;
+ case e_float: m_float = llvm::APFloat(m_float.convertToFloat()); success = true; break;
+ case e_double: m_float = llvm::APFloat(m_float.convertToFloat()); success = true; break;
+ case e_long_double:
+ if(m_ieee_quad)
+ m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_float.bitcastToAPInt());
+ else
+ m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_float.bitcastToAPInt());
+ success = true;
+ break;
}
break;
- case e_slong:
+ case e_double:
switch (type)
{
- case e_void:
- case e_sint: m_data.sint = (sint_t)m_data.slong; success = true; break;
- case e_uint: m_data.uint = (uint_t)m_data.slong; success = true; break;
- case e_slong: success = true; break;
- case e_ulong: m_data.ulong = m_data.slong; success = true; break;
- case e_slonglong: m_data.slonglong = m_data.slong; success = true; break;
- case e_ulonglong: m_data.ulonglong = m_data.slong; success = true; break;
- case e_float: m_data.flt = m_data.slong; success = true; break;
- case e_double: m_data.dbl = m_data.slong; success = true; break;
- case e_long_double: m_data.ldbl = m_data.slong; success = true; break;
+ 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: m_integer = m_float.bitcastToAPInt(); success = true; break;
+ case e_float: m_float = llvm::APFloat(m_float.convertToDouble()); success = true; break;
+ case e_double: m_float = llvm::APFloat(m_float.convertToDouble()); success = true; break;
+ case e_long_double:
+ if(m_ieee_quad)
+ m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_float.bitcastToAPInt());
+ else
+ m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_float.bitcastToAPInt());
+ success = true;
+ break;
}
break;
- case e_ulong:
+ case e_long_double:
switch (type)
{
- case e_void:
- case e_sint: m_data.sint = (sint_t)m_data.ulong; success = true; break;
- case e_uint: m_data.uint = (uint_t)m_data.ulong; success = true; break;
- case e_slong: m_data.slong = m_data.ulong; success = true; break;
- case e_ulong: success = true; break;
- case e_slonglong: m_data.slonglong = m_data.ulong; success = true; break;
- case e_ulonglong: m_data.ulonglong = m_data.ulong; success = true; break;
- case e_float: m_data.flt = m_data.ulong; success = true; break;
- case e_double: m_data.dbl = m_data.ulong; success = true; break;
- case e_long_double: m_data.ldbl = m_data.ulong; success = true; break;
+ case e_void: break;
+ case e_sint:
+ {
+ m_integer = m_float.bitcastToAPInt();
+ m_integer = m_integer.sextOrTrunc(sizeof(sint_t) * 8);
+ success = true;
+ break;
}
- break;
-
- case e_slonglong:
- switch (type)
+ case e_uint:
{
- case e_void:
- case e_sint: m_data.sint = (sint_t)m_data.slonglong; success = true; break;
- case e_uint: m_data.uint = (uint_t)m_data.slonglong; success = true; break;
- case e_slong: m_data.slong = m_data.slonglong; success = true; break;
- case e_ulong: m_data.ulong = m_data.slonglong; success = true; break;
- case e_slonglong: success = true; break;
- case e_ulonglong: m_data.ulonglong = m_data.slonglong; success = true; break;
- case e_float: m_data.flt = m_data.slonglong; success = true; break;
- case e_double: m_data.dbl = m_data.slonglong; success = true; break;
- case e_long_double: m_data.ldbl = m_data.slonglong; success = true; break;
+ m_integer = m_float.bitcastToAPInt();
+ m_integer = m_integer.zextOrTrunc(sizeof(sint_t) * 8);
+ success = true;
+ break;
}
- break;
-
- case e_ulonglong:
- switch (type)
+ case e_slong:
{
- case e_void:
- case e_sint: m_data.sint = (sint_t)m_data.ulonglong; success = true; break;
- case e_uint: m_data.uint = (uint_t)m_data.ulonglong; success = true; break;
- case e_slong: m_data.slong = m_data.ulonglong; success = true; break;
- case e_ulong: m_data.ulong = m_data.ulonglong; success = true; break;
- case e_slonglong: m_data.slonglong = m_data.ulonglong; success = true; break;
- case e_ulonglong: success = true; break;
- case e_float: m_data.flt = m_data.ulonglong; success = true; break;
- case e_double: m_data.dbl = m_data.ulonglong; success = true; break;
- case e_long_double: m_data.ldbl = m_data.ulonglong; success = true; break;
+ m_integer = m_float.bitcastToAPInt();
+ m_integer = m_integer.sextOrTrunc(sizeof(slong_t) * 8);
+ success = true;
+ break;
}
- break;
-
- case e_float:
- switch (type)
+ case e_ulong:
{
- case e_void:
- case e_sint: m_data.sint = (sint_t)m_data.flt; success = true; break;
- case e_uint: m_data.uint = (uint_t)m_data.flt; success = true; break;
- case e_slong: m_data.slong = (slong_t)m_data.flt; success = true; break;
- case e_ulong: m_data.ulong = (ulong_t)m_data.flt; success = true; break;
- case e_slonglong: m_data.slonglong = (slonglong_t)m_data.flt; success = true; break;
- case e_ulonglong: m_data.ulonglong = (ulonglong_t)m_data.flt; success = true; break;
- case e_float: success = true; break;
- case e_double: m_data.dbl = m_data.flt; success = true; break;
- case e_long_double: m_data.ldbl = m_data.flt; success = true; break;
+ m_integer = m_float.bitcastToAPInt();
+ m_integer = m_integer.zextOrTrunc(sizeof(slong_t) * 8);
+ success = true;
+ break;
}
- break;
-
- case e_double:
- switch (type)
+ case e_slonglong:
{
- case e_void:
- case e_sint: m_data.sint = (sint_t)m_data.dbl; success = true; break;
- case e_uint: m_data.uint = (uint_t)m_data.dbl; success = true; break;
- case e_slong: m_data.slong = (slong_t)m_data.dbl; success = true; break;
- case e_ulong: m_data.ulong = (ulong_t)m_data.dbl; success = true; break;
- case e_slonglong: m_data.slonglong = (slonglong_t)m_data.dbl; success = true; break;
- case e_ulonglong: m_data.ulonglong = (ulonglong_t)m_data.dbl; success = true; break;
- case e_float: m_data.flt = (float_t)m_data.dbl; success = true; break;
- case e_double: success = true; break;
- case e_long_double: m_data.ldbl = m_data.dbl; success = true; break;
+ m_integer = m_float.bitcastToAPInt();
+ m_integer = m_integer.sextOrTrunc(sizeof(slonglong_t) * 8);
+ success = true;
+ break;
}
- break;
-
- case e_long_double:
- switch (type)
+ case e_ulonglong:
{
- case e_void:
- case e_sint: m_data.sint = (sint_t)m_data.ldbl; success = true; break;
- case e_uint: m_data.uint = (uint_t)m_data.ldbl; success = true; break;
- case e_slong: m_data.slong = (slong_t)m_data.ldbl; success = true; break;
- case e_ulong: m_data.ulong = (ulong_t)m_data.ldbl; success = true; break;
- case e_slonglong: m_data.slonglong = (slonglong_t)m_data.ldbl; success = true; break;
- case e_ulonglong: m_data.ulonglong = (ulonglong_t)m_data.ldbl; success = true; break;
- case e_float: m_data.flt = (float_t)m_data.ldbl; success = true; break;
- case e_double: m_data.dbl = (double_t)m_data.ldbl; success = true; break;
+ m_integer = m_float.bitcastToAPInt();
+ m_integer = m_integer.zextOrTrunc(sizeof(slonglong_t) * 8);
+ success = true;
+ break;
+ }
+ case e_sint128:
+ {
+ m_integer = m_float.bitcastToAPInt();
+ m_integer = m_integer.sextOrTrunc(BITWIDTH_INT128);
+ success = true;
+ break;
+ }
+ case e_uint128:
+ {
+ m_integer = m_float.bitcastToAPInt();
+ m_integer = m_integer.zextOrTrunc(BITWIDTH_INT128);
+ success = true;
+ break;
+ }
+ case e_float: m_float = llvm::APFloat(m_float.convertToFloat()); success = true; break;
+ case e_double: m_float = llvm::APFloat(m_float.convertToFloat()); success = true; break;
case e_long_double: success = true; break;
}
break;
@@ -730,6 +1282,8 @@ Scalar::MakeSigned ()
case e_ulong: m_type = e_slong; success = true; break;
case e_slonglong: success = true; break;
case e_ulonglong: m_type = e_slonglong; success = true; break;
+ case e_sint128: success = true; break;
+ case e_uint128: m_type = e_sint; success = true; break;
case e_float: success = true; break;
case e_double: success = true; break;
case e_long_double: success = true; break;
@@ -738,21 +1292,132 @@ Scalar::MakeSigned ()
return success;
}
+char
+Scalar::SChar(char 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:
+ return *(const schar_t *)(m_integer.sextOrTrunc(sizeof(schar_t) * 8)).getRawData();
+ case e_float:
+ return (schar_t)m_float.convertToFloat();
+ case e_double:
+ return (schar_t)m_float.convertToDouble();
+ case e_long_double:
+ llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+ return (schar_t)*ldbl_val.getRawData();
+ }
+ return fail_value;
+}
+
+unsigned char
+Scalar::UChar(unsigned char 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:
+ return *(const uchar_t *)m_integer.getRawData();
+ case e_float:
+ return (uchar_t)m_float.convertToFloat();
+ case e_double:
+ return (uchar_t)m_float.convertToDouble();
+ case e_long_double:
+ llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+ return (uchar_t)*ldbl_val.getRawData();
+ }
+ return fail_value;
+}
+
+short
+Scalar::SShort(short 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:
+ return *(const sshort_t *)(m_integer.sextOrTrunc(sizeof(sshort_t) * 8)).getRawData();
+ case e_float:
+ return (sshort_t)m_float.convertToFloat();
+ case e_double:
+ return (sshort_t)m_float.convertToDouble();
+ case e_long_double:
+ llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+ return *(const sshort_t *)ldbl_val.getRawData();
+ }
+ return fail_value;
+}
+
+unsigned short
+Scalar::UShort(unsigned short 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:
+ return *(const ushort_t *)m_integer.getRawData();
+ case e_float:
+ return (ushort_t)m_float.convertToFloat();
+ case e_double:
+ return (ushort_t)m_float.convertToDouble();
+ case e_long_double:
+ llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+ return *(const ushort_t *)ldbl_val.getRawData();;
+ }
+ return fail_value;
+}
+
int
Scalar::SInt(int fail_value) const
{
switch (m_type)
{
case e_void: break;
- case e_sint: return m_data.sint;
- case e_uint: return (int)m_data.uint;
- case e_slong: return (int)m_data.slong;
- case e_ulong: return (int)m_data.ulong;
- case e_slonglong: return (int)m_data.slonglong;
- case e_ulonglong: return (int)m_data.ulonglong;
- case e_float: return (int)m_data.flt;
- case e_double: return (int)m_data.dbl;
- case e_long_double: return (int)m_data.ldbl;
+ case e_sint:
+ case e_uint:
+ case e_slong:
+ case e_ulong:
+ case e_slonglong:
+ case e_ulonglong:
+ case e_sint128:
+ case e_uint128:
+ return *(const sint_t *)(m_integer.sextOrTrunc(sizeof(sint_t) * 8)).getRawData();
+ case e_float:
+ return (sint_t)m_float.convertToFloat();
+ case e_double:
+ return (sint_t)m_float.convertToDouble();
+ case e_long_double:
+ llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+ return *(const sint_t *)ldbl_val.getRawData();
}
return fail_value;
}
@@ -763,15 +1428,22 @@ Scalar::UInt(unsigned int fail_value) const
switch (m_type)
{
case e_void: break;
- case e_sint: return (unsigned int)m_data.sint;
- case e_uint: return (unsigned int)m_data.uint;
- case e_slong: return (unsigned int)m_data.slong;
- case e_ulong: return (unsigned int)m_data.ulong;
- case e_slonglong: return (unsigned int)m_data.slonglong;
- case e_ulonglong: return (unsigned int)m_data.ulonglong;
- case e_float: return (unsigned int)m_data.flt;
- case e_double: return (unsigned int)m_data.dbl;
- case e_long_double: return (unsigned int)m_data.ldbl;
+ case e_sint:
+ case e_uint:
+ case e_slong:
+ case e_ulong:
+ case e_slonglong:
+ case e_ulonglong:
+ case e_sint128:
+ case e_uint128:
+ return *(const uint_t *)m_integer.getRawData();
+ case e_float:
+ return (uint_t)m_float.convertToFloat();
+ case e_double:
+ return (uint_t)m_float.convertToDouble();
+ case e_long_double:
+ llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+ return *(const uint_t *)ldbl_val.getRawData();
}
return fail_value;
}
@@ -783,15 +1455,22 @@ Scalar::SLong(long fail_value) const
switch (m_type)
{
case e_void: break;
- case e_sint: return (long)m_data.sint;
- case e_uint: return (long)m_data.uint;
- case e_slong: return (long)m_data.slong;
- case e_ulong: return (long)m_data.ulong;
- case e_slonglong: return (long)m_data.slonglong;
- case e_ulonglong: return (long)m_data.ulonglong;
- case e_float: return (long)m_data.flt;
- case e_double: return (long)m_data.dbl;
- case e_long_double: return (long)m_data.ldbl;
+ case e_sint:
+ case e_uint:
+ case e_slong:
+ case e_ulong:
+ case e_slonglong:
+ case e_ulonglong:
+ case e_sint128:
+ case e_uint128:
+ return *(const slong_t *)(m_integer.sextOrTrunc(sizeof(slong_t) * 8)).getRawData();
+ case e_float:
+ return (slong_t)m_float.convertToFloat();
+ case e_double:
+ return (slong_t)m_float.convertToDouble();
+ case e_long_double:
+ llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+ return *(const slong_t *)ldbl_val.getRawData();
}
return fail_value;
}
@@ -804,15 +1483,22 @@ Scalar::ULong(unsigned long fail_value) const
switch (m_type)
{
case e_void: break;
- case e_sint: return (unsigned long)m_data.sint;
- case e_uint: return (unsigned long)m_data.uint;
- case e_slong: return (unsigned long)m_data.slong;
- case e_ulong: return (unsigned long)m_data.ulong;
- case e_slonglong: return (unsigned long)m_data.slonglong;
- case e_ulonglong: return (unsigned long)m_data.ulonglong;
- case e_float: return (unsigned long)m_data.flt;
- case e_double: return (unsigned long)m_data.dbl;
- case e_long_double: return (unsigned long)m_data.ldbl;
+ case e_sint:
+ case e_uint:
+ case e_slong:
+ case e_ulong:
+ case e_slonglong:
+ case e_ulonglong:
+ case e_sint128:
+ case e_uint128:
+ return *(const ulong_t *)m_integer.getRawData();
+ case e_float:
+ return (ulong_t)m_float.convertToFloat();
+ case e_double:
+ return (ulong_t)m_float.convertToDouble();
+ case e_long_double:
+ llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+ return *(const ulong_t *)ldbl_val.getRawData();
}
return fail_value;
}
@@ -827,42 +1513,20 @@ Scalar::GetRawBits64(uint64_t fail_value) const
case e_sint:
case e_uint:
- return m_data.uint;
-
case e_slong:
case e_ulong:
- return m_data.ulong;
-
case e_slonglong:
case e_ulonglong:
- return m_data.ulonglong;
-
+ case e_sint128:
+ case e_uint128:
+ return *m_integer.getRawData();
case e_float:
- if (sizeof(m_data.flt) == sizeof(m_data.uint))
- return m_data.uint;
- else if (sizeof(m_data.flt) == sizeof(m_data.ulong))
- return m_data.ulong;
- else if (sizeof(m_data.flt) == sizeof(m_data.ulonglong))
- return m_data.ulonglong;
- break;
-
+ return (uint64_t)m_float.convertToFloat();
case e_double:
- if (sizeof(m_data.dbl) == sizeof(m_data.uint))
- return m_data.uint;
- else if (sizeof(m_data.dbl) == sizeof(m_data.ulong))
- return m_data.ulong;
- else if (sizeof(m_data.dbl) == sizeof(m_data.ulonglong))
- return m_data.ulonglong;
- break;
-
+ return (uint64_t)m_float.convertToDouble();
case e_long_double:
- if (sizeof(m_data.ldbl) == sizeof(m_data.uint))
- return m_data.uint;
- else if (sizeof(m_data.ldbl) == sizeof(m_data.ulong))
- return m_data.ulong;
- else if (sizeof(m_data.ldbl) == sizeof(m_data.ulonglong))
- return m_data.ulonglong;
- break;
+ llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+ return *ldbl_val.getRawData();
}
return fail_value;
}
@@ -875,15 +1539,22 @@ Scalar::SLongLong(long long fail_value) const
switch (m_type)
{
case e_void: break;
- case e_sint: return (long long)m_data.sint;
- case e_uint: return (long long)m_data.uint;
- case e_slong: return (long long)m_data.slong;
- case e_ulong: return (long long)m_data.ulong;
- case e_slonglong: return (long long)m_data.slonglong;
- case e_ulonglong: return (long long)m_data.ulonglong;
- case e_float: return (long long)m_data.flt;
- case e_double: return (long long)m_data.dbl;
- case e_long_double: return (long long)m_data.ldbl;
+ case e_sint:
+ case e_uint:
+ case e_slong:
+ case e_ulong:
+ case e_slonglong:
+ case e_ulonglong:
+ case e_sint128:
+ case e_uint128:
+ return *(const slonglong_t *)(m_integer.sextOrTrunc(sizeof(slonglong_t) * 8)).getRawData();
+ case e_float:
+ return (slonglong_t)m_float.convertToFloat();
+ case e_double:
+ return (slonglong_t)m_float.convertToDouble();
+ case e_long_double:
+ llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+ return *(const slonglong_t *)ldbl_val.getRawData();
}
return fail_value;
}
@@ -895,19 +1566,71 @@ Scalar::ULongLong(unsigned long long fail_value) const
switch (m_type)
{
case e_void: break;
- case e_sint: return (unsigned long long)m_data.sint;
- case e_uint: return (unsigned long long)m_data.uint;
- case e_slong: return (unsigned long long)m_data.slong;
- case e_ulong: return (unsigned long long)m_data.ulong;
- case e_slonglong: return (unsigned long long)m_data.slonglong;
- case e_ulonglong: return (unsigned long long)m_data.ulonglong;
- case e_float: return (unsigned long long)m_data.flt;
- case e_double: return (unsigned long long)m_data.dbl;
- case e_long_double: return (unsigned long long)m_data.ldbl;
+ case e_sint:
+ case e_uint:
+ case e_slong:
+ case e_ulong:
+ case e_slonglong:
+ case e_ulonglong:
+ case e_sint128:
+ case e_uint128:
+ return *(const ulonglong_t *)m_integer.getRawData();
+ case e_float:
+ return (ulonglong_t)m_float.convertToFloat();
+ case e_double:
+ return (ulonglong_t)m_float.convertToDouble();
+ case e_long_double:
+ llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+ return *(const ulonglong_t *)ldbl_val.getRawData();
}
return fail_value;
}
+llvm::APInt
+Scalar::UInt128(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:
+ return m_integer;
+ case e_float:
+ case e_double:
+ case e_long_double:
+ return m_float.bitcastToAPInt();
+ }
+ return fail_value;
+}
+
+llvm::APInt
+Scalar::SInt128(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:
+ return m_integer;
+ case e_float:
+ case e_double:
+ case e_long_double:
+ return m_float.bitcastToAPInt();
+ }
+ return fail_value;
+}
float
Scalar::Float(float fail_value) const
@@ -915,15 +1638,22 @@ Scalar::Float(float fail_value) const
switch (m_type)
{
case e_void: break;
- case e_sint: return (float)m_data.sint;
- case e_uint: return (float)m_data.uint;
- case e_slong: return (float)m_data.slong;
- case e_ulong: return (float)m_data.ulong;
- case e_slonglong: return (float)m_data.slonglong;
- case e_ulonglong: return (float)m_data.ulonglong;
- case e_float: return (float)m_data.flt;
- case e_double: return (float)m_data.dbl;
- case e_long_double: return (float)m_data.ldbl;
+ case e_sint:
+ case e_uint:
+ case e_slong:
+ case e_ulong:
+ case e_slonglong:
+ case e_ulonglong:
+ case e_sint128:
+ case e_uint128:
+ return m_integer.bitsToFloat();
+ case e_float:
+ return m_float.convertToFloat();
+ case e_double:
+ return (float_t)m_float.convertToDouble();
+ case e_long_double:
+ llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+ return ldbl_val.bitsToFloat();
}
return fail_value;
}
@@ -935,15 +1665,22 @@ Scalar::Double(double fail_value) const
switch (m_type)
{
case e_void: break;
- case e_sint: return (double)m_data.sint;
- case e_uint: return (double)m_data.uint;
- case e_slong: return (double)m_data.slong;
- case e_ulong: return (double)m_data.ulong;
- case e_slonglong: return (double)m_data.slonglong;
- case e_ulonglong: return (double)m_data.ulonglong;
- case e_float: return (double)m_data.flt;
- case e_double: return (double)m_data.dbl;
- case e_long_double: return (double)m_data.ldbl;
+ case e_sint:
+ case e_uint:
+ case e_slong:
+ case e_ulong:
+ case e_slonglong:
+ case e_ulonglong:
+ case e_sint128:
+ case e_uint128:
+ return m_integer.bitsToDouble();
+ case e_float:
+ return (double_t)m_float.convertToFloat();
+ case e_double:
+ return m_float.convertToDouble();
+ case e_long_double:
+ llvm::APInt ldbl_val = m_float.bitcastToAPInt();
+ return ldbl_val.bitsToFloat();
}
return fail_value;
}
@@ -955,15 +1692,22 @@ Scalar::LongDouble(long double fail_value) const
switch (m_type)
{
case e_void: break;
- case e_sint: return (long double)m_data.sint;
- case e_uint: return (long double)m_data.uint;
- case e_slong: return (long double)m_data.slong;
- case e_ulong: return (long double)m_data.ulong;
- case e_slonglong: return (long double)m_data.slonglong;
- case e_ulonglong: return (long double)m_data.ulonglong;
- case e_float: return (long double)m_data.flt;
- case e_double: return (long double)m_data.dbl;
- case e_long_double: return (long double)m_data.ldbl;
+ case e_sint:
+ case e_uint:
+ case e_slong:
+ case e_ulong:
+ case e_slonglong:
+ case e_ulonglong:
+ case e_sint128:
+ case e_uint128:
+ return (long_double_t)m_integer.bitsToDouble();
+ case e_float:
+ return (long_double_t)m_float.convertToFloat();
+ case e_double:
+ return (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 fail_value;
}
@@ -978,17 +1722,27 @@ Scalar::operator+= (const Scalar& rhs)
if ((m_type = PromoteToMaxType(*this, rhs, temp_value, a, b)) != Scalar::e_void)
{
switch (m_type)
- {
- case e_void: break;
- case e_sint: m_data.sint = a->m_data.sint + b->m_data.sint; break;
- case e_uint: m_data.uint = a->m_data.uint + b->m_data.uint; break;
- case e_slong: m_data.slong = a->m_data.slong + b->m_data.slong; break;
- case e_ulong: m_data.ulong = a->m_data.ulong + b->m_data.ulong; break;
- case e_slonglong: m_data.slonglong = a->m_data.slonglong + b->m_data.slonglong; break;
- case e_ulonglong: m_data.ulonglong = a->m_data.ulonglong + b->m_data.ulonglong; break;
- case e_float: m_data.flt = a->m_data.flt + b->m_data.flt; break;
- case e_double: m_data.dbl = a->m_data.dbl + b->m_data.dbl; break;
- case e_long_double: m_data.ldbl = a->m_data.ldbl + b->m_data.ldbl; break;
+ {
+ 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:
+ {
+ m_integer = a->m_integer + b->m_integer;
+ break;
+ }
+ case e_float:
+ case e_double:
+ case e_long_double:
+ {
+ m_float = a->m_float + b->m_float;
+ break;
+ }
}
}
return *this;
@@ -1007,109 +1761,33 @@ Scalar::operator<<= (const Scalar& rhs)
break;
case e_sint:
- switch (rhs.m_type)
- {
- case e_void:
- case e_float:
- case e_double:
- case e_long_double:
- m_type = e_void;
- break;
- case e_sint: m_data.sint <<= rhs.m_data.sint; break;
- case e_uint: m_data.sint <<= rhs.m_data.uint; break;
- case e_slong: m_data.sint <<= rhs.m_data.slong; break;
- case e_ulong: m_data.sint <<= rhs.m_data.ulong; break;
- case e_slonglong: m_data.sint <<= rhs.m_data.slonglong; break;
- case e_ulonglong: m_data.sint <<= rhs.m_data.ulonglong; break;
- }
- break;
-
case e_uint:
- switch (rhs.m_type)
- {
- case e_void:
- case e_float:
- case e_double:
- case e_long_double:
- m_type = e_void;
- break;
- case e_sint: m_data.uint <<= rhs.m_data.sint; break;
- case e_uint: m_data.uint <<= rhs.m_data.uint; break;
- case e_slong: m_data.uint <<= rhs.m_data.slong; break;
- case e_ulong: m_data.uint <<= rhs.m_data.ulong; break;
- case e_slonglong: m_data.uint <<= rhs.m_data.slonglong; break;
- case e_ulonglong: m_data.uint <<= rhs.m_data.ulonglong; break;
- }
- break;
-
case e_slong:
- switch (rhs.m_type)
- {
- case e_void:
- case e_float:
- case e_double:
- case e_long_double:
- m_type = e_void;
- break;
- case e_sint: m_data.slong <<= rhs.m_data.sint; break;
- case e_uint: m_data.slong <<= rhs.m_data.uint; break;
- case e_slong: m_data.slong <<= rhs.m_data.slong; break;
- case e_ulong: m_data.slong <<= rhs.m_data.ulong; break;
- case e_slonglong: m_data.slong <<= rhs.m_data.slonglong; break;
- case e_ulonglong: m_data.slong <<= rhs.m_data.ulonglong; break;
- }
- break;
-
case e_ulong:
- switch (rhs.m_type)
- {
- case e_void:
- case e_float:
- case e_double:
- case e_long_double:
- m_type = e_void;
- break;
- case e_sint: m_data.ulong <<= rhs.m_data.sint; break;
- case e_uint: m_data.ulong <<= rhs.m_data.uint; break;
- case e_slong: m_data.ulong <<= rhs.m_data.slong; break;
- case e_ulong: m_data.ulong <<= rhs.m_data.ulong; break;
- case e_slonglong: m_data.ulong <<= rhs.m_data.slonglong; break;
- case e_ulonglong: m_data.ulong <<= rhs.m_data.ulonglong; break;
- }
- break;
case e_slonglong:
- switch (rhs.m_type)
- {
- case e_void:
- case e_float:
- case e_double:
- case e_long_double:
- m_type = e_void;
- break;
- case e_sint: m_data.slonglong <<= rhs.m_data.sint; break;
- case e_uint: m_data.slonglong <<= rhs.m_data.uint; break;
- case e_slong: m_data.slonglong <<= rhs.m_data.slong; break;
- case e_ulong: m_data.slonglong <<= rhs.m_data.ulong; break;
- case e_slonglong: m_data.slonglong <<= rhs.m_data.slonglong; break;
- case e_ulonglong: m_data.slonglong <<= rhs.m_data.ulonglong; break;
- }
- break;
-
case e_ulonglong:
+ case e_sint128:
+ case e_uint128:
switch (rhs.m_type)
{
- case e_void:
- case e_float:
- case e_double:
- case e_long_double:
- m_type = e_void;
- break;
- case e_sint: m_data.ulonglong <<= rhs.m_data.sint; break;
- case e_uint: m_data.ulonglong <<= rhs.m_data.uint; break;
- case e_slong: m_data.ulonglong <<= rhs.m_data.slong; break;
- case e_ulong: m_data.ulonglong <<= rhs.m_data.ulong; break;
- case e_slonglong: m_data.ulonglong <<= rhs.m_data.slonglong; break;
- case e_ulonglong: m_data.ulonglong <<= rhs.m_data.ulonglong; break;
+ case e_void:
+ case e_float:
+ case e_double:
+ case e_long_double:
+ m_type = 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:
+ {
+ m_integer <<= *rhs.m_integer.getRawData();
+ break;
+ }
}
break;
}
@@ -1130,44 +1808,12 @@ Scalar::ShiftRightLogical(const Scalar& rhs)
case e_sint:
case e_uint:
- switch (rhs.m_type)
- {
- case e_void:
- case e_float:
- case e_double:
- case e_long_double:
- m_type = e_void;
- break;
- case e_sint: m_data.uint >>= rhs.m_data.sint; break;
- case e_uint: m_data.uint >>= rhs.m_data.uint; break;
- case e_slong: m_data.uint >>= rhs.m_data.slong; break;
- case e_ulong: m_data.uint >>= rhs.m_data.ulong; break;
- case e_slonglong: m_data.uint >>= rhs.m_data.slonglong; break;
- case e_ulonglong: m_data.uint >>= rhs.m_data.ulonglong; break;
- }
- break;
-
case e_slong:
case e_ulong:
- switch (rhs.m_type)
- {
- case e_void:
- case e_float:
- case e_double:
- case e_long_double:
- m_type = e_void;
- break;
- case e_sint: m_data.ulong >>= rhs.m_data.sint; break;
- case e_uint: m_data.ulong >>= rhs.m_data.uint; break;
- case e_slong: m_data.ulong >>= rhs.m_data.slong; break;
- case e_ulong: m_data.ulong >>= rhs.m_data.ulong; break;
- case e_slonglong: m_data.ulong >>= rhs.m_data.slonglong; break;
- case e_ulonglong: m_data.ulong >>= rhs.m_data.ulonglong; break;
- }
- break;
-
case e_slonglong:
case e_ulonglong:
+ case e_sint128:
+ case e_uint128:
switch (rhs.m_type)
{
case e_void:
@@ -1176,12 +1822,15 @@ Scalar::ShiftRightLogical(const Scalar& rhs)
case e_long_double:
m_type = e_void;
break;
- case e_sint: m_data.ulonglong >>= rhs.m_data.sint; break;
- case e_uint: m_data.ulonglong >>= rhs.m_data.uint; break;
- case e_slong: m_data.ulonglong >>= rhs.m_data.slong; break;
- case e_ulong: m_data.ulonglong >>= rhs.m_data.ulong; break;
- case e_slonglong: m_data.ulonglong >>= rhs.m_data.slonglong; break;
- case e_ulonglong: m_data.ulonglong >>= rhs.m_data.ulonglong; 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:
+ m_integer = m_integer.lshr(*(const uint_t *) rhs.m_integer.getRawData()); break;
}
break;
}
@@ -1202,95 +1851,13 @@ Scalar::operator>>= (const Scalar& rhs)
break;
case e_sint:
- switch (rhs.m_type)
- {
- case e_void:
- case e_float:
- case e_double:
- case e_long_double:
- m_type = e_void;
- break;
- case e_sint: m_data.sint >>= rhs.m_data.sint; break;
- case e_uint: m_data.sint >>= rhs.m_data.uint; break;
- case e_slong: m_data.sint >>= rhs.m_data.slong; break;
- case e_ulong: m_data.sint >>= rhs.m_data.ulong; break;
- case e_slonglong: m_data.sint >>= rhs.m_data.slonglong; break;
- case e_ulonglong: m_data.sint >>= rhs.m_data.ulonglong; break;
- }
- break;
-
case e_uint:
- switch (rhs.m_type)
- {
- case e_void:
- case e_float:
- case e_double:
- case e_long_double:
- m_type = e_void;
- break;
- case e_sint: m_data.uint >>= rhs.m_data.sint; break;
- case e_uint: m_data.uint >>= rhs.m_data.uint; break;
- case e_slong: m_data.uint >>= rhs.m_data.slong; break;
- case e_ulong: m_data.uint >>= rhs.m_data.ulong; break;
- case e_slonglong: m_data.uint >>= rhs.m_data.slonglong; break;
- case e_ulonglong: m_data.uint >>= rhs.m_data.ulonglong; break;
- }
- break;
-
case e_slong:
- switch (rhs.m_type)
- {
- case e_void:
- case e_float:
- case e_double:
- case e_long_double:
- m_type = e_void;
- break;
- case e_sint: m_data.slong >>= rhs.m_data.sint; break;
- case e_uint: m_data.slong >>= rhs.m_data.uint; break;
- case e_slong: m_data.slong >>= rhs.m_data.slong; break;
- case e_ulong: m_data.slong >>= rhs.m_data.ulong; break;
- case e_slonglong: m_data.slong >>= rhs.m_data.slonglong; break;
- case e_ulonglong: m_data.slong >>= rhs.m_data.ulonglong; break;
- }
- break;
-
case e_ulong:
- switch (rhs.m_type)
- {
- case e_void:
- case e_float:
- case e_double:
- case e_long_double:
- m_type = e_void;
- break;
- case e_sint: m_data.ulong >>= rhs.m_data.sint; break;
- case e_uint: m_data.ulong >>= rhs.m_data.uint; break;
- case e_slong: m_data.ulong >>= rhs.m_data.slong; break;
- case e_ulong: m_data.ulong >>= rhs.m_data.ulong; break;
- case e_slonglong: m_data.ulong >>= rhs.m_data.slonglong; break;
- case e_ulonglong: m_data.ulong >>= rhs.m_data.ulonglong; break;
- }
- break;
case e_slonglong:
- switch (rhs.m_type)
- {
- case e_void:
- case e_float:
- case e_double:
- case e_long_double:
- m_type = e_void;
- break;
- case e_sint: m_data.slonglong >>= rhs.m_data.sint; break;
- case e_uint: m_data.slonglong >>= rhs.m_data.uint; break;
- case e_slong: m_data.slonglong >>= rhs.m_data.slong; break;
- case e_ulong: m_data.slonglong >>= rhs.m_data.ulong; break;
- case e_slonglong: m_data.slonglong >>= rhs.m_data.slonglong; break;
- case e_ulonglong: m_data.slonglong >>= rhs.m_data.ulonglong; break;
- }
- break;
-
case e_ulonglong:
+ case e_sint128:
+ case e_uint128:
switch (rhs.m_type)
{
case e_void:
@@ -1299,12 +1866,18 @@ Scalar::operator>>= (const Scalar& rhs)
case e_long_double:
m_type = e_void;
break;
- case e_sint: m_data.ulonglong >>= rhs.m_data.sint; break;
- case e_uint: m_data.ulonglong >>= rhs.m_data.uint; break;
- case e_slong: m_data.ulonglong >>= rhs.m_data.slong; break;
- case e_ulong: m_data.ulonglong >>= rhs.m_data.ulong; break;
- case e_slonglong: m_data.ulonglong >>= rhs.m_data.slonglong; break;
- case e_ulonglong: m_data.ulonglong >>= rhs.m_data.ulonglong; 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:
+ {
+ m_integer >> *rhs.m_integer.getRawData();
+ break;
+ }
}
break;
}
@@ -1325,95 +1898,13 @@ Scalar::operator&= (const Scalar& rhs)
break;
case e_sint:
- switch (rhs.m_type)
- {
- case e_void:
- case e_float:
- case e_double:
- case e_long_double:
- m_type = e_void;
- break;
- case e_sint: m_data.sint &= rhs.m_data.sint; break;
- case e_uint: m_data.sint &= rhs.m_data.uint; break;
- case e_slong: m_data.sint &= rhs.m_data.slong; break;
- case e_ulong: m_data.sint &= rhs.m_data.ulong; break;
- case e_slonglong: m_data.sint &= rhs.m_data.slonglong; break;
- case e_ulonglong: m_data.sint &= rhs.m_data.ulonglong; break;
- }
- break;
-
case e_uint:
- switch (rhs.m_type)
- {
- case e_void:
- case e_float:
- case e_double:
- case e_long_double:
- m_type = e_void;
- break;
- case e_sint: m_data.uint &= rhs.m_data.sint; break;
- case e_uint: m_data.uint &= rhs.m_data.uint; break;
- case e_slong: m_data.uint &= rhs.m_data.slong; break;
- case e_ulong: m_data.uint &= rhs.m_data.ulong; break;
- case e_slonglong: m_data.uint &= rhs.m_data.slonglong; break;
- case e_ulonglong: m_data.uint &= rhs.m_data.ulonglong; break;
- }
- break;
-
case e_slong:
- switch (rhs.m_type)
- {
- case e_void:
- case e_float:
- case e_double:
- case e_long_double:
- m_type = e_void;
- break;
- case e_sint: m_data.slong &= rhs.m_data.sint; break;
- case e_uint: m_data.slong &= rhs.m_data.uint; break;
- case e_slong: m_data.slong &= rhs.m_data.slong; break;
- case e_ulong: m_data.slong &= rhs.m_data.ulong; break;
- case e_slonglong: m_data.slong &= rhs.m_data.slonglong; break;
- case e_ulonglong: m_data.slong &= rhs.m_data.ulonglong; break;
- }
- break;
-
case e_ulong:
- switch (rhs.m_type)
- {
- case e_void:
- case e_float:
- case e_double:
- case e_long_double:
- m_type = e_void;
- break;
- case e_sint: m_data.ulong &= rhs.m_data.sint; break;
- case e_uint: m_data.ulong &= rhs.m_data.uint; break;
- case e_slong: m_data.ulong &= rhs.m_data.slong; break;
- case e_ulong: m_data.ulong &= rhs.m_data.ulong; break;
- case e_slonglong: m_data.ulong &= rhs.m_data.slonglong; break;
- case e_ulonglong: m_data.ulong &= rhs.m_data.ulonglong; break;
- }
- break;
case e_slonglong:
- switch (rhs.m_type)
- {
- case e_void:
- case e_float:
- case e_double:
- case e_long_double:
- m_type = e_void;
- break;
- case e_sint: m_data.slonglong &= rhs.m_data.sint; break;
- case e_uint: m_data.slonglong &= rhs.m_data.uint; break;
- case e_slong: m_data.slonglong &= rhs.m_data.slong; break;
- case e_ulong: m_data.slonglong &= rhs.m_data.ulong; break;
- case e_slonglong: m_data.slonglong &= rhs.m_data.slonglong; break;
- case e_ulonglong: m_data.slonglong &= rhs.m_data.ulonglong; break;
- }
- break;
-
case e_ulonglong:
+ case e_sint128:
+ case e_uint128:
switch (rhs.m_type)
{
case e_void:
@@ -1422,12 +1913,18 @@ Scalar::operator&= (const Scalar& rhs)
case e_long_double:
m_type = e_void;
break;
- case e_sint: m_data.ulonglong &= rhs.m_data.sint; break;
- case e_uint: m_data.ulonglong &= rhs.m_data.uint; break;
- case e_slong: m_data.ulonglong &= rhs.m_data.slong; break;
- case e_ulong: m_data.ulonglong &= rhs.m_data.ulong; break;
- case e_slonglong: m_data.ulonglong &= rhs.m_data.slonglong; break;
- case e_ulonglong: m_data.ulonglong &= rhs.m_data.ulonglong; 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:
+ {
+ m_integer &= rhs.m_integer;
+ break;
+ }
}
break;
}
@@ -1445,26 +1942,22 @@ Scalar::AbsoluteValue()
break;
case e_sint:
- if (m_data.sint < 0)
- m_data.sint = -m_data.sint;
- return true;
-
case e_slong:
- if (m_data.slong < 0)
- m_data.slong = -m_data.slong;
- return true;
-
case e_slonglong:
- if (m_data.slonglong < 0)
- m_data.slonglong = -m_data.slonglong;
+ case e_sint128:
+ if (m_integer.isNegative())
+ m_integer = -m_integer;
return true;
case e_uint:
case e_ulong:
case e_ulonglong: return true;
- case e_float: m_data.flt = fabsf(m_data.flt); return true;
- case e_double: m_data.dbl = fabs(m_data.dbl); return true;
- case e_long_double: m_data.ldbl = fabsl(m_data.ldbl); return true;
+ case e_uint128:
+ case e_float:
+ case e_double:
+ case e_long_double:
+ m_float.clearSign();
+ return true;
}
return false;
}
@@ -1476,15 +1969,19 @@ Scalar::UnaryNegate()
switch (m_type)
{
case e_void: break;
- case e_sint: m_data.sint = -m_data.sint; return true;
- case e_uint: m_data.uint = -m_data.uint; return true;
- case e_slong: m_data.slong = -m_data.slong; return true;
- case e_ulong: m_data.ulong = -m_data.ulong; return true;
- case e_slonglong: m_data.slonglong = -m_data.slonglong; return true;
- case e_ulonglong: m_data.ulonglong = -m_data.ulonglong; return true;
- case e_float: m_data.flt = -m_data.flt; return true;
- case e_double: m_data.dbl = -m_data.dbl; return true;
- case e_long_double: m_data.ldbl = -m_data.ldbl; return true;
+ case e_sint:
+ case e_uint:
+ case e_slong:
+ case e_ulong:
+ case e_slonglong:
+ case e_ulonglong:
+ case e_sint128:
+ case e_uint128:
+ m_integer = -m_integer; return true;
+ case e_float:
+ case e_double:
+ case e_long_double:
+ m_float.changeSign(); return true;
}
return false;
}
@@ -1494,12 +1991,15 @@ Scalar::OnesComplement()
{
switch (m_type)
{
- case e_sint: m_data.sint = ~m_data.sint; return true;
- case e_uint: m_data.uint = ~m_data.uint; return true;
- case e_slong: m_data.slong = ~m_data.slong; return true;
- case e_ulong: m_data.ulong = ~m_data.ulong; return true;
- case e_slonglong: m_data.slonglong = ~m_data.slonglong; return true;
- case e_ulonglong: m_data.ulonglong = ~m_data.ulonglong; return true;
+ case e_sint:
+ case e_uint:
+ case e_slong:
+ case e_ulong:
+ case e_slonglong:
+ case e_ulonglong:
+ case e_sint128:
+ case e_uint128:
+ m_integer = ~m_integer; return true;
case e_void:
case e_float:
@@ -1523,15 +2023,19 @@ lldb_private::operator+ (const Scalar& lhs, const Scalar& rhs)
switch (result.m_type)
{
case Scalar::e_void: break;
- case Scalar::e_sint: result.m_data.sint = a->m_data.sint + b->m_data.sint; break;
- case Scalar::e_uint: result.m_data.uint = a->m_data.uint + b->m_data.uint; break;
- case Scalar::e_slong: result.m_data.slong = a->m_data.slong + b->m_data.slong; break;
- case Scalar::e_ulong: result.m_data.ulong = a->m_data.ulong + b->m_data.ulong; break;
- case Scalar::e_slonglong: result.m_data.slonglong = a->m_data.slonglong + b->m_data.slonglong; break;
- case Scalar::e_ulonglong: result.m_data.ulonglong = a->m_data.ulonglong + b->m_data.ulonglong; break;
- case Scalar::e_float: result.m_data.flt = a->m_data.flt + b->m_data.flt; break;
- case Scalar::e_double: result.m_data.dbl = a->m_data.dbl + b->m_data.dbl; break;
- case Scalar::e_long_double: result.m_data.ldbl = a->m_data.ldbl + b->m_data.ldbl; break;
+ case Scalar::e_sint:
+ case Scalar::e_uint:
+ case Scalar::e_slong:
+ case Scalar::e_ulong:
+ case Scalar::e_slonglong:
+ case Scalar::e_ulonglong:
+ case Scalar::e_sint128:
+ case Scalar::e_uint128:
+ result.m_integer = a->m_integer + b->m_integer; break;
+ case Scalar::e_float:
+ case Scalar::e_double:
+ case Scalar::e_long_double:
+ result.m_float = a->m_float + b->m_float; break;
}
}
return result;
@@ -1550,15 +2054,19 @@ lldb_private::operator- (const Scalar& lhs, const Scalar& rhs)
switch (result.m_type)
{
case Scalar::e_void: break;
- case Scalar::e_sint: result.m_data.sint = a->m_data.sint - b->m_data.sint; break;
- case Scalar::e_uint: result.m_data.uint = a->m_data.uint - b->m_data.uint; break;
- case Scalar::e_slong: result.m_data.slong = a->m_data.slong - b->m_data.slong; break;
- case Scalar::e_ulong: result.m_data.ulong = a->m_data.ulong - b->m_data.ulong; break;
- case Scalar::e_slonglong: result.m_data.slonglong = a->m_data.slonglong - b->m_data.slonglong; break;
- case Scalar::e_ulonglong: result.m_data.ulonglong = a->m_data.ulonglong - b->m_data.ulonglong; break;
- case Scalar::e_float: result.m_data.flt = a->m_data.flt - b->m_data.flt; break;
- case Scalar::e_double: result.m_data.dbl = a->m_data.dbl - b->m_data.dbl; break;
- case Scalar::e_long_double: result.m_data.ldbl = a->m_data.ldbl - b->m_data.ldbl; break;
+ case Scalar::e_sint:
+ case Scalar::e_uint:
+ case Scalar::e_slong:
+ case Scalar::e_ulong:
+ case Scalar::e_slonglong:
+ case Scalar::e_ulonglong:
+ case Scalar::e_sint128:
+ case Scalar::e_uint128:
+ result.m_integer = a->m_integer - b->m_integer; break;
+ case Scalar::e_float:
+ case Scalar::e_double:
+ case Scalar::e_long_double:
+ result.m_float = a->m_float - b->m_float; break;
}
}
return result;
@@ -1576,16 +2084,31 @@ lldb_private::operator/ (const Scalar& lhs, const Scalar& rhs)
switch (result.m_type)
{
case Scalar::e_void: break;
-
- case Scalar::e_sint: if (b->m_data.sint != 0) { result.m_data.sint = a->m_data.sint/ b->m_data.sint; return result; } break;
- case Scalar::e_uint: if (b->m_data.uint != 0) { result.m_data.uint = a->m_data.uint / b->m_data.uint; return result; } break;
- case Scalar::e_slong: if (b->m_data.slong != 0) { result.m_data.slong = a->m_data.slong / b->m_data.slong; return result; } break;
- case Scalar::e_ulong: if (b->m_data.ulong != 0) { result.m_data.ulong = a->m_data.ulong / b->m_data.ulong; return result; } break;
- case Scalar::e_slonglong: if (b->m_data.slonglong != 0) { result.m_data.slonglong = a->m_data.slonglong / b->m_data.slonglong; return result; } break;
- case Scalar::e_ulonglong: if (b->m_data.ulonglong != 0) { result.m_data.ulonglong = a->m_data.ulonglong / b->m_data.ulonglong; return result; } break;
- case Scalar::e_float: if (b->m_data.flt != 0.0f) { result.m_data.flt = a->m_data.flt / b->m_data.flt; return result; } break;
- case Scalar::e_double: if (b->m_data.dbl != 0.0) { result.m_data.dbl = a->m_data.dbl / b->m_data.dbl; return result; } break;
- case Scalar::e_long_double: if (b->m_data.ldbl != 0.0) { result.m_data.ldbl = a->m_data.ldbl / b->m_data.ldbl; return result; } break;
+ case Scalar::e_sint:
+ case Scalar::e_uint:
+ case Scalar::e_slong:
+ case Scalar::e_ulong:
+ case Scalar::e_slonglong:
+ case Scalar::e_ulonglong:
+ case Scalar::e_sint128:
+ case Scalar::e_uint128:
+ {
+ if (b->m_integer != 0)
+ {
+ result.m_integer = *a->m_integer.getRawData() / *b->m_integer.getRawData();
+ return result;
+ }
+ break;
+ }
+ case Scalar::e_float:
+ case Scalar::e_double:
+ case Scalar::e_long_double:
+ if (b->m_float.isZero())
+ {
+ result.m_float = a->m_float / b->m_float;
+ return result;
+ }
+ break;
}
}
// For division only, the only way it should make it here is if a promotion failed,
@@ -1606,15 +2129,19 @@ lldb_private::operator* (const Scalar& lhs, const Scalar& rhs)
switch (result.m_type)
{
case Scalar::e_void: break;
- case Scalar::e_sint: result.m_data.sint = a->m_data.sint * b->m_data.sint; break;
- case Scalar::e_uint: result.m_data.uint = a->m_data.uint * b->m_data.uint; break;
- case Scalar::e_slong: result.m_data.slong = a->m_data.slong * b->m_data.slong; break;
- case Scalar::e_ulong: result.m_data.ulong = a->m_data.ulong * b->m_data.ulong; break;
- case Scalar::e_slonglong: result.m_data.slonglong = a->m_data.slonglong * b->m_data.slonglong; break;
- case Scalar::e_ulonglong: result.m_data.ulonglong = a->m_data.ulonglong * b->m_data.ulonglong; break;
- case Scalar::e_float: result.m_data.flt = a->m_data.flt * b->m_data.flt; break;
- case Scalar::e_double: result.m_data.dbl = a->m_data.dbl * b->m_data.dbl; break;
- case Scalar::e_long_double: result.m_data.ldbl = a->m_data.ldbl * b->m_data.ldbl; break;
+ case Scalar::e_sint:
+ case Scalar::e_uint:
+ case Scalar::e_slong:
+ case Scalar::e_ulong:
+ case Scalar::e_slonglong:
+ case Scalar::e_ulonglong:
+ case Scalar::e_sint128:
+ case Scalar::e_uint128:
+ result.m_integer = a->m_integer * b->m_integer; break;
+ case Scalar::e_float:
+ case Scalar::e_double:
+ case Scalar::e_long_double:
+ result.m_float = a->m_float * b->m_float; break;
}
}
return result;
@@ -1631,13 +2158,15 @@ lldb_private::operator& (const Scalar& lhs, const Scalar& rhs)
{
switch (result.m_type)
{
- case Scalar::e_sint: result.m_data.sint = a->m_data.sint & b->m_data.sint; break;
- case Scalar::e_uint: result.m_data.uint = a->m_data.uint & b->m_data.uint; break;
- case Scalar::e_slong: result.m_data.slong = a->m_data.slong & b->m_data.slong; break;
- case Scalar::e_ulong: result.m_data.ulong = a->m_data.ulong & b->m_data.ulong; break;
- case Scalar::e_slonglong: result.m_data.slonglong = a->m_data.slonglong & b->m_data.slonglong; break;
- case Scalar::e_ulonglong: result.m_data.ulonglong = a->m_data.ulonglong & b->m_data.ulonglong; break;
-
+ case Scalar::e_sint:
+ case Scalar::e_uint:
+ case Scalar::e_slong:
+ case Scalar::e_ulong:
+ case Scalar::e_slonglong:
+ case Scalar::e_ulonglong:
+ case Scalar::e_sint128:
+ case Scalar::e_uint128:
+ result.m_integer = a->m_integer & b->m_integer; break;
case Scalar::e_void:
case Scalar::e_float:
case Scalar::e_double:
@@ -1661,12 +2190,15 @@ lldb_private::operator| (const Scalar& lhs, const Scalar& rhs)
{
switch (result.m_type)
{
- case Scalar::e_sint: result.m_data.sint = a->m_data.sint | b->m_data.sint; break;
- case Scalar::e_uint: result.m_data.uint = a->m_data.uint | b->m_data.uint; break;
- case Scalar::e_slong: result.m_data.slong = a->m_data.slong | b->m_data.slong; break;
- case Scalar::e_ulong: result.m_data.ulong = a->m_data.ulong | b->m_data.ulong; break;
- case Scalar::e_slonglong: result.m_data.slonglong = a->m_data.slonglong | b->m_data.slonglong; break;
- case Scalar::e_ulonglong: result.m_data.ulonglong = a->m_data.ulonglong | b->m_data.ulonglong; break;
+ case Scalar::e_sint:
+ case Scalar::e_uint:
+ case Scalar::e_slong:
+ case Scalar::e_ulong:
+ case Scalar::e_slonglong:
+ case Scalar::e_ulonglong:
+ case Scalar::e_sint128:
+ case Scalar::e_uint128:
+ result.m_integer = a->m_integer | b->m_integer; break;
case Scalar::e_void:
case Scalar::e_float:
@@ -1692,12 +2224,23 @@ lldb_private::operator% (const Scalar& lhs, const Scalar& rhs)
switch (result.m_type)
{
default: break;
- case Scalar::e_sint: if (b->m_data.sint != 0) { result.m_data.sint = a->m_data.sint % b->m_data.sint; return result; } break;
- case Scalar::e_uint: if (b->m_data.uint != 0) { result.m_data.uint = a->m_data.uint % b->m_data.uint; return result; } break;
- case Scalar::e_slong: if (b->m_data.slong != 0) { result.m_data.slong = a->m_data.slong % b->m_data.slong; return result; } break;
- case Scalar::e_ulong: if (b->m_data.ulong != 0) { result.m_data.ulong = a->m_data.ulong % b->m_data.ulong; return result; } break;
- case Scalar::e_slonglong: if (b->m_data.slonglong != 0) { result.m_data.slonglong = a->m_data.slonglong % b->m_data.slonglong; return result; } break;
- case Scalar::e_ulonglong: if (b->m_data.ulonglong != 0) { result.m_data.ulonglong = a->m_data.ulonglong % b->m_data.ulonglong; return result; } break;
+ case Scalar::e_void: break;
+ case Scalar::e_sint:
+ case Scalar::e_uint:
+ case Scalar::e_slong:
+ case Scalar::e_ulong:
+ case Scalar::e_slonglong:
+ case Scalar::e_ulonglong:
+ case Scalar::e_sint128:
+ case Scalar::e_uint128:
+ {
+ if (b->m_integer != 0)
+ {
+ result.m_integer = *a->m_integer.getRawData() % *b->m_integer.getRawData();
+ return result;
+ }
+ break;
+ }
}
}
result.m_type = Scalar::e_void;
@@ -1715,12 +2258,15 @@ lldb_private::operator^ (const Scalar& lhs, const Scalar& rhs)
{
switch (result.m_type)
{
- case Scalar::e_sint: result.m_data.sint = a->m_data.sint ^ b->m_data.sint; break;
- case Scalar::e_uint: result.m_data.uint = a->m_data.uint ^ b->m_data.uint; break;
- case Scalar::e_slong: result.m_data.slong = a->m_data.slong ^ b->m_data.slong; break;
- case Scalar::e_ulong: result.m_data.ulong = a->m_data.ulong ^ b->m_data.ulong; break;
- case Scalar::e_slonglong: result.m_data.slonglong = a->m_data.slonglong ^ b->m_data.slonglong; break;
- case Scalar::e_ulonglong: result.m_data.ulonglong = a->m_data.ulonglong ^ b->m_data.ulonglong; break;
+ case Scalar::e_sint:
+ case Scalar::e_uint:
+ case Scalar::e_slong:
+ case Scalar::e_ulong:
+ case Scalar::e_slonglong:
+ case Scalar::e_ulonglong:
+ case Scalar::e_sint128:
+ case Scalar::e_uint128:
+ result.m_integer = a->m_integer ^ b->m_integer; break;
case Scalar::e_void:
case Scalar::e_float:
@@ -1754,21 +2300,21 @@ lldb_private::operator>> (const Scalar& lhs, const Scalar &rhs)
unsigned int
Scalar::RawUInt () const
{
- return m_data.uint;
+ return *(const uint_t *) m_integer.getRawData();
}
// Return the raw unsigned long without any casting or conversion
unsigned long
Scalar::RawULong () const
{
- return m_data.ulong;
+ return *(const ulong_t *) m_integer.getRawData();
}
// Return the raw unsigned long long without any casting or conversion
unsigned long long
Scalar::RawULongLong () const
{
- return m_data.ulonglong;
+ return *(const ulonglong_t *) m_integer.getRawData();
}
@@ -1801,9 +2347,9 @@ Scalar::SetValueFromCString (const char *value_str, Encoding encoding, size_t by
m_type = Scalar::GetValueTypeForUnsignedIntegerWithByteSize (byte_size);
switch (m_type)
{
- case e_uint: m_data.uint = (uint_t)uval64; break;
- case e_ulong: m_data.ulong = (ulong_t)uval64; break;
- case e_ulonglong: m_data.ulonglong = (ulonglong_t)uval64; break;
+ case e_uint: m_integer = llvm::APInt(sizeof(uint_t) * 8, uval64, false); break;
+ case e_ulong: m_integer = llvm::APInt(sizeof(ulong_t) * 8, uval64, false); break;
+ case e_ulonglong: m_integer = llvm::APInt(sizeof(ulonglong_t) * 8, uval64, false); break;
default:
error.SetErrorStringWithFormat("unsupported unsigned integer byte size: %" PRIu64 "", (uint64_t)byte_size);
break;
@@ -1830,9 +2376,9 @@ Scalar::SetValueFromCString (const char *value_str, Encoding encoding, size_t by
m_type = Scalar::GetValueTypeForSignedIntegerWithByteSize (byte_size);
switch (m_type)
{
- case e_sint: m_data.sint = (sint_t)sval64; break;
- case e_slong: m_data.slong = (slong_t)sval64; break;
- case e_slonglong: m_data.slonglong = (slonglong_t)sval64; break;
+ case e_sint: m_integer = llvm::APInt(sizeof(sint_t) * 8, sval64, true); break;
+ case e_slong: m_integer = llvm::APInt(sizeof(slong_t) * 8, sval64, true); break;
+ case e_slonglong: m_integer = llvm::APInt(sizeof(slonglong_t) * 8, sval64, true); break;
default:
error.SetErrorStringWithFormat("unsupported signed integer byte size: %" PRIu64 "", (uint64_t)byte_size);
break;
@@ -1847,24 +2393,36 @@ Scalar::SetValueFromCString (const char *value_str, Encoding encoding, size_t by
break;
case eEncodingIEEE754:
+ static float f_val;
+ static double d_val;
+ static long double l_val;
if (byte_size == sizeof (float))
{
- if (::sscanf (value_str, "%f", &m_data.flt) == 1)
+ if (::sscanf (value_str, "%f", &f_val) == 1)
+ {
+ m_float = llvm::APFloat(f_val);
m_type = e_float;
+ }
else
error.SetErrorStringWithFormat ("'%s' is not a valid float string value", value_str);
}
else if (byte_size == sizeof (double))
{
- if (::sscanf (value_str, "%lf", &m_data.dbl) == 1)
+ if (::sscanf (value_str, "%lf", &d_val) == 1)
+ {
+ m_float = llvm::APFloat(d_val);
m_type = e_double;
+ }
else
error.SetErrorStringWithFormat ("'%s' is not a valid float string value", value_str);
}
else if (byte_size == sizeof (long double))
{
- if (::sscanf (value_str, "%Lf", &m_data.ldbl) == 1)
+ 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_type = e_long_double;
+ }
else
error.SetErrorStringWithFormat ("'%s' is not a valid float string value", value_str);
}
@@ -1890,6 +2448,7 @@ Scalar::SetValueFromData (DataExtractor &data, lldb::Encoding encoding, size_t b
{
Error error;
+ type128 int128;
switch (encoding)
{
case lldb::eEncodingInvalid:
@@ -1904,10 +2463,25 @@ Scalar::SetValueFromData (DataExtractor &data, lldb::Encoding encoding, size_t b
switch (byte_size)
{
- case 1: operator=((uint8_t)data.GetU8(&offset)); break;
- case 2: operator=((uint16_t)data.GetU16(&offset)); break;
- case 4: operator=((uint32_t)data.GetU32(&offset)); break;
- case 8: operator=((uint64_t)data.GetU64(&offset)); break;
+ case 1: operator=((uint8_t)data.GetU8(&offset)); break;
+ case 2: operator=((uint16_t)data.GetU16(&offset)); break;
+ case 4: operator=((uint32_t)data.GetU32(&offset)); break;
+ case 8: operator=((uint64_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 + 1);
+ }
+ else
+ {
+ int128.x[0] = (uint64_t)data.GetU64 (&offset);
+ int128.x[1] = (uint64_t)data.GetU64 (&offset + 1);
+ }
+ operator=(llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, int128.x));
+ break;
+ }
default:
error.SetErrorStringWithFormat("unsupported unsigned integer byte size: %" PRIu64 "", (uint64_t)byte_size);
break;
@@ -1924,6 +2498,21 @@ Scalar::SetValueFromData (DataExtractor &data, lldb::Encoding encoding, size_t b
case 2: operator=((int16_t)data.GetU16(&offset)); break;
case 4: operator=((int32_t)data.GetU32(&offset)); break;
case 8: operator=((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 + 1);
+ }
+ else
+ {
+ int128.x[0] = (uint64_t)data.GetU64 (&offset);
+ int128.x[1] = (uint64_t)data.GetU64 (&offset + 1);
+ }
+ operator=(llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, int128.x));
+ break;
+ }
default:
error.SetErrorStringWithFormat("unsupported signed integer byte size: %" PRIu64 "", (uint64_t)byte_size);
break;
@@ -1966,47 +2555,22 @@ Scalar::SignExtend (uint32_t sign_bit_pos)
case Scalar::e_sint:
case Scalar::e_uint:
- if (max_bit_pos == sign_bit_pos)
- return true;
- else if (sign_bit_pos < (max_bit_pos-1))
- {
- unsigned int sign_bit = 1u << sign_bit_pos;
- if (m_data.uint & sign_bit)
- {
- const unsigned int mask = ~(sign_bit) + 1u;
- m_data.uint |= mask;
- }
- return true;
- }
- break;
-
case Scalar::e_slong:
case Scalar::e_ulong:
- if (max_bit_pos == sign_bit_pos)
- return true;
- else if (sign_bit_pos < (max_bit_pos-1))
- {
- unsigned long sign_bit = 1ul << sign_bit_pos;
- if (m_data.ulong & sign_bit)
- {
- const unsigned long mask = ~(sign_bit) + 1ul;
- m_data.ulong |= mask;
- }
- return true;
- }
- break;
-
case Scalar::e_slonglong:
case Scalar::e_ulonglong:
+ case Scalar::e_sint128:
+ case Scalar::e_uint128:
if (max_bit_pos == sign_bit_pos)
return true;
else if (sign_bit_pos < (max_bit_pos-1))
{
- unsigned long long sign_bit = 1ull << sign_bit_pos;
- if (m_data.ulonglong & sign_bit)
+ llvm::APInt sign_bit = llvm::APInt::getSignBit(sign_bit_pos + 1);
+ llvm::APInt bitwize_and = m_integer & sign_bit;
+ if (bitwize_and.getBoolValue())
{
- const unsigned long long mask = ~(sign_bit) + 1ull;
- m_data.ulonglong |= mask;
+ const llvm::APInt mask = ~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1);
+ m_integer |= mask;
}
return true;
}
@@ -2053,66 +2617,40 @@ Scalar::ExtractBitfield (uint32_t bit_size,
uint32_t msbit = bit_offset + bit_size - 1;
uint32_t lsbit = bit_offset;
+ uint64_t result;
switch (m_type)
{
case Scalar::e_void:
break;
case e_float:
- if (sizeof(m_data.flt) == sizeof(sint_t))
- m_data.sint = (sint_t)SignedBits (m_data.sint, msbit, lsbit);
- else if (sizeof(m_data.flt) == sizeof(ulong_t))
- m_data.slong = (slong_t)SignedBits (m_data.slong, msbit, lsbit);
- else if (sizeof(m_data.flt) == sizeof(ulonglong_t))
- m_data.slonglong = (slonglong_t)SignedBits (m_data.slonglong, msbit, lsbit);
- else
- return false;
+ result = SignedBits ((uint64_t )m_float.convertToFloat(), msbit, lsbit);
+ m_float = llvm::APFloat((float_t)result);
return true;
-
case e_double:
- if (sizeof(m_data.dbl) == sizeof(sint_t))
- m_data.sint = SignedBits (m_data.sint, msbit, lsbit);
- else if (sizeof(m_data.dbl) == sizeof(ulong_t))
- m_data.slong = SignedBits (m_data.slong, msbit, lsbit);
- else if (sizeof(m_data.dbl) == sizeof(ulonglong_t))
- m_data.slonglong = SignedBits (m_data.slonglong, msbit, lsbit);
- else
- return false;
- return true;
-
+ result = SignedBits ((uint64_t )m_float.convertToDouble(), msbit, lsbit);
+ m_float = llvm::APFloat((double_t)result);
case e_long_double:
- if (sizeof(m_data.ldbl) == sizeof(sint_t))
- m_data.sint = SignedBits (m_data.sint, msbit, lsbit);
- else if (sizeof(m_data.ldbl) == sizeof(ulong_t))
- m_data.slong = SignedBits (m_data.slong, msbit, lsbit);
- else if (sizeof(m_data.ldbl) == sizeof(ulonglong_t))
- m_data.slonglong = SignedBits (m_data.slonglong, msbit, lsbit);
+ m_integer = m_float.bitcastToAPInt();
+ result = SignedBits (*m_integer.getRawData(), msbit, lsbit);
+ if(m_ieee_quad)
+ m_float = llvm::APFloat(llvm::APFloat::IEEEquad, llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&result)->x));
else
- return false;
+ m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&result)->x));
return true;
case Scalar::e_sint:
- m_data.sint = (sint_t)SignedBits (m_data.sint, msbit, lsbit);
- return true;
-
- case Scalar::e_uint:
- m_data.uint = (uint_t)UnsignedBits (m_data.uint, msbit, lsbit);
- return true;
-
case Scalar::e_slong:
- m_data.slong = (slong_t)SignedBits (m_data.slong, msbit, lsbit);
- return true;
-
- case Scalar::e_ulong:
- m_data.ulong = (ulong_t)UnsignedBits (m_data.ulong, msbit, lsbit);
- return true;
-
case Scalar::e_slonglong:
- m_data.slonglong = (slonglong_t)SignedBits (m_data.slonglong, msbit, lsbit);
+ case Scalar::e_sint128:
+ m_integer = SignedBits (*m_integer.getRawData(), msbit, lsbit);
return true;
+ case Scalar::e_uint:
+ case Scalar::e_ulong:
case Scalar::e_ulonglong:
- m_data.ulonglong = (ulonglong_t)UnsignedBits (m_data.ulonglong, msbit, lsbit);
+ case Scalar::e_uint128:
+ m_integer = UnsignedBits (*m_integer.getRawData(), msbit, lsbit);
return true;
}
return false;
@@ -2132,18 +2670,25 @@ lldb_private::operator== (const Scalar& lhs, const Scalar& rhs)
Scalar temp_value;
const Scalar* a;
const Scalar* b;
+ llvm::APFloat::cmpResult result;
switch (PromoteToMaxType(lhs, rhs, temp_value, a, b))
{
case Scalar::e_void: break;
- case Scalar::e_sint: return a->m_data.sint == b->m_data.sint;
- case Scalar::e_uint: return a->m_data.uint == b->m_data.uint;
- case Scalar::e_slong: return a->m_data.slong == b->m_data.slong;
- case Scalar::e_ulong: return a->m_data.ulong == b->m_data.ulong;
- case Scalar::e_slonglong: return a->m_data.slonglong == b->m_data.slonglong;
- case Scalar::e_ulonglong: return a->m_data.ulonglong == b->m_data.ulonglong;
- case Scalar::e_float: return a->m_data.flt == b->m_data.flt;
- case Scalar::e_double: return a->m_data.dbl == b->m_data.dbl;
- case Scalar::e_long_double: return a->m_data.ldbl == b->m_data.ldbl;
+ case Scalar::e_sint:
+ case Scalar::e_uint:
+ case Scalar::e_slong:
+ case Scalar::e_ulong:
+ case Scalar::e_slonglong:
+ case Scalar::e_ulonglong:
+ case Scalar::e_sint128:
+ case Scalar::e_uint128:
+ return a->m_integer == b->m_integer;
+ case Scalar::e_float:
+ case Scalar::e_double:
+ case Scalar::e_long_double:
+ result = a->m_float.compare(b->m_float);
+ if(result == llvm::APFloat::cmpEqual)
+ return true;
}
return false;
}
@@ -2158,18 +2703,25 @@ lldb_private::operator!= (const Scalar& lhs, const Scalar& rhs)
Scalar temp_value; // A temp value that might get a copy of either promoted value
const Scalar* a;
const Scalar* b;
+ llvm::APFloat::cmpResult result;
switch (PromoteToMaxType(lhs, rhs, temp_value, a, b))
{
case Scalar::e_void: break;
- case Scalar::e_sint: return a->m_data.sint != b->m_data.sint;
- case Scalar::e_uint: return a->m_data.uint != b->m_data.uint;
- case Scalar::e_slong: return a->m_data.slong != b->m_data.slong;
- case Scalar::e_ulong: return a->m_data.ulong != b->m_data.ulong;
- case Scalar::e_slonglong: return a->m_data.slonglong != b->m_data.slonglong;
- case Scalar::e_ulonglong: return a->m_data.ulonglong != b->m_data.ulonglong;
- case Scalar::e_float: return a->m_data.flt != b->m_data.flt;
- case Scalar::e_double: return a->m_data.dbl != b->m_data.dbl;
- case Scalar::e_long_double: return a->m_data.ldbl != b->m_data.ldbl;
+ case Scalar::e_sint:
+ case Scalar::e_uint:
+ case Scalar::e_slong:
+ case Scalar::e_ulong:
+ case Scalar::e_slonglong:
+ case Scalar::e_ulonglong:
+ case Scalar::e_sint128:
+ case Scalar::e_uint128:
+ return a->m_integer != b->m_integer;
+ case Scalar::e_float:
+ case Scalar::e_double:
+ case Scalar::e_long_double:
+ result = a->m_float.compare(b->m_float);
+ if(result != llvm::APFloat::cmpEqual)
+ return true;
}
return true;
}
@@ -2183,18 +2735,26 @@ lldb_private::operator< (const Scalar& lhs, const Scalar& rhs)
Scalar temp_value;
const Scalar* a;
const Scalar* b;
+ llvm::APFloat::cmpResult result;
switch (PromoteToMaxType(lhs, rhs, temp_value, a, b))
{
case Scalar::e_void: break;
- case Scalar::e_sint: return a->m_data.sint < b->m_data.sint;
- case Scalar::e_uint: return a->m_data.uint < b->m_data.uint;
- case Scalar::e_slong: return a->m_data.slong < b->m_data.slong;
- case Scalar::e_ulong: return a->m_data.ulong < b->m_data.ulong;
- case Scalar::e_slonglong: return a->m_data.slonglong < b->m_data.slonglong;
- case Scalar::e_ulonglong: return a->m_data.ulonglong < b->m_data.ulonglong;
- case Scalar::e_float: return a->m_data.flt < b->m_data.flt;
- case Scalar::e_double: return a->m_data.dbl < b->m_data.dbl;
- case Scalar::e_long_double: return a->m_data.ldbl < b->m_data.ldbl;
+ case Scalar::e_sint:
+ case Scalar::e_slong:
+ case Scalar::e_slonglong:
+ case Scalar::e_sint128:
+ return a->m_integer.slt(b->m_integer);
+ case Scalar::e_uint:
+ case Scalar::e_ulong:
+ case Scalar::e_ulonglong:
+ case Scalar::e_uint128:
+ return a->m_integer.ult(b->m_integer);
+ case Scalar::e_float:
+ case Scalar::e_double:
+ case Scalar::e_long_double:
+ result = a->m_float.compare(b->m_float);
+ if(result == llvm::APFloat::cmpLessThan)
+ return true;
}
return false;
}
@@ -2208,18 +2768,26 @@ lldb_private::operator<= (const Scalar& lhs, const Scalar& rhs)
Scalar temp_value;
const Scalar* a;
const Scalar* b;
+ llvm::APFloat::cmpResult result;
switch (PromoteToMaxType(lhs, rhs, temp_value, a, b))
{
case Scalar::e_void: break;
- case Scalar::e_sint: return a->m_data.sint <= b->m_data.sint;
- case Scalar::e_uint: return a->m_data.uint <= b->m_data.uint;
- case Scalar::e_slong: return a->m_data.slong <= b->m_data.slong;
- case Scalar::e_ulong: return a->m_data.ulong <= b->m_data.ulong;
- case Scalar::e_slonglong: return a->m_data.slonglong <= b->m_data.slonglong;
- case Scalar::e_ulonglong: return a->m_data.ulonglong <= b->m_data.ulonglong;
- case Scalar::e_float: return a->m_data.flt <= b->m_data.flt;
- case Scalar::e_double: return a->m_data.dbl <= b->m_data.dbl;
- case Scalar::e_long_double: return a->m_data.ldbl <= b->m_data.ldbl;
+ case Scalar::e_sint:
+ case Scalar::e_slong:
+ case Scalar::e_slonglong:
+ case Scalar::e_sint128:
+ return a->m_integer.sle(b->m_integer);
+ case Scalar::e_uint:
+ case Scalar::e_ulong:
+ case Scalar::e_ulonglong:
+ case Scalar::e_uint128:
+ return a->m_integer.ule(b->m_integer);
+ case Scalar::e_float:
+ case Scalar::e_double:
+ case Scalar::e_long_double:
+ result = a->m_float.compare(b->m_float);
+ if(result == llvm::APFloat::cmpLessThan || result == llvm::APFloat::cmpEqual)
+ return true;
}
return false;
}
@@ -2234,18 +2802,26 @@ lldb_private::operator> (const Scalar& lhs, const Scalar& rhs)
Scalar temp_value;
const Scalar* a;
const Scalar* b;
+ llvm::APFloat::cmpResult result;
switch (PromoteToMaxType(lhs, rhs, temp_value, a, b))
{
- case Scalar::e_void: break;
- case Scalar::e_sint: return a->m_data.sint > b->m_data.sint;
- case Scalar::e_uint: return a->m_data.uint > b->m_data.uint;
- case Scalar::e_slong: return a->m_data.slong > b->m_data.slong;
- case Scalar::e_ulong: return a->m_data.ulong > b->m_data.ulong;
- case Scalar::e_slonglong: return a->m_data.slonglong > b->m_data.slonglong;
- case Scalar::e_ulonglong: return a->m_data.ulonglong > b->m_data.ulonglong;
- case Scalar::e_float: return a->m_data.flt > b->m_data.flt;
- case Scalar::e_double: return a->m_data.dbl > b->m_data.dbl;
- case Scalar::e_long_double: return a->m_data.ldbl > b->m_data.ldbl;
+ case Scalar::e_void: break;
+ case Scalar::e_sint:
+ case Scalar::e_slong:
+ case Scalar::e_slonglong:
+ case Scalar::e_sint128:
+ return a->m_integer.sgt(b->m_integer);
+ case Scalar::e_uint:
+ case Scalar::e_ulong:
+ case Scalar::e_ulonglong:
+ case Scalar::e_uint128:
+ return a->m_integer.ugt(b->m_integer);
+ case Scalar::e_float:
+ case Scalar::e_double:
+ case Scalar::e_long_double:
+ result = a->m_float.compare(b->m_float);
+ if(result == llvm::APFloat::cmpGreaterThan)
+ return true;
}
return false;
}
@@ -2259,22 +2835,140 @@ lldb_private::operator>= (const Scalar& lhs, const Scalar& rhs)
Scalar temp_value;
const Scalar* a;
const Scalar* b;
+ llvm::APFloat::cmpResult result;
switch (PromoteToMaxType(lhs, rhs, temp_value, a, b))
{
- case Scalar::e_void: break;
- case Scalar::e_sint: return a->m_data.sint >= b->m_data.sint;
- case Scalar::e_uint: return a->m_data.uint >= b->m_data.uint;
- case Scalar::e_slong: return a->m_data.slong >= b->m_data.slong;
- case Scalar::e_ulong: return a->m_data.ulong >= b->m_data.ulong;
- case Scalar::e_slonglong: return a->m_data.slonglong >= b->m_data.slonglong;
- case Scalar::e_ulonglong: return a->m_data.ulonglong >= b->m_data.ulonglong;
- case Scalar::e_float: return a->m_data.flt >= b->m_data.flt;
- case Scalar::e_double: return a->m_data.dbl >= b->m_data.dbl;
- case Scalar::e_long_double: return a->m_data.ldbl >= b->m_data.ldbl;
+ case Scalar::e_void: break;
+ case Scalar::e_sint:
+ case Scalar::e_slong:
+ case Scalar::e_slonglong:
+ case Scalar::e_sint128:
+ return a->m_integer.sge(b->m_integer);
+ case Scalar::e_uint:
+ case Scalar::e_ulong:
+ case Scalar::e_ulonglong:
+ case Scalar::e_uint128:
+ return a->m_integer.uge(b->m_integer);
+ case Scalar::e_float:
+ case Scalar::e_double:
+ case Scalar::e_long_double:
+ result = a->m_float.compare(b->m_float);
+ if(result == llvm::APFloat::cmpGreaterThan || result == llvm::APFloat::cmpEqual)
+ return true;
}
return false;
}
+bool
+Scalar::ClearBit (uint32_t bit)
+{
+ 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: m_integer.clearBit(bit); return true;
+ case e_float:
+ case e_double:
+ case e_long_double: break;
+ }
+ return false;
+}
+bool
+Scalar::SetBit (uint32_t bit)
+{
+ 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: m_integer.setBit(bit); return true;
+ case e_float:
+ case e_double:
+ case e_long_double: break;
+ }
+ return false;
+}
-
+void
+Scalar::SetType (const RegisterInfo *reg_info)
+{
+ const uint32_t byte_size = reg_info->byte_size;
+ switch (reg_info->encoding)
+ {
+ case eEncodingInvalid:
+ break;
+ case eEncodingUint:
+ if (byte_size == 1 || byte_size == 2 || byte_size == 4)
+ {
+ m_integer = llvm::APInt(sizeof(uint_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+ m_type = e_uint;
+ }
+ if (byte_size == 8)
+ {
+ m_integer = llvm::APInt(sizeof(ulonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), false);
+ m_type = e_ulonglong;
+ }
+ if (byte_size == 16)
+ {
+ m_integer = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((const type128 *)m_integer.getRawData())->x);
+ m_type = e_uint128;
+ }
+ break;
+ case eEncodingSint:
+ if (byte_size == 1 || byte_size == 2 || byte_size == 4)
+ {
+ m_integer = llvm::APInt(sizeof(sint_t) * 8, *(const uint64_t *)m_integer.getRawData(), true);
+ m_type = e_sint;
+ }
+ if (byte_size == 8)
+ {
+ m_integer = llvm::APInt(sizeof(slonglong_t) * 8, *(const uint64_t *)m_integer.getRawData(), true);
+ m_type = e_slonglong;
+ }
+ if (byte_size == 16)
+ {
+ m_integer = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((const type128 *)m_integer.getRawData())->x);
+ m_type = e_sint128;
+ }
+ break;
+ case eEncodingIEEE754:
+ if (byte_size == sizeof(float))
+ {
+ bool losesInfo = false;
+ m_float.convert(llvm::APFloat::IEEEsingle, llvm::APFloat::rmTowardZero, &losesInfo);
+ m_type = e_float;
+ }
+ else if (byte_size == sizeof(double))
+ {
+ bool losesInfo = false;
+ m_float.convert(llvm::APFloat::IEEEdouble, llvm::APFloat::rmTowardZero, &losesInfo);
+ m_type = e_double;
+ }
+ else if (byte_size == sizeof(long double))
+ {
+ if(m_ieee_quad)
+ m_float = llvm::APFloat(llvm::APFloat::IEEEquad, m_float.bitcastToAPInt());
+ else
+ m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, m_float.bitcastToAPInt());
+ m_type = e_long_double;
+ }
+ break;
+ case eEncodingVector:
+ m_type = e_void;
+ break;
+ }
+}
diff --git a/source/Core/Section.cpp b/source/Core/Section.cpp
index 9a3f220beb44..cf1cbac8fd7c 100644
--- a/source/Core/Section.cpp
+++ b/source/Core/Section.cpp
@@ -319,6 +319,25 @@ Section::Slide (addr_t slide_amount, bool slide_children)
return false;
}
+lldb::offset_t
+Section::GetSectionData (void *dst, lldb::offset_t dst_len, lldb::offset_t offset)
+{
+ if (m_obj_file)
+ return m_obj_file->ReadSectionData (this,
+ offset,
+ dst,
+ dst_len);
+ return 0;
+}
+
+lldb::offset_t
+Section::GetSectionData (DataExtractor& section_data) const
+{
+ if (m_obj_file)
+ return m_obj_file->ReadSectionData (this, section_data);
+ return 0;
+}
+
#pragma mark SectionList
SectionList::SectionList () :
diff --git a/source/Core/SourceManager.cpp b/source/Core/SourceManager.cpp
index 324ed34bfaac..a69e75fe244a 100644
--- a/source/Core/SourceManager.cpp
+++ b/source/Core/SourceManager.cpp
@@ -18,7 +18,6 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/Stream.h"
-#include "lldb/Symbol/ClangNamespaceDecl.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/SymbolContext.h"
@@ -83,6 +82,10 @@ SourceManager::GetFile (const FileSpec &file_spec)
if (target_sp && file_sp && file_sp->GetSourceMapModificationID() != target_sp->GetSourcePathMap().GetModificationID())
file_sp.reset();
+ // Update the file contents if needed if we found a file
+ if (file_sp)
+ file_sp->UpdateIfNeeded();
+
// If file_sp is no good or it points to a non-existent file, reset it.
if (!file_sp || !file_sp->GetFileSpec().Exists())
{
@@ -492,8 +495,8 @@ SourceManager::File::LineIsValid (uint32_t line)
return false;
}
-size_t
-SourceManager::File::DisplaySourceLines (uint32_t line, uint32_t context_before, uint32_t context_after, Stream *s)
+void
+SourceManager::File::UpdateIfNeeded ()
{
// TODO: use host API to sign up for file modifications to anything in our
// source cache and only update when we determine a file has been updated.
@@ -506,7 +509,11 @@ SourceManager::File::DisplaySourceLines (uint32_t line, uint32_t context_before,
m_data_sp = m_file_spec.ReadFileContents ();
m_offsets.clear();
}
+}
+size_t
+SourceManager::File::DisplaySourceLines (uint32_t line, uint32_t context_before, uint32_t context_after, Stream *s)
+{
// Sanity check m_data_sp before proceeding.
if (!m_data_sp)
return 0;
@@ -538,14 +545,6 @@ SourceManager::File::DisplaySourceLines (uint32_t line, uint32_t context_before,
void
SourceManager::File::FindLinesMatchingRegex (RegularExpression& regex, uint32_t start_line, uint32_t end_line, std::vector<uint32_t> &match_lines)
{
- TimeValue curr_mod_time (m_file_spec.GetModificationTime());
- if (m_mod_time != curr_mod_time)
- {
- m_mod_time = curr_mod_time;
- m_data_sp = m_file_spec.ReadFileContents ();
- m_offsets.clear();
- }
-
match_lines.clear();
if (!LineIsValid(start_line) || (end_line != UINT32_MAX && !LineIsValid(end_line)))
@@ -645,14 +644,14 @@ SourceManager::File::CalculateLineOffsets (uint32_t line)
else
{
// Some lines have been populated, start where we last left off
- assert("Not implemented yet" == NULL);
+ assert("Not implemented yet" && false);
}
}
else
{
// Calculate all line offsets up to "line"
- assert("Not implemented yet" == NULL);
+ assert("Not implemented yet" && false);
}
return false;
}
diff --git a/source/Core/Stream.cpp b/source/Core/Stream.cpp
index 29bebb3ae3db..15876d558ec5 100644
--- a/source/Core/Stream.cpp
+++ b/source/Core/Stream.cpp
@@ -30,7 +30,7 @@ Stream::Stream (uint32_t flags, uint32_t addr_size, ByteOrder byte_order) :
Stream::Stream () :
m_flags (0),
m_addr_size (4),
- m_byte_order (lldb::endian::InlHostByteOrder()),
+ m_byte_order (endian::InlHostByteOrder()),
m_indent_level(0)
{
}
@@ -284,9 +284,9 @@ Stream::operator<< (const char *s)
// Stream the pointer value out to this stream.
//------------------------------------------------------------------
Stream&
-Stream::operator<< (void *p)
+Stream::operator<< (const void *p)
{
- Printf ("0x%.*tx", (int)sizeof(void*) * 2, (ptrdiff_t)p);
+ Printf ("0x%.*tx", (int)sizeof(const void*) * 2, (ptrdiff_t)p);
return *this;
}
@@ -632,7 +632,7 @@ Stream::PutMaxHex64
size_t
Stream::PutPointer (void *ptr)
{
- return PutRawBytes (&ptr, sizeof(ptr), lldb::endian::InlHostByteOrder(), lldb::endian::InlHostByteOrder());
+ return PutRawBytes (&ptr, sizeof(ptr), endian::InlHostByteOrder(), endian::InlHostByteOrder());
}
size_t
@@ -641,7 +641,7 @@ Stream::PutFloat(float f, ByteOrder byte_order)
if (byte_order == eByteOrderInvalid)
byte_order = m_byte_order;
- return PutRawBytes (&f, sizeof(f), lldb::endian::InlHostByteOrder(), byte_order);
+ return PutRawBytes (&f, sizeof(f), endian::InlHostByteOrder(), byte_order);
}
size_t
@@ -650,7 +650,7 @@ Stream::PutDouble(double d, ByteOrder byte_order)
if (byte_order == eByteOrderInvalid)
byte_order = m_byte_order;
- return PutRawBytes (&d, sizeof(d), lldb::endian::InlHostByteOrder(), byte_order);
+ return PutRawBytes (&d, sizeof(d), endian::InlHostByteOrder(), byte_order);
}
size_t
@@ -659,7 +659,7 @@ Stream::PutLongDouble(long double ld, ByteOrder byte_order)
if (byte_order == eByteOrderInvalid)
byte_order = m_byte_order;
- return PutRawBytes (&ld, sizeof(ld), lldb::endian::InlHostByteOrder(), byte_order);
+ return PutRawBytes (&ld, sizeof(ld), endian::InlHostByteOrder(), byte_order);
}
size_t
@@ -743,21 +743,21 @@ Stream::UnitTest(Stream *s)
s->PutHex8(0x12);
s->PutChar(' ');
- s->PutHex16(0x3456, lldb::endian::InlHostByteOrder());
+ s->PutHex16(0x3456, endian::InlHostByteOrder());
s->PutChar(' ');
s->PutHex16(0x3456, eByteOrderBig);
s->PutChar(' ');
s->PutHex16(0x3456, eByteOrderLittle);
s->PutChar(' ');
- s->PutHex32(0x789abcde, lldb::endian::InlHostByteOrder());
+ s->PutHex32(0x789abcde, endian::InlHostByteOrder());
s->PutChar(' ');
s->PutHex32(0x789abcde, eByteOrderBig);
s->PutChar(' ');
s->PutHex32(0x789abcde, eByteOrderLittle);
s->PutChar(' ');
- s->PutHex64(0x1122334455667788ull, lldb::endian::InlHostByteOrder());
+ s->PutHex64(0x1122334455667788ull, endian::InlHostByteOrder());
s->PutChar(' ');
s->PutHex64(0x1122334455667788ull, eByteOrderBig);
s->PutChar(' ');
diff --git a/source/Core/StreamAsynchronousIO.cpp b/source/Core/StreamAsynchronousIO.cpp
index ccfde0c9a011..6f8fcce932e7 100644
--- a/source/Core/StreamAsynchronousIO.cpp
+++ b/source/Core/StreamAsynchronousIO.cpp
@@ -36,7 +36,7 @@ StreamAsynchronousIO::Flush ()
if (!m_data.empty())
{
m_debugger.PrintAsync (m_data.data(), m_data.size(), m_for_stdout);
- m_data = std::move(std::string());
+ m_data = std::string();
}
}
diff --git a/source/Core/StreamString.cpp b/source/Core/StreamString.cpp
index ef2b70583ebd..36e086b0b433 100644
--- a/source/Core/StreamString.cpp
+++ b/source/Core/StreamString.cpp
@@ -37,7 +37,7 @@ StreamString::Flush ()
size_t
StreamString::Write (const void *s, size_t length)
{
- m_packet.append ((char *)s, length);
+ m_packet.append (reinterpret_cast<const char *>(s), length);
return length;
}
diff --git a/source/Core/Timer.cpp b/source/Core/Timer.cpp
index bbd990056ba0..e53ce2ec453d 100644
--- a/source/Core/Timer.cpp
+++ b/source/Core/Timer.cpp
@@ -21,12 +21,27 @@
using namespace lldb_private;
#define TIMER_INDENT_AMOUNT 2
-static bool g_quiet = true;
-uint32_t Timer::g_depth = 0;
-uint32_t Timer::g_display_depth = 0;
-FILE * Timer::g_file = NULL;
-typedef std::vector<Timer *> TimerStack;
-typedef std::map<const char *, uint64_t> TimerCategoryMap;
+
+namespace
+{
+ typedef std::map<const char*, uint64_t> TimerCategoryMap;
+
+ struct TimerStack
+ {
+ TimerStack() :
+ m_depth(0)
+ {}
+
+ uint32_t m_depth;
+ std::vector<Timer*> m_stack;
+ };
+} // end of anonymous namespace
+
+std::atomic<bool> Timer::g_quiet(true);
+std::atomic<unsigned> Timer::g_display_depth(0);
+std::mutex Timer::g_file_mutex;
+FILE* Timer::g_file = nullptr;
+
static lldb::thread_key_t g_key;
static Mutex &
@@ -82,12 +97,18 @@ Timer::Timer (const char *category, const char *format, ...) :
m_total_ticks (0),
m_timer_ticks (0)
{
- if (g_depth++ < g_display_depth)
+ TimerStack *stack = GetTimerStackForCurrentThread ();
+ if (!stack)
+ return;
+
+ if (stack->m_depth++ < g_display_depth)
{
if (g_quiet == false)
{
+ std::lock_guard<std::mutex> lock(g_file_mutex);
+
// Indent
- ::fprintf (g_file, "%*s", g_depth * TIMER_INDENT_AMOUNT, "");
+ ::fprintf (g_file, "%*s", stack->m_depth * TIMER_INDENT_AMOUNT, "");
// Print formatted string
va_list args;
va_start (args, format);
@@ -100,19 +121,19 @@ Timer::Timer (const char *category, const char *format, ...) :
TimeValue start_time(TimeValue::Now());
m_total_start = start_time;
m_timer_start = start_time;
- TimerStack *stack = GetTimerStackForCurrentThread ();
- if (stack)
- {
- if (stack->empty() == false)
- stack->back()->ChildStarted (start_time);
- stack->push_back(this);
- }
+
+ if (!stack->m_stack.empty())
+ stack->m_stack.back()->ChildStarted (start_time);
+ stack->m_stack.push_back(this);
}
}
-
Timer::~Timer()
{
+ TimerStack *stack = GetTimerStackForCurrentThread ();
+ if (!stack)
+ return;
+
if (m_total_start.IsValid())
{
TimeValue stop_time = TimeValue::Now();
@@ -127,14 +148,10 @@ Timer::~Timer()
m_timer_start.Clear();
}
- TimerStack *stack = GetTimerStackForCurrentThread ();
- if (stack)
- {
- assert (stack->back() == this);
- stack->pop_back();
- if (stack->empty() == false)
- stack->back()->ChildStopped(stop_time);
- }
+ assert (stack->m_stack.back() == this);
+ stack->m_stack.pop_back();
+ if (stack->m_stack.empty() == false)
+ stack->m_stack.back()->ChildStopped(stop_time);
const uint64_t total_nsec_uint = GetTotalElapsedNanoSeconds();
const uint64_t timer_nsec_uint = GetTimerElapsedNanoSeconds();
@@ -143,10 +160,10 @@ Timer::~Timer()
if (g_quiet == false)
{
-
+ std::lock_guard<std::mutex> lock(g_file_mutex);
::fprintf (g_file,
"%*s%.9f sec (%.9f sec)\n",
- (g_depth - 1) *TIMER_INDENT_AMOUNT, "",
+ (stack->m_depth - 1) *TIMER_INDENT_AMOUNT, "",
total_nsec / 1000000000.0,
timer_nsec / 1000000000.0);
}
@@ -156,8 +173,8 @@ Timer::~Timer()
TimerCategoryMap &category_map = GetCategoryMap();
category_map[m_category] += timer_nsec_uint;
}
- if (g_depth > 0)
- --g_depth;
+ if (stack->m_depth > 0)
+ --stack->m_depth;
}
uint64_t
diff --git a/source/Core/Value.cpp b/source/Core/Value.cpp
index a416d0745a69..a5c48e823ace 100644
--- a/source/Core/Value.cpp
+++ b/source/Core/Value.cpp
@@ -18,7 +18,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/State.h"
#include "lldb/Core/Stream.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
@@ -35,7 +35,7 @@ using namespace lldb_private;
Value::Value() :
m_value (),
m_vector (),
- m_clang_type (),
+ m_compiler_type (),
m_context (NULL),
m_value_type (eValueTypeScalar),
m_context_type (eContextTypeInvalid),
@@ -46,7 +46,7 @@ Value::Value() :
Value::Value(const Scalar& scalar) :
m_value (scalar),
m_vector (),
- m_clang_type (),
+ m_compiler_type (),
m_context (NULL),
m_value_type (eValueTypeScalar),
m_context_type (eContextTypeInvalid),
@@ -58,7 +58,7 @@ Value::Value(const Scalar& scalar) :
Value::Value(const void *bytes, int len) :
m_value (),
m_vector (),
- m_clang_type (),
+ m_compiler_type (),
m_context (NULL),
m_value_type (eValueTypeHostAddress),
m_context_type (eContextTypeInvalid),
@@ -70,7 +70,7 @@ Value::Value(const void *bytes, int len) :
Value::Value(const Value &v) :
m_value (v.m_value),
m_vector (v.m_vector),
- m_clang_type (v.m_clang_type),
+ m_compiler_type (v.m_compiler_type),
m_context (v.m_context),
m_value_type (v.m_value_type),
m_context_type (v.m_context_type),
@@ -93,7 +93,7 @@ Value::operator=(const Value &rhs)
{
m_value = rhs.m_value;
m_vector = rhs.m_vector;
- m_clang_type = rhs.m_clang_type;
+ m_compiler_type = rhs.m_compiler_type;
m_context = rhs.m_context;
m_value_type = rhs.m_value_type;
m_context_type = rhs.m_context_type;
@@ -189,7 +189,7 @@ Value::AppendDataToHostBuffer (const Value &rhs)
{
rhs.m_value.GetAsMemoryData (m_data_buffer.GetBytes() + curr_size,
scalar_size,
- lldb::endian::InlHostByteOrder(),
+ endian::InlHostByteOrder(),
error);
return scalar_size;
}
@@ -260,7 +260,7 @@ Value::ValueOf(ExecutionContext *exe_ctx)
}
uint64_t
-Value::GetValueByteSize (Error *error_ptr)
+Value::GetValueByteSize (Error *error_ptr, ExecutionContext *exe_ctx)
{
uint64_t byte_size = 0;
@@ -275,9 +275,9 @@ Value::GetValueByteSize (Error *error_ptr)
case eContextTypeLLDBType: // Type *
case eContextTypeVariable: // Variable *
{
- const ClangASTType &ast_type = GetClangType();
+ const CompilerType &ast_type = GetCompilerType();
if (ast_type.IsValid())
- byte_size = ast_type.GetByteSize(nullptr);
+ byte_size = ast_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr);
}
break;
}
@@ -297,10 +297,10 @@ Value::GetValueByteSize (Error *error_ptr)
return byte_size;
}
-const ClangASTType &
-Value::GetClangType ()
+const CompilerType &
+Value::GetCompilerType ()
{
- if (!m_clang_type.IsValid())
+ if (!m_compiler_type.IsValid())
{
switch (m_context_type)
{
@@ -308,13 +308,13 @@ Value::GetClangType ()
break;
case eContextTypeRegisterInfo:
- break; // TODO: Eventually convert into a clang type?
+ break; // TODO: Eventually convert into a compiler type?
case eContextTypeLLDBType:
{
Type *lldb_type = GetType();
if (lldb_type)
- m_clang_type = lldb_type->GetClangForwardType();
+ m_compiler_type = lldb_type->GetForwardCompilerType ();
}
break;
@@ -325,20 +325,20 @@ Value::GetClangType ()
{
Type *variable_type = variable->GetType();
if (variable_type)
- m_clang_type = variable_type->GetClangForwardType();
+ m_compiler_type = variable_type->GetForwardCompilerType ();
}
}
break;
}
}
- return m_clang_type;
+ return m_compiler_type;
}
void
-Value::SetClangType (const ClangASTType &clang_type)
+Value::SetCompilerType (const CompilerType &compiler_type)
{
- m_clang_type = clang_type;
+ m_compiler_type = compiler_type;
}
lldb::Format
@@ -355,7 +355,7 @@ Value::GetValueDefaultFormat ()
case eContextTypeLLDBType:
case eContextTypeVariable:
{
- const ClangASTType &ast_type = GetClangType();
+ const CompilerType &ast_type = GetCompilerType();
if (ast_type.IsValid())
return ast_type.GetFormat();
}
@@ -407,7 +407,7 @@ Value::GetValueAsData (ExecutionContext *exe_ctx,
lldb::addr_t address = LLDB_INVALID_ADDRESS;
AddressType address_type = eAddressTypeFile;
Address file_so_addr;
- const ClangASTType &ast_type = GetClangType();
+ const CompilerType &ast_type = GetCompilerType();
switch (m_value_type)
{
case eValueTypeVector:
@@ -420,7 +420,7 @@ Value::GetValueAsData (ExecutionContext *exe_ctx,
case eValueTypeScalar:
{
- data.SetByteOrder (lldb::endian::InlHostByteOrder());
+ data.SetByteOrder (endian::InlHostByteOrder());
if (ast_type.IsValid())
data.SetAddressByteSize (ast_type.GetPointerByteSize());
else
@@ -434,7 +434,7 @@ Value::GetValueAsData (ExecutionContext *exe_ctx,
lldb::Encoding type_encoding = ast_type.GetEncoding(type_encoding_count);
if (type_encoding == eEncodingUint || type_encoding == eEncodingSint)
- limit_byte_size = ast_type.GetByteSize(nullptr);
+ limit_byte_size = ast_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr);
}
if (m_value.GetData (data, limit_byte_size))
@@ -623,7 +623,7 @@ Value::GetValueAsData (ExecutionContext *exe_ctx,
}
}
// fallback to host settings
- data.SetByteOrder(lldb::endian::InlHostByteOrder());
+ data.SetByteOrder(endian::InlHostByteOrder());
data.SetAddressByteSize(sizeof(void *));
break;
}
@@ -639,7 +639,7 @@ Value::GetValueAsData (ExecutionContext *exe_ctx,
}
// If we got here, we need to read the value from memory
- size_t byte_size = GetValueByteSize (&error);
+ size_t byte_size = GetValueByteSize (&error, exe_ctx);
// Bail if we encountered any errors getting the byte size
if (error.Fail())
@@ -721,8 +721,8 @@ Value::GetValueAsData (ExecutionContext *exe_ctx,
Scalar &
Value::ResolveValue(ExecutionContext *exe_ctx)
{
- const ClangASTType &clang_type = GetClangType();
- if (clang_type.IsValid())
+ const CompilerType &compiler_type = GetCompilerType();
+ if (compiler_type.IsValid())
{
switch (m_value_type)
{
@@ -740,7 +740,7 @@ Value::ResolveValue(ExecutionContext *exe_ctx)
if (error.Success())
{
Scalar scalar;
- if (clang_type.GetValueAsScalar (data, 0, data.GetByteSize(), scalar))
+ if (compiler_type.GetValueAsScalar (data, 0, data.GetByteSize(), scalar))
{
m_value = scalar;
m_value_type = eValueTypeScalar;
@@ -782,7 +782,7 @@ Value::Clear()
{
m_value.Clear();
m_vector.Clear();
- m_clang_type.Clear();
+ m_compiler_type.Clear();
m_value_type = eValueTypeScalar;
m_context = NULL;
m_context_type = eContextTypeInvalid;
diff --git a/source/Core/ValueObject.cpp b/source/Core/ValueObject.cpp
index 8718b37b95e0..6b1a6c590631 100644
--- a/source/Core/ValueObject.cpp
+++ b/source/Core/ValueObject.cpp
@@ -15,7 +15,6 @@
// C++ Includes
// Other libraries and framework includes
#include "llvm/Support/raw_ostream.h"
-#include "clang/AST/Type.h"
// Project includes
#include "lldb/Core/DataBufferHeap.h"
@@ -35,19 +34,20 @@
#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/DataFormatters/ValueObjectPrinter.h"
-#include "lldb/Expression/ClangExpressionVariable.h"
-#include "lldb/Expression/ClangPersistentVariables.h"
+#include "Plugins/ExpressionParser/Clang/ClangExpressionVariable.h"
+#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
#include "lldb/Host/Endian.h"
#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Type.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"
@@ -97,6 +97,7 @@ ValueObject::ValueObject (ValueObject &parent) :
m_address_type_of_ptr_or_ref_children(eAddressTypeInvalid),
m_value_checksum(),
m_preferred_display_language(lldb::eLanguageTypeUnknown),
+ m_language_flags(0),
m_value_is_valid (false),
m_value_did_change (false),
m_children_count_valid (false),
@@ -148,6 +149,7 @@ ValueObject::ValueObject (ExecutionContextScope *exe_scope,
m_address_type_of_ptr_or_ref_children(child_ptr_or_ref_addr_type),
m_value_checksum(),
m_preferred_display_language(lldb::eLanguageTypeUnknown),
+ m_language_flags(0),
m_value_is_valid (false),
m_value_did_change (false),
m_children_count_valid (false),
@@ -276,7 +278,7 @@ ValueObject::UpdateValueIfNeeded (bool update_format)
bool
ValueObject::UpdateFormatsIfNeeded()
{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_DATAFORMATTERS));
if (log)
log->Printf("[%s %p] checking for FormatManager revisions. ValueObject rev: %d - Global rev: %d",
GetName().GetCString(), static_cast<void*>(this),
@@ -316,39 +318,39 @@ ValueObject::ClearDynamicTypeInformation ()
m_children_count_valid = false;
m_did_calculate_complete_objc_class_type = false;
m_last_format_mgr_revision = 0;
- m_override_type = ClangASTType();
+ m_override_type = CompilerType();
SetValueFormat(lldb::TypeFormatImplSP());
SetSummaryFormat(lldb::TypeSummaryImplSP());
SetSyntheticChildren(lldb::SyntheticChildrenSP());
}
-ClangASTType
+CompilerType
ValueObject::MaybeCalculateCompleteType ()
{
- ClangASTType clang_type(GetClangTypeImpl());
+ CompilerType compiler_type(GetCompilerTypeImpl());
if (m_did_calculate_complete_objc_class_type)
{
if (m_override_type.IsValid())
return m_override_type;
else
- return clang_type;
+ return compiler_type;
}
- ClangASTType class_type;
+ CompilerType class_type;
bool is_pointer_type = false;
- if (clang_type.IsObjCObjectPointerType(&class_type))
+ if (ClangASTContext::IsObjCObjectPointerType(compiler_type, &class_type))
{
is_pointer_type = true;
}
- else if (clang_type.IsObjCObjectOrInterfaceType())
+ else if (ClangASTContext::IsObjCObjectOrInterfaceType(compiler_type))
{
- class_type = clang_type;
+ class_type = compiler_type;
}
else
{
- return clang_type;
+ return compiler_type;
}
m_did_calculate_complete_objc_class_type = true;
@@ -371,7 +373,7 @@ ValueObject::MaybeCalculateCompleteType ()
if (complete_objc_class_type_sp)
{
- ClangASTType complete_class(complete_objc_class_type_sp->GetClangFullType());
+ CompilerType complete_class(complete_objc_class_type_sp->GetFullCompilerType ());
if (complete_class.GetCompleteType())
{
@@ -392,11 +394,11 @@ ValueObject::MaybeCalculateCompleteType ()
}
}
}
- return clang_type;
+ return compiler_type;
}
-ClangASTType
-ValueObject::GetClangType ()
+CompilerType
+ValueObject::GetCompilerType ()
{
return MaybeCalculateCompleteType();
}
@@ -404,7 +406,7 @@ ValueObject::GetClangType ()
TypeImpl
ValueObject::GetTypeImpl ()
{
- return TypeImpl(GetClangType());
+ return TypeImpl(GetCompilerType());
}
DataExtractor &
@@ -514,6 +516,39 @@ ValueObject::ResolveValue (Scalar &scalar)
}
bool
+ValueObject::IsLogicalTrue (Error& error)
+{
+ if (Language *language = Language::FindPlugin(GetObjectRuntimeLanguage()))
+ {
+ LazyBool is_logical_true = language->IsLogicalTrue(*this, error);
+ switch (is_logical_true)
+ {
+ case eLazyBoolYes:
+ case eLazyBoolNo:
+ return (is_logical_true == true);
+ case eLazyBoolCalculate:
+ break;
+ }
+ }
+
+ Scalar scalar_value;
+
+ if (!ResolveValue (scalar_value))
+ {
+ error.SetErrorString("failed to get a scalar result");
+ return false;
+ }
+
+ bool ret;
+ if (scalar_value.ULongLong(1) == 0)
+ ret = false;
+ else
+ ret = true;
+ error.Clear();
+ return ret;
+}
+
+bool
ValueObject::GetValueIsValid () const
{
return m_value_is_valid;
@@ -566,40 +601,16 @@ ValueObjectSP
ValueObject::GetChildAtIndexPath (const std::initializer_list<size_t>& idxs,
size_t* index_of_error)
{
- if (idxs.size() == 0)
- return GetSP();
- ValueObjectSP root(GetSP());
- for (size_t idx : idxs)
- {
- root = root->GetChildAtIndex(idx, true);
- if (!root)
- {
- if (index_of_error)
- *index_of_error = idx;
- return root;
- }
- }
- return root;
+ return GetChildAtIndexPath( std::vector<size_t>(idxs),
+ index_of_error );
}
ValueObjectSP
ValueObject::GetChildAtIndexPath (const std::initializer_list< std::pair<size_t, bool> >& idxs,
size_t* index_of_error)
{
- if (idxs.size() == 0)
- return GetSP();
- ValueObjectSP root(GetSP());
- for (std::pair<size_t, bool> idx : idxs)
- {
- root = root->GetChildAtIndex(idx.first, idx.second);
- if (!root)
- {
- if (index_of_error)
- *index_of_error = idx.first;
- return root;
- }
- }
- return root;
+ return GetChildAtIndexPath( std::vector<std::pair<size_t,bool>>(idxs),
+ index_of_error );
}
lldb::ValueObjectSP
@@ -646,20 +657,16 @@ lldb::ValueObjectSP
ValueObject::GetChildAtNamePath (const std::initializer_list<ConstString> &names,
ConstString* name_of_error)
{
- if (names.size() == 0)
- return GetSP();
- ValueObjectSP root(GetSP());
- for (ConstString name : names)
- {
- root = root->GetChildMemberWithName(name, true);
- if (!root)
- {
- if (name_of_error)
- *name_of_error = name;
- return root;
- }
- }
- return root;
+ return GetChildAtNamePath( std::vector<ConstString>(names),
+ name_of_error );
+}
+
+lldb::ValueObjectSP
+ValueObject::GetChildAtNamePath (const std::initializer_list< std::pair<ConstString, bool> > &names,
+ ConstString* name_of_error)
+{
+ return GetChildAtNamePath( std::vector<std::pair<ConstString,bool>>(names),
+ name_of_error );
}
lldb::ValueObjectSP
@@ -683,7 +690,7 @@ ValueObject::GetChildAtNamePath (const std::vector<ConstString> &names,
}
lldb::ValueObjectSP
-ValueObject::GetChildAtNamePath (const std::initializer_list< std::pair<ConstString, bool> > &names,
+ValueObject::GetChildAtNamePath (const std::vector< std::pair<ConstString, bool> > &names,
ConstString* name_of_error)
{
if (names.size() == 0)
@@ -696,37 +703,17 @@ ValueObject::GetChildAtNamePath (const std::initializer_list< std::pair<ConstStr
{
if (name_of_error)
*name_of_error = name.first;
- return root;
+ return root;
}
}
return root;
}
-lldb::ValueObjectSP
-ValueObject::GetChildAtNamePath (const std::vector< std::pair<ConstString, bool> > &names,
- ConstString* name_of_error)
-{
- if (names.size() == 0)
- return GetSP();
- ValueObjectSP root(GetSP());
- for (std::pair<ConstString, bool> name : names)
- {
- root = root->GetChildMemberWithName(name.first, name.second);
- if (!root)
- {
- if (name_of_error)
- *name_of_error = name.first;
- return root;
- }
- }
- return root;
-}
-
size_t
ValueObject::GetIndexOfChildWithName (const ConstString &name)
{
bool omit_empty_base_classes = true;
- return GetClangType().GetIndexOfChildWithName (name.GetCString(), omit_empty_base_classes);
+ return GetCompilerType().GetIndexOfChildWithName (name.GetCString(), omit_empty_base_classes);
}
ValueObjectSP
@@ -743,7 +730,7 @@ ValueObject::GetChildMemberWithName (const ConstString &name, bool can_create)
std::vector<uint32_t> child_indexes;
bool omit_empty_base_classes = true;
- const size_t num_child_indexes = GetClangType().GetIndexOfChildMemberWithName (name.GetCString(),
+ const size_t num_child_indexes = GetCompilerType().GetIndexOfChildMemberWithName (name.GetCString(),
omit_empty_base_classes,
child_indexes);
if (num_child_indexes > 0)
@@ -771,9 +758,21 @@ ValueObject::GetChildMemberWithName (const ConstString &name, bool can_create)
size_t
-ValueObject::GetNumChildren ()
+ValueObject::GetNumChildren (uint32_t max)
{
UpdateValueIfNeeded();
+
+ if (max < UINT32_MAX)
+ {
+ if (m_children_count_valid)
+ {
+ size_t children_count = m_children.GetChildrenCount();
+ return children_count <= max ? children_count : max;
+ }
+ else
+ return CalculateNumChildren(max);
+ }
+
if (!m_children_count_valid)
{
SetNumChildren (CalculateNumChildren());
@@ -828,26 +827,28 @@ ValueObject::CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_
uint32_t child_bitfield_bit_offset = 0;
bool child_is_base_class = false;
bool child_is_deref_of_parent = false;
+ uint64_t language_flags = 0;
const bool transparent_pointers = synthetic_array_member == false;
- ClangASTType child_clang_type;
+ CompilerType child_compiler_type;
ExecutionContext exe_ctx (GetExecutionContextRef());
- child_clang_type = GetClangType().GetChildClangTypeAtIndex (&exe_ctx,
- idx,
- transparent_pointers,
- omit_empty_base_classes,
- ignore_array_bounds,
- child_name_str,
- child_byte_size,
- child_byte_offset,
- child_bitfield_bit_size,
- child_bitfield_bit_offset,
- child_is_base_class,
- child_is_deref_of_parent,
- this);
- if (child_clang_type)
+ child_compiler_type = GetCompilerType().GetChildCompilerTypeAtIndex (&exe_ctx,
+ idx,
+ transparent_pointers,
+ omit_empty_base_classes,
+ ignore_array_bounds,
+ child_name_str,
+ child_byte_size,
+ child_byte_offset,
+ child_bitfield_bit_size,
+ child_bitfield_bit_offset,
+ child_is_base_class,
+ child_is_deref_of_parent,
+ this,
+ language_flags);
+ if (child_compiler_type)
{
if (synthetic_index)
child_byte_offset += child_byte_size * synthetic_index;
@@ -857,7 +858,7 @@ ValueObject::CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_
child_name.SetCString (child_name_str.c_str());
valobj = new ValueObjectChild (*this,
- child_clang_type,
+ child_compiler_type,
child_name,
child_byte_size,
child_byte_offset,
@@ -865,7 +866,8 @@ ValueObject::CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_
child_bitfield_bit_offset,
child_is_base_class,
child_is_deref_of_parent,
- eAddressTypeInvalid);
+ eAddressTypeInvalid,
+ language_flags);
//if (valobj)
// valobj->SetAddressTypeOfChildren(eAddressTypeInvalid);
}
@@ -875,9 +877,10 @@ ValueObject::CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_
bool
ValueObject::GetSummaryAsCString (TypeSummaryImpl* summary_ptr,
- std::string& destination)
+ std::string& destination,
+ lldb::LanguageType lang)
{
- return GetSummaryAsCString(summary_ptr, destination, TypeSummaryOptions());
+ return GetSummaryAsCString(summary_ptr, destination, TypeSummaryOptions().SetLanguage(lang));
}
bool
@@ -886,7 +889,7 @@ ValueObject::GetSummaryAsCString (TypeSummaryImpl* summary_ptr,
const TypeSummaryOptions& options)
{
destination.clear();
-
+
// ideally we would like to bail out if passing NULL, but if we do so
// we end up not providing the summary for function pointers anymore
if (/*summary_ptr == NULL ||*/ m_is_getting_summary)
@@ -894,31 +897,38 @@ ValueObject::GetSummaryAsCString (TypeSummaryImpl* summary_ptr,
m_is_getting_summary = true;
+ TypeSummaryOptions actual_options(options);
+
+ if (actual_options.GetLanguage() == lldb::eLanguageTypeUnknown)
+ actual_options.SetLanguage(GetPreferredDisplayLanguage());
+
// this is a hot path in code and we prefer to avoid setting this string all too often also clearing out other
// information that we might care to see in a crash log. might be useful in very specific situations though.
/*Host::SetCrashDescriptionWithFormat("Trying to fetch a summary for %s %s. Summary provider's description is %s",
- GetTypeName().GetCString(),
- GetName().GetCString(),
- summary_ptr->GetDescription().c_str());*/
+ GetTypeName().GetCString(),
+ GetName().GetCString(),
+ summary_ptr->GetDescription().c_str());*/
if (UpdateValueIfNeeded (false) && summary_ptr)
{
if (HasSyntheticValue())
m_synthetic_value->UpdateValueIfNeeded(); // the summary might depend on the synthetic children being up-to-date (e.g. ${svar%#})
- summary_ptr->FormatObject(this, destination, options);
+ summary_ptr->FormatObject(this, destination, actual_options);
}
m_is_getting_summary = false;
return !destination.empty();
}
const char *
-ValueObject::GetSummaryAsCString ()
+ValueObject::GetSummaryAsCString (lldb::LanguageType lang)
{
if (UpdateValueIfNeeded(true) && m_summary_str.empty())
{
+ TypeSummaryOptions summary_options;
+ summary_options.SetLanguage(lang);
GetSummaryAsCString(GetSummaryFormat().get(),
m_summary_str,
- TypeSummaryOptions());
+ summary_options);
}
if (m_summary_str.empty())
return NULL;
@@ -930,17 +940,17 @@ ValueObject::GetSummaryAsCString (std::string& destination,
const TypeSummaryOptions& options)
{
return GetSummaryAsCString(GetSummaryFormat().get(),
- destination,
- options);
+ destination,
+ options);
}
bool
ValueObject::IsCStringContainer(bool check_pointer)
{
- ClangASTType pointee_or_element_clang_type;
- const Flags type_flags (GetTypeInfo (&pointee_or_element_clang_type));
+ CompilerType pointee_or_element_compiler_type;
+ const Flags type_flags (GetTypeInfo (&pointee_or_element_compiler_type));
bool is_char_arr_ptr (type_flags.AnySet (eTypeIsArray | eTypeIsPointer) &&
- pointee_or_element_clang_type.IsCharType ());
+ pointee_or_element_compiler_type.IsCharType ());
if (!is_char_arr_ptr)
return false;
if (!check_pointer)
@@ -958,8 +968,8 @@ ValueObject::GetPointeeData (DataExtractor& data,
uint32_t item_idx,
uint32_t item_count)
{
- ClangASTType pointee_or_element_clang_type;
- const uint32_t type_info = GetTypeInfo (&pointee_or_element_clang_type);
+ CompilerType pointee_or_element_compiler_type;
+ const uint32_t type_info = GetTypeInfo (&pointee_or_element_compiler_type);
const bool is_pointer_type = type_info & eTypeIsPointer;
const bool is_array_type = type_info & eTypeIsArray;
if (!(is_pointer_type || is_array_type))
@@ -970,7 +980,7 @@ ValueObject::GetPointeeData (DataExtractor& data,
ExecutionContext exe_ctx (GetExecutionContextRef());
- const uint64_t item_type_size = pointee_or_element_clang_type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
+ const uint64_t item_type_size = pointee_or_element_compiler_type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
const uint64_t bytes = item_count * item_type_size;
const uint64_t offset = item_idx * item_type_size;
@@ -1046,12 +1056,12 @@ ValueObject::GetPointeeData (DataExtractor& data,
break;
case eAddressTypeHost:
{
- const uint64_t max_bytes = GetClangType().GetByteSize(exe_ctx.GetBestExecutionContextScope());
+ const uint64_t max_bytes = GetCompilerType().GetByteSize(exe_ctx.GetBestExecutionContextScope());
if (max_bytes > offset)
{
size_t bytes_read = std::min<uint64_t>(max_bytes - offset, bytes);
addr = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
- if (addr == LLDB_INVALID_ADDRESS)
+ if (addr == 0 || addr == LLDB_INVALID_ADDRESS)
break;
heap_buf_ptr->CopyData((uint8_t*)(addr + offset), bytes_read);
data.SetData(data_sp);
@@ -1077,6 +1087,7 @@ ValueObject::GetData (DataExtractor& data, Error &error)
if (m_data.GetByteSize())
{
data = m_data;
+ error.Clear();
return data.GetByteSize();
}
else
@@ -1102,7 +1113,7 @@ ValueObject::SetData (DataExtractor &data, Error &error)
}
uint64_t count = 0;
- const Encoding encoding = GetClangType().GetEncoding(count);
+ const Encoding encoding = GetCompilerType().GetEncoding(count);
const size_t byte_size = GetByteSize();
@@ -1167,31 +1178,6 @@ ValueObject::SetData (DataExtractor &data, Error &error)
return true;
}
-// will compute strlen(str), but without consuming more than
-// maxlen bytes out of str (this serves the purpose of reading
-// chunks of a string without having to worry about
-// missing NULL terminators in the chunk)
-// of course, if strlen(str) > maxlen, the function will return
-// maxlen_value (which should be != maxlen, because that allows you
-// to know whether strlen(str) == maxlen or strlen(str) > maxlen)
-static uint32_t
-strlen_or_inf (const char* str,
- uint32_t maxlen,
- uint32_t maxlen_value)
-{
- uint32_t len = 0;
- if (str)
- {
- while(*str)
- {
- len++;str++;
- if (len >= maxlen)
- return maxlen_value;
- }
- }
- return len;
-}
-
static bool
CopyStringDataToBufferSP(const StreamString& source,
lldb::DataBufferSP& destination)
@@ -1201,13 +1187,14 @@ CopyStringDataToBufferSP(const StreamString& source,
return true;
}
-size_t
+std::pair<size_t,bool>
ValueObject::ReadPointedString (lldb::DataBufferSP& buffer_sp,
Error& error,
uint32_t max_length,
bool honor_array,
Format item_format)
{
+ bool was_capped = false;
StreamString s;
ExecutionContext exe_ctx (GetExecutionContextRef());
Target* target = exe_ctx.GetTargetPtr();
@@ -1217,7 +1204,7 @@ ValueObject::ReadPointedString (lldb::DataBufferSP& buffer_sp,
s << "<no target to read from>";
error.SetErrorString("no target to read from");
CopyStringDataToBufferSP(s, buffer_sp);
- return 0;
+ return {0,was_capped};
}
if (max_length == 0)
@@ -1226,11 +1213,11 @@ ValueObject::ReadPointedString (lldb::DataBufferSP& buffer_sp,
size_t bytes_read = 0;
size_t total_bytes_read = 0;
- ClangASTType clang_type = GetClangType();
- ClangASTType elem_or_pointee_clang_type;
- const Flags type_flags (GetTypeInfo (&elem_or_pointee_clang_type));
+ CompilerType compiler_type = GetCompilerType();
+ CompilerType elem_or_pointee_compiler_type;
+ const Flags type_flags (GetTypeInfo (&elem_or_pointee_compiler_type));
if (type_flags.AnySet (eTypeIsArray | eTypeIsPointer) &&
- elem_or_pointee_clang_type.IsCharType ())
+ elem_or_pointee_compiler_type.IsCharType ())
{
addr_t cstr_address = LLDB_INVALID_ADDRESS;
AddressType cstr_address_type = eAddressTypeInvalid;
@@ -1241,7 +1228,7 @@ ValueObject::ReadPointedString (lldb::DataBufferSP& buffer_sp,
{
// We have an array
uint64_t array_size = 0;
- if (clang_type.IsArrayType(NULL, &array_size, NULL))
+ if (compiler_type.IsArrayType(NULL, &array_size, NULL))
{
cstr_len = array_size;
if (cstr_len > max_length)
@@ -1263,7 +1250,7 @@ ValueObject::ReadPointedString (lldb::DataBufferSP& buffer_sp,
s << "<invalid address>";
error.SetErrorString("invalid address");
CopyStringDataToBufferSP(s, buffer_sp);
- return 0;
+ return {0,was_capped};
}
Address cstr_so_addr (cstr_address);
@@ -1280,7 +1267,7 @@ ValueObject::ReadPointedString (lldb::DataBufferSP& buffer_sp,
for (size_t offset = 0; offset < bytes_read; offset++)
s.Printf("%c", *data.PeekData(offset, 1));
if (capped_data)
- s << "...";
+ was_capped = true;
}
}
else
@@ -1298,10 +1285,7 @@ ValueObject::ReadPointedString (lldb::DataBufferSP& buffer_sp,
{
total_bytes_read += bytes_read;
const char *cstr = data.PeekCStr(0);
- size_t len = strlen_or_inf (cstr, k_max_buf_size, k_max_buf_size+1);
- if (len > k_max_buf_size)
- len = k_max_buf_size;
-
+ size_t len = strnlen (cstr, k_max_buf_size);
if (cstr_len_displayed < 0)
cstr_len_displayed = len;
@@ -1332,7 +1316,7 @@ ValueObject::ReadPointedString (lldb::DataBufferSP& buffer_sp,
if (cstr_len_displayed >= 0)
{
if (capped_cstr)
- s << "...";
+ was_capped = true;
}
}
}
@@ -1342,7 +1326,7 @@ ValueObject::ReadPointedString (lldb::DataBufferSP& buffer_sp,
s << "<not a string object>";
}
CopyStringDataToBufferSP(s, buffer_sp);
- return total_bytes_read;
+ return {total_bytes_read,was_capped};
}
std::pair<TypeValidatorResult, std::string>
@@ -1385,11 +1369,11 @@ ValueObject::GetObjectDescription ()
if (runtime == NULL)
{
// Aw, hell, if the things a pointer, or even just an integer, let's try ObjC anyway...
- ClangASTType clang_type = GetClangType();
- if (clang_type)
+ CompilerType compiler_type = GetCompilerType();
+ if (compiler_type)
{
bool is_signed;
- if (clang_type.IsIntegerType (is_signed) || clang_type.IsPointerType ())
+ if (compiler_type.IsIntegerType (is_signed) || compiler_type.IsPointerType ())
{
runtime = process->GetLanguageRuntime(eLanguageTypeObjC);
}
@@ -1449,7 +1433,7 @@ ValueObject::GetValueAsCString ()
}
else
{
- my_format = GetValue().GetClangType().GetFormat();
+ my_format = GetValue().GetCompilerType().GetFormat();
}
}
}
@@ -1590,18 +1574,19 @@ ValueObject::DumpPrintableRepresentation(Stream& s,
{
Error error;
lldb::DataBufferSP buffer_sp;
- ReadPointedString(buffer_sp,
- error,
- 0,
- (custom_format == eFormatVectorOfChar) ||
- (custom_format == eFormatCharArray));
- lldb_private::formatters::ReadBufferAndDumpToStreamOptions options(*this);
+ std::pair<size_t, bool> read_string = ReadPointedString(buffer_sp,
+ error,
+ 0,
+ (custom_format == eFormatVectorOfChar) ||
+ (custom_format == eFormatCharArray));
+ lldb_private::formatters::StringPrinter::ReadBufferAndDumpToStreamOptions options(*this);
options.SetData(DataExtractor(buffer_sp, lldb::eByteOrderInvalid, 8)); // none of this matters for a string - pass some defaults
options.SetStream(&s);
options.SetPrefixToken(0);
options.SetQuote('"');
options.SetSourceSize(buffer_sp->GetByteSize());
- lldb_private::formatters::ReadBufferAndDumpToStream<lldb_private::formatters::StringElementType::ASCII>(options);
+ options.SetIsTruncated(read_string.second);
+ formatters::StringPrinter::ReadBufferAndDumpToStream<lldb_private::formatters::StringPrinter::StringElementType::ASCII>(options);
return !error.Fail();
}
@@ -1886,7 +1871,7 @@ ValueObject::SetValueFromCString (const char *value_str, Error& error)
}
uint64_t count = 0;
- const Encoding encoding = GetClangType().GetEncoding (count);
+ const Encoding encoding = GetCompilerType().GetEncoding (count);
const size_t byte_size = GetByteSize();
@@ -1897,7 +1882,7 @@ ValueObject::SetValueFromCString (const char *value_str, Error& error)
// If the value is already a scalar, then let the scalar change itself:
m_value.GetScalar().SetValueFromCString (value_str, encoding, byte_size);
}
- else if (byte_size <= Scalar::GetMaxByteSize())
+ else if (byte_size <= 16)
{
// If the value fits in a scalar, then make a new scalar and again let the
// scalar code do the conversion, then figure out where to put the new value.
@@ -1984,7 +1969,7 @@ ValueObject::GetDeclaration (Declaration &decl)
ConstString
ValueObject::GetTypeName()
{
- return GetClangType().GetConstTypeName();
+ return GetCompilerType().GetConstTypeName();
}
ConstString
@@ -1996,14 +1981,14 @@ ValueObject::GetDisplayTypeName()
ConstString
ValueObject::GetQualifiedTypeName()
{
- return GetClangType().GetConstQualifiedTypeName();
+ return GetCompilerType().GetConstQualifiedTypeName();
}
LanguageType
ValueObject::GetObjectRuntimeLanguage ()
{
- return GetClangType().GetMinimumLanguage ();
+ return GetCompilerType().GetMinimumLanguage ();
}
void
@@ -2023,39 +2008,39 @@ ValueObject::GetSyntheticChild (const ConstString &key) const
}
uint32_t
-ValueObject::GetTypeInfo (ClangASTType *pointee_or_element_clang_type)
+ValueObject::GetTypeInfo (CompilerType *pointee_or_element_compiler_type)
{
- return GetClangType().GetTypeInfo (pointee_or_element_clang_type);
+ return GetCompilerType().GetTypeInfo (pointee_or_element_compiler_type);
}
bool
ValueObject::IsPointerType ()
{
- return GetClangType().IsPointerType();
+ return GetCompilerType().IsPointerType();
}
bool
ValueObject::IsArrayType ()
{
- return GetClangType().IsArrayType (NULL, NULL, NULL);
+ return GetCompilerType().IsArrayType (NULL, NULL, NULL);
}
bool
ValueObject::IsScalarType ()
{
- return GetClangType().IsScalarType ();
+ return GetCompilerType().IsScalarType ();
}
bool
ValueObject::IsIntegerType (bool &is_signed)
{
- return GetClangType().IsIntegerType (is_signed);
+ return GetCompilerType().IsIntegerType (is_signed);
}
bool
ValueObject::IsPointerOrReferenceType ()
{
- return GetClangType().IsPointerOrReferenceType ();
+ return GetCompilerType().IsPointerOrReferenceType ();
}
bool
@@ -2066,7 +2051,7 @@ ValueObject::IsPossibleDynamicType ()
if (process)
return process->IsPossibleDynamicValue(*this);
else
- return GetClangType().IsPossibleDynamicType (NULL, true, true);
+ return GetCompilerType().IsPossibleDynamicType (NULL, true, true);
}
bool
@@ -2085,15 +2070,23 @@ ValueObject::IsRuntimeSupportValue ()
}
bool
-ValueObject::IsObjCNil ()
+ValueObject::IsNilReference ()
{
- const uint32_t mask = eTypeIsObjC | eTypeIsPointer;
- bool isObjCpointer = (((GetClangType().GetTypeInfo(NULL)) & mask) == mask);
- if (!isObjCpointer)
- return false;
- bool canReadValue = true;
- bool isZero = GetValueAsUnsigned(0,&canReadValue) == 0;
- return canReadValue && isZero;
+ if (Language *language = Language::FindPlugin(GetObjectRuntimeLanguage()))
+ {
+ return language->IsNilReference(*this);
+ }
+ return false;
+}
+
+bool
+ValueObject::IsUninitializedReference ()
+{
+ if (Language *language = Language::FindPlugin(GetObjectRuntimeLanguage()))
+ {
+ return language->IsUninitializedReference(*this);
+ }
+ return false;
}
// This allows you to create an array member using and index
@@ -2156,7 +2149,7 @@ ValueObject::GetSyntheticBitFieldChild (uint32_t from, uint32_t to, bool can_cre
// We haven't made a synthetic array member for INDEX yet, so
// lets make one and cache it for any future reference.
ValueObjectChild *synthetic_child = new ValueObjectChild (*this,
- GetClangType(),
+ GetCompilerType(),
index_const_str,
GetByteSize(),
0,
@@ -2164,7 +2157,8 @@ ValueObject::GetSyntheticBitFieldChild (uint32_t from, uint32_t to, bool can_cre
from,
false,
false,
- eAddressTypeInvalid);
+ eAddressTypeInvalid,
+ 0);
// Cache the value if we got one back...
if (synthetic_child)
@@ -2180,7 +2174,7 @@ ValueObject::GetSyntheticBitFieldChild (uint32_t from, uint32_t to, bool can_cre
}
ValueObjectSP
-ValueObject::GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create)
+ValueObject::GetSyntheticChildAtOffset(uint32_t offset, const CompilerType& type, bool can_create)
{
ValueObjectSP synthetic_child_sp;
@@ -2210,7 +2204,8 @@ ValueObject::GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type
0,
false,
false,
- eAddressTypeInvalid);
+ eAddressTypeInvalid,
+ 0);
if (synthetic_child)
{
AddSyntheticChild(name_const_str, synthetic_child);
@@ -2222,7 +2217,7 @@ ValueObject::GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type
}
ValueObjectSP
-ValueObject::GetSyntheticBase (uint32_t offset, const ClangASTType& type, bool can_create)
+ValueObject::GetSyntheticBase (uint32_t offset, const CompilerType& type, bool can_create)
{
ValueObjectSP synthetic_child_sp;
@@ -2253,7 +2248,8 @@ ValueObject::GetSyntheticBase (uint32_t offset, const ClangASTType& type, bool c
0,
is_base_class,
false,
- eAddressTypeInvalid);
+ eAddressTypeInvalid,
+ 0);
if (synthetic_child)
{
AddSyntheticChild(name_const_str, synthetic_child);
@@ -2417,9 +2413,9 @@ ValueObject::GetBaseClassPath (Stream &s)
if (IsBaseClass())
{
bool parent_had_base_class = GetParent() && GetParent()->GetBaseClassPath (s);
- ClangASTType clang_type = GetClangType();
+ CompilerType compiler_type = GetCompilerType();
std::string cxx_class_name;
- bool this_had_base_class = clang_type.GetCXXClassName (cxx_class_name);
+ bool this_had_base_class = ClangASTContext::GetCXXClassName (compiler_type, cxx_class_name);
if (this_had_base_class)
{
if (parent_had_base_class)
@@ -2536,8 +2532,8 @@ ValueObject::GetExpressionPath (Stream &s, bool qualify_cxx_base_classes, GetExp
ValueObject *non_base_class_parent = GetNonBaseClassParent();
if (non_base_class_parent)
{
- ClangASTType non_base_class_parent_clang_type = non_base_class_parent->GetClangType();
- if (non_base_class_parent_clang_type)
+ CompilerType non_base_class_parent_compiler_type = non_base_class_parent->GetCompilerType();
+ if (non_base_class_parent_compiler_type)
{
if (parent && parent->IsDereferenceOfParent() && epformat == eGetExpressionPathFormatHonorPointers)
{
@@ -2545,7 +2541,7 @@ ValueObject::GetExpressionPath (Stream &s, bool qualify_cxx_base_classes, GetExp
}
else
{
- const uint32_t non_base_class_parent_type_info = non_base_class_parent_clang_type.GetTypeInfo();
+ const uint32_t non_base_class_parent_type_info = non_base_class_parent_compiler_type.GetTypeInfo();
if (non_base_class_parent_type_info & eTypeIsPointer)
{
@@ -2757,13 +2753,13 @@ ValueObject::GetValueForExpressionPath_Impl(const char* expression_cstr,
const char* expression_cstr = *first_unparsed; // hide the top level expression_cstr
- ClangASTType root_clang_type = root->GetClangType();
- ClangASTType pointee_clang_type;
- Flags pointee_clang_type_info;
+ CompilerType root_compiler_type = root->GetCompilerType();
+ CompilerType pointee_compiler_type;
+ Flags pointee_compiler_type_info;
- Flags root_clang_type_info(root_clang_type.GetTypeInfo(&pointee_clang_type));
- if (pointee_clang_type)
- pointee_clang_type_info.Reset(pointee_clang_type.GetTypeInfo());
+ Flags root_compiler_type_info(root_compiler_type.GetTypeInfo(&pointee_compiler_type));
+ if (pointee_compiler_type)
+ pointee_compiler_type_info.Reset(pointee_compiler_type.GetTypeInfo());
if (!expression_cstr || *expression_cstr == '\0')
{
@@ -2776,15 +2772,15 @@ ValueObject::GetValueForExpressionPath_Impl(const char* expression_cstr,
case '-':
{
if (options.m_check_dot_vs_arrow_syntax &&
- root_clang_type_info.Test(eTypeIsPointer) ) // if you are trying to use -> on a non-pointer and I must catch the error
+ root_compiler_type_info.Test(eTypeIsPointer) ) // if you are trying to use -> on a non-pointer and I must catch the error
{
*first_unparsed = expression_cstr;
*reason_to_stop = ValueObject::eExpressionPathScanEndReasonArrowInsteadOfDot;
*final_result = ValueObject::eExpressionPathEndResultTypeInvalid;
return ValueObjectSP();
}
- if (root_clang_type_info.Test(eTypeIsObjC) && // if yo are trying to extract an ObjC IVar when this is forbidden
- root_clang_type_info.Test(eTypeIsPointer) &&
+ if (root_compiler_type_info.Test(eTypeIsObjC) && // if yo are trying to extract an ObjC IVar when this is forbidden
+ root_compiler_type_info.Test(eTypeIsPointer) &&
options.m_no_fragile_ivar)
{
*first_unparsed = expression_cstr;
@@ -2804,7 +2800,7 @@ ValueObject::GetValueForExpressionPath_Impl(const char* expression_cstr,
case '.': // or fallthrough from ->
{
if (options.m_check_dot_vs_arrow_syntax && *expression_cstr == '.' &&
- root_clang_type_info.Test(eTypeIsPointer)) // if you are trying to use . on a pointer and I must catch the error
+ root_compiler_type_info.Test(eTypeIsPointer)) // if you are trying to use . on a pointer and I must catch the error
{
*first_unparsed = expression_cstr;
*reason_to_stop = ValueObject::eExpressionPathScanEndReasonDotInsteadOfArrow;
@@ -2953,9 +2949,9 @@ ValueObject::GetValueForExpressionPath_Impl(const char* expression_cstr,
}
case '[':
{
- if (!root_clang_type_info.Test(eTypeIsArray) && !root_clang_type_info.Test(eTypeIsPointer) && !root_clang_type_info.Test(eTypeIsVector)) // if this is not a T[] nor a T*
+ if (!root_compiler_type_info.Test(eTypeIsArray) && !root_compiler_type_info.Test(eTypeIsPointer) && !root_compiler_type_info.Test(eTypeIsVector)) // if this is not a T[] nor a T*
{
- if (!root_clang_type_info.Test(eTypeIsScalar)) // if this is not even a scalar...
+ if (!root_compiler_type_info.Test(eTypeIsScalar)) // if this is not even a scalar...
{
if (options.m_synthetic_children_traversal == GetValueForExpressionPathOptions::SyntheticChildrenTraversal::None) // ...only chance left is synthetic
{
@@ -2975,7 +2971,7 @@ ValueObject::GetValueForExpressionPath_Impl(const char* expression_cstr,
}
if (*(expression_cstr+1) == ']') // if this is an unbounded range it only works for arrays
{
- if (!root_clang_type_info.Test(eTypeIsArray))
+ if (!root_compiler_type_info.Test(eTypeIsArray))
{
*first_unparsed = expression_cstr;
*reason_to_stop = ValueObject::eExpressionPathScanEndReasonEmptyRangeNotAllowed;
@@ -3012,7 +3008,7 @@ ValueObject::GetValueForExpressionPath_Impl(const char* expression_cstr,
}
if (end - expression_cstr == 1) // if this is [], only return a valid value for arrays
{
- if (root_clang_type_info.Test(eTypeIsArray))
+ if (root_compiler_type_info.Test(eTypeIsArray))
{
*first_unparsed = expression_cstr+2;
*reason_to_stop = ValueObject::eExpressionPathScanEndReasonArrayRangeOperatorMet;
@@ -3028,7 +3024,7 @@ ValueObject::GetValueForExpressionPath_Impl(const char* expression_cstr,
}
}
// from here on we do have a valid index
- if (root_clang_type_info.Test(eTypeIsArray))
+ if (root_compiler_type_info.Test(eTypeIsArray))
{
ValueObjectSP child_valobj_sp = root->GetChildAtIndex(index, true);
if (!child_valobj_sp)
@@ -3051,10 +3047,10 @@ ValueObject::GetValueForExpressionPath_Impl(const char* expression_cstr,
return ValueObjectSP();
}
}
- else if (root_clang_type_info.Test(eTypeIsPointer))
+ else if (root_compiler_type_info.Test(eTypeIsPointer))
{
if (*what_next == ValueObject::eExpressionPathAftermathDereference && // if this is a ptr-to-scalar, I am accessing it by index and I would have deref'ed anyway, then do it now and use this as a bitfield
- pointee_clang_type_info.Test(eTypeIsScalar))
+ pointee_compiler_type_info.Test(eTypeIsScalar))
{
Error error;
root = root->Dereference(error);
@@ -3073,8 +3069,8 @@ ValueObject::GetValueForExpressionPath_Impl(const char* expression_cstr,
}
else
{
- if (root->GetClangType().GetMinimumLanguage() == eLanguageTypeObjC
- && pointee_clang_type_info.AllClear(eTypeIsPointer)
+ if (root->GetCompilerType().GetMinimumLanguage() == eLanguageTypeObjC
+ && pointee_compiler_type_info.AllClear(eTypeIsPointer)
&& root->HasSyntheticValue()
&& (options.m_synthetic_children_traversal == GetValueForExpressionPathOptions::SyntheticChildrenTraversal::ToSynthetic ||
options.m_synthetic_children_traversal == GetValueForExpressionPathOptions::SyntheticChildrenTraversal::Both))
@@ -3098,7 +3094,7 @@ ValueObject::GetValueForExpressionPath_Impl(const char* expression_cstr,
}
}
}
- else if (root_clang_type_info.Test(eTypeIsScalar))
+ else if (root_compiler_type_info.Test(eTypeIsScalar))
{
root = root->GetSyntheticBitFieldChild(index, index, true);
if (!root.get())
@@ -3116,7 +3112,7 @@ ValueObject::GetValueForExpressionPath_Impl(const char* expression_cstr,
return root;
}
}
- else if (root_clang_type_info.Test(eTypeIsVector))
+ else if (root_compiler_type_info.Test(eTypeIsVector))
{
root = root->GetChildAtIndex(index, true);
if (!root.get())
@@ -3202,7 +3198,7 @@ ValueObject::GetValueForExpressionPath_Impl(const char* expression_cstr,
index_lower = index_higher;
index_higher = temp;
}
- if (root_clang_type_info.Test(eTypeIsScalar)) // expansion only works for scalars
+ if (root_compiler_type_info.Test(eTypeIsScalar)) // expansion only works for scalars
{
root = root->GetSyntheticBitFieldChild(index_lower, index_higher, true);
if (!root.get())
@@ -3220,9 +3216,9 @@ ValueObject::GetValueForExpressionPath_Impl(const char* expression_cstr,
return root;
}
}
- else if (root_clang_type_info.Test(eTypeIsPointer) && // if this is a ptr-to-scalar, I am accessing it by index and I would have deref'ed anyway, then do it now and use this as a bitfield
+ else if (root_compiler_type_info.Test(eTypeIsPointer) && // if this is a ptr-to-scalar, I am accessing it by index and I would have deref'ed anyway, then do it now and use this as a bitfield
*what_next == ValueObject::eExpressionPathAftermathDereference &&
- pointee_clang_type_info.Test(eTypeIsScalar))
+ pointee_compiler_type_info.Test(eTypeIsScalar))
{
Error error;
root = root->Dereference(error);
@@ -3281,12 +3277,12 @@ ValueObject::ExpandArraySliceExpression(const char* expression_cstr,
const char* expression_cstr = *first_unparsed; // hide the top level expression_cstr
- ClangASTType root_clang_type = root->GetClangType();
- ClangASTType pointee_clang_type;
- Flags pointee_clang_type_info;
- Flags root_clang_type_info(root_clang_type.GetTypeInfo(&pointee_clang_type));
- if (pointee_clang_type)
- pointee_clang_type_info.Reset(pointee_clang_type.GetTypeInfo());
+ CompilerType root_compiler_type = root->GetCompilerType();
+ CompilerType pointee_compiler_type;
+ Flags pointee_compiler_type_info;
+ Flags root_compiler_type_info(root_compiler_type.GetTypeInfo(&pointee_compiler_type));
+ if (pointee_compiler_type)
+ pointee_compiler_type_info.Reset(pointee_compiler_type.GetTypeInfo());
if (!expression_cstr || *expression_cstr == '\0')
{
@@ -3299,9 +3295,9 @@ ValueObject::ExpandArraySliceExpression(const char* expression_cstr,
{
case '[':
{
- if (!root_clang_type_info.Test(eTypeIsArray) && !root_clang_type_info.Test(eTypeIsPointer)) // if this is not a T[] nor a T*
+ if (!root_compiler_type_info.Test(eTypeIsArray) && !root_compiler_type_info.Test(eTypeIsPointer)) // if this is not a T[] nor a T*
{
- if (!root_clang_type_info.Test(eTypeIsScalar)) // if this is not even a scalar, this syntax is just plain wrong!
+ if (!root_compiler_type_info.Test(eTypeIsScalar)) // if this is not even a scalar, this syntax is just plain wrong!
{
*first_unparsed = expression_cstr;
*reason_to_stop = ValueObject::eExpressionPathScanEndReasonRangeOperatorInvalid;
@@ -3318,7 +3314,7 @@ ValueObject::ExpandArraySliceExpression(const char* expression_cstr,
}
if (*(expression_cstr+1) == ']') // if this is an unbounded range it only works for arrays
{
- if (!root_clang_type_info.Test(eTypeIsArray))
+ if (!root_compiler_type_info.Test(eTypeIsArray))
{
*first_unparsed = expression_cstr;
*reason_to_stop = ValueObject::eExpressionPathScanEndReasonEmptyRangeNotAllowed;
@@ -3362,7 +3358,7 @@ ValueObject::ExpandArraySliceExpression(const char* expression_cstr,
}
if (end - expression_cstr == 1) // if this is [], only return a valid value for arrays
{
- if (root_clang_type_info.Test(eTypeIsArray))
+ if (root_compiler_type_info.Test(eTypeIsArray))
{
const size_t max_index = root->GetNumChildren() - 1;
for (size_t index = 0; index < max_index; index++)
@@ -3385,7 +3381,7 @@ ValueObject::ExpandArraySliceExpression(const char* expression_cstr,
}
}
// from here on we do have a valid index
- if (root_clang_type_info.Test(eTypeIsArray))
+ if (root_compiler_type_info.Test(eTypeIsArray))
{
root = root->GetChildAtIndex(index, true);
if (!root.get())
@@ -3404,10 +3400,10 @@ ValueObject::ExpandArraySliceExpression(const char* expression_cstr,
return 1;
}
}
- else if (root_clang_type_info.Test(eTypeIsPointer))
+ else if (root_compiler_type_info.Test(eTypeIsPointer))
{
if (*what_next == ValueObject::eExpressionPathAftermathDereference && // if this is a ptr-to-scalar, I am accessing it by index and I would have deref'ed anyway, then do it now and use this as a bitfield
- pointee_clang_type_info.Test(eTypeIsScalar))
+ pointee_compiler_type_info.Test(eTypeIsScalar))
{
Error error;
root = root->Dereference(error);
@@ -3444,7 +3440,7 @@ ValueObject::ExpandArraySliceExpression(const char* expression_cstr,
}
}
}
- else /*if (ClangASTContext::IsScalarType(root_clang_type))*/
+ else /*if (ClangASTContext::IsScalarType(root_compiler_type))*/
{
root = root->GetSyntheticBitFieldChild(index, index, true);
if (!root.get())
@@ -3489,7 +3485,7 @@ ValueObject::ExpandArraySliceExpression(const char* expression_cstr,
index_lower = index_higher;
index_higher = temp;
}
- if (root_clang_type_info.Test(eTypeIsScalar)) // expansion only works for scalars
+ if (root_compiler_type_info.Test(eTypeIsScalar)) // expansion only works for scalars
{
root = root->GetSyntheticBitFieldChild(index_lower, index_higher, true);
if (!root.get())
@@ -3508,9 +3504,9 @@ ValueObject::ExpandArraySliceExpression(const char* expression_cstr,
return 1;
}
}
- else if (root_clang_type_info.Test(eTypeIsPointer) && // if this is a ptr-to-scalar, I am accessing it by index and I would have deref'ed anyway, then do it now and use this as a bitfield
+ else if (root_compiler_type_info.Test(eTypeIsPointer) && // if this is a ptr-to-scalar, I am accessing it by index and I would have deref'ed anyway, then do it now and use this as a bitfield
*what_next == ValueObject::eExpressionPathAftermathDereference &&
- pointee_clang_type_info.Test(eTypeIsScalar))
+ pointee_compiler_type_info.Test(eTypeIsScalar))
{
Error error;
root = root->Dereference(error);
@@ -3611,7 +3607,7 @@ ValueObject::CreateConstantValue (const ConstString &name)
m_error = m_value.GetValueAsData (&exe_ctx, data, 0, GetModule().get());
valobj_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
- GetClangType(),
+ GetCompilerType(),
name,
data,
GetAddressOf());
@@ -3677,8 +3673,8 @@ ValueObject::GetQualifiedRepresentationIfAvailable (lldb::DynamicValueType dynVa
lldb::addr_t
ValueObject::GetCPPVTableAddress (AddressType &address_type)
{
- ClangASTType pointee_type;
- ClangASTType this_type(GetClangType());
+ CompilerType pointee_type;
+ CompilerType this_type(GetCompilerType());
uint32_t type_info = this_type.GetTypeInfo(&pointee_type);
if (type_info)
{
@@ -3711,9 +3707,9 @@ ValueObject::Dereference (Error &error)
{
if (m_deref_valobj)
return m_deref_valobj->GetSP();
-
- const bool is_pointer_type = IsPointerType();
- if (is_pointer_type)
+
+ const bool is_pointer_or_reference_type = IsPointerOrReferenceType();
+ if (is_pointer_or_reference_type)
{
bool omit_empty_base_classes = true;
bool ignore_array_bounds = false;
@@ -3726,32 +3722,34 @@ ValueObject::Dereference (Error &error)
bool child_is_base_class = false;
bool child_is_deref_of_parent = false;
const bool transparent_pointers = false;
- ClangASTType clang_type = GetClangType();
- ClangASTType child_clang_type;
+ CompilerType compiler_type = GetCompilerType();
+ CompilerType child_compiler_type;
+ uint64_t language_flags;
ExecutionContext exe_ctx (GetExecutionContextRef());
-
- child_clang_type = clang_type.GetChildClangTypeAtIndex (&exe_ctx,
- 0,
- transparent_pointers,
- omit_empty_base_classes,
- ignore_array_bounds,
- child_name_str,
- child_byte_size,
- child_byte_offset,
- child_bitfield_bit_size,
- child_bitfield_bit_offset,
- child_is_base_class,
- child_is_deref_of_parent,
- this);
- if (child_clang_type && child_byte_size)
+
+ child_compiler_type = compiler_type.GetChildCompilerTypeAtIndex (&exe_ctx,
+ 0,
+ transparent_pointers,
+ omit_empty_base_classes,
+ ignore_array_bounds,
+ child_name_str,
+ child_byte_size,
+ child_byte_offset,
+ child_bitfield_bit_size,
+ child_bitfield_bit_offset,
+ child_is_base_class,
+ child_is_deref_of_parent,
+ this,
+ language_flags);
+ if (child_compiler_type && child_byte_size)
{
ConstString child_name;
if (!child_name_str.empty())
child_name.SetCString (child_name_str.c_str());
m_deref_valobj = new ValueObjectChild (*this,
- child_clang_type,
+ child_compiler_type,
child_name,
child_byte_size,
child_byte_offset,
@@ -3759,7 +3757,8 @@ ValueObject::Dereference (Error &error)
child_bitfield_bit_offset,
child_is_base_class,
child_is_deref_of_parent,
- eAddressTypeInvalid);
+ eAddressTypeInvalid,
+ language_flags);
}
}
@@ -3773,10 +3772,10 @@ ValueObject::Dereference (Error &error)
StreamString strm;
GetExpressionPath(strm, true);
- if (is_pointer_type)
+ if (is_pointer_or_reference_type)
error.SetErrorStringWithFormat("dereference failed: (%s) %s", GetTypeName().AsCString("<invalid type>"), strm.GetString().c_str());
else
- error.SetErrorStringWithFormat("not a pointer type: (%s) %s", GetTypeName().AsCString("<invalid type>"), strm.GetString().c_str());
+ error.SetErrorStringWithFormat("not a pointer or reference type: (%s) %s", GetTypeName().AsCString("<invalid type>"), strm.GetString().c_str());
return ValueObjectSP();
}
}
@@ -3806,14 +3805,14 @@ ValueObject::AddressOf (Error &error)
case eAddressTypeFile:
case eAddressTypeLoad:
{
- ClangASTType clang_type = GetClangType();
- if (clang_type)
+ CompilerType compiler_type = GetCompilerType();
+ if (compiler_type)
{
std::string name (1, '&');
name.append (m_name.AsCString(""));
ExecutionContext exe_ctx (GetExecutionContextRef());
m_addr_of_valobj_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
- clang_type.GetPointerType(),
+ compiler_type.GetPointerType(),
ConstString (name.c_str()),
addr,
eAddressTypeInvalid,
@@ -3836,13 +3835,13 @@ ValueObject::AddressOf (Error &error)
}
ValueObjectSP
-ValueObject::Cast (const ClangASTType &clang_ast_type)
+ValueObject::Cast (const CompilerType &compiler_type)
{
- return ValueObjectCast::Create (*this, GetName(), clang_ast_type);
+ return ValueObjectCast::Create (*this, GetName(), compiler_type);
}
ValueObjectSP
-ValueObject::CastPointerType (const char *name, ClangASTType &clang_ast_type)
+ValueObject::CastPointerType (const char *name, CompilerType &compiler_type)
{
ValueObjectSP valobj_sp;
AddressType address_type;
@@ -3855,7 +3854,7 @@ ValueObject::CastPointerType (const char *name, ClangASTType &clang_ast_type)
valobj_sp = ValueObjectMemory::Create (exe_ctx.GetBestExecutionContextScope(),
name,
ptr_addr,
- clang_ast_type);
+ compiler_type);
}
return valobj_sp;
}
@@ -4104,11 +4103,11 @@ lldb::ValueObjectSP
ValueObject::CreateValueObjectFromAddress (const char* name,
uint64_t address,
const ExecutionContext& exe_ctx,
- ClangASTType type)
+ CompilerType type)
{
if (type)
{
- ClangASTType pointer_type(type.GetPointerType());
+ CompilerType pointer_type(type.GetPointerType());
if (pointer_type)
{
lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(&address,sizeof(lldb::addr_t)));
@@ -4136,7 +4135,7 @@ lldb::ValueObjectSP
ValueObject::CreateValueObjectFromData (const char* name,
const DataExtractor& data,
const ExecutionContext& exe_ctx,
- ClangASTType type)
+ CompilerType type)
{
lldb::ValueObjectSP new_value_sp;
new_value_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
@@ -4252,13 +4251,20 @@ ValueObject::SetPreferredDisplayLanguage (lldb::LanguageType lt)
m_preferred_display_language = lt;
}
+void
+ValueObject::SetPreferredDisplayLanguageIfNeeded (lldb::LanguageType lt)
+{
+ if (m_preferred_display_language == lldb::eLanguageTypeUnknown)
+ SetPreferredDisplayLanguage(lt);
+}
+
bool
ValueObject::CanProvideValue ()
{
// we need to support invalid types as providers of values because some bare-board
// debugging scenarios have no notion of types, but still manage to have raw numeric
// values for things like registers. sigh.
- const ClangASTType &type(GetClangType());
+ const CompilerType &type(GetCompilerType());
return (false == type.IsValid()) || (0 != (type.GetTypeInfo() & eTypeHasValue));
}
@@ -4278,15 +4284,18 @@ ValueObject::Persist ()
if (!target_sp)
return nullptr;
- ConstString name(target_sp->GetPersistentVariables().GetNextPersistentVariableName());
+ PersistentExpressionState *persistent_state = target_sp->GetPersistentExpressionStateForLanguage(GetPreferredDisplayLanguage());
- ClangExpressionVariableSP clang_var_sp(new ClangExpressionVariable(target_sp.get(), GetValue(), name));
- if (clang_var_sp)
- {
- clang_var_sp->m_live_sp = clang_var_sp->m_frozen_sp;
- clang_var_sp->m_flags |= ClangExpressionVariable::EVIsProgramReference;
- target_sp->GetPersistentVariables().AddVariable(clang_var_sp);
- }
+ if (!persistent_state)
+ return nullptr;
+
+ ConstString name(persistent_state->GetNextPersistentVariableName());
+
+ ValueObjectSP const_result_sp = ValueObjectConstResult::Create (target_sp.get(), GetValue(), name);
+
+ ExpressionVariableSP clang_var_sp = persistent_state->CreatePersistentVariable(const_result_sp);
+ clang_var_sp->m_live_sp = clang_var_sp->m_frozen_sp;
+ clang_var_sp->m_flags |= ExpressionVariable::EVIsProgramReference;
return clang_var_sp->GetValueObject();
}
@@ -4302,3 +4311,15 @@ ValueObject::SetSyntheticChildrenGenerated (bool b)
{
m_is_synthetic_children_generated = b;
}
+
+uint64_t
+ValueObject::GetLanguageFlags ()
+{
+ return m_language_flags;
+}
+
+void
+ValueObject::SetLanguageFlags (uint64_t flags)
+{
+ m_language_flags = flags;
+}
diff --git a/source/Core/ValueObjectCast.cpp b/source/Core/ValueObjectCast.cpp
index b20371b128df..1c5838b820e1 100644
--- a/source/Core/ValueObjectCast.cpp
+++ b/source/Core/ValueObjectCast.cpp
@@ -20,14 +20,13 @@
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObject.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Symbol/Variable.h"
#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/LanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
@@ -38,7 +37,7 @@ using namespace lldb_private;
lldb::ValueObjectSP
ValueObjectCast::Create (ValueObject &parent,
const ConstString &name,
- const ClangASTType &cast_type)
+ const CompilerType &cast_type)
{
ValueObjectCast *cast_valobj_ptr = new ValueObjectCast (parent, name, cast_type);
return cast_valobj_ptr->GetSP();
@@ -48,36 +47,38 @@ ValueObjectCast::ValueObjectCast
(
ValueObject &parent,
const ConstString &name,
- const ClangASTType &cast_type
+ const CompilerType &cast_type
) :
ValueObject(parent),
m_cast_type (cast_type)
{
SetName (name);
//m_value.SetContext (Value::eContextTypeClangType, cast_type.GetOpaqueQualType());
- m_value.SetClangType (cast_type);
+ m_value.SetCompilerType (cast_type);
}
ValueObjectCast::~ValueObjectCast()
{
}
-ClangASTType
-ValueObjectCast::GetClangTypeImpl ()
+CompilerType
+ValueObjectCast::GetCompilerTypeImpl ()
{
return m_cast_type;
}
size_t
-ValueObjectCast::CalculateNumChildren()
+ValueObjectCast::CalculateNumChildren(uint32_t max)
{
- return GetClangType().GetNumChildren (true);
+ auto children_count = GetCompilerType().GetNumChildren (true);
+ return children_count <= max ? children_count : max;
}
uint64_t
ValueObjectCast::GetByteSize()
{
- return m_value.GetValueByteSize(NULL);
+ ExecutionContext exe_ctx (GetExecutionContextRef());
+ return m_value.GetValueByteSize(nullptr, &exe_ctx);
}
lldb::ValueType
@@ -98,9 +99,9 @@ ValueObjectCast::UpdateValue ()
Value old_value(m_value);
m_update_point.SetUpdated();
m_value = m_parent->GetValue();
- ClangASTType clang_type (GetClangType());
- //m_value.SetContext (Value::eContextTypeClangType, clang_type);
- m_value.SetClangType (clang_type);
+ CompilerType compiler_type (GetCompilerType());
+ //m_value.SetContext (Value::eContextTypeClangType, compiler_type);
+ m_value.SetCompilerType (compiler_type);
SetAddressTypeOfChildren(m_parent->GetAddressTypeOfChildren());
if (!CanProvideValue())
{
diff --git a/source/Core/ValueObjectChild.cpp b/source/Core/ValueObjectChild.cpp
index c1e45e1f48de..6ecc749b8953 100644
--- a/source/Core/ValueObjectChild.cpp
+++ b/source/Core/ValueObjectChild.cpp
@@ -12,7 +12,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/ValueObjectList.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/Type.h"
@@ -27,7 +27,7 @@ using namespace lldb_private;
ValueObjectChild::ValueObjectChild
(
ValueObject &parent,
- const ClangASTType &clang_type,
+ const CompilerType &compiler_type,
const ConstString &name,
uint64_t byte_size,
int32_t byte_offset,
@@ -35,19 +35,22 @@ ValueObjectChild::ValueObjectChild
uint32_t bitfield_bit_offset,
bool is_base_class,
bool is_deref_of_parent,
- AddressType child_ptr_or_ref_addr_type
+ AddressType child_ptr_or_ref_addr_type,
+ uint64_t language_flags
) :
ValueObject (parent),
- m_clang_type (clang_type),
+ m_compiler_type (compiler_type),
m_byte_size (byte_size),
m_byte_offset (byte_offset),
m_bitfield_bit_size (bitfield_bit_size),
m_bitfield_bit_offset (bitfield_bit_offset),
m_is_base_class (is_base_class),
- m_is_deref_of_parent (is_deref_of_parent)
+ m_is_deref_of_parent (is_deref_of_parent),
+ m_can_update_with_invalid_exe_ctx()
{
m_name = name;
SetAddressTypeOfChildren(child_ptr_or_ref_addr_type);
+ SetLanguageFlags(language_flags);
}
ValueObjectChild::~ValueObjectChild()
@@ -61,9 +64,10 @@ ValueObjectChild::GetValueType() const
}
size_t
-ValueObjectChild::CalculateNumChildren()
+ValueObjectChild::CalculateNumChildren(uint32_t max)
{
- return GetClangType().GetNumChildren (true);
+ auto children_count = GetCompilerType().GetNumChildren (true);
+ return children_count <= max ? children_count : max;
}
static void
@@ -72,11 +76,11 @@ AdjustForBitfieldness(ConstString& name,
{
if (name && bitfield_bit_size)
{
- const char *clang_type_name = name.AsCString();
- if (clang_type_name)
+ const char *compiler_type_name = name.AsCString();
+ if (compiler_type_name)
{
- std::vector<char> bitfield_type_name (strlen(clang_type_name) + 32, 0);
- ::snprintf (&bitfield_type_name.front(), bitfield_type_name.size(), "%s:%u", clang_type_name, bitfield_bit_size);
+ std::vector<char> bitfield_type_name (strlen(compiler_type_name) + 32, 0);
+ ::snprintf (&bitfield_type_name.front(), bitfield_type_name.size(), "%s:%u", compiler_type_name, bitfield_bit_size);
name.SetCString(&bitfield_type_name.front());
}
}
@@ -87,7 +91,7 @@ ValueObjectChild::GetTypeName()
{
if (m_type_name.IsEmpty())
{
- m_type_name = GetClangType().GetConstTypeName ();
+ m_type_name = GetCompilerType().GetConstTypeName ();
AdjustForBitfieldness(m_type_name, m_bitfield_bit_size);
}
return m_type_name;
@@ -96,7 +100,7 @@ ValueObjectChild::GetTypeName()
ConstString
ValueObjectChild::GetQualifiedTypeName()
{
- ConstString qualified_name = GetClangType().GetConstTypeName();
+ ConstString qualified_name = GetCompilerType().GetConstTypeName();
AdjustForBitfieldness(qualified_name, m_bitfield_bit_size);
return qualified_name;
}
@@ -104,17 +108,25 @@ ValueObjectChild::GetQualifiedTypeName()
ConstString
ValueObjectChild::GetDisplayTypeName()
{
- ConstString display_name = GetClangType().GetDisplayTypeName();
+ ConstString display_name = GetCompilerType().GetDisplayTypeName();
AdjustForBitfieldness(display_name, m_bitfield_bit_size);
return display_name;
}
-bool
+LazyBool
ValueObjectChild::CanUpdateWithInvalidExecutionContext ()
{
+ if (m_can_update_with_invalid_exe_ctx.hasValue())
+ return m_can_update_with_invalid_exe_ctx.getValue();
if (m_parent)
- return m_parent->CanUpdateWithInvalidExecutionContext();
- return this->ValueObject::CanUpdateWithInvalidExecutionContext();
+ {
+ ValueObject *opinionated_parent = m_parent->FollowParentChain([] (ValueObject* valobj) -> bool {
+ return (valobj->CanUpdateWithInvalidExecutionContext() == eLazyBoolCalculate);
+ });
+ if (opinionated_parent)
+ return (m_can_update_with_invalid_exe_ctx = opinionated_parent->CanUpdateWithInvalidExecutionContext()).getValue();
+ }
+ return (m_can_update_with_invalid_exe_ctx = this->ValueObject::CanUpdateWithInvalidExecutionContext()).getValue();
}
bool
@@ -127,18 +139,22 @@ ValueObjectChild::UpdateValue ()
{
if (parent->UpdateValueIfNeeded(false))
{
- m_value.SetClangType(GetClangType());
-
+ m_value.SetCompilerType(GetCompilerType());
+
+ CompilerType parent_type(parent->GetCompilerType());
// Copy the parent scalar value and the scalar value type
m_value.GetScalar() = parent->GetValue().GetScalar();
Value::ValueType value_type = parent->GetValue().GetValueType();
m_value.SetValueType (value_type);
+
+ Flags parent_type_flags(parent_type.GetTypeInfo());
+ const bool is_instance_ptr_base = ((m_is_base_class == true) && (parent_type_flags.AnySet(lldb::eTypeInstanceIsPointer)));
- if (parent->GetClangType().IsPointerOrReferenceType ())
+ if (parent->GetCompilerType().ShouldTreatScalarValueAsAddress())
{
lldb::addr_t addr = parent->GetPointerValue ();
m_value.GetScalar() = addr;
-
+
if (addr == LLDB_INVALID_ADDRESS)
{
m_error.SetErrorString ("parent address is invalid.");
@@ -155,16 +171,16 @@ ValueObjectChild::UpdateValue ()
switch (addr_type)
{
case eAddressTypeFile:
- {
- lldb::ProcessSP process_sp (GetProcessSP());
- if (process_sp && process_sp->IsAlive() == true)
- m_value.SetValueType (Value::eValueTypeLoadAddress);
- else
- m_value.SetValueType(Value::eValueTypeFileAddress);
- }
+ {
+ lldb::ProcessSP process_sp (GetProcessSP());
+ if (process_sp && process_sp->IsAlive() == true)
+ m_value.SetValueType (Value::eValueTypeLoadAddress);
+ else
+ m_value.SetValueType(Value::eValueTypeFileAddress);
+ }
break;
case eAddressTypeLoad:
- m_value.SetValueType (Value::eValueTypeLoadAddress);
+ m_value.SetValueType (is_instance_ptr_base ? Value::eValueTypeScalar: Value::eValueTypeLoadAddress);
break;
case eAddressTypeHost:
m_value.SetValueType(Value::eValueTypeHostAddress);
@@ -180,9 +196,9 @@ ValueObjectChild::UpdateValue ()
{
switch (value_type)
{
- case Value::eValueTypeLoadAddress:
- case Value::eValueTypeFileAddress:
- case Value::eValueTypeHostAddress:
+ case Value::eValueTypeLoadAddress:
+ case Value::eValueTypeFileAddress:
+ case Value::eValueTypeHostAddress:
{
lldb::addr_t addr = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
if (addr == LLDB_INVALID_ADDRESS)
@@ -200,27 +216,42 @@ ValueObjectChild::UpdateValue ()
m_value.GetScalar() += GetByteOffset();
}
}
- break;
-
- case Value::eValueTypeScalar:
- // TODO: What if this is a register value? Do we try and
- // extract the child value from within the parent data?
- // Probably...
- default:
- m_error.SetErrorString ("parent has invalid value.");
- break;
+ break;
+
+ case Value::eValueTypeScalar:
+ // try to extract the child value from the parent's scalar value
+ {
+ Scalar scalar(m_value.GetScalar());
+ if (m_bitfield_bit_size)
+ scalar.ExtractBitfield(m_bitfield_bit_size, m_bitfield_bit_offset);
+ else
+ scalar.ExtractBitfield(8*m_byte_size, 8*m_byte_offset);
+ m_value.GetScalar() = scalar;
+ }
+ break;
+ default:
+ m_error.SetErrorString ("parent has invalid value.");
+ break;
}
}
-
+
if (m_error.Success())
{
const bool thread_and_frame_only_if_stopped = true;
ExecutionContext exe_ctx (GetExecutionContextRef().Lock(thread_and_frame_only_if_stopped));
- if (GetClangType().GetTypeInfo() & lldb::eTypeHasValue)
- m_error = m_value.GetValueAsData (&exe_ctx, m_data, 0, GetModule().get());
+ if (GetCompilerType().GetTypeInfo() & lldb::eTypeHasValue)
+ {
+ if (!is_instance_ptr_base)
+ m_error = m_value.GetValueAsData (&exe_ctx, m_data, 0, GetModule().get());
+ else
+ m_error = m_parent->GetValue().GetValueAsData (&exe_ctx, m_data, 0, GetModule().get());
+ }
else
+ {
m_error.Clear(); // No value so nothing to read...
+ }
}
+
}
else
{
diff --git a/source/Core/ValueObjectConstResult.cpp b/source/Core/ValueObjectConstResult.cpp
index b4e630306469..a0f1737a861c 100644
--- a/source/Core/ValueObjectConstResult.cpp
+++ b/source/Core/ValueObjectConstResult.cpp
@@ -16,7 +16,7 @@
#include "lldb/Core/ValueObjectDynamicValue.h"
#include "lldb/Core/ValueObjectList.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/Type.h"
@@ -61,21 +61,21 @@ ValueObjectSP
ValueObjectConstResult::Create
(
ExecutionContextScope *exe_scope,
- const ClangASTType &clang_type,
+ const CompilerType &compiler_type,
const ConstString &name,
const DataExtractor &data,
lldb::addr_t address
)
{
return (new ValueObjectConstResult (exe_scope,
- clang_type,
+ compiler_type,
name,
data,
address))->GetSP();
}
ValueObjectConstResult::ValueObjectConstResult (ExecutionContextScope *exe_scope,
- const ClangASTType &clang_type,
+ const CompilerType &compiler_type,
const ConstString &name,
const DataExtractor &data,
lldb::addr_t address) :
@@ -94,7 +94,7 @@ ValueObjectConstResult::ValueObjectConstResult (ExecutionContextScope *exe_scope
m_value.GetScalar() = (uintptr_t)m_data.GetDataStart();
m_value.SetValueType(Value::eValueTypeHostAddress);
- m_value.SetClangType(clang_type);
+ m_value.SetCompilerType(compiler_type);
m_name = name;
SetIsConstant ();
SetValueIsValid(true);
@@ -103,7 +103,7 @@ ValueObjectConstResult::ValueObjectConstResult (ExecutionContextScope *exe_scope
ValueObjectSP
ValueObjectConstResult::Create (ExecutionContextScope *exe_scope,
- const ClangASTType &clang_type,
+ const CompilerType &compiler_type,
const ConstString &name,
const lldb::DataBufferSP &data_sp,
lldb::ByteOrder data_byte_order,
@@ -111,7 +111,7 @@ ValueObjectConstResult::Create (ExecutionContextScope *exe_scope,
lldb::addr_t address)
{
return (new ValueObjectConstResult (exe_scope,
- clang_type,
+ compiler_type,
name,
data_sp,
data_byte_order,
@@ -129,7 +129,7 @@ ValueObjectConstResult::Create (ExecutionContextScope *exe_scope,
}
ValueObjectConstResult::ValueObjectConstResult (ExecutionContextScope *exe_scope,
- const ClangASTType &clang_type,
+ const CompilerType &compiler_type,
const ConstString &name,
const lldb::DataBufferSP &data_sp,
lldb::ByteOrder data_byte_order,
@@ -145,8 +145,8 @@ ValueObjectConstResult::ValueObjectConstResult (ExecutionContextScope *exe_scope
m_data.SetData(data_sp);
m_value.GetScalar() = (uintptr_t)data_sp->GetBytes();
m_value.SetValueType(Value::eValueTypeHostAddress);
- //m_value.SetContext(Value::eContextTypeClangType, clang_type);
- m_value.SetClangType (clang_type);
+ //m_value.SetContext(Value::eContextTypeClangType, compiler_type);
+ m_value.SetCompilerType (compiler_type);
m_name = name;
SetIsConstant ();
SetValueIsValid(true);
@@ -155,14 +155,14 @@ ValueObjectConstResult::ValueObjectConstResult (ExecutionContextScope *exe_scope
ValueObjectSP
ValueObjectConstResult::Create (ExecutionContextScope *exe_scope,
- const ClangASTType &clang_type,
+ const CompilerType &compiler_type,
const ConstString &name,
lldb::addr_t address,
AddressType address_type,
uint32_t addr_byte_size)
{
return (new ValueObjectConstResult (exe_scope,
- clang_type,
+ compiler_type,
name,
address,
address_type,
@@ -170,7 +170,7 @@ ValueObjectConstResult::Create (ExecutionContextScope *exe_scope,
}
ValueObjectConstResult::ValueObjectConstResult (ExecutionContextScope *exe_scope,
- const ClangASTType &clang_type,
+ const CompilerType &compiler_type,
const ConstString &name,
lldb::addr_t address,
AddressType address_type,
@@ -191,8 +191,8 @@ ValueObjectConstResult::ValueObjectConstResult (ExecutionContextScope *exe_scope
case eAddressTypeLoad: m_value.SetValueType(Value::eValueTypeLoadAddress); break;
case eAddressTypeHost: m_value.SetValueType(Value::eValueTypeHostAddress); break;
}
-// m_value.SetContext(Value::eContextTypeClangType, clang_type);
- m_value.SetClangType (clang_type);
+// m_value.SetContext(Value::eContextTypeClangType, compiler_type);
+ m_value.SetCompilerType (compiler_type);
m_name = name;
SetIsConstant ();
SetValueIsValid(true);
@@ -241,10 +241,10 @@ ValueObjectConstResult::~ValueObjectConstResult()
{
}
-ClangASTType
-ValueObjectConstResult::GetClangTypeImpl()
+CompilerType
+ValueObjectConstResult::GetCompilerTypeImpl()
{
- return m_value.GetClangType();
+ return m_value.GetCompilerType();
}
lldb::ValueType
@@ -259,7 +259,7 @@ ValueObjectConstResult::GetByteSize()
ExecutionContext exe_ctx(GetExecutionContextRef());
if (m_byte_size == 0)
- SetByteSize(GetClangType().GetByteSize(exe_ctx.GetBestExecutionContextScope()));
+ SetByteSize(GetCompilerType().GetByteSize(exe_ctx.GetBestExecutionContextScope()));
return m_byte_size;
}
@@ -270,23 +270,24 @@ ValueObjectConstResult::SetByteSize (size_t size)
}
size_t
-ValueObjectConstResult::CalculateNumChildren()
+ValueObjectConstResult::CalculateNumChildren(uint32_t max)
{
- return GetClangType().GetNumChildren (true);
+ auto children_count = GetCompilerType().GetNumChildren (true);
+ return children_count <= max ? children_count : max;
}
ConstString
ValueObjectConstResult::GetTypeName()
{
if (m_type_name.IsEmpty())
- m_type_name = GetClangType().GetConstTypeName ();
+ m_type_name = GetCompilerType().GetConstTypeName ();
return m_type_name;
}
ConstString
ValueObjectConstResult::GetDisplayTypeName()
{
- return GetClangType().GetDisplayTypeName();
+ return GetCompilerType().GetDisplayTypeName();
}
bool
@@ -313,7 +314,7 @@ ValueObjectConstResult::Dereference (Error &error)
}
lldb::ValueObjectSP
-ValueObjectConstResult::GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create)
+ValueObjectConstResult::GetSyntheticChildAtOffset(uint32_t offset, const CompilerType& type, bool can_create)
{
return m_impl.GetSyntheticChildAtOffset(offset, type, can_create);
}
@@ -365,8 +366,16 @@ ValueObjectConstResult::GetDynamicValue (lldb::DynamicValueType use_dynamic)
return ValueObjectSP();
}
+lldb::ValueObjectSP
+ValueObjectConstResult::Cast (const CompilerType &compiler_type)
+{
+ return m_impl.Cast(compiler_type);
+}
+
lldb::LanguageType
ValueObjectConstResult::GetPreferredDisplayLanguage ()
{
- return lldb::eLanguageTypeUnknown;
+ if (m_preferred_display_language != lldb::eLanguageTypeUnknown)
+ return m_preferred_display_language;
+ return GetCompilerTypeImpl().GetMinimumLanguage();
}
diff --git a/source/Core/ValueObjectConstResultCast.cpp b/source/Core/ValueObjectConstResultCast.cpp
new file mode 100644
index 000000000000..8f0c0f1522f2
--- /dev/null
+++ b/source/Core/ValueObjectConstResultCast.cpp
@@ -0,0 +1,75 @@
+//===-- ValueObjectConstResultCast.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/Core/ValueObjectConstResultCast.h"
+
+#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/Core/ValueObjectList.h"
+
+#include "lldb/Symbol/ClangASTContext.h"
+
+using namespace lldb_private;
+
+ValueObjectConstResultCast::ValueObjectConstResultCast(
+ ValueObject &parent,
+ const ConstString &name,
+ const CompilerType &cast_type,
+ lldb::addr_t live_address) :
+ ValueObjectCast (parent, name, cast_type),
+ m_impl(this, live_address)
+{
+ m_name = name;
+}
+
+ValueObjectConstResultCast::~ValueObjectConstResultCast()
+{
+}
+
+lldb::ValueObjectSP
+ValueObjectConstResultCast::Dereference (Error &error)
+{
+ return m_impl.Dereference(error);
+}
+
+lldb::ValueObjectSP
+ValueObjectConstResultCast::GetSyntheticChildAtOffset(uint32_t offset,
+ const CompilerType& type,
+ bool can_create)
+{
+ return m_impl.GetSyntheticChildAtOffset(offset, type, can_create);
+}
+
+lldb::ValueObjectSP
+ValueObjectConstResultCast::AddressOf (Error &error)
+{
+ return m_impl.AddressOf(error);
+}
+
+ValueObject *
+ValueObjectConstResultCast::CreateChildAtIndex (size_t idx,
+ bool synthetic_array_member,
+ int32_t synthetic_index)
+{
+ return m_impl.CreateChildAtIndex(
+ idx, synthetic_array_member, synthetic_index);
+}
+
+size_t
+ValueObjectConstResultCast::GetPointeeData (DataExtractor& data,
+ uint32_t item_idx,
+ uint32_t item_count)
+{
+ return m_impl.GetPointeeData(data, item_idx, item_count);
+}
+
+lldb::ValueObjectSP
+ValueObjectConstResultCast::Cast (const CompilerType &compiler_type)
+{
+ return m_impl.Cast(compiler_type);
+}
diff --git a/source/Core/ValueObjectConstResultChild.cpp b/source/Core/ValueObjectConstResultChild.cpp
index 64425ea50969..c93aedc22603 100644
--- a/source/Core/ValueObjectConstResultChild.cpp
+++ b/source/Core/ValueObjectConstResultChild.cpp
@@ -19,17 +19,19 @@ using namespace lldb_private;
ValueObjectConstResultChild::ValueObjectConstResultChild
(
ValueObject &parent,
- const ClangASTType &clang_type,
+ const CompilerType &compiler_type,
const ConstString &name,
uint32_t byte_size,
int32_t byte_offset,
uint32_t bitfield_bit_size,
uint32_t bitfield_bit_offset,
bool is_base_class,
- bool is_deref_of_parent
+ bool is_deref_of_parent,
+ lldb::addr_t live_address,
+ uint64_t language_flags
) :
ValueObjectChild (parent,
- clang_type,
+ compiler_type,
name,
byte_size,
byte_offset,
@@ -37,8 +39,9 @@ ValueObjectConstResultChild::ValueObjectConstResultChild
bitfield_bit_offset,
is_base_class,
is_deref_of_parent,
- eAddressTypeLoad),
- m_impl(this)
+ eAddressTypeLoad,
+ language_flags),
+ m_impl(this, live_address)
{
m_name = name;
}
@@ -54,7 +57,7 @@ ValueObjectConstResultChild::Dereference (Error &error)
}
lldb::ValueObjectSP
-ValueObjectConstResultChild::GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create)
+ValueObjectConstResultChild::GetSyntheticChildAtOffset(uint32_t offset, const CompilerType& type, bool can_create)
{
return m_impl.GetSyntheticChildAtOffset(offset, type, can_create);
}
@@ -78,3 +81,9 @@ ValueObjectConstResultChild::GetPointeeData (DataExtractor& data,
{
return m_impl.GetPointeeData(data, item_idx, item_count);
}
+
+lldb::ValueObjectSP
+ValueObjectConstResultChild::Cast (const CompilerType &compiler_type)
+{
+ return m_impl.Cast(compiler_type);
+}
diff --git a/source/Core/ValueObjectConstResultImpl.cpp b/source/Core/ValueObjectConstResultImpl.cpp
index 733d767b7ee1..85ac3f2c5fe5 100644
--- a/source/Core/ValueObjectConstResultImpl.cpp
+++ b/source/Core/ValueObjectConstResultImpl.cpp
@@ -11,13 +11,14 @@
#include "lldb/Core/ValueObjectChild.h"
#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/Core/ValueObjectConstResultCast.h"
#include "lldb/Core/ValueObjectConstResultChild.h"
#include "lldb/Core/ValueObjectMemory.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ValueObjectList.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/Type.h"
@@ -68,27 +69,29 @@ ValueObjectConstResultImpl::CreateChildAtIndex (size_t idx, bool synthetic_array
uint32_t child_bitfield_bit_offset = 0;
bool child_is_base_class = false;
bool child_is_deref_of_parent = false;
+ uint64_t language_flags;
const bool transparent_pointers = synthetic_array_member == false;
- ClangASTType clang_type = m_impl_backend->GetClangType();
- ClangASTType child_clang_type;
+ CompilerType compiler_type = m_impl_backend->GetCompilerType();
+ CompilerType child_compiler_type;
ExecutionContext exe_ctx (m_impl_backend->GetExecutionContextRef());
- child_clang_type = clang_type.GetChildClangTypeAtIndex (&exe_ctx,
- idx,
- transparent_pointers,
- omit_empty_base_classes,
- ignore_array_bounds,
- child_name_str,
- child_byte_size,
- child_byte_offset,
- child_bitfield_bit_size,
- child_bitfield_bit_offset,
- child_is_base_class,
- child_is_deref_of_parent,
- m_impl_backend);
- if (child_clang_type && child_byte_size)
+ child_compiler_type = compiler_type.GetChildCompilerTypeAtIndex (&exe_ctx,
+ idx,
+ transparent_pointers,
+ omit_empty_base_classes,
+ ignore_array_bounds,
+ child_name_str,
+ child_byte_size,
+ child_byte_offset,
+ child_bitfield_bit_size,
+ child_bitfield_bit_offset,
+ child_is_base_class,
+ child_is_deref_of_parent,
+ m_impl_backend,
+ language_flags);
+ if (child_compiler_type && child_byte_size)
{
if (synthetic_index)
child_byte_offset += child_byte_size * synthetic_index;
@@ -96,25 +99,25 @@ ValueObjectConstResultImpl::CreateChildAtIndex (size_t idx, bool synthetic_array
ConstString child_name;
if (!child_name_str.empty())
child_name.SetCString (child_name_str.c_str());
-
+
valobj = new ValueObjectConstResultChild (*m_impl_backend,
- child_clang_type,
+ child_compiler_type,
child_name,
child_byte_size,
child_byte_offset,
child_bitfield_bit_size,
child_bitfield_bit_offset,
child_is_base_class,
- child_is_deref_of_parent);
- if (m_live_address != LLDB_INVALID_ADDRESS)
- valobj->m_impl.SetLiveAddress(m_live_address+child_byte_offset);
+ child_is_deref_of_parent,
+ m_live_address == LLDB_INVALID_ADDRESS ? m_live_address : m_live_address+child_byte_offset,
+ language_flags);
}
return valobj;
}
lldb::ValueObjectSP
-ValueObjectConstResultImpl::GetSyntheticChildAtOffset (uint32_t offset, const ClangASTType& type, bool can_create)
+ValueObjectConstResultImpl::GetSyntheticChildAtOffset (uint32_t offset, const CompilerType& type, bool can_create)
{
if (m_impl_backend == NULL)
return lldb::ValueObjectSP();
@@ -132,7 +135,7 @@ ValueObjectConstResultImpl::AddressOf (Error &error)
return lldb::ValueObjectSP();
if (m_live_address != LLDB_INVALID_ADDRESS)
{
- ClangASTType clang_type(m_impl_backend->GetClangType());
+ CompilerType compiler_type(m_impl_backend->GetCompilerType());
lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(&m_live_address,sizeof(lldb::addr_t)));
@@ -140,10 +143,10 @@ ValueObjectConstResultImpl::AddressOf (Error &error)
new_name.append(m_impl_backend->GetName().AsCString(""));
ExecutionContext exe_ctx (m_impl_backend->GetExecutionContextRef());
m_address_of_backend = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
- clang_type.GetPointerType(),
+ compiler_type.GetPointerType(),
ConstString(new_name.c_str()),
buffer,
- lldb::endian::InlHostByteOrder(),
+ endian::InlHostByteOrder(),
exe_ctx.GetAddressByteSize());
m_address_of_backend->GetValue().SetValueType(Value::eValueTypeScalar);
@@ -155,6 +158,17 @@ ValueObjectConstResultImpl::AddressOf (Error &error)
return m_impl_backend->ValueObject::AddressOf(error);
}
+lldb::ValueObjectSP
+ValueObjectConstResultImpl::Cast (const CompilerType &compiler_type)
+{
+ if (m_impl_backend == NULL)
+ return lldb::ValueObjectSP();
+
+ ValueObjectConstResultCast *result_cast = new ValueObjectConstResultCast(
+ *m_impl_backend, m_impl_backend->GetName(), compiler_type, m_live_address);
+ return result_cast->GetSP();
+}
+
lldb::addr_t
ValueObjectConstResultImpl::GetAddressOf (bool scalar_is_load_address,
AddressType *address_type)
diff --git a/source/Core/ValueObjectDynamicValue.cpp b/source/Core/ValueObjectDynamicValue.cpp
index 89b98a1db1ba..0ac86a68f19f 100644
--- a/source/Core/ValueObjectDynamicValue.cpp
+++ b/source/Core/ValueObjectDynamicValue.cpp
@@ -20,7 +20,7 @@
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObject.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/Type.h"
@@ -49,18 +49,18 @@ ValueObjectDynamicValue::~ValueObjectDynamicValue()
m_owning_valobj_sp.reset();
}
-ClangASTType
-ValueObjectDynamicValue::GetClangTypeImpl ()
+CompilerType
+ValueObjectDynamicValue::GetCompilerTypeImpl ()
{
const bool success = UpdateValueIfNeeded(false);
if (success)
{
if (m_dynamic_type_info.HasType())
- return m_value.GetClangType();
+ return m_value.GetCompilerType();
else
- return m_parent->GetClangType();
+ return m_parent->GetCompilerType();
}
- return m_parent->GetClangType();
+ return m_parent->GetCompilerType();
}
ConstString
@@ -105,7 +105,7 @@ ValueObjectDynamicValue::GetDisplayTypeName()
if (success)
{
if (m_dynamic_type_info.HasType())
- return GetClangType().GetDisplayTypeName();
+ return GetCompilerType().GetDisplayTypeName();
if (m_dynamic_type_info.HasName())
return m_dynamic_type_info.GetName();
}
@@ -113,13 +113,16 @@ ValueObjectDynamicValue::GetDisplayTypeName()
}
size_t
-ValueObjectDynamicValue::CalculateNumChildren()
+ValueObjectDynamicValue::CalculateNumChildren(uint32_t max)
{
const bool success = UpdateValueIfNeeded(false);
if (success && m_dynamic_type_info.HasType())
- return GetClangType().GetNumChildren (true);
+ {
+ auto children_count = GetCompilerType().GetNumChildren (true);
+ return children_count <= max ? children_count : max;
+ }
else
- return m_parent->GetNumChildren();
+ return m_parent->GetNumChildren(max);
}
uint64_t
@@ -127,7 +130,10 @@ ValueObjectDynamicValue::GetByteSize()
{
const bool success = UpdateValueIfNeeded(false);
if (success && m_dynamic_type_info.HasType())
- return m_value.GetValueByteSize(nullptr);
+ {
+ ExecutionContext exe_ctx (GetExecutionContextRef());
+ return m_value.GetValueByteSize(nullptr, &exe_ctx);
+ }
else
return m_parent->GetByteSize();
}
@@ -138,40 +144,6 @@ ValueObjectDynamicValue::GetValueType() const
return m_parent->GetValueType();
}
-
-static TypeAndOrName
-FixupTypeAndOrName (const TypeAndOrName& type_andor_name,
- ValueObject& parent)
-{
- TypeAndOrName ret(type_andor_name);
- if (type_andor_name.HasType())
- {
- // The type will always be the type of the dynamic object. If our parent's type was a pointer,
- // then our type should be a pointer to the type of the dynamic object. If a reference, then the original type
- // should be okay...
- ClangASTType orig_type = type_andor_name.GetClangASTType();
- ClangASTType corrected_type = orig_type;
- if (parent.IsPointerType())
- corrected_type = orig_type.GetPointerType ();
- else if (parent.IsPointerOrReferenceType())
- corrected_type = orig_type.GetLValueReferenceType ();
- ret.SetClangASTType(corrected_type);
- }
- else /*if (m_dynamic_type_info.HasName())*/
- {
- // If we are here we need to adjust our dynamic type name to include the correct & or * symbol
- std::string corrected_name (type_andor_name.GetName().GetCString());
- if (parent.IsPointerType())
- corrected_name.append(" *");
- else if (parent.IsPointerOrReferenceType())
- corrected_name.append(" &");
- // the parent type should be a correctly pointer'ed or referenc'ed type
- ret.SetClangASTType(parent.GetClangType());
- ret.SetName(corrected_name.c_str());
- }
- return ret;
-}
-
bool
ValueObjectDynamicValue::UpdateValue ()
{
@@ -210,25 +182,28 @@ ValueObjectDynamicValue::UpdateValue ()
TypeAndOrName class_type_or_name;
Address dynamic_address;
bool found_dynamic_type = false;
+ Value::ValueType value_type;
+
+ LanguageRuntime *runtime = nullptr;
lldb::LanguageType known_type = m_parent->GetObjectRuntimeLanguage();
if (known_type != lldb::eLanguageTypeUnknown && known_type != lldb::eLanguageTypeC)
{
- LanguageRuntime *runtime = process->GetLanguageRuntime (known_type);
+ runtime = process->GetLanguageRuntime (known_type);
if (runtime)
- found_dynamic_type = runtime->GetDynamicTypeAndAddress (*m_parent, m_use_dynamic, class_type_or_name, dynamic_address);
+ found_dynamic_type = runtime->GetDynamicTypeAndAddress (*m_parent, m_use_dynamic, class_type_or_name, dynamic_address, value_type);
}
else
{
- LanguageRuntime *cpp_runtime = process->GetLanguageRuntime (lldb::eLanguageTypeC_plus_plus);
- if (cpp_runtime)
- found_dynamic_type = cpp_runtime->GetDynamicTypeAndAddress (*m_parent, m_use_dynamic, class_type_or_name, dynamic_address);
+ runtime = process->GetLanguageRuntime (lldb::eLanguageTypeC_plus_plus);
+ if (runtime)
+ found_dynamic_type = runtime->GetDynamicTypeAndAddress (*m_parent, m_use_dynamic, class_type_or_name, dynamic_address, value_type);
if (!found_dynamic_type)
{
- LanguageRuntime *objc_runtime = process->GetLanguageRuntime (lldb::eLanguageTypeObjC);
- if (objc_runtime)
- found_dynamic_type = objc_runtime->GetDynamicTypeAndAddress (*m_parent, m_use_dynamic, class_type_or_name, dynamic_address);
+ runtime = process->GetLanguageRuntime (lldb::eLanguageTypeObjC);
+ if (runtime)
+ found_dynamic_type = runtime->GetDynamicTypeAndAddress (*m_parent, m_use_dynamic, class_type_or_name, dynamic_address, value_type);
}
}
@@ -237,11 +212,12 @@ ValueObjectDynamicValue::UpdateValue ()
m_update_point.SetUpdated();
- if (found_dynamic_type)
+ if (runtime && found_dynamic_type)
{
if (class_type_or_name.HasType())
{
- m_type_impl = TypeImpl(m_parent->GetClangType(),FixupTypeAndOrName(class_type_or_name, *m_parent).GetClangASTType());
+ m_type_impl = TypeImpl(m_parent->GetCompilerType(),
+ runtime->FixUpDynamicType(class_type_or_name, *m_parent).GetCompilerType());
}
else
{
@@ -300,14 +276,13 @@ ValueObjectDynamicValue::UpdateValue ()
m_value.GetScalar() = load_address;
}
- m_dynamic_type_info = FixupTypeAndOrName(m_dynamic_type_info, *m_parent);
+ if (runtime)
+ m_dynamic_type_info = runtime->FixUpDynamicType(m_dynamic_type_info, *m_parent);
//m_value.SetContext (Value::eContextTypeClangType, corrected_type);
- m_value.SetClangType (m_dynamic_type_info.GetClangASTType());
+ m_value.SetCompilerType (m_dynamic_type_info.GetCompilerType());
- // Our address is the location of the dynamic type stored in memory. It isn't a load address,
- // because we aren't pointing to the LOCATION that stores the pointer to us, we're pointing to us...
- m_value.SetValueType(Value::eValueTypeScalar);
+ m_value.SetValueType(value_type);
if (has_changed_type && log)
log->Printf("[%s %p] has a new dynamic type %s", GetName().GetCString(),
@@ -421,3 +396,50 @@ ValueObjectDynamicValue::SetData (DataExtractor &data, Error &error)
SetNeedsUpdate();
return ret_val;
}
+
+void
+ValueObjectDynamicValue::SetPreferredDisplayLanguage (lldb::LanguageType lang)
+{
+ this->ValueObject::SetPreferredDisplayLanguage(lang);
+ if (m_parent)
+ m_parent->SetPreferredDisplayLanguage(lang);
+}
+
+lldb::LanguageType
+ValueObjectDynamicValue::GetPreferredDisplayLanguage ()
+{
+ if (m_preferred_display_language == lldb::eLanguageTypeUnknown)
+ {
+ if (m_parent)
+ return m_parent->GetPreferredDisplayLanguage();
+ return lldb::eLanguageTypeUnknown;
+ }
+ else
+ return m_preferred_display_language;
+}
+
+bool
+ValueObjectDynamicValue::GetDeclaration (Declaration &decl)
+{
+ if (m_parent)
+ return m_parent->GetDeclaration(decl);
+
+ return ValueObject::GetDeclaration(decl);
+}
+
+uint64_t
+ValueObjectDynamicValue::GetLanguageFlags ()
+{
+ if (m_parent)
+ return m_parent->GetLanguageFlags();
+ return this->ValueObject::GetLanguageFlags();
+}
+
+void
+ValueObjectDynamicValue::SetLanguageFlags (uint64_t flags)
+{
+ if (m_parent)
+ m_parent->SetLanguageFlags(flags);
+ else
+ this->ValueObject::SetLanguageFlags(flags);
+}
diff --git a/source/Core/ValueObjectMemory.cpp b/source/Core/ValueObjectMemory.cpp
index 9f1953138f62..b989710c95d5 100644
--- a/source/Core/ValueObjectMemory.cpp
+++ b/source/Core/ValueObjectMemory.cpp
@@ -46,7 +46,7 @@ ValueObjectSP
ValueObjectMemory::Create (ExecutionContextScope *exe_scope,
const char *name,
const Address &address,
- const ClangASTType &ast_type)
+ const CompilerType &ast_type)
{
return (new ValueObjectMemory (exe_scope, name, address, ast_type))->GetSP();
}
@@ -58,7 +58,7 @@ ValueObjectMemory::ValueObjectMemory (ExecutionContextScope *exe_scope,
ValueObject(exe_scope),
m_address (address),
m_type_sp(type_sp),
- m_clang_type()
+ m_compiler_type()
{
// Do not attempt to construct one of these objects with no variable!
assert (m_type_sp.get() != NULL);
@@ -90,21 +90,21 @@ ValueObjectMemory::ValueObjectMemory (ExecutionContextScope *exe_scope,
ValueObjectMemory::ValueObjectMemory (ExecutionContextScope *exe_scope,
const char *name,
const Address &address,
- const ClangASTType &ast_type) :
+ const CompilerType &ast_type) :
ValueObject(exe_scope),
m_address (address),
m_type_sp(),
- m_clang_type(ast_type)
+ m_compiler_type(ast_type)
{
// Do not attempt to construct one of these objects with no variable!
- assert (m_clang_type.GetASTContext());
- assert (m_clang_type.GetOpaqueQualType());
+ assert (m_compiler_type.GetTypeSystem());
+ assert (m_compiler_type.GetOpaqueQualType());
TargetSP target_sp (GetTargetSP());
SetName (ConstString(name));
-// m_value.SetContext(Value::eContextTypeClangType, m_clang_type.GetOpaqueQualType());
- m_value.SetClangType(m_clang_type);
+// m_value.SetContext(Value::eContextTypeClangType, m_compiler_type.GetOpaqueQualType());
+ m_value.SetCompilerType(m_compiler_type);
lldb::addr_t load_address = m_address.GetLoadAddress (target_sp.get());
if (load_address != LLDB_INVALID_ADDRESS)
{
@@ -131,12 +131,12 @@ ValueObjectMemory::~ValueObjectMemory()
{
}
-ClangASTType
-ValueObjectMemory::GetClangTypeImpl ()
+CompilerType
+ValueObjectMemory::GetCompilerTypeImpl ()
{
if (m_type_sp)
- return m_type_sp->GetClangForwardType();
- return m_clang_type;
+ return m_type_sp->GetForwardCompilerType ();
+ return m_compiler_type;
}
ConstString
@@ -144,24 +144,29 @@ ValueObjectMemory::GetTypeName()
{
if (m_type_sp)
return m_type_sp->GetName();
- return m_clang_type.GetConstTypeName();
+ return m_compiler_type.GetConstTypeName();
}
ConstString
ValueObjectMemory::GetDisplayTypeName()
{
if (m_type_sp)
- return m_type_sp->GetClangForwardType().GetDisplayTypeName();
- return m_clang_type.GetDisplayTypeName();
+ return m_type_sp->GetForwardCompilerType ().GetDisplayTypeName();
+ return m_compiler_type.GetDisplayTypeName();
}
size_t
-ValueObjectMemory::CalculateNumChildren()
+ValueObjectMemory::CalculateNumChildren(uint32_t max)
{
if (m_type_sp)
- return m_type_sp->GetNumChildren(true);
+ {
+ auto child_count = m_type_sp->GetNumChildren(true);
+ return child_count <= max ? child_count : max;
+ }
+
const bool omit_empty_base_classes = true;
- return m_clang_type.GetNumChildren (omit_empty_base_classes);
+ auto child_count = m_compiler_type.GetNumChildren (omit_empty_base_classes);
+ return child_count <= max ? child_count : max;
}
uint64_t
@@ -169,7 +174,7 @@ ValueObjectMemory::GetByteSize()
{
if (m_type_sp)
return m_type_sp->GetByteSize();
- return m_clang_type.GetByteSize (nullptr);
+ return m_compiler_type.GetByteSize (nullptr);
}
lldb::ValueType
@@ -249,8 +254,8 @@ ValueObjectMemory::UpdateValue ()
value.SetContext(Value::eContextTypeLLDBType, m_type_sp.get());
else
{
- //value.SetContext(Value::eContextTypeClangType, m_clang_type.GetOpaqueQualType());
- value.SetClangType(m_clang_type);
+ //value.SetContext(Value::eContextTypeClangType, m_compiler_type.GetOpaqueQualType());
+ value.SetCompilerType(m_compiler_type);
}
m_error = value.GetValueAsData(&exe_ctx, m_data, 0, GetModule().get());
diff --git a/source/Core/ValueObjectRegister.cpp b/source/Core/ValueObjectRegister.cpp
index 0db1f0cd45cf..c7845cd03207 100644
--- a/source/Core/ValueObjectRegister.cpp
+++ b/source/Core/ValueObjectRegister.cpp
@@ -15,7 +15,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Module.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/TypeList.h"
#include "lldb/Target/ExecutionContext.h"
@@ -42,10 +42,10 @@ ValueObjectRegisterContext::~ValueObjectRegisterContext()
{
}
-ClangASTType
-ValueObjectRegisterContext::GetClangTypeImpl ()
+CompilerType
+ValueObjectRegisterContext::GetCompilerTypeImpl ()
{
- return ClangASTType();
+ return CompilerType();
}
ConstString
@@ -67,9 +67,10 @@ ValueObjectRegisterContext::GetQualifiedTypeName()
}
size_t
-ValueObjectRegisterContext::CalculateNumChildren()
+ValueObjectRegisterContext::CalculateNumChildren(uint32_t max)
{
- return m_reg_ctx_sp->GetRegisterSetCount();
+ auto reg_set_count = m_reg_ctx_sp->GetRegisterSetCount();
+ return reg_set_count <= max ? reg_set_count : max;
}
uint64_t
@@ -144,10 +145,10 @@ ValueObjectRegisterSet::~ValueObjectRegisterSet()
{
}
-ClangASTType
-ValueObjectRegisterSet::GetClangTypeImpl ()
+CompilerType
+ValueObjectRegisterSet::GetCompilerTypeImpl ()
{
- return ClangASTType();
+ return CompilerType();
}
ConstString
@@ -163,11 +164,14 @@ ValueObjectRegisterSet::GetQualifiedTypeName()
}
size_t
-ValueObjectRegisterSet::CalculateNumChildren()
+ValueObjectRegisterSet::CalculateNumChildren(uint32_t max)
{
const RegisterSet *reg_set = m_reg_ctx_sp->GetRegisterSet(m_reg_set_idx);
if (reg_set)
- return reg_set->num_registers;
+ {
+ auto reg_count = reg_set->num_registers;
+ return reg_count <= max ? reg_count : max;
+ }
return 0;
}
@@ -279,7 +283,7 @@ ValueObjectRegister::ValueObjectRegister (ValueObject &parent, lldb::RegisterCon
m_reg_info (),
m_reg_value (),
m_type_name (),
- m_clang_type ()
+ m_compiler_type ()
{
assert (reg_ctx_sp.get());
ConstructObject(reg_num);
@@ -297,7 +301,7 @@ ValueObjectRegister::ValueObjectRegister (ExecutionContextScope *exe_scope, lldb
m_reg_info (),
m_reg_value (),
m_type_name (),
- m_clang_type ()
+ m_compiler_type ()
{
assert (reg_ctx);
ConstructObject(reg_num);
@@ -307,10 +311,10 @@ ValueObjectRegister::~ValueObjectRegister()
{
}
-ClangASTType
-ValueObjectRegister::GetClangTypeImpl ()
+CompilerType
+ValueObjectRegister::GetCompilerTypeImpl ()
{
- if (!m_clang_type.IsValid())
+ if (!m_compiler_type.IsValid())
{
ExecutionContext exe_ctx (GetExecutionContextRef());
Target *target = exe_ctx.GetTargetPtr();
@@ -319,26 +323,29 @@ ValueObjectRegister::GetClangTypeImpl ()
Module *exe_module = target->GetExecutableModulePointer();
if (exe_module)
{
- m_clang_type = exe_module->GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize (m_reg_info.encoding,
- m_reg_info.byte_size * 8);
+ TypeSystem *type_system = exe_module->GetTypeSystemForLanguage (eLanguageTypeC);
+ if (type_system)
+ m_compiler_type = type_system->GetBuiltinTypeForEncodingAndBitSize (m_reg_info.encoding,
+ m_reg_info.byte_size * 8);
}
}
}
- return m_clang_type;
+ return m_compiler_type;
}
ConstString
ValueObjectRegister::GetTypeName()
{
if (m_type_name.IsEmpty())
- m_type_name = GetClangType().GetConstTypeName ();
+ m_type_name = GetCompilerType().GetConstTypeName ();
return m_type_name;
}
size_t
-ValueObjectRegister::CalculateNumChildren()
+ValueObjectRegister::CalculateNumChildren(uint32_t max)
{
- return GetClangType().GetNumChildren(true);
+ auto children_count = GetCompilerType().GetNumChildren (true);
+ return children_count <= max ? children_count : max;
}
uint64_t
diff --git a/source/Core/ValueObjectSyntheticFilter.cpp b/source/Core/ValueObjectSyntheticFilter.cpp
index 867b52016298..0ccc4385e3cc 100644
--- a/source/Core/ValueObjectSyntheticFilter.cpp
+++ b/source/Core/ValueObjectSyntheticFilter.cpp
@@ -1,4 +1,4 @@
-//===-- ValueObjectSyntheticFilter.cpp -----------------------------*- C++ -*-===//
+//===-- ValueObjectSyntheticFilter.cpp --------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/ValueObjectSyntheticFilter.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Core/ValueObjectSyntheticFilter.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
@@ -26,35 +25,34 @@ public:
{}
size_t
- CalculateNumChildren()
+ CalculateNumChildren() override
{
return m_backend.GetNumChildren();
}
lldb::ValueObjectSP
- GetChildAtIndex (size_t idx)
+ GetChildAtIndex(size_t idx) override
{
return m_backend.GetChildAtIndex(idx, true);
}
-
+
size_t
- GetIndexOfChildWithName (const ConstString &name)
+ GetIndexOfChildWithName(const ConstString &name) override
{
return m_backend.GetIndexOfChildWithName(name);
}
bool
- MightHaveChildren ()
+ MightHaveChildren() override
{
return true;
}
bool
- Update()
+ Update() override
{
return false;
}
-
};
ValueObjectSynthetic::ValueObjectSynthetic (ValueObject &parent, lldb::SyntheticChildrenSP filter) :
@@ -78,14 +76,12 @@ ValueObjectSynthetic::ValueObjectSynthetic (ValueObject &parent, lldb::Synthetic
CreateSynthFilter();
}
-ValueObjectSynthetic::~ValueObjectSynthetic()
-{
-}
+ValueObjectSynthetic::~ValueObjectSynthetic() = default;
-ClangASTType
-ValueObjectSynthetic::GetClangTypeImpl ()
+CompilerType
+ValueObjectSynthetic::GetCompilerTypeImpl ()
{
- return m_parent->GetClangType();
+ return m_parent->GetCompilerType();
}
ConstString
@@ -107,12 +103,16 @@ ValueObjectSynthetic::GetDisplayTypeName()
}
size_t
-ValueObjectSynthetic::CalculateNumChildren()
+ValueObjectSynthetic::CalculateNumChildren(uint32_t max)
{
UpdateValueIfNeeded();
if (m_synthetic_children_count < UINT32_MAX)
- return m_synthetic_children_count;
- return (m_synthetic_children_count = m_synth_filter_ap->CalculateNumChildren());
+ return m_synthetic_children_count <= max ? m_synthetic_children_count : max;
+
+ if (max < UINT32_MAX)
+ return m_synth_filter_ap->CalculateNumChildren(max);
+ else
+ return (m_synthetic_children_count = m_synth_filter_ap->CalculateNumChildren(max));
}
lldb::ValueObjectSP
@@ -217,12 +217,13 @@ ValueObjectSynthetic::GetChildAtIndex (size_t idx, bool can_create)
ValueObject *valobj;
if (m_children_byindex.GetValueForKey(idx, valobj) == false)
{
- if (can_create && m_synth_filter_ap.get() != NULL)
+ if (can_create && m_synth_filter_ap.get() != nullptr)
{
lldb::ValueObjectSP synth_guy = m_synth_filter_ap->GetChildAtIndex (idx);
if (!synth_guy)
return synth_guy;
m_children_byindex.SetValueForKey(idx, synth_guy.get());
+ synth_guy->SetPreferredDisplayLanguageIfNeeded(GetPreferredDisplayLanguage());
return synth_guy;
}
else
@@ -253,7 +254,7 @@ ValueObjectSynthetic::GetIndexOfChildWithName (const ConstString &name)
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() != NULL)
+ if (!did_find && m_synth_filter_ap.get() != nullptr)
{
uint32_t index = m_synth_filter_ap->GetIndexOfChildWithName (name);
if (index == UINT32_MAX)
@@ -261,7 +262,7 @@ ValueObjectSynthetic::GetIndexOfChildWithName (const ConstString &name)
m_name_toindex.SetValueForKey(name.GetCString(), index);
return index;
}
- else if (!did_find && m_synth_filter_ap.get() == NULL)
+ else if (!did_find && m_synth_filter_ap.get() == nullptr)
return UINT32_MAX;
else /*if (iter != m_name_toindex.end())*/
return found_index;
@@ -314,3 +315,50 @@ ValueObjectSynthetic::SetFormat (lldb::Format format)
this->ValueObject::SetFormat(format);
this->ClearUserVisibleData(eClearUserVisibleDataItemsAll);
}
+
+void
+ValueObjectSynthetic::SetPreferredDisplayLanguage (lldb::LanguageType lang)
+{
+ this->ValueObject::SetPreferredDisplayLanguage(lang);
+ if (m_parent)
+ m_parent->SetPreferredDisplayLanguage(lang);
+}
+
+lldb::LanguageType
+ValueObjectSynthetic::GetPreferredDisplayLanguage ()
+{
+ if (m_preferred_display_language == lldb::eLanguageTypeUnknown)
+ {
+ if (m_parent)
+ return m_parent->GetPreferredDisplayLanguage();
+ return lldb::eLanguageTypeUnknown;
+ }
+ else
+ return m_preferred_display_language;
+}
+
+bool
+ValueObjectSynthetic::GetDeclaration (Declaration &decl)
+{
+ if (m_parent)
+ return m_parent->GetDeclaration(decl);
+
+ return ValueObject::GetDeclaration(decl);
+}
+
+uint64_t
+ValueObjectSynthetic::GetLanguageFlags ()
+{
+ if (m_parent)
+ return m_parent->GetLanguageFlags();
+ return this->ValueObject::GetLanguageFlags();
+}
+
+void
+ValueObjectSynthetic::SetLanguageFlags (uint64_t flags)
+{
+ if (m_parent)
+ m_parent->SetLanguageFlags(flags);
+ else
+ this->ValueObject::SetLanguageFlags(flags);
+}
diff --git a/source/Core/ValueObjectVariable.cpp b/source/Core/ValueObjectVariable.cpp
index c86bece42eb8..389b7c54243d 100644
--- a/source/Core/ValueObjectVariable.cpp
+++ b/source/Core/ValueObjectVariable.cpp
@@ -54,13 +54,13 @@ ValueObjectVariable::~ValueObjectVariable()
{
}
-ClangASTType
-ValueObjectVariable::GetClangTypeImpl ()
+CompilerType
+ValueObjectVariable::GetCompilerTypeImpl ()
{
Type *var_type = m_variable_sp->GetType();
if (var_type)
- return var_type->GetClangForwardType();
- return ClangASTType();
+ return var_type->GetForwardCompilerType ();
+ return CompilerType();
}
ConstString
@@ -77,7 +77,7 @@ ValueObjectVariable::GetDisplayTypeName()
{
Type * var_type = m_variable_sp->GetType();
if (var_type)
- return var_type->GetClangForwardType().GetDisplayTypeName();
+ return var_type->GetForwardCompilerType ().GetDisplayTypeName();
return ConstString();
}
@@ -91,15 +91,16 @@ ValueObjectVariable::GetQualifiedTypeName()
}
size_t
-ValueObjectVariable::CalculateNumChildren()
+ValueObjectVariable::CalculateNumChildren(uint32_t max)
{
- ClangASTType type(GetClangType());
+ CompilerType type(GetCompilerType());
if (!type.IsValid())
return 0;
const bool omit_empty_base_classes = true;
- return type.GetNumChildren(omit_empty_base_classes);
+ auto child_count = type.GetNumChildren(omit_empty_base_classes);
+ return child_count <= max ? child_count : max;
}
uint64_t
@@ -107,7 +108,7 @@ ValueObjectVariable::GetByteSize()
{
ExecutionContext exe_ctx(GetExecutionContextRef());
- ClangASTType type(GetClangType());
+ CompilerType type(GetCompilerType());
if (!type.IsValid())
return 0;
@@ -168,15 +169,15 @@ ValueObjectVariable::UpdateValue ()
m_resolved_value = m_value;
m_value.SetContext(Value::eContextTypeVariable, variable);
- ClangASTType clang_type = GetClangType();
- if (clang_type.IsValid())
- m_value.SetClangType(clang_type);
+ CompilerType compiler_type = GetCompilerType();
+ if (compiler_type.IsValid())
+ m_value.SetCompilerType(compiler_type);
Value::ValueType value_type = m_value.GetValueType();
Process *process = exe_ctx.GetProcessPtr();
const bool process_is_alive = process && process->IsAlive();
- const uint32_t type_info = clang_type.GetTypeInfo();
+ const uint32_t type_info = compiler_type.GetTypeInfo();
const bool is_pointer_or_ref = (type_info & (lldb::eTypeIsPointer | lldb::eTypeIsReference)) != 0;
switch (value_type)
diff --git a/source/DataFormatters/CXXFormatterFunctions.cpp b/source/DataFormatters/CXXFormatterFunctions.cpp
deleted file mode 100644
index 49eacee42f78..000000000000
--- a/source/DataFormatters/CXXFormatterFunctions.cpp
+++ /dev/null
@@ -1,1228 +0,0 @@
-//===-- CXXFormatterFunctions.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/DataFormatters/CXXFormatterFunctions.h"
-#include "lldb/DataFormatters/StringPrinter.h"
-#include "lldb/DataFormatters/TypeSummary.h"
-
-#include "llvm/Support/ConvertUTF.h"
-
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/ValueObject.h"
-#include "lldb/Core/ValueObjectConstResult.h"
-#include "lldb/Host/Endian.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Target/SectionLoadList.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
-
-#include "lldb/Utility/ProcessStructReader.h"
-
-#include <algorithm>
-
-#if __ANDROID_NDK__
-#include <sys/types.h>
-#endif
-
-#include "lldb/Host/Time.h"
-
-using namespace lldb;
-using namespace lldb_private;
-using namespace lldb_private::formatters;
-
-StackFrame*
-lldb_private::formatters::GetViableFrame (ExecutionContext exe_ctx)
-{
- StackFrame* frame = exe_ctx.GetFramePtr();
- if (frame)
- return frame;
-
- Process* process = exe_ctx.GetProcessPtr();
- if (!process)
- return nullptr;
-
- ThreadSP thread_sp(process->GetThreadList().GetSelectedThread());
- if (thread_sp)
- return thread_sp->GetSelectedFrame().get();
- return nullptr;
-}
-
-bool
-lldb_private::formatters::ExtractValueFromObjCExpression (ValueObject &valobj,
- const char* target_type,
- const char* selector,
- uint64_t &value)
-{
- if (!target_type || !*target_type)
- return false;
- if (!selector || !*selector)
- return false;
- StreamString expr;
- expr.Printf("(%s)[(id)0x%" PRIx64 " %s]",target_type,valobj.GetPointerValue(),selector);
- ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
- lldb::ValueObjectSP result_sp;
- Target* target = exe_ctx.GetTargetPtr();
- StackFrame* stack_frame = GetViableFrame(exe_ctx);
- if (!target || !stack_frame)
- return false;
-
- EvaluateExpressionOptions options;
- options.SetCoerceToId(false);
- options.SetUnwindOnError(true);
- options.SetKeepInMemory(true);
-
- target->EvaluateExpression(expr.GetData(),
- stack_frame,
- result_sp,
- options);
- if (!result_sp)
- return false;
- value = result_sp->GetValueAsUnsigned(0);
- return true;
-}
-
-bool
-lldb_private::formatters::ExtractSummaryFromObjCExpression (ValueObject &valobj,
- const char* target_type,
- const char* selector,
- Stream &stream)
-{
- if (!target_type || !*target_type)
- return false;
- if (!selector || !*selector)
- return false;
- StreamString expr;
- expr.Printf("(%s)[(id)0x%" PRIx64 " %s]",target_type,valobj.GetPointerValue(),selector);
- ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
- lldb::ValueObjectSP result_sp;
- Target* target = exe_ctx.GetTargetPtr();
- StackFrame* stack_frame = GetViableFrame(exe_ctx);
- if (!target || !stack_frame)
- return false;
-
- EvaluateExpressionOptions options;
- options.SetCoerceToId(false);
- options.SetUnwindOnError(true);
- options.SetKeepInMemory(true);
- options.SetUseDynamic(lldb::eDynamicCanRunTarget);
-
- target->EvaluateExpression(expr.GetData(),
- stack_frame,
- result_sp,
- options);
- if (!result_sp)
- return false;
- stream.Printf("%s",result_sp->GetSummaryAsCString());
- return true;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::CallSelectorOnObject (ValueObject &valobj,
- const char* return_type,
- const char* selector,
- uint64_t index)
-{
- lldb::ValueObjectSP valobj_sp;
- if (!return_type || !*return_type)
- return valobj_sp;
- if (!selector || !*selector)
- return valobj_sp;
- StreamString expr_path_stream;
- valobj.GetExpressionPath(expr_path_stream, false);
- StreamString expr;
- expr.Printf("(%s)[%s %s:%" PRId64 "]",return_type,expr_path_stream.GetData(),selector,index);
- ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
- lldb::ValueObjectSP result_sp;
- Target* target = exe_ctx.GetTargetPtr();
- StackFrame* stack_frame = GetViableFrame(exe_ctx);
- if (!target || !stack_frame)
- return valobj_sp;
-
- EvaluateExpressionOptions options;
- options.SetCoerceToId(false);
- options.SetUnwindOnError(true);
- options.SetKeepInMemory(true);
- options.SetUseDynamic(lldb::eDynamicCanRunTarget);
-
- target->EvaluateExpression(expr.GetData(),
- stack_frame,
- valobj_sp,
- options);
- return valobj_sp;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::CallSelectorOnObject (ValueObject &valobj,
- const char* return_type,
- const char* selector,
- const char* key)
-{
- lldb::ValueObjectSP valobj_sp;
- if (!return_type || !*return_type)
- return valobj_sp;
- if (!selector || !*selector)
- return valobj_sp;
- if (!key || !*key)
- return valobj_sp;
- StreamString expr_path_stream;
- valobj.GetExpressionPath(expr_path_stream, false);
- StreamString expr;
- expr.Printf("(%s)[%s %s:%s]",return_type,expr_path_stream.GetData(),selector,key);
- ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
- lldb::ValueObjectSP result_sp;
- Target* target = exe_ctx.GetTargetPtr();
- StackFrame* stack_frame = GetViableFrame(exe_ctx);
- if (!target || !stack_frame)
- return valobj_sp;
-
- EvaluateExpressionOptions options;
- options.SetCoerceToId(false);
- options.SetUnwindOnError(true);
- options.SetKeepInMemory(true);
- options.SetUseDynamic(lldb::eDynamicCanRunTarget);
-
- target->EvaluateExpression(expr.GetData(),
- stack_frame,
- valobj_sp,
- options);
- return valobj_sp;
-}
-
-bool
-lldb_private::formatters::FunctionPointerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
-{
- std::string destination;
- StreamString sstr;
- AddressType func_ptr_address_type = eAddressTypeInvalid;
- addr_t func_ptr_address = valobj.GetPointerValue (&func_ptr_address_type);
- if (func_ptr_address != 0 && func_ptr_address != LLDB_INVALID_ADDRESS)
- {
- switch (func_ptr_address_type)
- {
- case eAddressTypeInvalid:
- case eAddressTypeFile:
- case eAddressTypeHost:
- break;
-
- case eAddressTypeLoad:
- {
- ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
-
- Address so_addr;
- Target *target = exe_ctx.GetTargetPtr();
- if (target && target->GetSectionLoadList().IsEmpty() == false)
- {
- if (target->GetSectionLoadList().ResolveLoadAddress(func_ptr_address, so_addr))
- {
- so_addr.Dump (&sstr,
- exe_ctx.GetBestExecutionContextScope(),
- Address::DumpStyleResolvedDescription,
- Address::DumpStyleSectionNameOffset);
- }
- }
- }
- break;
- }
- }
- if (sstr.GetSize() > 0)
- {
- stream.Printf("(%s)", sstr.GetData());
- return true;
- }
- else
- return false;
-}
-
-bool
-lldb_private::formatters::Char16StringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions&)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
-
- if (!valobj_addr)
- return false;
-
- ReadStringAndDumpToStreamOptions options(valobj);
- options.SetLocation(valobj_addr);
- options.SetProcessSP(process_sp);
- options.SetStream(&stream);
- options.SetPrefixToken('u');
-
- if (!ReadStringAndDumpToStream<StringElementType::UTF16>(options))
- {
- stream.Printf("Summary Unavailable");
- return true;
- }
-
- return true;
-}
-
-bool
-lldb_private::formatters::Char32StringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions&)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
-
- if (!valobj_addr)
- return false;
-
- ReadStringAndDumpToStreamOptions options(valobj);
- options.SetLocation(valobj_addr);
- options.SetProcessSP(process_sp);
- options.SetStream(&stream);
- options.SetPrefixToken('U');
-
- if (!ReadStringAndDumpToStream<StringElementType::UTF32>(options))
- {
- stream.Printf("Summary Unavailable");
- return true;
- }
-
- return true;
-}
-
-bool
-lldb_private::formatters::WCharStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions&)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- lldb::addr_t data_addr = 0;
-
- if (valobj.IsPointerType())
- data_addr = valobj.GetValueAsUnsigned(0);
- else if (valobj.IsArrayType())
- data_addr = valobj.GetAddressOf();
-
- if (data_addr == 0 || data_addr == LLDB_INVALID_ADDRESS)
- return false;
-
- clang::ASTContext* ast = valobj.GetClangType().GetASTContext();
-
- if (!ast)
- return false;
-
- ClangASTType wchar_clang_type = ClangASTContext::GetBasicType(ast, lldb::eBasicTypeWChar);
- const uint32_t wchar_size = wchar_clang_type.GetBitSize(nullptr); // Safe to pass NULL for exe_scope here
-
- ReadStringAndDumpToStreamOptions options(valobj);
- options.SetLocation(data_addr);
- options.SetProcessSP(process_sp);
- options.SetStream(&stream);
- options.SetPrefixToken('L');
-
- switch (wchar_size)
- {
- case 8:
- return ReadStringAndDumpToStream<StringElementType::UTF8>(options);
- case 16:
- return ReadStringAndDumpToStream<StringElementType::UTF16>(options);
- case 32:
- return ReadStringAndDumpToStream<StringElementType::UTF32>(options);
- default:
- stream.Printf("size for wchar_t is not valid");
- return true;
- }
- return true;
-}
-
-bool
-lldb_private::formatters::Char16SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions&)
-{
- DataExtractor data;
- Error error;
- valobj.GetData(data, error);
-
- if (error.Fail())
- return false;
-
- std::string value;
- valobj.GetValueAsCString(lldb::eFormatUnicode16, value);
- if (!value.empty())
- stream.Printf("%s ", value.c_str());
-
- ReadBufferAndDumpToStreamOptions options(valobj);
- options.SetData(data);
- options.SetStream(&stream);
- options.SetPrefixToken('u');
- options.SetQuote('\'');
- options.SetSourceSize(1);
-
- return ReadBufferAndDumpToStream<StringElementType::UTF16>(options);
-}
-
-bool
-lldb_private::formatters::Char32SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions&)
-{
- DataExtractor data;
- Error error;
- valobj.GetData(data, error);
-
- if (error.Fail())
- return false;
-
- std::string value;
- valobj.GetValueAsCString(lldb::eFormatUnicode32, value);
- if (!value.empty())
- stream.Printf("%s ", value.c_str());
-
- ReadBufferAndDumpToStreamOptions options(valobj);
- options.SetData(data);
- options.SetStream(&stream);
- options.SetPrefixToken('U');
- options.SetQuote('\'');
- options.SetSourceSize(1);
-
- return ReadBufferAndDumpToStream<StringElementType::UTF32>(options);
-}
-
-bool
-lldb_private::formatters::WCharSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions&)
-{
- DataExtractor data;
- Error error;
- valobj.GetData(data, error);
-
- if (error.Fail())
- return false;
-
- ReadBufferAndDumpToStreamOptions options(valobj);
- options.SetData(data);
- options.SetStream(&stream);
- options.SetPrefixToken('L');
- options.SetQuote('\'');
- options.SetSourceSize(1);
-
- return ReadBufferAndDumpToStream<StringElementType::UTF16>(options);
-}
-
-// the field layout in a libc++ string (cap, side, data or data, size, cap)
-enum LibcxxStringLayoutMode
-{
- eLibcxxStringLayoutModeCSD = 0,
- eLibcxxStringLayoutModeDSC = 1,
- eLibcxxStringLayoutModeInvalid = 0xffff
-};
-
-// this function abstracts away the layout and mode details of a libc++ string
-// and returns the address of the data and the size ready for callers to consume
-static bool
-ExtractLibcxxStringInfo (ValueObject& valobj,
- ValueObjectSP &location_sp,
- uint64_t& size)
-{
- ValueObjectSP D(valobj.GetChildAtIndexPath({0,0,0,0}));
- if (!D)
- return false;
-
- ValueObjectSP layout_decider(D->GetChildAtIndexPath({0,0}));
-
- // this child should exist
- if (!layout_decider)
- return false;
-
- ConstString g_data_name("__data_");
- ConstString g_size_name("__size_");
- bool short_mode = false; // this means the string is in short-mode and the data is stored inline
- LibcxxStringLayoutMode layout = (layout_decider->GetName() == g_data_name) ? eLibcxxStringLayoutModeDSC : eLibcxxStringLayoutModeCSD;
- uint64_t size_mode_value = 0;
-
- if (layout == eLibcxxStringLayoutModeDSC)
- {
- ValueObjectSP size_mode(D->GetChildAtIndexPath({1,1,0}));
- if (!size_mode)
- return false;
-
- if (size_mode->GetName() != g_size_name)
- {
- // we are hitting the padding structure, move along
- size_mode = D->GetChildAtIndexPath({1,1,1});
- if (!size_mode)
- return false;
- }
-
- size_mode_value = (size_mode->GetValueAsUnsigned(0));
- short_mode = ((size_mode_value & 0x80) == 0);
- }
- else
- {
- ValueObjectSP size_mode(D->GetChildAtIndexPath({1,0,0}));
- if (!size_mode)
- return false;
-
- size_mode_value = (size_mode->GetValueAsUnsigned(0));
- short_mode = ((size_mode_value & 1) == 0);
- }
-
- if (short_mode)
- {
- ValueObjectSP s(D->GetChildAtIndex(1, true));
- if (!s)
- return false;
- location_sp = s->GetChildAtIndex((layout == eLibcxxStringLayoutModeDSC) ? 0 : 1, true);
- size = (layout == eLibcxxStringLayoutModeDSC) ? size_mode_value : ((size_mode_value >> 1) % 256);
- return (location_sp.get() != nullptr);
- }
- else
- {
- ValueObjectSP l(D->GetChildAtIndex(0, true));
- if (!l)
- return false;
- // we can use the layout_decider object as the data pointer
- location_sp = (layout == eLibcxxStringLayoutModeDSC) ? layout_decider : l->GetChildAtIndex(2, true);
- ValueObjectSP size_vo(l->GetChildAtIndex(1, true));
- if (!size_vo || !location_sp)
- return false;
- size = size_vo->GetValueAsUnsigned(0);
- return true;
- }
-}
-
-bool
-lldb_private::formatters::LibcxxWStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
-{
- uint64_t size = 0;
- ValueObjectSP location_sp((ValueObject*)nullptr);
- if (!ExtractLibcxxStringInfo(valobj, location_sp, size))
- return false;
- if (size == 0)
- {
- stream.Printf("L\"\"");
- return true;
- }
- if (!location_sp)
- return false;
- return WCharStringSummaryProvider(*location_sp.get(), stream, options);
-}
-
-bool
-lldb_private::formatters::LibcxxStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& summary_options)
-{
- uint64_t size = 0;
- ValueObjectSP location_sp((ValueObject*)nullptr);
-
- if (!ExtractLibcxxStringInfo(valobj, location_sp, size))
- return false;
-
- if (size == 0)
- {
- stream.Printf("\"\"");
- return true;
- }
-
- if (!location_sp)
- return false;
-
- DataExtractor extractor;
- if (summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryCapped)
- size = std::min<decltype(size)>(size, valobj.GetTargetSP()->GetMaximumSizeOfStringSummary());
- location_sp->GetPointeeData(extractor, 0, size);
-
- ReadBufferAndDumpToStreamOptions options(valobj);
- options.SetData(extractor); // none of this matters for a string - pass some defaults
- options.SetStream(&stream);
- options.SetPrefixToken(0);
- options.SetQuote('"');
- options.SetSourceSize(size);
- lldb_private::formatters::ReadBufferAndDumpToStream<lldb_private::formatters::StringElementType::ASCII>(options);
-
- return true;
-}
-
-bool
-lldb_private::formatters::ObjCClassSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
-
- if (!runtime)
- return false;
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptorFromISA(valobj.GetValueAsUnsigned(0)));
-
- if (!descriptor.get() || !descriptor->IsValid())
- return false;
-
- const char* class_name = descriptor->GetClassName().GetCString();
-
- if (!class_name || !*class_name)
- return false;
-
- stream.Printf("%s",class_name);
- return true;
-}
-
-class ObjCClassSyntheticChildrenFrontEnd : public SyntheticChildrenFrontEnd
-{
-public:
- ObjCClassSyntheticChildrenFrontEnd (lldb::ValueObjectSP valobj_sp) :
- SyntheticChildrenFrontEnd(*valobj_sp.get())
- {
- }
-
- virtual size_t
- CalculateNumChildren ()
- {
- return 0;
- }
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx)
- {
- return lldb::ValueObjectSP();
- }
-
- virtual bool
- Update()
- {
- return false;
- }
-
- virtual bool
- MightHaveChildren ()
- {
- return false;
- }
-
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name)
- {
- return UINT32_MAX;
- }
-
- virtual
- ~ObjCClassSyntheticChildrenFrontEnd ()
- {
- }
-};
-
-SyntheticChildrenFrontEnd*
-lldb_private::formatters::ObjCClassSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
- return new ObjCClassSyntheticChildrenFrontEnd(valobj_sp);
-}
-
-template<bool needs_at>
-bool
-lldb_private::formatters::NSDataSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
-
- if (!runtime)
- return false;
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
-
- if (!descriptor.get() || !descriptor->IsValid())
- return false;
-
- bool is_64bit = (process_sp->GetAddressByteSize() == 8);
- lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
-
- if (!valobj_addr)
- return false;
-
- uint64_t value = 0;
-
- const char* class_name = descriptor->GetClassName().GetCString();
-
- if (!class_name || !*class_name)
- return false;
-
- if (!strcmp(class_name,"NSConcreteData") ||
- !strcmp(class_name,"NSConcreteMutableData") ||
- !strcmp(class_name,"__NSCFData"))
- {
- uint32_t offset = (is_64bit ? 16 : 8);
- Error error;
- value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + offset, is_64bit ? 8 : 4, 0, error);
- if (error.Fail())
- return false;
- }
- else
- {
- if (!ExtractValueFromObjCExpression(valobj, "int", "length", value))
- return false;
- }
-
- stream.Printf("%s%" PRIu64 " byte%s%s",
- (needs_at ? "@\"" : ""),
- value,
- (value != 1 ? "s" : ""),
- (needs_at ? "\"" : ""));
-
- return true;
-}
-
-static bool
-ReadAsciiBufferAndDumpToStream (lldb::addr_t location,
- lldb::ProcessSP& process_sp,
- Stream& dest,
- uint32_t size = 0,
- Error* error = NULL,
- size_t *data_read = NULL,
- char prefix_token = '@',
- char quote = '"')
-{
- Error my_error;
- size_t my_data_read;
- if (!process_sp || location == 0)
- return false;
-
- if (!size)
- size = process_sp->GetTarget().GetMaximumSizeOfStringSummary();
- else
- size = std::min(size,process_sp->GetTarget().GetMaximumSizeOfStringSummary());
-
- lldb::DataBufferSP buffer_sp(new DataBufferHeap(size,0));
-
- my_data_read = process_sp->ReadCStringFromMemory(location, (char*)buffer_sp->GetBytes(), size, my_error);
-
- if (error)
- *error = my_error;
- if (data_read)
- *data_read = my_data_read;
-
- if (my_error.Fail())
- return false;
-
- dest.Printf("%c%c",prefix_token,quote);
-
- if (my_data_read)
- dest.Printf("%s",(char*)buffer_sp->GetBytes());
-
- dest.Printf("%c",quote);
-
- return true;
-}
-
-bool
-lldb_private::formatters::NSTaggedString_SummaryProvider (ObjCLanguageRuntime::ClassDescriptorSP descriptor, Stream& stream)
-{
- if (!descriptor)
- return false;
- uint64_t len_bits = 0, data_bits = 0;
- if (!descriptor->GetTaggedPointerInfo(&len_bits,&data_bits,nullptr))
- return false;
-
- static const int g_MaxNonBitmaskedLen = 7; //TAGGED_STRING_UNPACKED_MAXLEN
- static const int g_SixbitMaxLen = 9;
- static const int g_fiveBitMaxLen = 11;
-
- static const char *sixBitToCharLookup = "eilotrm.apdnsIc ufkMShjTRxgC4013" "bDNvwyUL2O856P-B79AFKEWV_zGJ/HYX";
-
- if (len_bits > g_fiveBitMaxLen)
- return false;
-
- // this is a fairly ugly trick - pretend that the numeric value is actually a char*
- // this works under a few assumptions:
- // little endian architecture
- // sizeof(uint64_t) > g_MaxNonBitmaskedLen
- if (len_bits <= g_MaxNonBitmaskedLen)
- {
- stream.Printf("@\"%s\"",(const char*)&data_bits);
- return true;
- }
-
- // if the data is bitmasked, we need to actually process the bytes
- uint8_t bitmask = 0;
- uint8_t shift_offset = 0;
-
- if (len_bits <= g_SixbitMaxLen)
- {
- bitmask = 0x03f;
- shift_offset = 6;
- }
- else
- {
- bitmask = 0x01f;
- shift_offset = 5;
- }
-
- std::vector<uint8_t> bytes;
- bytes.resize(len_bits);
- for (; len_bits > 0; data_bits >>= shift_offset, --len_bits)
- {
- uint8_t packed = data_bits & bitmask;
- bytes.insert(bytes.begin(), sixBitToCharLookup[packed]);
- }
-
- stream.Printf("@\"%s\"",&bytes[0]);
- return true;
-}
-
-static ClangASTType
-GetNSPathStore2Type (Target &target)
-{
- static ConstString g_type_name("__lldb_autogen_nspathstore2");
-
- ClangASTContext *ast_ctx = target.GetScratchClangASTContext();
-
- if (!ast_ctx)
- return ClangASTType();
-
- ClangASTType voidstar = ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType();
- ClangASTType uint32 = ast_ctx->GetIntTypeFromBitSize(32, false);
-
- return ast_ctx->GetOrCreateStructForIdentifier(g_type_name, {
- {"isa",voidstar},
- {"lengthAndRef",uint32},
- {"buffer",voidstar}
- });
-}
-
-bool
-lldb_private::formatters::NSStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& summary_options)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
-
- if (!runtime)
- return false;
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
-
- if (!descriptor.get() || !descriptor->IsValid())
- return false;
-
- uint32_t ptr_size = process_sp->GetAddressByteSize();
-
- lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
-
- if (!valobj_addr)
- return false;
-
- const char* class_name = descriptor->GetClassName().GetCString();
-
- if (!class_name || !*class_name)
- return false;
-
- bool is_tagged_ptr = (0 == strcmp(class_name,"NSTaggedPointerString")) && descriptor->GetTaggedPointerInfo();
- // for a tagged pointer, the descriptor has everything we need
- if (is_tagged_ptr)
- return NSTaggedString_SummaryProvider(descriptor, stream);
-
- // if not a tagged pointer that we know about, try the normal route
- uint64_t info_bits_location = valobj_addr + ptr_size;
- if (process_sp->GetByteOrder() != lldb::eByteOrderLittle)
- info_bits_location += 3;
-
- Error error;
-
- uint8_t info_bits = process_sp->ReadUnsignedIntegerFromMemory(info_bits_location, 1, 0, error);
- if (error.Fail())
- return false;
-
- bool is_mutable = (info_bits & 1) == 1;
- bool is_inline = (info_bits & 0x60) == 0;
- bool has_explicit_length = (info_bits & (1 | 4)) != 4;
- bool is_unicode = (info_bits & 0x10) == 0x10;
- bool is_special = strcmp(class_name,"NSPathStore2") == 0;
- bool has_null = (info_bits & 8) == 8;
-
- size_t explicit_length = 0;
- if (!has_null && has_explicit_length && !is_special)
- {
- lldb::addr_t explicit_length_offset = 2*ptr_size;
- if (is_mutable && !is_inline)
- explicit_length_offset = explicit_length_offset + ptr_size; // notInlineMutable.length;
- else if (is_inline)
- explicit_length = explicit_length + 0; // inline1.length;
- else if (!is_inline && !is_mutable)
- explicit_length_offset = explicit_length_offset + ptr_size; // notInlineImmutable1.length;
- else
- explicit_length_offset = 0;
-
- if (explicit_length_offset)
- {
- explicit_length_offset = valobj_addr + explicit_length_offset;
- explicit_length = process_sp->ReadUnsignedIntegerFromMemory(explicit_length_offset, 4, 0, error);
- }
- }
-
- if (strcmp(class_name,"NSString") &&
- strcmp(class_name,"CFStringRef") &&
- strcmp(class_name,"CFMutableStringRef") &&
- strcmp(class_name,"__NSCFConstantString") &&
- strcmp(class_name,"__NSCFString") &&
- strcmp(class_name,"NSCFConstantString") &&
- strcmp(class_name,"NSCFString") &&
- strcmp(class_name,"NSPathStore2"))
- {
- // not one of us - but tell me class name
- stream.Printf("class name = %s",class_name);
- return true;
- }
-
- if (is_mutable)
- {
- uint64_t location = 2 * ptr_size + valobj_addr;
- location = process_sp->ReadPointerFromMemory(location, error);
- if (error.Fail())
- return false;
- if (has_explicit_length && is_unicode)
- {
- ReadStringAndDumpToStreamOptions options(valobj);
- options.SetLocation(location);
- options.SetProcessSP(process_sp);
- options.SetStream(&stream);
- options.SetPrefixToken('@');
- options.SetQuote('"');
- options.SetSourceSize(explicit_length);
- options.SetNeedsZeroTermination(false);
- options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped);
- return ReadStringAndDumpToStream<StringElementType::UTF16>(options);
- }
- else
- {
- ReadStringAndDumpToStreamOptions options(valobj);
- options.SetLocation(location+1);
- options.SetProcessSP(process_sp);
- options.SetStream(&stream);
- options.SetPrefixToken('@');
- options.SetSourceSize(explicit_length);
- options.SetNeedsZeroTermination(false);
- options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped);
- return ReadStringAndDumpToStream<StringElementType::ASCII>(options);
- }
- }
- else if (is_inline && has_explicit_length && !is_unicode && !is_special && !is_mutable)
- {
- uint64_t location = 3 * ptr_size + valobj_addr;
- return ReadAsciiBufferAndDumpToStream(location,process_sp,stream,explicit_length);
- }
- else if (is_unicode)
- {
- uint64_t location = valobj_addr + 2*ptr_size;
- if (is_inline)
- {
- if (!has_explicit_length)
- {
- stream.Printf("found new combo");
- return true;
- }
- else
- location += ptr_size;
- }
- else
- {
- location = process_sp->ReadPointerFromMemory(location, error);
- if (error.Fail())
- return false;
- }
- ReadStringAndDumpToStreamOptions options(valobj);
- options.SetLocation(location);
- options.SetProcessSP(process_sp);
- options.SetStream(&stream);
- options.SetPrefixToken('@');
- options.SetQuote('"');
- options.SetSourceSize(explicit_length);
- options.SetNeedsZeroTermination(has_explicit_length == false);
- options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped);
- return ReadStringAndDumpToStream<StringElementType::UTF16> (options);
- }
- else if (is_special)
- {
- ProcessStructReader reader(valobj.GetProcessSP().get(), valobj.GetValueAsUnsigned(0), GetNSPathStore2Type(*valobj.GetTargetSP()));
- explicit_length = reader.GetField<uint32_t>(ConstString("lengthAndRef")) >> 20;
- lldb::addr_t location = valobj.GetValueAsUnsigned(0) + ptr_size + 4;
-
- ReadStringAndDumpToStreamOptions options(valobj);
- options.SetLocation(location);
- options.SetProcessSP(process_sp);
- options.SetStream(&stream);
- options.SetPrefixToken('@');
- options.SetQuote('"');
- options.SetSourceSize(explicit_length);
- options.SetNeedsZeroTermination(has_explicit_length == false);
- options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped);
- return ReadStringAndDumpToStream<StringElementType::UTF16> (options);
- }
- else if (is_inline)
- {
- uint64_t location = valobj_addr + 2*ptr_size;
- if (!has_explicit_length)
- location++;
- ReadStringAndDumpToStreamOptions options(valobj);
- options.SetLocation(location);
- options.SetProcessSP(process_sp);
- options.SetStream(&stream);
- options.SetPrefixToken('@');
- options.SetSourceSize(explicit_length);
- options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped);
- return ReadStringAndDumpToStream<StringElementType::ASCII>(options);
- }
- else
- {
- uint64_t location = valobj_addr + 2*ptr_size;
- location = process_sp->ReadPointerFromMemory(location, error);
- if (error.Fail())
- return false;
- if (has_explicit_length && !has_null)
- explicit_length++; // account for the fact that there is no NULL and we need to have one added
- ReadStringAndDumpToStreamOptions options(valobj);
- options.SetLocation(location);
- options.SetProcessSP(process_sp);
- options.SetPrefixToken('@');
- options.SetStream(&stream);
- options.SetSourceSize(explicit_length);
- options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped);
- return ReadStringAndDumpToStream<StringElementType::ASCII>(options);
- }
-}
-
-bool
-lldb_private::formatters::NSAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
-{
- TargetSP target_sp(valobj.GetTargetSP());
- if (!target_sp)
- return false;
- uint32_t addr_size = target_sp->GetArchitecture().GetAddressByteSize();
- uint64_t pointer_value = valobj.GetValueAsUnsigned(0);
- if (!pointer_value)
- return false;
- pointer_value += addr_size;
- ClangASTType type(valobj.GetClangType());
- ExecutionContext exe_ctx(target_sp,false);
- ValueObjectSP child_ptr_sp(valobj.CreateValueObjectFromAddress("string_ptr", pointer_value, exe_ctx, type));
- if (!child_ptr_sp)
- return false;
- DataExtractor data;
- Error error;
- child_ptr_sp->GetData(data, error);
- if (error.Fail())
- return false;
- ValueObjectSP child_sp(child_ptr_sp->CreateValueObjectFromData("string_data", data, exe_ctx, type));
- child_sp->GetValueAsUnsigned(0);
- if (child_sp)
- return NSStringSummaryProvider(*child_sp, stream, options);
- return false;
-}
-
-bool
-lldb_private::formatters::NSMutableAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
-{
- return NSAttributedStringSummaryProvider(valobj, stream, options);
-}
-
-bool
-lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
-{
- stream.Printf("%s",valobj.GetObjectDescription());
- return true;
-}
-
-bool
-lldb_private::formatters::ObjCBOOLSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
-{
- const uint32_t type_info = valobj.GetClangType().GetTypeInfo();
-
- ValueObjectSP real_guy_sp = valobj.GetSP();
-
- if (type_info & eTypeIsPointer)
- {
- Error err;
- real_guy_sp = valobj.Dereference(err);
- if (err.Fail() || !real_guy_sp)
- return false;
- }
- else if (type_info & eTypeIsReference)
- {
- real_guy_sp = valobj.GetChildAtIndex(0, true);
- if (!real_guy_sp)
- return false;
- }
- uint64_t value = real_guy_sp->GetValueAsUnsigned(0);
- if (value == 0)
- {
- stream.Printf("NO");
- return true;
- }
- stream.Printf("YES");
- return true;
-}
-
-template <bool is_sel_ptr>
-bool
-lldb_private::formatters::ObjCSELSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
-{
- lldb::ValueObjectSP valobj_sp;
-
- ClangASTType charstar (valobj.GetClangType().GetBasicTypeFromAST(eBasicTypeChar).GetPointerType());
-
- if (!charstar)
- return false;
-
- ExecutionContext exe_ctx(valobj.GetExecutionContextRef());
-
- if (is_sel_ptr)
- {
- lldb::addr_t data_address = valobj.GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
- if (data_address == LLDB_INVALID_ADDRESS)
- return false;
- valobj_sp = ValueObject::CreateValueObjectFromAddress("text", data_address, exe_ctx, charstar);
- }
- else
- {
- DataExtractor data;
- Error error;
- valobj.GetData(data, error);
- if (error.Fail())
- return false;
- valobj_sp = ValueObject::CreateValueObjectFromData("text", data, exe_ctx, charstar);
- }
-
- if (!valobj_sp)
- return false;
-
- stream.Printf("%s",valobj_sp->GetSummaryAsCString());
- return true;
-}
-
-// POSIX has an epoch on Jan-1-1970, but Cocoa prefers Jan-1-2001
-// this call gives the POSIX equivalent of the Cocoa epoch
-time_t
-lldb_private::formatters::GetOSXEpoch ()
-{
- static time_t epoch = 0;
- if (!epoch)
- {
-#ifndef _WIN32
- tzset();
- tm tm_epoch;
- tm_epoch.tm_sec = 0;
- tm_epoch.tm_hour = 0;
- tm_epoch.tm_min = 0;
- tm_epoch.tm_mon = 0;
- tm_epoch.tm_mday = 1;
- tm_epoch.tm_year = 2001-1900; // for some reason, we need to subtract 1900 from this field. not sure why.
- tm_epoch.tm_isdst = -1;
- tm_epoch.tm_gmtoff = 0;
- tm_epoch.tm_zone = NULL;
- epoch = timegm(&tm_epoch);
-#endif
- }
- return epoch;
-}
-
-size_t
-lldb_private::formatters::ExtractIndexFromString (const char* item_name)
-{
- if (!item_name || !*item_name)
- return UINT32_MAX;
- if (*item_name != '[')
- return UINT32_MAX;
- item_name++;
- char* endptr = NULL;
- unsigned long int idx = ::strtoul(item_name, &endptr, 0);
- if (idx == 0 && endptr == item_name)
- return UINT32_MAX;
- if (idx == ULONG_MAX)
- return UINT32_MAX;
- return idx;
-}
-
-lldb_private::formatters::VectorIteratorSyntheticFrontEnd::VectorIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp,
- ConstString item_name) :
-SyntheticChildrenFrontEnd(*valobj_sp.get()),
-m_exe_ctx_ref(),
-m_item_name(item_name),
-m_item_sp()
-{
- if (valobj_sp)
- Update();
-}
-
-bool
-lldb_private::formatters::VectorIteratorSyntheticFrontEnd::Update()
-{
- m_item_sp.reset();
-
- ValueObjectSP valobj_sp = m_backend.GetSP();
- if (!valobj_sp)
- return false;
-
- if (!valobj_sp)
- return false;
-
- ValueObjectSP item_ptr(valobj_sp->GetChildMemberWithName(m_item_name,true));
- if (!item_ptr)
- return false;
- if (item_ptr->GetValueAsUnsigned(0) == 0)
- return false;
- Error err;
- m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
- m_item_sp = CreateValueObjectFromAddress("item", item_ptr->GetValueAsUnsigned(0), m_exe_ctx_ref, item_ptr->GetClangType().GetPointeeType());
- if (err.Fail())
- m_item_sp.reset();
- return false;
-}
-
-size_t
-lldb_private::formatters::VectorIteratorSyntheticFrontEnd::CalculateNumChildren ()
-{
- return 1;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::VectorIteratorSyntheticFrontEnd::GetChildAtIndex (size_t idx)
-{
- if (idx == 0)
- return m_item_sp;
- return lldb::ValueObjectSP();
-}
-
-bool
-lldb_private::formatters::VectorIteratorSyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
-}
-
-size_t
-lldb_private::formatters::VectorIteratorSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- if (name == ConstString("item"))
- return 0;
- return UINT32_MAX;
-}
-
-lldb_private::formatters::VectorIteratorSyntheticFrontEnd::~VectorIteratorSyntheticFrontEnd ()
-{
-}
-
-template bool
-lldb_private::formatters::NSDataSummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&) ;
-
-template bool
-lldb_private::formatters::NSDataSummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&) ;
-
-template bool
-lldb_private::formatters::ObjCSELSummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&) ;
-
-template bool
-lldb_private::formatters::ObjCSELSummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&) ;
diff --git a/source/DataFormatters/CXXFunctionPointer.cpp b/source/DataFormatters/CXXFunctionPointer.cpp
new file mode 100644
index 000000000000..c9e0ccb29698
--- /dev/null
+++ b/source/DataFormatters/CXXFunctionPointer.cpp
@@ -0,0 +1,66 @@
+//===-- CXXFormatterFunctions.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/DataFormatters/CXXFunctionPointer.h"
+
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Target/SectionLoadList.h"
+#include "lldb/Target/Target.h"
+
+#include <string>
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+bool
+lldb_private::formatters::CXXFunctionPointerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
+{
+ std::string destination;
+ StreamString sstr;
+ AddressType func_ptr_address_type = eAddressTypeInvalid;
+ addr_t func_ptr_address = valobj.GetPointerValue (&func_ptr_address_type);
+ if (func_ptr_address != 0 && func_ptr_address != LLDB_INVALID_ADDRESS)
+ {
+ switch (func_ptr_address_type)
+ {
+ case eAddressTypeInvalid:
+ case eAddressTypeFile:
+ case eAddressTypeHost:
+ break;
+
+ case eAddressTypeLoad:
+ {
+ ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
+
+ Address so_addr;
+ Target *target = exe_ctx.GetTargetPtr();
+ if (target && target->GetSectionLoadList().IsEmpty() == false)
+ {
+ if (target->GetSectionLoadList().ResolveLoadAddress(func_ptr_address, so_addr))
+ {
+ so_addr.Dump (&sstr,
+ exe_ctx.GetBestExecutionContextScope(),
+ Address::DumpStyleResolvedDescription,
+ Address::DumpStyleSectionNameOffset);
+ }
+ }
+ }
+ break;
+ }
+ }
+ if (sstr.GetSize() > 0)
+ {
+ stream.Printf("(%s)", sstr.GetData());
+ return true;
+ }
+ else
+ return false;
+}
diff --git a/source/DataFormatters/DataVisualization.cpp b/source/DataFormatters/DataVisualization.cpp
index 361254185b31..14cf13d2f185 100644
--- a/source/DataFormatters/DataVisualization.cpp
+++ b/source/DataFormatters/DataVisualization.cpp
@@ -14,8 +14,6 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Debugger.h"
-
using namespace lldb;
using namespace lldb_private;
@@ -133,6 +131,14 @@ DataVisualization::Categories::GetCategory (const ConstString &category, lldb::T
return (entry.get() != NULL);
}
+bool
+DataVisualization::Categories::GetCategory (lldb::LanguageType language, lldb::TypeCategoryImplSP &entry)
+{
+ if (LanguageCategory *lang_category = GetFormatManager().GetCategoryForLanguage(language))
+ entry = lang_category->GetCategory();
+ return (entry.get() != nullptr);
+}
+
void
DataVisualization::Categories::Add (const ConstString &category)
{
@@ -164,7 +170,14 @@ DataVisualization::Categories::Enable (const ConstString& category,
{
if (GetFormatManager().GetCategory(category)->IsEnabled())
GetFormatManager().DisableCategory(category);
- GetFormatManager().EnableCategory(category, pos);
+ GetFormatManager().EnableCategory(category, pos, std::initializer_list<lldb::LanguageType>());
+}
+
+void
+DataVisualization::Categories::Enable (lldb::LanguageType lang_type)
+{
+ if (LanguageCategory* lang_category = GetFormatManager().GetCategoryForLanguage(lang_type))
+ lang_category->Enable();
}
void
@@ -175,6 +188,13 @@ DataVisualization::Categories::Disable (const ConstString& category)
}
void
+DataVisualization::Categories::Disable (lldb::LanguageType lang_type)
+{
+ if (LanguageCategory* lang_category = GetFormatManager().GetCategoryForLanguage(lang_type))
+ lang_category->Disable();
+}
+
+void
DataVisualization::Categories::Enable (const lldb::TypeCategoryImplSP& category,
TypeCategoryMap::Position pos)
{
@@ -206,9 +226,9 @@ DataVisualization::Categories::DisableStar ()
}
void
-DataVisualization::Categories::LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton)
+DataVisualization::Categories::ForEach (TypeCategoryMap::ForEachCallback callback)
{
- GetFormatManager().LoopThroughCategories(callback, callback_baton);
+ GetFormatManager().ForEachCategory(callback);
}
uint32_t
@@ -248,9 +268,9 @@ DataVisualization::NamedSummaryFormats::Clear ()
}
void
-DataVisualization::NamedSummaryFormats::LoopThrough (TypeSummaryImpl::SummaryCallback callback, void* callback_baton)
+DataVisualization::NamedSummaryFormats::ForEach (std::function<bool(ConstString, const lldb::TypeSummaryImplSP&)> callback)
{
- GetFormatManager().GetNamedSummaryContainer().LoopThrough(callback, callback_baton);
+ GetFormatManager().GetNamedSummaryContainer().ForEach(callback);
}
uint32_t
diff --git a/source/DataFormatters/DumpValueObjectOptions.cpp b/source/DataFormatters/DumpValueObjectOptions.cpp
new file mode 100644
index 000000000000..f3de1257bb80
--- /dev/null
+++ b/source/DataFormatters/DumpValueObjectOptions.cpp
@@ -0,0 +1,245 @@
+//===-- DumpValueObjectOptions.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/DataFormatters/DumpValueObjectOptions.h"
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/ValueObject.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+DumpValueObjectOptions::DumpValueObjectOptions() :
+ m_summary_sp(),
+ m_root_valobj_name(),
+ m_max_ptr_depth(PointerDepth{PointerDepth::Mode::Default,0}),
+ m_decl_printing_helper(),
+ m_use_synthetic(true),
+ m_scope_already_checked(false),
+ m_flat_output(false),
+ m_ignore_cap(false),
+ m_show_types(false),
+ m_show_location(false),
+ m_use_objc(false),
+ m_hide_root_type(false),
+ m_hide_name(false),
+ m_hide_value(false),
+ m_run_validator(false),
+ m_use_type_display_name(true),
+ m_allow_oneliner_mode(true),
+ m_hide_pointer_value(false),
+ m_reveal_empty_aggregates(true)
+{}
+
+
+DumpValueObjectOptions::DumpValueObjectOptions (ValueObject& valobj) :
+ DumpValueObjectOptions()
+{
+ m_use_dynamic = valobj.GetDynamicValueType();
+ m_use_synthetic = valobj.IsSynthetic();
+ m_varformat_language = valobj.GetPreferredDisplayLanguage();
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetMaximumPointerDepth(PointerDepth depth)
+{
+ m_max_ptr_depth = depth;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetMaximumDepth(uint32_t depth)
+{
+ m_max_depth = depth;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetDeclPrintingHelper(DeclPrintingHelper helper)
+{
+ m_decl_printing_helper = helper;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetShowTypes(bool show)
+{
+ m_show_types = show;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetShowLocation(bool show)
+{
+ m_show_location = show;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetUseObjectiveC(bool use)
+{
+ m_use_objc = use;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetShowSummary(bool show)
+{
+ if (show == false)
+ SetOmitSummaryDepth(UINT32_MAX);
+ else
+ SetOmitSummaryDepth(0);
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetUseDynamicType(lldb::DynamicValueType dyn)
+{
+ m_use_dynamic = dyn;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetUseSyntheticValue(bool use_synthetic)
+{
+ m_use_synthetic = use_synthetic;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetScopeChecked(bool check)
+{
+ m_scope_already_checked = check;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetFlatOutput(bool flat)
+{
+ m_flat_output = flat;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetOmitSummaryDepth(uint32_t depth)
+{
+ m_omit_summary_depth = depth;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetIgnoreCap(bool ignore)
+{
+ m_ignore_cap = ignore;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetRawDisplay()
+{
+ SetUseSyntheticValue(false);
+ SetOmitSummaryDepth(UINT32_MAX);
+ SetIgnoreCap(true);
+ SetHideName(false);
+ SetHideValue(false);
+ SetUseTypeDisplayName(false);
+ SetAllowOnelinerMode(false);
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetFormat (lldb::Format format)
+{
+ m_format = format;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetSummary (lldb::TypeSummaryImplSP summary)
+{
+ m_summary_sp = summary;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetRootValueObjectName (const char* name)
+{
+ if (name)
+ m_root_valobj_name.assign(name);
+ else
+ m_root_valobj_name.clear();
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetHideRootType (bool hide_root_type)
+{
+ m_hide_root_type = hide_root_type;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetHideName (bool hide_name)
+{
+ m_hide_name = hide_name;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetHideValue (bool hide_value)
+{
+ m_hide_value = hide_value;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetHidePointerValue (bool hide)
+{
+ m_hide_pointer_value = hide;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetVariableFormatDisplayLanguage (lldb::LanguageType lang)
+{
+ m_varformat_language = lang;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetRunValidator (bool run)
+{
+ m_run_validator = run;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetUseTypeDisplayName (bool dis)
+{
+ m_use_type_display_name = dis;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetAllowOnelinerMode (bool oneliner)
+{
+ m_allow_oneliner_mode = oneliner;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetRevealEmptyAggregates (bool reveal)
+{
+ m_reveal_empty_aggregates = reveal;
+ return *this;
+}
+
diff --git a/source/DataFormatters/FormatClasses.cpp b/source/DataFormatters/FormatClasses.cpp
index f27b45b30491..2e4acd175f1f 100644
--- a/source/DataFormatters/FormatClasses.cpp
+++ b/source/DataFormatters/FormatClasses.cpp
@@ -9,6 +9,8 @@
#include "lldb/DataFormatters/FormatClasses.h"
+#include "lldb/DataFormatters/FormatManager.h"
+
// C Includes
// C++ Includes
@@ -20,3 +22,48 @@
using namespace lldb;
using namespace lldb_private;
+FormattersMatchData::FormattersMatchData (ValueObject& valobj, lldb::DynamicValueType use_dynamic) :
+ m_valobj(valobj),
+ m_dynamic_value_type(use_dynamic),
+ m_formatters_match_vector({},false),
+ m_type_for_cache(),
+ m_candidate_languages()
+{
+ m_type_for_cache = FormatManager::GetTypeForCache(valobj, use_dynamic);
+ m_candidate_languages = FormatManager::GetCandidateLanguages(valobj);
+}
+
+FormattersMatchVector
+FormattersMatchData::GetMatchesVector ()
+{
+ if (!m_formatters_match_vector.second)
+ {
+ m_formatters_match_vector.second = true;
+ m_formatters_match_vector.first = FormatManager::GetPossibleMatches(m_valobj, m_dynamic_value_type);
+ }
+ return m_formatters_match_vector.first;
+}
+
+ConstString
+FormattersMatchData::GetTypeForCache ()
+{
+ return m_type_for_cache;
+}
+
+CandidateLanguagesVector
+FormattersMatchData::GetCandidateLanguages ()
+{
+ return m_candidate_languages;
+}
+
+ValueObject&
+FormattersMatchData::GetValueObject ()
+{
+ return m_valobj;
+}
+
+lldb::DynamicValueType
+FormattersMatchData::GetDynamicValueType ()
+{
+ return m_dynamic_value_type;
+}
diff --git a/source/DataFormatters/FormatManager.cpp b/source/DataFormatters/FormatManager.cpp
index 4e0fffbe6a1a..35a0468306fa 100644
--- a/source/DataFormatters/FormatManager.cpp
+++ b/source/DataFormatters/FormatManager.cpp
@@ -9,20 +9,23 @@
#include "lldb/DataFormatters/FormatManager.h"
+#include "llvm/ADT/STLExtras.h"
+
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Debugger.h"
-#include "lldb/DataFormatters/CXXFormatterFunctions.h"
+#include "lldb/Core/Log.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/DataFormatters/LanguageCategory.h"
#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/Platform.h"
-#include "llvm/ADT/STLExtras.h"
+#include "lldb/Target/Language.h"
using namespace lldb;
using namespace lldb_private;
-
+using namespace lldb_private::formatters;
struct FormatInfo
{
@@ -63,6 +66,7 @@ g_format_infos[] =
{ eFormatVectorOfUInt32 , '\0' , "uint32_t[]" },
{ eFormatVectorOfSInt64 , '\0' , "int64_t[]" },
{ eFormatVectorOfUInt64 , '\0' , "uint64_t[]" },
+ { eFormatVectorOfFloat16, '\0' , "float16[]" },
{ eFormatVectorOfFloat32, '\0' , "float32[]" },
{ eFormatVectorOfFloat64, '\0' , "float64[]" },
{ eFormatVectorOfUInt128, '\0' , "uint128_t[]" },
@@ -119,6 +123,19 @@ GetFormatFromFormatName (const char *format_name, bool partial_match_ok, Format
return false;
}
+void
+FormatManager::Changed ()
+{
+ ++m_last_revision;
+ m_format_cache.Clear ();
+ Mutex::Locker lang_locker(m_language_categories_mutex);
+ for (auto& iter : m_language_categories_map)
+ {
+ if (iter.second)
+ iter.second->GetFormatCache().Clear();
+ }
+}
+
bool
FormatManager::GetFormatFromCString (const char *format_cstr,
bool partial_match_ok,
@@ -161,8 +178,32 @@ FormatManager::GetFormatAsCString (Format format)
}
void
+FormatManager::EnableAllCategories ()
+{
+ m_categories_map.EnableAllCategories ();
+ Mutex::Locker lang_locker(m_language_categories_mutex);
+ for (auto& iter : m_language_categories_map)
+ {
+ if (iter.second)
+ iter.second->Enable();
+ }
+}
+
+void
+FormatManager::DisableAllCategories ()
+{
+ m_categories_map.DisableAllCategories ();
+ Mutex::Locker lang_locker(m_language_categories_mutex);
+ for (auto& iter : m_language_categories_map)
+ {
+ if (iter.second)
+ iter.second->Disable();
+ }
+}
+
+void
FormatManager::GetPossibleMatches (ValueObject& valobj,
- ClangASTType clang_type,
+ CompilerType compiler_type,
uint32_t reason,
lldb::DynamicValueType use_dynamic,
FormattersMatchVector& entries,
@@ -171,8 +212,8 @@ FormatManager::GetPossibleMatches (ValueObject& valobj,
bool did_strip_typedef,
bool root_level)
{
- clang_type = clang_type.RemoveFastQualifiers();
- ConstString type_name(clang_type.GetConstTypeName());
+ compiler_type = compiler_type.GetTypeForFormatters();
+ ConstString type_name(compiler_type.GetConstTypeName());
if (valobj.GetBitfieldBitSize() > 0)
{
StreamString sstring;
@@ -181,15 +222,19 @@ FormatManager::GetPossibleMatches (ValueObject& valobj,
entries.push_back({bitfieldname,0,did_strip_ptr,did_strip_ref,did_strip_typedef});
reason |= lldb_private::eFormatterChoiceCriterionStrippedBitField;
}
- entries.push_back({type_name,reason,did_strip_ptr,did_strip_ref,did_strip_typedef});
- ConstString display_type_name(clang_type.GetDisplayTypeName());
- if (display_type_name != type_name)
- entries.push_back({display_type_name,reason,did_strip_ptr,did_strip_ref,did_strip_typedef});
+ if (!compiler_type.IsMeaninglessWithoutDynamicResolution())
+ {
+ entries.push_back({type_name,reason,did_strip_ptr,did_strip_ref,did_strip_typedef});
+
+ ConstString display_type_name(compiler_type.GetDisplayTypeName());
+ if (display_type_name != type_name)
+ entries.push_back({display_type_name,reason,did_strip_ptr,did_strip_ref,did_strip_typedef});
+ }
- for (bool is_rvalue_ref = true, j = true; j && clang_type.IsReferenceType(nullptr, &is_rvalue_ref); j = false)
+ for (bool is_rvalue_ref = true, j = true; j && compiler_type.IsReferenceType(nullptr, &is_rvalue_ref); j = false)
{
- ClangASTType non_ref_type = clang_type.GetNonReferenceType();
+ CompilerType non_ref_type = compiler_type.GetNonReferenceType();
GetPossibleMatches(valobj,
non_ref_type,
reason | lldb_private::eFormatterChoiceCriterionStrippedPointerReference,
@@ -200,7 +245,7 @@ FormatManager::GetPossibleMatches (ValueObject& valobj,
did_strip_typedef);
if (non_ref_type.IsTypedefType())
{
- ClangASTType deffed_referenced_type = non_ref_type.GetTypedefedType();
+ CompilerType deffed_referenced_type = non_ref_type.GetTypedefedType();
deffed_referenced_type = is_rvalue_ref ? deffed_referenced_type.GetRValueReferenceType() : deffed_referenced_type.GetLValueReferenceType();
GetPossibleMatches(valobj,
deffed_referenced_type,
@@ -213,9 +258,9 @@ FormatManager::GetPossibleMatches (ValueObject& valobj,
}
}
- if (clang_type.IsPointerType())
+ if (compiler_type.IsPointerType())
{
- ClangASTType non_ptr_type = clang_type.GetPointeeType();
+ CompilerType non_ptr_type = compiler_type.GetPointeeType();
GetPossibleMatches(valobj,
non_ptr_type,
reason | lldb_private::eFormatterChoiceCriterionStrippedPointerReference,
@@ -226,7 +271,7 @@ FormatManager::GetPossibleMatches (ValueObject& valobj,
did_strip_typedef);
if (non_ptr_type.IsTypedefType())
{
- ClangASTType deffed_pointed_type = non_ptr_type.GetTypedefedType().GetPointerType();
+ CompilerType deffed_pointed_type = non_ptr_type.GetTypedefedType().GetPointerType();
GetPossibleMatches(valobj,
deffed_pointed_type,
reason | lldb_private::eFormatterChoiceCriterionNavigatedTypedefs,
@@ -237,45 +282,26 @@ FormatManager::GetPossibleMatches (ValueObject& valobj,
true); // this is not exactly the usual meaning of stripping typedefs
}
}
- bool canBeObjCDynamic = clang_type.IsPossibleDynamicType (NULL,
- false, // no C
- true); // yes ObjC
- if (canBeObjCDynamic)
+ for (lldb::LanguageType language_type : GetCandidateLanguages(valobj))
{
- if (use_dynamic != lldb::eNoDynamicValues)
+ if (Language* language = Language::FindPlugin(language_type))
{
- do
+ for (ConstString candidate : language->GetPossibleFormattersMatches(valobj, use_dynamic))
{
- lldb::ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- break;
- ObjCLanguageRuntime* runtime = process_sp->GetObjCLanguageRuntime();
- if (runtime == nullptr)
- break;
- ObjCLanguageRuntime::ClassDescriptorSP objc_class_sp (runtime->GetClassDescriptor(valobj));
- if (!objc_class_sp)
- break;
- ConstString name (objc_class_sp->GetClassName());
- entries.push_back({name,reason | lldb_private::eFormatterChoiceCriterionDynamicObjCDiscovery,did_strip_ptr,did_strip_ref,did_strip_typedef});
- } while (false);
+ entries.push_back({candidate,
+ reason | lldb_private::eFormatterChoiceCriterionLanguagePlugin,
+ did_strip_ptr,
+ did_strip_ref,
+ did_strip_typedef});
+ }
}
-
- ClangASTType non_ptr_type = clang_type.GetPointeeType();
- GetPossibleMatches(valobj,
- non_ptr_type,
- reason | lldb_private::eFormatterChoiceCriterionStrippedPointerReference,
- use_dynamic,
- entries,
- true,
- did_strip_ref,
- did_strip_typedef);
}
-
+
// try to strip typedef chains
- if (clang_type.IsTypedefType())
+ if (compiler_type.IsTypedefType())
{
- ClangASTType deffed_type = clang_type.GetTypedefedType();
+ CompilerType deffed_type = compiler_type.GetTypedefedType();
GetPossibleMatches(valobj,
deffed_type,
reason | lldb_private::eFormatterChoiceCriterionNavigatedTypedefs,
@@ -289,15 +315,15 @@ FormatManager::GetPossibleMatches (ValueObject& valobj,
if (root_level)
{
do {
- if (!clang_type.IsValid())
+ if (!compiler_type.IsValid())
break;
- ClangASTType unqual_clang_ast_type = clang_type.GetFullyUnqualifiedType();
- if (!unqual_clang_ast_type.IsValid())
+ CompilerType unqual_compiler_ast_type = compiler_type.GetFullyUnqualifiedType();
+ if (!unqual_compiler_ast_type.IsValid())
break;
- if (unqual_clang_ast_type.GetOpaqueQualType() != clang_type.GetOpaqueQualType())
+ if (unqual_compiler_ast_type.GetOpaqueQualType() != compiler_type.GetOpaqueQualType())
GetPossibleMatches (valobj,
- unqual_clang_ast_type,
+ unqual_compiler_ast_type,
reason,
use_dynamic,
entries,
@@ -313,7 +339,7 @@ FormatManager::GetPossibleMatches (ValueObject& valobj,
lldb::ValueObjectSP static_value_sp(valobj.GetStaticValue());
if (static_value_sp)
GetPossibleMatches(*static_value_sp.get(),
- static_value_sp->GetClangType(),
+ static_value_sp->GetCompilerType(),
reason | lldb_private::eFormatterChoiceCriterionWentToStaticValue,
use_dynamic,
entries,
@@ -472,6 +498,21 @@ FormatManager::GetValidatorForType (lldb::TypeNameSpecifierImplSP type_sp)
return validator_chosen_sp;
}
+void
+FormatManager::ForEachCategory(TypeCategoryMap::ForEachCallback callback)
+{
+ m_categories_map.ForEach(callback);
+ Mutex::Locker locker(m_language_categories_mutex);
+ for (const auto& entry : m_language_categories_map)
+ {
+ if (auto category_sp = entry.second->GetCategory())
+ {
+ if (!callback(category_sp))
+ break;
+ }
+ }
+}
+
lldb::TypeCategoryImplSP
FormatManager::GetCategory (const ConstString& category_name,
bool can_create)
@@ -510,6 +551,7 @@ FormatManager::GetSingleItemFormat(lldb::Format vector_format)
case eFormatVectorOfUInt128:
return eFormatHex;
+ case eFormatVectorOfFloat16:
case eFormatVectorOfFloat32:
case eFormatVectorOfFloat64:
return eFormatFloat;
@@ -534,6 +576,22 @@ FormatManager::ShouldPrintAsOneLiner (ValueObject& valobj)
if (valobj.GetNumChildren() == 0)
return false;
+ // ask the type if it has any opinion about this
+ // eLazyBoolCalculate == no opinion; other values should be self explanatory
+ CompilerType compiler_type(valobj.GetCompilerType());
+ if (compiler_type.IsValid())
+ {
+ switch (compiler_type.ShouldPrintAsOneLiner(&valobj))
+ {
+ case eLazyBoolNo:
+ return false;
+ case eLazyBoolYes:
+ return true;
+ case eLazyBoolCalculate:
+ break;
+ }
+ }
+
size_t total_children_name_len = 0;
for (size_t idx = 0;
@@ -545,6 +603,23 @@ FormatManager::ShouldPrintAsOneLiner (ValueObject& valobj)
// something is wrong here - bail out
if (!child_sp)
return false;
+
+ // also ask the child's type if it has any opinion
+ CompilerType child_compiler_type(child_sp->GetCompilerType());
+ if (child_compiler_type.IsValid())
+ {
+ switch (child_compiler_type.ShouldPrintAsOneLiner(child_sp.get()))
+ {
+ case eLazyBoolYes:
+ // an opinion of yes is only binding for the child, so keep going
+ case eLazyBoolCalculate:
+ break;
+ case eLazyBoolNo:
+ // but if the child says no, then it's a veto on the whole thing
+ return false;
+ }
+ }
+
// if we decided to define synthetic children for a type, we probably care enough
// to show them, but avoid nesting children in children
if (child_sp->GetSyntheticChildren().get() != nullptr)
@@ -596,53 +671,86 @@ FormatManager::GetValidTypeName (const ConstString& type)
}
ConstString
-GetTypeForCache (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
+FormatManager::GetTypeForCache (ValueObject& valobj,
+ lldb::DynamicValueType use_dynamic)
{
- if (use_dynamic == lldb::eNoDynamicValues)
+ ValueObjectSP valobj_sp = valobj.GetQualifiedRepresentationIfAvailable(use_dynamic, valobj.IsSynthetic());
+ if (valobj_sp && valobj_sp->GetCompilerType().IsValid())
{
- if (valobj.IsDynamic())
- {
- if (valobj.GetStaticValue())
- return valobj.GetStaticValue()->GetQualifiedTypeName();
- else
- return ConstString();
- }
- else
- return valobj.GetQualifiedTypeName();
+ if (!valobj_sp->GetCompilerType().IsMeaninglessWithoutDynamicResolution())
+ return valobj_sp->GetQualifiedTypeName();
}
- if (valobj.IsDynamic())
- return valobj.GetQualifiedTypeName();
- if (valobj.GetDynamicValue(use_dynamic))
- return valobj.GetDynamicValue(use_dynamic)->GetQualifiedTypeName();
return ConstString();
}
+std::vector<lldb::LanguageType>
+FormatManager::GetCandidateLanguages (ValueObject& valobj)
+{
+ lldb::LanguageType lang_type = valobj.GetObjectRuntimeLanguage();
+ return GetCandidateLanguages(lang_type);
+}
+
+std::vector<lldb::LanguageType>
+FormatManager::GetCandidateLanguages (lldb::LanguageType lang_type)
+{
+ switch (lang_type)
+ {
+ 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:
+ return {lldb::eLanguageTypeC_plus_plus, lldb::eLanguageTypeObjC};
+ default:
+ return {lang_type};
+ }
+}
+
+LanguageCategory*
+FormatManager::GetCategoryForLanguage (lldb::LanguageType lang_type)
+{
+ Mutex::Locker locker(m_language_categories_mutex);
+ auto iter = m_language_categories_map.find(lang_type), end = m_language_categories_map.end();
+ if (iter != end)
+ return iter->second.get();
+ LanguageCategory* lang_category = new LanguageCategory(lang_type);
+ m_language_categories_map[lang_type] = LanguageCategory::UniquePointer(lang_category);
+ return lang_category;
+}
+
lldb::TypeFormatImplSP
-FormatManager::GetHardcodedFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
+FormatManager::GetHardcodedFormat (FormattersMatchData& match_data)
{
- for (const auto& candidate: m_hardcoded_formats)
+ TypeFormatImplSP retval_sp;
+
+ for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages())
{
- auto result = candidate(valobj,use_dynamic,*this);
- if (result)
- return result;
+ if (LanguageCategory* lang_category = GetCategoryForLanguage(lang_type))
+ {
+ if (lang_category->GetHardcoded(*this, match_data, retval_sp))
+ break;
+ }
}
- return nullptr;
+
+ return retval_sp;
}
lldb::TypeFormatImplSP
FormatManager::GetFormat (ValueObject& valobj,
lldb::DynamicValueType use_dynamic)
{
+ FormattersMatchData match_data(valobj, use_dynamic);
+
TypeFormatImplSP retval;
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
- ConstString valobj_type(GetTypeForCache(valobj, use_dynamic));
- if (valobj_type)
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_DATAFORMATTERS));
+ if (match_data.GetTypeForCache())
{
if (log)
- log->Printf("\n\n[FormatManager::GetFormat] Looking into cache for type %s", valobj_type.AsCString("<invalid>"));
- if (m_format_cache.GetFormat(valobj_type,retval))
+ log->Printf("\n\n[FormatManager::GetFormat] Looking into cache for type %s", match_data.GetTypeForCache().AsCString("<invalid>"));
+ if (m_format_cache.GetFormat(match_data.GetTypeForCache(),retval))
{
if (log)
{
@@ -655,21 +763,41 @@ FormatManager::GetFormat (ValueObject& valobj,
if (log)
log->Printf("[FormatManager::GetFormat] Cache search failed. Going normal route");
}
- retval = m_categories_map.GetFormat(valobj, use_dynamic);
+
+ retval = m_categories_map.GetFormat(match_data);
+ if (!retval)
+ {
+ if (log)
+ log->Printf("[FormatManager::GetFormat] Search failed. Giving language a chance.");
+ for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages())
+ {
+ if (LanguageCategory* lang_category = GetCategoryForLanguage(lang_type))
+ {
+ if (lang_category->Get(match_data, retval))
+ break;
+ }
+ }
+ if (retval)
+ {
+ if (log)
+ log->Printf("[FormatManager::GetFormat] Language search success. Returning.");
+ return retval;
+ }
+ }
if (!retval)
{
if (log)
log->Printf("[FormatManager::GetFormat] Search failed. Giving hardcoded a chance.");
- retval = GetHardcodedFormat(valobj, use_dynamic);
+ retval = GetHardcodedFormat(match_data);
}
- if (valobj_type && (!retval || !retval->NonCacheable()))
+ if (match_data.GetTypeForCache() && (!retval || !retval->NonCacheable()))
{
if (log)
log->Printf("[FormatManager::GetFormat] Caching %p for type %s",
static_cast<void*>(retval.get()),
- valobj_type.AsCString("<invalid>"));
- m_format_cache.SetFormat(valobj_type,retval);
+ match_data.GetTypeForCache().AsCString("<invalid>"));
+ m_format_cache.SetFormat(match_data.GetTypeForCache(),retval);
}
if (log && log->GetDebug())
log->Printf("[FormatManager::GetFormat] Cache hits: %" PRIu64 " - Cache Misses: %" PRIu64, m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
@@ -677,30 +805,35 @@ FormatManager::GetFormat (ValueObject& valobj,
}
lldb::TypeSummaryImplSP
-FormatManager::GetHardcodedSummaryFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
+FormatManager::GetHardcodedSummaryFormat (FormattersMatchData& match_data)
{
- for (const auto& candidate: m_hardcoded_summaries)
+ TypeSummaryImplSP retval_sp;
+
+ for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages())
{
- auto result = candidate(valobj,use_dynamic,*this);
- if (result)
- return result;
+ if (LanguageCategory* lang_category = GetCategoryForLanguage(lang_type))
+ {
+ if (lang_category->GetHardcoded(*this, match_data, retval_sp))
+ break;
+ }
}
- return nullptr;
+
+ return retval_sp;
}
lldb::TypeSummaryImplSP
FormatManager::GetSummaryFormat (ValueObject& valobj,
lldb::DynamicValueType use_dynamic)
{
+ FormattersMatchData match_data(valobj, use_dynamic);
+
TypeSummaryImplSP retval;
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
- ConstString valobj_type(GetTypeForCache(valobj, use_dynamic));
- if (valobj_type)
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_DATAFORMATTERS));
+ if (match_data.GetTypeForCache())
{
if (log)
- log->Printf("\n\n[FormatManager::GetSummaryFormat] Looking into cache for type %s", valobj_type.AsCString("<invalid>"));
- if (m_format_cache.GetSummary(valobj_type,retval))
+ log->Printf("\n\n[FormatManager::GetSummaryFormat] Looking into cache for type %s", match_data.GetTypeForCache().AsCString("<invalid>"));
+ if (m_format_cache.GetSummary(match_data.GetTypeForCache(),retval))
{
if (log)
{
@@ -713,21 +846,41 @@ FormatManager::GetSummaryFormat (ValueObject& valobj,
if (log)
log->Printf("[FormatManager::GetSummaryFormat] Cache search failed. Going normal route");
}
- retval = m_categories_map.GetSummaryFormat(valobj, use_dynamic);
+
+ retval = m_categories_map.GetSummaryFormat(match_data);
+ if (!retval)
+ {
+ if (log)
+ log->Printf("[FormatManager::GetSummaryFormat] Search failed. Giving language a chance.");
+ for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages())
+ {
+ if (LanguageCategory* lang_category = GetCategoryForLanguage(lang_type))
+ {
+ if (lang_category->Get(match_data, retval))
+ break;
+ }
+ }
+ if (retval)
+ {
+ if (log)
+ log->Printf("[FormatManager::GetSummaryFormat] Language search success. Returning.");
+ return retval;
+ }
+ }
if (!retval)
{
if (log)
log->Printf("[FormatManager::GetSummaryFormat] Search failed. Giving hardcoded a chance.");
- retval = GetHardcodedSummaryFormat(valobj, use_dynamic);
+ retval = GetHardcodedSummaryFormat(match_data);
}
- if (valobj_type && (!retval || !retval->NonCacheable()))
+ if (match_data.GetTypeForCache() && (!retval || !retval->NonCacheable()))
{
if (log)
log->Printf("[FormatManager::GetSummaryFormat] Caching %p for type %s",
static_cast<void*>(retval.get()),
- valobj_type.AsCString("<invalid>"));
- m_format_cache.SetSummary(valobj_type,retval);
+ match_data.GetTypeForCache().AsCString("<invalid>"));
+ m_format_cache.SetSummary(match_data.GetTypeForCache(),retval);
}
if (log && log->GetDebug())
log->Printf("[FormatManager::GetSummaryFormat] Cache hits: %" PRIu64 " - Cache Misses: %" PRIu64, m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
@@ -736,30 +889,35 @@ FormatManager::GetSummaryFormat (ValueObject& valobj,
#ifndef LLDB_DISABLE_PYTHON
lldb::SyntheticChildrenSP
-FormatManager::GetHardcodedSyntheticChildren (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
+FormatManager::GetHardcodedSyntheticChildren (FormattersMatchData& match_data)
{
- for (const auto& candidate: m_hardcoded_synthetics)
+ SyntheticChildrenSP retval_sp;
+
+ for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages())
{
- auto result = candidate(valobj,use_dynamic,*this);
- if (result)
- return result;
+ if (LanguageCategory* lang_category = GetCategoryForLanguage(lang_type))
+ {
+ if (lang_category->GetHardcoded(*this, match_data, retval_sp))
+ break;
+ }
}
- return nullptr;
+
+ return retval_sp;
}
lldb::SyntheticChildrenSP
FormatManager::GetSyntheticChildren (ValueObject& valobj,
lldb::DynamicValueType use_dynamic)
{
+ FormattersMatchData match_data(valobj, use_dynamic);
+
SyntheticChildrenSP retval;
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
- ConstString valobj_type(GetTypeForCache(valobj, use_dynamic));
- if (valobj_type)
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_DATAFORMATTERS));
+ if (match_data.GetTypeForCache())
{
if (log)
- log->Printf("\n\n[FormatManager::GetSyntheticChildren] Looking into cache for type %s", valobj_type.AsCString("<invalid>"));
- if (m_format_cache.GetSynthetic(valobj_type,retval))
+ log->Printf("\n\n[FormatManager::GetSyntheticChildren] Looking into cache for type %s", match_data.GetTypeForCache().AsCString("<invalid>"));
+ if (m_format_cache.GetSynthetic(match_data.GetTypeForCache(),retval))
{
if (log)
{
@@ -772,21 +930,41 @@ FormatManager::GetSyntheticChildren (ValueObject& valobj,
if (log)
log->Printf("[FormatManager::GetSyntheticChildren] Cache search failed. Going normal route");
}
- retval = m_categories_map.GetSyntheticChildren(valobj, use_dynamic);
+
+ retval = m_categories_map.GetSyntheticChildren(match_data);
+ if (!retval)
+ {
+ if (log)
+ log->Printf("[FormatManager::GetSyntheticChildren] Search failed. Giving language a chance.");
+ for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages())
+ {
+ if (LanguageCategory* lang_category = GetCategoryForLanguage(lang_type))
+ {
+ if (lang_category->Get(match_data, retval))
+ break;
+ }
+ }
+ if (retval)
+ {
+ if (log)
+ log->Printf("[FormatManager::GetSyntheticChildren] Language search success. Returning.");
+ return retval;
+ }
+ }
if (!retval)
{
if (log)
log->Printf("[FormatManager::GetSyntheticChildren] Search failed. Giving hardcoded a chance.");
- retval = GetHardcodedSyntheticChildren(valobj, use_dynamic);
+ retval = GetHardcodedSyntheticChildren(match_data);
}
- if (valobj_type && (!retval || !retval->NonCacheable()))
+ if (match_data.GetTypeForCache() && (!retval || !retval->NonCacheable()))
{
if (log)
log->Printf("[FormatManager::GetSyntheticChildren] Caching %p for type %s",
static_cast<void*>(retval.get()),
- valobj_type.AsCString("<invalid>"));
- m_format_cache.SetSynthetic(valobj_type,retval);
+ match_data.GetTypeForCache().AsCString("<invalid>"));
+ m_format_cache.SetSynthetic(match_data.GetTypeForCache(),retval);
}
if (log && log->GetDebug())
log->Printf("[FormatManager::GetSyntheticChildren] Cache hits: %" PRIu64 " - Cache Misses: %" PRIu64, m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
@@ -798,14 +976,15 @@ lldb::TypeValidatorImplSP
FormatManager::GetValidator (ValueObject& valobj,
lldb::DynamicValueType use_dynamic)
{
+ FormattersMatchData match_data(valobj, use_dynamic);
+
TypeValidatorImplSP retval;
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
- ConstString valobj_type(GetTypeForCache(valobj, use_dynamic));
- if (valobj_type)
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_DATAFORMATTERS));
+ if (match_data.GetTypeForCache())
{
if (log)
- log->Printf("\n\n[FormatManager::GetValidator] Looking into cache for type %s", valobj_type.AsCString("<invalid>"));
- if (m_format_cache.GetValidator(valobj_type,retval))
+ log->Printf("\n\n[FormatManager::GetValidator] Looking into cache for type %s", match_data.GetTypeForCache().AsCString("<invalid>"));
+ if (m_format_cache.GetValidator(match_data.GetTypeForCache(),retval))
{
if (log)
{
@@ -818,21 +997,41 @@ FormatManager::GetValidator (ValueObject& valobj,
if (log)
log->Printf("[FormatManager::GetValidator] Cache search failed. Going normal route");
}
- retval = m_categories_map.GetValidator(valobj, use_dynamic);
+
+ retval = m_categories_map.GetValidator(match_data);
+ if (!retval)
+ {
+ if (log)
+ log->Printf("[FormatManager::GetValidator] Search failed. Giving language a chance.");
+ for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages())
+ {
+ if (LanguageCategory* lang_category = GetCategoryForLanguage(lang_type))
+ {
+ if (lang_category->Get(match_data, retval))
+ break;
+ }
+ }
+ if (retval)
+ {
+ if (log)
+ log->Printf("[FormatManager::GetValidator] Language search success. Returning.");
+ return retval;
+ }
+ }
if (!retval)
{
if (log)
log->Printf("[FormatManager::GetValidator] Search failed. Giving hardcoded a chance.");
- retval = GetHardcodedValidator(valobj, use_dynamic);
+ retval = GetHardcodedValidator(match_data);
}
- if (valobj_type && (!retval || !retval->NonCacheable()))
+ if (match_data.GetTypeForCache() && (!retval || !retval->NonCacheable()))
{
if (log)
log->Printf("[FormatManager::GetValidator] Caching %p for type %s",
static_cast<void*>(retval.get()),
- valobj_type.AsCString("<invalid>"));
- m_format_cache.SetValidator(valobj_type,retval);
+ match_data.GetTypeForCache().AsCString("<invalid>"));
+ m_format_cache.SetValidator(match_data.GetTypeForCache(),retval);
}
if (log && log->GetDebug())
log->Printf("[FormatManager::GetValidator] Cache hits: %" PRIu64 " - Cache Misses: %" PRIu64, m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
@@ -840,313 +1039,43 @@ FormatManager::GetValidator (ValueObject& valobj,
}
lldb::TypeValidatorImplSP
-FormatManager::GetHardcodedValidator (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
+FormatManager::GetHardcodedValidator (FormattersMatchData& match_data)
{
- for (const auto& candidate: m_hardcoded_validators)
+ TypeValidatorImplSP retval_sp;
+
+ for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages())
{
- auto result = candidate(valobj,use_dynamic,*this);
- if (result)
- return result;
+ if (LanguageCategory* lang_category = GetCategoryForLanguage(lang_type))
+ {
+ if (lang_category->GetHardcoded(*this, match_data, retval_sp))
+ break;
+ }
}
- return nullptr;
+
+ return retval_sp;
}
FormatManager::FormatManager() :
+ m_last_revision(0),
m_format_cache(),
+ m_language_categories_mutex(Mutex::eMutexTypeRecursive),
+ m_language_categories_map(),
m_named_summaries_map(this),
- m_last_revision(0),
m_categories_map(this),
m_default_category_name(ConstString("default")),
m_system_category_name(ConstString("system")),
- m_gnu_cpp_category_name(ConstString("gnu-libstdc++")),
- m_libcxx_category_name(ConstString("libcxx")),
- m_objc_category_name(ConstString("objc")),
- m_corefoundation_category_name(ConstString("CoreFoundation")),
- m_coregraphics_category_name(ConstString("CoreGraphics")),
- m_coreservices_category_name(ConstString("CoreServices")),
- m_vectortypes_category_name(ConstString("VectorTypes")),
- m_appkit_category_name(ConstString("AppKit")),
- m_coremedia_category_name(ConstString("CoreMedia")),
- m_hardcoded_formats(),
- m_hardcoded_summaries(),
- m_hardcoded_synthetics(),
- m_hardcoded_validators()
-
+ m_vectortypes_category_name(ConstString("VectorTypes"))
{
LoadSystemFormatters();
- LoadLibStdcppFormatters();
- LoadLibcxxFormatters();
- LoadObjCFormatters();
- LoadCoreMediaFormatters();
- LoadHardcodedFormatters();
-
- EnableCategory(m_objc_category_name,TypeCategoryMap::Last);
- EnableCategory(m_corefoundation_category_name,TypeCategoryMap::Last);
- EnableCategory(m_appkit_category_name,TypeCategoryMap::Last);
- EnableCategory(m_coreservices_category_name,TypeCategoryMap::Last);
- EnableCategory(m_coregraphics_category_name,TypeCategoryMap::Last);
- EnableCategory(m_coremedia_category_name,TypeCategoryMap::Last);
- EnableCategory(m_gnu_cpp_category_name,TypeCategoryMap::Last);
- EnableCategory(m_libcxx_category_name,TypeCategoryMap::Last);
- EnableCategory(m_vectortypes_category_name,TypeCategoryMap::Last);
- EnableCategory(m_system_category_name,TypeCategoryMap::Last);
-}
-
-static void
-AddFormat (TypeCategoryImpl::SharedPointer category_sp,
- lldb::Format format,
- ConstString type_name,
- TypeFormatImpl::Flags flags,
- bool regex = false)
-{
- lldb::TypeFormatImplSP format_sp(new TypeFormatImpl_Format(format, flags));
-
- if (regex)
- category_sp->GetRegexTypeFormatsContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),format_sp);
- else
- category_sp->GetTypeFormatsContainer()->Add(type_name, format_sp);
-}
-
-
-static void
-AddStringSummary(TypeCategoryImpl::SharedPointer category_sp,
- const char* string,
- ConstString type_name,
- TypeSummaryImpl::Flags flags,
- bool regex = false)
-{
- lldb::TypeSummaryImplSP summary_sp(new StringSummaryFormat(flags,
- string));
-
- if (regex)
- category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),summary_sp);
- else
- category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
-}
-
-static void
-AddOneLineSummary (TypeCategoryImpl::SharedPointer category_sp,
- ConstString type_name,
- TypeSummaryImpl::Flags flags,
- bool regex = false)
-{
- flags.SetShowMembersOneLiner(true);
- lldb::TypeSummaryImplSP summary_sp(new StringSummaryFormat(flags, ""));
-
- if (regex)
- category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),summary_sp);
- else
- category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
-}
-
-#ifndef LLDB_DISABLE_PYTHON
-static void
-AddCXXSummary (TypeCategoryImpl::SharedPointer category_sp,
- CXXFunctionSummaryFormat::Callback funct,
- const char* description,
- ConstString type_name,
- TypeSummaryImpl::Flags flags,
- bool regex = false)
-{
- lldb::TypeSummaryImplSP summary_sp(new CXXFunctionSummaryFormat(flags,funct,description));
- if (regex)
- category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),summary_sp);
- else
- category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
-}
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
-static void AddCXXSynthetic (TypeCategoryImpl::SharedPointer category_sp,
- CXXSyntheticChildren::CreateFrontEndCallback generator,
- const char* description,
- ConstString type_name,
- ScriptedSyntheticChildren::Flags flags,
- bool regex = false)
-{
- lldb::SyntheticChildrenSP synth_sp(new CXXSyntheticChildren(flags,description,generator));
- if (regex)
- category_sp->GetRegexTypeSyntheticsContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())), synth_sp);
- else
- category_sp->GetTypeSyntheticsContainer()->Add(type_name,synth_sp);
-}
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
-static void AddFilter (TypeCategoryImpl::SharedPointer category_sp,
- std::vector<std::string> children,
- const char* description,
- ConstString type_name,
- ScriptedSyntheticChildren::Flags flags,
- bool regex = false)
-{
- TypeFilterImplSP filter_sp(new TypeFilterImpl(flags));
- for (auto child : children)
- filter_sp->AddExpressionPath(child);
- if (regex)
- category_sp->GetRegexTypeFiltersContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())), filter_sp);
- else
- category_sp->GetTypeFiltersContainer()->Add(type_name,filter_sp);
-}
-#endif
-
-void
-FormatManager::LoadLibStdcppFormatters()
-{
- TypeSummaryImpl::Flags stl_summary_flags;
- stl_summary_flags.SetCascades(true)
- .SetSkipPointers(false)
- .SetSkipReferences(false)
- .SetDontShowChildren(true)
- .SetDontShowValue(true)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false);
-
- lldb::TypeSummaryImplSP std_string_summary_sp(new StringSummaryFormat(stl_summary_flags,
- "${var._M_dataplus._M_p}"));
-
- TypeCategoryImpl::SharedPointer gnu_category_sp = GetCategory(m_gnu_cpp_category_name);
-
- gnu_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::string"),
- std_string_summary_sp);
- gnu_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::basic_string<char>"),
- std_string_summary_sp);
- gnu_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::basic_string<char,std::char_traits<char>,std::allocator<char> >"),
- std_string_summary_sp);
- gnu_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::basic_string<char, std::char_traits<char>, std::allocator<char> >"),
- std_string_summary_sp);
-
- // making sure we force-pick the summary for printing wstring (_M_p is a wchar_t*)
- lldb::TypeSummaryImplSP std_wstring_summary_sp(new StringSummaryFormat(stl_summary_flags,
- "${var._M_dataplus._M_p%S}"));
-
- gnu_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::wstring"),
- std_wstring_summary_sp);
- gnu_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::basic_string<wchar_t>"),
- std_wstring_summary_sp);
- gnu_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >"),
- std_wstring_summary_sp);
- gnu_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >"),
- std_wstring_summary_sp);
+ LoadVectorFormatters();
-
-#ifndef LLDB_DISABLE_PYTHON
-
- SyntheticChildren::Flags stl_synth_flags;
- stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(false);
-
- gnu_category_sp->GetRegexTypeSyntheticsContainer()->Add(RegularExpressionSP(new RegularExpression("^std::vector<.+>(( )?&)?$")),
- SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
- "lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider")));
- gnu_category_sp->GetRegexTypeSyntheticsContainer()->Add(RegularExpressionSP(new RegularExpression("^std::map<.+> >(( )?&)?$")),
- SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
- "lldb.formatters.cpp.gnu_libstdcpp.StdMapSynthProvider")));
- gnu_category_sp->GetRegexTypeSyntheticsContainer()->Add(RegularExpressionSP(new RegularExpression("^std::list<.+>(( )?&)?$")),
- SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
- "lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider")));
-
- stl_summary_flags.SetDontShowChildren(false);stl_summary_flags.SetSkipPointers(true);
- gnu_category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression("^std::vector<.+>(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags,
- "size=${svar%#}")));
- gnu_category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression("^std::map<.+> >(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags,
- "size=${svar%#}")));
- gnu_category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression("^std::list<.+>(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags,
- "size=${svar%#}")));
-
- AddCXXSynthetic(gnu_category_sp, lldb_private::formatters::LibStdcppVectorIteratorSyntheticFrontEndCreator, "std::vector iterator synthetic children", ConstString("^__gnu_cxx::__normal_iterator<.+>$"), stl_synth_flags, true);
-
- AddCXXSynthetic(gnu_category_sp, lldb_private::formatters::LibstdcppMapIteratorSyntheticFrontEndCreator, "std::map iterator synthetic children", ConstString("^std::_Rb_tree_iterator<.+>$"), stl_synth_flags, true);
-#endif
-}
-
-void
-FormatManager::LoadLibcxxFormatters()
-{
- TypeSummaryImpl::Flags stl_summary_flags;
- stl_summary_flags.SetCascades(true)
- .SetSkipPointers(false)
- .SetSkipReferences(false)
- .SetDontShowChildren(true)
- .SetDontShowValue(true)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false);
-
-#ifndef LLDB_DISABLE_PYTHON
- //std::string code(" lldb.formatters.cpp.libcxx.stdstring_SummaryProvider(valobj,internal_dict)");
- //lldb::TypeSummaryImplSP std_string_summary_sp(new ScriptSummaryFormat(stl_summary_flags, "lldb.formatters.cpp.libcxx.stdstring_SummaryProvider",code.c_str()));
-
- lldb::TypeSummaryImplSP std_string_summary_sp(new CXXFunctionSummaryFormat(stl_summary_flags, lldb_private::formatters::LibcxxStringSummaryProvider, "std::string summary provider"));
- lldb::TypeSummaryImplSP std_wstring_summary_sp(new CXXFunctionSummaryFormat(stl_summary_flags, lldb_private::formatters::LibcxxWStringSummaryProvider, "std::wstring summary provider"));
-
- TypeCategoryImpl::SharedPointer libcxx_category_sp = GetCategory(m_libcxx_category_name);
-
- libcxx_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::__1::string"),
- std_string_summary_sp);
- libcxx_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >"),
- std_string_summary_sp);
-
- libcxx_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::__1::wstring"),
- std_wstring_summary_sp);
- libcxx_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);
-
- SyntheticChildren::Flags stl_synth_flags;
- stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(false);
-
- AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibcxxStdVectorSyntheticFrontEndCreator, "libc++ std::vector synthetic children", ConstString("^std::__1::vector<.+>(( )?&)?$"), stl_synth_flags, true);
- AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibcxxStdListSyntheticFrontEndCreator, "libc++ std::list synthetic children", ConstString("^std::__1::list<.+>(( )?&)?$"), stl_synth_flags, true);
- AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator, "libc++ std::map synthetic children", ConstString("^std::__1::map<.+> >(( )?&)?$"), stl_synth_flags, true);
- AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator, "libc++ std::vector<bool> synthetic children", ConstString("std::__1::vector<std::__1::allocator<bool> >"), stl_synth_flags);
- AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator, "libc++ std::vector<bool> synthetic children", ConstString("std::__1::vector<bool, std::__1::allocator<bool> >"), stl_synth_flags);
- AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator, "libc++ std::set synthetic children", ConstString("^std::__1::set<.+> >(( )?&)?$"), stl_synth_flags, true);
- AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator, "libc++ std::multiset synthetic children", ConstString("^std::__1::multiset<.+> >(( )?&)?$"), stl_synth_flags, true);
- AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator, "libc++ std::multimap synthetic children", ConstString("^std::__1::multimap<.+> >(( )?&)?$"), stl_synth_flags, true);
- AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEndCreator, "libc++ std::unordered containers synthetic children", ConstString("^(std::__1::)unordered_(multi)?(map|set)<.+> >$"), stl_synth_flags, true);
- AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibcxxInitializerListSyntheticFrontEndCreator, "libc++ std::initializer_list synthetic children", ConstString("^std::initializer_list<.+>(( )?&)?$"), stl_synth_flags, true);
-
- libcxx_category_sp->GetRegexTypeSyntheticsContainer()->Add(RegularExpressionSP(new RegularExpression("^(std::__1::)deque<.+>(( )?&)?$")),
- SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
- "lldb.formatters.cpp.libcxx.stddeque_SynthProvider")));
-
- AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator, "shared_ptr synthetic children", ConstString("^(std::__1::)shared_ptr<.+>(( )?&)?$"), stl_synth_flags, true);
- AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator, "weak_ptr synthetic children", ConstString("^(std::__1::)weak_ptr<.+>(( )?&)?$"), stl_synth_flags, true);
-
- stl_summary_flags.SetDontShowChildren(false);stl_summary_flags.SetSkipPointers(false);
- AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator, "libc++ std::vector<bool> synthetic children", ConstString("std::__1::vector<bool, std::__1::allocator<bool> >"), stl_synth_flags);
-
- AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::vector summary provider", ConstString("^std::__1::vector<.+>(( )?&)?$"), stl_summary_flags, true);
- AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::list summary provider", ConstString("^std::__1::list<.+>(( )?&)?$"), stl_summary_flags, true);
- AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::map summary provider", ConstString("^std::__1::map<.+>(( )?&)?$"), stl_summary_flags, true);
- AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::deque summary provider", ConstString("^std::__1::deque<.+>(( )?&)?$"), stl_summary_flags, true);
- AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::vector<bool> summary provider", ConstString("std::__1::vector<std::__1::allocator<bool> >"), stl_summary_flags);
- AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::vector<bool> summary provider", ConstString("std::__1::vector<bool, std::__1::allocator<bool> >"), stl_summary_flags);
- AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::set summary provider", ConstString("^std::__1::set<.+>(( )?&)?$"), stl_summary_flags, true);
- AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::multiset summary provider", ConstString("^std::__1::multiset<.+>(( )?&)?$"), stl_summary_flags, true);
- AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::multimap summary provider", ConstString("^std::__1::multimap<.+>(( )?&)?$"), stl_summary_flags, true);
- AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::unordered containers summary provider", ConstString("^(std::__1::)unordered_(multi)?(map|set)<.+> >$"), stl_summary_flags, true);
-
- stl_summary_flags.SetSkipPointers(true);
-
- AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxSmartPointerSummaryProvider, "libc++ std::shared_ptr summary provider", ConstString("^std::__1::shared_ptr<.+>(( )?&)?$"), stl_summary_flags, true);
- AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxSmartPointerSummaryProvider, "libc++ std::weak_ptr summary provider", ConstString("^std::__1::weak_ptr<.+>(( )?&)?$"), stl_summary_flags, true);
-
- AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibCxxVectorIteratorSyntheticFrontEndCreator, "std::vector iterator synthetic children", ConstString("^std::__1::__wrap_iter<.+>$"), stl_synth_flags, true);
-
- AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::vector<bool> summary provider", ConstString("std::__1::vector<bool, std::__1::allocator<bool> >"), stl_summary_flags);
- AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEndCreator, "std::map iterator synthetic children", ConstString("^std::__1::__map_iterator<.+>$"), stl_synth_flags, true);
-
- AddFilter(libcxx_category_sp, {"__a_"}, "libc++ std::atomic filter", ConstString("^std::__1::atomic<.*>$"), stl_synth_flags, true);
-#endif
+ EnableCategory(m_vectortypes_category_name,TypeCategoryMap::Last, lldb::eLanguageTypeObjC_plus_plus);
+ EnableCategory(m_system_category_name,TypeCategoryMap::Last, lldb::eLanguageTypeObjC_plus_plus);
}
void
FormatManager::LoadSystemFormatters()
{
-
TypeSummaryImpl::Flags string_flags;
string_flags.SetCascades(true)
.SetSkipPointers(true)
@@ -1157,7 +1086,7 @@ FormatManager::LoadSystemFormatters()
.SetHideItemNames(false);
TypeSummaryImpl::Flags string_array_flags;
- string_array_flags.SetCascades(false)
+ string_array_flags.SetCascades(true)
.SetSkipPointers(true)
.SetSkipReferences(false)
.SetDontShowChildren(true)
@@ -1192,31 +1121,6 @@ FormatManager::LoadSystemFormatters()
sys_category_sp->GetTypeSummariesContainer()->Add(ConstString("OSType"), ostype_summary);
#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(sys_category_sp, lldb_private::formatters::Char16StringSummaryProvider, "char16_t * summary provider", ConstString("char16_t *"), string_flags);
-
- AddCXXSummary(sys_category_sp, lldb_private::formatters::Char32StringSummaryProvider, "char32_t * summary provider", ConstString("char32_t *"), string_flags);
-
- AddCXXSummary(sys_category_sp, lldb_private::formatters::WCharStringSummaryProvider, "wchar_t * summary provider", ConstString("wchar_t *"), string_flags);
- AddCXXSummary(sys_category_sp, lldb_private::formatters::WCharStringSummaryProvider, "wchar_t * summary provider", ConstString("wchar_t \\[[0-9]+\\]"), string_array_flags, true);
-
- AddCXXSummary(sys_category_sp, lldb_private::formatters::Char16StringSummaryProvider, "unichar * summary provider", ConstString("unichar *"), string_flags);
-
- TypeSummaryImpl::Flags widechar_flags;
- widechar_flags.SetDontShowValue(true)
- .SetSkipPointers(true)
- .SetSkipReferences(false)
- .SetCascades(true)
- .SetDontShowChildren(true)
- .SetHideItemNames(true)
- .SetShowMembersOneLiner(false);
-
- AddCXXSummary(sys_category_sp, lldb_private::formatters::Char16SummaryProvider, "char16_t summary provider", ConstString("char16_t"), widechar_flags);
- AddCXXSummary(sys_category_sp, lldb_private::formatters::Char32SummaryProvider, "char32_t summary provider", ConstString("char32_t"), widechar_flags);
- AddCXXSummary(sys_category_sp, lldb_private::formatters::WCharSummaryProvider, "wchar_t summary provider", ConstString("wchar_t"), widechar_flags);
-
- AddCXXSummary(sys_category_sp, lldb_private::formatters::Char16SummaryProvider, "unichar summary provider", ConstString("unichar"), widechar_flags);
-
TypeFormatImpl::Flags fourchar_flags;
fourchar_flags.SetCascades(true).SetSkipPointers(true).SetSkipReferences(true);
@@ -1225,283 +1129,10 @@ FormatManager::LoadSystemFormatters()
}
void
-FormatManager::LoadObjCFormatters()
+FormatManager::LoadVectorFormatters()
{
- TypeSummaryImpl::Flags objc_flags;
- objc_flags.SetCascades(false)
- .SetSkipPointers(true)
- .SetSkipReferences(true)
- .SetDontShowChildren(true)
- .SetDontShowValue(true)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false);
-
- TypeCategoryImpl::SharedPointer objc_category_sp = GetCategory(m_objc_category_name);
- TypeCategoryImpl::SharedPointer appkit_category_sp = GetCategory(m_appkit_category_name);
- TypeCategoryImpl::SharedPointer corefoundation_category_sp = GetCategory(m_corefoundation_category_name);
- TypeCategoryImpl::SharedPointer coregraphics_category_sp = GetCategory(m_coregraphics_category_name);
- TypeCategoryImpl::SharedPointer coreservices_category_sp = GetCategory(m_coreservices_category_name);
-
- lldb::TypeSummaryImplSP ObjC_BOOL_summary(new CXXFunctionSummaryFormat(objc_flags, lldb_private::formatters::ObjCBOOLSummaryProvider,""));
- objc_category_sp->GetTypeSummariesContainer()->Add(ConstString("BOOL"),
- ObjC_BOOL_summary);
- objc_category_sp->GetTypeSummariesContainer()->Add(ConstString("BOOL &"),
- ObjC_BOOL_summary);
- 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);
- AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<false>, "SEL summary provider", ConstString("SEL"), objc_flags);
- AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<false>, "SEL summary provider", ConstString("struct objc_selector"), objc_flags);
- AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<false>, "SEL summary provider", ConstString("objc_selector"), objc_flags);
- AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<true>, "SEL summary provider", ConstString("objc_selector *"), objc_flags);
- AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<true>, "SEL summary provider", ConstString("SEL *"), objc_flags);
-
- AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCClassSummaryProvider, "Class summary provider", ConstString("Class"), objc_flags);
-
- SyntheticChildren::Flags class_synth_flags;
- class_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(false);
-
- AddCXXSynthetic(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);
- objc_flags.SetSkipReferences(false);
-
- AddStringSummary (objc_category_sp,
- "${var.__FuncPtr%A}",
- ConstString("__block_literal_generic"),
- objc_flags);
-
- AddStringSummary(corefoundation_category_sp,
- "${var.years} years, ${var.months} months, ${var.days} days, ${var.hours} hours, ${var.minutes} minutes ${var.seconds} seconds",
- ConstString("CFGregorianUnits"),
- objc_flags);
- AddStringSummary(corefoundation_category_sp,
- "location=${var.location} length=${var.length}",
- ConstString("CFRange"),
- objc_flags);
-
- AddStringSummary(appkit_category_sp,
- "location=${var.location}, length=${var.length}",
- ConstString("NSRange"),
- objc_flags);
- AddStringSummary(appkit_category_sp,
- "(${var.origin}, ${var.size}), ...",
- ConstString("NSRectArray"),
- objc_flags);
-
- AddOneLineSummary (appkit_category_sp,
- ConstString("NSPoint"),
- objc_flags);
- AddOneLineSummary (appkit_category_sp,
- ConstString("NSSize"),
- objc_flags);
- AddOneLineSummary (appkit_category_sp,
- ConstString("NSRect"),
- objc_flags);
-
- AddOneLineSummary (coregraphics_category_sp,
- ConstString("CGSize"),
- objc_flags);
- AddOneLineSummary (coregraphics_category_sp,
- ConstString("CGPoint"),
- objc_flags);
- AddOneLineSummary (coregraphics_category_sp,
- ConstString("CGRect"),
- objc_flags);
-
- AddStringSummary(coreservices_category_sp,
- "red=${var.red} green=${var.green} blue=${var.blue}",
- ConstString("RGBColor"),
- objc_flags);
- AddStringSummary(coreservices_category_sp,
- "(t=${var.top}, l=${var.left}, b=${var.bottom}, r=${var.right})",
- ConstString("Rect"),
- objc_flags);
- AddStringSummary(coreservices_category_sp,
- "(v=${var.v}, h=${var.h})",
- ConstString("Point"),
- objc_flags);
- AddStringSummary(coreservices_category_sp,
- "${var.month}/${var.day}/${var.year} ${var.hour} :${var.minute} :${var.second} dayOfWeek:${var.dayOfWeek}",
- ConstString("DateTimeRect *"),
- objc_flags);
- AddStringSummary(coreservices_category_sp,
- "${var.ld.month}/${var.ld.day}/${var.ld.year} ${var.ld.hour} :${var.ld.minute} :${var.ld.second} dayOfWeek:${var.ld.dayOfWeek}",
- ConstString("LongDateRect"),
- objc_flags);
- AddStringSummary(coreservices_category_sp,
- "(x=${var.x}, y=${var.y})",
- ConstString("HIPoint"),
- objc_flags);
- AddStringSummary(coreservices_category_sp,
- "origin=${var.origin} size=${var.size}",
- ConstString("HIRect"),
- objc_flags);
-
- TypeSummaryImpl::Flags appkit_flags;
- appkit_flags.SetCascades(true)
- .SetSkipPointers(false)
- .SetSkipReferences(false)
- .SetDontShowChildren(true)
- .SetDontShowValue(false)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false);
-
- appkit_flags.SetDontShowChildren(false);
-
-
-#ifndef LLDB_DISABLE_PYTHON
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("NSArray"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("NSMutableArray"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("__NSArrayI"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("__NSArrayM"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("__NSCFArray"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("CFArrayRef"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("CFMutableArrayRef"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<false>, "NSDictionary summary provider", ConstString("NSDictionary"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<false>, "NSDictionary summary provider", ConstString("NSMutableDictionary"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<false>, "NSDictionary summary provider", ConstString("__NSCFDictionary"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<false>, "NSDictionary summary provider", ConstString("__NSDictionaryI"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<false>, "NSDictionary summary provider", ConstString("__NSDictionaryM"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<true>, "NSDictionary summary provider", ConstString("CFDictionaryRef"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<true>, "NSDictionary summary provider", ConstString("CFMutableDictionaryRef"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "NSSet summary", ConstString("NSSet"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "NSMutableSet summary", ConstString("NSMutableSet"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSSetSummaryProvider<true>, "CFSetRef summary", ConstString("CFSetRef"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSSetSummaryProvider<true>, "CFMutableSetRef summary", ConstString("CFMutableSetRef"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "__NSCFSet summary", ConstString("__NSCFSet"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "__NSSetI summary", ConstString("__NSSetI"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "__NSSetM summary", ConstString("__NSSetM"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "NSCountedSet summary", ConstString("NSCountedSet"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "NSMutableSet summary", ConstString("NSMutableSet"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "NSOrderedSet summary", ConstString("NSOrderedSet"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "__NSOrderedSetI summary", ConstString("__NSOrderedSetI"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "__NSOrderedSetM summary", ConstString("__NSOrderedSetM"), appkit_flags);
-
- // AddSummary(appkit_category_sp, "${var.key%@} -> ${var.value%@}", ConstString("$_lldb_typegen_nspair"), appkit_flags);
-
- appkit_flags.SetDontShowChildren(true);
-
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSArrayM"), ScriptedSyntheticChildren::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSArrayI"), ScriptedSyntheticChildren::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("NSArray"), ScriptedSyntheticChildren::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("NSMutableArray"), ScriptedSyntheticChildren::Flags());
- AddCXXSynthetic(corefoundation_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSCFArray"), ScriptedSyntheticChildren::Flags());
- AddCXXSynthetic(corefoundation_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("CFMutableArrayRef"), ScriptedSyntheticChildren::Flags());
- AddCXXSynthetic(corefoundation_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("CFArrayRef"), ScriptedSyntheticChildren::Flags());
-
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("__NSDictionaryM"), ScriptedSyntheticChildren::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("__NSDictionaryI"), ScriptedSyntheticChildren::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("__NSCFDictionary"), ScriptedSyntheticChildren::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("NSDictionary"), ScriptedSyntheticChildren::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("NSMutableDictionary"), ScriptedSyntheticChildren::Flags());
- AddCXXSynthetic(corefoundation_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("CFDictionaryRef"), ScriptedSyntheticChildren::Flags());
- AddCXXSynthetic(corefoundation_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("CFMutableDictionaryRef"), ScriptedSyntheticChildren::Flags());
-
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator, "NSSet synthetic children", ConstString("NSSet"), ScriptedSyntheticChildren::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator, "__NSSetI synthetic children", ConstString("__NSSetI"), ScriptedSyntheticChildren::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator, "__NSSetM synthetic children", ConstString("__NSSetM"), ScriptedSyntheticChildren::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator, "NSMutableSet synthetic children", ConstString("NSMutableSet"), ScriptedSyntheticChildren::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator, "NSOrderedSet synthetic children", ConstString("NSOrderedSet"), ScriptedSyntheticChildren::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator, "__NSOrderedSetI synthetic children", ConstString("__NSOrderedSetI"), ScriptedSyntheticChildren::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator, "__NSOrderedSetM synthetic children", ConstString("__NSOrderedSetM"), ScriptedSyntheticChildren::Flags());
-
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSIndexPathSyntheticFrontEndCreator, "NSIndexPath synthetic children", ConstString("NSIndexPath"), ScriptedSyntheticChildren::Flags());
-
- AddCXXSummary(corefoundation_category_sp,lldb_private::formatters::CFBagSummaryProvider, "CFBag summary provider", ConstString("CFBagRef"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp,lldb_private::formatters::CFBagSummaryProvider, "CFBag summary provider", ConstString("__CFBag"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp,lldb_private::formatters::CFBagSummaryProvider, "CFBag summary provider", ConstString("const struct __CFBag"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp,lldb_private::formatters::CFBagSummaryProvider, "CFBag summary provider", ConstString("CFMutableBagRef"), appkit_flags);
-
- AddCXXSummary(corefoundation_category_sp,lldb_private::formatters::CFBinaryHeapSummaryProvider, "CFBinaryHeap summary provider", ConstString("CFBinaryHeapRef"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp,lldb_private::formatters::CFBinaryHeapSummaryProvider, "CFBinaryHeap summary provider", ConstString("__CFBinaryHeap"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("NSString"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("CFStringRef"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("__CFString"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("CFMutableStringRef"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("NSMutableString"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("__NSCFConstantString"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("__NSCFString"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("NSCFConstantString"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("NSCFString"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("NSPathStore2"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSAttributedStringSummaryProvider, "NSAttributedString summary provider", ConstString("NSAttributedString"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSMutableAttributedStringSummaryProvider, "NSMutableAttributedString summary provider", ConstString("NSMutableAttributedString"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSMutableAttributedStringSummaryProvider, "NSMutableAttributedString summary provider", ConstString("NSConcreteMutableAttributedString"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSBundleSummaryProvider, "NSBundle summary provider", ConstString("NSBundle"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("NSData"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("NSConcreteData"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("NSConcreteMutableData"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("NSMutableData"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("__NSCFData"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSDataSummaryProvider<true>, "NSData summary provider", ConstString("CFDataRef"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSDataSummaryProvider<true>, "NSData summary provider", ConstString("CFMutableDataRef"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSMachPortSummaryProvider, "NSMachPort summary provider", ConstString("NSMachPort"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSNotificationSummaryProvider, "NSNotification summary provider", ConstString("NSNotification"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSNotificationSummaryProvider, "NSNotification summary provider", ConstString("NSConcreteNotification"), appkit_flags);
-
- AddStringSummary(appkit_category_sp, "domain: ${var._domain} - code: ${var._code}", ConstString("NSError"), appkit_flags);
- AddStringSummary(appkit_category_sp,"name:${var.name%S} reason:${var.reason%S}",ConstString("NSException"),appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("NSNumber"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "CFNumberRef summary provider", ConstString("CFNumberRef"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("__NSCFBoolean"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("__NSCFNumber"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("NSCFBoolean"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("NSCFNumber"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSDecimalNumber summary provider", ConstString("NSDecimalNumber"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSHost summary provider", ConstString("NSHost"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSTask summary provider", ConstString("NSTask"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSValue summary provider", ConstString("NSValue"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSURLSummaryProvider, "NSURL summary provider", ConstString("NSURL"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSURLSummaryProvider, "NSURL summary provider", ConstString("CFURLRef"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDateSummaryProvider, "NSDate summary provider", ConstString("NSDate"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDateSummaryProvider, "NSDate summary provider", ConstString("__NSDate"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDateSummaryProvider, "NSDate summary provider", ConstString("__NSTaggedDate"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDateSummaryProvider, "NSDate summary provider", ConstString("NSCalendarDate"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSTimeZoneSummaryProvider, "NSTimeZone summary provider", ConstString("NSTimeZone"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::NSTimeZoneSummaryProvider, "NSTimeZone summary provider", ConstString("CFTimeZoneRef"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSTimeZoneSummaryProvider, "NSTimeZone summary provider", ConstString("__NSTimeZone"), appkit_flags);
-
- // CFAbsoluteTime is actually a double rather than a pointer to an object
- // we do not care about the numeric value, since it is probably meaningless to users
- appkit_flags.SetDontShowValue(true);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::CFAbsoluteTimeSummaryProvider, "CFAbsoluteTime summary provider", ConstString("CFAbsoluteTime"), appkit_flags);
- appkit_flags.SetDontShowValue(false);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSIndexSetSummaryProvider, "NSIndexSet summary provider", ConstString("NSIndexSet"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSIndexSetSummaryProvider, "NSIndexSet summary provider", ConstString("NSMutableIndexSet"), appkit_flags);
-
- AddStringSummary(corefoundation_category_sp,
- "@\"${var.month%d}/${var.day%d}/${var.year%d} ${var.hour%d}:${var.minute%d}:${var.second}\"",
- ConstString("CFGregorianDate"),
- appkit_flags);
-
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::CFBitVectorSummaryProvider, "CFBitVector summary provider", ConstString("CFBitVectorRef"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::CFBitVectorSummaryProvider, "CFBitVector summary provider", ConstString("CFMutableBitVectorRef"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::CFBitVectorSummaryProvider, "CFBitVector summary provider", ConstString("__CFBitVector"), appkit_flags);
- AddCXXSummary(corefoundation_category_sp, lldb_private::formatters::CFBitVectorSummaryProvider, "CFBitVector summary provider", ConstString("__CFMutableBitVector"), appkit_flags);
-#endif // LLDB_DISABLE_PYTHON
-
TypeCategoryImpl::SharedPointer vectors_category_sp = GetCategory(m_vectortypes_category_name);
-
+
TypeSummaryImpl::Flags vector_flags;
vector_flags.SetCascades(true)
.SetSkipPointers(true)
@@ -1514,8 +1145,8 @@ FormatManager::LoadObjCFormatters()
AddStringSummary(vectors_category_sp,
"${var.uint128}",
ConstString("builtin_type_vec128"),
- objc_flags);
-
+ vector_flags);
+
AddStringSummary(vectors_category_sp,
"",
ConstString("float [4]"),
@@ -1569,84 +1200,3 @@ FormatManager::LoadObjCFormatters()
ConstString("vBool32"),
vector_flags);
}
-
-void
-FormatManager::LoadCoreMediaFormatters()
-{
- TypeSummaryImpl::Flags cm_flags;
- cm_flags.SetCascades(true)
- .SetDontShowChildren(false)
- .SetDontShowValue(false)
- .SetHideItemNames(false)
- .SetShowMembersOneLiner(false)
- .SetSkipPointers(false)
- .SetSkipReferences(false);
-
- TypeCategoryImpl::SharedPointer cm_category_sp = GetCategory(m_coremedia_category_name);
-
-#ifndef LLDB_DISABLE_PYTHON
- AddCXXSummary(cm_category_sp, lldb_private::formatters::CMTimeSummaryProvider, "CMTime summary provider", ConstString("CMTime"), cm_flags);
-#endif // LLDB_DISABLE_PYTHON
-}
-
-void
-FormatManager::LoadHardcodedFormatters()
-{
- {
- // insert code to load formats here
- }
- {
- // insert code to load summaries here
- m_hardcoded_summaries.push_back(
- [](lldb_private::ValueObject& valobj,
- lldb::DynamicValueType,
- FormatManager&) -> TypeSummaryImpl::SharedPointer {
- static CXXFunctionSummaryFormat::SharedPointer formatter_sp(new CXXFunctionSummaryFormat(TypeSummaryImpl::Flags(), lldb_private::formatters::FunctionPointerSummaryProvider, "Function pointer summary provider"));
- if (valobj.GetClangType().IsFunctionPointerType())
- {
- return formatter_sp;
- }
- return nullptr;
- });
- m_hardcoded_summaries.push_back(
- [](lldb_private::ValueObject& valobj,
- lldb::DynamicValueType,
- FormatManager& fmt_mgr) -> TypeSummaryImpl::SharedPointer {
- static CXXFunctionSummaryFormat::SharedPointer formatter_sp(new CXXFunctionSummaryFormat(TypeSummaryImpl::Flags()
- .SetCascades(true)
- .SetDontShowChildren(true)
- .SetHideItemNames(true)
- .SetShowMembersOneLiner(true)
- .SetSkipPointers(true)
- .SetSkipReferences(false),
- lldb_private::formatters::VectorTypeSummaryProvider,
- "vector_type pointer summary provider"));
- if (valobj.GetClangType().IsVectorType(nullptr, nullptr))
- {
- if (fmt_mgr.GetCategory(fmt_mgr.m_vectortypes_category_name)->IsEnabled())
- return formatter_sp;
- }
- return nullptr;
- });
- }
- {
- // insert code to load synthetics here
- m_hardcoded_synthetics.push_back(
- [](lldb_private::ValueObject& valobj,
- lldb::DynamicValueType,
- FormatManager& fmt_mgr) -> SyntheticChildren::SharedPointer {
- static CXXSyntheticChildren::SharedPointer formatter_sp(new CXXSyntheticChildren(SyntheticChildren::Flags().SetCascades(true).SetSkipPointers(true).SetSkipReferences(true).SetNonCacheable(true),
- "vector_type synthetic children",
- lldb_private::formatters::VectorTypeSyntheticFrontEndCreator));
- if (valobj.GetClangType().IsVectorType(nullptr, nullptr))
- {
- if (fmt_mgr.GetCategory(fmt_mgr.m_vectortypes_category_name)->IsEnabled())
- return formatter_sp;
- }
- return nullptr;
- });
- }
- {
- // insert code to load validators here
- }
-}
diff --git a/source/DataFormatters/FormattersHelpers.cpp b/source/DataFormatters/FormattersHelpers.cpp
new file mode 100644
index 000000000000..4b0e82e975e4
--- /dev/null
+++ b/source/DataFormatters/FormattersHelpers.cpp
@@ -0,0 +1,336 @@
+//===-- FormattersHelpers.cpp -------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C Includes
+
+// C++ Includes
+
+// Other libraries and framework includes
+
+// Project includes
+#include "lldb/DataFormatters/FormattersHelpers.h"
+
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/RegularExpression.h"
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+void
+lldb_private::formatters::AddFormat (TypeCategoryImpl::SharedPointer category_sp,
+ lldb::Format format,
+ ConstString type_name,
+ TypeFormatImpl::Flags flags,
+ bool regex)
+{
+ lldb::TypeFormatImplSP format_sp(new TypeFormatImpl_Format(format, flags));
+
+ if (regex)
+ category_sp->GetRegexTypeFormatsContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),format_sp);
+ else
+ category_sp->GetTypeFormatsContainer()->Add(type_name, format_sp);
+}
+
+void
+lldb_private::formatters::AddSummary(TypeCategoryImpl::SharedPointer category_sp,
+ TypeSummaryImplSP summary_sp,
+ ConstString type_name,
+ bool regex)
+{
+ if (regex)
+ category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),summary_sp);
+ else
+ category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
+}
+
+void
+lldb_private::formatters::AddStringSummary(TypeCategoryImpl::SharedPointer category_sp,
+ const char* string,
+ ConstString type_name,
+ TypeSummaryImpl::Flags flags,
+ bool regex)
+{
+ lldb::TypeSummaryImplSP summary_sp(new StringSummaryFormat(flags,
+ string));
+
+ if (regex)
+ category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),summary_sp);
+ else
+ category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
+}
+
+void
+lldb_private::formatters::AddOneLineSummary (TypeCategoryImpl::SharedPointer category_sp,
+ ConstString type_name,
+ TypeSummaryImpl::Flags flags,
+ bool regex)
+{
+ flags.SetShowMembersOneLiner(true);
+ lldb::TypeSummaryImplSP summary_sp(new StringSummaryFormat(flags, ""));
+
+ if (regex)
+ category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),summary_sp);
+ else
+ 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,
+ ConstString type_name,
+ TypeSummaryImpl::Flags flags,
+ bool regex)
+{
+ lldb::TypeSummaryImplSP summary_sp(new CXXFunctionSummaryFormat(flags,funct,description));
+ if (regex)
+ category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),summary_sp);
+ else
+ category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
+}
+
+void
+lldb_private::formatters::AddCXXSynthetic (TypeCategoryImpl::SharedPointer category_sp,
+ CXXSyntheticChildren::CreateFrontEndCallback generator,
+ const char* description,
+ ConstString type_name,
+ ScriptedSyntheticChildren::Flags flags,
+ bool regex)
+{
+ lldb::SyntheticChildrenSP synth_sp(new CXXSyntheticChildren(flags,description,generator));
+ if (regex)
+ category_sp->GetRegexTypeSyntheticsContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())), synth_sp);
+ else
+ category_sp->GetTypeSyntheticsContainer()->Add(type_name,synth_sp);
+}
+
+void
+lldb_private::formatters::AddFilter (TypeCategoryImpl::SharedPointer category_sp,
+ std::vector<std::string> children,
+ const char* description,
+ ConstString type_name,
+ ScriptedSyntheticChildren::Flags flags,
+ bool regex)
+{
+ TypeFilterImplSP filter_sp(new TypeFilterImpl(flags));
+ for (auto child : children)
+ filter_sp->AddExpressionPath(child);
+ if (regex)
+ category_sp->GetRegexTypeFiltersContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())), filter_sp);
+ else
+ category_sp->GetTypeFiltersContainer()->Add(type_name,filter_sp);
+}
+#endif
+
+StackFrame*
+lldb_private::formatters::GetViableFrame (ExecutionContext exe_ctx)
+{
+ StackFrame* frame = exe_ctx.GetFramePtr();
+ if (frame)
+ return frame;
+
+ Process* process = exe_ctx.GetProcessPtr();
+ if (!process)
+ return nullptr;
+
+ ThreadSP thread_sp(process->GetThreadList().GetSelectedThread());
+ if (thread_sp)
+ return thread_sp->GetSelectedFrame().get();
+ return nullptr;
+}
+
+bool
+lldb_private::formatters::ExtractValueFromObjCExpression (ValueObject &valobj,
+ const char* target_type,
+ const char* selector,
+ uint64_t &value)
+{
+ if (!target_type || !*target_type)
+ return false;
+ if (!selector || !*selector)
+ return false;
+ StreamString expr;
+ expr.Printf("(%s)[(id)0x%" PRIx64 " %s]",target_type,valobj.GetPointerValue(),selector);
+ ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
+ lldb::ValueObjectSP result_sp;
+ Target* target = exe_ctx.GetTargetPtr();
+ StackFrame* stack_frame = GetViableFrame(exe_ctx);
+ if (!target || !stack_frame)
+ return false;
+
+ EvaluateExpressionOptions options;
+ options.SetCoerceToId(false);
+ options.SetUnwindOnError(true);
+ options.SetKeepInMemory(true);
+ options.SetLanguage(lldb::eLanguageTypeObjC_plus_plus);
+ options.SetResultIsInternal(true);
+ options.SetUseDynamic(lldb::eDynamicCanRunTarget);
+
+ target->EvaluateExpression(expr.GetData(),
+ stack_frame,
+ result_sp,
+ options);
+ if (!result_sp)
+ return false;
+ value = result_sp->GetValueAsUnsigned(0);
+ return true;
+}
+
+bool
+lldb_private::formatters::ExtractSummaryFromObjCExpression (ValueObject &valobj,
+ const char* target_type,
+ const char* selector,
+ Stream &stream,
+ lldb::LanguageType lang_type)
+{
+ if (!target_type || !*target_type)
+ return false;
+ if (!selector || !*selector)
+ return false;
+ StreamString expr;
+ expr.Printf("(%s)[(id)0x%" PRIx64 " %s]",target_type,valobj.GetPointerValue(),selector);
+ ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
+ lldb::ValueObjectSP result_sp;
+ Target* target = exe_ctx.GetTargetPtr();
+ StackFrame* stack_frame = GetViableFrame(exe_ctx);
+ if (!target || !stack_frame)
+ return false;
+
+ EvaluateExpressionOptions options;
+ options.SetCoerceToId(false);
+ options.SetUnwindOnError(true);
+ options.SetKeepInMemory(true);
+ options.SetLanguage(lldb::eLanguageTypeObjC_plus_plus);
+ options.SetResultIsInternal(true);
+ options.SetUseDynamic(lldb::eDynamicCanRunTarget);
+
+ target->EvaluateExpression(expr.GetData(),
+ stack_frame,
+ result_sp,
+ options);
+ if (!result_sp)
+ return false;
+ stream.Printf("%s",result_sp->GetSummaryAsCString(lang_type));
+ return true;
+}
+
+lldb::ValueObjectSP
+lldb_private::formatters::CallSelectorOnObject (ValueObject &valobj,
+ const char* return_type,
+ const char* selector,
+ uint64_t index)
+{
+ lldb::ValueObjectSP valobj_sp;
+ if (!return_type || !*return_type)
+ return valobj_sp;
+ if (!selector || !*selector)
+ return valobj_sp;
+ StreamString expr;
+ const char *colon = "";
+ llvm::StringRef selector_sr(selector);
+ if (selector_sr.back() != ':')
+ colon = ":";
+ expr.Printf("(%s)[(id)0x%" PRIx64 " %s%s%" PRId64 "]",return_type,valobj.GetPointerValue(),selector,colon,index);
+ ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
+ lldb::ValueObjectSP result_sp;
+ Target* target = exe_ctx.GetTargetPtr();
+ StackFrame* stack_frame = GetViableFrame(exe_ctx);
+ if (!target || !stack_frame)
+ return valobj_sp;
+
+ EvaluateExpressionOptions options;
+ options.SetCoerceToId(false);
+ options.SetUnwindOnError(true);
+ options.SetKeepInMemory(true);
+ options.SetLanguage(lldb::eLanguageTypeObjC_plus_plus);
+ options.SetResultIsInternal(true);
+ options.SetUseDynamic(lldb::eDynamicCanRunTarget);
+
+ target->EvaluateExpression(expr.GetData(),
+ stack_frame,
+ valobj_sp,
+ options);
+ return valobj_sp;
+}
+
+lldb::ValueObjectSP
+lldb_private::formatters::CallSelectorOnObject (ValueObject &valobj,
+ const char* return_type,
+ const char* selector,
+ const char* key)
+{
+ lldb::ValueObjectSP valobj_sp;
+ if (!return_type || !*return_type)
+ return valobj_sp;
+ if (!selector || !*selector)
+ return valobj_sp;
+ if (!key || !*key)
+ return valobj_sp;
+ StreamString expr;
+ const char *colon = "";
+ llvm::StringRef selector_sr(selector);
+ if (selector_sr.back() != ':')
+ colon = ":";
+ expr.Printf("(%s)[(id)0x%" PRIx64 " %s%s%s]",return_type,valobj.GetPointerValue(),selector,colon,key);
+ ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
+ lldb::ValueObjectSP result_sp;
+ Target* target = exe_ctx.GetTargetPtr();
+ StackFrame* stack_frame = GetViableFrame(exe_ctx);
+ if (!target || !stack_frame)
+ return valobj_sp;
+
+ EvaluateExpressionOptions options;
+ options.SetCoerceToId(false);
+ options.SetUnwindOnError(true);
+ options.SetKeepInMemory(true);
+ options.SetLanguage(lldb::eLanguageTypeObjC_plus_plus);
+ options.SetResultIsInternal(true);
+ options.SetUseDynamic(lldb::eDynamicCanRunTarget);
+
+ target->EvaluateExpression(expr.GetData(),
+ stack_frame,
+ valobj_sp,
+ options);
+ return valobj_sp;
+}
+
+size_t
+lldb_private::formatters::ExtractIndexFromString (const char* item_name)
+{
+ if (!item_name || !*item_name)
+ return UINT32_MAX;
+ if (*item_name != '[')
+ return UINT32_MAX;
+ item_name++;
+ char* endptr = NULL;
+ unsigned long int idx = ::strtoul(item_name, &endptr, 0);
+ if (idx == 0 && endptr == item_name)
+ return UINT32_MAX;
+ if (idx == ULONG_MAX)
+ return UINT32_MAX;
+ return idx;
+}
+
+lldb::addr_t
+lldb_private::formatters::GetArrayAddressOrPointerValue (ValueObject& valobj)
+{
+ lldb::addr_t data_addr = LLDB_INVALID_ADDRESS;
+
+ if (valobj.IsPointerType())
+ data_addr = valobj.GetValueAsUnsigned(0);
+ else if (valobj.IsArrayType())
+ data_addr = valobj.GetAddressOf();
+
+ return data_addr;
+}
diff --git a/source/DataFormatters/LanguageCategory.cpp b/source/DataFormatters/LanguageCategory.cpp
new file mode 100644
index 000000000000..261c3e6302e1
--- /dev/null
+++ b/source/DataFormatters/LanguageCategory.cpp
@@ -0,0 +1,271 @@
+//===-- LanguageCategory.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/DataFormatters/LanguageCategory.h"
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/DataFormatters/FormatManager.h"
+#include "lldb/DataFormatters/TypeCategory.h"
+#include "lldb/DataFormatters/TypeFormat.h"
+#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
+#include "lldb/DataFormatters/TypeValidator.h"
+#include "lldb/Target/Language.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+LanguageCategory::LanguageCategory (lldb::LanguageType lang_type) :
+ m_category_sp(),
+ m_hardcoded_formats(),
+ m_hardcoded_summaries(),
+ m_hardcoded_synthetics(),
+ m_hardcoded_validators(),
+ m_format_cache(),
+ m_enabled(false)
+{
+ if (Language* language_plugin = Language::FindPlugin(lang_type))
+ {
+ m_category_sp = language_plugin->GetFormatters();
+ m_hardcoded_formats = language_plugin->GetHardcodedFormats();
+ m_hardcoded_summaries = language_plugin->GetHardcodedSummaries();
+ m_hardcoded_synthetics = language_plugin->GetHardcodedSynthetics();
+ m_hardcoded_validators = language_plugin->GetHardcodedValidators();
+ }
+ Enable();
+}
+
+bool
+LanguageCategory::Get (FormattersMatchData& match_data,
+ lldb::TypeFormatImplSP& format_sp)
+{
+ if (!m_category_sp)
+ return false;
+
+ if (!IsEnabled())
+ return false;
+
+ if (match_data.GetTypeForCache())
+ {
+ if (m_format_cache.GetFormat(match_data.GetTypeForCache(), format_sp))
+ return format_sp.get() != nullptr;
+ }
+
+ ValueObject& valobj(match_data.GetValueObject());
+ bool result = m_category_sp->Get(valobj, match_data.GetMatchesVector(), format_sp);
+ if (match_data.GetTypeForCache() && (!format_sp || !format_sp->NonCacheable()))
+ {
+ m_format_cache.SetFormat(match_data.GetTypeForCache(), format_sp);
+ }
+ return result;
+}
+
+bool
+LanguageCategory::Get (FormattersMatchData& match_data,
+ lldb::TypeSummaryImplSP& format_sp)
+{
+ if (!m_category_sp)
+ return false;
+
+ if (!IsEnabled())
+ return false;
+
+ if (match_data.GetTypeForCache())
+ {
+ if (m_format_cache.GetSummary(match_data.GetTypeForCache(), format_sp))
+ return format_sp.get() != nullptr;
+ }
+
+ ValueObject& valobj(match_data.GetValueObject());
+ bool result = m_category_sp->Get(valobj, match_data.GetMatchesVector(), format_sp);
+ if (match_data.GetTypeForCache() && (!format_sp || !format_sp->NonCacheable()))
+ {
+ m_format_cache.SetSummary(match_data.GetTypeForCache(), format_sp);
+ }
+ return result;
+}
+
+bool
+LanguageCategory::Get (FormattersMatchData& match_data,
+ lldb::SyntheticChildrenSP& format_sp)
+{
+ if (!m_category_sp)
+ return false;
+
+ if (!IsEnabled())
+ return false;
+
+ if (match_data.GetTypeForCache())
+ {
+ if (m_format_cache.GetSynthetic(match_data.GetTypeForCache(), format_sp))
+ return format_sp.get() != nullptr;
+ }
+
+ ValueObject& valobj(match_data.GetValueObject());
+ bool result = m_category_sp->Get(valobj, match_data.GetMatchesVector(), format_sp);
+ if (match_data.GetTypeForCache() && (!format_sp || !format_sp->NonCacheable()))
+ {
+ m_format_cache.SetSynthetic(match_data.GetTypeForCache(), format_sp);
+ }
+ return result;
+}
+
+bool
+LanguageCategory::Get (FormattersMatchData& match_data,
+ lldb::TypeValidatorImplSP& format_sp)
+{
+ if (!m_category_sp)
+ return false;
+
+ if (!IsEnabled())
+ return false;
+
+ if (match_data.GetTypeForCache())
+ {
+ if (m_format_cache.GetValidator(match_data.GetTypeForCache(), format_sp))
+ return format_sp.get() != nullptr;
+ }
+
+ ValueObject& valobj(match_data.GetValueObject());
+ bool result = m_category_sp->Get(valobj, match_data.GetMatchesVector(), format_sp);
+ if (match_data.GetTypeForCache() && (!format_sp || !format_sp->NonCacheable()))
+ {
+ m_format_cache.SetValidator(match_data.GetTypeForCache(), format_sp);
+ }
+ return result;
+}
+
+bool
+LanguageCategory::GetHardcoded (FormatManager& fmt_mgr,
+ FormattersMatchData& match_data,
+ lldb::TypeFormatImplSP& format_sp)
+{
+ if (!IsEnabled())
+ return false;
+
+ ValueObject& valobj(match_data.GetValueObject());
+ lldb::DynamicValueType use_dynamic(match_data.GetDynamicValueType());
+
+ for (auto& candidate : m_hardcoded_formats)
+ {
+ if ((format_sp = candidate(valobj, use_dynamic, fmt_mgr)))
+ break;
+ }
+ if (match_data.GetTypeForCache() && (!format_sp || !format_sp->NonCacheable()))
+ {
+ m_format_cache.SetFormat(match_data.GetTypeForCache(), format_sp);
+ }
+ return format_sp.get() != nullptr;
+}
+
+bool
+LanguageCategory::GetHardcoded (FormatManager& fmt_mgr,
+ FormattersMatchData& match_data,
+ lldb::TypeSummaryImplSP& format_sp)
+{
+ if (!IsEnabled())
+ return false;
+
+ ValueObject& valobj(match_data.GetValueObject());
+ lldb::DynamicValueType use_dynamic(match_data.GetDynamicValueType());
+
+ for (auto& candidate : m_hardcoded_summaries)
+ {
+ if ((format_sp = candidate(valobj, use_dynamic, fmt_mgr)))
+ break;
+ }
+ if (match_data.GetTypeForCache() && (!format_sp || !format_sp->NonCacheable()))
+ {
+ m_format_cache.SetSummary(match_data.GetTypeForCache(), format_sp);
+ }
+ return format_sp.get() != nullptr;
+}
+
+bool
+LanguageCategory::GetHardcoded (FormatManager& fmt_mgr,
+ FormattersMatchData& match_data,
+ lldb::SyntheticChildrenSP& format_sp)
+{
+ if (!IsEnabled())
+ return false;
+
+ ValueObject& valobj(match_data.GetValueObject());
+ lldb::DynamicValueType use_dynamic(match_data.GetDynamicValueType());
+
+ for (auto& candidate : m_hardcoded_synthetics)
+ {
+ if ((format_sp = candidate(valobj, use_dynamic, fmt_mgr)))
+ break;
+ }
+ if (match_data.GetTypeForCache() && (!format_sp || !format_sp->NonCacheable()))
+ {
+ m_format_cache.SetSynthetic(match_data.GetTypeForCache(), format_sp);
+ }
+ return format_sp.get() != nullptr;
+}
+
+bool
+LanguageCategory::GetHardcoded (FormatManager& fmt_mgr,
+ FormattersMatchData& match_data,
+ lldb::TypeValidatorImplSP& format_sp)
+{
+ if (!IsEnabled())
+ return false;
+
+ ValueObject& valobj(match_data.GetValueObject());
+ lldb::DynamicValueType use_dynamic(match_data.GetDynamicValueType());
+
+ for (auto& candidate : m_hardcoded_validators)
+ {
+ if ((format_sp = candidate(valobj, use_dynamic, fmt_mgr)))
+ break;
+ }
+ if (match_data.GetTypeForCache() && (!format_sp || !format_sp->NonCacheable()))
+ {
+ m_format_cache.SetValidator(match_data.GetTypeForCache(), format_sp);
+ }
+ return format_sp.get() != nullptr;
+}
+
+lldb::TypeCategoryImplSP
+LanguageCategory::GetCategory () const
+{
+ return m_category_sp;
+}
+
+FormatCache&
+LanguageCategory::GetFormatCache ()
+{
+ return m_format_cache;
+}
+
+void
+LanguageCategory::Enable ()
+{
+ if (m_category_sp)
+ m_category_sp->Enable(true, TypeCategoryMap::Default);
+ m_enabled = true;
+}
+
+void
+LanguageCategory::Disable ()
+{
+ if (m_category_sp)
+ m_category_sp->Disable();
+ m_enabled = false;
+}
+
+bool
+LanguageCategory::IsEnabled ()
+{
+ return m_enabled;
+}
diff --git a/source/DataFormatters/LibStdcpp.cpp b/source/DataFormatters/LibStdcpp.cpp
deleted file mode 100644
index 2b3bcb58afac..000000000000
--- a/source/DataFormatters/LibStdcpp.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-//===-- LibStdcpp.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/DataFormatters/CXXFormatterFunctions.h"
-
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/ValueObject.h"
-#include "lldb/Core/ValueObjectConstResult.h"
-#include "lldb/Host/Endian.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
-#include "lldb/Target/Target.h"
-
-using namespace lldb;
-using namespace lldb_private;
-using namespace lldb_private::formatters;
-
-/*
- (std::_Rb_tree_iterator<std::pair<const int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >) ibeg = {
- (_Base_ptr) _M_node = 0x0000000100103910 {
- (std::_Rb_tree_color) _M_color = _S_black
- (std::_Rb_tree_node_base::_Base_ptr) _M_parent = 0x00000001001038c0
- (std::_Rb_tree_node_base::_Base_ptr) _M_left = 0x0000000000000000
- (std::_Rb_tree_node_base::_Base_ptr) _M_right = 0x0000000000000000
- }
- }
- */
-
-lldb_private::formatters::LibstdcppMapIteratorSyntheticFrontEnd::LibstdcppMapIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
- SyntheticChildrenFrontEnd(*valobj_sp.get()),
- m_exe_ctx_ref(),
- m_pair_address(0),
- m_pair_type(),
- m_options(),
- m_pair_sp()
-{
- if (valobj_sp)
- Update();
- m_options.SetCoerceToId(false);
- m_options.SetUnwindOnError(true);
- m_options.SetKeepInMemory(true);
- m_options.SetUseDynamic(lldb::eDynamicCanRunTarget);
-}
-
-bool
-lldb_private::formatters::LibstdcppMapIteratorSyntheticFrontEnd::Update()
-{
- ValueObjectSP valobj_sp = m_backend.GetSP();
- if (!valobj_sp)
- return false;
-
- TargetSP target_sp(valobj_sp->GetTargetSP());
-
- if (!target_sp)
- return false;
-
- bool is_64bit = (target_sp->GetArchitecture().GetAddressByteSize() == 8);
-
- if (!valobj_sp)
- return false;
- m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
-
- ValueObjectSP _M_node_sp(valobj_sp->GetChildMemberWithName(ConstString("_M_node"), true));
- if (!_M_node_sp)
- return false;
-
- m_pair_address = _M_node_sp->GetValueAsUnsigned(0);
- if (m_pair_address == 0)
- return false;
-
- m_pair_address += (is_64bit ? 32 : 16);
-
- ClangASTType my_type(valobj_sp->GetClangType());
- if (my_type.GetNumTemplateArguments() >= 1)
- {
- TemplateArgumentKind kind;
- ClangASTType pair_type = my_type.GetTemplateArgument(0, kind);
- if (kind != eTemplateArgumentKindType && kind != eTemplateArgumentKindTemplate && kind != eTemplateArgumentKindTemplateExpansion)
- return false;
- m_pair_type = pair_type;
- }
- else
- return false;
-
- return true;
-}
-
-size_t
-lldb_private::formatters::LibstdcppMapIteratorSyntheticFrontEnd::CalculateNumChildren ()
-{
- return 2;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::LibstdcppMapIteratorSyntheticFrontEnd::GetChildAtIndex (size_t idx)
-{
- if (m_pair_address != 0 && m_pair_type)
- {
- if (!m_pair_sp)
- m_pair_sp = CreateValueObjectFromAddress("pair", m_pair_address, m_exe_ctx_ref, m_pair_type);
- if (m_pair_sp)
- return m_pair_sp->GetChildAtIndex(idx, true);
- }
- return lldb::ValueObjectSP();
-}
-
-bool
-lldb_private::formatters::LibstdcppMapIteratorSyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
-}
-
-size_t
-lldb_private::formatters::LibstdcppMapIteratorSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- if (name == ConstString("first"))
- return 0;
- if (name == ConstString("second"))
- return 1;
- return UINT32_MAX;
-}
-
-lldb_private::formatters::LibstdcppMapIteratorSyntheticFrontEnd::~LibstdcppMapIteratorSyntheticFrontEnd ()
-{}
-
-SyntheticChildrenFrontEnd*
-lldb_private::formatters::LibstdcppMapIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
- if (!valobj_sp)
- return NULL;
- return (new LibstdcppMapIteratorSyntheticFrontEnd(valobj_sp));
-}
-
-/*
- (lldb) fr var ibeg --ptr-depth 1
- (__gnu_cxx::__normal_iterator<int *, std::vector<int, std::allocator<int> > >) ibeg = {
- _M_current = 0x00000001001037a0 {
- *_M_current = 1
- }
- }
- */
-
-SyntheticChildrenFrontEnd*
-lldb_private::formatters::LibStdcppVectorIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
- static ConstString g_item_name;
- if (!g_item_name)
- g_item_name.SetCString("_M_current");
- if (!valobj_sp)
- return NULL;
- return (new VectorIteratorSyntheticFrontEnd(valobj_sp,g_item_name));
-}
diff --git a/source/DataFormatters/StringPrinter.cpp b/source/DataFormatters/StringPrinter.cpp
index a011cd553d0c..b114add50640 100644
--- a/source/DataFormatters/StringPrinter.cpp
+++ b/source/DataFormatters/StringPrinter.cpp
@@ -9,109 +9,26 @@
#include "lldb/DataFormatters/StringPrinter.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/ValueObject.h"
+#include "lldb/Target/Language.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "llvm/Support/ConvertUTF.h"
#include <ctype.h>
-#include <functional>
#include <locale>
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
-// I can't use a std::unique_ptr for this because the Deleter is a template argument there
-// and I want the same type to represent both pointers I want to free and pointers I don't need
-// to free - which is what this class essentially is
-// It's very specialized to the needs of this file, and not suggested for general use
-template <typename T = uint8_t, typename U = char, typename S = size_t>
-struct StringPrinterBufferPointer
-{
-public:
-
- typedef std::function<void(const T*)> Deleter;
-
- StringPrinterBufferPointer (std::nullptr_t ptr) :
- m_data(nullptr),
- m_size(0),
- m_deleter()
- {}
-
- StringPrinterBufferPointer(const T* bytes, S size, Deleter deleter = nullptr) :
- m_data(bytes),
- m_size(size),
- m_deleter(deleter)
- {}
-
- StringPrinterBufferPointer(const U* bytes, S size, Deleter deleter = nullptr) :
- m_data((T*)bytes),
- m_size(size),
- m_deleter(deleter)
- {}
-
- StringPrinterBufferPointer(StringPrinterBufferPointer&& rhs) :
- m_data(rhs.m_data),
- m_size(rhs.m_size),
- m_deleter(rhs.m_deleter)
- {
- rhs.m_data = nullptr;
- }
-
- StringPrinterBufferPointer(const StringPrinterBufferPointer& rhs) :
- m_data(rhs.m_data),
- m_size(rhs.m_size),
- m_deleter(rhs.m_deleter)
- {
- rhs.m_data = nullptr; // this is why m_data has to be mutable
- }
-
- const T*
- GetBytes () const
- {
- return m_data;
- }
-
- const S
- GetSize () const
- {
- return m_size;
- }
-
- ~StringPrinterBufferPointer ()
- {
- if (m_data && m_deleter)
- m_deleter(m_data);
- m_data = nullptr;
- }
-
- StringPrinterBufferPointer&
- operator = (const StringPrinterBufferPointer& rhs)
- {
- if (m_data && m_deleter)
- m_deleter(m_data);
- m_data = rhs.m_data;
- m_size = rhs.m_size;
- m_deleter = rhs.m_deleter;
- rhs.m_data = nullptr;
- return *this;
- }
-
-private:
- mutable const T* m_data;
- size_t m_size;
- Deleter m_deleter;
-};
-
// we define this for all values of type but only implement it for those we care about
// that's good because we get linker errors for any unsupported type
-template <StringElementType type>
-static StringPrinterBufferPointer<>
+template <lldb_private::formatters::StringPrinter::StringElementType type>
+static StringPrinter::StringPrinterBufferPointer<>
GetPrintableImpl(uint8_t* buffer, uint8_t* buffer_end, uint8_t*& next);
// mimic isprint() for Unicode codepoints
@@ -142,10 +59,10 @@ isprint(char32_t codepoint)
}
template <>
-StringPrinterBufferPointer<>
-GetPrintableImpl<StringElementType::ASCII> (uint8_t* buffer, uint8_t* buffer_end, uint8_t*& next)
+StringPrinter::StringPrinterBufferPointer<>
+GetPrintableImpl<StringPrinter::StringElementType::ASCII> (uint8_t* buffer, uint8_t* buffer_end, uint8_t*& next)
{
- StringPrinterBufferPointer<> retval = {nullptr};
+ StringPrinter::StringPrinterBufferPointer<> retval = {nullptr};
switch (*buffer)
{
@@ -212,10 +129,10 @@ ConvertUTF8ToCodePoint (unsigned char c0, unsigned char c1, unsigned char c2, un
}
template <>
-StringPrinterBufferPointer<>
-GetPrintableImpl<StringElementType::UTF8> (uint8_t* buffer, uint8_t* buffer_end, uint8_t*& next)
+StringPrinter::StringPrinterBufferPointer<>
+GetPrintableImpl<StringPrinter::StringElementType::UTF8> (uint8_t* buffer, uint8_t* buffer_end, uint8_t*& next)
{
- StringPrinterBufferPointer<> retval {nullptr};
+ StringPrinter::StringPrinterBufferPointer<> retval {nullptr};
unsigned utf8_encoded_len = getNumBytesForUTF8(*buffer);
@@ -232,7 +149,7 @@ GetPrintableImpl<StringElementType::UTF8> (uint8_t* buffer, uint8_t* buffer_end,
{
case 1:
// this is just an ASCII byte - ask ASCII
- return GetPrintableImpl<StringElementType::ASCII>(buffer, buffer_end, next);
+ return GetPrintableImpl<StringPrinter::StringElementType::ASCII>(buffer, buffer_end, next);
case 2:
codepoint = ConvertUTF8ToCodePoint((unsigned char)*buffer, (unsigned char)*(buffer+1));
break;
@@ -309,23 +226,40 @@ GetPrintableImpl<StringElementType::UTF8> (uint8_t* buffer, uint8_t* buffer_end,
// Given a sequence of bytes, this function returns:
// a sequence of bytes to actually print out + a length
// the following unscanned position of the buffer is in next
-static StringPrinterBufferPointer<>
-GetPrintable(StringElementType type, uint8_t* buffer, uint8_t* buffer_end, uint8_t*& next)
+static StringPrinter::StringPrinterBufferPointer<>
+GetPrintable(StringPrinter::StringElementType type, uint8_t* buffer, uint8_t* buffer_end, uint8_t*& next)
{
if (!buffer)
return {nullptr};
switch (type)
{
- case StringElementType::ASCII:
- return GetPrintableImpl<StringElementType::ASCII>(buffer, buffer_end, next);
- case StringElementType::UTF8:
- return GetPrintableImpl<StringElementType::UTF8>(buffer, buffer_end, next);
+ case StringPrinter::StringElementType::ASCII:
+ return GetPrintableImpl<StringPrinter::StringElementType::ASCII>(buffer, buffer_end, next);
+ case StringPrinter::StringElementType::UTF8:
+ return GetPrintableImpl<StringPrinter::StringElementType::UTF8>(buffer, buffer_end, next);
default:
return {nullptr};
}
}
+StringPrinter::EscapingHelper
+StringPrinter::GetDefaultEscapingHelper (GetPrintableElementType elem_type)
+{
+ switch (elem_type)
+ {
+ case GetPrintableElementType::UTF8:
+ return [] (uint8_t* buffer, uint8_t* buffer_end, uint8_t*& next) -> StringPrinter::StringPrinterBufferPointer<> {
+ return GetPrintable(StringPrinter::StringElementType::UTF8, buffer, buffer_end, next);
+ };
+ case GetPrintableElementType::ASCII:
+ return [] (uint8_t* buffer, uint8_t* buffer_end, uint8_t*& next) -> StringPrinter::StringPrinterBufferPointer<> {
+ return GetPrintable(StringPrinter::StringElementType::ASCII, buffer, buffer_end, next);
+ };
+ }
+ llvm_unreachable("bad element type");
+}
+
// use this call if you already have an LLDB-side buffer for the data
template<typename SourceDataType>
static bool
@@ -334,41 +268,44 @@ DumpUTFBufferToStream (ConversionResult (*ConvertFunction) (const SourceDataType
UTF8**,
UTF8*,
ConversionFlags),
- const DataExtractor& data,
- Stream& stream,
- char prefix_token,
- char quote,
- uint32_t sourceSize,
- bool escapeNonPrintables)
+ const StringPrinter::ReadBufferAndDumpToStreamOptions& dump_options)
{
- if (prefix_token != 0)
- stream.Printf("%c",prefix_token);
- if (quote != 0)
- stream.Printf("%c",quote);
+ Stream &stream(*dump_options.GetStream());
+ if (dump_options.GetPrefixToken() != 0)
+ stream.Printf("%s",dump_options.GetPrefixToken());
+ if (dump_options.GetQuote() != 0)
+ stream.Printf("%c",dump_options.GetQuote());
+ auto data(dump_options.GetData());
+ auto source_size(dump_options.GetSourceSize());
if (data.GetByteSize() && data.GetDataStart() && data.GetDataEnd())
{
const int bufferSPSize = data.GetByteSize();
- if (sourceSize == 0)
+ if (dump_options.GetSourceSize() == 0)
{
const int origin_encoding = 8*sizeof(SourceDataType);
- sourceSize = bufferSPSize/(origin_encoding / 4);
+ source_size = bufferSPSize/(origin_encoding / 4);
}
const SourceDataType *data_ptr = (const SourceDataType*)data.GetDataStart();
- const SourceDataType *data_end_ptr = data_ptr + sourceSize;
+ const SourceDataType *data_end_ptr = data_ptr + source_size;
- while (data_ptr < data_end_ptr)
+ const bool zero_is_terminator = dump_options.GetBinaryZeroIsTerminator();
+
+ if (zero_is_terminator)
{
- if (!*data_ptr)
+ while (data_ptr < data_end_ptr)
{
- data_end_ptr = data_ptr;
- break;
+ if (!*data_ptr)
+ {
+ data_end_ptr = data_ptr;
+ break;
+ }
+ data_ptr++;
}
- data_ptr++;
+
+ data_ptr = (const SourceDataType*)data.GetDataStart();
}
- data_ptr = (const SourceDataType*)data.GetDataStart();
-
lldb::DataBufferSP utf8_data_buffer_sp;
UTF8* utf8_data_ptr = nullptr;
UTF8* utf8_data_end_ptr = nullptr;
@@ -379,14 +316,26 @@ DumpUTFBufferToStream (ConversionResult (*ConvertFunction) (const SourceDataType
utf8_data_ptr = (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, utf8_data_end_ptr, lenientConversion );
+ if (false == zero_is_terminator)
+ utf8_data_end_ptr = utf8_data_ptr;
utf8_data_ptr = (UTF8*)utf8_data_buffer_sp->GetBytes(); // needed because the ConvertFunction will change the value of the data_ptr
}
else
{
// just copy the pointers - the cast is necessary to make the compiler happy
// but this should only happen if we are reading UTF8 data
- utf8_data_ptr = (UTF8*)data_ptr;
- utf8_data_end_ptr = (UTF8*)data_end_ptr;
+ utf8_data_ptr = const_cast<UTF8 *>(reinterpret_cast<const UTF8*>(data_ptr));
+ utf8_data_end_ptr = const_cast<UTF8 *>(reinterpret_cast<const UTF8*>(data_end_ptr));
+ }
+
+ const bool escape_non_printables = dump_options.GetEscapeNonPrintables();
+ lldb_private::formatters::StringPrinter::EscapingHelper escaping_callback;
+ if (escape_non_printables)
+ {
+ if (Language *language = Language::FindPlugin(dump_options.GetLanguage()))
+ escaping_callback = language->GetStringPrinterEscapingHelper(lldb_private::formatters::StringPrinter::GetPrintableElementType::UTF8);
+ else
+ escaping_callback = lldb_private::formatters::StringPrinter::GetDefaultEscapingHelper(lldb_private::formatters::StringPrinter::GetPrintableElementType::UTF8);
}
// since we tend to accept partial data (and even partially malformed data)
@@ -394,13 +343,13 @@ DumpUTFBufferToStream (ConversionResult (*ConvertFunction) (const SourceDataType
// hence we need to take a slower route and ensure we stay within boundaries
for (;utf8_data_ptr < utf8_data_end_ptr;)
{
- if (!*utf8_data_ptr)
+ if (zero_is_terminator && !*utf8_data_ptr)
break;
- if (escapeNonPrintables)
+ if (escape_non_printables)
{
uint8_t* next_data = nullptr;
- auto printable = GetPrintable(StringElementType::UTF8, utf8_data_ptr, utf8_data_end_ptr, next_data);
+ auto printable = escaping_callback(utf8_data_ptr, utf8_data_end_ptr, next_data);
auto printable_bytes = printable.GetBytes();
auto printable_size = printable.GetSize();
if (!printable_bytes || !next_data)
@@ -421,23 +370,39 @@ DumpUTFBufferToStream (ConversionResult (*ConvertFunction) (const SourceDataType
}
}
}
- if (quote != 0)
- stream.Printf("%c",quote);
+ if (dump_options.GetQuote() != 0)
+ stream.Printf("%c",dump_options.GetQuote());
+ if (dump_options.GetSuffixToken() != 0)
+ stream.Printf("%s",dump_options.GetSuffixToken());
+ if (dump_options.GetIsTruncated())
+ stream.Printf("...");
return true;
}
-lldb_private::formatters::ReadStringAndDumpToStreamOptions::ReadStringAndDumpToStreamOptions (ValueObject& valobj) :
+lldb_private::formatters::StringPrinter::ReadStringAndDumpToStreamOptions::ReadStringAndDumpToStreamOptions (ValueObject& valobj) :
ReadStringAndDumpToStreamOptions()
{
SetEscapeNonPrintables(valobj.GetTargetSP()->GetDebugger().GetEscapeNonPrintables());
}
-lldb_private::formatters::ReadBufferAndDumpToStreamOptions::ReadBufferAndDumpToStreamOptions (ValueObject& valobj) :
+lldb_private::formatters::StringPrinter::ReadBufferAndDumpToStreamOptions::ReadBufferAndDumpToStreamOptions (ValueObject& valobj) :
ReadBufferAndDumpToStreamOptions()
{
SetEscapeNonPrintables(valobj.GetTargetSP()->GetDebugger().GetEscapeNonPrintables());
}
+lldb_private::formatters::StringPrinter::ReadBufferAndDumpToStreamOptions::ReadBufferAndDumpToStreamOptions (const ReadStringAndDumpToStreamOptions& options) :
+ ReadBufferAndDumpToStreamOptions()
+{
+ SetStream(options.GetStream());
+ SetPrefixToken(options.GetPrefixToken());
+ SetSuffixToken(options.GetSuffixToken());
+ SetQuote(options.GetQuote());
+ SetEscapeNonPrintables(options.GetEscapeNonPrintables());
+ SetBinaryZeroIsTerminator(options.GetBinaryZeroIsTerminator());
+ SetLanguage(options.GetLanguage());
+}
+
namespace lldb_private
{
@@ -447,7 +412,7 @@ namespace formatters
template <>
bool
-ReadStringAndDumpToStream<StringElementType::ASCII> (ReadStringAndDumpToStreamOptions options)
+StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::ASCII> (const ReadStringAndDumpToStreamOptions& options)
{
assert(options.GetStream() && "need a Stream to print the string to");
Error my_error;
@@ -458,11 +423,20 @@ ReadStringAndDumpToStream<StringElementType::ASCII> (ReadStringAndDumpToStreamOp
return false;
size_t size;
+ const auto max_size = process_sp->GetTarget().GetMaximumSizeOfStringSummary();
+ bool is_truncated = false;
if (options.GetSourceSize() == 0)
- size = process_sp->GetTarget().GetMaximumSizeOfStringSummary();
+ size = max_size;
else if (!options.GetIgnoreMaxLength())
- size = std::min(options.GetSourceSize(),process_sp->GetTarget().GetMaximumSizeOfStringSummary());
+ {
+ size = options.GetSourceSize();
+ if (size > max_size)
+ {
+ size = max_size;
+ is_truncated = true;
+ }
+ }
else
size = options.GetSourceSize();
@@ -473,25 +447,35 @@ ReadStringAndDumpToStream<StringElementType::ASCII> (ReadStringAndDumpToStreamOp
if (my_error.Fail())
return false;
- char prefix_token = options.GetPrefixToken();
+ const char* prefix_token = options.GetPrefixToken();
char quote = options.GetQuote();
if (prefix_token != 0)
- options.GetStream()->Printf("%c%c",prefix_token,quote);
+ options.GetStream()->Printf("%s%c",prefix_token,quote);
else if (quote != 0)
options.GetStream()->Printf("%c",quote);
uint8_t* data_end = buffer_sp->GetBytes()+buffer_sp->GetByteSize();
+ const bool escape_non_printables = options.GetEscapeNonPrintables();
+ lldb_private::formatters::StringPrinter::EscapingHelper escaping_callback;
+ if (escape_non_printables)
+ {
+ if (Language *language = Language::FindPlugin(options.GetLanguage()))
+ escaping_callback = language->GetStringPrinterEscapingHelper(lldb_private::formatters::StringPrinter::GetPrintableElementType::ASCII);
+ else
+ escaping_callback = lldb_private::formatters::StringPrinter::GetDefaultEscapingHelper(lldb_private::formatters::StringPrinter::GetPrintableElementType::ASCII);
+ }
+
// since we tend to accept partial data (and even partially malformed data)
// we might end up with no NULL terminator before the end_ptr
// hence we need to take a slower route and ensure we stay within boundaries
for (uint8_t* data = buffer_sp->GetBytes(); *data && (data < data_end);)
{
- if (options.GetEscapeNonPrintables())
+ if (escape_non_printables)
{
uint8_t* next_data = nullptr;
- auto printable = GetPrintable(StringElementType::ASCII, data, data_end, next_data);
+ auto printable = escaping_callback(data, data_end, next_data);
auto printable_bytes = printable.GetBytes();
auto printable_size = printable.GetSize();
if (!printable_bytes || !next_data)
@@ -511,16 +495,23 @@ ReadStringAndDumpToStream<StringElementType::ASCII> (ReadStringAndDumpToStreamOp
data++;
}
}
-
- if (quote != 0)
+
+ const char* suffix_token = options.GetSuffixToken();
+
+ if (suffix_token != 0)
+ options.GetStream()->Printf("%c%s",quote, suffix_token);
+ else if (quote != 0)
options.GetStream()->Printf("%c",quote);
+ if (is_truncated)
+ options.GetStream()->Printf("...");
+
return true;
}
template<typename SourceDataType>
static bool
-ReadUTFBufferAndDumpToStream (const ReadStringAndDumpToStreamOptions& options,
+ReadUTFBufferAndDumpToStream (const StringPrinter::ReadStringAndDumpToStreamOptions& options,
ConversionResult (*ConvertFunction) (const SourceDataType**,
const SourceDataType*,
UTF8**,
@@ -550,14 +541,23 @@ ReadUTFBufferAndDumpToStream (const ReadStringAndDumpToStreamOptions& options,
uint32_t sourceSize = options.GetSourceSize();
bool needs_zero_terminator = options.GetNeedsZeroTermination();
+
+ bool is_truncated = false;
+ const auto max_size = process_sp->GetTarget().GetMaximumSizeOfStringSummary();
if (!sourceSize)
{
- sourceSize = process_sp->GetTarget().GetMaximumSizeOfStringSummary();
+ sourceSize = max_size;
needs_zero_terminator = true;
}
else if (!options.GetIgnoreMaxLength())
- sourceSize = std::min(sourceSize,process_sp->GetTarget().GetMaximumSizeOfStringSummary());
+ {
+ if (sourceSize > max_size)
+ {
+ sourceSize = max_size;
+ is_truncated = true;
+ }
+ }
const int bufferSPSize = sourceSize * type_width;
@@ -581,13 +581,18 @@ ReadUTFBufferAndDumpToStream (const ReadStringAndDumpToStreamOptions& options,
}
DataExtractor data(buffer_sp, process_sp->GetByteOrder(), process_sp->GetAddressByteSize());
+
+ StringPrinter::ReadBufferAndDumpToStreamOptions dump_options(options);
+ dump_options.SetData(data);
+ dump_options.SetSourceSize(sourceSize);
+ dump_options.SetIsTruncated(is_truncated);
- return DumpUTFBufferToStream(ConvertFunction, data, *options.GetStream(), options.GetPrefixToken(), options.GetQuote(), sourceSize, options.GetEscapeNonPrintables());
+ return DumpUTFBufferToStream(ConvertFunction, dump_options);
}
template <>
bool
-ReadStringAndDumpToStream<StringElementType::UTF8> (ReadStringAndDumpToStreamOptions options)
+StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF8> (const ReadStringAndDumpToStreamOptions& options)
{
return ReadUTFBufferAndDumpToStream<UTF8>(options,
nullptr);
@@ -595,7 +600,7 @@ ReadStringAndDumpToStream<StringElementType::UTF8> (ReadStringAndDumpToStreamOpt
template <>
bool
-ReadStringAndDumpToStream<StringElementType::UTF16> (ReadStringAndDumpToStreamOptions options)
+StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF16> (const ReadStringAndDumpToStreamOptions& options)
{
return ReadUTFBufferAndDumpToStream<UTF16>(options,
ConvertUTF16toUTF8);
@@ -603,7 +608,7 @@ ReadStringAndDumpToStream<StringElementType::UTF16> (ReadStringAndDumpToStreamOp
template <>
bool
-ReadStringAndDumpToStream<StringElementType::UTF32> (ReadStringAndDumpToStreamOptions options)
+StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF32> (const ReadStringAndDumpToStreamOptions& options)
{
return ReadUTFBufferAndDumpToStream<UTF32>(options,
ConvertUTF32toUTF8);
@@ -611,16 +616,16 @@ ReadStringAndDumpToStream<StringElementType::UTF32> (ReadStringAndDumpToStreamOp
template <>
bool
-ReadBufferAndDumpToStream<StringElementType::UTF8> (ReadBufferAndDumpToStreamOptions options)
+StringPrinter::ReadBufferAndDumpToStream<StringPrinter::StringElementType::UTF8> (const ReadBufferAndDumpToStreamOptions& options)
{
assert(options.GetStream() && "need a Stream to print the string to");
- return DumpUTFBufferToStream<UTF8>(nullptr, options.GetData(), *options.GetStream(), options.GetPrefixToken(), options.GetQuote(), options.GetSourceSize(), options.GetEscapeNonPrintables());
+ return DumpUTFBufferToStream<UTF8>(nullptr, options);
}
template <>
bool
-ReadBufferAndDumpToStream<StringElementType::ASCII> (ReadBufferAndDumpToStreamOptions options)
+StringPrinter::ReadBufferAndDumpToStream<StringPrinter::StringElementType::ASCII> (const ReadBufferAndDumpToStreamOptions& options)
{
// treat ASCII the same as UTF8
// FIXME: can we optimize ASCII some more?
@@ -629,20 +634,20 @@ ReadBufferAndDumpToStream<StringElementType::ASCII> (ReadBufferAndDumpToStreamOp
template <>
bool
-ReadBufferAndDumpToStream<StringElementType::UTF16> (ReadBufferAndDumpToStreamOptions options)
+StringPrinter::ReadBufferAndDumpToStream<StringPrinter::StringElementType::UTF16> (const ReadBufferAndDumpToStreamOptions& options)
{
assert(options.GetStream() && "need a Stream to print the string to");
- return DumpUTFBufferToStream(ConvertUTF16toUTF8, options.GetData(), *options.GetStream(), options.GetPrefixToken(), options.GetQuote(), options.GetSourceSize(), options.GetEscapeNonPrintables());
+ return DumpUTFBufferToStream(ConvertUTF16toUTF8, options);
}
template <>
bool
-ReadBufferAndDumpToStream<StringElementType::UTF32> (ReadBufferAndDumpToStreamOptions options)
+StringPrinter::ReadBufferAndDumpToStream<StringPrinter::StringElementType::UTF32> (const ReadBufferAndDumpToStreamOptions& options)
{
assert(options.GetStream() && "need a Stream to print the string to");
- return DumpUTFBufferToStream(ConvertUTF32toUTF8, options.GetData(), *options.GetStream(), options.GetPrefixToken(), options.GetQuote(), options.GetSourceSize(), options.GetEscapeNonPrintables());
+ return DumpUTFBufferToStream(ConvertUTF32toUTF8, options);
}
} // namespace formatters
diff --git a/source/DataFormatters/TypeCategory.cpp b/source/DataFormatters/TypeCategory.cpp
index b05cea55ff51..636d935b7625 100644
--- a/source/DataFormatters/TypeCategory.cpp
+++ b/source/DataFormatters/TypeCategory.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/DataFormatters/TypeCategory.h"
+#include "lldb/Target/Language.h"
// C Includes
// C++ Includes
@@ -18,7 +19,8 @@ using namespace lldb;
using namespace lldb_private;
TypeCategoryImpl::TypeCategoryImpl(IFormatChangeListener* clist,
- ConstString name) :
+ ConstString name,
+ std::initializer_list<lldb::LanguageType> langs) :
m_format_cont("format","regex-format",clist),
m_summary_cont("summary","regex-summary",clist),
m_filter_cont("filter","regex-filter",clist),
@@ -29,8 +31,118 @@ m_validator_cont("validator","regex-validator",clist),
m_enabled(false),
m_change_listener(clist),
m_mutex(Mutex::eMutexTypeRecursive),
-m_name(name)
-{}
+m_name(name),
+m_languages()
+{
+ for (const lldb::LanguageType lang : langs)
+ AddLanguage(lang);
+}
+
+static bool
+IsApplicable(lldb::LanguageType category_lang,
+ lldb::LanguageType valobj_lang)
+{
+ switch (category_lang)
+ {
+ // these are not languages that LLDB would ordinarily deal with
+ // only allow an exact equality here, since we really don't know
+ // any better
+ case eLanguageTypeAda83:
+ case eLanguageTypeCobol74:
+ case eLanguageTypeCobol85:
+ case eLanguageTypeFortran77:
+ case eLanguageTypeFortran90:
+ case eLanguageTypePascal83:
+ case eLanguageTypeModula2:
+ case eLanguageTypeJava:
+ case eLanguageTypeAda95:
+ case eLanguageTypeFortran95:
+ case eLanguageTypePLI:
+ case eLanguageTypeUPC:
+ case eLanguageTypeD:
+ case eLanguageTypePython:
+ return category_lang == valobj_lang;
+
+ // the C family, we consider it as one
+ case eLanguageTypeC89:
+ case eLanguageTypeC:
+ case eLanguageTypeC99:
+ return valobj_lang == eLanguageTypeC89 ||
+ valobj_lang == eLanguageTypeC ||
+ valobj_lang == eLanguageTypeC99;
+
+ // ObjC knows about C and itself
+ case eLanguageTypeObjC:
+ return valobj_lang == eLanguageTypeC89 ||
+ valobj_lang == eLanguageTypeC ||
+ valobj_lang == eLanguageTypeC99 ||
+ valobj_lang == eLanguageTypeObjC;
+
+ // C++ knows about C and C++
+ case eLanguageTypeC_plus_plus:
+ return valobj_lang == eLanguageTypeC89 ||
+ valobj_lang == eLanguageTypeC ||
+ valobj_lang == eLanguageTypeC99 ||
+ valobj_lang == eLanguageTypeC_plus_plus;
+
+ // ObjC++ knows about C,C++,ObjC and ObjC++
+ case eLanguageTypeObjC_plus_plus:
+ return valobj_lang == eLanguageTypeC89 ||
+ valobj_lang == eLanguageTypeC ||
+ valobj_lang == eLanguageTypeC99 ||
+ valobj_lang == eLanguageTypeC_plus_plus ||
+ valobj_lang == eLanguageTypeObjC;
+
+ default:
+ case eLanguageTypeUnknown:
+ return true;
+ }
+}
+
+bool
+TypeCategoryImpl::IsApplicable (ValueObject& valobj)
+{
+ lldb::LanguageType valobj_lang = valobj.GetObjectRuntimeLanguage();
+ for (size_t idx = 0;
+ idx < GetNumLanguages();
+ idx++)
+ {
+ const lldb::LanguageType category_lang = GetLanguageAtIndex(idx);
+ if (::IsApplicable(category_lang,valobj_lang))
+ return true;
+ }
+ return false;
+}
+
+size_t
+TypeCategoryImpl::GetNumLanguages ()
+{
+ if (m_languages.empty())
+ return 1;
+ return m_languages.size();
+}
+
+lldb::LanguageType
+TypeCategoryImpl::GetLanguageAtIndex (size_t idx)
+{
+ if (m_languages.empty())
+ return lldb::eLanguageTypeUnknown;
+ return m_languages[idx];
+}
+
+void
+TypeCategoryImpl::AddLanguage (lldb::LanguageType lang)
+{
+ m_languages.push_back(lang);
+}
+
+bool
+TypeCategoryImpl::HasLanguage (lldb::LanguageType lang)
+{
+ const auto iter = std::find(m_languages.begin(), m_languages.end(), lang),
+ end = m_languages.end();
+ return (iter != end);
+}
bool
TypeCategoryImpl::Get (ValueObject& valobj,
@@ -38,7 +150,7 @@ TypeCategoryImpl::Get (ValueObject& valobj,
lldb::TypeFormatImplSP& entry,
uint32_t* reason)
{
- if (!IsEnabled())
+ if (!IsEnabled() || !IsApplicable(valobj))
return false;
if (GetTypeFormatsContainer()->Get(candidates, entry, reason))
return true;
@@ -54,7 +166,7 @@ TypeCategoryImpl::Get (ValueObject& valobj,
lldb::TypeSummaryImplSP& entry,
uint32_t* reason)
{
- if (!IsEnabled())
+ if (!IsEnabled() || !IsApplicable(valobj))
return false;
if (GetTypeSummariesContainer()->Get(candidates, entry, reason))
return true;
@@ -70,7 +182,7 @@ TypeCategoryImpl::Get (ValueObject& valobj,
lldb::SyntheticChildrenSP& entry,
uint32_t* reason)
{
- if (!IsEnabled())
+ if (!IsEnabled() || !IsApplicable(valobj))
return false;
TypeFilterImpl::SharedPointer filter_sp;
uint32_t reason_filter = 0;
@@ -567,3 +679,30 @@ TypeCategoryImpl::Enable (bool value, uint32_t position)
if (m_change_listener)
m_change_listener->Changed();
}
+
+std::string
+TypeCategoryImpl::GetDescription ()
+{
+ StreamString stream;
+ stream.Printf("%s (%s",
+ GetName(),
+ (IsEnabled() ? "enabled" : "disabled"));
+ StreamString lang_stream;
+ lang_stream.Printf(", applicable for language(s): ");
+ bool print_lang = false;
+ for (size_t idx = 0;
+ idx < GetNumLanguages();
+ idx++)
+ {
+ const lldb::LanguageType lang = GetLanguageAtIndex(idx);
+ if (lang != lldb::eLanguageTypeUnknown)
+ print_lang = true;
+ lang_stream.Printf("%s%s",
+ Language::GetNameForLanguageType(lang),
+ idx+1<GetNumLanguages() ? ", " : "");
+ }
+ if (print_lang)
+ stream.Printf("%s",lang_stream.GetData());
+ stream.PutChar(')');
+ return stream.GetData();
+}
diff --git a/source/DataFormatters/TypeCategoryMap.cpp b/source/DataFormatters/TypeCategoryMap.cpp
index 96b9e6df8a47..58e4e2117bb6 100644
--- a/source/DataFormatters/TypeCategoryMap.cpp
+++ b/source/DataFormatters/TypeCategoryMap.cpp
@@ -9,8 +9,8 @@
#include "lldb/DataFormatters/TypeCategoryMap.h"
+#include "lldb/Core/Log.h"
#include "lldb/DataFormatters/FormatClasses.h"
-#include "lldb/DataFormatters/FormatManager.h"
// C Includes
// C++ Includes
@@ -218,25 +218,35 @@ TypeCategoryMap::AnyMatches (ConstString type_name,
}
lldb::TypeFormatImplSP
-TypeCategoryMap::GetFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
+TypeCategoryMap::GetFormat (FormattersMatchData& match_data)
{
Mutex::Locker locker(m_map_mutex);
uint32_t reason_why;
ActiveCategoriesIterator begin, end = m_active_categories.end();
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
-
- FormattersMatchVector matches = FormatManager::GetPossibleMatches(valobj, use_dynamic);
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_DATAFORMATTERS));
+ if (log)
+ {
+ for (auto match : match_data.GetMatchesVector())
+ {
+ log->Printf("[CategoryMap::GetSummaryFormat] candidate match = %s %s %s %s reason = %" PRIu32,
+ match.GetTypeName().GetCString(),
+ match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers",
+ match.DidStripReference() ? "strip-reference" : "no-strip-reference",
+ match.DidStripTypedef() ? "strip-typedef" : "no-strip-typedef",
+ match.GetReason());
+ }
+ }
+
for (begin = m_active_categories.begin(); begin != end; begin++)
{
lldb::TypeCategoryImplSP category_sp = *begin;
lldb::TypeFormatImplSP current_format;
if (log)
- log->Printf("\n[TypeCategoryMap::GetFormat] Trying to use category %s", category_sp->GetName());
- if (!category_sp->Get(valobj, matches, current_format, &reason_why))
+ log->Printf("[TypeCategoryMap::GetFormat] Trying to use category %s", category_sp->GetName());
+ if (!category_sp->Get(match_data.GetValueObject(), match_data.GetMatchesVector(), current_format, &reason_why))
continue;
return current_format;
}
@@ -246,25 +256,35 @@ TypeCategoryMap::GetFormat (ValueObject& valobj,
}
lldb::TypeSummaryImplSP
-TypeCategoryMap::GetSummaryFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
+TypeCategoryMap::GetSummaryFormat (FormattersMatchData& match_data)
{
Mutex::Locker locker(m_map_mutex);
uint32_t reason_why;
ActiveCategoriesIterator begin, end = m_active_categories.end();
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
-
- FormattersMatchVector matches = FormatManager::GetPossibleMatches(valobj, use_dynamic);
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_DATAFORMATTERS));
+ if (log)
+ {
+ for (auto match : match_data.GetMatchesVector())
+ {
+ log->Printf("[CategoryMap::GetSummaryFormat] candidate match = %s %s %s %s reason = %" PRIu32,
+ match.GetTypeName().GetCString(),
+ match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers",
+ match.DidStripReference() ? "strip-reference" : "no-strip-reference",
+ match.DidStripTypedef() ? "strip-typedef" : "no-strip-typedef",
+ match.GetReason());
+ }
+ }
+
for (begin = m_active_categories.begin(); begin != end; begin++)
{
lldb::TypeCategoryImplSP category_sp = *begin;
lldb::TypeSummaryImplSP current_format;
if (log)
- log->Printf("\n[CategoryMap::GetSummaryFormat] Trying to use category %s", category_sp->GetName());
- if (!category_sp->Get(valobj, matches, current_format, &reason_why))
+ log->Printf("[CategoryMap::GetSummaryFormat] Trying to use category %s", category_sp->GetName());
+ if (!category_sp->Get(match_data.GetValueObject(), match_data.GetMatchesVector(), current_format, &reason_why))
continue;
return current_format;
}
@@ -275,8 +295,7 @@ TypeCategoryMap::GetSummaryFormat (ValueObject& valobj,
#ifndef LLDB_DISABLE_PYTHON
lldb::SyntheticChildrenSP
-TypeCategoryMap::GetSyntheticChildren (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
+TypeCategoryMap::GetSyntheticChildren (FormattersMatchData& match_data)
{
Mutex::Locker locker(m_map_mutex);
@@ -284,17 +303,28 @@ TypeCategoryMap::GetSyntheticChildren (ValueObject& valobj,
ActiveCategoriesIterator begin, end = m_active_categories.end();
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
-
- FormattersMatchVector matches = FormatManager::GetPossibleMatches(valobj, use_dynamic);
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_DATAFORMATTERS));
+ if (log)
+ {
+ for (auto match : match_data.GetMatchesVector())
+ {
+ log->Printf("[CategoryMap::GetSummaryFormat] candidate match = %s %s %s %s reason = %" PRIu32,
+ match.GetTypeName().GetCString(),
+ match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers",
+ match.DidStripReference() ? "strip-reference" : "no-strip-reference",
+ match.DidStripTypedef() ? "strip-typedef" : "no-strip-typedef",
+ match.GetReason());
+ }
+ }
+
for (begin = m_active_categories.begin(); begin != end; begin++)
{
lldb::TypeCategoryImplSP category_sp = *begin;
lldb::SyntheticChildrenSP current_format;
if (log)
- log->Printf("\n[CategoryMap::GetSyntheticChildren] Trying to use category %s", category_sp->GetName());
- if (!category_sp->Get(valobj, matches, current_format, &reason_why))
+ log->Printf("[CategoryMap::GetSyntheticChildren] Trying to use category %s", category_sp->GetName());
+ if (!category_sp->Get(match_data.GetValueObject(), match_data.GetMatchesVector(), current_format, &reason_why))
continue;
return current_format;
}
@@ -305,25 +335,35 @@ TypeCategoryMap::GetSyntheticChildren (ValueObject& valobj,
#endif
lldb::TypeValidatorImplSP
-TypeCategoryMap::GetValidator (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
+TypeCategoryMap::GetValidator (FormattersMatchData& match_data)
{
Mutex::Locker locker(m_map_mutex);
uint32_t reason_why;
ActiveCategoriesIterator begin, end = m_active_categories.end();
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
-
- FormattersMatchVector matches = FormatManager::GetPossibleMatches(valobj, use_dynamic);
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_DATAFORMATTERS));
+ if (log)
+ {
+ for (auto match : match_data.GetMatchesVector())
+ {
+ log->Printf("[CategoryMap::GetValidator] candidate match = %s %s %s %s reason = %" PRIu32,
+ match.GetTypeName().GetCString(),
+ match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers",
+ match.DidStripReference() ? "strip-reference" : "no-strip-reference",
+ match.DidStripTypedef() ? "strip-typedef" : "no-strip-typedef",
+ match.GetReason());
+ }
+ }
+
for (begin = m_active_categories.begin(); begin != end; begin++)
{
lldb::TypeCategoryImplSP category_sp = *begin;
lldb::TypeValidatorImplSP current_format;
if (log)
- log->Printf("\n[CategoryMap::GetValidator] Trying to use category %s", category_sp->GetName());
- if (!category_sp->Get(valobj, matches, current_format, &reason_why))
+ log->Printf("[CategoryMap::GetValidator] Trying to use category %s", category_sp->GetName());
+ if (!category_sp->Get(match_data.GetValueObject(), match_data.GetMatchesVector(), current_format, &reason_why))
continue;
return current_format;
}
@@ -333,7 +373,7 @@ TypeCategoryMap::GetValidator (ValueObject& valobj,
}
void
-TypeCategoryMap::LoopThrough(CallbackType callback, void* param)
+TypeCategoryMap::ForEach(ForEachCallback callback)
{
if (callback)
{
@@ -345,8 +385,7 @@ TypeCategoryMap::LoopThrough(CallbackType callback, void* param)
for (begin = m_active_categories.begin(); begin != end; begin++)
{
lldb::TypeCategoryImplSP category = *begin;
- ConstString type = ConstString(category->GetName());
- if (!callback(param, category))
+ if (!callback(category))
break;
}
}
@@ -359,7 +398,7 @@ TypeCategoryMap::LoopThrough(CallbackType callback, void* param)
if (pos->second->IsEnabled())
continue;
KeyType type = pos->first;
- if (!callback(param, pos->second))
+ if (!callback(pos->second))
break;
}
}
diff --git a/source/DataFormatters/TypeFormat.cpp b/source/DataFormatters/TypeFormat.cpp
index c4a65fea7da5..6ab8d298f94b 100644
--- a/source/DataFormatters/TypeFormat.cpp
+++ b/source/DataFormatters/TypeFormat.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+#include "lldb/DataFormatters/TypeFormat.h"
+
// C Includes
// C++ Includes
@@ -17,15 +19,11 @@
#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
-#include "lldb/Core/Debugger.h"
#include "lldb/Core/StreamString.h"
-#include "lldb/Core/Timer.h"
#include "lldb/DataFormatters/FormatManager.h"
-#include "lldb/DataFormatters/TypeFormat.h"
-#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/TypeList.h"
-#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
using namespace lldb;
@@ -91,13 +89,13 @@ TypeFormatImpl_Format::FormatObject (ValueObject *valobj,
}
else
{
- ClangASTType clang_type = value.GetClangType ();
- if (clang_type)
+ CompilerType compiler_type = value.GetCompilerType ();
+ if (compiler_type)
{
// put custom bytes to display in the DataExtractor to override the default value logic
if (GetFormat() == eFormatCString)
{
- lldb_private::Flags type_flags(clang_type.GetTypeInfo(NULL)); // disambiguate w.r.t. TypeFormatImpl::Flags
+ lldb_private::Flags type_flags(compiler_type.GetTypeInfo(NULL)); // 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 as a string
@@ -122,7 +120,7 @@ TypeFormatImpl_Format::FormatObject (ValueObject *valobj,
}
StreamString sstr;
- clang_type.DumpTypeValue (&sstr, // The stream to use for display
+ compiler_type.DumpTypeValue (&sstr, // The stream to use for display
GetFormat(), // Format to display this type with
data, // Data to extract from
0, // Byte offset into "m_data"
@@ -134,7 +132,7 @@ TypeFormatImpl_Format::FormatObject (ValueObject *valobj,
// for a formatting error (or else we wouldn't be able to reformat
// until a next update), an empty string is treated as a "false"
// return from here, but that's about as severe as we get
- // ClangASTType::DumpTypeValue() should always return
+ // CompilerType::DumpTypeValue() should always return
// something, even if that something is an error message
if (sstr.GetString().empty())
dest.clear();
@@ -192,7 +190,7 @@ TypeFormatImpl_EnumType::FormatObject (ValueObject *valobj,
return false;
auto iter = m_types.find(valobj_key),
end = m_types.end();
- ClangASTType valobj_enum_type;
+ CompilerType valobj_enum_type;
if (iter == end)
{
// probably a redundant check
@@ -208,9 +206,9 @@ TypeFormatImpl_EnumType::FormatObject (ValueObject *valobj,
{
if (!type_sp)
continue;
- if ( (type_sp->GetClangForwardType().GetTypeInfo() & eTypeIsEnumeration) == eTypeIsEnumeration)
+ if ( (type_sp->GetForwardCompilerType().GetTypeInfo() & eTypeIsEnumeration) == eTypeIsEnumeration)
{
- valobj_enum_type = type_sp->GetClangFullType();
+ valobj_enum_type = type_sp->GetFullCompilerType ();
m_types.emplace(valobj_key,valobj_enum_type);
break;
}
diff --git a/source/DataFormatters/TypeSummary.cpp b/source/DataFormatters/TypeSummary.cpp
index fa06f297f829..2806ba20c6a9 100644
--- a/source/DataFormatters/TypeSummary.cpp
+++ b/source/DataFormatters/TypeSummary.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+#include "lldb/DataFormatters/TypeSummary.h"
+
// C Includes
// C++ Includes
@@ -19,16 +21,13 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/StreamString.h"
-#include "lldb/Core/Timer.h"
-#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/ValueObjectPrinter.h"
#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
-#include "lldb/Host/Host.h"
-
using namespace lldb;
using namespace lldb_private;
@@ -76,15 +75,17 @@ TypeSummaryOptions::SetCapping (lldb::TypeSummaryCapping cap)
return *this;
}
-TypeSummaryImpl::TypeSummaryImpl (const TypeSummaryImpl::Flags& flags) :
-m_flags(flags)
+TypeSummaryImpl::TypeSummaryImpl (Kind kind,
+ const TypeSummaryImpl::Flags& flags) :
+ m_flags(flags),
+ m_kind(kind)
{
}
StringSummaryFormat::StringSummaryFormat (const TypeSummaryImpl::Flags& flags,
const char *format_cstr) :
- TypeSummaryImpl(flags),
+ TypeSummaryImpl(Kind::eSummaryString,flags),
m_format_str()
{
SetSummaryString (format_cstr);
@@ -170,7 +171,7 @@ StringSummaryFormat::GetDescription ()
CXXFunctionSummaryFormat::CXXFunctionSummaryFormat (const TypeSummaryImpl::Flags& flags,
Callback impl,
const char* description) :
-TypeSummaryImpl(flags),
+ TypeSummaryImpl(Kind::eCallback,flags),
m_impl(impl),
m_description(description ? description : "")
{
@@ -193,28 +194,25 @@ std::string
CXXFunctionSummaryFormat::GetDescription ()
{
StreamString sstr;
- sstr.Printf ("`%s (%p) `%s%s%s%s%s%s%s", m_description.c_str(),
- static_cast<void*>(&m_impl),
+ sstr.Printf ("%s%s%s%s%s%s%s %s",
Cascades() ? "" : " (not cascading)",
!DoesPrintChildren(nullptr) ? "" : " (show children)",
!DoesPrintValue(nullptr) ? " (hide value)" : "",
IsOneLiner() ? " (one-line printout)" : "",
SkipsPointers() ? " (skip pointers)" : "",
SkipsReferences() ? " (skip references)" : "",
- HideNames(nullptr) ? " (hide member names)" : "");
+ HideNames(nullptr) ? " (hide member names)" : "",
+ m_description.c_str());
return sstr.GetString();
}
-#ifndef LLDB_DISABLE_PYTHON
-
-
ScriptSummaryFormat::ScriptSummaryFormat (const TypeSummaryImpl::Flags& flags,
const char * function_name,
const char * python_script) :
-TypeSummaryImpl(flags),
-m_function_name(),
-m_python_script(),
-m_script_function_sp()
+ TypeSummaryImpl(Kind::eScript,flags),
+ m_function_name(),
+ m_python_script(),
+ m_script_function_sp()
{
if (function_name)
m_function_name.assign(function_name);
@@ -227,15 +225,9 @@ ScriptSummaryFormat::FormatObject (ValueObject *valobj,
std::string& retval,
const TypeSummaryOptions& options)
{
- Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
-
if (!valobj)
return false;
- Host::SetCrashDescriptionWithFormat("[Python summary] Name: %s - Function: %s",
- valobj->GetName().AsCString("unknown"),
- m_function_name.c_str());
-
TargetSP target_sp(valobj->GetTargetSP());
if (!target_sp)
@@ -275,5 +267,3 @@ ScriptSummaryFormat::GetDescription ()
return sstr.GetString();
}
-
-#endif // #ifndef LLDB_DISABLE_PYTHON
diff --git a/source/DataFormatters/TypeSynthetic.cpp b/source/DataFormatters/TypeSynthetic.cpp
index 5bd8d30e4873..e49cd99b02ea 100644
--- a/source/DataFormatters/TypeSynthetic.cpp
+++ b/source/DataFormatters/TypeSynthetic.cpp
@@ -22,8 +22,7 @@
#include "lldb/DataFormatters/TypeSynthetic.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
-#include "lldb/Symbol/ClangASTType.h"
-#include "lldb/Target/StackFrame.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/Target.h"
using namespace lldb;
@@ -111,11 +110,10 @@ std::string
CXXSyntheticChildren::GetDescription()
{
StreamString sstr;
- sstr.Printf("%s%s%s Generator at %p - %s",
+ sstr.Printf("%s%s%s %s",
Cascades() ? "" : " (not cascading)",
SkipsPointers() ? " (skip pointers)" : "",
SkipsReferences() ? " (skip references)" : "",
- reinterpret_cast<void*>(reinterpret_cast<intptr_t>(m_create_callback)),
m_description.c_str());
return sstr.GetString();
@@ -136,7 +134,7 @@ lldb::ValueObjectSP
SyntheticChildrenFrontEnd::CreateValueObjectFromAddress (const char* name,
uint64_t address,
const ExecutionContext& exe_ctx,
- ClangASTType type)
+ CompilerType type)
{
ValueObjectSP valobj_sp(ValueObject::CreateValueObjectFromAddress(name, address, exe_ctx, type));
if (valobj_sp)
@@ -148,7 +146,7 @@ lldb::ValueObjectSP
SyntheticChildrenFrontEnd::CreateValueObjectFromData (const char* name,
const DataExtractor& data,
const ExecutionContext& exe_ctx,
- ClangASTType type)
+ CompilerType type)
{
ValueObjectSP valobj_sp(ValueObject::CreateValueObjectFromData(name, data, exe_ctx, type));
if (valobj_sp)
@@ -202,7 +200,15 @@ ScriptedSyntheticChildren::FrontEnd::CalculateNumChildren ()
{
if (!m_wrapper_sp || m_interpreter == NULL)
return 0;
- return m_interpreter->CalculateNumChildren(m_wrapper_sp);
+ return m_interpreter->CalculateNumChildren(m_wrapper_sp, UINT32_MAX);
+}
+
+size_t
+ScriptedSyntheticChildren::FrontEnd::CalculateNumChildren (uint32_t max)
+{
+ if (!m_wrapper_sp || m_interpreter == NULL)
+ return 0;
+ return m_interpreter->CalculateNumChildren(m_wrapper_sp, max);
}
bool
diff --git a/source/DataFormatters/ValueObjectPrinter.cpp b/source/DataFormatters/ValueObjectPrinter.cpp
index 7c794ee2ddac..04c291283546 100644
--- a/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/source/DataFormatters/ValueObjectPrinter.cpp
@@ -13,33 +13,28 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Target/Language.h"
#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
-DumpValueObjectOptions::DumpValueObjectOptions (ValueObject& valobj) :
-DumpValueObjectOptions()
-{
- m_use_dynamic = valobj.GetDynamicValueType();
- m_use_synthetic = valobj.IsSynthetic();
-}
-
ValueObjectPrinter::ValueObjectPrinter (ValueObject* valobj,
Stream* s)
{
if (valobj)
{
DumpValueObjectOptions options(*valobj);
- Init (valobj,s,options,options.m_max_ptr_depth,0);
+ Init (valobj,s,options,m_options.m_max_ptr_depth,0, nullptr);
}
else
{
DumpValueObjectOptions options;
- Init (valobj,s,options,options.m_max_ptr_depth,0);
+ Init (valobj,s,options,m_options.m_max_ptr_depth,0, nullptr);
}
}
@@ -47,42 +42,48 @@ ValueObjectPrinter::ValueObjectPrinter (ValueObject* valobj,
Stream* s,
const DumpValueObjectOptions& options)
{
- Init(valobj,s,options,options.m_max_ptr_depth,0);
+ Init(valobj,s,options,m_options.m_max_ptr_depth,0, nullptr);
}
ValueObjectPrinter::ValueObjectPrinter (ValueObject* valobj,
Stream* s,
const DumpValueObjectOptions& options,
- uint32_t ptr_depth,
- uint32_t curr_depth)
+ const DumpValueObjectOptions::PointerDepth& ptr_depth,
+ uint32_t curr_depth,
+ InstancePointersSetSP printed_instance_pointers)
{
- Init(valobj,s,options,ptr_depth,curr_depth);
+ Init(valobj,s,options,ptr_depth,curr_depth, printed_instance_pointers);
}
void
ValueObjectPrinter::Init (ValueObject* valobj,
Stream* s,
const DumpValueObjectOptions& options,
- uint32_t ptr_depth,
- uint32_t curr_depth)
+ const DumpValueObjectOptions::PointerDepth& ptr_depth,
+ uint32_t curr_depth,
+ InstancePointersSetSP printed_instance_pointers)
{
m_orig_valobj = valobj;
m_valobj = nullptr;
m_stream = s;
- this->options = options;
+ m_options = options;
m_ptr_depth = ptr_depth;
m_curr_depth = curr_depth;
assert (m_orig_valobj && "cannot print a NULL ValueObject");
assert (m_stream && "cannot print to a NULL Stream");
m_should_print = eLazyBoolCalculate;
m_is_nil = eLazyBoolCalculate;
+ m_is_uninit = eLazyBoolCalculate;
m_is_ptr = eLazyBoolCalculate;
m_is_ref = eLazyBoolCalculate;
m_is_aggregate = eLazyBoolCalculate;
+ m_is_instance_ptr = eLazyBoolCalculate;
m_summary_formatter = {nullptr,false};
m_value.assign("");
m_summary.assign("");
m_error.assign("");
+ m_val_summary_ok = false;
+ m_printed_instance_pointers = printed_instance_pointers ? printed_instance_pointers : InstancePointersSetSP(new InstancePointersSet());
}
bool
@@ -98,17 +99,15 @@ ValueObjectPrinter::PrintValueObject ()
PrintLocationIfNeeded();
m_stream->Indent();
- bool show_type = PrintTypeIfNeeded();
-
- PrintNameIfNeeded(show_type);
+ PrintDecl();
}
bool value_printed = false;
bool summary_printed = false;
- bool val_summary_ok = PrintValueAndSummaryIfNeeded (value_printed,summary_printed);
+ m_val_summary_ok = PrintValueAndSummaryIfNeeded (value_printed,summary_printed);
- if (val_summary_ok)
+ if (m_val_summary_ok)
PrintChildrenIfNeeded (value_printed, summary_printed);
else
m_stream->EOL();
@@ -132,7 +131,7 @@ ValueObjectPrinter::GetMostSpecializedValue ()
{
if (m_orig_valobj->IsDynamic())
{
- if (options.m_use_dynamic == eNoDynamicValues)
+ if (m_options.m_use_dynamic == eNoDynamicValues)
{
ValueObject *static_value = m_orig_valobj->GetStaticValue().get();
if (static_value)
@@ -145,9 +144,9 @@ ValueObjectPrinter::GetMostSpecializedValue ()
}
else
{
- if (options.m_use_dynamic != eNoDynamicValues)
+ if (m_options.m_use_dynamic != eNoDynamicValues)
{
- ValueObject *dynamic_value = m_orig_valobj->GetDynamicValue(options.m_use_dynamic).get();
+ ValueObject *dynamic_value = m_orig_valobj->GetDynamicValue(m_options.m_use_dynamic).get();
if (dynamic_value)
m_valobj = dynamic_value;
else
@@ -159,7 +158,7 @@ ValueObjectPrinter::GetMostSpecializedValue ()
if (m_valobj->IsSynthetic())
{
- if (options.m_use_synthetic == false)
+ if (m_options.m_use_synthetic == false)
{
ValueObject *non_synthetic = m_valobj->GetNonSyntheticValue().get();
if (non_synthetic)
@@ -168,7 +167,7 @@ ValueObjectPrinter::GetMostSpecializedValue ()
}
else
{
- if (options.m_use_synthetic == true)
+ if (m_options.m_use_synthetic == true)
{
ValueObject *synthetic = m_valobj->GetSyntheticValue().get();
if (synthetic)
@@ -176,8 +175,8 @@ ValueObjectPrinter::GetMostSpecializedValue ()
}
}
}
- m_clang_type = m_valobj->GetClangType();
- m_type_flags = m_clang_type.GetTypeInfo ();
+ m_compiler_type = m_valobj->GetCompilerType();
+ m_type_flags = m_compiler_type.GetTypeInfo ();
return true;
}
@@ -195,9 +194,9 @@ ValueObjectPrinter::GetDescriptionForDisplay ()
const char*
ValueObjectPrinter::GetRootNameForDisplay (const char* if_fail)
{
- const char *root_valobj_name = options.m_root_valobj_name.empty() ?
+ const char *root_valobj_name = m_options.m_root_valobj_name.empty() ?
m_valobj->GetName().AsCString() :
- options.m_root_valobj_name.c_str();
+ m_options.m_root_valobj_name.c_str();
return root_valobj_name ? root_valobj_name : if_fail;
}
@@ -205,7 +204,7 @@ bool
ValueObjectPrinter::ShouldPrintValueObject ()
{
if (m_should_print == eLazyBoolCalculate)
- m_should_print = (options.m_flat_output == false || m_type_flags.Test (eTypeHasValue)) ? eLazyBoolYes : eLazyBoolNo;
+ m_should_print = (m_options.m_flat_output == false || m_type_flags.Test (eTypeHasValue)) ? eLazyBoolYes : eLazyBoolNo;
return m_should_print == eLazyBoolYes;
}
@@ -213,11 +212,19 @@ bool
ValueObjectPrinter::IsNil ()
{
if (m_is_nil == eLazyBoolCalculate)
- m_is_nil = m_valobj->IsObjCNil() ? eLazyBoolYes : eLazyBoolNo;
+ m_is_nil = m_valobj->IsNilReference() ? eLazyBoolYes : eLazyBoolNo;
return m_is_nil == eLazyBoolYes;
}
bool
+ValueObjectPrinter::IsUninitialized ()
+{
+ if (m_is_uninit == eLazyBoolCalculate)
+ m_is_uninit = m_valobj->IsUninitializedReference() ? eLazyBoolYes : eLazyBoolNo;
+ return m_is_uninit == eLazyBoolYes;
+}
+
+bool
ValueObjectPrinter::IsPtr ()
{
if (m_is_ptr == eLazyBoolCalculate)
@@ -242,9 +249,20 @@ ValueObjectPrinter::IsAggregate ()
}
bool
+ValueObjectPrinter::IsInstancePointer ()
+{
+ // you need to do this check on the value's clang type
+ if (m_is_instance_ptr == eLazyBoolCalculate)
+ m_is_instance_ptr = (m_valobj->GetValue().GetCompilerType().GetTypeInfo() & eTypeInstanceIsPointer) != 0 ? eLazyBoolYes : eLazyBoolNo;
+ if ((eLazyBoolYes == m_is_instance_ptr) && m_valobj->IsBaseClass())
+ m_is_instance_ptr = eLazyBoolNo;
+ return m_is_instance_ptr == eLazyBoolYes;
+}
+
+bool
ValueObjectPrinter::PrintLocationIfNeeded ()
{
- if (options.m_show_location)
+ if (m_options.m_show_location)
{
m_stream->Printf("%s: ", m_valobj->GetLocationAsCString());
return true;
@@ -252,88 +270,155 @@ ValueObjectPrinter::PrintLocationIfNeeded ()
return false;
}
-bool
-ValueObjectPrinter::PrintTypeIfNeeded ()
+void
+ValueObjectPrinter::PrintDecl ()
{
bool show_type = true;
// if we are at the root-level and been asked to hide the root's type, then hide it
- if (m_curr_depth == 0 && options.m_hide_root_type)
+ if (m_curr_depth == 0 && m_options.m_hide_root_type)
show_type = false;
else
// otherwise decide according to the usual rules (asked to show types - always at the root level)
- show_type = options.m_show_types || (m_curr_depth == 0 && !options.m_flat_output);
+ show_type = m_options.m_show_types || (m_curr_depth == 0 && !m_options.m_flat_output);
+
+ StreamString typeName;
+ // always show the type at the root level if it is invalid
if (show_type)
{
// Some ValueObjects don't have types (like registers sets). Only print
// the type if there is one to print
ConstString type_name;
- if (options.m_use_type_display_name)
- type_name = m_valobj->GetDisplayTypeName();
+ if (m_compiler_type.IsValid())
+ {
+ if (m_options.m_use_type_display_name)
+ type_name = m_valobj->GetDisplayTypeName();
+ else
+ type_name = m_valobj->GetQualifiedTypeName();
+ }
else
- type_name = m_valobj->GetQualifiedTypeName();
+ {
+ // only show an invalid type name if the user explicitly triggered show_type
+ if (m_options.m_show_types)
+ type_name = ConstString("<invalid type>");
+ else
+ type_name.Clear();
+ }
+
if (type_name)
- m_stream->Printf("(%s) ", type_name.GetCString());
- else
- show_type = false;
+ {
+ std::string type_name_str(type_name.GetCString());
+ if (m_options.m_hide_pointer_value)
+ {
+ for(auto iter = type_name_str.find(" *");
+ iter != std::string::npos;
+ iter = type_name_str.find(" *"))
+ {
+ type_name_str.erase(iter, 2);
+ }
+ }
+ typeName.Printf("%s", type_name_str.c_str());
+ }
}
- return show_type;
-}
-
-bool
-ValueObjectPrinter::PrintNameIfNeeded (bool show_type)
-{
- if (options.m_flat_output)
+
+ StreamString varName;
+
+ if (m_options.m_flat_output)
{
// If we are showing types, also qualify the C++ base classes
const bool qualify_cxx_base_classes = show_type;
- if (!options.m_hide_name)
+ if (!m_options.m_hide_name)
{
- m_valobj->GetExpressionPath(*m_stream, qualify_cxx_base_classes);
- m_stream->PutCString(" =");
- return true;
+ m_valobj->GetExpressionPath(varName, qualify_cxx_base_classes);
}
}
- else if (!options.m_hide_name)
+ else if (!m_options.m_hide_name)
{
const char *name_cstr = GetRootNameForDisplay("");
- m_stream->Printf ("%s =", name_cstr);
- return true;
+ varName.Printf ("%s", name_cstr);
+ }
+
+ bool decl_printed = false;
+ if (!m_options.m_decl_printing_helper)
+ {
+ // if the user didn't give us a custom helper, pick one based upon the language, either the one that this printer is bound to, or the preferred one for the ValueObject
+ lldb::LanguageType lang_type = (m_options.m_varformat_language == lldb::eLanguageTypeUnknown) ? m_valobj->GetPreferredDisplayLanguage() : m_options.m_varformat_language;
+ if (Language *lang_plugin = Language::FindPlugin(lang_type))
+ {
+ m_options.m_decl_printing_helper = lang_plugin->GetDeclPrintingHelper();
+ }
+ }
+
+ if (m_options.m_decl_printing_helper)
+ {
+ ConstString type_name_cstr(typeName.GetData());
+ ConstString var_name_cstr(varName.GetData());
+
+ StreamString dest_stream;
+ if (m_options.m_decl_printing_helper (type_name_cstr,
+ var_name_cstr,
+ m_options,
+ dest_stream))
+ {
+ decl_printed = true;
+ m_stream->Printf("%s", dest_stream.GetData());
+ }
+ }
+
+ // if the helper failed, or there is none, do a default thing
+ if (!decl_printed)
+ {
+ if (typeName.GetSize())
+ m_stream->Printf("(%s) ", typeName.GetData());
+ if (varName.GetSize())
+ m_stream->Printf("%s =", varName.GetData());
+ else if (!m_options.m_hide_name)
+ m_stream->Printf(" =");
}
- return false;
}
bool
ValueObjectPrinter::CheckScopeIfNeeded ()
{
- if (options.m_scope_already_checked)
+ if (m_options.m_scope_already_checked)
return true;
return m_valobj->IsInScope();
}
TypeSummaryImpl*
-ValueObjectPrinter::GetSummaryFormatter ()
+ValueObjectPrinter::GetSummaryFormatter (bool null_if_omitted)
{
if (m_summary_formatter.second == false)
{
- TypeSummaryImpl* entry = options.m_summary_sp ? options.m_summary_sp.get() : m_valobj->GetSummaryFormat().get();
+ TypeSummaryImpl* entry = m_options.m_summary_sp ? m_options.m_summary_sp.get() : m_valobj->GetSummaryFormat().get();
- if (options.m_omit_summary_depth > 0)
+ if (m_options.m_omit_summary_depth > 0)
entry = NULL;
m_summary_formatter.first = entry;
m_summary_formatter.second = true;
}
+ if (m_options.m_omit_summary_depth > 0 && null_if_omitted)
+ return nullptr;
return m_summary_formatter.first;
}
+static bool
+IsPointerValue (const CompilerType &type)
+{
+ Flags type_flags(type.GetTypeInfo());
+ if (type_flags.AnySet(eTypeInstanceIsPointer | eTypeIsPointer))
+ return type_flags.AllClear(eTypeIsBuiltIn);
+ return false;
+}
+
void
ValueObjectPrinter::GetValueSummaryError (std::string& value,
std::string& summary,
std::string& error)
{
- if (options.m_format != eFormatDefault && options.m_format != m_valobj->GetFormat())
+ if (m_options.m_format != eFormatDefault && m_options.m_format != m_valobj->GetFormat())
{
- m_valobj->GetValueAsCString(options.m_format,
+ m_valobj->GetValueAsCString(m_options.m_format,
value);
}
else
@@ -350,14 +435,16 @@ ValueObjectPrinter::GetValueSummaryError (std::string& value,
{
if (IsNil())
summary.assign("nil");
- else if (options.m_omit_summary_depth == 0)
+ else if (IsUninitialized())
+ summary.assign("<uninitialized>");
+ else if (m_options.m_omit_summary_depth == 0)
{
TypeSummaryImpl* entry = GetSummaryFormatter();
if (entry)
- m_valobj->GetSummaryAsCString(entry, summary);
+ m_valobj->GetSummaryAsCString(entry, summary, m_options.m_varformat_language);
else
{
- const char* sum_cstr = m_valobj->GetSummaryAsCString();
+ const char* sum_cstr = m_valobj->GetSummaryAsCString(m_options.m_varformat_language);
if (sum_cstr)
summary.assign(sum_cstr);
}
@@ -380,6 +467,16 @@ ValueObjectPrinter::PrintValueAndSummaryIfNeeded (bool& value_printed,
}
if (m_error.size())
{
+ // we need to support scenarios in which it is actually fine for a value to have no type
+ // but - on the other hand - if we get an error *AND* have no type, we try to get out
+ // gracefully, since most often that combination means "could not resolve a type"
+ // and the default failure mode is quite ugly
+ if (!m_compiler_type.IsValid())
+ {
+ m_stream->Printf(" <could not resolve type>");
+ return false;
+ }
+
error_printed = true;
m_stream->Printf (" <%s>\n", m_error.c_str());
}
@@ -390,10 +487,14 @@ ValueObjectPrinter::PrintValueAndSummaryIfNeeded (bool& value_printed,
// the value if this thing is nil
// (but show the value if the user passes a format explicitly)
TypeSummaryImpl* entry = GetSummaryFormatter();
- if (!IsNil() && !m_value.empty() && (entry == NULL || (entry->DoesPrintValue(m_valobj) || options.m_format != eFormatDefault) || m_summary.empty()) && !options.m_hide_value)
+ if (!IsNil() && !IsUninitialized() && !m_value.empty() && (entry == NULL || (entry->DoesPrintValue(m_valobj) || m_options.m_format != eFormatDefault) || m_summary.empty()) && !m_options.m_hide_value)
{
- m_stream->Printf(" %s", m_value.c_str());
- value_printed = true;
+ if (m_options.m_hide_pointer_value && IsPointerValue(m_valobj->GetCompilerType())) {}
+ else
+ {
+ m_stream->Printf(" %s", m_value.c_str());
+ value_printed = true;
+ }
}
if (m_summary.size())
@@ -413,9 +514,9 @@ ValueObjectPrinter::PrintObjectDescriptionIfNeeded (bool value_printed,
if (ShouldPrintValueObject())
{
// let's avoid the overly verbose no description error for a nil thing
- if (options.m_use_objc && !IsNil())
+ if (m_options.m_use_objc && !IsNil() && !IsUninitialized())
{
- if (!options.m_hide_value || !options.m_hide_name)
+ if (!m_options.m_hide_value || !m_options.m_hide_name)
m_stream->Printf(" ");
const char *object_desc = nullptr;
if (value_printed || summary_printed)
@@ -437,13 +538,61 @@ ValueObjectPrinter::PrintObjectDescriptionIfNeeded (bool value_printed,
}
bool
+DumpValueObjectOptions::PointerDepth::CanAllowExpansion (bool is_root,
+ TypeSummaryImpl* entry,
+ ValueObject *valobj,
+ const std::string& summary)
+{
+ switch (m_mode)
+ {
+ case Mode::Always:
+ return (m_count > 0);
+ case Mode::Never:
+ return false;
+ case Mode::Default:
+ if (is_root)
+ m_count = std::min<decltype(m_count)>(m_count,1);
+ return m_count > 0;
+ case Mode::Formatters:
+ if (!entry || entry->DoesPrintChildren(valobj) || summary.empty())
+ return m_count > 0;
+ return false;
+ }
+ return false;
+}
+
+bool
+DumpValueObjectOptions::PointerDepth::CanAllowExpansion () const
+{
+ switch (m_mode)
+ {
+ case Mode::Always:
+ case Mode::Default:
+ case Mode::Formatters:
+ return (m_count > 0);
+ case Mode::Never:
+ return false;
+ }
+ return false;
+}
+
+bool
ValueObjectPrinter::ShouldPrintChildren (bool is_failed_description,
- uint32_t& curr_ptr_depth)
+ DumpValueObjectOptions::PointerDepth& curr_ptr_depth)
{
const bool is_ref = IsRef ();
const bool is_ptr = IsPtr ();
-
- if (is_failed_description || m_curr_depth < options.m_max_depth)
+ const bool is_uninit = IsUninitialized();
+
+ if (is_uninit)
+ return false;
+
+ TypeSummaryImpl* entry = GetSummaryFormatter();
+
+ if (m_options.m_use_objc)
+ return false;
+
+ if (is_failed_description || m_curr_depth < m_options.m_max_depth)
{
// We will show children for all concrete types. We won't show
// pointer contents unless a pointer depth has been specified.
@@ -461,25 +610,37 @@ ValueObjectPrinter::ShouldPrintChildren (bool is_failed_description,
if (m_valobj->GetPointerValue (&ptr_address_type) == 0)
return false;
- else if (is_ref && m_curr_depth == 0 && curr_ptr_depth == 0)
+ const bool is_root_level = m_curr_depth == 0;
+
+ if (is_ref &&
+ is_root_level)
{
// If this is the root object (depth is zero) that we are showing
// and it is a reference, and no pointer depth has been supplied
// print out what it references. Don't do this at deeper depths
// otherwise we can end up with infinite recursion...
- curr_ptr_depth = 1;
+ return true;
}
- return (curr_ptr_depth > 0);
+ return curr_ptr_depth.CanAllowExpansion(false, entry, m_valobj, m_summary);
}
- TypeSummaryImpl* entry = GetSummaryFormatter();
-
return (!entry || entry->DoesPrintChildren(m_valobj) || m_summary.empty());
}
return false;
}
+bool
+ValueObjectPrinter::ShouldExpandEmptyAggregates ()
+{
+ TypeSummaryImpl* entry = GetSummaryFormatter();
+
+ if (!entry)
+ return true;
+
+ return entry->DoesPrintEmptyAggregates();
+}
+
ValueObject*
ValueObjectPrinter::GetValueObjectForChildrenGeneration ()
{
@@ -489,7 +650,7 @@ ValueObjectPrinter::GetValueObjectForChildrenGeneration ()
void
ValueObjectPrinter::PrintChildrenPreamble ()
{
- if (options.m_flat_output)
+ if (m_options.m_flat_output)
{
if (ShouldPrintValueObject())
m_stream->EOL();
@@ -504,22 +665,23 @@ ValueObjectPrinter::PrintChildrenPreamble ()
void
ValueObjectPrinter::PrintChild (ValueObjectSP child_sp,
- uint32_t curr_ptr_depth)
+ const DumpValueObjectOptions::PointerDepth& curr_ptr_depth)
{
- DumpValueObjectOptions child_options(options);
- child_options.SetFormat(options.m_format).SetSummary().SetRootValueObjectName();
- child_options.SetScopeChecked(true).SetHideName(options.m_hide_name).SetHideValue(options.m_hide_value)
+ DumpValueObjectOptions child_options(m_options);
+ child_options.SetFormat(m_options.m_format).SetSummary().SetRootValueObjectName();
+ child_options.SetScopeChecked(true).SetHideName(m_options.m_hide_name).SetHideValue(m_options.m_hide_value)
.SetOmitSummaryDepth(child_options.m_omit_summary_depth > 1 ? child_options.m_omit_summary_depth - 1 : 0);
+
if (child_sp.get())
{
ValueObjectPrinter child_printer(child_sp.get(),
m_stream,
child_options,
- (IsPtr() || IsRef()) && curr_ptr_depth >= 1 ? curr_ptr_depth - 1 : curr_ptr_depth,
- m_curr_depth + 1);
+ (IsPtr() || IsRef()) ? --curr_ptr_depth : curr_ptr_depth,
+ m_curr_depth + 1,
+ m_printed_instance_pointers);
child_printer.PrintValueObject();
}
-
}
uint32_t
@@ -533,7 +695,7 @@ ValueObjectPrinter::GetMaxNumChildrenToPrint (bool& print_dotdotdot)
{
const size_t max_num_children = m_valobj->GetTargetSP()->GetMaximumNumberOfChildrenToDisplay();
- if (num_children > max_num_children && !options.m_ignore_cap)
+ if (num_children > max_num_children && !m_options.m_ignore_cap)
{
print_dotdotdot = true;
return max_num_children;
@@ -545,7 +707,7 @@ ValueObjectPrinter::GetMaxNumChildrenToPrint (bool& print_dotdotdot)
void
ValueObjectPrinter::PrintChildrenPostamble (bool print_dotdotdot)
{
- if (!options.m_flat_output)
+ if (!m_options.m_flat_output)
{
if (print_dotdotdot)
{
@@ -557,8 +719,34 @@ ValueObjectPrinter::PrintChildrenPostamble (bool print_dotdotdot)
}
}
+bool
+ValueObjectPrinter::ShouldPrintEmptyBrackets (bool value_printed,
+ bool summary_printed)
+{
+ ValueObject* synth_m_valobj = GetValueObjectForChildrenGeneration();
+
+ if (!IsAggregate())
+ return false;
+
+ if (m_options.m_reveal_empty_aggregates == false)
+ {
+ if (value_printed || summary_printed)
+ return false;
+ }
+
+ if (synth_m_valobj->MightHaveChildren())
+ return true;
+
+ if (m_val_summary_ok)
+ return false;
+
+ return true;
+}
+
void
-ValueObjectPrinter::PrintChildren (uint32_t curr_ptr_depth)
+ValueObjectPrinter::PrintChildren (bool value_printed,
+ bool summary_printed,
+ const DumpValueObjectOptions::PointerDepth& curr_ptr_depth)
{
ValueObject* synth_m_valobj = GetValueObjectForChildrenGeneration();
@@ -566,23 +754,44 @@ ValueObjectPrinter::PrintChildren (uint32_t curr_ptr_depth)
size_t num_children = GetMaxNumChildrenToPrint(print_dotdotdot);
if (num_children)
{
- PrintChildrenPreamble ();
+ bool any_children_printed = false;
for (size_t idx=0; idx<num_children; ++idx)
{
ValueObjectSP child_sp(synth_m_valobj->GetChildAtIndex(idx, true));
- PrintChild (child_sp, curr_ptr_depth);
+ if (child_sp)
+ {
+ if (!any_children_printed)
+ {
+ PrintChildrenPreamble ();
+ any_children_printed = true;
+ }
+ PrintChild (child_sp, curr_ptr_depth);
+ }
}
- PrintChildrenPostamble (print_dotdotdot);
+ if (any_children_printed)
+ PrintChildrenPostamble (print_dotdotdot);
+ else
+ {
+ if (ShouldPrintEmptyBrackets(value_printed, summary_printed))
+ {
+ if (ShouldPrintValueObject())
+ m_stream->PutCString(" {}\n");
+ else
+ m_stream->EOL();
+ }
+ else
+ m_stream->EOL();
+ }
}
- else if (IsAggregate())
+ else if (ShouldPrintEmptyBrackets(value_printed, summary_printed))
{
// Aggregate, no children...
if (ShouldPrintValueObject())
{
// if it has a synthetic value, then don't print {}, the synthetic children are probably only being used to vend a value
- if (m_valobj->DoesProvideSyntheticValue())
+ if (m_valobj->DoesProvideSyntheticValue() || !ShouldExpandEmptyAggregates())
m_stream->PutCString( "\n");
else
m_stream->PutCString(" {}\n");
@@ -614,7 +823,7 @@ ValueObjectPrinter::PrintChildrenOneLiner (bool hide_names)
{
lldb::ValueObjectSP child_sp(synth_m_valobj->GetChildAtIndex(idx, true));
if (child_sp)
- child_sp = child_sp->GetQualifiedRepresentationIfAvailable(options.m_use_dynamic, options.m_use_synthetic);
+ child_sp = child_sp->GetQualifiedRepresentationIfAvailable(m_options.m_use_dynamic, m_options.m_use_synthetic);
if (child_sp)
{
if (idx)
@@ -630,7 +839,7 @@ ValueObjectPrinter::PrintChildrenOneLiner (bool hide_names)
}
child_sp->DumpPrintableRepresentation(*m_stream,
ValueObject::eValueObjectRepresentationStyleSummary,
- lldb::eFormatInvalid,
+ m_options.m_format,
ValueObject::ePrintableRepresentationSpecialCasesDisable);
}
}
@@ -651,13 +860,30 @@ ValueObjectPrinter::PrintChildrenIfNeeded (bool value_printed,
// if that happens, we want to display the children, if any
bool is_failed_description = !PrintObjectDescriptionIfNeeded(value_printed, summary_printed);
- uint32_t curr_ptr_depth = m_ptr_depth;
+ auto curr_ptr_depth = m_ptr_depth;
bool print_children = ShouldPrintChildren (is_failed_description,curr_ptr_depth);
- bool print_oneline = (curr_ptr_depth > 0 ||
- options.m_show_types ||
- !options.m_allow_oneliner_mode ||
- options.m_flat_output ||
- options.m_show_location) ? false : DataVisualization::ShouldPrintAsOneLiner(*m_valobj);
+ bool print_oneline = (curr_ptr_depth.CanAllowExpansion() ||
+ m_options.m_show_types ||
+ !m_options.m_allow_oneliner_mode ||
+ m_options.m_flat_output ||
+ m_options.m_show_location) ? false : DataVisualization::ShouldPrintAsOneLiner(*m_valobj);
+ bool is_instance_ptr = IsInstancePointer();
+ uint64_t instance_ptr_value = LLDB_INVALID_ADDRESS;
+
+ if (print_children && is_instance_ptr)
+ {
+ instance_ptr_value = m_valobj->GetValueAsUnsigned(0);
+ if (m_printed_instance_pointers->count(instance_ptr_value))
+ {
+ // we already printed this instance-is-pointer thing, so don't expand it
+ m_stream->PutCString(" {...}\n");
+
+ // we're done here - get out fast
+ return;
+ }
+ else
+ m_printed_instance_pointers->emplace(instance_ptr_value); // remember this guy for future reference
+ }
if (print_children)
{
@@ -668,11 +894,11 @@ ValueObjectPrinter::PrintChildrenIfNeeded (bool value_printed,
m_stream->EOL();
}
else
- PrintChildren (curr_ptr_depth);
+ PrintChildren (value_printed, summary_printed, curr_ptr_depth);
}
- else if (m_curr_depth >= options.m_max_depth && IsAggregate() && ShouldPrintValueObject())
+ else if (m_curr_depth >= m_options.m_max_depth && IsAggregate() && ShouldPrintValueObject())
{
- m_stream->PutCString("{...}\n");
+ m_stream->PutCString("{...}\n");
}
else
m_stream->EOL();
@@ -681,7 +907,7 @@ ValueObjectPrinter::PrintChildrenIfNeeded (bool value_printed,
bool
ValueObjectPrinter::ShouldPrintValidation ()
{
- return options.m_run_validator;
+ return m_options.m_run_validator;
}
bool
diff --git a/source/DataFormatters/VectorType.cpp b/source/DataFormatters/VectorType.cpp
index 316d7b540bcd..347afa5c0559 100644
--- a/source/DataFormatters/VectorType.cpp
+++ b/source/DataFormatters/VectorType.cpp
@@ -1,4 +1,4 @@
-//===-- VectorType.cpp ---------------------------------------------*- C++ -*-===//
+//===-- VectorType.cpp ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,12 +7,17 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/DataFormatters/VectorType.h"
#include "lldb/Core/ValueObject.h"
-#include "lldb/DataFormatters/CXXFormatterFunctions.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Symbol/TypeSystem.h"
+#include "lldb/Target/Target.h"
#include "lldb/Utility/LLDBAssert.h"
@@ -20,87 +25,87 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
-static ClangASTType
-GetClangTypeForFormat (lldb::Format format,
- ClangASTType element_type,
- ClangASTContext *ast_ctx)
+static CompilerType
+GetCompilerTypeForFormat (lldb::Format format,
+ CompilerType element_type,
+ TypeSystem *type_system)
{
- lldbassert(ast_ctx && "ast_ctx needs to be not NULL");
+ lldbassert(type_system && "type_system needs to be not NULL");
switch (format)
{
case lldb::eFormatAddressInfo:
case lldb::eFormatPointer:
- return ast_ctx->GetPointerSizedIntType(false);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingUint, 8*type_system->GetPointerByteSize());
case lldb::eFormatBoolean:
- return ast_ctx->GetBasicType(lldb::eBasicTypeBool);
+ return type_system->GetBasicTypeFromAST(lldb::eBasicTypeBool);
case lldb::eFormatBytes:
case lldb::eFormatBytesWithASCII:
case lldb::eFormatChar:
case lldb::eFormatCharArray:
case lldb::eFormatCharPrintable:
- return ast_ctx->GetBasicType(lldb::eBasicTypeChar);
+ return type_system->GetBasicTypeFromAST(lldb::eBasicTypeChar);
case lldb::eFormatComplex /* lldb::eFormatComplexFloat */:
- return ast_ctx->GetBasicType(lldb::eBasicTypeFloatComplex);
+ return type_system->GetBasicTypeFromAST(lldb::eBasicTypeFloatComplex);
case lldb::eFormatCString:
- return ast_ctx->GetBasicType(lldb::eBasicTypeChar).GetPointerType();
+ return type_system->GetBasicTypeFromAST(lldb::eBasicTypeChar).GetPointerType();
case lldb::eFormatFloat:
- return ast_ctx->GetBasicType(lldb::eBasicTypeFloat);
+ return type_system->GetBasicTypeFromAST(lldb::eBasicTypeFloat);
case lldb::eFormatHex:
case lldb::eFormatHexUppercase:
case lldb::eFormatOctal:
- return ast_ctx->GetBasicType(lldb::eBasicTypeInt);
+ return type_system->GetBasicTypeFromAST(lldb::eBasicTypeInt);
case lldb::eFormatHexFloat:
- return ast_ctx->GetBasicType(lldb::eBasicTypeFloat);
+ return type_system->GetBasicTypeFromAST(lldb::eBasicTypeFloat);
case lldb::eFormatUnicode16:
case lldb::eFormatUnicode32:
case lldb::eFormatUnsigned:
- return ast_ctx->GetBasicType(lldb::eBasicTypeUnsignedInt);
+ return type_system->GetBasicTypeFromAST(lldb::eBasicTypeUnsignedInt);
case lldb::eFormatVectorOfChar:
- return ast_ctx->GetBasicType(lldb::eBasicTypeChar);
+ return type_system->GetBasicTypeFromAST(lldb::eBasicTypeChar);
case lldb::eFormatVectorOfFloat32:
- return ast_ctx->GetFloatTypeFromBitSize(32);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize(eEncodingIEEE754, 32);
case lldb::eFormatVectorOfFloat64:
- return ast_ctx->GetFloatTypeFromBitSize(64);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize(eEncodingIEEE754, 64);
case lldb::eFormatVectorOfSInt16:
- return ast_ctx->GetIntTypeFromBitSize(16, true);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingSint, 16);
case lldb::eFormatVectorOfSInt32:
- return ast_ctx->GetIntTypeFromBitSize(32, true);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingSint, 32);
case lldb::eFormatVectorOfSInt64:
- return ast_ctx->GetIntTypeFromBitSize(64, true);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingSint, 64);
case lldb::eFormatVectorOfSInt8:
- return ast_ctx->GetIntTypeFromBitSize(8, true);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingSint, 8);
case lldb::eFormatVectorOfUInt128:
- return ast_ctx->GetIntTypeFromBitSize(128, false);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingUint, 128);
case lldb::eFormatVectorOfUInt16:
- return ast_ctx->GetIntTypeFromBitSize(16, false);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingUint, 16);
case lldb::eFormatVectorOfUInt32:
- return ast_ctx->GetIntTypeFromBitSize(32, false);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingUint, 32);
case lldb::eFormatVectorOfUInt64:
- return ast_ctx->GetIntTypeFromBitSize(64, false);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingUint, 64);
case lldb::eFormatVectorOfUInt8:
- return ast_ctx->GetIntTypeFromBitSize(8, false);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingUint, 8);
case lldb::eFormatDefault:
return element_type;
@@ -113,13 +118,13 @@ GetClangTypeForFormat (lldb::Format format,
case lldb::eFormatOSType:
case lldb::eFormatVoid:
default:
- return ast_ctx->GetIntTypeFromBitSize(8, false);
+ return type_system->GetBuiltinTypeForEncodingAndBitSize (eEncodingUint, 8);
}
}
static lldb::Format
GetItemFormatForFormat (lldb::Format format,
- ClangASTType element_type)
+ CompilerType element_type)
{
switch (format)
{
@@ -169,8 +174,8 @@ GetItemFormatForFormat (lldb::Format format,
}
static size_t
-CalculateNumChildren (ClangASTType container_type,
- ClangASTType element_type,
+CalculateNumChildren (CompilerType container_type,
+ CompilerType element_type,
lldb_private::ExecutionContextScope *exe_scope = nullptr // does not matter here because all we trade in are basic types
)
{
@@ -199,15 +204,17 @@ namespace lldb_private {
m_child_type(),
m_num_children(0)
{}
-
- virtual size_t
- CalculateNumChildren ()
+
+ ~VectorTypeSyntheticFrontEnd() override = default;
+
+ size_t
+ CalculateNumChildren() override
{
return m_num_children;
}
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx)
+
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override
{
if (idx >= CalculateNumChildren())
return lldb::ValueObjectSP();
@@ -225,29 +232,32 @@ namespace lldb_private {
return child_sp;
}
- virtual bool
- Update()
+ bool
+ Update() override
{
m_parent_format = m_backend.GetFormat();
- ClangASTType parent_type(m_backend.GetClangType());
- ClangASTType element_type;
+ CompilerType parent_type(m_backend.GetCompilerType());
+ CompilerType element_type;
parent_type.IsVectorType(&element_type, nullptr);
- m_child_type = ::GetClangTypeForFormat(m_parent_format, element_type, ClangASTContext::GetASTContext(parent_type.GetASTContext()));
+ TargetSP target_sp(m_backend.GetTargetSP());
+ m_child_type = ::GetCompilerTypeForFormat(m_parent_format,
+ element_type,
+ target_sp ? target_sp->GetScratchTypeSystemForLanguage(nullptr, lldb::eLanguageTypeC) : nullptr);
m_num_children = ::CalculateNumChildren(parent_type,
m_child_type);
m_item_format = GetItemFormatForFormat(m_parent_format,
m_child_type);
return false;
}
-
- virtual bool
- MightHaveChildren ()
+
+ bool
+ MightHaveChildren() override
{
return true;
}
-
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name)
+
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override
{
const char* item_name = name.GetCString();
uint32_t idx = ExtractIndexFromString(item_name);
@@ -255,18 +265,16 @@ namespace lldb_private {
return UINT32_MAX;
return idx;
}
-
- virtual
- ~VectorTypeSyntheticFrontEnd () {}
-
+
private:
lldb::Format m_parent_format;
lldb::Format m_item_format;
- ClangASTType m_child_type;
+ CompilerType m_child_type;
size_t m_num_children;
};
- }
-}
+
+ } // namespace formatters
+} // namespace lldb_private
bool
lldb_private::formatters::VectorTypeSummaryProvider (ValueObject& valobj,
@@ -317,6 +325,6 @@ lldb_private::SyntheticChildrenFrontEnd*
lldb_private::formatters::VectorTypeSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
{
if (!valobj_sp)
- return NULL;
- return (new VectorTypeSyntheticFrontEnd(valobj_sp));
+ return nullptr;
+ return new VectorTypeSyntheticFrontEnd(valobj_sp);
}
diff --git a/source/Expression/ClangExpressionVariable.cpp b/source/Expression/ClangExpressionVariable.cpp
deleted file mode 100644
index e86016e53a7d..000000000000
--- a/source/Expression/ClangExpressionVariable.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-//===-- ClangExpressionVariable.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/Expression/ClangExpressionVariable.h"
-#include "clang/AST/ASTContext.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/Value.h"
-#include "lldb/Core/ValueObjectConstResult.h"
-#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/Process.h"
-
-using namespace lldb_private;
-using namespace clang;
-
-ClangExpressionVariable::ClangExpressionVariable(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size) :
- m_parser_vars(),
- m_jit_vars (),
- m_flags (EVNone),
- m_frozen_sp (ValueObjectConstResult::Create (exe_scope, byte_order, addr_byte_size))
-{
-}
-
-ClangExpressionVariable::ClangExpressionVariable (ExecutionContextScope *exe_scope,
- Value &value,
- const ConstString &name,
- uint16_t flags) :
- m_parser_vars(),
- m_jit_vars (),
- m_flags (flags),
- m_frozen_sp (ValueObjectConstResult::Create (exe_scope, value, name))
-{
-}
-
-ClangExpressionVariable::ClangExpressionVariable (const lldb::ValueObjectSP &valobj_sp) :
- m_parser_vars(),
- m_jit_vars (),
- m_flags (EVNone),
- m_frozen_sp (valobj_sp)
-{
-}
-
-//----------------------------------------------------------------------
-/// Return the variable's size in bytes
-//----------------------------------------------------------------------
-size_t
-ClangExpressionVariable::GetByteSize ()
-{
- return m_frozen_sp->GetByteSize();
-}
-
-const ConstString &
-ClangExpressionVariable::GetName ()
-{
- return m_frozen_sp->GetName();
-}
-
-lldb::ValueObjectSP
-ClangExpressionVariable::GetValueObject()
-{
- return m_frozen_sp;
-}
-
-RegisterInfo *
-ClangExpressionVariable::GetRegisterInfo()
-{
- return m_frozen_sp->GetValue().GetRegisterInfo();
-}
-
-void
-ClangExpressionVariable::SetRegisterInfo (const RegisterInfo *reg_info)
-{
- return m_frozen_sp->GetValue().SetContext (Value::eContextTypeRegisterInfo, const_cast<RegisterInfo *>(reg_info));
-}
-
-ClangASTType
-ClangExpressionVariable::GetClangType()
-{
- return m_frozen_sp->GetClangType();
-}
-
-void
-ClangExpressionVariable::SetClangType(const ClangASTType &clang_type)
-{
- m_frozen_sp->GetValue().SetClangType(clang_type);
-}
-
-
-TypeFromUser
-ClangExpressionVariable::GetTypeFromUser()
-{
- TypeFromUser tfu (m_frozen_sp->GetClangType());
- return tfu;
-}
-
-uint8_t *
-ClangExpressionVariable::GetValueBytes()
-{
- const size_t byte_size = m_frozen_sp->GetByteSize();
- if (byte_size > 0)
- {
- if (m_frozen_sp->GetDataExtractor().GetByteSize() < byte_size)
- {
- m_frozen_sp->GetValue().ResizeData(byte_size);
- m_frozen_sp->GetValue().GetData (m_frozen_sp->GetDataExtractor());
- }
- return const_cast<uint8_t *>(m_frozen_sp->GetDataExtractor().GetDataStart());
- }
- return NULL;
-}
-
-void
-ClangExpressionVariable::SetName (const ConstString &name)
-{
- m_frozen_sp->SetName (name);
-}
-
-void
-ClangExpressionVariable::ValueUpdated ()
-{
- m_frozen_sp->ValueUpdated ();
-}
-
-void
-ClangExpressionVariable::TransferAddress (bool force)
-{
- if (m_live_sp.get() == NULL)
- return;
-
- if (m_frozen_sp.get() == NULL)
- return;
-
- if (force || (m_frozen_sp->GetLiveAddress() == LLDB_INVALID_ADDRESS))
- m_frozen_sp->SetLiveAddress(m_live_sp->GetLiveAddress());
-}
diff --git a/source/Expression/ClangUserExpression.cpp b/source/Expression/ClangUserExpression.cpp
deleted file mode 100644
index 0da70e2b0a70..000000000000
--- a/source/Expression/ClangUserExpression.cpp
+++ /dev/null
@@ -1,1172 +0,0 @@
-//===-- ClangUserExpression.cpp ---------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <stdio.h>
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#include <cstdlib>
-#include <string>
-#include <map>
-
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Module.h"
-#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Core/ValueObjectConstResult.h"
-#include "lldb/Expression/ASTResultSynthesizer.h"
-#include "lldb/Expression/ClangExpressionDeclMap.h"
-#include "lldb/Expression/ClangExpressionParser.h"
-#include "lldb/Expression/ClangFunction.h"
-#include "lldb/Expression/ClangModulesDeclVendor.h"
-#include "lldb/Expression/ClangPersistentVariables.h"
-#include "lldb/Expression/ClangUserExpression.h"
-#include "lldb/Expression/ExpressionSourceCode.h"
-#include "lldb/Expression/IRExecutionUnit.h"
-#include "lldb/Expression/IRInterpreter.h"
-#include "lldb/Expression/Materializer.h"
-#include "lldb/Host/HostInfo.h"
-#include "lldb/Symbol/Block.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/Function.h"
-#include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Symbol/SymbolVendor.h"
-#include "lldb/Symbol/Type.h"
-#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
-#include "lldb/Symbol/VariableList.h"
-#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/StackFrame.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/ThreadPlan.h"
-#include "lldb/Target/ThreadPlanCallUserExpression.h"
-
-#include "clang/AST/DeclCXX.h"
-#include "clang/AST/DeclObjC.h"
-
-using namespace lldb_private;
-
-ClangUserExpression::ClangUserExpression (const char *expr,
- const char *expr_prefix,
- lldb::LanguageType language,
- ResultType desired_type) :
- ClangExpression (),
- m_stack_frame_bottom (LLDB_INVALID_ADDRESS),
- m_stack_frame_top (LLDB_INVALID_ADDRESS),
- m_expr_text (expr),
- m_expr_prefix (expr_prefix ? expr_prefix : ""),
- m_language (language),
- m_transformed_text (),
- m_desired_type (desired_type),
- m_expr_decl_map(),
- m_execution_unit_sp(),
- m_materializer_ap(),
- m_result_synthesizer(),
- 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_const_object (false),
- m_target (NULL),
- m_can_interpret (false),
- m_materialized_address (LLDB_INVALID_ADDRESS)
-{
- switch (m_language)
- {
- case lldb::eLanguageTypeC_plus_plus:
- m_allow_cxx = true;
- break;
- case lldb::eLanguageTypeObjC:
- m_allow_objc = true;
- break;
- case lldb::eLanguageTypeObjC_plus_plus:
- default:
- m_allow_cxx = true;
- m_allow_objc = true;
- break;
- }
-}
-
-ClangUserExpression::~ClangUserExpression ()
-{
- if (m_target)
- {
- lldb::ModuleSP jit_module_sp (m_jit_module_wp.lock());
- if (jit_module_sp)
- m_target->GetImages().Remove(jit_module_sp);
- }
-}
-
-clang::ASTConsumer *
-ClangUserExpression::ASTTransformer (clang::ASTConsumer *passthrough)
-{
- m_result_synthesizer.reset(new ASTResultSynthesizer(passthrough,
- *m_target));
-
- return m_result_synthesizer.get();
-}
-
-void
-ClangUserExpression::ScanContext(ExecutionContext &exe_ctx, Error &err)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-
- if (log)
- log->Printf("ClangUserExpression::ScanContext()");
-
- m_target = exe_ctx.GetTargetPtr();
-
- if (!(m_allow_cxx || m_allow_objc))
- {
- if (log)
- log->Printf(" [CUE::SC] Settings inhibit C++ and Objective-C");
- return;
- }
-
- StackFrame *frame = exe_ctx.GetFramePtr();
- if (frame == NULL)
- {
- if (log)
- log->Printf(" [CUE::SC] Null stack frame");
- return;
- }
-
- SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction | lldb::eSymbolContextBlock);
-
- if (!sym_ctx.function)
- {
- if (log)
- log->Printf(" [CUE::SC] Null function");
- return;
- }
-
- // Find the block that defines the function represented by "sym_ctx"
- Block *function_block = sym_ctx.GetFunctionBlock();
-
- if (!function_block)
- {
- if (log)
- log->Printf(" [CUE::SC] Null function block");
- return;
- }
-
- clang::DeclContext *decl_context = function_block->GetClangDeclContext();
-
- if (!decl_context)
- {
- if (log)
- log->Printf(" [CUE::SC] Null decl context");
- return;
- }
-
- if (clang::CXXMethodDecl *method_decl = llvm::dyn_cast<clang::CXXMethodDecl>(decl_context))
- {
- if (m_allow_cxx && method_decl->isInstance())
- {
- if (m_enforce_valid_object)
- {
- lldb::VariableListSP variable_list_sp (function_block->GetBlockVariableList (true));
-
- const char *thisErrorString = "Stopped in a C++ method, but 'this' isn't available; pretending we are in a generic context";
-
- if (!variable_list_sp)
- {
- err.SetErrorString(thisErrorString);
- return;
- }
-
- lldb::VariableSP this_var_sp (variable_list_sp->FindVariable(ConstString("this")));
-
- if (!this_var_sp ||
- !this_var_sp->IsInScope(frame) ||
- !this_var_sp->LocationIsValidForFrame (frame))
- {
- err.SetErrorString(thisErrorString);
- return;
- }
- }
-
- m_in_cplusplus_method = true;
- m_needs_object_ptr = true;
- }
- }
- else if (clang::ObjCMethodDecl *method_decl = llvm::dyn_cast<clang::ObjCMethodDecl>(decl_context))
- {
- if (m_allow_objc)
- {
- if (m_enforce_valid_object)
- {
- lldb::VariableListSP variable_list_sp (function_block->GetBlockVariableList (true));
-
- const char *selfErrorString = "Stopped in an Objective-C method, but 'self' isn't available; pretending we are in a generic context";
-
- if (!variable_list_sp)
- {
- err.SetErrorString(selfErrorString);
- return;
- }
-
- lldb::VariableSP self_variable_sp = variable_list_sp->FindVariable(ConstString("self"));
-
- if (!self_variable_sp ||
- !self_variable_sp->IsInScope(frame) ||
- !self_variable_sp->LocationIsValidForFrame (frame))
- {
- err.SetErrorString(selfErrorString);
- return;
- }
- }
-
- m_in_objectivec_method = true;
- m_needs_object_ptr = true;
-
- if (!method_decl->isInstanceMethod())
- m_in_static_method = true;
- }
- }
- else if (clang::FunctionDecl *function_decl = llvm::dyn_cast<clang::FunctionDecl>(decl_context))
- {
- // We might also have a function that said in the debug information that it captured an
- // object pointer. The best way to deal with getting to the ivars at present is by pretending
- // that this is a method of a class in whatever runtime the debug info says the object pointer
- // belongs to. Do that here.
-
- ClangASTMetadata *metadata = ClangASTContext::GetMetadata (&decl_context->getParentASTContext(), function_decl);
- if (metadata && metadata->HasObjectPtr())
- {
- lldb::LanguageType language = metadata->GetObjectPtrLanguage();
- if (language == lldb::eLanguageTypeC_plus_plus)
- {
- if (m_enforce_valid_object)
- {
- lldb::VariableListSP variable_list_sp (function_block->GetBlockVariableList (true));
-
- const char *thisErrorString = "Stopped in a context claiming to capture a C++ object pointer, but 'this' isn't available; pretending we are in a generic context";
-
- if (!variable_list_sp)
- {
- err.SetErrorString(thisErrorString);
- return;
- }
-
- lldb::VariableSP this_var_sp (variable_list_sp->FindVariable(ConstString("this")));
-
- if (!this_var_sp ||
- !this_var_sp->IsInScope(frame) ||
- !this_var_sp->LocationIsValidForFrame (frame))
- {
- err.SetErrorString(thisErrorString);
- return;
- }
- }
-
- m_in_cplusplus_method = true;
- m_needs_object_ptr = true;
- }
- else if (language == lldb::eLanguageTypeObjC)
- {
- if (m_enforce_valid_object)
- {
- lldb::VariableListSP variable_list_sp (function_block->GetBlockVariableList (true));
-
- const char *selfErrorString = "Stopped in a context claiming to capture an Objective-C object pointer, but 'self' isn't available; pretending we are in a generic context";
-
- if (!variable_list_sp)
- {
- err.SetErrorString(selfErrorString);
- return;
- }
-
- lldb::VariableSP self_variable_sp = variable_list_sp->FindVariable(ConstString("self"));
-
- if (!self_variable_sp ||
- !self_variable_sp->IsInScope(frame) ||
- !self_variable_sp->LocationIsValidForFrame (frame))
- {
- err.SetErrorString(selfErrorString);
- return;
- }
-
- Type *self_type = self_variable_sp->GetType();
-
- if (!self_type)
- {
- err.SetErrorString(selfErrorString);
- return;
- }
-
- ClangASTType self_clang_type = self_type->GetClangForwardType();
-
- if (!self_clang_type)
- {
- err.SetErrorString(selfErrorString);
- return;
- }
-
- if (self_clang_type.IsObjCClassType())
- {
- return;
- }
- else if (self_clang_type.IsObjCObjectPointerType())
- {
- m_in_objectivec_method = true;
- m_needs_object_ptr = true;
- }
- else
- {
- err.SetErrorString(selfErrorString);
- return;
- }
- }
- else
- {
- m_in_objectivec_method = true;
- m_needs_object_ptr = true;
- }
- }
- }
- }
-}
-
-void
-ClangUserExpression::InstallContext (ExecutionContext &exe_ctx)
-{
- m_process_wp = exe_ctx.GetProcessSP();
-
- lldb::StackFrameSP frame_sp = exe_ctx.GetFrameSP();
-
- if (frame_sp)
- m_address = frame_sp->GetFrameCodeAddress();
-}
-
-bool
-ClangUserExpression::LockAndCheckContext (ExecutionContext &exe_ctx,
- lldb::TargetSP &target_sp,
- lldb::ProcessSP &process_sp,
- lldb::StackFrameSP &frame_sp)
-{
- lldb::ProcessSP expected_process_sp = m_process_wp.lock();
- process_sp = exe_ctx.GetProcessSP();
-
- if (process_sp != expected_process_sp)
- return false;
-
- process_sp = exe_ctx.GetProcessSP();
- target_sp = exe_ctx.GetTargetSP();
- frame_sp = exe_ctx.GetFrameSP();
-
- if (m_address.IsValid())
- {
- if (!frame_sp)
- return false;
- else
- return (0 == Address::CompareLoadAddress(m_address, frame_sp->GetFrameCodeAddress(), target_sp.get()));
- }
-
- return true;
-}
-
-bool
-ClangUserExpression::MatchesContext (ExecutionContext &exe_ctx)
-{
- lldb::TargetSP target_sp;
- lldb::ProcessSP process_sp;
- lldb::StackFrameSP frame_sp;
-
- return LockAndCheckContext(exe_ctx, target_sp, process_sp, frame_sp);
-}
-
-// This is a really nasty hack, meant to fix Objective-C expressions of the form
-// (int)[myArray count]. Right now, because the type information for count is
-// not available, [myArray count] returns id, which can't be directly cast to
-// int without causing a clang error.
-static void
-ApplyObjcCastHack(std::string &expr)
-{
-#define OBJC_CAST_HACK_FROM "(int)["
-#define OBJC_CAST_HACK_TO "(int)(long long)["
-
- size_t from_offset;
-
- while ((from_offset = expr.find(OBJC_CAST_HACK_FROM)) != expr.npos)
- expr.replace(from_offset, sizeof(OBJC_CAST_HACK_FROM) - 1, OBJC_CAST_HACK_TO);
-
-#undef OBJC_CAST_HACK_TO
-#undef OBJC_CAST_HACK_FROM
-}
-
-// Another hack, meant to allow use of unichar despite it not being available in
-// the type information. Although we could special-case it in type lookup,
-// hopefully we'll figure out a way to #include the same environment as is
-// present in the original source file rather than try to hack specific type
-// definitions in as needed.
-//static void
-//ApplyUnicharHack(std::string &expr)
-//{
-//#define UNICHAR_HACK_FROM "unichar"
-//#define UNICHAR_HACK_TO "unsigned short"
-//
-// size_t from_offset;
-//
-// while ((from_offset = expr.find(UNICHAR_HACK_FROM)) != expr.npos)
-// expr.replace(from_offset, sizeof(UNICHAR_HACK_FROM) - 1, UNICHAR_HACK_TO);
-//
-//#undef UNICHAR_HACK_TO
-//#undef UNICHAR_HACK_FROM
-//}
-
-bool
-ClangUserExpression::Parse (Stream &error_stream,
- ExecutionContext &exe_ctx,
- lldb_private::ExecutionPolicy execution_policy,
- bool keep_result_in_memory,
- bool generate_debug_info)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-
- Error err;
-
- InstallContext(exe_ctx);
-
- ScanContext(exe_ctx, err);
-
- if (!err.Success())
- {
- error_stream.Printf("warning: %s\n", err.AsCString());
- }
-
- StreamString m_transformed_stream;
-
- ////////////////////////////////////
- // Generate the expression
- //
-
- ApplyObjcCastHack(m_expr_text);
- //ApplyUnicharHack(m_expr_text);
-
- std::string prefix = m_expr_prefix;
-
- if (ClangModulesDeclVendor *decl_vendor = m_target->GetClangModulesDeclVendor())
- {
- const ClangModulesDeclVendor::ModuleVector &hand_imported_modules = m_target->GetPersistentVariables().GetHandLoadedClangModules();
- ClangModulesDeclVendor::ModuleVector modules_for_macros;
-
- for (ClangModulesDeclVendor::ModuleID module : hand_imported_modules)
- {
- modules_for_macros.push_back(module);
- }
-
- if (m_target->GetEnableAutoImportClangModules())
- {
- if (StackFrame *frame = exe_ctx.GetFramePtr())
- {
- if (Block *block = frame->GetFrameBlock())
- {
- SymbolContext sc;
-
- block->CalculateSymbolContext(&sc);
-
- if (sc.comp_unit)
- {
- StreamString error_stream;
-
- decl_vendor->AddModulesForCompileUnit(*sc.comp_unit, modules_for_macros, error_stream);
- }
- }
- }
- }
- }
-
- std::unique_ptr<ExpressionSourceCode> source_code (ExpressionSourceCode::CreateWrapped(prefix.c_str(), m_expr_text.c_str()));
-
- lldb::LanguageType lang_type;
-
- if (m_in_cplusplus_method)
- lang_type = lldb::eLanguageTypeC_plus_plus;
- else if (m_in_objectivec_method)
- lang_type = lldb::eLanguageTypeObjC;
- else
- lang_type = lldb::eLanguageTypeC;
-
- if (!source_code->GetText(m_transformed_text, lang_type, m_const_object, m_in_static_method, exe_ctx))
- {
- error_stream.PutCString ("error: couldn't construct expression body");
- return false;
- }
-
- if (log)
- log->Printf("Parsing the following code:\n%s", m_transformed_text.c_str());
-
- ////////////////////////////////////
- // Set up the target and compiler
- //
-
- Target *target = exe_ctx.GetTargetPtr();
-
- if (!target)
- {
- error_stream.PutCString ("error: invalid target\n");
- return false;
- }
-
- //////////////////////////
- // Parse the expression
- //
-
- m_materializer_ap.reset(new Materializer());
-
- m_expr_decl_map.reset(new ClangExpressionDeclMap(keep_result_in_memory, exe_ctx));
-
- class OnExit
- {
- public:
- typedef std::function <void (void)> Callback;
-
- OnExit (Callback const &callback) :
- m_callback(callback)
- {
- }
-
- ~OnExit ()
- {
- m_callback();
- }
- private:
- Callback m_callback;
- };
-
- OnExit on_exit([this]() { m_expr_decl_map.reset(); });
-
- if (!m_expr_decl_map->WillParse(exe_ctx, m_materializer_ap.get()))
- {
- error_stream.PutCString ("error: current process state is unsuitable for expression parsing\n");
-
- m_expr_decl_map.reset(); // We are being careful here in the case of breakpoint conditions.
-
- return false;
- }
-
- Process *process = exe_ctx.GetProcessPtr();
- ExecutionContextScope *exe_scope = process;
-
- if (!exe_scope)
- exe_scope = exe_ctx.GetTargetPtr();
-
- ClangExpressionParser parser(exe_scope, *this, generate_debug_info);
-
- unsigned num_errors = parser.Parse (error_stream);
-
- if (num_errors)
- {
- error_stream.Printf ("error: %d errors parsing expression\n", num_errors);
-
- m_expr_decl_map.reset(); // We are being careful here in the case of breakpoint conditions.
-
- return false;
- }
-
- //////////////////////////////////////////////////////////////////////////////////////////
- // Prepare the output of the parser for execution, evaluating it statically if possible
- //
-
- Error jit_error = parser.PrepareForExecution (m_jit_start_addr,
- m_jit_end_addr,
- m_execution_unit_sp,
- exe_ctx,
- m_can_interpret,
- execution_policy);
-
- if (generate_debug_info)
- {
- lldb::ModuleSP jit_module_sp ( m_execution_unit_sp->GetJITModule());
-
- if (jit_module_sp)
- {
- ConstString const_func_name(FunctionName());
- FileSpec jit_file;
- jit_file.GetFilename() = const_func_name;
- jit_module_sp->SetFileSpecAndObjectName (jit_file, ConstString());
- m_jit_module_wp = jit_module_sp;
- target->GetImages().Append(jit_module_sp);
- }
-// lldb_private::ObjectFile *jit_obj_file = jit_module_sp->GetObjectFile();
-// StreamFile strm (stdout, false);
-// if (jit_obj_file)
-// {
-// jit_obj_file->GetSectionList();
-// jit_obj_file->GetSymtab();
-// jit_obj_file->Dump(&strm);
-// }
-// lldb_private::SymbolVendor *jit_sym_vendor = jit_module_sp->GetSymbolVendor();
-// if (jit_sym_vendor)
-// {
-// lldb_private::SymbolContextList sc_list;
-// jit_sym_vendor->FindFunctions(const_func_name, NULL, lldb::eFunctionNameTypeFull, true, false, sc_list);
-// sc_list.Dump(&strm, target);
-// jit_sym_vendor->Dump(&strm);
-// }
- }
-
- m_expr_decl_map.reset(); // Make this go away since we don't need any of its state after parsing. This also gets rid of any ClangASTImporter::Minions.
-
- if (jit_error.Success())
- {
- if (process && m_jit_start_addr != LLDB_INVALID_ADDRESS)
- m_jit_process_wp = lldb::ProcessWP(process->shared_from_this());
- return true;
- }
- else
- {
- const char *error_cstr = jit_error.AsCString();
- if (error_cstr && error_cstr[0])
- error_stream.Printf ("error: %s\n", error_cstr);
- else
- error_stream.Printf ("error: expression can't be interpreted or run\n");
- return false;
- }
-}
-
-static lldb::addr_t
-GetObjectPointer (lldb::StackFrameSP frame_sp,
- ConstString &object_name,
- Error &err)
-{
- err.Clear();
-
- if (!frame_sp)
- {
- err.SetErrorStringWithFormat("Couldn't load '%s' because the context is incomplete", object_name.AsCString());
- return LLDB_INVALID_ADDRESS;
- }
-
- lldb::VariableSP var_sp;
- lldb::ValueObjectSP valobj_sp;
-
- valobj_sp = frame_sp->GetValueForVariableExpressionPath(object_name.AsCString(),
- lldb::eNoDynamicValues,
- StackFrame::eExpressionPathOptionCheckPtrVsMember |
- StackFrame::eExpressionPathOptionsNoFragileObjcIvar |
- StackFrame::eExpressionPathOptionsNoSyntheticChildren |
- StackFrame::eExpressionPathOptionsNoSyntheticArrayRange,
- var_sp,
- err);
-
- if (!err.Success() || !valobj_sp.get())
- return LLDB_INVALID_ADDRESS;
-
- lldb::addr_t ret = valobj_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
-
- if (ret == LLDB_INVALID_ADDRESS)
- {
- err.SetErrorStringWithFormat("Couldn't load '%s' because its value couldn't be evaluated", object_name.AsCString());
- return LLDB_INVALID_ADDRESS;
- }
-
- return ret;
-}
-
-bool
-ClangUserExpression::PrepareToExecuteJITExpression (Stream &error_stream,
- ExecutionContext &exe_ctx,
- lldb::addr_t &struct_address,
- lldb::addr_t &object_ptr,
- lldb::addr_t &cmd_ptr)
-{
- lldb::TargetSP target;
- lldb::ProcessSP process;
- lldb::StackFrameSP frame;
-
- if (!LockAndCheckContext(exe_ctx,
- target,
- process,
- frame))
- {
- error_stream.Printf("The context has changed before we could JIT the expression!\n");
- return false;
- }
-
- if (m_jit_start_addr != LLDB_INVALID_ADDRESS || m_can_interpret)
- {
- if (m_needs_object_ptr)
- {
- ConstString object_name;
-
- if (m_in_cplusplus_method)
- {
- object_name.SetCString("this");
- }
- else if (m_in_objectivec_method)
- {
- object_name.SetCString("self");
- }
- else
- {
- error_stream.Printf("Need object pointer but don't know the language\n");
- return false;
- }
-
- Error object_ptr_error;
-
- object_ptr = GetObjectPointer(frame, object_name, object_ptr_error);
-
- if (!object_ptr_error.Success())
- {
- error_stream.Printf("warning: couldn't get required object pointer (substituting NULL): %s\n", object_ptr_error.AsCString());
- object_ptr = 0;
- }
-
- if (m_in_objectivec_method)
- {
- ConstString cmd_name("_cmd");
-
- cmd_ptr = GetObjectPointer(frame, cmd_name, object_ptr_error);
-
- if (!object_ptr_error.Success())
- {
- error_stream.Printf("warning: couldn't get cmd pointer (substituting NULL): %s\n", object_ptr_error.AsCString());
- cmd_ptr = 0;
- }
- }
- }
-
- if (m_materialized_address == LLDB_INVALID_ADDRESS)
- {
- Error alloc_error;
-
- IRMemoryMap::AllocationPolicy policy = m_can_interpret ? IRMemoryMap::eAllocationPolicyHostOnly : IRMemoryMap::eAllocationPolicyMirror;
-
- m_materialized_address = m_execution_unit_sp->Malloc(m_materializer_ap->GetStructByteSize(),
- m_materializer_ap->GetStructAlignment(),
- lldb::ePermissionsReadable | lldb::ePermissionsWritable,
- policy,
- alloc_error);
-
- if (!alloc_error.Success())
- {
- error_stream.Printf("Couldn't allocate space for materialized struct: %s\n", alloc_error.AsCString());
- return false;
- }
- }
-
- struct_address = m_materialized_address;
-
- if (m_can_interpret && m_stack_frame_bottom == LLDB_INVALID_ADDRESS)
- {
- Error alloc_error;
-
- const size_t stack_frame_size = 512 * 1024;
-
- m_stack_frame_bottom = m_execution_unit_sp->Malloc(stack_frame_size,
- 8,
- lldb::ePermissionsReadable | lldb::ePermissionsWritable,
- IRMemoryMap::eAllocationPolicyHostOnly,
- alloc_error);
-
- m_stack_frame_top = m_stack_frame_bottom + stack_frame_size;
-
- if (!alloc_error.Success())
- {
- error_stream.Printf("Couldn't allocate space for the stack frame: %s\n", alloc_error.AsCString());
- return false;
- }
- }
-
- Error materialize_error;
-
- m_dematerializer_sp = m_materializer_ap->Materialize(frame, *m_execution_unit_sp, struct_address, materialize_error);
-
- if (!materialize_error.Success())
- {
- error_stream.Printf("Couldn't materialize: %s\n", materialize_error.AsCString());
- return false;
- }
- }
- return true;
-}
-
-bool
-ClangUserExpression::FinalizeJITExecution (Stream &error_stream,
- ExecutionContext &exe_ctx,
- lldb::ClangExpressionVariableSP &result,
- lldb::addr_t function_stack_bottom,
- lldb::addr_t function_stack_top)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-
- if (log)
- log->Printf("-- [ClangUserExpression::FinalizeJITExecution] Dematerializing after execution --");
-
- if (!m_dematerializer_sp)
- {
- error_stream.Printf ("Couldn't apply expression side effects : no dematerializer is present");
- return false;
- }
-
- Error dematerialize_error;
-
- m_dematerializer_sp->Dematerialize(dematerialize_error, result, function_stack_bottom, function_stack_top);
-
- if (!dematerialize_error.Success())
- {
- error_stream.Printf ("Couldn't apply expression side effects : %s\n", dematerialize_error.AsCString("unknown error"));
- return false;
- }
-
- if (result)
- result->TransferAddress();
-
- m_dematerializer_sp.reset();
-
- return true;
-}
-
-lldb::ExpressionResults
-ClangUserExpression::Execute (Stream &error_stream,
- ExecutionContext &exe_ctx,
- const EvaluateExpressionOptions& options,
- lldb::ClangUserExpressionSP &shared_ptr_to_me,
- lldb::ClangExpressionVariableSP &result)
-{
- // The expression log is quite verbose, and if you're just tracking the execution of the
- // expression, it's quite convenient to have these logs come out with the STEP log as well.
- Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
-
- if (m_jit_start_addr != LLDB_INVALID_ADDRESS || m_can_interpret)
- {
- lldb::addr_t struct_address = LLDB_INVALID_ADDRESS;
-
- lldb::addr_t object_ptr = 0;
- lldb::addr_t cmd_ptr = 0;
-
- if (!PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr, cmd_ptr))
- {
- error_stream.Printf("Errored out in %s, couldn't PrepareToExecuteJITExpression", __FUNCTION__);
- return lldb::eExpressionSetupError;
- }
-
- lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS;
- lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS;
-
- if (m_can_interpret)
- {
- llvm::Module *module = m_execution_unit_sp->GetModule();
- llvm::Function *function = m_execution_unit_sp->GetFunction();
-
- if (!module || !function)
- {
- error_stream.Printf("Supposed to interpret, but nothing is there");
- return lldb::eExpressionSetupError;
- }
-
- Error interpreter_error;
-
- llvm::SmallVector <lldb::addr_t, 3> args;
-
- if (m_needs_object_ptr)
- {
- args.push_back(object_ptr);
-
- if (m_in_objectivec_method)
- args.push_back(cmd_ptr);
- }
-
- args.push_back(struct_address);
-
- 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);
-
- if (!interpreter_error.Success())
- {
- error_stream.Printf("Supposed to interpret, but failed: %s", interpreter_error.AsCString());
- return lldb::eExpressionDiscarded;
- }
- }
- else
- {
- if (!exe_ctx.HasThreadScope())
- {
- error_stream.Printf("ClangUserExpression::Execute called with no thread selected.");
- return lldb::eExpressionSetupError;
- }
-
- Address wrapper_address (m_jit_start_addr);
-
- llvm::SmallVector <lldb::addr_t, 3> args;
-
- if (m_needs_object_ptr) {
- args.push_back(object_ptr);
- if (m_in_objectivec_method)
- args.push_back(cmd_ptr);
- }
-
- args.push_back(struct_address);
-
- lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallUserExpression (exe_ctx.GetThreadRef(),
- wrapper_address,
- args,
- options,
- shared_ptr_to_me));
-
- if (!call_plan_sp || !call_plan_sp->ValidatePlan (&error_stream))
- return lldb::eExpressionSetupError;
-
- ThreadPlanCallUserExpression *user_expression_plan = static_cast<ThreadPlanCallUserExpression *>(call_plan_sp.get());
-
- lldb::addr_t function_stack_pointer = user_expression_plan->GetFunctionStackPointer();
-
- function_stack_bottom = function_stack_pointer - HostInfo::GetPageSize();
- function_stack_top = function_stack_pointer;
-
- if (log)
- log->Printf("-- [ClangUserExpression::Execute] Execution of expression begins --");
-
- if (exe_ctx.GetProcessPtr())
- exe_ctx.GetProcessPtr()->SetRunningUserExpression(true);
-
- lldb::ExpressionResults execution_result = exe_ctx.GetProcessRef().RunThreadPlan (exe_ctx,
- call_plan_sp,
- options,
- error_stream);
-
- if (exe_ctx.GetProcessPtr())
- exe_ctx.GetProcessPtr()->SetRunningUserExpression(false);
-
- if (log)
- log->Printf("-- [ClangUserExpression::Execute] Execution of expression completed --");
-
- if (execution_result == lldb::eExpressionInterrupted || execution_result == lldb::eExpressionHitBreakpoint)
- {
- const char *error_desc = NULL;
-
- if (call_plan_sp)
- {
- lldb::StopInfoSP real_stop_info_sp = call_plan_sp->GetRealStopInfo();
- if (real_stop_info_sp)
- error_desc = real_stop_info_sp->GetDescription();
- }
- if (error_desc)
- error_stream.Printf ("Execution was interrupted, reason: %s.", error_desc);
- else
- error_stream.PutCString ("Execution was interrupted.");
-
- if ((execution_result == lldb::eExpressionInterrupted && options.DoesUnwindOnError())
- || (execution_result == lldb::eExpressionHitBreakpoint && options.DoesIgnoreBreakpoints()))
- error_stream.PutCString ("\nThe process has been returned to the state before expression evaluation.");
- else
- {
- if (execution_result == lldb::eExpressionHitBreakpoint)
- user_expression_plan->TransferExpressionOwnership();
- error_stream.PutCString ("\nThe process has been left at the point where it was interrupted, "
- "use \"thread return -x\" to return to the state before expression evaluation.");
- }
-
- return execution_result;
- }
- else if (execution_result == lldb::eExpressionStoppedForDebug)
- {
- error_stream.PutCString ("Execution was halted at the first instruction of the expression "
- "function because \"debug\" was requested.\n"
- "Use \"thread return -x\" to return to the state before expression evaluation.");
- return execution_result;
- }
- else if (execution_result != lldb::eExpressionCompleted)
- {
- error_stream.Printf ("Couldn't execute function; result was %s\n", Process::ExecutionResultAsCString (execution_result));
- return execution_result;
- }
- }
-
- if (FinalizeJITExecution (error_stream, exe_ctx, result, function_stack_bottom, function_stack_top))
- {
- return lldb::eExpressionCompleted;
- }
- else
- {
- return lldb::eExpressionResultUnavailable;
- }
- }
- else
- {
- error_stream.Printf("Expression can't be run, because there is no JIT compiled function");
- return lldb::eExpressionSetupError;
- }
-}
-
-lldb::ExpressionResults
-ClangUserExpression::Evaluate (ExecutionContext &exe_ctx,
- const EvaluateExpressionOptions& options,
- const char *expr_cstr,
- const char *expr_prefix,
- lldb::ValueObjectSP &result_valobj_sp,
- Error &error)
-{
- Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
-
- lldb_private::ExecutionPolicy execution_policy = options.GetExecutionPolicy();
- const lldb::LanguageType language = options.GetLanguage();
- const ResultType desired_type = options.DoesCoerceToId() ? ClangUserExpression::eResultTypeId : ClangUserExpression::eResultTypeAny;
- lldb::ExpressionResults execution_results = lldb::eExpressionSetupError;
-
- Process *process = exe_ctx.GetProcessPtr();
-
- if (process == NULL || process->GetState() != lldb::eStateStopped)
- {
- if (execution_policy == eExecutionPolicyAlways)
- {
- if (log)
- log->Printf("== [ClangUserExpression::Evaluate] Expression may not run, but is not constant ==");
-
- error.SetErrorString ("expression needed to run but couldn't");
-
- return execution_results;
- }
- }
-
- if (process == NULL || !process->CanJIT())
- execution_policy = eExecutionPolicyNever;
-
- const char *full_prefix = NULL;
- const char *option_prefix = options.GetPrefix();
- std::string full_prefix_storage;
- if (expr_prefix && option_prefix)
- {
- full_prefix_storage.assign(expr_prefix);
- full_prefix_storage.append(option_prefix);
- if (!full_prefix_storage.empty())
- full_prefix = full_prefix_storage.c_str();
- }
- else if (expr_prefix)
- full_prefix = expr_prefix;
- else
- full_prefix = option_prefix;
-
- lldb::ClangUserExpressionSP user_expression_sp (new ClangUserExpression (expr_cstr, full_prefix, language, desired_type));
-
- StreamString error_stream;
-
- if (log)
- log->Printf("== [ClangUserExpression::Evaluate] Parsing expression %s ==", expr_cstr);
-
- const bool keep_expression_in_memory = true;
- const bool generate_debug_info = options.GetGenerateDebugInfo();
-
- if (options.InvokeCancelCallback (lldb::eExpressionEvaluationParse))
- {
- error.SetErrorString ("expression interrupted by callback before parse");
- result_valobj_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(), error);
- return lldb::eExpressionInterrupted;
- }
-
- if (!user_expression_sp->Parse (error_stream,
- exe_ctx,
- execution_policy,
- keep_expression_in_memory,
- generate_debug_info))
- {
- execution_results = lldb::eExpressionParseError;
- if (error_stream.GetString().empty())
- error.SetExpressionError (execution_results, "expression failed to parse, unknown error");
- else
- error.SetExpressionError (execution_results, error_stream.GetString().c_str());
- }
- else
- {
- lldb::ClangExpressionVariableSP expr_result;
-
- if (execution_policy == eExecutionPolicyNever &&
- !user_expression_sp->CanInterpret())
- {
- if (log)
- log->Printf("== [ClangUserExpression::Evaluate] Expression may not run, but is not constant ==");
-
- if (error_stream.GetString().empty())
- error.SetExpressionError (lldb::eExpressionSetupError, "expression needed to run but couldn't");
- }
- else
- {
- if (options.InvokeCancelCallback (lldb::eExpressionEvaluationExecution))
- {
- error.SetExpressionError (lldb::eExpressionInterrupted, "expression interrupted by callback before execution");
- result_valobj_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(), error);
- return lldb::eExpressionInterrupted;
- }
-
- error_stream.GetString().clear();
-
- if (log)
- log->Printf("== [ClangUserExpression::Evaluate] Executing expression ==");
-
- execution_results = user_expression_sp->Execute (error_stream,
- exe_ctx,
- options,
- user_expression_sp,
- expr_result);
-
- if (options.GetResultIsInternal() && expr_result && process)
- {
- process->GetTarget().GetPersistentVariables().RemovePersistentVariable (expr_result);
- }
-
- if (execution_results != lldb::eExpressionCompleted)
- {
- if (log)
- log->Printf("== [ClangUserExpression::Evaluate] Execution completed abnormally ==");
-
- if (error_stream.GetString().empty())
- error.SetExpressionError (execution_results, "expression failed to execute, unknown error");
- else
- error.SetExpressionError (execution_results, error_stream.GetString().c_str());
- }
- else
- {
- if (expr_result)
- {
- result_valobj_sp = expr_result->GetValueObject();
-
- if (log)
- log->Printf("== [ClangUserExpression::Evaluate] Execution completed normally with result %s ==",
- result_valobj_sp->GetValueAsCString());
- }
- else
- {
- if (log)
- log->Printf("== [ClangUserExpression::Evaluate] Execution completed normally with no result ==");
-
- error.SetError(ClangUserExpression::kNoResult, lldb::eErrorTypeGeneric);
- }
- }
- }
- }
-
- if (options.InvokeCancelCallback(lldb::eExpressionEvaluationComplete))
- {
- error.SetExpressionError (lldb::eExpressionInterrupted, "expression interrupted by callback after complete");
- return lldb::eExpressionInterrupted;
- }
-
- if (result_valobj_sp.get() == NULL)
- {
- result_valobj_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(), error);
- }
-
- return execution_results;
-}
diff --git a/source/Expression/DWARFExpression.cpp b/source/Expression/DWARFExpression.cpp
index 9307c84510b0..ebcc28460395 100644
--- a/source/Expression/DWARFExpression.cpp
+++ b/source/Expression/DWARFExpression.cpp
@@ -24,8 +24,8 @@
#include "lldb/Core/Value.h"
#include "lldb/Core/VMRange.h"
-#include "lldb/Expression/ClangExpressionDeclMap.h"
-#include "lldb/Expression/ClangExpressionVariable.h"
+#include "Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h"
+#include "Plugins/ExpressionParser/Clang/ClangExpressionVariable.h"
#include "lldb/Host/Endian.h"
#include "lldb/Host/Host.h"
@@ -38,190 +38,27 @@
#include "lldb/Target/StackID.h"
#include "lldb/Target/Thread.h"
+#include "Plugins/SymbolFile/DWARF/DWARFCompileUnit.h"
+
using namespace lldb;
using namespace lldb_private;
-// TODO- why is this also defined (in a better way) in DWARFDefines.cpp?
-const char *
-DW_OP_value_to_name (uint32_t val)
+static lldb::addr_t
+ReadAddressFromDebugAddrSection(const DWARFCompileUnit* dwarf_cu, uint32_t index)
{
- static char invalid[100];
- switch (val) {
- case 0x03: return "DW_OP_addr";
- case 0x06: return "DW_OP_deref";
- case 0x08: return "DW_OP_const1u";
- case 0x09: return "DW_OP_const1s";
- case 0x0a: return "DW_OP_const2u";
- case 0x0b: return "DW_OP_const2s";
- case 0x0c: return "DW_OP_const4u";
- case 0x0d: return "DW_OP_const4s";
- case 0x0e: return "DW_OP_const8u";
- case 0x0f: return "DW_OP_const8s";
- case 0x10: return "DW_OP_constu";
- case 0x11: return "DW_OP_consts";
- case 0x12: return "DW_OP_dup";
- case 0x13: return "DW_OP_drop";
- case 0x14: return "DW_OP_over";
- case 0x15: return "DW_OP_pick";
- case 0x16: return "DW_OP_swap";
- case 0x17: return "DW_OP_rot";
- case 0x18: return "DW_OP_xderef";
- case 0x19: return "DW_OP_abs";
- case 0x1a: return "DW_OP_and";
- case 0x1b: return "DW_OP_div";
- case 0x1c: return "DW_OP_minus";
- case 0x1d: return "DW_OP_mod";
- case 0x1e: return "DW_OP_mul";
- case 0x1f: return "DW_OP_neg";
- case 0x20: return "DW_OP_not";
- case 0x21: return "DW_OP_or";
- case 0x22: return "DW_OP_plus";
- case 0x23: return "DW_OP_plus_uconst";
- case 0x24: return "DW_OP_shl";
- case 0x25: return "DW_OP_shr";
- case 0x26: return "DW_OP_shra";
- case 0x27: return "DW_OP_xor";
- case 0x2f: return "DW_OP_skip";
- case 0x28: return "DW_OP_bra";
- case 0x29: return "DW_OP_eq";
- case 0x2a: return "DW_OP_ge";
- case 0x2b: return "DW_OP_gt";
- case 0x2c: return "DW_OP_le";
- case 0x2d: return "DW_OP_lt";
- case 0x2e: return "DW_OP_ne";
- case 0x30: return "DW_OP_lit0";
- case 0x31: return "DW_OP_lit1";
- case 0x32: return "DW_OP_lit2";
- case 0x33: return "DW_OP_lit3";
- case 0x34: return "DW_OP_lit4";
- case 0x35: return "DW_OP_lit5";
- case 0x36: return "DW_OP_lit6";
- case 0x37: return "DW_OP_lit7";
- case 0x38: return "DW_OP_lit8";
- case 0x39: return "DW_OP_lit9";
- case 0x3a: return "DW_OP_lit10";
- case 0x3b: return "DW_OP_lit11";
- case 0x3c: return "DW_OP_lit12";
- case 0x3d: return "DW_OP_lit13";
- case 0x3e: return "DW_OP_lit14";
- case 0x3f: return "DW_OP_lit15";
- case 0x40: return "DW_OP_lit16";
- case 0x41: return "DW_OP_lit17";
- case 0x42: return "DW_OP_lit18";
- case 0x43: return "DW_OP_lit19";
- case 0x44: return "DW_OP_lit20";
- case 0x45: return "DW_OP_lit21";
- case 0x46: return "DW_OP_lit22";
- case 0x47: return "DW_OP_lit23";
- case 0x48: return "DW_OP_lit24";
- case 0x49: return "DW_OP_lit25";
- case 0x4a: return "DW_OP_lit26";
- case 0x4b: return "DW_OP_lit27";
- case 0x4c: return "DW_OP_lit28";
- case 0x4d: return "DW_OP_lit29";
- case 0x4e: return "DW_OP_lit30";
- case 0x4f: return "DW_OP_lit31";
- case 0x50: return "DW_OP_reg0";
- case 0x51: return "DW_OP_reg1";
- case 0x52: return "DW_OP_reg2";
- case 0x53: return "DW_OP_reg3";
- case 0x54: return "DW_OP_reg4";
- case 0x55: return "DW_OP_reg5";
- case 0x56: return "DW_OP_reg6";
- case 0x57: return "DW_OP_reg7";
- case 0x58: return "DW_OP_reg8";
- case 0x59: return "DW_OP_reg9";
- case 0x5a: return "DW_OP_reg10";
- case 0x5b: return "DW_OP_reg11";
- case 0x5c: return "DW_OP_reg12";
- case 0x5d: return "DW_OP_reg13";
- case 0x5e: return "DW_OP_reg14";
- case 0x5f: return "DW_OP_reg15";
- case 0x60: return "DW_OP_reg16";
- case 0x61: return "DW_OP_reg17";
- case 0x62: return "DW_OP_reg18";
- case 0x63: return "DW_OP_reg19";
- case 0x64: return "DW_OP_reg20";
- case 0x65: return "DW_OP_reg21";
- case 0x66: return "DW_OP_reg22";
- case 0x67: return "DW_OP_reg23";
- case 0x68: return "DW_OP_reg24";
- case 0x69: return "DW_OP_reg25";
- case 0x6a: return "DW_OP_reg26";
- case 0x6b: return "DW_OP_reg27";
- case 0x6c: return "DW_OP_reg28";
- case 0x6d: return "DW_OP_reg29";
- case 0x6e: return "DW_OP_reg30";
- case 0x6f: return "DW_OP_reg31";
- case 0x70: return "DW_OP_breg0";
- case 0x71: return "DW_OP_breg1";
- case 0x72: return "DW_OP_breg2";
- case 0x73: return "DW_OP_breg3";
- case 0x74: return "DW_OP_breg4";
- case 0x75: return "DW_OP_breg5";
- case 0x76: return "DW_OP_breg6";
- case 0x77: return "DW_OP_breg7";
- case 0x78: return "DW_OP_breg8";
- case 0x79: return "DW_OP_breg9";
- case 0x7a: return "DW_OP_breg10";
- case 0x7b: return "DW_OP_breg11";
- case 0x7c: return "DW_OP_breg12";
- case 0x7d: return "DW_OP_breg13";
- case 0x7e: return "DW_OP_breg14";
- case 0x7f: return "DW_OP_breg15";
- case 0x80: return "DW_OP_breg16";
- case 0x81: return "DW_OP_breg17";
- case 0x82: return "DW_OP_breg18";
- case 0x83: return "DW_OP_breg19";
- case 0x84: return "DW_OP_breg20";
- case 0x85: return "DW_OP_breg21";
- case 0x86: return "DW_OP_breg22";
- case 0x87: return "DW_OP_breg23";
- case 0x88: return "DW_OP_breg24";
- case 0x89: return "DW_OP_breg25";
- case 0x8a: return "DW_OP_breg26";
- case 0x8b: return "DW_OP_breg27";
- case 0x8c: return "DW_OP_breg28";
- case 0x8d: return "DW_OP_breg29";
- case 0x8e: return "DW_OP_breg30";
- case 0x8f: return "DW_OP_breg31";
- case 0x90: return "DW_OP_regx";
- case 0x91: return "DW_OP_fbreg";
- case 0x92: return "DW_OP_bregx";
- case 0x93: return "DW_OP_piece";
- case 0x94: return "DW_OP_deref_size";
- case 0x95: return "DW_OP_xderef_size";
- case 0x96: return "DW_OP_nop";
- case 0x97: return "DW_OP_push_object_address";
- case 0x98: return "DW_OP_call2";
- case 0x99: return "DW_OP_call4";
- case 0x9a: return "DW_OP_call_ref";
-// case DW_OP_APPLE_array_ref: return "DW_OP_APPLE_array_ref";
-// case DW_OP_APPLE_extern: return "DW_OP_APPLE_extern";
- case DW_OP_APPLE_uninit: return "DW_OP_APPLE_uninit";
-// case DW_OP_APPLE_assign: return "DW_OP_APPLE_assign";
-// case DW_OP_APPLE_address_of: return "DW_OP_APPLE_address_of";
-// case DW_OP_APPLE_value_of: return "DW_OP_APPLE_value_of";
-// case DW_OP_APPLE_deref_type: return "DW_OP_APPLE_deref_type";
-// case DW_OP_APPLE_expr_local: return "DW_OP_APPLE_expr_local";
-// case DW_OP_APPLE_constf: return "DW_OP_APPLE_constf";
-// case DW_OP_APPLE_scalar_cast: return "DW_OP_APPLE_scalar_cast";
-// case DW_OP_APPLE_clang_cast: return "DW_OP_APPLE_clang_cast";
-// case DW_OP_APPLE_clear: return "DW_OP_APPLE_clear";
-// case DW_OP_APPLE_error: return "DW_OP_APPLE_error";
- default:
- snprintf (invalid, sizeof(invalid), "Unknown DW_OP constant: 0x%x", val);
- return invalid;
- }
+ 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);
}
-
//----------------------------------------------------------------------
// DWARFExpression constructor
//----------------------------------------------------------------------
-DWARFExpression::DWARFExpression() :
+DWARFExpression::DWARFExpression(DWARFCompileUnit* dwarf_cu) :
m_module_wp(),
m_data(),
+ m_dwarf_cu(dwarf_cu),
m_reg_kind (eRegisterKindDWARF),
m_loclist_slide (LLDB_INVALID_ADDRESS)
{
@@ -230,15 +67,21 @@ DWARFExpression::DWARFExpression() :
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, lldb::offset_t data_offset, lldb::offset_t data_length) :
+DWARFExpression::DWARFExpression(lldb::ModuleSP module_sp,
+ const DataExtractor& data,
+ DWARFCompileUnit* dwarf_cu,
+ lldb::offset_t data_offset,
+ lldb::offset_t data_length) :
m_module_wp(),
m_data(data, data_offset, data_length),
+ m_dwarf_cu(dwarf_cu),
m_reg_kind (eRegisterKindDWARF),
m_loclist_slide(LLDB_INVALID_ADDRESS)
{
@@ -624,6 +467,12 @@ DWARFExpression::DumpLocation (Stream *s, lldb::offset_t offset, lldb::offset_t
case DW_OP_form_tls_address:
s->PutCString("DW_OP_form_tls_address"); // 0x9b
break;
+ case DW_OP_GNU_addr_index: // 0xfb
+ s->Printf("DW_OP_GNU_addr_index(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));
+ break;
case DW_OP_GNU_push_tls_address:
s->PutCString("DW_OP_GNU_push_tls_address"); // 0xe0
break;
@@ -709,8 +558,14 @@ DWARFExpression::GetDescription (Stream *s, lldb::DescriptionLevel level, addr_t
addr_t curr_base_addr = location_list_base_addr;
while (m_data.ValidOffset(offset))
{
- lldb::addr_t begin_addr_offset = m_data.GetAddress(&offset);
- lldb::addr_t end_addr_offset = m_data.GetAddress(&offset);
+ addr_t begin_addr_offset = LLDB_INVALID_ADDRESS;
+ addr_t end_addr_offset = LLDB_INVALID_ADDRESS;
+ if (!AddressRangeForLocationListEntry(m_dwarf_cu, m_data, &offset, begin_addr_offset, end_addr_offset))
+ break;
+
+ if (begin_addr_offset == 0 && end_addr_offset == 0)
+ break;
+
if (begin_addr_offset < end_addr_offset)
{
if (count > 0)
@@ -723,11 +578,6 @@ DWARFExpression::GetDescription (Stream *s, lldb::DescriptionLevel level, addr_t
s->PutChar('}');
offset += location_length;
}
- else if (begin_addr_offset == 0 && end_addr_offset == 0)
- {
- // The end of the location list is marked by both the start and end offset being zero
- break;
- }
else
{
if ((m_data.GetAddressByteSize() == 4 && (begin_addr_offset == UINT32_MAX)) ||
@@ -1027,8 +877,10 @@ GetOpcodeDataSize (const DataExtractor &data, const lldb::offset_t data_offset,
case DW_OP_regx: // 0x90 1 ULEB128 register
case DW_OP_fbreg: // 0x91 1 SLEB128 offset
case DW_OP_piece: // 0x93 1 ULEB128 size of piece addressed
+ case DW_OP_GNU_addr_index: // 0xfb 1 ULEB128 index
+ case DW_OP_GNU_const_index: // 0xfc 1 ULEB128 index
data.Skip_LEB128(&offset);
- return offset - data_offset;
+ return offset - data_offset;
// All opcodes that have a 2 ULEB (signed or unsigned) arguments
case DW_OP_bregx: // 0x92 2 ULEB128 register followed by SLEB128 offset
@@ -1070,6 +922,22 @@ DWARFExpression::GetLocation_DW_OP_addr (uint32_t op_addr_idx, bool &error) cons
else
++curr_op_addr_idx;
}
+ else if (op == DW_OP_GNU_addr_index)
+ {
+ uint64_t index = m_data.GetULEB128(&offset);
+ if (curr_op_addr_idx == op_addr_idx)
+ {
+ if (!m_dwarf_cu)
+ {
+ error = true;
+ break;
+ }
+
+ return ReadAddressFromDebugAddrSection(m_dwarf_cu, index);
+ }
+ else
+ ++curr_op_addr_idx;
+ }
else
{
const offset_t op_arg_size = GetOpcodeDataSize (m_data, offset, op);
@@ -1104,7 +972,7 @@ DWARFExpression::Update_DW_OP_addr (lldb::addr_t file_addr)
// So first we copy the data into a heap buffer
std::unique_ptr<DataBufferHeap> head_data_ap (new DataBufferHeap (m_data.GetDataStart(),
- m_data.GetByteSize()));
+ m_data.GetByteSize()));
// Make en encoder so we can write the address into the buffer using
// the correct byte order (endianness)
@@ -1150,20 +1018,21 @@ DWARFExpression::LocationListContainsAddress (lldb::addr_t loclist_base_addr, ll
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);
+ addr_t lo_pc = LLDB_INVALID_ADDRESS;
+ addr_t hi_pc = LLDB_INVALID_ADDRESS;
+ if (!AddressRangeForLocationListEntry(m_dwarf_cu, m_data, &offset, lo_pc, hi_pc))
+ break;
+
if (lo_pc == 0 && hi_pc == 0)
break;
- else
- {
- lo_pc += loclist_base_addr - m_loclist_slide;
- hi_pc += loclist_base_addr - m_loclist_slide;
- if (lo_pc <= addr && addr < hi_pc)
- return true;
+ lo_pc += loclist_base_addr - m_loclist_slide;
+ hi_pc += loclist_base_addr - m_loclist_slide;
- offset += m_data.GetU16(&offset);
- }
+ if (lo_pc <= addr && addr < hi_pc)
+ return true;
+
+ offset += m_data.GetU16(&offset);
}
}
return false;
@@ -1186,24 +1055,23 @@ DWARFExpression::GetLocation (addr_t base_addr, addr_t pc, lldb::offset_t &offse
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);
+ addr_t lo_pc = LLDB_INVALID_ADDRESS;
+ addr_t hi_pc = LLDB_INVALID_ADDRESS;
+ if (!AddressRangeForLocationListEntry(m_dwarf_cu, m_data, &offset, lo_pc, hi_pc))
+ break;
+
if (lo_pc == 0 && hi_pc == 0)
- {
break;
- }
- else
- {
- lo_pc += curr_base_addr - m_loclist_slide;
- hi_pc += curr_base_addr - m_loclist_slide;
-
- length = m_data.GetU16(&offset);
-
- if (length > 0 && lo_pc <= pc && pc < hi_pc)
- return true;
- offset += length;
- }
+ lo_pc += curr_base_addr - m_loclist_slide;
+ hi_pc += curr_base_addr - m_loclist_slide;
+
+ length = m_data.GetU16(&offset);
+
+ if (length > 0 && lo_pc <= pc && pc < hi_pc)
+ return true;
+
+ offset += length;
}
}
offset = LLDB_INVALID_OFFSET;
@@ -1295,25 +1163,36 @@ DWARFExpression::Evaluate
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);
+ addr_t lo_pc = LLDB_INVALID_ADDRESS;
+ addr_t hi_pc = LLDB_INVALID_ADDRESS;
+ if (!AddressRangeForLocationListEntry(m_dwarf_cu, m_data, &offset, lo_pc, hi_pc))
+ break;
+
if (lo_pc == 0 && hi_pc == 0)
- {
break;
- }
- else
- {
- lo_pc += curr_loclist_base_load_addr - m_loclist_slide;
- hi_pc += curr_loclist_base_load_addr - m_loclist_slide;
- uint16_t length = m_data.GetU16(&offset);
+ lo_pc += curr_loclist_base_load_addr - m_loclist_slide;
+ hi_pc += curr_loclist_base_load_addr - m_loclist_slide;
- if (length > 0 && lo_pc <= pc && pc < hi_pc)
- {
- return DWARFExpression::Evaluate (exe_ctx, expr_locals, decl_map, reg_ctx, module_sp, m_data, offset, length, m_reg_kind, initial_value_ptr, result, error_ptr);
- }
- offset += length;
+ uint16_t length = m_data.GetU16(&offset);
+
+ if (length > 0 && lo_pc <= pc && pc < hi_pc)
+ {
+ return DWARFExpression::Evaluate (exe_ctx,
+ expr_locals,
+ decl_map,
+ reg_ctx,
+ module_sp,
+ m_data,
+ m_dwarf_cu,
+ offset,
+ length,
+ m_reg_kind,
+ initial_value_ptr,
+ result,
+ error_ptr);
}
+ offset += length;
}
}
if (error_ptr)
@@ -1322,7 +1201,19 @@ DWARFExpression::Evaluate
}
// Not a location list, just a single expression.
- return DWARFExpression::Evaluate (exe_ctx, expr_locals, decl_map, reg_ctx, module_sp, m_data, 0, m_data.GetByteSize(), m_reg_kind, initial_value_ptr, result, error_ptr);
+ return DWARFExpression::Evaluate (exe_ctx,
+ expr_locals,
+ decl_map,
+ reg_ctx,
+ module_sp,
+ m_data,
+ m_dwarf_cu,
+ 0,
+ m_data.GetByteSize(),
+ m_reg_kind,
+ initial_value_ptr,
+ result,
+ error_ptr);
}
@@ -1336,6 +1227,7 @@ DWARFExpression::Evaluate
RegisterContext *reg_ctx,
lldb::ModuleSP module_sp,
const DataExtractor& opcodes,
+ DWARFCompileUnit* dwarf_cu,
const lldb::offset_t opcodes_offset,
const lldb::offset_t opcodes_length,
const lldb::RegisterKind reg_kind,
@@ -2711,7 +2603,7 @@ DWARFExpression::Evaluate
return false;
}
}
- else if (!stack.empty())
+ else
{
// If this is the second or later piece there should be a value on the stack
if (pieces.GetBuffer().GetByteSize() != op_piece_offset)
@@ -2950,6 +2842,69 @@ DWARFExpression::Evaluate
}
break;
+ //----------------------------------------------------------------------
+ // OPCODE: DW_OP_GNU_addr_index
+ // 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_GNU_addr_index:
+ {
+ if (!dwarf_cu)
+ {
+ if (error_ptr)
+ error_ptr->SetErrorString ("DW_OP_GNU_addr_index found without a compile unit being specified");
+ 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);
+ 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
+ // DESCRIPTION: Pushes an constant with the size of a machine 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_GNU_const_index:
+ {
+ if (!dwarf_cu)
+ {
+ if (error_ptr)
+ error_ptr->SetErrorString ("DW_OP_GNU_const_index found without a compile unit being specified");
+ 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;
+ }
+ }
+ break;
+
default:
if (log)
log->Printf("Unhandled opcode %s in DWARFExpression.", DW_OP_value_to_name(op));
@@ -2990,3 +2945,255 @@ DWARFExpression::Evaluate
return true; // Return true on success
}
+size_t
+DWARFExpression::LocationListSize(const DWARFCompileUnit* dwarf_cu,
+ const DataExtractor& debug_loc_data,
+ lldb::offset_t offset)
+{
+ const lldb::offset_t debug_loc_offset = offset;
+ while (debug_loc_data.ValidOffset(offset))
+ {
+ lldb::addr_t start_addr = LLDB_INVALID_ADDRESS;
+ lldb::addr_t end_addr = LLDB_INVALID_ADDRESS;
+ if (!AddressRangeForLocationListEntry(dwarf_cu, debug_loc_data, &offset, start_addr, end_addr))
+ break;
+
+ if (start_addr == 0 && end_addr == 0)
+ break;
+
+ uint16_t loc_length = debug_loc_data.GetU16(&offset);
+ offset += loc_length;
+ }
+
+ if (offset > debug_loc_offset)
+ return offset - debug_loc_offset;
+ return 0;
+}
+
+bool
+DWARFExpression::AddressRangeForLocationListEntry(const DWARFCompileUnit* dwarf_cu,
+ const DataExtractor& debug_loc_data,
+ lldb::offset_t* offset_ptr,
+ lldb::addr_t& low_pc,
+ lldb::addr_t& high_pc)
+{
+ if (!debug_loc_data.ValidOffset(*offset_ptr))
+ return false;
+
+ switch (dwarf_cu->GetSymbolFileDWARF()->GetLocationListFormat())
+ {
+ case NonLocationList:
+ return false;
+ case RegularLocationList:
+ low_pc = debug_loc_data.GetAddress(offset_ptr);
+ high_pc = debug_loc_data.GetAddress(offset_ptr);
+ return true;
+ case SplitDwarfLocationList:
+ switch (debug_loc_data.GetU8(offset_ptr))
+ {
+ case DW_LLE_end_of_list_entry:
+ return false;
+ case DW_LLE_start_end_entry:
+ {
+ uint64_t index = debug_loc_data.GetULEB128(offset_ptr);
+ low_pc = ReadAddressFromDebugAddrSection(dwarf_cu, index);
+ index = debug_loc_data.GetULEB128(offset_ptr);
+ high_pc = ReadAddressFromDebugAddrSection(dwarf_cu, index);
+ return true;
+ }
+ case DW_LLE_start_length_entry:
+ {
+ uint64_t index = debug_loc_data.GetULEB128(offset_ptr);
+ low_pc = ReadAddressFromDebugAddrSection(dwarf_cu, index);
+ uint32_t length = debug_loc_data.GetU32(offset_ptr);
+ high_pc = low_pc + length;
+ return true;
+ }
+ default:
+ // Not supported entry type
+ return false;
+ }
+ }
+ assert (false && "Not supported location list type");
+ return false;
+}
+
+static bool
+print_dwarf_exp_op (Stream &s,
+ const DataExtractor& data,
+ lldb::offset_t *offset_ptr,
+ int address_size,
+ int dwarf_ref_size)
+{
+ uint8_t opcode = data.GetU8(offset_ptr);
+ DRC_class opcode_class;
+ uint64_t uint;
+ int64_t sint;
+
+ int size;
+
+ opcode_class = DW_OP_value_to_class (opcode) & (~DRC_DWARFv3);
+
+ s.Printf("%s ", DW_OP_value_to_name (opcode));
+
+ /* Does this take zero parameters? If so we can shortcut this function. */
+ if (opcode_class == DRC_ZEROOPERANDS)
+ return true;
+
+ if (opcode_class == DRC_TWOOPERANDS && opcode == DW_OP_bregx)
+ {
+ uint = data.GetULEB128(offset_ptr);
+ sint = data.GetSLEB128(offset_ptr);
+ s.Printf("%" PRIu64 " %" PRIi64, uint, sint);
+ return true;
+ }
+ if (opcode_class != DRC_ONEOPERAND)
+ {
+ s.Printf("UNKNOWN OP %u", opcode);
+ return false;
+ }
+
+ switch (opcode)
+ {
+ case DW_OP_addr: size = address_size; break;
+ case DW_OP_const1u: size = 1; break;
+ case DW_OP_const1s: size = -1; break;
+ case DW_OP_const2u: size = 2; break;
+ case DW_OP_const2s: size = -2; break;
+ case DW_OP_const4u: size = 4; break;
+ case DW_OP_const4s: size = -4; break;
+ case DW_OP_const8u: size = 8; break;
+ case DW_OP_const8s: size = -8; break;
+ case DW_OP_constu: size = 128; break;
+ case DW_OP_consts: size = -128; break;
+ case DW_OP_fbreg: size = -128; break;
+ case DW_OP_breg0:
+ case DW_OP_breg1:
+ case DW_OP_breg2:
+ case DW_OP_breg3:
+ case DW_OP_breg4:
+ case DW_OP_breg5:
+ case DW_OP_breg6:
+ case DW_OP_breg7:
+ case DW_OP_breg8:
+ case DW_OP_breg9:
+ case DW_OP_breg10:
+ case DW_OP_breg11:
+ case DW_OP_breg12:
+ case DW_OP_breg13:
+ case DW_OP_breg14:
+ case DW_OP_breg15:
+ case DW_OP_breg16:
+ case DW_OP_breg17:
+ case DW_OP_breg18:
+ case DW_OP_breg19:
+ case DW_OP_breg20:
+ case DW_OP_breg21:
+ case DW_OP_breg22:
+ case DW_OP_breg23:
+ case DW_OP_breg24:
+ case DW_OP_breg25:
+ case DW_OP_breg26:
+ case DW_OP_breg27:
+ case DW_OP_breg28:
+ case DW_OP_breg29:
+ case DW_OP_breg30:
+ case DW_OP_breg31:
+ size = -128; break;
+ case DW_OP_pick:
+ case DW_OP_deref_size:
+ case DW_OP_xderef_size:
+ size = 1; break;
+ case DW_OP_skip:
+ case DW_OP_bra:
+ size = -2; break;
+ case DW_OP_call2:
+ size = 2; break;
+ case DW_OP_call4:
+ size = 4; break;
+ case DW_OP_call_ref:
+ size = dwarf_ref_size; break;
+ case DW_OP_piece:
+ case DW_OP_plus_uconst:
+ case DW_OP_regx:
+ case DW_OP_GNU_addr_index:
+ case DW_OP_GNU_const_index:
+ size = 128; break;
+ default:
+ s.Printf("UNKNOWN ONE-OPERAND OPCODE, #%u", opcode);
+ return true;
+ }
+
+ switch (size)
+ {
+ case -1: sint = (int8_t) data.GetU8(offset_ptr); s.Printf("%+" PRIi64, sint); break;
+ case -2: sint = (int16_t) data.GetU16(offset_ptr); s.Printf("%+" PRIi64, sint); break;
+ case -4: sint = (int32_t) data.GetU32(offset_ptr); s.Printf("%+" PRIi64, sint); break;
+ case -8: sint = (int64_t) data.GetU64(offset_ptr); s.Printf("%+" PRIi64, sint); break;
+ case -128: sint = data.GetSLEB128(offset_ptr); s.Printf("%+" PRIi64, sint); break;
+ case 1: uint = data.GetU8(offset_ptr); s.Printf("0x%2.2" PRIx64, uint); break;
+ case 2: uint = data.GetU16(offset_ptr); s.Printf("0x%4.4" PRIx64, uint); break;
+ case 4: uint = data.GetU32(offset_ptr); s.Printf("0x%8.8" PRIx64, uint); break;
+ case 8: uint = data.GetU64(offset_ptr); s.Printf("0x%16.16" PRIx64, uint); break;
+ case 128: uint = data.GetULEB128(offset_ptr); s.Printf("0x%" PRIx64, uint); break;
+ }
+
+ return false;
+}
+
+bool
+DWARFExpression::PrintDWARFExpression(Stream &s,
+ const DataExtractor& data,
+ int address_size,
+ int dwarf_ref_size,
+ bool location_expression)
+{
+ int op_count = 0;
+ lldb::offset_t offset = 0;
+ while (data.ValidOffset(offset))
+ {
+ if (location_expression && op_count > 0)
+ return false;
+ if (op_count > 0)
+ s.PutCString(", ");
+ if (!print_dwarf_exp_op (s, data, &offset, address_size, dwarf_ref_size))
+ return false;
+ op_count++;
+ }
+
+ return true;
+}
+
+void
+DWARFExpression::PrintDWARFLocationList(Stream &s,
+ const DWARFCompileUnit* cu,
+ const DataExtractor& debug_loc_data,
+ lldb::offset_t offset)
+{
+ uint64_t start_addr, end_addr;
+ uint32_t addr_size = DWARFCompileUnit::GetAddressByteSize(cu);
+ s.SetAddressByteSize(DWARFCompileUnit::GetAddressByteSize(cu));
+ dw_addr_t base_addr = cu ? cu->GetBaseAddress() : 0;
+ while (debug_loc_data.ValidOffset(offset))
+ {
+ start_addr = debug_loc_data.GetMaxU64(&offset,addr_size);
+ end_addr = debug_loc_data.GetMaxU64(&offset,addr_size);
+
+ if (start_addr == 0 && end_addr == 0)
+ break;
+
+ s.PutCString("\n ");
+ s.Indent();
+ if (cu)
+ s.AddressRange (start_addr + base_addr,
+ end_addr + base_addr,
+ cu->GetAddressByteSize(),
+ NULL,
+ ": ");
+ uint32_t loc_length = debug_loc_data.GetU16(&offset);
+
+ DataExtractor locationData(debug_loc_data, offset, loc_length);
+ PrintDWARFExpression (s, locationData, addr_size, 4, false);
+ offset += loc_length;
+ }
+}
diff --git a/source/Expression/Expression.cpp b/source/Expression/Expression.cpp
new file mode 100644
index 000000000000..e5dd9c03db7d
--- /dev/null
+++ b/source/Expression/Expression.cpp
@@ -0,0 +1,32 @@
+//===-- Expression.h ---------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Expression/Expression.h"
+#include "lldb/Target/ExecutionContextScope.h"
+#include "lldb/Target/Target.h"
+
+using namespace lldb_private;
+
+Expression::Expression (Target &target) :
+ 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()),
+ m_jit_start_addr (LLDB_INVALID_ADDRESS),
+ m_jit_end_addr (LLDB_INVALID_ADDRESS)
+{
+ assert (m_target_wp.lock());
+}
+
diff --git a/source/Expression/ExpressionSourceCode.cpp b/source/Expression/ExpressionSourceCode.cpp
index 9a42510d0a24..c4ab7a95d7a9 100644
--- a/source/Expression/ExpressionSourceCode.cpp
+++ b/source/Expression/ExpressionSourceCode.cpp
@@ -10,9 +10,12 @@
#include "lldb/Expression/ExpressionSourceCode.h"
#include "lldb/Core/StreamString.h"
-#include "lldb/Expression/ClangModulesDeclVendor.h"
-#include "lldb/Expression/ClangPersistentVariables.h"
+#include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h"
+#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
+#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/DebugMacros.h"
#include "lldb/Symbol/Block.h"
+#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/StackFrame.h"
@@ -56,6 +59,121 @@ extern "C"
}
)";
+namespace {
+
+class AddMacroState
+{
+ enum State
+ {
+ CURRENT_FILE_NOT_YET_PUSHED,
+ CURRENT_FILE_PUSHED,
+ CURRENT_FILE_POPPED
+ };
+
+public:
+ AddMacroState(const FileSpec &current_file, const uint32_t current_file_line)
+ : m_state(CURRENT_FILE_NOT_YET_PUSHED),
+ m_current_file(current_file),
+ m_current_file_line(current_file_line)
+ { }
+
+ void
+ StartFile(const FileSpec &file)
+ {
+ m_file_stack.push_back(file);
+ if (file == m_current_file)
+ m_state = CURRENT_FILE_PUSHED;
+ }
+
+ void
+ EndFile()
+ {
+ if (m_file_stack.size() == 0)
+ return;
+
+ FileSpec old_top = m_file_stack.back();
+ m_file_stack.pop_back();
+ if (old_top == m_current_file)
+ m_state = CURRENT_FILE_POPPED;
+ }
+
+ // An entry is valid if it occurs before the current line in
+ // the current file.
+ bool
+ IsValidEntry(uint32_t line)
+ {
+ switch (m_state)
+ {
+ case CURRENT_FILE_NOT_YET_PUSHED:
+ return true;
+ case CURRENT_FILE_POPPED:
+ return false;
+ case CURRENT_FILE_PUSHED:
+ // If we are in file included in the current file,
+ // the entry should be added.
+ if (m_file_stack.back() != m_current_file)
+ return true;
+
+ if (line >= m_current_file_line)
+ return false;
+ else
+ return true;
+ }
+ }
+
+private:
+ std::vector<FileSpec> m_file_stack;
+ State m_state;
+ FileSpec m_current_file;
+ uint32_t m_current_file_line;
+};
+
+} // anonymous namespace
+
+static void
+AddMacros(const DebugMacros *dm, CompileUnit *comp_unit, AddMacroState &state, StreamString &stream)
+{
+ if (dm == nullptr)
+ return;
+
+ for (size_t i = 0; i < dm->GetNumMacroEntries(); i++)
+ {
+ const DebugMacroEntry &entry = dm->GetMacroEntryAtIndex(i);
+ uint32_t line;
+
+ switch (entry.GetType())
+ {
+ case DebugMacroEntry::DEFINE:
+ if (state.IsValidEntry(entry.GetLineNumber()))
+ stream.Printf("#define %s\n", entry.GetMacroString().AsCString());
+ else
+ return;
+ break;
+ case DebugMacroEntry::UNDEF:
+ if (state.IsValidEntry(entry.GetLineNumber()))
+ stream.Printf("#undef %s\n", entry.GetMacroString().AsCString());
+ else
+ return;
+ break;
+ case DebugMacroEntry::START_FILE:
+ line = entry.GetLineNumber();
+ if (state.IsValidEntry(line))
+ state.StartFile(entry.GetFileSpec(comp_unit));
+ else
+ return;
+ break;
+ case DebugMacroEntry::END_FILE:
+ state.EndFile();
+ break;
+ case DebugMacroEntry::INDIRECT:
+ AddMacros(entry.GetIndirectDebugMacros(), comp_unit, state, stream);
+ break;
+ default:
+ // This is an unknown/invalid entry. Ignore.
+ break;
+ }
+ }
+}
bool ExpressionSourceCode::GetText (std::string &text, lldb::LanguageType wrapping_language, bool const_object, bool static_method, ExecutionContext &exe_ctx) const
{
@@ -82,7 +200,8 @@ bool ExpressionSourceCode::GetText (std::string &text, lldb::LanguageType wrappi
if (ClangModulesDeclVendor *decl_vendor = target->GetClangModulesDeclVendor())
{
- const ClangModulesDeclVendor::ModuleVector &hand_imported_modules = target->GetPersistentVariables().GetHandLoadedClangModules();
+ ClangPersistentVariables *persistent_vars = llvm::cast<ClangPersistentVariables>(target->GetPersistentExpressionStateForLanguage(lldb::eLanguageTypeC));
+ const ClangModulesDeclVendor::ModuleVector &hand_imported_modules = persistent_vars->GetHandLoadedClangModules();
ClangModulesDeclVendor::ModuleVector modules_for_macros;
for (ClangModulesDeclVendor::ModuleID module : hand_imported_modules)
@@ -118,6 +237,23 @@ bool ExpressionSourceCode::GetText (std::string &text, lldb::LanguageType wrappi
}
}
+
+ StreamString debug_macros_stream;
+ if (StackFrame *frame = exe_ctx.GetFramePtr())
+ {
+ const SymbolContext &sc = frame->GetSymbolContext(
+ lldb:: eSymbolContextCompUnit | lldb::eSymbolContextLineEntry);
+
+ if (sc.comp_unit && sc.line_entry.IsValid())
+ {
+ DebugMacros *dm = sc.comp_unit->GetDebugMacros();
+ if (dm)
+ {
+ AddMacroState state(sc.line_entry.file, sc.line_entry.line);
+ AddMacros(dm, sc.comp_unit, state, debug_macros_stream);
+ }
+ }
+ }
if (m_wrap)
{
@@ -133,8 +269,9 @@ bool ExpressionSourceCode::GetText (std::string &text, lldb::LanguageType wrappi
StreamString wrap_stream;
- wrap_stream.Printf("%s\n%s\n%s\n%s\n",
+ wrap_stream.Printf("%s\n%s\n%s\n%s\n%s\n",
module_macros.c_str(),
+ debug_macros_stream.GetData(),
g_expression_prefix,
target_specific_defines,
m_prefix.c_str());
diff --git a/source/Expression/ExpressionVariable.cpp b/source/Expression/ExpressionVariable.cpp
new file mode 100644
index 000000000000..8bef60fdf1d7
--- /dev/null
+++ b/source/Expression/ExpressionVariable.cpp
@@ -0,0 +1,36 @@
+//===-- ExpressionVariable.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/Expression/ExpressionVariable.h"
+
+using namespace lldb_private;
+
+ExpressionVariable::~ExpressionVariable()
+{
+}
+
+uint8_t *
+ExpressionVariable::GetValueBytes()
+{
+ const size_t byte_size = m_frozen_sp->GetByteSize();
+ if (byte_size > 0)
+ {
+ if (m_frozen_sp->GetDataExtractor().GetByteSize() < byte_size)
+ {
+ m_frozen_sp->GetValue().ResizeData(byte_size);
+ m_frozen_sp->GetValue().GetData (m_frozen_sp->GetDataExtractor());
+ }
+ return const_cast<uint8_t *>(m_frozen_sp->GetDataExtractor().GetDataStart());
+ }
+ return NULL;
+}
+
+PersistentExpressionState::~PersistentExpressionState ()
+{
+}
diff --git a/source/Expression/ClangFunction.cpp b/source/Expression/FunctionCaller.cpp
index b438dacdfabc..ddc378dcb416 100644
--- a/source/Expression/ClangFunction.cpp
+++ b/source/Expression/FunctionCaller.cpp
@@ -1,4 +1,4 @@
-//===-- ClangFunction.cpp ---------------------------------------*- C++ -*-===//
+//===-- FunctionCaller.cpp ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -11,15 +11,6 @@
// C Includes
// C++ Includes
// Other libraries and framework includes
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/RecordLayout.h"
-#include "clang/CodeGen/CodeGenAction.h"
-#include "clang/CodeGen/ModuleBuilder.h"
-#include "clang/Frontend/CompilerInstance.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/Triple.h"
-#include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/IR/Module.h"
// Project includes
#include "lldb/Core/DataExtractor.h"
@@ -28,12 +19,9 @@
#include "lldb/Core/State.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectList.h"
-#include "lldb/Expression/ASTStructExtractor.h"
-#include "lldb/Expression/ClangExpressionParser.h"
-#include "lldb/Expression/ClangFunction.h"
+#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/IRExecutionUnit.h"
#include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Target/ExecutionContext.h"
@@ -47,16 +35,17 @@
using namespace lldb_private;
//----------------------------------------------------------------------
-// ClangFunction constructor
+// FunctionCaller constructor
//----------------------------------------------------------------------
-ClangFunction::ClangFunction
+FunctionCaller::FunctionCaller
(
ExecutionContextScope &exe_scope,
- const ClangASTType &return_type,
+ 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(),
@@ -72,41 +61,14 @@ ClangFunction::ClangFunction
m_JITted (false)
{
m_jit_process_wp = lldb::ProcessWP(exe_scope.CalculateProcess());
- // Can't make a ClangFunction without a process.
+ // Can't make a FunctionCaller without a process.
assert (m_jit_process_wp.lock());
}
-ClangFunction::ClangFunction
-(
- ExecutionContextScope &exe_scope,
- Function &function,
- ClangASTContext *ast_context,
- const ValueList &arg_value_list,
- const char *name
-) :
- m_name (name ? name : "<unknown>"),
- m_function_ptr (&function),
- m_function_addr (),
- m_function_return_type (),
- m_wrapper_function_name ("__lldb_function_caller"),
- m_wrapper_struct_name ("__lldb_caller_struct"),
- m_wrapper_args_addrs (),
- m_arg_values (arg_value_list),
- m_compiled (false),
- m_JITted (false)
-{
- m_jit_process_wp = exe_scope.CalculateProcess();
- // Can't make a ClangFunction without a process.
- assert (m_jit_process_wp.lock());
-
- m_function_addr = m_function_ptr->GetAddressRange().GetBaseAddress();
- m_function_return_type = m_function_ptr->GetClangType().GetFunctionReturnType();
-}
-
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-ClangFunction::~ClangFunction()
+FunctionCaller::~FunctionCaller()
{
lldb::ProcessSP process_sp (m_jit_process_wp.lock());
if (process_sp)
@@ -117,147 +79,8 @@ ClangFunction::~ClangFunction()
}
}
-unsigned
-ClangFunction::CompileFunction (Stream &errors)
-{
- if (m_compiled)
- return 0;
-
- // FIXME: How does clang tell us there's no return value? We need to handle that case.
- unsigned num_errors = 0;
-
- std::string return_type_str (m_function_return_type.GetTypeName().AsCString(""));
-
- // Cons up the function we're going to wrap our call in, then compile it...
- // We declare the function "extern "C"" because the compiler might be in C++
- // mode which would mangle the name and then we couldn't find it again...
- m_wrapper_function_text.clear();
- m_wrapper_function_text.append ("extern \"C\" void ");
- m_wrapper_function_text.append (m_wrapper_function_name);
- m_wrapper_function_text.append (" (void *input)\n{\n struct ");
- m_wrapper_function_text.append (m_wrapper_struct_name);
- m_wrapper_function_text.append (" \n {\n");
- m_wrapper_function_text.append (" ");
- m_wrapper_function_text.append (return_type_str);
- m_wrapper_function_text.append (" (*fn_ptr) (");
-
- // Get the number of arguments. If we have a function type and it is prototyped,
- // trust that, otherwise use the values we were given.
-
- // FIXME: This will need to be extended to handle Variadic functions. We'll need
- // to pull the defined arguments out of the function, then add the types from the
- // arguments list for the variable arguments.
-
- uint32_t num_args = UINT32_MAX;
- bool trust_function = false;
- // GetArgumentCount returns -1 for an unprototyped function.
- ClangASTType function_clang_type;
- if (m_function_ptr)
- {
- function_clang_type = m_function_ptr->GetClangType();
- if (function_clang_type)
- {
- int num_func_args = function_clang_type.GetFunctionArgumentCount();
- if (num_func_args >= 0)
- {
- trust_function = true;
- num_args = num_func_args;
- }
- }
- }
-
- if (num_args == UINT32_MAX)
- num_args = m_arg_values.GetSize();
-
- std::string args_buffer; // This one stores the definition of all the args in "struct caller".
- std::string args_list_buffer; // This one stores the argument list called from the structure.
- for (size_t i = 0; i < num_args; i++)
- {
- std::string type_name;
-
- if (trust_function)
- {
- type_name = function_clang_type.GetFunctionArgumentTypeAtIndex(i).GetTypeName().AsCString("");
- }
- else
- {
- ClangASTType clang_qual_type = m_arg_values.GetValueAtIndex(i)->GetClangType ();
- if (clang_qual_type)
- {
- type_name = clang_qual_type.GetTypeName().AsCString("");
- }
- else
- {
- errors.Printf("Could not determine type of input value %" PRIu64 ".", (uint64_t)i);
- return 1;
- }
- }
-
- m_wrapper_function_text.append (type_name);
- if (i < num_args - 1)
- m_wrapper_function_text.append (", ");
-
- char arg_buf[32];
- args_buffer.append (" ");
- args_buffer.append (type_name);
- snprintf(arg_buf, 31, "arg_%" PRIu64, (uint64_t)i);
- args_buffer.push_back (' ');
- args_buffer.append (arg_buf);
- args_buffer.append (";\n");
-
- args_list_buffer.append ("__lldb_fn_data->");
- args_list_buffer.append (arg_buf);
- if (i < num_args - 1)
- args_list_buffer.append (", ");
-
- }
- m_wrapper_function_text.append (");\n"); // Close off the function calling prototype.
-
- m_wrapper_function_text.append (args_buffer);
-
- m_wrapper_function_text.append (" ");
- m_wrapper_function_text.append (return_type_str);
- m_wrapper_function_text.append (" return_value;");
- m_wrapper_function_text.append ("\n };\n struct ");
- m_wrapper_function_text.append (m_wrapper_struct_name);
- m_wrapper_function_text.append ("* __lldb_fn_data = (struct ");
- m_wrapper_function_text.append (m_wrapper_struct_name);
- m_wrapper_function_text.append (" *) input;\n");
-
- m_wrapper_function_text.append (" __lldb_fn_data->return_value = __lldb_fn_data->fn_ptr (");
- m_wrapper_function_text.append (args_list_buffer);
- m_wrapper_function_text.append (");\n}\n");
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
- if (log)
- log->Printf ("Expression: \n\n%s\n\n", m_wrapper_function_text.c_str());
-
- // Okay, now compile this expression
-
- lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock());
- if (jit_process_sp)
- {
- const bool generate_debug_info = true;
- m_parser.reset(new ClangExpressionParser(jit_process_sp.get(), *this, generate_debug_info));
-
- num_errors = m_parser->Parse (errors);
- }
- else
- {
- errors.Printf("no process - unable to inject function");
- num_errors = 1;
- }
-
- m_compiled = (num_errors == 0);
-
- if (!m_compiled)
- return num_errors;
-
- return num_errors;
-}
-
bool
-ClangFunction::WriteFunctionWrapper (ExecutionContext &exe_ctx, Stream &errors)
+FunctionCaller::WriteFunctionWrapper (ExecutionContext &exe_ctx, Stream &errors)
{
Process *process = exe_ctx.GetProcessPtr();
@@ -310,18 +133,17 @@ ClangFunction::WriteFunctionWrapper (ExecutionContext &exe_ctx, Stream &errors)
}
bool
-ClangFunction::WriteFunctionArguments (ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, Stream &errors)
+FunctionCaller::WriteFunctionArguments (ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, Stream &errors)
{
- return WriteFunctionArguments(exe_ctx, args_addr_ref, m_function_addr, m_arg_values, errors);
+ return WriteFunctionArguments(exe_ctx, args_addr_ref, m_arg_values, errors);
}
// FIXME: Assure that the ValueList we were passed in is consistent with the one that defined this function.
bool
-ClangFunction::WriteFunctionArguments (ExecutionContext &exe_ctx,
+FunctionCaller::WriteFunctionArguments (ExecutionContext &exe_ctx,
lldb::addr_t &args_addr_ref,
- Address function_address,
- ValueList &arg_values,
+ ValueList &arg_values,
Stream &errors)
{
// All the information to reconstruct the struct is provided by the
@@ -333,7 +155,6 @@ ClangFunction::WriteFunctionArguments (ExecutionContext &exe_ctx,
}
Error error;
- using namespace clang;
lldb::ExpressionResults return_value = lldb::eExpressionSetupError;
Process *process = exe_ctx.GetProcessPtr();
@@ -363,7 +184,7 @@ ClangFunction::WriteFunctionArguments (ExecutionContext &exe_ctx,
}
// TODO: verify fun_addr needs to be a callable address
- Scalar fun_addr (function_address.GetCallableLoadAddress(exe_ctx.GetTargetPtr()));
+ Scalar fun_addr (m_function_addr.GetCallableLoadAddress(exe_ctx.GetTargetPtr()));
uint64_t first_offset = m_member_offsets[0];
process->WriteScalarToMemory(args_addr_ref + first_offset, fun_addr, process->GetAddressByteSize(), error);
@@ -391,7 +212,7 @@ ClangFunction::WriteFunctionArguments (ExecutionContext &exe_ctx,
if (arg_value->GetValueType() == Value::eValueTypeHostAddress &&
arg_value->GetContextType() == Value::eContextTypeInvalid &&
- arg_value->GetClangType().IsPointerType())
+ arg_value->GetCompilerType().IsPointerType())
continue;
const Scalar &arg_scalar = arg_value->ResolveValue(&exe_ctx);
@@ -404,10 +225,8 @@ ClangFunction::WriteFunctionArguments (ExecutionContext &exe_ctx,
}
bool
-ClangFunction::InsertFunction (ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, Stream &errors)
+FunctionCaller::InsertFunction (ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, Stream &errors)
{
- using namespace clang;
-
if (CompileFunction(errors) != 0)
return false;
if (!WriteFunctionWrapper(exe_ctx, errors))
@@ -423,7 +242,7 @@ ClangFunction::InsertFunction (ExecutionContext &exe_ctx, lldb::addr_t &args_add
}
lldb::ThreadPlanSP
-ClangFunction::GetThreadPlanToCallFunction (ExecutionContext &exe_ctx,
+FunctionCaller::GetThreadPlanToCallFunction (ExecutionContext &exe_ctx,
lldb::addr_t args_addr,
const EvaluateExpressionOptions &options,
Stream &errors)
@@ -431,7 +250,7 @@ ClangFunction::GetThreadPlanToCallFunction (ExecutionContext &exe_ctx,
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
if (log)
- log->Printf("-- [ClangFunction::GetThreadPlanToCallFunction] Creating thread plan to call function \"%s\" --", m_name.c_str());
+ log->Printf("-- [FunctionCaller::GetThreadPlanToCallFunction] Creating thread plan to call function \"%s\" --", m_name.c_str());
// FIXME: Use the errors Stream for better error reporting.
Thread *thread = exe_ctx.GetThreadPtr();
@@ -449,7 +268,7 @@ ClangFunction::GetThreadPlanToCallFunction (ExecutionContext &exe_ctx,
lldb::ThreadPlanSP new_plan_sp (new ThreadPlanCallFunction (*thread,
wrapper_address,
- ClangASTType(),
+ CompilerType(),
args,
options));
new_plan_sp->SetIsMasterPlan(true);
@@ -458,17 +277,17 @@ ClangFunction::GetThreadPlanToCallFunction (ExecutionContext &exe_ctx,
}
bool
-ClangFunction::FetchFunctionResults (ExecutionContext &exe_ctx, lldb::addr_t args_addr, Value &ret_value)
+FunctionCaller::FetchFunctionResults (ExecutionContext &exe_ctx, lldb::addr_t args_addr, Value &ret_value)
{
// Read the return value - it is the last field in the struct:
// FIXME: How does clang tell us there's no return value? We need to handle that case.
- // FIXME: Create our ThreadPlanCallFunction with the return ClangASTType, and then use GetReturnValueObject
+ // FIXME: Create our ThreadPlanCallFunction with the return CompilerType, and then use GetReturnValueObject
// to fetch the value. That way we can fetch any values we need.
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
if (log)
- log->Printf("-- [ClangFunction::FetchFunctionResults] Fetching function results for \"%s\"--", m_name.c_str());
+ log->Printf("-- [FunctionCaller::FetchFunctionResults] Fetching function results for \"%s\"--", m_name.c_str());
Process *process = exe_ctx.GetProcessPtr();
@@ -486,13 +305,13 @@ ClangFunction::FetchFunctionResults (ExecutionContext &exe_ctx, lldb::addr_t arg
if (error.Fail())
return false;
- ret_value.SetClangType(m_function_return_type);
+ ret_value.SetCompilerType(m_function_return_type);
ret_value.SetValueType(Value::eValueTypeScalar);
return true;
}
void
-ClangFunction::DeallocateFunctionResults (ExecutionContext &exe_ctx, lldb::addr_t args_addr)
+FunctionCaller::DeallocateFunctionResults (ExecutionContext &exe_ctx, lldb::addr_t args_addr)
{
std::list<lldb::addr_t>::iterator pos;
pos = std::find(m_wrapper_args_addrs.begin(), m_wrapper_args_addrs.end(), args_addr);
@@ -503,17 +322,16 @@ ClangFunction::DeallocateFunctionResults (ExecutionContext &exe_ctx, lldb::addr_
}
lldb::ExpressionResults
-ClangFunction::ExecuteFunction(
+FunctionCaller::ExecuteFunction(
ExecutionContext &exe_ctx,
lldb::addr_t *args_addr_ptr,
const EvaluateExpressionOptions &options,
Stream &errors,
Value &results)
{
- using namespace clang;
lldb::ExpressionResults return_value = lldb::eExpressionSetupError;
- // ClangFunction::ExecuteFunction execution is always just to get the result. Do make sure we ignore
+ // FunctionCaller::ExecuteFunction execution is always just to get the result. Do make sure we ignore
// breakpoints, unwind on error, and don't try to debug it.
EvaluateExpressionOptions real_options = options;
real_options.SetDebug(false);
@@ -539,7 +357,7 @@ ClangFunction::ExecuteFunction(
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
if (log)
- log->Printf("== [ClangFunction::ExecuteFunction] Executing function \"%s\" ==", m_name.c_str());
+ log->Printf("== [FunctionCaller::ExecuteFunction] Executing function \"%s\" ==", m_name.c_str());
lldb::ThreadPlanSP call_plan_sp = GetThreadPlanToCallFunction (exe_ctx,
args_addr,
@@ -562,11 +380,11 @@ ClangFunction::ExecuteFunction(
{
if (return_value != lldb::eExpressionCompleted)
{
- log->Printf("== [ClangFunction::ExecuteFunction] Execution of \"%s\" completed abnormally ==", m_name.c_str());
+ log->Printf("== [FunctionCaller::ExecuteFunction] Execution of \"%s\" completed abnormally ==", m_name.c_str());
}
else
{
- log->Printf("== [ClangFunction::ExecuteFunction] Execution of \"%s\" completed normally ==", m_name.c_str());
+ log->Printf("== [FunctionCaller::ExecuteFunction] Execution of \"%s\" completed normally ==", m_name.c_str());
}
}
@@ -586,11 +404,3 @@ ClangFunction::ExecuteFunction(
return lldb::eExpressionCompleted;
}
-
-clang::ASTConsumer *
-ClangFunction::ASTTransformer (clang::ASTConsumer *passthrough)
-{
- m_struct_extractor.reset(new ASTStructExtractor(passthrough, m_wrapper_struct_name.c_str(), *this));
-
- return m_struct_extractor.get();
-}
diff --git a/source/Expression/IRDynamicChecks.cpp b/source/Expression/IRDynamicChecks.cpp
index aa5d28bb8aad..30d7f6330f65 100644
--- a/source/Expression/IRDynamicChecks.cpp
+++ b/source/Expression/IRDynamicChecks.cpp
@@ -1,4 +1,4 @@
-//===-- IRDynamicChecks.cpp -------------------------------------------*- C++ -*-===//
+//===-- IRDynamicChecks.cpp -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,23 +7,28 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/DataLayout.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/Value.h"
+
+// Project includes
#include "lldb/Expression/IRDynamicChecks.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Log.h"
-#include "lldb/Expression/ClangUtilityFunction.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 "llvm/Support/raw_ostream.h"
-#include "llvm/IR/Constants.h"
-#include "llvm/IR/DataLayout.h"
-#include "llvm/IR/Function.h"
-#include "llvm/IR/Instructions.h"
-#include "llvm/IR/Module.h"
-#include "llvm/IR/Value.h"
+#include "lldb/Target/Target.h"
using namespace llvm;
using namespace lldb_private;
@@ -40,20 +45,22 @@ static const char g_valid_pointer_check_text[] =
" unsigned char $__lldb_local_val = *$__lldb_arg_ptr;\n"
"}";
-DynamicCheckerFunctions::DynamicCheckerFunctions ()
-{
-}
+DynamicCheckerFunctions::DynamicCheckerFunctions() = default;
-DynamicCheckerFunctions::~DynamicCheckerFunctions ()
-{
-}
+DynamicCheckerFunctions::~DynamicCheckerFunctions() = default;
bool
DynamicCheckerFunctions::Install(Stream &error_stream,
ExecutionContext &exe_ctx)
{
- m_valid_pointer_check.reset(new ClangUtilityFunction(g_valid_pointer_check_text,
- VALID_POINTER_CHECK_NAME));
+ Error error;
+ m_valid_pointer_check.reset(exe_ctx.GetTargetRef().GetUtilityFunctionForLanguage(g_valid_pointer_check_text,
+ lldb::eLanguageTypeC,
+ VALID_POINTER_CHECK_NAME,
+ error));
+ if (error.Fail())
+ return false;
+
if (!m_valid_pointer_check->Install(error_stream, exe_ctx))
return false;
@@ -80,12 +87,12 @@ DynamicCheckerFunctions::DoCheckersExplainStop (lldb::addr_t addr, Stream &messa
{
// 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.
- if (m_valid_pointer_check.get() != NULL && m_valid_pointer_check->ContainsAddress(addr))
+ if (m_valid_pointer_check && m_valid_pointer_check->ContainsAddress(addr))
{
message.Printf ("Attempted to dereference an invalid pointer.");
return true;
}
- else if (m_objc_object_check.get() != NULL && m_objc_object_check->ContainsAddress(addr))
+ else if (m_objc_object_check && m_objc_object_check->ContainsAddress(addr))
{
message.Printf ("Attempted to dereference an invalid ObjC Object or send it an unrecognized selector");
return true;
@@ -93,7 +100,6 @@ DynamicCheckerFunctions::DoCheckersExplainStop (lldb::addr_t addr, Stream &messa
return false;
}
-
static std::string
PrintValue(llvm::Value *V, bool truncate = false)
{
@@ -146,14 +152,12 @@ public:
DynamicCheckerFunctions &checker_functions) :
m_module(module),
m_checker_functions(checker_functions),
- m_i8ptr_ty(NULL),
- m_intptr_ty(NULL)
+ m_i8ptr_ty(nullptr),
+ m_intptr_ty(nullptr)
{
}
- virtual~Instrumenter ()
- {
- }
+ virtual ~Instrumenter() = default;
//------------------------------------------------------------------
/// Inspect a function to find instructions to instrument
@@ -187,6 +191,7 @@ public:
return true;
}
+
protected:
//------------------------------------------------------------------
/// Add instrumentation to a single instruction
@@ -344,6 +349,7 @@ 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
+
private:
PointerType *m_i8ptr_ty;
IntegerType *m_intptr_ty;
@@ -355,15 +361,14 @@ public:
ValidPointerChecker (llvm::Module &module,
DynamicCheckerFunctions &checker_functions) :
Instrumenter(module, checker_functions),
- m_valid_pointer_check_func(NULL)
+ m_valid_pointer_check_func(nullptr)
{
}
- virtual ~ValidPointerChecker ()
- {
- }
-private:
- bool InstrumentInstruction(llvm::Instruction *inst)
+ ~ValidPointerChecker() override = default;
+
+protected:
+ bool InstrumentInstruction(llvm::Instruction *inst) override
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
@@ -374,7 +379,7 @@ private:
if (!m_valid_pointer_check_func)
m_valid_pointer_check_func = BuildPointerValidatorFunc(m_checker_functions.m_valid_pointer_check->StartAddress());
- llvm::Value *dereferenced_ptr = NULL;
+ llvm::Value *dereferenced_ptr = nullptr;
if (llvm::LoadInst *li = dyn_cast<llvm::LoadInst> (inst))
dereferenced_ptr = li->getPointerOperand();
@@ -406,7 +411,7 @@ private:
return true;
}
- bool InspectInstruction(llvm::Instruction &i)
+ bool InspectInstruction(llvm::Instruction &i) override
{
if (dyn_cast<llvm::LoadInst> (&i) ||
dyn_cast<llvm::StoreInst> (&i))
@@ -415,6 +420,7 @@ private:
return true;
}
+private:
llvm::Value *m_valid_pointer_check_func;
};
@@ -424,14 +430,11 @@ public:
ObjcObjectChecker(llvm::Module &module,
DynamicCheckerFunctions &checker_functions) :
Instrumenter(module, checker_functions),
- m_objc_object_check_func(NULL)
+ m_objc_object_check_func(nullptr)
{
}
- virtual
- ~ObjcObjectChecker ()
- {
- }
+ ~ObjcObjectChecker() override = default;
enum msgSend_type
{
@@ -444,13 +447,13 @@ public:
std::map <llvm::Instruction *, msgSend_type> msgSend_types;
-private:
- bool InstrumentInstruction(llvm::Instruction *inst)
+protected:
+ bool InstrumentInstruction(llvm::Instruction *inst) override
{
CallInst *call_inst = dyn_cast<CallInst>(inst);
if (!call_inst)
- return false; // call_inst really shouldn't be NULL, because otherwise InspectInstruction wouldn't have registered it
+ return false; // call_inst really shouldn't be nullptr, because otherwise 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());
@@ -504,7 +507,7 @@ private:
return true;
}
- bool InspectInstruction(llvm::Instruction &i)
+ bool InspectInstruction(llvm::Instruction &i) override
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
@@ -593,6 +596,7 @@ private:
return true;
}
+private:
llvm::Value *m_objc_object_check_func;
};
@@ -604,9 +608,7 @@ IRDynamicChecks::IRDynamicChecks(DynamicCheckerFunctions &checker_functions,
{
}
-IRDynamicChecks::~IRDynamicChecks()
-{
-}
+IRDynamicChecks::~IRDynamicChecks() = default;
bool
IRDynamicChecks::runOnModule(llvm::Module &M)
@@ -623,7 +625,7 @@ IRDynamicChecks::runOnModule(llvm::Module &M)
return false;
}
- if (m_checker_functions.m_valid_pointer_check.get())
+ if (m_checker_functions.m_valid_pointer_check)
{
ValidPointerChecker vpc(M, m_checker_functions);
@@ -634,7 +636,7 @@ IRDynamicChecks::runOnModule(llvm::Module &M)
return false;
}
- if (m_checker_functions.m_objc_object_check.get())
+ if (m_checker_functions.m_objc_object_check)
{
ObjcObjectChecker ooc(M, m_checker_functions);
@@ -650,7 +652,7 @@ IRDynamicChecks::runOnModule(llvm::Module &M)
std::string s;
raw_string_ostream oss(s);
- M.print(oss, NULL);
+ M.print(oss, nullptr);
oss.flush();
diff --git a/source/Expression/IRExecutionUnit.cpp b/source/Expression/IRExecutionUnit.cpp
index 59c7fb6f786f..3f19c508c926 100644
--- a/source/Expression/IRExecutionUnit.cpp
+++ b/source/Expression/IRExecutionUnit.cpp
@@ -50,10 +50,12 @@ IRExecutionUnit::WriteNow (const uint8_t *bytes,
size_t size,
Error &error)
{
+ const bool zero_memory = false;
lldb::addr_t allocation_process_addr = Malloc (size,
8,
lldb::ePermissionsWritable | lldb::ePermissionsReadable,
eAllocationPolicyMirror,
+ zero_memory,
error);
if (!error.Success())
@@ -432,6 +434,13 @@ IRExecutionUnit::GetRunnableInfo(Error &error,
my_extractor.PutToLog(log, 0, my_buffer.GetByteSize(), record.m_process_address, 16, DataExtractor::TypeUInt8);
}
}
+ else
+ {
+ record.dump(log);
+
+ DataExtractor my_extractor ((const void*)record.m_host_address, record.m_size, lldb::eByteOrderBig, 8);
+ my_extractor.PutToLog(log, 0, record.m_size, record.m_host_address, 16, DataExtractor::TypeUInt8);
+ }
}
}
@@ -488,6 +497,8 @@ IRExecutionUnit::GetSectionTypeFromSectionName (const llvm::StringRef &name, IRE
sect_type = lldb::eSectionTypeDWARFDebugAbbrev;
else if (dwarf_name.equals("aranges"))
sect_type = lldb::eSectionTypeDWARFDebugAranges;
+ else if (dwarf_name.equals("addr"))
+ sect_type = lldb::eSectionTypeDWARFDebugAddr;
break;
case 'f':
@@ -522,6 +533,8 @@ IRExecutionUnit::GetSectionTypeFromSectionName (const llvm::StringRef &name, IRE
case 's':
if (dwarf_name.equals("str"))
sect_type = lldb::eSectionTypeDWARFDebugStr;
+ else if (dwarf_name.equals("str_offsets"))
+ sect_type = lldb::eSectionTypeDWARFDebugStrOffsets;
break;
case 'r':
@@ -789,6 +802,7 @@ IRExecutionUnit::CommitAllocations (lldb::ProcessSP &process_sp)
{
case lldb::eSectionTypeInvalid:
case lldb::eSectionTypeDWARFDebugAbbrev:
+ case lldb::eSectionTypeDWARFDebugAddr:
case lldb::eSectionTypeDWARFDebugAranges:
case lldb::eSectionTypeDWARFDebugFrame:
case lldb::eSectionTypeDWARFDebugInfo:
@@ -799,6 +813,7 @@ IRExecutionUnit::CommitAllocations (lldb::ProcessSP &process_sp)
case lldb::eSectionTypeDWARFDebugPubTypes:
case lldb::eSectionTypeDWARFDebugRanges:
case lldb::eSectionTypeDWARFDebugStr:
+ case lldb::eSectionTypeDWARFDebugStrOffsets:
case lldb::eSectionTypeDWARFAppleNames:
case lldb::eSectionTypeDWARFAppleTypes:
case lldb::eSectionTypeDWARFAppleNamespaces:
@@ -806,10 +821,12 @@ IRExecutionUnit::CommitAllocations (lldb::ProcessSP &process_sp)
err.Clear();
break;
default:
+ const bool zero_memory = false;
record.m_process_address = Malloc (record.m_size,
record.m_alignment,
record.m_permissions,
eAllocationPolicyProcessOnly,
+ zero_memory,
err);
break;
}
@@ -877,12 +894,13 @@ IRExecutionUnit::AllocationRecord::dump (Log *log)
if (!log)
return;
- log->Printf("[0x%llx+0x%llx]->0x%llx (alignment %d, section ID %d)",
+ log->Printf("[0x%llx+0x%llx]->0x%llx (alignment %d, section ID %d, name %s)",
(unsigned long long)m_host_address,
(unsigned long long)m_size,
(unsigned long long)m_process_address,
(unsigned)m_alignment,
- (unsigned)m_section_id);
+ (unsigned)m_section_id,
+ m_name.c_str());
}
diff --git a/source/Expression/IRInterpreter.cpp b/source/Expression/IRInterpreter.cpp
index 926d1f22b6aa..a2b0c5b86851 100644
--- a/source/Expression/IRInterpreter.cpp
+++ b/source/Expression/IRInterpreter.cpp
@@ -365,7 +365,7 @@ public:
const uint64_t *raw_data = resolved_value.getRawData();
- buffer.PutRawBytes(raw_data, constant_size, lldb::endian::InlHostByteOrder());
+ buffer.PutRawBytes(raw_data, constant_size, lldb_private::endian::InlHostByteOrder());
lldb_private::Error write_error;
@@ -498,7 +498,7 @@ IRInterpreter::CanInterpret (llvm::Module &module,
default:
{
if (log)
- log->Printf("Unsupported instruction: %s", PrintValue(ii).c_str());
+ log->Printf("Unsupported instruction: %s", PrintValue(&*ii).c_str());
error.SetErrorToGenericError();
error.SetErrorString(unsupported_opcode_error);
return false;
@@ -522,7 +522,7 @@ IRInterpreter::CanInterpret (llvm::Module &module,
if (!CanIgnoreCall(call_inst) && !support_function_calls)
{
if (log)
- log->Printf("Unsupported instruction: %s", PrintValue(ii).c_str());
+ log->Printf("Unsupported instruction: %s", PrintValue(&*ii).c_str());
error.SetErrorToGenericError();
error.SetErrorString(unsupported_opcode_error);
return false;
@@ -547,7 +547,7 @@ IRInterpreter::CanInterpret (llvm::Module &module,
default:
{
if (log)
- log->Printf("Unsupported ICmp predicate: %s", PrintValue(ii).c_str());
+ log->Printf("Unsupported ICmp predicate: %s", PrintValue(&*ii).c_str());
error.SetErrorToGenericError();
error.SetErrorString(unsupported_opcode_error);
@@ -655,7 +655,7 @@ IRInterpreter::Interpret (llvm::Module &module,
ai != ae;
++ai, ++arg_index)
{
- if (args.size() < static_cast<size_t>(arg_index))
+ if (args.size() <= static_cast<size_t>(arg_index))
{
error.SetErrorString ("Not enough arguments passed in to function");
return false;
@@ -663,16 +663,16 @@ IRInterpreter::Interpret (llvm::Module &module,
lldb::addr_t ptr = args[arg_index];
- frame.MakeArgument(ai, ptr);
+ frame.MakeArgument(&*ai, ptr);
}
uint32_t num_insts = 0;
- frame.Jump(function.begin());
+ frame.Jump(&function.front());
while (frame.m_ii != frame.m_ie && (++num_insts < 4096))
{
- const Instruction *inst = frame.m_ii;
+ const Instruction *inst = &*frame.m_ii;
if (log)
log->Printf("Interpreting %s", PrintValue(inst).c_str());
diff --git a/source/Expression/IRMemoryMap.cpp b/source/Expression/IRMemoryMap.cpp
index 4733b16d5f1c..e96bddde7cbb 100644
--- a/source/Expression/IRMemoryMap.cpp
+++ b/source/Expression/IRMemoryMap.cpp
@@ -47,7 +47,7 @@ IRMemoryMap::~IRMemoryMap ()
}
lldb::addr_t
-IRMemoryMap::FindSpace (size_t size)
+IRMemoryMap::FindSpace (size_t size, bool zero_memory)
{
lldb::TargetSP target_sp = m_target_wp.lock();
lldb::ProcessSP process_sp = m_process_wp.lock();
@@ -60,7 +60,10 @@ IRMemoryMap::FindSpace (size_t size)
{
Error alloc_error;
- ret = process_sp->AllocateMemory(size, lldb::ePermissionsReadable | lldb::ePermissionsWritable, alloc_error);
+ if (!zero_memory)
+ ret = process_sp->AllocateMemory(size, lldb::ePermissionsReadable | lldb::ePermissionsWritable, alloc_error);
+ else
+ ret = process_sp->CallocateMemory(size, lldb::ePermissionsReadable | lldb::ePermissionsWritable, alloc_error);
if (!alloc_error.Success())
return LLDB_INVALID_ADDRESS;
@@ -225,7 +228,7 @@ IRMemoryMap::Allocation::Allocation (lldb::addr_t process_alloc,
}
lldb::addr_t
-IRMemoryMap::Malloc (size_t size, uint8_t alignment, uint32_t permissions, AllocationPolicy policy, Error &error)
+IRMemoryMap::Malloc (size_t size, uint8_t alignment, uint32_t permissions, AllocationPolicy policy, bool zero_memory, Error &error)
{
lldb_private::Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
error.Clear();
@@ -263,7 +266,11 @@ IRMemoryMap::Malloc (size_t size, uint8_t alignment, uint32_t permissions, Alloc
log->Printf ("IRMemoryMap::%s process_sp=0x%" PRIx64 ", process_sp->CanJIT()=%s, process_sp->IsAlive()=%s", __FUNCTION__, (lldb::addr_t) process_sp.get (), process_sp && process_sp->CanJIT () ? "true" : "false", process_sp && process_sp->IsAlive () ? "true" : "false");
if (process_sp && process_sp->CanJIT() && process_sp->IsAlive())
{
- allocation_address = process_sp->AllocateMemory(allocation_size, permissions, error);
+ if (!zero_memory)
+ allocation_address = process_sp->AllocateMemory(allocation_size, permissions, error);
+ else
+ allocation_address = process_sp->CallocateMemory(allocation_size, permissions, error);
+
if (!error.Success())
return LLDB_INVALID_ADDRESS;
}
@@ -287,7 +294,11 @@ IRMemoryMap::Malloc (size_t size, uint8_t alignment, uint32_t permissions, Alloc
{
if (process_sp->CanJIT() && process_sp->IsAlive())
{
- allocation_address = process_sp->AllocateMemory(allocation_size, permissions, error);
+ if (!zero_memory)
+ allocation_address = process_sp->AllocateMemory(allocation_size, permissions, error);
+ else
+ allocation_address = process_sp->CallocateMemory(allocation_size, permissions, error);
+
if (!error.Success())
return LLDB_INVALID_ADDRESS;
}
diff --git a/source/Expression/LLVMUserExpression.cpp b/source/Expression/LLVMUserExpression.cpp
new file mode 100644
index 000000000000..eff0a2dc30d6
--- /dev/null
+++ b/source/Expression/LLVMUserExpression.cpp
@@ -0,0 +1,363 @@
+//===-- LLVMUserExpression.cpp ----------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C Includes
+// C++ Includes
+
+// Project includes
+#include "lldb/Expression/LLVMUserExpression.h"
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/StreamFile.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/Expression/ExpressionSourceCode.h"
+#include "lldb/Expression/IRExecutionUnit.h"
+#include "lldb/Expression/IRInterpreter.h"
+#include "lldb/Expression/Materializer.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/Block.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
+#include "lldb/Symbol/VariableList.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/ThreadPlan.h"
+#include "lldb/Target/ThreadPlanCallUserExpression.h"
+
+using namespace lldb_private;
+
+LLVMUserExpression::LLVMUserExpression(ExecutionContextScope &exe_scope,
+ const char *expr,
+ const char *expr_prefix,
+ lldb::LanguageType language,
+ ResultType desired_type,
+ const EvaluateExpressionOptions &options)
+ : UserExpression(exe_scope, expr, expr_prefix, language, desired_type, options),
+ m_stack_frame_bottom(LLDB_INVALID_ADDRESS),
+ m_stack_frame_top(LLDB_INVALID_ADDRESS),
+ 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_const_object(false),
+ m_target(NULL),
+ m_can_interpret(false),
+ m_materialized_address(LLDB_INVALID_ADDRESS)
+{
+}
+
+LLVMUserExpression::~LLVMUserExpression()
+{
+ if (m_target)
+ {
+ lldb::ModuleSP jit_module_sp(m_jit_module_wp.lock());
+ if (jit_module_sp)
+ m_target->GetImages().Remove(jit_module_sp);
+ }
+}
+
+lldb::ExpressionResults
+LLVMUserExpression::Execute(Stream &error_stream, ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options,
+ lldb::UserExpressionSP &shared_ptr_to_me, lldb::ExpressionVariableSP &result)
+{
+ // The expression log is quite verbose, and if you're just tracking the execution of the
+ // expression, it's quite convenient to have these logs come out with the STEP log as well.
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
+
+ if (m_jit_start_addr != LLDB_INVALID_ADDRESS || m_can_interpret)
+ {
+ lldb::addr_t struct_address = LLDB_INVALID_ADDRESS;
+
+ if (!PrepareToExecuteJITExpression(error_stream, exe_ctx, struct_address))
+ {
+ error_stream.Printf("Errored out in %s, couldn't PrepareToExecuteJITExpression", __FUNCTION__);
+ return lldb::eExpressionSetupError;
+ }
+
+ lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS;
+ lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS;
+
+ if (m_can_interpret)
+ {
+ llvm::Module *module = m_execution_unit_sp->GetModule();
+ llvm::Function *function = m_execution_unit_sp->GetFunction();
+
+ if (!module || !function)
+ {
+ error_stream.Printf("Supposed to interpret, but nothing is there");
+ return lldb::eExpressionSetupError;
+ }
+
+ Error interpreter_error;
+
+ std::vector<lldb::addr_t> args;
+
+ if (!AddArguments(exe_ctx, args, struct_address, error_stream))
+ {
+ error_stream.Printf("Errored out in %s, couldn't AddArguments", __FUNCTION__);
+ return lldb::eExpressionSetupError;
+ }
+
+ 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);
+
+ if (!interpreter_error.Success())
+ {
+ error_stream.Printf("Supposed to interpret, but failed: %s", interpreter_error.AsCString());
+ return lldb::eExpressionDiscarded;
+ }
+ }
+ else
+ {
+ if (!exe_ctx.HasThreadScope())
+ {
+ error_stream.Printf("UserExpression::Execute called with no thread selected.");
+ return lldb::eExpressionSetupError;
+ }
+
+ Address wrapper_address(m_jit_start_addr);
+
+ std::vector<lldb::addr_t> args;
+
+ if (!AddArguments(exe_ctx, args, struct_address, error_stream))
+ {
+ error_stream.Printf("Errored out in %s, couldn't AddArguments", __FUNCTION__);
+ return lldb::eExpressionSetupError;
+ }
+
+ lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallUserExpression(exe_ctx.GetThreadRef(), wrapper_address,
+ args, options, shared_ptr_to_me));
+
+ if (!call_plan_sp || !call_plan_sp->ValidatePlan(&error_stream))
+ return lldb::eExpressionSetupError;
+
+ ThreadPlanCallUserExpression *user_expression_plan =
+ static_cast<ThreadPlanCallUserExpression *>(call_plan_sp.get());
+
+ lldb::addr_t function_stack_pointer = user_expression_plan->GetFunctionStackPointer();
+
+ function_stack_bottom = function_stack_pointer - HostInfo::GetPageSize();
+ function_stack_top = function_stack_pointer;
+
+ if (log)
+ log->Printf("-- [UserExpression::Execute] Execution of expression begins --");
+
+ if (exe_ctx.GetProcessPtr())
+ exe_ctx.GetProcessPtr()->SetRunningUserExpression(true);
+
+ lldb::ExpressionResults execution_result =
+ exe_ctx.GetProcessRef().RunThreadPlan(exe_ctx, call_plan_sp, options, error_stream);
+
+ if (exe_ctx.GetProcessPtr())
+ exe_ctx.GetProcessPtr()->SetRunningUserExpression(false);
+
+ if (log)
+ log->Printf("-- [UserExpression::Execute] Execution of expression completed --");
+
+ if (execution_result == lldb::eExpressionInterrupted || execution_result == lldb::eExpressionHitBreakpoint)
+ {
+ const char *error_desc = NULL;
+
+ if (call_plan_sp)
+ {
+ lldb::StopInfoSP real_stop_info_sp = call_plan_sp->GetRealStopInfo();
+ if (real_stop_info_sp)
+ error_desc = real_stop_info_sp->GetDescription();
+ }
+ if (error_desc)
+ error_stream.Printf("Execution was interrupted, reason: %s.", error_desc);
+ else
+ error_stream.PutCString("Execution was interrupted.");
+
+ if ((execution_result == lldb::eExpressionInterrupted && options.DoesUnwindOnError()) ||
+ (execution_result == lldb::eExpressionHitBreakpoint && options.DoesIgnoreBreakpoints()))
+ error_stream.PutCString(
+ "\nThe process has been returned to the state before expression evaluation.");
+ else
+ {
+ if (execution_result == lldb::eExpressionHitBreakpoint)
+ user_expression_plan->TransferExpressionOwnership();
+ error_stream.PutCString(
+ "\nThe process has been left at the point where it was interrupted, "
+ "use \"thread return -x\" to return to the state before expression evaluation.");
+ }
+
+ return execution_result;
+ }
+ else if (execution_result == lldb::eExpressionStoppedForDebug)
+ {
+ error_stream.PutCString(
+ "Execution was halted at the first instruction of the expression "
+ "function because \"debug\" was requested.\n"
+ "Use \"thread return -x\" to return to the state before expression evaluation.");
+ return execution_result;
+ }
+ else if (execution_result != lldb::eExpressionCompleted)
+ {
+ error_stream.Printf("Couldn't execute function; result was %s\n",
+ Process::ExecutionResultAsCString(execution_result));
+ return execution_result;
+ }
+ }
+
+ if (FinalizeJITExecution(error_stream, exe_ctx, result, function_stack_bottom, function_stack_top))
+ {
+ return lldb::eExpressionCompleted;
+ }
+ else
+ {
+ return lldb::eExpressionResultUnavailable;
+ }
+ }
+ else
+ {
+ error_stream.Printf("Expression can't be run, because there is no JIT compiled function");
+ return lldb::eExpressionSetupError;
+ }
+}
+
+bool
+LLVMUserExpression::FinalizeJITExecution(Stream &error_stream, ExecutionContext &exe_ctx,
+ lldb::ExpressionVariableSP &result, lldb::addr_t function_stack_bottom,
+ lldb::addr_t function_stack_top)
+{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+
+ if (log)
+ log->Printf("-- [UserExpression::FinalizeJITExecution] Dematerializing after execution --");
+
+ if (!m_dematerializer_sp)
+ {
+ error_stream.Printf("Couldn't apply expression side effects : no dematerializer is present");
+ return false;
+ }
+
+ Error dematerialize_error;
+
+ m_dematerializer_sp->Dematerialize(dematerialize_error, function_stack_bottom, function_stack_top);
+
+ if (!dematerialize_error.Success())
+ {
+ error_stream.Printf("Couldn't apply expression side effects : %s\n",
+ dematerialize_error.AsCString("unknown error"));
+ return false;
+ }
+
+ result = GetResultAfterDematerialization(exe_ctx.GetBestExecutionContextScope());
+
+ if (result)
+ result->TransferAddress();
+
+ m_dematerializer_sp.reset();
+
+ return true;
+}
+
+bool
+LLVMUserExpression::PrepareToExecuteJITExpression(Stream &error_stream, ExecutionContext &exe_ctx,
+ lldb::addr_t &struct_address)
+{
+ lldb::TargetSP target;
+ lldb::ProcessSP process;
+ lldb::StackFrameSP frame;
+
+ if (!LockAndCheckContext(exe_ctx, target, process, frame))
+ {
+ error_stream.Printf("The context has changed before we could JIT the expression!\n");
+ return false;
+ }
+
+ if (m_jit_start_addr != LLDB_INVALID_ADDRESS || m_can_interpret)
+ {
+ if (m_materialized_address == LLDB_INVALID_ADDRESS)
+ {
+ Error alloc_error;
+
+ IRMemoryMap::AllocationPolicy policy =
+ m_can_interpret ? IRMemoryMap::eAllocationPolicyHostOnly : IRMemoryMap::eAllocationPolicyMirror;
+
+ const bool zero_memory = false;
+
+ m_materialized_address = m_execution_unit_sp->Malloc(m_materializer_ap->GetStructByteSize(),
+ m_materializer_ap->GetStructAlignment(),
+ lldb::ePermissionsReadable | lldb::ePermissionsWritable,
+ policy,
+ zero_memory,
+ alloc_error);
+
+ if (!alloc_error.Success())
+ {
+ error_stream.Printf("Couldn't allocate space for materialized struct: %s\n", alloc_error.AsCString());
+ return false;
+ }
+ }
+
+ struct_address = m_materialized_address;
+
+ if (m_can_interpret && m_stack_frame_bottom == LLDB_INVALID_ADDRESS)
+ {
+ Error alloc_error;
+
+ const size_t stack_frame_size = 512 * 1024;
+
+ const bool zero_memory = false;
+
+ m_stack_frame_bottom = m_execution_unit_sp->Malloc(stack_frame_size,
+ 8,
+ lldb::ePermissionsReadable | lldb::ePermissionsWritable,
+ IRMemoryMap::eAllocationPolicyHostOnly,
+ zero_memory,
+ alloc_error);
+
+ m_stack_frame_top = m_stack_frame_bottom + stack_frame_size;
+
+ if (!alloc_error.Success())
+ {
+ error_stream.Printf("Couldn't allocate space for the stack frame: %s\n", alloc_error.AsCString());
+ return false;
+ }
+ }
+
+ Error materialize_error;
+
+ m_dematerializer_sp =
+ m_materializer_ap->Materialize(frame, *m_execution_unit_sp, struct_address, materialize_error);
+
+ if (!materialize_error.Success())
+ {
+ error_stream.Printf("Couldn't materialize: %s\n", materialize_error.AsCString());
+ return false;
+ }
+ }
+ return true;
+}
+
+lldb::ModuleSP
+LLVMUserExpression::GetJITModule()
+{
+ if (m_execution_unit_sp)
+ return m_execution_unit_sp->GetJITModule();
+ return lldb::ModuleSP();
+}
diff --git a/source/Expression/Materializer.cpp b/source/Expression/Materializer.cpp
index ef01feea2a4c..8d68b4f79819 100644
--- a/source/Expression/Materializer.cpp
+++ b/source/Expression/Materializer.cpp
@@ -7,12 +7,15 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Core/Log.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectVariable.h"
-#include "lldb/Expression/ClangExpressionVariable.h"
-#include "lldb/Expression/ClangPersistentVariables.h"
+#include "lldb/Expression/ExpressionVariable.h"
#include "lldb/Expression/Materializer.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/Symbol.h"
@@ -48,7 +51,7 @@ Materializer::AddStructMember (Entity &entity)
}
void
-Materializer::Entity::SetSizeAndAlignmentFromType (ClangASTType &type)
+Materializer::Entity::SetSizeAndAlignmentFromType (CompilerType &type)
{
m_size = type.GetByteSize(nullptr);
@@ -66,9 +69,11 @@ Materializer::Entity::SetSizeAndAlignmentFromType (ClangASTType &type)
class EntityPersistentVariable : public Materializer::Entity
{
public:
- EntityPersistentVariable (lldb::ClangExpressionVariableSP &persistent_variable_sp) :
+ EntityPersistentVariable (lldb::ExpressionVariableSP &persistent_variable_sp,
+ Materializer::PersistentVariableDelegate *delegate) :
Entity(),
- m_persistent_variable_sp(persistent_variable_sp)
+ m_persistent_variable_sp(persistent_variable_sp),
+ m_delegate(delegate)
{
// Hard-coding to maximum size of a pointer since persistent variables are materialized by reference
m_size = 8;
@@ -82,11 +87,13 @@ public:
// Allocate a spare memory area to store the persistent variable's contents.
Error allocate_error;
+ const bool zero_memory = false;
lldb::addr_t mem = map.Malloc(m_persistent_variable_sp->GetByteSize(),
8,
lldb::ePermissionsReadable | lldb::ePermissionsWritable,
IRMemoryMap::eAllocationPolicyMirror,
+ zero_memory,
allocate_error);
if (!allocate_error.Success())
@@ -99,21 +106,21 @@ public:
log->Printf("Allocated %s (0x%" PRIx64 ") successfully", m_persistent_variable_sp->GetName().GetCString(), mem);
// Put the location of the spare memory into the live data of the ValueObject.
-
+
m_persistent_variable_sp->m_live_sp = ValueObjectConstResult::Create (map.GetBestExecutionContextScope(),
- m_persistent_variable_sp->GetTypeFromUser(),
+ m_persistent_variable_sp->GetCompilerType(),
m_persistent_variable_sp->GetName(),
mem,
eAddressTypeLoad,
- m_persistent_variable_sp->GetByteSize());
+ map.GetAddressByteSize());
// Clear the flag if the variable will never be deallocated.
- if (m_persistent_variable_sp->m_flags & ClangExpressionVariable::EVKeepInTarget)
+ if (m_persistent_variable_sp->m_flags & ExpressionVariable::EVKeepInTarget)
{
Error leak_error;
map.Leak(mem, leak_error);
- m_persistent_variable_sp->m_flags &= ~ClangExpressionVariable::EVNeedsAllocation;
+ m_persistent_variable_sp->m_flags &= ~ExpressionVariable::EVNeedsAllocation;
}
// Write the contents of the variable to the area.
@@ -147,7 +154,10 @@ public:
}
}
- void Materialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Error &err)
+ void Materialize(lldb::StackFrameSP &frame_sp,
+ IRMemoryMap &map,
+ lldb::addr_t process_address,
+ Error &err) override
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
@@ -161,17 +171,17 @@ public:
m_persistent_variable_sp->m_flags);
}
- if (m_persistent_variable_sp->m_flags & ClangExpressionVariable::EVNeedsAllocation)
+ if (m_persistent_variable_sp->m_flags & ExpressionVariable::EVNeedsAllocation)
{
MakeAllocation(map, err);
- m_persistent_variable_sp->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
+ m_persistent_variable_sp->m_flags |= ExpressionVariable::EVIsLLDBAllocated;
if (!err.Success())
return;
}
- if ((m_persistent_variable_sp->m_flags & ClangExpressionVariable::EVIsProgramReference && m_persistent_variable_sp->m_live_sp) ||
- m_persistent_variable_sp->m_flags & ClangExpressionVariable::EVIsLLDBAllocated)
+ if ((m_persistent_variable_sp->m_flags & ExpressionVariable::EVIsProgramReference && m_persistent_variable_sp->m_live_sp) ||
+ m_persistent_variable_sp->m_flags & ExpressionVariable::EVIsLLDBAllocated)
{
Error write_error;
@@ -192,12 +202,12 @@ public:
}
}
- void Dematerialize (lldb::StackFrameSP &frame_sp,
- IRMemoryMap &map,
- lldb::addr_t process_address,
- lldb::addr_t frame_top,
- lldb::addr_t frame_bottom,
- Error &err)
+ void Dematerialize(lldb::StackFrameSP &frame_sp,
+ IRMemoryMap &map,
+ lldb::addr_t process_address,
+ lldb::addr_t frame_top,
+ lldb::addr_t frame_bottom,
+ Error &err) override
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
@@ -211,10 +221,15 @@ public:
m_persistent_variable_sp->m_flags);
}
- if ((m_persistent_variable_sp->m_flags & ClangExpressionVariable::EVIsLLDBAllocated) ||
- (m_persistent_variable_sp->m_flags & ClangExpressionVariable::EVIsProgramReference))
+ if (m_delegate)
+ {
+ m_delegate->DidDematerialize(m_persistent_variable_sp);
+ }
+
+ if ((m_persistent_variable_sp->m_flags & ExpressionVariable::EVIsLLDBAllocated) ||
+ (m_persistent_variable_sp->m_flags & ExpressionVariable::EVIsProgramReference))
{
- if (m_persistent_variable_sp->m_flags & ClangExpressionVariable::EVIsProgramReference &&
+ if (m_persistent_variable_sp->m_flags & ExpressionVariable::EVIsProgramReference &&
!m_persistent_variable_sp->m_live_sp)
{
// If the reference comes from the program, then the ClangExpressionVariable's
@@ -230,9 +245,9 @@ public:
err.SetErrorStringWithFormat("couldn't read the address of program-allocated variable %s: %s", m_persistent_variable_sp->GetName().GetCString(), read_error.AsCString());
return;
}
-
+
m_persistent_variable_sp->m_live_sp = ValueObjectConstResult::Create (map.GetBestExecutionContextScope (),
- m_persistent_variable_sp->GetTypeFromUser(),
+ m_persistent_variable_sp.get()->GetCompilerType(),
m_persistent_variable_sp->GetName(),
location,
eAddressTypeLoad,
@@ -246,10 +261,10 @@ public:
// If the variable is resident in the stack frame created by the expression,
// then it cannot be relied upon to stay around. We treat it as needing
// reallocation.
- m_persistent_variable_sp->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
- m_persistent_variable_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
- m_persistent_variable_sp->m_flags |= ClangExpressionVariable::EVNeedsFreezeDry;
- m_persistent_variable_sp->m_flags &= ~ClangExpressionVariable::EVIsProgramReference;
+ m_persistent_variable_sp->m_flags |= ExpressionVariable::EVIsLLDBAllocated;
+ m_persistent_variable_sp->m_flags |= ExpressionVariable::EVNeedsAllocation;
+ m_persistent_variable_sp->m_flags |= ExpressionVariable::EVNeedsFreezeDry;
+ m_persistent_variable_sp->m_flags &= ~ExpressionVariable::EVIsProgramReference;
}
}
@@ -267,8 +282,8 @@ public:
return;
}
- if (m_persistent_variable_sp->m_flags & ClangExpressionVariable::EVNeedsFreezeDry ||
- m_persistent_variable_sp->m_flags & ClangExpressionVariable::EVKeepInTarget)
+ if (m_persistent_variable_sp->m_flags & ExpressionVariable::EVNeedsFreezeDry ||
+ m_persistent_variable_sp->m_flags & ExpressionVariable::EVKeepInTarget)
{
if (log)
log->Printf("Dematerializing %s from 0x%" PRIx64 " (size = %llu)", m_persistent_variable_sp->GetName().GetCString(), (uint64_t)mem, (unsigned long long)m_persistent_variable_sp->GetByteSize());
@@ -290,7 +305,7 @@ public:
return;
}
- m_persistent_variable_sp->m_flags &= ~ClangExpressionVariable::EVNeedsFreezeDry;
+ m_persistent_variable_sp->m_flags &= ~ExpressionVariable::EVNeedsFreezeDry;
}
}
else
@@ -305,14 +320,14 @@ public:
{
// Allocations are not persistent so persistent variables cannot stay materialized.
- m_persistent_variable_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
+ m_persistent_variable_sp->m_flags |= ExpressionVariable::EVNeedsAllocation;
DestroyAllocation(map, err);
if (!err.Success())
return;
}
- else if (m_persistent_variable_sp->m_flags & ClangExpressionVariable::EVNeedsAllocation &&
- !(m_persistent_variable_sp->m_flags & ClangExpressionVariable::EVKeepInTarget))
+ else if (m_persistent_variable_sp->m_flags & ExpressionVariable::EVNeedsAllocation &&
+ !(m_persistent_variable_sp->m_flags & ExpressionVariable::EVKeepInTarget))
{
DestroyAllocation(map, err);
if (!err.Success())
@@ -320,7 +335,7 @@ public:
}
}
- void DumpToLog (IRMemoryMap &map, lldb::addr_t process_address, Log *log)
+ void DumpToLog(IRMemoryMap &map, lldb::addr_t process_address, Log *log) override
{
StreamString dump_stream;
@@ -386,18 +401,22 @@ public:
log->PutCString(dump_stream.GetData());
}
- void Wipe (IRMemoryMap &map, lldb::addr_t process_address)
+ void Wipe(IRMemoryMap &map, lldb::addr_t process_address) override
{
}
+
private:
- lldb::ClangExpressionVariableSP m_persistent_variable_sp;
+ lldb::ExpressionVariableSP m_persistent_variable_sp;
+ Materializer::PersistentVariableDelegate *m_delegate;
};
uint32_t
-Materializer::AddPersistentVariable (lldb::ClangExpressionVariableSP &persistent_variable_sp, Error &err)
+Materializer::AddPersistentVariable (lldb::ExpressionVariableSP &persistent_variable_sp,
+ PersistentVariableDelegate *delegate,
+ Error &err)
{
EntityVector::iterator iter = m_entities.insert(m_entities.end(), EntityUP());
- iter->reset (new EntityPersistentVariable (persistent_variable_sp));
+ iter->reset (new EntityPersistentVariable (persistent_variable_sp, delegate));
uint32_t ret = AddStructMember(**iter);
(*iter)->SetOffset(ret);
return ret;
@@ -416,10 +435,13 @@ public:
// Hard-coding to maximum size of a pointer since all variables are materialized by reference
m_size = 8;
m_alignment = 8;
- m_is_reference = m_variable_sp->GetType()->GetClangForwardType().IsReferenceType();
+ m_is_reference = m_variable_sp->GetType()->GetForwardCompilerType ().IsReferenceType();
}
- void Materialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Error &err)
+ void Materialize(lldb::StackFrameSP &frame_sp,
+ IRMemoryMap &map,
+ lldb::addr_t process_address,
+ Error &err) override
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
@@ -525,15 +547,22 @@ public:
return;
}
- size_t bit_align = m_variable_sp->GetType()->GetClangLayoutType().GetTypeBitAlign();
+ size_t bit_align = m_variable_sp->GetType()->GetLayoutCompilerType ().GetTypeBitAlign();
size_t byte_align = (bit_align + 7) / 8;
if (!byte_align)
byte_align = 1;
Error alloc_error;
+ const bool zero_memory = false;
+
+ m_temporary_allocation = map.Malloc(data.GetByteSize(),
+ byte_align,
+ lldb::ePermissionsReadable | lldb::ePermissionsWritable,
+ IRMemoryMap::eAllocationPolicyMirror,
+ zero_memory,
+ alloc_error);
- m_temporary_allocation = map.Malloc(data.GetByteSize(), byte_align, lldb::ePermissionsReadable | lldb::ePermissionsWritable, IRMemoryMap::eAllocationPolicyMirror, alloc_error);
m_temporary_allocation_size = data.GetByteSize();
m_original_data.reset(new DataBufferHeap(data.GetDataStart(), data.GetByteSize()));
@@ -566,12 +595,12 @@ public:
}
}
- void Dematerialize (lldb::StackFrameSP &frame_sp,
- IRMemoryMap &map,
- lldb::addr_t process_address,
- lldb::addr_t frame_top,
- lldb::addr_t frame_bottom,
- Error &err)
+ void Dematerialize(lldb::StackFrameSP &frame_sp,
+ IRMemoryMap &map,
+ lldb::addr_t process_address,
+ lldb::addr_t frame_top,
+ lldb::addr_t frame_bottom,
+ Error &err) override
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
@@ -650,7 +679,7 @@ public:
}
}
- void DumpToLog (IRMemoryMap &map, lldb::addr_t process_address, Log *log)
+ void DumpToLog(IRMemoryMap &map, lldb::addr_t process_address, Log *log) override
{
StreamString dump_stream;
@@ -722,7 +751,7 @@ public:
log->PutCString(dump_stream.GetData());
}
- void Wipe (IRMemoryMap &map, lldb::addr_t process_address)
+ void Wipe(IRMemoryMap &map, lldb::addr_t process_address) override
{
if (m_temporary_allocation != LLDB_INVALID_ADDRESS)
{
@@ -735,6 +764,7 @@ public:
}
}
+
private:
lldb::VariableSP m_variable_sp;
bool m_is_reference;
@@ -756,20 +786,27 @@ Materializer::AddVariable (lldb::VariableSP &variable_sp, Error &err)
class EntityResultVariable : public Materializer::Entity
{
public:
- EntityResultVariable (const TypeFromUser &type, bool is_program_reference, bool keep_in_memory) :
+ EntityResultVariable (const CompilerType &type,
+ bool is_program_reference,
+ bool keep_in_memory,
+ Materializer::PersistentVariableDelegate *delegate) :
Entity(),
m_type(type),
m_is_program_reference(is_program_reference),
m_keep_in_memory(keep_in_memory),
m_temporary_allocation(LLDB_INVALID_ADDRESS),
- m_temporary_allocation_size(0)
+ m_temporary_allocation_size(0),
+ m_delegate(delegate)
{
// Hard-coding to maximum size of a pointer since all results are materialized by reference
m_size = 8;
m_alignment = 8;
}
- void Materialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Error &err)
+ void Materialize(lldb::StackFrameSP &frame_sp,
+ IRMemoryMap &map,
+ lldb::addr_t process_address,
+ Error &err) override
{
if (!m_is_program_reference)
{
@@ -789,8 +826,14 @@ public:
byte_align = 1;
Error alloc_error;
-
- m_temporary_allocation = map.Malloc(byte_size, byte_align, lldb::ePermissionsReadable | lldb::ePermissionsWritable, IRMemoryMap::eAllocationPolicyMirror, alloc_error);
+ const bool zero_memory = true;
+
+ m_temporary_allocation = map.Malloc(byte_size,
+ byte_align,
+ lldb::ePermissionsReadable | lldb::ePermissionsWritable,
+ IRMemoryMap::eAllocationPolicyMirror,
+ zero_memory,
+ alloc_error);
m_temporary_allocation_size = byte_size;
if (!alloc_error.Success())
@@ -810,23 +853,12 @@ public:
}
}
- void Dematerialize (lldb::StackFrameSP &frame_sp,
- IRMemoryMap &map,
- lldb::addr_t process_address,
- lldb::addr_t frame_top,
- lldb::addr_t frame_bottom,
- Error &err)
- {
- err.SetErrorString("Tried to detmaterialize a result variable with the normal Dematerialize method");
- }
-
- void Dematerialize (lldb::ClangExpressionVariableSP &result_variable_sp,
- lldb::StackFrameSP &frame_sp,
- IRMemoryMap &map,
- lldb::addr_t process_address,
- lldb::addr_t frame_top,
- lldb::addr_t frame_bottom,
- Error &err)
+ void Dematerialize(lldb::StackFrameSP &frame_sp,
+ IRMemoryMap &map,
+ lldb::addr_t process_address,
+ lldb::addr_t frame_top,
+ lldb::addr_t frame_bottom,
+ Error &err) override
{
err.Clear();
@@ -858,15 +890,30 @@ public:
return;
}
- ConstString name = target_sp->GetPersistentVariables().GetNextPersistentVariableName();
+ Error type_system_error;
+ TypeSystem *type_system = target_sp->GetScratchTypeSystemForLanguage(&type_system_error, m_type.GetMinimumLanguage());
+
+ if (!type_system)
+ {
+ err.SetErrorStringWithFormat("Couldn't dematerialize a result variable: couldn't get the corresponding type system: %s", type_system_error.AsCString());
+ return;
+ }
+
+ PersistentExpressionState *persistent_state = type_system->GetPersistentExpressionState();
+
+ if (!persistent_state)
+ {
+ err.SetErrorString("Couldn't dematerialize a result variable: corresponding type system doesn't handle persistent variables");
+ return;
+ }
- lldb::ClangExpressionVariableSP ret;
+ ConstString name = m_delegate ? m_delegate->GetName() : persistent_state->GetNextPersistentVariableName();
- ret = target_sp->GetPersistentVariables().CreateVariable(exe_scope,
- name,
- m_type,
- map.GetByteOrder(),
- map.GetAddressByteSize());
+ lldb::ExpressionVariableSP ret = persistent_state->CreatePersistentVariable(exe_scope,
+ name,
+ m_type,
+ map.GetByteOrder(),
+ map.GetAddressByteSize());
if (!ret)
{
@@ -876,6 +923,11 @@ public:
lldb::ProcessSP process_sp = map.GetBestExecutionContextScope()->CalculateProcess();
+ if (m_delegate)
+ {
+ m_delegate->DidDematerialize(ret);
+ }
+
bool can_persist = (m_is_program_reference && process_sp && process_sp->CanJIT() && !(address >= frame_bottom && address < frame_top));
if (can_persist && m_keep_in_memory)
@@ -900,12 +952,10 @@ public:
err.SetErrorString("Couldn't dematerialize a result variable: couldn't read its memory");
return;
}
-
- result_variable_sp = ret;
if (!can_persist || !m_keep_in_memory)
{
- ret->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
+ ret->m_flags |= ExpressionVariable::EVNeedsAllocation;
if (m_temporary_allocation != LLDB_INVALID_ADDRESS)
{
@@ -915,14 +965,14 @@ public:
}
else
{
- ret->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
+ ret->m_flags |= ExpressionVariable::EVIsLLDBAllocated;
}
m_temporary_allocation = LLDB_INVALID_ADDRESS;
m_temporary_allocation_size = 0;
}
- void DumpToLog (IRMemoryMap &map, lldb::addr_t process_address, Log *log)
+ void DumpToLog(IRMemoryMap &map, lldb::addr_t process_address, Log *log) override
{
StreamString dump_stream;
@@ -995,7 +1045,7 @@ public:
log->PutCString(dump_stream.GetData());
}
- void Wipe (IRMemoryMap &map, lldb::addr_t process_address)
+ void Wipe(IRMemoryMap &map, lldb::addr_t process_address) override
{
if (!m_keep_in_memory && m_temporary_allocation != LLDB_INVALID_ADDRESS)
{
@@ -1007,23 +1057,28 @@ public:
m_temporary_allocation = LLDB_INVALID_ADDRESS;
m_temporary_allocation_size = 0;
}
+
private:
- TypeFromUser m_type;
+ CompilerType m_type;
bool m_is_program_reference;
bool m_keep_in_memory;
lldb::addr_t m_temporary_allocation;
size_t m_temporary_allocation_size;
+ Materializer::PersistentVariableDelegate *m_delegate;
};
uint32_t
-Materializer::AddResultVariable (const TypeFromUser &type, bool is_program_reference, bool keep_in_memory, Error &err)
+Materializer::AddResultVariable (const CompilerType &type,
+ bool is_program_reference,
+ bool keep_in_memory,
+ PersistentVariableDelegate *delegate,
+ Error &err)
{
EntityVector::iterator iter = m_entities.insert(m_entities.end(), EntityUP());
- iter->reset (new EntityResultVariable (type, is_program_reference, keep_in_memory));
+ iter->reset (new EntityResultVariable (type, is_program_reference, keep_in_memory, delegate));
uint32_t ret = AddStructMember(**iter);
(*iter)->SetOffset(ret);
- m_result_entity = iter->get();
return ret;
}
@@ -1039,7 +1094,10 @@ public:
m_alignment = 8;
}
- void Materialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Error &err)
+ void Materialize(lldb::StackFrameSP &frame_sp,
+ IRMemoryMap &map,
+ lldb::addr_t process_address,
+ Error &err) override
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
@@ -1083,12 +1141,12 @@ public:
}
}
- void Dematerialize (lldb::StackFrameSP &frame_sp,
- IRMemoryMap &map,
- lldb::addr_t process_address,
- lldb::addr_t frame_top,
- lldb::addr_t frame_bottom,
- Error &err)
+ void Dematerialize(lldb::StackFrameSP &frame_sp,
+ IRMemoryMap &map,
+ lldb::addr_t process_address,
+ lldb::addr_t frame_top,
+ lldb::addr_t frame_bottom,
+ Error &err) override
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
@@ -1104,7 +1162,7 @@ public:
// no work needs to be done
}
- void DumpToLog (IRMemoryMap &map, lldb::addr_t process_address, Log *log)
+ void DumpToLog(IRMemoryMap &map, lldb::addr_t process_address, Log *log) override
{
StreamString dump_stream;
@@ -1138,9 +1196,10 @@ public:
log->PutCString(dump_stream.GetData());
}
- void Wipe (IRMemoryMap &map, lldb::addr_t process_address)
+ void Wipe(IRMemoryMap &map, lldb::addr_t process_address) override
{
}
+
private:
Symbol m_symbol;
};
@@ -1167,7 +1226,10 @@ public:
m_alignment = m_register_info.byte_size;
}
- void Materialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Error &err)
+ void Materialize(lldb::StackFrameSP &frame_sp,
+ IRMemoryMap &map,
+ lldb::addr_t process_address,
+ Error &err) override
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
@@ -1223,12 +1285,12 @@ public:
}
}
- void Dematerialize (lldb::StackFrameSP &frame_sp,
- IRMemoryMap &map,
- lldb::addr_t process_address,
- lldb::addr_t frame_top,
- lldb::addr_t frame_bottom,
- Error &err)
+ void Dematerialize(lldb::StackFrameSP &frame_sp,
+ IRMemoryMap &map,
+ lldb::addr_t process_address,
+ lldb::addr_t frame_top,
+ lldb::addr_t frame_bottom,
+ Error &err) override
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
@@ -1280,7 +1342,7 @@ public:
}
}
- void DumpToLog (IRMemoryMap &map, lldb::addr_t process_address, Log *log)
+ void DumpToLog(IRMemoryMap &map, lldb::addr_t process_address, Log *log) override
{
StreamString dump_stream;
@@ -1315,9 +1377,10 @@ public:
log->PutCString(dump_stream.GetData());
}
- void Wipe (IRMemoryMap &map, lldb::addr_t process_address)
+ void Wipe(IRMemoryMap &map, lldb::addr_t process_address) override
{
}
+
private:
RegisterInfo m_register_info;
lldb::DataBufferSP m_register_contents;
@@ -1335,7 +1398,6 @@ Materializer::AddRegister (const RegisterInfo &register_info, Error &err)
Materializer::Materializer () :
m_dematerializer_wp(),
- m_result_entity(NULL),
m_current_offset(0),
m_struct_alignment(8)
{
@@ -1395,7 +1457,9 @@ Materializer::Materialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb:
}
void
-Materializer::Dematerializer::Dematerialize (Error &error, lldb::ClangExpressionVariableSP &result_sp, lldb::addr_t frame_bottom, lldb::addr_t frame_top)
+Materializer::Dematerializer::Dematerialize (Error &error,
+ lldb::addr_t frame_bottom,
+ lldb::addr_t frame_top)
{
lldb::StackFrameSP frame_sp;
@@ -1428,14 +1492,7 @@ Materializer::Dematerializer::Dematerialize (Error &error, lldb::ClangExpression
for (EntityUP &entity_up : m_materializer->m_entities)
{
- if (entity_up.get() == m_materializer->m_result_entity)
- {
- static_cast<EntityResultVariable*>(m_materializer->m_result_entity)->Dematerialize (result_sp, frame_sp, *m_map, m_process_address, frame_top, frame_bottom, error);
- }
- else
- {
- entity_up->Dematerialize (frame_sp, *m_map, m_process_address, frame_top, frame_bottom, error);
- }
+ entity_up->Dematerialize (frame_sp, *m_map, m_process_address, frame_top, frame_bottom, error);
if (!error.Success())
break;
@@ -1456,7 +1513,9 @@ Materializer::Dematerializer::Wipe ()
entity_up->Wipe (*m_map, m_process_address);
}
- m_materializer = NULL;
- m_map = NULL;
+ m_materializer = nullptr;
+ m_map = nullptr;
m_process_address = LLDB_INVALID_ADDRESS;
}
+
+Materializer::PersistentVariableDelegate::~PersistentVariableDelegate() = default;
diff --git a/source/Expression/REPL.cpp b/source/Expression/REPL.cpp
new file mode 100644
index 000000000000..1727a13abd06
--- /dev/null
+++ b/source/Expression/REPL.cpp
@@ -0,0 +1,649 @@
+//===-- REPL.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/StreamFile.h"
+#include "lldb/Expression/ExpressionVariable.h"
+#include "lldb/Expression/REPL.h"
+#include "lldb/Expression/UserExpression.h"
+#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"
+
+using namespace lldb_private;
+
+REPL::REPL(LLVMCastKind kind, Target &target) :
+ m_target(target),
+ m_kind(kind)
+{
+ // Make sure all option values have sane defaults
+ Debugger &debugger = m_target.GetDebugger();
+ CommandInterpreter &ci = debugger.GetCommandInterpreter();
+ m_format_options.OptionParsingStarting(ci);
+ m_varobj_options.OptionParsingStarting(ci);
+ m_command_options.OptionParsingStarting(ci);
+
+ // 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;
+
+lldb::REPLSP
+REPL::Create(Error &err, lldb::LanguageType language, Debugger *debugger, Target *target, const char *repl_options)
+{
+ uint32_t idx = 0;
+ lldb::REPLSP ret;
+
+ while (REPLCreateInstance create_instance = PluginManager::GetREPLCreateCallbackAtIndex(idx++))
+ {
+ ret = (*create_instance)(err, language, debugger, target, repl_options);
+ if (ret)
+ {
+ break;
+ }
+ }
+
+ return ret;
+}
+
+std::string
+REPL::GetSourcePath()
+{
+ ConstString file_basename = GetSourceFileBasename();
+
+ FileSpec tmpdir_file_spec;
+ if (HostInfo::GetLLDBPath (lldb::ePathTypeLLDBTempSystemDir, tmpdir_file_spec))
+ {
+ tmpdir_file_spec.GetFilename().SetCString(file_basename.AsCString());
+ m_repl_source_path = tmpdir_file_spec.GetPath();
+ }
+ else
+ {
+ tmpdir_file_spec = FileSpec("/tmp", false);
+ tmpdir_file_spec.AppendPathComponent(file_basename.AsCString());
+ }
+
+ return tmpdir_file_spec.GetPath();
+}
+
+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
+ "> ", // prompt
+ ". ", // Continuation prompt
+ true, // Multi-line
+ true, // The REPL prompt is always colored
+ 1, // Line number
+ *this));
+
+ // Don't exit if CTRL+C is pressed
+ static_cast<IOHandlerEditline *>(m_io_handler_sp.get())->SetInterruptExits(false);
+
+ if (m_io_handler_sp->GetIsInteractive() && m_io_handler_sp->GetIsRealTerminal())
+ {
+ m_indent_str.assign (debugger.GetTabSize(), ' ');
+ m_enable_auto_indent = debugger.GetAutoIndent();
+ }
+ else
+ {
+ m_indent_str.clear();
+ m_enable_auto_indent = false;
+ }
+
+ }
+ return m_io_handler_sp;
+}
+
+void
+REPL::IOHandlerActivated (IOHandler &io_handler)
+{
+ lldb::ProcessSP process_sp = m_target.GetProcessSP();
+ if (process_sp && process_sp->IsAlive())
+ return;
+ lldb::StreamFileSP error_sp(io_handler.GetErrorStreamFile());
+ error_sp->Printf("REPL requires a running target process.\n");
+ io_handler.SetIsDone(true);
+}
+
+bool
+REPL::IOHandlerInterrupt (IOHandler &io_handler)
+{
+ return false;
+}
+
+void
+REPL::IOHandlerInputInterrupted (IOHandler &io_handler,
+ std::string &line)
+{
+}
+
+const char *
+REPL::IOHandlerGetFixIndentationCharacters()
+{
+ return (m_enable_auto_indent ? GetAutoIndentCharacters() : nullptr);
+}
+
+ConstString
+REPL::IOHandlerGetControlSequence (char ch)
+{
+ if (ch == 'd')
+ return ConstString(":quit\n");
+ return ConstString();
+}
+
+const char *
+REPL::IOHandlerGetCommandPrefix ()
+{
+ return ":";
+}
+
+const char *
+REPL::IOHandlerGetHelpPrologue ()
+{
+ return "\nThe REPL (Read-Eval-Print-Loop) acts like an interpreter. "
+ "Valid statements, expressions, and declarations are immediately compiled and executed.\n\n"
+ "The complete set of LLDB debugging commands are also available as described below. Commands "
+ "must be prefixed with a colon at the REPL prompt (:quit for example.) Typing just a colon "
+ "followed by return will switch to the LLDB prompt.\n\n";
+}
+
+bool
+REPL::IOHandlerIsInputComplete (IOHandler &io_handler,
+ StringList &lines)
+{
+ // Check for meta command
+ const size_t num_lines = lines.GetSize();
+ if (num_lines == 1)
+ {
+ const char *first_line = lines.GetStringAtIndex(0);
+ if (first_line[0] == ':')
+ return true; // Meta command is a single line where that starts with ':'
+ }
+
+ // Check if REPL input is done
+ std::string source_string (lines.CopyList());
+ return SourceIsComplete(source_string);
+}
+
+int
+REPL::CalculateActualIndentation (const StringList &lines)
+{
+ std::string last_line = lines[lines.GetSize() - 1];
+
+ int actual_indent = 0;
+ for (char &ch : last_line)
+ {
+ if (ch != ' ') break;
+ ++actual_indent;
+ }
+
+ return actual_indent;
+}
+
+int
+REPL::IOHandlerFixIndentation (IOHandler &io_handler,
+ const StringList &lines,
+ int cursor_position)
+{
+ if (!m_enable_auto_indent) return 0;
+
+ if (!lines.GetSize())
+ {
+ return 0;
+ }
+
+ int tab_size = io_handler.GetDebugger().GetTabSize();
+
+ lldb::offset_t desired_indent = GetDesiredIndentation(lines,
+ cursor_position,
+ tab_size);
+
+ int actual_indent = REPL::CalculateActualIndentation(lines);
+
+ if (desired_indent == LLDB_INVALID_OFFSET)
+ return 0;
+
+ return (int)desired_indent - actual_indent;
+}
+
+void
+REPL::IOHandlerInputComplete (IOHandler &io_handler, std::string &code)
+{
+ lldb::StreamFileSP output_sp(io_handler.GetOutputStreamFile());
+ lldb::StreamFileSP error_sp(io_handler.GetErrorStreamFile());
+ bool extra_line = false;
+ bool did_quit = false;
+
+ if (code.empty())
+ {
+ m_code.AppendString("");
+ static_cast<IOHandlerEditline &>(io_handler).SetBaseLineNumber(m_code.GetSize()+1);
+ }
+ else
+ {
+ Debugger &debugger = m_target.GetDebugger();
+ CommandInterpreter &ci = debugger.GetCommandInterpreter();
+ extra_line = ci.GetSpaceReplPrompts();
+
+ ExecutionContext exe_ctx (m_target.GetProcessSP()->GetThreadList().GetSelectedThread()->GetSelectedFrame().get());
+
+ lldb::ProcessSP process_sp(exe_ctx.GetProcessSP());
+
+ if (code[0] == ':')
+ {
+ // Meta command
+ // Strip the ':'
+ code.erase(0, 1);
+ if (Args::StripSpaces (code))
+ {
+ // "lldb" was followed by arguments, so just execute the command dump the results
+
+ // Turn off prompt on quit in case the user types ":quit"
+ const bool saved_prompt_on_quit = ci.GetPromptOnQuit();
+ if (saved_prompt_on_quit)
+ ci.SetPromptOnQuit(false);
+
+ // Execute the command
+ CommandReturnObject result;
+ result.SetImmediateOutputStream(output_sp);
+ result.SetImmediateErrorStream(error_sp);
+ ci.HandleCommand(code.c_str(), eLazyBoolNo, result);
+
+ if (saved_prompt_on_quit)
+ ci.SetPromptOnQuit(true);
+
+ if (result.GetStatus() == lldb::eReturnStatusQuit)
+ {
+ did_quit = true;
+ io_handler.SetIsDone(true);
+ if (debugger.CheckTopIOHandlerTypes(IOHandler::Type::REPL, IOHandler::Type::CommandInterpreter))
+ {
+ // We typed "quit" or an alias to quit so we need to check if the
+ // command interpreter is above us and tell it that it is done as well
+ // so we don't drop back into the command interpreter if we have already
+ // quit
+ lldb::IOHandlerSP io_handler_sp (ci.GetIOHandler());
+ if (io_handler_sp)
+ io_handler_sp->SetIsDone(true);
+ }
+ }
+ }
+ else
+ {
+ // ":" was followed by no arguments, so push the LLDB command prompt
+ if (debugger.CheckTopIOHandlerTypes(IOHandler::Type::REPL, IOHandler::Type::CommandInterpreter))
+ {
+ // If the user wants to get back to the command interpreter and the
+ // command interpreter is what launched the REPL, then just let the
+ // REPL exit and fall back to the command interpreter.
+ io_handler.SetIsDone(true);
+ }
+ else
+ {
+ // The REPL wasn't launched the by the command interpreter, it is the
+ // base IOHandler, so we need to get the command interpreter and
+ lldb::IOHandlerSP io_handler_sp (ci.GetIOHandler());
+ if (io_handler_sp)
+ {
+ io_handler_sp->SetIsDone(false);
+ debugger.PushIOHandler(ci.GetIOHandler());
+ }
+ }
+ }
+ }
+ else
+ {
+ // Unwind any expression we might have been running in case our REPL
+ // expression crashed and the user was looking around
+ if (m_dedicated_repl_mode)
+ {
+ Thread *thread = exe_ctx.GetThreadPtr();
+ if (thread && thread->UnwindInnermostExpression().Success())
+ {
+ thread->SetSelectedFrameByIndex(0, false);
+ exe_ctx.SetFrameSP(thread->GetSelectedFrame());
+ }
+ }
+
+ const bool colorize_err = error_sp->GetFile().GetIsTerminalWithColors();
+
+ EvaluateExpressionOptions 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.SetTimeoutUsec(m_command_options.timeout);
+ else
+ expr_options.SetTimeoutUsec(0);
+
+ expr_options.SetLanguage(GetLanguage());
+
+ PersistentExpressionState *persistent_state = m_target.GetPersistentExpressionStateForLanguage(GetLanguage());
+
+ const size_t var_count_before = persistent_state->GetSize();
+
+ const char *expr_prefix = nullptr;
+ lldb::ValueObjectSP result_valobj_sp;
+ Error error;
+ lldb::ModuleSP jit_module_sp;
+ lldb::ExpressionResults execution_results = UserExpression::Evaluate (exe_ctx,
+ expr_options,
+ code.c_str(),
+ expr_prefix,
+ result_valobj_sp,
+ error,
+ 0, // Line offset
+ &jit_module_sp);
+
+ //CommandInterpreter &ci = debugger.GetCommandInterpreter();
+
+ if (process_sp && process_sp->IsAlive())
+ {
+ bool add_to_code = true;
+ bool handled = false;
+ if (result_valobj_sp)
+ {
+ lldb::Format format = m_format_options.GetFormat();
+
+ if (result_valobj_sp->GetError().Success())
+ {
+ handled |= PrintOneVariable(debugger, output_sp, result_valobj_sp);
+ }
+ else if (result_valobj_sp->GetError().GetError() == UserExpression::kNoResult)
+ {
+ if (format != lldb::eFormatVoid && debugger.GetNotifyVoid())
+ {
+ error_sp->PutCString("(void)\n");
+ handled = true;
+ }
+ }
+ }
+
+ if (debugger.GetPrintDecls())
+ {
+ for (size_t vi = var_count_before, ve = persistent_state->GetSize();
+ vi != ve;
+ ++vi)
+ {
+ lldb::ExpressionVariableSP persistent_var_sp = persistent_state->GetVariableAtIndex(vi);
+ lldb::ValueObjectSP valobj_sp = persistent_var_sp->GetValueObject();
+
+ PrintOneVariable(debugger, output_sp, valobj_sp, persistent_var_sp.get());
+ }
+ }
+
+ if (!handled)
+ {
+ bool useColors = error_sp->GetFile().GetIsTerminalWithColors();
+ switch (execution_results)
+ {
+ case lldb::eExpressionSetupError:
+ case lldb::eExpressionParseError:
+ add_to_code = false;
+ // Fall through
+ case lldb::eExpressionDiscarded:
+ error_sp->Printf("%s\n", error.AsCString());
+ break;
+
+ case lldb::eExpressionCompleted:
+ break;
+ case lldb::eExpressionInterrupted:
+ if (useColors) {
+ error_sp->Printf(ANSI_ESCAPE1(ANSI_FG_COLOR_RED));
+ error_sp->Printf(ANSI_ESCAPE1(ANSI_CTRL_BOLD));
+ }
+ error_sp->Printf("Execution interrupted. ");
+ if (useColors) error_sp->Printf(ANSI_ESCAPE1(ANSI_CTRL_NORMAL));
+ error_sp->Printf("Enter code to recover and continue.\nEnter LLDB commands to investigate (type :help for assistance.)\n");
+ break;
+
+ case lldb::eExpressionHitBreakpoint:
+ // Breakpoint was hit, drop into LLDB command interpreter
+ if (useColors) {
+ error_sp->Printf(ANSI_ESCAPE1(ANSI_FG_COLOR_RED));
+ error_sp->Printf(ANSI_ESCAPE1(ANSI_CTRL_BOLD));
+ }
+ output_sp->Printf("Execution stopped at breakpoint. ");
+ if (useColors) error_sp->Printf(ANSI_ESCAPE1(ANSI_CTRL_NORMAL));
+ output_sp->Printf("Enter LLDB commands to investigate (type help for assistance.)\n");
+ {
+ lldb::IOHandlerSP io_handler_sp (ci.GetIOHandler());
+ if (io_handler_sp)
+ {
+ io_handler_sp->SetIsDone(false);
+ debugger.PushIOHandler(ci.GetIOHandler());
+ }
+ }
+ break;
+
+ case lldb::eExpressionTimedOut:
+ error_sp->Printf("error: timeout\n");
+ if (error.AsCString())
+ error_sp->Printf("error: %s\n", error.AsCString());
+ break;
+ case lldb::eExpressionResultUnavailable:
+ // Shoulnd't happen???
+ error_sp->Printf("error: could not fetch result -- %s\n", error.AsCString());
+ break;
+ case lldb::eExpressionStoppedForDebug:
+ // Shoulnd't happen???
+ error_sp->Printf("error: stopped for debug -- %s\n", error.AsCString());
+ break;
+ }
+ }
+
+ if (add_to_code)
+ {
+ const uint32_t new_default_line = m_code.GetSize() + 1;
+
+ m_code.SplitIntoLines(code);
+
+ // Update our code on disk
+ if (!m_repl_source_path.empty())
+ {
+ lldb_private::File file (m_repl_source_path.c_str(),
+ File::eOpenOptionWrite | File::eOpenOptionTruncate | File::eOpenOptionCanCreate,
+ lldb::eFilePermissionsFileDefault);
+ std::string code (m_code.CopyList());
+ code.append(1, '\n');
+ size_t bytes_written = code.size();
+ file.Write(code.c_str(), bytes_written);
+ file.Close();
+
+ // Now set the default file and line to the REPL source file
+ m_target.GetSourceManager().SetDefaultFileAndLine(FileSpec(m_repl_source_path.c_str(), false), new_default_line);
+ }
+ static_cast<IOHandlerEditline &>(io_handler).SetBaseLineNumber(m_code.GetSize()+1);
+ }
+ if (extra_line)
+ {
+ fprintf(output_sp->GetFile().GetStream(), "\n");
+ }
+ }
+ }
+
+ // Don't complain about the REPL process going away if we are in the process of quitting.
+ if (!did_quit && (!process_sp || !process_sp->IsAlive()))
+ {
+ error_sp->Printf("error: REPL process is no longer alive, exiting REPL\n");
+ io_handler.SetIsDone(true);
+ }
+ }
+}
+
+int
+REPL::IOHandlerComplete (IOHandler &io_handler,
+ const char *current_line,
+ const char *cursor,
+ const char *last_char,
+ int skip_first_n_matches,
+ int max_matches,
+ StringList &matches)
+{
+ matches.Clear();
+
+ llvm::StringRef line (current_line, cursor - current_line);
+
+ // Complete an LLDB command if the first character is a colon...
+ if (!line.empty() && line[0] == ':')
+ {
+ Debugger &debugger = m_target.GetDebugger();
+
+ // auto complete LLDB commands
+ const char *lldb_current_line = line.substr(1).data();
+ return debugger.GetCommandInterpreter().HandleCompletion (lldb_current_line,
+ cursor,
+ last_char,
+ skip_first_n_matches,
+ max_matches,
+ matches);
+ }
+
+ // Strip spaces from the line and see if we had only spaces
+ line = line.ltrim();
+ if (line.empty())
+ {
+ // Only spaces on this line, so just indent
+ matches.AppendString(m_indent_str);
+ return 1;
+ }
+
+ std::string current_code;
+ current_code.append(m_code.CopyList());
+
+ IOHandlerEditline &editline = static_cast<IOHandlerEditline &>(io_handler);
+ const StringList *current_lines = editline.GetCurrentLines();
+ if (current_lines)
+ {
+ const uint32_t current_line_idx = editline.GetCurrentLineIndex();
+
+ if (current_line_idx < current_lines->GetSize())
+ {
+ for (uint32_t i=0; i<current_line_idx; ++i)
+ {
+ const char *line_cstr = current_lines->GetStringAtIndex(i);
+ if (line_cstr)
+ {
+ current_code.append("\n");
+ current_code.append (line_cstr);
+ }
+ }
+ }
+ }
+
+ if (cursor > current_line)
+ {
+ current_code.append("\n");
+ current_code.append(current_line, cursor - current_line);
+ }
+
+ return CompleteCode(current_code, matches);
+}
+
+bool
+QuitCommandOverrideCallback(void *baton, const char **argv)
+{
+ Target *target = (Target *)baton;
+ lldb::ProcessSP process_sp (target->GetProcessSP());
+ if (process_sp)
+ {
+ process_sp->Destroy(false);
+ process_sp->GetTarget().GetDebugger().ClearIOHandlers();
+ }
+ return false;
+}
+
+Error
+REPL::RunLoop ()
+{
+ Error error;
+
+ error = DoInitialization();
+ m_repl_source_path = GetSourcePath();
+
+ if (!error.Success())
+ return error;
+
+ Debugger &debugger = m_target.GetDebugger();
+
+ lldb::IOHandlerSP io_handler_sp (GetIOHandler());
+
+ FileSpec save_default_file;
+ uint32_t save_default_line = 0;
+
+ if (!m_repl_source_path.empty())
+ {
+ // Save the current default file and line
+ m_target.GetSourceManager().GetDefaultFileAndLine(save_default_file, save_default_line);
+ }
+
+ debugger.PushIOHandler(io_handler_sp);
+
+ // Check if we are in dedicated REPL mode where LLDB was start with the "--repl" option
+ // from the command line. Currently we know this by checking if the debugger already
+ // has a IOHandler thread.
+ if (!debugger.HasIOHandlerThread())
+ {
+ // The debugger doesn't have an existing IOHandler thread, so this must be
+ // dedicated REPL mode...
+ m_dedicated_repl_mode = true;
+ debugger.StartIOHandlerThread();
+ std::string command_name_str ("quit");
+ CommandObject *cmd_obj = debugger.GetCommandInterpreter().GetCommandObjectForCommand(command_name_str);
+ if (cmd_obj)
+ {
+ assert(command_name_str.empty());
+ cmd_obj->SetOverrideCallback (QuitCommandOverrideCallback, &m_target);
+ }
+ }
+
+ // Wait for the REPL command interpreter to get popped
+ io_handler_sp->WaitForPop();
+
+ if (m_dedicated_repl_mode)
+ {
+ // If we were in dedicated REPL mode we would have started the
+ // IOHandler thread, and we should kill our process
+ lldb::ProcessSP process_sp = m_target.GetProcessSP();
+ if (process_sp && process_sp->IsAlive())
+ process_sp->Destroy(false);
+
+ // Wait for the IO handler thread to exit (TODO: don't do this if the IO handler thread already exists...)
+ debugger.JoinIOHandlerThread();
+ }
+
+ // Restore the default file and line
+ if (save_default_file && save_default_line != 0)
+ m_target.GetSourceManager().SetDefaultFileAndLine(save_default_file, save_default_line);
+ return error;
+}
diff --git a/source/Expression/UserExpression.cpp b/source/Expression/UserExpression.cpp
new file mode 100644
index 000000000000..70f004ba25c9
--- /dev/null
+++ b/source/Expression/UserExpression.cpp
@@ -0,0 +1,348 @@
+//===-- UserExpression.cpp ---------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#include <cstdlib>
+#include <string>
+#include <map>
+
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/StreamFile.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/Expression/ExpressionSourceCode.h"
+#include "lldb/Expression/IRExecutionUnit.h"
+#include "lldb/Expression/IRInterpreter.h"
+#include "lldb/Expression/Materializer.h"
+#include "lldb/Expression/UserExpression.h"
+#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/Block.h"
+#include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/TypeSystem.h"
+#include "lldb/Symbol/VariableList.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/ThreadPlan.h"
+#include "lldb/Target/ThreadPlanCallUserExpression.h"
+
+using namespace lldb_private;
+
+UserExpression::UserExpression (ExecutionContextScope &exe_scope,
+ const char *expr,
+ const char *expr_prefix,
+ lldb::LanguageType language,
+ ResultType desired_type,
+ const EvaluateExpressionOptions &options) :
+ Expression(exe_scope),
+ m_expr_text(expr),
+ m_expr_prefix(expr_prefix ? expr_prefix : ""),
+ m_language(language),
+ m_desired_type(desired_type),
+ m_options (options)
+{
+}
+
+UserExpression::~UserExpression ()
+{
+}
+
+void
+UserExpression::InstallContext (ExecutionContext &exe_ctx)
+{
+ m_jit_process_wp = exe_ctx.GetProcessSP();
+
+ lldb::StackFrameSP frame_sp = exe_ctx.GetFrameSP();
+
+ if (frame_sp)
+ m_address = frame_sp->GetFrameCodeAddress();
+}
+
+bool
+UserExpression::LockAndCheckContext (ExecutionContext &exe_ctx,
+ lldb::TargetSP &target_sp,
+ lldb::ProcessSP &process_sp,
+ lldb::StackFrameSP &frame_sp)
+{
+ lldb::ProcessSP expected_process_sp = m_jit_process_wp.lock();
+ process_sp = exe_ctx.GetProcessSP();
+
+ if (process_sp != expected_process_sp)
+ return false;
+
+ process_sp = exe_ctx.GetProcessSP();
+ target_sp = exe_ctx.GetTargetSP();
+ frame_sp = exe_ctx.GetFrameSP();
+
+ if (m_address.IsValid())
+ {
+ if (!frame_sp)
+ return false;
+ else
+ return (0 == Address::CompareLoadAddress(m_address, frame_sp->GetFrameCodeAddress(), target_sp.get()));
+ }
+
+ return true;
+}
+
+bool
+UserExpression::MatchesContext (ExecutionContext &exe_ctx)
+{
+ lldb::TargetSP target_sp;
+ lldb::ProcessSP process_sp;
+ lldb::StackFrameSP frame_sp;
+
+ return LockAndCheckContext(exe_ctx, target_sp, process_sp, frame_sp);
+}
+
+lldb::addr_t
+UserExpression::GetObjectPointer (lldb::StackFrameSP frame_sp,
+ ConstString &object_name,
+ Error &err)
+{
+ err.Clear();
+
+ if (!frame_sp)
+ {
+ err.SetErrorStringWithFormat("Couldn't load '%s' because the context is incomplete", object_name.AsCString());
+ return LLDB_INVALID_ADDRESS;
+ }
+
+ lldb::VariableSP var_sp;
+ lldb::ValueObjectSP valobj_sp;
+
+ valobj_sp = frame_sp->GetValueForVariableExpressionPath(object_name.AsCString(),
+ lldb::eNoDynamicValues,
+ StackFrame::eExpressionPathOptionCheckPtrVsMember |
+ StackFrame::eExpressionPathOptionsNoFragileObjcIvar |
+ StackFrame::eExpressionPathOptionsNoSyntheticChildren |
+ StackFrame::eExpressionPathOptionsNoSyntheticArrayRange,
+ var_sp,
+ err);
+
+ if (!err.Success() || !valobj_sp.get())
+ return LLDB_INVALID_ADDRESS;
+
+ lldb::addr_t ret = valobj_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
+
+ if (ret == LLDB_INVALID_ADDRESS)
+ {
+ err.SetErrorStringWithFormat("Couldn't load '%s' because its value couldn't be evaluated", object_name.AsCString());
+ return LLDB_INVALID_ADDRESS;
+ }
+
+ return ret;
+}
+
+lldb::ExpressionResults
+UserExpression::Evaluate (ExecutionContext &exe_ctx,
+ const EvaluateExpressionOptions& options,
+ const char *expr_cstr,
+ const char *expr_prefix,
+ lldb::ValueObjectSP &result_valobj_sp,
+ Error &error,
+ uint32_t line_offset,
+ lldb::ModuleSP *jit_module_sp_ptr)
+{
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
+
+ lldb_private::ExecutionPolicy execution_policy = options.GetExecutionPolicy();
+ lldb::LanguageType language = options.GetLanguage();
+ const ResultType desired_type = options.DoesCoerceToId() ? UserExpression::eResultTypeId : UserExpression::eResultTypeAny;
+ lldb::ExpressionResults execution_results = lldb::eExpressionSetupError;
+
+ Target *target = exe_ctx.GetTargetPtr();
+ if (!target)
+ {
+ if (log)
+ log->Printf("== [UserExpression::Evaluate] Passed a NULL target, can't run expressions.");
+ return lldb::eExpressionSetupError;
+ }
+
+ Process *process = exe_ctx.GetProcessPtr();
+
+ if (process == NULL || process->GetState() != lldb::eStateStopped)
+ {
+ if (execution_policy == eExecutionPolicyAlways)
+ {
+ if (log)
+ log->Printf("== [UserExpression::Evaluate] Expression may not run, but is not constant ==");
+
+ error.SetErrorString ("expression needed to run but couldn't");
+
+ return execution_results;
+ }
+ }
+
+ if (process == NULL || !process->CanJIT())
+ execution_policy = eExecutionPolicyNever;
+
+ const char *full_prefix = NULL;
+ const char *option_prefix = options.GetPrefix();
+ std::string full_prefix_storage;
+ if (expr_prefix && option_prefix)
+ {
+ full_prefix_storage.assign(expr_prefix);
+ full_prefix_storage.append(option_prefix);
+ if (!full_prefix_storage.empty())
+ full_prefix = full_prefix_storage.c_str();
+ }
+ else if (expr_prefix)
+ full_prefix = expr_prefix;
+ else
+ full_prefix = option_prefix;
+
+ // If the language was not specified in the expression command,
+ // set it to the language in the target's properties if
+ // specified, else default to the langage for the frame.
+ if (language == lldb::eLanguageTypeUnknown)
+ {
+ if (target->GetLanguage() != lldb::eLanguageTypeUnknown)
+ language = target->GetLanguage();
+ else if (StackFrame *frame = exe_ctx.GetFramePtr())
+ language = frame->GetLanguage();
+ }
+
+ lldb::UserExpressionSP user_expression_sp(target->GetUserExpressionForLanguage (expr_cstr,
+ full_prefix,
+ language,
+ desired_type,
+ options,
+ error));
+ if (error.Fail())
+ {
+ if (log)
+ log->Printf ("== [UserExpression::Evaluate] Getting expression: %s ==", error.AsCString());
+ return lldb::eExpressionSetupError;
+ }
+
+ StreamString error_stream;
+
+ if (log)
+ log->Printf("== [UserExpression::Evaluate] Parsing expression %s ==", expr_cstr);
+
+ const bool keep_expression_in_memory = true;
+ const bool generate_debug_info = options.GetGenerateDebugInfo();
+
+ if (options.InvokeCancelCallback (lldb::eExpressionEvaluationParse))
+ {
+ error.SetErrorString ("expression interrupted by callback before parse");
+ result_valobj_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(), error);
+ return lldb::eExpressionInterrupted;
+ }
+
+ if (!user_expression_sp->Parse (error_stream,
+ exe_ctx,
+ execution_policy,
+ keep_expression_in_memory,
+ generate_debug_info))
+ {
+ execution_results = lldb::eExpressionParseError;
+ if (error_stream.GetString().empty())
+ error.SetExpressionError (execution_results, "expression failed to parse, unknown error");
+ else
+ error.SetExpressionError (execution_results, error_stream.GetString().c_str());
+ }
+ else
+ {
+ // If a pointer to a lldb::ModuleSP was passed in, return the JIT'ed module if one was created
+ if (jit_module_sp_ptr)
+ *jit_module_sp_ptr = user_expression_sp->GetJITModule();
+
+ lldb::ExpressionVariableSP expr_result;
+
+ if (execution_policy == eExecutionPolicyNever &&
+ !user_expression_sp->CanInterpret())
+ {
+ if (log)
+ log->Printf("== [UserExpression::Evaluate] Expression may not run, but is not constant ==");
+
+ if (error_stream.GetString().empty())
+ error.SetExpressionError (lldb::eExpressionSetupError, "expression needed to run but couldn't");
+ }
+ else
+ {
+ if (options.InvokeCancelCallback (lldb::eExpressionEvaluationExecution))
+ {
+ error.SetExpressionError (lldb::eExpressionInterrupted, "expression interrupted by callback before execution");
+ result_valobj_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(), error);
+ return lldb::eExpressionInterrupted;
+ }
+
+ error_stream.GetString().clear();
+
+ if (log)
+ log->Printf("== [UserExpression::Evaluate] Executing expression ==");
+
+ execution_results = user_expression_sp->Execute (error_stream,
+ exe_ctx,
+ options,
+ user_expression_sp,
+ expr_result);
+
+ if (options.GetResultIsInternal() && expr_result && process)
+ {
+ process->GetTarget().GetPersistentExpressionStateForLanguage(language)->RemovePersistentVariable (expr_result);
+ }
+
+ if (execution_results != lldb::eExpressionCompleted)
+ {
+ if (log)
+ log->Printf("== [UserExpression::Evaluate] Execution completed abnormally ==");
+
+ if (error_stream.GetString().empty())
+ error.SetExpressionError (execution_results, "expression failed to execute, unknown error");
+ else
+ error.SetExpressionError (execution_results, error_stream.GetString().c_str());
+ }
+ else
+ {
+ if (expr_result)
+ {
+ result_valobj_sp = expr_result->GetValueObject();
+
+ if (log)
+ log->Printf("== [UserExpression::Evaluate] Execution completed normally with result %s ==",
+ result_valobj_sp->GetValueAsCString());
+ }
+ else
+ {
+ if (log)
+ log->Printf("== [UserExpression::Evaluate] Execution completed normally with no result ==");
+
+ error.SetError(UserExpression::kNoResult, lldb::eErrorTypeGeneric);
+ }
+ }
+ }
+ }
+
+ if (options.InvokeCancelCallback(lldb::eExpressionEvaluationComplete))
+ {
+ error.SetExpressionError (lldb::eExpressionInterrupted, "expression interrupted by callback after complete");
+ return lldb::eExpressionInterrupted;
+ }
+
+ if (result_valobj_sp.get() == NULL)
+ {
+ result_valobj_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(), error);
+ }
+
+ return execution_results;
+}
diff --git a/source/Expression/UtilityFunction.cpp b/source/Expression/UtilityFunction.cpp
new file mode 100644
index 000000000000..f93e358d35df
--- /dev/null
+++ b/source/Expression/UtilityFunction.cpp
@@ -0,0 +1,124 @@
+//===-- ClangUserExpression.cpp -------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C Includes
+#include <stdio.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+// C++ Includes
+
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/StreamFile.h"
+#include "lldb/Expression/FunctionCaller.h"
+#include "lldb/Expression/UtilityFunction.h"
+#include "lldb/Expression/ExpressionSourceCode.h"
+#include "lldb/Expression/IRExecutionUnit.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+
+using namespace lldb_private;
+using namespace lldb;
+
+//------------------------------------------------------------------
+/// Constructor
+///
+/// @param[in] text
+/// The text of the function. Must be a full translation unit.
+///
+/// @param[in] name
+/// The name of the function, as used in the text.
+//------------------------------------------------------------------
+UtilityFunction::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);
+}
+
+UtilityFunction::~UtilityFunction ()
+{
+ lldb::ProcessSP process_sp (m_jit_process_wp.lock());
+ if (process_sp)
+ {
+ lldb::ModuleSP jit_module_sp (m_jit_module_wp.lock());
+ if (jit_module_sp)
+ process_sp->GetTarget().GetImages().Remove(jit_module_sp);
+ }
+
+}
+
+// FIXME: We should check that every time this is called it is called with the same return type & arguments...
+
+FunctionCaller *
+UtilityFunction::MakeFunctionCaller (const CompilerType &return_type, const ValueList &arg_value_list, Error &error)
+{
+ if (m_caller_up)
+ return m_caller_up.get();
+
+ ProcessSP process_sp = m_jit_process_wp.lock();
+ if (!process_sp)
+ return nullptr;
+
+ Address impl_code_address;
+ impl_code_address.SetOffset(StartAddress());
+ std::string name(m_function_name);
+ name.append("-caller");
+
+ m_caller_up.reset (process_sp->GetTarget().GetFunctionCallerForLanguage (Language(),
+ return_type,
+ impl_code_address,
+ arg_value_list,
+ name.c_str(),
+ error));
+ if (error.Fail())
+ {
+
+ return nullptr;
+ }
+ if (m_caller_up)
+ {
+ StreamString errors;
+ errors.Clear();
+ unsigned num_errors = m_caller_up->CompileFunction(errors);
+ if (num_errors)
+ {
+ error.SetErrorStringWithFormat ("Error compiling %s caller function: \"%s\".",
+ m_function_name.c_str(),
+ errors.GetData());
+ m_caller_up.reset();
+ return nullptr;
+ }
+
+ errors.Clear();
+ ExecutionContext exe_ctx(process_sp);
+
+ if (!m_caller_up->WriteFunctionWrapper(exe_ctx, errors))
+ {
+ error.SetErrorStringWithFormat ("Error inserting caller function for %s: \"%s\".",
+ m_function_name.c_str(),
+ errors.GetData());
+ m_caller_up.reset();
+ return nullptr;
+ }
+ }
+ return m_caller_up.get();
+}
diff --git a/source/Host/common/Editline.cpp b/source/Host/common/Editline.cpp
index ed67d0c2c2b3..4640154c6cb1 100644
--- a/source/Host/common/Editline.cpp
+++ b/source/Host/common/Editline.cpp
@@ -203,7 +203,7 @@ namespace lldb_private
{
snprintf (history_path, sizeof (history_path), "~/%s-widehistory", m_prefix.c_str());
}
- m_path = std::move (FileSpec (history_path, true).GetPath());
+ m_path = FileSpec (history_path, true).GetPath();
}
if (m_path.empty())
return NULL;
@@ -863,34 +863,50 @@ Editline::NextLineCommand (int ch)
unsigned char
Editline::FixIndentationCommand (int ch)
{
- if (!m_fix_indentation_callback)
+ if (!m_fix_indentation_callback)
return CC_NORM;
-
- // Insert the character by hand prior to correction
+
+ // Insert the character typed before proceeding
EditLineCharType inserted[] = { (EditLineCharType)ch, 0 };
el_winsertstr (m_editline, inserted);
- SaveEditedLine();
- StringList lines = GetInputAsStringList (m_current_line_index + 1);
-
- // Determine the cursor position
LineInfoW * info = const_cast<LineInfoW *>(el_wline (m_editline));
int cursor_position = info->cursor - info->buffer;
-
+
+ // Save the edits and determine the correct indentation level
+ SaveEditedLine();
+ StringList lines = GetInputAsStringList (m_current_line_index + 1);
int indent_correction = m_fix_indentation_callback (this, lines, cursor_position, m_fix_indentation_callback_baton);
-
- // Adjust the input buffer to correct indentation
+
+ // If it is already correct no special work is needed
+ if (indent_correction == 0)
+ return CC_REFRESH;
+
+ // Change the indentation level of the line
+ std::string currentLine = lines.GetStringAtIndex (m_current_line_index);
if (indent_correction > 0)
{
- info->cursor = info->buffer;
- el_winsertstr (m_editline, EditLineStringType (indent_correction, EditLineCharType(' ')).c_str());
+ currentLine = currentLine.insert (0, indent_correction, ' ');
}
- else if (indent_correction < 0)
+ else
{
- info->cursor = info->buffer - indent_correction;
- el_wdeletestr (m_editline, -indent_correction);
+ currentLine = currentLine.erase (0, -indent_correction);
}
- info->cursor = info->buffer + cursor_position + indent_correction;
- return CC_REFRESH;
+#if LLDB_EDITLINE_USE_WCHAR
+ m_input_lines[m_current_line_index] = m_utf8conv.from_bytes (currentLine);
+#else
+ m_input_lines[m_current_line_index] = currentLine;
+#endif
+
+ // Update the display to reflect the change
+ MoveCursor (CursorLocation::EditingCursor, CursorLocation::EditingPrompt);
+ DisplayInput (m_current_line_index);
+
+ // Reposition the cursor back on the original line and prepare to restart editing
+ // with a new cursor position
+ SetCurrentLine (m_current_line_index);
+ MoveCursor (CursorLocation::BlockEnd, CursorLocation::EditingPrompt);
+ m_revert_cursor_index = cursor_position + indent_correction;
+ return CC_NEWLINE;
}
unsigned char
diff --git a/source/Host/common/File.cpp b/source/Host/common/File.cpp
index a3420bff65f5..71a6149cd614 100644
--- a/source/Host/common/File.cpp
+++ b/source/Host/common/File.cpp
@@ -22,6 +22,8 @@
#include <sys/ioctl.h>
#endif
+#include "llvm/Support/Process.h" // for llvm::sys::Process::FileDescriptorHasColors()
+
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Log.h"
@@ -143,7 +145,13 @@ File::GetDescriptor() const
// Don't open the file descriptor if we don't need to, just get it from the
// stream if we have one.
if (StreamIsValid())
- return fileno (m_stream);
+ {
+#if defined(LLVM_ON_WIN32)
+ return _fileno(m_stream);
+#else
+ return fileno(m_stream);
+#endif
+ }
// Invalid descriptor and invalid stream, return invalid descriptor.
return kInvalidDescriptor;
@@ -1045,7 +1053,11 @@ File::CalculateInteractiveAndTerminal ()
if (::ioctl (fd, TIOCGWINSZ, &window_size) == 0)
{
if (window_size.ws_col > 0)
+ {
m_is_real_terminal = eLazyBoolYes;
+ if (llvm::sys::Process::FileDescriptorHasColors(fd))
+ m_supports_colors = eLazyBoolYes;
+ }
}
}
#endif
@@ -1068,3 +1080,11 @@ File::GetIsRealTerminal ()
return m_is_real_terminal == eLazyBoolYes;
}
+bool
+File::GetIsTerminalWithColors ()
+{
+ if (m_supports_colors == eLazyBoolCalculate)
+ CalculateInteractiveAndTerminal();
+ return m_supports_colors == eLazyBoolYes;
+}
+
diff --git a/source/Host/common/FileSpec.cpp b/source/Host/common/FileSpec.cpp
index ceb094b9ede7..8885a791d88c 100644
--- a/source/Host/common/FileSpec.cpp
+++ b/source/Host/common/FileSpec.cpp
@@ -107,7 +107,7 @@ FileSpec::ResolveUsername (llvm::SmallVectorImpl<char> &path)
return;
llvm::StringRef path_str(path.data(), path.size());
- size_t slash_pos = path_str.find_first_of("/", 1);
+ size_t slash_pos = path_str.find('/', 1);
if (slash_pos == 1 || path.size() == 1)
{
// A path of ~/ resolves to the current user's home dir
@@ -789,6 +789,28 @@ FileSpec::GetFileType () const
return eFileTypeInvalid;
}
+bool
+FileSpec::IsSymbolicLink () const
+{
+ char resolved_path[PATH_MAX];
+ if (!GetPath (resolved_path, sizeof (resolved_path)))
+ return false;
+
+#ifdef _WIN32
+ auto attrs = ::GetFileAttributes (resolved_path);
+ if (attrs == INVALID_FILE_ATTRIBUTES)
+ return false;
+
+ return (attrs & FILE_ATTRIBUTE_REPARSE_POINT);
+#else
+ struct stat file_stats;
+ if (::lstat (resolved_path, &file_stats) != 0)
+ return false;
+
+ return (file_stats.st_mode & S_IFMT) == S_IFLNK;
+#endif
+}
+
uint32_t
FileSpec::GetPermissions () const
{
@@ -1409,7 +1431,7 @@ FileSpec::AppendPathComponent(const char *new_path)
return;
}
StreamString stream;
- if (m_filename.IsEmpty())
+ if (m_filename.IsEmpty() || (m_filename.GetLength() == 1 && m_filename.GetCString()[0] == '.'))
stream.Printf("%s/%s", m_directory.GetCString(), new_path);
else if (m_directory.IsEmpty())
stream.Printf("%s/%s", m_filename.GetCString(), new_path);
diff --git a/source/Host/common/GetOptInc.cpp b/source/Host/common/GetOptInc.cpp
new file mode 100644
index 000000000000..7689f36c8154
--- /dev/null
+++ b/source/Host/common/GetOptInc.cpp
@@ -0,0 +1,473 @@
+#include "lldb/Host/common/GetOptInc.h"
+
+#if defined(REPLACE_GETOPT) || defined(REPLACE_GETOPT_LONG) || defined(REPLACE_GETOPT_LONG_ONLY)
+
+// getopt.cpp
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if defined(REPLACE_GETOPT)
+int opterr = 1; /* if error message should be printed */
+int optind = 1; /* index into parent argv vector */
+int optopt = '?'; /* character checked for validity */
+int optreset; /* reset getopt */
+char *optarg; /* argument associated with option */
+#endif
+
+#define PRINT_ERROR ((opterr) && (*options != ':'))
+
+#define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */
+#define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */
+#define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */
+
+/* return values */
+#define BADCH (int)'?'
+#define BADARG ((*options == ':') ? (int)':' : (int)'?')
+#define INORDER (int)1
+
+#define EMSG ""
+
+static int getopt_internal(int, char * const *, const char *,
+ const struct option *, int *, int);
+static int parse_long_options(char * const *, const char *,
+ const struct option *, int *, int);
+static int gcd(int, int);
+static void permute_args(int, int, int, char * const *);
+
+static const char *place = EMSG; /* option letter processing */
+
+/* XXX: set optreset to 1 rather than these two */
+static int nonopt_start = -1; /* first non option argument (for permute) */
+static int nonopt_end = -1; /* first option after non options (for permute) */
+
+/*
+* Compute the greatest common divisor of a and b.
+*/
+static int
+gcd(int a, int b)
+{
+ int c;
+
+ c = a % b;
+ while (c != 0) {
+ a = b;
+ b = c;
+ c = a % b;
+ }
+
+ return (b);
+}
+
+static void pass() {}
+#define warnx(a, ...) pass();
+
+/*
+* Exchange the block from nonopt_start to nonopt_end with the block
+* from nonopt_end to opt_end (keeping the same order of arguments
+* in each block).
+*/
+static void
+permute_args(int panonopt_start, int panonopt_end, int opt_end,
+char * const *nargv)
+{
+ int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
+ char *swap;
+
+ /*
+ * compute lengths of blocks and number and size of cycles
+ */
+ nnonopts = panonopt_end - panonopt_start;
+ nopts = opt_end - panonopt_end;
+ ncycle = gcd(nnonopts, nopts);
+ cyclelen = (opt_end - panonopt_start) / ncycle;
+
+ for (i = 0; i < ncycle; i++) {
+ cstart = panonopt_end + i;
+ pos = cstart;
+ for (j = 0; j < cyclelen; j++) {
+ if (pos >= panonopt_end)
+ pos -= nnonopts;
+ else
+ pos += nopts;
+ swap = nargv[pos];
+ /* LINTED const cast */
+ ((char **)nargv)[pos] = nargv[cstart];
+ /* LINTED const cast */
+ ((char **)nargv)[cstart] = swap;
+ }
+ }
+}
+
+/*
+* parse_long_options --
+* Parse long options in argc/argv argument vector.
+* Returns -1 if short_too is set and the option does not match long_options.
+*/
+static int
+parse_long_options(char * const *nargv, const char *options,
+const struct option *long_options, int *idx, int short_too)
+{
+ char *current_argv, *has_equal;
+ size_t current_argv_len;
+ int i, match;
+
+ current_argv = const_cast<char*>(place);
+ match = -1;
+
+ optind++;
+
+ if ((has_equal = strchr(current_argv, '=')) != NULL) {
+ /* argument found (--option=arg) */
+ current_argv_len = has_equal - current_argv;
+ has_equal++;
+ }
+ else
+ current_argv_len = strlen(current_argv);
+
+ for (i = 0; long_options[i].name; i++) {
+ /* find matching long option */
+ if (strncmp(current_argv, long_options[i].name,
+ current_argv_len))
+ continue;
+
+ if (strlen(long_options[i].name) == current_argv_len) {
+ /* exact match */
+ match = i;
+ break;
+ }
+ /*
+ * If this is a known short option, don't allow
+ * a partial match of a single character.
+ */
+ if (short_too && current_argv_len == 1)
+ continue;
+
+ if (match == -1) /* partial match */
+ match = i;
+ else {
+ /* ambiguous abbreviation */
+ if (PRINT_ERROR)
+ warnx(ambig, (int)current_argv_len,
+ current_argv);
+ optopt = 0;
+ return (BADCH);
+ }
+ }
+ if (match != -1) { /* option found */
+ if (long_options[match].has_arg == no_argument
+ && has_equal) {
+ if (PRINT_ERROR)
+ warnx(noarg, (int)current_argv_len,
+ current_argv);
+ /*
+ * XXX: GNU sets optopt to val regardless of flag
+ */
+ if (long_options[match].flag == NULL)
+ optopt = long_options[match].val;
+ else
+ optopt = 0;
+ return (BADARG);
+ }
+ if (long_options[match].has_arg == required_argument ||
+ long_options[match].has_arg == optional_argument) {
+ if (has_equal)
+ optarg = has_equal;
+ else if (long_options[match].has_arg ==
+ required_argument) {
+ /*
+ * optional argument doesn't use next nargv
+ */
+ optarg = nargv[optind++];
+ }
+ }
+ if ((long_options[match].has_arg == required_argument)
+ && (optarg == NULL)) {
+ /*
+ * Missing argument; leading ':' indicates no error
+ * should be generated.
+ */
+ if (PRINT_ERROR)
+ warnx(recargstring,
+ current_argv);
+ /*
+ * XXX: GNU sets optopt to val regardless of flag
+ */
+ if (long_options[match].flag == NULL)
+ optopt = long_options[match].val;
+ else
+ optopt = 0;
+ --optind;
+ return (BADARG);
+ }
+ }
+ else { /* unknown option */
+ if (short_too) {
+ --optind;
+ return (-1);
+ }
+ if (PRINT_ERROR)
+ warnx(illoptstring, current_argv);
+ optopt = 0;
+ return (BADCH);
+ }
+ if (idx)
+ *idx = match;
+ if (long_options[match].flag) {
+ *long_options[match].flag = long_options[match].val;
+ return (0);
+ }
+ else
+ return (long_options[match].val);
+}
+
+/*
+* getopt_internal --
+* Parse argc/argv argument vector. Called by user level routines.
+*/
+static int
+getopt_internal(int nargc, char * const *nargv, const char *options,
+const struct option *long_options, int *idx, int flags)
+{
+ const char *oli; /* option letter list index */
+ int optchar, short_too;
+ static int posixly_correct = -1;
+
+ if (options == NULL)
+ return (-1);
+
+ /*
+ * XXX Some GNU programs (like cvs) set optind to 0 instead of
+ * XXX using optreset. Work around this braindamage.
+ */
+ if (optind == 0)
+ optind = optreset = 1;
+
+ /*
+ * Disable GNU extensions if POSIXLY_CORRECT is set or options
+ * string begins with a '+'.
+ */
+ if (posixly_correct == -1 || optreset)
+ posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
+ if (*options == '-')
+ flags |= FLAG_ALLARGS;
+ else if (posixly_correct || *options == '+')
+ flags &= ~FLAG_PERMUTE;
+ if (*options == '+' || *options == '-')
+ options++;
+
+ optarg = NULL;
+ if (optreset)
+ nonopt_start = nonopt_end = -1;
+start:
+ if (optreset || !*place) { /* update scanning pointer */
+ optreset = 0;
+ if (optind >= nargc) { /* end of argument vector */
+ place = EMSG;
+ if (nonopt_end != -1) {
+ /* do permutation, if we have to */
+ permute_args(nonopt_start, nonopt_end,
+ optind, nargv);
+ optind -= nonopt_end - nonopt_start;
+ }
+ else if (nonopt_start != -1) {
+ /*
+ * If we skipped non-options, set optind
+ * to the first of them.
+ */
+ optind = nonopt_start;
+ }
+ nonopt_start = nonopt_end = -1;
+ return (-1);
+ }
+ if (*(place = nargv[optind]) != '-' ||
+ (place[1] == '\0' && strchr(options, '-') == NULL)) {
+ place = EMSG; /* found non-option */
+ if (flags & FLAG_ALLARGS) {
+ /*
+ * GNU extension:
+ * return non-option as argument to option 1
+ */
+ optarg = nargv[optind++];
+ return (INORDER);
+ }
+ if (!(flags & FLAG_PERMUTE)) {
+ /*
+ * If no permutation wanted, stop parsing
+ * at first non-option.
+ */
+ return (-1);
+ }
+ /* do permutation */
+ if (nonopt_start == -1)
+ nonopt_start = optind;
+ else if (nonopt_end != -1) {
+ permute_args(nonopt_start, nonopt_end,
+ optind, nargv);
+ nonopt_start = optind -
+ (nonopt_end - nonopt_start);
+ nonopt_end = -1;
+ }
+ optind++;
+ /* process next argument */
+ goto start;
+ }
+ if (nonopt_start != -1 && nonopt_end == -1)
+ nonopt_end = optind;
+
+ /*
+ * If we have "-" do nothing, if "--" we are done.
+ */
+ if (place[1] != '\0' && *++place == '-' && place[1] == '\0') {
+ optind++;
+ place = EMSG;
+ /*
+ * We found an option (--), so if we skipped
+ * non-options, we have to permute.
+ */
+ if (nonopt_end != -1) {
+ permute_args(nonopt_start, nonopt_end,
+ optind, nargv);
+ optind -= nonopt_end - nonopt_start;
+ }
+ nonopt_start = nonopt_end = -1;
+ return (-1);
+ }
+ }
+
+ /*
+ * Check long options if:
+ * 1) we were passed some
+ * 2) the arg is not just "-"
+ * 3) either the arg starts with -- we are getopt_long_only()
+ */
+ if (long_options != NULL && place != nargv[optind] &&
+ (*place == '-' || (flags & FLAG_LONGONLY))) {
+ short_too = 0;
+ if (*place == '-')
+ place++; /* --foo long option */
+ else if (*place != ':' && strchr(options, *place) != NULL)
+ short_too = 1; /* could be short option too */
+
+ optchar = parse_long_options(nargv, options, long_options,
+ idx, short_too);
+ if (optchar != -1) {
+ place = EMSG;
+ return (optchar);
+ }
+ }
+
+ if ((optchar = (int)*place++) == (int)':' ||
+ (optchar == (int)'-' && *place != '\0') ||
+ (oli = strchr(options, optchar)) == NULL) {
+ /*
+ * If the user specified "-" and '-' isn't listed in
+ * options, return -1 (non-option) as per POSIX.
+ * Otherwise, it is an unknown option character (or ':').
+ */
+ if (optchar == (int)'-' && *place == '\0')
+ return (-1);
+ if (!*place)
+ ++optind;
+ if (PRINT_ERROR)
+ warnx(illoptchar, optchar);
+ optopt = optchar;
+ return (BADCH);
+ }
+ if (long_options != NULL && optchar == 'W' && oli[1] == ';') {
+ /* -W long-option */
+ if (*place) /* no space */
+ /* NOTHING */;
+ else if (++optind >= nargc) { /* no arg */
+ place = EMSG;
+ if (PRINT_ERROR)
+ warnx(recargchar, optchar);
+ optopt = optchar;
+ return (BADARG);
+ }
+ else /* white space */
+ place = nargv[optind];
+ optchar = parse_long_options(nargv, options, long_options,
+ idx, 0);
+ place = EMSG;
+ return (optchar);
+ }
+ if (*++oli != ':') { /* doesn't take argument */
+ if (!*place)
+ ++optind;
+ }
+ else { /* takes (optional) argument */
+ optarg = NULL;
+ if (*place) /* no white space */
+ optarg = const_cast<char*>(place);
+ else if (oli[1] != ':') { /* arg not optional */
+ if (++optind >= nargc) { /* no arg */
+ place = EMSG;
+ if (PRINT_ERROR)
+ warnx(recargchar, optchar);
+ optopt = optchar;
+ return (BADARG);
+ }
+ else
+ optarg = nargv[optind];
+ }
+ place = EMSG;
+ ++optind;
+ }
+ /* dump back option letter */
+ return (optchar);
+}
+
+/*
+* getopt --
+* Parse argc/argv argument vector.
+*
+* [eventually this will replace the BSD getopt]
+*/
+#if defined(REPLACE_GETOPT)
+int
+getopt(int nargc, char * const *nargv, const char *options)
+{
+
+ /*
+ * We don't pass FLAG_PERMUTE to getopt_internal() since
+ * the BSD getopt(3) (unlike GNU) has never done this.
+ *
+ * Furthermore, since many privileged programs call getopt()
+ * before dropping privileges it makes sense to keep things
+ * as simple (and bug-free) as possible.
+ */
+ return (getopt_internal(nargc, nargv, options, NULL, NULL, 0));
+}
+#endif
+
+/*
+* getopt_long --
+* Parse argc/argv argument vector.
+*/
+#if defined(REPLACE_GETOPT_LONG)
+int
+getopt_long(int nargc, char * const *nargv, const char *options,
+const struct option *long_options, int *idx)
+{
+ return (getopt_internal(nargc, nargv, options, long_options, idx,
+ FLAG_PERMUTE));
+}
+#endif
+
+/*
+* getopt_long_only --
+* Parse argc/argv argument vector.
+*/
+#if defined(REPLACE_GETOPT_LONG_ONLY)
+int
+getopt_long_only(int nargc, char * const *nargv, const char *options,
+const struct option *long_options, int *idx)
+{
+
+ return (getopt_internal(nargc, nargv, options, long_options, idx,
+ FLAG_PERMUTE | FLAG_LONGONLY));
+}
+#endif
+
+#endif
diff --git a/source/Host/common/Host.cpp b/source/Host/common/Host.cpp
index 94c78a015651..e89f4def478c 100644
--- a/source/Host/common/Host.cpp
+++ b/source/Host/common/Host.cpp
@@ -143,7 +143,11 @@ private:
#endif // __linux__
#ifdef __linux__
+#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8))
+static __thread volatile sig_atomic_t g_usr1_called;
+#else
static thread_local volatile sig_atomic_t g_usr1_called;
+#endif
static void
SigUsr1Handler (int)
@@ -816,8 +820,8 @@ Host::LaunchProcessPosixSpawn(const char *exe_path, const ProcessLaunchInfo &lau
#endif
const char *tmp_argv[2];
- char * const *argv = (char * const*)launch_info.GetArguments().GetConstArgumentVector();
- char * const *envp = (char * const*)launch_info.GetEnvironmentEntries().GetConstArgumentVector();
+ char * const *argv = const_cast<char * const*>(launch_info.GetArguments().GetConstArgumentVector());
+ char * const *envp = const_cast<char * const*>(launch_info.GetEnvironmentEntries().GetConstArgumentVector());
if (argv == NULL)
{
// posix_spawn gets very unhappy if it doesn't have at least the program
@@ -825,7 +829,7 @@ Host::LaunchProcessPosixSpawn(const char *exe_path, const ProcessLaunchInfo &lau
// variables don't make it into the child process if "argv == NULL"!!!
tmp_argv[0] = exe_path;
tmp_argv[1] = NULL;
- argv = (char * const*)tmp_argv;
+ argv = const_cast<char * const*>(tmp_argv);
}
#if !defined (__APPLE__)
diff --git a/source/Host/common/HostInfoBase.cpp b/source/Host/common/HostInfoBase.cpp
index e969e33190eb..0f4324f83dd6 100644
--- a/source/Host/common/HostInfoBase.cpp
+++ b/source/Host/common/HostInfoBase.cpp
@@ -20,6 +20,7 @@
#include "llvm/ADT/Triple.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Host.h"
+#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include <thread>
@@ -102,7 +103,7 @@ HostInfoBase::GetVendorString()
{
static std::once_flag g_once_flag;
std::call_once(g_once_flag, []() {
- g_fields->m_vendor_string = std::move(HostInfo::GetArchitecture().GetTriple().getVendorName().str());
+ g_fields->m_vendor_string = HostInfo::GetArchitecture().GetTriple().getVendorName().str();
});
return g_fields->m_vendor_string;
}
@@ -306,7 +307,10 @@ HostInfoBase::ComputeSharedLibraryDirectory(FileSpec &file_spec)
FileSpec lldb_file_spec(
Host::GetModuleFileSpecForHostAddress(reinterpret_cast<void *>(reinterpret_cast<intptr_t>(HostInfoBase::GetLLDBPath))));
-
+
+ // This is necessary because when running the testsuite the shlib might be a symbolic link inside the Python resource dir.
+ FileSystem::ResolveSymbolicLink(lldb_file_spec, lldb_file_spec);
+
// Remove the filename so that this FileSpec only represents the directory.
file_spec.GetDirectory() = lldb_file_spec.GetDirectory();
@@ -341,19 +345,9 @@ HostInfoBase::ComputeProcessTempFileDirectory(FileSpec &file_spec)
bool
HostInfoBase::ComputeTempFileBaseDirectory(FileSpec &file_spec)
{
- file_spec.Clear();
-
- const char *tmpdir_cstr = getenv("TMPDIR");
- if (tmpdir_cstr == nullptr)
- {
- tmpdir_cstr = getenv("TMP");
- if (tmpdir_cstr == nullptr)
- tmpdir_cstr = getenv("TEMP");
- }
- if (!tmpdir_cstr)
- return false;
-
- file_spec = FileSpec(tmpdir_cstr, false);
+ llvm::SmallVector<char, 16> tmpdir;
+ llvm::sys::path::system_temp_directory(/*ErasedOnReboot*/ true, tmpdir);
+ file_spec = FileSpec(std::string(tmpdir.data(), tmpdir.size()), true);
return true;
}
diff --git a/source/Host/common/Mutex.cpp b/source/Host/common/Mutex.cpp
index c26467fa0d79..98f5321ad67f 100644
--- a/source/Host/common/Mutex.cpp
+++ b/source/Host/common/Mutex.cpp
@@ -27,7 +27,7 @@
#endif
// Enable extra mutex error checking
-#ifdef LLDB_CONFIGURATION_DEBUG
+#if 0 // LLDB_CONFIGURATION_DEBUG
#define ENABLE_MUTEX_ERROR_CHECKING 1
#include <inttypes.h>
#endif
diff --git a/source/Host/common/NativeProcessProtocol.cpp b/source/Host/common/NativeProcessProtocol.cpp
index 818d69bdabdc..7d2f4012bf85 100644
--- a/source/Host/common/NativeProcessProtocol.cpp
+++ b/source/Host/common/NativeProcessProtocol.cpp
@@ -436,12 +436,6 @@ NativeProcessProtocol::DoStopIDBumped (uint32_t /* newBumpId */)
// Default implementation does nothing.
}
-void
-NativeProcessProtocol::Terminate ()
-{
- // Default implementation does nothing.
-}
-
#ifndef __linux__
// These need to be implemented to support lldb-gdb-server on a given platform. Stubs are
// provided to make the rest of the code link on non-supported platforms.
@@ -449,6 +443,7 @@ NativeProcessProtocol::Terminate ()
Error
NativeProcessProtocol::Launch (ProcessLaunchInfo &launch_info,
NativeDelegate &native_delegate,
+ MainLoop &mainloop,
NativeProcessProtocolSP &process_sp)
{
llvm_unreachable("Platform has no NativeProcessProtocol support");
@@ -457,6 +452,7 @@ NativeProcessProtocol::Launch (ProcessLaunchInfo &launch_info,
Error
NativeProcessProtocol::Attach (lldb::pid_t pid,
NativeDelegate &native_delegate,
+ MainLoop &mainloop,
NativeProcessProtocolSP &process_sp)
{
llvm_unreachable("Platform has no NativeProcessProtocol support");
diff --git a/source/Host/common/OptionParser.cpp b/source/Host/common/OptionParser.cpp
index a91e764bfe3b..a9784592a738 100644
--- a/source/Host/common/OptionParser.cpp
+++ b/source/Host/common/OptionParser.cpp
@@ -16,8 +16,10 @@
using namespace lldb_private;
void
-OptionParser::Prepare()
+OptionParser::Prepare(Mutex::Locker &locker)
{
+ static Mutex g_mutex(Mutex::eMutexTypeNormal);
+ locker.Lock(g_mutex);
#ifdef __GLIBC__
optind = 0;
#else
diff --git a/source/Host/common/Socket.cpp b/source/Host/common/Socket.cpp
index f7e93c634a12..91a5e37424e6 100644
--- a/source/Host/common/Socket.cpp
+++ b/source/Host/common/Socket.cpp
@@ -12,21 +12,16 @@
#include "lldb/Core/Log.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Host/Config.h"
-#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/SocketAddress.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Host/TimeValue.h"
-
-#ifdef __ANDROID_NDK__
-#include <linux/tcp.h>
-#include <bits/error_constants.h>
-#include <asm-generic/errno-base.h>
-#include <errno.h>
-#include <arpa/inet.h>
-#endif
+#include "lldb/Host/common/TCPSocket.h"
+#include "lldb/Host/common/UDPSocket.h"
#ifndef LLDB_DISABLE_POSIX
+#include "lldb/Host/posix/DomainSocket.h"
+
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
@@ -35,6 +30,23 @@
#include <sys/un.h>
#endif
+#ifdef __linux__
+#include "lldb/Host/linux/AbstractSocket.h"
+#endif
+
+#ifdef __ANDROID_NDK__
+#include <linux/tcp.h>
+#include <bits/error_constants.h>
+#include <asm-generic/errno-base.h>
+#include <errno.h>
+#include <arpa/inet.h>
+#if defined(ANDROID_ARM_BUILD_STATIC) || defined(ANDROID_MIPS_BUILD_STATIC)
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <fcntl.h>
+#endif // ANDROID_ARM_BUILD_STATIC || ANDROID_MIPS_BUILD_STATIC
+#endif // __ANDROID_NDK__
+
using namespace lldb;
using namespace lldb_private;
@@ -48,48 +60,8 @@ typedef void * get_socket_option_arg_type;
const NativeSocket Socket::kInvalidSocketValue = -1;
#endif // #if defined(_WIN32)
-#ifdef __ANDROID__
-// Android does not have SUN_LEN
-#ifndef SUN_LEN
-#define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) + strlen((ptr)->sun_path))
-#endif
-#endif // #ifdef __ANDROID__
-
namespace {
-NativeSocket CreateSocket(const int domain, const int type, const int protocol, bool child_processes_inherit)
-{
- auto socketType = type;
-#ifdef SOCK_CLOEXEC
- if (!child_processes_inherit) {
- socketType |= SOCK_CLOEXEC;
- }
-#endif
- return ::socket (domain, socketType, protocol);
-}
-
-NativeSocket Accept(NativeSocket sockfd, struct sockaddr *addr, socklen_t *addrlen, bool child_processes_inherit)
-{
-#ifdef SOCK_CLOEXEC
- int flags = 0;
- if (!child_processes_inherit) {
- flags |= SOCK_CLOEXEC;
- }
- return ::accept4 (sockfd, addr, addrlen, flags);
-#else
- return ::accept (sockfd, addr, addrlen);
-#endif
-}
-
-void SetLastError(Error &error)
-{
-#if defined(_WIN32)
- error.SetError(::WSAGetLastError(), lldb::eErrorTypeWin32);
-#else
- error.SetErrorToErrno();
-#endif
-}
-
bool IsInterrupted()
{
#if defined(_WIN32)
@@ -114,128 +86,84 @@ Socket::~Socket()
Close();
}
-Error Socket::TcpConnect(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&socket)
+std::unique_ptr<Socket> Socket::Create(const SocketProtocol protocol, bool child_processes_inherit, Error &error)
{
- // Store the result in a unique_ptr in case we error out, the memory will get correctly freed.
- std::unique_ptr<Socket> final_socket;
- NativeSocket sock = kInvalidSocketValue;
- Error error;
-
- Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_HOST));
- if (log)
- log->Printf ("Socket::TcpConnect (host/port = %s)", host_and_port.data());
-
- std::string host_str;
- std::string port_str;
- int32_t port = INT32_MIN;
- if (!DecodeHostAndPort (host_and_port, host_str, port_str, port, &error))
- return error;
-
- // Create the socket
- sock = CreateSocket (AF_INET, SOCK_STREAM, IPPROTO_TCP, child_processes_inherit);
- if (sock == kInvalidSocketValue)
- {
- SetLastError (error);
- return error;
- }
-
- // Since they both refer to the same socket descriptor, arbitrarily choose the send socket to
- // be the owner.
- final_socket.reset(new Socket(sock, ProtocolTcp, true));
-
- // Enable local address reuse
- final_socket->SetOption(SOL_SOCKET, SO_REUSEADDR, 1);
-
- struct sockaddr_in sa;
- ::memset (&sa, 0, sizeof (sa));
- sa.sin_family = AF_INET;
- sa.sin_port = htons (port);
-
- int inet_pton_result = ::inet_pton (AF_INET, host_str.c_str(), &sa.sin_addr);
+ error.Clear();
- if (inet_pton_result <= 0)
+ std::unique_ptr<Socket> socket_up;
+ switch (protocol)
{
- struct hostent *host_entry = gethostbyname (host_str.c_str());
- if (host_entry)
- host_str = ::inet_ntoa (*(struct in_addr *)*host_entry->h_addr_list);
- inet_pton_result = ::inet_pton (AF_INET, host_str.c_str(), &sa.sin_addr);
- if (inet_pton_result <= 0)
- {
- if (inet_pton_result == -1)
- SetLastError(error);
- else
- error.SetErrorStringWithFormat("invalid host string: '%s'", host_str.c_str());
-
- return error;
- }
+ case ProtocolTcp:
+ socket_up.reset(new TCPSocket(child_processes_inherit, error));
+ break;
+ case ProtocolUdp:
+ socket_up.reset(new UDPSocket(child_processes_inherit, error));
+ break;
+ case ProtocolUnixDomain:
+#ifndef LLDB_DISABLE_POSIX
+ socket_up.reset(new DomainSocket(child_processes_inherit, error));
+#else
+ error.SetErrorString("Unix domain sockets are not supported on this platform.");
+#endif
+ break;
+ case ProtocolUnixAbstract:
+#ifdef __linux__
+ socket_up.reset(new AbstractSocket(child_processes_inherit, error));
+#else
+ error.SetErrorString("Abstract domain sockets are not supported on this platform.");
+#endif
+ break;
}
- if (-1 == ::connect (sock, (const struct sockaddr *)&sa, sizeof(sa)))
- {
- SetLastError (error);
- return error;
- }
+ if (error.Fail())
+ socket_up.reset();
- // Keep our TCP packets coming without any delays.
- final_socket->SetOption(IPPROTO_TCP, TCP_NODELAY, 1);
- error.Clear();
- socket = final_socket.release();
- return error;
+ return socket_up;
}
-Error Socket::TcpListen(
- llvm::StringRef host_and_port,
- bool child_processes_inherit,
- Socket *&socket,
- Predicate<uint16_t>* predicate,
- int backlog)
+Error Socket::TcpConnect(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&socket)
{
- std::unique_ptr<Socket> listen_socket;
- NativeSocket listen_sock = kInvalidSocketValue;
- Error error;
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION));
+ if (log)
+ log->Printf ("Socket::%s (host/port = %s)", __FUNCTION__, host_and_port.data());
- const sa_family_t family = AF_INET;
- const int socktype = SOCK_STREAM;
- const int protocol = IPPROTO_TCP;
- listen_sock = ::CreateSocket (family, socktype, protocol, child_processes_inherit);
- if (listen_sock == kInvalidSocketValue)
- {
- SetLastError (error);
+ Error error;
+ std::unique_ptr<Socket> connect_socket(Create(ProtocolTcp, child_processes_inherit, error));
+ if (error.Fail())
return error;
- }
- listen_socket.reset(new Socket(listen_sock, ProtocolTcp, true));
+ error = connect_socket->Connect(host_and_port);
+ if (error.Success())
+ socket = connect_socket.release();
- // enable local address reuse
- listen_socket->SetOption(SOL_SOCKET, SO_REUSEADDR, 1);
+ return error;
+}
+Error
+Socket::TcpListen (llvm::StringRef host_and_port,
+ bool child_processes_inherit,
+ Socket *&socket,
+ Predicate<uint16_t>* predicate,
+ int backlog)
+{
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
if (log)
- log->Printf ("Socket::TcpListen (%s)", host_and_port.data());
+ log->Printf ("Socket::%s (%s)", __FUNCTION__, host_and_port.data());
+ Error error;
std::string host_str;
std::string port_str;
int32_t port = INT32_MIN;
if (!DecodeHostAndPort (host_and_port, host_str, port_str, port, &error))
return error;
- SocketAddress anyaddr;
- if (anyaddr.SetToAnyAddress (family, port))
- {
- int err = ::bind (listen_sock, anyaddr, anyaddr.GetLength());
- if (err == -1)
- {
- SetLastError (error);
- return error;
- }
-
- err = ::listen (listen_sock, backlog);
- if (err == -1)
- {
- SetLastError (error);
- return error;
- }
+ std::unique_ptr<TCPSocket> listen_socket(new TCPSocket(child_processes_inherit, error));
+ if (error.Fail())
+ return error;
+ error = listen_socket->Listen(host_and_port, backlog);
+ if (error.Success())
+ {
// We were asked to listen on port zero which means we
// must now read the actual port that was given to us
// as port zero is a special code for "find an open port
@@ -250,287 +178,77 @@ Error Socket::TcpListen(
// another thread in an efficient manor.
if (predicate)
predicate->SetValue (port, eBroadcastAlways);
-
socket = listen_socket.release();
}
return error;
}
-Error Socket::BlockingAccept(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&socket)
-{
- Error error;
- std::string host_str;
- std::string port_str;
- int32_t port;
- if (!DecodeHostAndPort(host_and_port, host_str, port_str, port, &error))
- return error;
-
- const sa_family_t family = AF_INET;
- const int socktype = SOCK_STREAM;
- const int protocol = IPPROTO_TCP;
- SocketAddress listen_addr;
- if (host_str.empty())
- listen_addr.SetToLocalhost(family, port);
- else if (host_str.compare("*") == 0)
- listen_addr.SetToAnyAddress(family, port);
- else
- {
- if (!listen_addr.getaddrinfo(host_str.c_str(), port_str.c_str(), family, socktype, protocol))
- {
- error.SetErrorStringWithFormat("unable to resolve hostname '%s'", host_str.c_str());
- return error;
- }
- }
-
- bool accept_connection = false;
- std::unique_ptr<Socket> accepted_socket;
-
- // Loop until we are happy with our connection
- while (!accept_connection)
- {
- struct sockaddr_in accept_addr;
- ::memset (&accept_addr, 0, sizeof accept_addr);
-#if !(defined (__linux__) || defined(_WIN32))
- accept_addr.sin_len = sizeof accept_addr;
-#endif
- socklen_t accept_addr_len = sizeof accept_addr;
-
- int sock = Accept (this->GetNativeSocket(),
- (struct sockaddr *)&accept_addr,
- &accept_addr_len,
- child_processes_inherit);
-
- if (sock == kInvalidSocketValue)
- {
- SetLastError (error);
- break;
- }
-
- bool is_same_addr = true;
-#if !(defined(__linux__) || (defined(_WIN32)))
- is_same_addr = (accept_addr_len == listen_addr.sockaddr_in().sin_len);
-#endif
- if (is_same_addr)
- is_same_addr = (accept_addr.sin_addr.s_addr == listen_addr.sockaddr_in().sin_addr.s_addr);
-
- if (is_same_addr || (listen_addr.sockaddr_in().sin_addr.s_addr == INADDR_ANY))
- {
- accept_connection = true;
- // Since both sockets have the same descriptor, arbitrarily choose the send
- // socket to be the owner.
- accepted_socket.reset(new Socket(sock, ProtocolTcp, true));
- }
- else
- {
- const uint8_t *accept_ip = (const uint8_t *)&accept_addr.sin_addr.s_addr;
- const uint8_t *listen_ip = (const uint8_t *)&listen_addr.sockaddr_in().sin_addr.s_addr;
- ::fprintf (stderr, "error: rejecting incoming connection from %u.%u.%u.%u (expecting %u.%u.%u.%u)\n",
- accept_ip[0], accept_ip[1], accept_ip[2], accept_ip[3],
- listen_ip[0], listen_ip[1], listen_ip[2], listen_ip[3]);
- accepted_socket.reset();
- }
- }
-
- if (!accepted_socket)
- return error;
-
- // Keep our TCP packets coming without any delays.
- accepted_socket->SetOption (IPPROTO_TCP, TCP_NODELAY, 1);
- error.Clear();
- socket = accepted_socket.release();
- return error;
-
-}
-
Error Socket::UdpConnect(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&send_socket, Socket *&recv_socket)
{
- std::unique_ptr<Socket> final_send_socket;
- std::unique_ptr<Socket> final_recv_socket;
- NativeSocket final_send_fd = kInvalidSocketValue;
- NativeSocket final_recv_fd = kInvalidSocketValue;
-
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
if (log)
- log->Printf ("Socket::UdpConnect (host/port = %s)", host_and_port.data());
+ log->Printf ("Socket::%s (host/port = %s)", __FUNCTION__, host_and_port.data());
+ return UDPSocket::Connect(host_and_port, child_processes_inherit, send_socket, recv_socket);
+}
+
+Error Socket::UnixDomainConnect(llvm::StringRef name, bool child_processes_inherit, Socket *&socket)
+{
Error error;
- std::string host_str;
- std::string port_str;
- int32_t port = INT32_MIN;
- if (!DecodeHostAndPort (host_and_port, host_str, port_str, port, &error))
+ std::unique_ptr<Socket> connect_socket(Create(ProtocolUnixDomain, child_processes_inherit, error));
+ if (error.Fail())
return error;
- // Setup the receiving end of the UDP connection on this localhost
- // on port zero. After we bind to port zero we can read the port.
- final_recv_fd = ::CreateSocket (AF_INET, SOCK_DGRAM, 0, child_processes_inherit);
- if (final_recv_fd == kInvalidSocketValue)
- {
- // Socket creation failed...
- SetLastError (error);
- }
- else
- {
- final_recv_socket.reset(new Socket(final_recv_fd, ProtocolUdp, true));
-
- // Socket was created, now lets bind to the requested port
- SocketAddress addr;
- addr.SetToAnyAddress (AF_INET, 0);
+ error = connect_socket->Connect(name);
+ if (error.Success())
+ socket = connect_socket.release();
- if (::bind (final_recv_fd, addr, addr.GetLength()) == -1)
- {
- // Bind failed...
- SetLastError (error);
- }
- }
+ return error;
+}
- assert(error.Fail() == !(final_recv_socket && final_recv_socket->IsValid()));
+Error Socket::UnixDomainAccept(llvm::StringRef name, bool child_processes_inherit, Socket *&socket)
+{
+ Error error;
+ std::unique_ptr<Socket> listen_socket(Create(ProtocolUnixDomain, child_processes_inherit, error));
if (error.Fail())
return error;
- // At this point we have setup the receive port, now we need to
- // setup the UDP send socket
-
- struct addrinfo hints;
- struct addrinfo *service_info_list = NULL;
-
- ::memset (&hints, 0, sizeof(hints));
- hints.ai_family = AF_INET;
- hints.ai_socktype = SOCK_DGRAM;
- int err = ::getaddrinfo (host_str.c_str(), port_str.c_str(), &hints, &service_info_list);
- if (err != 0)
- {
- error.SetErrorStringWithFormat("getaddrinfo(%s, %s, &hints, &info) returned error %i (%s)",
- host_str.c_str(),
- port_str.c_str(),
- err,
- gai_strerror(err));
- return error;
- }
-
- for (struct addrinfo *service_info_ptr = service_info_list;
- service_info_ptr != NULL;
- service_info_ptr = service_info_ptr->ai_next)
- {
- final_send_fd = ::CreateSocket (service_info_ptr->ai_family,
- service_info_ptr->ai_socktype,
- service_info_ptr->ai_protocol,
- child_processes_inherit);
-
- if (final_send_fd != kInvalidSocketValue)
- {
- final_send_socket.reset(new Socket(final_send_fd, ProtocolUdp, true));
- final_send_socket->m_udp_send_sockaddr = service_info_ptr;
- break;
- }
- else
- continue;
- }
-
- :: freeaddrinfo (service_info_list);
-
- if (final_send_fd == kInvalidSocketValue)
- {
- SetLastError (error);
+ error = listen_socket->Listen(name, 5);
+ if (error.Fail())
return error;
- }
- send_socket = final_send_socket.release();
- recv_socket = final_recv_socket.release();
- error.Clear();
+ error = listen_socket->Accept(name, child_processes_inherit, socket);
return error;
}
-Error Socket::UnixDomainConnect(llvm::StringRef name, bool child_processes_inherit, Socket *&socket)
+Error
+Socket::UnixAbstractConnect(llvm::StringRef name, bool child_processes_inherit, Socket *&socket)
{
Error error;
-#ifndef LLDB_DISABLE_POSIX
- std::unique_ptr<Socket> final_socket;
-
- // Open the socket that was passed in as an option
- struct sockaddr_un saddr_un;
- int fd = ::CreateSocket (AF_UNIX, SOCK_STREAM, 0, child_processes_inherit);
- if (fd == kInvalidSocketValue)
- {
- SetLastError (error);
- return error;
- }
-
- final_socket.reset(new Socket(fd, ProtocolUnixDomain, true));
-
- saddr_un.sun_family = AF_UNIX;
- ::strncpy(saddr_un.sun_path, name.data(), sizeof(saddr_un.sun_path) - 1);
- saddr_un.sun_path[sizeof(saddr_un.sun_path) - 1] = '\0';
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
- saddr_un.sun_len = SUN_LEN (&saddr_un);
-#endif
-
- if (::connect (fd, (struct sockaddr *)&saddr_un, SUN_LEN (&saddr_un)) < 0)
- {
- SetLastError (error);
+ std::unique_ptr<Socket> connect_socket(Create(ProtocolUnixAbstract, child_processes_inherit, error));
+ if (error.Fail())
return error;
- }
- socket = final_socket.release();
-#else
- error.SetErrorString("Unix domain sockets are not supported on this platform.");
-#endif
+ error = connect_socket->Connect(name);
+ if (error.Success())
+ socket = connect_socket.release();
return error;
}
-Error Socket::UnixDomainAccept(llvm::StringRef name, bool child_processes_inherit, Socket *&socket)
+Error
+Socket::UnixAbstractAccept(llvm::StringRef name, bool child_processes_inherit, Socket *&socket)
{
Error error;
-#ifndef LLDB_DISABLE_POSIX
- struct sockaddr_un saddr_un;
- std::unique_ptr<Socket> listen_socket;
- std::unique_ptr<Socket> final_socket;
- NativeSocket listen_fd = kInvalidSocketValue;
- NativeSocket socket_fd = kInvalidSocketValue;
-
- listen_fd = ::CreateSocket (AF_UNIX, SOCK_STREAM, 0, child_processes_inherit);
- if (listen_fd == kInvalidSocketValue)
- {
- SetLastError (error);
+ std::unique_ptr<Socket> listen_socket(Create(ProtocolUnixAbstract,child_processes_inherit, error));
+ if (error.Fail())
return error;
- }
-
- listen_socket.reset(new Socket(listen_fd, ProtocolUnixDomain, true));
-
- saddr_un.sun_family = AF_UNIX;
- ::strncpy(saddr_un.sun_path, name.data(), sizeof(saddr_un.sun_path) - 1);
- saddr_un.sun_path[sizeof(saddr_un.sun_path) - 1] = '\0';
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
- saddr_un.sun_len = SUN_LEN (&saddr_un);
-#endif
- FileSystem::Unlink(FileSpec{name, true});
- bool success = false;
- if (::bind (listen_fd, (struct sockaddr *)&saddr_un, SUN_LEN (&saddr_un)) == 0)
- {
- if (::listen (listen_fd, 5) == 0)
- {
- socket_fd = Accept (listen_fd, NULL, 0, child_processes_inherit);
- if (socket_fd > 0)
- {
- final_socket.reset(new Socket(socket_fd, ProtocolUnixDomain, true));
- success = true;
- }
- }
- }
-
- if (!success)
- {
- SetLastError (error);
+ error = listen_socket->Listen(name, 5);
+ if (error.Fail())
return error;
- }
- // We are done with the listen port
- listen_socket.reset();
- socket = final_socket.release();
-#else
- error.SetErrorString("Unix domain sockets are not supported on this platform.");
-#endif
+ error = listen_socket->Accept(name, child_processes_inherit, socket);
return error;
}
@@ -605,7 +323,7 @@ Error Socket::Read (void *buf, size_t &num_bytes)
else
num_bytes = bytes_received;
- Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_HOST | LIBLLDB_LOG_COMMUNICATION));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION));
if (log)
{
log->Printf ("%p Socket::Read() (socket = %" PRIu64 ", src = %p, src_len = %" PRIu64 ", flags = 0) => %" PRIi64 " (error = %s)",
@@ -626,17 +344,7 @@ Error Socket::Write (const void *buf, size_t &num_bytes)
int bytes_sent = 0;
do
{
- if (m_protocol == ProtocolUdp)
- {
- bytes_sent = ::sendto (m_socket,
- static_cast<const char*>(buf),
- num_bytes,
- 0,
- m_udp_send_sockaddr,
- m_udp_send_sockaddr.GetLength());
- }
- else
- bytes_sent = ::send (m_socket, static_cast<const char *>(buf), num_bytes, 0);
+ bytes_sent = Send(buf, num_bytes);
} while (bytes_sent < 0 && IsInterrupted ());
if (bytes_sent < 0)
@@ -647,7 +355,7 @@ Error Socket::Write (const void *buf, size_t &num_bytes)
else
num_bytes = bytes_sent;
- Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_HOST));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION));
if (log)
{
log->Printf ("%p Socket::Write() (socket = %" PRIu64 ", src = %p, src_len = %" PRIu64 ", flags = 0) => %" PRIi64 " (error = %s)",
@@ -698,70 +406,84 @@ int Socket::GetOption(int level, int option_name, int &option_value)
{
get_socket_option_arg_type option_value_p = reinterpret_cast<get_socket_option_arg_type>(&option_value);
socklen_t option_value_size = sizeof(int);
- return ::getsockopt(m_socket, level, option_name, option_value_p, &option_value_size);
+ return ::getsockopt(m_socket, level, option_name, option_value_p, &option_value_size);
}
int Socket::SetOption(int level, int option_name, int option_value)
{
set_socket_option_arg_type option_value_p = reinterpret_cast<get_socket_option_arg_type>(&option_value);
- return ::setsockopt(m_socket, level, option_name, option_value_p, sizeof(option_value));
+ return ::setsockopt(m_socket, level, option_name, option_value_p, sizeof(option_value));
}
-uint16_t Socket::GetLocalPortNumber(const NativeSocket& socket)
+size_t Socket::Send(const void *buf, const size_t num_bytes)
{
- // We bound to port zero, so we need to figure out which port we actually bound to
- if (socket != kInvalidSocketValue)
- {
- SocketAddress sock_addr;
- socklen_t sock_addr_len = sock_addr.GetMaxLength ();
- if (::getsockname (socket, sock_addr, &sock_addr_len) == 0)
- return sock_addr.GetPort ();
- }
- return 0;
+ return ::send (m_socket, static_cast<const char *>(buf), num_bytes, 0);
}
-// Return the port number that is being used by the socket.
-uint16_t Socket::GetLocalPortNumber() const
+void Socket::SetLastError(Error &error)
{
- return GetLocalPortNumber (m_socket);
+#if defined(_WIN32)
+ error.SetError(::WSAGetLastError(), lldb::eErrorTypeWin32);
+#else
+ error.SetErrorToErrno();
+#endif
}
-std::string Socket::GetLocalIPAddress () const
+NativeSocket
+Socket::CreateSocket(const int domain,
+ const int type,
+ const int protocol,
+ bool child_processes_inherit,
+ Error& error)
{
- // We bound to port zero, so we need to figure out which port we actually bound to
- if (m_socket != kInvalidSocketValue)
- {
- SocketAddress sock_addr;
- socklen_t sock_addr_len = sock_addr.GetMaxLength ();
- if (::getsockname (m_socket, sock_addr, &sock_addr_len) == 0)
- return sock_addr.GetIPAddress ();
- }
- return "";
-}
+ error.Clear();
+ auto socketType = type;
+#ifdef SOCK_CLOEXEC
+ if (!child_processes_inherit)
+ socketType |= SOCK_CLOEXEC;
+#endif
+ auto sock = ::socket (domain, socketType, protocol);
+ if (sock == kInvalidSocketValue)
+ SetLastError(error);
-uint16_t Socket::GetRemotePortNumber () const
-{
- if (m_socket != kInvalidSocketValue)
- {
- SocketAddress sock_addr;
- socklen_t sock_addr_len = sock_addr.GetMaxLength ();
- if (::getpeername (m_socket, sock_addr, &sock_addr_len) == 0)
- return sock_addr.GetPort ();
- }
- return 0;
+ return sock;
}
-std::string Socket::GetRemoteIPAddress () const
+NativeSocket
+Socket::AcceptSocket(NativeSocket sockfd,
+ struct sockaddr *addr,
+ socklen_t *addrlen,
+ bool child_processes_inherit,
+ Error& error)
{
- // We bound to port zero, so we need to figure out which port we actually bound to
- if (m_socket != kInvalidSocketValue)
+ error.Clear();
+#if defined(ANDROID_ARM_BUILD_STATIC) || defined(ANDROID_MIPS_BUILD_STATIC)
+ // Temporary workaround for statically linking Android lldb-server with the
+ // latest API.
+ int fd = syscall(__NR_accept, sockfd, addr, addrlen);
+ if (fd >= 0 && !child_processes_inherit)
{
- SocketAddress sock_addr;
- socklen_t sock_addr_len = sock_addr.GetMaxLength ();
- if (::getpeername (m_socket, sock_addr, &sock_addr_len) == 0)
- return sock_addr.GetIPAddress ();
+ int flags = ::fcntl(fd, F_GETFD);
+ if (flags != -1 && ::fcntl(fd, F_SETFD, flags | FD_CLOEXEC) != -1)
+ return fd;
+ SetLastError(error);
+ close(fd);
+ }
+ return fd;
+#elif defined(SOCK_CLOEXEC)
+ int flags = 0;
+ if (!child_processes_inherit) {
+ flags |= SOCK_CLOEXEC;
}
- return "";
+#if defined(__NetBSD__)
+ NativeSocket fd = ::paccept (sockfd, addr, addrlen, nullptr, flags);
+#else
+ NativeSocket fd = ::accept4 (sockfd, addr, addrlen, flags);
+#endif
+#else
+ NativeSocket fd = ::accept (sockfd, addr, addrlen);
+#endif
+ if (fd == kInvalidSocketValue)
+ SetLastError(error);
+ return fd;
}
-
-
diff --git a/source/Host/common/SocketAddress.cpp b/source/Host/common/SocketAddress.cpp
index 3ab6cfeec4a0..c8b1687c378e 100644
--- a/source/Host/common/SocketAddress.cpp
+++ b/source/Host/common/SocketAddress.cpp
@@ -304,8 +304,10 @@ SocketAddress::getaddrinfo (const char *host,
*this = service_info_list;
result = IsValid ();
}
-
- :: freeaddrinfo (service_info_list);
+
+ if (service_info_list)
+ ::freeaddrinfo(service_info_list);
+
return result;
}
diff --git a/source/Host/common/Symbols.cpp b/source/Host/common/Symbols.cpp
index 2b63f46c02e6..60e1dc6bf995 100644
--- a/source/Host/common/Symbols.cpp
+++ b/source/Host/common/Symbols.cpp
@@ -11,6 +11,7 @@
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/DataBuffer.h"
#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/StreamString.h"
@@ -37,8 +38,7 @@ int
LocateMacOSXFilesUsingDebugSymbols
(
const ModuleSpec &module_spec,
- FileSpec *out_exec_fspec, // If non-NULL, try and find the executable
- FileSpec *out_dsym_fspec // If non-NULL try and find the debug symbol file
+ ModuleSpec &return_module_spec
);
#else
@@ -47,8 +47,7 @@ int
LocateMacOSXFilesUsingDebugSymbols
(
const ModuleSpec &module_spec,
- FileSpec *out_exec_fspec, // If non-NULL, try and find the executable
- FileSpec *out_dsym_fspec // If non-NULL try and find the debug symbol file
+ ModuleSpec &return_module_spec
) {
// Cannot find MacOSX files using debug symbols on non MacOSX.
return 0;
@@ -79,6 +78,7 @@ FileAtPathContainsArchAndUUID (const FileSpec &file_fspec, const ArchSpec *arch,
static bool
LocateDSYMInVincinityOfExecutable (const ModuleSpec &module_spec, FileSpec &dsym_fspec)
{
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
if (exec_fspec)
{
@@ -88,6 +88,17 @@ LocateDSYMInVincinityOfExecutable (const ModuleSpec &module_spec, FileSpec &dsym
// Make sure the module isn't already just a dSYM file...
if (strcasestr(path, ".dSYM/Contents/Resources/DWARF") == NULL)
{
+ if (log)
+ {
+ if (module_spec.GetUUIDPtr() && module_spec.GetUUIDPtr()->IsValid())
+ {
+ log->Printf ("Searching for dSYM bundle next to executable %s, UUID %s", path, module_spec.GetUUIDPtr()->GetAsString().c_str());
+ }
+ else
+ {
+ log->Printf ("Searching for dSYM bundle next to executable %s", path);
+ }
+ }
size_t obj_file_path_length = strlen(path);
::strncat(path, ".dSYM/Contents/Resources/DWARF/", sizeof(path) - strlen(path) - 1);
::strncat(path, exec_fspec->GetFilename().AsCString(), sizeof(path) - strlen(path) - 1);
@@ -99,6 +110,10 @@ LocateDSYMInVincinityOfExecutable (const ModuleSpec &module_spec, FileSpec &dsym
if (dsym_fspec.Exists() &&
FileAtPathContainsArchAndUUID(dsym_fspec, module_spec.GetArchitecturePtr(), module_spec.GetUUIDPtr()))
{
+ if (log)
+ {
+ log->Printf ("dSYM with matching UUID & arch found at %s", path);
+ }
return true;
}
else
@@ -118,6 +133,10 @@ LocateDSYMInVincinityOfExecutable (const ModuleSpec &module_spec, FileSpec &dsym
if (dsym_fspec.Exists() &&
FileAtPathContainsArchAndUUID(dsym_fspec, module_spec.GetArchitecturePtr(), module_spec.GetUUIDPtr()))
{
+ if (log)
+ {
+ log->Printf ("dSYM with matching UUID & arch found at %s", path);
+ }
return true;
}
else
@@ -154,22 +173,28 @@ LocateExecutableSymbolFileDsym (const ModuleSpec &module_spec)
"LocateExecutableSymbolFileDsym (file = %s, arch = %s, uuid = %p)",
exec_fspec ? exec_fspec->GetFilename().AsCString ("<NULL>") : "<NULL>",
arch ? arch->GetArchitectureName() : "<NULL>",
- (void*)uuid);
+ (const void*)uuid);
FileSpec symbol_fspec;
+ ModuleSpec dsym_module_spec;
// First try and find the dSYM in the same directory as the executable or in
// an appropriate parent directory
if (LocateDSYMInVincinityOfExecutable (module_spec, symbol_fspec) == false)
{
// We failed to easily find the dSYM above, so use DebugSymbols
- LocateMacOSXFilesUsingDebugSymbols (module_spec, NULL, &symbol_fspec);
+ LocateMacOSXFilesUsingDebugSymbols (module_spec, dsym_module_spec);
}
- return symbol_fspec;
+ else
+ {
+ dsym_module_spec.GetSymbolFileSpec() = symbol_fspec;
+ }
+ return dsym_module_spec.GetSymbolFileSpec();
}
-FileSpec
+ModuleSpec
Symbols::LocateExecutableObjectFile (const ModuleSpec &module_spec)
{
+ ModuleSpec result;
const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
const ArchSpec *arch = module_spec.GetArchitecturePtr();
const UUID *uuid = module_spec.GetUUIDPtr();
@@ -177,28 +202,31 @@ Symbols::LocateExecutableObjectFile (const ModuleSpec &module_spec)
"LocateExecutableObjectFile (file = %s, arch = %s, uuid = %p)",
exec_fspec ? exec_fspec->GetFilename().AsCString ("<NULL>") : "<NULL>",
arch ? arch->GetArchitectureName() : "<NULL>",
- (void*)uuid);
+ (const void*)uuid);
- FileSpec objfile_fspec;
ModuleSpecList module_specs;
ModuleSpec matched_module_spec;
if (exec_fspec &&
ObjectFile::GetModuleSpecifications(*exec_fspec, 0, 0, module_specs) &&
module_specs.FindMatchingModuleSpec(module_spec, matched_module_spec))
{
- objfile_fspec = exec_fspec;
+ result.GetFileSpec() = exec_fspec;
}
else
{
- LocateMacOSXFilesUsingDebugSymbols (module_spec, &objfile_fspec, NULL);
+ LocateMacOSXFilesUsingDebugSymbols (module_spec, result);
}
- return objfile_fspec;
+ return result;
}
FileSpec
Symbols::LocateExecutableSymbolFile (const ModuleSpec &module_spec)
{
- const char *symbol_filename = module_spec.GetSymbolFileSpec().GetFilename().AsCString();
+ FileSpec symbol_file_spec = module_spec.GetSymbolFileSpec();
+ if (symbol_file_spec.IsAbsolute() && symbol_file_spec.Exists())
+ return symbol_file_spec;
+
+ const char *symbol_filename = symbol_file_spec.GetFilename().AsCString();
if (symbol_filename && symbol_filename[0])
{
FileSpecList debug_file_search_paths (Target::GetDefaultDebugFileSearchPaths());
@@ -210,8 +238,10 @@ Symbols::LocateExecutableSymbolFile (const ModuleSpec &module_spec)
// Add current working directory.
debug_file_search_paths.AppendIfUnique (FileSpec(".", true));
+#ifndef LLVM_ON_WIN32
// Add /usr/lib/debug directory.
debug_file_search_paths.AppendIfUnique (FileSpec("/usr/lib/debug", true));
+#endif // LLVM_ON_WIN32
std::string uuid_str;
const UUID &module_uuid = module_spec.GetUUID();
@@ -224,10 +254,6 @@ Symbols::LocateExecutableSymbolFile (const ModuleSpec &module_spec)
uuid_str = uuid_str + ".debug";
}
- // Get directory of our module. Needed to check debug files like this:
- // /usr/lib/debug/usr/lib/library.so.debug
- std::string module_directory = module_spec.GetFileSpec().GetDirectory().AsCString();
-
size_t num_directories = debug_file_search_paths.GetSize();
for (size_t idx = 0; idx < num_directories; ++idx)
{
@@ -242,7 +268,11 @@ Symbols::LocateExecutableSymbolFile (const ModuleSpec &module_spec)
files.push_back (dirname + "/" + symbol_filename);
files.push_back (dirname + "/.debug/" + symbol_filename);
files.push_back (dirname + "/.build-id/" + uuid_str);
- files.push_back (dirname + module_directory + "/" + symbol_filename);
+
+ // Some debug files may stored in the module directory like this:
+ // /usr/lib/debug/usr/lib/library.so.debug
+ if (!file_dir.IsEmpty())
+ files.push_back (dirname + file_dir.AsCString() + "/" + symbol_filename);
const uint32_t num_files = files.size();
for (size_t idx_file = 0; idx_file < num_files; ++idx_file)
diff --git a/source/Host/common/TCPSocket.cpp b/source/Host/common/TCPSocket.cpp
new file mode 100644
index 000000000000..b23055ee7d87
--- /dev/null
+++ b/source/Host/common/TCPSocket.cpp
@@ -0,0 +1,288 @@
+//===-- TcpSocket.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/Host/common/TCPSocket.h"
+
+#include "lldb/Core/Log.h"
+#include "lldb/Host/Config.h"
+
+#ifndef LLDB_DISABLE_POSIX
+#include <arpa/inet.h>
+#include <netinet/tcp.h>
+#include <sys/socket.h>
+#endif
+
+using namespace lldb;
+using namespace lldb_private;
+
+namespace {
+
+const int kDomain = AF_INET;
+const int kType = SOCK_STREAM;
+
+}
+
+TCPSocket::TCPSocket(NativeSocket socket, bool should_close)
+ : Socket(socket, ProtocolTcp, should_close)
+{
+
+}
+
+TCPSocket::TCPSocket(bool child_processes_inherit, Error &error)
+ : TCPSocket(CreateSocket(kDomain, kType, IPPROTO_TCP, child_processes_inherit, error), true)
+{
+}
+
+
+// Return the port number that is being used by the socket.
+uint16_t
+TCPSocket::GetLocalPortNumber() const
+{
+ if (m_socket != kInvalidSocketValue)
+ {
+ SocketAddress sock_addr;
+ socklen_t sock_addr_len = sock_addr.GetMaxLength ();
+ if (::getsockname (m_socket, sock_addr, &sock_addr_len) == 0)
+ return sock_addr.GetPort ();
+ }
+ return 0;
+}
+
+std::string
+TCPSocket::GetLocalIPAddress() const
+{
+ // We bound to port zero, so we need to figure out which port we actually bound to
+ if (m_socket != kInvalidSocketValue)
+ {
+ SocketAddress sock_addr;
+ socklen_t sock_addr_len = sock_addr.GetMaxLength ();
+ if (::getsockname (m_socket, sock_addr, &sock_addr_len) == 0)
+ return sock_addr.GetIPAddress ();
+ }
+ return "";
+}
+
+uint16_t
+TCPSocket::GetRemotePortNumber() const
+{
+ if (m_socket != kInvalidSocketValue)
+ {
+ SocketAddress sock_addr;
+ socklen_t sock_addr_len = sock_addr.GetMaxLength ();
+ if (::getpeername (m_socket, sock_addr, &sock_addr_len) == 0)
+ return sock_addr.GetPort ();
+ }
+ return 0;
+}
+
+std::string
+TCPSocket::GetRemoteIPAddress () const
+{
+ // We bound to port zero, so we need to figure out which port we actually bound to
+ if (m_socket != kInvalidSocketValue)
+ {
+ SocketAddress sock_addr;
+ socklen_t sock_addr_len = sock_addr.GetMaxLength ();
+ if (::getpeername (m_socket, sock_addr, &sock_addr_len) == 0)
+ return sock_addr.GetIPAddress ();
+ }
+ return "";
+}
+
+Error
+TCPSocket::Connect(llvm::StringRef name)
+{
+ if (m_socket == kInvalidSocketValue)
+ return Error("Invalid socket");
+
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION));
+ if (log)
+ log->Printf ("TCPSocket::%s (host/port = %s)", __FUNCTION__, name.data());
+
+ Error error;
+ std::string host_str;
+ std::string port_str;
+ int32_t port = INT32_MIN;
+ if (!DecodeHostAndPort (name, host_str, port_str, port, &error))
+ return error;
+
+ // Enable local address reuse
+ SetOptionReuseAddress();
+
+ struct sockaddr_in sa;
+ ::memset (&sa, 0, sizeof (sa));
+ sa.sin_family = kDomain;
+ sa.sin_port = htons (port);
+
+ int inet_pton_result = ::inet_pton (kDomain, host_str.c_str(), &sa.sin_addr);
+
+ if (inet_pton_result <= 0)
+ {
+ struct hostent *host_entry = gethostbyname (host_str.c_str());
+ if (host_entry)
+ host_str = ::inet_ntoa (*(struct in_addr *)*host_entry->h_addr_list);
+ inet_pton_result = ::inet_pton (kDomain, host_str.c_str(), &sa.sin_addr);
+ if (inet_pton_result <= 0)
+ {
+ if (inet_pton_result == -1)
+ SetLastError(error);
+ else
+ error.SetErrorStringWithFormat("invalid host string: '%s'", host_str.c_str());
+
+ return error;
+ }
+ }
+
+ if (-1 == ::connect (GetNativeSocket(), (const struct sockaddr *)&sa, sizeof(sa)))
+ {
+ SetLastError (error);
+ return error;
+ }
+
+ // Keep our TCP packets coming without any delays.
+ SetOptionNoDelay();
+ error.Clear();
+ return error;
+}
+
+Error
+TCPSocket::Listen(llvm::StringRef name, int backlog)
+{
+ Error error;
+
+ // enable local address reuse
+ SetOptionReuseAddress();
+
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+ if (log)
+ log->Printf ("TCPSocket::%s (%s)", __FUNCTION__, name.data());
+
+ std::string host_str;
+ std::string port_str;
+ int32_t port = INT32_MIN;
+ if (!DecodeHostAndPort (name, host_str, port_str, port, &error))
+ return error;
+
+ SocketAddress bind_addr;
+
+ // Only bind to the loopback address if we are expecting a connection from
+ // localhost to avoid any firewall issues.
+ const bool bind_addr_success = (host_str == "127.0.0.1") ?
+ bind_addr.SetToLocalhost (kDomain, port) :
+ bind_addr.SetToAnyAddress (kDomain, port);
+
+ if (!bind_addr_success)
+ {
+ error.SetErrorString("Failed to bind port");
+ return error;
+ }
+
+ int err = ::bind (GetNativeSocket(), bind_addr, bind_addr.GetLength());
+ if (err != -1)
+ err = ::listen (GetNativeSocket(), backlog);
+
+ if (err == -1)
+ SetLastError (error);
+
+ return error;
+}
+
+Error
+TCPSocket::Accept(llvm::StringRef name, bool child_processes_inherit, Socket *&conn_socket)
+{
+ Error error;
+ std::string host_str;
+ std::string port_str;
+ int32_t port;
+ if (!DecodeHostAndPort(name, host_str, port_str, port, &error))
+ return error;
+
+ const sa_family_t family = kDomain;
+ const int socktype = kType;
+ const int protocol = IPPROTO_TCP;
+ SocketAddress listen_addr;
+ if (host_str.empty())
+ listen_addr.SetToLocalhost(family, port);
+ else if (host_str.compare("*") == 0)
+ listen_addr.SetToAnyAddress(family, port);
+ else
+ {
+ if (!listen_addr.getaddrinfo(host_str.c_str(), port_str.c_str(), family, socktype, protocol))
+ {
+ error.SetErrorStringWithFormat("unable to resolve hostname '%s'", host_str.c_str());
+ return error;
+ }
+ }
+
+ bool accept_connection = false;
+ std::unique_ptr<TCPSocket> accepted_socket;
+
+ // Loop until we are happy with our connection
+ while (!accept_connection)
+ {
+ struct sockaddr_in accept_addr;
+ ::memset (&accept_addr, 0, sizeof accept_addr);
+#if !(defined (__linux__) || defined(_WIN32))
+ accept_addr.sin_len = sizeof accept_addr;
+#endif
+ socklen_t accept_addr_len = sizeof accept_addr;
+
+ int sock = AcceptSocket (GetNativeSocket(),
+ (struct sockaddr *)&accept_addr,
+ &accept_addr_len,
+ child_processes_inherit,
+ error);
+
+ if (error.Fail())
+ break;
+
+ bool is_same_addr = true;
+#if !(defined(__linux__) || (defined(_WIN32)))
+ is_same_addr = (accept_addr_len == listen_addr.sockaddr_in().sin_len);
+#endif
+ if (is_same_addr)
+ is_same_addr = (accept_addr.sin_addr.s_addr == listen_addr.sockaddr_in().sin_addr.s_addr);
+
+ if (is_same_addr || (listen_addr.sockaddr_in().sin_addr.s_addr == INADDR_ANY))
+ {
+ accept_connection = true;
+ accepted_socket.reset(new TCPSocket(sock, true));
+ }
+ else
+ {
+ const uint8_t *accept_ip = (const uint8_t *)&accept_addr.sin_addr.s_addr;
+ const uint8_t *listen_ip = (const uint8_t *)&listen_addr.sockaddr_in().sin_addr.s_addr;
+ ::fprintf (stderr, "error: rejecting incoming connection from %u.%u.%u.%u (expecting %u.%u.%u.%u)\n",
+ accept_ip[0], accept_ip[1], accept_ip[2], accept_ip[3],
+ listen_ip[0], listen_ip[1], listen_ip[2], listen_ip[3]);
+ accepted_socket.reset();
+ }
+ }
+
+ if (!accepted_socket)
+ return error;
+
+ // Keep our TCP packets coming without any delays.
+ accepted_socket->SetOptionNoDelay();
+ error.Clear();
+ conn_socket = accepted_socket.release();
+ return error;
+}
+
+int
+TCPSocket::SetOptionNoDelay()
+{
+ return SetOption (IPPROTO_TCP, TCP_NODELAY, 1);
+}
+
+int
+TCPSocket::SetOptionReuseAddress()
+{
+ return SetOption(SOL_SOCKET, SO_REUSEADDR, 1);
+}
diff --git a/source/Host/common/ThisThread.cpp b/source/Host/common/ThisThread.cpp
index 289ec780e9fb..763701441c1a 100644
--- a/source/Host/common/ThisThread.cpp
+++ b/source/Host/common/ThisThread.cpp
@@ -37,7 +37,7 @@ ThisThread::SetName(llvm::StringRef name, int max_length)
{
// We're still too long. Since this is a dotted component, use everything after the last
// dot, up to a maximum of |length| characters.
- std::string::size_type last_dot = truncated_name.find_last_of(".");
+ std::string::size_type last_dot = truncated_name.rfind('.');
if (last_dot != std::string::npos)
begin = last_dot + 1;
diff --git a/source/Host/common/UDPSocket.cpp b/source/Host/common/UDPSocket.cpp
new file mode 100644
index 000000000000..8297232ae723
--- /dev/null
+++ b/source/Host/common/UDPSocket.cpp
@@ -0,0 +1,158 @@
+//===-- UdpSocket.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/Host/common/UDPSocket.h"
+
+#include "lldb/Core/Log.h"
+#include "lldb/Host/Config.h"
+
+#ifndef LLDB_DISABLE_POSIX
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#endif
+
+#include <memory>
+
+using namespace lldb;
+using namespace lldb_private;
+
+namespace {
+
+const int kDomain = AF_INET;
+const int kType = SOCK_DGRAM;
+
+const Error kNotSupported("Not supported");
+
+}
+
+UDPSocket::UDPSocket(NativeSocket socket)
+ : Socket(socket, ProtocolUdp, true)
+{
+}
+
+UDPSocket::UDPSocket(bool child_processes_inherit, Error &error)
+ : UDPSocket(CreateSocket(kDomain, kType, 0, child_processes_inherit, error))
+{
+}
+
+size_t
+UDPSocket::Send(const void *buf, const size_t num_bytes)
+{
+ return ::sendto (m_socket,
+ static_cast<const char*>(buf),
+ num_bytes,
+ 0,
+ m_send_sockaddr,
+ m_send_sockaddr.GetLength());
+}
+
+Error
+UDPSocket::Connect(llvm::StringRef name)
+{
+ return kNotSupported;
+}
+
+Error
+UDPSocket::Listen(llvm::StringRef name, int backlog)
+{
+ return kNotSupported;
+}
+
+Error
+UDPSocket::Accept(llvm::StringRef name, bool child_processes_inherit, Socket *&socket)
+{
+ return kNotSupported;
+}
+
+Error
+UDPSocket::Connect(llvm::StringRef name, bool child_processes_inherit, Socket *&send_socket, Socket *&recv_socket)
+{
+ std::unique_ptr<UDPSocket> final_send_socket;
+ std::unique_ptr<UDPSocket> final_recv_socket;
+
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+ if (log)
+ log->Printf ("UDPSocket::%s (host/port = %s)", __FUNCTION__, name.data());
+
+ Error error;
+ std::string host_str;
+ std::string port_str;
+ int32_t port = INT32_MIN;
+ if (!DecodeHostAndPort (name, host_str, port_str, port, &error))
+ return error;
+
+ // Setup the receiving end of the UDP connection on this localhost
+ // on port zero. After we bind to port zero we can read the port.
+ final_recv_socket.reset(new UDPSocket(child_processes_inherit, error));
+ if (error.Success())
+ {
+ // Socket was created, now lets bind to the requested port
+ SocketAddress addr;
+ addr.SetToAnyAddress (AF_INET, 0);
+
+ if (::bind (final_recv_socket->GetNativeSocket(), addr, addr.GetLength()) == -1)
+ {
+ // Bind failed...
+ SetLastError (error);
+ }
+ }
+
+ assert(error.Fail() == !(final_recv_socket && final_recv_socket->IsValid()));
+ if (error.Fail())
+ return error;
+
+ // At this point we have setup the receive port, now we need to
+ // setup the UDP send socket
+
+ struct addrinfo hints;
+ struct addrinfo *service_info_list = nullptr;
+
+ ::memset (&hints, 0, sizeof(hints));
+ hints.ai_family = kDomain;
+ hints.ai_socktype = kType;
+ int err = ::getaddrinfo (host_str.c_str(), port_str.c_str(), &hints, &service_info_list);
+ if (err != 0)
+ {
+ error.SetErrorStringWithFormat("getaddrinfo(%s, %s, &hints, &info) returned error %i (%s)",
+ host_str.c_str(),
+ port_str.c_str(),
+ err,
+ gai_strerror(err));
+ return error;
+ }
+
+ for (struct addrinfo *service_info_ptr = service_info_list;
+ service_info_ptr != nullptr;
+ service_info_ptr = service_info_ptr->ai_next)
+ {
+ auto send_fd = CreateSocket (service_info_ptr->ai_family,
+ service_info_ptr->ai_socktype,
+ service_info_ptr->ai_protocol,
+ child_processes_inherit,
+ error);
+ if (error.Success())
+ {
+ final_send_socket.reset(new UDPSocket(send_fd));
+ final_send_socket->m_send_sockaddr = service_info_ptr;
+ break;
+ }
+ else
+ continue;
+ }
+
+ :: freeaddrinfo (service_info_list);
+
+ if (!final_send_socket)
+ return error;
+
+ send_socket = final_send_socket.release();
+ recv_socket = final_recv_socket.release();
+ error.Clear();
+ return error;
+}
diff --git a/source/Host/common/XML.cpp b/source/Host/common/XML.cpp
index 14e786ab8b16..dc9cb0bc5a33 100644
--- a/source/Host/common/XML.cpp
+++ b/source/Host/common/XML.cpp
@@ -329,7 +329,7 @@ XMLNode::ForEachSiblingElementWithName (const char *name, NodeCallback const &ca
else
{
if (node->name)
- continue; // nullptr name specified and this elemnt has a name, ignore this one
+ continue; // nullptr name specified and this element has a name, ignore this one
}
if (callback(XMLNode(node)) == false)
@@ -592,7 +592,7 @@ ApplePropertyList::ExtractStringFromValueNode (const XMLNode &node, std::string
if (element_name == "true" || element_name == "false")
{
// The text value _is_ the element name itself...
- value = std::move(element_name.str());
+ value = element_name.str();
return true;
}
else if (element_name == "dict" || element_name == "array")
@@ -689,5 +689,3 @@ ApplePropertyList::GetStructuredData()
#endif
return root_sp;
}
-
-
diff --git a/source/Host/freebsd/Host.cpp b/source/Host/freebsd/Host.cpp
index 7f8d7ae96e7a..cf53cda40b19 100644
--- a/source/Host/freebsd/Host.cpp
+++ b/source/Host/freebsd/Host.cpp
@@ -76,7 +76,7 @@ GetFreeBSDProcessArgs (const ProcessInstanceInfoMatch *match_info_ptr,
size_t arg_data_size = sizeof(arg_data);
if (::sysctl (mib, 4, arg_data, &arg_data_size , NULL, 0) == 0)
{
- DataExtractor data (arg_data, arg_data_size, lldb::endian::InlHostByteOrder(), sizeof(void *));
+ DataExtractor data (arg_data, arg_data_size, endian::InlHostByteOrder(), sizeof(void *));
lldb::offset_t offset = 0;
const char *cstr;
diff --git a/source/Host/netbsd/Host.cpp b/source/Host/netbsd/Host.cpp
new file mode 100644
index 000000000000..874285072049
--- /dev/null
+++ b/source/Host/netbsd/Host.cpp
@@ -0,0 +1,287 @@
+//===-- 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.
+//
+//===----------------------------------------------------------------------===//
+
+// C Includes
+#include <stdio.h>
+#include <dlfcn.h>
+#include <execinfo.h>
+#include <sys/types.h>
+#include <sys/user.h>
+#include <sys/sysctl.h>
+#include <sys/proc.h>
+
+#include <limits.h>
+
+#include <sys/ptrace.h>
+#include <sys/exec.h>
+#include <elf.h>
+#include <kvm.h>
+
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/Error.h"
+#include "lldb/Host/Endian.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/StreamFile.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Platform.h"
+
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Utility/CleanUp.h"
+#include "lldb/Utility/NameMatches.h"
+
+#include "llvm/Support/Host.h"
+
+extern "C" {
+ extern char **environ;
+}
+
+using namespace lldb;
+using namespace lldb_private;
+
+size_t
+Host::GetEnvironment (StringList &env)
+{
+ char *v;
+ char **var = environ;
+ for (; var != NULL && *var != NULL; ++var)
+ {
+ v = ::strchr(*var, (int)'-');
+ if (v == NULL)
+ continue;
+ env.AppendString(v);
+ }
+ return env.GetSize();
+}
+
+static bool
+GetNetBSDProcessArgs (const ProcessInstanceInfoMatch *match_info_ptr,
+ ProcessInstanceInfo &process_info)
+{
+ if (!process_info.ProcessIDIsValid())
+ return false;
+
+ int pid = process_info.GetProcessID();
+
+ int mib[4] = { CTL_KERN, KERN_PROC_ARGS, pid, KERN_PROC_ARGV };
+
+ char arg_data[8192];
+ size_t arg_data_size = sizeof(arg_data);
+ if (::sysctl (mib, 4, arg_data, &arg_data_size , NULL, 0) != 0)
+ return false;
+
+ DataExtractor data (arg_data, arg_data_size, endian::InlHostByteOrder(), sizeof(void *));
+ lldb::offset_t offset = 0;
+ const char *cstr;
+
+ cstr = data.GetCStr (&offset);
+ if (!cstr)
+ return false;
+
+ process_info.GetExecutableFile().SetFile(cstr, false);
+
+ if (!(match_info_ptr == NULL ||
+ NameMatches (process_info.GetExecutableFile().GetFilename().GetCString(),
+ match_info_ptr->GetNameMatchType(),
+ match_info_ptr->GetProcessInfo().GetName())))
+ return false;
+
+ Args &proc_args = process_info.GetArguments();
+ while (1)
+ {
+ const uint8_t *p = data.PeekData(offset, 1);
+ while ((p != NULL) && (*p == '\0') && offset < arg_data_size)
+ {
+ ++offset;
+ p = data.PeekData(offset, 1);
+ }
+ if (p == NULL || offset >= arg_data_size)
+ break;
+
+ cstr = data.GetCStr(&offset);
+ if (!cstr)
+ break;
+
+ proc_args.AppendArgument(cstr);
+ }
+
+ return true;
+}
+
+static bool
+GetNetBSDProcessCPUType (ProcessInstanceInfo &process_info)
+{
+ if (process_info.ProcessIDIsValid())
+ {
+ process_info.GetArchitecture() = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
+ return true;
+ }
+ process_info.GetArchitecture().Clear();
+ return false;
+}
+
+static bool
+GetNetBSDProcessUserAndGroup(ProcessInstanceInfo &process_info)
+{
+ ::kvm_t *kdp;
+ char errbuf[_POSIX2_LINE_MAX]; /* XXX: error string unused */
+
+ struct ::kinfo_proc2 *proc_kinfo;
+ const int pid = process_info.GetProcessID();
+ int nproc;
+
+ if (!process_info.ProcessIDIsValid())
+ goto error;
+
+ if ((kdp = ::kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf)) == NULL)
+ goto error;
+
+ if ((proc_kinfo = ::kvm_getproc2(kdp, KERN_PROC_PID, pid,
+ sizeof(struct ::kinfo_proc2),
+ &nproc)) == NULL) {
+ ::kvm_close(kdp);
+ goto error;
+ }
+
+ if (nproc < 1) {
+ ::kvm_close(kdp); /* XXX: we don't check for error here */
+ goto error;
+ }
+
+ process_info.SetParentProcessID (proc_kinfo->p_ppid);
+ process_info.SetUserID (proc_kinfo->p_ruid);
+ process_info.SetGroupID (proc_kinfo->p_rgid);
+ process_info.SetEffectiveUserID (proc_kinfo->p_uid);
+ process_info.SetEffectiveGroupID (proc_kinfo->p_gid);
+
+ ::kvm_close(kdp); /* XXX: we don't check for error here */
+
+ return true;
+
+error:
+ process_info.SetParentProcessID (LLDB_INVALID_PROCESS_ID);
+ process_info.SetUserID (UINT32_MAX);
+ process_info.SetGroupID (UINT32_MAX);
+ process_info.SetEffectiveUserID (UINT32_MAX);
+ process_info.SetEffectiveGroupID (UINT32_MAX);
+ return false;
+}
+
+uint32_t
+Host::FindProcesses (const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &process_infos)
+{
+ const ::pid_t our_pid = ::getpid();
+ const ::uid_t our_uid = ::getuid();
+
+ const bool all_users = match_info.GetMatchAllUsers() ||
+ // Special case, if lldb is being run as root we can attach to anything
+ (our_uid == 0);
+
+ kvm_t *kdp;
+ char errbuf[_POSIX2_LINE_MAX]; /* XXX: error string unused */
+ if ((kdp = ::kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf)) == NULL)
+ return 0;
+
+ struct ::kinfo_proc2 *proc_kinfo;
+ int nproc;
+ if ((proc_kinfo = ::kvm_getproc2(kdp, KERN_PROC_ALL, 0,
+ sizeof(struct ::kinfo_proc2),
+ &nproc)) == NULL) {
+ ::kvm_close(kdp);
+ return 0;
+ }
+
+ for (int i = 0; i < nproc; i++) {
+ if (proc_kinfo[i].p_pid < 1)
+ continue; /* not valid */
+ /* Make sure the user is acceptable */
+ if (!all_users && proc_kinfo[i].p_ruid != our_uid)
+ continue;
+
+ if (proc_kinfo[i].p_pid == our_pid || // Skip this process
+ proc_kinfo[i].p_pid == 0 || // Skip kernel (kernel pid is 0)
+ proc_kinfo[i].p_stat == LSZOMB || // Zombies are bad
+ proc_kinfo[i].p_flag & P_TRACED || // Being debugged?
+ proc_kinfo[i].p_flag & P_WEXIT) // Working on exiting
+ continue;
+
+
+ // Every thread is a process in NetBSD, but all the threads of a single
+ // process have the same pid. Do not store the process info in the
+ // result list if a process with given identifier is already registered
+ // there.
+ if (proc_kinfo[i].p_nlwps > 1) {
+ bool already_registered = false;
+ for (size_t pi = 0; pi < process_infos.GetSize(); pi++) {
+ if (process_infos.GetProcessIDAtIndex(pi) ==
+ proc_kinfo[i].p_pid) {
+ already_registered = true;
+ break;
+ }
+ }
+
+ if (already_registered)
+ continue;
+ }
+ ProcessInstanceInfo process_info;
+ process_info.SetProcessID (proc_kinfo[i].p_pid);
+ process_info.SetParentProcessID (proc_kinfo[i].p_ppid);
+ process_info.SetUserID (proc_kinfo[i].p_ruid);
+ process_info.SetGroupID (proc_kinfo[i].p_rgid);
+ process_info.SetEffectiveUserID (proc_kinfo[i].p_uid);
+ process_info.SetEffectiveGroupID (proc_kinfo[i].p_gid);
+ // Make sure our info matches before we go fetch the name and cpu type
+ if (match_info.Matches (process_info) &&
+ GetNetBSDProcessArgs (&match_info, process_info))
+ {
+ GetNetBSDProcessCPUType (process_info);
+ if (match_info.Matches (process_info))
+ process_infos.Append (process_info);
+ }
+ }
+
+ kvm_close(kdp); /* XXX: we don't check for error here */
+
+ return process_infos.GetSize();
+}
+
+bool
+Host::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
+{
+ process_info.SetProcessID(pid);
+
+ if (GetNetBSDProcessArgs(NULL, process_info))
+ {
+ GetNetBSDProcessCPUType(process_info);
+ GetNetBSDProcessUserAndGroup(process_info);
+ return true;
+ }
+
+ process_info.Clear();
+ return false;
+}
+
+lldb::DataBufferSP
+Host::GetAuxvData(lldb_private::Process *process)
+{
+ return lldb::DataBufferSP();
+}
+
+Error
+Host::ShellExpandArguments (ProcessLaunchInfo &launch_info)
+{
+ return Error("unimplemented");
+}
diff --git a/source/Host/netbsd/HostInfoNetBSD.cpp b/source/Host/netbsd/HostInfoNetBSD.cpp
new file mode 100644
index 000000000000..aadda767fdae
--- /dev/null
+++ b/source/Host/netbsd/HostInfoNetBSD.cpp
@@ -0,0 +1,112 @@
+//===-- HostInfoNetBSD.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/Host/netbsd/HostInfoNetBSD.h"
+
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <sys/utsname.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <inttypes.h>
+
+
+using namespace lldb_private;
+
+uint32_t
+HostInfoNetBSD::GetMaxThreadNameLength()
+{
+ return PTHREAD_MAX_NAMELEN_NP;
+}
+
+bool
+HostInfoNetBSD::GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update)
+{
+ struct utsname un;
+
+ ::memset(&un, 0, sizeof(un));
+ if (::uname(&un) < 0)
+ return false;
+
+ /* Accept versions like 7.99.21 and 6.1_STABLE */
+ int status = ::sscanf(un.release, "%" PRIu32 ".%" PRIu32 ".%" PRIu32, &major, &minor, &update);
+ switch(status) {
+ case 0:
+ return false;
+ case 1:
+ minor = 0;
+ /* FALLTHROUGH */
+ case 2:
+ update = 0;
+ /* FALLTHROUGH */
+ case 3:
+ default:
+ return true;
+ }
+}
+
+bool
+HostInfoNetBSD::GetOSBuildString(std::string &s)
+{
+ int mib[2] = {CTL_KERN, KERN_OSREV};
+ char osrev_str[12];
+ int osrev = 0;
+ size_t osrev_len = sizeof(osrev);
+
+ if (::sysctl(mib, 2, &osrev, &osrev_len, NULL, 0) == 0)
+ {
+ ::snprintf(osrev_str, sizeof(osrev_str), "%-10.10d", osrev);
+ s.assign(osrev_str);
+ return true;
+ }
+
+ s.clear();
+ return false;
+}
+
+bool
+HostInfoNetBSD::GetOSKernelDescription(std::string &s)
+{
+ struct utsname un;
+
+ ::memset(&un, 0, sizeof(un));
+ s.clear();
+
+ if (::uname(&un) < 0)
+ return false;
+
+ s.assign(un.version);
+
+ return true;
+}
+
+FileSpec
+HostInfoNetBSD::GetProgramFileSpec()
+{
+ static FileSpec g_program_filespec;
+
+ if (!g_program_filespec)
+ {
+ ssize_t len;
+ static char buf[PATH_MAX];
+ char name[PATH_MAX];
+
+ ::snprintf(name, PATH_MAX, "/proc/%d/exe", ::getpid());
+ len = ::readlink(name, buf, PATH_MAX - 1);
+ if (len != -1)
+ {
+ buf[len] = '\0';
+ g_program_filespec.SetFile(buf, false);
+ }
+ }
+ return g_program_filespec;
+}
diff --git a/source/Host/netbsd/HostThreadNetBSD.cpp b/source/Host/netbsd/HostThreadNetBSD.cpp
new file mode 100644
index 000000000000..06bc502516a6
--- /dev/null
+++ b/source/Host/netbsd/HostThreadNetBSD.cpp
@@ -0,0 +1,50 @@
+//===-- HostThreadNetBSD.cpp -----------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// lldb Includes
+#include "lldb/Host/netbsd/HostThreadNetBSD.h"
+#include "lldb/Host/Host.h"
+
+// C includes
+#include <errno.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/sysctl.h>
+#include <sys/user.h>
+
+// C++ includes
+#include <string>
+
+using namespace lldb_private;
+
+HostThreadNetBSD::HostThreadNetBSD()
+{
+}
+
+HostThreadNetBSD::HostThreadNetBSD(lldb::thread_t thread)
+ : HostThreadPosix(thread)
+{
+}
+
+void
+HostThreadNetBSD::SetName(lldb::thread_t thread, llvm::StringRef &name)
+{
+ ::pthread_setname_np(thread, "%s", const_cast<char*>(name.data()));
+}
+
+void
+HostThreadNetBSD::GetName(lldb::thread_t thread, llvm::SmallVectorImpl<char> &name)
+{
+ char buf[PTHREAD_MAX_NAMELEN_NP];
+ ::pthread_getname_np(thread, buf, PTHREAD_MAX_NAMELEN_NP);
+
+ name.clear();
+ name.append(buf, buf + strlen(buf));
+}
diff --git a/source/Host/netbsd/ThisThread.cpp b/source/Host/netbsd/ThisThread.cpp
new file mode 100644
index 000000000000..dff5d9e0f109
--- /dev/null
+++ b/source/Host/netbsd/ThisThread.cpp
@@ -0,0 +1,30 @@
+//===-- ThisThread.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/Host/HostNativeThread.h"
+#include "lldb/Host/ThisThread.h"
+
+#include "llvm/ADT/SmallVector.h"
+
+#include <pthread.h>
+#include <string.h>
+
+using namespace lldb_private;
+
+void
+ThisThread::SetName(llvm::StringRef name)
+{
+ HostNativeThread::SetName(::pthread_self(), name);
+}
+
+void
+ThisThread::GetName(llvm::SmallVectorImpl<char> &name)
+{
+ HostNativeThread::GetName(::pthread_self(), name);
+}
diff --git a/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index f12f98c30b44..dbbd5a1dcc3c 100644
--- a/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -33,6 +33,8 @@
#endif
// C++ Includes
+#include <sstream>
+
// Other libraries and framework includes
#include "llvm/Support/ErrorHandling.h"
#if defined(__APPLE__)
@@ -45,11 +47,37 @@
#include "lldb/Core/Timer.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/Socket.h"
+#include "lldb/Host/common/TCPSocket.h"
#include "lldb/Interpreter/Args.h"
using namespace lldb;
using namespace lldb_private;
+const char* ConnectionFileDescriptor::LISTEN_SCHEME = "listen";
+const char* ConnectionFileDescriptor::ACCEPT_SCHEME = "accept";
+const char* ConnectionFileDescriptor::UNIX_ACCEPT_SCHEME = "unix-accept";
+const char* ConnectionFileDescriptor::CONNECT_SCHEME = "connect";
+const char* ConnectionFileDescriptor::TCP_CONNECT_SCHEME = "tcp-connect";
+const char* ConnectionFileDescriptor::UDP_SCHEME = "udp";
+const char* ConnectionFileDescriptor::UNIX_CONNECT_SCHEME = "unix-connect";
+const char* ConnectionFileDescriptor::UNIX_ABSTRACT_CONNECT_SCHEME = "unix-abstract-connect";
+const char* ConnectionFileDescriptor::FD_SCHEME = "fd";
+const char* ConnectionFileDescriptor::FILE_SCHEME = "file";
+
+namespace {
+
+const char*
+GetURLAddress(const char *url, const char *scheme)
+{
+ const auto prefix = std::string(scheme) + "://";
+ if (strstr(url, prefix.c_str()) != url)
+ return nullptr;
+
+ return url + prefix.size();
+}
+
+}
+
ConnectionFileDescriptor::ConnectionFileDescriptor(bool child_processes_inherit)
: Connection()
, m_pipe()
@@ -151,49 +179,51 @@ ConnectionFileDescriptor::Connect(const char *s, Error *error_ptr)
if (s && s[0])
{
- if (strstr(s, "listen://") == s)
+ const char *addr = nullptr;
+ if ((addr = GetURLAddress(s, LISTEN_SCHEME)))
{
// listen://HOST:PORT
- return SocketListenAndAccept(s + strlen("listen://"), error_ptr);
+ return SocketListenAndAccept(addr, error_ptr);
}
- else if (strstr(s, "accept://") == s)
+ else if ((addr = GetURLAddress(s, ACCEPT_SCHEME)))
{
// unix://SOCKNAME
- return NamedSocketAccept(s + strlen("accept://"), error_ptr);
+ return NamedSocketAccept(addr, error_ptr);
}
- else if (strstr(s, "unix-accept://") == s)
+ else if ((addr = GetURLAddress(s, UNIX_ACCEPT_SCHEME)))
{
// unix://SOCKNAME
- return NamedSocketAccept(s + strlen("unix-accept://"), error_ptr);
+ return NamedSocketAccept(addr, error_ptr);
+ }
+ else if ((addr = GetURLAddress(s, CONNECT_SCHEME)))
+ {
+ return ConnectTCP(addr, error_ptr);
}
- else if (strstr(s, "adb://") == s)
+ else if ((addr = GetURLAddress(s, TCP_CONNECT_SCHEME)))
{
- int port = -1;
- sscanf(s, "adb://%*[^:]:%d", &port);
- char host_and_port[sizeof("localhost:65535")];
- snprintf(host_and_port, sizeof(host_and_port), "localhost:%d", port);
- return ConnectTCP(host_and_port, error_ptr);
+ return ConnectTCP(addr, error_ptr);
}
- else if (strstr(s, "connect://") == s)
+ else if ((addr = GetURLAddress(s, UDP_SCHEME)))
{
- return ConnectTCP(s + strlen("connect://"), error_ptr);
+ return ConnectUDP(addr, error_ptr);
}
- else if (strstr(s, "tcp-connect://") == s)
+ else if ((addr = GetURLAddress(s, UNIX_CONNECT_SCHEME)))
{
- return ConnectTCP(s + strlen("tcp-connect://"), error_ptr);
+ // unix-connect://SOCKNAME
+ return NamedSocketConnect(addr, error_ptr);
}
- else if (strstr(s, "udp://") == s)
+ else if ((addr = GetURLAddress(s, UNIX_ABSTRACT_CONNECT_SCHEME)))
{
- return ConnectUDP(s + strlen("udp://"), error_ptr);
+ // unix-abstract-connect://SOCKNAME
+ return UnixAbstractSocketConnect(addr, error_ptr);
}
#ifndef LLDB_DISABLE_POSIX
- else if (strstr(s, "fd://") == s)
+ else if ((addr = GetURLAddress(s, FD_SCHEME)))
{
// Just passing a native file descriptor within this current process
// that is already opened (possibly from a service or other source).
- s += strlen("fd://");
bool success = false;
- int fd = StringConvert::ToSInt32(s, -1, 0, &success);
+ int fd = StringConvert::ToSInt32(addr, -1, 0, &success);
if (success)
{
@@ -223,8 +253,8 @@ ConnectionFileDescriptor::Connect(const char *s, Error *error_ptr)
// allow us to specify this. For now, we assume we must
// assume we don't own it.
- std::unique_ptr<Socket> tcp_socket;
- tcp_socket.reset(new Socket(fd, Socket::ProtocolTcp, false));
+ std::unique_ptr<TCPSocket> tcp_socket;
+ tcp_socket.reset(new TCPSocket(fd, false));
// Try and get a socket option from this file descriptor to
// see if this is a socket and set m_is_socket accordingly.
int resuse;
@@ -239,21 +269,21 @@ ConnectionFileDescriptor::Connect(const char *s, Error *error_ptr)
m_read_sp.reset(new File(fd, false));
m_write_sp.reset(new File(fd, false));
}
- m_uri.assign(s);
+ m_uri.assign(addr);
return eConnectionStatusSuccess;
}
}
if (error_ptr)
- error_ptr->SetErrorStringWithFormat("invalid file descriptor: \"fd://%s\"", s);
+ error_ptr->SetErrorStringWithFormat("invalid file descriptor: \"%s\"", s);
m_read_sp.reset();
m_write_sp.reset();
return eConnectionStatusError;
}
- else if (strstr(s, "file://") == s)
+ else if ((addr = GetURLAddress(s, FILE_SCHEME)))
{
// file:///PATH
- const char *path = s + strlen("file://");
+ const char *path = addr;
int fd = -1;
do
{
@@ -763,6 +793,23 @@ ConnectionFileDescriptor::NamedSocketConnect(const char *socket_name, Error *err
return eConnectionStatusSuccess;
}
+lldb::ConnectionStatus
+ConnectionFileDescriptor::UnixAbstractSocketConnect(const char *socket_name, Error *error_ptr)
+{
+ Socket *socket = nullptr;
+ Error error = Socket::UnixAbstractConnect(socket_name, m_child_processes_inherit, socket);
+ if (error_ptr)
+ *error_ptr = error;
+ m_write_sp.reset(socket);
+ m_read_sp = m_write_sp;
+ if (error.Fail())
+ {
+ return eConnectionStatusError;
+ }
+ m_uri.assign(socket_name);
+ return eConnectionStatusSuccess;
+}
+
ConnectionStatus
ConnectionFileDescriptor::SocketListenAndAccept(const char *s, Error *error_ptr)
{
@@ -780,7 +827,7 @@ ConnectionFileDescriptor::SocketListenAndAccept(const char *s, Error *error_ptr)
listening_socket_up.reset(socket);
socket = nullptr;
- error = listening_socket_up->BlockingAccept(s, m_child_processes_inherit, socket);
+ error = listening_socket_up->Accept(s, m_child_processes_inherit, socket);
listening_socket_up.reset();
if (error_ptr)
*error_ptr = error;
@@ -856,9 +903,12 @@ ConnectionFileDescriptor::SetChildProcessesInherit(bool child_processes_inherit)
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",socket->GetRemoteIPAddress().c_str(), socket->GetRemotePortNumber());
+ strm.Printf("connect://%s:%u",tcp_socket->GetRemoteIPAddress().c_str(), tcp_socket->GetRemotePortNumber());
m_uri.swap(strm.GetString());
}
diff --git a/source/Host/posix/DomainSocket.cpp b/source/Host/posix/DomainSocket.cpp
new file mode 100644
index 000000000000..b4427e305f3e
--- /dev/null
+++ b/source/Host/posix/DomainSocket.cpp
@@ -0,0 +1,133 @@
+//===-- DomainSocket.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/Host/posix/DomainSocket.h"
+
+#include "lldb/Host/FileSystem.h"
+
+#include <stddef.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+
+using namespace lldb;
+using namespace lldb_private;
+
+#ifdef __ANDROID__
+// Android does not have SUN_LEN
+#ifndef SUN_LEN
+#define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) + strlen((ptr)->sun_path))
+#endif
+#endif // #ifdef __ANDROID__
+
+namespace {
+
+const int kDomain = AF_UNIX;
+const int kType = SOCK_STREAM;
+
+bool SetSockAddr(llvm::StringRef name,
+ const size_t name_offset,
+ sockaddr_un* saddr_un,
+ socklen_t& saddr_un_len)
+{
+ if (name.size() + name_offset > sizeof(saddr_un->sun_path))
+ return false;
+
+ memset(saddr_un, 0, sizeof(*saddr_un));
+ saddr_un->sun_family = kDomain;
+
+ memcpy(saddr_un->sun_path + name_offset, name.data(), name.size());
+
+ // For domain sockets we can use SUN_LEN in order to calculate size of
+ // sockaddr_un, but for abstract sockets we have to calculate size manually
+ // because of leading null symbol.
+ if (name_offset == 0)
+ saddr_un_len = SUN_LEN(saddr_un);
+ else
+ saddr_un_len = offsetof(struct sockaddr_un, sun_path) + name_offset + name.size();
+
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
+ saddr_un->sun_len = saddr_un_len;
+#endif
+
+ return true;
+}
+
+}
+
+DomainSocket::DomainSocket(NativeSocket socket)
+ : Socket(socket, ProtocolUnixDomain, true)
+{
+}
+
+DomainSocket::DomainSocket(bool child_processes_inherit, Error &error)
+ : DomainSocket(CreateSocket(kDomain, kType, 0, child_processes_inherit, error))
+{
+}
+
+DomainSocket::DomainSocket(SocketProtocol protocol, bool child_processes_inherit, Error &error)
+ : Socket(CreateSocket(kDomain, kType, 0, child_processes_inherit, error), protocol, true)
+{
+}
+
+Error
+DomainSocket::Connect(llvm::StringRef name)
+{
+ sockaddr_un saddr_un;
+ socklen_t saddr_un_len;
+ if (!SetSockAddr(name, GetNameOffset(), &saddr_un, saddr_un_len))
+ return Error("Failed to set socket address");
+
+ Error error;
+ if (::connect(GetNativeSocket(), (struct sockaddr *)&saddr_un, saddr_un_len) < 0)
+ SetLastError (error);
+
+ return error;
+}
+
+Error
+DomainSocket::Listen(llvm::StringRef name, int backlog)
+{
+ sockaddr_un saddr_un;
+ socklen_t saddr_un_len;
+ if (!SetSockAddr(name, GetNameOffset(), &saddr_un, saddr_un_len))
+ return Error("Failed to set socket address");
+
+ DeleteSocketFile(name);
+
+ Error error;
+ if (::bind(GetNativeSocket(), (struct sockaddr *)&saddr_un, saddr_un_len) == 0)
+ if (::listen(GetNativeSocket(), backlog) == 0)
+ return error;
+
+ SetLastError(error);
+ return error;
+}
+
+Error
+DomainSocket::Accept(llvm::StringRef name, bool child_processes_inherit, Socket *&socket)
+{
+ Error error;
+ auto conn_fd = AcceptSocket(GetNativeSocket(), nullptr, nullptr, child_processes_inherit, error);
+ if (error.Success())
+ socket = new DomainSocket(conn_fd);
+
+ return error;
+}
+
+size_t
+DomainSocket::GetNameOffset() const
+{
+ return 0;
+}
+
+void
+DomainSocket::DeleteSocketFile(llvm::StringRef name)
+{
+ FileSystem::Unlink(FileSpec{name, true});
+}
diff --git a/source/Host/posix/FileSystem.cpp b/source/Host/posix/FileSystem.cpp
index 52698039b46e..1f2e7db0e1e4 100644
--- a/source/Host/posix/FileSystem.cpp
+++ b/source/Host/posix/FileSystem.cpp
@@ -20,6 +20,9 @@
#include <sys/mount.h>
#include <linux/magic.h>
#endif
+#if defined(__NetBSD__)
+#include <sys/statvfs.h>
+#endif
// lldb Includes
#include "lldb/Core/Error.h"
@@ -29,6 +32,9 @@
using namespace lldb;
using namespace lldb_private;
+const char *
+FileSystem::DEV_NULL = "/dev/null";
+
FileSpec::PathSyntax
FileSystem::GetNativePathSyntax()
{
@@ -179,6 +185,16 @@ FileSystem::Hardlink(const FileSpec &src, const FileSpec &dst)
return error;
}
+int
+FileSystem::GetHardlinkCount(const FileSpec &file_spec)
+{
+ struct stat file_stat;
+ if (::stat(file_spec.GetCString(), &file_stat) == 0)
+ return file_stat.st_nlink;
+
+ return -1;
+}
+
Error
FileSystem::Symlink(const FileSpec &src, const FileSpec &dst)
{
@@ -213,6 +229,34 @@ FileSystem::Readlink(const FileSpec &src, FileSpec &dst)
return error;
}
+Error
+FileSystem::ResolveSymbolicLink(const FileSpec &src, FileSpec &dst)
+{
+ char resolved_path[PATH_MAX];
+ if (!src.GetPath (resolved_path, sizeof (resolved_path)))
+ {
+ return Error("Couldn't get the canonical path for %s", src.GetCString());
+ }
+
+ char real_path[PATH_MAX + 1];
+ if (realpath(resolved_path, real_path) == nullptr)
+ {
+ Error err;
+ err.SetErrorToErrno();
+ return err;
+ }
+
+ dst = FileSpec(real_path, false);
+
+ return Error();
+}
+
+#if defined(__NetBSD__)
+static bool IsLocal(const struct statvfs& info)
+{
+ return (info.f_flag & MNT_LOCAL) != 0;
+}
+#else
static bool IsLocal(const struct statfs& info)
{
#ifdef __linux__
@@ -230,7 +274,19 @@ static bool IsLocal(const struct statfs& info)
return (info.f_flags & MNT_LOCAL) != 0;
#endif
}
+#endif
+#if defined(__NetBSD__)
+bool
+FileSystem::IsLocal(const FileSpec &spec)
+{
+ struct statvfs statfs_info;
+ std::string path (spec.GetPath());
+ if (statvfs(path.c_str(), &statfs_info) == 0)
+ return ::IsLocal(statfs_info);
+ return false;
+}
+#else
bool
FileSystem::IsLocal(const FileSpec &spec)
{
@@ -240,3 +296,4 @@ FileSystem::IsLocal(const FileSpec &spec)
return ::IsLocal(statfs_info);
return false;
}
+#endif
diff --git a/source/Host/posix/HostInfoPosix.cpp b/source/Host/posix/HostInfoPosix.cpp
index c04db71e1b81..cfdbf5635ad1 100644
--- a/source/Host/posix/HostInfoPosix.cpp
+++ b/source/Host/posix/HostInfoPosix.cpp
@@ -7,7 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
+#if !defined(LLDB_DISABLE_PYTHON)
+#include "Plugins/ScriptInterpreter/Python/lldb-python.h"
+#endif
+
#include "lldb/Core/Log.h"
#include "lldb/Host/posix/HostInfoPosix.h"
@@ -19,6 +22,7 @@
#include <mutex>
#include <netdb.h>
#include <pwd.h>
+#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
@@ -211,16 +215,29 @@ HostInfoPosix::ComputePythonDirectory(FileSpec &file_spec)
char raw_path[PATH_MAX];
lldb_file_spec.GetPath(raw_path, sizeof(raw_path));
+#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).
+ char python_path[PATH_MAX];
+ ::snprintf(python_path, sizeof(python_path), "%s/../%s", raw_path, LLDB_PYTHON_RELATIVE_LIBDIR);
+
+ char final_path[PATH_MAX];
+ realpath(python_path, final_path);
+ file_spec.GetDirectory().SetCString(final_path);
+
+ return true;
+#else
llvm::SmallString<256> python_version_dir;
llvm::raw_svector_ostream os(python_version_dir);
os << "/python" << PY_MAJOR_VERSION << '.' << PY_MINOR_VERSION << "/site-packages";
- os.flush();
// We may get our string truncated. Should we protect this with an assert?
::strncat(raw_path, python_version_dir.c_str(), sizeof(raw_path) - strlen(raw_path) - 1);
file_spec.GetDirectory().SetCString(raw_path);
return true;
+#endif
#else
return false;
#endif
diff --git a/source/Host/posix/MainLoopPosix.cpp b/source/Host/posix/MainLoopPosix.cpp
index cb213b9b79f1..897f2d13c0c6 100644
--- a/source/Host/posix/MainLoopPosix.cpp
+++ b/source/Host/posix/MainLoopPosix.cpp
@@ -94,10 +94,10 @@ MainLoopPosix::RegisterSignal(int signo, const Callback &callback, Error &error)
}
void
-MainLoopPosix::UnregisterReadObject(const lldb::IOObjectSP &object_sp)
+MainLoopPosix::UnregisterReadObject(IOObject::WaitableHandle handle)
{
- bool erased = m_read_fds.erase(object_sp->GetWaitableHandle());
- (void) erased;
+ bool erased = m_read_fds.erase(handle);
+ UNUSED_IF_ASSERT_DISABLED(erased);
assert(erased);
}
diff --git a/source/Host/posix/PipePosix.cpp b/source/Host/posix/PipePosix.cpp
index 0ed319facf93..353faae1628e 100644
--- a/source/Host/posix/PipePosix.cpp
+++ b/source/Host/posix/PipePosix.cpp
@@ -13,6 +13,12 @@
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/FileSystem.h"
+#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8))
+#ifndef _GLIBCXX_USE_NANOSLEEP
+#define _GLIBCXX_USE_NANOSLEEP
+#endif
+#endif
+
#include <functional>
#include <thread>
@@ -30,9 +36,9 @@ int PipePosix::kInvalidDescriptor = -1;
enum PIPES { READ, WRITE }; // Constants 0 and 1 for READ and WRITE
-// pipe2 is supported by Linux, FreeBSD v10 and higher.
+// pipe2 is supported by a limited set of platforms
// TODO: Add more platforms that support pipe2.
-#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD__ >= 10)
+#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD__ >= 10) || defined(__NetBSD__)
#define PIPE2_SUPPORTED 1
#else
#define PIPE2_SUPPORTED 0
diff --git a/source/Initialization/SystemInitializerCommon.cpp b/source/Initialization/SystemInitializerCommon.cpp
index 51f32a2776a8..6cbc0b707df4 100644
--- a/source/Initialization/SystemInitializerCommon.cpp
+++ b/source/Initialization/SystemInitializerCommon.cpp
@@ -13,8 +13,8 @@
#include "lldb/Host/HostInfo.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Timer.h"
-#include "lldb/Interpreter/ScriptInterpreterPython.h"
-
+#include "lldb/Symbol/GoASTContext.h"
+#include "lldb/Symbol/ClangASTContext.h"
#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
#include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
#include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
@@ -26,17 +26,19 @@
#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
#include "Plugins/OperatingSystem/Python/OperatingSystemPython.h"
+#include "Plugins/OperatingSystem/Go/OperatingSystemGo.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/PlatformiOSSimulator.h"
#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
#include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
+#include "Plugins/Platform/NetBSD/PlatformNetBSD.h"
#include "Plugins/Platform/Windows/PlatformWindows.h"
#include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
#if defined(__APPLE__)
+#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h"
#include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h"
#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
#include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h"
@@ -48,7 +50,7 @@
#if defined(_MSC_VER)
#include "lldb/Host/windows/windows.h"
-#include "Plugins/Process/Windows/ProcessWindowsLog.h"
+#include "Plugins/Process/Windows/Common/ProcessWindowsLog.h"
#endif
#include "llvm/Support/TargetSelect.h"
@@ -103,6 +105,9 @@ SystemInitializerCommon::Initialize()
process_gdb_remote::ProcessGDBRemoteLog::Initialize();
// Initialize plug-ins
+ ClangASTContext::Initialize();
+ GoASTContext::Initialize();
+
ObjectContainerBSDArchive::Initialize();
ObjectFileELF::Initialize();
ObjectFilePECOFF::Initialize();
@@ -110,6 +115,7 @@ SystemInitializerCommon::Initialize()
DynamicLoaderWindowsDYLD::Initialize();
platform_freebsd::PlatformFreeBSD::Initialize();
platform_linux::PlatformLinux::Initialize();
+ platform_netbsd::PlatformNetBSD::Initialize();
PlatformWindows::Initialize();
PlatformKalimba::Initialize();
platform_android::PlatformAndroid::Initialize();
@@ -126,9 +132,9 @@ SystemInitializerCommon::Initialize()
PlatformRemoteiOS::Initialize();
PlatformMacOSX::Initialize();
- PlatformiOSSimulator::Initialize();
#if defined(__APPLE__)
+ PlatformiOSSimulator::Initialize();
DynamicLoaderDarwinKernel::Initialize();
PlatformDarwinKernel::Initialize();
ObjectFileMachO::Initialize();
@@ -141,9 +147,9 @@ SystemInitializerCommon::Initialize()
ProcessWindowsLog::Initialize();
#endif
#ifndef LLDB_DISABLE_PYTHON
- ScriptInterpreterPython::InitializePrivate();
OperatingSystemPython::Initialize();
#endif
+ OperatingSystemGo::Initialize();
}
void
@@ -157,6 +163,7 @@ SystemInitializerCommon::Terminate()
DynamicLoaderWindowsDYLD::Terminate();
platform_freebsd::PlatformFreeBSD::Terminate();
platform_linux::PlatformLinux::Terminate();
+ platform_netbsd::PlatformNetBSD::Terminate();
PlatformWindows::Terminate();
PlatformKalimba::Terminate();
platform_android::PlatformAndroid::Terminate();
@@ -164,25 +171,29 @@ SystemInitializerCommon::Terminate()
ObjectContainerUniversalMachO::Terminate();
PlatformMacOSX::Terminate();
PlatformRemoteiOS::Terminate();
- PlatformiOSSimulator::Terminate();
+
+ ClangASTContext::Terminate();
+ GoASTContext::Terminate();
EmulateInstructionARM::Terminate();
EmulateInstructionMIPS::Terminate();
EmulateInstructionMIPS64::Terminate();
#if defined(__APPLE__)
+ PlatformiOSSimulator::Terminate();
DynamicLoaderDarwinKernel::Terminate();
ObjectFileMachO::Terminate();
PlatformDarwinKernel::Terminate();
#endif
-#if defined(__WIN32__)
+#if defined(_MSC_VER)
ProcessWindowsLog::Terminate();
#endif
#ifndef LLDB_DISABLE_PYTHON
OperatingSystemPython::Terminate();
#endif
+ OperatingSystemGo::Terminate();
Log::Terminate();
}
diff --git a/source/Interpreter/Args.cpp b/source/Interpreter/Args.cpp
index 2258c26e6c39..81e6b0aa1dbc 100644
--- a/source/Interpreter/Args.cpp
+++ b/source/Interpreter/Args.cpp
@@ -371,7 +371,7 @@ char **
Args::GetArgumentVector()
{
if (!m_argv.empty())
- return (char **)&m_argv[0];
+ return const_cast<char **>(&m_argv[0]);
return nullptr;
}
@@ -379,7 +379,7 @@ const char **
Args::GetConstArgumentVector() const
{
if (!m_argv.empty())
- return (const char **)&m_argv[0];
+ return const_cast<const char **>(&m_argv[0]);
return nullptr;
}
@@ -575,7 +575,8 @@ Args::ParseOptions (Options &options)
}
}
}
- OptionParser::Prepare();
+ Mutex::Locker options_locker(NULL);
+ OptionParser::Prepare(options_locker);
int val;
while (1)
{
@@ -719,7 +720,7 @@ Args::StringToAddress (const ExecutionContext *exe_ctx, const char *s, lldb::add
else
{
// Since the compiler can't handle things like "main + 12" we should
- // try to do this for now. The compliler doesn't like adding offsets
+ // try to do this for now. The compiler doesn't like adding offsets
// to function pointer types.
static RegularExpression g_symbol_plus_offset_regex("^(.*)([-\\+])[[:space:]]*(0x[0-9A-Fa-f]+|[0-9]+)[[:space:]]*$");
RegularExpression::Match regex_match(3);
@@ -1189,7 +1190,8 @@ Args::ParseAliasOptions (Options &options,
}
}
- OptionParser::Prepare();
+ Mutex::Locker options_locker(NULL);
+ OptionParser::Prepare(options_locker);
int val;
while (1)
{
@@ -1366,7 +1368,8 @@ Args::ParseArgsForCompletion
}
}
- OptionParser::Prepare();
+ Mutex::Locker options_locker(NULL);
+ OptionParser::Prepare(options_locker);
OptionParser::EnableError(false);
int val;
@@ -1387,7 +1390,7 @@ Args::ParseArgsForCompletion
int long_options_index = -1;
val = OptionParser::Parse (dummy_vec.size() - 1,
- (char *const *) &dummy_vec.front(),
+ const_cast<char *const *>(&dummy_vec.front()),
sstr.GetData(),
long_options,
&long_options_index);
@@ -1668,3 +1671,33 @@ Args::ExpandEscapedCharacters (const char *src, std::string &dst)
}
}
+std::string
+Args::EscapeLLDBCommandArgument (const std::string& arg, char quote_char)
+{
+ const char* chars_to_escape = nullptr;
+ switch (quote_char)
+ {
+ case '\0':
+ chars_to_escape = " \t\\'\"`";
+ break;
+ case '\'':
+ chars_to_escape = "";
+ break;
+ case '"':
+ chars_to_escape = "$\"`\\";
+ break;
+ default:
+ assert(false && "Unhandled quote character");
+ }
+
+ std::string res;
+ res.reserve(arg.size());
+ for (char c : arg)
+ {
+ if (::strchr(chars_to_escape, c))
+ res.push_back('\\');
+ res.push_back(c);
+ }
+ return res;
+}
+
diff --git a/source/Interpreter/CommandInterpreter.cpp b/source/Interpreter/CommandInterpreter.cpp
index 1da541b8c00f..b7cc607e8070 100644
--- a/source/Interpreter/CommandInterpreter.cpp
+++ b/source/Interpreter/CommandInterpreter.cpp
@@ -41,9 +41,9 @@
#include "../Commands/CommandObjectWatchpoint.h"
#include "../Commands/CommandObjectLanguage.h"
-
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
+#include "lldb/Core/PluginManager.h"
#include "lldb/Core/State.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
@@ -62,8 +62,6 @@
#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Interpreter/Property.h"
-#include "lldb/Interpreter/ScriptInterpreterNone.h"
-#include "lldb/Interpreter/ScriptInterpreterPython.h"
#include "lldb/Target/Process.h"
@@ -87,6 +85,7 @@ g_properties[] =
{ "expand-regex-aliases", OptionValue::eTypeBoolean, true, false, nullptr, nullptr, "If true, regular expression alias commands will show the expanded command that will be executed. This can be used to debug new regular expression alias commands." },
{ "prompt-on-quit", OptionValue::eTypeBoolean, true, true, nullptr, nullptr, "If true, LLDB will prompt you before quitting if there are any live processes being debugged. If false, LLDB will quit without asking in any case." },
{ "stop-command-source-on-error", OptionValue::eTypeBoolean, true, true, nullptr, nullptr, "If true, LLDB will stop running a 'command source' script upon encountering an error." },
+ { "space-repl-prompts", OptionValue::eTypeBoolean, true, false, nullptr, nullptr, "If true, blank lines will be printed between between REPL submissions." },
{ nullptr , OptionValue::eTypeInvalid, true, 0 , nullptr, nullptr, nullptr }
};
@@ -94,7 +93,8 @@ enum
{
ePropertyExpandRegexAliases = 0,
ePropertyPromptOnQuit = 1,
- ePropertyStopCmdSourceOnError = 2
+ ePropertyStopCmdSourceOnError = 2,
+ eSpaceReplPrompts = 3
};
ConstString &
@@ -104,29 +104,23 @@ CommandInterpreter::GetStaticBroadcasterClass ()
return class_name;
}
-CommandInterpreter::CommandInterpreter
-(
- Debugger &debugger,
- ScriptLanguage script_language,
- bool synchronous_execution
-) :
- Broadcaster (&debugger, CommandInterpreter::GetStaticBroadcasterClass().AsCString()),
- Properties(OptionValuePropertiesSP(new OptionValueProperties(ConstString("interpreter")))),
- 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_ap (),
- 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)
-
+CommandInterpreter::CommandInterpreter(Debugger &debugger, ScriptLanguage script_language, bool synchronous_execution)
+ : Broadcaster(&debugger, CommandInterpreter::GetStaticBroadcasterClass().AsCString()),
+ Properties(OptionValuePropertiesSP(new OptionValueProperties(ConstString("interpreter")))),
+ 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_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");
@@ -175,6 +169,13 @@ CommandInterpreter::GetStopCmdSourceOnError () const
return m_collection_sp->GetPropertyAtIndexAsBoolean (nullptr, idx, g_properties[idx].default_uint_value != 0);
}
+bool
+CommandInterpreter::GetSpaceReplPrompts () const
+{
+ const uint32_t idx = eSpaceReplPrompts;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean (nullptr, idx, g_properties[idx].default_uint_value != 0);
+}
+
void
CommandInterpreter::Initialize ()
{
@@ -360,11 +361,19 @@ CommandInterpreter::Initialize ()
#if defined (__arm__) || defined (__arm64__) || defined (__aarch64__)
ProcessAliasOptionsArgs (cmd_obj_sp, "--", alias_arguments_vector_sp);
#else
+ #if defined(__APPLE__)
+ std::string shell_option;
+ shell_option.append("--shell-expand-args");
+ shell_option.append(" true");
+ shell_option.append(" --");
+ ProcessAliasOptionsArgs (cmd_obj_sp, shell_option.c_str(), alias_arguments_vector_sp);
+ #else
std::string shell_option;
shell_option.append("--shell=");
shell_option.append(HostInfo::GetDefaultShell().GetPath());
shell_option.append(" --");
ProcessAliasOptionsArgs (cmd_obj_sp, shell_option.c_str(), alias_arguments_vector_sp);
+ #endif
#endif
AddAlias ("r", cmd_obj_sp);
AddAlias ("run", cmd_obj_sp);
@@ -392,9 +401,9 @@ void
CommandInterpreter::Clear()
{
m_command_io_handler_sp.reset();
-
- if (m_script_interpreter_ap)
- m_script_interpreter_ap->Clear();
+
+ if (m_script_interpreter_sp)
+ m_script_interpreter_sp->Clear();
}
const char *
@@ -511,8 +520,7 @@ CommandInterpreter::LoadCommandDictionary ()
char buffer[1024];
int num_printed = snprintf(buffer, 1024, "%s %s", break_regexes[i][1], "-o");
assert (num_printed < 1024);
- // Quiet unused variable warning for release builds.
- (void) num_printed;
+ UNUSED_IF_ASSERT_DISABLED(num_printed);
success = tbreak_regex_cmd_ap->AddRegexCommand (break_regexes[i][0], buffer);
if (!success)
break;
@@ -2011,7 +2019,7 @@ CommandInterpreter::HandleCompletion (const char *current_line,
matches);
if (num_command_matches <= 0)
- return num_command_matches;
+ return num_command_matches;
if (num_args == 0)
{
@@ -2030,18 +2038,18 @@ CommandInterpreter::HandleCompletion (const char *current_line,
std::string common_prefix;
matches.LongestCommonPrefix (common_prefix);
const size_t partial_name_len = command_partial_str.size();
+ common_prefix.erase (0, partial_name_len);
// If we matched a unique single command, add a space...
// Only do this if the completer told us this was a complete word, however...
if (num_command_matches == 1 && word_complete)
{
char quote_char = parsed_line.GetArgumentQuoteCharAtIndex(cursor_index);
+ common_prefix = Args::EscapeLLDBCommandArgument(common_prefix, quote_char);
if (quote_char != '\0')
common_prefix.push_back(quote_char);
-
common_prefix.push_back(' ');
}
- common_prefix.erase (0, partial_name_len);
matches.InsertStringAtIndex(0, common_prefix.c_str());
}
return num_command_matches;
@@ -2709,48 +2717,19 @@ CommandInterpreter::HandleCommandsFromFile (FileSpec &cmd_file,
}
ScriptInterpreter *
-CommandInterpreter::GetScriptInterpreter (bool can_create)
+CommandInterpreter::GetScriptInterpreter(bool can_create)
{
- if (m_script_interpreter_ap.get() != nullptr)
- return m_script_interpreter_ap.get();
-
+ if (m_script_interpreter_sp)
+ return m_script_interpreter_sp.get();
+
if (!can_create)
return nullptr;
-
- // <rdar://problem/11751427>
- // we need to protect the initialization of the script interpreter
- // otherwise we could end up with two threads both trying to create
- // their instance of it, and for some languages (e.g. Python)
- // this is a bulletproof recipe for disaster!
- // this needs to be a function-level static because multiple Debugger instances living in the same process
- // still need to be isolated and not try to initialize Python concurrently
- static Mutex g_interpreter_mutex(Mutex::eMutexTypeRecursive);
- Mutex::Locker interpreter_lock(g_interpreter_mutex);
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("Initializing the ScriptInterpreter now\n");
-
+
lldb::ScriptLanguage script_lang = GetDebugger().GetScriptLanguage();
- switch (script_lang)
- {
- case eScriptLanguagePython:
-#ifndef LLDB_DISABLE_PYTHON
- m_script_interpreter_ap.reset (new ScriptInterpreterPython (*this));
- break;
-#else
- // Fall through to the None case when python is disabled
-#endif
- case eScriptLanguageNone:
- m_script_interpreter_ap.reset (new ScriptInterpreterNone (*this));
- break;
- };
-
- return m_script_interpreter_ap.get();
+ m_script_interpreter_sp = PluginManager::GetScriptInterpreterForLanguage(script_lang, *this);
+ return m_script_interpreter_sp.get();
}
-
-
bool
CommandInterpreter::GetSynchronous ()
{
diff --git a/source/Interpreter/CommandObject.cpp b/source/Interpreter/CommandObject.cpp
index c0efd9e33c08..616d3e38acbb 100644
--- a/source/Interpreter/CommandObject.cpp
+++ b/source/Interpreter/CommandObject.cpp
@@ -28,6 +28,8 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Target/Language.h"
+
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -395,7 +397,7 @@ CommandObject::HandleCompletion
StringList &matches
)
{
- // Default implmentation of WantsCompletion() is !WantsRawCommandString().
+ // Default implementation of WantsCompletion() is !WantsRawCommandString().
// Subclasses who want raw command string but desire, for example,
// argument completion should override WantsCompletion() to return true,
// instead.
@@ -848,7 +850,7 @@ LanguageTypeHelpTextCallback ()
StreamString sstr;
sstr << "One of the following languages:\n";
- LanguageRuntime::PrintAllLanguages(sstr, " ", "\n");
+ Language::PrintAllLanguages(sstr, " ", "\n");
sstr.Flush();
diff --git a/source/Interpreter/CommandObjectScript.h b/source/Interpreter/CommandObjectScript.h
index fd55fc44a46a..5365aaac4cbe 100644
--- a/source/Interpreter/CommandObjectScript.h
+++ b/source/Interpreter/CommandObjectScript.h
@@ -25,18 +25,16 @@ namespace lldb_private {
class CommandObjectScript : public CommandObjectRaw
{
public:
+ CommandObjectScript(CommandInterpreter &interpreter,
+ lldb::ScriptLanguage script_lang);
- CommandObjectScript (CommandInterpreter &interpreter,
- lldb::ScriptLanguage script_lang);
-
- virtual
- ~CommandObjectScript ();
+ ~CommandObjectScript() override;
protected:
- virtual bool
- DoExecute (const char *command, CommandReturnObject &result);
+ bool
+ DoExecute(const char *command, CommandReturnObject &result) override;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectScript_h_
+#endif // liblldb_CommandObjectScript_h_
diff --git a/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/source/Interpreter/OptionGroupValueObjectDisplay.cpp
index e5a5c004b2da..bbd966859c34 100644
--- a/source/Interpreter/OptionGroupValueObjectDisplay.cpp
+++ b/source/Interpreter/OptionGroupValueObjectDisplay.cpp
@@ -162,7 +162,7 @@ OptionGroupValueObjectDisplay::GetAsDumpOptions (LanguageRuntimeDescriptionDispl
lldb::TypeSummaryImplSP summary_sp)
{
DumpValueObjectOptions options;
- options.SetMaximumPointerDepth(ptr_depth);
+ options.SetMaximumPointerDepth( {DumpValueObjectOptions::PointerDepth::Mode::Always,ptr_depth} );
if (use_objc)
options.SetShowSummary(false);
else
diff --git a/source/Interpreter/OptionValueLanguage.cpp b/source/Interpreter/OptionValueLanguage.cpp
index fd46553dabde..dd7173c3dc74 100644
--- a/source/Interpreter/OptionValueLanguage.cpp
+++ b/source/Interpreter/OptionValueLanguage.cpp
@@ -16,7 +16,7 @@
#include "lldb/Core/Stream.h"
#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/Interpreter/Args.h"
-#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Target/Language.h"
using namespace lldb;
using namespace lldb_private;
@@ -30,7 +30,7 @@ OptionValueLanguage::DumpValue (const ExecutionContext *exe_ctx, Stream &strm, u
{
if (dump_mask & eDumpOptionType)
strm.PutCString (" = ");
- strm.PutCString (LanguageRuntime::GetNameForLanguageType(m_current_value));
+ strm.PutCString (Language::GetNameForLanguageType(m_current_value));
}
}
@@ -47,9 +47,28 @@ OptionValueLanguage::SetValueFromString (llvm::StringRef value, VarSetOperationT
case eVarSetOperationReplace:
case eVarSetOperationAssign:
{
- LanguageType new_type = LanguageRuntime::GetLanguageTypeFromString(value.data());
- m_value_was_set = true;
- m_current_value = new_type;
+ ConstString lang_name(value.trim());
+ std::set<lldb::LanguageType> languages_for_types;
+ std::set<lldb::LanguageType> languages_for_expressions;
+ Language::GetLanguagesSupportingTypeSystems(languages_for_types, languages_for_expressions);
+
+ LanguageType new_type = Language::GetLanguageTypeFromString(lang_name.GetCString());
+ if (new_type && languages_for_types.count(new_type))
+ {
+ m_value_was_set = true;
+ m_current_value = new_type;
+ }
+ else
+ {
+ StreamString error_strm;
+ error_strm.Printf("invalid language type '%s', ", value.str().c_str());
+ error_strm.Printf("valid values are:\n");
+ for (lldb::LanguageType language : languages_for_types)
+ {
+ error_strm.Printf("%s%s%s", " ", Language::GetNameForLanguageType(language), "\n");
+ }
+ error.SetErrorString(error_strm.GetData());
+ }
}
break;
diff --git a/source/Interpreter/OptionValueProperties.cpp b/source/Interpreter/OptionValueProperties.cpp
index e8d870a99cf8..a3c28f70270f 100644
--- a/source/Interpreter/OptionValueProperties.cpp
+++ b/source/Interpreter/OptionValueProperties.cpp
@@ -311,6 +311,15 @@ OptionValueProperties::GetPropertyAtIndexAsOptionValueArch (const ExecutionConte
return nullptr;
}
+OptionValueLanguage *
+OptionValueProperties::GetPropertyAtIndexAsOptionValueLanguage (const ExecutionContext *exe_ctx, uint32_t idx) const
+{
+ const Property *property = GetPropertyAtIndex (exe_ctx, false, idx);
+ if (property)
+ return property->GetValue()->GetAsLanguage();
+ return nullptr;
+}
+
bool
OptionValueProperties::GetPropertyAtIndexAsArgs (const ExecutionContext *exe_ctx, uint32_t idx, Args &args) const
{
diff --git a/source/Interpreter/Property.cpp b/source/Interpreter/Property.cpp
index 077fcbc54cc3..b9fe28620a4f 100644
--- a/source/Interpreter/Property.cpp
+++ b/source/Interpreter/Property.cpp
@@ -17,7 +17,7 @@
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/OptionValues.h"
-#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Target/Language.h"
using namespace lldb;
using namespace lldb_private;
@@ -129,7 +129,7 @@ Property::Property (const PropertyDefinition &definition) :
{
LanguageType new_lang = eLanguageTypeUnknown;
if (definition.default_cstr_value)
- LanguageRuntime::GetLanguageTypeFromString(definition.default_cstr_value);
+ Language::GetLanguageTypeFromString(definition.default_cstr_value);
else
new_lang = (LanguageType)definition.default_uint_value;
m_value_sp.reset (new OptionValueLanguage(new_lang));
diff --git a/source/Interpreter/PythonDataObjects.cpp b/source/Interpreter/PythonDataObjects.cpp
deleted file mode 100644
index a581a0b3601a..000000000000
--- a/source/Interpreter/PythonDataObjects.cpp
+++ /dev/null
@@ -1,524 +0,0 @@
-//===-- PythonDataObjects.cpp ------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// In order to guarantee correct working with Python, Python.h *MUST* be
-// the *FIRST* header file included here.
-#ifdef LLDB_DISABLE_PYTHON
-
-// Python is disabled in this build
-
-#else
-
-#include "lldb/lldb-python.h"
-
-#include <stdio.h>
-
-#include "lldb/Core/Stream.h"
-#include "lldb/Host/File.h"
-#include "lldb/Interpreter/PythonDataObjects.h"
-#include "lldb/Interpreter/ScriptInterpreter.h"
-#include "lldb/Interpreter/ScriptInterpreterPython.h"
-
-using namespace lldb_private;
-using namespace lldb;
-
-void
-StructuredPythonObject::Dump(Stream &s) const
-{
- s << "Python Obj: 0x" << GetValue();
-}
-
-//----------------------------------------------------------------------
-// PythonObject
-//----------------------------------------------------------------------
-
-void
-PythonObject::Dump (Stream &strm) const
-{
- if (m_py_obj)
- {
- FILE *file = ::tmpfile();
- if (file)
- {
- ::PyObject_Print (m_py_obj, file, 0);
- const long length = ftell (file);
- if (length)
- {
- ::rewind(file);
- std::vector<char> file_contents (length,'\0');
- const size_t length_read = ::fread (file_contents.data(), 1, file_contents.size(), file);
- if (length_read > 0)
- strm.Write (file_contents.data(), length_read);
- }
- ::fclose (file);
- }
- }
- else
- strm.PutCString ("NULL");
-}
-
-PyObjectType
-PythonObject::GetObjectType() const
-{
- if (IsNULLOrNone())
- return PyObjectType::None;
-
- if (PyList_Check(m_py_obj))
- return PyObjectType::List;
- if (PyDict_Check(m_py_obj))
- return PyObjectType::Dictionary;
- if (PyString_Check(m_py_obj))
- return PyObjectType::String;
- if (PyInt_Check(m_py_obj) || PyLong_Check(m_py_obj))
- return PyObjectType::Integer;
- return PyObjectType::Unknown;
-}
-
-PythonString
-PythonObject::Repr ()
-{
- if (!m_py_obj)
- return PythonString ();
- PyObject *repr = PyObject_Repr(m_py_obj);
- if (!repr)
- return PythonString ();
- return PythonString(repr);
-}
-
-PythonString
-PythonObject::Str ()
-{
- if (!m_py_obj)
- return PythonString ();
- PyObject *str = PyObject_Str(m_py_obj);
- if (!str)
- return PythonString ();
- return PythonString(str);
-}
-
-bool
-PythonObject::IsNULLOrNone () const
-{
- return ((m_py_obj == nullptr) || (m_py_obj == Py_None));
-}
-
-StructuredData::ObjectSP
-PythonObject::CreateStructuredObject() const
-{
- switch (GetObjectType())
- {
- case PyObjectType::Dictionary:
- return PythonDictionary(m_py_obj).CreateStructuredDictionary();
- case PyObjectType::Integer:
- return PythonInteger(m_py_obj).CreateStructuredInteger();
- case PyObjectType::List:
- return PythonList(m_py_obj).CreateStructuredArray();
- case PyObjectType::String:
- return PythonString(m_py_obj).CreateStructuredString();
- case PyObjectType::None:
- return StructuredData::ObjectSP();
- default:
- return StructuredData::ObjectSP(new StructuredPythonObject(m_py_obj));
- }
-}
-
-//----------------------------------------------------------------------
-// PythonString
-//----------------------------------------------------------------------
-
-PythonString::PythonString (PyObject *py_obj) :
- PythonObject()
-{
- Reset(py_obj); // Use "Reset()" to ensure that py_obj is a string
-}
-
-PythonString::PythonString (const PythonObject &object) :
- PythonObject()
-{
- Reset(object.get()); // Use "Reset()" to ensure that py_obj is a string
-}
-
-PythonString::PythonString (llvm::StringRef string) :
- PythonObject(PyString_FromStringAndSize(string.data(), string.size()))
-{
-}
-
-PythonString::PythonString(const char *string) :
- PythonObject(PyString_FromString(string))
-{
-}
-
-PythonString::PythonString () :
- PythonObject()
-{
-}
-
-PythonString::~PythonString ()
-{
-}
-
-bool
-PythonString::Reset (PyObject *py_obj)
-{
- if (py_obj && PyString_Check(py_obj))
- return PythonObject::Reset(py_obj);
-
- PythonObject::Reset(nullptr);
- return py_obj == nullptr;
-}
-
-llvm::StringRef
-PythonString::GetString() const
-{
- if (m_py_obj)
- return llvm::StringRef(PyString_AsString(m_py_obj), GetSize());
- return llvm::StringRef();
-}
-
-size_t
-PythonString::GetSize() const
-{
- if (m_py_obj)
- return PyString_Size(m_py_obj);
- return 0;
-}
-
-void
-PythonString::SetString (llvm::StringRef string)
-{
- PythonObject::Reset(PyString_FromStringAndSize(string.data(), string.size()));
-}
-
-StructuredData::StringSP
-PythonString::CreateStructuredString() const
-{
- StructuredData::StringSP result(new StructuredData::String);
- result->SetValue(GetString());
- return result;
-}
-
-//----------------------------------------------------------------------
-// PythonInteger
-//----------------------------------------------------------------------
-
-PythonInteger::PythonInteger (PyObject *py_obj) :
- PythonObject()
-{
- Reset(py_obj); // Use "Reset()" to ensure that py_obj is a integer type
-}
-
-PythonInteger::PythonInteger (const PythonObject &object) :
- PythonObject()
-{
- Reset(object.get()); // Use "Reset()" to ensure that py_obj is a integer type
-}
-
-PythonInteger::PythonInteger (int64_t value) :
- PythonObject()
-{
- SetInteger (value);
-}
-
-
-PythonInteger::~PythonInteger ()
-{
-}
-
-bool
-PythonInteger::Reset (PyObject *py_obj)
-{
- if (py_obj)
- {
- if (PyInt_Check (py_obj) || PyLong_Check(py_obj))
- return PythonObject::Reset(py_obj);
- }
-
- PythonObject::Reset(nullptr);
- return py_obj == nullptr;
-}
-
-int64_t
-PythonInteger::GetInteger() const
-{
- if (m_py_obj)
- {
- if (PyInt_Check(m_py_obj))
- return PyInt_AsLong(m_py_obj);
- else if (PyLong_Check(m_py_obj))
- return PyLong_AsLongLong(m_py_obj);
- }
- return UINT64_MAX;
-}
-
-void
-PythonInteger::SetInteger (int64_t value)
-{
- PythonObject::Reset(PyLong_FromLongLong(value));
-}
-
-StructuredData::IntegerSP
-PythonInteger::CreateStructuredInteger() const
-{
- StructuredData::IntegerSP result(new StructuredData::Integer);
- result->SetValue(GetInteger());
- return result;
-}
-
-//----------------------------------------------------------------------
-// PythonList
-//----------------------------------------------------------------------
-
-PythonList::PythonList (bool create_empty) :
- PythonObject(create_empty ? PyList_New(0) : nullptr)
-{
-}
-
-PythonList::PythonList (uint32_t count) :
- PythonObject(PyList_New(count))
-{
-}
-
-PythonList::PythonList (PyObject *py_obj) :
- PythonObject()
-{
- Reset(py_obj); // Use "Reset()" to ensure that py_obj is a list
-}
-
-
-PythonList::PythonList (const PythonObject &object) :
- PythonObject()
-{
- Reset(object.get()); // Use "Reset()" to ensure that py_obj is a list
-}
-
-PythonList::~PythonList ()
-{
-}
-
-bool
-PythonList::Reset (PyObject *py_obj)
-{
- if (py_obj && PyList_Check(py_obj))
- return PythonObject::Reset(py_obj);
-
- PythonObject::Reset(nullptr);
- return py_obj == nullptr;
-}
-
-uint32_t
-PythonList::GetSize() const
-{
- if (m_py_obj)
- return PyList_GET_SIZE(m_py_obj);
- return 0;
-}
-
-PythonObject
-PythonList::GetItemAtIndex(uint32_t index) const
-{
- if (m_py_obj)
- return PythonObject(PyList_GetItem(m_py_obj, index));
- return PythonObject();
-}
-
-void
-PythonList::SetItemAtIndex (uint32_t index, const PythonObject & object)
-{
- if (m_py_obj && object)
- PyList_SetItem(m_py_obj, index, object.get());
-}
-
-void
-PythonList::AppendItem (const PythonObject &object)
-{
- if (m_py_obj && object)
- PyList_Append(m_py_obj, object.get());
-}
-
-StructuredData::ArraySP
-PythonList::CreateStructuredArray() const
-{
- StructuredData::ArraySP result(new StructuredData::Array);
- uint32_t count = GetSize();
- for (uint32_t i = 0; i < count; ++i)
- {
- PythonObject obj = GetItemAtIndex(i);
- result->AddItem(obj.CreateStructuredObject());
- }
- return result;
-}
-
-//----------------------------------------------------------------------
-// PythonDictionary
-//----------------------------------------------------------------------
-
-PythonDictionary::PythonDictionary (bool create_empty) :
-PythonObject(create_empty ? PyDict_New() : nullptr)
-{
-}
-
-PythonDictionary::PythonDictionary (PyObject *py_obj) :
- PythonObject(py_obj)
-{
- Reset(py_obj); // Use "Reset()" to ensure that py_obj is a dictionary
-}
-
-
-PythonDictionary::PythonDictionary (const PythonObject &object) :
- PythonObject()
-{
- Reset(object.get()); // Use "Reset()" to ensure that py_obj is a dictionary
-}
-
-PythonDictionary::~PythonDictionary ()
-{
-}
-
-bool
-PythonDictionary::Reset (PyObject *py_obj)
-{
- if (py_obj && PyDict_Check(py_obj))
- return PythonObject::Reset(py_obj);
-
- PythonObject::Reset(nullptr);
- return py_obj == nullptr;
-}
-
-uint32_t
-PythonDictionary::GetSize() const
-{
- if (m_py_obj)
- return PyDict_Size(m_py_obj);
- return 0;
-}
-
-PythonObject
-PythonDictionary::GetItemForKey (const char *key) const
-{
- if (key && key[0])
- {
- PythonString python_key(key);
- return GetItemForKey(python_key);
- }
- return PythonObject();
-}
-
-
-PythonObject
-PythonDictionary::GetItemForKey (const PythonString &key) const
-{
- if (m_py_obj && key)
- return PythonObject(PyDict_GetItem(m_py_obj, key.get()));
- return PythonObject();
-}
-
-
-const char *
-PythonDictionary::GetItemForKeyAsString (const PythonString &key, const char *fail_value) const
-{
- if (m_py_obj && key)
- {
- PyObject *py_obj = PyDict_GetItem(m_py_obj, key.get());
- if (py_obj && PyString_Check(py_obj))
- return PyString_AsString(py_obj);
- }
- return fail_value;
-}
-
-int64_t
-PythonDictionary::GetItemForKeyAsInteger (const PythonString &key, int64_t fail_value) const
-{
- if (m_py_obj && key)
- {
- PyObject *py_obj = PyDict_GetItem(m_py_obj, key.get());
- if (py_obj)
- {
- if (PyInt_Check(py_obj))
- return PyInt_AsLong(py_obj);
-
- if (PyLong_Check(py_obj))
- return PyLong_AsLong(py_obj);
- }
- }
- return fail_value;
-}
-
-PythonList
-PythonDictionary::GetKeys () const
-{
- if (m_py_obj)
- return PythonList(PyDict_Keys(m_py_obj));
- return PythonList(true);
-}
-
-PythonString
-PythonDictionary::GetKeyAtPosition (uint32_t pos) const
-{
- PyObject *key, *value;
- Py_ssize_t pos_iter = 0;
-
- if (m_py_obj)
- {
- while (PyDict_Next(m_py_obj, &pos_iter, &key, &value))
- {
- if (pos-- == 0)
- return PythonString(key);
- }
- }
- return PythonString();
-}
-
-PythonObject
-PythonDictionary::GetValueAtPosition (uint32_t pos) const
-{
- PyObject *key, *value;
- Py_ssize_t pos_iter = 0;
-
- if (!m_py_obj)
- return PythonObject();
-
- while (PyDict_Next(m_py_obj, &pos_iter, &key, &value)) {
- if (pos-- == 0)
- return PythonObject(value);
- }
- return PythonObject();
-}
-
-void
-PythonDictionary::SetItemForKey (const PythonString &key, PyObject *value)
-{
- if (m_py_obj && key && value)
- PyDict_SetItem(m_py_obj, key.get(), value);
-}
-
-void
-PythonDictionary::SetItemForKey (const PythonString &key, const PythonObject &value)
-{
- if (m_py_obj && key && value)
- PyDict_SetItem(m_py_obj, key.get(), value.get());
-}
-
-StructuredData::DictionarySP
-PythonDictionary::CreateStructuredDictionary() const
-{
- StructuredData::DictionarySP result(new StructuredData::Dictionary);
- PythonList keys(GetKeys());
- uint32_t num_keys = keys.GetSize();
- for (uint32_t i = 0; i < num_keys; ++i)
- {
- PythonObject key = keys.GetItemAtIndex(i);
- PythonString key_str = key.Str();
- PythonObject value = GetItemForKey(key);
- StructuredData::ObjectSP structured_value = value.CreateStructuredObject();
- result->AddItem(key_str.GetString(), structured_value);
- }
- return result;
-}
-
-#endif
diff --git a/source/Interpreter/ScriptInterpreterNone.cpp b/source/Interpreter/ScriptInterpreterNone.cpp
deleted file mode 100644
index 909a1161c9c1..000000000000
--- a/source/Interpreter/ScriptInterpreterNone.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-//===-- ScriptInterpreterNone.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/Interpreter/ScriptInterpreterNone.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StringList.h"
-#include "lldb/Core/Debugger.h"
-#include "lldb/Interpreter/CommandInterpreter.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-ScriptInterpreterNone::ScriptInterpreterNone (CommandInterpreter &interpreter) :
- ScriptInterpreter (interpreter, eScriptLanguageNone)
-{
-}
-
-ScriptInterpreterNone::~ScriptInterpreterNone ()
-{
-}
-
-bool
-ScriptInterpreterNone::ExecuteOneLine (const char *command, CommandReturnObject *, const ExecuteScriptOptions&)
-{
- m_interpreter.GetDebugger().GetErrorFile()->PutCString ("error: there is no embedded script interpreter in this mode.\n");
- return false;
-}
-
-void
-ScriptInterpreterNone::ExecuteInterpreterLoop ()
-{
- m_interpreter.GetDebugger().GetErrorFile()->PutCString ("error: there is no embedded script interpreter in this mode.\n");
-}
-
-
diff --git a/source/Interpreter/embedded_interpreter.py b/source/Interpreter/embedded_interpreter.py
index 10186f5a9d50..8ba539a2b0c9 100644
--- a/source/Interpreter/embedded_interpreter.py
+++ b/source/Interpreter/embedded_interpreter.py
@@ -1,7 +1,10 @@
-import __builtin__
+import sys
+if sys.version_info[0] < 3:
+ import __builtin__ as builtins
+else:
+ import builtins
import code
import lldb
-import sys
import traceback
try:
@@ -42,8 +45,8 @@ def setquit():
# "sys.exit(123)"
global g_builtin_override_called
g_builtin_override_called = False
- __builtin__.quit = LLDBQuitter('quit')
- __builtin__.exit = LLDBQuitter('exit')
+ builtins.quit = LLDBQuitter('quit')
+ builtins.exit = LLDBQuitter('exit')
# When running one line, we might place the string to run in this string
# in case it would be hard to correctly escape a string's contents
@@ -94,7 +97,7 @@ def run_python_interpreter (local_dict):
except SystemExit as e:
global g_builtin_override_called
if not g_builtin_override_called:
- print 'Script exited with %s' %(e)
+ print('Script exited with %s' %(e))
def run_one_line (local_dict, input_string):
global g_run_one_line_str
@@ -109,4 +112,4 @@ def run_one_line (local_dict, input_string):
except SystemExit as e:
global g_builtin_override_called
if not g_builtin_override_called:
- print 'Script exited with %s' %(e)
+ print('Script exited with %s' %(e))
diff --git a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
index 700d223fbc6d..3b9b0f346072 100644
--- a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
+++ b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
@@ -17,7 +17,6 @@
#include "lldb/Core/Scalar.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
@@ -28,7 +27,7 @@
#include "llvm/ADT/Triple.h"
#include "Utility/ARM_DWARF_Registers.h"
-#include "Utility/ARM_GCC_Registers.h"
+#include "Utility/ARM_ehframe_Registers.h"
#include "Plugins/Process/Utility/ARMDefines.h"
#include <vector>
@@ -38,90 +37,90 @@ using namespace lldb_private;
static RegisterInfo g_register_infos[] =
{
- // NAME ALT SZ OFF ENCODING FORMAT COMPILER DWARF GENERIC GDB LLDB NATIVE VALUE REGS INVALIDATE REGS
+ // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB NATIVE VALUE REGS INVALIDATE REGS
// ========== ======= == === ============= ============ ======================= =================== =========================== ======================= ====================== ========== ===============
- { "r0", "arg1", 4, 0, eEncodingUint , eFormatHex, { gcc_r0, dwarf_r0, LLDB_REGNUM_GENERIC_ARG1, gdb_arm_r0, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r1", "arg2", 4, 0, eEncodingUint , eFormatHex, { gcc_r1, dwarf_r1, LLDB_REGNUM_GENERIC_ARG2, gdb_arm_r1, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r2", "arg3", 4, 0, eEncodingUint , eFormatHex, { gcc_r2, dwarf_r2, LLDB_REGNUM_GENERIC_ARG3, gdb_arm_r2, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r3", "arg4", 4, 0, eEncodingUint , eFormatHex, { gcc_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG4, gdb_arm_r3, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r4", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r4, dwarf_r4, LLDB_INVALID_REGNUM, gdb_arm_r4, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r5", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r5, dwarf_r5, LLDB_INVALID_REGNUM, gdb_arm_r5, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r6", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r6, dwarf_r6, LLDB_INVALID_REGNUM, gdb_arm_r6, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r7", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP, gdb_arm_r7, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r8", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r8, dwarf_r8, LLDB_INVALID_REGNUM, gdb_arm_r8, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r9", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r9, dwarf_r9, LLDB_INVALID_REGNUM, gdb_arm_r9, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r10", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r10, dwarf_r10, LLDB_INVALID_REGNUM, gdb_arm_r10, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r11", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r11, dwarf_r11, LLDB_INVALID_REGNUM, gdb_arm_r11, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r12", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r12, dwarf_r12, LLDB_INVALID_REGNUM, gdb_arm_r12, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "sp", "r13", 4, 0, eEncodingUint , eFormatHex, { gcc_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, gdb_arm_sp, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "lr", "r14", 4, 0, eEncodingUint , eFormatHex, { gcc_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, gdb_arm_lr, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "pc", "r15", 4, 0, eEncodingUint , eFormatHex, { gcc_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, gdb_arm_pc, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "cpsr", "psr", 4, 0, eEncodingUint , eFormatHex, { gcc_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS, gdb_arm_cpsr, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s0", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, gdb_arm_s0, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s1", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, gdb_arm_s1, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s2", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, gdb_arm_s2, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s3", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, gdb_arm_s3, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s4", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, gdb_arm_s4, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s5", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, gdb_arm_s5, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s6", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, gdb_arm_s6, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s7", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, gdb_arm_s7, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s8", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, gdb_arm_s8, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s9", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, gdb_arm_s9, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s10", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, gdb_arm_s10, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s11", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, gdb_arm_s11, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s12", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, gdb_arm_s12, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s13", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, gdb_arm_s13, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s14", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, gdb_arm_s14, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s15", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, gdb_arm_s15, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s16", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, gdb_arm_s16, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s17", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, gdb_arm_s17, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s18", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, gdb_arm_s18, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s19", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, gdb_arm_s19, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s20", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, gdb_arm_s20, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s21", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, gdb_arm_s21, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s22", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, gdb_arm_s22, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s23", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, gdb_arm_s23, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s24", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, gdb_arm_s24, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s25", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, gdb_arm_s25, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s26", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, gdb_arm_s26, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s27", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, gdb_arm_s27, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s28", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, gdb_arm_s28, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s29", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, gdb_arm_s29, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s30", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, gdb_arm_s30, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s31", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, gdb_arm_s31, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "fpscr", NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM, gdb_arm_fpscr, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d0", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d0, LLDB_INVALID_REGNUM, gdb_arm_d0, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d1", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d1, LLDB_INVALID_REGNUM, gdb_arm_d1, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d2", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d2, LLDB_INVALID_REGNUM, gdb_arm_d2, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d3", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d3, LLDB_INVALID_REGNUM, gdb_arm_d3, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d4", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d4, LLDB_INVALID_REGNUM, gdb_arm_d4, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d5", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d5, LLDB_INVALID_REGNUM, gdb_arm_d5, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d6", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d6, LLDB_INVALID_REGNUM, gdb_arm_d6, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d7", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d7, LLDB_INVALID_REGNUM, gdb_arm_d7, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d8", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d8, LLDB_INVALID_REGNUM, gdb_arm_d8, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d9", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d9, LLDB_INVALID_REGNUM, gdb_arm_d9, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d10", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d10, LLDB_INVALID_REGNUM, gdb_arm_d10, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d11", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d11, LLDB_INVALID_REGNUM, gdb_arm_d11, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d12", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d12, LLDB_INVALID_REGNUM, gdb_arm_d12, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d13", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d13, LLDB_INVALID_REGNUM, gdb_arm_d13, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d14", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d14, LLDB_INVALID_REGNUM, gdb_arm_d14, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d15", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d15, LLDB_INVALID_REGNUM, gdb_arm_d15, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d16", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d16, LLDB_INVALID_REGNUM, gdb_arm_d16, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d17", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d17, LLDB_INVALID_REGNUM, gdb_arm_d17, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d18", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d18, LLDB_INVALID_REGNUM, gdb_arm_d18, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d19", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d19, LLDB_INVALID_REGNUM, gdb_arm_d19, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d20", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d20, LLDB_INVALID_REGNUM, gdb_arm_d20, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d21", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d21, LLDB_INVALID_REGNUM, gdb_arm_d21, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d22", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d22, LLDB_INVALID_REGNUM, gdb_arm_d22, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d23", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d23, LLDB_INVALID_REGNUM, gdb_arm_d23, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d24", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d24, LLDB_INVALID_REGNUM, gdb_arm_d24, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d25", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d25, LLDB_INVALID_REGNUM, gdb_arm_d25, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d26", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d26, LLDB_INVALID_REGNUM, gdb_arm_d26, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d27", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d27, LLDB_INVALID_REGNUM, gdb_arm_d27, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d28", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d28, LLDB_INVALID_REGNUM, gdb_arm_d28, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d29", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d29, LLDB_INVALID_REGNUM, gdb_arm_d29, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d30", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d30, LLDB_INVALID_REGNUM, gdb_arm_d30, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d31", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d31, LLDB_INVALID_REGNUM, gdb_arm_d31, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r0", "arg1", 4, 0, eEncodingUint , eFormatHex, { ehframe_r0, dwarf_r0, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r1", "arg2", 4, 0, eEncodingUint , eFormatHex, { ehframe_r1, dwarf_r1, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r2", "arg3", 4, 0, eEncodingUint , eFormatHex, { ehframe_r2, dwarf_r2, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r3", "arg4", 4, 0, eEncodingUint , eFormatHex, { ehframe_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r4", NULL, 4, 0, eEncodingUint , eFormatHex, { ehframe_r4, dwarf_r4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r5", NULL, 4, 0, eEncodingUint , eFormatHex, { ehframe_r5, dwarf_r5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r6", NULL, 4, 0, eEncodingUint , eFormatHex, { ehframe_r6, dwarf_r6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r7", NULL, 4, 0, eEncodingUint , eFormatHex, { ehframe_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r8", NULL, 4, 0, eEncodingUint , eFormatHex, { ehframe_r8, dwarf_r8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r9", NULL, 4, 0, eEncodingUint , eFormatHex, { ehframe_r9, dwarf_r9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r10", NULL, 4, 0, eEncodingUint , eFormatHex, { ehframe_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r11", NULL, 4, 0, eEncodingUint , eFormatHex, { ehframe_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r12", NULL, 4, 0, eEncodingUint , eFormatHex, { ehframe_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "sp", "r13", 4, 0, eEncodingUint , eFormatHex, { ehframe_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "lr", "r14", 4, 0, eEncodingUint , eFormatHex, { ehframe_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "pc", "r15", 4, 0, eEncodingUint , eFormatHex, { ehframe_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "cpsr", "psr", 4, 0, eEncodingUint , eFormatHex, { ehframe_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s0", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s1", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s2", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s3", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s4", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s5", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s6", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s7", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s8", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s9", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s10", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s11", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s12", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s13", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s14", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s15", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s16", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s17", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s18", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s19", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s20", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s21", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s22", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s23", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s24", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s25", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s26", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s27", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s28", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s29", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s30", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s31", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "fpscr", NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d0", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d1", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d2", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d3", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d4", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d5", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d6", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d7", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d8", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d9", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d10", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d11", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d12", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d13", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d14", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d15", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d16", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d17", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d18", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d19", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d20", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d21", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d22", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d23", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d24", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d25", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d26", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d27", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d28", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d29", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d30", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d31", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
{ "r8_usr", NULL, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r8_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
{ "r9_usr", NULL, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r9_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
{ "r10_usr", NULL, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r10_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
@@ -239,8 +238,8 @@ ABIMacOSX_arm::PrepareTrivialCall (Thread &thread,
size_t num_stack_regs = ae - ai;
sp -= (num_stack_regs * 4);
- // Keep the stack 8 byte aligned, not that we need to
- sp &= ~(8ull-1ull);
+ // Keep the stack 16 byte aligned
+ sp &= ~(16ull-1ull);
// just using arg1 to get the right size
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1);
@@ -333,18 +332,18 @@ ABIMacOSX_arm::GetArgumentValues (Thread &thread,
if (!value)
return false;
- ClangASTType clang_type = value->GetClangType();
- if (clang_type)
+ CompilerType compiler_type = value->GetCompilerType();
+ if (compiler_type)
{
bool is_signed = false;
size_t bit_width = 0;
- if (clang_type.IsIntegerType (is_signed))
+ if (compiler_type.IsIntegerType (is_signed))
{
- bit_width = clang_type.GetBitSize(&thread);
+ bit_width = compiler_type.GetBitSize(&thread);
}
- else if (clang_type.IsPointerOrReferenceType ())
+ else if (compiler_type.IsPointerOrReferenceType ())
{
- bit_width = clang_type.GetBitSize(&thread);
+ bit_width = compiler_type.GetBitSize(&thread);
}
else
{
@@ -414,22 +413,37 @@ ABIMacOSX_arm::GetArgumentValues (Thread &thread,
return true;
}
+bool
+ABIMacOSX_arm::IsArmv7kProcess (Thread *thread) const
+{
+ bool is_armv7k = false;
+ if (thread)
+ {
+ ProcessSP process_sp (thread->GetProcess());
+ if (process_sp)
+ {
+ const ArchSpec &arch (process_sp->GetTarget().GetArchitecture());
+ const ArchSpec::Core system_core = arch.GetCore();
+ if (system_core == ArchSpec::eCore_arm_armv7k)
+ {
+ is_armv7k = true;
+ }
+ }
+ }
+ return is_armv7k;
+}
+
ValueObjectSP
ABIMacOSX_arm::GetReturnValueObjectImpl (Thread &thread,
- lldb_private::ClangASTType &clang_type) const
+ lldb_private::CompilerType &compiler_type) const
{
Value value;
ValueObjectSP return_valobj_sp;
- if (!clang_type)
- return return_valobj_sp;
-
- clang::ASTContext *ast_context = clang_type.GetASTContext();
- if (!ast_context)
+ if (!compiler_type)
return return_valobj_sp;
- //value.SetContext (Value::eContextTypeClangType, clang_type.GetOpaqueQualType());
- value.SetClangType (clang_type);
+ value.SetCompilerType (compiler_type);
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
if (!reg_ctx)
@@ -441,14 +455,68 @@ ABIMacOSX_arm::GetReturnValueObjectImpl (Thread &thread,
// when reading data
const RegisterInfo *r0_reg_info = reg_ctx->GetRegisterInfoByName("r0", 0);
- if (clang_type.IsIntegerType (is_signed))
+ if (compiler_type.IsIntegerType (is_signed))
{
- size_t bit_width = clang_type.GetBitSize(&thread);
+ size_t bit_width = compiler_type.GetBitSize(&thread);
switch (bit_width)
{
default:
return return_valobj_sp;
+ case 128:
+ if (IsArmv7kProcess (&thread))
+ {
+ // "A composite type not larger than 16 bytes is returned in r0-r3. The format is
+ // as if the result had been stored in memory at a word-aligned address and then
+ // loaded into r0-r3 with an ldm instruction"
+ {
+ const RegisterInfo *r1_reg_info = reg_ctx->GetRegisterInfoByName("r1", 0);
+ const RegisterInfo *r2_reg_info = reg_ctx->GetRegisterInfoByName("r2", 0);
+ const RegisterInfo *r3_reg_info = reg_ctx->GetRegisterInfoByName("r3", 0);
+ if (r1_reg_info && r2_reg_info && r3_reg_info)
+ {
+ const size_t byte_size = compiler_type.GetByteSize(&thread);
+ ProcessSP process_sp (thread.GetProcess());
+ if (byte_size <= r0_reg_info->byte_size + r1_reg_info->byte_size + r2_reg_info->byte_size + r3_reg_info->byte_size
+ && process_sp)
+ {
+ std::unique_ptr<DataBufferHeap> heap_data_ap (new DataBufferHeap(byte_size, 0));
+ const ByteOrder byte_order = process_sp->GetByteOrder();
+ RegisterValue r0_reg_value;
+ RegisterValue r1_reg_value;
+ RegisterValue r2_reg_value;
+ RegisterValue r3_reg_value;
+ if (reg_ctx->ReadRegister(r0_reg_info, r0_reg_value)
+ && reg_ctx->ReadRegister(r1_reg_info, r1_reg_value)
+ && reg_ctx->ReadRegister(r2_reg_info, r2_reg_value)
+ && reg_ctx->ReadRegister(r3_reg_info, r3_reg_value))
+ {
+ Error error;
+ if (r0_reg_value.GetAsMemoryData (r0_reg_info, heap_data_ap->GetBytes()+0, 4, byte_order, error)
+ && r1_reg_value.GetAsMemoryData (r1_reg_info, heap_data_ap->GetBytes()+4, 4, byte_order, error)
+ && r2_reg_value.GetAsMemoryData (r2_reg_info, heap_data_ap->GetBytes()+8, 4, byte_order, error)
+ && r3_reg_value.GetAsMemoryData (r3_reg_info, heap_data_ap->GetBytes()+12, 4, byte_order, error))
+ {
+ DataExtractor data (DataBufferSP (heap_data_ap.release()),
+ byte_order,
+ process_sp->GetAddressByteSize());
+
+ return_valobj_sp = ValueObjectConstResult::Create (&thread,
+ compiler_type,
+ ConstString(""),
+ data);
+ return return_valobj_sp;
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ return return_valobj_sp;
+ }
+ break;
case 64:
{
const RegisterInfo *r1_reg_info = reg_ctx->GetRegisterInfoByName("r1", 0);
@@ -481,7 +549,7 @@ ABIMacOSX_arm::GetReturnValueObjectImpl (Thread &thread,
break;
}
}
- else if (clang_type.IsPointerType ())
+ else if (compiler_type.IsPointerType ())
{
uint32_t ptr = thread.GetRegisterContext()->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX;
value.GetScalar() = ptr;
@@ -510,8 +578,8 @@ ABIMacOSX_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObj
return error;
}
- ClangASTType clang_type = new_value_sp->GetClangType();
- if (!clang_type)
+ CompilerType compiler_type = new_value_sp->GetCompilerType();
+ if (!compiler_type)
{
error.SetErrorString ("Null clang type for return value.");
return error;
@@ -526,7 +594,7 @@ ABIMacOSX_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObj
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
bool set_it_simple = false;
- if (clang_type.IsIntegerType (is_signed) || clang_type.IsPointerType())
+ if (compiler_type.IsIntegerType (is_signed) || compiler_type.IsPointerType())
{
DataExtractor data;
Error data_error;
@@ -561,12 +629,45 @@ ABIMacOSX_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObj
}
}
}
+ else if (num_bytes <= 16 && IsArmv7kProcess (frame_sp->GetThread().get()))
+ {
+ // "A composite type not larger than 16 bytes is returned in r0-r3. The format is
+ // as if the result had been stored in memory at a word-aligned address and then
+ // loaded into r0-r3 with an ldm instruction"
+
+ const RegisterInfo *r0_info = reg_ctx->GetRegisterInfoByName("r0", 0);
+ const RegisterInfo *r1_info = reg_ctx->GetRegisterInfoByName("r1", 0);
+ const RegisterInfo *r2_info = reg_ctx->GetRegisterInfoByName("r2", 0);
+ const RegisterInfo *r3_info = reg_ctx->GetRegisterInfoByName("r3", 0);
+ lldb::offset_t offset = 0;
+ uint32_t bytes_written = 4;
+ uint32_t raw_value = data.GetMaxU64(&offset, 4);
+ if (reg_ctx->WriteRegisterFromUnsigned (r0_info, raw_value) && bytes_written <= num_bytes)
+ {
+ bytes_written += 4;
+ raw_value = data.GetMaxU64(&offset, 4);
+ if (bytes_written <= num_bytes && reg_ctx->WriteRegisterFromUnsigned (r1_info, raw_value))
+ {
+ bytes_written += 4;
+ raw_value = data.GetMaxU64(&offset, 4);
+ if (bytes_written <= num_bytes && reg_ctx->WriteRegisterFromUnsigned (r2_info, raw_value))
+ {
+ bytes_written += 4;
+ raw_value = data.GetMaxU64(&offset, 4);
+ if (bytes_written <= num_bytes && reg_ctx->WriteRegisterFromUnsigned (r3_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 (clang_type.IsFloatingPointType (count, is_complex))
+ else if (compiler_type.IsFloatingPointType (count, is_complex))
{
if (is_complex)
error.SetErrorString ("We don't support returning complex values at present");
diff --git a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h
index eee43943d73a..a4e9dead7794 100644
--- a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h
+++ b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h
@@ -20,42 +20,36 @@
class ABIMacOSX_arm : public lldb_private::ABI
{
public:
- ~ABIMacOSX_arm() { }
+ ~ABIMacOSX_arm() override = default;
- virtual size_t
- GetRedZoneSize () const;
+ size_t
+ GetRedZoneSize() const override;
- virtual bool
- PrepareTrivialCall (lldb_private::Thread &thread,
- lldb::addr_t sp,
- lldb::addr_t func_addr,
- lldb::addr_t returnAddress,
- llvm::ArrayRef<lldb::addr_t> args) const;
+ bool
+ PrepareTrivialCall(lldb_private::Thread &thread,
+ lldb::addr_t sp,
+ lldb::addr_t func_addr,
+ lldb::addr_t returnAddress,
+ llvm::ArrayRef<lldb::addr_t> args) const override;
- virtual bool
- GetArgumentValues (lldb_private::Thread &thread,
- lldb_private::ValueList &values) const;
+ bool
+ GetArgumentValues(lldb_private::Thread &thread,
+ lldb_private::ValueList &values) const override;
- virtual lldb_private::Error
- SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value);
+ lldb_private::Error
+ SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override;
-protected:
- virtual lldb::ValueObjectSP
- GetReturnValueObjectImpl (lldb_private::Thread &thread,
- lldb_private::ClangASTType &ast_type) const;
-
-public:
- virtual bool
- CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
+ bool
+ CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
- virtual bool
- CreateDefaultUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
+ bool
+ CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
- virtual bool
- RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info);
+ bool
+ RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
- virtual bool
- CallFrameAddressIsValid (lldb::addr_t cfa)
+ bool
+ CallFrameAddressIsValid(lldb::addr_t cfa) override
{
// Make sure the stack call frame addresses are are 4 byte aligned
if (cfa & (4ull - 1ull))
@@ -65,8 +59,8 @@ public:
return true;
}
- virtual bool
- CodeAddressIsValid (lldb::addr_t pc)
+ bool
+ CodeAddressIsValid(lldb::addr_t pc) override
{
// Just make sure the address is a valid 32 bit address. Bit zero
// might be set due to Thumb function calls, so don't enforce 2 byte
@@ -74,20 +68,24 @@ public:
return pc <= UINT32_MAX;
}
- virtual lldb::addr_t
- FixCodeAddress (lldb::addr_t pc)
+ lldb::addr_t
+ FixCodeAddress(lldb::addr_t pc) override
{
// ARM uses bit zero to signify a code address is thumb, so we must
// strip bit zero in any code addresses.
return pc & ~(lldb::addr_t)1;
}
- virtual const lldb_private::RegisterInfo *
- GetRegisterInfoArray (uint32_t &count);
+ const lldb_private::RegisterInfo *
+ GetRegisterInfoArray(uint32_t &count) override;
+
+ bool
+ IsArmv7kProcess (lldb_private::Thread *thread) const;
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
+
static void
Initialize();
@@ -103,13 +101,18 @@ public:
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
- virtual lldb_private::ConstString
- GetPluginName();
+
+ lldb_private::ConstString
+ GetPluginName() override;
- virtual uint32_t
- GetPluginVersion();
+ uint32_t
+ GetPluginVersion() override;
protected:
+ lldb::ValueObjectSP
+ GetReturnValueObjectImpl(lldb_private::Thread &thread,
+ lldb_private::CompilerType &ast_type) const override;
+
private:
ABIMacOSX_arm() :
lldb_private::ABI()
@@ -118,4 +121,4 @@ private:
}
};
-#endif // liblldb_ABIMacOSX_arm_h_
+#endif // liblldb_ABIMacOSX_arm_h_
diff --git a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
index 04b96180deb3..0e6f9d663ae8 100644
--- a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
+++ b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
@@ -19,7 +19,6 @@
#include "lldb/Core/Value.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
@@ -37,12 +36,11 @@ using namespace lldb;
using namespace lldb_private;
static const char *pluginDesc = "Mac OS X ABI for arm64 targets";
-static const char *pluginShort = "abi.macosx-arm64";
static RegisterInfo g_register_infos[] =
{
- // NAME ALT SZ OFF ENCODING FORMAT COMPILER DWARF GENERIC GDB LLDB NATIVE
+ // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB NATIVE
// ========== ======= == === ============= =================== =================== ====================== =========================== ======================= ======================
{ "x0", NULL, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x0, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
{ "x1", NULL, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x1, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
@@ -77,7 +75,7 @@ static RegisterInfo g_register_infos[] =
{ "lr", "x30", 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x30, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
{ "sp", "x31", 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x31, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
{ "pc", NULL, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "cpsr", "psr", 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::cpsr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "cpsr", "psr", 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::cpsr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
{ "v0", NULL, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
{ "v1", NULL, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
@@ -115,71 +113,71 @@ static RegisterInfo g_register_infos[] =
{ "fpsr", NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
{ "fpcr", NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s0", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s1", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s2", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s3", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s4", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s5", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s6", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s7", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s8", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s9", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s10", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s11", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s12", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s13", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s14", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s15", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s16", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s17", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s18", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s19", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s20", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s21", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s22", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s23", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s24", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s25", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s26", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s27", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s28", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s29", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s30", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "s31", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
-
- { "d0", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d1", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d2", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d3", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d4", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d5", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d6", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d7", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d8", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d9", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d10", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d11", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d12", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d13", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d14", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d15", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d16", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d17", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d18", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d19", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d20", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d21", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d22", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d23", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d24", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d25", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d26", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d27", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d28", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d29", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d30", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
- { "d31", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL }
+ { "s0", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s1", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s2", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s3", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s4", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s5", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s6", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s7", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s8", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s9", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s10", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s11", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s12", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s13", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s14", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s15", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s16", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s17", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s18", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s19", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s20", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s21", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s22", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s23", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s24", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s25", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s26", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s27", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s28", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s29", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s30", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "s31", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+
+ { "d0", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d1", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d2", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d3", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d4", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d5", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d6", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d7", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d8", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d9", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d10", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d11", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d12", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d13", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d14", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d15", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d16", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d17", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d18", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d19", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d20", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d21", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d22", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d23", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d24", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d25", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d26", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d27", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d28", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d29", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d30", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
+ { "d31", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL }
};
static const uint32_t k_num_register_infos = llvm::array_lengthof(g_register_infos);
@@ -322,7 +320,7 @@ ABIMacOSX_arm64::GetArgumentValues (Thread &thread, ValueList &values) const
if (!value)
return false;
- ClangASTType value_type = value->GetClangType();
+ CompilerType value_type = value->GetCompilerType();
if (value_type)
{
bool is_signed = false;
@@ -424,7 +422,7 @@ ABIMacOSX_arm64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueO
return error;
}
- ClangASTType return_value_type = new_value_sp->GetClangType();
+ CompilerType return_value_type = new_value_sp->GetCompilerType();
if (!return_value_type)
{
error.SetErrorString ("Null clang type for return value.");
@@ -709,7 +707,7 @@ ABIMacOSX_arm64::RegisterIsVolatile (const RegisterInfo *reg_info)
static bool
LoadValueFromConsecutiveGPRRegisters (ExecutionContext &exe_ctx,
RegisterContext *reg_ctx,
- const ClangASTType &value_type,
+ const CompilerType &value_type,
bool is_return_value, // false => parameter, true => return value
uint32_t &NGRN, // NGRN (see ABI documentation)
uint32_t &NSRN, // NSRN (see ABI documentation)
@@ -724,18 +722,16 @@ LoadValueFromConsecutiveGPRRegisters (ExecutionContext &exe_ctx,
const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder();
Error error;
- ClangASTType base_type;
+ CompilerType base_type;
const uint32_t homogeneous_count = value_type.IsHomogeneousAggregate (&base_type);
if (homogeneous_count > 0 && homogeneous_count <= 8)
{
- printf ("ClangASTContext::IsHomogeneousAggregate() => %u\n", homogeneous_count);
// Make sure we have enough registers
if (NSRN < 8 && (8-NSRN) >= homogeneous_count)
{
if (!base_type)
return false;
const size_t base_byte_size = base_type.GetByteSize(nullptr);
- printf ("ClangASTContext::IsHomogeneousAggregate() => base_byte_size = %" PRIu64 "\n", (uint64_t) base_byte_size);
uint32_t data_offset = 0;
for (uint32_t i=0; i<homogeneous_count; ++i)
@@ -861,7 +857,7 @@ LoadValueFromConsecutiveGPRRegisters (ExecutionContext &exe_ctx,
}
ValueObjectSP
-ABIMacOSX_arm64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_clang_type) const
+ABIMacOSX_arm64::GetReturnValueObjectImpl (Thread &thread, CompilerType &return_compiler_type) const
{
ValueObjectSP return_valobj_sp;
Value value;
@@ -870,16 +866,16 @@ ABIMacOSX_arm64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_
if (exe_ctx.GetTargetPtr() == NULL || exe_ctx.GetProcessPtr() == NULL)
return return_valobj_sp;
- //value.SetContext (Value::eContextTypeClangType, return_clang_type);
- value.SetClangType(return_clang_type);
+ //value.SetContext (Value::eContextTypeClangType, return_compiler_type);
+ value.SetCompilerType(return_compiler_type);
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
if (!reg_ctx)
return return_valobj_sp;
- const size_t byte_size = return_clang_type.GetByteSize(nullptr);
+ const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
- const uint32_t type_flags = return_clang_type.GetTypeInfo (NULL);
+ const uint32_t type_flags = return_compiler_type.GetTypeInfo (NULL);
if (type_flags & eTypeIsScalar ||
type_flags & eTypeIsPointer)
{
@@ -926,7 +922,7 @@ ABIMacOSX_arm64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_
exe_ctx.GetProcessRef().GetAddressByteSize());
return_valobj_sp = ValueObjectConstResult::Create (&thread,
- return_clang_type,
+ return_compiler_type,
ConstString(""),
data);
return return_valobj_sp;
@@ -1043,7 +1039,7 @@ ABIMacOSX_arm64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_
byte_order,
exe_ctx.GetProcessRef().GetAddressByteSize());
return_valobj_sp = ValueObjectConstResult::Create (&thread,
- return_clang_type,
+ return_compiler_type,
ConstString(""),
data);
}
@@ -1060,10 +1056,10 @@ ABIMacOSX_arm64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_
uint32_t NGRN = 0; // Search ABI docs for NGRN
uint32_t NSRN = 0; // Search ABI docs for NSRN
const bool is_return_value = true;
- if (LoadValueFromConsecutiveGPRRegisters (exe_ctx, reg_ctx, return_clang_type, is_return_value, NGRN, NSRN, data))
+ if (LoadValueFromConsecutiveGPRRegisters (exe_ctx, reg_ctx, return_compiler_type, is_return_value, NGRN, NSRN, data))
{
return_valobj_sp = ValueObjectConstResult::Create (&thread,
- return_clang_type,
+ return_compiler_type,
ConstString(""),
data);
}
@@ -1095,12 +1091,6 @@ ABIMacOSX_arm64::GetPluginNameStatic()
return g_plugin_name;
}
-const char *
-ABIMacOSX_arm64::GetShortPluginName()
-{
- return pluginShort;
-}
-
uint32_t
ABIMacOSX_arm64::GetPluginVersion()
{
diff --git a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h
index 6cce6a6f1174..1bc94f61c2f1 100644
--- a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h
+++ b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h
@@ -22,30 +22,30 @@ class ABIMacOSX_arm64 :
public lldb_private::ABI
{
public:
- ~ABIMacOSX_arm64() { }
+ ~ABIMacOSX_arm64() override = default;
- virtual size_t
- GetRedZoneSize () const;
+ size_t
+ GetRedZoneSize() const override;
- virtual bool
- PrepareTrivialCall (lldb_private::Thread &thread,
- lldb::addr_t sp,
- lldb::addr_t functionAddress,
- lldb::addr_t returnAddress,
- llvm::ArrayRef<lldb::addr_t> args) const;
+ 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;
- virtual bool
- GetArgumentValues (lldb_private::Thread &thread,
- lldb_private::ValueList &values) const;
+ bool
+ GetArgumentValues(lldb_private::Thread &thread,
+ lldb_private::ValueList &values) const override;
- virtual bool
- CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
+ bool
+ CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
- virtual bool
- CreateDefaultUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
+ bool
+ CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
- virtual bool
- RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info);
+ bool
+ RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
// The arm64 ABI requires that stack frames be 16 byte aligned.
// When there is a trap handler on the stack, e.g. _sigtramp in userland
@@ -57,9 +57,8 @@ public:
// Whitelisting the trap handlers for user space would be easy (_sigtramp) but
// in other environments there can be a large number of different functions
// involved in async traps.
-
- virtual bool
- CallFrameAddressIsValid (lldb::addr_t cfa)
+ bool
+ CallFrameAddressIsValid(lldb::addr_t cfa) override
{
// Make sure the stack call frame addresses are are 8 byte aligned
if (cfa & (8ull - 1ull))
@@ -69,8 +68,8 @@ public:
return true;
}
- virtual bool
- CodeAddressIsValid (lldb::addr_t pc)
+ bool
+ CodeAddressIsValid(lldb::addr_t pc) override
{
if (pc & (4ull - 1ull))
return false; // Not 4 byte aligned
@@ -79,12 +78,13 @@ public:
return true;
}
- virtual const lldb_private::RegisterInfo *
- GetRegisterInfoArray (uint32_t &count);
+ const lldb_private::RegisterInfo *
+ GetRegisterInfoArray(uint32_t &count) override;
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
+
static void
Initialize();
@@ -97,28 +97,26 @@ public:
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
+
static lldb_private::ConstString
GetPluginNameStatic();
- virtual lldb_private::ConstString
- GetPluginName()
+ lldb_private::ConstString
+ GetPluginName() override
{
return GetPluginNameStatic();
}
- virtual const char *
- GetShortPluginName();
-
- virtual uint32_t
- GetPluginVersion();
+ uint32_t
+ GetPluginVersion() override;
- virtual lldb_private::Error
- SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value);
+ lldb_private::Error
+ SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override;
protected:
- virtual lldb::ValueObjectSP
+ lldb::ValueObjectSP
GetReturnValueObjectImpl (lldb_private::Thread &thread,
- lldb_private::ClangASTType &ast_type) const;
+ lldb_private::CompilerType &ast_type) const override;
private:
ABIMacOSX_arm64() :
@@ -128,4 +126,4 @@ private:
}
};
-#endif // liblldb_ABI_h_
+#endif // liblldb_ABIMacOSX_arm64_h_
diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
index 4204d18769b8..75e5fb1558e6 100644
--- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
+++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
@@ -16,13 +16,13 @@
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Core/ValueObjectConstResult.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
#include <vector>
@@ -32,16 +32,16 @@ using namespace lldb_private;
enum
{
- gcc_eax = 0,
- gcc_ecx,
- gcc_edx,
- gcc_ebx,
- gcc_ebp,
- gcc_esp,
- gcc_esi,
- gcc_edi,
- gcc_eip,
- gcc_eflags
+ ehframe_eax = 0,
+ ehframe_ecx,
+ ehframe_edx,
+ ehframe_ebx,
+ ehframe_ebp, // Different from DWARF the regnums - eh_frame esp/ebp had their regnums switched on i386 darwin
+ ehframe_esp, // Different from DWARF the regnums - eh_frame esp/ebp had their regnums switched on i386 darwin
+ ehframe_esi,
+ ehframe_edi,
+ ehframe_eip,
+ ehframe_eflags
};
enum
@@ -82,121 +82,60 @@ enum
dwarf_ymm7 = dwarf_xmm7
};
-enum
-{
- gdb_eax = 0,
- gdb_ecx = 1,
- gdb_edx = 2,
- gdb_ebx = 3,
- gdb_esp = 4,
- gdb_ebp = 5,
- gdb_esi = 6,
- gdb_edi = 7,
- gdb_eip = 8,
- gdb_eflags = 9,
- gdb_cs = 10,
- gdb_ss = 11,
- gdb_ds = 12,
- gdb_es = 13,
- gdb_fs = 14,
- gdb_gs = 15,
- gdb_stmm0 = 16,
- gdb_stmm1 = 17,
- gdb_stmm2 = 18,
- gdb_stmm3 = 19,
- gdb_stmm4 = 20,
- gdb_stmm5 = 21,
- gdb_stmm6 = 22,
- gdb_stmm7 = 23,
- gdb_fctrl = 24, gdb_fcw = gdb_fctrl,
- gdb_fstat = 25, gdb_fsw = gdb_fstat,
- gdb_ftag = 26, gdb_ftw = gdb_ftag,
- gdb_fiseg = 27, gdb_fpu_cs = gdb_fiseg,
- gdb_fioff = 28, gdb_ip = gdb_fioff,
- gdb_foseg = 29, gdb_fpu_ds = gdb_foseg,
- gdb_fooff = 30, gdb_dp = gdb_fooff,
- gdb_fop = 31,
- gdb_xmm0 = 32,
- gdb_xmm1 = 33,
- gdb_xmm2 = 34,
- gdb_xmm3 = 35,
- gdb_xmm4 = 36,
- gdb_xmm5 = 37,
- gdb_xmm6 = 38,
- gdb_xmm7 = 39,
- gdb_mxcsr = 40,
- gdb_mm0 = 41,
- gdb_mm1 = 42,
- gdb_mm2 = 43,
- gdb_mm3 = 44,
- gdb_mm4 = 45,
- gdb_mm5 = 46,
- gdb_mm6 = 47,
- gdb_mm7 = 48,
- gdb_ymm0 = gdb_xmm0,
- gdb_ymm1 = gdb_xmm1,
- gdb_ymm2 = gdb_xmm2,
- gdb_ymm3 = gdb_xmm3,
- gdb_ymm4 = gdb_xmm4,
- gdb_ymm5 = gdb_xmm5,
- gdb_ymm6 = gdb_xmm6,
- gdb_ymm7 = gdb_xmm7
-};
-
static RegisterInfo g_register_infos[] =
{
- // NAME ALT SZ OFF ENCODING FORMAT COMPILER DWARF GENERIC GDB LLDB NATIVE VALUE REGS INVALIDATE REGS
+ // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB NATIVE VALUE REGS INVALIDATE REGS
// ====== ======= == === ============= ============ ===================== ===================== ============================ ==================== ====================== ========== ===============
- { "eax", NULL, 4, 0, eEncodingUint , eFormatHex , { gcc_eax , dwarf_eax , LLDB_INVALID_REGNUM , gdb_eax , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ebx" , NULL, 4, 0, eEncodingUint , eFormatHex , { gcc_ebx , dwarf_ebx , LLDB_INVALID_REGNUM , gdb_ebx , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ecx" , NULL, 4, 0, eEncodingUint , eFormatHex , { gcc_ecx , dwarf_ecx , LLDB_REGNUM_GENERIC_ARG4 , gdb_ecx , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "edx" , NULL, 4, 0, eEncodingUint , eFormatHex , { gcc_edx , dwarf_edx , LLDB_REGNUM_GENERIC_ARG3 , gdb_edx , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "esi" , NULL, 4, 0, eEncodingUint , eFormatHex , { gcc_esi , dwarf_esi , LLDB_REGNUM_GENERIC_ARG2 , gdb_esi , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "edi" , NULL, 4, 0, eEncodingUint , eFormatHex , { gcc_edi , dwarf_edi , LLDB_REGNUM_GENERIC_ARG1 , gdb_edi , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ebp" , "fp", 4, 0, eEncodingUint , eFormatHex , { gcc_ebp , dwarf_ebp , LLDB_REGNUM_GENERIC_FP , gdb_ebp , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "esp" , "sp", 4, 0, eEncodingUint , eFormatHex , { gcc_esp , dwarf_esp , LLDB_REGNUM_GENERIC_SP , gdb_esp , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "eip" , "pc", 4, 0, eEncodingUint , eFormatHex , { gcc_eip , dwarf_eip , LLDB_REGNUM_GENERIC_PC , gdb_eip , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "eflags", NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_REGNUM_GENERIC_FLAGS , gdb_eflags , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "cs" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_cs , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ss" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ss , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ds" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ds , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "es" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_es , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "fs" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fs , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "gs" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_gs , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "stmm0" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm0 , LLDB_INVALID_REGNUM , gdb_stmm0 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "stmm1" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm1 , LLDB_INVALID_REGNUM , gdb_stmm1 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "stmm2" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm2 , LLDB_INVALID_REGNUM , gdb_stmm2 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "stmm3" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm3 , LLDB_INVALID_REGNUM , gdb_stmm3 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "stmm4" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm4 , LLDB_INVALID_REGNUM , gdb_stmm4 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "stmm5" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm5 , LLDB_INVALID_REGNUM , gdb_stmm5 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "stmm6" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm6 , LLDB_INVALID_REGNUM , gdb_stmm6 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "stmm7" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm7 , LLDB_INVALID_REGNUM , gdb_stmm7 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "fctrl" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fctrl , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "fstat" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fstat , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ftag" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ftag , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "fiseg" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fiseg , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "fioff" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fioff , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "foseg" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_foseg , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "fooff" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fooff , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "fop" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fop , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm0" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm0 , LLDB_INVALID_REGNUM , gdb_xmm0 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm1" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm1 , LLDB_INVALID_REGNUM , gdb_xmm1 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm2" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm2 , LLDB_INVALID_REGNUM , gdb_xmm2 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm3" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm3 , LLDB_INVALID_REGNUM , gdb_xmm3 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm4" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm4 , LLDB_INVALID_REGNUM , gdb_xmm4 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm5" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm5 , LLDB_INVALID_REGNUM , gdb_xmm5 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm6" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm6 , LLDB_INVALID_REGNUM , gdb_xmm6 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm7" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm7 , LLDB_INVALID_REGNUM , gdb_xmm7 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "mxcsr" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_mxcsr , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm0" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm0 , LLDB_INVALID_REGNUM , gdb_ymm0 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm1" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm1 , LLDB_INVALID_REGNUM , gdb_ymm1 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm2" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm2 , LLDB_INVALID_REGNUM , gdb_ymm2 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm3" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm3 , LLDB_INVALID_REGNUM , gdb_ymm3 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm4" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm4 , LLDB_INVALID_REGNUM , gdb_ymm4 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm5" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm5 , LLDB_INVALID_REGNUM , gdb_ymm5 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm6" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm6 , LLDB_INVALID_REGNUM , gdb_ymm6 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm7" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm7 , LLDB_INVALID_REGNUM , gdb_ymm7 , LLDB_INVALID_REGNUM }, NULL, NULL}
+ { "eax", NULL, 4, 0, eEncodingUint , eFormatHex , { ehframe_eax , dwarf_eax , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ebx" , NULL, 4, 0, eEncodingUint , eFormatHex , { ehframe_ebx , dwarf_ebx , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ecx" , NULL, 4, 0, eEncodingUint , eFormatHex , { ehframe_ecx , dwarf_ecx , LLDB_REGNUM_GENERIC_ARG4 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "edx" , NULL, 4, 0, eEncodingUint , eFormatHex , { ehframe_edx , dwarf_edx , LLDB_REGNUM_GENERIC_ARG3 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "esi" , NULL, 4, 0, eEncodingUint , eFormatHex , { ehframe_esi , dwarf_esi , LLDB_REGNUM_GENERIC_ARG2 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "edi" , NULL, 4, 0, eEncodingUint , eFormatHex , { ehframe_edi , dwarf_edi , LLDB_REGNUM_GENERIC_ARG1 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ebp" , "fp", 4, 0, eEncodingUint , eFormatHex , { ehframe_ebp , dwarf_ebp , LLDB_REGNUM_GENERIC_FP , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "esp" , "sp", 4, 0, eEncodingUint , eFormatHex , { ehframe_esp , dwarf_esp , LLDB_REGNUM_GENERIC_SP , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "eip" , "pc", 4, 0, eEncodingUint , eFormatHex , { ehframe_eip , dwarf_eip , LLDB_REGNUM_GENERIC_PC , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "eflags", NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_REGNUM_GENERIC_FLAGS , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "cs" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ss" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ds" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "es" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "fs" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "gs" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "stmm0" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm0 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "stmm1" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm1 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "stmm2" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm2 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "stmm3" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm3 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "stmm4" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm4 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "stmm5" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm5 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "stmm6" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm6 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "stmm7" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm7 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "fctrl" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "fstat" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ftag" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "fiseg" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "fioff" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "foseg" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "fooff" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "fop" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm0" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm0 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm1" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm1 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm2" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm2 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm3" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm3 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm4" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm4 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm5" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm5 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm6" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm6 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm7" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm7 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "mxcsr" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm0" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm0 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm1" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm1 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm2" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm2 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm3" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm3 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm4" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm4 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm5" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm5 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm6" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm6 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm7" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm7 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL}
};
static const uint32_t k_num_register_infos = llvm::array_lengthof(g_register_infos);
@@ -237,7 +176,7 @@ ABIMacOSX_i386::CreateInstance (const ArchSpec &arch)
{
static ABISP g_abi_sp;
if ((arch.GetTriple().getArch() == llvm::Triple::x86) &&
- (arch.GetTriple().isMacOSX() || arch.GetTriple().isiOS()))
+ (arch.GetTriple().isMacOSX() || arch.GetTriple().isiOS() || arch.GetTriple().isWatchOS()))
{
if (!g_abi_sp)
g_abi_sp.reset (new ABIMacOSX_i386);
@@ -316,184 +255,6 @@ ABIMacOSX_i386::PrepareTrivialCall (Thread &thread,
return true;
}
-bool
-ABIMacOSX_i386::PrepareNormalCall (Thread &thread,
- addr_t sp,
- addr_t func_addr,
- addr_t return_addr,
- ValueList &args) const
-{
- ExecutionContext exe_ctx (thread.shared_from_this());
- RegisterContext *reg_ctx = thread.GetRegisterContext().get();
- if (!reg_ctx)
- return false;
-
- Process *process = exe_ctx.GetProcessPtr();
- Error error;
- uint32_t fp_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP);
- uint32_t pc_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
- uint32_t sp_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP);
-
- // Do the argument layout
-
- std::vector <uint32_t> argLayout; // 4-byte chunks, as discussed in the ABI Function Call Guide
-
- size_t numArgs = args.GetSize();
- size_t index;
-
- for (index = 0; index < numArgs; ++index)
- {
- Value *val = args.GetValueAtIndex(index);
-
- if (!val)
- return false;
-
- switch (val->GetValueType())
- {
- case Value::eValueTypeScalar:
- {
- Scalar &scalar = val->GetScalar();
- switch (scalar.GetType())
- {
- case Scalar::e_void:
- return false;
- case Scalar::e_sint:
- case Scalar::e_uint:
- case Scalar::e_slong:
- case Scalar::e_ulong:
- case Scalar::e_slonglong:
- case Scalar::e_ulonglong:
- {
- uint64_t data = scalar.ULongLong();
-
- switch (scalar.GetByteSize())
- {
- default:
- return false;
- case 1:
- argLayout.push_back((uint32_t)(data & 0xffull));
- break;
- case 2:
- argLayout.push_back((uint32_t)(data & 0xffffull));
- break;
- case 4:
- argLayout.push_back((uint32_t)(data & 0xffffffffull));
- break;
- case 8:
- argLayout.push_back((uint32_t)(data & 0xffffffffull));
- argLayout.push_back((uint32_t)(data >> 32));
- break;
- }
- }
- break;
- case Scalar::e_float:
- {
- float data = scalar.Float();
- uint32_t dataRaw = *((uint32_t*)(&data));
- argLayout.push_back(dataRaw);
- }
- break;
- case Scalar::e_double:
- {
- double data = scalar.Double();
- uint32_t *dataRaw = ((uint32_t*)(&data));
- argLayout.push_back(dataRaw[0]);
- argLayout.push_back(dataRaw[1]);
- }
- break;
- case Scalar::e_long_double:
- {
- long double data = scalar.Double();
- uint32_t *dataRaw = ((uint32_t*)(&data));
- while ((argLayout.size() * 4) & 0xf)
- argLayout.push_back(0);
- argLayout.push_back(dataRaw[0]);
- argLayout.push_back(dataRaw[1]);
- argLayout.push_back(dataRaw[2]);
- argLayout.push_back(dataRaw[3]);
- }
- break;
- }
- }
- break;
- case Value::eValueTypeHostAddress:
- {
- ClangASTType clang_type (val->GetClangType());
- if (clang_type)
- {
- uint32_t cstr_length = 0;
- if (clang_type.IsCStringType (cstr_length))
- {
- const char *cstr = (const char*)val->GetScalar().ULongLong();
- cstr_length = strlen(cstr);
-
- // Push the string onto the stack immediately.
-
- sp -= (cstr_length + 1);
-
- if (process->WriteMemory(sp, cstr, cstr_length + 1, error) != (cstr_length + 1))
- return false;
-
- // Put the address of the string into the argument array.
-
- argLayout.push_back((uint32_t)(sp & 0xffffffff));
- }
- else
- {
- return false;
- }
- }
- break;
- }
- break;
- case Value::eValueTypeFileAddress:
- case Value::eValueTypeLoadAddress:
- default:
- return false;
- }
- }
-
- // Make room for the arguments on the stack
-
- sp -= 4 * argLayout.size();
-
- // Align the SP
-
- sp &= ~(16ull-1ull); // 16-byte alignment
-
- // Write the arguments on the stack
-
- size_t numChunks = argLayout.size();
-
- for (index = 0; index < numChunks; ++index)
- if (process->WriteMemory(sp + (index * 4), &argLayout[index], sizeof(uint32_t), error) != sizeof(uint32_t))
- return false;
-
- // The return address is pushed onto the stack.
-
- sp -= 4;
- uint32_t returnAddressU32 = return_addr;
- if (process->WriteMemory (sp, &returnAddressU32, sizeof(returnAddressU32), error) != sizeof(returnAddressU32))
- return false;
-
- // %esp is set to the actual stack value.
-
- if (!reg_ctx->WriteRegisterFromUnsigned(sp_reg_num, sp))
- return false;
-
- // %ebp is set to a fake value, in our case 0x0x00000000
-
- if (!reg_ctx->WriteRegisterFromUnsigned(fp_reg_num, 0x00000000))
- return false;
-
- // %eip is set to the address of the called function.
-
- if (!reg_ctx->WriteRegisterFromUnsigned(pc_reg_num, func_addr))
- return false;
-
- return true;
-}
-
static bool
ReadIntegerArgument (Scalar &scalar,
unsigned int bit_width,
@@ -545,23 +306,23 @@ ABIMacOSX_i386::GetArgumentValues (Thread &thread,
// We currently only support extracting values with Clang QualTypes.
// Do we care about others?
- ClangASTType clang_type (value->GetClangType());
- if (clang_type)
+ CompilerType compiler_type (value->GetCompilerType());
+ if (compiler_type)
{
bool is_signed;
- if (clang_type.IsIntegerType (is_signed))
+ if (compiler_type.IsIntegerType (is_signed))
{
ReadIntegerArgument(value->GetScalar(),
- clang_type.GetBitSize(&thread),
+ compiler_type.GetBitSize(&thread),
is_signed,
thread.GetProcess().get(),
current_stack_argument);
}
- else if (clang_type.IsPointerType())
+ else if (compiler_type.IsPointerType())
{
ReadIntegerArgument(value->GetScalar(),
- clang_type.GetBitSize(&thread),
+ compiler_type.GetBitSize(&thread),
false,
thread.GetProcess().get(),
current_stack_argument);
@@ -582,8 +343,8 @@ ABIMacOSX_i386::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueOb
return error;
}
- ClangASTType clang_type = new_value_sp->GetClangType();
- if (!clang_type)
+ CompilerType compiler_type = new_value_sp->GetCompilerType();
+ if (!compiler_type)
{
error.SetErrorString ("Null clang type for return value.");
return error;
@@ -598,7 +359,7 @@ ABIMacOSX_i386::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueOb
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
bool set_it_simple = false;
- if (clang_type.IsIntegerType (is_signed) || clang_type.IsPointerType())
+ if (compiler_type.IsIntegerType (is_signed) || compiler_type.IsPointerType())
{
DataExtractor data;
Error data_error;
@@ -638,7 +399,7 @@ ABIMacOSX_i386::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueOb
error.SetErrorString("We don't support returning longer than 64 bit integer values at present.");
}
}
- else if (clang_type.IsFloatingPointType (count, is_complex))
+ else if (compiler_type.IsFloatingPointType (count, is_complex))
{
if (is_complex)
error.SetErrorString ("We don't support returning complex values at present");
@@ -654,16 +415,16 @@ ABIMacOSX_i386::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueOb
ValueObjectSP
ABIMacOSX_i386::GetReturnValueObjectImpl (Thread &thread,
- ClangASTType &clang_type) const
+ CompilerType &compiler_type) const
{
Value value;
ValueObjectSP return_valobj_sp;
- if (!clang_type)
+ if (!compiler_type)
return return_valobj_sp;
- //value.SetContext (Value::eContextTypeClangType, clang_type.GetOpaqueQualType());
- value.SetClangType (clang_type);
+ //value.SetContext (Value::eContextTypeClangType, compiler_type.GetOpaqueQualType());
+ value.SetCompilerType (compiler_type);
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
if (!reg_ctx)
@@ -671,9 +432,9 @@ ABIMacOSX_i386::GetReturnValueObjectImpl (Thread &thread,
bool is_signed;
- if (clang_type.IsIntegerType (is_signed))
+ if (compiler_type.IsIntegerType (is_signed))
{
- size_t bit_width = clang_type.GetBitSize(&thread);
+ size_t bit_width = compiler_type.GetBitSize(&thread);
unsigned eax_id = reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB];
unsigned edx_id = reg_ctx->GetRegisterInfoByName("edx", 0)->kinds[eRegisterKindLLDB];
@@ -713,7 +474,7 @@ ABIMacOSX_i386::GetReturnValueObjectImpl (Thread &thread,
break;
}
}
- else if (clang_type.IsPointerType ())
+ else if (compiler_type.IsPointerType ())
{
unsigned eax_id = reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB];
uint32_t ptr = thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff;
diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h
index d81b7a7e684b..6a82fce35bf7 100644
--- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h
+++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h
@@ -22,48 +22,33 @@ class ABIMacOSX_i386 :
public lldb_private::ABI
{
public:
-
- ~ABIMacOSX_i386() { }
-
- virtual size_t
- GetRedZoneSize () const;
+ ~ABIMacOSX_i386() override = default;
- virtual bool
- PrepareTrivialCall (lldb_private::Thread &thread,
- lldb::addr_t sp,
- lldb::addr_t func_addr,
- lldb::addr_t return_addr,
- llvm::ArrayRef<lldb::addr_t> args) const;
+ size_t
+ GetRedZoneSize() const override;
- virtual bool
- PrepareNormalCall (lldb_private::Thread &thread,
+ bool
+ PrepareTrivialCall(lldb_private::Thread &thread,
lldb::addr_t sp,
lldb::addr_t func_addr,
lldb::addr_t return_addr,
- lldb_private::ValueList &args) const;
+ llvm::ArrayRef<lldb::addr_t> args) const override;
- virtual bool
- GetArgumentValues (lldb_private::Thread &thread,
- lldb_private::ValueList &values) const;
+ bool
+ GetArgumentValues(lldb_private::Thread &thread,
+ lldb_private::ValueList &values) const override;
- virtual lldb_private::Error
- SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value);
+ lldb_private::Error
+ SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override;
-protected:
- virtual lldb::ValueObjectSP
- GetReturnValueObjectImpl (lldb_private::Thread &thread,
- lldb_private::ClangASTType &ast_type) const;
-
-public:
-
- virtual bool
- CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
+ bool
+ CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
- virtual bool
- CreateDefaultUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
+ bool
+ CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
- virtual bool
- RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info);
+ bool
+ RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
// The Darwin i386 ABI requires that stack frames be 16 byte aligned.
// When there is a trap handler on the stack, e.g. _sigtramp in userland
@@ -78,8 +63,8 @@ public:
//
// If we were to enforce 16-byte alignment, we also need to relax to 4-byte
// alignment for non-darwin i386 targets.
- virtual bool
- CallFrameAddressIsValid (lldb::addr_t cfa)
+ bool
+ CallFrameAddressIsValid(lldb::addr_t cfa) override
{
// Make sure the stack call frame addresses are are 4 byte aligned
if (cfa & (4ull - 1ull))
@@ -89,19 +74,20 @@ public:
return true;
}
- virtual bool
- CodeAddressIsValid (lldb::addr_t pc)
+ bool
+ CodeAddressIsValid(lldb::addr_t pc) override
{
// Just make sure the address is a valid 32 bit address.
return pc <= UINT32_MAX;
}
- virtual const lldb_private::RegisterInfo *
- GetRegisterInfoArray (uint32_t &count);
+ const lldb_private::RegisterInfo *
+ GetRegisterInfoArray(uint32_t &count) override;
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
+
static void
Initialize();
@@ -114,22 +100,30 @@ public:
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
+
static lldb_private::ConstString
GetPluginNameStatic ();
- virtual lldb_private::ConstString
- GetPluginName();
+ lldb_private::ConstString
+ GetPluginName() override;
- virtual uint32_t
- GetPluginVersion();
+ uint32_t
+ GetPluginVersion() override;
protected:
+ lldb::ValueObjectSP
+ GetReturnValueObjectImpl(lldb_private::Thread &thread,
+ lldb_private::CompilerType &ast_type) const override;
+
bool
RegisterIsCalleeSaved (const lldb_private::RegisterInfo *reg_info);
private:
- ABIMacOSX_i386() : lldb_private::ABI() { } // Call CreateInstance instead.
+ ABIMacOSX_i386() :
+ lldb_private::ABI()
+ {
+ // Call CreateInstance instead.
+ }
};
-
-#endif // liblldb_ABI_h_
+#endif // liblldb_ABIMacOSX_i386_h_
diff --git a/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp b/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
index 50a9863d83e7..ef625dece265 100644
--- a/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
+++ b/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
@@ -17,7 +17,6 @@
#include "lldb/Core/Scalar.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
@@ -28,7 +27,7 @@
#include "llvm/ADT/Triple.h"
#include "Utility/ARM_DWARF_Registers.h"
-#include "Utility/ARM_GCC_Registers.h"
+#include "Utility/ARM_ehframe_Registers.h"
#include "Plugins/Process/Utility/ARMDefines.h"
#include <vector>
@@ -38,90 +37,90 @@ using namespace lldb_private;
static RegisterInfo g_register_infos[] =
{
- // NAME ALT SZ OFF ENCODING FORMAT COMPILER DWARF GENERIC GDB LLDB NATIVE VALUE REGS INVALIDATE REGS
+ // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB NATIVE VALUE REGS INVALIDATE REGS
// ========== ======= == === ============= ============ ======================= =================== =========================== ======================= ====================== ========== ===============
- { "r0", "arg1", 4, 0, eEncodingUint , eFormatHex, { gcc_r0, dwarf_r0, LLDB_REGNUM_GENERIC_ARG1, gdb_arm_r0, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r1", "arg2", 4, 0, eEncodingUint , eFormatHex, { gcc_r1, dwarf_r1, LLDB_REGNUM_GENERIC_ARG2, gdb_arm_r1, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r2", "arg3", 4, 0, eEncodingUint , eFormatHex, { gcc_r2, dwarf_r2, LLDB_REGNUM_GENERIC_ARG3, gdb_arm_r2, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r3", "arg4", 4, 0, eEncodingUint , eFormatHex, { gcc_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG4, gdb_arm_r3, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r4", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r4, dwarf_r4, LLDB_INVALID_REGNUM, gdb_arm_r4, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r5", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r5, dwarf_r5, LLDB_INVALID_REGNUM, gdb_arm_r5, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r6", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r6, dwarf_r6, LLDB_INVALID_REGNUM, gdb_arm_r6, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r7", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP, gdb_arm_r7, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r8", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r8, dwarf_r8, LLDB_INVALID_REGNUM, gdb_arm_r8, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r9", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r9, dwarf_r9, LLDB_INVALID_REGNUM, gdb_arm_r9, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r10", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r10, dwarf_r10, LLDB_INVALID_REGNUM, gdb_arm_r10, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r11", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r11, dwarf_r11, LLDB_INVALID_REGNUM, gdb_arm_r11, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r12", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r12, dwarf_r12, LLDB_INVALID_REGNUM, gdb_arm_r12, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "sp", "r13", 4, 0, eEncodingUint , eFormatHex, { gcc_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, gdb_arm_sp, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "lr", "r14", 4, 0, eEncodingUint , eFormatHex, { gcc_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, gdb_arm_lr, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "pc", "r15", 4, 0, eEncodingUint , eFormatHex, { gcc_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, gdb_arm_pc, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "cpsr", "psr", 4, 0, eEncodingUint , eFormatHex, { gcc_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS, gdb_arm_cpsr, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s0", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, gdb_arm_s0, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s1", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, gdb_arm_s1, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s2", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, gdb_arm_s2, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s3", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, gdb_arm_s3, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s4", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, gdb_arm_s4, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s5", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, gdb_arm_s5, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s6", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, gdb_arm_s6, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s7", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, gdb_arm_s7, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s8", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, gdb_arm_s8, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s9", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, gdb_arm_s9, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s10", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, gdb_arm_s10, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s11", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, gdb_arm_s11, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s12", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, gdb_arm_s12, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s13", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, gdb_arm_s13, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s14", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, gdb_arm_s14, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s15", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, gdb_arm_s15, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s16", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, gdb_arm_s16, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s17", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, gdb_arm_s17, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s18", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, gdb_arm_s18, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s19", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, gdb_arm_s19, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s20", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, gdb_arm_s20, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s21", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, gdb_arm_s21, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s22", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, gdb_arm_s22, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s23", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, gdb_arm_s23, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s24", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, gdb_arm_s24, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s25", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, gdb_arm_s25, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s26", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, gdb_arm_s26, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s27", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, gdb_arm_s27, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s28", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, gdb_arm_s28, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s29", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, gdb_arm_s29, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s30", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, gdb_arm_s30, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "s31", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, gdb_arm_s31, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "fpscr", NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM, gdb_arm_fpscr, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d0", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d0, LLDB_INVALID_REGNUM, gdb_arm_d0, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d1", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d1, LLDB_INVALID_REGNUM, gdb_arm_d1, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d2", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d2, LLDB_INVALID_REGNUM, gdb_arm_d2, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d3", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d3, LLDB_INVALID_REGNUM, gdb_arm_d3, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d4", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d4, LLDB_INVALID_REGNUM, gdb_arm_d4, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d5", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d5, LLDB_INVALID_REGNUM, gdb_arm_d5, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d6", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d6, LLDB_INVALID_REGNUM, gdb_arm_d6, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d7", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d7, LLDB_INVALID_REGNUM, gdb_arm_d7, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d8", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d8, LLDB_INVALID_REGNUM, gdb_arm_d8, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d9", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d9, LLDB_INVALID_REGNUM, gdb_arm_d9, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d10", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d10, LLDB_INVALID_REGNUM, gdb_arm_d10, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d11", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d11, LLDB_INVALID_REGNUM, gdb_arm_d11, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d12", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d12, LLDB_INVALID_REGNUM, gdb_arm_d12, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d13", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d13, LLDB_INVALID_REGNUM, gdb_arm_d13, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d14", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d14, LLDB_INVALID_REGNUM, gdb_arm_d14, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d15", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d15, LLDB_INVALID_REGNUM, gdb_arm_d15, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d16", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d16, LLDB_INVALID_REGNUM, gdb_arm_d16, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d17", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d17, LLDB_INVALID_REGNUM, gdb_arm_d17, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d18", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d18, LLDB_INVALID_REGNUM, gdb_arm_d18, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d19", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d19, LLDB_INVALID_REGNUM, gdb_arm_d19, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d20", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d20, LLDB_INVALID_REGNUM, gdb_arm_d20, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d21", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d21, LLDB_INVALID_REGNUM, gdb_arm_d21, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d22", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d22, LLDB_INVALID_REGNUM, gdb_arm_d22, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d23", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d23, LLDB_INVALID_REGNUM, gdb_arm_d23, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d24", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d24, LLDB_INVALID_REGNUM, gdb_arm_d24, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d25", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d25, LLDB_INVALID_REGNUM, gdb_arm_d25, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d26", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d26, LLDB_INVALID_REGNUM, gdb_arm_d26, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d27", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d27, LLDB_INVALID_REGNUM, gdb_arm_d27, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d28", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d28, LLDB_INVALID_REGNUM, gdb_arm_d28, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d29", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d29, LLDB_INVALID_REGNUM, gdb_arm_d29, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d30", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d30, LLDB_INVALID_REGNUM, gdb_arm_d30, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "d31", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d31, LLDB_INVALID_REGNUM, gdb_arm_d31, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r0", "arg1", 4, 0, eEncodingUint , eFormatHex, { ehframe_r0, dwarf_r0, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r1", "arg2", 4, 0, eEncodingUint , eFormatHex, { ehframe_r1, dwarf_r1, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r2", "arg3", 4, 0, eEncodingUint , eFormatHex, { ehframe_r2, dwarf_r2, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r3", "arg4", 4, 0, eEncodingUint , eFormatHex, { ehframe_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r4", NULL, 4, 0, eEncodingUint , eFormatHex, { ehframe_r4, dwarf_r4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r5", NULL, 4, 0, eEncodingUint , eFormatHex, { ehframe_r5, dwarf_r5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r6", NULL, 4, 0, eEncodingUint , eFormatHex, { ehframe_r6, dwarf_r6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r7", NULL, 4, 0, eEncodingUint , eFormatHex, { ehframe_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r8", NULL, 4, 0, eEncodingUint , eFormatHex, { ehframe_r8, dwarf_r8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r9", NULL, 4, 0, eEncodingUint , eFormatHex, { ehframe_r9, dwarf_r9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r10", NULL, 4, 0, eEncodingUint , eFormatHex, { ehframe_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r11", NULL, 4, 0, eEncodingUint , eFormatHex, { ehframe_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r12", NULL, 4, 0, eEncodingUint , eFormatHex, { ehframe_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "sp", "r13", 4, 0, eEncodingUint , eFormatHex, { ehframe_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "lr", "r14", 4, 0, eEncodingUint , eFormatHex, { ehframe_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "pc", "r15", 4, 0, eEncodingUint , eFormatHex, { ehframe_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "cpsr", "psr", 4, 0, eEncodingUint , eFormatHex, { ehframe_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s0", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s1", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s2", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s3", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s4", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s5", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s6", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s7", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s8", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s9", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s10", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s11", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s12", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s13", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s14", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s15", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s16", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s17", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s18", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s19", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s20", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s21", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s22", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s23", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s24", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s25", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s26", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s27", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s28", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s29", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s30", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "s31", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "fpscr", NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d0", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d1", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d2", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d3", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d4", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d5", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d6", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d7", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d8", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d9", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d10", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d11", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d12", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d13", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d14", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d15", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d16", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d17", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d18", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d19", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d20", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d21", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d22", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d23", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d24", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d25", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d26", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d27", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d28", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d29", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d30", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "d31", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
{ "r8_usr", NULL, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r8_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
{ "r9_usr", NULL, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r9_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
{ "r10_usr", NULL, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r10_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
@@ -333,18 +332,18 @@ ABISysV_arm::GetArgumentValues (Thread &thread,
if (!value)
return false;
- ClangASTType clang_type = value->GetClangType();
- if (clang_type)
+ CompilerType compiler_type = value->GetCompilerType();
+ if (compiler_type)
{
bool is_signed = false;
size_t bit_width = 0;
- if (clang_type.IsIntegerType (is_signed))
+ if (compiler_type.IsIntegerType (is_signed))
{
- bit_width = clang_type.GetBitSize(&thread);
+ bit_width = compiler_type.GetBitSize(&thread);
}
- else if (clang_type.IsPointerOrReferenceType ())
+ else if (compiler_type.IsPointerOrReferenceType ())
{
- bit_width = clang_type.GetBitSize(&thread);
+ bit_width = compiler_type.GetBitSize(&thread);
}
else
{
@@ -398,22 +397,35 @@ ABISysV_arm::GetArgumentValues (Thread &thread,
return true;
}
+static bool
+GetReturnValuePassedInMemory(Thread &thread, RegisterContext* reg_ctx, size_t byte_size, Value& value)
+{
+ Error error;
+ DataBufferHeap buffer(byte_size, 0);
+
+ const RegisterInfo *r0_reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1);
+ uint32_t address = reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX;
+ thread.GetProcess()->ReadMemory(address, buffer.GetBytes(), buffer.GetByteSize(), error);
+
+ if (error.Fail())
+ return false;
+
+ value.SetBytes(buffer.GetBytes(), buffer.GetByteSize());
+ return true;
+}
+
ValueObjectSP
ABISysV_arm::GetReturnValueObjectImpl (Thread &thread,
- lldb_private::ClangASTType &clang_type) const
+ lldb_private::CompilerType &compiler_type) const
{
Value value;
ValueObjectSP return_valobj_sp;
- if (!clang_type)
+ if (!compiler_type)
return return_valobj_sp;
- clang::ASTContext *ast_context = clang_type.GetASTContext();
- if (!ast_context)
- return return_valobj_sp;
-
- //value.SetContext (Value::eContextTypeClangType, clang_type.GetOpaqueQualType());
- value.SetClangType (clang_type);
+ //value.SetContext (Value::eContextTypeClangType, compiler_type.GetOpaqueQualType());
+ value.SetCompilerType (compiler_type);
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
if (!reg_ctx)
@@ -427,9 +439,9 @@ ABISysV_arm::GetReturnValueObjectImpl (Thread &thread,
// when reading data
const RegisterInfo *r0_reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1);
- size_t bit_width = clang_type.GetBitSize(&thread);
+ size_t bit_width = compiler_type.GetBitSize(&thread);
- if (clang_type.IsIntegerType (is_signed))
+ if (compiler_type.IsIntegerType (is_signed))
{
switch (bit_width)
{
@@ -467,12 +479,33 @@ ABISysV_arm::GetReturnValueObjectImpl (Thread &thread,
break;
}
}
- else if (clang_type.IsPointerType ())
+ else if (compiler_type.IsPointerType ())
{
uint32_t ptr = thread.GetRegisterContext()->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX;
value.GetScalar() = ptr;
}
- else if (clang_type.IsFloatingPointType(float_count, is_complex))
+ else if (compiler_type.IsVectorType(nullptr, nullptr))
+ {
+ size_t byte_size = compiler_type.GetByteSize(&thread);
+ if (byte_size <= 16)
+ {
+ DataBufferHeap buffer(16, 0);
+ uint32_t* buffer_ptr = (uint32_t*)buffer.GetBytes();
+
+ for (uint32_t i = 0; 4*i < byte_size; ++i)
+ {
+ const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + i);
+ buffer_ptr[i] = reg_ctx->ReadRegisterAsUnsigned(reg_info, 0) & UINT32_MAX;
+ }
+ value.SetBytes(buffer.GetBytes(), byte_size);
+ }
+ else
+ {
+ if (!GetReturnValuePassedInMemory(thread, reg_ctx, byte_size, value))
+ return return_valobj_sp;
+ }
+ }
+ else if (compiler_type.IsFloatingPointType(float_count, is_complex))
{
if (float_count == 1 && !is_complex)
{
@@ -506,9 +539,9 @@ ABISysV_arm::GetReturnValueObjectImpl (Thread &thread,
return return_valobj_sp;
}
}
- else if (clang_type.IsAggregateType())
+ else if (compiler_type.IsAggregateType())
{
- size_t byte_size = clang_type.GetByteSize(&thread);
+ size_t byte_size = compiler_type.GetByteSize(&thread);
if (byte_size <= 4)
{
RegisterValue r0_reg_value;
@@ -517,16 +550,7 @@ ABISysV_arm::GetReturnValueObjectImpl (Thread &thread,
}
else
{
- RegisterValue r0_reg_value;
- uint32_t address = reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX;
-
- Error error;
- DataBufferHeap buffer(byte_size, 0);
- thread.GetProcess()->ReadMemory(address, buffer.GetBytes(), buffer.GetByteSize(), error);
-
- if (error.Success())
- value.SetBytes(buffer.GetBytes(), buffer.GetByteSize());
- else
+ if (!GetReturnValuePassedInMemory(thread, reg_ctx, byte_size, value))
return return_valobj_sp;
}
}
@@ -554,8 +578,8 @@ ABISysV_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjec
return error;
}
- ClangASTType clang_type = new_value_sp->GetClangType();
- if (!clang_type)
+ CompilerType compiler_type = new_value_sp->GetCompilerType();
+ if (!compiler_type)
{
error.SetErrorString ("Null clang type for return value.");
return error;
@@ -570,7 +594,7 @@ ABISysV_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjec
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
bool set_it_simple = false;
- if (clang_type.IsIntegerType (is_signed) || clang_type.IsPointerType())
+ if (compiler_type.IsIntegerType (is_signed) || compiler_type.IsPointerType())
{
DataExtractor data;
Error data_error;
@@ -610,7 +634,7 @@ ABISysV_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjec
error.SetErrorString("We don't support returning longer than 64 bit integer values at present.");
}
}
- else if (clang_type.IsFloatingPointType (count, is_complex))
+ else if (compiler_type.IsFloatingPointType (count, is_complex))
{
if (is_complex)
error.SetErrorString ("We don't support returning complex values at present");
diff --git a/source/Plugins/ABI/SysV-arm/ABISysV_arm.h b/source/Plugins/ABI/SysV-arm/ABISysV_arm.h
index 69becd6ec0c2..e3b280296a64 100644
--- a/source/Plugins/ABI/SysV-arm/ABISysV_arm.h
+++ b/source/Plugins/ABI/SysV-arm/ABISysV_arm.h
@@ -20,7 +20,7 @@
class ABISysV_arm : public lldb_private::ABI
{
public:
- ~ABISysV_arm() { }
+ ~ABISysV_arm() override = default;
size_t
GetRedZoneSize () const override;
@@ -39,12 +39,6 @@ public:
lldb_private::Error
SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override;
-protected:
- lldb::ValueObjectSP
- GetReturnValueObjectImpl (lldb_private::Thread &thread,
- lldb_private::ClangASTType &ast_type) const override;
-
-public:
bool
CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan) override;
@@ -88,6 +82,7 @@ public:
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
+
static void
Initialize();
@@ -103,6 +98,7 @@ public:
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
+
lldb_private::ConstString
GetPluginName() override;
@@ -110,6 +106,10 @@ public:
GetPluginVersion() override;
protected:
+ lldb::ValueObjectSP
+ GetReturnValueObjectImpl(lldb_private::Thread &thread,
+ lldb_private::CompilerType &ast_type) const override;
+
private:
ABISysV_arm() :
lldb_private::ABI()
@@ -118,4 +118,4 @@ private:
}
};
-#endif // liblldb_ABISysV_arm_h_
+#endif // liblldb_ABISysV_arm_h_
diff --git a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
index ed058ff19d99..bc6df235cb1e 100644
--- a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
+++ b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
@@ -18,7 +18,6 @@
#include "lldb/Core/Scalar.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
@@ -37,7 +36,7 @@ using namespace lldb_private;
static RegisterInfo g_register_infos[] =
{
- // NAME ALT SZ OFF ENCODING FORMAT COMPILER DWARF GENERIC GDB LLDB NATIVE
+ // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB NATIVE
// ========== ======= == === ============= =================== =================== ====================== =========================== ======================= ======================
{ "x0", NULL, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x0, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
{ "x1", NULL, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x1, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL },
@@ -313,7 +312,7 @@ ABISysV_arm64::GetArgumentValues (Thread &thread, ValueList &values) const
if (!value)
return false;
- ClangASTType value_type = value->GetClangType();
+ CompilerType value_type = value->GetCompilerType();
if (value_type)
{
bool is_signed = false;
@@ -397,7 +396,7 @@ ABISysV_arm64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObj
return error;
}
- ClangASTType return_value_type = new_value_sp->GetClangType();
+ CompilerType return_value_type = new_value_sp->GetCompilerType();
if (!return_value_type)
{
error.SetErrorString ("Null clang type for return value.");
@@ -686,7 +685,7 @@ ABISysV_arm64::RegisterIsVolatile (const RegisterInfo *reg_info)
static bool
LoadValueFromConsecutiveGPRRegisters (ExecutionContext &exe_ctx,
RegisterContext *reg_ctx,
- const ClangASTType &value_type,
+ const CompilerType &value_type,
bool is_return_value, // false => parameter, true => return value
uint32_t &NGRN, // NGRN (see ABI documentation)
uint32_t &NSRN, // NSRN (see ABI documentation)
@@ -701,18 +700,16 @@ LoadValueFromConsecutiveGPRRegisters (ExecutionContext &exe_ctx,
const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder();
Error error;
- ClangASTType base_type;
+ CompilerType base_type;
const uint32_t homogeneous_count = value_type.IsHomogeneousAggregate (&base_type);
if (homogeneous_count > 0 && homogeneous_count <= 8)
{
- printf ("ClangASTContext::IsHomogeneousAggregate() => %u\n", homogeneous_count);
// Make sure we have enough registers
if (NSRN < 8 && (8-NSRN) >= homogeneous_count)
{
if (!base_type)
return false;
const size_t base_byte_size = base_type.GetByteSize(nullptr);
- printf ("ClangASTContext::IsHomogeneousAggregate() => base_byte_size = %" PRIu64 "\n", (uint64_t) base_byte_size);
uint32_t data_offset = 0;
for (uint32_t i=0; i<homogeneous_count; ++i)
@@ -831,7 +828,7 @@ LoadValueFromConsecutiveGPRRegisters (ExecutionContext &exe_ctx,
}
ValueObjectSP
-ABISysV_arm64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_clang_type) const
+ABISysV_arm64::GetReturnValueObjectImpl (Thread &thread, CompilerType &return_compiler_type) const
{
ValueObjectSP return_valobj_sp;
Value value;
@@ -840,16 +837,16 @@ ABISysV_arm64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_cl
if (exe_ctx.GetTargetPtr() == NULL || exe_ctx.GetProcessPtr() == NULL)
return return_valobj_sp;
- //value.SetContext (Value::eContextTypeClangType, return_clang_type);
- value.SetClangType(return_clang_type);
+ //value.SetContext (Value::eContextTypeClangType, return_compiler_type);
+ value.SetCompilerType(return_compiler_type);
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
if (!reg_ctx)
return return_valobj_sp;
- const size_t byte_size = return_clang_type.GetByteSize(nullptr);
+ const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
- const uint32_t type_flags = return_clang_type.GetTypeInfo (NULL);
+ const uint32_t type_flags = return_compiler_type.GetTypeInfo (NULL);
if (type_flags & eTypeIsScalar ||
type_flags & eTypeIsPointer)
{
@@ -898,7 +895,7 @@ ABISysV_arm64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_cl
exe_ctx.GetProcessRef().GetAddressByteSize());
return_valobj_sp = ValueObjectConstResult::Create (&thread,
- return_clang_type,
+ return_compiler_type,
ConstString(""),
data);
return return_valobj_sp;
@@ -1015,7 +1012,7 @@ ABISysV_arm64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_cl
byte_order,
exe_ctx.GetProcessRef().GetAddressByteSize());
return_valobj_sp = ValueObjectConstResult::Create (&thread,
- return_clang_type,
+ return_compiler_type,
ConstString(""),
data);
}
@@ -1032,10 +1029,10 @@ ABISysV_arm64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_cl
uint32_t NGRN = 0; // Search ABI docs for NGRN
uint32_t NSRN = 0; // Search ABI docs for NSRN
const bool is_return_value = true;
- if (LoadValueFromConsecutiveGPRRegisters (exe_ctx, reg_ctx, return_clang_type, is_return_value, NGRN, NSRN, data))
+ if (LoadValueFromConsecutiveGPRRegisters (exe_ctx, reg_ctx, return_compiler_type, is_return_value, NGRN, NSRN, data))
{
return_valobj_sp = ValueObjectConstResult::Create (&thread,
- return_clang_type,
+ return_compiler_type,
ConstString(""),
data);
}
diff --git a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h
index 08c8682d8fa4..e36f87e744f4 100644
--- a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h
+++ b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h
@@ -20,7 +20,7 @@
class ABISysV_arm64 : public lldb_private::ABI
{
public:
- ~ABISysV_arm64() { }
+ ~ABISysV_arm64() override = default;
size_t
GetRedZoneSize () const override;
@@ -39,12 +39,6 @@ public:
lldb_private::Error
SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override;
-protected:
- lldb::ValueObjectSP
- GetReturnValueObjectImpl (lldb_private::Thread &thread,
- lldb_private::ClangASTType &ast_type) const override;
-
-public:
bool
CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan) override;
@@ -64,7 +58,6 @@ public:
// Whitelisting the trap handlers for user space would be easy (_sigtramp) but
// in other environments there can be a large number of different functions
// involved in async traps.
-
bool
CallFrameAddressIsValid (lldb::addr_t cfa) override
{
@@ -92,6 +85,7 @@ public:
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
+
static void
Initialize();
@@ -107,6 +101,7 @@ public:
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
+
lldb_private::ConstString
GetPluginName() override;
@@ -114,6 +109,10 @@ public:
GetPluginVersion() override;
protected:
+ lldb::ValueObjectSP
+ GetReturnValueObjectImpl(lldb_private::Thread &thread,
+ lldb_private::CompilerType &ast_type) const override;
+
private:
ABISysV_arm64() :
lldb_private::ABI()
@@ -122,4 +121,4 @@ private:
}
};
-#endif // liblldb_ABISysV_arm64_h_
+#endif // liblldb_ABISysV_arm64_h_
diff --git a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
index 69129df1f16b..e0299b6f0b94 100644
--- a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
+++ b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
@@ -20,7 +20,6 @@
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectRegister.h"
#include "lldb/Core/ValueObjectMemory.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Process.h"
@@ -30,7 +29,7 @@
#include "llvm/ADT/Triple.h"
-#include "llvm/IR/Type.h"
+#include "llvm/IR/DerivedTypes.h"
using namespace lldb;
using namespace lldb_private;
@@ -227,7 +226,7 @@ ABISysV_hexagon::PrepareTrivialCall ( Thread &thread,
// . handle 64bit values and their register / stack requirements
*/
-#define HEX_ABI_DEBUG 1
+#define HEX_ABI_DEBUG 0
bool
ABISysV_hexagon::PrepareTrivialCall ( Thread &thread,
lldb::addr_t sp ,
@@ -243,6 +242,23 @@ ABISysV_hexagon::PrepareTrivialCall ( Thread &thread,
// grab the process so we have access to the memory for spilling
lldb::ProcessSP proc = thread.GetProcess( );
+ // get the register context for modifying all of the registers
+ RegisterContext *reg_ctx = thread.GetRegisterContext().get();
+ if (!reg_ctx)
+ return false;
+
+ uint32_t pc_reg = reg_ctx->ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
+ if (pc_reg == LLDB_INVALID_REGNUM)
+ return false;
+
+ uint32_t ra_reg = reg_ctx->ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA);
+ if (ra_reg == LLDB_INVALID_REGNUM)
+ return false;
+
+ uint32_t sp_reg = reg_ctx->ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP);
+ if (sp_reg == LLDB_INVALID_REGNUM)
+ return false;
+
// push host data onto target
for ( size_t i = 0; i < args.size( ); i++ )
{
@@ -277,11 +293,6 @@ ABISysV_hexagon::PrepareTrivialCall ( Thread &thread,
// check if this is a variable argument function
bool isVArg = prototype.isFunctionVarArg();
- // get the register context for modifying all of the registers
- RegisterContext *reg_ctx = thread.GetRegisterContext().get();
- if (!reg_ctx)
- return false;
-
// number of arguments passed by register
int nRegArgs = nVArgRegParams;
if (! isVArg )
@@ -324,10 +335,9 @@ ABISysV_hexagon::PrepareTrivialCall ( Thread &thread,
}
// update registers with current function call state
- reg_ctx->WriteRegisterFromUnsigned ( 41, pc );
- reg_ctx->WriteRegisterFromUnsigned ( 31, ra );
- reg_ctx->WriteRegisterFromUnsigned ( 29, sp );
-// reg_ctx->WriteRegisterFromUnsigned ( FP ??? );
+ reg_ctx->WriteRegisterFromUnsigned(pc_reg, pc);
+ reg_ctx->WriteRegisterFromUnsigned(ra_reg, ra);
+ reg_ctx->WriteRegisterFromUnsigned(sp_reg, sp);
#if HEX_ABI_DEBUG
// quick and dirty stack dumper for debugging
@@ -359,14 +369,14 @@ ABISysV_hexagon::SetReturnValueObject ( lldb::StackFrameSP &frame_sp, lldb::Valu
}
ValueObjectSP
-ABISysV_hexagon::GetReturnValueObjectSimple ( Thread &thread, ClangASTType &return_clang_type ) const
+ABISysV_hexagon::GetReturnValueObjectSimple ( Thread &thread, CompilerType &return_compiler_type ) const
{
ValueObjectSP return_valobj_sp;
return return_valobj_sp;
}
ValueObjectSP
-ABISysV_hexagon::GetReturnValueObjectImpl ( Thread &thread, ClangASTType &return_clang_type ) const
+ABISysV_hexagon::GetReturnValueObjectImpl ( Thread &thread, CompilerType &return_compiler_type ) const
{
ValueObjectSP return_valobj_sp;
return return_valobj_sp;
diff --git a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h
index 1550a38c4f3b..337e3fdcf7b5 100644
--- a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h
+++ b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h
@@ -21,63 +21,54 @@ class ABISysV_hexagon :
public lldb_private::ABI
{
public:
+ ~ABISysV_hexagon() override = default;
- ~ABISysV_hexagon( void )
- {
- }
-
- virtual size_t
- GetRedZoneSize ( void ) const;
+ size_t
+ GetRedZoneSize() const override;
- virtual bool
- PrepareTrivialCall ( lldb_private::Thread &thread,
- lldb::addr_t sp,
- lldb::addr_t functionAddress,
- lldb::addr_t returnAddress,
- llvm::ArrayRef<lldb::addr_t> args ) const;
+ 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;
// special thread plan for GDB style non-jit function calls
- virtual bool
- PrepareTrivialCall ( lldb_private::Thread &thread,
- lldb::addr_t sp,
- lldb::addr_t functionAddress,
- lldb::addr_t returnAddress,
- llvm::Type &prototype,
- llvm::ArrayRef<ABI::CallArgument> args ) const;
-
- virtual bool
- GetArgumentValues ( lldb_private::Thread &thread,
- lldb_private::ValueList &values ) const;
+ bool
+ PrepareTrivialCall(lldb_private::Thread &thread,
+ lldb::addr_t sp,
+ lldb::addr_t functionAddress,
+ lldb::addr_t returnAddress,
+ llvm::Type &prototype,
+ llvm::ArrayRef<ABI::CallArgument> args) const override;
+
+ bool
+ GetArgumentValues(lldb_private::Thread &thread,
+ lldb_private::ValueList &values) const override;
- virtual lldb_private::Error
- SetReturnValueObject ( lldb::StackFrameSP &frame_sp,
- lldb::ValueObjectSP &new_value );
+ lldb_private::Error
+ SetReturnValueObject(lldb::StackFrameSP &frame_sp,
+ lldb::ValueObjectSP &new_value) override;
-protected:
lldb::ValueObjectSP
- GetReturnValueObjectSimple ( lldb_private::Thread &thread,
- lldb_private::ClangASTType &ast_type ) const;
-
-public:
- virtual lldb::ValueObjectSP
- GetReturnValueObjectImpl ( lldb_private::Thread &thread,
- lldb_private::ClangASTType &type ) const;
+ GetReturnValueObjectImpl(lldb_private::Thread &thread,
+ lldb_private::CompilerType &type) const override;
// specialized to work with llvm IR types
- virtual lldb::ValueObjectSP
- GetReturnValueObjectImpl ( lldb_private::Thread &thread, llvm::Type &type ) const;
+ lldb::ValueObjectSP
+ GetReturnValueObjectImpl(lldb_private::Thread &thread, llvm::Type &type) const override;
- virtual bool
- CreateFunctionEntryUnwindPlan ( lldb_private::UnwindPlan &unwind_plan );
+ bool
+ CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
- virtual bool
- CreateDefaultUnwindPlan ( lldb_private::UnwindPlan &unwind_plan );
+ bool
+ CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
- virtual bool
- RegisterIsVolatile ( const lldb_private::RegisterInfo *reg_info );
+ bool
+ RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
- virtual bool
- CallFrameAddressIsValid ( lldb::addr_t cfa )
+ bool
+ CallFrameAddressIsValid(lldb::addr_t cfa) override
{
// Make sure the stack call frame addresses are 8 byte aligned
if (cfa & 0x07)
@@ -87,50 +78,60 @@ public:
return true;
}
- virtual bool
- CodeAddressIsValid ( lldb::addr_t pc )
+ 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;
}
- virtual const lldb_private::RegisterInfo *
- GetRegisterInfoArray ( uint32_t &count );
+ const lldb_private::RegisterInfo *
+ GetRegisterInfoArray(uint32_t &count) override;
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
+
static void
- Initialize ( void );
+ Initialize();
static void
- Terminate ( void );
+ Terminate();
static lldb::ABISP
CreateInstance ( const lldb_private::ArchSpec &arch );
static lldb_private::ConstString
- GetPluginNameStatic ( void );
+ GetPluginNameStatic();
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
- virtual lldb_private::ConstString
- GetPluginName ( void );
- virtual uint32_t
- GetPluginVersion ( void );
+ lldb_private::ConstString
+ GetPluginName() override;
+
+ uint32_t
+ GetPluginVersion() override;
protected:
void
- CreateRegisterMapIfNeeded ( void );
+ CreateRegisterMapIfNeeded();
+
+ lldb::ValueObjectSP
+ GetReturnValueObjectSimple(lldb_private::Thread &thread,
+ lldb_private::CompilerType &ast_type) const;
bool
RegisterIsCalleeSaved (const lldb_private::RegisterInfo *reg_info);
private:
- ABISysV_hexagon ( void ) : lldb_private::ABI() { } // Call CreateInstance instead.
+ ABISysV_hexagon() :
+ lldb_private::ABI()
+ {
+ // Call CreateInstance instead.
+ }
};
-#endif // liblldb_ABISysV_hexagon_h_
+#endif // liblldb_ABISysV_hexagon_h_
diff --git a/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp b/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
index 26da9aeb370d..0a3779a2ce94 100644
--- a/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
+++ b/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
@@ -19,7 +19,6 @@
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectRegister.h"
#include "lldb/Core/ValueObjectMemory.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Process.h"
@@ -59,171 +58,109 @@ using namespace lldb_private;
// Comment: Table 2.14 is followed till 'mm' entries.
// After that, all entries are ignored here.
-enum gcc_dwarf_regnums
+enum dwarf_regnums
{
- gcc_dwarf_eax = 0,
- gcc_dwarf_ecx,
- gcc_dwarf_edx,
- gcc_dwarf_ebx,
- gcc_dwarf_esp,
- gcc_dwarf_ebp,
- gcc_dwarf_esi,
- gcc_dwarf_edi,
- gcc_dwarf_eip,
- gcc_dwarf_eflags,
-
- gcc_dwarf_st0 = 11,
- gcc_dwarf_st1,
- gcc_dwarf_st2,
- gcc_dwarf_st3,
- gcc_dwarf_st4,
- gcc_dwarf_st5,
- gcc_dwarf_st6,
- gcc_dwarf_st7,
-
- gcc_dwarf_xmm0 = 21,
- gcc_dwarf_xmm1,
- gcc_dwarf_xmm2,
- gcc_dwarf_xmm3,
- gcc_dwarf_xmm4,
- gcc_dwarf_xmm5,
- gcc_dwarf_xmm6,
- gcc_dwarf_xmm7,
- gcc_dwarf_ymm0 = gcc_dwarf_xmm0,
- gcc_dwarf_ymm1 = gcc_dwarf_xmm1,
- gcc_dwarf_ymm2 = gcc_dwarf_xmm2,
- gcc_dwarf_ymm3 = gcc_dwarf_xmm3,
- gcc_dwarf_ymm4 = gcc_dwarf_xmm4,
- gcc_dwarf_ymm5 = gcc_dwarf_xmm5,
- gcc_dwarf_ymm6 = gcc_dwarf_xmm6,
- gcc_dwarf_ymm7 = gcc_dwarf_xmm7,
-
- gcc_dwarf_mm0 = 29,
- gcc_dwarf_mm1,
- gcc_dwarf_mm2,
- gcc_dwarf_mm3,
- gcc_dwarf_mm4,
- gcc_dwarf_mm5,
- gcc_dwarf_mm6,
- gcc_dwarf_mm7
-};
-
-
-enum gdb_regnums
-{
- gdb_eax = 0,
- gdb_ecx = 1,
- gdb_edx = 2,
- gdb_ebx = 3,
- gdb_esp = 4,
- gdb_ebp = 5,
- gdb_esi = 6,
- gdb_edi = 7,
- gdb_eip = 8,
- gdb_eflags = 9,
- gdb_cs = 10,
- gdb_ss = 11,
- gdb_ds = 12,
- gdb_es = 13,
- gdb_fs = 14,
- gdb_gs = 15,
- gdb_st0 = 16,
- gdb_st1 = 17,
- gdb_st2 = 18,
- gdb_st3 = 19,
- gdb_st4 = 20,
- gdb_st5 = 21,
- gdb_st6 = 22,
- gdb_st7 = 23,
- gdb_fctrl = 24, gdb_fcw = gdb_fctrl,
- gdb_fstat = 25, gdb_fsw = gdb_fstat,
- gdb_ftag = 26, gdb_ftw = gdb_ftag,
- gdb_fiseg = 27, gdb_fpu_cs = gdb_fiseg,
- gdb_fioff = 28, gdb_ip = gdb_fioff,
- gdb_foseg = 29, gdb_fpu_ds = gdb_foseg,
- gdb_fooff = 30, gdb_dp = gdb_fooff,
- gdb_fop = 31,
- gdb_xmm0 = 32,
- gdb_xmm1 = 33,
- gdb_xmm2 = 34,
- gdb_xmm3 = 35,
- gdb_xmm4 = 36,
- gdb_xmm5 = 37,
- gdb_xmm6 = 38,
- gdb_xmm7 = 39,
- gdb_mxcsr = 40,
- gdb_mm0 = 41,
- gdb_mm1 = 42,
- gdb_mm2 = 43,
- gdb_mm3 = 44,
- gdb_mm4 = 45,
- gdb_mm5 = 46,
- gdb_mm6 = 47,
- gdb_mm7 = 48,
- gdb_ymm0 = gdb_xmm0,
- gdb_ymm1 = gdb_xmm1,
- gdb_ymm2 = gdb_xmm2,
- gdb_ymm3 = gdb_xmm3,
- gdb_ymm4 = gdb_xmm4,
- gdb_ymm5 = gdb_xmm5,
- gdb_ymm6 = gdb_xmm6,
- gdb_ymm7 = gdb_xmm7
+ dwarf_eax = 0,
+ dwarf_ecx,
+ dwarf_edx,
+ dwarf_ebx,
+ dwarf_esp,
+ dwarf_ebp,
+ dwarf_esi,
+ dwarf_edi,
+ dwarf_eip,
+ dwarf_eflags,
+
+ dwarf_st0 = 11,
+ dwarf_st1,
+ dwarf_st2,
+ dwarf_st3,
+ dwarf_st4,
+ dwarf_st5,
+ dwarf_st6,
+ dwarf_st7,
+
+ dwarf_xmm0 = 21,
+ dwarf_xmm1,
+ dwarf_xmm2,
+ dwarf_xmm3,
+ dwarf_xmm4,
+ dwarf_xmm5,
+ dwarf_xmm6,
+ dwarf_xmm7,
+ dwarf_ymm0 = dwarf_xmm0,
+ dwarf_ymm1 = dwarf_xmm1,
+ dwarf_ymm2 = dwarf_xmm2,
+ dwarf_ymm3 = dwarf_xmm3,
+ dwarf_ymm4 = dwarf_xmm4,
+ dwarf_ymm5 = dwarf_xmm5,
+ dwarf_ymm6 = dwarf_xmm6,
+ dwarf_ymm7 = dwarf_xmm7,
+
+ dwarf_mm0 = 29,
+ dwarf_mm1,
+ dwarf_mm2,
+ dwarf_mm3,
+ dwarf_mm4,
+ dwarf_mm5,
+ dwarf_mm6,
+ dwarf_mm7
};
static RegisterInfo g_register_infos[] =
{
- // NAME ALT SZ OFF ENCODING FORMAT COMPILER DWARF GENERIC GDB LLDB NATIVE VALUE REGS INVALIDATE REGS
+ // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB NATIVE VALUE REGS INVALIDATE REGS
// ====== ======= == === ============= ============ ===================== ===================== ============================ ==================== ====================== ========== ===============
- { "eax", nullptr, 4, 0, eEncodingUint , eFormatHex , { gcc_dwarf_eax , gcc_dwarf_eax , LLDB_INVALID_REGNUM , gdb_eax , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "ebx" , nullptr, 4, 0, eEncodingUint , eFormatHex , { gcc_dwarf_ebx , gcc_dwarf_ebx , LLDB_INVALID_REGNUM , gdb_ebx , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "ecx" , nullptr, 4, 0, eEncodingUint , eFormatHex , { gcc_dwarf_ecx , gcc_dwarf_ecx , LLDB_REGNUM_GENERIC_ARG4 , gdb_ecx , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "edx" , nullptr, 4, 0, eEncodingUint , eFormatHex , { gcc_dwarf_edx , gcc_dwarf_edx , LLDB_REGNUM_GENERIC_ARG3 , gdb_edx , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "esi" , nullptr, 4, 0, eEncodingUint , eFormatHex , { gcc_dwarf_esi , gcc_dwarf_esi , LLDB_REGNUM_GENERIC_ARG2 , gdb_esi , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "edi" , nullptr, 4, 0, eEncodingUint , eFormatHex , { gcc_dwarf_edi , gcc_dwarf_edi , LLDB_REGNUM_GENERIC_ARG1 , gdb_edi , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "ebp" , "fp", 4, 0, eEncodingUint , eFormatHex , { gcc_dwarf_ebp , gcc_dwarf_ebp , LLDB_REGNUM_GENERIC_FP , gdb_ebp , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "esp" , "sp", 4, 0, eEncodingUint , eFormatHex , { gcc_dwarf_esp , gcc_dwarf_esp , LLDB_REGNUM_GENERIC_SP , gdb_esp , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "eip" , "pc", 4, 0, eEncodingUint , eFormatHex , { gcc_dwarf_eip , gcc_dwarf_eip , LLDB_REGNUM_GENERIC_PC , gdb_eip , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "eflags", nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_REGNUM_GENERIC_FLAGS , gdb_eflags , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "cs" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_cs , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "ss" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ss , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "ds" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ds , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "es" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_es , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "fs" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fs , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "gs" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_gs , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "st0" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_st0 , LLDB_INVALID_REGNUM , gdb_st0 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "st1" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_st1 , LLDB_INVALID_REGNUM , gdb_st1 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "st2" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_st2 , LLDB_INVALID_REGNUM , gdb_st2 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "st3" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_st3 , LLDB_INVALID_REGNUM , gdb_st3 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "st4" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_st4 , LLDB_INVALID_REGNUM , gdb_st4 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "st5" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_st5 , LLDB_INVALID_REGNUM , gdb_st5 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "st6" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_st6 , LLDB_INVALID_REGNUM , gdb_st6 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "st7" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_st7 , LLDB_INVALID_REGNUM , gdb_st7 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "fctrl" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fctrl , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "fstat" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fstat , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "ftag" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ftag , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "fiseg" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fiseg , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "fioff" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fioff , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "foseg" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_foseg , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "fooff" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fooff , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "fop" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fop , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "xmm0" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_xmm0 , LLDB_INVALID_REGNUM , gdb_xmm0 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "xmm1" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_xmm1 , LLDB_INVALID_REGNUM , gdb_xmm1 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "xmm2" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_xmm2 , LLDB_INVALID_REGNUM , gdb_xmm2 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "xmm3" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_xmm3 , LLDB_INVALID_REGNUM , gdb_xmm3 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "xmm4" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_xmm4 , LLDB_INVALID_REGNUM , gdb_xmm4 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "xmm5" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_xmm5 , LLDB_INVALID_REGNUM , gdb_xmm5 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "xmm6" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_xmm6 , LLDB_INVALID_REGNUM , gdb_xmm6 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "xmm7" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_xmm7 , LLDB_INVALID_REGNUM , gdb_xmm7 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "mxcsr" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_mxcsr , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "ymm0" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_ymm0 , LLDB_INVALID_REGNUM , gdb_ymm0 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "ymm1" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_ymm1 , LLDB_INVALID_REGNUM , gdb_ymm1 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "ymm2" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_ymm2 , LLDB_INVALID_REGNUM , gdb_ymm2 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "ymm3" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_ymm3 , LLDB_INVALID_REGNUM , gdb_ymm3 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "ymm4" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_ymm4 , LLDB_INVALID_REGNUM , gdb_ymm4 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "ymm5" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_ymm5 , LLDB_INVALID_REGNUM , gdb_ymm5 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "ymm6" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_ymm6 , LLDB_INVALID_REGNUM , gdb_ymm6 , LLDB_INVALID_REGNUM }, nullptr, nullptr},
- { "ymm7" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , gcc_dwarf_ymm7 , LLDB_INVALID_REGNUM , gdb_ymm7 , LLDB_INVALID_REGNUM }, nullptr, nullptr}
+ { "eax", nullptr, 4, 0, eEncodingUint , eFormatHex , { dwarf_eax , dwarf_eax , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "ebx" , nullptr, 4, 0, eEncodingUint , eFormatHex , { dwarf_ebx , dwarf_ebx , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "ecx" , nullptr, 4, 0, eEncodingUint , eFormatHex , { dwarf_ecx , dwarf_ecx , LLDB_REGNUM_GENERIC_ARG4 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "edx" , nullptr, 4, 0, eEncodingUint , eFormatHex , { dwarf_edx , dwarf_edx , LLDB_REGNUM_GENERIC_ARG3 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "esi" , nullptr, 4, 0, eEncodingUint , eFormatHex , { dwarf_esi , dwarf_esi , LLDB_REGNUM_GENERIC_ARG2 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "edi" , nullptr, 4, 0, eEncodingUint , eFormatHex , { dwarf_edi , dwarf_edi , LLDB_REGNUM_GENERIC_ARG1 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "ebp" , "fp", 4, 0, eEncodingUint , eFormatHex , { dwarf_ebp , dwarf_ebp , LLDB_REGNUM_GENERIC_FP , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "esp" , "sp", 4, 0, eEncodingUint , eFormatHex , { dwarf_esp , dwarf_esp , LLDB_REGNUM_GENERIC_SP , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "eip" , "pc", 4, 0, eEncodingUint , eFormatHex , { dwarf_eip , dwarf_eip , LLDB_REGNUM_GENERIC_PC , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "eflags", nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_REGNUM_GENERIC_FLAGS , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "cs" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "ss" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "ds" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "es" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "fs" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "gs" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "st0" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_st0 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "st1" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_st1 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "st2" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_st2 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "st3" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_st3 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "st4" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_st4 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "st5" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_st5 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "st6" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_st6 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "st7" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_st7 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "fctrl" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "fstat" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "ftag" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "fiseg" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "fioff" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "foseg" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "fooff" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "fop" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "xmm0" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm0 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "xmm1" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm1 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "xmm2" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm2 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "xmm3" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm3 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "xmm4" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm4 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "xmm5" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm5 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "xmm6" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm6 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "xmm7" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm7 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "mxcsr" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "ymm0" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm0 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "ymm1" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm1 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "ymm2" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm2 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "ymm3" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm3 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "ymm4" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm4 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "ymm5" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm5 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "ymm6" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm6 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr},
+ { "ymm7" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm7 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}
};
static const uint32_t k_num_register_infos = llvm::array_lengthof(g_register_infos);
@@ -387,22 +324,22 @@ ABISysV_i386::GetArgumentValues (Thread &thread,
return false;
// Currently: Support for extracting values with Clang QualTypes only.
- ClangASTType clang_type (value->GetClangType());
- if (clang_type)
+ CompilerType compiler_type (value->GetCompilerType());
+ if (compiler_type)
{
bool is_signed;
- if (clang_type.IsIntegerType (is_signed))
+ if (compiler_type.IsIntegerType (is_signed))
{
ReadIntegerArgument(value->GetScalar(),
- clang_type.GetBitSize(&thread),
+ compiler_type.GetBitSize(&thread),
is_signed,
thread.GetProcess().get(),
current_stack_argument);
}
- else if (clang_type.IsPointerType())
+ else if (compiler_type.IsPointerType())
{
ReadIntegerArgument(value->GetScalar(),
- clang_type.GetBitSize(&thread),
+ compiler_type.GetBitSize(&thread),
false,
thread.GetProcess().get(),
current_stack_argument);
@@ -418,29 +355,170 @@ Error
ABISysV_i386::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value_sp)
{
Error error;
- //ToDo: Yet to be implemented
- error.SetErrorString("ABISysV_i386::SetReturnValueObject(): Not implemented yet");
+ 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;
+ }
+
+ const uint32_t type_flags = compiler_type.GetTypeInfo ();
+ Thread *thread = frame_sp->GetThread().get();
+ RegisterContext *reg_ctx = thread->GetRegisterContext().get();
+ DataExtractor data;
+ Error data_error;
+ size_t num_bytes = new_value_sp->GetData(data, data_error);
+ bool register_write_successful = true;
+
+ if (data_error.Fail())
+ {
+ error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", data_error.AsCString());
+ return error;
+ }
+
+ // Following "IF ELSE" block categorizes various 'Fundamental Data Types'.
+ // The terminology 'Fundamental Data Types' used here is adopted from
+ // Table 2.1 of the reference document (specified on top of this file)
+
+ if (type_flags & eTypeIsPointer) // 'Pointer'
+ {
+ if(num_bytes != sizeof(uint32_t))
+ {
+ error.SetErrorString("Pointer to be returned is not 4 bytes wide");
+ return error;
+ }
+ lldb::offset_t offset = 0;
+ const RegisterInfo *eax_info = reg_ctx->GetRegisterInfoByName("eax", 0);
+ uint32_t raw_value = data.GetMaxU32(&offset, num_bytes);
+ register_write_successful = reg_ctx->WriteRegisterFromUnsigned (eax_info, raw_value);
+ }
+ else if ((type_flags & eTypeIsScalar) || (type_flags & eTypeIsEnumeration)) //'Integral' + 'Floating Point'
+ {
+ lldb::offset_t offset = 0;
+ const RegisterInfo *eax_info = reg_ctx->GetRegisterInfoByName("eax", 0);
+
+ if (type_flags & eTypeIsInteger) // 'Integral' except enum
+ {
+ switch (num_bytes)
+ {
+ default:
+ break;
+ case 16:
+ // For clang::BuiltinType::UInt128 & Int128
+ // ToDo: Need to decide how to handle it
+ break;
+ case 8:
+ {
+ uint32_t raw_value_low = data.GetMaxU32(&offset, 4);
+ const RegisterInfo *edx_info = reg_ctx->GetRegisterInfoByName("edx", 0);
+ uint32_t raw_value_high = data.GetMaxU32(&offset, num_bytes - offset);
+ register_write_successful = (reg_ctx->WriteRegisterFromUnsigned (eax_info, raw_value_low) &&
+ reg_ctx->WriteRegisterFromUnsigned (edx_info, raw_value_high));
+ break;
+ }
+ case 4:
+ case 2:
+ case 1:
+ {
+ uint32_t raw_value = data.GetMaxU32(&offset, num_bytes);
+ register_write_successful = reg_ctx->WriteRegisterFromUnsigned (eax_info, raw_value);
+ break;
+ }
+ }
+ }
+ else if (type_flags & eTypeIsEnumeration) // handles enum
+ {
+ uint32_t raw_value = data.GetMaxU32(&offset, num_bytes);
+ register_write_successful = reg_ctx->WriteRegisterFromUnsigned (eax_info, raw_value);
+ }
+ else if (type_flags & eTypeIsFloat) // 'Floating Point'
+ {
+ RegisterValue st0_value, fstat_value, ftag_value;
+ const RegisterInfo *st0_info = reg_ctx->GetRegisterInfoByName("st0", 0);
+ const RegisterInfo *fstat_info = reg_ctx->GetRegisterInfoByName("fstat", 0);
+ const RegisterInfo *ftag_info = reg_ctx->GetRegisterInfoByName("ftag", 0);
+
+ /* According to Page 3-12 of document
+ System V Application Binary Interface, Intel386 Architecture Processor Supplement, Fourth Edition
+ To return Floating Point values, all st% registers except st0 should be empty after exiting from
+ a function. This requires setting fstat and ftag registers to specific values.
+ fstat: The TOP field of fstat should be set to a value [0,7]. ABI doesn't specify the specific
+ value of TOP in case of function return. Hence, we set the TOP field to 7 by our choice. */
+ uint32_t value_fstat_u32 = 0x00003800;
+
+ /* ftag: Implication of setting TOP to 7 and indicating all st% registers empty except st0 is to set
+ 7th bit of 4th byte of FXSAVE area to 1 and all other bits of this byte to 0. This is in accordance
+ with the document Intel 64 and IA-32 Architectures Software Developer's Manual, January 2015 */
+ uint32_t value_ftag_u32 = 0x00000080;
+
+ if (num_bytes <= 12) // handles float, double, long double, __float80
+ {
+ long double value_long_dbl = 0.0;
+ if (num_bytes == 4)
+ value_long_dbl = data.GetFloat(&offset);
+ else if (num_bytes == 8)
+ value_long_dbl = data.GetDouble(&offset);
+ else if (num_bytes == 12)
+ value_long_dbl = data.GetLongDouble(&offset);
+ else
+ {
+ error.SetErrorString ("Invalid number of bytes for this return type");
+ return error;
+ }
+ st0_value.SetLongDouble(value_long_dbl);
+ fstat_value.SetUInt32(value_fstat_u32);
+ ftag_value.SetUInt32(value_ftag_u32);
+ register_write_successful = reg_ctx->WriteRegister(st0_info, st0_value) &&
+ reg_ctx->WriteRegister(fstat_info, fstat_value) &&
+ reg_ctx->WriteRegister(ftag_info, ftag_value);
+ }
+ else if(num_bytes == 16) // handles __float128
+ {
+ error.SetErrorString ("Implementation is missing for this clang type.");
+ }
+ }
+ else
+ {
+ // Neither 'Integral' nor 'Floating Point'. If flow reaches here
+ // then check type_flags. This type_flags is not a valid type.
+ error.SetErrorString ("Invalid clang type");
+ }
+ }
+ else
+ {
+ /* 'Complex Floating Point', 'Packed', 'Decimal Floating Point' and 'Aggregate' data types
+ are yet to be implemented */
+ error.SetErrorString ("Currently only Integral and Floating Point clang types are supported.");
+ }
+ if(!register_write_successful)
+ error.SetErrorString ("Register writing failed");
return error;
}
ValueObjectSP
ABISysV_i386::GetReturnValueObjectSimple (Thread &thread,
- ClangASTType &return_clang_type) const
+ CompilerType &return_compiler_type) const
{
ValueObjectSP return_valobj_sp;
Value value;
- if (!return_clang_type)
+ if (!return_compiler_type)
return return_valobj_sp;
- value.SetClangType (return_clang_type);
+ value.SetCompilerType (return_compiler_type);
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
if (!reg_ctx)
return return_valobj_sp;
- const uint32_t type_flags = return_clang_type.GetTypeInfo ();
+ const uint32_t type_flags = return_compiler_type.GetTypeInfo ();
unsigned eax_id = reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB];
unsigned edx_id = reg_ctx->GetRegisterInfoByName("edx", 0)->kinds[eRegisterKindLLDB];
@@ -463,7 +541,7 @@ ABISysV_i386::GetReturnValueObjectSimple (Thread &thread,
else if ((type_flags & eTypeIsScalar) || (type_flags & eTypeIsEnumeration)) //'Integral' + 'Floating Point'
{
value.SetValueType(Value::eValueTypeScalar);
- const size_t byte_size = return_clang_type.GetByteSize(nullptr);
+ const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
bool success = false;
if (type_flags & eTypeIsInteger) // 'Integral' except enum
@@ -579,7 +657,7 @@ ABISysV_i386::GetReturnValueObjectSimple (Thread &thread,
return_valobj_sp = ValueObjectMemory::Create (&thread,
"",
Address (storage_addr, nullptr),
- return_clang_type);
+ return_compiler_type);
}
}
@@ -597,16 +675,12 @@ ABISysV_i386::GetReturnValueObjectSimple (Thread &thread,
else if (type_flags & eTypeIsVector) // 'Packed'
{
- const size_t byte_size = return_clang_type.GetByteSize(nullptr);
+ const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
if (byte_size > 0)
{
- const RegisterInfo *vec_reg = reg_ctx->GetRegisterInfoByName("ymm0", 0);
+ const RegisterInfo *vec_reg = reg_ctx->GetRegisterInfoByName("xmm0", 0);
if (vec_reg == nullptr)
- {
- vec_reg = reg_ctx->GetRegisterInfoByName("xmm0", 0);
- if (vec_reg == nullptr)
- vec_reg = reg_ctx->GetRegisterInfoByName("mm0", 0);
- }
+ vec_reg = reg_ctx->GetRegisterInfoByName("mm0", 0);
if (vec_reg)
{
@@ -631,13 +705,52 @@ ABISysV_i386::GetReturnValueObjectSimple (Thread &thread,
byte_order,
process_sp->GetTarget().GetArchitecture().GetAddressByteSize());
return_valobj_sp = ValueObjectConstResult::Create (&thread,
- return_clang_type,
+ return_compiler_type,
ConstString(""),
data);
}
}
}
}
+ else if (byte_size <= vec_reg->byte_size*2)
+ {
+ const RegisterInfo *vec_reg2 = reg_ctx->GetRegisterInfoByName("xmm1", 0);
+ if (vec_reg2)
+ {
+ ProcessSP process_sp (thread.GetProcess());
+ if (process_sp)
+ {
+ std::unique_ptr<DataBufferHeap> heap_data_ap (new DataBufferHeap(byte_size, 0));
+ const ByteOrder byte_order = process_sp->GetByteOrder();
+ RegisterValue reg_value;
+ RegisterValue reg_value2;
+ if (reg_ctx->ReadRegister(vec_reg, reg_value) && reg_ctx->ReadRegister(vec_reg2, reg_value2))
+ {
+
+ Error error;
+ if (reg_value.GetAsMemoryData (vec_reg,
+ heap_data_ap->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,
+ byte_order,
+ error))
+ {
+ DataExtractor data (DataBufferSP (heap_data_ap.release()),
+ byte_order,
+ process_sp->GetTarget().GetArchitecture().GetAddressByteSize());
+ return_valobj_sp = ValueObjectConstResult::Create (&thread,
+ return_compiler_type,
+ ConstString(""),
+ data);
+ }
+ }
+ }
+ }
+ }
}
}
}
@@ -651,15 +764,15 @@ ABISysV_i386::GetReturnValueObjectSimple (Thread &thread,
ValueObjectSP
-ABISysV_i386::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_clang_type) const
+ABISysV_i386::GetReturnValueObjectImpl (Thread &thread, CompilerType &return_compiler_type) const
{
ValueObjectSP return_valobj_sp;
- if (!return_clang_type)
+ if (!return_compiler_type)
return return_valobj_sp;
ExecutionContext exe_ctx (thread.shared_from_this());
- return_valobj_sp = GetReturnValueObjectSimple(thread, return_clang_type);
+ return_valobj_sp = GetReturnValueObjectSimple(thread, return_compiler_type);
if (return_valobj_sp)
return return_valobj_sp;
@@ -667,14 +780,14 @@ ABISysV_i386::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_cla
if (!reg_ctx_sp)
return return_valobj_sp;
- if (return_clang_type.IsAggregateType())
+ if (return_compiler_type.IsAggregateType())
{
unsigned eax_id = reg_ctx_sp->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB];
lldb::addr_t storage_addr = (uint32_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff);
return_valobj_sp = ValueObjectMemory::Create (&thread,
"",
Address (storage_addr, nullptr),
- return_clang_type);
+ return_compiler_type);
}
return return_valobj_sp;
@@ -690,8 +803,8 @@ ABISysV_i386::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan)
unwind_plan.Clear();
unwind_plan.SetRegisterKind (eRegisterKindDWARF);
- uint32_t sp_reg_num = gcc_dwarf_esp;
- uint32_t pc_reg_num = gcc_dwarf_eip;
+ uint32_t sp_reg_num = dwarf_esp;
+ uint32_t pc_reg_num = dwarf_eip;
UnwindPlan::RowSP row(new UnwindPlan::Row);
row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 4);
@@ -714,9 +827,9 @@ ABISysV_i386::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan)
unwind_plan.Clear();
unwind_plan.SetRegisterKind (eRegisterKindDWARF);
- uint32_t fp_reg_num = gcc_dwarf_ebp;
- uint32_t sp_reg_num = gcc_dwarf_esp;
- uint32_t pc_reg_num = gcc_dwarf_eip;
+ uint32_t fp_reg_num = dwarf_ebp;
+ uint32_t sp_reg_num = dwarf_esp;
+ uint32_t pc_reg_num = dwarf_eip;
UnwindPlan::RowSP row(new UnwindPlan::Row);
const int32_t ptr_size = 4;
diff --git a/source/Plugins/ABI/SysV-i386/ABISysV_i386.h b/source/Plugins/ABI/SysV-i386/ABISysV_i386.h
index 9612f900d2ce..2d0f097c328e 100644
--- a/source/Plugins/ABI/SysV-i386/ABISysV_i386.h
+++ b/source/Plugins/ABI/SysV-i386/ABISysV_i386.h
@@ -21,10 +21,7 @@ class ABISysV_i386 :
public lldb_private::ABI
{
public:
-
- ~ABISysV_i386()
- {
- }
+ ~ABISysV_i386() override = default;
size_t
GetRedZoneSize () const override
@@ -46,18 +43,9 @@ public:
lldb_private::Error
SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override;
-protected:
- lldb::ValueObjectSP
- GetReturnValueObjectSimple (lldb_private::Thread &thread,
- lldb_private::ClangASTType &ast_type) const;
-
- bool
- RegisterIsCalleeSaved (const lldb_private::RegisterInfo *reg_info);
-
-public:
lldb::ValueObjectSP
GetReturnValueObjectImpl (lldb_private::Thread &thread,
- lldb_private::ClangASTType &type) const override;
+ lldb_private::CompilerType &type) const override;
bool
CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan) override;
@@ -104,9 +92,11 @@ public:
const lldb_private::RegisterInfo *
GetRegisterInfoArray (uint32_t &count) override;
+
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
+
static void
Initialize();
@@ -119,6 +109,7 @@ public:
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
+
static lldb_private::ConstString
GetPluginNameStatic();
@@ -126,13 +117,25 @@ public:
GetPluginName() override;
uint32_t
- GetPluginVersion() override
+ GetPluginVersion() override
{
return 1;
}
+protected:
+ lldb::ValueObjectSP
+ GetReturnValueObjectSimple(lldb_private::Thread &thread,
+ lldb_private::CompilerType &ast_type) const;
+
+ bool
+ RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
+
private:
- ABISysV_i386() : lldb_private::ABI() { } // Call CreateInstance instead.
+ ABISysV_i386() :
+ lldb_private::ABI()
+ {
+ // Call CreateInstance instead.
+ }
};
-#endif // liblldb_ABI_h
+#endif // liblldb_ABISysV_i386_h_
diff --git a/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp b/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
index e1fc13a691af..3c7e9495d6ce 100644
--- a/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
+++ b/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
@@ -20,7 +20,6 @@
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectRegister.h"
#include "lldb/Core/ValueObjectMemory.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Process.h"
@@ -34,133 +33,91 @@
using namespace lldb;
using namespace lldb_private;
-enum gcc_dwarf_regnums
+enum dwarf_regnums
{
- gcc_dwarf_r0 = 0,
- gcc_dwarf_r1,
- gcc_dwarf_r2,
- gcc_dwarf_r3,
- gcc_dwarf_r4,
- gcc_dwarf_r5,
- gcc_dwarf_r6,
- gcc_dwarf_r7,
- gcc_dwarf_r8,
- gcc_dwarf_r9,
- gcc_dwarf_r10,
- gcc_dwarf_r11,
- gcc_dwarf_r12,
- gcc_dwarf_r13,
- gcc_dwarf_r14,
- gcc_dwarf_r15,
- gcc_dwarf_r16,
- gcc_dwarf_r17,
- gcc_dwarf_r18,
- gcc_dwarf_r19,
- gcc_dwarf_r20,
- gcc_dwarf_r21,
- gcc_dwarf_r22,
- gcc_dwarf_r23,
- gcc_dwarf_r24,
- gcc_dwarf_r25,
- gcc_dwarf_r26,
- gcc_dwarf_r27,
- gcc_dwarf_r28,
- gcc_dwarf_r29,
- gcc_dwarf_r30,
- gcc_dwarf_r31,
- gcc_dwarf_sr,
- gcc_dwarf_lo,
- gcc_dwarf_hi,
- gcc_dwarf_bad,
- gcc_dwarf_cause,
- gcc_dwarf_pc
-};
-
-enum gdb_regnums
-{
- gdb_r0 = 0,
- gdb_r1,
- gdb_r2,
- gdb_r3,
- gdb_r4,
- gdb_r5,
- gdb_r6,
- gdb_r7,
- gdb_r8,
- gdb_r9,
- gdb_r10,
- gdb_r11,
- gdb_r12,
- gdb_r13,
- gdb_r14,
- gdb_r15,
- gdb_r16,
- gdb_r17,
- gdb_r18,
- gdb_r19,
- gdb_r20,
- gdb_r21,
- gdb_r22,
- gdb_r23,
- gdb_r24,
- gdb_r25,
- gdb_r26,
- gdb_r27,
- gdb_r28,
- gdb_r29,
- gdb_r30,
- gdb_r31,
- gdb_sr,
- gdb_lo,
- gdb_hi,
- gdb_bad,
- gdb_cause,
- gdb_pc
+ dwarf_r0 = 0,
+ dwarf_r1,
+ dwarf_r2,
+ dwarf_r3,
+ dwarf_r4,
+ dwarf_r5,
+ dwarf_r6,
+ dwarf_r7,
+ dwarf_r8,
+ dwarf_r9,
+ dwarf_r10,
+ dwarf_r11,
+ dwarf_r12,
+ dwarf_r13,
+ dwarf_r14,
+ dwarf_r15,
+ dwarf_r16,
+ dwarf_r17,
+ dwarf_r18,
+ dwarf_r19,
+ dwarf_r20,
+ dwarf_r21,
+ dwarf_r22,
+ dwarf_r23,
+ dwarf_r24,
+ dwarf_r25,
+ dwarf_r26,
+ dwarf_r27,
+ dwarf_r28,
+ dwarf_r29,
+ dwarf_r30,
+ dwarf_r31,
+ dwarf_sr,
+ dwarf_lo,
+ dwarf_hi,
+ dwarf_bad,
+ dwarf_cause,
+ dwarf_pc
};
static const RegisterInfo
g_register_infos[] =
{
- // NAME ALT SZ OFF ENCODING FORMAT COMPILER DWARF GENERIC GDB LLDB NATIVE VALUE REGS INVALIDATE REGS
- // ======== ====== == === ============= =================== ============ ===================== ==================== ================= ====================== ========== ===============
- { "r0" , "zero", 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r0, gcc_dwarf_r0, LLDB_INVALID_REGNUM, gdb_r0, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r1" , "AT", 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r1, gcc_dwarf_r1, LLDB_INVALID_REGNUM, gdb_r1, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r2" , "v0", 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r2, gcc_dwarf_r2, LLDB_INVALID_REGNUM, gdb_r2, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r3" , "v1", 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r3, gcc_dwarf_r3, LLDB_INVALID_REGNUM, gdb_r3, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r4" , "arg1", 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r4, gcc_dwarf_r4, LLDB_REGNUM_GENERIC_ARG1, gdb_r4, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r5" , "arg2", 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r5, gcc_dwarf_r5, LLDB_REGNUM_GENERIC_ARG2, gdb_r5, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r6" , "arg3", 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r6, gcc_dwarf_r6, LLDB_REGNUM_GENERIC_ARG3, gdb_r6, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r7" , "arg4", 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r7, gcc_dwarf_r7, LLDB_REGNUM_GENERIC_ARG4, gdb_r7, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r8" , "arg5", 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r8, gcc_dwarf_r8, LLDB_INVALID_REGNUM, gdb_r8, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r9" , "arg6", 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r9, gcc_dwarf_r9, LLDB_INVALID_REGNUM, gdb_r9, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r10" , "arg7", 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r10, gcc_dwarf_r10, LLDB_INVALID_REGNUM, gdb_r10, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r11" , "arg8", 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r11, gcc_dwarf_r11, LLDB_INVALID_REGNUM, gdb_r11, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r12" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r12, gcc_dwarf_r12, LLDB_INVALID_REGNUM, gdb_r12, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r13" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r13, gcc_dwarf_r13, LLDB_INVALID_REGNUM, gdb_r13, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r14" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r14, gcc_dwarf_r14, LLDB_INVALID_REGNUM, gdb_r14, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r15" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r15, gcc_dwarf_r15, LLDB_INVALID_REGNUM, gdb_r15, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r16" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r16, gcc_dwarf_r16, LLDB_INVALID_REGNUM, gdb_r16, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r17" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r17, gcc_dwarf_r17, LLDB_INVALID_REGNUM, gdb_r17, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r18" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r18, gcc_dwarf_r18, LLDB_INVALID_REGNUM, gdb_r18, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r19" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r19, gcc_dwarf_r19, LLDB_INVALID_REGNUM, gdb_r19, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r20" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r20, gcc_dwarf_r20, LLDB_INVALID_REGNUM, gdb_r20, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r21" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r21, gcc_dwarf_r21, LLDB_INVALID_REGNUM, gdb_r21, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r22" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r22, gcc_dwarf_r22, LLDB_INVALID_REGNUM, gdb_r22, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r23" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r23, gcc_dwarf_r23, LLDB_INVALID_REGNUM, gdb_r23, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r24" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r24, gcc_dwarf_r24, LLDB_INVALID_REGNUM, gdb_r24, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r25" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r25, gcc_dwarf_r25, LLDB_INVALID_REGNUM, gdb_r25, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r26" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r26, gcc_dwarf_r26, LLDB_INVALID_REGNUM, gdb_r26, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r27" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r27, gcc_dwarf_r27, LLDB_INVALID_REGNUM, gdb_r27, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r28" , "gp", 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r28, gcc_dwarf_r28, LLDB_INVALID_REGNUM, gdb_r28, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r29" , "sp", 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r29, gcc_dwarf_r29, LLDB_REGNUM_GENERIC_SP, gdb_r29, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r30" , "fp", 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r30, gcc_dwarf_r30, LLDB_REGNUM_GENERIC_FP, gdb_r30, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r31" , "ra", 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r31, gcc_dwarf_r31, LLDB_REGNUM_GENERIC_RA, gdb_r31, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "sr" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_sr, gcc_dwarf_sr, LLDB_REGNUM_GENERIC_FLAGS, gdb_sr, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "lo" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_lo, gcc_dwarf_lo, LLDB_INVALID_REGNUM, gdb_lo, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "hi" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_hi, gcc_dwarf_hi, LLDB_INVALID_REGNUM, gdb_hi, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "bad" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_bad, gcc_dwarf_bad, LLDB_INVALID_REGNUM, gdb_bad, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "cause" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_cause, gcc_dwarf_cause, LLDB_INVALID_REGNUM, gdb_cause, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "pc" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_pc, gcc_dwarf_pc, LLDB_REGNUM_GENERIC_PC, gdb_pc, LLDB_INVALID_REGNUM }, NULL, NULL},
+ // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGINS LLDB NATIVE VALUE REGS INVALIDATE REGS
+ // ======== ====== == === ============= =========== ============ ============== ============ ================= =================== ========== =================
+ { "r0" , "zero", 4, 0, eEncodingUint, eFormatHex, { dwarf_r0, dwarf_r0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r1" , "AT", 4, 0, eEncodingUint, eFormatHex, { dwarf_r1, dwarf_r1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r2" , "v0", 4, 0, eEncodingUint, eFormatHex, { dwarf_r2, dwarf_r2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r3" , "v1", 4, 0, eEncodingUint, eFormatHex, { dwarf_r3, dwarf_r3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r4" , "arg1", 4, 0, eEncodingUint, eFormatHex, { dwarf_r4, dwarf_r4, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r5" , "arg2", 4, 0, eEncodingUint, eFormatHex, { dwarf_r5, dwarf_r5, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r6" , "arg3", 4, 0, eEncodingUint, eFormatHex, { dwarf_r6, dwarf_r6, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r7" , "arg4", 4, 0, eEncodingUint, eFormatHex, { dwarf_r7, dwarf_r7, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r8" , "arg5", 4, 0, eEncodingUint, eFormatHex, { dwarf_r8, dwarf_r8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r9" , "arg6", 4, 0, eEncodingUint, eFormatHex, { dwarf_r9, dwarf_r9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r10" , "arg7", 4, 0, eEncodingUint, eFormatHex, { dwarf_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r11" , "arg8", 4, 0, eEncodingUint, eFormatHex, { dwarf_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r12" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r13" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_r13, dwarf_r13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r14" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_r14, dwarf_r14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r15" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_r15, dwarf_r15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r16" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_r16, dwarf_r16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r17" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_r17, dwarf_r17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r18" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_r18, dwarf_r18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r19" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_r19, dwarf_r19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r20" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_r20, dwarf_r20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r21" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_r21, dwarf_r21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r22" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_r22, dwarf_r22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r23" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_r23, dwarf_r23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r24" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_r24, dwarf_r24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r25" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_r25, dwarf_r25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r26" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_r26, dwarf_r26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r27" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_r27, dwarf_r27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r28" , "gp", 4, 0, eEncodingUint, eFormatHex, { dwarf_r28, dwarf_r28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r29" , "sp", 4, 0, eEncodingUint, eFormatHex, { dwarf_r29, dwarf_r29, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r30" , "fp", 4, 0, eEncodingUint, eFormatHex, { dwarf_r30, dwarf_r30, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r31" , "ra", 4, 0, eEncodingUint, eFormatHex, { dwarf_r31, dwarf_r31, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "sr" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_sr, dwarf_sr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "lo" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_lo, dwarf_lo, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "hi" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_hi, dwarf_hi, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "bad" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_bad, dwarf_bad, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "cause" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_cause, dwarf_cause, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "pc" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
};
static const uint32_t k_num_register_infos = llvm::array_lengthof(g_register_infos);
@@ -284,6 +241,7 @@ ABISysV_mips::PrepareTrivialCall (Thread &thread,
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);
const RegisterInfo *ra_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA);
+ const RegisterInfo *r25_info = reg_ctx->GetRegisterInfoByName("r25", 0);
if (log)
log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp);
@@ -305,7 +263,14 @@ ABISysV_mips::PrepareTrivialCall (Thread &thread,
// Set pc to the address of the called function.
if (!reg_ctx->WriteRegisterFromUnsigned (pc_reg_info, func_addr))
return false;
-
+
+ if (log)
+ log->Printf("Writing r25: 0x%" PRIx64, (uint64_t)func_addr);
+
+ // All callers of position independent functions must place the address of the called function in t9 (r25)
+ if (!reg_ctx->WriteRegisterFromUnsigned (r25_info, func_addr))
+ return false;
+
return true;
}
@@ -325,8 +290,8 @@ ABISysV_mips::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObje
return error;
}
- ClangASTType clang_type = new_value_sp->GetClangType();
- if (!clang_type)
+ CompilerType compiler_type = new_value_sp->GetCompilerType();
+ if (!compiler_type)
{
error.SetErrorString ("Null clang type for return value.");
return error;
@@ -341,7 +306,7 @@ ABISysV_mips::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObje
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
bool set_it_simple = false;
- if (clang_type.IsIntegerType (is_signed) || clang_type.IsPointerType())
+ if (compiler_type.IsIntegerType (is_signed) || compiler_type.IsPointerType())
{
DataExtractor data;
Error data_error;
@@ -382,7 +347,7 @@ ABISysV_mips::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObje
error.SetErrorString("We don't support returning longer than 64 bit integer values at present.");
}
}
- else if (clang_type.IsFloatingPointType (count, is_complex))
+ else if (compiler_type.IsFloatingPointType (count, is_complex))
{
if (is_complex)
error.SetErrorString ("We don't support returning complex values at present");
@@ -398,40 +363,41 @@ ABISysV_mips::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObje
ValueObjectSP
-ABISysV_mips::GetReturnValueObjectSimple (Thread &thread, ClangASTType &return_clang_type) const
+ABISysV_mips::GetReturnValueObjectSimple (Thread &thread, CompilerType &return_compiler_type) const
{
ValueObjectSP return_valobj_sp;
return return_valobj_sp;
}
ValueObjectSP
-ABISysV_mips::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_clang_type) const
+ABISysV_mips::GetReturnValueObjectImpl (Thread &thread, CompilerType &return_compiler_type) const
{
ValueObjectSP return_valobj_sp;
Value value;
- if (!return_clang_type)
+ if (!return_compiler_type)
return return_valobj_sp;
ExecutionContext exe_ctx (thread.shared_from_this());
if (exe_ctx.GetTargetPtr() == NULL || exe_ctx.GetProcessPtr() == NULL)
return return_valobj_sp;
- value.SetClangType(return_clang_type);
+ value.SetCompilerType(return_compiler_type);
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
if (!reg_ctx)
return return_valobj_sp;
- bool is_signed;
+ bool is_signed = false;
+ bool is_complex = false;
+ uint32_t count = 0;
// In MIPS register "r2" (v0) holds the integer function return values
const RegisterInfo *r2_reg_info = reg_ctx->GetRegisterInfoByName("r2", 0);
+ size_t bit_width = return_compiler_type.GetBitSize(&thread);
- if (return_clang_type.IsIntegerType (is_signed))
+ if (return_compiler_type.IsIntegerType (is_signed))
{
- size_t bit_width = return_clang_type.GetBitSize(&thread);
-
switch (bit_width)
{
default:
@@ -468,11 +434,57 @@ ABISysV_mips::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_cla
break;
}
}
- else if (return_clang_type.IsPointerType ())
+ else if (return_compiler_type.IsPointerType ())
{
uint32_t ptr = thread.GetRegisterContext()->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT32_MAX;
value.GetScalar() = ptr;
}
+ else if (return_compiler_type.IsAggregateType ())
+ {
+ // Structure/Vector is always passed in memory and pointer to that memory is passed in r2.
+ uint64_t mem_address = reg_ctx->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("r2", 0), 0);
+ // We have got the address. Create a memory object out of it
+ return_valobj_sp = ValueObjectMemory::Create (&thread,
+ "",
+ Address (mem_address, NULL),
+ return_compiler_type);
+ return return_valobj_sp;
+ }
+ else if (return_compiler_type.IsFloatingPointType (count, is_complex))
+ {
+ const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0);
+ const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0);
+
+ if (count == 1 && !is_complex)
+ {
+ switch (bit_width)
+ {
+ default:
+ return return_valobj_sp;
+ case 64:
+ {
+ static_assert(sizeof(double) == sizeof(uint64_t), "");
+ uint64_t raw_value;
+ raw_value = reg_ctx->ReadRegisterAsUnsigned(f0_info, 0) & UINT32_MAX;
+ raw_value |= ((uint64_t)(reg_ctx->ReadRegisterAsUnsigned(f1_info, 0) & UINT32_MAX)) << 32;
+ value.GetScalar() = *reinterpret_cast<double*>(&raw_value);
+ break;
+ }
+ case 32:
+ {
+ static_assert(sizeof(float) == sizeof(uint32_t), "");
+ uint32_t raw_value = reg_ctx->ReadRegisterAsUnsigned(f0_info, 0) & UINT32_MAX;
+ value.GetScalar() = *reinterpret_cast<float*>(&raw_value);
+ break;
+ }
+ }
+ }
+ else
+ {
+ // not handled yet
+ return return_valobj_sp;
+ }
+ }
else
{
// not handled yet
@@ -496,17 +508,17 @@ ABISysV_mips::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan)
UnwindPlan::RowSP row(new UnwindPlan::Row);
// Our Call Frame Address is the stack pointer value
- row->GetCFAValue().SetIsRegisterPlusOffset(gcc_dwarf_r29, 0);
+ row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_r29, 0);
// The previous PC is in the RA
- row->SetRegisterLocationToRegister(gcc_dwarf_pc, gcc_dwarf_r31, true);
+ row->SetRegisterLocationToRegister(dwarf_pc, dwarf_r31, true);
unwind_plan.AppendRow (row);
// All other registers are the same.
unwind_plan.SetSourceName ("mips at-func-entry default");
unwind_plan.SetSourcedFromCompiler (eLazyBoolNo);
- unwind_plan.SetReturnAddressRegister(gcc_dwarf_r31);
+ unwind_plan.SetReturnAddressRegister(dwarf_r31);
return true;
}
@@ -518,9 +530,9 @@ ABISysV_mips::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan)
UnwindPlan::RowSP row(new UnwindPlan::Row);
- row->GetCFAValue().SetIsRegisterPlusOffset(gcc_dwarf_r29, 0);
+ row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_r29, 0);
- row->SetRegisterLocationToRegister(gcc_dwarf_pc, gcc_dwarf_r31, true);
+ row->SetRegisterLocationToRegister(dwarf_pc, dwarf_r31, true);
unwind_plan.AppendRow (row);
unwind_plan.SetSourceName ("mips default unwind plan");
@@ -542,13 +554,36 @@ ABISysV_mips::RegisterIsCalleeSaved (const RegisterInfo *reg_info)
{
// Preserved registers are :
// r16-r23, r28, r29, r30, r31
+ const char *name = reg_info->name;
- int reg = ((reg_info->byte_offset) / 4);
-
- bool save = (reg >= 16) && (reg <= 23);
- save |= (reg >= 28) && (reg <= 31);
+ if (name[0] == 'r')
+ {
+ switch (name[1])
+ {
+ case '1':
+ if (name[2] == '6' || name[2] == '7' || name[2] == '8' || name[2] == '9') // r16-r19
+ return name[3] == '\0';
+ break;
+ case '2':
+ if (name[2] == '0' || name[2] == '1' || name[2] == '2' || name[2] == '3' // r20-r23
+ || name[2] == '8' || name[2] == '9') // r28 and r29
+ return name[3] == '\0';
+ break;
+ case '3':
+ if (name[2] == '0' || name[2] == '1') // r30 and r31
+ return name[3] == '\0';
+ break;
+ }
- return save;
+ if (name[0] == 'g' && name[1] == 'p' && name[2] == '\0') // gp (r28)
+ return true;
+ if (name[0] == 's' && name[1] == 'p' && name[2] == '\0') // sp (r29)
+ return true;
+ if (name[0] == 'f' && name[1] == 'p' && name[2] == '\0') // fp (r30)
+ return true;
+ if (name[0] == 'r' && name[1] == 'a' && name[2] == '\0') // ra (r31)
+ return true;
+ }
}
return false;
}
diff --git a/source/Plugins/ABI/SysV-mips/ABISysV_mips.h b/source/Plugins/ABI/SysV-mips/ABISysV_mips.h
index ad47ac222932..709c3bfe3adf 100644
--- a/source/Plugins/ABI/SysV-mips/ABISysV_mips.h
+++ b/source/Plugins/ABI/SysV-mips/ABISysV_mips.h
@@ -21,49 +21,40 @@ class ABISysV_mips :
public lldb_private::ABI
{
public:
+ ~ABISysV_mips() override = default;
- ~ABISysV_mips()
- {
- }
-
- virtual size_t
- GetRedZoneSize () const;
+ size_t
+ GetRedZoneSize() const override;
- virtual bool
- PrepareTrivialCall (lldb_private::Thread &thread,
- lldb::addr_t sp,
- lldb::addr_t functionAddress,
- lldb::addr_t returnAddress,
- llvm::ArrayRef<lldb::addr_t> args) const;
+ 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;
- virtual bool
- GetArgumentValues (lldb_private::Thread &thread,
- lldb_private::ValueList &values) const;
+ bool
+ GetArgumentValues(lldb_private::Thread &thread,
+ lldb_private::ValueList &values) const override;
- virtual lldb_private::Error
- SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value);
+ lldb_private::Error
+ SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override;
-protected:
lldb::ValueObjectSP
- GetReturnValueObjectSimple (lldb_private::Thread &thread,
- lldb_private::ClangASTType &ast_type) const;
-
-public:
- virtual lldb::ValueObjectSP
- GetReturnValueObjectImpl (lldb_private::Thread &thread,
- lldb_private::ClangASTType &type) const;
+ GetReturnValueObjectImpl(lldb_private::Thread &thread,
+ lldb_private::CompilerType &type) const override;
- virtual bool
- CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
+ bool
+ CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
- virtual bool
- CreateDefaultUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
+ bool
+ CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
- virtual bool
- RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info);
+ bool
+ RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
- virtual bool
- CallFrameAddressIsValid (lldb::addr_t cfa)
+ bool
+ CallFrameAddressIsValid(lldb::addr_t cfa) override
{
// Make sure the stack call frame addresses are 8 byte aligned
if (cfa & (8ull - 1ull))
@@ -73,21 +64,21 @@ public:
return true;
}
- virtual bool
- CodeAddressIsValid (lldb::addr_t pc)//must- check
+ bool
+ CodeAddressIsValid(lldb::addr_t pc) override
{
- if (pc & (4ull - 1ull))
- return false; // Not 4 byte aligned
-
- // Anything else if fair game..
- return true;
+ // Just make sure the address is a valid 32 bit address. Bit zero
+ // might be set due to MicroMIPS function calls, so don't enforce alignment.
+ return (pc <= UINT32_MAX);
}
- virtual const lldb_private::RegisterInfo *
- GetRegisterInfoArray (uint32_t &count);
+ const lldb_private::RegisterInfo *
+ GetRegisterInfoArray(uint32_t &count) override;
+
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
+
static void
Initialize();
@@ -103,21 +94,30 @@ public:
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
- virtual lldb_private::ConstString
- GetPluginName();
- virtual uint32_t
- GetPluginVersion();
+ 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:
- ABISysV_mips() : lldb_private::ABI() { } // Call CreateInstance instead.
+ ABISysV_mips() :
+ lldb_private::ABI()
+ {
+ // Call CreateInstance instead.
+ }
};
-#endif // liblldb_ABI_h_
+#endif // liblldb_ABISysV_mips_h_
diff --git a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
index c790fa7e7bdd..bc62c9fe82ee 100644
--- a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
+++ b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
@@ -20,7 +20,6 @@
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectRegister.h"
#include "lldb/Core/ValueObjectMemory.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Process.h"
@@ -34,133 +33,91 @@
using namespace lldb;
using namespace lldb_private;
-enum gcc_dwarf_regnums
+enum dwarf_regnums
{
- gcc_dwarf_r0 = 0,
- gcc_dwarf_r1,
- gcc_dwarf_r2,
- gcc_dwarf_r3,
- gcc_dwarf_r4,
- gcc_dwarf_r5,
- gcc_dwarf_r6,
- gcc_dwarf_r7,
- gcc_dwarf_r8,
- gcc_dwarf_r9,
- gcc_dwarf_r10,
- gcc_dwarf_r11,
- gcc_dwarf_r12,
- gcc_dwarf_r13,
- gcc_dwarf_r14,
- gcc_dwarf_r15,
- gcc_dwarf_r16,
- gcc_dwarf_r17,
- gcc_dwarf_r18,
- gcc_dwarf_r19,
- gcc_dwarf_r20,
- gcc_dwarf_r21,
- gcc_dwarf_r22,
- gcc_dwarf_r23,
- gcc_dwarf_r24,
- gcc_dwarf_r25,
- gcc_dwarf_r26,
- gcc_dwarf_r27,
- gcc_dwarf_r28,
- gcc_dwarf_r29,
- gcc_dwarf_r30,
- gcc_dwarf_r31,
- gcc_dwarf_sr,
- gcc_dwarf_lo,
- gcc_dwarf_hi,
- gcc_dwarf_bad,
- gcc_dwarf_cause,
- gcc_dwarf_pc
-};
-
-enum gdb_regnums
-{
- gdb_r0 = 0,
- gdb_r1,
- gdb_r2,
- gdb_r3,
- gdb_r4,
- gdb_r5,
- gdb_r6,
- gdb_r7,
- gdb_r8,
- gdb_r9,
- gdb_r10,
- gdb_r11,
- gdb_r12,
- gdb_r13,
- gdb_r14,
- gdb_r15,
- gdb_r16,
- gdb_r17,
- gdb_r18,
- gdb_r19,
- gdb_r20,
- gdb_r21,
- gdb_r22,
- gdb_r23,
- gdb_r24,
- gdb_r25,
- gdb_r26,
- gdb_r27,
- gdb_r28,
- gdb_r29,
- gdb_r30,
- gdb_r31,
- gdb_sr,
- gdb_lo,
- gdb_hi,
- gdb_bad,
- gdb_cause,
- gdb_pc
+ dwarf_r0 = 0,
+ dwarf_r1,
+ dwarf_r2,
+ dwarf_r3,
+ dwarf_r4,
+ dwarf_r5,
+ dwarf_r6,
+ dwarf_r7,
+ dwarf_r8,
+ dwarf_r9,
+ dwarf_r10,
+ dwarf_r11,
+ dwarf_r12,
+ dwarf_r13,
+ dwarf_r14,
+ dwarf_r15,
+ dwarf_r16,
+ dwarf_r17,
+ dwarf_r18,
+ dwarf_r19,
+ dwarf_r20,
+ dwarf_r21,
+ dwarf_r22,
+ dwarf_r23,
+ dwarf_r24,
+ dwarf_r25,
+ dwarf_r26,
+ dwarf_r27,
+ dwarf_r28,
+ dwarf_r29,
+ dwarf_r30,
+ dwarf_r31,
+ dwarf_sr,
+ dwarf_lo,
+ dwarf_hi,
+ dwarf_bad,
+ dwarf_cause,
+ dwarf_pc
};
static const RegisterInfo
g_register_infos_mips64[] =
{
- // NAME ALT SZ OFF ENCODING FORMAT COMPILER DWARF GENERIC GDB LLDB NATIVE VALUE REGS INVALIDATE REGS
- // ======== ====== == === ============= =================== ============ ===================== ==================== ================= ====================== ========== ===============
- { "r0" , "zero", 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r0, gcc_dwarf_r0, LLDB_INVALID_REGNUM, gdb_r0, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r1" , "AT", 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r1, gcc_dwarf_r1, LLDB_INVALID_REGNUM, gdb_r1, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r2" , "v0", 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r2, gcc_dwarf_r2, LLDB_INVALID_REGNUM, gdb_r2, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r3" , "v1", 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r3, gcc_dwarf_r3, LLDB_INVALID_REGNUM, gdb_r3, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r4" , "arg1", 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r4, gcc_dwarf_r4, LLDB_REGNUM_GENERIC_ARG1, gdb_r4, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r5" , "arg2", 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r5, gcc_dwarf_r5, LLDB_REGNUM_GENERIC_ARG2, gdb_r5, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r6" , "arg3", 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r6, gcc_dwarf_r6, LLDB_REGNUM_GENERIC_ARG3, gdb_r6, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r7" , "arg4", 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r7, gcc_dwarf_r7, LLDB_REGNUM_GENERIC_ARG4, gdb_r7, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r8" , "arg5", 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r8, gcc_dwarf_r8, LLDB_REGNUM_GENERIC_ARG5, gdb_r8, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r9" , "arg6", 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r9, gcc_dwarf_r9, LLDB_REGNUM_GENERIC_ARG6, gdb_r9, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r10" , "arg7", 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r10, gcc_dwarf_r10, LLDB_REGNUM_GENERIC_ARG7, gdb_r10, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r11" , "arg8", 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r11, gcc_dwarf_r11, LLDB_REGNUM_GENERIC_ARG8, gdb_r11, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r12" , NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r12, gcc_dwarf_r12, LLDB_INVALID_REGNUM, gdb_r12, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r13" , NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r13, gcc_dwarf_r13, LLDB_INVALID_REGNUM, gdb_r13, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r14" , NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r14, gcc_dwarf_r14, LLDB_INVALID_REGNUM, gdb_r14, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r15" , NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r15, gcc_dwarf_r15, LLDB_INVALID_REGNUM, gdb_r15, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r16" , NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r16, gcc_dwarf_r16, LLDB_INVALID_REGNUM, gdb_r16, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r17" , NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r17, gcc_dwarf_r17, LLDB_INVALID_REGNUM, gdb_r17, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r18" , NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r18, gcc_dwarf_r18, LLDB_INVALID_REGNUM, gdb_r18, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r19" , NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r19, gcc_dwarf_r19, LLDB_INVALID_REGNUM, gdb_r19, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r20" , NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r20, gcc_dwarf_r20, LLDB_INVALID_REGNUM, gdb_r20, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r21" , NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r21, gcc_dwarf_r21, LLDB_INVALID_REGNUM, gdb_r21, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r22" , NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r22, gcc_dwarf_r22, LLDB_INVALID_REGNUM, gdb_r22, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r23" , NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r23, gcc_dwarf_r23, LLDB_INVALID_REGNUM, gdb_r23, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r24" , NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r24, gcc_dwarf_r24, LLDB_INVALID_REGNUM, gdb_r24, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r25" , NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r25, gcc_dwarf_r25, LLDB_INVALID_REGNUM, gdb_r25, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r26" , NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r26, gcc_dwarf_r26, LLDB_INVALID_REGNUM, gdb_r26, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r27" , NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r27, gcc_dwarf_r27, LLDB_INVALID_REGNUM, gdb_r27, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r28" , "gp", 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r28, gcc_dwarf_r28, LLDB_INVALID_REGNUM, gdb_r28, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r29" , "sp", 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r29, gcc_dwarf_r29, LLDB_REGNUM_GENERIC_SP, gdb_r29, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r30" , "fp", 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r30, gcc_dwarf_r30, LLDB_REGNUM_GENERIC_FP, gdb_r30, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r31" , "ra", 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_r31, gcc_dwarf_r31, LLDB_REGNUM_GENERIC_RA, gdb_r31, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "sr" , NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_dwarf_sr, gcc_dwarf_sr, LLDB_REGNUM_GENERIC_FLAGS, gdb_sr, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "lo" , NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_lo, gcc_dwarf_lo, LLDB_INVALID_REGNUM, gdb_lo, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "hi" , NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_hi, gcc_dwarf_hi, LLDB_INVALID_REGNUM, gdb_hi, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "bad" , NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_bad, gcc_dwarf_bad, LLDB_INVALID_REGNUM, gdb_bad, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "cause" , NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_cause, gcc_dwarf_cause, LLDB_INVALID_REGNUM, gdb_cause, LLDB_INVALID_REGNUM }, NULL, NULL},
- { "pc" , NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_pc, gcc_dwarf_pc, LLDB_REGNUM_GENERIC_PC, gdb_pc, LLDB_INVALID_REGNUM }, NULL, NULL},
+ // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB NATIVE VALUE REGS INVALIDATE REGS
+ // ======== ====== == === ============= ========== ============= ================= ==================== ================= ==================== ========== ===============
+ { "r0" , "zero", 8, 0, eEncodingUint, eFormatHex, { dwarf_r0, dwarf_r0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r1" , "AT", 8, 0, eEncodingUint, eFormatHex, { dwarf_r1, dwarf_r1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r2" , "v0", 8, 0, eEncodingUint, eFormatHex, { dwarf_r2, dwarf_r2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r3" , "v1", 8, 0, eEncodingUint, eFormatHex, { dwarf_r3, dwarf_r3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r4" , "arg1", 8, 0, eEncodingUint, eFormatHex, { dwarf_r4, dwarf_r4, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r5" , "arg2", 8, 0, eEncodingUint, eFormatHex, { dwarf_r5, dwarf_r5, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r6" , "arg3", 8, 0, eEncodingUint, eFormatHex, { dwarf_r6, dwarf_r6, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r7" , "arg4", 8, 0, eEncodingUint, eFormatHex, { dwarf_r7, dwarf_r7, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r8" , "arg5", 8, 0, eEncodingUint, eFormatHex, { dwarf_r8, dwarf_r8, LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r9" , "arg6", 8, 0, eEncodingUint, eFormatHex, { dwarf_r9, dwarf_r9, LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r10" , "arg7", 8, 0, eEncodingUint, eFormatHex, { dwarf_r10, dwarf_r10, LLDB_REGNUM_GENERIC_ARG7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r11" , "arg8", 8, 0, eEncodingUint, eFormatHex, { dwarf_r11, dwarf_r11, LLDB_REGNUM_GENERIC_ARG8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r12" , NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r13" , NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_r13, dwarf_r13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r14" , NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_r14, dwarf_r14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r15" , NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_r15, dwarf_r15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r16" , NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_r16, dwarf_r16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r17" , NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_r17, dwarf_r17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r18" , NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_r18, dwarf_r18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r19" , NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_r19, dwarf_r19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r20" , NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_r20, dwarf_r20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r21" , NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_r21, dwarf_r21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r22" , NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_r22, dwarf_r22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r23" , NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_r23, dwarf_r23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r24" , NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_r24, dwarf_r24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r25" , NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_r25, dwarf_r25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r26" , NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_r26, dwarf_r26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r27" , NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_r27, dwarf_r27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r28" , "gp", 8, 0, eEncodingUint, eFormatHex, { dwarf_r28, dwarf_r28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r29" , "sp", 8, 0, eEncodingUint, eFormatHex, { dwarf_r29, dwarf_r29, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r30" , "fp", 8, 0, eEncodingUint, eFormatHex, { dwarf_r30, dwarf_r30, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r31" , "ra", 8, 0, eEncodingUint, eFormatHex, { dwarf_r31, dwarf_r31, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "sr" , NULL, 4, 0, eEncodingUint, eFormatHex, { dwarf_sr, dwarf_sr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "lo" , NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_lo, dwarf_lo, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "hi" , NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_hi, dwarf_hi, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "bad" , NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_bad, dwarf_bad, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "cause" , NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_cause, dwarf_cause, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "pc" , NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
};
static const uint32_t k_num_register_infos = llvm::array_lengthof(g_register_infos_mips64);
@@ -290,8 +247,8 @@ ABISysV_mips64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueOb
return error;
}
- ClangASTType clang_type = new_value_sp->GetClangType();
- if (!clang_type)
+ CompilerType compiler_type = new_value_sp->GetCompilerType();
+ if (!compiler_type)
{
error.SetErrorString ("Null clang type for return value.");
return error;
@@ -313,7 +270,7 @@ ABISysV_mips64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueOb
return error;
}
- const uint32_t type_flags = clang_type.GetTypeInfo (NULL);
+ const uint32_t type_flags = compiler_type.GetTypeInfo (NULL);
if (type_flags & eTypeIsScalar ||
type_flags & eTypeIsPointer)
@@ -368,42 +325,50 @@ ABISysV_mips64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueOb
ValueObjectSP
-ABISysV_mips64::GetReturnValueObjectSimple (Thread &thread, ClangASTType &return_clang_type) const
+ABISysV_mips64::GetReturnValueObjectSimple (Thread &thread, CompilerType &return_compiler_type) const
{
ValueObjectSP return_valobj_sp;
return return_valobj_sp;
}
ValueObjectSP
-ABISysV_mips64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_clang_type) const
+ABISysV_mips64::GetReturnValueObjectImpl (Thread &thread, CompilerType &return_compiler_type) const
{
ValueObjectSP return_valobj_sp;
Value value;
-
+ Error error;
+
ExecutionContext exe_ctx (thread.shared_from_this());
if (exe_ctx.GetTargetPtr() == NULL || exe_ctx.GetProcessPtr() == NULL)
return return_valobj_sp;
- value.SetClangType(return_clang_type);
+ value.SetCompilerType(return_compiler_type);
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
if (!reg_ctx)
return return_valobj_sp;
- const size_t byte_size = return_clang_type.GetByteSize(nullptr);
- const uint32_t type_flags = return_clang_type.GetTypeInfo (NULL);
+ Target *target = exe_ctx.GetTargetPtr();
+ ByteOrder target_byte_order = target->GetArchitecture().GetByteOrder();
+ const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
+ const uint32_t type_flags = return_compiler_type.GetTypeInfo (NULL);
+
+ const RegisterInfo *r2_info = reg_ctx->GetRegisterInfoByName("r2", 0);
+ const RegisterInfo *r3_info = reg_ctx->GetRegisterInfoByName("r3", 0);
- if (type_flags & eTypeIsScalar)
+ if (type_flags & eTypeIsScalar ||
+ type_flags & eTypeIsPointer)
{
value.SetValueType(Value::eValueTypeScalar);
bool success = false;
- if (type_flags & eTypeIsInteger)
+ if (type_flags & eTypeIsInteger ||
+ type_flags & eTypeIsPointer)
{
// Extract the register context so we can read arguments from registers
// In MIPS register "r2" (v0) holds the integer function return values
- uint64_t raw_value = reg_ctx->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("r2", 0), 0);
+ uint64_t raw_value = reg_ctx->ReadRegisterAsUnsigned(r2_info, 0);
const bool is_signed = (type_flags & eTypeIsSigned) != 0;
switch (byte_size)
@@ -444,25 +409,302 @@ ABISysV_mips64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_c
break;
}
}
+ else if (type_flags & eTypeIsFloat)
+ {
+ if (type_flags & eTypeIsComplex)
+ {
+ // Don't handle complex yet.
+ }
+ else
+ {
+ if (byte_size <= sizeof(long double))
+ {
+ const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0);
+ const RegisterInfo *f2_info = reg_ctx->GetRegisterInfoByName("f2", 0);
+ RegisterValue f0_value, f2_value;
+ DataExtractor f0_data, f2_data;
+
+ reg_ctx->ReadRegister (f0_info, f0_value);
+ reg_ctx->ReadRegister (f2_info, f2_value);
+
+ f0_value.GetData(f0_data);
+ f2_value.GetData(f2_data);
+
+ lldb::offset_t offset = 0;
+ if (byte_size == sizeof(float))
+ {
+ value.GetScalar() = (float) f0_data.GetFloat(&offset);
+ success = true;
+ }
+ else if (byte_size == sizeof(double))
+ {
+ value.GetScalar() = (double) f0_data.GetDouble(&offset);
+ success = true;
+ }
+ else if (byte_size == sizeof(long double))
+ {
+ DataExtractor *copy_from_extractor = NULL;
+ DataBufferSP data_sp (new DataBufferHeap(16, 0));
+ DataExtractor return_ext (data_sp,
+ target_byte_order,
+ target->GetArchitecture().GetAddressByteSize());
+
+ if (target_byte_order == eByteOrderLittle)
+ {
+ f0_data.Append(f2_data);
+ copy_from_extractor = &f0_data;
+ }
+ else
+ {
+ f2_data.Append(f0_data);
+ copy_from_extractor = &f2_data;
+ }
+
+ copy_from_extractor->CopyByteOrderedData (0,
+ byte_size,
+ data_sp->GetBytes(),
+ byte_size,
+ target_byte_order);
+
+ return_valobj_sp = ValueObjectConstResult::Create (&thread,
+ return_compiler_type,
+ ConstString(""),
+ return_ext);
+ return return_valobj_sp;
+
+ }
+ }
+ }
+ }
if (success)
return_valobj_sp = ValueObjectConstResult::Create (thread.GetStackFrameAtIndex(0).get(),
value,
ConstString(""));
}
- else if (type_flags & eTypeIsPointer)
+ else if (type_flags & eTypeIsStructUnion ||
+ type_flags & eTypeIsClass ||
+ type_flags & eTypeIsVector)
{
- value.SetValueType(Value::eValueTypeScalar);
- uint64_t raw_value = reg_ctx->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("r2", 0), 0);
- value.GetScalar() = (uint64_t)(raw_value);
+ // Any structure of up to 16 bytes in size is returned in the registers.
+ if (byte_size <= 16)
+ {
+ DataBufferSP data_sp (new DataBufferHeap(16, 0));
+ DataExtractor return_ext (data_sp,
+ target_byte_order,
+ target->GetArchitecture().GetAddressByteSize());
+
+ RegisterValue r2_value, r3_value, f0_value, f1_value, f2_value;
+
+ uint32_t integer_bytes = 0; // Tracks how much bytes of r2 and r3 registers we've consumed so far
+ bool use_fp_regs = 0; // True if return values are in FP return registers.
+ bool found_non_fp_field = 0; // True if we found any non floating point field in structure.
+ bool use_r2 = 0; // True if return values are in r2 register.
+ bool use_r3 = 0; // True if return values are in r3 register.
+ bool sucess = 0; // True if the result is copied into our data buffer
+ std::string name;
+ bool is_complex;
+ uint32_t count;
+ const uint32_t num_children = return_compiler_type.GetNumFields ();
+
+ // A structure consisting of one or two FP values (and nothing else) will be
+ // returned in the two FP return-value registers i.e fp0 and fp2.
+ if (num_children <= 2)
+ {
+ uint64_t field_bit_offset = 0;
- return_valobj_sp = ValueObjectConstResult::Create (thread.GetStackFrameAtIndex(0).get(),
- value,
- ConstString(""));
- }
- else if (type_flags & eTypeIsVector)
- {
- // TODO: Handle vector types
+ // Check if this structure contains only floating point fields
+ for (uint32_t idx = 0; idx < num_children; idx++)
+ {
+ CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex (idx, name, &field_bit_offset, NULL, NULL);
+
+ if (field_compiler_type.IsFloatingPointType (count, is_complex))
+ use_fp_regs = 1;
+ else
+ found_non_fp_field = 1;
+ }
+
+ if (use_fp_regs && !found_non_fp_field)
+ {
+ // We have one or two FP-only values in this structure. Get it from f0/f2 registers.
+ DataExtractor f0_data, f1_data, f2_data;
+ const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0);
+ const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0);
+ const RegisterInfo *f2_info = reg_ctx->GetRegisterInfoByName("f2", 0);
+
+ reg_ctx->ReadRegister (f0_info, f0_value);
+ reg_ctx->ReadRegister (f2_info, f2_value);
+
+ f0_value.GetData(f0_data);
+ f2_value.GetData(f2_data);
+
+ for (uint32_t idx = 0; idx < num_children; idx++)
+ {
+ CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex (idx, name, &field_bit_offset, NULL, NULL);
+ const size_t field_byte_width = field_compiler_type.GetByteSize(nullptr);
+
+ DataExtractor *copy_from_extractor = NULL;
+
+ if (idx == 0)
+ {
+ if (field_byte_width == 16) // This case is for long double type.
+ {
+ // If structure contains long double type, then it is returned in fp0/fp1 registers.
+ reg_ctx->ReadRegister (f1_info, f1_value);
+ f1_value.GetData(f1_data);
+
+ if (target_byte_order == eByteOrderLittle)
+ {
+ f0_data.Append(f1_data);
+ copy_from_extractor = &f0_data;
+ }
+ else
+ {
+ f1_data.Append(f0_data);
+ copy_from_extractor = &f1_data;
+ }
+ }
+ else
+ copy_from_extractor = &f0_data; // This is in f0, copy from register to our result structure
+ }
+ else
+ copy_from_extractor = &f2_data; // This is in f2, copy from register to our result structure
+
+ // Sanity check to avoid crash
+ if (!copy_from_extractor || field_byte_width > copy_from_extractor->GetByteSize())
+ return return_valobj_sp;
+
+ // copy the register contents into our data buffer
+ copy_from_extractor->CopyByteOrderedData (0,
+ field_byte_width,
+ data_sp->GetBytes() + (field_bit_offset/8),
+ field_byte_width,
+ target_byte_order);
+ }
+
+ // The result is in our data buffer. Create a variable object out of it
+ return_valobj_sp = ValueObjectConstResult::Create (&thread,
+ return_compiler_type,
+ ConstString(""),
+ return_ext);
+
+ return return_valobj_sp;
+ }
+ }
+
+ // If we reach here, it means this structure either contains more than two fields or
+ // it contains at least one non floating point type.
+ // In that case, all fields are returned in GP return registers.
+ for (uint32_t idx = 0; idx < num_children; idx++)
+ {
+ uint64_t field_bit_offset = 0;
+ bool is_signed;
+ uint32_t padding;
+
+ CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex (idx, name, &field_bit_offset, NULL, NULL);
+ const size_t field_byte_width = field_compiler_type.GetByteSize(nullptr);
+
+ // if we don't know the size of the field (e.g. invalid type), just bail out
+ if (field_byte_width == 0)
+ break;
+
+ uint32_t field_byte_offset = field_bit_offset/8;
+
+ if (field_compiler_type.IsIntegerType (is_signed)
+ || field_compiler_type.IsPointerType ()
+ || field_compiler_type.IsFloatingPointType (count, is_complex))
+ {
+ padding = field_byte_offset - integer_bytes;
+
+ if (integer_bytes < 8)
+ {
+ // We have not yet consumed r2 completely.
+ if (integer_bytes + field_byte_width + padding <= 8)
+ {
+ // This field fits in r2, copy its value from r2 to our result structure
+ integer_bytes = integer_bytes + field_byte_width + padding; // Increase the consumed bytes.
+ use_r2 = 1;
+ }
+ 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;
+ }
+ }
+ // 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;
+ }
+ else
+ {
+ // There isn't any space left for this field, this should not happen as we have already checked
+ // the overall size is not greater than 16 bytes. For now, return a NULL return value object.
+ return return_valobj_sp;
+ }
+ }
+ }
+ // Vector types upto 16 bytes are returned in GP return registers
+ if (type_flags & eTypeIsVector)
+ {
+ if (byte_size <= 8)
+ use_r2 = 1;
+ else
+ {
+ use_r2 = 1;
+ use_r3 = 1;
+ }
+ }
+
+ if (use_r2)
+ {
+ reg_ctx->ReadRegister (r2_info, r2_value);
+
+ const size_t bytes_copied = r2_value.GetAsMemoryData (r2_info,
+ data_sp->GetBytes(),
+ r2_info->byte_size,
+ target_byte_order,
+ error);
+ if (bytes_copied != r2_info->byte_size)
+ return return_valobj_sp;
+ sucess = 1;
+ }
+ if (use_r3)
+ {
+ reg_ctx->ReadRegister (r3_info, r3_value);
+ const size_t bytes_copied = r3_value.GetAsMemoryData (r3_info,
+ data_sp->GetBytes() + r2_info->byte_size,
+ r3_info->byte_size,
+ target_byte_order,
+ error);
+
+ if (bytes_copied != r3_info->byte_size)
+ return return_valobj_sp;
+ sucess = 1;
+ }
+ if (sucess)
+ {
+ // The result is in our data buffer. Create a variable object out of it
+ return_valobj_sp = ValueObjectConstResult::Create (&thread,
+ return_compiler_type,
+ ConstString(""),
+ return_ext);
+ }
+ return return_valobj_sp;
+ }
+
+ // Any structure/vector greater than 16 bytes in size is returned in memory.
+ // The pointer to that memory is returned in r2.
+ uint64_t mem_address = reg_ctx->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("r2", 0), 0);
+
+ // We have got the address. Create a memory object out of it
+ return_valobj_sp = ValueObjectMemory::Create (&thread,
+ "",
+ Address (mem_address, NULL),
+ return_compiler_type);
}
return return_valobj_sp;
}
@@ -476,17 +718,17 @@ ABISysV_mips64::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan)
UnwindPlan::RowSP row(new UnwindPlan::Row);
// Our Call Frame Address is the stack pointer value
- row->GetCFAValue().SetIsRegisterPlusOffset(gcc_dwarf_r29, 0);
+ row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_r29, 0);
// The previous PC is in the RA
- row->SetRegisterLocationToRegister(gcc_dwarf_pc, gcc_dwarf_r31, true);
+ row->SetRegisterLocationToRegister(dwarf_pc, dwarf_r31, true);
unwind_plan.AppendRow (row);
// All other registers are the same.
unwind_plan.SetSourceName ("mips64 at-func-entry default");
unwind_plan.SetSourcedFromCompiler (eLazyBoolNo);
- unwind_plan.SetReturnAddressRegister(gcc_dwarf_r31);
+ unwind_plan.SetReturnAddressRegister(dwarf_r31);
return true;
}
@@ -498,9 +740,9 @@ ABISysV_mips64::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan)
UnwindPlan::RowSP row(new UnwindPlan::Row);
- row->GetCFAValue().SetIsRegisterPlusOffset(gcc_dwarf_r29, 0);
+ row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_r29, 0);
- row->SetRegisterLocationToRegister(gcc_dwarf_pc, gcc_dwarf_r31, true);
+ row->SetRegisterLocationToRegister(dwarf_pc, dwarf_r31, true);
unwind_plan.AppendRow (row);
unwind_plan.SetSourceName ("mips64 default unwind plan");
diff --git a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h
index c37e717e0938..3290331e05a0 100644
--- a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h
+++ b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h
@@ -21,46 +21,37 @@ class ABISysV_mips64 :
public lldb_private::ABI
{
public:
+ ~ABISysV_mips64() override = default;
- ~ABISysV_mips64()
- {
- }
-
- virtual size_t
- GetRedZoneSize () const;
+ size_t
+ GetRedZoneSize() const override;
- virtual bool
- PrepareTrivialCall (lldb_private::Thread &thread,
- lldb::addr_t sp,
- lldb::addr_t functionAddress,
- lldb::addr_t returnAddress,
- llvm::ArrayRef<lldb::addr_t> args) const;
+ 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;
- virtual bool
- GetArgumentValues (lldb_private::Thread &thread,
- lldb_private::ValueList &values) const;
+ bool
+ GetArgumentValues(lldb_private::Thread &thread,
+ lldb_private::ValueList &values) const override;
- virtual lldb_private::Error
- SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value);
+ lldb_private::Error
+ SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override;
-protected:
lldb::ValueObjectSP
- GetReturnValueObjectSimple (lldb_private::Thread &thread,
- lldb_private::ClangASTType &ast_type) const;
-
-public:
- virtual lldb::ValueObjectSP
- GetReturnValueObjectImpl (lldb_private::Thread &thread,
- lldb_private::ClangASTType &type) const;
+ GetReturnValueObjectImpl(lldb_private::Thread &thread,
+ lldb_private::CompilerType &type) const override;
- virtual bool
- CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
+ bool
+ CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
- virtual bool
- CreateDefaultUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
+ bool
+ CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
- virtual bool
- RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info);
+ bool
+ RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
// The SysV mips ABI requires that stack frames be 16 byte aligned.
// When there is a trap handler on the stack, e.g. _sigtramp in userland
@@ -72,8 +63,8 @@ public:
// Whitelisting the trap handlers for user space would be easy (_sigtramp) but
// in other environments there can be a large number of different functions
// involved in async traps.
- virtual bool
- CallFrameAddressIsValid (lldb::addr_t cfa)
+ bool
+ CallFrameAddressIsValid(lldb::addr_t cfa) override
{
// Make sure the stack call frame addresses are 8 byte aligned
if (cfa & (8ull - 1ull))
@@ -83,8 +74,8 @@ public:
return true;
}
- virtual bool
- CodeAddressIsValid (lldb::addr_t pc)
+ bool
+ CodeAddressIsValid(lldb::addr_t pc) override
{
if (pc & (4ull - 1ull))
return false; // Not 4 byte aligned
@@ -93,11 +84,13 @@ public:
return true;
}
- virtual const lldb_private::RegisterInfo *
- GetRegisterInfoArray (uint32_t &count);
+ const lldb_private::RegisterInfo *
+ GetRegisterInfoArray(uint32_t &count) override;
+
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
+
static void
Initialize();
@@ -113,21 +106,30 @@ public:
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
- virtual lldb_private::ConstString
- GetPluginName();
- virtual uint32_t
- GetPluginVersion();
+ 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:
- ABISysV_mips64() : lldb_private::ABI() { } // Call CreateInstance instead.
+ ABISysV_mips64() :
+ lldb_private::ABI()
+ {
+ // Call CreateInstance instead.
+ }
};
-#endif // liblldb_ABI_h_
+#endif // liblldb_ABISysV_mips64_h_
diff --git a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
index 08416dc25b08..f0da18637ba8 100644
--- a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
+++ b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
@@ -20,7 +20,6 @@
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectRegister.h"
#include "lldb/Core/ValueObjectMemory.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Process.h"
@@ -34,123 +33,81 @@
using namespace lldb;
using namespace lldb_private;
-enum gcc_dwarf_regnums
+enum dwarf_regnums
{
- gcc_dwarf_r0 = 0,
- gcc_dwarf_r1,
- gcc_dwarf_r2,
- gcc_dwarf_r3,
- gcc_dwarf_r4,
- gcc_dwarf_r5,
- gcc_dwarf_r6,
- gcc_dwarf_r7,
- gcc_dwarf_r8,
- gcc_dwarf_r9,
- gcc_dwarf_r10,
- gcc_dwarf_r11,
- gcc_dwarf_r12,
- gcc_dwarf_r13,
- gcc_dwarf_r14,
- gcc_dwarf_r15,
- gcc_dwarf_r16,
- gcc_dwarf_r17,
- gcc_dwarf_r18,
- gcc_dwarf_r19,
- gcc_dwarf_r20,
- gcc_dwarf_r21,
- gcc_dwarf_r22,
- gcc_dwarf_r23,
- gcc_dwarf_r24,
- gcc_dwarf_r25,
- gcc_dwarf_r26,
- gcc_dwarf_r27,
- gcc_dwarf_r28,
- gcc_dwarf_r29,
- gcc_dwarf_r30,
- gcc_dwarf_r31,
- gcc_dwarf_f0,
- gcc_dwarf_f1,
- gcc_dwarf_f2,
- gcc_dwarf_f3,
- gcc_dwarf_f4,
- gcc_dwarf_f5,
- gcc_dwarf_f6,
- gcc_dwarf_f7,
- gcc_dwarf_f8,
- gcc_dwarf_f9,
- gcc_dwarf_f10,
- gcc_dwarf_f11,
- gcc_dwarf_f12,
- gcc_dwarf_f13,
- gcc_dwarf_f14,
- gcc_dwarf_f15,
- gcc_dwarf_f16,
- gcc_dwarf_f17,
- gcc_dwarf_f18,
- gcc_dwarf_f19,
- gcc_dwarf_f20,
- gcc_dwarf_f21,
- gcc_dwarf_f22,
- gcc_dwarf_f23,
- gcc_dwarf_f24,
- gcc_dwarf_f25,
- gcc_dwarf_f26,
- gcc_dwarf_f27,
- gcc_dwarf_f28,
- gcc_dwarf_f29,
- gcc_dwarf_f30,
- gcc_dwarf_f31,
- gcc_dwarf_cr,
- gcc_dwarf_fpscr,
- gcc_dwarf_xer = 101,
- gcc_dwarf_lr = 108,
- gcc_dwarf_ctr,
- gcc_dwarf_pc,
- gcc_dwarf_cfa,
+ dwarf_r0 = 0,
+ dwarf_r1,
+ dwarf_r2,
+ dwarf_r3,
+ dwarf_r4,
+ dwarf_r5,
+ dwarf_r6,
+ dwarf_r7,
+ dwarf_r8,
+ dwarf_r9,
+ dwarf_r10,
+ dwarf_r11,
+ dwarf_r12,
+ dwarf_r13,
+ dwarf_r14,
+ dwarf_r15,
+ dwarf_r16,
+ dwarf_r17,
+ dwarf_r18,
+ dwarf_r19,
+ dwarf_r20,
+ dwarf_r21,
+ dwarf_r22,
+ dwarf_r23,
+ dwarf_r24,
+ dwarf_r25,
+ dwarf_r26,
+ dwarf_r27,
+ dwarf_r28,
+ dwarf_r29,
+ dwarf_r30,
+ dwarf_r31,
+ dwarf_f0,
+ dwarf_f1,
+ dwarf_f2,
+ dwarf_f3,
+ dwarf_f4,
+ dwarf_f5,
+ dwarf_f6,
+ dwarf_f7,
+ dwarf_f8,
+ dwarf_f9,
+ dwarf_f10,
+ dwarf_f11,
+ dwarf_f12,
+ dwarf_f13,
+ dwarf_f14,
+ dwarf_f15,
+ dwarf_f16,
+ dwarf_f17,
+ dwarf_f18,
+ dwarf_f19,
+ dwarf_f20,
+ dwarf_f21,
+ dwarf_f22,
+ dwarf_f23,
+ dwarf_f24,
+ dwarf_f25,
+ dwarf_f26,
+ dwarf_f27,
+ dwarf_f28,
+ dwarf_f29,
+ dwarf_f30,
+ dwarf_f31,
+ dwarf_cr,
+ dwarf_fpscr,
+ dwarf_xer = 101,
+ dwarf_lr = 108,
+ dwarf_ctr,
+ dwarf_pc,
+ dwarf_cfa,
};
-enum gdb_regnums
-{
- gdb_r0 = 0,
- gdb_r1,
- gdb_r2,
- gdb_r3,
- gdb_r4,
- gdb_r5,
- gdb_r6,
- gdb_r7,
- gdb_r8,
- gdb_r9,
- gdb_r10,
- gdb_r11,
- gdb_r12,
- gdb_r13,
- gdb_r14,
- gdb_r15,
- gdb_r16,
- gdb_r17,
- gdb_r18,
- gdb_r19,
- gdb_r20,
- gdb_r21,
- gdb_r22,
- gdb_r23,
- gdb_r24,
- gdb_r25,
- gdb_r26,
- gdb_r27,
- gdb_r28,
- gdb_r29,
- gdb_r30,
- gdb_r31,
- gdb_lr,
- gdb_cr,
- gdb_xer,
- gdb_ctr,
- gdb_pc,
-};
-
-
// Note that the size and offset will be updated by platform-specific classes.
#define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \
{ #reg, alt, 8, 0, eEncodingUint, \
@@ -158,45 +115,45 @@ enum gdb_regnums
static const RegisterInfo
g_register_infos[] =
{
- // General purpose registers. GCC, DWARF, Generic, GDB
- DEFINE_GPR(r0, NULL, gcc_dwarf_r0, gcc_dwarf_r0, LLDB_INVALID_REGNUM, gdb_r0),
- DEFINE_GPR(r1, "sp", gcc_dwarf_r1, gcc_dwarf_r1, LLDB_REGNUM_GENERIC_SP, gdb_r1),
- DEFINE_GPR(r2, NULL, gcc_dwarf_r2, gcc_dwarf_r2, LLDB_INVALID_REGNUM, gdb_r2),
- DEFINE_GPR(r3, "arg1",gcc_dwarf_r3, gcc_dwarf_r3, LLDB_REGNUM_GENERIC_ARG1, gdb_r3),
- DEFINE_GPR(r4, "arg2",gcc_dwarf_r4, gcc_dwarf_r4, LLDB_REGNUM_GENERIC_ARG2 ,gdb_r4),
- DEFINE_GPR(r5, "arg3",gcc_dwarf_r5, gcc_dwarf_r5, LLDB_REGNUM_GENERIC_ARG3, gdb_r5),
- DEFINE_GPR(r6, "arg4",gcc_dwarf_r6, gcc_dwarf_r6, LLDB_REGNUM_GENERIC_ARG4, gdb_r6),
- DEFINE_GPR(r7, "arg5",gcc_dwarf_r7, gcc_dwarf_r7, LLDB_REGNUM_GENERIC_ARG5, gdb_r7),
- DEFINE_GPR(r8, "arg6",gcc_dwarf_r8, gcc_dwarf_r8, LLDB_REGNUM_GENERIC_ARG6, gdb_r8),
- DEFINE_GPR(r9, "arg7",gcc_dwarf_r9, gcc_dwarf_r9, LLDB_REGNUM_GENERIC_ARG7, gdb_r9),
- DEFINE_GPR(r10, "arg8",gcc_dwarf_r10, gcc_dwarf_r10, LLDB_REGNUM_GENERIC_ARG8, gdb_r10),
- DEFINE_GPR(r11, NULL, gcc_dwarf_r11, gcc_dwarf_r11, LLDB_INVALID_REGNUM, gdb_r11),
- DEFINE_GPR(r12, NULL, gcc_dwarf_r12, gcc_dwarf_r12, LLDB_INVALID_REGNUM, gdb_r12),
- DEFINE_GPR(r13, NULL, gcc_dwarf_r13, gcc_dwarf_r13, LLDB_INVALID_REGNUM, gdb_r13),
- DEFINE_GPR(r14, NULL, gcc_dwarf_r14, gcc_dwarf_r14, LLDB_INVALID_REGNUM, gdb_r14),
- DEFINE_GPR(r15, NULL, gcc_dwarf_r15, gcc_dwarf_r15, LLDB_INVALID_REGNUM, gdb_r15),
- DEFINE_GPR(r16, NULL, gcc_dwarf_r16, gcc_dwarf_r16, LLDB_INVALID_REGNUM, gdb_r16),
- DEFINE_GPR(r17, NULL, gcc_dwarf_r17, gcc_dwarf_r17, LLDB_INVALID_REGNUM, gdb_r17),
- DEFINE_GPR(r18, NULL, gcc_dwarf_r18, gcc_dwarf_r18, LLDB_INVALID_REGNUM, gdb_r18),
- DEFINE_GPR(r19, NULL, gcc_dwarf_r19, gcc_dwarf_r19, LLDB_INVALID_REGNUM, gdb_r19),
- DEFINE_GPR(r20, NULL, gcc_dwarf_r20, gcc_dwarf_r20, LLDB_INVALID_REGNUM, gdb_r20),
- DEFINE_GPR(r21, NULL, gcc_dwarf_r21, gcc_dwarf_r21, LLDB_INVALID_REGNUM, gdb_r21),
- DEFINE_GPR(r22, NULL, gcc_dwarf_r22, gcc_dwarf_r22, LLDB_INVALID_REGNUM, gdb_r22),
- DEFINE_GPR(r23, NULL, gcc_dwarf_r23, gcc_dwarf_r23, LLDB_INVALID_REGNUM, gdb_r23),
- DEFINE_GPR(r24, NULL, gcc_dwarf_r24, gcc_dwarf_r24, LLDB_INVALID_REGNUM, gdb_r24),
- DEFINE_GPR(r25, NULL, gcc_dwarf_r25, gcc_dwarf_r25, LLDB_INVALID_REGNUM, gdb_r25),
- DEFINE_GPR(r26, NULL, gcc_dwarf_r26, gcc_dwarf_r26, LLDB_INVALID_REGNUM, gdb_r26),
- DEFINE_GPR(r27, NULL, gcc_dwarf_r27, gcc_dwarf_r27, LLDB_INVALID_REGNUM, gdb_r27),
- DEFINE_GPR(r28, NULL, gcc_dwarf_r28, gcc_dwarf_r28, LLDB_INVALID_REGNUM, gdb_r28),
- DEFINE_GPR(r29, NULL, gcc_dwarf_r29, gcc_dwarf_r29, LLDB_INVALID_REGNUM, gdb_r29),
- DEFINE_GPR(r30, NULL, gcc_dwarf_r30, gcc_dwarf_r30, LLDB_INVALID_REGNUM, gdb_r30),
- DEFINE_GPR(r31, NULL, gcc_dwarf_r31, gcc_dwarf_r31, LLDB_INVALID_REGNUM, gdb_r31),
- DEFINE_GPR(lr, "lr", gcc_dwarf_lr, gcc_dwarf_lr, LLDB_REGNUM_GENERIC_RA, gdb_lr),
- DEFINE_GPR(cr, "cr", gcc_dwarf_cr, gcc_dwarf_cr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
- DEFINE_GPR(xer, "xer", gcc_dwarf_xer, gcc_dwarf_xer, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(ctr, "ctr", gcc_dwarf_ctr, gcc_dwarf_ctr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(pc, "pc", gcc_dwarf_pc, gcc_dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
- { NULL, NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_cfa, gcc_dwarf_cfa, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, NULL, NULL},
+ // General purpose registers. eh_frame, DWARF, Generic, Process Plugin
+ DEFINE_GPR(r0, NULL, dwarf_r0, dwarf_r0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r1, "sp", dwarf_r1, dwarf_r1, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r2, NULL, dwarf_r2, dwarf_r2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r3, "arg1",dwarf_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r4, "arg2",dwarf_r4, dwarf_r4, LLDB_REGNUM_GENERIC_ARG2 ,LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r5, "arg3",dwarf_r5, dwarf_r5, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r6, "arg4",dwarf_r6, dwarf_r6, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r7, "arg5",dwarf_r7, dwarf_r7, LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r8, "arg6",dwarf_r8, dwarf_r8, LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r9, "arg7",dwarf_r9, dwarf_r9, LLDB_REGNUM_GENERIC_ARG7, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r10, "arg8",dwarf_r10, dwarf_r10, LLDB_REGNUM_GENERIC_ARG8, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r11, NULL, dwarf_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r12, NULL, dwarf_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r13, NULL, dwarf_r13, dwarf_r13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r14, NULL, dwarf_r14, dwarf_r14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r15, NULL, dwarf_r15, dwarf_r15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r16, NULL, dwarf_r16, dwarf_r16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r17, NULL, dwarf_r17, dwarf_r17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r18, NULL, dwarf_r18, dwarf_r18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r19, NULL, dwarf_r19, dwarf_r19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r20, NULL, dwarf_r20, dwarf_r20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r21, NULL, dwarf_r21, dwarf_r21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r22, NULL, dwarf_r22, dwarf_r22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r23, NULL, dwarf_r23, dwarf_r23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r24, NULL, dwarf_r24, dwarf_r24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r25, NULL, dwarf_r25, dwarf_r25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r26, NULL, dwarf_r26, dwarf_r26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r27, NULL, dwarf_r27, dwarf_r27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r28, NULL, dwarf_r28, dwarf_r28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r29, NULL, dwarf_r29, dwarf_r29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r30, NULL, dwarf_r30, dwarf_r30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r31, NULL, dwarf_r31, dwarf_r31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(lr, "lr", dwarf_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(cr, "cr", dwarf_cr, dwarf_cr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(xer, "xer", dwarf_xer, dwarf_xer, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(ctr, "ctr", dwarf_ctr, dwarf_ctr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(pc, "pc", dwarf_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
+ { NULL, NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_cfa, dwarf_cfa, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, NULL, NULL},
};
static const uint32_t k_num_register_infos = llvm::array_lengthof(g_register_infos);
@@ -436,25 +393,25 @@ ABISysV_ppc::GetArgumentValues (Thread &thread,
// We currently only support extracting values with Clang QualTypes.
// Do we care about others?
- ClangASTType clang_type = value->GetClangType();
- if (!clang_type)
+ CompilerType compiler_type = value->GetCompilerType();
+ if (!compiler_type)
return false;
bool is_signed;
- if (clang_type.IsIntegerType (is_signed))
+ if (compiler_type.IsIntegerType (is_signed))
{
ReadIntegerArgument(value->GetScalar(),
- clang_type.GetBitSize(&thread),
+ compiler_type.GetBitSize(&thread),
is_signed,
thread,
argument_register_ids,
current_argument_register,
current_stack_argument);
}
- else if (clang_type.IsPointerType ())
+ else if (compiler_type.IsPointerType ())
{
ReadIntegerArgument(value->GetScalar(),
- clang_type.GetBitSize(&thread),
+ compiler_type.GetBitSize(&thread),
false,
thread,
argument_register_ids,
@@ -476,8 +433,8 @@ ABISysV_ppc::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjec
return error;
}
- ClangASTType clang_type = new_value_sp->GetClangType();
- if (!clang_type)
+ CompilerType compiler_type = new_value_sp->GetCompilerType();
+ if (!compiler_type)
{
error.SetErrorString ("Null clang type for return value.");
return error;
@@ -492,7 +449,7 @@ ABISysV_ppc::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjec
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
bool set_it_simple = false;
- if (clang_type.IsIntegerType (is_signed) || clang_type.IsPointerType())
+ if (compiler_type.IsIntegerType (is_signed) || compiler_type.IsPointerType())
{
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName("r3", 0);
@@ -518,13 +475,13 @@ ABISysV_ppc::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjec
}
}
- else if (clang_type.IsFloatingPointType (count, is_complex))
+ else if (compiler_type.IsFloatingPointType (count, is_complex))
{
if (is_complex)
error.SetErrorString ("We don't support returning complex values at present");
else
{
- size_t bit_width = clang_type.GetBitSize(frame_sp.get());
+ size_t bit_width = compiler_type.GetBitSize(frame_sp.get());
if (bit_width <= 64)
{
DataExtractor data;
@@ -563,22 +520,22 @@ ABISysV_ppc::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjec
ValueObjectSP
ABISysV_ppc::GetReturnValueObjectSimple (Thread &thread,
- ClangASTType &return_clang_type) const
+ CompilerType &return_compiler_type) const
{
ValueObjectSP return_valobj_sp;
Value value;
- if (!return_clang_type)
+ if (!return_compiler_type)
return return_valobj_sp;
//value.SetContext (Value::eContextTypeClangType, return_value_type);
- value.SetClangType (return_clang_type);
+ value.SetCompilerType (return_compiler_type);
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
if (!reg_ctx)
return return_valobj_sp;
- const uint32_t type_flags = return_clang_type.GetTypeInfo ();
+ const uint32_t type_flags = return_compiler_type.GetTypeInfo ();
if (type_flags & eTypeIsScalar)
{
value.SetValueType(Value::eValueTypeScalar);
@@ -588,7 +545,7 @@ ABISysV_ppc::GetReturnValueObjectSimple (Thread &thread,
{
// Extract the register context so we can read arguments from registers
- const size_t byte_size = return_clang_type.GetByteSize(nullptr);
+ const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("r3", 0), 0);
const bool is_signed = (type_flags & eTypeIsSigned) != 0;
switch (byte_size)
@@ -637,7 +594,7 @@ ABISysV_ppc::GetReturnValueObjectSimple (Thread &thread,
}
else
{
- const size_t byte_size = return_clang_type.GetByteSize(nullptr);
+ const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
if (byte_size <= sizeof(long double))
{
const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0);
@@ -681,7 +638,7 @@ ABISysV_ppc::GetReturnValueObjectSimple (Thread &thread,
}
else if (type_flags & eTypeIsVector)
{
- const size_t byte_size = return_clang_type.GetByteSize(nullptr);
+ const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
if (byte_size > 0)
{
@@ -709,7 +666,7 @@ ABISysV_ppc::GetReturnValueObjectSimple (Thread &thread,
byte_order,
process_sp->GetTarget().GetArchitecture().GetAddressByteSize());
return_valobj_sp = ValueObjectConstResult::Create (&thread,
- return_clang_type,
+ return_compiler_type,
ConstString(""),
data);
}
@@ -724,15 +681,15 @@ ABISysV_ppc::GetReturnValueObjectSimple (Thread &thread,
}
ValueObjectSP
-ABISysV_ppc::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_clang_type) const
+ABISysV_ppc::GetReturnValueObjectImpl (Thread &thread, CompilerType &return_compiler_type) const
{
ValueObjectSP return_valobj_sp;
- if (!return_clang_type)
+ if (!return_compiler_type)
return return_valobj_sp;
ExecutionContext exe_ctx (thread.shared_from_this());
- return_valobj_sp = GetReturnValueObjectSimple(thread, return_clang_type);
+ return_valobj_sp = GetReturnValueObjectSimple(thread, return_compiler_type);
if (return_valobj_sp)
return return_valobj_sp;
@@ -740,8 +697,8 @@ ABISysV_ppc::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_clan
if (!reg_ctx_sp)
return return_valobj_sp;
- const size_t bit_width = return_clang_type.GetBitSize(&thread);
- if (return_clang_type.IsAggregateType())
+ const size_t bit_width = return_compiler_type.GetBitSize(&thread);
+ if (return_compiler_type.IsAggregateType())
{
Target *target = exe_ctx.GetTargetPtr();
bool is_memory = true;
@@ -768,7 +725,7 @@ ABISysV_ppc::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_clan
uint32_t fp_bytes = 0; // Tracks how much of the xmm registers we've consumed so far
uint32_t integer_bytes = 0; // Tracks how much of the r3/rds registers we've consumed so far
- const uint32_t num_children = return_clang_type.GetNumFields ();
+ const uint32_t num_children = return_compiler_type.GetNumFields ();
// Since we are in the small struct regime, assume we are not in memory.
is_memory = false;
@@ -781,8 +738,8 @@ ABISysV_ppc::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_clan
bool is_complex;
uint32_t count;
- ClangASTType field_clang_type = return_clang_type.GetFieldAtIndex (idx, name, &field_bit_offset, NULL, NULL);
- const size_t field_bit_width = field_clang_type.GetBitSize(&thread);
+ CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex (idx, name, &field_bit_offset, NULL, NULL);
+ const size_t field_bit_width = field_compiler_type.GetBitSize(&thread);
// If there are any unaligned fields, this is stored in memory.
if (field_bit_offset % field_bit_width != 0)
@@ -798,7 +755,7 @@ ABISysV_ppc::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_clan
DataExtractor *copy_from_extractor = NULL;
uint32_t copy_from_offset = 0;
- if (field_clang_type.IsIntegerType (is_signed) || field_clang_type.IsPointerType ())
+ if (field_compiler_type.IsIntegerType (is_signed) || field_compiler_type.IsPointerType ())
{
if (integer_bytes < 8)
{
@@ -831,7 +788,7 @@ ABISysV_ppc::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_clan
return return_valobj_sp;
}
}
- else if (field_clang_type.IsFloatingPointType (count, is_complex))
+ else if (field_compiler_type.IsFloatingPointType (count, is_complex))
{
// Structs with long doubles are always passed in memory.
if (field_bit_width == 128)
@@ -858,12 +815,12 @@ ABISysV_ppc::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_clan
else
{
uint64_t next_field_bit_offset = 0;
- ClangASTType next_field_clang_type = return_clang_type.GetFieldAtIndex (idx + 1,
+ CompilerType next_field_compiler_type = return_compiler_type.GetFieldAtIndex (idx + 1,
name,
&next_field_bit_offset,
NULL,
NULL);
- if (next_field_clang_type.IsIntegerType (is_signed))
+ if (next_field_compiler_type.IsIntegerType (is_signed))
in_gpr = true;
else
{
@@ -882,12 +839,12 @@ ABISysV_ppc::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_clan
else
{
uint64_t prev_field_bit_offset = 0;
- ClangASTType prev_field_clang_type = return_clang_type.GetFieldAtIndex (idx - 1,
+ CompilerType prev_field_compiler_type = return_compiler_type.GetFieldAtIndex (idx - 1,
name,
&prev_field_bit_offset,
NULL,
NULL);
- if (prev_field_clang_type.IsIntegerType (is_signed))
+ if (prev_field_compiler_type.IsIntegerType (is_signed))
in_gpr = true;
else
{
@@ -946,7 +903,7 @@ ABISysV_ppc::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_clan
{
// The result is in our data buffer. Let's make a variable object out of it:
return_valobj_sp = ValueObjectConstResult::Create (&thread,
- return_clang_type,
+ return_compiler_type,
ConstString(""),
return_ext);
}
@@ -965,7 +922,7 @@ ABISysV_ppc::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_clan
return_valobj_sp = ValueObjectMemory::Create (&thread,
"",
Address (storage_addr, NULL),
- return_clang_type);
+ return_compiler_type);
}
}
@@ -978,9 +935,9 @@ ABISysV_ppc::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan)
unwind_plan.Clear();
unwind_plan.SetRegisterKind (eRegisterKindDWARF);
- uint32_t lr_reg_num = gcc_dwarf_lr;
- uint32_t sp_reg_num = gcc_dwarf_r1;
- uint32_t pc_reg_num = gcc_dwarf_pc;
+ uint32_t lr_reg_num = dwarf_lr;
+ uint32_t sp_reg_num = dwarf_r1;
+ uint32_t pc_reg_num = dwarf_pc;
UnwindPlan::RowSP row(new UnwindPlan::Row);
@@ -1005,8 +962,8 @@ ABISysV_ppc::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan)
unwind_plan.Clear();
unwind_plan.SetRegisterKind (eRegisterKindDWARF);
- uint32_t sp_reg_num = gcc_dwarf_r1;
- uint32_t pc_reg_num = gcc_dwarf_lr;
+ uint32_t sp_reg_num = dwarf_r1;
+ uint32_t pc_reg_num = dwarf_lr;
UnwindPlan::RowSP row(new UnwindPlan::Row);
@@ -1020,7 +977,7 @@ ABISysV_ppc::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan)
unwind_plan.SetSourceName ("ppc default unwind plan");
unwind_plan.SetSourcedFromCompiler (eLazyBoolNo);
unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolNo);
- unwind_plan.SetReturnAddressRegister(gcc_dwarf_lr);
+ unwind_plan.SetReturnAddressRegister(dwarf_lr);
return true;
}
diff --git a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h
index a7aad300e297..99ee755631c2 100644
--- a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h
+++ b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h
@@ -21,52 +21,37 @@ class ABISysV_ppc :
public lldb_private::ABI
{
public:
+ ~ABISysV_ppc() override = default;
- ~ABISysV_ppc()
- {
- }
+ size_t
+ GetRedZoneSize() const override;
- virtual size_t
- GetRedZoneSize () const;
-
- virtual bool
- PrepareTrivialCall (lldb_private::Thread &thread,
- lldb::addr_t sp,
- lldb::addr_t functionAddress,
- lldb::addr_t returnAddress,
- llvm::ArrayRef<lldb::addr_t> args) const;
+ 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;
- virtual bool
- GetArgumentValues (lldb_private::Thread &thread,
- lldb_private::ValueList &values) const;
+ bool
+ GetArgumentValues(lldb_private::Thread &thread,
+ lldb_private::ValueList &values) const override;
- virtual lldb_private::Error
- SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value);
+ lldb_private::Error
+ SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override;
-protected:
lldb::ValueObjectSP
- GetReturnValueObjectSimple (lldb_private::Thread &thread,
- lldb_private::ClangASTType &ast_type) const;
-
-public:
- virtual lldb::ValueObjectSP
- GetReturnValueObjectImpl (lldb_private::Thread &thread,
- lldb_private::ClangASTType &type) const;
+ GetReturnValueObjectImpl(lldb_private::Thread &thread,
+ lldb_private::CompilerType &type) const override;
- virtual bool
- CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
+ bool
+ CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
- virtual bool
- CreateDefaultUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
+ bool
+ CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
- virtual bool
- RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info);
-
- virtual bool
- StackUsesFrames ()
- {
- return true;
- }
+ bool
+ RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
// The SysV ppc ABI requires that stack frames be 16 byte aligned.
// When there is a trap handler on the stack, e.g. _sigtramp in userland
@@ -78,8 +63,8 @@ public:
// Whitelisting the trap handlers for user space would be easy (_sigtramp) but
// in other environments there can be a large number of different functions
// involved in async traps.
- virtual bool
- CallFrameAddressIsValid (lldb::addr_t cfa)
+ bool
+ CallFrameAddressIsValid(lldb::addr_t cfa) override
{
// Make sure the stack call frame addresses are 8 byte aligned
if (cfa & (8ull - 1ull))
@@ -89,25 +74,21 @@ public:
return true;
}
- virtual bool
- CodeAddressIsValid (lldb::addr_t pc)
+ 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;
}
- virtual bool
- FunctionCallsChangeCFA ()
- {
- return true;
- }
+ const lldb_private::RegisterInfo *
+ GetRegisterInfoArray(uint32_t &count) override;
- virtual const lldb_private::RegisterInfo *
- GetRegisterInfoArray (uint32_t &count);
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
+
static void
Initialize();
@@ -123,21 +104,30 @@ public:
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
- virtual lldb_private::ConstString
- GetPluginName();
- virtual uint32_t
- GetPluginVersion();
+ 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:
- ABISysV_ppc() : lldb_private::ABI() { } // Call CreateInstance instead.
+ ABISysV_ppc() :
+ lldb_private::ABI()
+ {
+ // Call CreateInstance instead.
+ }
};
-#endif // liblldb_ABI_h_
+#endif // liblldb_ABISysV_ppc_h_
diff --git a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
index eb0d7c00070f..96c54ce97eec 100644
--- a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
+++ b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
@@ -20,7 +20,6 @@
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectRegister.h"
#include "lldb/Core/ValueObjectMemory.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Process.h"
@@ -34,120 +33,79 @@
using namespace lldb;
using namespace lldb_private;
-enum gcc_dwarf_regnums
+enum dwarf_regnums
{
- gcc_dwarf_r0 = 0,
- gcc_dwarf_r1,
- gcc_dwarf_r2,
- gcc_dwarf_r3,
- gcc_dwarf_r4,
- gcc_dwarf_r5,
- gcc_dwarf_r6,
- gcc_dwarf_r7,
- gcc_dwarf_r8,
- gcc_dwarf_r9,
- gcc_dwarf_r10,
- gcc_dwarf_r11,
- gcc_dwarf_r12,
- gcc_dwarf_r13,
- gcc_dwarf_r14,
- gcc_dwarf_r15,
- gcc_dwarf_r16,
- gcc_dwarf_r17,
- gcc_dwarf_r18,
- gcc_dwarf_r19,
- gcc_dwarf_r20,
- gcc_dwarf_r21,
- gcc_dwarf_r22,
- gcc_dwarf_r23,
- gcc_dwarf_r24,
- gcc_dwarf_r25,
- gcc_dwarf_r26,
- gcc_dwarf_r27,
- gcc_dwarf_r28,
- gcc_dwarf_r29,
- gcc_dwarf_r30,
- gcc_dwarf_r31,
- gcc_dwarf_f0,
- gcc_dwarf_f1,
- gcc_dwarf_f2,
- gcc_dwarf_f3,
- gcc_dwarf_f4,
- gcc_dwarf_f5,
- gcc_dwarf_f6,
- gcc_dwarf_f7,
- gcc_dwarf_f8,
- gcc_dwarf_f9,
- gcc_dwarf_f10,
- gcc_dwarf_f11,
- gcc_dwarf_f12,
- gcc_dwarf_f13,
- gcc_dwarf_f14,
- gcc_dwarf_f15,
- gcc_dwarf_f16,
- gcc_dwarf_f17,
- gcc_dwarf_f18,
- gcc_dwarf_f19,
- gcc_dwarf_f20,
- gcc_dwarf_f21,
- gcc_dwarf_f22,
- gcc_dwarf_f23,
- gcc_dwarf_f24,
- gcc_dwarf_f25,
- gcc_dwarf_f26,
- gcc_dwarf_f27,
- gcc_dwarf_f28,
- gcc_dwarf_f29,
- gcc_dwarf_f30,
- gcc_dwarf_f31,
- gcc_dwarf_cr,
- gcc_dwarf_fpscr,
- gcc_dwarf_xer = 101,
- gcc_dwarf_lr = 108,
- gcc_dwarf_ctr,
- gcc_dwarf_pc,
- gcc_dwarf_cfa,
-};
-
-enum gdb_regnums
-{
- gdb_r0 = 0,
- gdb_r1,
- gdb_r2,
- gdb_r3,
- gdb_r4,
- gdb_r5,
- gdb_r6,
- gdb_r7,
- gdb_r8,
- gdb_r9,
- gdb_r10,
- gdb_r11,
- gdb_r12,
- gdb_r13,
- gdb_r14,
- gdb_r15,
- gdb_r16,
- gdb_r17,
- gdb_r18,
- gdb_r19,
- gdb_r20,
- gdb_r21,
- gdb_r22,
- gdb_r23,
- gdb_r24,
- gdb_r25,
- gdb_r26,
- gdb_r27,
- gdb_r28,
- gdb_r29,
- gdb_r30,
- gdb_r31,
- gdb_lr,
- gdb_cr,
- gdb_xer,
- gdb_ctr,
- gdb_pc,
+ dwarf_r0 = 0,
+ dwarf_r1,
+ dwarf_r2,
+ dwarf_r3,
+ dwarf_r4,
+ dwarf_r5,
+ dwarf_r6,
+ dwarf_r7,
+ dwarf_r8,
+ dwarf_r9,
+ dwarf_r10,
+ dwarf_r11,
+ dwarf_r12,
+ dwarf_r13,
+ dwarf_r14,
+ dwarf_r15,
+ dwarf_r16,
+ dwarf_r17,
+ dwarf_r18,
+ dwarf_r19,
+ dwarf_r20,
+ dwarf_r21,
+ dwarf_r22,
+ dwarf_r23,
+ dwarf_r24,
+ dwarf_r25,
+ dwarf_r26,
+ dwarf_r27,
+ dwarf_r28,
+ dwarf_r29,
+ dwarf_r30,
+ dwarf_r31,
+ dwarf_f0,
+ dwarf_f1,
+ dwarf_f2,
+ dwarf_f3,
+ dwarf_f4,
+ dwarf_f5,
+ dwarf_f6,
+ dwarf_f7,
+ dwarf_f8,
+ dwarf_f9,
+ dwarf_f10,
+ dwarf_f11,
+ dwarf_f12,
+ dwarf_f13,
+ dwarf_f14,
+ dwarf_f15,
+ dwarf_f16,
+ dwarf_f17,
+ dwarf_f18,
+ dwarf_f19,
+ dwarf_f20,
+ dwarf_f21,
+ dwarf_f22,
+ dwarf_f23,
+ dwarf_f24,
+ dwarf_f25,
+ dwarf_f26,
+ dwarf_f27,
+ dwarf_f28,
+ dwarf_f29,
+ dwarf_f30,
+ dwarf_f31,
+ dwarf_cr,
+ dwarf_fpscr,
+ dwarf_xer = 101,
+ dwarf_lr = 108,
+ dwarf_ctr,
+ dwarf_pc,
+ dwarf_cfa,
};
@@ -158,45 +116,45 @@ enum gdb_regnums
static const RegisterInfo
g_register_infos[] =
{
- // General purpose registers. GCC, DWARF, Generic, GDB
- DEFINE_GPR(r0, NULL, gcc_dwarf_r0, gcc_dwarf_r0, LLDB_INVALID_REGNUM, gdb_r0),
- DEFINE_GPR(r1, "sp", gcc_dwarf_r1, gcc_dwarf_r1, LLDB_REGNUM_GENERIC_SP, gdb_r1),
- DEFINE_GPR(r2, NULL, gcc_dwarf_r2, gcc_dwarf_r2, LLDB_INVALID_REGNUM, gdb_r2),
- DEFINE_GPR(r3, "arg1",gcc_dwarf_r3, gcc_dwarf_r3, LLDB_REGNUM_GENERIC_ARG1, gdb_r3),
- DEFINE_GPR(r4, "arg2",gcc_dwarf_r4, gcc_dwarf_r4, LLDB_REGNUM_GENERIC_ARG2 ,gdb_r4),
- DEFINE_GPR(r5, "arg3",gcc_dwarf_r5, gcc_dwarf_r5, LLDB_REGNUM_GENERIC_ARG3, gdb_r5),
- DEFINE_GPR(r6, "arg4",gcc_dwarf_r6, gcc_dwarf_r6, LLDB_REGNUM_GENERIC_ARG4, gdb_r6),
- DEFINE_GPR(r7, "arg5",gcc_dwarf_r7, gcc_dwarf_r7, LLDB_REGNUM_GENERIC_ARG5, gdb_r7),
- DEFINE_GPR(r8, "arg6",gcc_dwarf_r8, gcc_dwarf_r8, LLDB_REGNUM_GENERIC_ARG6, gdb_r8),
- DEFINE_GPR(r9, "arg7",gcc_dwarf_r9, gcc_dwarf_r9, LLDB_REGNUM_GENERIC_ARG7, gdb_r9),
- DEFINE_GPR(r10, "arg8",gcc_dwarf_r10, gcc_dwarf_r10, LLDB_REGNUM_GENERIC_ARG8, gdb_r10),
- DEFINE_GPR(r11, NULL, gcc_dwarf_r11, gcc_dwarf_r11, LLDB_INVALID_REGNUM, gdb_r11),
- DEFINE_GPR(r12, NULL, gcc_dwarf_r12, gcc_dwarf_r12, LLDB_INVALID_REGNUM, gdb_r12),
- DEFINE_GPR(r13, NULL, gcc_dwarf_r13, gcc_dwarf_r13, LLDB_INVALID_REGNUM, gdb_r13),
- DEFINE_GPR(r14, NULL, gcc_dwarf_r14, gcc_dwarf_r14, LLDB_INVALID_REGNUM, gdb_r14),
- DEFINE_GPR(r15, NULL, gcc_dwarf_r15, gcc_dwarf_r15, LLDB_INVALID_REGNUM, gdb_r15),
- DEFINE_GPR(r16, NULL, gcc_dwarf_r16, gcc_dwarf_r16, LLDB_INVALID_REGNUM, gdb_r16),
- DEFINE_GPR(r17, NULL, gcc_dwarf_r17, gcc_dwarf_r17, LLDB_INVALID_REGNUM, gdb_r17),
- DEFINE_GPR(r18, NULL, gcc_dwarf_r18, gcc_dwarf_r18, LLDB_INVALID_REGNUM, gdb_r18),
- DEFINE_GPR(r19, NULL, gcc_dwarf_r19, gcc_dwarf_r19, LLDB_INVALID_REGNUM, gdb_r19),
- DEFINE_GPR(r20, NULL, gcc_dwarf_r20, gcc_dwarf_r20, LLDB_INVALID_REGNUM, gdb_r20),
- DEFINE_GPR(r21, NULL, gcc_dwarf_r21, gcc_dwarf_r21, LLDB_INVALID_REGNUM, gdb_r21),
- DEFINE_GPR(r22, NULL, gcc_dwarf_r22, gcc_dwarf_r22, LLDB_INVALID_REGNUM, gdb_r22),
- DEFINE_GPR(r23, NULL, gcc_dwarf_r23, gcc_dwarf_r23, LLDB_INVALID_REGNUM, gdb_r23),
- DEFINE_GPR(r24, NULL, gcc_dwarf_r24, gcc_dwarf_r24, LLDB_INVALID_REGNUM, gdb_r24),
- DEFINE_GPR(r25, NULL, gcc_dwarf_r25, gcc_dwarf_r25, LLDB_INVALID_REGNUM, gdb_r25),
- DEFINE_GPR(r26, NULL, gcc_dwarf_r26, gcc_dwarf_r26, LLDB_INVALID_REGNUM, gdb_r26),
- DEFINE_GPR(r27, NULL, gcc_dwarf_r27, gcc_dwarf_r27, LLDB_INVALID_REGNUM, gdb_r27),
- DEFINE_GPR(r28, NULL, gcc_dwarf_r28, gcc_dwarf_r28, LLDB_INVALID_REGNUM, gdb_r28),
- DEFINE_GPR(r29, NULL, gcc_dwarf_r29, gcc_dwarf_r29, LLDB_INVALID_REGNUM, gdb_r29),
- DEFINE_GPR(r30, NULL, gcc_dwarf_r30, gcc_dwarf_r30, LLDB_INVALID_REGNUM, gdb_r30),
- DEFINE_GPR(r31, NULL, gcc_dwarf_r31, gcc_dwarf_r31, LLDB_INVALID_REGNUM, gdb_r31),
- DEFINE_GPR(lr, "lr", gcc_dwarf_lr, gcc_dwarf_lr, LLDB_REGNUM_GENERIC_RA, gdb_lr),
- DEFINE_GPR(cr, "cr", gcc_dwarf_cr, gcc_dwarf_cr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
- DEFINE_GPR(xer, "xer", gcc_dwarf_xer, gcc_dwarf_xer, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(ctr, "ctr", gcc_dwarf_ctr, gcc_dwarf_ctr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(pc, "pc", gcc_dwarf_pc, gcc_dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
- { NULL, NULL, 8, 0, eEncodingUint, eFormatHex, { gcc_dwarf_cfa, gcc_dwarf_cfa, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, NULL, NULL},
+ // General purpose registers. eh_frame, DWARF, Generic, Process Plugin
+ DEFINE_GPR(r0, NULL, dwarf_r0, dwarf_r0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r1, "sp", dwarf_r1, dwarf_r1, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r2, NULL, dwarf_r2, dwarf_r2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r3, "arg1",dwarf_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r4, "arg2",dwarf_r4, dwarf_r4, LLDB_REGNUM_GENERIC_ARG2 ,LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r5, "arg3",dwarf_r5, dwarf_r5, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r6, "arg4",dwarf_r6, dwarf_r6, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r7, "arg5",dwarf_r7, dwarf_r7, LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r8, "arg6",dwarf_r8, dwarf_r8, LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r9, "arg7",dwarf_r9, dwarf_r9, LLDB_REGNUM_GENERIC_ARG7, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r10, "arg8",dwarf_r10, dwarf_r10, LLDB_REGNUM_GENERIC_ARG8, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r11, NULL, dwarf_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r12, NULL, dwarf_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r13, NULL, dwarf_r13, dwarf_r13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r14, NULL, dwarf_r14, dwarf_r14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r15, NULL, dwarf_r15, dwarf_r15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r16, NULL, dwarf_r16, dwarf_r16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r17, NULL, dwarf_r17, dwarf_r17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r18, NULL, dwarf_r18, dwarf_r18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r19, NULL, dwarf_r19, dwarf_r19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r20, NULL, dwarf_r20, dwarf_r20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r21, NULL, dwarf_r21, dwarf_r21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r22, NULL, dwarf_r22, dwarf_r22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r23, NULL, dwarf_r23, dwarf_r23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r24, NULL, dwarf_r24, dwarf_r24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r25, NULL, dwarf_r25, dwarf_r25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r26, NULL, dwarf_r26, dwarf_r26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r27, NULL, dwarf_r27, dwarf_r27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r28, NULL, dwarf_r28, dwarf_r28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r29, NULL, dwarf_r29, dwarf_r29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r30, NULL, dwarf_r30, dwarf_r30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r31, NULL, dwarf_r31, dwarf_r31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(lr, "lr", dwarf_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(cr, "cr", dwarf_cr, dwarf_cr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(xer, "xer", dwarf_xer, dwarf_xer, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(ctr, "ctr", dwarf_ctr, dwarf_ctr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(pc, "pc", dwarf_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
+ { NULL, NULL, 8, 0, eEncodingUint, eFormatHex, { dwarf_cfa, dwarf_cfa, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, NULL, NULL},
};
static const uint32_t k_num_register_infos = llvm::array_lengthof(g_register_infos);
@@ -436,25 +394,25 @@ ABISysV_ppc64::GetArgumentValues (Thread &thread,
// We currently only support extracting values with Clang QualTypes.
// Do we care about others?
- ClangASTType clang_type = value->GetClangType();
- if (!clang_type)
+ CompilerType compiler_type = value->GetCompilerType();
+ if (!compiler_type)
return false;
bool is_signed;
- if (clang_type.IsIntegerType (is_signed))
+ if (compiler_type.IsIntegerType (is_signed))
{
ReadIntegerArgument(value->GetScalar(),
- clang_type.GetBitSize(&thread),
+ compiler_type.GetBitSize(&thread),
is_signed,
thread,
argument_register_ids,
current_argument_register,
current_stack_argument);
}
- else if (clang_type.IsPointerType ())
+ else if (compiler_type.IsPointerType ())
{
ReadIntegerArgument(value->GetScalar(),
- clang_type.GetBitSize(&thread),
+ compiler_type.GetBitSize(&thread),
false,
thread,
argument_register_ids,
@@ -476,8 +434,8 @@ ABISysV_ppc64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObj
return error;
}
- ClangASTType clang_type = new_value_sp->GetClangType();
- if (!clang_type)
+ CompilerType compiler_type = new_value_sp->GetCompilerType();
+ if (!compiler_type)
{
error.SetErrorString ("Null clang type for return value.");
return error;
@@ -492,7 +450,7 @@ ABISysV_ppc64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObj
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
bool set_it_simple = false;
- if (clang_type.IsIntegerType (is_signed) || clang_type.IsPointerType())
+ if (compiler_type.IsIntegerType (is_signed) || compiler_type.IsPointerType())
{
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName("r3", 0);
@@ -518,13 +476,13 @@ ABISysV_ppc64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObj
}
}
- else if (clang_type.IsFloatingPointType (count, is_complex))
+ else if (compiler_type.IsFloatingPointType (count, is_complex))
{
if (is_complex)
error.SetErrorString ("We don't support returning complex values at present");
else
{
- size_t bit_width = clang_type.GetBitSize(frame_sp.get());
+ size_t bit_width = compiler_type.GetBitSize(frame_sp.get());
if (bit_width <= 64)
{
DataExtractor data;
@@ -563,22 +521,22 @@ ABISysV_ppc64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObj
ValueObjectSP
ABISysV_ppc64::GetReturnValueObjectSimple (Thread &thread,
- ClangASTType &return_clang_type) const
+ CompilerType &return_compiler_type) const
{
ValueObjectSP return_valobj_sp;
Value value;
- if (!return_clang_type)
+ if (!return_compiler_type)
return return_valobj_sp;
//value.SetContext (Value::eContextTypeClangType, return_value_type);
- value.SetClangType (return_clang_type);
+ value.SetCompilerType (return_compiler_type);
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
if (!reg_ctx)
return return_valobj_sp;
- const uint32_t type_flags = return_clang_type.GetTypeInfo ();
+ const uint32_t type_flags = return_compiler_type.GetTypeInfo ();
if (type_flags & eTypeIsScalar)
{
value.SetValueType(Value::eValueTypeScalar);
@@ -588,7 +546,7 @@ ABISysV_ppc64::GetReturnValueObjectSimple (Thread &thread,
{
// Extract the register context so we can read arguments from registers
- const size_t byte_size = return_clang_type.GetByteSize(nullptr);
+ const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("r3", 0), 0);
const bool is_signed = (type_flags & eTypeIsSigned) != 0;
switch (byte_size)
@@ -637,7 +595,7 @@ ABISysV_ppc64::GetReturnValueObjectSimple (Thread &thread,
}
else
{
- const size_t byte_size = return_clang_type.GetByteSize(nullptr);
+ const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
if (byte_size <= sizeof(long double))
{
const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0);
@@ -681,7 +639,7 @@ ABISysV_ppc64::GetReturnValueObjectSimple (Thread &thread,
}
else if (type_flags & eTypeIsVector)
{
- const size_t byte_size = return_clang_type.GetByteSize(nullptr);
+ const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
if (byte_size > 0)
{
@@ -709,7 +667,7 @@ ABISysV_ppc64::GetReturnValueObjectSimple (Thread &thread,
byte_order,
process_sp->GetTarget().GetArchitecture().GetAddressByteSize());
return_valobj_sp = ValueObjectConstResult::Create (&thread,
- return_clang_type,
+ return_compiler_type,
ConstString(""),
data);
}
@@ -724,15 +682,15 @@ ABISysV_ppc64::GetReturnValueObjectSimple (Thread &thread,
}
ValueObjectSP
-ABISysV_ppc64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_clang_type) const
+ABISysV_ppc64::GetReturnValueObjectImpl (Thread &thread, CompilerType &return_compiler_type) const
{
ValueObjectSP return_valobj_sp;
- if (!return_clang_type)
+ if (!return_compiler_type)
return return_valobj_sp;
ExecutionContext exe_ctx (thread.shared_from_this());
- return_valobj_sp = GetReturnValueObjectSimple(thread, return_clang_type);
+ return_valobj_sp = GetReturnValueObjectSimple(thread, return_compiler_type);
if (return_valobj_sp)
return return_valobj_sp;
@@ -740,8 +698,8 @@ ABISysV_ppc64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_cl
if (!reg_ctx_sp)
return return_valobj_sp;
- const size_t bit_width = return_clang_type.GetBitSize(&thread);
- if (return_clang_type.IsAggregateType())
+ const size_t bit_width = return_compiler_type.GetBitSize(&thread);
+ if (return_compiler_type.IsAggregateType())
{
Target *target = exe_ctx.GetTargetPtr();
bool is_memory = true;
@@ -768,7 +726,7 @@ ABISysV_ppc64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_cl
uint32_t fp_bytes = 0; // Tracks how much of the xmm registers we've consumed so far
uint32_t integer_bytes = 0; // Tracks how much of the r3/rds registers we've consumed so far
- const uint32_t num_children = return_clang_type.GetNumFields ();
+ const uint32_t num_children = return_compiler_type.GetNumFields ();
// Since we are in the small struct regime, assume we are not in memory.
is_memory = false;
@@ -781,8 +739,8 @@ ABISysV_ppc64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_cl
bool is_complex;
uint32_t count;
- ClangASTType field_clang_type = return_clang_type.GetFieldAtIndex (idx, name, &field_bit_offset, NULL, NULL);
- const size_t field_bit_width = field_clang_type.GetBitSize(&thread);
+ CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex (idx, name, &field_bit_offset, NULL, NULL);
+ const size_t field_bit_width = field_compiler_type.GetBitSize(&thread);
// If there are any unaligned fields, this is stored in memory.
if (field_bit_offset % field_bit_width != 0)
@@ -798,7 +756,7 @@ ABISysV_ppc64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_cl
DataExtractor *copy_from_extractor = NULL;
uint32_t copy_from_offset = 0;
- if (field_clang_type.IsIntegerType (is_signed) || field_clang_type.IsPointerType ())
+ if (field_compiler_type.IsIntegerType (is_signed) || field_compiler_type.IsPointerType ())
{
if (integer_bytes < 8)
{
@@ -831,7 +789,7 @@ ABISysV_ppc64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_cl
return return_valobj_sp;
}
}
- else if (field_clang_type.IsFloatingPointType (count, is_complex))
+ else if (field_compiler_type.IsFloatingPointType (count, is_complex))
{
// Structs with long doubles are always passed in memory.
if (field_bit_width == 128)
@@ -858,12 +816,12 @@ ABISysV_ppc64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_cl
else
{
uint64_t next_field_bit_offset = 0;
- ClangASTType next_field_clang_type = return_clang_type.GetFieldAtIndex (idx + 1,
+ CompilerType next_field_compiler_type = return_compiler_type.GetFieldAtIndex (idx + 1,
name,
&next_field_bit_offset,
NULL,
NULL);
- if (next_field_clang_type.IsIntegerType (is_signed))
+ if (next_field_compiler_type.IsIntegerType (is_signed))
in_gpr = true;
else
{
@@ -882,12 +840,12 @@ ABISysV_ppc64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_cl
else
{
uint64_t prev_field_bit_offset = 0;
- ClangASTType prev_field_clang_type = return_clang_type.GetFieldAtIndex (idx - 1,
+ CompilerType prev_field_compiler_type = return_compiler_type.GetFieldAtIndex (idx - 1,
name,
&prev_field_bit_offset,
NULL,
NULL);
- if (prev_field_clang_type.IsIntegerType (is_signed))
+ if (prev_field_compiler_type.IsIntegerType (is_signed))
in_gpr = true;
else
{
@@ -946,7 +904,7 @@ ABISysV_ppc64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_cl
{
// The result is in our data buffer. Let's make a variable object out of it:
return_valobj_sp = ValueObjectConstResult::Create (&thread,
- return_clang_type,
+ return_compiler_type,
ConstString(""),
return_ext);
}
@@ -965,7 +923,7 @@ ABISysV_ppc64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_cl
return_valobj_sp = ValueObjectMemory::Create (&thread,
"",
Address (storage_addr, NULL),
- return_clang_type);
+ return_compiler_type);
}
}
@@ -978,9 +936,9 @@ ABISysV_ppc64::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan)
unwind_plan.Clear();
unwind_plan.SetRegisterKind (eRegisterKindDWARF);
- uint32_t lr_reg_num = gcc_dwarf_lr;
- uint32_t sp_reg_num = gcc_dwarf_r1;
- uint32_t pc_reg_num = gcc_dwarf_pc;
+ uint32_t lr_reg_num = dwarf_lr;
+ uint32_t sp_reg_num = dwarf_r1;
+ uint32_t pc_reg_num = dwarf_pc;
UnwindPlan::RowSP row(new UnwindPlan::Row);
@@ -1005,8 +963,8 @@ ABISysV_ppc64::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan)
unwind_plan.Clear();
unwind_plan.SetRegisterKind (eRegisterKindDWARF);
- uint32_t sp_reg_num = gcc_dwarf_r1;
- uint32_t pc_reg_num = gcc_dwarf_lr;
+ uint32_t sp_reg_num = dwarf_r1;
+ uint32_t pc_reg_num = dwarf_lr;
UnwindPlan::RowSP row(new UnwindPlan::Row);
@@ -1015,13 +973,13 @@ ABISysV_ppc64::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan)
row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * 2, true);
row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true);
- row->SetRegisterLocationToAtCFAPlusOffset(gcc_dwarf_cr, ptr_size, true);
+ row->SetRegisterLocationToAtCFAPlusOffset(dwarf_cr, ptr_size, true);
unwind_plan.AppendRow (row);
unwind_plan.SetSourceName ("ppc64 default unwind plan");
unwind_plan.SetSourcedFromCompiler (eLazyBoolNo);
unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolNo);
- unwind_plan.SetReturnAddressRegister(gcc_dwarf_lr);
+ unwind_plan.SetReturnAddressRegister(dwarf_lr);
return true;
}
diff --git a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h
index d77cb9f1efe3..b87f7938d544 100644
--- a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h
+++ b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h
@@ -21,52 +21,37 @@ class ABISysV_ppc64 :
public lldb_private::ABI
{
public:
+ ~ABISysV_ppc64() override = default;
- ~ABISysV_ppc64()
- {
- }
+ size_t
+ GetRedZoneSize() const override;
- virtual size_t
- GetRedZoneSize () const;
-
- virtual bool
- PrepareTrivialCall (lldb_private::Thread &thread,
- lldb::addr_t sp,
- lldb::addr_t functionAddress,
- lldb::addr_t returnAddress,
- llvm::ArrayRef<lldb::addr_t> args) const;
+ 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;
- virtual bool
- GetArgumentValues (lldb_private::Thread &thread,
- lldb_private::ValueList &values) const;
+ bool
+ GetArgumentValues(lldb_private::Thread &thread,
+ lldb_private::ValueList &values) const override;
- virtual lldb_private::Error
- SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value);
+ lldb_private::Error
+ SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override;
-protected:
lldb::ValueObjectSP
- GetReturnValueObjectSimple (lldb_private::Thread &thread,
- lldb_private::ClangASTType &ast_type) const;
-
-public:
- virtual lldb::ValueObjectSP
- GetReturnValueObjectImpl (lldb_private::Thread &thread,
- lldb_private::ClangASTType &type) const;
+ GetReturnValueObjectImpl(lldb_private::Thread &thread,
+ lldb_private::CompilerType &type) const override;
- virtual bool
- CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
+ bool
+ CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
- virtual bool
- CreateDefaultUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
+ bool
+ CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
- virtual bool
- RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info);
-
- virtual bool
- StackUsesFrames ()
- {
- return true;
- }
+ bool
+ RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
// The SysV ppc64 ABI requires that stack frames be 16 byte aligned.
// When there is a trap handler on the stack, e.g. _sigtramp in userland
@@ -78,8 +63,8 @@ public:
// Whitelisting the trap handlers for user space would be easy (_sigtramp) but
// in other environments there can be a large number of different functions
// involved in async traps.
- virtual bool
- CallFrameAddressIsValid (lldb::addr_t cfa)
+ bool
+ CallFrameAddressIsValid(lldb::addr_t cfa) override
{
// Make sure the stack call frame addresses are 8 byte aligned
if (cfa & (8ull - 1ull))
@@ -89,25 +74,21 @@ public:
return true;
}
- virtual bool
- CodeAddressIsValid (lldb::addr_t pc)
+ 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;
}
- virtual bool
- FunctionCallsChangeCFA ()
- {
- return true;
- }
+ const lldb_private::RegisterInfo *
+ GetRegisterInfoArray(uint32_t &count) override;
- virtual const lldb_private::RegisterInfo *
- GetRegisterInfoArray (uint32_t &count);
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
+
static void
Initialize();
@@ -123,21 +104,30 @@ public:
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
- virtual lldb_private::ConstString
- GetPluginName();
- virtual uint32_t
- GetPluginVersion();
+ 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:
- ABISysV_ppc64() : lldb_private::ABI() { } // Call CreateInstance instead.
+ ABISysV_ppc64() :
+ lldb_private::ABI()
+ {
+ // Call CreateInstance instead.
+ }
};
-#endif // liblldb_ABI_h_
+#endif // liblldb_ABISysV_ppc64_h_
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 1d63628466c2..11e383d269c3 100644
--- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
+++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
@@ -20,7 +20,6 @@
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectRegister.h"
#include "lldb/Core/ValueObjectMemory.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Process.h"
@@ -34,222 +33,144 @@
using namespace lldb;
using namespace lldb_private;
-enum gcc_dwarf_regnums
+enum dwarf_regnums
{
- gcc_dwarf_rax = 0,
- gcc_dwarf_rdx,
- gcc_dwarf_rcx,
- gcc_dwarf_rbx,
- gcc_dwarf_rsi,
- gcc_dwarf_rdi,
- gcc_dwarf_rbp,
- gcc_dwarf_rsp,
- gcc_dwarf_r8,
- gcc_dwarf_r9,
- gcc_dwarf_r10,
- gcc_dwarf_r11,
- gcc_dwarf_r12,
- gcc_dwarf_r13,
- gcc_dwarf_r14,
- gcc_dwarf_r15,
- gcc_dwarf_rip,
- gcc_dwarf_xmm0,
- gcc_dwarf_xmm1,
- gcc_dwarf_xmm2,
- gcc_dwarf_xmm3,
- gcc_dwarf_xmm4,
- gcc_dwarf_xmm5,
- gcc_dwarf_xmm6,
- gcc_dwarf_xmm7,
- gcc_dwarf_xmm8,
- gcc_dwarf_xmm9,
- gcc_dwarf_xmm10,
- gcc_dwarf_xmm11,
- gcc_dwarf_xmm12,
- gcc_dwarf_xmm13,
- gcc_dwarf_xmm14,
- gcc_dwarf_xmm15,
- gcc_dwarf_stmm0,
- gcc_dwarf_stmm1,
- gcc_dwarf_stmm2,
- gcc_dwarf_stmm3,
- gcc_dwarf_stmm4,
- gcc_dwarf_stmm5,
- gcc_dwarf_stmm6,
- gcc_dwarf_stmm7,
- gcc_dwarf_ymm0,
- gcc_dwarf_ymm1,
- gcc_dwarf_ymm2,
- gcc_dwarf_ymm3,
- gcc_dwarf_ymm4,
- gcc_dwarf_ymm5,
- gcc_dwarf_ymm6,
- gcc_dwarf_ymm7,
- gcc_dwarf_ymm8,
- gcc_dwarf_ymm9,
- gcc_dwarf_ymm10,
- gcc_dwarf_ymm11,
- gcc_dwarf_ymm12,
- gcc_dwarf_ymm13,
- gcc_dwarf_ymm14,
- gcc_dwarf_ymm15
+ 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
};
-enum gdb_regnums
-{
- gdb_rax = 0,
- gdb_rbx = 1,
- gdb_rcx = 2,
- gdb_rdx = 3,
- gdb_rsi = 4,
- gdb_rdi = 5,
- gdb_rbp = 6,
- gdb_rsp = 7,
- gdb_r8 = 8,
- gdb_r9 = 9,
- gdb_r10 = 10,
- gdb_r11 = 11,
- gdb_r12 = 12,
- gdb_r13 = 13,
- gdb_r14 = 14,
- gdb_r15 = 15,
- gdb_rip = 16,
- gdb_rflags = 17,
- gdb_cs = 18,
- gdb_ss = 19,
- gdb_ds = 20,
- gdb_es = 21,
- gdb_fs = 22,
- gdb_gs = 23,
- gdb_stmm0 = 24,
- gdb_stmm1 = 25,
- gdb_stmm2 = 26,
- gdb_stmm3 = 27,
- gdb_stmm4 = 28,
- gdb_stmm5 = 29,
- gdb_stmm6 = 30,
- gdb_stmm7 = 31,
- gdb_fctrl = 32, gdb_fcw = gdb_fctrl,
- gdb_fstat = 33, gdb_fsw = gdb_fstat,
- gdb_ftag = 34, gdb_ftw = gdb_ftag,
- gdb_fiseg = 35, gdb_fpu_cs = gdb_fiseg,
- gdb_fioff = 36, gdb_ip = gdb_fioff,
- gdb_foseg = 37, gdb_fpu_ds = gdb_foseg,
- gdb_fooff = 38, gdb_dp = gdb_fooff,
- gdb_fop = 39,
- gdb_xmm0 = 40,
- gdb_xmm1 = 41,
- gdb_xmm2 = 42,
- gdb_xmm3 = 43,
- gdb_xmm4 = 44,
- gdb_xmm5 = 45,
- gdb_xmm6 = 46,
- gdb_xmm7 = 47,
- gdb_xmm8 = 48,
- gdb_xmm9 = 49,
- gdb_xmm10 = 50,
- gdb_xmm11 = 51,
- gdb_xmm12 = 52,
- gdb_xmm13 = 53,
- gdb_xmm14 = 54,
- gdb_xmm15 = 55,
- gdb_mxcsr = 56,
- gdb_ymm0 = 57,
- gdb_ymm1 = 58,
- gdb_ymm2 = 59,
- gdb_ymm3 = 60,
- gdb_ymm4 = 61,
- gdb_ymm5 = 62,
- gdb_ymm6 = 63,
- gdb_ymm7 = 64,
- gdb_ymm8 = 65,
- gdb_ymm9 = 66,
- gdb_ymm10 = 67,
- gdb_ymm11 = 68,
- gdb_ymm12 = 69,
- gdb_ymm13 = 70,
- gdb_ymm14 = 71,
- gdb_ymm15 = 72
-};
-
-
static RegisterInfo g_register_infos[] =
{
- // NAME ALT SZ OFF ENCODING FORMAT COMPILER DWARF GENERIC GDB LLDB NATIVE VALUE REGS INVALIDATE REGS
+ // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB NATIVE VALUE REGS INVALIDATE REGS
// ======== ======= == === ============= =================== ======================= ===================== =========================== ===================== ====================== ========== ===============
- { "rax" , NULL, 8, 0, eEncodingUint , eFormatHex , { gcc_dwarf_rax , gcc_dwarf_rax , LLDB_INVALID_REGNUM , gdb_rax , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "rbx" , NULL, 8, 0, eEncodingUint , eFormatHex , { gcc_dwarf_rbx , gcc_dwarf_rbx , LLDB_INVALID_REGNUM , gdb_rbx , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "rcx" , "arg4", 8, 0, eEncodingUint , eFormatHex , { gcc_dwarf_rcx , gcc_dwarf_rcx , LLDB_REGNUM_GENERIC_ARG4 , gdb_rcx , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "rdx" , "arg3", 8, 0, eEncodingUint , eFormatHex , { gcc_dwarf_rdx , gcc_dwarf_rdx , LLDB_REGNUM_GENERIC_ARG3 , gdb_rdx , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "rsi" , "arg2", 8, 0, eEncodingUint , eFormatHex , { gcc_dwarf_rsi , gcc_dwarf_rsi , LLDB_REGNUM_GENERIC_ARG2 , gdb_rsi , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "rdi" , "arg1", 8, 0, eEncodingUint , eFormatHex , { gcc_dwarf_rdi , gcc_dwarf_rdi , LLDB_REGNUM_GENERIC_ARG1 , gdb_rdi , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "rbp" , "fp", 8, 0, eEncodingUint , eFormatHex , { gcc_dwarf_rbp , gcc_dwarf_rbp , LLDB_REGNUM_GENERIC_FP , gdb_rbp , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "rsp" , "sp", 8, 0, eEncodingUint , eFormatHex , { gcc_dwarf_rsp , gcc_dwarf_rsp , LLDB_REGNUM_GENERIC_SP , gdb_rsp , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r8" , "arg5", 8, 0, eEncodingUint , eFormatHex , { gcc_dwarf_r8 , gcc_dwarf_r8 , LLDB_REGNUM_GENERIC_ARG5 , gdb_r8 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r9" , "arg6", 8, 0, eEncodingUint , eFormatHex , { gcc_dwarf_r9 , gcc_dwarf_r9 , LLDB_REGNUM_GENERIC_ARG6 , gdb_r9 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r10" , NULL, 8, 0, eEncodingUint , eFormatHex , { gcc_dwarf_r10 , gcc_dwarf_r10 , LLDB_INVALID_REGNUM , gdb_r10 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r11" , NULL, 8, 0, eEncodingUint , eFormatHex , { gcc_dwarf_r11 , gcc_dwarf_r11 , LLDB_INVALID_REGNUM , gdb_r11 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r12" , NULL, 8, 0, eEncodingUint , eFormatHex , { gcc_dwarf_r12 , gcc_dwarf_r12 , LLDB_INVALID_REGNUM , gdb_r12 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r13" , NULL, 8, 0, eEncodingUint , eFormatHex , { gcc_dwarf_r13 , gcc_dwarf_r13 , LLDB_INVALID_REGNUM , gdb_r13 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r14" , NULL, 8, 0, eEncodingUint , eFormatHex , { gcc_dwarf_r14 , gcc_dwarf_r14 , LLDB_INVALID_REGNUM , gdb_r14 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "r15" , NULL, 8, 0, eEncodingUint , eFormatHex , { gcc_dwarf_r15 , gcc_dwarf_r15 , LLDB_INVALID_REGNUM , gdb_r15 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "rip" , "pc", 8, 0, eEncodingUint , eFormatHex , { gcc_dwarf_rip , gcc_dwarf_rip , LLDB_REGNUM_GENERIC_PC , gdb_rip , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "rflags", NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_REGNUM_GENERIC_FLAGS , gdb_rflags , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "cs" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_cs , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ss" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ss , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ds" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ds , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "es" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_es , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "fs" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fs , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "gs" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_gs , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "stmm0" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_stmm0 , gcc_dwarf_stmm0 , LLDB_INVALID_REGNUM , gdb_stmm0 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "stmm1" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_stmm1 , gcc_dwarf_stmm1 , LLDB_INVALID_REGNUM , gdb_stmm1 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "stmm2" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_stmm2 , gcc_dwarf_stmm2 , LLDB_INVALID_REGNUM , gdb_stmm2 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "stmm3" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_stmm3 , gcc_dwarf_stmm3 , LLDB_INVALID_REGNUM , gdb_stmm3 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "stmm4" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_stmm4 , gcc_dwarf_stmm4 , LLDB_INVALID_REGNUM , gdb_stmm4 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "stmm5" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_stmm5 , gcc_dwarf_stmm5 , LLDB_INVALID_REGNUM , gdb_stmm5 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "stmm6" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_stmm6 , gcc_dwarf_stmm6 , LLDB_INVALID_REGNUM , gdb_stmm6 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "stmm7" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_stmm7 , gcc_dwarf_stmm7 , LLDB_INVALID_REGNUM , gdb_stmm7 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "fctrl" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fctrl , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "fstat" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fstat , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ftag" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ftag , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "fiseg" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fiseg , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "fioff" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fioff , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "foseg" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_foseg , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "fooff" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fooff , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "fop" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fop , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm0" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_xmm0 , gcc_dwarf_xmm0 , LLDB_INVALID_REGNUM , gdb_xmm0 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm1" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_xmm1 , gcc_dwarf_xmm1 , LLDB_INVALID_REGNUM , gdb_xmm1 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm2" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_xmm2 , gcc_dwarf_xmm2 , LLDB_INVALID_REGNUM , gdb_xmm2 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm3" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_xmm3 , gcc_dwarf_xmm3 , LLDB_INVALID_REGNUM , gdb_xmm3 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm4" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_xmm4 , gcc_dwarf_xmm4 , LLDB_INVALID_REGNUM , gdb_xmm4 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm5" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_xmm5 , gcc_dwarf_xmm5 , LLDB_INVALID_REGNUM , gdb_xmm5 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm6" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_xmm6 , gcc_dwarf_xmm6 , LLDB_INVALID_REGNUM , gdb_xmm6 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm7" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_xmm7 , gcc_dwarf_xmm7 , LLDB_INVALID_REGNUM , gdb_xmm7 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm8" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_xmm8 , gcc_dwarf_xmm8 , LLDB_INVALID_REGNUM , gdb_xmm8 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm9" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_xmm9 , gcc_dwarf_xmm9 , LLDB_INVALID_REGNUM , gdb_xmm9 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm10" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_xmm10 , gcc_dwarf_xmm10 , LLDB_INVALID_REGNUM , gdb_xmm10 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm11" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_xmm11 , gcc_dwarf_xmm11 , LLDB_INVALID_REGNUM , gdb_xmm11 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm12" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_xmm12 , gcc_dwarf_xmm12 , LLDB_INVALID_REGNUM , gdb_xmm12 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm13" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_xmm13 , gcc_dwarf_xmm13 , LLDB_INVALID_REGNUM , gdb_xmm13 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm14" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_xmm14 , gcc_dwarf_xmm14 , LLDB_INVALID_REGNUM , gdb_xmm14 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "xmm15" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_xmm15 , gcc_dwarf_xmm15 , LLDB_INVALID_REGNUM , gdb_xmm15 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "mxcsr" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_mxcsr , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm0" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_ymm0 , gcc_dwarf_ymm0 , LLDB_INVALID_REGNUM , gdb_ymm0 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm1" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_ymm1 , gcc_dwarf_ymm1 , LLDB_INVALID_REGNUM , gdb_ymm1 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm2" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_ymm2 , gcc_dwarf_ymm2 , LLDB_INVALID_REGNUM , gdb_ymm2 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm3" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_ymm3 , gcc_dwarf_ymm3 , LLDB_INVALID_REGNUM , gdb_ymm3 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm4" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_ymm4 , gcc_dwarf_ymm4 , LLDB_INVALID_REGNUM , gdb_ymm4 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm5" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_ymm5 , gcc_dwarf_ymm5 , LLDB_INVALID_REGNUM , gdb_ymm5 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm6" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_ymm6 , gcc_dwarf_ymm6 , LLDB_INVALID_REGNUM , gdb_ymm6 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm7" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_ymm7 , gcc_dwarf_ymm7 , LLDB_INVALID_REGNUM , gdb_ymm7 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm8" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_ymm8 , gcc_dwarf_ymm8 , LLDB_INVALID_REGNUM , gdb_ymm8 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm9" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_ymm9 , gcc_dwarf_ymm9 , LLDB_INVALID_REGNUM , gdb_ymm9 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm10" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_ymm10 , gcc_dwarf_ymm10 , LLDB_INVALID_REGNUM , gdb_ymm10 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm11" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_ymm11 , gcc_dwarf_ymm11 , LLDB_INVALID_REGNUM , gdb_ymm11 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm12" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_ymm12 , gcc_dwarf_ymm12 , LLDB_INVALID_REGNUM , gdb_ymm12 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm13" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_ymm13 , gcc_dwarf_ymm13 , LLDB_INVALID_REGNUM , gdb_ymm13 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm14" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_ymm14 , gcc_dwarf_ymm14 , LLDB_INVALID_REGNUM , gdb_ymm14 , LLDB_INVALID_REGNUM }, NULL, NULL},
- { "ymm15" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_ymm15 , gcc_dwarf_ymm15 , LLDB_INVALID_REGNUM , gdb_ymm15 , LLDB_INVALID_REGNUM }, NULL, NULL}
+ { "rax" , NULL, 8, 0, eEncodingUint , eFormatHex , { dwarf_rax , dwarf_rax , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "rbx" , NULL, 8, 0, eEncodingUint , eFormatHex , { dwarf_rbx , dwarf_rbx , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "rcx" , "arg4", 8, 0, eEncodingUint , eFormatHex , { dwarf_rcx , dwarf_rcx , LLDB_REGNUM_GENERIC_ARG4 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "rdx" , "arg3", 8, 0, eEncodingUint , eFormatHex , { dwarf_rdx , dwarf_rdx , LLDB_REGNUM_GENERIC_ARG3 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "rsi" , "arg2", 8, 0, eEncodingUint , eFormatHex , { dwarf_rsi , dwarf_rsi , LLDB_REGNUM_GENERIC_ARG2 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "rdi" , "arg1", 8, 0, eEncodingUint , eFormatHex , { dwarf_rdi , dwarf_rdi , LLDB_REGNUM_GENERIC_ARG1 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "rbp" , "fp", 8, 0, eEncodingUint , eFormatHex , { dwarf_rbp , dwarf_rbp , LLDB_REGNUM_GENERIC_FP , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "rsp" , "sp", 8, 0, eEncodingUint , eFormatHex , { dwarf_rsp , dwarf_rsp , LLDB_REGNUM_GENERIC_SP , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r8" , "arg5", 8, 0, eEncodingUint , eFormatHex , { dwarf_r8 , dwarf_r8 , LLDB_REGNUM_GENERIC_ARG5 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r9" , "arg6", 8, 0, eEncodingUint , eFormatHex , { dwarf_r9 , dwarf_r9 , LLDB_REGNUM_GENERIC_ARG6 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r10" , NULL, 8, 0, eEncodingUint , eFormatHex , { dwarf_r10 , dwarf_r10 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r11" , NULL, 8, 0, eEncodingUint , eFormatHex , { dwarf_r11 , dwarf_r11 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r12" , NULL, 8, 0, eEncodingUint , eFormatHex , { dwarf_r12 , dwarf_r12 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r13" , NULL, 8, 0, eEncodingUint , eFormatHex , { dwarf_r13 , dwarf_r13 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r14" , NULL, 8, 0, eEncodingUint , eFormatHex , { dwarf_r14 , dwarf_r14 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "r15" , NULL, 8, 0, eEncodingUint , eFormatHex , { dwarf_r15 , dwarf_r15 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "rip" , "pc", 8, 0, eEncodingUint , eFormatHex , { dwarf_rip , dwarf_rip , LLDB_REGNUM_GENERIC_PC , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "rflags", NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_REGNUM_GENERIC_FLAGS , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "cs" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ss" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ds" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "es" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "fs" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "gs" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "stmm0" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_stmm0 , dwarf_stmm0 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "stmm1" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_stmm1 , dwarf_stmm1 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "stmm2" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_stmm2 , dwarf_stmm2 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "stmm3" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_stmm3 , dwarf_stmm3 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "stmm4" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_stmm4 , dwarf_stmm4 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "stmm5" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_stmm5 , dwarf_stmm5 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "stmm6" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_stmm6 , dwarf_stmm6 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "stmm7" , NULL, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_stmm7 , dwarf_stmm7 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "fctrl" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "fstat" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ftag" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "fiseg" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "fioff" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "foseg" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "fooff" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "fop" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm0" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm0 , dwarf_xmm0 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm1" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm1 , dwarf_xmm1 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm2" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm2 , dwarf_xmm2 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm3" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm3 , dwarf_xmm3 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm4" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm4 , dwarf_xmm4 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm5" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm5 , dwarf_xmm5 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm6" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm6 , dwarf_xmm6 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm7" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm7 , dwarf_xmm7 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm8" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm8 , dwarf_xmm8 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm9" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm9 , dwarf_xmm9 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm10" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm10 , dwarf_xmm10 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm11" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm11 , dwarf_xmm11 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm12" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm12 , dwarf_xmm12 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm13" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm13 , dwarf_xmm13 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm14" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm14 , dwarf_xmm14 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "xmm15" , NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm15 , dwarf_xmm15 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "mxcsr" , NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm0" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm0 , dwarf_ymm0 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm1" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm1 , dwarf_ymm1 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm2" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm2 , dwarf_ymm2 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm3" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm3 , dwarf_ymm3 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm4" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm4 , dwarf_ymm4 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm5" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm5 , dwarf_ymm5 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm6" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm6 , dwarf_ymm6 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm7" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm7 , dwarf_ymm7 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm8" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm8 , dwarf_ymm8 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm9" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm9 , dwarf_ymm9 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm10" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm10 , dwarf_ymm10 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm11" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm11 , dwarf_ymm11 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm12" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm12 , dwarf_ymm12 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm13" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm13 , dwarf_ymm13 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm14" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm14 , dwarf_ymm14 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL},
+ { "ymm15" , NULL, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm15 , dwarf_ymm15 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL}
};
static const uint32_t k_num_register_infos = llvm::array_lengthof(g_register_infos);
@@ -502,25 +423,25 @@ ABISysV_x86_64::GetArgumentValues (Thread &thread,
// We currently only support extracting values with Clang QualTypes.
// Do we care about others?
- ClangASTType clang_type = value->GetClangType();
- if (!clang_type)
+ CompilerType compiler_type = value->GetCompilerType();
+ if (!compiler_type)
return false;
bool is_signed;
- if (clang_type.IsIntegerType (is_signed))
+ if (compiler_type.IsIntegerType (is_signed))
{
ReadIntegerArgument(value->GetScalar(),
- clang_type.GetBitSize(&thread),
+ compiler_type.GetBitSize(&thread),
is_signed,
thread,
argument_register_ids,
current_argument_register,
current_stack_argument);
}
- else if (clang_type.IsPointerType ())
+ else if (compiler_type.IsPointerType ())
{
ReadIntegerArgument(value->GetScalar(),
- clang_type.GetBitSize(&thread),
+ compiler_type.GetBitSize(&thread),
false,
thread,
argument_register_ids,
@@ -542,8 +463,8 @@ ABISysV_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueOb
return error;
}
- ClangASTType clang_type = new_value_sp->GetClangType();
- if (!clang_type)
+ CompilerType compiler_type = new_value_sp->GetCompilerType();
+ if (!compiler_type)
{
error.SetErrorString ("Null clang type for return value.");
return error;
@@ -558,7 +479,7 @@ ABISysV_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueOb
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
bool set_it_simple = false;
- if (clang_type.IsIntegerType (is_signed) || clang_type.IsPointerType())
+ if (compiler_type.IsIntegerType (is_signed) || compiler_type.IsPointerType())
{
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName("rax", 0);
@@ -584,13 +505,13 @@ ABISysV_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueOb
}
}
- else if (clang_type.IsFloatingPointType (count, is_complex))
+ else if (compiler_type.IsFloatingPointType (count, is_complex))
{
if (is_complex)
error.SetErrorString ("We don't support returning complex values at present");
else
{
- size_t bit_width = clang_type.GetBitSize(frame_sp.get());
+ size_t bit_width = compiler_type.GetBitSize(frame_sp.get());
if (bit_width <= 64)
{
const RegisterInfo *xmm0_info = reg_ctx->GetRegisterInfoByName("xmm0", 0);
@@ -633,22 +554,22 @@ ABISysV_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueOb
ValueObjectSP
ABISysV_x86_64::GetReturnValueObjectSimple (Thread &thread,
- ClangASTType &return_clang_type) const
+ CompilerType &return_compiler_type) const
{
ValueObjectSP return_valobj_sp;
Value value;
- if (!return_clang_type)
+ if (!return_compiler_type)
return return_valobj_sp;
//value.SetContext (Value::eContextTypeClangType, return_value_type);
- value.SetClangType (return_clang_type);
+ value.SetCompilerType (return_compiler_type);
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
if (!reg_ctx)
return return_valobj_sp;
- const uint32_t type_flags = return_clang_type.GetTypeInfo ();
+ const uint32_t type_flags = return_compiler_type.GetTypeInfo ();
if (type_flags & eTypeIsScalar)
{
value.SetValueType(Value::eValueTypeScalar);
@@ -658,7 +579,7 @@ ABISysV_x86_64::GetReturnValueObjectSimple (Thread &thread,
{
// Extract the register context so we can read arguments from registers
- const size_t byte_size = return_clang_type.GetByteSize(nullptr);
+ const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("rax", 0), 0);
const bool is_signed = (type_flags & eTypeIsSigned) != 0;
switch (byte_size)
@@ -707,7 +628,7 @@ ABISysV_x86_64::GetReturnValueObjectSimple (Thread &thread,
}
else
{
- const size_t byte_size = return_clang_type.GetByteSize(nullptr);
+ const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
if (byte_size <= sizeof(long double))
{
const RegisterInfo *xmm0_info = reg_ctx->GetRegisterInfoByName("xmm0", 0);
@@ -755,18 +676,13 @@ ABISysV_x86_64::GetReturnValueObjectSimple (Thread &thread,
}
else if (type_flags & eTypeIsVector)
{
- const size_t byte_size = return_clang_type.GetByteSize(nullptr);
+ const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
if (byte_size > 0)
{
+ const RegisterInfo *altivec_reg = reg_ctx->GetRegisterInfoByName("xmm0", 0);
+ if (altivec_reg == nullptr)
+ altivec_reg = reg_ctx->GetRegisterInfoByName("mm0", 0);
- const RegisterInfo *altivec_reg = reg_ctx->GetRegisterInfoByName("ymm0", 0);
- if (altivec_reg == NULL)
- {
- altivec_reg = reg_ctx->GetRegisterInfoByName("xmm0", 0);
- if (altivec_reg == NULL)
- altivec_reg = reg_ctx->GetRegisterInfoByName("mm0", 0);
- }
-
if (altivec_reg)
{
if (byte_size <= altivec_reg->byte_size)
@@ -790,13 +706,52 @@ ABISysV_x86_64::GetReturnValueObjectSimple (Thread &thread,
byte_order,
process_sp->GetTarget().GetArchitecture().GetAddressByteSize());
return_valobj_sp = ValueObjectConstResult::Create (&thread,
- return_clang_type,
+ return_compiler_type,
ConstString(""),
data);
}
}
}
}
+ else if (byte_size <= altivec_reg->byte_size*2)
+ {
+ const RegisterInfo *altivec_reg2 = reg_ctx->GetRegisterInfoByName("xmm1", 0);
+ if (altivec_reg2)
+ {
+ ProcessSP process_sp (thread.GetProcess());
+ if (process_sp)
+ {
+ std::unique_ptr<DataBufferHeap> heap_data_ap (new DataBufferHeap(byte_size, 0));
+ const ByteOrder byte_order = process_sp->GetByteOrder();
+ RegisterValue reg_value;
+ RegisterValue reg_value2;
+ if (reg_ctx->ReadRegister(altivec_reg, reg_value) && reg_ctx->ReadRegister(altivec_reg2, reg_value2))
+ {
+
+ Error error;
+ if (reg_value.GetAsMemoryData (altivec_reg,
+ heap_data_ap->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,
+ byte_order,
+ error))
+ {
+ DataExtractor data (DataBufferSP (heap_data_ap.release()),
+ byte_order,
+ process_sp->GetTarget().GetArchitecture().GetAddressByteSize());
+ return_valobj_sp = ValueObjectConstResult::Create (&thread,
+ return_compiler_type,
+ ConstString(""),
+ data);
+ }
+ }
+ }
+ }
+ }
}
}
}
@@ -805,15 +760,15 @@ ABISysV_x86_64::GetReturnValueObjectSimple (Thread &thread,
}
ValueObjectSP
-ABISysV_x86_64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_clang_type) const
+ABISysV_x86_64::GetReturnValueObjectImpl (Thread &thread, CompilerType &return_compiler_type) const
{
ValueObjectSP return_valobj_sp;
- if (!return_clang_type)
+ if (!return_compiler_type)
return return_valobj_sp;
ExecutionContext exe_ctx (thread.shared_from_this());
- return_valobj_sp = GetReturnValueObjectSimple(thread, return_clang_type);
+ return_valobj_sp = GetReturnValueObjectSimple(thread, return_compiler_type);
if (return_valobj_sp)
return return_valobj_sp;
@@ -821,8 +776,8 @@ ABISysV_x86_64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_c
if (!reg_ctx_sp)
return return_valobj_sp;
- const size_t bit_width = return_clang_type.GetBitSize(&thread);
- if (return_clang_type.IsAggregateType())
+ const size_t bit_width = return_compiler_type.GetBitSize(&thread);
+ if (return_compiler_type.IsAggregateType())
{
Target *target = exe_ctx.GetTargetPtr();
bool is_memory = true;
@@ -855,7 +810,7 @@ ABISysV_x86_64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_c
uint32_t fp_bytes = 0; // Tracks how much of the xmm registers we've consumed so far
uint32_t integer_bytes = 0; // Tracks how much of the rax/rds registers we've consumed so far
- const uint32_t num_children = return_clang_type.GetNumFields ();
+ const uint32_t num_children = return_compiler_type.GetNumFields ();
// Since we are in the small struct regime, assume we are not in memory.
is_memory = false;
@@ -868,8 +823,8 @@ ABISysV_x86_64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_c
bool is_complex;
uint32_t count;
- ClangASTType field_clang_type = return_clang_type.GetFieldAtIndex (idx, name, &field_bit_offset, NULL, NULL);
- const size_t field_bit_width = field_clang_type.GetBitSize(&thread);
+ CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex (idx, name, &field_bit_offset, NULL, NULL);
+ const size_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 == 0)
@@ -889,7 +844,7 @@ ABISysV_x86_64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_c
DataExtractor *copy_from_extractor = NULL;
uint32_t copy_from_offset = 0;
- if (field_clang_type.IsIntegerType (is_signed) || field_clang_type.IsPointerType ())
+ if (field_compiler_type.IsIntegerType (is_signed) || field_compiler_type.IsPointerType ())
{
if (integer_bytes < 8)
{
@@ -922,7 +877,7 @@ ABISysV_x86_64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_c
return return_valobj_sp;
}
}
- else if (field_clang_type.IsFloatingPointType (count, is_complex))
+ else if (field_compiler_type.IsFloatingPointType (count, is_complex))
{
// Structs with long doubles are always passed in memory.
if (field_bit_width == 128)
@@ -955,12 +910,12 @@ ABISysV_x86_64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_c
else
{
uint64_t next_field_bit_offset = 0;
- ClangASTType next_field_clang_type = return_clang_type.GetFieldAtIndex (idx + 1,
+ CompilerType next_field_compiler_type = return_compiler_type.GetFieldAtIndex (idx + 1,
name,
&next_field_bit_offset,
NULL,
NULL);
- if (next_field_clang_type.IsIntegerType (is_signed))
+ if (next_field_compiler_type.IsIntegerType (is_signed))
in_gpr = true;
else
{
@@ -979,12 +934,12 @@ ABISysV_x86_64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_c
else
{
uint64_t prev_field_bit_offset = 0;
- ClangASTType prev_field_clang_type = return_clang_type.GetFieldAtIndex (idx - 1,
+ CompilerType prev_field_compiler_type = return_compiler_type.GetFieldAtIndex (idx - 1,
name,
&prev_field_bit_offset,
NULL,
NULL);
- if (prev_field_clang_type.IsIntegerType (is_signed))
+ if (prev_field_compiler_type.IsIntegerType (is_signed))
in_gpr = true;
else
{
@@ -1048,7 +1003,7 @@ ABISysV_x86_64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_c
{
// The result is in our data buffer. Let's make a variable object out of it:
return_valobj_sp = ValueObjectConstResult::Create (&thread,
- return_clang_type,
+ return_compiler_type,
ConstString(""),
return_ext);
}
@@ -1067,7 +1022,7 @@ ABISysV_x86_64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_c
return_valobj_sp = ValueObjectMemory::Create (&thread,
"",
Address (storage_addr, NULL),
- return_clang_type);
+ return_compiler_type);
}
}
@@ -1084,8 +1039,8 @@ ABISysV_x86_64::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan)
unwind_plan.Clear();
unwind_plan.SetRegisterKind (eRegisterKindDWARF);
- uint32_t sp_reg_num = gcc_dwarf_rsp;
- uint32_t pc_reg_num = gcc_dwarf_rip;
+ 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);
@@ -1108,14 +1063,14 @@ ABISysV_x86_64::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan)
unwind_plan.Clear();
unwind_plan.SetRegisterKind (eRegisterKindDWARF);
- uint32_t fp_reg_num = gcc_dwarf_rbp;
- uint32_t sp_reg_num = gcc_dwarf_rsp;
- uint32_t pc_reg_num = gcc_dwarf_rip;
+ 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(gcc_dwarf_rbp, 2 * ptr_size);
+ row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_rbp, 2 * ptr_size);
row->SetOffset (0);
row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true);
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 6fefcc2a9c74..07b57abaf57c 100644
--- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h
+++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h
@@ -21,46 +21,37 @@ class ABISysV_x86_64 :
public lldb_private::ABI
{
public:
+ ~ABISysV_x86_64() override = default;
- ~ABISysV_x86_64()
- {
- }
-
- virtual size_t
- GetRedZoneSize () const;
+ size_t
+ GetRedZoneSize() const override;
- virtual bool
- PrepareTrivialCall (lldb_private::Thread &thread,
- lldb::addr_t sp,
- lldb::addr_t functionAddress,
- lldb::addr_t returnAddress,
- llvm::ArrayRef<lldb::addr_t> args) const;
+ 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;
- virtual bool
- GetArgumentValues (lldb_private::Thread &thread,
- lldb_private::ValueList &values) const;
+ bool
+ GetArgumentValues(lldb_private::Thread &thread,
+ lldb_private::ValueList &values) const override;
- virtual lldb_private::Error
- SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value);
+ lldb_private::Error
+ SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override;
-protected:
lldb::ValueObjectSP
- GetReturnValueObjectSimple (lldb_private::Thread &thread,
- lldb_private::ClangASTType &ast_type) const;
-
-public:
- virtual lldb::ValueObjectSP
- GetReturnValueObjectImpl (lldb_private::Thread &thread,
- lldb_private::ClangASTType &type) const;
+ GetReturnValueObjectImpl(lldb_private::Thread &thread,
+ lldb_private::CompilerType &type) const override;
- virtual bool
- CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
+ bool
+ CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
- virtual bool
- CreateDefaultUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
+ bool
+ CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
- virtual bool
- RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info);
+ bool
+ RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
// The SysV x86_64 ABI requires that stack frames be 16 byte aligned.
// When there is a trap handler on the stack, e.g. _sigtramp in userland
@@ -72,8 +63,8 @@ public:
// Whitelisting the trap handlers for user space would be easy (_sigtramp) but
// in other environments there can be a large number of different functions
// involved in async traps.
- virtual bool
- CallFrameAddressIsValid (lldb::addr_t cfa)
+ bool
+ CallFrameAddressIsValid(lldb::addr_t cfa) override
{
// Make sure the stack call frame addresses are 8 byte aligned
if (cfa & (8ull - 1ull))
@@ -83,19 +74,21 @@ public:
return true;
}
- virtual bool
- CodeAddressIsValid (lldb::addr_t pc)
+ 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;
}
- virtual const lldb_private::RegisterInfo *
- GetRegisterInfoArray (uint32_t &count);
+ const lldb_private::RegisterInfo *
+ GetRegisterInfoArray(uint32_t &count) override;
+
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
+
static void
Initialize();
@@ -111,21 +104,30 @@ public:
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
- virtual lldb_private::ConstString
- GetPluginName();
- virtual uint32_t
- GetPluginVersion();
+ 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:
- ABISysV_x86_64() : lldb_private::ABI() { } // Call CreateInstance instead.
+ ABISysV_x86_64() :
+ lldb_private::ABI()
+ {
+ // Call CreateInstance instead.
+ }
};
-#endif // liblldb_ABI_h_
+#endif // liblldb_ABISysV_x86_64_h_
diff --git a/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp b/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
index d20219f6d1eb..6d124b689341 100644
--- a/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
+++ b/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
@@ -7,8 +7,9 @@
//
//===----------------------------------------------------------------------===//
-#include "DisassemblerLLVMC.h"
-
+// C Includes
+// C++ Includes
+// Project includes
#include "llvm-c/Disassembler.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
@@ -25,6 +26,8 @@
#include "llvm/Support/TargetSelect.h"
#include "llvm/ADT/SmallString.h"
+// Other libraries and framework includes
+#include "DisassemblerLLVMC.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/DataExtractor.h"
@@ -52,18 +55,16 @@ public:
Instruction (address, addr_class),
m_disasm_sp (disasm.shared_from_this()),
m_does_branch (eLazyBoolCalculate),
+ m_has_delay_slot (eLazyBoolCalculate),
m_is_valid (false),
m_using_file_addr (false)
{
}
- virtual
- ~InstructionLLVMC ()
- {
- }
+ ~InstructionLLVMC() override = default;
- virtual bool
- DoesBranch ()
+ bool
+ DoesBranch() override
{
if (m_does_branch == eLazyBoolCalculate)
{
@@ -99,6 +100,43 @@ public:
return m_does_branch == eLazyBoolYes;
}
+ bool
+ HasDelaySlot() override
+ {
+ if (m_has_delay_slot == eLazyBoolCalculate)
+ {
+ GetDisassemblerLLVMC().Lock(this, NULL);
+ DataExtractor data;
+ if (m_opcode.GetData(data))
+ {
+ bool is_alternate_isa;
+ lldb::addr_t pc = m_address.GetFileAddress();
+
+ DisassemblerLLVMC::LLVMCDisassembler *mc_disasm_ptr = GetDisasmToUse (is_alternate_isa);
+ const uint8_t *opcode_data = data.GetDataStart();
+ const size_t opcode_data_len = data.GetByteSize();
+ llvm::MCInst inst;
+ const size_t inst_size = mc_disasm_ptr->GetMCInst (opcode_data,
+ opcode_data_len,
+ pc,
+ inst);
+ // if we didn't understand the instruction, say it doesn't have a delay slot...
+ if (inst_size == 0)
+ m_has_delay_slot = eLazyBoolNo;
+ else
+ {
+ const bool has_delay_slot = mc_disasm_ptr->HasDelaySlot(inst);
+ if (has_delay_slot)
+ m_has_delay_slot = eLazyBoolYes;
+ else
+ m_has_delay_slot = eLazyBoolNo;
+ }
+ }
+ GetDisassemblerLLVMC().Unlock();
+ }
+ return m_has_delay_slot == eLazyBoolYes;
+ }
+
DisassemblerLLVMC::LLVMCDisassembler *
GetDisasmToUse (bool &is_alternate_isa)
{
@@ -117,10 +155,10 @@ public:
return llvm_disasm.m_disasm_ap.get();
}
- virtual size_t
- Decode (const lldb_private::Disassembler &disassembler,
- const lldb_private::DataExtractor &data,
- lldb::offset_t data_offset)
+ size_t
+ Decode(const lldb_private::Disassembler &disassembler,
+ const lldb_private::DataExtractor &data,
+ lldb::offset_t data_offset) override
{
// All we have to do is read the opcode which can be easy for some
// architectures
@@ -234,15 +272,16 @@ public:
}
}
- virtual void
- CalculateMnemonicOperandsAndComment (const lldb_private::ExecutionContext *exe_ctx)
+ void
+ CalculateMnemonicOperandsAndComment(const lldb_private::ExecutionContext *exe_ctx) override
{
DataExtractor data;
const AddressClass address_class = GetAddressClass ();
if (m_opcode.GetData(data))
{
- char out_string[512];
+ std::string out_string;
+ std::string comment_string;
DisassemblerLLVMC &llvm_disasm = GetDisassemblerLLVMC();
@@ -293,7 +332,12 @@ public:
if (inst_size > 0)
{
mc_disasm_ptr->SetStyle(use_hex_immediates, hex_style);
- mc_disasm_ptr->PrintMCInst(inst, out_string, sizeof(out_string));
+ mc_disasm_ptr->PrintMCInst(inst, out_string, comment_string);
+
+ if (!comment_string.empty())
+ {
+ AppendComment(comment_string);
+ }
}
llvm_disasm.Unlock();
@@ -375,10 +419,10 @@ public:
RegularExpression::Match matches(3);
- if (s_regex.Execute(out_string, &matches))
+ if (s_regex.Execute(out_string.c_str(), &matches))
{
- matches.GetMatchAtIndex(out_string, 1, m_opcode_name);
- matches.GetMatchAtIndex(out_string, 2, m_mnemonics);
+ matches.GetMatchAtIndex(out_string.c_str(), 1, m_opcode_name);
+ matches.GetMatchAtIndex(out_string.c_str(), 2, m_mnemonics);
}
}
}
@@ -409,12 +453,11 @@ protected:
DisassemblerSP m_disasm_sp; // for ownership
LazyBool m_does_branch;
+ LazyBool m_has_delay_slot;
bool m_is_valid;
bool m_using_file_addr;
};
-
-
DisassemblerLLVMC::LLVMCDisassembler::LLVMCDisassembler (const char *triple, const char *cpu, const char *features_str, unsigned flavor, DisassemblerLLVMC &owner):
m_is_valid(true)
{
@@ -482,9 +525,7 @@ DisassemblerLLVMC::LLVMCDisassembler::LLVMCDisassembler (const char *triple, con
m_is_valid = false;
}
-DisassemblerLLVMC::LLVMCDisassembler::~LLVMCDisassembler()
-{
-}
+DisassemblerLLVMC::LLVMCDisassembler::~LLVMCDisassembler() = default;
uint64_t
DisassemblerLLVMC::LLVMCDisassembler::GetMCInst (const uint8_t *opcode_data,
@@ -508,22 +549,25 @@ DisassemblerLLVMC::LLVMCDisassembler::GetMCInst (const uint8_t *opcode_data,
return 0;
}
-uint64_t
+void
DisassemblerLLVMC::LLVMCDisassembler::PrintMCInst (llvm::MCInst &mc_inst,
- char *dst,
- size_t dst_len)
+ std::string &inst_string,
+ std::string &comments_string)
{
- llvm::StringRef unused_annotations;
- llvm::SmallString<64> inst_string;
- llvm::raw_svector_ostream inst_stream(inst_string);
- m_instr_printer_ap->printInst (&mc_inst, inst_stream, unused_annotations,
- *m_subtarget_info_ap);
- inst_stream.flush();
- const size_t output_size = std::min(dst_len - 1, inst_string.size());
- std::memcpy(dst, inst_string.data(), output_size);
- dst[output_size] = '\0';
-
- return output_size;
+ llvm::raw_string_ostream inst_stream(inst_string);
+ llvm::raw_string_ostream comments_stream(comments_string);
+
+ m_instr_printer_ap->setCommentStream(comments_stream);
+ m_instr_printer_ap->printInst (&mc_inst, inst_stream, llvm::StringRef(), *m_subtarget_info_ap);
+ m_instr_printer_ap->setCommentStream(llvm::nulls());
+ comments_stream.flush();
+
+ static std::string g_newlines("\r\n");
+
+ for (size_t newline_pos = 0; (newline_pos = comments_string.find_first_of(g_newlines, newline_pos)) != comments_string.npos; /**/)
+ {
+ comments_string.replace(comments_string.begin() + newline_pos, comments_string.begin() + newline_pos + 1, 1, ' ');
+ }
}
void
@@ -544,35 +588,9 @@ DisassemblerLLVMC::LLVMCDisassembler::CanBranch (llvm::MCInst &mc_inst)
}
bool
-DisassemblerLLVMC::FlavorValidForArchSpec (const lldb_private::ArchSpec &arch, const char *flavor)
+DisassemblerLLVMC::LLVMCDisassembler::HasDelaySlot (llvm::MCInst &mc_inst)
{
- llvm::Triple triple = arch.GetTriple();
- if (flavor == NULL || strcmp (flavor, "default") == 0)
- return true;
-
- if (triple.getArch() == llvm::Triple::x86 || triple.getArch() == llvm::Triple::x86_64)
- {
- if (strcmp (flavor, "intel") == 0 || strcmp (flavor, "att") == 0)
- return true;
- else
- return false;
- }
- else
- return false;
-}
-
-
-Disassembler *
-DisassemblerLLVMC::CreateInstance (const ArchSpec &arch, const char *flavor)
-{
- if (arch.GetTriple().getArch() != llvm::Triple::UnknownArch)
- {
- std::unique_ptr<DisassemblerLLVMC> disasm_ap (new DisassemblerLLVMC(arch, flavor));
-
- if (disasm_ap.get() && disasm_ap->IsValid())
- return disasm_ap.release();
- }
- return NULL;
+ return m_instr_info_ap->get(mc_inst.getOpcode()).hasDelaySlot();
}
DisassemblerLLVMC::DisassemblerLLVMC (const ArchSpec &arch, const char *flavor_string) :
@@ -586,13 +604,12 @@ DisassemblerLLVMC::DisassemblerLLVMC (const ArchSpec &arch, const char *flavor_s
m_flavor.assign("default");
}
- const char *triple = arch.GetTriple().getTriple().c_str();
unsigned flavor = ~0U;
+ llvm::Triple triple = arch.GetTriple();
// So far the only supported flavor is "intel" on x86. The base class will set this
// correctly coming in.
- if (arch.GetTriple().getArch() == llvm::Triple::x86
- || arch.GetTriple().getArch() == llvm::Triple::x86_64)
+ if (triple.getArch() == llvm::Triple::x86 || triple.getArch() == llvm::Triple::x86_64)
{
if (m_flavor == "intel")
{
@@ -605,7 +622,7 @@ DisassemblerLLVMC::DisassemblerLLVMC (const ArchSpec &arch, const char *flavor_s
}
ArchSpec thumb_arch(arch);
- if (arch.GetTriple().getArch() == llvm::Triple::arm)
+ if (triple.getArch() == llvm::Triple::arm)
{
std::string thumb_arch_name (thumb_arch.GetTriple().getArchName().str());
// Replace "arm" with "thumb" so we get all thumb variants correct
@@ -621,18 +638,29 @@ DisassemblerLLVMC::DisassemblerLLVMC (const ArchSpec &arch, const char *flavor_s
thumb_arch.GetTriple().setArchName(llvm::StringRef(thumb_arch_name.c_str()));
}
+ // If no sub architecture specified then use the most recent arm architecture so the
+ // disassembler will return all instruction. Without it we will see a lot of unknow opcode
+ // in case the code uses instructions which are not available in the oldest arm version
+ // (used when no sub architecture is specified)
+ if (triple.getArch() == llvm::Triple::arm && triple.getSubArch() == llvm::Triple::NoSubArch)
+ triple.setArchName("armv8.1a");
+
+ const char *triple_str = triple.getTriple().c_str();
+
+ // v. https://en.wikipedia.org/wiki/ARM_Cortex-M#Silicon_customization
+ //
// Cortex-M3 devices (e.g. armv7m) can only execute thumb (T2) instructions,
// so hardcode the primary disassembler to thumb mode. Same for Cortex-M4 (armv7em).
//
// Handle the Cortex-M0 (armv6m) the same; the ISA is a subset of the T and T32
// instructions defined in ARMv7-A.
- if (arch.GetTriple().getArch() == llvm::Triple::arm
+ if ((triple.getArch() == llvm::Triple::arm || triple.getArch() == llvm::Triple::thumb)
&& (arch.GetCore() == ArchSpec::Core::eCore_arm_armv7m
|| arch.GetCore() == ArchSpec::Core::eCore_arm_armv7em
|| arch.GetCore() == ArchSpec::Core::eCore_arm_armv6m))
{
- triple = thumb_arch.GetTriple().getTriple().c_str();
+ triple_str = thumb_arch.GetTriple().getTriple().c_str();
}
const char *cpu = "";
@@ -674,8 +702,8 @@ DisassemblerLLVMC::DisassemblerLLVMC (const ArchSpec &arch, const char *flavor_s
}
std::string features_str = "";
- if (arch.GetTriple().getArch() == llvm::Triple::mips || arch.GetTriple().getArch() == llvm::Triple::mipsel
- || arch.GetTriple().getArch() == llvm::Triple::mips64 || arch.GetTriple().getArch() == llvm::Triple::mips64el)
+ if (triple.getArch() == llvm::Triple::mips || triple.getArch() == llvm::Triple::mipsel
+ || triple.getArch() == llvm::Triple::mips64 || triple.getArch() == llvm::Triple::mips64el)
{
uint32_t arch_flags = arch.GetFlags ();
if (arch_flags & ArchSpec::eMIPSAse_msa)
@@ -684,13 +712,9 @@ DisassemblerLLVMC::DisassemblerLLVMC (const ArchSpec &arch, const char *flavor_s
features_str += "+dsp,";
if (arch_flags & ArchSpec::eMIPSAse_dspr2)
features_str += "+dspr2,";
- if (arch_flags & ArchSpec::eMIPSAse_mips16)
- features_str += "+mips16,";
- if (arch_flags & ArchSpec::eMIPSAse_micromips)
- features_str += "+micromips,";
}
- m_disasm_ap.reset (new LLVMCDisassembler(triple, cpu, features_str.c_str(), flavor, *this));
+ m_disasm_ap.reset (new LLVMCDisassembler(triple_str, cpu, features_str.c_str(), flavor, *this));
if (!m_disasm_ap->IsValid())
{
// We use m_disasm_ap.get() to tell whether we are valid or not, so if this isn't good for some reason,
@@ -698,8 +722,10 @@ DisassemblerLLVMC::DisassemblerLLVMC (const ArchSpec &arch, const char *flavor_s
m_disasm_ap.reset();
}
+ llvm::Triple::ArchType llvm_arch = triple.getArch();
+
// For arm CPUs that can execute arm or thumb instructions, also create a thumb instruction disassembler.
- if (arch.GetTriple().getArch() == llvm::Triple::arm)
+ if (llvm_arch == llvm::Triple::arm)
{
std::string thumb_triple(thumb_arch.GetTriple().getTriple());
m_alternate_disasm_ap.reset(new LLVMCDisassembler(thumb_triple.c_str(), "", "", flavor, *this));
@@ -709,10 +735,40 @@ DisassemblerLLVMC::DisassemblerLLVMC (const ArchSpec &arch, const char *flavor_s
m_alternate_disasm_ap.reset();
}
}
+ else if (llvm_arch == llvm::Triple::mips
+ || llvm_arch == llvm::Triple::mipsel
+ || llvm_arch == llvm::Triple::mips64
+ || llvm_arch == llvm::Triple::mips64el)
+ {
+ /* Create alternate disassembler for MIPS16 and microMIPS */
+ uint32_t arch_flags = arch.GetFlags ();
+ if (arch_flags & ArchSpec::eMIPSAse_mips16)
+ features_str += "+mips16,";
+ else if (arch_flags & ArchSpec::eMIPSAse_micromips)
+ features_str += "+micromips,";
+
+ m_alternate_disasm_ap.reset(new LLVMCDisassembler (triple_str, cpu, features_str.c_str(), flavor, *this));
+ if (!m_alternate_disasm_ap->IsValid())
+ {
+ m_disasm_ap.reset();
+ m_alternate_disasm_ap.reset();
+ }
+ }
}
-DisassemblerLLVMC::~DisassemblerLLVMC()
+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 (new DisassemblerLLVMC(arch, flavor));
+
+ if (disasm_ap.get() && disasm_ap->IsValid())
+ return disasm_ap.release();
+ }
+ return NULL;
}
size_t
@@ -817,6 +873,24 @@ const char *DisassemblerLLVMC::SymbolLookupCallback (void *disassembler,
name);
}
+bool
+DisassemblerLLVMC::FlavorValidForArchSpec (const lldb_private::ArchSpec &arch, const char *flavor)
+{
+ llvm::Triple triple = arch.GetTriple();
+ if (flavor == NULL || strcmp (flavor, "default") == 0)
+ return true;
+
+ if (triple.getArch() == llvm::Triple::x86 || triple.getArch() == llvm::Triple::x86_64)
+ {
+ if (strcmp (flavor, "intel") == 0 || strcmp (flavor, "att") == 0)
+ return true;
+ else
+ return false;
+ }
+ else
+ return false;
+}
+
int DisassemblerLLVMC::OpInfo (uint64_t PC,
uint64_t Offset,
uint64_t Size,
diff --git a/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h b/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h
index 56cec03994ef..6359146d81d8 100644
--- a/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h
+++ b/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h
@@ -10,10 +10,20 @@
#ifndef liblldb_DisassemblerLLVMC_h_
#define liblldb_DisassemblerLLVMC_h_
+// C Includes
+// C++ Includes
+#include <memory>
#include <string>
+// Other libraries and framework includes
#include "llvm-c/Disassembler.h"
+// Project includes
+#include "lldb/Core/Address.h"
+#include "lldb/Core/Disassembler.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Host/Mutex.h"
+
// Opaque references to C++ Objects in LLVM's MC.
namespace llvm
{
@@ -25,12 +35,7 @@ namespace llvm
class MCInstPrinter;
class MCAsmInfo;
class MCSubtargetInfo;
-}
-
-#include "lldb/Core/Address.h"
-#include "lldb/Core/Disassembler.h"
-#include "lldb/Core/PluginManager.h"
-#include "lldb/Host/Mutex.h"
+} // namespace llvm
class InstructionLLVMC;
@@ -46,9 +51,10 @@ class DisassemblerLLVMC : public lldb_private::Disassembler
~LLVMCDisassembler();
uint64_t GetMCInst (const uint8_t *opcode_data, size_t opcode_data_len, lldb::addr_t pc, llvm::MCInst &mc_inst);
- uint64_t PrintMCInst (llvm::MCInst &mc_inst, char *output_buffer, size_t out_buffer_len);
+ void PrintMCInst (llvm::MCInst &mc_inst, std::string &inst_string, std::string &comments_string);
void SetStyle (bool use_hex_immed, HexImmediateStyle hex_style);
bool CanBranch (llvm::MCInst &mc_inst);
+ bool HasDelaySlot (llvm::MCInst &mc_inst);
bool IsValid()
{
return m_is_valid;
@@ -66,6 +72,10 @@ class DisassemblerLLVMC : public lldb_private::Disassembler
};
public:
+ DisassemblerLLVMC(const lldb_private::ArchSpec &arch, const char *flavor /* = NULL */);
+
+ ~DisassemblerLLVMC() override;
+
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
@@ -81,33 +91,28 @@ public:
static lldb_private::Disassembler *
CreateInstance(const lldb_private::ArchSpec &arch, const char *flavor);
- DisassemblerLLVMC(const lldb_private::ArchSpec &arch, const char *flavor /* = NULL */);
-
- virtual
- ~DisassemblerLLVMC();
-
- virtual size_t
- DecodeInstructions (const lldb_private::Address &base_addr,
- const lldb_private::DataExtractor& data,
- lldb::offset_t data_offset,
- size_t num_instructions,
- bool append,
- bool data_from_file);
+ size_t
+ DecodeInstructions(const lldb_private::Address &base_addr,
+ const lldb_private::DataExtractor& data,
+ lldb::offset_t data_offset,
+ size_t num_instructions,
+ bool append,
+ bool data_from_file) override;
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
- virtual lldb_private::ConstString
- GetPluginName();
+ lldb_private::ConstString
+ GetPluginName() override;
- virtual uint32_t
- GetPluginVersion();
+ uint32_t
+ GetPluginVersion() override;
protected:
friend class InstructionLLVMC;
- virtual bool
- FlavorValidForArchSpec (const lldb_private::ArchSpec &arch, const char *flavor);
+ bool
+ FlavorValidForArchSpec(const lldb_private::ArchSpec &arch, const char *flavor) override;
bool
IsValid()
@@ -163,4 +168,4 @@ protected:
std::unique_ptr<LLVMCDisassembler> m_alternate_disasm_ap;
};
-#endif // liblldb_DisassemblerLLVM_h_
+#endif // liblldb_DisassemblerLLVM_h_
diff --git a/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp b/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
index 2308129b8cab..28493170ac36 100644
--- a/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
+++ b/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
@@ -104,11 +104,6 @@ DynamicLoaderHexagonDYLD::GetPluginDescriptionStatic()
"loads/unloads in Hexagon processes.";
}
-void
-DynamicLoaderHexagonDYLD::GetPluginCommandHelp(const char *command, Stream *strm)
-{
-}
-
uint32_t
DynamicLoaderHexagonDYLD::GetPluginVersion()
{
@@ -177,7 +172,7 @@ DynamicLoaderHexagonDYLD::DidAttach()
// Map the loaded sections of this executable
if ( load_offset != LLDB_INVALID_ADDRESS )
- UpdateLoadedSections(executable, LLDB_INVALID_ADDRESS, load_offset);
+ UpdateLoadedSections(executable, LLDB_INVALID_ADDRESS, load_offset, true);
// AD: confirm this?
// Load into LLDB all of the currently loaded executables in the stub
@@ -248,18 +243,6 @@ DynamicLoaderHexagonDYLD::GetTargetExecutable()
return executable;
}
-Error
-DynamicLoaderHexagonDYLD::ExecutePluginCommand(Args &command, Stream *strm)
-{
- return Error();
-}
-
-Log *
-DynamicLoaderHexagonDYLD::EnablePluginLogging(Stream *strm, Args &command)
-{
- return NULL;
-}
-
//AD: Needs to be updated?
Error
DynamicLoaderHexagonDYLD::CanLoadImage()
@@ -268,7 +251,10 @@ DynamicLoaderHexagonDYLD::CanLoadImage()
}
void
-DynamicLoaderHexagonDYLD::UpdateLoadedSections(ModuleSP module, addr_t link_map_addr, addr_t base_addr)
+DynamicLoaderHexagonDYLD::UpdateLoadedSections(ModuleSP module,
+ addr_t link_map_addr,
+ addr_t base_addr,
+ bool base_addr_is_offset)
{
Target &target = m_process->GetTarget();
const SectionList *sections = GetSectionListFromModule(module);
@@ -442,7 +428,7 @@ DynamicLoaderHexagonDYLD::RefreshModules()
for (I = m_rendezvous.loaded_begin(); I != E; ++I)
{
FileSpec file(I->path.c_str(), true);
- ModuleSP module_sp = LoadModuleAtAddress(file, I->link_addr, I->base_addr);
+ ModuleSP module_sp = LoadModuleAtAddress(file, I->link_addr, I->base_addr, true);
if (module_sp.get())
{
loaded_modules.AppendIfNeeded( module_sp );
@@ -571,7 +557,7 @@ DynamicLoaderHexagonDYLD::LoadAllCurrentModules()
{
const char *module_path = I->path.c_str();
FileSpec file(module_path, false);
- ModuleSP module_sp = LoadModuleAtAddress(file, I->link_addr, I->base_addr);
+ ModuleSP module_sp = LoadModuleAtAddress(file, I->link_addr, I->base_addr, true);
if (module_sp.get())
{
module_list.Append(module_sp);
@@ -591,7 +577,10 @@ DynamicLoaderHexagonDYLD::LoadAllCurrentModules()
/// Helper for the entry breakpoint callback. Resolves the load addresses
/// of all dependent modules.
ModuleSP
-DynamicLoaderHexagonDYLD::LoadModuleAtAddress(const FileSpec &file, addr_t link_map_addr, addr_t base_addr)
+DynamicLoaderHexagonDYLD::LoadModuleAtAddress(const FileSpec &file,
+ addr_t link_map_addr,
+ addr_t base_addr,
+ bool base_addr_is_offset)
{
Target &target = m_process->GetTarget();
ModuleList &modules = target.GetImages();
@@ -602,12 +591,12 @@ DynamicLoaderHexagonDYLD::LoadModuleAtAddress(const FileSpec &file, addr_t link_
// check if module is currently loaded
if ((module_sp = modules.FindFirstModule (module_spec)))
{
- UpdateLoadedSections(module_sp, link_map_addr, base_addr);
+ UpdateLoadedSections(module_sp, link_map_addr, base_addr, true);
}
// try to load this module from disk
else if ((module_sp = target.GetSharedModule(module_spec)))
{
- UpdateLoadedSections(module_sp, link_map_addr, base_addr);
+ UpdateLoadedSections(module_sp, link_map_addr, base_addr, true);
}
return module_sp;
diff --git a/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h b/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h
index aafa385c0fca..e10d4ee64209 100644
--- a/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h
+++ b/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h
@@ -7,12 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DynamicLoaderHexagon_H_
-#define liblldb_DynamicLoaderHexagon_H_
+#ifndef liblldb_DynamicLoaderHexagonDYLD_h_
+#define liblldb_DynamicLoaderHexagonDYLD_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
+// Project includes
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Target/DynamicLoader.h"
@@ -21,6 +22,9 @@
class DynamicLoaderHexagonDYLD : public lldb_private::DynamicLoader
{
public:
+ DynamicLoaderHexagonDYLD(lldb_private::Process *process);
+
+ ~DynamicLoaderHexagonDYLD() override;
static void
Initialize();
@@ -37,48 +41,34 @@ public:
static lldb_private::DynamicLoader *
CreateInstance(lldb_private::Process *process, bool force);
- DynamicLoaderHexagonDYLD(lldb_private::Process *process);
-
- virtual
- ~DynamicLoaderHexagonDYLD();
-
//------------------------------------------------------------------
// DynamicLoader protocol
//------------------------------------------------------------------
- virtual void
- DidAttach();
+ void
+ DidAttach() override;
- virtual void
- DidLaunch();
+ void
+ DidLaunch() override;
- virtual lldb::ThreadPlanSP
+ lldb::ThreadPlanSP
GetStepThroughTrampolinePlan(lldb_private::Thread &thread,
- bool stop_others);
+ bool stop_others) override;
- virtual lldb_private::Error
- CanLoadImage();
+ lldb_private::Error
+ CanLoadImage() override;
- virtual lldb::addr_t
- GetThreadLocalData (const lldb::ModuleSP module, const lldb::ThreadSP thread);
+ lldb::addr_t
+ GetThreadLocalData(const lldb::ModuleSP module, const lldb::ThreadSP thread) override;
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
- virtual lldb_private::ConstString
- GetPluginName();
+ lldb_private::ConstString
+ GetPluginName() override;
- virtual uint32_t
- GetPluginVersion();
-
- virtual void
- GetPluginCommandHelp(const char *command, lldb_private::Stream *strm);
-
- virtual lldb_private::Error
- ExecutePluginCommand(lldb_private::Args &command, lldb_private::Stream *strm);
-
- virtual lldb_private::Log *
- EnablePluginLogging(lldb_private::Stream *strm, lldb_private::Args &command);
+ uint32_t
+ GetPluginVersion() override;
protected:
/// Runtime linker rendezvous structure.
@@ -124,18 +114,22 @@ protected:
void
UpdateLoadedSections(lldb::ModuleSP module,
lldb::addr_t link_map_addr,
- lldb::addr_t base_addr);
+ lldb::addr_t base_addr,
+ bool base_addr_is_offset) override;
/// Removes the loaded sections from the target in @p module.
///
/// @param module The module to traverse.
void
- UnloadSections(const lldb::ModuleSP module);
+ UnloadSections(const lldb::ModuleSP module) override;
/// Locates or creates a module given by @p file and updates/loads the
/// resulting module at the virtual base address @p base_addr.
lldb::ModuleSP
- LoadModuleAtAddress(const lldb_private::FileSpec &file, lldb::addr_t link_map_addr, lldb::addr_t base_addr);
+ LoadModuleAtAddress(const lldb_private::FileSpec &file,
+ lldb::addr_t link_map_addr,
+ lldb::addr_t base_addr,
+ bool base_addr_is_offset) override;
/// Callback routine invoked when we hit the breakpoint on process entry.
///
@@ -173,10 +167,10 @@ protected:
FindRendezvousBreakpointAddress( );
private:
- DISALLOW_COPY_AND_ASSIGN(DynamicLoaderHexagonDYLD);
-
const lldb_private::SectionList *
GetSectionListFromModule(const lldb::ModuleSP module) const;
+
+ DISALLOW_COPY_AND_ASSIGN(DynamicLoaderHexagonDYLD);
};
-#endif // liblldb_DynamicLoaderHexagonDYLD_H_
+#endif // liblldb_DynamicLoaderHexagonDYLD_h_
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
index 8b1dd283394b..09e874a011df 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
@@ -17,6 +17,7 @@
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
@@ -290,19 +291,13 @@ DYLDRendezvous::SOEntryIsMainExecutable(const SOEntry &entry)
// FreeBSD and on Android it is the full path to the executable.
auto triple = m_process->GetTarget().GetArchitecture().GetTriple();
- auto os_type = triple.getOS();
- auto env_type = triple.getEnvironment();
-
- switch (os_type) {
+ switch (triple.getOS()) {
case llvm::Triple::FreeBSD:
return entry.file_spec == m_exe_file_spec;
case llvm::Triple::Linux:
- switch (env_type) {
- case llvm::Triple::Android:
- return entry.file_spec == m_exe_file_spec;
- default:
- return !entry.file_spec;
- }
+ if (triple.isAndroid())
+ return entry.file_spec == m_exe_file_spec;
+ return !entry.file_spec;
default:
return false;
}
@@ -372,6 +367,25 @@ DYLDRendezvous::ReadStringFromMemory(addr_t addr)
return str;
}
+// Returns true if the load bias reported by the linker is incorrect for the given entry. This
+// function is used to handle cases where we want to work around a bug in the system linker.
+static bool
+isLoadBiasIncorrect(Target& target, const std::string& file_path)
+{
+ // On Android L (API 21, 22) the load address of the "/system/bin/linker" isn't filled in
+ // correctly.
+ uint32_t os_major = 0, os_minor = 0, os_update = 0;
+ if (target.GetArchitecture().GetTriple().isAndroid() &&
+ target.GetPlatform()->GetOSVersion(os_major, os_minor, os_update) &&
+ (os_major == 21 || os_major == 22) &&
+ (file_path == "/system/bin/linker" || file_path == "/system/bin/linker64"))
+ {
+ return true;
+ }
+
+ return false;
+}
+
bool
DYLDRendezvous::ReadSOEntryFromMemory(lldb::addr_t addr, SOEntry &entry)
{
@@ -413,11 +427,9 @@ DYLDRendezvous::ReadSOEntryFromMemory(lldb::addr_t addr, SOEntry &entry)
std::string file_path = ReadStringFromMemory(entry.path_addr);
entry.file_spec.SetFile(file_path, false);
- // On Android L (5.0, 5.1) the load address of the "/system/bin/linker" isn't filled in
- // correctly. To get the correct load address we fetch the load address of the file from the
- // proc file system.
- if (arch.GetTriple().getEnvironment() == llvm::Triple::Android && entry.base_addr == 0 &&
- (file_path == "/system/bin/linker" || file_path == "/system/bin/linker64"))
+ // If the load bias reported by the linker is incorrect then fetch the load address of the file
+ // from the proc file system.
+ if (isLoadBiasIncorrect(m_process->GetTarget(), file_path))
{
lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
bool is_loaded = false;
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index 8724fc039cb9..6ba7b470d743 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -62,11 +62,6 @@ DynamicLoaderPOSIXDYLD::GetPluginDescriptionStatic()
"loads/unloads in POSIX processes.";
}
-void
-DynamicLoaderPOSIXDYLD::GetPluginCommandHelp(const char *command, Stream *strm)
-{
-}
-
uint32_t
DynamicLoaderPOSIXDYLD::GetPluginVersion()
{
@@ -96,7 +91,8 @@ DynamicLoaderPOSIXDYLD::DynamicLoaderPOSIXDYLD(Process *process)
m_load_offset(LLDB_INVALID_ADDRESS),
m_entry_point(LLDB_INVALID_ADDRESS),
m_auxv(),
- m_dyld_bid(LLDB_INVALID_BREAK_ID)
+ m_dyld_bid(LLDB_INVALID_BREAK_ID),
+ m_vdso_base(LLDB_INVALID_ADDRESS)
{
}
@@ -131,6 +127,8 @@ DynamicLoaderPOSIXDYLD::DidAttach()
if (log)
log->Printf ("DynamicLoaderPOSIXDYLD::%s pid %" PRIu64 " executable '%s', load_offset 0x%" PRIx64, __FUNCTION__, m_process ? m_process->GetID () : LLDB_INVALID_PROCESS_ID, executable_sp ? executable_sp->GetFileSpec().GetPath().c_str () : "<null executable>", load_offset);
+ EvalVdsoStatus();
+
// if we dont have a load address we cant re-base
bool rebase_exec = (load_offset == LLDB_INVALID_ADDRESS) ? false : true;
@@ -165,7 +163,7 @@ DynamicLoaderPOSIXDYLD::DidAttach()
m_process ? m_process->GetID () : LLDB_INVALID_PROCESS_ID,
executable_sp->GetFileSpec().GetPath().c_str ());
- UpdateLoadedSections(executable_sp, LLDB_INVALID_ADDRESS, load_offset);
+ UpdateLoadedSections(executable_sp, LLDB_INVALID_ADDRESS, load_offset, true);
// When attaching to a target, there are two possible states:
// (1) We already crossed the entry point and therefore the rendezvous
@@ -218,12 +216,13 @@ DynamicLoaderPOSIXDYLD::DidLaunch()
executable = GetTargetExecutable();
load_offset = ComputeLoadOffset();
+ EvalVdsoStatus();
if (executable.get() && load_offset != LLDB_INVALID_ADDRESS)
{
ModuleList module_list;
module_list.Append(executable);
- UpdateLoadedSections(executable, LLDB_INVALID_ADDRESS, load_offset);
+ UpdateLoadedSections(executable, LLDB_INVALID_ADDRESS, load_offset, true);
if (log)
log->Printf ("DynamicLoaderPOSIXDYLD::%s about to call ProbeEntry()", __FUNCTION__);
@@ -234,29 +233,19 @@ DynamicLoaderPOSIXDYLD::DidLaunch()
}
Error
-DynamicLoaderPOSIXDYLD::ExecutePluginCommand(Args &command, Stream *strm)
-{
- return Error();
-}
-
-Log *
-DynamicLoaderPOSIXDYLD::EnablePluginLogging(Stream *strm, Args &command)
-{
- return NULL;
-}
-
-Error
DynamicLoaderPOSIXDYLD::CanLoadImage()
{
return Error();
}
void
-DynamicLoaderPOSIXDYLD::UpdateLoadedSections(ModuleSP module, addr_t link_map_addr, addr_t base_addr)
+DynamicLoaderPOSIXDYLD::UpdateLoadedSections(ModuleSP module,
+ addr_t link_map_addr,
+ addr_t base_addr,
+ bool base_addr_is_offset)
{
m_loaded_modules[module] = link_map_addr;
-
- UpdateLoadedSectionsCommon(module, base_addr);
+ UpdateLoadedSectionsCommon(module, base_addr, base_addr_is_offset);
}
void
@@ -414,7 +403,7 @@ DynamicLoaderPOSIXDYLD::RefreshModules()
E = m_rendezvous.loaded_end();
for (I = m_rendezvous.loaded_begin(); I != E; ++I)
{
- ModuleSP module_sp = LoadModuleAtAddress(I->file_spec, I->link_addr, I->base_addr);
+ ModuleSP module_sp = LoadModuleAtAddress(I->file_spec, I->link_addr, I->base_addr, true);
if (module_sp.get())
{
loaded_modules.AppendIfNeeded(module_sp);
@@ -432,8 +421,7 @@ DynamicLoaderPOSIXDYLD::RefreshModules()
for (I = m_rendezvous.unloaded_begin(); I != E; ++I)
{
ModuleSpec module_spec{I->file_spec};
- ModuleSP module_sp =
- loaded_modules.FindFirstModule (module_spec);
+ ModuleSP module_sp = loaded_modules.FindFirstModule (module_spec);
if (module_sp.get())
{
@@ -519,11 +507,18 @@ DynamicLoaderPOSIXDYLD::LoadAllCurrentModules()
// that ourselves here.
ModuleSP executable = GetTargetExecutable();
m_loaded_modules[executable] = m_rendezvous.GetLinkMapAddress();
-
-
+ if (m_vdso_base != LLDB_INVALID_ADDRESS)
+ {
+ FileSpec file_spec("[vdso]", false);
+ ModuleSP module_sp = LoadModuleAtAddress(file_spec, LLDB_INVALID_ADDRESS, m_vdso_base, false);
+ if (module_sp.get())
+ {
+ module_list.Append(module_sp);
+ }
+ }
for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I)
{
- ModuleSP module_sp = LoadModuleAtAddress(I->file_spec, I->link_addr, I->base_addr);
+ ModuleSP module_sp = LoadModuleAtAddress(I->file_spec, I->link_addr, I->base_addr, true);
if (module_sp.get())
{
module_list.Append(module_sp);
@@ -568,6 +563,16 @@ DynamicLoaderPOSIXDYLD::ComputeLoadOffset()
return m_load_offset;
}
+void
+DynamicLoaderPOSIXDYLD::EvalVdsoStatus()
+{
+ AuxVector::iterator I = m_auxv->FindEntry(AuxVector::AT_SYSINFO_EHDR);
+
+ if (I != m_auxv->end())
+ m_vdso_base = I->value;
+
+}
+
addr_t
DynamicLoaderPOSIXDYLD::GetEntryPoint()
{
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
index 68d3059cb4be..cb97bbf43ba9 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
@@ -1,4 +1,4 @@
-//===-- DynamicLoaderPOSIX.h ------------------------------------*- C++ -*-===//
+//===-- DynamicLoaderPOSIXDYLD.h --------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,12 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DynamicLoaderPOSIX_H_
-#define liblldb_DynamicLoaderPOSIX_H_
+#ifndef liblldb_DynamicLoaderPOSIXDYLD_h_
+#define liblldb_DynamicLoaderPOSIXDYLD_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
+// Project includes
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Target/DynamicLoader.h"
@@ -23,6 +24,9 @@ class AuxVector;
class DynamicLoaderPOSIXDYLD : public lldb_private::DynamicLoader
{
public:
+ DynamicLoaderPOSIXDYLD(lldb_private::Process *process);
+
+ ~DynamicLoaderPOSIXDYLD() override;
static void
Initialize();
@@ -39,48 +43,34 @@ public:
static lldb_private::DynamicLoader *
CreateInstance(lldb_private::Process *process, bool force);
- DynamicLoaderPOSIXDYLD(lldb_private::Process *process);
-
- virtual
- ~DynamicLoaderPOSIXDYLD();
-
//------------------------------------------------------------------
// DynamicLoader protocol
//------------------------------------------------------------------
- virtual void
- DidAttach();
+ void
+ DidAttach() override;
- virtual void
- DidLaunch();
+ void
+ DidLaunch() override;
- virtual lldb::ThreadPlanSP
+ lldb::ThreadPlanSP
GetStepThroughTrampolinePlan(lldb_private::Thread &thread,
- bool stop_others);
+ bool stop_others) override;
- virtual lldb_private::Error
- CanLoadImage();
+ lldb_private::Error
+ CanLoadImage() override;
- virtual lldb::addr_t
- GetThreadLocalData (const lldb::ModuleSP module, const lldb::ThreadSP thread);
+ lldb::addr_t
+ GetThreadLocalData(const lldb::ModuleSP module, const lldb::ThreadSP thread) override;
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
- virtual lldb_private::ConstString
- GetPluginName();
-
- virtual uint32_t
- GetPluginVersion();
-
- virtual void
- GetPluginCommandHelp(const char *command, lldb_private::Stream *strm);
+ lldb_private::ConstString
+ GetPluginName() override;
- virtual lldb_private::Error
- ExecutePluginCommand(lldb_private::Args &command, lldb_private::Stream *strm);
-
- virtual lldb_private::Log *
- EnablePluginLogging(lldb_private::Stream *strm, lldb_private::Args &command);
+ uint32_t
+ GetPluginVersion() override;
protected:
/// Runtime linker rendezvous structure.
@@ -98,12 +88,16 @@ protected:
/// Rendezvous breakpoint.
lldb::break_id_t m_dyld_bid;
+ /// Contains AT_SYSINFO_EHDR, which means a vDSO has been
+ /// mapped to the address space
+ lldb::addr_t m_vdso_base;
+
/// Loaded module list. (link map for each module)
std::map<lldb::ModuleWP, lldb::addr_t, std::owner_less<lldb::ModuleWP>> m_loaded_modules;
/// Enables a breakpoint on a function called by the runtime
/// linker each time a module is loaded or unloaded.
- void
+ virtual void
SetRendezvousBreakpoint();
/// Callback routine which updates the current list of loaded modules based
@@ -126,16 +120,17 @@ protected:
/// @param link_map_addr The virtual address of the link map for the @p module.
///
/// @param base_addr The virtual base address @p module is loaded at.
- virtual void
+ void
UpdateLoadedSections(lldb::ModuleSP module,
lldb::addr_t link_map_addr,
- lldb::addr_t base_addr);
+ lldb::addr_t base_addr,
+ bool base_addr_is_offset) override;
/// Removes the loaded sections from the target in @p module.
///
/// @param module The module to traverse.
- virtual void
- UnloadSections(const lldb::ModuleSP module);
+ void
+ UnloadSections(const lldb::ModuleSP module) override;
/// Resolves the entry point for the current inferior process and sets a
/// breakpoint at that address.
@@ -155,7 +150,7 @@ protected:
/// Helper for the entry breakpoint callback. Resolves the load addresses
/// of all dependent modules.
- void
+ virtual void
LoadAllCurrentModules();
/// Computes a value for m_load_offset returning the computed address on
@@ -168,6 +163,11 @@ protected:
lldb::addr_t
GetEntryPoint();
+ /// Evaluate if Aux vectors contain vDSO information
+ /// in case they do, read and assign the address to m_vdso_base
+ void
+ EvalVdsoStatus();
+
/// Loads Module from inferior process.
void
ResolveExecutableModule(lldb::ModuleSP &module_sp);
@@ -176,4 +176,4 @@ private:
DISALLOW_COPY_AND_ASSIGN(DynamicLoaderPOSIXDYLD);
};
-#endif // liblldb_DynamicLoaderPOSIXDYLD_H_
+#endif // liblldb_DynamicLoaderPOSIXDYLD_h_
diff --git a/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h b/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h
index ea33164cf823..a7fdf4d22165 100644
--- a/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h
+++ b/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h
@@ -12,12 +12,8 @@
// C Includes
// C++ Includes
-#include <map>
-#include <vector>
-#include <string>
-
// Other libraries and framework includes
-
+// Project includes
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Core/UUID.h"
@@ -27,6 +23,10 @@
class DynamicLoaderStatic : public lldb_private::DynamicLoader
{
public:
+ DynamicLoaderStatic(lldb_private::Process *process);
+
+ ~DynamicLoaderStatic() override;
+
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
@@ -45,37 +45,33 @@ public:
static lldb_private::DynamicLoader *
CreateInstance (lldb_private::Process *process, bool force);
- DynamicLoaderStatic (lldb_private::Process *process);
-
- virtual
- ~DynamicLoaderStatic ();
//------------------------------------------------------------------
/// Called after attaching a process.
///
/// Allow DynamicLoader plug-ins to execute some code after
/// attaching to a process.
//------------------------------------------------------------------
- virtual void
- DidAttach ();
+ void
+ DidAttach() override;
- virtual void
- DidLaunch ();
+ void
+ DidLaunch() override;
- virtual lldb::ThreadPlanSP
- GetStepThroughTrampolinePlan (lldb_private::Thread &thread,
- bool stop_others);
+ lldb::ThreadPlanSP
+ GetStepThroughTrampolinePlan(lldb_private::Thread &thread,
+ bool stop_others) override;
- virtual lldb_private::Error
- CanLoadImage ();
+ lldb_private::Error
+ CanLoadImage() override;
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
- virtual lldb_private::ConstString
- GetPluginName();
+ lldb_private::ConstString
+ GetPluginName() override;
- virtual uint32_t
- GetPluginVersion();
+ uint32_t
+ GetPluginVersion() override;
private:
void
@@ -84,4 +80,4 @@ private:
DISALLOW_COPY_AND_ASSIGN (DynamicLoaderStatic);
};
-#endif // liblldb_DynamicLoaderStatic_h_
+#endif // liblldb_DynamicLoaderStatic_h_
diff --git a/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp b/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
index 56b56ab3a194..dd391b4ca4d2 100644
--- a/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
+++ b/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
@@ -21,40 +21,39 @@ using namespace lldb_private;
DynamicLoaderWindowsDYLD::DynamicLoaderWindowsDYLD(Process *process)
: DynamicLoader(process)
{
-
}
DynamicLoaderWindowsDYLD::~DynamicLoaderWindowsDYLD()
{
-
}
-void DynamicLoaderWindowsDYLD::Initialize()
+void
+DynamicLoaderWindowsDYLD::Initialize()
{
- PluginManager::RegisterPlugin(GetPluginNameStatic(),
- GetPluginDescriptionStatic(),
- CreateInstance);
+ PluginManager::RegisterPlugin(GetPluginNameStatic(), GetPluginDescriptionStatic(), CreateInstance);
}
-void DynamicLoaderWindowsDYLD::Terminate()
+void
+DynamicLoaderWindowsDYLD::Terminate()
{
-
}
-ConstString DynamicLoaderWindowsDYLD::GetPluginNameStatic()
+ConstString
+DynamicLoaderWindowsDYLD::GetPluginNameStatic()
{
static ConstString g_plugin_name("windows-dyld");
return g_plugin_name;
}
-const char *DynamicLoaderWindowsDYLD::GetPluginDescriptionStatic()
+const char *
+DynamicLoaderWindowsDYLD::GetPluginDescriptionStatic()
{
return "Dynamic loader plug-in that watches for shared library "
"loads/unloads in Windows processes.";
}
-
-DynamicLoader *DynamicLoaderWindowsDYLD::CreateInstance(Process *process, bool force)
+DynamicLoader *
+DynamicLoaderWindowsDYLD::CreateInstance(Process *process, bool force)
{
bool should_create = force;
if (!should_create)
@@ -65,32 +64,35 @@ DynamicLoader *DynamicLoaderWindowsDYLD::CreateInstance(Process *process, bool f
}
if (should_create)
- return new DynamicLoaderWindowsDYLD (process);
+ return new DynamicLoaderWindowsDYLD(process);
return nullptr;
}
-void DynamicLoaderWindowsDYLD::DidAttach()
+void
+DynamicLoaderWindowsDYLD::DidAttach()
{
-
}
-void DynamicLoaderWindowsDYLD::DidLaunch()
+void
+DynamicLoaderWindowsDYLD::DidLaunch()
{
-
}
-Error DynamicLoaderWindowsDYLD::CanLoadImage()
+Error
+DynamicLoaderWindowsDYLD::CanLoadImage()
{
return Error();
}
-ConstString DynamicLoaderWindowsDYLD::GetPluginName()
+ConstString
+DynamicLoaderWindowsDYLD::GetPluginName()
{
return GetPluginNameStatic();
}
-uint32_t DynamicLoaderWindowsDYLD::GetPluginVersion()
+uint32_t
+DynamicLoaderWindowsDYLD::GetPluginVersion()
{
return 1;
}
diff --git a/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h b/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
index d12b999f4627..8c479819c535 100644
--- a/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
+++ b/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
@@ -1,4 +1,4 @@
-//===-- DynamicLoaderWindowsDYLDh ----------------------------------*- C++ -*-===//
+//===-- DynamicLoaderWindowsDYLD.h ------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,9 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Plugins_Process_Windows_DynamicLoaderWindowsDYLD_H_
-#define liblldb_Plugins_Process_Windows_DynamicLoaderWindowsDYLD_H_
+#ifndef liblldb_Plugins_Process_Windows_DynamicLoaderWindowsDYLD_h_
+#define liblldb_Plugins_Process_Windows_DynamicLoaderWindowsDYLD_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-forward.h"
#include "lldb/Target/DynamicLoader.h"
@@ -18,9 +22,10 @@ namespace lldb_private
class DynamicLoaderWindowsDYLD : public DynamicLoader
{
- public:
+public:
DynamicLoaderWindowsDYLD(Process *process);
- virtual ~DynamicLoaderWindowsDYLD();
+
+ ~DynamicLoaderWindowsDYLD() override;
static void Initialize();
static void Terminate();
@@ -29,15 +34,15 @@ class DynamicLoaderWindowsDYLD : public DynamicLoader
static DynamicLoader *CreateInstance(Process *process, bool force);
- void DidAttach () override;
- void DidLaunch () override;
- Error CanLoadImage () override;
+ void DidAttach() override;
+ void DidLaunch() override;
+ Error CanLoadImage() override;
lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, bool stop) override;
ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
};
-}
+} // namespace lldb_private
-#endif
+#endif // liblldb_Plugins_Process_Windows_DynamicLoaderWindowsDYLD_h_
diff --git a/source/Expression/ASTDumper.cpp b/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp
index 5210d149e666..976310610f51 100644
--- a/source/Expression/ASTDumper.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp
@@ -7,9 +7,11 @@
//
//===----------------------------------------------------------------------===//
+#include "ASTDumper.h"
+
#include "lldb/Core/Log.h"
-#include "lldb/Expression/ASTDumper.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/CompilerType.h"
#include "llvm/Support/raw_ostream.h"
@@ -74,14 +76,14 @@ ASTDumper::ASTDumper (clang::QualType type)
m_dump = type.getAsString();
}
-ASTDumper::ASTDumper (lldb::clang_type_t type)
+ASTDumper::ASTDumper (lldb::opaque_compiler_type_t type)
{
m_dump = clang::QualType::getFromOpaquePtr(type).getAsString();
}
-ASTDumper::ASTDumper (const ClangASTType &clang_type)
+ASTDumper::ASTDumper (const CompilerType &compiler_type)
{
- m_dump = clang_type.GetQualType().getAsString();
+ m_dump = ClangASTContext::GetQualType(compiler_type).getAsString();
}
diff --git a/include/lldb/Expression/ASTDumper.h b/source/Plugins/ExpressionParser/Clang/ASTDumper.h
index 47f7ea460b87..c8dc6847d6c2 100644
--- a/include/lldb/Expression/ASTDumper.h
+++ b/source/Plugins/ExpressionParser/Clang/ASTDumper.h
@@ -11,7 +11,6 @@
#define liblldb_ASTDumper_h_
#include "clang/AST/DeclVisitor.h"
-#include "clang/AST/StmtVisitor.h"
#include "clang/AST/TypeVisitor.h"
#include "lldb/Core/Stream.h"
@@ -27,8 +26,8 @@ public:
ASTDumper (clang::DeclContext *decl_ctx);
ASTDumper (const clang::Type *type);
ASTDumper (clang::QualType type);
- ASTDumper (lldb::clang_type_t type);
- ASTDumper (const ClangASTType &clang_type);
+ ASTDumper (lldb::opaque_compiler_type_t type);
+ ASTDumper (const CompilerType &compiler_type);
const char *GetCString();
void ToSTDERR();
diff --git a/source/Expression/ASTResultSynthesizer.cpp b/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
index c3d42cb49ec5..02505bde240c 100644
--- a/source/Expression/ASTResultSynthesizer.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
+#include "ASTResultSynthesizer.h"
+
+#include "ClangPersistentVariables.h"
+
#include "stdlib.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
@@ -20,8 +24,6 @@
#include "llvm/Support/Casting.h"
#include "llvm/Support/raw_ostream.h"
#include "lldb/Core/Log.h"
-#include "lldb/Expression/ClangPersistentVariables.h"
-#include "lldb/Expression/ASTResultSynthesizer.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ClangASTImporter.h"
#include "lldb/Target/Target.h"
@@ -462,7 +464,7 @@ ASTResultSynthesizer::MaybeRecordPersistentType(TypeDecl *D)
D);
if (TypeDecl *TypeDecl_scratch = dyn_cast<TypeDecl>(D_scratch))
- m_target.GetPersistentVariables().RegisterPersistentType(name_cs, TypeDecl_scratch);
+ llvm::cast<ClangPersistentVariables>(m_target.GetPersistentExpressionStateForLanguage(lldb::eLanguageTypeC))->RegisterPersistentType(name_cs, TypeDecl_scratch);
}
void
diff --git a/include/lldb/Expression/ASTResultSynthesizer.h b/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.h
index 410a862fc12a..9f7bbe05b082 100644
--- a/include/lldb/Expression/ASTResultSynthesizer.h
+++ b/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.h
@@ -12,7 +12,7 @@
#include "clang/Sema/SemaConsumer.h"
#include "lldb/Core/ClangForward.h"
-#include "lldb/Symbol/TaggedASTType.h"
+#include "lldb/Target/Target.h"
namespace lldb_private {
@@ -51,7 +51,7 @@ public:
//----------------------------------------------------------------------
/// Destructor
//----------------------------------------------------------------------
- ~ASTResultSynthesizer();
+ ~ASTResultSynthesizer() override;
//----------------------------------------------------------------------
/// Link this consumer with a particular AST context
@@ -60,7 +60,7 @@ public:
/// 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);
+ void Initialize(clang::ASTContext &Context) override;
//----------------------------------------------------------------------
/// Examine a list of Decls to find the function $__lldb_expr and
@@ -71,32 +71,32 @@ public:
/// which need to be searched recursively. That job falls to
/// TransformTopLevelDecl.
//----------------------------------------------------------------------
- bool HandleTopLevelDecl(clang::DeclGroupRef D);
+ bool HandleTopLevelDecl(clang::DeclGroupRef D) override;
//----------------------------------------------------------------------
/// Passthrough stub
//----------------------------------------------------------------------
- void HandleTranslationUnit(clang::ASTContext &Ctx);
+ void HandleTranslationUnit(clang::ASTContext &Ctx) override;
//----------------------------------------------------------------------
/// Passthrough stub
//----------------------------------------------------------------------
- void HandleTagDeclDefinition(clang::TagDecl *D);
+ void HandleTagDeclDefinition(clang::TagDecl *D) override;
//----------------------------------------------------------------------
/// Passthrough stub
//----------------------------------------------------------------------
- void CompleteTentativeDefinition(clang::VarDecl *D);
+ void CompleteTentativeDefinition(clang::VarDecl *D) override;
//----------------------------------------------------------------------
/// Passthrough stub
//----------------------------------------------------------------------
- void HandleVTable(clang::CXXRecordDecl *RD);
+ void HandleVTable(clang::CXXRecordDecl *RD) override;
//----------------------------------------------------------------------
/// Passthrough stub
//----------------------------------------------------------------------
- void PrintStats();
+ void PrintStats() override;
//----------------------------------------------------------------------
/// Set the Sema object to use when performing transforms, and pass it on
@@ -105,12 +105,13 @@ public:
/// 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);
+ void InitializeSema(clang::Sema &S) override;
//----------------------------------------------------------------------
/// Reset the Sema to NULL now that transformations are done
//----------------------------------------------------------------------
- void ForgetSema();
+ void ForgetSema() override;
+
private:
//----------------------------------------------------------------------
/// Hunt the given Decl for FunctionDecls named $__lldb_expr, recursing
@@ -179,6 +180,6 @@ private:
clang::Sema *m_sema; ///< The Sema to use.
};
-}
+} // namespace lldb_private
-#endif
+#endif // liblldb_ASTResultSynthesizer_h_
diff --git a/source/Expression/ASTStructExtractor.cpp b/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp
index 98628dbc92be..38a2b6b33a8a 100644
--- a/source/Expression/ASTStructExtractor.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+#include "ASTStructExtractor.h"
+
#include "stdlib.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
@@ -20,7 +22,6 @@
#include "llvm/Support/Casting.h"
#include "llvm/Support/raw_ostream.h"
#include "lldb/Core/Log.h"
-#include "lldb/Expression/ASTStructExtractor.h"
using namespace llvm;
using namespace clang;
@@ -28,7 +29,7 @@ using namespace lldb_private;
ASTStructExtractor::ASTStructExtractor(ASTConsumer *passthrough,
const char *struct_name,
- ClangFunction &function) :
+ ClangFunctionCaller &function) :
m_ast_context (NULL),
m_passthrough (passthrough),
m_passthrough_sema (NULL),
diff --git a/include/lldb/Expression/ASTStructExtractor.h b/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.h
index 25193744c9e0..2152cff911ff 100644
--- a/include/lldb/Expression/ASTStructExtractor.h
+++ b/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.h
@@ -10,10 +10,11 @@
#ifndef liblldb_ASTStructExtractor_h_
#define liblldb_ASTStructExtractor_h_
+#include "ClangExpressionVariable.h"
+#include "ClangFunctionCaller.h"
+
#include "clang/Sema/SemaConsumer.h"
#include "lldb/Core/ClangForward.h"
-#include "lldb/Expression/ClangExpressionVariable.h"
-#include "lldb/Expression/ClangFunction.h"
namespace lldb_private {
@@ -21,9 +22,9 @@ namespace lldb_private {
/// @class ASTStructExtractor ASTStructExtractor.h "lldb/Expression/ASTStructExtractor.h"
/// @brief Extracts and describes the argument structure for a wrapped function.
///
-/// This pass integrates with ClangFunction, which calls functions with custom
+/// This pass integrates with ClangFunctionCaller, which calls functions with custom
/// sets of arguments. To avoid having to implement the full calling convention
-/// for the target's architecture, ClangFunction writes a simple wrapper
+/// for the target's architecture, ClangFunctionCaller writes a simple wrapper
/// function that takes a pointer to an argument structure that contains room
/// for the address of the function to be called, the values of all its
/// arguments, and room for the function's return value.
@@ -49,17 +50,17 @@ public:
///
/// @param[in] function
/// The caller object whose members should be populated with information
- /// about the argument struct. ClangFunction friends ASTStructExtractor
+ /// about the argument struct. ClangFunctionCaller friends ASTStructExtractor
/// for this purpose.
//----------------------------------------------------------------------
ASTStructExtractor(clang::ASTConsumer *passthrough,
const char *struct_name,
- ClangFunction &function);
+ ClangFunctionCaller &function);
//----------------------------------------------------------------------
/// Destructor
//----------------------------------------------------------------------
- virtual ~ASTStructExtractor();
+ ~ASTStructExtractor() override;
//----------------------------------------------------------------------
/// Link this consumer with a particular AST context
@@ -68,7 +69,7 @@ public:
/// 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);
+ void Initialize(clang::ASTContext &Context) override;
//----------------------------------------------------------------------
/// Examine a list of Decls to find the function $__lldb_expr and
@@ -79,32 +80,32 @@ public:
/// which need to be searched recursively. That job falls to
/// TransformTopLevelDecl.
//----------------------------------------------------------------------
- bool HandleTopLevelDecl(clang::DeclGroupRef D);
+ bool HandleTopLevelDecl(clang::DeclGroupRef D) override;
//----------------------------------------------------------------------
/// Passthrough stub
//----------------------------------------------------------------------
- void HandleTranslationUnit(clang::ASTContext &Ctx);
+ void HandleTranslationUnit(clang::ASTContext &Ctx) override;
//----------------------------------------------------------------------
/// Passthrough stub
//----------------------------------------------------------------------
- void HandleTagDeclDefinition(clang::TagDecl *D);
+ void HandleTagDeclDefinition(clang::TagDecl *D) override;
//----------------------------------------------------------------------
/// Passthrough stub
//----------------------------------------------------------------------
- void CompleteTentativeDefinition(clang::VarDecl *D);
+ void CompleteTentativeDefinition(clang::VarDecl *D) override;
//----------------------------------------------------------------------
/// Passthrough stub
//----------------------------------------------------------------------
- void HandleVTable(clang::CXXRecordDecl *RD);
+ void HandleVTable(clang::CXXRecordDecl *RD) override;
//----------------------------------------------------------------------
/// Passthrough stub
//----------------------------------------------------------------------
- void PrintStats();
+ void PrintStats() override;
//----------------------------------------------------------------------
/// Set the Sema object to use when performing transforms, and pass it on
@@ -113,12 +114,13 @@ public:
/// 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);
+ void InitializeSema(clang::Sema &S) override;
//----------------------------------------------------------------------
/// Reset the Sema to NULL now that transformations are done
//----------------------------------------------------------------------
- void ForgetSema();
+ void ForgetSema() override;
+
private:
//----------------------------------------------------------------------
/// Hunt the given FunctionDecl for the argument struct and place
@@ -147,10 +149,10 @@ private:
clang::Sema *m_sema; ///< The Sema to use.
clang::Action *m_action; ///< The Sema to use, cast to an Action so it's usable.
- ClangFunction &m_function; ///< The function to populate with information about the argument structure.
+ ClangFunctionCaller &m_function; ///< The function to populate with information about the argument structure.
std::string m_struct_name; ///< The name of the structure to extract.
};
-}
+} // namespace lldb_private
-#endif
+#endif // liblldb_ASTStructExtractor_h_
diff --git a/source/Expression/ClangASTSource.cpp b/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index 3988cd674afd..d2ea4390560a 100644
--- a/source/Expression/ClangASTSource.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -7,18 +7,18 @@
//
//===----------------------------------------------------------------------===//
+#include "ClangASTSource.h"
+
+#include "ASTDumper.h"
+#include "ClangModulesDeclVendor.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/RecordLayout.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
-#include "lldb/Expression/ASTDumper.h"
-#include "lldb/Expression/ClangASTSource.h"
-#include "lldb/Expression/ClangExpression.h"
-#include "lldb/Expression/ClangModulesDeclVendor.h"
#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangNamespaceDecl.h"
+#include "lldb/Symbol/CompilerDeclContext.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/TaggedASTType.h"
@@ -57,7 +57,7 @@ namespace {
ClangASTSource::~ClangASTSource()
{
- m_ast_importer->ForgetDestination(m_ast_context);
+ m_ast_importer_sp->ForgetDestination(m_ast_context);
// We are in the process of destruction, don't create clang ast context on demand
// by passing false to Target::GetScratchClangASTContext(create_on_demand).
@@ -72,7 +72,7 @@ ClangASTSource::~ClangASTSource()
return;
if (m_ast_context != scratch_ast_context)
- m_ast_importer->ForgetSource(scratch_ast_context, m_ast_context);
+ m_ast_importer_sp->ForgetSource(scratch_ast_context, m_ast_context);
}
void
@@ -125,11 +125,10 @@ ClangASTSource::FindExternalVisibleDeclsByName
}
break;
- // Operator names. Not important for now.
+ // Operator names.
case DeclarationName::CXXOperatorName:
case DeclarationName::CXXLiteralOperatorName:
- SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
- return false;
+ break;
// Using directives found in this context.
// Tell Sema we didn't find any or we'll end up getting asked a *lot*.
@@ -222,7 +221,7 @@ ClangASTSource::CompleteType (TagDecl *tag_decl)
m_active_lexical_decls.insert(tag_decl);
ScopedLexicalDeclEraser eraser(m_active_lexical_decls, tag_decl);
- if (!m_ast_importer->CompleteTagDecl (tag_decl))
+ if (!m_ast_importer_sp->CompleteTagDecl (tag_decl))
{
// We couldn't complete the type. Maybe there's a definition
// somewhere else that can be completed.
@@ -236,7 +235,7 @@ ClangASTSource::CompleteType (TagDecl *tag_decl)
if (const NamespaceDecl *namespace_context = dyn_cast<NamespaceDecl>(decl_ctx))
{
- ClangASTImporter::NamespaceMapSP namespace_map = m_ast_importer->GetNamespaceMap(namespace_context);
+ ClangASTImporter::NamespaceMapSP namespace_map = m_ast_importer_sp->GetNamespaceMap(namespace_context);
if (log && log->GetVerbose())
log->Printf(" CTD[%u] Inspecting namespace map %p (%d entries)",
@@ -253,7 +252,7 @@ ClangASTSource::CompleteType (TagDecl *tag_decl)
if (log)
log->Printf(" CTD[%u] Searching namespace %s in module %s",
current_id,
- i->second.GetNamespaceDecl()->getNameAsString().c_str(),
+ i->second.GetName().AsCString(),
i->first->GetFileSpec().GetFilename().GetCString());
TypeList types;
@@ -272,19 +271,19 @@ ClangASTSource::CompleteType (TagDecl *tag_decl)
if (!type)
continue;
- ClangASTType clang_type (type->GetClangFullType());
+ CompilerType clang_type (type->GetFullCompilerType ());
if (!clang_type)
continue;
- const TagType *tag_type = clang_type.GetQualType()->getAs<TagType>();
+ const TagType *tag_type = ClangASTContext::GetQualType(clang_type)->getAs<TagType>();
if (!tag_type)
continue;
TagDecl *candidate_tag_decl = const_cast<TagDecl*>(tag_type->getDecl());
- if (m_ast_importer->CompleteTagDeclWithOrigin (tag_decl, candidate_tag_decl))
+ if (m_ast_importer_sp->CompleteTagDeclWithOrigin (tag_decl, candidate_tag_decl))
found = true;
}
}
@@ -295,7 +294,7 @@ ClangASTSource::CompleteType (TagDecl *tag_decl)
SymbolContext null_sc;
ConstString name(tag_decl->getName().str().c_str());
- ClangNamespaceDecl namespace_decl;
+ CompilerDeclContext namespace_decl;
const ModuleList &module_list = m_target->GetImages();
@@ -311,19 +310,24 @@ ClangASTSource::CompleteType (TagDecl *tag_decl)
if (!type)
continue;
- ClangASTType clang_type (type->GetClangFullType());
+ CompilerType clang_type (type->GetFullCompilerType ());
if (!clang_type)
continue;
- const TagType *tag_type = clang_type.GetQualType()->getAs<TagType>();
+ const TagType *tag_type = ClangASTContext::GetQualType(clang_type)->getAs<TagType>();
if (!tag_type)
continue;
TagDecl *candidate_tag_decl = const_cast<TagDecl*>(tag_type->getDecl());
- if (m_ast_importer->CompleteTagDeclWithOrigin (tag_decl, candidate_tag_decl))
+ // We have found a type by basename and we need to make sure the decl contexts
+ // are the same before we can try to complete this type with another
+ if (!ClangASTContext::DeclsAreEquivalent (tag_decl, candidate_tag_decl))
+ continue;
+
+ if (m_ast_importer_sp->CompleteTagDeclWithOrigin (tag_decl, candidate_tag_decl))
found = true;
}
}
@@ -355,7 +359,7 @@ ClangASTSource::CompleteType (clang::ObjCInterfaceDecl *interface_decl)
Decl *original_decl = NULL;
ASTContext *original_ctx = NULL;
- if (m_ast_importer->ResolveDeclOrigin(interface_decl, &original_decl, &original_ctx))
+ if (m_ast_importer_sp->ResolveDeclOrigin(interface_decl, &original_decl, &original_ctx))
{
if (ObjCInterfaceDecl *original_iface_decl = dyn_cast<ObjCInterfaceDecl>(original_decl))
{
@@ -363,12 +367,12 @@ ClangASTSource::CompleteType (clang::ObjCInterfaceDecl *interface_decl)
if (complete_iface_decl && (complete_iface_decl != original_iface_decl))
{
- m_ast_importer->SetDeclOrigin(interface_decl, original_iface_decl);
+ m_ast_importer_sp->SetDeclOrigin(interface_decl, original_iface_decl);
}
}
}
- m_ast_importer->CompleteObjCInterfaceDecl (interface_decl);
+ m_ast_importer_sp->CompleteObjCInterfaceDecl (interface_decl);
if (interface_decl->getSuperClass() &&
interface_decl->getSuperClass() != interface_decl)
@@ -402,8 +406,8 @@ ClangASTSource::GetCompleteObjCInterface (clang::ObjCInterfaceDecl *interface_de
if (!complete_type_sp)
return NULL;
- TypeFromUser complete_type = TypeFromUser(complete_type_sp->GetClangFullType());
- lldb::clang_type_t complete_opaque_type = complete_type.GetOpaqueQualType();
+ TypeFromUser complete_type = TypeFromUser(complete_type_sp->GetFullCompilerType ());
+ lldb::opaque_compiler_type_t complete_opaque_type = complete_type.GetOpaqueQualType();
if (!complete_opaque_type)
return NULL;
@@ -419,9 +423,9 @@ ClangASTSource::GetCompleteObjCInterface (clang::ObjCInterfaceDecl *interface_de
return complete_iface_decl;
}
-clang::ExternalLoadResult
+void
ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
- bool (*predicate)(Decl::Kind),
+ llvm::function_ref<bool(Decl::Kind)> predicate,
llvm::SmallVectorImpl<Decl*> &decls)
{
ClangASTMetrics::RegisterLexicalQuery();
@@ -431,11 +435,11 @@ ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
const Decl *context_decl = dyn_cast<Decl>(decl_context);
if (!context_decl)
- return ELR_Failure;
+ return;
auto iter = m_active_lexical_decls.find(context_decl);
if (iter != m_active_lexical_decls.end())
- return ELR_Failure;
+ return;
m_active_lexical_decls.insert(context_decl);
ScopedLexicalDeclEraser eraser(m_active_lexical_decls, context_decl);
@@ -445,29 +449,26 @@ ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
if (log)
{
if (const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context_decl))
- log->Printf("FindExternalLexicalDecls[%u] on (ASTContext*)%p in '%s' (%sDecl*)%p with %s predicate",
+ log->Printf("FindExternalLexicalDecls[%u] on (ASTContext*)%p in '%s' (%sDecl*)%p",
current_id, static_cast<void*>(m_ast_context),
context_named_decl->getNameAsString().c_str(),
context_decl->getDeclKindName(),
- static_cast<const void*>(context_decl),
- (predicate ? "non-null" : "null"));
+ static_cast<const void*>(context_decl));
else if(context_decl)
- log->Printf("FindExternalLexicalDecls[%u] on (ASTContext*)%p in (%sDecl*)%p with %s predicate",
+ log->Printf("FindExternalLexicalDecls[%u] on (ASTContext*)%p in (%sDecl*)%p",
current_id, static_cast<void*>(m_ast_context),
context_decl->getDeclKindName(),
- static_cast<const void*>(context_decl),
- (predicate ? "non-null" : "null"));
+ static_cast<const void*>(context_decl));
else
- log->Printf("FindExternalLexicalDecls[%u] on (ASTContext*)%p in a NULL context with %s predicate",
- current_id, static_cast<const void*>(m_ast_context),
- (predicate ? "non-null" : "null"));
+ log->Printf("FindExternalLexicalDecls[%u] on (ASTContext*)%p in a NULL context",
+ current_id, static_cast<const void*>(m_ast_context));
}
Decl *original_decl = NULL;
ASTContext *original_ctx = NULL;
- if (!m_ast_importer->ResolveDeclOrigin(context_decl, &original_decl, &original_ctx))
- return ELR_Failure;
+ if (!m_ast_importer_sp->ResolveDeclOrigin(context_decl, &original_decl, &original_ctx))
+ return;
if (log)
{
@@ -486,7 +487,7 @@ ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
original_decl = complete_iface_decl;
original_ctx = &complete_iface_decl->getASTContext();
- m_ast_importer->SetDeclOrigin(context_decl, original_iface_decl);
+ m_ast_importer_sp->SetDeclOrigin(context_decl, original_iface_decl);
}
}
@@ -501,7 +502,7 @@ ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
const DeclContext *original_decl_context = dyn_cast<DeclContext>(original_decl);
if (!original_decl_context)
- return ELR_Failure;
+ return;
for (TagDecl::decl_iterator iter = original_decl_context->decls_begin();
iter != original_decl_context->decls_end();
@@ -509,7 +510,7 @@ ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
{
Decl *decl = *iter;
- if (!predicate || predicate(decl->getKind()))
+ if (predicate(decl->getKind()))
{
if (log)
{
@@ -519,8 +520,8 @@ ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
else
log->Printf(" FELD[%d] Adding lexical %sDecl %s", current_id, decl->getDeclKindName(), ast_dumper.GetCString());
}
-
- Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, original_ctx, decl);
+
+ Decl *copied_decl = m_ast_importer_sp->CopyDecl(m_ast_context, original_ctx, decl);
if (!copied_decl)
continue;
@@ -529,11 +530,9 @@ ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
{
QualType copied_field_type = copied_field->getType();
- m_ast_importer->RequireCompleteType(copied_field_type);
+ m_ast_importer_sp->RequireCompleteType(copied_field_type);
}
- decls.push_back(copied_decl);
-
DeclContext *decl_context_non_const = const_cast<DeclContext *>(decl_context);
if (copied_decl->getDeclContext() != decl_context)
@@ -548,7 +547,7 @@ ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
}
}
- return ELR_AlreadyLoaded;
+ return;
}
void
@@ -587,7 +586,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context)
if (const NamespaceDecl *namespace_context = dyn_cast<NamespaceDecl>(context.m_decl_context))
{
- ClangASTImporter::NamespaceMapSP namespace_map = m_ast_importer->GetNamespaceMap(namespace_context);
+ ClangASTImporter::NamespaceMapSP namespace_map = m_ast_importer_sp->GetNamespaceMap(namespace_context);
if (log && log->GetVerbose())
log->Printf(" CAS::FEVD[%u] Inspecting namespace map %p (%d entries)",
@@ -604,7 +603,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context)
if (log)
log->Printf(" CAS::FEVD[%u] Searching namespace %s in module %s",
current_id,
- i->second.GetNamespaceDecl()->getNameAsString().c_str(),
+ i->second.GetName().AsCString(),
i->first->GetFileSpec().GetFilename().GetCString());
FindExternalVisibleDecls(context,
@@ -624,7 +623,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context)
}
else
{
- ClangNamespaceDecl namespace_decl;
+ CompilerDeclContext namespace_decl;
if (log)
log->Printf(" CAS::FEVD[%u] Searching the root namespace", current_id);
@@ -653,7 +652,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context)
void
ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
lldb::ModuleSP module_sp,
- ClangNamespaceDecl &namespace_decl,
+ CompilerDeclContext &namespace_decl,
unsigned int current_id)
{
assert (m_ast_context);
@@ -681,7 +680,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
if (module_sp && namespace_decl)
{
- ClangNamespaceDecl found_namespace_decl;
+ CompilerDeclContext found_namespace_decl;
SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor();
@@ -693,7 +692,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
if (found_namespace_decl)
{
- context.m_namespace_map->push_back(std::pair<lldb::ModuleSP, ClangNamespaceDecl>(module_sp, found_namespace_decl));
+ context.m_namespace_map->push_back(std::pair<lldb::ModuleSP, CompilerDeclContext>(module_sp, found_namespace_decl));
if (log)
log->Printf(" CAS::FEVD[%u] Found namespace %s in module %s",
@@ -715,7 +714,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
if (!image)
continue;
- ClangNamespaceDecl found_namespace_decl;
+ CompilerDeclContext found_namespace_decl;
SymbolVendor *symbol_vendor = image->GetSymbolVendor();
@@ -728,7 +727,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
if (found_namespace_decl)
{
- context.m_namespace_map->push_back(std::pair<lldb::ModuleSP, ClangNamespaceDecl>(image, found_namespace_decl));
+ context.m_namespace_map->push_back(std::pair<lldb::ModuleSP, CompilerDeclContext>(image, found_namespace_decl));
if (log)
log->Printf(" CAS::FEVD[%u] Found namespace %s in module %s",
@@ -752,38 +751,42 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
bool found_a_type = false;
- if (types.GetSize())
+ if (size_t num_types = types.GetSize())
{
- lldb::TypeSP type_sp = types.GetTypeAtIndex(0);
-
- if (log)
- {
- const char *name_string = type_sp->GetName().GetCString();
-
- log->Printf(" CAS::FEVD[%u] Matching type found for \"%s\": %s",
- current_id,
- name.GetCString(),
- (name_string ? name_string : "<anonymous>"));
- }
-
- ClangASTType full_type = type_sp->GetClangFullType();
-
- ClangASTType copied_clang_type (GuardedCopyType(full_type));
-
- if (!copied_clang_type)
+ for (size_t ti = 0; ti < num_types; ++ti)
{
+ lldb::TypeSP type_sp = types.GetTypeAtIndex(ti);
+
if (log)
- log->Printf(" CAS::FEVD[%u] - Couldn't export a type",
- current_id);
-
+ {
+ const char *name_string = type_sp->GetName().GetCString();
+
+ log->Printf(" CAS::FEVD[%u] Matching type found for \"%s\": %s",
+ current_id,
+ name.GetCString(),
+ (name_string ? name_string : "<anonymous>"));
+ }
+
+ CompilerType full_type = type_sp->GetFullCompilerType();
+
+ CompilerType copied_clang_type (GuardedCopyType(full_type));
+
+ if (!copied_clang_type)
+ {
+ if (log)
+ log->Printf(" CAS::FEVD[%u] - Couldn't export a type",
+ current_id);
+
+ continue;
+ }
+
+ context.AddTypeDecl(copied_clang_type);
+
+ found_a_type = true;
break;
}
-
- context.AddTypeDecl(copied_clang_type);
-
- found_a_type = true;
}
-
+
if (!found_a_type)
{
// Try the modules next.
@@ -815,7 +818,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
llvm::isa<clang::ObjCContainerDecl>(decl_from_modules) ||
llvm::isa<clang::EnumConstantDecl>(decl_from_modules))
{
- clang::Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, &decl_from_modules->getASTContext(), decl_from_modules);
+ clang::Decl *copied_decl = m_ast_importer_sp->CopyDecl(m_ast_context, &decl_from_modules->getASTContext(), decl_from_modules);
clang::NamedDecl *copied_named_decl = copied_decl ? dyn_cast<clang::NamedDecl>(copied_decl) : nullptr;
if (!copied_named_decl)
@@ -873,7 +876,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
name.GetCString());
}
- clang::Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, &decls[0]->getASTContext(), decls[0]);
+ clang::Decl *copied_decl = m_ast_importer_sp->CopyDecl(m_ast_context, &decls[0]->getASTContext(), decls[0]);
clang::NamedDecl *copied_named_decl = copied_decl ? dyn_cast<clang::NamedDecl>(copied_decl) : nullptr;
if (!copied_named_decl)
@@ -1068,7 +1071,7 @@ ClangASTSource::FindObjCMethodDecls (NameSearchContext &context)
Decl *original_decl = NULL;
ASTContext *original_ctx = NULL;
- m_ast_importer->ResolveDeclOrigin(interface_decl, &original_decl, &original_ctx);
+ m_ast_importer_sp->ResolveDeclOrigin(interface_decl, &original_decl, &original_ctx);
if (!original_decl)
break;
@@ -1079,7 +1082,7 @@ ClangASTSource::FindObjCMethodDecls (NameSearchContext &context)
context,
original_interface_decl,
m_ast_context,
- m_ast_importer,
+ m_ast_importer_sp.get(),
"at origin"))
return; // found it, no need to look any further
} while (0);
@@ -1210,12 +1213,11 @@ ClangASTSource::FindObjCMethodDecls (NameSearchContext &context)
if (!sc.function)
continue;
- DeclContext *function_ctx = sc.function->GetClangDeclContext();
-
- if (!function_ctx)
+ CompilerDeclContext function_decl_ctx = sc.function->GetDeclContext();
+ if (!function_decl_ctx)
continue;
- ObjCMethodDecl *method_decl = dyn_cast<ObjCMethodDecl>(function_ctx);
+ ObjCMethodDecl *method_decl = ClangASTContext::DeclContextGetAsObjCMethodDecl(function_decl_ctx);
if (!method_decl)
continue;
@@ -1227,7 +1229,7 @@ ClangASTSource::FindObjCMethodDecls (NameSearchContext &context)
if (found_interface_decl->getName() == interface_decl->getName())
{
- Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, &method_decl->getASTContext(), method_decl);
+ Decl *copied_decl = m_ast_importer_sp->CopyDecl(m_ast_context, &method_decl->getASTContext(), method_decl);
if (!copied_decl)
continue;
@@ -1275,7 +1277,7 @@ ClangASTSource::FindObjCMethodDecls (NameSearchContext &context)
context,
complete_interface_decl,
m_ast_context,
- m_ast_importer,
+ m_ast_importer_sp.get(),
"in debug info");
return;
@@ -1308,7 +1310,7 @@ ClangASTSource::FindObjCMethodDecls (NameSearchContext &context)
context,
interface_decl_from_modules,
m_ast_context,
- m_ast_importer,
+ m_ast_importer_sp.get(),
"in modules"))
return;
}
@@ -1354,7 +1356,7 @@ ClangASTSource::FindObjCMethodDecls (NameSearchContext &context)
context,
runtime_interface_decl,
m_ast_context,
- m_ast_importer,
+ m_ast_importer_sp.get(),
"in runtime");
}
while(0);
@@ -1426,7 +1428,7 @@ ClangASTSource::FindObjCPropertyAndIvarDecls (NameSearchContext &context)
unsigned int current_id = invocation_id++;
DeclFromParser<const ObjCInterfaceDecl> parser_iface_decl(cast<ObjCInterfaceDecl>(context.m_decl_context));
- DeclFromUser<const ObjCInterfaceDecl> origin_iface_decl(parser_iface_decl.GetOrigin(m_ast_importer));
+ DeclFromUser<const ObjCInterfaceDecl> origin_iface_decl(parser_iface_decl.GetOrigin(m_ast_importer_sp.get()));
ConstString class_name(parser_iface_decl->getNameAsString().c_str());
@@ -1439,7 +1441,7 @@ ClangASTSource::FindObjCPropertyAndIvarDecls (NameSearchContext &context)
if (FindObjCPropertyAndIvarDeclsWithOrigin(current_id,
context,
*m_ast_context,
- m_ast_importer,
+ m_ast_importer_sp.get(),
origin_iface_decl))
return;
@@ -1474,7 +1476,7 @@ ClangASTSource::FindObjCPropertyAndIvarDecls (NameSearchContext &context)
FindObjCPropertyAndIvarDeclsWithOrigin(current_id,
context,
*m_ast_context,
- m_ast_importer,
+ m_ast_importer_sp.get(),
complete_iface_decl);
return;
@@ -1514,7 +1516,7 @@ ClangASTSource::FindObjCPropertyAndIvarDecls (NameSearchContext &context)
if (FindObjCPropertyAndIvarDeclsWithOrigin(current_id,
context,
*m_ast_context,
- m_ast_importer,
+ m_ast_importer_sp.get(),
interface_decl_from_modules))
return;
}
@@ -1564,7 +1566,7 @@ ClangASTSource::FindObjCPropertyAndIvarDecls (NameSearchContext &context)
if (FindObjCPropertyAndIvarDeclsWithOrigin(current_id,
context,
*m_ast_context,
- m_ast_importer,
+ m_ast_importer_sp.get(),
interface_decl_from_runtime))
return;
}
@@ -1667,7 +1669,7 @@ ClangASTSource::layoutRecordType(const RecordDecl *record, uint64_t &size, uint6
record->getNameAsString().c_str());
DeclFromParser <const RecordDecl> parser_record(record);
- DeclFromUser <const RecordDecl> origin_record(parser_record.GetOrigin(m_ast_importer));
+ DeclFromUser <const RecordDecl> origin_record(parser_record.GetOrigin(m_ast_importer_sp.get()));
if (origin_record.IsInvalid())
return false;
@@ -1678,7 +1680,8 @@ ClangASTSource::layoutRecordType(const RecordDecl *record, uint64_t &size, uint6
ClangASTContext::GetCompleteDecl(&origin_record->getASTContext(), const_cast<RecordDecl*>(origin_record.decl));
- if (!origin_record.decl->getDefinition())
+ clang::RecordDecl* definition = origin_record.decl->getDefinition();
+ if (!definition || !definition->isCompleteDefinition())
return false;
const ASTRecordLayout &record_layout(origin_record->getASTContext().getASTRecordLayout(origin_record.decl));
@@ -1708,9 +1711,9 @@ ClangASTSource::layoutRecordType(const RecordDecl *record, uint64_t &size, uint6
return false;
}
- if (!ImportOffsetMap(field_offsets, origin_field_offsets, m_ast_importer, parser_ast_context) ||
- !ImportOffsetMap(base_offsets, origin_base_offsets, m_ast_importer, parser_ast_context) ||
- !ImportOffsetMap(virtual_base_offsets, origin_virtual_base_offsets, m_ast_importer, parser_ast_context))
+ if (!ImportOffsetMap(field_offsets, origin_field_offsets, m_ast_importer_sp.get(), parser_ast_context) ||
+ !ImportOffsetMap(base_offsets, origin_base_offsets, m_ast_importer_sp.get(), parser_ast_context) ||
+ !ImportOffsetMap(virtual_base_offsets, origin_virtual_base_offsets, m_ast_importer_sp.get(), parser_ast_context))
return false;
size = record_layout.getSize().getQuantity() * m_ast_context->getCharWidth();
@@ -1778,7 +1781,7 @@ ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespac
log->Printf("CompleteNamespaceMap[%u] on (ASTContext*)%p Searching for namespace %s in namespace %s",
current_id, static_cast<void*>(m_ast_context),
name.GetCString(),
- parent_map->begin()->second.GetNamespaceDecl()->getDeclName().getAsString().c_str());
+ parent_map->begin()->second.GetName().AsCString());
else
log->Printf("CompleteNamespaceMap[%u] on (ASTContext*)%p Searching for namespace %s",
current_id, static_cast<void*>(m_ast_context),
@@ -1791,10 +1794,10 @@ ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespac
i != e;
++i)
{
- ClangNamespaceDecl found_namespace_decl;
+ CompilerDeclContext found_namespace_decl;
lldb::ModuleSP module_sp = i->first;
- ClangNamespaceDecl module_parent_namespace_decl = i->second;
+ CompilerDeclContext module_parent_namespace_decl = i->second;
SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor();
@@ -1808,7 +1811,7 @@ ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespac
if (!found_namespace_decl)
continue;
- namespace_map->push_back(std::pair<lldb::ModuleSP, ClangNamespaceDecl>(module_sp, found_namespace_decl));
+ namespace_map->push_back(std::pair<lldb::ModuleSP, CompilerDeclContext>(module_sp, found_namespace_decl));
if (log)
log->Printf(" CMN[%u] Found namespace %s in module %s",
@@ -1822,7 +1825,7 @@ ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespac
const ModuleList &target_images = m_target->GetImages();
Mutex::Locker modules_locker(target_images.GetMutex());
- ClangNamespaceDecl null_namespace_decl;
+ CompilerDeclContext null_namespace_decl;
for (size_t i = 0, e = target_images.GetSize(); i < e; ++i)
{
@@ -1831,7 +1834,7 @@ ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespac
if (!image)
continue;
- ClangNamespaceDecl found_namespace_decl;
+ CompilerDeclContext found_namespace_decl;
SymbolVendor *symbol_vendor = image->GetSymbolVendor();
@@ -1845,7 +1848,7 @@ ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespac
if (!found_namespace_decl)
continue;
- namespace_map->push_back(std::pair<lldb::ModuleSP, ClangNamespaceDecl>(image, found_namespace_decl));
+ namespace_map->push_back(std::pair<lldb::ModuleSP, CompilerDeclContext>(image, found_namespace_decl));
if (log)
log->Printf(" CMN[%u] Found namespace %s in module %s",
@@ -1860,64 +1863,80 @@ NamespaceDecl *
ClangASTSource::AddNamespace (NameSearchContext &context, ClangASTImporter::NamespaceMapSP &namespace_decls)
{
if (!namespace_decls)
- return NULL;
+ return nullptr;
- const ClangNamespaceDecl &namespace_decl = namespace_decls->begin()->second;
+ const CompilerDeclContext &namespace_decl = namespace_decls->begin()->second;
- Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, namespace_decl.GetASTContext(), namespace_decl.GetNamespaceDecl());
+ clang::ASTContext *src_ast = ClangASTContext::DeclContextGetClangASTContext(namespace_decl);
+ if (!src_ast)
+ return nullptr;
+ clang::NamespaceDecl *src_namespace_decl = ClangASTContext::DeclContextGetAsNamespaceDecl(namespace_decl);
+
+ if (!src_namespace_decl)
+ return nullptr;
+
+ Decl *copied_decl = m_ast_importer_sp->CopyDecl(m_ast_context, src_ast, src_namespace_decl);
if (!copied_decl)
- return NULL;
+ return nullptr;
NamespaceDecl *copied_namespace_decl = dyn_cast<NamespaceDecl>(copied_decl);
if (!copied_namespace_decl)
- return NULL;
+ return nullptr;
context.m_decls.push_back(copied_namespace_decl);
- m_ast_importer->RegisterNamespaceMap(copied_namespace_decl, namespace_decls);
+ m_ast_importer_sp->RegisterNamespaceMap(copied_namespace_decl, namespace_decls);
return dyn_cast<NamespaceDecl>(copied_decl);
}
-ClangASTType
-ClangASTSource::GuardedCopyType (const ClangASTType &src_type)
+CompilerType
+ClangASTSource::GuardedCopyType (const CompilerType &src_type)
{
+ ClangASTContext *src_ast = llvm::dyn_cast_or_null<ClangASTContext>(src_type.GetTypeSystem());
+ if (src_ast == nullptr)
+ return CompilerType();
+
ClangASTMetrics::RegisterLLDBImport();
SetImportInProgress(true);
- QualType copied_qual_type = m_ast_importer->CopyType (m_ast_context, src_type.GetASTContext(), src_type.GetQualType());
+ QualType copied_qual_type = m_ast_importer_sp->CopyType (m_ast_context, src_ast->getASTContext(), ClangASTContext::GetQualType(src_type));
SetImportInProgress(false);
if (copied_qual_type.getAsOpaquePtr() && copied_qual_type->getCanonicalTypeInternal().isNull())
// this shouldn't happen, but we're hardening because the AST importer seems to be generating bad types
// on occasion.
- return ClangASTType();
+ return CompilerType();
- return ClangASTType(m_ast_context, copied_qual_type);
+ return CompilerType(m_ast_context, copied_qual_type);
}
clang::NamedDecl *
-NameSearchContext::AddVarDecl(const ClangASTType &type)
+NameSearchContext::AddVarDecl(const CompilerType &type)
{
assert (type && "Type for variable must be valid!");
if (!type.IsValid())
return NULL;
+ ClangASTContext* lldb_ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
+ if (!lldb_ast)
+ return NULL;
+
IdentifierInfo *ii = m_decl_name.getAsIdentifierInfo();
- clang::ASTContext *ast = type.GetASTContext();
+ clang::ASTContext *ast = lldb_ast->getASTContext();
clang::NamedDecl *Decl = VarDecl::Create(*ast,
const_cast<DeclContext*>(m_decl_context),
SourceLocation(),
SourceLocation(),
ii,
- type.GetQualType(),
+ ClangASTContext::GetQualType(type),
0,
SC_Static);
m_decls.push_back(Decl);
@@ -1926,7 +1945,7 @@ NameSearchContext::AddVarDecl(const ClangASTType &type)
}
clang::NamedDecl *
-NameSearchContext::AddFunDecl (const ClangASTType &type, bool extern_c)
+NameSearchContext::AddFunDecl (const CompilerType &type, bool extern_c)
{
assert (type && "Type for variable must be valid!");
@@ -1935,12 +1954,16 @@ NameSearchContext::AddFunDecl (const ClangASTType &type, bool extern_c)
if (m_function_types.count(type))
return NULL;
+
+ ClangASTContext* lldb_ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
+ if (!lldb_ast)
+ return NULL;
m_function_types.insert(type);
- QualType qual_type (type.GetQualType());
+ QualType qual_type (ClangASTContext::GetQualType(type));
- clang::ASTContext *ast = type.GetASTContext();
+ clang::ASTContext *ast = lldb_ast->getASTContext();
const bool isInlineSpecified = false;
const bool hasWrittenPrototype = true;
@@ -1957,11 +1980,14 @@ NameSearchContext::AddFunDecl (const ClangASTType &type, bool extern_c)
false);
}
+ // Pass the identifier info for functions the decl_name is needed for operators
+ clang::DeclarationName decl_name = m_decl_name.getNameKind() == DeclarationName::Identifier ? m_decl_name.getAsIdentifierInfo() : m_decl_name;
+
clang::FunctionDecl *func_decl = FunctionDecl::Create (*ast,
context,
SourceLocation(),
SourceLocation(),
- m_decl_name.getAsIdentifierInfo(),
+ decl_name,
qual_type,
NULL,
SC_Extern,
@@ -2023,15 +2049,15 @@ NameSearchContext::AddGenericFunDecl()
ArrayRef<QualType>(), // argument types
proto_info));
- return AddFunDecl(ClangASTType (m_ast_source.m_ast_context, generic_function_type), true);
+ return AddFunDecl(CompilerType (m_ast_source.m_ast_context, generic_function_type), true);
}
clang::NamedDecl *
-NameSearchContext::AddTypeDecl(const ClangASTType &clang_type)
+NameSearchContext::AddTypeDecl(const CompilerType &clang_type)
{
if (clang_type)
{
- QualType qual_type = clang_type.GetQualType();
+ QualType qual_type = ClangASTContext::GetQualType(clang_type);
if (const TypedefType *typedef_type = llvm::dyn_cast<TypedefType>(qual_type))
{
diff --git a/include/lldb/Expression/ClangASTSource.h b/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
index 46140d2f2e64..bb6384721f51 100644
--- a/include/lldb/Expression/ClangASTSource.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
@@ -15,7 +15,7 @@
#include "clang/Basic/IdentifierTable.h"
#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
#include "lldb/Symbol/ClangASTImporter.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/Target.h"
#include "llvm/ADT/SmallSet.h"
@@ -54,13 +54,13 @@ public:
m_active_lexical_decls (),
m_active_lookups ()
{
- m_ast_importer = m_target->GetClangASTImporter();
+ m_ast_importer_sp = m_target->GetClangASTImporter();
}
//------------------------------------------------------------------
/// Destructor
//------------------------------------------------------------------
- ~ClangASTSource();
+ ~ClangASTSource() override;
//------------------------------------------------------------------
/// Interface stubs.
@@ -77,7 +77,7 @@ public:
void InstallASTContext (clang::ASTContext *ast_context)
{
m_ast_context = ast_context;
- m_ast_importer->InstallMapCompleter(ast_context, *this);
+ m_ast_importer_sp->InstallMapCompleter(ast_context, *this);
}
//
@@ -111,15 +111,15 @@ public:
/// The DeclContext being searched.
///
/// @param[in] isKindWeWant
- /// If non-NULL, a callback function that returns true given the
+ /// A callback function that returns true given the
/// DeclKinds of desired Decls, and false otherwise.
///
/// @param[in] Decls
/// A vector that is filled in with matching Decls.
//------------------------------------------------------------------
- clang::ExternalLoadResult FindExternalLexicalDecls(const clang::DeclContext *DC,
- bool (*isKindWeWant)(clang::Decl::Kind),
- llvm::SmallVectorImpl<clang::Decl *> &Decls) override;
+ 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.
@@ -249,11 +249,12 @@ public:
return m_original.FindExternalVisibleDeclsByName(DC, Name);
}
- clang::ExternalLoadResult
- FindExternalLexicalDecls(const clang::DeclContext *DC, bool (*isKindWeWant)(clang::Decl::Kind),
+ void
+ FindExternalLexicalDecls(const clang::DeclContext *DC,
+ llvm::function_ref<bool(clang::Decl::Kind)> IsKindWeWant,
llvm::SmallVectorImpl<clang::Decl *> &Decls) override
{
- return m_original.FindExternalLexicalDecls(DC, isKindWeWant, Decls);
+ return m_original.FindExternalLexicalDecls(DC, IsKindWeWant, Decls);
}
void
@@ -352,7 +353,7 @@ protected:
void
FindExternalVisibleDecls (NameSearchContext &context,
lldb::ModuleSP module,
- ClangNamespaceDecl &namespace_decl,
+ CompilerDeclContext &namespace_decl,
unsigned int current_id);
//------------------------------------------------------------------
@@ -388,14 +389,14 @@ protected:
/// The source AST context, typically the AST context of whatever
/// symbol file the type was found in.
///
- /// @param[in] clang_type
+ /// @param[in] src_type
/// The source type.
///
/// @return
/// The imported type.
//------------------------------------------------------------------
- ClangASTType
- GuardedCopyType (const ClangASTType &src_type);
+ CompilerType
+ GuardedCopyType (const CompilerType &src_type);
friend struct NameSearchContext;
@@ -404,7 +405,7 @@ protected:
const lldb::TargetSP m_target; ///< The target to use in finding variables and types.
clang::ASTContext *m_ast_context; ///< The AST context requests are coming in for.
- ClangASTImporter *m_ast_importer; ///< The target's AST importer.
+ lldb::ClangASTImporterSP m_ast_importer_sp; ///< The target's AST importer.
std::set<const clang::Decl *> m_active_lexical_decls;
std::set<const char *> m_active_lookups;
};
@@ -423,7 +424,7 @@ struct NameSearchContext {
ClangASTImporter::NamespaceMapSP m_namespace_map; ///< The mapping of all namespaces found for this request back to their modules
const clang::DeclarationName &m_decl_name; ///< The name being looked for
const clang::DeclContext *m_decl_context; ///< The DeclContext to put declarations into
- llvm::SmallSet <ClangASTType, 5> m_function_types; ///< All the types of functions that have been reported, so we don't report conflicts
+ llvm::SmallSet <CompilerType, 5> m_function_types; ///< All the types of functions that have been reported, so we don't report conflicts
struct {
bool variable : 1;
@@ -468,7 +469,7 @@ struct NameSearchContext {
/// @param[in] type
/// The opaque QualType for the VarDecl being registered.
//------------------------------------------------------------------
- clang::NamedDecl *AddVarDecl(const ClangASTType &type);
+ clang::NamedDecl *AddVarDecl(const CompilerType &type);
//------------------------------------------------------------------
/// Create a FunDecl with the name being searched for and the provided
@@ -480,7 +481,7 @@ struct NameSearchContext {
/// @param[in] extern_c
/// If true, build an extern "C" linkage specification for this.
//------------------------------------------------------------------
- clang::NamedDecl *AddFunDecl(const ClangASTType &type,
+ clang::NamedDecl *AddFunDecl(const CompilerType &type,
bool extern_c = false);
//------------------------------------------------------------------
@@ -494,10 +495,10 @@ struct NameSearchContext {
/// Create a TypeDecl with the name being searched for and the provided
/// type and register it in the right places.
///
- /// @param[in] type
+ /// @param[in] compiler_type
/// The opaque QualType for the TypeDecl being registered.
//------------------------------------------------------------------
- clang::NamedDecl *AddTypeDecl(const ClangASTType &clang_type);
+ clang::NamedDecl *AddTypeDecl(const CompilerType &compiler_type);
//------------------------------------------------------------------
@@ -520,6 +521,6 @@ struct NameSearchContext {
void AddNamedDecl (clang::NamedDecl *decl);
};
-}
+} // namespace lldb_private
-#endif
+#endif // liblldb_ClangASTSource_h_
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index 2c66a0aa4278..c9bc4b6487cd 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -7,7 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Expression/ClangExpressionDeclMap.h"
+#include "ClangExpressionDeclMap.h"
+
+#include "ASTDumper.h"
+#include "ClangASTSource.h"
+#include "ClangModulesDeclVendor.h"
+#include "ClangPersistentVariables.h"
+
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclarationName.h"
@@ -21,14 +27,11 @@
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectVariable.h"
-#include "lldb/Expression/ASTDumper.h"
-#include "lldb/Expression/ClangASTSource.h"
-#include "lldb/Expression/ClangModulesDeclVendor.h"
-#include "lldb/Expression/ClangPersistentVariables.h"
#include "lldb/Expression/Materializer.h"
#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangNamespaceDecl.h"
+#include "lldb/Symbol/CompilerDecl.h"
+#include "lldb/Symbol/CompilerDeclContext.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -47,15 +50,20 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
+
using namespace lldb;
using namespace lldb_private;
using namespace clang;
-ClangExpressionDeclMap::ClangExpressionDeclMap (bool keep_result_in_memory, ExecutionContext &exe_ctx) :
+ClangExpressionDeclMap::ClangExpressionDeclMap (bool keep_result_in_memory,
+ Materializer::PersistentVariableDelegate *result_delegate,
+ ExecutionContext &exe_ctx) :
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 ()
{
@@ -99,7 +107,7 @@ ClangExpressionDeclMap::WillParse(ExecutionContext &exe_ctx,
if (target)
{
- m_parser_vars->m_persistent_vars = &target->GetPersistentVariables();
+ m_parser_vars->m_persistent_vars = llvm::cast<ClangPersistentVariables>(target->GetPersistentExpressionStateForLanguage(eLanguageTypeC));
if (!target->GetScratchClangASTContext())
return false;
@@ -132,18 +140,18 @@ ClangExpressionDeclMap::DidParse()
entity_index < num_entities;
++entity_index)
{
- ClangExpressionVariableSP var_sp(m_found_entities.GetVariableAtIndex(entity_index));
+ ExpressionVariableSP var_sp(m_found_entities.GetVariableAtIndex(entity_index));
if (var_sp)
- var_sp->DisableParserVars(GetParserID());
+ llvm::cast<ClangExpressionVariable>(var_sp.get())->DisableParserVars(GetParserID());
}
for (size_t pvar_index = 0, num_pvars = m_parser_vars->m_persistent_vars->GetSize();
pvar_index < num_pvars;
++pvar_index)
{
- ClangExpressionVariableSP pvar_sp(m_parser_vars->m_persistent_vars->GetVariableAtIndex(pvar_index));
- if (pvar_sp)
- pvar_sp->DisableParserVars(GetParserID());
+ ExpressionVariableSP pvar_sp(m_parser_vars->m_persistent_vars->GetVariableAtIndex(pvar_index));
+ if (ClangExpressionVariable *clang_var = llvm::dyn_cast<ClangExpressionVariable>(pvar_sp.get()))
+ clang_var->DisableParserVars(GetParserID());
}
DisableParserVars();
@@ -192,43 +200,50 @@ ClangExpressionDeclMap::AddPersistentVariable
{
assert (m_parser_vars.get());
+ ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(parser_type.GetTypeSystem());
+ if (ast == nullptr)
+ return false;
+
if (m_parser_vars->m_materializer && is_result)
{
Error err;
ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
Target *target = exe_ctx.GetTargetPtr();
- if (target == NULL)
+ if (target == nullptr)
return false;
- ASTContext *context(target->GetScratchClangASTContext()->getASTContext());
+ ClangASTContext *context(target->GetScratchClangASTContext());
- TypeFromUser user_type(m_ast_importer->DeportType(context,
- parser_type.GetASTContext(),
- parser_type.GetOpaqueQualType()),
+ TypeFromUser user_type(m_ast_importer_sp->DeportType(context->getASTContext(),
+ ast->getASTContext(),
+ parser_type.GetOpaqueQualType()),
context);
+
+ uint32_t offset = m_parser_vars->m_materializer->AddResultVariable(user_type,
+ is_lvalue,
+ m_keep_result_in_memory,
+ m_result_delegate,
+ err);
+
+ ClangExpressionVariable *var = new ClangExpressionVariable(exe_ctx.GetBestExecutionContextScope(),
+ name,
+ user_type,
+ m_parser_vars->m_target_info.byte_order,
+ m_parser_vars->m_target_info.address_byte_size);
+
+ m_found_entities.AddNewlyConstructedVariable(var);
+
+ var->EnableParserVars(GetParserID());
- uint32_t offset = m_parser_vars->m_materializer->AddResultVariable(user_type, is_lvalue, m_keep_result_in_memory, err);
-
- ClangExpressionVariableSP var_sp = m_found_entities.CreateVariable(exe_ctx.GetBestExecutionContextScope(),
- name,
- user_type,
- m_parser_vars->m_target_info.byte_order,
- m_parser_vars->m_target_info.address_byte_size);
-
- if (!var_sp)
- return false;
-
- var_sp->EnableParserVars(GetParserID());
-
- ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(GetParserID());
+ ClangExpressionVariable::ParserVars *parser_vars = var->GetParserVars(GetParserID());
parser_vars->m_named_decl = decl;
parser_vars->m_parser_type = parser_type;
- var_sp->EnableJITVars(GetParserID());
+ var->EnableJITVars(GetParserID());
- ClangExpressionVariable::JITVars *jit_vars = var_sp->GetJITVars(GetParserID());
+ ClangExpressionVariable::JITVars *jit_vars = var->GetJITVars(GetParserID());
jit_vars->m_offset = offset;
@@ -241,11 +256,11 @@ ClangExpressionDeclMap::AddPersistentVariable
if (target == NULL)
return false;
- ASTContext *context(target->GetScratchClangASTContext()->getASTContext());
+ ClangASTContext *context(target->GetScratchClangASTContext());
- TypeFromUser user_type(m_ast_importer->DeportType(context,
- parser_type.GetASTContext(),
- parser_type.GetOpaqueQualType()),
+ TypeFromUser user_type(m_ast_importer_sp->DeportType(context->getASTContext(),
+ ast->getASTContext(),
+ parser_type.GetOpaqueQualType()),
context);
if (!user_type.GetOpaqueQualType())
@@ -258,43 +273,43 @@ ClangExpressionDeclMap::AddPersistentVariable
if (!m_parser_vars->m_target_info.IsValid())
return false;
- ClangExpressionVariableSP var_sp = m_parser_vars->m_persistent_vars->CreatePersistentVariable (exe_ctx.GetBestExecutionContextScope (),
- name,
- user_type,
- m_parser_vars->m_target_info.byte_order,
- m_parser_vars->m_target_info.address_byte_size);
+ ClangExpressionVariable *var = llvm::cast<ClangExpressionVariable>(m_parser_vars->m_persistent_vars->CreatePersistentVariable (exe_ctx.GetBestExecutionContextScope (),
+ name,
+ user_type,
+ m_parser_vars->m_target_info.byte_order,
+ m_parser_vars->m_target_info.address_byte_size).get());
- if (!var_sp)
+ if (!var)
return false;
- var_sp->m_frozen_sp->SetHasCompleteType();
+ var->m_frozen_sp->SetHasCompleteType();
if (is_result)
- var_sp->m_flags |= ClangExpressionVariable::EVNeedsFreezeDry;
+ var->m_flags |= ClangExpressionVariable::EVNeedsFreezeDry;
else
- var_sp->m_flags |= ClangExpressionVariable::EVKeepInTarget; // explicitly-declared persistent variables should persist
+ var->m_flags |= ClangExpressionVariable::EVKeepInTarget; // explicitly-declared persistent variables should persist
if (is_lvalue)
{
- var_sp->m_flags |= ClangExpressionVariable::EVIsProgramReference;
+ var->m_flags |= ClangExpressionVariable::EVIsProgramReference;
}
else
{
- var_sp->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
- var_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
+ var->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
+ var->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
}
if (m_keep_result_in_memory)
{
- var_sp->m_flags |= ClangExpressionVariable::EVKeepInTarget;
+ var->m_flags |= ClangExpressionVariable::EVKeepInTarget;
}
if (log)
- log->Printf("Created persistent variable with flags 0x%hx", var_sp->m_flags);
+ log->Printf("Created persistent variable with flags 0x%hx", var->m_flags);
- var_sp->EnableParserVars(GetParserID());
+ var->EnableParserVars(GetParserID());
- ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(GetParserID());
+ ClangExpressionVariable::ParserVars *parser_vars = var->GetParserVars(GetParserID());
parser_vars->m_named_decl = decl;
parser_vars->m_parser_type = parser_type;
@@ -321,33 +336,33 @@ ClangExpressionDeclMap::AddValueToStruct
m_struct_vars->m_struct_laid_out = false;
- if (m_struct_members.GetVariable(decl, GetParserID()))
+ if (ClangExpressionVariable::FindVariableInList(m_struct_members, decl, GetParserID()))
return true;
- ClangExpressionVariableSP var_sp (m_found_entities.GetVariable(decl, GetParserID()));
+ ClangExpressionVariable *var(ClangExpressionVariable::FindVariableInList(m_found_entities, decl, GetParserID()));
- if (!var_sp)
+ if (!var)
{
- var_sp = m_parser_vars->m_persistent_vars->GetVariable(decl, GetParserID());
+ var = ClangExpressionVariable::FindVariableInList(*m_parser_vars->m_persistent_vars, decl, GetParserID());
is_persistent_variable = true;
}
- if (!var_sp)
+ if (!var)
return false;
if (log)
log->Printf("Adding value for (NamedDecl*)%p [%s - %s] to the structure",
static_cast<const void*>(decl), name.GetCString(),
- var_sp->GetName().GetCString());
+ var->GetName().GetCString());
// We know entity->m_parser_vars is valid because we used a parser variable
// to find it
- ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(GetParserID());
+ ClangExpressionVariable::ParserVars *parser_vars = llvm::cast<ClangExpressionVariable>(var)->GetParserVars(GetParserID());
parser_vars->m_llvm_value = value;
- if (ClangExpressionVariable::JITVars *jit_vars = var_sp->GetJITVars(GetParserID()))
+ if (ClangExpressionVariable::JITVars *jit_vars = llvm::cast<ClangExpressionVariable>(var)->GetJITVars(GetParserID()))
{
// We already laid this out; do not touch
@@ -355,14 +370,14 @@ ClangExpressionDeclMap::AddValueToStruct
log->Printf("Already placed at 0x%llx", (unsigned long long)jit_vars->m_offset);
}
- var_sp->EnableJITVars(GetParserID());
+ llvm::cast<ClangExpressionVariable>(var)->EnableJITVars(GetParserID());
- ClangExpressionVariable::JITVars *jit_vars = var_sp->GetJITVars(GetParserID());
+ ClangExpressionVariable::JITVars *jit_vars = llvm::cast<ClangExpressionVariable>(var)->GetJITVars(GetParserID());
jit_vars->m_alignment = alignment;
jit_vars->m_size = size;
- m_struct_members.AddVariable(var_sp);
+ m_struct_members.AddVariable(var->shared_from_this());
if (m_parser_vars->m_materializer)
{
@@ -372,13 +387,14 @@ ClangExpressionDeclMap::AddValueToStruct
if (is_persistent_variable)
{
- offset = m_parser_vars->m_materializer->AddPersistentVariable(var_sp, err);
+ ExpressionVariableSP var_sp(var->shared_from_this());
+ offset = m_parser_vars->m_materializer->AddPersistentVariable(var_sp, nullptr, err);
}
else
{
if (const lldb_private::Symbol *sym = parser_vars->m_lldb_sym)
offset = m_parser_vars->m_materializer->AddSymbol(*sym, err);
- else if (const RegisterInfo *reg_info = var_sp->GetRegisterInfo())
+ else if (const RegisterInfo *reg_info = var->GetRegisterInfo())
offset = m_parser_vars->m_materializer->AddRegister(*reg_info, err);
else if (parser_vars->m_lldb_var)
offset = m_parser_vars->m_materializer->AddVariable(parser_vars->m_lldb_var, err);
@@ -450,13 +466,13 @@ ClangExpressionDeclMap::GetStructElement
if (index >= m_struct_members.GetSize())
return false;
- ClangExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(index));
+ ExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(index));
if (!member_sp)
return false;
- ClangExpressionVariable::ParserVars *parser_vars = member_sp->GetParserVars(GetParserID());
- ClangExpressionVariable::JITVars *jit_vars = member_sp->GetJITVars(GetParserID());
+ ClangExpressionVariable::ParserVars *parser_vars = llvm::cast<ClangExpressionVariable>(member_sp.get())->GetParserVars(GetParserID());
+ ClangExpressionVariable::JITVars *jit_vars = llvm::cast<ClangExpressionVariable>(member_sp.get())->GetJITVars(GetParserID());
if (!parser_vars ||
!jit_vars ||
@@ -478,15 +494,15 @@ ClangExpressionDeclMap::GetFunctionInfo
uint64_t &ptr
)
{
- ClangExpressionVariableSP entity_sp(m_found_entities.GetVariable(decl, GetParserID()));
+ ClangExpressionVariable *entity(ClangExpressionVariable::FindVariableInList(m_found_entities, decl, GetParserID()));
- if (!entity_sp)
+ if (!entity)
return false;
// We know m_parser_vars is valid since we searched for the variable by
// its NamedDecl
- ClangExpressionVariable::ParserVars *parser_vars = entity_sp->GetParserVars(GetParserID());
+ ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
ptr = parser_vars->m_lldb_value.GetScalar().ULongLong();
@@ -498,6 +514,7 @@ FindCodeSymbolInContext
(
const ConstString &name,
SymbolContext &sym_ctx,
+ uint32_t name_type_mask,
SymbolContextList &sc_list
)
{
@@ -506,7 +523,7 @@ FindCodeSymbolInContext
if (sym_ctx.module_sp)
sym_ctx.module_sp->FindFunctions(name,
NULL,
- eFunctionNameTypeAuto,
+ name_type_mask,
true, // include_symbols
false, // include_inlines
true, // append
@@ -515,7 +532,7 @@ FindCodeSymbolInContext
{
if (sym_ctx.target_sp)
sym_ctx.target_sp->GetImages().FindFunctions(name,
- eFunctionNameTypeAuto,
+ name_type_mask,
true, // include_symbols
false, // include_inlines
true, // append
@@ -573,10 +590,33 @@ ClangExpressionDeclMap::GetFunctionAddress
SymbolContextList sc_list;
- FindCodeSymbolInContext(name, m_parser_vars->m_sym_ctx, sc_list);
+ FindCodeSymbolInContext(name, m_parser_vars->m_sym_ctx, eFunctionNameTypeAuto, sc_list);
uint32_t sc_list_size = sc_list.GetSize();
-
+
+ if (sc_list_size == 0)
+ {
+ SymbolContext &sc = m_parser_vars->m_sym_ctx;
+ if (sc.comp_unit)
+ {
+ LanguageType lang_type = sc.comp_unit->GetLanguage();
+ if (Language::LanguageIsCPlusPlus(lang_type) &&
+ CPlusPlusLanguage::IsCPPMangledName(name.AsCString()))
+ {
+ // 1. Demangle the name
+ Mangled mangled(name, true);
+ ConstString demangled = mangled.GetDemangledName(lang_type);
+
+ if (demangled)
+ {
+ FindCodeSymbolInContext(
+ demangled, m_parser_vars->m_sym_ctx, eFunctionNameTypeFull, sc_list);
+ sc_list_size = sc_list.GetSize();
+ }
+ }
+ }
+ }
+
if (sc_list_size == 0)
{
// We occasionally get debug information in which a const function is reported
@@ -592,7 +632,8 @@ ClangExpressionDeclMap::GetFunctionAddress
if (log)
log->Printf("Failed to find symbols given non-const name %s; trying %s", name.GetCString(), fixed_name.GetCString());
- FindCodeSymbolInContext(fixed_name, m_parser_vars->m_sym_ctx, sc_list);
+ FindCodeSymbolInContext(
+ fixed_name, m_parser_vars->m_sym_ctx, eFunctionNameTypeAuto, sc_list);
sc_list_size = sc_list.GetSize();
}
}
@@ -863,7 +904,7 @@ ClangExpressionDeclMap::FindGlobalVariable
Target &target,
ModuleSP &module,
const ConstString &name,
- ClangNamespaceDecl *namespace_decl,
+ CompilerDeclContext *namespace_decl,
TypeFromUser *type
)
{
@@ -882,7 +923,7 @@ ClangExpressionDeclMap::FindGlobalVariable
{
VariableSP var_sp = vars.GetVariableAtIndex(i);
- if (ClangASTContext::AreTypesSame(*type, var_sp->GetType()->GetClangFullType()))
+ if (ClangASTContext::AreTypesSame(*type, var_sp->GetType()->GetFullCompilerType ()))
return var_sp;
}
}
@@ -930,7 +971,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context)
if (const NamespaceDecl *namespace_context = dyn_cast<NamespaceDecl>(context.m_decl_context))
{
- ClangASTImporter::NamespaceMapSP namespace_map = m_ast_importer->GetNamespaceMap(namespace_context);
+ ClangASTImporter::NamespaceMapSP namespace_map = m_ast_importer_sp->GetNamespaceMap(namespace_context);
if (log && log->GetVerbose())
log->Printf(" CEDM::FEVD[%u] Inspecting (NamespaceMap*)%p (%d entries)",
@@ -947,7 +988,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context)
if (log)
log->Printf(" CEDM::FEVD[%u] Searching namespace %s in module %s",
current_id,
- i->second.GetNamespaceDecl()->getNameAsString().c_str(),
+ i->second.GetName().AsCString(),
i->first->GetFileSpec().GetFilename().GetCString());
FindExternalVisibleDecls(context,
@@ -958,7 +999,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context)
}
else if (isa<TranslationUnitDecl>(context.m_decl_context))
{
- ClangNamespaceDecl namespace_decl;
+ CompilerDeclContext namespace_decl;
if (log)
log->Printf(" CEDM::FEVD[%u] Searching the root namespace", current_id);
@@ -976,7 +1017,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context)
void
ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
lldb::ModuleSP module_sp,
- ClangNamespaceDecl &namespace_decl,
+ CompilerDeclContext &namespace_decl,
unsigned int current_id)
{
assert (m_ast_context);
@@ -1002,6 +1043,9 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
// doesn't start with our phony prefix of '$'
Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
+ SymbolContext sym_ctx;
+ if (frame != nullptr)
+ sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction|lldb::eSymbolContextBlock);
if (name_unique_cstr[0] == '$' && !namespace_decl)
{
static ConstString g_lldb_class_name ("$__lldb_class");
@@ -1013,23 +1057,19 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
if (frame == NULL)
return;
- SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction);
-
- if (!sym_ctx.function)
- return;
- // Get the block that defines the function
+ // Find the block that defines the function represented by "sym_ctx"
Block *function_block = sym_ctx.GetFunctionBlock();
if (!function_block)
return;
- clang::DeclContext *decl_context = function_block->GetClangDeclContext();
+ CompilerDeclContext function_decl_ctx = function_block->GetDeclContext();
- if (!decl_context)
+ if (!function_decl_ctx)
return;
- clang::CXXMethodDecl *method_decl = llvm::dyn_cast<clang::CXXMethodDecl>(decl_context);
+ clang::CXXMethodDecl *method_decl = ClangASTContext::DeclContextGetAsCXXMethodDecl(function_decl_ctx);
if (method_decl)
{
@@ -1038,7 +1078,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
QualType class_qual_type(class_decl->getTypeForDecl(), 0);
TypeFromUser class_user_type (class_qual_type.getAsOpaquePtr(),
- &class_decl->getASTContext());
+ ClangASTContext::GetASTContext(&class_decl->getASTContext()));
if (log)
{
@@ -1046,28 +1086,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
log->Printf(" CEDM::FEVD[%u] Adding type for $__lldb_class: %s", current_id, ast_dumper.GetCString());
}
- TypeFromParser class_type = CopyClassType(class_user_type, current_id);
-
- if (!class_type.IsValid())
- return;
-
- TypeSourceInfo *type_source_info = m_ast_context->getTrivialTypeSourceInfo(QualType::getFromOpaquePtr(class_type.GetOpaqueQualType()));
-
- if (!type_source_info)
- return;
-
- TypedefDecl *typedef_decl = TypedefDecl::Create(*m_ast_context,
- m_ast_context->getTranslationUnitDecl(),
- SourceLocation(),
- SourceLocation(),
- context.m_decl_name.getAsIdentifierInfo(),
- type_source_info);
-
-
- if (!typedef_decl)
- return;
-
- context.AddNamedDecl(typedef_decl);
+ AddThisType(context, class_user_type, current_id);
if (method_decl->isInstance())
{
@@ -1076,7 +1095,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
QualType class_pointer_type = method_decl->getASTContext().getPointerType(class_qual_type);
TypeFromUser self_user_type(class_pointer_type.getAsOpaquePtr(),
- &method_decl->getASTContext());
+ ClangASTContext::GetASTContext(&method_decl->getASTContext()));
m_struct_vars->m_object_pointer_type = self_user_type;
}
@@ -1103,21 +1122,18 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
if (!this_type)
return;
- ClangASTType pointee_type = this_type->GetClangForwardType().GetPointeeType();
+ TypeFromUser pointee_type = this_type->GetForwardCompilerType ().GetPointeeType();
if (pointee_type.IsValid())
{
if (log)
{
- ASTDumper ast_dumper(this_type->GetClangFullType());
- log->Printf(" FEVD[%u] Adding type for $__lldb_objc_class: %s", current_id, ast_dumper.GetCString());
+ ASTDumper ast_dumper(pointee_type);
+ log->Printf(" FEVD[%u] Adding type for $__lldb_class: %s", current_id, ast_dumper.GetCString());
}
-
- TypeFromUser class_user_type(pointee_type);
- AddOneType(context, class_user_type, current_id);
-
-
- TypeFromUser this_user_type(this_type->GetClangFullType());
+
+ AddThisType(context, pointee_type, current_id);
+ TypeFromUser this_user_type(this_type->GetFullCompilerType ());
m_struct_vars->m_object_pointer_type = this_user_type;
return;
}
@@ -1135,23 +1151,20 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
if (!frame)
return;
- SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction);
-
- if (!sym_ctx.function)
- return;
+ SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction|lldb::eSymbolContextBlock);
- // Get the block that defines the function
+ // Find the block that defines the function represented by "sym_ctx"
Block *function_block = sym_ctx.GetFunctionBlock();
if (!function_block)
return;
- clang::DeclContext *decl_context = function_block->GetClangDeclContext();
+ CompilerDeclContext function_decl_ctx = function_block->GetDeclContext();
- if (!decl_context)
+ if (!function_decl_ctx)
return;
- clang::ObjCMethodDecl *method_decl = llvm::dyn_cast<clang::ObjCMethodDecl>(decl_context);
+ clang::ObjCMethodDecl *method_decl = ClangASTContext::DeclContextGetAsObjCMethodDecl(function_decl_ctx);
if (method_decl)
{
@@ -1166,7 +1179,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
return; // This is unlikely, but we have seen crashes where this occurred
TypeFromUser class_user_type(QualType(interface_type, 0).getAsOpaquePtr(),
- &method_decl->getASTContext());
+ ClangASTContext::GetASTContext(&method_decl->getASTContext()));
if (log)
{
@@ -1183,7 +1196,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
QualType class_pointer_type = method_decl->getASTContext().getObjCObjectPointerType(QualType(interface_type, 0));
TypeFromUser self_user_type(class_pointer_type.getAsOpaquePtr(),
- &method_decl->getASTContext());
+ ClangASTContext::GetASTContext(&method_decl->getASTContext()));
m_struct_vars->m_object_pointer_type = self_user_type;
}
@@ -1193,7 +1206,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
QualType class_type = method_decl->getASTContext().getObjCClassType();
TypeFromUser self_user_type(class_type.getAsOpaquePtr(),
- &method_decl->getASTContext());
+ ClangASTContext::GetASTContext(&method_decl->getASTContext()));
m_struct_vars->m_object_pointer_type = self_user_type;
}
@@ -1220,13 +1233,13 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
if (!self_type)
return;
- ClangASTType self_clang_type = self_type->GetClangFullType();
+ CompilerType self_clang_type = self_type->GetFullCompilerType ();
- if (self_clang_type.IsObjCClassType())
+ if (ClangASTContext::IsObjCClassType(self_clang_type))
{
return;
}
- else if (self_clang_type.IsObjCObjectPointerType())
+ else if (ClangASTContext::IsObjCObjectPointerType(self_clang_type))
{
self_clang_type = self_clang_type.GetPointeeType();
@@ -1235,7 +1248,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
if (log)
{
- ASTDumper ast_dumper(self_type->GetClangFullType());
+ ASTDumper ast_dumper(self_type->GetFullCompilerType ());
log->Printf(" FEVD[%u] Adding type for $__lldb_objc_class: %s", current_id, ast_dumper.GetCString());
}
@@ -1243,7 +1256,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
AddOneType(context, class_user_type, current_id);
- TypeFromUser self_user_type(self_type->GetClangFullType());
+ TypeFromUser self_user_type(self_type->GetFullCompilerType ());
m_struct_vars->m_object_pointer_type = self_user_type;
return;
@@ -1278,7 +1291,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
if (!ptype_type_decl)
break;
- Decl *parser_ptype_decl = m_ast_importer->CopyDecl(m_ast_context, scratch_ast_context, ptype_type_decl);
+ Decl *parser_ptype_decl = m_ast_importer_sp->CopyDecl(m_ast_context, scratch_ast_context, ptype_type_decl);
if (!parser_ptype_decl)
break;
@@ -1294,7 +1307,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
context.AddNamedDecl(parser_ptype_type_decl);
} while (0);
- ClangExpressionVariableSP pvar_sp(m_parser_vars->m_persistent_vars->GetVariable(name));
+ ExpressionVariableSP pvar_sp(m_parser_vars->m_persistent_vars->GetVariable(name));
if (pvar_sp)
{
@@ -1321,28 +1334,37 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
{
ValueObjectSP valobj;
VariableSP var;
- Error err;
if (frame && !namespace_decl)
{
- valobj = frame->GetValueForVariableExpressionPath(name_unique_cstr,
- eNoDynamicValues,
- StackFrame::eExpressionPathOptionCheckPtrVsMember |
- StackFrame::eExpressionPathOptionsNoFragileObjcIvar |
- StackFrame::eExpressionPathOptionsNoSyntheticChildren |
- StackFrame::eExpressionPathOptionsNoSyntheticArrayRange,
- var,
- err);
-
- // If we found a variable in scope, no need to pull up function names
- if (err.Success() && var)
+ CompilerDeclContext compiler_decl_context = sym_ctx.block != nullptr ? sym_ctx.block->GetDeclContext() : CompilerDeclContext();
+
+ if (compiler_decl_context)
{
- AddOneVariable(context, var, valobj, current_id);
- context.m_found.variable = true;
- return;
+ // Make sure that the variables are parsed so that we have the declarations
+ VariableListSP vars = frame->GetInScopeVariableList(true);
+ for (size_t i = 0; i < vars->GetSize(); i++)
+ vars->GetVariableAtIndex(i)->GetDecl();
+
+ // Search for declarations matching the name
+ std::vector<CompilerDecl> found_decls = compiler_decl_context.FindDeclByName(name);
+
+ bool variable_found = false;
+ for (CompilerDecl decl : found_decls)
+ {
+ var = decl.GetAsVariable();
+ if (var)
+ {
+ variable_found = true;
+ valobj = ValueObjectVariable::Create(frame, var);
+ AddOneVariable(context, var, valobj, current_id);
+ context.m_found.variable = true;
+ }
+ }
+ if (variable_found)
+ return;
}
}
-
if (target)
{
var = FindGlobalVariable (*target,
@@ -1402,6 +1424,128 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
sc_list);
}
+ // If we found more than one function, see if we can use the
+ // frame's decl context to remove functions that are shadowed
+ // by other functions which match in type but are nearer in scope.
+ //
+ // AddOneFunction will not add a function whose type has already been
+ // added, so if there's another function in the list with a matching
+ // type, check to see if their decl context is a parent of the current
+ // frame's or was imported via a and using statement, and pick the
+ // best match according to lookup rules.
+ if (sc_list.GetSize() > 1)
+ {
+ // Collect some info about our frame's context.
+ StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
+ SymbolContext frame_sym_ctx;
+ if (frame != nullptr)
+ frame_sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction|lldb::eSymbolContextBlock);
+ CompilerDeclContext frame_decl_context = frame_sym_ctx.block != nullptr ? frame_sym_ctx.block->GetDeclContext() : CompilerDeclContext();
+
+ // We can't do this without a compiler decl context for our frame.
+ if (frame_decl_context)
+ {
+ clang::DeclContext *frame_decl_ctx = (clang::DeclContext *)frame_decl_context.GetOpaqueDeclContext();
+ ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(frame_decl_context.GetTypeSystem());
+
+ // Structure to hold the info needed when comparing function
+ // declarations.
+ struct FuncDeclInfo
+ {
+ ConstString m_name;
+ CompilerType m_copied_type;
+ uint32_t m_decl_lvl;
+ SymbolContext m_sym_ctx;
+ };
+
+ // First, symplify things by looping through the symbol contexts
+ // to remove unwanted functions and separate out the functions we
+ // want to compare and prune into a separate list.
+ // Cache the info needed about the function declarations in a
+ // vector for efficiency.
+ SymbolContextList sc_sym_list;
+ uint32_t num_indices = sc_list.GetSize();
+ std::vector<FuncDeclInfo> fdi_cache;
+ fdi_cache.reserve(num_indices);
+ for (uint32_t index = 0; index < num_indices; ++index)
+ {
+ FuncDeclInfo fdi;
+ SymbolContext sym_ctx;
+ sc_list.GetContextAtIndex(index, sym_ctx);
+
+ // We don't know enough about symbols to compare them,
+ // but we should keep them in the list.
+ Function *function = sym_ctx.function;
+ if (!function)
+ {
+ sc_sym_list.Append(sym_ctx);
+ continue;
+ }
+ // Filter out functions without declaration contexts, as well as
+ // class/instance methods, since they'll be skipped in the
+ // code that follows anyway.
+ CompilerDeclContext func_decl_context = function->GetDeclContext();
+ if (!func_decl_context || func_decl_context.IsClassMethod(nullptr, nullptr, nullptr))
+ continue;
+ // We can only prune functions for which we can copy the type.
+ CompilerType func_clang_type = function->GetType()->GetFullCompilerType();
+ CompilerType copied_func_type = GuardedCopyType(func_clang_type);
+ if (!copied_func_type)
+ {
+ sc_sym_list.Append(sym_ctx);
+ continue;
+ }
+
+ fdi.m_sym_ctx = sym_ctx;
+ fdi.m_name = function->GetName();
+ fdi.m_copied_type = copied_func_type;
+ fdi.m_decl_lvl = LLDB_INVALID_DECL_LEVEL;
+ if (fdi.m_copied_type && func_decl_context)
+ {
+ // Call CountDeclLevels to get the number of parent scopes we
+ // have to look through before we find the function declaration.
+ // When comparing functions of the same type, the one with a
+ // lower count will be closer to us in the lookup scope and
+ // shadows the other.
+ clang::DeclContext *func_decl_ctx = (clang::DeclContext *)func_decl_context.GetOpaqueDeclContext();
+ fdi.m_decl_lvl = ast->CountDeclLevels(frame_decl_ctx,
+ func_decl_ctx,
+ &fdi.m_name,
+ &fdi.m_copied_type);
+ }
+ fdi_cache.emplace_back(fdi);
+ }
+
+ // Loop through the functions in our cache looking for matching types,
+ // then compare their scope levels to see which is closer.
+ std::multimap<CompilerType, const FuncDeclInfo*> matches;
+ for (const FuncDeclInfo &fdi : fdi_cache)
+ {
+ const CompilerType t = fdi.m_copied_type;
+ auto q = matches.find(t);
+ if (q != matches.end())
+ {
+ if (q->second->m_decl_lvl > fdi.m_decl_lvl)
+ // This function is closer; remove the old set.
+ matches.erase(t);
+ else if (q->second->m_decl_lvl < fdi.m_decl_lvl)
+ // The functions in our set are closer - skip this one.
+ continue;
+ }
+ matches.insert(std::make_pair(t, &fdi));
+ }
+
+ // Loop through our matches and add their symbol contexts to our list.
+ SymbolContextList sc_func_list;
+ for (const auto &q : matches)
+ sc_func_list.Append(q.second->m_sym_ctx);
+
+ // Rejoin the lists with the functions in front.
+ sc_list = sc_func_list;
+ sc_list.Append(sc_sym_list);
+ }
+ }
+
if (sc_list.GetSize())
{
Symbol *extern_symbol = NULL;
@@ -1416,15 +1560,13 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
if (sym_ctx.function)
{
- clang::DeclContext *decl_ctx = sym_ctx.function->GetClangDeclContext();
+ CompilerDeclContext decl_ctx = sym_ctx.function->GetDeclContext();
if (!decl_ctx)
continue;
// Filter out class/instance methods.
- if (dyn_cast<clang::ObjCMethodDecl>(decl_ctx))
- continue;
- if (dyn_cast<clang::CXXMethodDecl>(decl_ctx))
+ if (decl_ctx.IsClassMethod(nullptr, nullptr, nullptr))
continue;
AddOneFunction(context, sym_ctx.function, NULL, current_id);
@@ -1453,7 +1595,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
{
if (llvm::isa<clang::FunctionDecl>(decl))
{
- clang::NamedDecl *copied_decl = llvm::cast<FunctionDecl>(m_ast_importer->CopyDecl(m_ast_context, &decl->getASTContext(), decl));
+ clang::NamedDecl *copied_decl = llvm::cast<FunctionDecl>(m_ast_importer_sp->CopyDecl(m_ast_context, &decl->getASTContext(), decl));
context.AddNamedDecl(copied_decl);
context.m_found.function_with_type_info = true;
}
@@ -1504,7 +1646,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
name.GetCString());
}
- clang::Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, &decl_from_modules->getASTContext(), decl_from_modules);
+ clang::Decl *copied_decl = m_ast_importer_sp->CopyDecl(m_ast_context, &decl_from_modules->getASTContext(), decl_from_modules);
clang::FunctionDecl *copied_function_decl = copied_decl ? dyn_cast<clang::FunctionDecl>(copied_decl) : nullptr;
if (!copied_function_decl)
@@ -1536,7 +1678,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
name.GetCString());
}
- clang::Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, &decl_from_modules->getASTContext(), decl_from_modules);
+ clang::Decl *copied_decl = m_ast_importer_sp->CopyDecl(m_ast_context, &decl_from_modules->getASTContext(), decl_from_modules);
clang::VarDecl *copied_var_decl = copied_decl ? dyn_cast_or_null<clang::VarDecl>(copied_decl) : nullptr;
if (!copied_var_decl)
@@ -1577,11 +1719,11 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
}
}
-//static clang_type_t
+//static opaque_compiler_type_t
//MaybePromoteToBlockPointerType
//(
// ASTContext *ast_context,
-// clang_type_t candidate_type
+// opaque_compiler_type_t candidate_type
//)
//{
// if (!candidate_type)
@@ -1632,7 +1774,7 @@ ClangExpressionDeclMap::GetVariableValue (VariableSP &var,
return false;
}
- ClangASTType var_clang_type = var_type->GetClangFullType();
+ CompilerType var_clang_type = var_type->GetFullCompilerType ();
if (!var_clang_type)
{
@@ -1641,7 +1783,17 @@ ClangExpressionDeclMap::GetVariableValue (VariableSP &var,
return false;
}
- ASTContext *ast = var_type->GetClangASTContext().getASTContext();
+ ClangASTContext *clang_ast = llvm::dyn_cast_or_null<ClangASTContext>(var_type->GetForwardCompilerType().GetTypeSystem());
+
+ if (!clang_ast)
+ {
+ if (log)
+ log->PutCString("Skipped a definition because it has no Clang AST");
+ return false;
+ }
+
+
+ ASTContext *ast = clang_ast->getASTContext();
if (!ast)
{
@@ -1673,7 +1825,7 @@ ClangExpressionDeclMap::GetVariableValue (VariableSP &var,
}
}
- ClangASTType type_to_use = GuardedCopyType(var_clang_type);
+ CompilerType type_to_use = GuardedCopyType(var_clang_type);
if (!type_to_use)
{
@@ -1687,7 +1839,7 @@ ClangExpressionDeclMap::GetVariableValue (VariableSP &var,
*parser_type = TypeFromParser(type_to_use);
if (var_location.GetContextType() == Value::eContextTypeInvalid)
- var_location.SetClangType(type_to_use);
+ var_location.SetCompilerType(type_to_use);
if (var_location.GetValueType() == Value::eValueTypeFileAddress)
{
@@ -1752,9 +1904,10 @@ ClangExpressionDeclMap::AddOneVariable (NameSearchContext &context, VariableSP v
std::string decl_name(context.m_decl_name.getAsString());
ConstString entity_name(decl_name.c_str());
- ClangExpressionVariableSP entity(m_found_entities.CreateVariable (valobj));
+ ClangExpressionVariable *entity(new ClangExpressionVariable(valobj));
+ m_found_entities.AddNewlyConstructedVariable(entity);
- assert (entity.get());
+ assert (entity);
entity->EnableParserVars(GetParserID());
ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
parser_vars->m_parser_type = pt;
@@ -1776,12 +1929,12 @@ ClangExpressionDeclMap::AddOneVariable (NameSearchContext &context, VariableSP v
void
ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
- ClangExpressionVariableSP &pvar_sp,
+ ExpressionVariableSP &pvar_sp,
unsigned int current_id)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
- TypeFromUser user_type (pvar_sp->GetTypeFromUser());
+ TypeFromUser user_type (llvm::cast<ClangExpressionVariable>(pvar_sp.get())->GetTypeFromUser());
TypeFromParser parser_type (GuardedCopyType(user_type));
@@ -1794,8 +1947,8 @@ ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
NamedDecl *var_decl = context.AddVarDecl(parser_type.GetLValueReferenceType());
- pvar_sp->EnableParserVars(GetParserID());
- ClangExpressionVariable::ParserVars *parser_vars = pvar_sp->GetParserVars(GetParserID());
+ llvm::cast<ClangExpressionVariable>(pvar_sp.get())->EnableParserVars(GetParserID());
+ ClangExpressionVariable::ParserVars *parser_vars = llvm::cast<ClangExpressionVariable>(pvar_sp.get())->GetParserVars(GetParserID());
parser_vars->m_parser_type = parser_type;
parser_vars->m_named_decl = var_decl;
parser_vars->m_llvm_value = NULL;
@@ -1830,13 +1983,13 @@ ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
std::string decl_name(context.m_decl_name.getAsString());
ConstString entity_name(decl_name.c_str());
- ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx.GetBestExecutionContextScope (),
- entity_name,
- user_type,
- m_parser_vars->m_target_info.byte_order,
- m_parser_vars->m_target_info.address_byte_size));
- assert (entity.get());
-
+ ClangExpressionVariable *entity(new ClangExpressionVariable(m_parser_vars->m_exe_ctx.GetBestExecutionContextScope (),
+ entity_name,
+ user_type,
+ m_parser_vars->m_target_info.byte_order,
+ m_parser_vars->m_target_info.address_byte_size));
+ m_found_entities.AddNewlyConstructedVariable(entity);
+
entity->EnableParserVars(GetParserID());
ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
@@ -1844,7 +1997,7 @@ ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
lldb::addr_t symbol_load_addr = symbol_address.GetLoadAddress(target);
//parser_vars->m_lldb_value.SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType());
- parser_vars->m_lldb_value.SetClangType(user_type);
+ parser_vars->m_lldb_value.SetCompilerType(user_type);
parser_vars->m_lldb_value.GetScalar() = symbol_load_addr;
parser_vars->m_lldb_value.SetValueType(Value::eValueTypeLoadAddress);
@@ -1867,15 +2020,15 @@ ClangExpressionDeclMap::ResolveUnknownTypes()
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
- ASTContext *scratch_ast_context = target->GetScratchClangASTContext()->getASTContext();
+ ClangASTContext *scratch_ast_context = target->GetScratchClangASTContext();
for (size_t index = 0, num_entities = m_found_entities.GetSize();
index < num_entities;
++index)
{
- ClangExpressionVariableSP entity = m_found_entities.GetVariableAtIndex(index);
+ ExpressionVariableSP entity = m_found_entities.GetVariableAtIndex(index);
- ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
+ ClangExpressionVariable::ParserVars *parser_vars = llvm::cast<ClangExpressionVariable>(entity.get())->GetParserVars(GetParserID());
if (entity->m_flags & ClangExpressionVariable::EVUnknownType)
{
@@ -1896,25 +2049,25 @@ ClangExpressionDeclMap::ResolveUnknownTypes()
}
QualType var_type = var_decl->getType();
- TypeFromParser parser_type(var_type.getAsOpaquePtr(), &var_decl->getASTContext());
+ TypeFromParser parser_type(var_type.getAsOpaquePtr(), ClangASTContext::GetASTContext(&var_decl->getASTContext()));
- lldb::clang_type_t copied_type = m_ast_importer->CopyType(scratch_ast_context, &var_decl->getASTContext(), var_type.getAsOpaquePtr());
+ lldb::opaque_compiler_type_t copied_type = m_ast_importer_sp->CopyType(scratch_ast_context->getASTContext(), &var_decl->getASTContext(), var_type.getAsOpaquePtr());
if (!copied_type)
{
if (log)
log->Printf("ClangExpressionDeclMap::ResolveUnknownType - Couldn't import the type for a variable");
- return (bool) lldb::ClangExpressionVariableSP();
+ return (bool) lldb::ExpressionVariableSP();
}
TypeFromUser user_type(copied_type, scratch_ast_context);
// parser_vars->m_lldb_value.SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType());
- parser_vars->m_lldb_value.SetClangType(user_type);
+ parser_vars->m_lldb_value.SetCompilerType(user_type);
parser_vars->m_parser_type = parser_type;
- entity->SetClangType(user_type);
+ entity->SetCompilerType(user_type);
entity->m_flags &= ~(ClangExpressionVariable::EVUnknownType);
}
@@ -1930,7 +2083,7 @@ ClangExpressionDeclMap::AddOneRegister (NameSearchContext &context,
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
- ClangASTType clang_type = ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (m_ast_context,
+ CompilerType clang_type = ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (m_ast_context,
reg_info->encoding,
reg_info->byte_size * 8);
@@ -1945,10 +2098,10 @@ ClangExpressionDeclMap::AddOneRegister (NameSearchContext &context,
NamedDecl *var_decl = context.AddVarDecl(parser_clang_type);
- ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
- m_parser_vars->m_target_info.byte_order,
- m_parser_vars->m_target_info.address_byte_size));
- assert (entity.get());
+ ClangExpressionVariable *entity(new ClangExpressionVariable(m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
+ m_parser_vars->m_target_info.byte_order,
+ m_parser_vars->m_target_info.address_byte_size));
+ m_found_entities.AddNewlyConstructedVariable(entity);
std::string decl_name(context.m_decl_name.getAsString());
entity->SetName (ConstString (decl_name.c_str()));
@@ -1980,7 +2133,7 @@ ClangExpressionDeclMap::AddOneFunction (NameSearchContext &context,
NamedDecl *function_decl = NULL;
Address fun_address;
- ClangASTType function_clang_type;
+ CompilerType function_clang_type;
bool is_indirect_function = false;
@@ -1995,7 +2148,7 @@ ClangExpressionDeclMap::AddOneFunction (NameSearchContext &context,
return;
}
- function_clang_type = function_type->GetClangFullType();
+ function_clang_type = function_type->GetFullCompilerType ();
if (!function_clang_type)
{
@@ -2006,7 +2159,7 @@ ClangExpressionDeclMap::AddOneFunction (NameSearchContext &context,
fun_address = function->GetAddressRange().GetBaseAddress();
- ClangASTType copied_function_type = GuardedCopyType(function_clang_type);
+ CompilerType copied_function_type = GuardedCopyType(function_clang_type);
if (copied_function_type)
{
function_decl = context.AddFunDecl(copied_function_type);
@@ -2053,14 +2206,14 @@ ClangExpressionDeclMap::AddOneFunction (NameSearchContext &context,
lldb::addr_t load_addr = fun_address.GetCallableLoadAddress(target, is_indirect_function);
- ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx.GetBestExecutionContextScope (),
- m_parser_vars->m_target_info.byte_order,
- m_parser_vars->m_target_info.address_byte_size));
- assert (entity.get());
+ ClangExpressionVariable *entity(new ClangExpressionVariable (m_parser_vars->m_exe_ctx.GetBestExecutionContextScope (),
+ m_parser_vars->m_target_info.byte_order,
+ m_parser_vars->m_target_info.address_byte_size));
+ m_found_entities.AddNewlyConstructedVariable(entity);
std::string decl_name(context.m_decl_name.getAsString());
entity->SetName(ConstString(decl_name.c_str()));
- entity->SetClangType (function_clang_type);
+ entity->SetCompilerType (function_clang_type);
entity->EnableParserVars(GetParserID());
ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
@@ -2101,28 +2254,29 @@ ClangExpressionDeclMap::AddOneFunction (NameSearchContext &context,
}
}
-TypeFromParser
-ClangExpressionDeclMap::CopyClassType(TypeFromUser &ut,
- unsigned int current_id)
+void
+ClangExpressionDeclMap::AddThisType(NameSearchContext &context,
+ TypeFromUser &ut,
+ unsigned int current_id)
{
- ClangASTType copied_clang_type = GuardedCopyType(ut);
+ CompilerType copied_clang_type = GuardedCopyType(ut);
if (!copied_clang_type)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
if (log)
- log->Printf("ClangExpressionDeclMap::CopyClassType - Couldn't import the type");
+ log->Printf("ClangExpressionDeclMap::AddThisType - Couldn't import the type");
- return TypeFromParser();
+ return;
}
if (copied_clang_type.IsAggregateType() && copied_clang_type.GetCompleteType ())
{
- ClangASTType void_clang_type = ClangASTContext::GetBasicType(m_ast_context, eBasicTypeVoid);
- ClangASTType void_ptr_clang_type = void_clang_type.GetPointerType();
+ CompilerType void_clang_type = ClangASTContext::GetBasicType(m_ast_context, eBasicTypeVoid);
+ CompilerType void_ptr_clang_type = void_clang_type.GetPointerType();
- ClangASTType method_type = ClangASTContext::CreateFunctionType (m_ast_context,
+ CompilerType method_type = ClangASTContext::CreateFunctionType (m_ast_context,
void_clang_type,
&void_ptr_clang_type,
1,
@@ -2136,18 +2290,44 @@ ClangExpressionDeclMap::CopyClassType(TypeFromUser &ut,
const bool is_attr_used = true;
const bool is_artificial = false;
- copied_clang_type.AddMethodToCXXRecordType ("$__lldb_expr",
- method_type,
- lldb::eAccessPublic,
- is_virtual,
- is_static,
- is_inline,
- is_explicit,
- is_attr_used,
- is_artificial);
+ ClangASTContext::GetASTContext(m_ast_context)->
+ AddMethodToCXXRecordType (copied_clang_type.GetOpaqueQualType(),
+ "$__lldb_expr",
+ method_type,
+ lldb::eAccessPublic,
+ is_virtual,
+ is_static,
+ is_inline,
+ is_explicit,
+ is_attr_used,
+ is_artificial);
}
- return TypeFromParser(copied_clang_type);
+ if (!copied_clang_type.IsValid())
+ return;
+
+ TypeSourceInfo *type_source_info = m_ast_context->getTrivialTypeSourceInfo(QualType::getFromOpaquePtr(copied_clang_type.GetOpaqueQualType()));
+
+ if (!type_source_info)
+ return;
+
+ // Construct a typedef type because if "*this" is a templated type we can't just return ClassTemplateSpecializationDecls in response to name queries.
+ // Using a typedef makes this much more robust.
+
+ TypedefDecl *typedef_decl = TypedefDecl::Create(*m_ast_context,
+ m_ast_context->getTranslationUnitDecl(),
+ SourceLocation(),
+ SourceLocation(),
+ context.m_decl_name.getAsIdentifierInfo(),
+ type_source_info);
+
+
+ if (!typedef_decl)
+ return;
+
+ context.AddNamedDecl(typedef_decl);
+
+ return;
}
void
@@ -2155,7 +2335,7 @@ ClangExpressionDeclMap::AddOneType(NameSearchContext &context,
TypeFromUser &ut,
unsigned int current_id)
{
- ClangASTType copied_clang_type = GuardedCopyType(ut);
+ CompilerType copied_clang_type = GuardedCopyType(ut);
if (!copied_clang_type)
{
diff --git a/include/lldb/Expression/ClangExpressionDeclMap.h b/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
index f24500ab5237..b3f890c7acc7 100644
--- a/include/lldb/Expression/ClangExpressionDeclMap.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
@@ -17,16 +17,16 @@
// C++ Includes
#include <vector>
+#include "ClangExpressionVariable.h"
+#include "ClangASTSource.h"
+
// Other libraries and framework includes
// Project includes
-#include "llvm/ADT/APInt.h"
#include "llvm/ADT/DenseMap.h"
#include "clang/AST/Decl.h"
#include "lldb/lldb-public.h"
#include "lldb/Core/ClangForward.h"
#include "lldb/Core/Value.h"
-#include "lldb/Expression/ClangASTSource.h"
-#include "lldb/Expression/ClangExpressionVariable.h"
#include "lldb/Expression/Materializer.h"
#include "lldb/Symbol/TaggedASTType.h"
#include "lldb/Symbol/SymbolContext.h"
@@ -71,16 +71,21 @@ public:
/// the result persistent variable, and instead marks the variable
/// as persisting.
///
+ /// @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
/// The execution context to use when parsing.
//------------------------------------------------------------------
ClangExpressionDeclMap (bool keep_result_in_memory,
+ Materializer::PersistentVariableDelegate *result_delegate,
ExecutionContext &exe_ctx);
//------------------------------------------------------------------
/// Destructor
//------------------------------------------------------------------
- ~ClangExpressionDeclMap ();
+ ~ClangExpressionDeclMap() override;
//------------------------------------------------------------------
/// Enable the state needed for parsing and IR transformation.
@@ -354,7 +359,7 @@ public:
/// True on success; false otherwise.
//------------------------------------------------------------------
void
- FindExternalVisibleDecls (NameSearchContext &context);
+ FindExternalVisibleDecls(NameSearchContext &context) override;
//------------------------------------------------------------------
/// Find all entities matching a given name in a given module/namespace,
@@ -385,12 +390,13 @@ public:
void
FindExternalVisibleDecls (NameSearchContext &context,
lldb::ModuleSP module,
- ClangNamespaceDecl &namespace_decl,
+ CompilerDeclContext &namespace_decl,
unsigned int current_id);
private:
- ClangExpressionVariableList m_found_entities; ///< All entities that were looked up for the parser.
- ClangExpressionVariableList m_struct_members; ///< All entities that need to be placed in the struct.
- bool m_keep_result_in_memory; ///< True if result persistent variables generated by this expression should stay in memory.
+ ExpressionVariableList m_found_entities; ///< All entities that were looked up for the parser.
+ ExpressionVariableList m_struct_members; ///< All entities that need to be placed in the struct.
+ bool m_keep_result_in_memory; ///< True if result persistent variables generated by this expression should stay in memory.
+ Materializer::PersistentVariableDelegate *m_result_delegate; ///< If non-NULL, used to report expression results to ClangUserExpression.
//----------------------------------------------------------------------
/// The following values should not live beyond parsing
@@ -546,7 +552,7 @@ private:
FindGlobalVariable (Target &target,
lldb::ModuleSP &module,
const ConstString &name,
- ClangNamespaceDecl *namespace_decl,
+ CompilerDeclContext *namespace_decl,
TypeFromUser *type = NULL);
//------------------------------------------------------------------
@@ -616,7 +622,7 @@ private:
//------------------------------------------------------------------
void
AddOneVariable (NameSearchContext &context,
- lldb::ClangExpressionVariableSP &pvar_sp,
+ lldb::ExpressionVariableSP &pvar_sp,
unsigned int current_id);
//------------------------------------------------------------------
@@ -688,18 +694,21 @@ private:
unsigned int current_id);
//------------------------------------------------------------------
- /// Copy a C++ class type into the parser's AST context and add a
- /// member function declaration to it for the expression.
+ /// Generate a Decl for "*this" and add a member function declaration
+ /// to it for the expression, then report it.
+ ///
+ /// @param[in] context
+ /// The NameSearchContext to use when constructing the Decl.
///
/// @param[in] type
- /// The type that needs to be created.
+ /// The type for *this.
//------------------------------------------------------------------
-
- TypeFromParser
- CopyClassType(TypeFromUser &type,
- unsigned int current_id);
+ void
+ AddThisType(NameSearchContext &context,
+ TypeFromUser &type,
+ unsigned int current_id);
};
} // namespace lldb_private
-#endif // liblldb_ClangExpressionDeclMap_h_
+#endif // liblldb_ClangExpressionDeclMap_h_
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h b/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h
new file mode 100644
index 000000000000..bb620def691f
--- /dev/null
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h
@@ -0,0 +1,79 @@
+//===-- ClangExpression.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_ClangExpression_h_
+#define liblldb_ClangExpression_h_
+
+// C Includes
+// C++ Includes
+#include <string>
+#include <map>
+#include <vector>
+
+// Other libraries and framework includes
+// Project includes
+
+#include "lldb/lldb-forward.h"
+#include "lldb/lldb-private.h"
+#include "lldb/Core/ClangForward.h"
+#include "lldb/Expression/ExpressionTypeSystemHelper.h"
+
+namespace lldb_private {
+
+class RecordingMemoryManager;
+
+//----------------------------------------------------------------------
+// ClangExpressionHelper
+//----------------------------------------------------------------------
+class ClangExpressionHelper : public ExpressionTypeSystemHelper
+{
+public:
+ static bool classof(const ExpressionTypeSystemHelper *ts)
+ {
+ return ts->getKind() == eKindClangHelper;
+ }
+
+ ClangExpressionHelper () :
+ 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
+ /// The ASTConsumer that the returned transformer should send
+ /// the ASTs to after transformation.
+ //------------------------------------------------------------------
+ virtual clang::ASTConsumer *
+ ASTTransformer (clang::ASTConsumer *passthrough) = 0;
+
+
+protected:
+
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_ClangExpression_h_
diff --git a/source/Expression/ClangExpressionParser.cpp b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 2b344b0c3733..72c33fec8105 100644
--- a/source/Expression/ClangExpressionParser.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -7,36 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Expression/ClangExpressionParser.h"
-
-#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Disassembler.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Module.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Expression/ClangASTSource.h"
-#include "lldb/Expression/ClangExpression.h"
-#include "lldb/Expression/ClangExpressionDeclMap.h"
-#include "lldb/Expression/ClangModulesDeclVendor.h"
-#include "lldb/Expression/ClangPersistentVariables.h"
-#include "lldb/Expression/IRExecutionUnit.h"
-#include "lldb/Expression/IRDynamicChecks.h"
-#include "lldb/Expression/IRInterpreter.h"
-#include "lldb/Host/File.h"
-#include "lldb/Host/HostInfo.h"
-#include "lldb/Symbol/SymbolVendor.h"
-#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/Target.h"
-
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
#include "clang/AST/ASTContext.h"
#include "clang/AST/ExternalASTSource.h"
#include "clang/Basic/FileManager.h"
+#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/Version.h"
#include "clang/CodeGen/CodeGenAction.h"
@@ -69,6 +46,37 @@
#include "llvm/Support/Host.h"
#include "llvm/Support/Signals.h"
+// Project includes
+#include "ClangExpressionParser.h"
+
+#include "ClangASTSource.h"
+#include "ClangExpressionHelper.h"
+#include "ClangExpressionDeclMap.h"
+#include "ClangModulesDeclVendor.h"
+#include "ClangPersistentVariables.h"
+#include "IRForTarget.h"
+
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Disassembler.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/StreamFile.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Expression/IRExecutionUnit.h"
+#include "lldb/Expression/IRDynamicChecks.h"
+#include "lldb/Expression/IRInterpreter.h"
+#include "lldb/Host/File.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+
using namespace clang;
using namespace llvm;
using namespace lldb_private;
@@ -99,6 +107,7 @@ class ClangExpressionParser::LLDBPreprocessorCallbacks : public PPCallbacks
ClangPersistentVariables &m_persistent_vars;
StreamString m_error_stream;
bool m_has_errors = false;
+
public:
LLDBPreprocessorCallbacks(ClangModulesDeclVendor &decl_vendor,
ClangPersistentVariables &persistent_vars) :
@@ -107,9 +116,10 @@ public:
{
}
- virtual void moduleImport(SourceLocation import_location,
- ModuleIdPath path,
- const clang::Module * /*null*/)
+ void
+ moduleImport(SourceLocation import_location,
+ clang::ModuleIdPath path,
+ const clang::Module * /*null*/) override
{
std::vector<ConstString> string_path;
@@ -149,9 +159,9 @@ public:
//===----------------------------------------------------------------------===//
ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope,
- ClangExpression &expr,
+ Expression &expr,
bool generate_debug_info) :
- m_expr (expr),
+ ExpressionParser (exe_scope, expr, generate_debug_info),
m_compiler (),
m_code_generator (),
m_pp_callbacks(nullptr)
@@ -210,17 +220,38 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope,
switch (language)
{
case lldb::eLanguageTypeC:
+ case lldb::eLanguageTypeC89:
+ case lldb::eLanguageTypeC99:
+ case lldb::eLanguageTypeC11:
+ // FIXME: the following language option is a temporary workaround,
+ // to "ask for C, get C++."
+ // 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;
break;
case lldb::eLanguageTypeObjC:
m_compiler->getLangOpts().ObjC1 = true;
m_compiler->getLangOpts().ObjC2 = true;
+ // FIXME: the following language option is a temporary workaround,
+ // to "ask for ObjC, get ObjC++" (see comment above).
+ m_compiler->getLangOpts().CPlusPlus = true;
break;
case lldb::eLanguageTypeC_plus_plus:
- m_compiler->getLangOpts().CPlusPlus = true;
+ case lldb::eLanguageTypeC_plus_plus_11:
+ case lldb::eLanguageTypeC_plus_plus_14:
m_compiler->getLangOpts().CPlusPlus11 = true;
m_compiler->getHeaderSearchOpts().UseLibcxx = true;
+ // fall thru ...
+ case lldb::eLanguageTypeC_plus_plus_03:
+ m_compiler->getLangOpts().CPlusPlus = true;
+ // FIXME: the following language option is a temporary workaround,
+ // to "ask for C++, get ObjC++". Apple hopes to remove this requirement
+ // on non-Apple platforms, but for now it is needed.
+ m_compiler->getLangOpts().ObjC1 = true;
break;
case lldb::eLanguageTypeObjC_plus_plus:
+ case lldb::eLanguageTypeUnknown:
default:
m_compiler->getLangOpts().ObjC1 = true;
m_compiler->getLangOpts().ObjC2 = true;
@@ -234,7 +265,7 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope,
m_compiler->getLangOpts().WChar = true;
m_compiler->getLangOpts().Blocks = true;
m_compiler->getLangOpts().DebuggerSupport = true; // Features specifically for debugger clients
- if (expr.DesiredResultType() == ClangExpression::eResultTypeId)
+ if (expr.DesiredResultType() == Expression::eResultTypeId)
m_compiler->getLangOpts().DebuggerCastResultToId = true;
m_compiler->getLangOpts().CharIsSigned =
@@ -254,7 +285,7 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope,
{
if (process_sp->GetObjCLanguageRuntime())
{
- if (process_sp->GetObjCLanguageRuntime()->GetRuntimeVersion() == eAppleObjC_V2)
+ if (process_sp->GetObjCLanguageRuntime()->GetRuntimeVersion() == ObjCLanguageRuntime::ObjCRuntimeVersions::eAppleObjC_V2)
m_compiler->getLangOpts().ObjCRuntime.set(ObjCRuntime::MacOSX, VersionTuple(10, 7));
else
m_compiler->getLangOpts().ObjCRuntime.set(ObjCRuntime::FragileMacOSX, VersionTuple(10, 7));
@@ -307,7 +338,8 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope,
if (ClangModulesDeclVendor *decl_vendor = target_sp->GetClangModulesDeclVendor())
{
- std::unique_ptr<PPCallbacks> pp_callbacks(new LLDBPreprocessorCallbacks(*decl_vendor, target_sp->GetPersistentVariables()));
+ ClangPersistentVariables *clang_persistent_vars = llvm::cast<ClangPersistentVariables>(target_sp->GetPersistentExpressionStateForLanguage(lldb::eLanguageTypeC));
+ std::unique_ptr<PPCallbacks> pp_callbacks(new LLDBPreprocessorCallbacks(*decl_vendor, *clang_persistent_vars));
m_pp_callbacks = static_cast<LLDBPreprocessorCallbacks*>(pp_callbacks.get());
m_compiler->getPreprocessor().addPPCallbacks(std::move(pp_callbacks));
}
@@ -325,7 +357,8 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope,
ast_context->InitBuiltinTypes(m_compiler->getTarget());
- ClangExpressionDeclMap *decl_map = m_expr.DeclMap();
+ ClangExpressionHelper *type_system_helper = dyn_cast<ClangExpressionHelper>(m_expr.GetTypeSystemHelper());
+ ClangExpressionDeclMap *decl_map = type_system_helper->DeclMap();
if (decl_map)
{
@@ -334,6 +367,8 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope,
ast_context->setExternalSource(ast_source);
}
+ m_ast_context.reset(new ClangASTContext(m_compiler->getTargetOpts().Triple.c_str()));
+ m_ast_context->setASTContext(ast_context.get());
m_compiler->setASTContext(ast_context.release());
std::string module_name("$__lldb_module");
@@ -372,7 +407,7 @@ ClangExpressionParser::Parse (Stream &stream)
if (HostInfo::GetLLDBPath(lldb::ePathTypeLLDBTempSystemDir, tmpdir_file_spec))
{
tmpdir_file_spec.AppendPathComponent("lldb-%%%%%%.expr");
- temp_source_path = std::move(tmpdir_file_spec.GetPath());
+ temp_source_path = tmpdir_file_spec.GetPath();
llvm::sys::fs::createUniqueFile(temp_source_path, temp_fd, result_path);
}
else
@@ -407,15 +442,23 @@ ClangExpressionParser::Parse (Stream &stream)
diag_buf->BeginSourceFile(m_compiler->getLangOpts(), &m_compiler->getPreprocessor());
- ASTConsumer *ast_transformer = m_expr.ASTTransformer(m_code_generator.get());
+ ClangExpressionHelper *type_system_helper = dyn_cast<ClangExpressionHelper>(m_expr.GetTypeSystemHelper());
- if (ClangExpressionDeclMap *decl_map = m_expr.DeclMap())
+ 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 (ast_transformer)
+ {
+ ast_transformer->Initialize(m_compiler->getASTContext());
ParseAST(m_compiler->getPreprocessor(), ast_transformer, m_compiler->getASTContext());
+ }
else
+ {
+ m_code_generator->Initialize(m_compiler->getASTContext());
ParseAST(m_compiler->getPreprocessor(), m_code_generator.get(), m_compiler->getASTContext());
+ }
diag_buf->EndSourceFile();
@@ -450,7 +493,7 @@ ClangExpressionParser::Parse (Stream &stream)
if (!num_errors)
{
- if (m_expr.DeclMap() && !m_expr.DeclMap()->ResolveUnknownTypes())
+ if (type_system_helper->DeclMap() && !type_system_helper->DeclMap()->ResolveUnknownTypes())
{
stream.Printf("error: Couldn't infer the type of a variable\n");
num_errors++;
@@ -481,7 +524,7 @@ static bool FindFunctionInModule (ConstString &mangled_name,
Error
ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_addr,
lldb::addr_t &func_end,
- std::shared_ptr<IRExecutionUnit> &execution_unit_sp,
+ lldb::IRExecutionUnitSP &execution_unit_sp,
ExecutionContext &exe_ctx,
bool &can_interpret,
ExecutionPolicy execution_policy)
@@ -523,7 +566,8 @@ ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_addr,
exe_ctx.GetTargetSP(),
m_compiler->getTargetOpts().Features));
- ClangExpressionDeclMap *decl_map = m_expr.DeclMap(); // result can be NULL
+ ClangExpressionHelper *type_system_helper = dyn_cast<ClangExpressionHelper>(m_expr.GetTypeSystemHelper());
+ ClangExpressionDeclMap *decl_map = type_system_helper->DeclMap(); // result can be NULL
if (decl_map)
{
@@ -611,11 +655,3 @@ ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_addr,
return err;
}
-
-bool
-ClangExpressionParser::GetGenerateDebugInfo () const
-{
- if (m_compiler)
- return m_compiler->getCodeGenOpts().getDebugInfo() == CodeGenOptions::FullDebugInfo;
- return false;
-}
diff --git a/include/lldb/Expression/ClangExpressionParser.h b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
index 21a27a489bcd..3c055380b839 100644
--- a/include/lldb/Expression/ClangExpressionParser.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
@@ -14,7 +14,7 @@
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/ClangForward.h"
#include "lldb/Core/Error.h"
-#include "lldb/Expression/IRForTarget.h"
+#include "lldb/Expression/ExpressionParser.h"
#include <string>
#include <vector>
@@ -34,7 +34,7 @@ class IRExecutionUnit;
/// conversion to formats (DWARF bytecode, or JIT compiled machine code)
/// that can be executed.
//----------------------------------------------------------------------
-class ClangExpressionParser
+class ClangExpressionParser : public ExpressionParser
{
public:
//------------------------------------------------------------------
@@ -51,13 +51,13 @@ public:
/// The expression to be parsed.
//------------------------------------------------------------------
ClangExpressionParser (ExecutionContextScope *exe_scope,
- ClangExpression &expr,
+ Expression &expr,
bool generate_debug_info);
//------------------------------------------------------------------
/// Destructor
//------------------------------------------------------------------
- ~ClangExpressionParser ();
+ ~ClangExpressionParser () override;
//------------------------------------------------------------------
/// Parse a single expression and convert it to IR using Clang. Don't
@@ -71,7 +71,7 @@ public:
/// success.
//------------------------------------------------------------------
unsigned
- Parse (Stream &stream);
+ Parse (Stream &stream) override;
//------------------------------------------------------------------
/// Ready an already-parsed expression for execution, possibly
@@ -113,33 +113,12 @@ public:
Error
PrepareForExecution (lldb::addr_t &func_addr,
lldb::addr_t &func_end,
- std::shared_ptr<IRExecutionUnit> &execution_unit_sp,
+ lldb::IRExecutionUnitSP &execution_unit_sp,
ExecutionContext &exe_ctx,
bool &can_interpret,
- lldb_private::ExecutionPolicy execution_policy);
+ lldb_private::ExecutionPolicy execution_policy) override;
- //------------------------------------------------------------------
- /// Disassemble the machine code for a JITted function from the target
- /// process's memory and print the result to a stream.
- ///
- /// @param[in] stream
- /// The stream to print disassembly to.
- ///
- /// @param[in] exc_context
- /// The execution context to get the machine code from.
- ///
- /// @return
- /// The error generated. If .Success() is true, disassembly succeeded.
- //------------------------------------------------------------------
- Error
- DisassembleFunction (Stream &stream,
- ExecutionContext &exe_ctx);
-
- bool
- GetGenerateDebugInfo () const;
-
private:
- ClangExpression & m_expr; ///< The expression to be parsed
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
@@ -149,6 +128,7 @@ private:
class LLDBPreprocessorCallbacks;
LLDBPreprocessorCallbacks *m_pp_callbacks; ///< Called when the preprocessor encounters module imports
+ std::unique_ptr<ClangASTContext> m_ast_context;
};
}
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp b/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
new file mode 100644
index 000000000000..908546b3ecdb
--- /dev/null
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
@@ -0,0 +1,76 @@
+//===-- ClangExpressionVariable.cpp -----------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "ClangExpressionVariable.h"
+
+#include "clang/AST/ASTContext.h"
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/Value.h"
+#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Process.h"
+
+using namespace lldb_private;
+using namespace clang;
+
+const char *g_clang_expression_variable_kind_name = "ClangExpressionVariable";
+
+ClangExpressionVariable::ClangExpressionVariable(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size) :
+ ExpressionVariable(LLVMCastKind::eKindClang),
+ m_parser_vars(),
+ m_jit_vars ()
+{
+ m_flags = EVNone;
+ m_frozen_sp = ValueObjectConstResult::Create (exe_scope, byte_order, addr_byte_size);
+}
+
+ClangExpressionVariable::ClangExpressionVariable (ExecutionContextScope *exe_scope,
+ Value &value,
+ const ConstString &name,
+ uint16_t flags) :
+ ExpressionVariable(LLVMCastKind::eKindClang),
+ m_parser_vars(),
+ m_jit_vars ()
+{
+ m_flags = flags;
+ m_frozen_sp = ValueObjectConstResult::Create (exe_scope, value, name);
+}
+
+ClangExpressionVariable::ClangExpressionVariable (const lldb::ValueObjectSP &valobj_sp) :
+ ExpressionVariable(LLVMCastKind::eKindClang),
+ m_parser_vars(),
+ m_jit_vars ()
+{
+ m_flags = EVNone;
+ m_frozen_sp = valobj_sp;
+}
+
+ClangExpressionVariable::ClangExpressionVariable(ExecutionContextScope *exe_scope,
+ const ConstString &name,
+ const TypeFromUser& user_type,
+ lldb::ByteOrder byte_order,
+ uint32_t addr_byte_size) :
+ ExpressionVariable(LLVMCastKind::eKindClang),
+ m_parser_vars(),
+ m_jit_vars()
+{
+ m_flags = EVNone;
+ m_frozen_sp = ValueObjectConstResult::Create (exe_scope, byte_order, addr_byte_size);
+ SetName (name);
+ SetCompilerType (user_type);
+}
+
+TypeFromUser
+ClangExpressionVariable::GetTypeFromUser()
+{
+ TypeFromUser tfu (m_frozen_sp->GetCompilerType());
+ return tfu;
+}
diff --git a/include/lldb/Expression/ClangExpressionVariable.h b/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
index 6c210106d51e..a4596148f6c7 100644
--- a/include/lldb/Expression/ClangExpressionVariable.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
@@ -21,11 +21,14 @@
#include <vector>
// Other libraries and framework includes
+#include "llvm/Support/Casting.h"
+
// Project includes
#include "lldb/lldb-public.h"
#include "lldb/Core/ClangForward.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Value.h"
+#include "lldb/Expression/ExpressionVariable.h"
#include "lldb/Symbol/TaggedASTType.h"
namespace llvm {
@@ -34,7 +37,6 @@ namespace llvm {
namespace lldb_private {
-class ClangExpressionVariableList;
class ValueObjectConstResult;
//----------------------------------------------------------------------
@@ -60,7 +62,7 @@ class ValueObjectConstResult;
/// polymorphism, and provides necessary support methods. Its interface
/// is RTTI-neutral.
//----------------------------------------------------------------------
-class ClangExpressionVariable
+class ClangExpressionVariable : public ExpressionVariable
{
public:
ClangExpressionVariable(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size);
@@ -71,6 +73,44 @@ public:
uint16_t flags = EVNone);
ClangExpressionVariable(const lldb::ValueObjectSP &valobj_sp);
+
+ ClangExpressionVariable(ExecutionContextScope *exe_scope,
+ const 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
+ /// The name of the requested variable.
+ ///
+ /// @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)
+ {
+ lldb::ExpressionVariableSP var_sp;
+ for (size_t index = 0, size = list.GetSize(); index < size; ++index)
+ {
+ var_sp = list.GetVariableAtIndex(index);
+
+ if (ClangExpressionVariable *clang_var = llvm::dyn_cast<ClangExpressionVariable>(var_sp.get()))
+ {
+ ClangExpressionVariable::ParserVars *parser_vars = clang_var->GetParserVars(parser_id);
+
+ if (parser_vars && parser_vars->m_named_decl == decl)
+ return clang_var;
+ }
+ }
+ return nullptr;
+ }
//----------------------------------------------------------------------
/// If the variable contains its own data, make a Value point at it.
@@ -90,9 +130,6 @@ public:
bool
PointValueAtData(Value &value, ExecutionContext *exe_ctx);
- lldb::ValueObjectSP
- GetValueObject();
-
//----------------------------------------------------------------------
/// The following values should not live beyond parsing
//----------------------------------------------------------------------
@@ -205,252 +242,24 @@ public:
else
return &i->second;
}
-
- //----------------------------------------------------------------------
- /// Return the variable's size in bytes
- //----------------------------------------------------------------------
- size_t
- GetByteSize ();
-
- const ConstString &
- GetName();
-
- RegisterInfo *
- GetRegisterInfo();
-
- void
- SetRegisterInfo (const RegisterInfo *reg_info);
-
- ClangASTType
- GetClangType ();
- void
- SetClangType (const ClangASTType &clang_type);
-
TypeFromUser
GetTypeFromUser ();
-
- uint8_t *
- GetValueBytes ();
- void
- SetName (const ConstString &name);
-
- void
- ValueUpdated ();
-
- // this function is used to copy the address-of m_live_sp into m_frozen_sp
- // this is necessary because the results of certain cast and pointer-arithmetic
- // operations (such as those described in bugzilla issues 11588 and 11618) generate
- // frozen objects that do not have a valid address-of, which can be troublesome when
- // using synthetic children providers. Transferring the address-of the live object
- // solves these issues and provides the expected user-level behavior
- void
- TransferAddress (bool force = false);
-
- typedef std::shared_ptr<ValueObjectConstResult> ValueObjectConstResultSP;
-
- //----------------------------------------------------------------------
- /// Members
- //----------------------------------------------------------------------
- enum Flags
- {
- EVNone = 0,
- EVIsLLDBAllocated = 1 << 0, ///< This variable is resident in a location specifically allocated for it by LLDB in the target process
- EVIsProgramReference = 1 << 1, ///< This variable is a reference to a (possibly invalid) area managed by the target program
- EVNeedsAllocation = 1 << 2, ///< Space for this variable has yet to be allocated in the target process
- EVIsFreezeDried = 1 << 3, ///< This variable's authoritative version is in m_frozen_sp (for example, for statically-computed results)
- EVNeedsFreezeDry = 1 << 4, ///< Copy from m_live_sp to m_frozen_sp during dematerialization
- EVKeepInTarget = 1 << 5, ///< Keep the allocation after the expression is complete rather than freeze drying its contents and freeing it
- EVTypeIsReference = 1 << 6, ///< The original type of this variable is a reference, so materialize the value rather than the location
- EVUnknownType = 1 << 7, ///< This is a symbol of unknown type, and the type must be resolved after parsing is complete
- EVBareRegister = 1 << 8 ///< This variable is a direct reference to $pc or some other entity.
- };
-
- typedef uint16_t FlagType;
-
- FlagType m_flags; // takes elements of Flags
-
- lldb::ValueObjectSP m_frozen_sp;
- lldb::ValueObjectSP m_live_sp;
-
- DISALLOW_COPY_AND_ASSIGN (ClangExpressionVariable);
-};
-
-//----------------------------------------------------------------------
-/// @class ClangExpressionVariableListBase ClangExpressionVariable.h "lldb/Expression/ClangExpressionVariable.h"
-/// @brief A list of variable references.
-///
-/// This class stores variables internally, acting as the permanent store.
-//----------------------------------------------------------------------
-class ClangExpressionVariableList
-{
-public:
- //----------------------------------------------------------------------
- /// Implementation of methods in ClangExpressionVariableListBase
- //----------------------------------------------------------------------
- size_t
- GetSize()
- {
- return m_variables.size();
- }
-
- lldb::ClangExpressionVariableSP
- GetVariableAtIndex(size_t index)
- {
- lldb::ClangExpressionVariableSP var_sp;
- if (index < m_variables.size())
- var_sp = m_variables[index];
- return var_sp;
- }
-
- size_t
- AddVariable (const lldb::ClangExpressionVariableSP &var_sp)
- {
- m_variables.push_back(var_sp);
- return m_variables.size() - 1;
- }
-
- bool
- ContainsVariable (const lldb::ClangExpressionVariableSP &var_sp)
- {
- const size_t size = m_variables.size();
- for (size_t index = 0; index < size; ++index)
- {
- if (m_variables[index].get() == var_sp.get())
- return true;
- }
- return false;
- }
-
- //----------------------------------------------------------------------
- /// Finds a variable by name in the list.
- ///
- /// @param[in] name
- /// The name of the requested variable.
- ///
- /// @return
- /// The variable requested, or NULL if that variable is not in the list.
- //----------------------------------------------------------------------
- lldb::ClangExpressionVariableSP
- GetVariable (const ConstString &name)
- {
- lldb::ClangExpressionVariableSP var_sp;
- for (size_t index = 0, size = GetSize(); index < size; ++index)
- {
- var_sp = GetVariableAtIndex(index);
- if (var_sp->GetName() == name)
- return var_sp;
- }
- var_sp.reset();
- return var_sp;
- }
-
- lldb::ClangExpressionVariableSP
- GetVariable (const char *name)
+ //------------------------------------------------------------------
+ // llvm casting support
+ //------------------------------------------------------------------
+ static bool classof(const ExpressionVariable *ev)
{
- lldb::ClangExpressionVariableSP var_sp;
- if (name && name[0])
- {
- for (size_t index = 0, size = GetSize(); index < size; ++index)
- {
- var_sp = GetVariableAtIndex(index);
- const char *var_name_cstr = var_sp->GetName().GetCString();
- if (!var_name_cstr || !name)
- continue;
- if (::strcmp (var_name_cstr, name) == 0)
- return var_sp;
- }
- var_sp.reset();
- }
- return var_sp;
+ return ev->getKind() == ExpressionVariable::eKindClang;
}
//----------------------------------------------------------------------
- /// Finds a variable by NamedDecl in the list.
- ///
- /// @param[in] name
- /// The name of the requested variable.
- ///
- /// @return
- /// The variable requested, or NULL if that variable is not in the list.
- //----------------------------------------------------------------------
- lldb::ClangExpressionVariableSP
- GetVariable (const clang::NamedDecl *decl, uint64_t parser_id)
- {
- lldb::ClangExpressionVariableSP var_sp;
- for (size_t index = 0, size = GetSize(); index < size; ++index)
- {
- var_sp = GetVariableAtIndex(index);
-
- ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(parser_id);
-
- if (parser_vars && parser_vars->m_named_decl == decl)
- return var_sp;
- }
- var_sp.reset();
- return var_sp;
- }
-
- //----------------------------------------------------------------------
- /// Create a new variable in the list and return its index
- //----------------------------------------------------------------------
- lldb::ClangExpressionVariableSP
- CreateVariable (ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size)
- {
- lldb::ClangExpressionVariableSP var_sp(new ClangExpressionVariable(exe_scope, byte_order, addr_byte_size));
- m_variables.push_back(var_sp);
- return var_sp;
- }
-
- lldb::ClangExpressionVariableSP
- CreateVariable(const lldb::ValueObjectSP &valobj_sp)
- {
- lldb::ClangExpressionVariableSP var_sp(new ClangExpressionVariable(valobj_sp));
- m_variables.push_back(var_sp);
- return var_sp;
- }
-
- lldb::ClangExpressionVariableSP
- CreateVariable (ExecutionContextScope *exe_scope,
- const ConstString &name,
- const TypeFromUser& user_type,
- lldb::ByteOrder byte_order,
- uint32_t addr_byte_size)
- {
- lldb::ClangExpressionVariableSP var_sp(new ClangExpressionVariable(exe_scope, byte_order, addr_byte_size));
- var_sp->SetName (name);
- var_sp->SetClangType (user_type);
- m_variables.push_back(var_sp);
- return var_sp;
- }
-
- void
- RemoveVariable (lldb::ClangExpressionVariableSP var_sp)
- {
- for (std::vector<lldb::ClangExpressionVariableSP>::iterator vi = m_variables.begin(), ve = m_variables.end();
- vi != ve;
- ++vi)
- {
- if (vi->get() == var_sp.get())
- {
- m_variables.erase(vi);
- return;
- }
- }
- }
-
- void
- Clear()
- {
- m_variables.clear();
- }
-
-private:
- std::vector <lldb::ClangExpressionVariableSP> m_variables;
+ /// Members
+ //----------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN (ClangExpressionVariable);
};
-
} // namespace lldb_private
#endif // liblldb_ClangExpressionVariable_h_
diff --git a/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp b/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
new file mode 100644
index 000000000000..0d0d7475a00e
--- /dev/null
+++ b/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
@@ -0,0 +1,221 @@
+//===-- ClangFunctionCallerCaller.cpp ---------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "ClangFunctionCaller.h"
+
+#include "ASTStructExtractor.h"
+#include "ClangExpressionParser.h"
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/RecordLayout.h"
+#include "clang/CodeGen/CodeGenAction.h"
+#include "clang/CodeGen/ModuleBuilder.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/ExecutionEngine/ExecutionEngine.h"
+#include "llvm/IR/Module.h"
+
+// Project includes
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/State.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Core/ValueObjectList.h"
+#include "lldb/Expression/IRExecutionUnit.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
+#include "lldb/Target/ThreadPlan.h"
+#include "lldb/Target/ThreadPlanCallFunction.h"
+
+using namespace lldb_private;
+
+//----------------------------------------------------------------------
+// ClangFunctionCaller constructor
+//----------------------------------------------------------------------
+ClangFunctionCaller::ClangFunctionCaller
+(
+ ExecutionContextScope &exe_scope,
+ const CompilerType &return_type,
+ const Address& functionAddress,
+ const ValueList &arg_value_list,
+ const char *name
+) :
+ FunctionCaller(exe_scope, return_type, functionAddress, arg_value_list, name),
+ m_type_system_helper (*this)
+{
+ m_jit_process_wp = lldb::ProcessWP(exe_scope.CalculateProcess());
+ // Can't make a ClangFunctionCaller without a process.
+ assert (m_jit_process_wp.lock());
+}
+
+//----------------------------------------------------------------------
+// Destructor
+//----------------------------------------------------------------------
+ClangFunctionCaller::~ClangFunctionCaller()
+{
+}
+
+unsigned
+ClangFunctionCaller::CompileFunction (Stream &errors)
+{
+ if (m_compiled)
+ return 0;
+
+ // FIXME: How does clang tell us there's no return value? We need to handle that case.
+ unsigned num_errors = 0;
+
+ std::string return_type_str (m_function_return_type.GetTypeName().AsCString(""));
+
+ // Cons up the function we're going to wrap our call in, then compile it...
+ // We declare the function "extern "C"" because the compiler might be in C++
+ // mode which would mangle the name and then we couldn't find it again...
+ m_wrapper_function_text.clear();
+ m_wrapper_function_text.append ("extern \"C\" void ");
+ m_wrapper_function_text.append (m_wrapper_function_name);
+ m_wrapper_function_text.append (" (void *input)\n{\n struct ");
+ m_wrapper_function_text.append (m_wrapper_struct_name);
+ m_wrapper_function_text.append (" \n {\n");
+ m_wrapper_function_text.append (" ");
+ m_wrapper_function_text.append (return_type_str);
+ m_wrapper_function_text.append (" (*fn_ptr) (");
+
+ // Get the number of arguments. If we have a function type and it is prototyped,
+ // trust that, otherwise use the values we were given.
+
+ // FIXME: This will need to be extended to handle Variadic functions. We'll need
+ // to pull the defined arguments out of the function, then add the types from the
+ // arguments list for the variable arguments.
+
+ uint32_t num_args = UINT32_MAX;
+ bool trust_function = false;
+ // GetArgumentCount returns -1 for an unprototyped function.
+ CompilerType function_clang_type;
+ if (m_function_ptr)
+ {
+ function_clang_type = m_function_ptr->GetCompilerType();
+ if (function_clang_type)
+ {
+ int num_func_args = function_clang_type.GetFunctionArgumentCount();
+ if (num_func_args >= 0)
+ {
+ trust_function = true;
+ num_args = num_func_args;
+ }
+ }
+ }
+
+ if (num_args == UINT32_MAX)
+ num_args = m_arg_values.GetSize();
+
+ std::string args_buffer; // This one stores the definition of all the args in "struct caller".
+ std::string args_list_buffer; // This one stores the argument list called from the structure.
+ for (size_t i = 0; i < num_args; i++)
+ {
+ std::string type_name;
+
+ if (trust_function)
+ {
+ type_name = function_clang_type.GetFunctionArgumentTypeAtIndex(i).GetTypeName().AsCString("");
+ }
+ else
+ {
+ CompilerType clang_qual_type = m_arg_values.GetValueAtIndex(i)->GetCompilerType ();
+ if (clang_qual_type)
+ {
+ type_name = clang_qual_type.GetTypeName().AsCString("");
+ }
+ else
+ {
+ errors.Printf("Could not determine type of input value %" PRIu64 ".", (uint64_t)i);
+ return 1;
+ }
+ }
+
+ m_wrapper_function_text.append (type_name);
+ if (i < num_args - 1)
+ m_wrapper_function_text.append (", ");
+
+ char arg_buf[32];
+ args_buffer.append (" ");
+ args_buffer.append (type_name);
+ snprintf(arg_buf, 31, "arg_%" PRIu64, (uint64_t)i);
+ args_buffer.push_back (' ');
+ args_buffer.append (arg_buf);
+ args_buffer.append (";\n");
+
+ args_list_buffer.append ("__lldb_fn_data->");
+ args_list_buffer.append (arg_buf);
+ if (i < num_args - 1)
+ args_list_buffer.append (", ");
+
+ }
+ m_wrapper_function_text.append (");\n"); // Close off the function calling prototype.
+
+ m_wrapper_function_text.append (args_buffer);
+
+ m_wrapper_function_text.append (" ");
+ m_wrapper_function_text.append (return_type_str);
+ m_wrapper_function_text.append (" return_value;");
+ m_wrapper_function_text.append ("\n };\n struct ");
+ m_wrapper_function_text.append (m_wrapper_struct_name);
+ m_wrapper_function_text.append ("* __lldb_fn_data = (struct ");
+ m_wrapper_function_text.append (m_wrapper_struct_name);
+ m_wrapper_function_text.append (" *) input;\n");
+
+ m_wrapper_function_text.append (" __lldb_fn_data->return_value = __lldb_fn_data->fn_ptr (");
+ m_wrapper_function_text.append (args_list_buffer);
+ m_wrapper_function_text.append (");\n}\n");
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ if (log)
+ log->Printf ("Expression: \n\n%s\n\n", m_wrapper_function_text.c_str());
+
+ // Okay, now compile this expression
+
+ lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock());
+ if (jit_process_sp)
+ {
+ const bool generate_debug_info = true;
+ m_parser.reset(new ClangExpressionParser(jit_process_sp.get(), *this, generate_debug_info));
+
+ num_errors = m_parser->Parse (errors);
+ }
+ else
+ {
+ errors.Printf("no process - unable to inject function");
+ num_errors = 1;
+ }
+
+ m_compiled = (num_errors == 0);
+
+ if (!m_compiled)
+ return num_errors;
+
+ return num_errors;
+}
+
+clang::ASTConsumer *
+ClangFunctionCaller::ClangFunctionCallerHelper::ASTTransformer (clang::ASTConsumer *passthrough)
+{
+ m_struct_extractor.reset(new ASTStructExtractor(passthrough, m_owner.GetWrapperStructName(), m_owner));
+
+ return m_struct_extractor.get();
+}
diff --git a/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h b/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h
new file mode 100644
index 000000000000..3e30f818a932
--- /dev/null
+++ b/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h
@@ -0,0 +1,173 @@
+//===-- ClangFunctionCaller.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_ClangFunctionCaller_h_
+#define liblldb_ClangFunctionCaller_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "ClangExpressionHelper.h"
+
+#include "lldb/Core/ClangForward.h"
+#include "lldb/Core/Address.h"
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Core/Value.h"
+#include "lldb/Core/ValueObjectList.h"
+#include "lldb/Expression/FunctionCaller.h"
+#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Target/Process.h"
+
+namespace lldb_private
+{
+
+class ASTStructExtractor;
+class ClangExpressionParser;
+
+//----------------------------------------------------------------------
+/// @class ClangFunctionCaller ClangFunctionCaller.h "lldb/Expression/ClangFunctionCaller.h"
+/// @brief Encapsulates a function that can be called.
+///
+/// A given ClangFunctionCaller object can handle a single function signature.
+/// Once constructed, it can set up any number of concurrent calls to
+/// functions with that signature.
+///
+/// It performs the call by synthesizing a structure that contains the pointer
+/// to the function and the arguments that should be passed to that function,
+/// and producing a special-purpose JIT-compiled function that accepts a void*
+/// pointing to this struct as its only argument and calls the function in the
+/// struct with the written arguments. This method lets Clang handle the
+/// vagaries of function calling conventions.
+///
+/// The simplest use of the ClangFunctionCaller is to construct it with a
+/// function representative of the signature you want to use, then call
+/// ExecuteFunction(ExecutionContext &, Stream &, Value &).
+///
+/// If you need to reuse the arguments for several calls, you can call
+/// InsertFunction() followed by WriteFunctionArguments(), which will return
+/// the location of the args struct for the wrapper function in args_addr_ref.
+///
+/// If you need to call the function on the thread plan stack, you can also
+/// call InsertFunction() followed by GetThreadPlanToCallFunction().
+///
+/// Any of the methods that take arg_addr_ptr or arg_addr_ref can be passed
+/// a pointer set to LLDB_INVALID_ADDRESS and new structure will be allocated
+/// and its address returned in that variable.
+///
+/// Any of the methods that take arg_addr_ptr can be passed NULL, and the
+/// argument space will be managed for you.
+//----------------------------------------------------------------------
+class ClangFunctionCaller : public FunctionCaller
+{
+ friend class ASTStructExtractor;
+
+ 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;
+ }
+
+ //------------------------------------------------------------------
+ /// 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
+ /// The ASTConsumer that the returned transformer should send
+ /// the ASTs to after transformation.
+ //------------------------------------------------------------------
+ clang::ASTConsumer *
+ ASTTransformer(clang::ASTConsumer *passthrough) override;
+
+ private:
+ ClangFunctionCaller &m_owner;
+ std::unique_ptr<ASTStructExtractor> m_struct_extractor; ///< The class that generates the argument struct layout.
+ };
+
+public:
+ //------------------------------------------------------------------
+ /// Constructor
+ ///
+ /// @param[in] exe_scope
+ /// An execution context scope that gets us at least a target and
+ /// process.
+ ///
+ /// @param[in] ast_context
+ /// The AST context to evaluate argument types in.
+ ///
+ /// @param[in] return_qualtype
+ /// An opaque Clang QualType for the function result. Should be
+ /// defined in ast_context.
+ ///
+ /// @param[in] function_address
+ /// The address of the function to call.
+ ///
+ /// @param[in] arg_value_list
+ /// The default values to use when calling this function. Can
+ /// be overridden using WriteFunctionArguments().
+ //------------------------------------------------------------------
+ ClangFunctionCaller (ExecutionContextScope &exe_scope,
+ const CompilerType &return_type,
+ const Address& function_address,
+ const ValueList &arg_value_list,
+ const char *name);
+
+ ~ClangFunctionCaller() override;
+
+ //------------------------------------------------------------------
+ /// Compile the wrapper function
+ ///
+ /// @param[in] errors
+ /// The stream to print parser errors to.
+ ///
+ /// @return
+ /// The number of errors.
+ //------------------------------------------------------------------
+ unsigned
+ CompileFunction (Stream &errors) override;
+
+ ExpressionTypeSystemHelper *
+ GetTypeSystemHelper () override
+ {
+ return &m_type_system_helper;
+ }
+
+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.
+ ClangFunctionCallerHelper m_type_system_helper;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_ClangFunctionCaller_h_
diff --git a/source/Expression/ClangModulesDeclVendor.cpp b/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index e8253630724a..05d8a320a5a4 100644
--- a/source/Expression/ClangModulesDeclVendor.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -7,9 +7,21 @@
//
//===----------------------------------------------------------------------===//
-#include <mutex> // std::once
+// C Includes
+// C++ Includes
+#include <mutex>
-#include "lldb/Expression/ClangModulesDeclVendor.h"
+// Other libraries and framework includes
+#include "clang/Basic/TargetInfo.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Lex/Preprocessor.h"
+#include "clang/Parse/Parser.h"
+#include "clang/Sema/Lookup.h"
+#include "clang/Serialization/ASTReader.h"
+
+// Project includes
+#include "ClangModulesDeclVendor.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/StreamString.h"
@@ -20,15 +32,6 @@
#include "lldb/Target/Target.h"
#include "lldb/Utility/LLDBAssert.h"
-#include "clang/Basic/TargetInfo.h"
-#include "clang/Frontend/CompilerInstance.h"
-#include "clang/Frontend/FrontendActions.h"
-#include "clang/Lex/Preprocessor.h"
-#include "clang/Parse/Parser.h"
-#include "clang/Sema/Lookup.h"
-#include "clang/Serialization/ASTReader.h"
-
-
using namespace lldb_private;
namespace {
@@ -38,14 +41,17 @@ namespace {
{
public:
StoringDiagnosticConsumer ();
+
void
- HandleDiagnostic (clang::DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &info);
+ HandleDiagnostic(clang::DiagnosticsEngine::Level DiagLevel,
+ const clang::Diagnostic &info) override;
void
ClearDiagnostics ();
void
DumpDiagnostics (Stream &error_stream);
+
private:
typedef std::pair<clang::DiagnosticsEngine::Level, std::string> IDAndDiagnostic;
std::vector<IDAndDiagnostic> m_diagnostics;
@@ -61,29 +67,29 @@ namespace {
llvm::IntrusiveRefCntPtr<clang::CompilerInvocation> &compiler_invocation,
std::unique_ptr<clang::CompilerInstance> &&compiler_instance,
std::unique_ptr<clang::Parser> &&parser);
-
- virtual bool
+
+ ~ClangModulesDeclVendorImpl() override = default;
+
+ bool
AddModule(ModulePath &path,
ModuleVector *exported_modules,
Stream &error_stream) override;
-
- virtual bool
+
+ bool
AddModulesForCompileUnit(CompileUnit &cu,
ModuleVector &exported_modules,
Stream &error_stream) override;
+
+ uint32_t
+ FindDecls(const ConstString &name,
+ bool append,
+ uint32_t max_matches,
+ std::vector <clang::NamedDecl*> &decls) override;
- virtual uint32_t
- FindDecls (const ConstString &name,
- bool append,
- uint32_t max_matches,
- std::vector <clang::NamedDecl*> &decls) override;
-
- virtual void
+ void
ForEachMacro(const ModuleVector &modules,
std::function<bool (const std::string &)> handler) override;
- ~ClangModulesDeclVendorImpl();
-
private:
void
ReportModuleExportsHelper (std::set<ClangModulesDeclVendor::ModuleID> &exports,
@@ -110,7 +116,7 @@ namespace {
ImportedModuleMap m_imported_modules;
ImportedModuleSet m_user_imported_modules;
};
-}
+} // anonymous namespace
StoringDiagnosticConsumer::StoringDiagnosticConsumer ()
{
@@ -164,7 +170,6 @@ GetResourceDir ()
return g_cached_resource_dir;
}
-
ClangModulesDeclVendor::ClangModulesDeclVendor()
{
}
@@ -318,7 +323,6 @@ ClangModulesDeclVendorImpl::AddModule(ModulePath &path,
return false;
}
-
bool
ClangModulesDeclVendor::LanguageSupportsClangModules (lldb::LanguageType language)
{
@@ -597,10 +601,6 @@ ClangModulesDeclVendorImpl::ForEachMacro(const ClangModulesDeclVendor::ModuleVec
}
}
-ClangModulesDeclVendorImpl::~ClangModulesDeclVendorImpl()
-{
-}
-
clang::ModuleLoadResult
ClangModulesDeclVendorImpl::DoGetModule(clang::ModuleIdPath path,
bool make_visible)
diff --git a/include/lldb/Expression/ClangModulesDeclVendor.h b/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h
index a8297c8fa331..df3b20550f9a 100644
--- a/include/lldb/Expression/ClangModulesDeclVendor.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef _liblldb_ClangModulesDeclVendor_
-#define _liblldb_ClangModulesDeclVendor_
+#ifndef liblldb_ClangModulesDeclVendor_h
+#define liblldb_ClangModulesDeclVendor_h
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/ClangForward.h"
@@ -29,8 +29,7 @@ public:
//------------------------------------------------------------------
ClangModulesDeclVendor();
- virtual
- ~ClangModulesDeclVendor();
+ ~ClangModulesDeclVendor() override;
static ClangModulesDeclVendor *
Create(Target &target);
@@ -122,8 +121,8 @@ public:
//------------------------------------------------------------------
static bool
LanguageSupportsClangModules (lldb::LanguageType language);
-
};
-}
-#endif /* defined(_lldb_ClangModulesDeclVendor_) */
+} // namespace lldb_private
+
+#endif // liblldb_ClangModulesDeclVendor_h
diff --git a/source/Expression/ClangPersistentVariables.cpp b/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
index db062d2e20b6..9bf9d435d7ea 100644
--- a/source/Expression/ClangPersistentVariables.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
@@ -7,7 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Expression/ClangPersistentVariables.h"
+#include "ClangPersistentVariables.h"
+
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/StreamString.h"
@@ -19,35 +20,29 @@ using namespace lldb;
using namespace lldb_private;
ClangPersistentVariables::ClangPersistentVariables () :
- ClangExpressionVariableList(),
+ lldb_private::PersistentExpressionState(LLVMCastKind::eKindClang),
m_next_persistent_variable_id (0)
{
}
-ClangExpressionVariableSP
+ExpressionVariableSP
ClangPersistentVariables::CreatePersistentVariable (const lldb::ValueObjectSP &valobj_sp)
{
- ClangExpressionVariableSP var_sp (CreateVariable(valobj_sp));
- return var_sp;
+ return AddNewlyConstructedVariable(new ClangExpressionVariable(valobj_sp));
}
-ClangExpressionVariableSP
+ExpressionVariableSP
ClangPersistentVariables::CreatePersistentVariable (ExecutionContextScope *exe_scope,
const ConstString &name,
- const TypeFromUser& user_type,
+ const CompilerType& compiler_type,
lldb::ByteOrder byte_order,
uint32_t addr_byte_size)
{
- ClangExpressionVariableSP var_sp (GetVariable(name));
-
- if (!var_sp)
- var_sp = CreateVariable(exe_scope, name, user_type, byte_order, addr_byte_size);
-
- return var_sp;
+ return AddNewlyConstructedVariable(new ClangExpressionVariable(exe_scope, name, compiler_type, byte_order, addr_byte_size));
}
void
-ClangPersistentVariables::RemovePersistentVariable (lldb::ClangExpressionVariableSP variable)
+ClangPersistentVariables::RemovePersistentVariable (lldb::ExpressionVariableSP variable)
{
RemoveVariable(variable);
diff --git a/include/lldb/Expression/ClangPersistentVariables.h b/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
index 247f87fae41b..0e03d013d049 100644
--- a/include/lldb/Expression/ClangPersistentVariables.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
@@ -10,11 +10,17 @@
#ifndef liblldb_ClangPersistentVariables_h_
#define liblldb_ClangPersistentVariables_h_
-#include "lldb/Expression/ClangExpressionVariable.h"
-#include "lldb/Expression/ClangModulesDeclVendor.h"
-
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
#include "llvm/ADT/DenseMap.h"
+// Project includes
+#include "ClangExpressionVariable.h"
+#include "ClangModulesDeclVendor.h"
+
+#include "lldb/Expression/ExpressionVariable.h"
+
namespace lldb_private
{
@@ -26,24 +32,30 @@ namespace lldb_private
/// ClangPersistentVariable for more discussion. Also provides an increasing,
/// 0-based counter for naming result variables.
//----------------------------------------------------------------------
-class ClangPersistentVariables : public ClangExpressionVariableList
+class ClangPersistentVariables : public PersistentExpressionState
{
public:
-
- //----------------------------------------------------------------------
- /// Constructor
- //----------------------------------------------------------------------
- ClangPersistentVariables ();
+ ClangPersistentVariables();
- lldb::ClangExpressionVariableSP
- CreatePersistentVariable (const lldb::ValueObjectSP &valobj_sp);
+ ~ClangPersistentVariables() override = default;
- lldb::ClangExpressionVariableSP
+ //------------------------------------------------------------------
+ // llvm casting support
+ //------------------------------------------------------------------
+ static bool classof(const PersistentExpressionState *pv)
+ {
+ return pv->getKind() == PersistentExpressionState::eKindClang;
+ }
+
+ lldb::ExpressionVariableSP
+ CreatePersistentVariable (const lldb::ValueObjectSP &valobj_sp) override;
+
+ lldb::ExpressionVariableSP
CreatePersistentVariable (ExecutionContextScope *exe_scope,
const ConstString &name,
- const TypeFromUser& user_type,
+ const CompilerType& compiler_type,
lldb::ByteOrder byte_order,
- uint32_t addr_byte_size);
+ uint32_t addr_byte_size) override;
//----------------------------------------------------------------------
/// Return the next entry in the sequence of strings "$0", "$1", ... for
@@ -53,10 +65,13 @@ public:
/// A string that contains the next persistent variable name.
//----------------------------------------------------------------------
ConstString
- GetNextPersistentVariableName ();
+ GetNextPersistentVariableName () override;
void
- RemovePersistentVariable (lldb::ClangExpressionVariableSP variable);
+ RemovePersistentVariable (lldb::ExpressionVariableSP variable) override;
+
+ lldb::addr_t
+ LookupSymbol (const ConstString &name) override { return LLDB_INVALID_ADDRESS; }
void
RegisterPersistentType (const ConstString &name,
@@ -86,6 +101,6 @@ private:
///< priority source for macros.
};
-}
+} // namespace lldb_private
-#endif
+#endif // liblldb_ClangPersistentVariables_h_
diff --git a/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
new file mode 100644
index 000000000000..11f7f84ff5f1
--- /dev/null
+++ b/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -0,0 +1,673 @@
+//===-- ClangUserExpression.cpp ---------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#include <cstdlib>
+#include <string>
+#include <map>
+
+#include "ClangUserExpression.h"
+
+#include "ASTResultSynthesizer.h"
+#include "ClangExpressionDeclMap.h"
+#include "ClangExpressionParser.h"
+#include "ClangModulesDeclVendor.h"
+#include "ClangPersistentVariables.h"
+
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/StreamFile.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/Expression/ExpressionSourceCode.h"
+#include "lldb/Expression/IRExecutionUnit.h"
+#include "lldb/Expression/IRInterpreter.h"
+#include "lldb/Expression/Materializer.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/Block.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
+#include "lldb/Symbol/VariableList.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/ThreadPlan.h"
+#include "lldb/Target/ThreadPlanCallUserExpression.h"
+
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclObjC.h"
+
+using namespace lldb_private;
+
+ClangUserExpression::ClangUserExpression (ExecutionContextScope &exe_scope,
+ const char *expr,
+ const char *expr_prefix,
+ lldb::LanguageType language,
+ ResultType desired_type,
+ const EvaluateExpressionOptions &options) :
+ LLVMUserExpression (exe_scope, expr, expr_prefix, language, desired_type, options),
+ m_type_system_helper(*m_target_wp.lock().get())
+{
+ switch (m_language)
+ {
+ case lldb::eLanguageTypeC_plus_plus:
+ m_allow_cxx = true;
+ break;
+ case lldb::eLanguageTypeObjC:
+ m_allow_objc = true;
+ break;
+ case lldb::eLanguageTypeObjC_plus_plus:
+ default:
+ m_allow_cxx = true;
+ m_allow_objc = true;
+ break;
+ }
+}
+
+ClangUserExpression::~ClangUserExpression ()
+{
+}
+
+void
+ClangUserExpression::ScanContext(ExecutionContext &exe_ctx, Error &err)
+{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+
+ if (log)
+ log->Printf("ClangUserExpression::ScanContext()");
+
+ m_target = exe_ctx.GetTargetPtr();
+
+ if (!(m_allow_cxx || m_allow_objc))
+ {
+ if (log)
+ log->Printf(" [CUE::SC] Settings inhibit C++ and Objective-C");
+ return;
+ }
+
+ StackFrame *frame = exe_ctx.GetFramePtr();
+ if (frame == NULL)
+ {
+ if (log)
+ log->Printf(" [CUE::SC] Null stack frame");
+ return;
+ }
+
+ SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction | lldb::eSymbolContextBlock);
+
+ if (!sym_ctx.function)
+ {
+ if (log)
+ log->Printf(" [CUE::SC] Null function");
+ return;
+ }
+
+ // Find the block that defines the function represented by "sym_ctx"
+ Block *function_block = sym_ctx.GetFunctionBlock();
+
+ if (!function_block)
+ {
+ if (log)
+ log->Printf(" [CUE::SC] Null function block");
+ return;
+ }
+
+ CompilerDeclContext decl_context = function_block->GetDeclContext();
+
+ if (!decl_context)
+ {
+ if (log)
+ log->Printf(" [CUE::SC] Null decl context");
+ return;
+ }
+
+ if (clang::CXXMethodDecl *method_decl = ClangASTContext::DeclContextGetAsCXXMethodDecl(decl_context))
+ {
+ if (m_allow_cxx && method_decl->isInstance())
+ {
+ if (m_enforce_valid_object)
+ {
+ lldb::VariableListSP variable_list_sp (function_block->GetBlockVariableList (true));
+
+ const char *thisErrorString = "Stopped in a C++ method, but 'this' isn't available; pretending we are in a generic context";
+
+ if (!variable_list_sp)
+ {
+ err.SetErrorString(thisErrorString);
+ return;
+ }
+
+ lldb::VariableSP this_var_sp (variable_list_sp->FindVariable(ConstString("this")));
+
+ if (!this_var_sp ||
+ !this_var_sp->IsInScope(frame) ||
+ !this_var_sp->LocationIsValidForFrame (frame))
+ {
+ err.SetErrorString(thisErrorString);
+ return;
+ }
+ }
+
+ m_in_cplusplus_method = true;
+ m_needs_object_ptr = true;
+ }
+ }
+ else if (clang::ObjCMethodDecl *method_decl = ClangASTContext::DeclContextGetAsObjCMethodDecl(decl_context))
+ {
+ if (m_allow_objc)
+ {
+ if (m_enforce_valid_object)
+ {
+ lldb::VariableListSP variable_list_sp (function_block->GetBlockVariableList (true));
+
+ const char *selfErrorString = "Stopped in an Objective-C method, but 'self' isn't available; pretending we are in a generic context";
+
+ if (!variable_list_sp)
+ {
+ err.SetErrorString(selfErrorString);
+ return;
+ }
+
+ lldb::VariableSP self_variable_sp = variable_list_sp->FindVariable(ConstString("self"));
+
+ if (!self_variable_sp ||
+ !self_variable_sp->IsInScope(frame) ||
+ !self_variable_sp->LocationIsValidForFrame (frame))
+ {
+ err.SetErrorString(selfErrorString);
+ return;
+ }
+ }
+
+ m_in_objectivec_method = true;
+ m_needs_object_ptr = true;
+
+ if (!method_decl->isInstanceMethod())
+ m_in_static_method = true;
+ }
+ }
+ else if (clang::FunctionDecl *function_decl = ClangASTContext::DeclContextGetAsFunctionDecl(decl_context))
+ {
+ // We might also have a function that said in the debug information that it captured an
+ // object pointer. The best way to deal with getting to the ivars at present is by pretending
+ // that this is a method of a class in whatever runtime the debug info says the object pointer
+ // belongs to. Do that here.
+
+ ClangASTMetadata *metadata = ClangASTContext::DeclContextGetMetaData (decl_context, function_decl);
+ if (metadata && metadata->HasObjectPtr())
+ {
+ lldb::LanguageType language = metadata->GetObjectPtrLanguage();
+ if (language == lldb::eLanguageTypeC_plus_plus)
+ {
+ if (m_enforce_valid_object)
+ {
+ lldb::VariableListSP variable_list_sp (function_block->GetBlockVariableList (true));
+
+ const char *thisErrorString = "Stopped in a context claiming to capture a C++ object pointer, but 'this' isn't available; pretending we are in a generic context";
+
+ if (!variable_list_sp)
+ {
+ err.SetErrorString(thisErrorString);
+ return;
+ }
+
+ lldb::VariableSP this_var_sp (variable_list_sp->FindVariable(ConstString("this")));
+
+ if (!this_var_sp ||
+ !this_var_sp->IsInScope(frame) ||
+ !this_var_sp->LocationIsValidForFrame (frame))
+ {
+ err.SetErrorString(thisErrorString);
+ return;
+ }
+ }
+
+ m_in_cplusplus_method = true;
+ m_needs_object_ptr = true;
+ }
+ else if (language == lldb::eLanguageTypeObjC)
+ {
+ if (m_enforce_valid_object)
+ {
+ lldb::VariableListSP variable_list_sp (function_block->GetBlockVariableList (true));
+
+ const char *selfErrorString = "Stopped in a context claiming to capture an Objective-C object pointer, but 'self' isn't available; pretending we are in a generic context";
+
+ if (!variable_list_sp)
+ {
+ err.SetErrorString(selfErrorString);
+ return;
+ }
+
+ lldb::VariableSP self_variable_sp = variable_list_sp->FindVariable(ConstString("self"));
+
+ if (!self_variable_sp ||
+ !self_variable_sp->IsInScope(frame) ||
+ !self_variable_sp->LocationIsValidForFrame (frame))
+ {
+ err.SetErrorString(selfErrorString);
+ return;
+ }
+
+ Type *self_type = self_variable_sp->GetType();
+
+ if (!self_type)
+ {
+ err.SetErrorString(selfErrorString);
+ return;
+ }
+
+ CompilerType self_clang_type = self_type->GetForwardCompilerType ();
+
+ if (!self_clang_type)
+ {
+ err.SetErrorString(selfErrorString);
+ return;
+ }
+
+ if (ClangASTContext::IsObjCClassType(self_clang_type))
+ {
+ return;
+ }
+ else if (ClangASTContext::IsObjCObjectPointerType(self_clang_type))
+ {
+ m_in_objectivec_method = true;
+ m_needs_object_ptr = true;
+ }
+ else
+ {
+ err.SetErrorString(selfErrorString);
+ return;
+ }
+ }
+ else
+ {
+ m_in_objectivec_method = true;
+ m_needs_object_ptr = true;
+ }
+ }
+ }
+ }
+}
+
+// This is a really nasty hack, meant to fix Objective-C expressions of the form
+// (int)[myArray count]. Right now, because the type information for count is
+// not available, [myArray count] returns id, which can't be directly cast to
+// int without causing a clang error.
+static void
+ApplyObjcCastHack(std::string &expr)
+{
+#define OBJC_CAST_HACK_FROM "(int)["
+#define OBJC_CAST_HACK_TO "(int)(long long)["
+
+ size_t from_offset;
+
+ while ((from_offset = expr.find(OBJC_CAST_HACK_FROM)) != expr.npos)
+ expr.replace(from_offset, sizeof(OBJC_CAST_HACK_FROM) - 1, OBJC_CAST_HACK_TO);
+
+#undef OBJC_CAST_HACK_TO
+#undef OBJC_CAST_HACK_FROM
+}
+
+bool
+ClangUserExpression::Parse (Stream &error_stream,
+ ExecutionContext &exe_ctx,
+ lldb_private::ExecutionPolicy execution_policy,
+ bool keep_result_in_memory,
+ bool generate_debug_info)
+{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+
+ Error err;
+
+ InstallContext(exe_ctx);
+
+ if (Target *target = exe_ctx.GetTargetPtr())
+ {
+ if (PersistentExpressionState *persistent_state = target->GetPersistentExpressionStateForLanguage(lldb::eLanguageTypeC))
+ {
+ m_result_delegate.RegisterPersistentState(persistent_state);
+ }
+ else
+ {
+ error_stream.PutCString ("error: couldn't start parsing (no persistent data)");
+ return false;
+ }
+ }
+ else
+ {
+ error_stream.PutCString ("error: couldn't start parsing (no target)");
+ return false;
+ }
+
+ ScanContext(exe_ctx, err);
+
+ if (!err.Success())
+ {
+ error_stream.Printf("warning: %s\n", err.AsCString());
+ }
+
+ StreamString m_transformed_stream;
+
+ ////////////////////////////////////
+ // Generate the expression
+ //
+
+ ApplyObjcCastHack(m_expr_text);
+ //ApplyUnicharHack(m_expr_text);
+
+ std::string prefix = m_expr_prefix;
+
+ if (ClangModulesDeclVendor *decl_vendor = m_target->GetClangModulesDeclVendor())
+ {
+ const ClangModulesDeclVendor::ModuleVector &hand_imported_modules = llvm::cast<ClangPersistentVariables>(m_target->GetPersistentExpressionStateForLanguage(lldb::eLanguageTypeC))->GetHandLoadedClangModules();
+ ClangModulesDeclVendor::ModuleVector modules_for_macros;
+
+ for (ClangModulesDeclVendor::ModuleID module : hand_imported_modules)
+ {
+ modules_for_macros.push_back(module);
+ }
+
+ if (m_target->GetEnableAutoImportClangModules())
+ {
+ if (StackFrame *frame = exe_ctx.GetFramePtr())
+ {
+ if (Block *block = frame->GetFrameBlock())
+ {
+ SymbolContext sc;
+
+ block->CalculateSymbolContext(&sc);
+
+ if (sc.comp_unit)
+ {
+ StreamString error_stream;
+
+ decl_vendor->AddModulesForCompileUnit(*sc.comp_unit, modules_for_macros, error_stream);
+ }
+ }
+ }
+ }
+ }
+
+ std::unique_ptr<ExpressionSourceCode> source_code (ExpressionSourceCode::CreateWrapped(prefix.c_str(), m_expr_text.c_str()));
+
+ lldb::LanguageType lang_type;
+
+ if (m_in_cplusplus_method)
+ lang_type = lldb::eLanguageTypeC_plus_plus;
+ else if (m_in_objectivec_method)
+ lang_type = lldb::eLanguageTypeObjC;
+ else
+ lang_type = lldb::eLanguageTypeC;
+
+ if (!source_code->GetText(m_transformed_text, lang_type, m_const_object, m_in_static_method, exe_ctx))
+ {
+ error_stream.PutCString ("error: couldn't construct expression body");
+ return false;
+ }
+
+ if (log)
+ log->Printf("Parsing the following code:\n%s", m_transformed_text.c_str());
+
+ ////////////////////////////////////
+ // Set up the target and compiler
+ //
+
+ Target *target = exe_ctx.GetTargetPtr();
+
+ if (!target)
+ {
+ error_stream.PutCString ("error: invalid target\n");
+ return false;
+ }
+
+ //////////////////////////
+ // Parse the expression
+ //
+
+ m_materializer_ap.reset(new Materializer());
+
+ ResetDeclMap(exe_ctx, m_result_delegate, keep_result_in_memory);
+
+ class OnExit
+ {
+ public:
+ typedef std::function <void (void)> Callback;
+
+ OnExit (Callback const &callback) :
+ m_callback(callback)
+ {
+ }
+
+ ~OnExit ()
+ {
+ m_callback();
+ }
+ private:
+ Callback m_callback;
+ };
+
+ OnExit on_exit([this]() { ResetDeclMap(); });
+
+ if (!DeclMap()->WillParse(exe_ctx, m_materializer_ap.get()))
+ {
+ error_stream.PutCString ("error: current process state is unsuitable for expression parsing\n");
+
+ ResetDeclMap(); // We are being careful here in the case of breakpoint conditions.
+
+ return false;
+ }
+
+ Process *process = exe_ctx.GetProcessPtr();
+ ExecutionContextScope *exe_scope = process;
+
+ if (!exe_scope)
+ exe_scope = exe_ctx.GetTargetPtr();
+
+ ClangExpressionParser parser(exe_scope, *this, generate_debug_info);
+
+ unsigned num_errors = parser.Parse (error_stream);
+
+ if (num_errors)
+ {
+ error_stream.Printf ("error: %d errors parsing expression\n", num_errors);
+
+ ResetDeclMap(); // We are being careful here in the case of breakpoint conditions.
+
+ return false;
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////
+ // Prepare the output of the parser for execution, evaluating it statically if possible
+ //
+
+ Error jit_error = parser.PrepareForExecution (m_jit_start_addr,
+ m_jit_end_addr,
+ m_execution_unit_sp,
+ exe_ctx,
+ m_can_interpret,
+ execution_policy);
+
+ if (generate_debug_info)
+ {
+ lldb::ModuleSP jit_module_sp ( m_execution_unit_sp->GetJITModule());
+
+ if (jit_module_sp)
+ {
+ ConstString const_func_name(FunctionName());
+ FileSpec jit_file;
+ jit_file.GetFilename() = const_func_name;
+ jit_module_sp->SetFileSpecAndObjectName (jit_file, ConstString());
+ m_jit_module_wp = jit_module_sp;
+ target->GetImages().Append(jit_module_sp);
+ }
+// lldb_private::ObjectFile *jit_obj_file = jit_module_sp->GetObjectFile();
+// StreamFile strm (stdout, false);
+// if (jit_obj_file)
+// {
+// jit_obj_file->GetSectionList();
+// jit_obj_file->GetSymtab();
+// jit_obj_file->Dump(&strm);
+// }
+// lldb_private::SymbolVendor *jit_sym_vendor = jit_module_sp->GetSymbolVendor();
+// if (jit_sym_vendor)
+// {
+// lldb_private::SymbolContextList sc_list;
+// jit_sym_vendor->FindFunctions(const_func_name, NULL, lldb::eFunctionNameTypeFull, true, false, sc_list);
+// sc_list.Dump(&strm, target);
+// jit_sym_vendor->Dump(&strm);
+// }
+ }
+
+ ResetDeclMap(); // Make this go away since we don't need any of its state after parsing. This also gets rid of any ClangASTImporter::Minions.
+
+ if (jit_error.Success())
+ {
+ if (process && m_jit_start_addr != LLDB_INVALID_ADDRESS)
+ m_jit_process_wp = lldb::ProcessWP(process->shared_from_this());
+ return true;
+ }
+ else
+ {
+ const char *error_cstr = jit_error.AsCString();
+ if (error_cstr && error_cstr[0])
+ error_stream.Printf ("error: %s\n", error_cstr);
+ else
+ error_stream.Printf ("error: expression can't be interpreted or run\n");
+ return false;
+ }
+}
+
+bool
+ClangUserExpression::AddArguments (ExecutionContext &exe_ctx,
+ std::vector<lldb::addr_t> &args,
+ lldb::addr_t struct_address,
+ Stream &error_stream)
+{
+ lldb::addr_t object_ptr = LLDB_INVALID_ADDRESS;
+ lldb::addr_t cmd_ptr = LLDB_INVALID_ADDRESS;
+
+ if (m_needs_object_ptr)
+ {
+ lldb::StackFrameSP frame_sp = exe_ctx.GetFrameSP();
+ if (!frame_sp)
+ return true;
+
+ ConstString object_name;
+
+ if (m_in_cplusplus_method)
+ {
+ object_name.SetCString("this");
+ }
+ else if (m_in_objectivec_method)
+ {
+ object_name.SetCString("self");
+ }
+ else
+ {
+ error_stream.Printf("Need object pointer but don't know the language\n");
+ return false;
+ }
+
+ Error object_ptr_error;
+
+ object_ptr = GetObjectPointer(frame_sp, object_name, object_ptr_error);
+
+ if (!object_ptr_error.Success())
+ {
+ error_stream.Printf("warning: couldn't get required object pointer (substituting NULL): %s\n", object_ptr_error.AsCString());
+ object_ptr = 0;
+ }
+
+ if (m_in_objectivec_method)
+ {
+ ConstString cmd_name("_cmd");
+
+ cmd_ptr = GetObjectPointer(frame_sp, cmd_name, object_ptr_error);
+
+ if (!object_ptr_error.Success())
+ {
+ error_stream.Printf("warning: couldn't get cmd pointer (substituting NULL): %s\n", object_ptr_error.AsCString());
+ cmd_ptr = 0;
+ }
+ }
+ if (object_ptr)
+ args.push_back(object_ptr);
+
+ if (m_in_objectivec_method)
+ args.push_back(cmd_ptr);
+
+ args.push_back(struct_address);
+ }
+ else
+ {
+ args.push_back(struct_address);
+ }
+ return true;
+}
+
+lldb::ExpressionVariableSP
+ClangUserExpression::GetResultAfterDematerialization(ExecutionContextScope *exe_scope)
+{
+ return m_result_delegate.GetVariable();
+}
+
+void
+ClangUserExpression::ClangUserExpressionHelper::ResetDeclMap(ExecutionContext &exe_ctx, Materializer::PersistentVariableDelegate &delegate, bool keep_result_in_memory)
+{
+ m_expr_decl_map_up.reset(new ClangExpressionDeclMap(keep_result_in_memory, &delegate, exe_ctx));
+}
+
+clang::ASTConsumer *
+ClangUserExpression::ClangUserExpressionHelper::ASTTransformer (clang::ASTConsumer *passthrough)
+{
+ m_result_synthesizer_up.reset(new ASTResultSynthesizer(passthrough,
+ m_target));
+
+ return m_result_synthesizer_up.get();
+}
+
+ClangUserExpression::ResultDelegate::ResultDelegate()
+{
+}
+
+ConstString
+ClangUserExpression::ResultDelegate::GetName()
+{
+ return m_persistent_state->GetNextPersistentVariableName();
+}
+
+void
+ClangUserExpression::ResultDelegate::DidDematerialize(lldb::ExpressionVariableSP &variable)
+{
+ m_variable = variable;
+}
+
+void
+ClangUserExpression::ResultDelegate::RegisterPersistentState(PersistentExpressionState *persistent_state)
+{
+ m_persistent_state = persistent_state;
+}
+
+lldb::ExpressionVariableSP &
+ClangUserExpression::ResultDelegate::GetVariable()
+{
+ return m_variable;
+}
+
diff --git a/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h b/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
new file mode 100644
index 000000000000..f2bfe31dce09
--- /dev/null
+++ b/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
@@ -0,0 +1,218 @@
+//===-- ClangUserExpression.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_ClangUserExpression_h_
+#define liblldb_ClangUserExpression_h_
+
+// C Includes
+// C++ Includes
+#include <vector>
+
+// Other libraries and framework includes
+// Project includes
+#include "ASTStructExtractor.h"
+#include "ASTResultSynthesizer.h"
+#include "ClangExpressionDeclMap.h"
+#include "ClangExpressionHelper.h"
+#include "ClangExpressionVariable.h"
+#include "IRForTarget.h"
+
+#include "lldb/lldb-forward.h"
+#include "lldb/lldb-private.h"
+#include "lldb/Core/Address.h"
+#include "lldb/Core/ClangForward.h"
+#include "lldb/Expression/LLVMUserExpression.h"
+#include "lldb/Expression/Materializer.h"
+#include "lldb/Target/ExecutionContext.h"
+
+namespace lldb_private
+{
+
+//----------------------------------------------------------------------
+/// @class ClangUserExpression ClangUserExpression.h "lldb/Expression/ClangUserExpression.h"
+/// @brief Encapsulates a single expression for use with Clang
+///
+/// LLDB uses expressions for various purposes, notably to call functions
+/// 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:
+ enum { kDefaultTimeout = 500000u };
+
+ class ClangUserExpressionHelper : public ClangExpressionHelper
+ {
+ public:
+ ClangUserExpressionHelper (Target &target) :
+ m_target(target)
+ {
+ }
+
+ ~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();
+ }
+
+ void
+ ResetDeclMap()
+ {
+ m_expr_decl_map_up.reset();
+ }
+
+ void
+ ResetDeclMap (ExecutionContext & exe_ctx, Materializer::PersistentVariableDelegate &result_delegate, 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
+ /// The ASTConsumer that the returned transformer should send
+ /// the ASTs to after transformation.
+ //------------------------------------------------------------------
+ clang::ASTConsumer *
+ ASTTransformer(clang::ASTConsumer *passthrough) override;
+
+ private:
+ Target &m_target;
+ std::unique_ptr<ClangExpressionDeclMap> m_expr_decl_map_up;
+ std::unique_ptr<ASTStructExtractor> m_struct_extractor_up; ///< The class that generates the argument struct layout.
+ std::unique_ptr<ASTResultSynthesizer> m_result_synthesizer_up;
+ };
+
+ //------------------------------------------------------------------
+ /// Constructor
+ ///
+ /// @param[in] expr
+ /// The expression to parse.
+ ///
+ /// @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
+ /// If not eLanguageTypeUnknown, a language to use when parsing
+ /// the expression. Currently restricted to those languages
+ /// supported by Clang.
+ ///
+ /// @param[in] desired_type
+ /// If not eResultTypeAny, the type to use for the expression
+ /// result.
+ //------------------------------------------------------------------
+ ClangUserExpression (ExecutionContextScope &exe_scope,
+ const char *expr,
+ const char *expr_prefix,
+ lldb::LanguageType language,
+ ResultType desired_type,
+ const EvaluateExpressionOptions &options);
+
+ ~ClangUserExpression() override;
+
+ //------------------------------------------------------------------
+ /// Parse the expression
+ ///
+ /// @param[in] error_stream
+ /// A stream to print parse errors and warnings to.
+ ///
+ /// @param[in] exe_ctx
+ /// The execution context to use when looking up entities that
+ /// are needed for parsing (locations of functions, types of
+ /// variables, persistent variables, etc.)
+ ///
+ /// @param[in] execution_policy
+ /// Determines whether interpretation is possible or mandatory.
+ ///
+ /// @param[in] keep_result_in_memory
+ /// True if the resulting persistent variable should reside in
+ /// target memory, if applicable.
+ ///
+ /// @return
+ /// True on success (no errors); false otherwise.
+ //------------------------------------------------------------------
+ bool
+ Parse (Stream &error_stream,
+ ExecutionContext &exe_ctx,
+ lldb_private::ExecutionPolicy execution_policy,
+ bool keep_result_in_memory,
+ bool generate_debug_info) override;
+
+ ExpressionTypeSystemHelper *
+ GetTypeSystemHelper () override
+ {
+ return &m_type_system_helper;
+ }
+
+ ClangExpressionDeclMap *
+ DeclMap ()
+ {
+ return m_type_system_helper.DeclMap();
+ }
+
+ void
+ ResetDeclMap ()
+ {
+ m_type_system_helper.ResetDeclMap();
+ }
+
+ void
+ ResetDeclMap (ExecutionContext & exe_ctx, Materializer::PersistentVariableDelegate &result_delegate, bool keep_result_in_memory)
+ {
+ m_type_system_helper.ResetDeclMap(exe_ctx, result_delegate, keep_result_in_memory);
+ }
+
+ lldb::ExpressionVariableSP
+ GetResultAfterDematerialization(ExecutionContextScope *exe_scope) override;
+
+private:
+ //------------------------------------------------------------------
+ /// Populate m_in_cplusplus_method and m_in_objectivec_method based on the environment.
+ //------------------------------------------------------------------
+
+ void
+ ScanContext (ExecutionContext &exe_ctx,
+ lldb_private::Error &err) override;
+
+ bool
+ AddArguments (ExecutionContext &exe_ctx,
+ std::vector<lldb::addr_t> &args,
+ lldb::addr_t struct_address,
+ Stream &error_stream) override;
+
+ ClangUserExpressionHelper m_type_system_helper;
+
+ class ResultDelegate : public Materializer::PersistentVariableDelegate
+ {
+ public:
+ ResultDelegate();
+ ConstString GetName() override;
+ void DidDematerialize(lldb::ExpressionVariableSP &variable) override;
+
+ void RegisterPersistentState(PersistentExpressionState *persistent_state);
+ lldb::ExpressionVariableSP &GetVariable();
+
+ private:
+ PersistentExpressionState *m_persistent_state;
+ lldb::ExpressionVariableSP m_variable;
+ };
+
+ ResultDelegate m_result_delegate;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_ClangUserExpression_h_
diff --git a/source/Expression/ClangUtilityFunction.cpp b/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
index de5b0c1b03f4..fe044c17ac78 100644
--- a/source/Expression/ClangUtilityFunction.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
@@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
+#include "ClangExpressionDeclMap.h"
+#include "ClangExpressionParser.h"
+#include "ClangUtilityFunction.h"
+
// C Includes
#include <stdio.h>
#if HAVE_SYS_TYPES_H
@@ -20,9 +24,6 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Expression/ClangExpressionDeclMap.h"
-#include "lldb/Expression/ClangExpressionParser.h"
-#include "lldb/Expression/ClangUtilityFunction.h"
#include "lldb/Expression/ExpressionSourceCode.h"
#include "lldb/Expression/IRExecutionUnit.h"
#include "lldb/Host/Host.h"
@@ -40,29 +41,15 @@ using namespace lldb_private;
/// @param[in] name
/// The name of the function, as used in the text.
//------------------------------------------------------------------
-ClangUtilityFunction::ClangUtilityFunction (const char *text,
+ClangUtilityFunction::ClangUtilityFunction (ExecutionContextScope &exe_scope,
+ const char *text,
const char *name) :
- ClangExpression (),
- m_expr_decl_map (),
- m_execution_unit_sp (),
- m_jit_module_wp (),
- m_function_text (ExpressionSourceCode::g_expression_prefix),
- m_function_name (name)
+ UtilityFunction (exe_scope, text, name)
{
- if (text && text[0])
- m_function_text.append (text);
}
ClangUtilityFunction::~ClangUtilityFunction ()
{
- lldb::ProcessSP process_sp (m_jit_process_wp.lock());
- if (process_sp)
- {
- lldb::ModuleSP jit_module_sp (m_jit_module_wp.lock());
- if (jit_module_sp)
- process_sp->GetTarget().GetImages().Remove(jit_module_sp);
- }
-
}
//------------------------------------------------------------------
@@ -113,9 +100,9 @@ ClangUtilityFunction::Install (Stream &error_stream,
bool keep_result_in_memory = false;
- m_expr_decl_map.reset(new ClangExpressionDeclMap(keep_result_in_memory, exe_ctx));
+ ResetDeclMap(exe_ctx, keep_result_in_memory);
- if (!m_expr_decl_map->WillParse(exe_ctx, NULL))
+ if (!DeclMap()->WillParse(exe_ctx, NULL))
{
error_stream.PutCString ("error: current process state is unsuitable for expression parsing\n");
return false;
@@ -130,7 +117,7 @@ ClangUtilityFunction::Install (Stream &error_stream,
{
error_stream.Printf ("error: %d errors parsing expression\n", num_errors);
- m_expr_decl_map.reset();
+ ResetDeclMap();
return false;
}
@@ -176,9 +163,9 @@ ClangUtilityFunction::Install (Stream &error_stream,
m_function_text.c_str());
#endif
- m_expr_decl_map->DidParse();
+ DeclMap()->DidParse();
- m_expr_decl_map.reset();
+ ResetDeclMap();
if (jit_error.Success())
{
@@ -195,4 +182,8 @@ ClangUtilityFunction::Install (Stream &error_stream,
}
}
-
+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));
+}
diff --git a/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h b/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
new file mode 100644
index 000000000000..74839717946b
--- /dev/null
+++ b/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
@@ -0,0 +1,137 @@
+//===-- ClangUtilityFunction.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_ClangUtilityFunction_h_
+#define liblldb_ClangUtilityFunction_h_
+
+// C Includes
+// C++ Includes
+#include <string>
+#include <map>
+#include <vector>
+
+// Other libraries and framework includes
+// Project includes
+#include "ClangExpressionHelper.h"
+
+#include "lldb/lldb-forward.h"
+#include "lldb/lldb-private.h"
+#include "lldb/Core/ClangForward.h"
+#include "lldb/Expression/UtilityFunction.h"
+
+namespace lldb_private
+{
+
+//----------------------------------------------------------------------
+/// @class ClangUtilityFunction ClangUtilityFunction.h "lldb/Expression/ClangUtilityFunction.h"
+/// @brief Encapsulates a single expression for use with Clang
+///
+/// LLDB uses expressions for various purposes, notably to call functions
+/// and as a backend for the expr command. ClangUtilityFunction encapsulates
+/// a self-contained function meant to be used from other code. Utility
+/// 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:
+ 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();
+ }
+
+ void
+ ResetDeclMap()
+ {
+ m_expr_decl_map_up.reset();
+ }
+
+ 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
+ /// The ASTConsumer that the returned transformer should send
+ /// the ASTs to after transformation.
+ //------------------------------------------------------------------
+ clang::ASTConsumer *
+ ASTTransformer(clang::ASTConsumer *passthrough) override
+ {
+ return nullptr;
+ }
+ private:
+ std::unique_ptr<ClangExpressionDeclMap> m_expr_decl_map_up;
+ };
+ //------------------------------------------------------------------
+ /// Constructor
+ ///
+ /// @param[in] text
+ /// The text of the function. Must be a full translation unit.
+ ///
+ /// @param[in] name
+ /// The name of the function, as used in the text.
+ //------------------------------------------------------------------
+ ClangUtilityFunction (ExecutionContextScope &exe_scope,
+ const char *text,
+ const char *name);
+
+ ~ClangUtilityFunction() override;
+
+ ExpressionTypeSystemHelper *
+ GetTypeSystemHelper () override
+ {
+ return &m_type_system_helper;
+ }
+
+ ClangExpressionDeclMap *
+ DeclMap()
+ {
+ return m_type_system_helper.DeclMap();
+ }
+
+ void
+ ResetDeclMap ()
+ {
+ m_type_system_helper.ResetDeclMap();
+ }
+
+ void
+ ResetDeclMap (ExecutionContext & exe_ctx, bool keep_result_in_memory)
+ {
+ m_type_system_helper.ResetDeclMap(exe_ctx, keep_result_in_memory);
+ }
+
+ bool
+ Install (Stream &error_stream, ExecutionContext &exe_ctx) override;
+
+private:
+ ClangUtilityFunctionHelper m_type_system_helper; ///< The map to use when parsing and materializing the expression.
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_ClangUtilityFunction_h_
diff --git a/source/Expression/IRForTarget.cpp b/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index cf2a93b3ea7f..37b7bd1d2c84 100644
--- a/source/Expression/IRForTarget.cpp
+++ b/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -7,7 +7,9 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Expression/IRForTarget.h"
+#include "IRForTarget.h"
+
+#include "ClangExpressionDeclMap.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/IR/Constants.h"
@@ -29,12 +31,11 @@
#include "lldb/Core/Log.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Core/StreamString.h"
-#include "lldb/Expression/ClangExpressionDeclMap.h"
#include "lldb/Expression/IRExecutionUnit.h"
#include "lldb/Expression/IRInterpreter.h"
#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/CPPLanguageRuntime.h"
#include <map>
@@ -337,7 +338,7 @@ IRForTarget::ResolveFunctionPointers(llvm::Module &llvm_module)
fi != llvm_module.end();
++fi)
{
- Function *fun = fi;
+ Function *fun = &*fi;
bool is_decl = fun->isDeclaration();
@@ -575,14 +576,14 @@ IRForTarget::CreateResultVariable (llvm::Function &llvm_function)
clang::QualType element_qual_type = pointer_pointertype->getPointeeType();
m_result_type = lldb_private::TypeFromParser(element_qual_type.getAsOpaquePtr(),
- &result_decl->getASTContext());
+ lldb_private::ClangASTContext::GetASTContext(&result_decl->getASTContext()));
}
else if (pointer_objcobjpointertype)
{
clang::QualType element_qual_type = clang::QualType(pointer_objcobjpointertype->getObjectType(), 0);
m_result_type = lldb_private::TypeFromParser(element_qual_type.getAsOpaquePtr(),
- &result_decl->getASTContext());
+ lldb_private::ClangASTContext::GetASTContext(&result_decl->getASTContext()));
}
else
{
@@ -598,7 +599,7 @@ IRForTarget::CreateResultVariable (llvm::Function &llvm_function)
else
{
m_result_type = lldb_private::TypeFromParser(result_var->getType().getAsOpaquePtr(),
- &result_decl->getASTContext());
+ lldb_private::ClangASTContext::GetASTContext(&result_decl->getASTContext()));
}
@@ -1241,7 +1242,7 @@ IRForTarget::RewritePersistentAlloc (llvm::Instruction *persistent_alloc)
clang::VarDecl *decl = reinterpret_cast<clang::VarDecl *>(ptr);
lldb_private::TypeFromParser result_decl_type (decl->getType().getAsOpaquePtr(),
- &decl->getASTContext());
+ lldb_private::ClangASTContext::GetASTContext(&decl->getASTContext()));
StringRef decl_name (decl->getName());
lldb_private::ConstString persistent_variable_name (decl_name.data(), decl_name.size());
@@ -1509,7 +1510,7 @@ IRForTarget::MaybeHandleVariable (Value *llvm_value_ptr)
if (value_decl == NULL)
return false;
- lldb_private::ClangASTType clang_type(&value_decl->getASTContext(), value_decl->getType());
+ lldb_private::CompilerType compiler_type(&value_decl->getASTContext(), value_decl->getType());
const Type *value_type = NULL;
@@ -1524,7 +1525,7 @@ IRForTarget::MaybeHandleVariable (Value *llvm_value_ptr)
// to the type of $__lldb_expr_result, not the type itself.
//
// We also do this for any user-declared persistent variables.
- clang_type = clang_type.GetPointerType();
+ compiler_type = compiler_type.GetPointerType();
value_type = PointerType::get(global_variable->getType(), 0);
}
else
@@ -1532,14 +1533,14 @@ IRForTarget::MaybeHandleVariable (Value *llvm_value_ptr)
value_type = global_variable->getType();
}
- const uint64_t value_size = clang_type.GetByteSize(nullptr);
- lldb::offset_t value_alignment = (clang_type.GetTypeBitAlign() + 7ull) / 8ull;
+ const uint64_t value_size = compiler_type.GetByteSize(nullptr);
+ lldb::offset_t value_alignment = (compiler_type.GetTypeBitAlign() + 7ull) / 8ull;
if (log)
{
log->Printf("Type of \"%s\" is [clang \"%s\", llvm \"%s\"] [size %" PRIu64 ", align %" PRIu64 "]",
name.c_str(),
- clang_type.GetQualType().getAsString().c_str(),
+ lldb_private::ClangASTContext::GetQualType(compiler_type).getAsString().c_str(),
PrintType(value_type).c_str(),
value_size,
value_alignment);
@@ -1954,7 +1955,7 @@ IRForTarget::ReplaceStaticLiterals (llvm::BasicBlock &basic_block)
if (operand_constant_fp/* && operand_constant_fp->getType()->isX86_FP80Ty()*/)
{
static_constants.push_back(operand_val);
- static_users.push_back(ii);
+ static_users.push_back(&*ii);
}
}
}
@@ -1999,7 +2000,7 @@ IRForTarget::ReplaceStaticLiterals (llvm::BasicBlock &basic_block)
lldb_private::DataBufferHeap data(operand_data_size, 0);
- if (lldb::endian::InlHostByteOrder() != m_data_allocator.GetStream().GetByteOrder())
+ if (lldb_private::endian::InlHostByteOrder() != m_data_allocator.GetStream().GetByteOrder())
{
uint8_t *data_bytes = data.GetBytes();
@@ -2279,7 +2280,7 @@ IRForTarget::ReplaceVariables (Function &llvm_function)
return false;
}
- Argument *argument = iter;
+ Argument *argument = &*iter;
if (argument->getName().equals("this"))
{
@@ -2293,7 +2294,7 @@ IRForTarget::ReplaceVariables (Function &llvm_function)
return false;
}
- argument = iter;
+ argument = &*iter;
}
else if (argument->getName().equals("self"))
{
@@ -2325,7 +2326,7 @@ IRForTarget::ReplaceVariables (Function &llvm_function)
return false;
}
- argument = iter;
+ argument = &*iter;
}
if (!argument->getName().equals("$__lldb_arg"))
@@ -2623,7 +2624,7 @@ IRForTarget::runOnModule (Module &llvm_module)
fi != fe;
++fi)
{
- llvm::Function *function = fi;
+ llvm::Function *function = &*fi;
if (function->begin() == function->end())
continue;
@@ -2698,7 +2699,7 @@ IRForTarget::runOnModule (Module &llvm_module)
fi != fe;
++fi)
{
- llvm::Function *function = fi;
+ llvm::Function *function = &*fi;
for (llvm::Function::iterator bbi = function->begin(), bbe = function->end();
bbi != bbe;
@@ -2720,7 +2721,7 @@ IRForTarget::runOnModule (Module &llvm_module)
fi != fe;
++fi)
{
- llvm::Function *function = fi;
+ llvm::Function *function = &*fi;
for (llvm::Function::iterator bbi = function->begin(), bbe = function->end();
bbi != bbe;
diff --git a/include/lldb/Expression/IRForTarget.h b/source/Plugins/ExpressionParser/Clang/IRForTarget.h
index b81fab7a8a83..fb4abcc103de 100644
--- a/include/lldb/Expression/IRForTarget.h
+++ b/source/Plugins/ExpressionParser/Clang/IRForTarget.h
@@ -107,7 +107,7 @@ public:
//------------------------------------------------------------------
/// Destructor
//------------------------------------------------------------------
- virtual ~IRForTarget();
+ ~IRForTarget() override;
//------------------------------------------------------------------
/// Run this IR transformer on a single module
@@ -126,8 +126,8 @@ public:
/// @return
/// True on success; false otherwise
//------------------------------------------------------------------
- virtual bool
- runOnModule (llvm::Module &llvm_module);
+ bool
+ runOnModule(llvm::Module &llvm_module) override;
//------------------------------------------------------------------
/// Interface stub
@@ -135,9 +135,9 @@ public:
/// Implementation of the llvm::ModulePass::assignPassManager()
/// function.
//------------------------------------------------------------------
- virtual void
- assignPassManager (llvm::PMStack &pass_mgr_stack,
- llvm::PassManagerType pass_mgr_type = llvm::PMT_ModulePassManager);
+ void
+ assignPassManager(llvm::PMStack &pass_mgr_stack,
+ llvm::PassManagerType pass_mgr_type = llvm::PMT_ModulePassManager) override;
//------------------------------------------------------------------
/// Returns PMT_ModulePassManager
@@ -145,8 +145,8 @@ public:
/// Implementation of the llvm::ModulePass::getPotentialPassManagerType()
/// function.
//------------------------------------------------------------------
- virtual llvm::PassManagerType
- getPotentialPassManagerType() const;
+ llvm::PassManagerType
+ getPotentialPassManagerType() const override;
private:
//------------------------------------------------------------------
@@ -742,4 +742,4 @@ private:
};
-#endif
+#endif // liblldb_IRForTarget_h_
diff --git a/source/Plugins/ExpressionParser/Go/GoAST.h b/source/Plugins/ExpressionParser/Go/GoAST.h
new file mode 100644
index 000000000000..6d51240eab5c
--- /dev/null
+++ b/source/Plugins/ExpressionParser/Go/GoAST.h
@@ -0,0 +1,3225 @@
+//===-- GoAST.h -------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// DO NOT EDIT.
+// Generated by gen_go_ast.py
+
+#ifndef liblldb_GoAST_h
+#define liblldb_GoAST_h
+
+#include "lldb/lldb-forward.h"
+#include "lldb/lldb-private.h"
+#include "llvm/Support/Casting.h"
+#include "Plugins/ExpressionParser/Go/GoLexer.h"
+
+namespace lldb_private
+{
+
+class GoASTNode
+{
+ public:
+ typedef GoLexer::TokenType TokenType;
+ typedef GoLexer::Token Token;
+ enum ChanDir
+ {
+ eChanBidir,
+ eChanSend,
+ eChanRecv,
+ };
+ enum NodeKind
+ {
+ eBadDecl,
+ eFuncDecl,
+ eGenDecl,
+ eArrayType,
+ eBadExpr,
+ eBasicLit,
+ eBinaryExpr,
+ eIdent,
+ eCallExpr,
+ eChanType,
+ eCompositeLit,
+ eEllipsis,
+ eFuncType,
+ eFuncLit,
+ eIndexExpr,
+ eInterfaceType,
+ eKeyValueExpr,
+ eMapType,
+ eParenExpr,
+ eSelectorExpr,
+ eSliceExpr,
+ eStarExpr,
+ eStructType,
+ eTypeAssertExpr,
+ eUnaryExpr,
+ eImportSpec,
+ eTypeSpec,
+ eValueSpec,
+ eAssignStmt,
+ eBadStmt,
+ eBlockStmt,
+ eBranchStmt,
+ eCaseClause,
+ eCommClause,
+ eDeclStmt,
+ eDeferStmt,
+ eEmptyStmt,
+ eExprStmt,
+ eForStmt,
+ eGoStmt,
+ eIfStmt,
+ eIncDecStmt,
+ eLabeledStmt,
+ eRangeStmt,
+ eReturnStmt,
+ eSelectStmt,
+ eSendStmt,
+ eSwitchStmt,
+ eTypeSwitchStmt,
+ eField,
+ eFieldList,
+ };
+
+ virtual ~GoASTNode() = default;
+
+ NodeKind
+ GetKind() const
+ {
+ return m_kind;
+ }
+
+ virtual const char *GetKindName() const = 0;
+
+ template <typename V> void WalkChildren(V &v);
+
+ protected:
+ explicit GoASTNode(NodeKind kind) : m_kind(kind) { }
+
+ private:
+ const NodeKind m_kind;
+
+ GoASTNode(const GoASTNode &) = delete;
+ const GoASTNode &operator=(const GoASTNode &) = delete;
+};
+
+
+class GoASTDecl : public GoASTNode
+{
+ public:
+ template <typename R, typename V> R Visit(V *v) const;
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() >= eBadDecl && n->GetKind() <= eGenDecl;
+ }
+
+ protected:
+ explicit GoASTDecl(NodeKind kind) : GoASTNode(kind) { }
+ private:
+
+ GoASTDecl(const GoASTDecl &) = delete;
+ const GoASTDecl &operator=(const GoASTDecl &) = delete;
+};
+
+class GoASTExpr : public GoASTNode
+{
+ public:
+ template <typename R, typename V> R Visit(V *v) const;
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() >= eArrayType && n->GetKind() <= eUnaryExpr;
+ }
+
+ protected:
+ explicit GoASTExpr(NodeKind kind) : GoASTNode(kind) { }
+ private:
+
+ GoASTExpr(const GoASTExpr &) = delete;
+ const GoASTExpr &operator=(const GoASTExpr &) = delete;
+};
+
+class GoASTSpec : public GoASTNode
+{
+ public:
+ template <typename R, typename V> R Visit(V *v) const;
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() >= eImportSpec && n->GetKind() <= eValueSpec;
+ }
+
+ protected:
+ explicit GoASTSpec(NodeKind kind) : GoASTNode(kind) { }
+ private:
+
+ GoASTSpec(const GoASTSpec &) = delete;
+ const GoASTSpec &operator=(const GoASTSpec &) = delete;
+};
+
+class GoASTStmt : public GoASTNode
+{
+ public:
+ template <typename R, typename V> R Visit(V *v) const;
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() >= eAssignStmt && n->GetKind() <= eTypeSwitchStmt;
+ }
+
+ protected:
+ explicit GoASTStmt(NodeKind kind) : GoASTNode(kind) { }
+ private:
+
+ GoASTStmt(const GoASTStmt &) = delete;
+ const GoASTStmt &operator=(const GoASTStmt &) = delete;
+};
+
+
+class GoASTArrayType : public GoASTExpr
+{
+ public:
+ GoASTArrayType(GoASTExpr *len, GoASTExpr *elt) : GoASTExpr(eArrayType), m_len_up(len), m_elt_up(elt) {}
+ ~GoASTArrayType() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "ArrayType";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eArrayType;
+ }
+
+ const GoASTExpr *
+ GetLen() const
+ {
+ return m_len_up.get();
+ }
+ void
+ SetLen(GoASTExpr *len)
+ {
+ m_len_up.reset(len);
+ }
+
+ const GoASTExpr *
+ GetElt() const
+ {
+ return m_elt_up.get();
+ }
+ void
+ SetElt(GoASTExpr *elt)
+ {
+ m_elt_up.reset(elt);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTExpr> m_len_up;
+ std::unique_ptr<GoASTExpr> m_elt_up;
+
+ GoASTArrayType(const GoASTArrayType &) = delete;
+ const GoASTArrayType &operator=(const GoASTArrayType &) = delete;
+};
+
+class GoASTAssignStmt : public GoASTStmt
+{
+ public:
+ explicit GoASTAssignStmt(bool define) : GoASTStmt(eAssignStmt), m_define(define) {}
+ ~GoASTAssignStmt() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "AssignStmt";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eAssignStmt;
+ }
+
+ size_t
+ NumLhs() const
+ {
+ return m_lhs.size();
+ }
+ const GoASTExpr *
+ GetLhs(int i) const
+ {
+ return m_lhs[i].get();
+ }
+ void
+ AddLhs(GoASTExpr *lhs)
+ {
+ m_lhs.push_back(std::unique_ptr<GoASTExpr>(lhs));
+ }
+
+ size_t
+ NumRhs() const
+ {
+ return m_rhs.size();
+ }
+ const GoASTExpr *
+ GetRhs(int i) const
+ {
+ return m_rhs[i].get();
+ }
+ void
+ AddRhs(GoASTExpr *rhs)
+ {
+ m_rhs.push_back(std::unique_ptr<GoASTExpr>(rhs));
+ }
+
+ bool
+ GetDefine() const
+ {
+ return m_define;
+ }
+ void
+ SetDefine(bool define)
+ {
+ m_define = define;
+ }
+
+ private:
+ friend class GoASTNode;
+ std::vector<std::unique_ptr<GoASTExpr> > m_lhs;
+ std::vector<std::unique_ptr<GoASTExpr> > m_rhs;
+ bool m_define;
+
+ GoASTAssignStmt(const GoASTAssignStmt &) = delete;
+ const GoASTAssignStmt &operator=(const GoASTAssignStmt &) = delete;
+};
+
+class GoASTBadDecl : public GoASTDecl
+{
+ public:
+ GoASTBadDecl() : GoASTDecl(eBadDecl) {}
+ ~GoASTBadDecl() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "BadDecl";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eBadDecl;
+ }
+
+ GoASTBadDecl(const GoASTBadDecl &) = delete;
+ const GoASTBadDecl &operator=(const GoASTBadDecl &) = delete;
+};
+
+class GoASTBadExpr : public GoASTExpr
+{
+ public:
+ GoASTBadExpr() : GoASTExpr(eBadExpr) {}
+ ~GoASTBadExpr() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "BadExpr";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eBadExpr;
+ }
+
+ GoASTBadExpr(const GoASTBadExpr &) = delete;
+ const GoASTBadExpr &operator=(const GoASTBadExpr &) = delete;
+};
+
+class GoASTBadStmt : public GoASTStmt
+{
+ public:
+ GoASTBadStmt() : GoASTStmt(eBadStmt) {}
+ ~GoASTBadStmt() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "BadStmt";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eBadStmt;
+ }
+
+ GoASTBadStmt(const GoASTBadStmt &) = delete;
+ const GoASTBadStmt &operator=(const GoASTBadStmt &) = delete;
+};
+
+class GoASTBasicLit : public GoASTExpr
+{
+ public:
+ explicit GoASTBasicLit(Token value) : GoASTExpr(eBasicLit), m_value(value) {}
+ ~GoASTBasicLit() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "BasicLit";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eBasicLit;
+ }
+
+ Token
+ GetValue() const
+ {
+ return m_value;
+ }
+ void
+ SetValue(Token value)
+ {
+ m_value = value;
+ }
+
+ private:
+ friend class GoASTNode;
+ Token m_value;
+
+ GoASTBasicLit(const GoASTBasicLit &) = delete;
+ const GoASTBasicLit &operator=(const GoASTBasicLit &) = delete;
+};
+
+class GoASTBinaryExpr : public GoASTExpr
+{
+ public:
+ GoASTBinaryExpr(GoASTExpr *x, GoASTExpr *y, TokenType op) : GoASTExpr(eBinaryExpr), m_x_up(x), m_y_up(y), m_op(op) {}
+ ~GoASTBinaryExpr() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "BinaryExpr";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eBinaryExpr;
+ }
+
+ const GoASTExpr *
+ GetX() const
+ {
+ return m_x_up.get();
+ }
+ void
+ SetX(GoASTExpr *x)
+ {
+ m_x_up.reset(x);
+ }
+
+ const GoASTExpr *
+ GetY() const
+ {
+ return m_y_up.get();
+ }
+ void
+ SetY(GoASTExpr *y)
+ {
+ m_y_up.reset(y);
+ }
+
+ TokenType
+ GetOp() const
+ {
+ return m_op;
+ }
+ void
+ SetOp(TokenType op)
+ {
+ m_op = op;
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTExpr> m_x_up;
+ std::unique_ptr<GoASTExpr> m_y_up;
+ TokenType m_op;
+
+ GoASTBinaryExpr(const GoASTBinaryExpr &) = delete;
+ const GoASTBinaryExpr &operator=(const GoASTBinaryExpr &) = delete;
+};
+
+class GoASTBlockStmt : public GoASTStmt
+{
+ public:
+ GoASTBlockStmt() : GoASTStmt(eBlockStmt) {}
+ ~GoASTBlockStmt() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "BlockStmt";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eBlockStmt;
+ }
+
+ size_t
+ NumList() const
+ {
+ return m_list.size();
+ }
+ const GoASTStmt *
+ GetList(int i) const
+ {
+ return m_list[i].get();
+ }
+ void
+ AddList(GoASTStmt *list)
+ {
+ m_list.push_back(std::unique_ptr<GoASTStmt>(list));
+ }
+
+ private:
+ friend class GoASTNode;
+ std::vector<std::unique_ptr<GoASTStmt> > m_list;
+
+ GoASTBlockStmt(const GoASTBlockStmt &) = delete;
+ const GoASTBlockStmt &operator=(const GoASTBlockStmt &) = delete;
+};
+
+class GoASTIdent : public GoASTExpr
+{
+ public:
+ explicit GoASTIdent(Token name) : GoASTExpr(eIdent), m_name(name) {}
+ ~GoASTIdent() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "Ident";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eIdent;
+ }
+
+ Token
+ GetName() const
+ {
+ return m_name;
+ }
+ void
+ SetName(Token name)
+ {
+ m_name = name;
+ }
+
+ private:
+ friend class GoASTNode;
+ Token m_name;
+
+ GoASTIdent(const GoASTIdent &) = delete;
+ const GoASTIdent &operator=(const GoASTIdent &) = delete;
+};
+
+class GoASTBranchStmt : public GoASTStmt
+{
+ public:
+ GoASTBranchStmt(GoASTIdent *label, TokenType tok) : GoASTStmt(eBranchStmt), m_label_up(label), m_tok(tok) {}
+ ~GoASTBranchStmt() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "BranchStmt";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eBranchStmt;
+ }
+
+ const GoASTIdent *
+ GetLabel() const
+ {
+ return m_label_up.get();
+ }
+ void
+ SetLabel(GoASTIdent *label)
+ {
+ m_label_up.reset(label);
+ }
+
+ TokenType
+ GetTok() const
+ {
+ return m_tok;
+ }
+ void
+ SetTok(TokenType tok)
+ {
+ m_tok = tok;
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTIdent> m_label_up;
+ TokenType m_tok;
+
+ GoASTBranchStmt(const GoASTBranchStmt &) = delete;
+ const GoASTBranchStmt &operator=(const GoASTBranchStmt &) = delete;
+};
+
+class GoASTCallExpr : public GoASTExpr
+{
+ public:
+ explicit GoASTCallExpr(bool ellipsis) : GoASTExpr(eCallExpr), m_ellipsis(ellipsis) {}
+ ~GoASTCallExpr() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "CallExpr";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eCallExpr;
+ }
+
+ const GoASTExpr *
+ GetFun() const
+ {
+ return m_fun_up.get();
+ }
+ void
+ SetFun(GoASTExpr *fun)
+ {
+ m_fun_up.reset(fun);
+ }
+
+ size_t
+ NumArgs() const
+ {
+ return m_args.size();
+ }
+ const GoASTExpr *
+ GetArgs(int i) const
+ {
+ return m_args[i].get();
+ }
+ void
+ AddArgs(GoASTExpr *args)
+ {
+ m_args.push_back(std::unique_ptr<GoASTExpr>(args));
+ }
+
+ bool
+ GetEllipsis() const
+ {
+ return m_ellipsis;
+ }
+ void
+ SetEllipsis(bool ellipsis)
+ {
+ m_ellipsis = ellipsis;
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTExpr> m_fun_up;
+ std::vector<std::unique_ptr<GoASTExpr> > m_args;
+ bool m_ellipsis;
+
+ GoASTCallExpr(const GoASTCallExpr &) = delete;
+ const GoASTCallExpr &operator=(const GoASTCallExpr &) = delete;
+};
+
+class GoASTCaseClause : public GoASTStmt
+{
+ public:
+ GoASTCaseClause() : GoASTStmt(eCaseClause) {}
+ ~GoASTCaseClause() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "CaseClause";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eCaseClause;
+ }
+
+ size_t
+ NumList() const
+ {
+ return m_list.size();
+ }
+ const GoASTExpr *
+ GetList(int i) const
+ {
+ return m_list[i].get();
+ }
+ void
+ AddList(GoASTExpr *list)
+ {
+ m_list.push_back(std::unique_ptr<GoASTExpr>(list));
+ }
+
+ size_t
+ NumBody() const
+ {
+ return m_body.size();
+ }
+ const GoASTStmt *
+ GetBody(int i) const
+ {
+ return m_body[i].get();
+ }
+ void
+ AddBody(GoASTStmt *body)
+ {
+ m_body.push_back(std::unique_ptr<GoASTStmt>(body));
+ }
+
+ private:
+ friend class GoASTNode;
+ std::vector<std::unique_ptr<GoASTExpr> > m_list;
+ std::vector<std::unique_ptr<GoASTStmt> > m_body;
+
+ GoASTCaseClause(const GoASTCaseClause &) = delete;
+ const GoASTCaseClause &operator=(const GoASTCaseClause &) = delete;
+};
+
+class GoASTChanType : public GoASTExpr
+{
+ public:
+ GoASTChanType(ChanDir dir, GoASTExpr *value) : GoASTExpr(eChanType), m_dir(dir), m_value_up(value) {}
+ ~GoASTChanType() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "ChanType";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eChanType;
+ }
+
+ ChanDir
+ GetDir() const
+ {
+ return m_dir;
+ }
+ void
+ SetDir(ChanDir dir)
+ {
+ m_dir = dir;
+ }
+
+ const GoASTExpr *
+ GetValue() const
+ {
+ return m_value_up.get();
+ }
+ void
+ SetValue(GoASTExpr *value)
+ {
+ m_value_up.reset(value);
+ }
+
+ private:
+ friend class GoASTNode;
+ ChanDir m_dir;
+ std::unique_ptr<GoASTExpr> m_value_up;
+
+ GoASTChanType(const GoASTChanType &) = delete;
+ const GoASTChanType &operator=(const GoASTChanType &) = delete;
+};
+
+class GoASTCommClause : public GoASTStmt
+{
+ public:
+ GoASTCommClause() : GoASTStmt(eCommClause) {}
+ ~GoASTCommClause() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "CommClause";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eCommClause;
+ }
+
+ const GoASTStmt *
+ GetComm() const
+ {
+ return m_comm_up.get();
+ }
+ void
+ SetComm(GoASTStmt *comm)
+ {
+ m_comm_up.reset(comm);
+ }
+
+ size_t
+ NumBody() const
+ {
+ return m_body.size();
+ }
+ const GoASTStmt *
+ GetBody(int i) const
+ {
+ return m_body[i].get();
+ }
+ void
+ AddBody(GoASTStmt *body)
+ {
+ m_body.push_back(std::unique_ptr<GoASTStmt>(body));
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTStmt> m_comm_up;
+ std::vector<std::unique_ptr<GoASTStmt> > m_body;
+
+ GoASTCommClause(const GoASTCommClause &) = delete;
+ const GoASTCommClause &operator=(const GoASTCommClause &) = delete;
+};
+
+class GoASTCompositeLit : public GoASTExpr
+{
+ public:
+ GoASTCompositeLit() : GoASTExpr(eCompositeLit) {}
+ ~GoASTCompositeLit() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "CompositeLit";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eCompositeLit;
+ }
+
+ const GoASTExpr *
+ GetType() const
+ {
+ return m_type_up.get();
+ }
+ void
+ SetType(GoASTExpr *type)
+ {
+ m_type_up.reset(type);
+ }
+
+ size_t
+ NumElts() const
+ {
+ return m_elts.size();
+ }
+ const GoASTExpr *
+ GetElts(int i) const
+ {
+ return m_elts[i].get();
+ }
+ void
+ AddElts(GoASTExpr *elts)
+ {
+ m_elts.push_back(std::unique_ptr<GoASTExpr>(elts));
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTExpr> m_type_up;
+ std::vector<std::unique_ptr<GoASTExpr> > m_elts;
+
+ GoASTCompositeLit(const GoASTCompositeLit &) = delete;
+ const GoASTCompositeLit &operator=(const GoASTCompositeLit &) = delete;
+};
+
+class GoASTDeclStmt : public GoASTStmt
+{
+ public:
+ explicit GoASTDeclStmt(GoASTDecl *decl) : GoASTStmt(eDeclStmt), m_decl_up(decl) {}
+ ~GoASTDeclStmt() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "DeclStmt";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eDeclStmt;
+ }
+
+ const GoASTDecl *
+ GetDecl() const
+ {
+ return m_decl_up.get();
+ }
+ void
+ SetDecl(GoASTDecl *decl)
+ {
+ m_decl_up.reset(decl);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTDecl> m_decl_up;
+
+ GoASTDeclStmt(const GoASTDeclStmt &) = delete;
+ const GoASTDeclStmt &operator=(const GoASTDeclStmt &) = delete;
+};
+
+class GoASTDeferStmt : public GoASTStmt
+{
+ public:
+ explicit GoASTDeferStmt(GoASTCallExpr *call) : GoASTStmt(eDeferStmt), m_call_up(call) {}
+ ~GoASTDeferStmt() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "DeferStmt";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eDeferStmt;
+ }
+
+ const GoASTCallExpr *
+ GetCall() const
+ {
+ return m_call_up.get();
+ }
+ void
+ SetCall(GoASTCallExpr *call)
+ {
+ m_call_up.reset(call);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTCallExpr> m_call_up;
+
+ GoASTDeferStmt(const GoASTDeferStmt &) = delete;
+ const GoASTDeferStmt &operator=(const GoASTDeferStmt &) = delete;
+};
+
+class GoASTEllipsis : public GoASTExpr
+{
+ public:
+ explicit GoASTEllipsis(GoASTExpr *elt) : GoASTExpr(eEllipsis), m_elt_up(elt) {}
+ ~GoASTEllipsis() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "Ellipsis";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eEllipsis;
+ }
+
+ const GoASTExpr *
+ GetElt() const
+ {
+ return m_elt_up.get();
+ }
+ void
+ SetElt(GoASTExpr *elt)
+ {
+ m_elt_up.reset(elt);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTExpr> m_elt_up;
+
+ GoASTEllipsis(const GoASTEllipsis &) = delete;
+ const GoASTEllipsis &operator=(const GoASTEllipsis &) = delete;
+};
+
+class GoASTEmptyStmt : public GoASTStmt
+{
+ public:
+ GoASTEmptyStmt() : GoASTStmt(eEmptyStmt) {}
+ ~GoASTEmptyStmt() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "EmptyStmt";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eEmptyStmt;
+ }
+
+ GoASTEmptyStmt(const GoASTEmptyStmt &) = delete;
+ const GoASTEmptyStmt &operator=(const GoASTEmptyStmt &) = delete;
+};
+
+class GoASTExprStmt : public GoASTStmt
+{
+ public:
+ explicit GoASTExprStmt(GoASTExpr *x) : GoASTStmt(eExprStmt), m_x_up(x) {}
+ ~GoASTExprStmt() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "ExprStmt";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eExprStmt;
+ }
+
+ const GoASTExpr *
+ GetX() const
+ {
+ return m_x_up.get();
+ }
+ void
+ SetX(GoASTExpr *x)
+ {
+ m_x_up.reset(x);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTExpr> m_x_up;
+
+ GoASTExprStmt(const GoASTExprStmt &) = delete;
+ const GoASTExprStmt &operator=(const GoASTExprStmt &) = delete;
+};
+
+class GoASTField : public GoASTNode
+{
+ public:
+ GoASTField() : GoASTNode(eField) {}
+ ~GoASTField() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "Field";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eField;
+ }
+
+ size_t
+ NumNames() const
+ {
+ return m_names.size();
+ }
+ const GoASTIdent *
+ GetNames(int i) const
+ {
+ return m_names[i].get();
+ }
+ void
+ AddNames(GoASTIdent *names)
+ {
+ m_names.push_back(std::unique_ptr<GoASTIdent>(names));
+ }
+
+ const GoASTExpr *
+ GetType() const
+ {
+ return m_type_up.get();
+ }
+ void
+ SetType(GoASTExpr *type)
+ {
+ m_type_up.reset(type);
+ }
+
+ const GoASTBasicLit *
+ GetTag() const
+ {
+ return m_tag_up.get();
+ }
+ void
+ SetTag(GoASTBasicLit *tag)
+ {
+ m_tag_up.reset(tag);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::vector<std::unique_ptr<GoASTIdent> > m_names;
+ std::unique_ptr<GoASTExpr> m_type_up;
+ std::unique_ptr<GoASTBasicLit> m_tag_up;
+
+ GoASTField(const GoASTField &) = delete;
+ const GoASTField &operator=(const GoASTField &) = delete;
+};
+
+class GoASTFieldList : public GoASTNode
+{
+ public:
+ GoASTFieldList() : GoASTNode(eFieldList) {}
+ ~GoASTFieldList() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "FieldList";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eFieldList;
+ }
+
+ size_t
+ NumList() const
+ {
+ return m_list.size();
+ }
+ const GoASTField *
+ GetList(int i) const
+ {
+ return m_list[i].get();
+ }
+ void
+ AddList(GoASTField *list)
+ {
+ m_list.push_back(std::unique_ptr<GoASTField>(list));
+ }
+
+ private:
+ friend class GoASTNode;
+ std::vector<std::unique_ptr<GoASTField> > m_list;
+
+ GoASTFieldList(const GoASTFieldList &) = delete;
+ const GoASTFieldList &operator=(const GoASTFieldList &) = delete;
+};
+
+class GoASTForStmt : public GoASTStmt
+{
+ public:
+ GoASTForStmt(GoASTStmt *init, GoASTExpr *cond, GoASTStmt *post, GoASTBlockStmt *body) : GoASTStmt(eForStmt), m_init_up(init), m_cond_up(cond), m_post_up(post), m_body_up(body) {}
+ ~GoASTForStmt() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "ForStmt";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eForStmt;
+ }
+
+ const GoASTStmt *
+ GetInit() const
+ {
+ return m_init_up.get();
+ }
+ void
+ SetInit(GoASTStmt *init)
+ {
+ m_init_up.reset(init);
+ }
+
+ const GoASTExpr *
+ GetCond() const
+ {
+ return m_cond_up.get();
+ }
+ void
+ SetCond(GoASTExpr *cond)
+ {
+ m_cond_up.reset(cond);
+ }
+
+ const GoASTStmt *
+ GetPost() const
+ {
+ return m_post_up.get();
+ }
+ void
+ SetPost(GoASTStmt *post)
+ {
+ m_post_up.reset(post);
+ }
+
+ const GoASTBlockStmt *
+ GetBody() const
+ {
+ return m_body_up.get();
+ }
+ void
+ SetBody(GoASTBlockStmt *body)
+ {
+ m_body_up.reset(body);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTStmt> m_init_up;
+ std::unique_ptr<GoASTExpr> m_cond_up;
+ std::unique_ptr<GoASTStmt> m_post_up;
+ std::unique_ptr<GoASTBlockStmt> m_body_up;
+
+ GoASTForStmt(const GoASTForStmt &) = delete;
+ const GoASTForStmt &operator=(const GoASTForStmt &) = delete;
+};
+
+class GoASTFuncType : public GoASTExpr
+{
+ public:
+ GoASTFuncType(GoASTFieldList *params, GoASTFieldList *results) : GoASTExpr(eFuncType), m_params_up(params), m_results_up(results) {}
+ ~GoASTFuncType() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "FuncType";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eFuncType;
+ }
+
+ const GoASTFieldList *
+ GetParams() const
+ {
+ return m_params_up.get();
+ }
+ void
+ SetParams(GoASTFieldList *params)
+ {
+ m_params_up.reset(params);
+ }
+
+ const GoASTFieldList *
+ GetResults() const
+ {
+ return m_results_up.get();
+ }
+ void
+ SetResults(GoASTFieldList *results)
+ {
+ m_results_up.reset(results);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTFieldList> m_params_up;
+ std::unique_ptr<GoASTFieldList> m_results_up;
+
+ GoASTFuncType(const GoASTFuncType &) = delete;
+ const GoASTFuncType &operator=(const GoASTFuncType &) = delete;
+};
+
+class GoASTFuncDecl : public GoASTDecl
+{
+ public:
+ GoASTFuncDecl(GoASTFieldList *recv, GoASTIdent *name, GoASTFuncType *type, GoASTBlockStmt *body) : GoASTDecl(eFuncDecl), m_recv_up(recv), m_name_up(name), m_type_up(type), m_body_up(body) {}
+ ~GoASTFuncDecl() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "FuncDecl";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eFuncDecl;
+ }
+
+ const GoASTFieldList *
+ GetRecv() const
+ {
+ return m_recv_up.get();
+ }
+ void
+ SetRecv(GoASTFieldList *recv)
+ {
+ m_recv_up.reset(recv);
+ }
+
+ const GoASTIdent *
+ GetName() const
+ {
+ return m_name_up.get();
+ }
+ void
+ SetName(GoASTIdent *name)
+ {
+ m_name_up.reset(name);
+ }
+
+ const GoASTFuncType *
+ GetType() const
+ {
+ return m_type_up.get();
+ }
+ void
+ SetType(GoASTFuncType *type)
+ {
+ m_type_up.reset(type);
+ }
+
+ const GoASTBlockStmt *
+ GetBody() const
+ {
+ return m_body_up.get();
+ }
+ void
+ SetBody(GoASTBlockStmt *body)
+ {
+ m_body_up.reset(body);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTFieldList> m_recv_up;
+ std::unique_ptr<GoASTIdent> m_name_up;
+ std::unique_ptr<GoASTFuncType> m_type_up;
+ std::unique_ptr<GoASTBlockStmt> m_body_up;
+
+ GoASTFuncDecl(const GoASTFuncDecl &) = delete;
+ const GoASTFuncDecl &operator=(const GoASTFuncDecl &) = delete;
+};
+
+class GoASTFuncLit : public GoASTExpr
+{
+ public:
+ GoASTFuncLit(GoASTFuncType *type, GoASTBlockStmt *body) : GoASTExpr(eFuncLit), m_type_up(type), m_body_up(body) {}
+ ~GoASTFuncLit() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "FuncLit";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eFuncLit;
+ }
+
+ const GoASTFuncType *
+ GetType() const
+ {
+ return m_type_up.get();
+ }
+ void
+ SetType(GoASTFuncType *type)
+ {
+ m_type_up.reset(type);
+ }
+
+ const GoASTBlockStmt *
+ GetBody() const
+ {
+ return m_body_up.get();
+ }
+ void
+ SetBody(GoASTBlockStmt *body)
+ {
+ m_body_up.reset(body);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTFuncType> m_type_up;
+ std::unique_ptr<GoASTBlockStmt> m_body_up;
+
+ GoASTFuncLit(const GoASTFuncLit &) = delete;
+ const GoASTFuncLit &operator=(const GoASTFuncLit &) = delete;
+};
+
+class GoASTGenDecl : public GoASTDecl
+{
+ public:
+ explicit GoASTGenDecl(TokenType tok) : GoASTDecl(eGenDecl), m_tok(tok) {}
+ ~GoASTGenDecl() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "GenDecl";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eGenDecl;
+ }
+
+ TokenType
+ GetTok() const
+ {
+ return m_tok;
+ }
+ void
+ SetTok(TokenType tok)
+ {
+ m_tok = tok;
+ }
+
+ size_t
+ NumSpecs() const
+ {
+ return m_specs.size();
+ }
+ const GoASTSpec *
+ GetSpecs(int i) const
+ {
+ return m_specs[i].get();
+ }
+ void
+ AddSpecs(GoASTSpec *specs)
+ {
+ m_specs.push_back(std::unique_ptr<GoASTSpec>(specs));
+ }
+
+ private:
+ friend class GoASTNode;
+ TokenType m_tok;
+ std::vector<std::unique_ptr<GoASTSpec> > m_specs;
+
+ GoASTGenDecl(const GoASTGenDecl &) = delete;
+ const GoASTGenDecl &operator=(const GoASTGenDecl &) = delete;
+};
+
+class GoASTGoStmt : public GoASTStmt
+{
+ public:
+ explicit GoASTGoStmt(GoASTCallExpr *call) : GoASTStmt(eGoStmt), m_call_up(call) {}
+ ~GoASTGoStmt() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "GoStmt";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eGoStmt;
+ }
+
+ const GoASTCallExpr *
+ GetCall() const
+ {
+ return m_call_up.get();
+ }
+ void
+ SetCall(GoASTCallExpr *call)
+ {
+ m_call_up.reset(call);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTCallExpr> m_call_up;
+
+ GoASTGoStmt(const GoASTGoStmt &) = delete;
+ const GoASTGoStmt &operator=(const GoASTGoStmt &) = delete;
+};
+
+class GoASTIfStmt : public GoASTStmt
+{
+ public:
+ GoASTIfStmt(GoASTStmt *init, GoASTExpr *cond, GoASTBlockStmt *body, GoASTStmt *els) : GoASTStmt(eIfStmt), m_init_up(init), m_cond_up(cond), m_body_up(body), m_els_up(els) {}
+ ~GoASTIfStmt() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "IfStmt";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eIfStmt;
+ }
+
+ const GoASTStmt *
+ GetInit() const
+ {
+ return m_init_up.get();
+ }
+ void
+ SetInit(GoASTStmt *init)
+ {
+ m_init_up.reset(init);
+ }
+
+ const GoASTExpr *
+ GetCond() const
+ {
+ return m_cond_up.get();
+ }
+ void
+ SetCond(GoASTExpr *cond)
+ {
+ m_cond_up.reset(cond);
+ }
+
+ const GoASTBlockStmt *
+ GetBody() const
+ {
+ return m_body_up.get();
+ }
+ void
+ SetBody(GoASTBlockStmt *body)
+ {
+ m_body_up.reset(body);
+ }
+
+ const GoASTStmt *
+ GetEls() const
+ {
+ return m_els_up.get();
+ }
+ void
+ SetEls(GoASTStmt *els)
+ {
+ m_els_up.reset(els);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTStmt> m_init_up;
+ std::unique_ptr<GoASTExpr> m_cond_up;
+ std::unique_ptr<GoASTBlockStmt> m_body_up;
+ std::unique_ptr<GoASTStmt> m_els_up;
+
+ GoASTIfStmt(const GoASTIfStmt &) = delete;
+ const GoASTIfStmt &operator=(const GoASTIfStmt &) = delete;
+};
+
+class GoASTImportSpec : public GoASTSpec
+{
+ public:
+ GoASTImportSpec(GoASTIdent *name, GoASTBasicLit *path) : GoASTSpec(eImportSpec), m_name_up(name), m_path_up(path) {}
+ ~GoASTImportSpec() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "ImportSpec";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eImportSpec;
+ }
+
+ const GoASTIdent *
+ GetName() const
+ {
+ return m_name_up.get();
+ }
+ void
+ SetName(GoASTIdent *name)
+ {
+ m_name_up.reset(name);
+ }
+
+ const GoASTBasicLit *
+ GetPath() const
+ {
+ return m_path_up.get();
+ }
+ void
+ SetPath(GoASTBasicLit *path)
+ {
+ m_path_up.reset(path);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTIdent> m_name_up;
+ std::unique_ptr<GoASTBasicLit> m_path_up;
+
+ GoASTImportSpec(const GoASTImportSpec &) = delete;
+ const GoASTImportSpec &operator=(const GoASTImportSpec &) = delete;
+};
+
+class GoASTIncDecStmt : public GoASTStmt
+{
+ public:
+ GoASTIncDecStmt(GoASTExpr *x, TokenType tok) : GoASTStmt(eIncDecStmt), m_x_up(x), m_tok(tok) {}
+ ~GoASTIncDecStmt() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "IncDecStmt";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eIncDecStmt;
+ }
+
+ const GoASTExpr *
+ GetX() const
+ {
+ return m_x_up.get();
+ }
+ void
+ SetX(GoASTExpr *x)
+ {
+ m_x_up.reset(x);
+ }
+
+ TokenType
+ GetTok() const
+ {
+ return m_tok;
+ }
+ void
+ SetTok(TokenType tok)
+ {
+ m_tok = tok;
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTExpr> m_x_up;
+ TokenType m_tok;
+
+ GoASTIncDecStmt(const GoASTIncDecStmt &) = delete;
+ const GoASTIncDecStmt &operator=(const GoASTIncDecStmt &) = delete;
+};
+
+class GoASTIndexExpr : public GoASTExpr
+{
+ public:
+ GoASTIndexExpr(GoASTExpr *x, GoASTExpr *index) : GoASTExpr(eIndexExpr), m_x_up(x), m_index_up(index) {}
+ ~GoASTIndexExpr() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "IndexExpr";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eIndexExpr;
+ }
+
+ const GoASTExpr *
+ GetX() const
+ {
+ return m_x_up.get();
+ }
+ void
+ SetX(GoASTExpr *x)
+ {
+ m_x_up.reset(x);
+ }
+
+ const GoASTExpr *
+ GetIndex() const
+ {
+ return m_index_up.get();
+ }
+ void
+ SetIndex(GoASTExpr *index)
+ {
+ m_index_up.reset(index);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTExpr> m_x_up;
+ std::unique_ptr<GoASTExpr> m_index_up;
+
+ GoASTIndexExpr(const GoASTIndexExpr &) = delete;
+ const GoASTIndexExpr &operator=(const GoASTIndexExpr &) = delete;
+};
+
+class GoASTInterfaceType : public GoASTExpr
+{
+ public:
+ explicit GoASTInterfaceType(GoASTFieldList *methods) : GoASTExpr(eInterfaceType), m_methods_up(methods) {}
+ ~GoASTInterfaceType() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "InterfaceType";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eInterfaceType;
+ }
+
+ const GoASTFieldList *
+ GetMethods() const
+ {
+ return m_methods_up.get();
+ }
+ void
+ SetMethods(GoASTFieldList *methods)
+ {
+ m_methods_up.reset(methods);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTFieldList> m_methods_up;
+
+ GoASTInterfaceType(const GoASTInterfaceType &) = delete;
+ const GoASTInterfaceType &operator=(const GoASTInterfaceType &) = delete;
+};
+
+class GoASTKeyValueExpr : public GoASTExpr
+{
+ public:
+ GoASTKeyValueExpr(GoASTExpr *key, GoASTExpr *value) : GoASTExpr(eKeyValueExpr), m_key_up(key), m_value_up(value) {}
+ ~GoASTKeyValueExpr() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "KeyValueExpr";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eKeyValueExpr;
+ }
+
+ const GoASTExpr *
+ GetKey() const
+ {
+ return m_key_up.get();
+ }
+ void
+ SetKey(GoASTExpr *key)
+ {
+ m_key_up.reset(key);
+ }
+
+ const GoASTExpr *
+ GetValue() const
+ {
+ return m_value_up.get();
+ }
+ void
+ SetValue(GoASTExpr *value)
+ {
+ m_value_up.reset(value);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTExpr> m_key_up;
+ std::unique_ptr<GoASTExpr> m_value_up;
+
+ GoASTKeyValueExpr(const GoASTKeyValueExpr &) = delete;
+ const GoASTKeyValueExpr &operator=(const GoASTKeyValueExpr &) = delete;
+};
+
+class GoASTLabeledStmt : public GoASTStmt
+{
+ public:
+ GoASTLabeledStmt(GoASTIdent *label, GoASTStmt *stmt) : GoASTStmt(eLabeledStmt), m_label_up(label), m_stmt_up(stmt) {}
+ ~GoASTLabeledStmt() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "LabeledStmt";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eLabeledStmt;
+ }
+
+ const GoASTIdent *
+ GetLabel() const
+ {
+ return m_label_up.get();
+ }
+ void
+ SetLabel(GoASTIdent *label)
+ {
+ m_label_up.reset(label);
+ }
+
+ const GoASTStmt *
+ GetStmt() const
+ {
+ return m_stmt_up.get();
+ }
+ void
+ SetStmt(GoASTStmt *stmt)
+ {
+ m_stmt_up.reset(stmt);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTIdent> m_label_up;
+ std::unique_ptr<GoASTStmt> m_stmt_up;
+
+ GoASTLabeledStmt(const GoASTLabeledStmt &) = delete;
+ const GoASTLabeledStmt &operator=(const GoASTLabeledStmt &) = delete;
+};
+
+class GoASTMapType : public GoASTExpr
+{
+ public:
+ GoASTMapType(GoASTExpr *key, GoASTExpr *value) : GoASTExpr(eMapType), m_key_up(key), m_value_up(value) {}
+ ~GoASTMapType() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "MapType";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eMapType;
+ }
+
+ const GoASTExpr *
+ GetKey() const
+ {
+ return m_key_up.get();
+ }
+ void
+ SetKey(GoASTExpr *key)
+ {
+ m_key_up.reset(key);
+ }
+
+ const GoASTExpr *
+ GetValue() const
+ {
+ return m_value_up.get();
+ }
+ void
+ SetValue(GoASTExpr *value)
+ {
+ m_value_up.reset(value);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTExpr> m_key_up;
+ std::unique_ptr<GoASTExpr> m_value_up;
+
+ GoASTMapType(const GoASTMapType &) = delete;
+ const GoASTMapType &operator=(const GoASTMapType &) = delete;
+};
+
+class GoASTParenExpr : public GoASTExpr
+{
+ public:
+ explicit GoASTParenExpr(GoASTExpr *x) : GoASTExpr(eParenExpr), m_x_up(x) {}
+ ~GoASTParenExpr() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "ParenExpr";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eParenExpr;
+ }
+
+ const GoASTExpr *
+ GetX() const
+ {
+ return m_x_up.get();
+ }
+ void
+ SetX(GoASTExpr *x)
+ {
+ m_x_up.reset(x);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTExpr> m_x_up;
+
+ GoASTParenExpr(const GoASTParenExpr &) = delete;
+ const GoASTParenExpr &operator=(const GoASTParenExpr &) = delete;
+};
+
+class GoASTRangeStmt : public GoASTStmt
+{
+ public:
+ GoASTRangeStmt(GoASTExpr *key, GoASTExpr *value, bool define, GoASTExpr *x, GoASTBlockStmt *body) : GoASTStmt(eRangeStmt), m_key_up(key), m_value_up(value), m_define(define), m_x_up(x), m_body_up(body) {}
+ ~GoASTRangeStmt() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "RangeStmt";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eRangeStmt;
+ }
+
+ const GoASTExpr *
+ GetKey() const
+ {
+ return m_key_up.get();
+ }
+ void
+ SetKey(GoASTExpr *key)
+ {
+ m_key_up.reset(key);
+ }
+
+ const GoASTExpr *
+ GetValue() const
+ {
+ return m_value_up.get();
+ }
+ void
+ SetValue(GoASTExpr *value)
+ {
+ m_value_up.reset(value);
+ }
+
+ bool
+ GetDefine() const
+ {
+ return m_define;
+ }
+ void
+ SetDefine(bool define)
+ {
+ m_define = define;
+ }
+
+ const GoASTExpr *
+ GetX() const
+ {
+ return m_x_up.get();
+ }
+ void
+ SetX(GoASTExpr *x)
+ {
+ m_x_up.reset(x);
+ }
+
+ const GoASTBlockStmt *
+ GetBody() const
+ {
+ return m_body_up.get();
+ }
+ void
+ SetBody(GoASTBlockStmt *body)
+ {
+ m_body_up.reset(body);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTExpr> m_key_up;
+ std::unique_ptr<GoASTExpr> m_value_up;
+ bool m_define;
+ std::unique_ptr<GoASTExpr> m_x_up;
+ std::unique_ptr<GoASTBlockStmt> m_body_up;
+
+ GoASTRangeStmt(const GoASTRangeStmt &) = delete;
+ const GoASTRangeStmt &operator=(const GoASTRangeStmt &) = delete;
+};
+
+class GoASTReturnStmt : public GoASTStmt
+{
+ public:
+ GoASTReturnStmt() : GoASTStmt(eReturnStmt) {}
+ ~GoASTReturnStmt() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "ReturnStmt";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eReturnStmt;
+ }
+
+ size_t
+ NumResults() const
+ {
+ return m_results.size();
+ }
+ const GoASTExpr *
+ GetResults(int i) const
+ {
+ return m_results[i].get();
+ }
+ void
+ AddResults(GoASTExpr *results)
+ {
+ m_results.push_back(std::unique_ptr<GoASTExpr>(results));
+ }
+
+ private:
+ friend class GoASTNode;
+ std::vector<std::unique_ptr<GoASTExpr> > m_results;
+
+ GoASTReturnStmt(const GoASTReturnStmt &) = delete;
+ const GoASTReturnStmt &operator=(const GoASTReturnStmt &) = delete;
+};
+
+class GoASTSelectStmt : public GoASTStmt
+{
+ public:
+ explicit GoASTSelectStmt(GoASTBlockStmt *body) : GoASTStmt(eSelectStmt), m_body_up(body) {}
+ ~GoASTSelectStmt() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "SelectStmt";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eSelectStmt;
+ }
+
+ const GoASTBlockStmt *
+ GetBody() const
+ {
+ return m_body_up.get();
+ }
+ void
+ SetBody(GoASTBlockStmt *body)
+ {
+ m_body_up.reset(body);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTBlockStmt> m_body_up;
+
+ GoASTSelectStmt(const GoASTSelectStmt &) = delete;
+ const GoASTSelectStmt &operator=(const GoASTSelectStmt &) = delete;
+};
+
+class GoASTSelectorExpr : public GoASTExpr
+{
+ public:
+ GoASTSelectorExpr(GoASTExpr *x, GoASTIdent *sel) : GoASTExpr(eSelectorExpr), m_x_up(x), m_sel_up(sel) {}
+ ~GoASTSelectorExpr() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "SelectorExpr";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eSelectorExpr;
+ }
+
+ const GoASTExpr *
+ GetX() const
+ {
+ return m_x_up.get();
+ }
+ void
+ SetX(GoASTExpr *x)
+ {
+ m_x_up.reset(x);
+ }
+
+ const GoASTIdent *
+ GetSel() const
+ {
+ return m_sel_up.get();
+ }
+ void
+ SetSel(GoASTIdent *sel)
+ {
+ m_sel_up.reset(sel);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTExpr> m_x_up;
+ std::unique_ptr<GoASTIdent> m_sel_up;
+
+ GoASTSelectorExpr(const GoASTSelectorExpr &) = delete;
+ const GoASTSelectorExpr &operator=(const GoASTSelectorExpr &) = delete;
+};
+
+class GoASTSendStmt : public GoASTStmt
+{
+ public:
+ GoASTSendStmt(GoASTExpr *chan, GoASTExpr *value) : GoASTStmt(eSendStmt), m_chan_up(chan), m_value_up(value) {}
+ ~GoASTSendStmt() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "SendStmt";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eSendStmt;
+ }
+
+ const GoASTExpr *
+ GetChan() const
+ {
+ return m_chan_up.get();
+ }
+ void
+ SetChan(GoASTExpr *chan)
+ {
+ m_chan_up.reset(chan);
+ }
+
+ const GoASTExpr *
+ GetValue() const
+ {
+ return m_value_up.get();
+ }
+ void
+ SetValue(GoASTExpr *value)
+ {
+ m_value_up.reset(value);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTExpr> m_chan_up;
+ std::unique_ptr<GoASTExpr> m_value_up;
+
+ GoASTSendStmt(const GoASTSendStmt &) = delete;
+ const GoASTSendStmt &operator=(const GoASTSendStmt &) = delete;
+};
+
+class GoASTSliceExpr : public GoASTExpr
+{
+ public:
+ GoASTSliceExpr(GoASTExpr *x, GoASTExpr *low, GoASTExpr *high, GoASTExpr *max, bool slice3) : GoASTExpr(eSliceExpr), m_x_up(x), m_low_up(low), m_high_up(high), m_max_up(max), m_slice3(slice3) {}
+ ~GoASTSliceExpr() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "SliceExpr";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eSliceExpr;
+ }
+
+ const GoASTExpr *
+ GetX() const
+ {
+ return m_x_up.get();
+ }
+ void
+ SetX(GoASTExpr *x)
+ {
+ m_x_up.reset(x);
+ }
+
+ const GoASTExpr *
+ GetLow() const
+ {
+ return m_low_up.get();
+ }
+ void
+ SetLow(GoASTExpr *low)
+ {
+ m_low_up.reset(low);
+ }
+
+ const GoASTExpr *
+ GetHigh() const
+ {
+ return m_high_up.get();
+ }
+ void
+ SetHigh(GoASTExpr *high)
+ {
+ m_high_up.reset(high);
+ }
+
+ const GoASTExpr *
+ GetMax() const
+ {
+ return m_max_up.get();
+ }
+ void
+ SetMax(GoASTExpr *max)
+ {
+ m_max_up.reset(max);
+ }
+
+ bool
+ GetSlice3() const
+ {
+ return m_slice3;
+ }
+ void
+ SetSlice3(bool slice3)
+ {
+ m_slice3 = slice3;
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTExpr> m_x_up;
+ std::unique_ptr<GoASTExpr> m_low_up;
+ std::unique_ptr<GoASTExpr> m_high_up;
+ std::unique_ptr<GoASTExpr> m_max_up;
+ bool m_slice3;
+
+ GoASTSliceExpr(const GoASTSliceExpr &) = delete;
+ const GoASTSliceExpr &operator=(const GoASTSliceExpr &) = delete;
+};
+
+class GoASTStarExpr : public GoASTExpr
+{
+ public:
+ explicit GoASTStarExpr(GoASTExpr *x) : GoASTExpr(eStarExpr), m_x_up(x) {}
+ ~GoASTStarExpr() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "StarExpr";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eStarExpr;
+ }
+
+ const GoASTExpr *
+ GetX() const
+ {
+ return m_x_up.get();
+ }
+ void
+ SetX(GoASTExpr *x)
+ {
+ m_x_up.reset(x);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTExpr> m_x_up;
+
+ GoASTStarExpr(const GoASTStarExpr &) = delete;
+ const GoASTStarExpr &operator=(const GoASTStarExpr &) = delete;
+};
+
+class GoASTStructType : public GoASTExpr
+{
+ public:
+ explicit GoASTStructType(GoASTFieldList *fields) : GoASTExpr(eStructType), m_fields_up(fields) {}
+ ~GoASTStructType() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "StructType";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eStructType;
+ }
+
+ const GoASTFieldList *
+ GetFields() const
+ {
+ return m_fields_up.get();
+ }
+ void
+ SetFields(GoASTFieldList *fields)
+ {
+ m_fields_up.reset(fields);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTFieldList> m_fields_up;
+
+ GoASTStructType(const GoASTStructType &) = delete;
+ const GoASTStructType &operator=(const GoASTStructType &) = delete;
+};
+
+class GoASTSwitchStmt : public GoASTStmt
+{
+ public:
+ GoASTSwitchStmt(GoASTStmt *init, GoASTExpr *tag, GoASTBlockStmt *body) : GoASTStmt(eSwitchStmt), m_init_up(init), m_tag_up(tag), m_body_up(body) {}
+ ~GoASTSwitchStmt() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "SwitchStmt";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eSwitchStmt;
+ }
+
+ const GoASTStmt *
+ GetInit() const
+ {
+ return m_init_up.get();
+ }
+ void
+ SetInit(GoASTStmt *init)
+ {
+ m_init_up.reset(init);
+ }
+
+ const GoASTExpr *
+ GetTag() const
+ {
+ return m_tag_up.get();
+ }
+ void
+ SetTag(GoASTExpr *tag)
+ {
+ m_tag_up.reset(tag);
+ }
+
+ const GoASTBlockStmt *
+ GetBody() const
+ {
+ return m_body_up.get();
+ }
+ void
+ SetBody(GoASTBlockStmt *body)
+ {
+ m_body_up.reset(body);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTStmt> m_init_up;
+ std::unique_ptr<GoASTExpr> m_tag_up;
+ std::unique_ptr<GoASTBlockStmt> m_body_up;
+
+ GoASTSwitchStmt(const GoASTSwitchStmt &) = delete;
+ const GoASTSwitchStmt &operator=(const GoASTSwitchStmt &) = delete;
+};
+
+class GoASTTypeAssertExpr : public GoASTExpr
+{
+ public:
+ GoASTTypeAssertExpr(GoASTExpr *x, GoASTExpr *type) : GoASTExpr(eTypeAssertExpr), m_x_up(x), m_type_up(type) {}
+ ~GoASTTypeAssertExpr() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "TypeAssertExpr";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eTypeAssertExpr;
+ }
+
+ const GoASTExpr *
+ GetX() const
+ {
+ return m_x_up.get();
+ }
+ void
+ SetX(GoASTExpr *x)
+ {
+ m_x_up.reset(x);
+ }
+
+ const GoASTExpr *
+ GetType() const
+ {
+ return m_type_up.get();
+ }
+ void
+ SetType(GoASTExpr *type)
+ {
+ m_type_up.reset(type);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTExpr> m_x_up;
+ std::unique_ptr<GoASTExpr> m_type_up;
+
+ GoASTTypeAssertExpr(const GoASTTypeAssertExpr &) = delete;
+ const GoASTTypeAssertExpr &operator=(const GoASTTypeAssertExpr &) = delete;
+};
+
+class GoASTTypeSpec : public GoASTSpec
+{
+ public:
+ GoASTTypeSpec(GoASTIdent *name, GoASTExpr *type) : GoASTSpec(eTypeSpec), m_name_up(name), m_type_up(type) {}
+ ~GoASTTypeSpec() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "TypeSpec";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eTypeSpec;
+ }
+
+ const GoASTIdent *
+ GetName() const
+ {
+ return m_name_up.get();
+ }
+ void
+ SetName(GoASTIdent *name)
+ {
+ m_name_up.reset(name);
+ }
+
+ const GoASTExpr *
+ GetType() const
+ {
+ return m_type_up.get();
+ }
+ void
+ SetType(GoASTExpr *type)
+ {
+ m_type_up.reset(type);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTIdent> m_name_up;
+ std::unique_ptr<GoASTExpr> m_type_up;
+
+ GoASTTypeSpec(const GoASTTypeSpec &) = delete;
+ const GoASTTypeSpec &operator=(const GoASTTypeSpec &) = delete;
+};
+
+class GoASTTypeSwitchStmt : public GoASTStmt
+{
+ public:
+ GoASTTypeSwitchStmt(GoASTStmt *init, GoASTStmt *assign, GoASTBlockStmt *body) : GoASTStmt(eTypeSwitchStmt), m_init_up(init), m_assign_up(assign), m_body_up(body) {}
+ ~GoASTTypeSwitchStmt() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "TypeSwitchStmt";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eTypeSwitchStmt;
+ }
+
+ const GoASTStmt *
+ GetInit() const
+ {
+ return m_init_up.get();
+ }
+ void
+ SetInit(GoASTStmt *init)
+ {
+ m_init_up.reset(init);
+ }
+
+ const GoASTStmt *
+ GetAssign() const
+ {
+ return m_assign_up.get();
+ }
+ void
+ SetAssign(GoASTStmt *assign)
+ {
+ m_assign_up.reset(assign);
+ }
+
+ const GoASTBlockStmt *
+ GetBody() const
+ {
+ return m_body_up.get();
+ }
+ void
+ SetBody(GoASTBlockStmt *body)
+ {
+ m_body_up.reset(body);
+ }
+
+ private:
+ friend class GoASTNode;
+ std::unique_ptr<GoASTStmt> m_init_up;
+ std::unique_ptr<GoASTStmt> m_assign_up;
+ std::unique_ptr<GoASTBlockStmt> m_body_up;
+
+ GoASTTypeSwitchStmt(const GoASTTypeSwitchStmt &) = delete;
+ const GoASTTypeSwitchStmt &operator=(const GoASTTypeSwitchStmt &) = delete;
+};
+
+class GoASTUnaryExpr : public GoASTExpr
+{
+ public:
+ GoASTUnaryExpr(TokenType op, GoASTExpr *x) : GoASTExpr(eUnaryExpr), m_op(op), m_x_up(x) {}
+ ~GoASTUnaryExpr() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "UnaryExpr";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eUnaryExpr;
+ }
+
+ TokenType
+ GetOp() const
+ {
+ return m_op;
+ }
+ void
+ SetOp(TokenType op)
+ {
+ m_op = op;
+ }
+
+ const GoASTExpr *
+ GetX() const
+ {
+ return m_x_up.get();
+ }
+ void
+ SetX(GoASTExpr *x)
+ {
+ m_x_up.reset(x);
+ }
+
+ private:
+ friend class GoASTNode;
+ TokenType m_op;
+ std::unique_ptr<GoASTExpr> m_x_up;
+
+ GoASTUnaryExpr(const GoASTUnaryExpr &) = delete;
+ const GoASTUnaryExpr &operator=(const GoASTUnaryExpr &) = delete;
+};
+
+class GoASTValueSpec : public GoASTSpec
+{
+ public:
+ GoASTValueSpec() : GoASTSpec(eValueSpec) {}
+ ~GoASTValueSpec() override = default;
+
+ const char *
+ GetKindName() const override
+ {
+ return "ValueSpec";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == eValueSpec;
+ }
+
+ size_t
+ NumNames() const
+ {
+ return m_names.size();
+ }
+ const GoASTIdent *
+ GetNames(int i) const
+ {
+ return m_names[i].get();
+ }
+ void
+ AddNames(GoASTIdent *names)
+ {
+ m_names.push_back(std::unique_ptr<GoASTIdent>(names));
+ }
+
+ const GoASTExpr *
+ GetType() const
+ {
+ return m_type_up.get();
+ }
+ void
+ SetType(GoASTExpr *type)
+ {
+ m_type_up.reset(type);
+ }
+
+ size_t
+ NumValues() const
+ {
+ return m_values.size();
+ }
+ const GoASTExpr *
+ GetValues(int i) const
+ {
+ return m_values[i].get();
+ }
+ void
+ AddValues(GoASTExpr *values)
+ {
+ m_values.push_back(std::unique_ptr<GoASTExpr>(values));
+ }
+
+ private:
+ friend class GoASTNode;
+ std::vector<std::unique_ptr<GoASTIdent> > m_names;
+ std::unique_ptr<GoASTExpr> m_type_up;
+ std::vector<std::unique_ptr<GoASTExpr> > m_values;
+
+ GoASTValueSpec(const GoASTValueSpec &) = delete;
+ const GoASTValueSpec &operator=(const GoASTValueSpec &) = delete;
+};
+
+
+template <typename R, typename V>
+R GoASTDecl::Visit(V* v) const
+{
+ switch(GetKind())
+ {
+ case eBadDecl:
+ return v->VisitBadDecl(llvm::cast<const GoASTBadDecl>(this));
+ case eFuncDecl:
+ return v->VisitFuncDecl(llvm::cast<const GoASTFuncDecl>(this));
+ case eGenDecl:
+ return v->VisitGenDecl(llvm::cast<const GoASTGenDecl>(this));
+ default:
+ assert(false && "Invalid kind");
+ }
+}
+
+template <typename R, typename V>
+R GoASTExpr::Visit(V* v) const
+{
+ switch(GetKind())
+ {
+ case eArrayType:
+ return v->VisitArrayType(llvm::cast<const GoASTArrayType>(this));
+ case eBadExpr:
+ return v->VisitBadExpr(llvm::cast<const GoASTBadExpr>(this));
+ case eBasicLit:
+ return v->VisitBasicLit(llvm::cast<const GoASTBasicLit>(this));
+ case eBinaryExpr:
+ return v->VisitBinaryExpr(llvm::cast<const GoASTBinaryExpr>(this));
+ case eIdent:
+ return v->VisitIdent(llvm::cast<const GoASTIdent>(this));
+ case eCallExpr:
+ return v->VisitCallExpr(llvm::cast<const GoASTCallExpr>(this));
+ case eChanType:
+ return v->VisitChanType(llvm::cast<const GoASTChanType>(this));
+ case eCompositeLit:
+ return v->VisitCompositeLit(llvm::cast<const GoASTCompositeLit>(this));
+ case eEllipsis:
+ return v->VisitEllipsis(llvm::cast<const GoASTEllipsis>(this));
+ case eFuncType:
+ return v->VisitFuncType(llvm::cast<const GoASTFuncType>(this));
+ case eFuncLit:
+ return v->VisitFuncLit(llvm::cast<const GoASTFuncLit>(this));
+ case eIndexExpr:
+ return v->VisitIndexExpr(llvm::cast<const GoASTIndexExpr>(this));
+ case eInterfaceType:
+ return v->VisitInterfaceType(llvm::cast<const GoASTInterfaceType>(this));
+ case eKeyValueExpr:
+ return v->VisitKeyValueExpr(llvm::cast<const GoASTKeyValueExpr>(this));
+ case eMapType:
+ return v->VisitMapType(llvm::cast<const GoASTMapType>(this));
+ case eParenExpr:
+ return v->VisitParenExpr(llvm::cast<const GoASTParenExpr>(this));
+ case eSelectorExpr:
+ return v->VisitSelectorExpr(llvm::cast<const GoASTSelectorExpr>(this));
+ case eSliceExpr:
+ return v->VisitSliceExpr(llvm::cast<const GoASTSliceExpr>(this));
+ case eStarExpr:
+ return v->VisitStarExpr(llvm::cast<const GoASTStarExpr>(this));
+ case eStructType:
+ return v->VisitStructType(llvm::cast<const GoASTStructType>(this));
+ case eTypeAssertExpr:
+ return v->VisitTypeAssertExpr(llvm::cast<const GoASTTypeAssertExpr>(this));
+ case eUnaryExpr:
+ return v->VisitUnaryExpr(llvm::cast<const GoASTUnaryExpr>(this));
+ default:
+ assert(false && "Invalid kind");
+ }
+}
+
+template <typename R, typename V>
+R GoASTSpec::Visit(V* v) const
+{
+ switch(GetKind())
+ {
+ case eImportSpec:
+ return v->VisitImportSpec(llvm::cast<const GoASTImportSpec>(this));
+ case eTypeSpec:
+ return v->VisitTypeSpec(llvm::cast<const GoASTTypeSpec>(this));
+ case eValueSpec:
+ return v->VisitValueSpec(llvm::cast<const GoASTValueSpec>(this));
+ default:
+ assert(false && "Invalid kind");
+ }
+}
+
+template <typename R, typename V>
+R GoASTStmt::Visit(V* v) const
+{
+ switch(GetKind())
+ {
+ case eAssignStmt:
+ return v->VisitAssignStmt(llvm::cast<const GoASTAssignStmt>(this));
+ case eBadStmt:
+ return v->VisitBadStmt(llvm::cast<const GoASTBadStmt>(this));
+ case eBlockStmt:
+ return v->VisitBlockStmt(llvm::cast<const GoASTBlockStmt>(this));
+ case eBranchStmt:
+ return v->VisitBranchStmt(llvm::cast<const GoASTBranchStmt>(this));
+ case eCaseClause:
+ return v->VisitCaseClause(llvm::cast<const GoASTCaseClause>(this));
+ case eCommClause:
+ return v->VisitCommClause(llvm::cast<const GoASTCommClause>(this));
+ case eDeclStmt:
+ return v->VisitDeclStmt(llvm::cast<const GoASTDeclStmt>(this));
+ case eDeferStmt:
+ return v->VisitDeferStmt(llvm::cast<const GoASTDeferStmt>(this));
+ case eEmptyStmt:
+ return v->VisitEmptyStmt(llvm::cast<const GoASTEmptyStmt>(this));
+ case eExprStmt:
+ return v->VisitExprStmt(llvm::cast<const GoASTExprStmt>(this));
+ case eForStmt:
+ return v->VisitForStmt(llvm::cast<const GoASTForStmt>(this));
+ case eGoStmt:
+ return v->VisitGoStmt(llvm::cast<const GoASTGoStmt>(this));
+ case eIfStmt:
+ return v->VisitIfStmt(llvm::cast<const GoASTIfStmt>(this));
+ case eIncDecStmt:
+ return v->VisitIncDecStmt(llvm::cast<const GoASTIncDecStmt>(this));
+ case eLabeledStmt:
+ return v->VisitLabeledStmt(llvm::cast<const GoASTLabeledStmt>(this));
+ case eRangeStmt:
+ return v->VisitRangeStmt(llvm::cast<const GoASTRangeStmt>(this));
+ case eReturnStmt:
+ return v->VisitReturnStmt(llvm::cast<const GoASTReturnStmt>(this));
+ case eSelectStmt:
+ return v->VisitSelectStmt(llvm::cast<const GoASTSelectStmt>(this));
+ case eSendStmt:
+ return v->VisitSendStmt(llvm::cast<const GoASTSendStmt>(this));
+ case eSwitchStmt:
+ return v->VisitSwitchStmt(llvm::cast<const GoASTSwitchStmt>(this));
+ case eTypeSwitchStmt:
+ return v->VisitTypeSwitchStmt(llvm::cast<const GoASTTypeSwitchStmt>(this));
+ default:
+ assert(false && "Invalid kind");
+ }
+}
+
+template <typename V>
+void GoASTNode::WalkChildren(V &v)
+{
+ switch (m_kind)
+ {
+
+
+ case eArrayType:
+ {
+ GoASTArrayType *n = llvm::cast<GoASTArrayType>(this);
+ (void)n;
+ v(n->m_len_up.get());
+ v(n->m_elt_up.get());
+ return;
+ }
+ case eAssignStmt:
+ {
+ GoASTAssignStmt *n = llvm::cast<GoASTAssignStmt>(this);
+ (void)n;
+ for (auto& e : n->m_lhs) { v(e.get()); }
+ for (auto& e : n->m_rhs) { v(e.get()); }
+ return;
+ }
+ case eBasicLit:
+ {
+ GoASTBasicLit *n = llvm::cast<GoASTBasicLit>(this);
+ (void)n;
+ return;
+ }
+ case eBinaryExpr:
+ {
+ GoASTBinaryExpr *n = llvm::cast<GoASTBinaryExpr>(this);
+ (void)n;
+ v(n->m_x_up.get());
+ v(n->m_y_up.get());
+ return;
+ }
+ case eBlockStmt:
+ {
+ GoASTBlockStmt *n = llvm::cast<GoASTBlockStmt>(this);
+ (void)n;
+ for (auto& e : n->m_list) { v(e.get()); }
+ return;
+ }
+ case eIdent:
+ {
+ GoASTIdent *n = llvm::cast<GoASTIdent>(this);
+ (void)n;
+ return;
+ }
+ case eBranchStmt:
+ {
+ GoASTBranchStmt *n = llvm::cast<GoASTBranchStmt>(this);
+ (void)n;
+ v(n->m_label_up.get());
+ return;
+ }
+ case eCallExpr:
+ {
+ GoASTCallExpr *n = llvm::cast<GoASTCallExpr>(this);
+ (void)n;
+ v(n->m_fun_up.get());
+ for (auto& e : n->m_args) { v(e.get()); }
+ return;
+ }
+ case eCaseClause:
+ {
+ GoASTCaseClause *n = llvm::cast<GoASTCaseClause>(this);
+ (void)n;
+ for (auto& e : n->m_list) { v(e.get()); }
+ for (auto& e : n->m_body) { v(e.get()); }
+ return;
+ }
+ case eChanType:
+ {
+ GoASTChanType *n = llvm::cast<GoASTChanType>(this);
+ (void)n;
+ v(n->m_value_up.get());
+ return;
+ }
+ case eCommClause:
+ {
+ GoASTCommClause *n = llvm::cast<GoASTCommClause>(this);
+ (void)n;
+ v(n->m_comm_up.get());
+ for (auto& e : n->m_body) { v(e.get()); }
+ return;
+ }
+ case eCompositeLit:
+ {
+ GoASTCompositeLit *n = llvm::cast<GoASTCompositeLit>(this);
+ (void)n;
+ v(n->m_type_up.get());
+ for (auto& e : n->m_elts) { v(e.get()); }
+ return;
+ }
+ case eDeclStmt:
+ {
+ GoASTDeclStmt *n = llvm::cast<GoASTDeclStmt>(this);
+ (void)n;
+ v(n->m_decl_up.get());
+ return;
+ }
+ case eDeferStmt:
+ {
+ GoASTDeferStmt *n = llvm::cast<GoASTDeferStmt>(this);
+ (void)n;
+ v(n->m_call_up.get());
+ return;
+ }
+ case eEllipsis:
+ {
+ GoASTEllipsis *n = llvm::cast<GoASTEllipsis>(this);
+ (void)n;
+ v(n->m_elt_up.get());
+ return;
+ }
+ case eExprStmt:
+ {
+ GoASTExprStmt *n = llvm::cast<GoASTExprStmt>(this);
+ (void)n;
+ v(n->m_x_up.get());
+ return;
+ }
+ case eField:
+ {
+ GoASTField *n = llvm::cast<GoASTField>(this);
+ (void)n;
+ for (auto& e : n->m_names) { v(e.get()); }
+ v(n->m_type_up.get());
+ v(n->m_tag_up.get());
+ return;
+ }
+ case eFieldList:
+ {
+ GoASTFieldList *n = llvm::cast<GoASTFieldList>(this);
+ (void)n;
+ for (auto& e : n->m_list) { v(e.get()); }
+ return;
+ }
+ case eForStmt:
+ {
+ GoASTForStmt *n = llvm::cast<GoASTForStmt>(this);
+ (void)n;
+ v(n->m_init_up.get());
+ v(n->m_cond_up.get());
+ v(n->m_post_up.get());
+ v(n->m_body_up.get());
+ return;
+ }
+ case eFuncType:
+ {
+ GoASTFuncType *n = llvm::cast<GoASTFuncType>(this);
+ (void)n;
+ v(n->m_params_up.get());
+ v(n->m_results_up.get());
+ return;
+ }
+ case eFuncDecl:
+ {
+ GoASTFuncDecl *n = llvm::cast<GoASTFuncDecl>(this);
+ (void)n;
+ v(n->m_recv_up.get());
+ v(n->m_name_up.get());
+ v(n->m_type_up.get());
+ v(n->m_body_up.get());
+ return;
+ }
+ case eFuncLit:
+ {
+ GoASTFuncLit *n = llvm::cast<GoASTFuncLit>(this);
+ (void)n;
+ v(n->m_type_up.get());
+ v(n->m_body_up.get());
+ return;
+ }
+ case eGenDecl:
+ {
+ GoASTGenDecl *n = llvm::cast<GoASTGenDecl>(this);
+ (void)n;
+ for (auto& e : n->m_specs) { v(e.get()); }
+ return;
+ }
+ case eGoStmt:
+ {
+ GoASTGoStmt *n = llvm::cast<GoASTGoStmt>(this);
+ (void)n;
+ v(n->m_call_up.get());
+ return;
+ }
+ case eIfStmt:
+ {
+ GoASTIfStmt *n = llvm::cast<GoASTIfStmt>(this);
+ (void)n;
+ v(n->m_init_up.get());
+ v(n->m_cond_up.get());
+ v(n->m_body_up.get());
+ v(n->m_els_up.get());
+ return;
+ }
+ case eImportSpec:
+ {
+ GoASTImportSpec *n = llvm::cast<GoASTImportSpec>(this);
+ (void)n;
+ v(n->m_name_up.get());
+ v(n->m_path_up.get());
+ return;
+ }
+ case eIncDecStmt:
+ {
+ GoASTIncDecStmt *n = llvm::cast<GoASTIncDecStmt>(this);
+ (void)n;
+ v(n->m_x_up.get());
+ return;
+ }
+ case eIndexExpr:
+ {
+ GoASTIndexExpr *n = llvm::cast<GoASTIndexExpr>(this);
+ (void)n;
+ v(n->m_x_up.get());
+ v(n->m_index_up.get());
+ return;
+ }
+ case eInterfaceType:
+ {
+ GoASTInterfaceType *n = llvm::cast<GoASTInterfaceType>(this);
+ (void)n;
+ v(n->m_methods_up.get());
+ return;
+ }
+ case eKeyValueExpr:
+ {
+ GoASTKeyValueExpr *n = llvm::cast<GoASTKeyValueExpr>(this);
+ (void)n;
+ v(n->m_key_up.get());
+ v(n->m_value_up.get());
+ return;
+ }
+ case eLabeledStmt:
+ {
+ GoASTLabeledStmt *n = llvm::cast<GoASTLabeledStmt>(this);
+ (void)n;
+ v(n->m_label_up.get());
+ v(n->m_stmt_up.get());
+ return;
+ }
+ case eMapType:
+ {
+ GoASTMapType *n = llvm::cast<GoASTMapType>(this);
+ (void)n;
+ v(n->m_key_up.get());
+ v(n->m_value_up.get());
+ return;
+ }
+ case eParenExpr:
+ {
+ GoASTParenExpr *n = llvm::cast<GoASTParenExpr>(this);
+ (void)n;
+ v(n->m_x_up.get());
+ return;
+ }
+ case eRangeStmt:
+ {
+ GoASTRangeStmt *n = llvm::cast<GoASTRangeStmt>(this);
+ (void)n;
+ v(n->m_key_up.get());
+ v(n->m_value_up.get());
+ v(n->m_x_up.get());
+ v(n->m_body_up.get());
+ return;
+ }
+ case eReturnStmt:
+ {
+ GoASTReturnStmt *n = llvm::cast<GoASTReturnStmt>(this);
+ (void)n;
+ for (auto& e : n->m_results) { v(e.get()); }
+ return;
+ }
+ case eSelectStmt:
+ {
+ GoASTSelectStmt *n = llvm::cast<GoASTSelectStmt>(this);
+ (void)n;
+ v(n->m_body_up.get());
+ return;
+ }
+ case eSelectorExpr:
+ {
+ GoASTSelectorExpr *n = llvm::cast<GoASTSelectorExpr>(this);
+ (void)n;
+ v(n->m_x_up.get());
+ v(n->m_sel_up.get());
+ return;
+ }
+ case eSendStmt:
+ {
+ GoASTSendStmt *n = llvm::cast<GoASTSendStmt>(this);
+ (void)n;
+ v(n->m_chan_up.get());
+ v(n->m_value_up.get());
+ return;
+ }
+ case eSliceExpr:
+ {
+ GoASTSliceExpr *n = llvm::cast<GoASTSliceExpr>(this);
+ (void)n;
+ v(n->m_x_up.get());
+ v(n->m_low_up.get());
+ v(n->m_high_up.get());
+ v(n->m_max_up.get());
+ return;
+ }
+ case eStarExpr:
+ {
+ GoASTStarExpr *n = llvm::cast<GoASTStarExpr>(this);
+ (void)n;
+ v(n->m_x_up.get());
+ return;
+ }
+ case eStructType:
+ {
+ GoASTStructType *n = llvm::cast<GoASTStructType>(this);
+ (void)n;
+ v(n->m_fields_up.get());
+ return;
+ }
+ case eSwitchStmt:
+ {
+ GoASTSwitchStmt *n = llvm::cast<GoASTSwitchStmt>(this);
+ (void)n;
+ v(n->m_init_up.get());
+ v(n->m_tag_up.get());
+ v(n->m_body_up.get());
+ return;
+ }
+ case eTypeAssertExpr:
+ {
+ GoASTTypeAssertExpr *n = llvm::cast<GoASTTypeAssertExpr>(this);
+ (void)n;
+ v(n->m_x_up.get());
+ v(n->m_type_up.get());
+ return;
+ }
+ case eTypeSpec:
+ {
+ GoASTTypeSpec *n = llvm::cast<GoASTTypeSpec>(this);
+ (void)n;
+ v(n->m_name_up.get());
+ v(n->m_type_up.get());
+ return;
+ }
+ case eTypeSwitchStmt:
+ {
+ GoASTTypeSwitchStmt *n = llvm::cast<GoASTTypeSwitchStmt>(this);
+ (void)n;
+ v(n->m_init_up.get());
+ v(n->m_assign_up.get());
+ v(n->m_body_up.get());
+ return;
+ }
+ case eUnaryExpr:
+ {
+ GoASTUnaryExpr *n = llvm::cast<GoASTUnaryExpr>(this);
+ (void)n;
+ v(n->m_x_up.get());
+ return;
+ }
+ case eValueSpec:
+ {
+ GoASTValueSpec *n = llvm::cast<GoASTValueSpec>(this);
+ (void)n;
+ for (auto& e : n->m_names) { v(e.get()); }
+ v(n->m_type_up.get());
+ for (auto& e : n->m_values) { v(e.get()); }
+ return;
+ }
+
+ case eEmptyStmt:
+ case eBadDecl:
+ case eBadExpr:
+ case eBadStmt:
+ break;
+ }
+}
+
+} // namespace lldb_private
+
+#endif
+
diff --git a/source/Plugins/ExpressionParser/Go/GoLexer.cpp b/source/Plugins/ExpressionParser/Go/GoLexer.cpp
new file mode 100644
index 000000000000..6de0f5619ca8
--- /dev/null
+++ b/source/Plugins/ExpressionParser/Go/GoLexer.cpp
@@ -0,0 +1,402 @@
+//===-- GoLexer.cpp ---------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <string.h>
+
+#include "GoLexer.h"
+
+using namespace lldb_private;
+
+llvm::StringMap<GoLexer::TokenType> *GoLexer::m_keywords;
+
+GoLexer::GoLexer(const char *src) : m_src(src), m_end(src + strlen(src)), m_last_token(TOK_INVALID, "")
+{
+}
+
+bool
+GoLexer::SkipWhitespace()
+{
+ bool saw_newline = false;
+ for (; m_src < m_end; ++m_src)
+ {
+ if (*m_src == '\n')
+ saw_newline = true;
+ if (*m_src == '/' && !SkipComment())
+ return saw_newline;
+ else if (!IsWhitespace(*m_src))
+ return saw_newline;
+ }
+ return saw_newline;
+}
+
+bool
+GoLexer::SkipComment()
+{
+ if (m_src[0] == '/' && m_src[1] == '/')
+ {
+ for (const char *c = m_src + 2; c < m_end; ++c)
+ {
+ if (*c == '\n')
+ {
+ m_src = c - 1;
+ return true;
+ }
+ }
+ return true;
+ }
+ else if (m_src[0] == '/' && m_src[1] == '*')
+ {
+ for (const char *c = m_src + 2; c < m_end; ++c)
+ {
+ if (c[0] == '*' && c[1] == '/')
+ {
+ m_src = c + 1;
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+const GoLexer::Token &
+GoLexer::Lex()
+{
+ bool newline = SkipWhitespace();
+ const char *start = m_src;
+ m_last_token.m_type = InternalLex(newline);
+ m_last_token.m_value = llvm::StringRef(start, m_src - start);
+ return m_last_token;
+}
+
+GoLexer::TokenType
+GoLexer::InternalLex(bool newline)
+{
+ if (m_src >= m_end)
+ {
+ return TOK_EOF;
+ }
+ if (newline)
+ {
+ switch (m_last_token.m_type)
+ {
+ case TOK_IDENTIFIER:
+ case LIT_FLOAT:
+ case LIT_IMAGINARY:
+ case LIT_INTEGER:
+ case LIT_RUNE:
+ case LIT_STRING:
+ case KEYWORD_BREAK:
+ case KEYWORD_CONTINUE:
+ case KEYWORD_FALLTHROUGH:
+ case KEYWORD_RETURN:
+ case OP_PLUS_PLUS:
+ case OP_MINUS_MINUS:
+ case OP_RPAREN:
+ case OP_RBRACK:
+ case OP_RBRACE:
+ return OP_SEMICOLON;
+ default:
+ break;
+ }
+ }
+ char c = *m_src;
+ switch (c)
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ return DoNumber();
+ case '+':
+ case '-':
+ case '*':
+ case '/':
+ case '%':
+ case '&':
+ case '|':
+ case '^':
+ case '<':
+ case '>':
+ case '!':
+ case ':':
+ case ';':
+ case '(':
+ case ')':
+ case '[':
+ case ']':
+ case '{':
+ case '}':
+ case ',':
+ case '=':
+ return DoOperator();
+ case '.':
+ if (IsDecimal(m_src[1]))
+ return DoNumber();
+ return DoOperator();
+ case '$':
+ // For lldb persistent vars.
+ return DoIdent();
+ case '"':
+ case '`':
+ return DoString();
+ case '\'':
+ return DoRune();
+ default:
+ break;
+ }
+ if (IsLetterOrDigit(c))
+ return DoIdent();
+ ++m_src;
+ return TOK_INVALID;
+}
+
+GoLexer::TokenType
+GoLexer::DoOperator()
+{
+ TokenType t = TOK_INVALID;
+ if (m_end - m_src > 2)
+ {
+ t = LookupKeyword(llvm::StringRef(m_src, 3));
+ if (t != TOK_INVALID)
+ m_src += 3;
+ }
+ if (t == TOK_INVALID && m_end - m_src > 1)
+ {
+ t = LookupKeyword(llvm::StringRef(m_src, 2));
+ if (t != TOK_INVALID)
+ m_src += 2;
+ }
+ if (t == TOK_INVALID)
+ {
+ t = LookupKeyword(llvm::StringRef(m_src, 1));
+ ++m_src;
+ }
+ return t;
+}
+
+GoLexer::TokenType
+GoLexer::DoIdent()
+{
+ const char *start = m_src++;
+ while (m_src < m_end && IsLetterOrDigit(*m_src))
+ {
+ ++m_src;
+ }
+ TokenType kw = LookupKeyword(llvm::StringRef(start, m_src - start));
+ if (kw != TOK_INVALID)
+ return kw;
+ return TOK_IDENTIFIER;
+}
+
+GoLexer::TokenType
+GoLexer::DoNumber()
+{
+ if (m_src[0] == '0' && (m_src[1] == 'x' || m_src[1] == 'X'))
+ {
+ m_src += 2;
+ while (IsHexChar(*m_src))
+ ++m_src;
+ return LIT_INTEGER;
+ }
+ bool dot_ok = true;
+ bool e_ok = true;
+ while (true)
+ {
+ while (IsDecimal(*m_src))
+ ++m_src;
+ switch (*m_src)
+ {
+ case 'i':
+ ++m_src;
+ return LIT_IMAGINARY;
+ case '.':
+ if (!dot_ok)
+ return LIT_FLOAT;
+ ++m_src;
+ dot_ok = false;
+ break;
+ case 'e':
+ case 'E':
+ if (!e_ok)
+ return LIT_FLOAT;
+ dot_ok = e_ok = false;
+ ++m_src;
+ if (*m_src == '+' || *m_src == '-')
+ ++m_src;
+ break;
+ default:
+ if (dot_ok)
+ return LIT_INTEGER;
+ return LIT_FLOAT;
+ }
+ }
+}
+
+GoLexer::TokenType
+GoLexer::DoRune()
+{
+ while (++m_src < m_end)
+ {
+ switch (*m_src)
+ {
+ case '\'':
+ ++m_src;
+ return LIT_RUNE;
+ case '\n':
+ return TOK_INVALID;
+ case '\\':
+ if (m_src[1] == '\n')
+ return TOK_INVALID;
+ ++m_src;
+ }
+ }
+ return TOK_INVALID;
+}
+
+GoLexer::TokenType
+GoLexer::DoString()
+{
+ if (*m_src == '`')
+ {
+ while (++m_src < m_end)
+ {
+ if (*m_src == '`')
+ {
+ ++m_src;
+ return LIT_STRING;
+ }
+ }
+ return TOK_INVALID;
+ }
+ while (++m_src < m_end)
+ {
+ switch (*m_src)
+ {
+ case '"':
+ ++m_src;
+ return LIT_STRING;
+ case '\n':
+ return TOK_INVALID;
+ case '\\':
+ if (m_src[1] == '\n')
+ return TOK_INVALID;
+ ++m_src;
+ }
+ }
+ return TOK_INVALID;
+}
+
+GoLexer::TokenType
+GoLexer::LookupKeyword(llvm::StringRef id)
+{
+ if (m_keywords == nullptr)
+ m_keywords = InitKeywords();
+ const auto &it = m_keywords->find(id);
+ if (it == m_keywords->end())
+ return TOK_INVALID;
+ return it->second;
+}
+
+llvm::StringRef
+GoLexer::LookupToken(TokenType t)
+{
+ if (m_keywords == nullptr)
+ m_keywords = InitKeywords();
+ for (const auto &e : *m_keywords)
+ {
+ if (e.getValue() == t)
+ return e.getKey();
+ }
+ return "";
+}
+
+llvm::StringMap<GoLexer::TokenType> *
+GoLexer::InitKeywords()
+{
+ auto &result = *new llvm::StringMap<TokenType>(128);
+ result["break"] = KEYWORD_BREAK;
+ result["default"] = KEYWORD_DEFAULT;
+ result["func"] = KEYWORD_FUNC;
+ result["interface"] = KEYWORD_INTERFACE;
+ result["select"] = KEYWORD_SELECT;
+ result["case"] = KEYWORD_CASE;
+ result["defer"] = KEYWORD_DEFER;
+ result["go"] = KEYWORD_GO;
+ result["map"] = KEYWORD_MAP;
+ result["struct"] = KEYWORD_STRUCT;
+ result["chan"] = KEYWORD_CHAN;
+ result["else"] = KEYWORD_ELSE;
+ result["goto"] = KEYWORD_GOTO;
+ result["package"] = KEYWORD_PACKAGE;
+ result["switch"] = KEYWORD_SWITCH;
+ result["const"] = KEYWORD_CONST;
+ result["fallthrough"] = KEYWORD_FALLTHROUGH;
+ result["if"] = KEYWORD_IF;
+ result["range"] = KEYWORD_RANGE;
+ result["type"] = KEYWORD_TYPE;
+ result["continue"] = KEYWORD_CONTINUE;
+ result["for"] = KEYWORD_FOR;
+ result["import"] = KEYWORD_IMPORT;
+ result["return"] = KEYWORD_RETURN;
+ result["var"] = KEYWORD_VAR;
+ result["+"] = OP_PLUS;
+ result["-"] = OP_MINUS;
+ result["*"] = OP_STAR;
+ result["/"] = OP_SLASH;
+ result["%"] = OP_PERCENT;
+ result["&"] = OP_AMP;
+ result["|"] = OP_PIPE;
+ result["^"] = OP_CARET;
+ result["<<"] = OP_LSHIFT;
+ result[">>"] = OP_RSHIFT;
+ result["&^"] = OP_AMP_CARET;
+ result["+="] = OP_PLUS_EQ;
+ result["-="] = OP_MINUS_EQ;
+ result["*="] = OP_STAR_EQ;
+ result["/="] = OP_SLASH_EQ;
+ result["%="] = OP_PERCENT_EQ;
+ result["&="] = OP_AMP_EQ;
+ result["|="] = OP_PIPE_EQ;
+ result["^="] = OP_CARET_EQ;
+ result["<<="] = OP_LSHIFT_EQ;
+ result[">>="] = OP_RSHIFT_EQ;
+ result["&^="] = OP_AMP_CARET_EQ;
+ result["&&"] = OP_AMP_AMP;
+ result["||"] = OP_PIPE_PIPE;
+ result["<-"] = OP_LT_MINUS;
+ result["++"] = OP_PLUS_PLUS;
+ result["--"] = OP_MINUS_MINUS;
+ result["=="] = OP_EQ_EQ;
+ result["<"] = OP_LT;
+ result[">"] = OP_GT;
+ result["="] = OP_EQ;
+ result["!"] = OP_BANG;
+ result["!="] = OP_BANG_EQ;
+ result["<="] = OP_LT_EQ;
+ result[">="] = OP_GT_EQ;
+ result[":="] = OP_COLON_EQ;
+ result["..."] = OP_DOTS;
+ result["("] = OP_LPAREN;
+ result["["] = OP_LBRACK;
+ result["{"] = OP_LBRACE;
+ result[","] = OP_COMMA;
+ result["."] = OP_DOT;
+ result[")"] = OP_RPAREN;
+ result["]"] = OP_RBRACK;
+ result["}"] = OP_RBRACE;
+ result[";"] = OP_SEMICOLON;
+ result[":"] = OP_COLON;
+ return &result;
+}
diff --git a/source/Plugins/ExpressionParser/Go/GoLexer.h b/source/Plugins/ExpressionParser/Go/GoLexer.h
new file mode 100644
index 000000000000..e8e1635bab77
--- /dev/null
+++ b/source/Plugins/ExpressionParser/Go/GoLexer.h
@@ -0,0 +1,201 @@
+//===-- GoLexer.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_GoLexer_h
+#define liblldb_GoLexer_h
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringMap.h"
+
+namespace lldb_private
+{
+
+class GoLexer
+{
+ public:
+ explicit GoLexer(const char *src);
+
+ enum TokenType
+ {
+ TOK_EOF,
+ TOK_INVALID,
+ TOK_IDENTIFIER,
+ LIT_INTEGER,
+ LIT_FLOAT,
+ LIT_IMAGINARY,
+ LIT_RUNE,
+ LIT_STRING,
+ KEYWORD_BREAK,
+ KEYWORD_DEFAULT,
+ KEYWORD_FUNC,
+ KEYWORD_INTERFACE,
+ KEYWORD_SELECT,
+ KEYWORD_CASE,
+ KEYWORD_DEFER,
+ KEYWORD_GO,
+ KEYWORD_MAP,
+ KEYWORD_STRUCT,
+ KEYWORD_CHAN,
+ KEYWORD_ELSE,
+ KEYWORD_GOTO,
+ KEYWORD_PACKAGE,
+ KEYWORD_SWITCH,
+ KEYWORD_CONST,
+ KEYWORD_FALLTHROUGH,
+ KEYWORD_IF,
+ KEYWORD_RANGE,
+ KEYWORD_TYPE,
+ KEYWORD_CONTINUE,
+ KEYWORD_FOR,
+ KEYWORD_IMPORT,
+ KEYWORD_RETURN,
+ KEYWORD_VAR,
+ OP_PLUS,
+ OP_MINUS,
+ OP_STAR,
+ OP_SLASH,
+ OP_PERCENT,
+ OP_AMP,
+ OP_PIPE,
+ OP_CARET,
+ OP_LSHIFT,
+ OP_RSHIFT,
+ OP_AMP_CARET,
+ OP_PLUS_EQ,
+ OP_MINUS_EQ,
+ OP_STAR_EQ,
+ OP_SLASH_EQ,
+ OP_PERCENT_EQ,
+ OP_AMP_EQ,
+ OP_PIPE_EQ,
+ OP_CARET_EQ,
+ OP_LSHIFT_EQ,
+ OP_RSHIFT_EQ,
+ OP_AMP_CARET_EQ,
+ OP_AMP_AMP,
+ OP_PIPE_PIPE,
+ OP_LT_MINUS,
+ OP_PLUS_PLUS,
+ OP_MINUS_MINUS,
+ OP_EQ_EQ,
+ OP_LT,
+ OP_GT,
+ OP_EQ,
+ OP_BANG,
+ OP_BANG_EQ,
+ OP_LT_EQ,
+ OP_GT_EQ,
+ OP_COLON_EQ,
+ OP_DOTS,
+ OP_LPAREN,
+ OP_LBRACK,
+ OP_LBRACE,
+ OP_COMMA,
+ OP_DOT,
+ OP_RPAREN,
+ OP_RBRACK,
+ OP_RBRACE,
+ OP_SEMICOLON,
+ OP_COLON,
+ };
+
+ struct Token
+ {
+ explicit Token(TokenType t, llvm::StringRef text) : m_type(t), m_value(text) {}
+ TokenType m_type;
+ llvm::StringRef m_value;
+ };
+
+ const Token &Lex();
+
+ size_t
+ BytesRemaining() const
+ {
+ return m_end - m_src;
+ }
+ llvm::StringRef
+ GetString(int len) const
+ {
+ return llvm::StringRef(m_src, len);
+ }
+
+ static TokenType LookupKeyword(llvm::StringRef id);
+ static llvm::StringRef LookupToken(TokenType t);
+
+ private:
+ bool
+ IsDecimal(char c)
+ {
+ return c >= '0' && c <= '9';
+ }
+ bool
+ IsHexChar(char c)
+ {
+ if (c >= '0' && c <= '9')
+ return true;
+ if (c >= 'A' && c <= 'F')
+ return true;
+ if (c >= 'a' && c <= 'f')
+ return true;
+ return false;
+ }
+ bool
+ IsLetterOrDigit(char c)
+ {
+ if (c >= 'a' && c <= 'z')
+ return true;
+ if (c >= 'A' && c <= 'Z')
+ return true;
+ if (c == '_')
+ return true;
+ if (c >= '0' && c <= '9')
+ return true;
+ // Treat all non-ascii chars as letters for simplicity.
+ return 0 != (c & 0x80);
+ }
+ bool
+ IsWhitespace(char c)
+ {
+ switch (c)
+ {
+ case ' ':
+ case '\t':
+ case '\r':
+ return true;
+ }
+ return false;
+ }
+
+ bool SkipWhitespace();
+ bool SkipComment();
+
+ TokenType InternalLex(bool newline);
+
+ TokenType DoOperator();
+
+ TokenType DoIdent();
+
+ TokenType DoNumber();
+
+ TokenType DoRune();
+
+ TokenType DoString();
+
+ static llvm::StringMap<TokenType> *InitKeywords();
+
+ static llvm::StringMap<TokenType> *m_keywords;
+
+ const char *m_src;
+ const char *m_end;
+ Token m_last_token;
+};
+
+} // namespace lldb_private
+
+#endif
diff --git a/source/Plugins/ExpressionParser/Go/GoParser.cpp b/source/Plugins/ExpressionParser/Go/GoParser.cpp
new file mode 100644
index 000000000000..0f136f7e61dc
--- /dev/null
+++ b/source/Plugins/ExpressionParser/Go/GoParser.cpp
@@ -0,0 +1,1035 @@
+//===-- GoParser.cpp ---------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <vector>
+
+#include "GoParser.h"
+
+#include "lldb/Core/Error.h"
+#include "llvm/ADT/SmallString.h"
+#include "Plugins/ExpressionParser/Go/GoAST.h"
+
+using namespace lldb_private;
+using namespace lldb;
+
+namespace
+{
+llvm::StringRef
+DescribeToken(GoLexer::TokenType t)
+{
+ switch (t)
+ {
+ case GoLexer::TOK_EOF:
+ return "<eof>";
+ case GoLexer::TOK_IDENTIFIER:
+ return "identifier";
+ case GoLexer::LIT_FLOAT:
+ return "float";
+ case GoLexer::LIT_IMAGINARY:
+ return "imaginary";
+ case GoLexer::LIT_INTEGER:
+ return "integer";
+ case GoLexer::LIT_RUNE:
+ return "rune";
+ case GoLexer::LIT_STRING:
+ return "string";
+ default:
+ return GoLexer::LookupToken(t);
+ }
+}
+} // namespace
+
+class GoParser::Rule
+{
+ public:
+ Rule(llvm::StringRef name, GoParser *p) : m_name(name), m_parser(p), m_pos(p->m_pos) {}
+
+ std::nullptr_t
+ error()
+ {
+ if (!m_parser->m_failed)
+ {
+ // Set m_error in case this is the top level.
+ if (m_parser->m_last_tok == GoLexer::TOK_INVALID)
+ m_parser->m_error = m_parser->m_last;
+ else
+ m_parser->m_error = DescribeToken(m_parser->m_last_tok);
+ // And set m_last in case it isn't.
+ m_parser->m_last = m_name;
+ m_parser->m_last_tok = GoLexer::TOK_INVALID;
+ m_parser->m_pos = m_pos;
+ }
+ return nullptr;
+ }
+
+ private:
+ llvm::StringRef m_name;
+ GoParser *m_parser;
+ size_t m_pos;
+};
+
+GoParser::GoParser(const char *src) : m_lexer(src), m_pos(0), m_failed(false)
+{
+}
+
+GoASTStmt *
+GoParser::Statement()
+{
+ Rule r("Statement", this);
+ GoLexer::TokenType t = peek();
+ GoASTStmt *ret = nullptr;
+ switch (t)
+ {
+ case GoLexer::TOK_EOF:
+ case GoLexer::OP_SEMICOLON:
+ case GoLexer::OP_RPAREN:
+ case GoLexer::OP_RBRACE:
+ case GoLexer::TOK_INVALID:
+ return EmptyStmt();
+ case GoLexer::OP_LBRACE:
+ return Block();
+
+ /* TODO:
+ case GoLexer::KEYWORD_GO:
+ return GoStmt();
+ case GoLexer::KEYWORD_RETURN:
+ return ReturnStmt();
+ case GoLexer::KEYWORD_BREAK:
+ case GoLexer::KEYWORD_CONTINUE:
+ case GoLexer::KEYWORD_GOTO:
+ case GoLexer::KEYWORD_FALLTHROUGH:
+ return BranchStmt();
+ case GoLexer::KEYWORD_IF:
+ return IfStmt();
+ case GoLexer::KEYWORD_SWITCH:
+ return SwitchStmt();
+ case GoLexer::KEYWORD_SELECT:
+ return SelectStmt();
+ case GoLexer::KEYWORD_FOR:
+ return ForStmt();
+ case GoLexer::KEYWORD_DEFER:
+ return DeferStmt();
+ case GoLexer::KEYWORD_CONST:
+ case GoLexer::KEYWORD_TYPE:
+ case GoLexer::KEYWORD_VAR:
+ return DeclStmt();
+ case GoLexer::TOK_IDENTIFIER:
+ if ((ret = LabeledStmt()) ||
+ (ret = ShortVarDecl()))
+ {
+ return ret;
+ }
+*/
+ default:
+ break;
+ }
+ GoASTExpr *expr = Expression();
+ if (expr == nullptr)
+ return r.error();
+ if (/*(ret = SendStmt(expr)) ||*/
+ (ret = IncDecStmt(expr)) || (ret = Assignment(expr)) || (ret = ExpressionStmt(expr)))
+ {
+ return ret;
+ }
+ delete expr;
+ return r.error();
+}
+
+GoASTStmt *
+GoParser::ExpressionStmt(GoASTExpr *e)
+{
+ if (Semicolon())
+ return new GoASTExprStmt(e);
+ return nullptr;
+}
+
+GoASTStmt *
+GoParser::IncDecStmt(GoASTExpr *e)
+{
+ Rule r("IncDecStmt", this);
+ if (match(GoLexer::OP_PLUS_PLUS))
+ return Semicolon() ? new GoASTIncDecStmt(e, GoLexer::OP_PLUS_PLUS) : r.error();
+ if (match(GoLexer::OP_MINUS_MINUS))
+ return Semicolon() ? new GoASTIncDecStmt(e, GoLexer::OP_MINUS_MINUS) : r.error();
+ return nullptr;
+}
+
+GoASTStmt *
+GoParser::Assignment(lldb_private::GoASTExpr *e)
+{
+ Rule r("Assignment", this);
+ std::vector<std::unique_ptr<GoASTExpr>> lhs;
+ for (GoASTExpr *l = MoreExpressionList(); l; l = MoreExpressionList())
+ lhs.push_back(std::unique_ptr<GoASTExpr>(l));
+ switch (peek())
+ {
+ case GoLexer::OP_EQ:
+ case GoLexer::OP_PLUS_EQ:
+ case GoLexer::OP_MINUS_EQ:
+ case GoLexer::OP_PIPE_EQ:
+ case GoLexer::OP_CARET_EQ:
+ case GoLexer::OP_STAR_EQ:
+ case GoLexer::OP_SLASH_EQ:
+ case GoLexer::OP_PERCENT_EQ:
+ case GoLexer::OP_LSHIFT_EQ:
+ case GoLexer::OP_RSHIFT_EQ:
+ case GoLexer::OP_AMP_EQ:
+ case GoLexer::OP_AMP_CARET_EQ:
+ break;
+ default:
+ return r.error();
+ }
+ // We don't want to own e until we know this is an assignment.
+ std::unique_ptr<GoASTAssignStmt> stmt(new GoASTAssignStmt(false));
+ stmt->AddLhs(e);
+ for (auto &l : lhs)
+ stmt->AddLhs(l.release());
+ for (GoASTExpr *r = Expression(); r; r = MoreExpressionList())
+ stmt->AddRhs(r);
+ if (!Semicolon() || stmt->NumRhs() == 0)
+ return new GoASTBadStmt;
+ return stmt.release();
+}
+
+GoASTStmt *
+GoParser::EmptyStmt()
+{
+ if (match(GoLexer::TOK_EOF))
+ return nullptr;
+ if (Semicolon())
+ return new GoASTEmptyStmt;
+ return nullptr;
+}
+
+GoASTStmt *
+GoParser::GoStmt()
+{
+ if (match(GoLexer::KEYWORD_GO))
+ {
+ if (GoASTCallExpr *e = llvm::dyn_cast_or_null<GoASTCallExpr>(Expression()))
+ {
+ return FinishStmt(new GoASTGoStmt(e));
+ }
+ m_last = "call expression";
+ m_failed = true;
+ return new GoASTBadStmt();
+ }
+ return nullptr;
+}
+
+GoASTStmt *
+GoParser::ReturnStmt()
+{
+ if (match(GoLexer::KEYWORD_RETURN))
+ {
+ std::unique_ptr<GoASTReturnStmt> r(new GoASTReturnStmt());
+ for (GoASTExpr *e = Expression(); e; e = MoreExpressionList())
+ r->AddResults(e);
+ return FinishStmt(r.release());
+ }
+ return nullptr;
+}
+
+GoASTStmt *
+GoParser::BranchStmt()
+{
+ GoLexer::Token *tok;
+ if ((tok = match(GoLexer::KEYWORD_BREAK)) || (tok = match(GoLexer::KEYWORD_CONTINUE)) ||
+ (tok = match(GoLexer::KEYWORD_GOTO)))
+ {
+ auto *e = Identifier();
+ if (tok->m_type == GoLexer::KEYWORD_GOTO && !e)
+ return syntaxerror();
+ return FinishStmt(new GoASTBranchStmt(e, tok->m_type));
+ }
+ if ((tok = match(GoLexer::KEYWORD_FALLTHROUGH)))
+ return FinishStmt(new GoASTBranchStmt(nullptr, tok->m_type));
+
+ return nullptr;
+}
+
+GoASTIdent *
+GoParser::Identifier()
+{
+ if (auto *tok = match(GoLexer::TOK_IDENTIFIER))
+ return new GoASTIdent(*tok);
+ return nullptr;
+}
+
+GoASTExpr *
+GoParser::MoreExpressionList()
+{
+ if (match(GoLexer::OP_COMMA))
+ {
+ auto *e = Expression();
+ if (!e)
+ return syntaxerror();
+ return e;
+ }
+ return nullptr;
+}
+
+GoASTIdent *
+GoParser::MoreIdentifierList()
+{
+ if (match(GoLexer::OP_COMMA))
+ {
+ auto *i = Identifier();
+ if (!i)
+ return syntaxerror();
+ return i;
+ }
+ return nullptr;
+}
+
+GoASTExpr *
+GoParser::Expression()
+{
+ Rule r("Expression", this);
+ if (GoASTExpr *ret = OrExpr())
+ return ret;
+ return r.error();
+}
+
+GoASTExpr *
+GoParser::UnaryExpr()
+{
+ switch (peek())
+ {
+ case GoLexer::OP_PLUS:
+ case GoLexer::OP_MINUS:
+ case GoLexer::OP_BANG:
+ case GoLexer::OP_CARET:
+ case GoLexer::OP_STAR:
+ case GoLexer::OP_AMP:
+ case GoLexer::OP_LT_MINUS:
+ {
+ const GoLexer::Token t = next();
+ if (GoASTExpr *e = UnaryExpr())
+ {
+ if (t.m_type == GoLexer::OP_STAR)
+ return new GoASTStarExpr(e);
+ else
+ return new GoASTUnaryExpr(t.m_type, e);
+ }
+ return syntaxerror();
+ }
+ default:
+ return PrimaryExpr();
+ }
+}
+
+GoASTExpr *
+GoParser::OrExpr()
+{
+ std::unique_ptr<GoASTExpr> l(AndExpr());
+ if (l)
+ {
+ while (match(GoLexer::OP_PIPE_PIPE))
+ {
+ GoASTExpr *r = AndExpr();
+ if (r)
+ l.reset(new GoASTBinaryExpr(l.release(), r, GoLexer::OP_PIPE_PIPE));
+ else
+ return syntaxerror();
+ }
+ return l.release();
+ }
+ return nullptr;
+}
+
+GoASTExpr *
+GoParser::AndExpr()
+{
+ std::unique_ptr<GoASTExpr> l(RelExpr());
+ if (l)
+ {
+ while (match(GoLexer::OP_AMP_AMP))
+ {
+ GoASTExpr *r = RelExpr();
+ if (r)
+ l.reset(new GoASTBinaryExpr(l.release(), r, GoLexer::OP_AMP_AMP));
+ else
+ return syntaxerror();
+ }
+ return l.release();
+ }
+ return nullptr;
+}
+
+GoASTExpr *
+GoParser::RelExpr()
+{
+ std::unique_ptr<GoASTExpr> l(AddExpr());
+ if (l)
+ {
+ for (GoLexer::Token *t; (t = match(GoLexer::OP_EQ_EQ)) || (t = match(GoLexer::OP_BANG_EQ)) ||
+ (t = match(GoLexer::OP_LT)) || (t = match(GoLexer::OP_LT_EQ)) ||
+ (t = match(GoLexer::OP_GT)) || (t = match(GoLexer::OP_GT_EQ));)
+ {
+ GoLexer::TokenType op = t->m_type;
+ GoASTExpr *r = AddExpr();
+ if (r)
+ l.reset(new GoASTBinaryExpr(l.release(), r, op));
+ else
+ return syntaxerror();
+ }
+ return l.release();
+ }
+ return nullptr;
+}
+
+GoASTExpr *
+GoParser::AddExpr()
+{
+ std::unique_ptr<GoASTExpr> l(MulExpr());
+ if (l)
+ {
+ for (GoLexer::Token *t; (t = match(GoLexer::OP_PLUS)) || (t = match(GoLexer::OP_MINUS)) ||
+ (t = match(GoLexer::OP_PIPE)) || (t = match(GoLexer::OP_CARET));)
+ {
+ GoLexer::TokenType op = t->m_type;
+ GoASTExpr *r = MulExpr();
+ if (r)
+ l.reset(new GoASTBinaryExpr(l.release(), r, op));
+ else
+ return syntaxerror();
+ }
+ return l.release();
+ }
+ return nullptr;
+}
+
+GoASTExpr *
+GoParser::MulExpr()
+{
+ std::unique_ptr<GoASTExpr> l(UnaryExpr());
+ if (l)
+ {
+ for (GoLexer::Token *t; (t = match(GoLexer::OP_STAR)) || (t = match(GoLexer::OP_SLASH)) ||
+ (t = match(GoLexer::OP_PERCENT)) || (t = match(GoLexer::OP_LSHIFT)) ||
+ (t = match(GoLexer::OP_RSHIFT)) || (t = match(GoLexer::OP_AMP)) ||
+ (t = match(GoLexer::OP_AMP_CARET));)
+ {
+ GoLexer::TokenType op = t->m_type;
+ GoASTExpr *r = UnaryExpr();
+ if (r)
+ l.reset(new GoASTBinaryExpr(l.release(), r, op));
+ else
+ return syntaxerror();
+ }
+ return l.release();
+ }
+ return nullptr;
+}
+
+GoASTExpr *
+GoParser::PrimaryExpr()
+{
+ GoASTExpr *l;
+ GoASTExpr *r;
+ (l = Conversion()) || (l = Operand());
+ if (!l)
+ return nullptr;
+ while ((r = Selector(l)) || (r = IndexOrSlice(l)) || (r = TypeAssertion(l)) || (r = Arguments(l)))
+ {
+ l = r;
+ }
+ return l;
+}
+
+GoASTExpr *
+GoParser::Operand()
+{
+ GoLexer::Token *lit;
+ if ((lit = match(GoLexer::LIT_INTEGER)) || (lit = match(GoLexer::LIT_FLOAT)) ||
+ (lit = match(GoLexer::LIT_IMAGINARY)) || (lit = match(GoLexer::LIT_RUNE)) || (lit = match(GoLexer::LIT_STRING)))
+ return new GoASTBasicLit(*lit);
+ if (match(GoLexer::OP_LPAREN))
+ {
+ GoASTExpr *e;
+ if (!((e = Expression()) && match(GoLexer::OP_RPAREN)))
+ return syntaxerror();
+ return e;
+ }
+ // MethodExpr should be handled by Selector
+ if (GoASTExpr *e = CompositeLit())
+ return e;
+ if (GoASTExpr *n = Name())
+ return n;
+ return FunctionLit();
+}
+
+GoASTExpr *
+GoParser::FunctionLit()
+{
+ if (!match(GoLexer::KEYWORD_FUNC))
+ return nullptr;
+ auto *sig = Signature();
+ if (!sig)
+ return syntaxerror();
+ auto *body = Block();
+ if (!body)
+ {
+ delete sig;
+ return syntaxerror();
+ }
+ return new GoASTFuncLit(sig, body);
+}
+
+GoASTBlockStmt *
+GoParser::Block()
+{
+ if (!match(GoLexer::OP_LBRACE))
+ return nullptr;
+ std::unique_ptr<GoASTBlockStmt> block(new GoASTBlockStmt);
+ for (auto *s = Statement(); s; s = Statement())
+ block->AddList(s);
+ if (!match(GoLexer::OP_RBRACE))
+ return syntaxerror();
+ return block.release();
+}
+
+GoASTExpr *
+GoParser::CompositeLit()
+{
+ Rule r("CompositeLit", this);
+ GoASTExpr *type;
+ (type = StructType()) || (type = ArrayOrSliceType(true)) || (type = MapType()) || (type = Name());
+ if (!type)
+ return r.error();
+ GoASTCompositeLit *lit = LiteralValue();
+ if (!lit)
+ return r.error();
+ lit->SetType(type);
+ return lit;
+}
+
+GoASTCompositeLit *
+GoParser::LiteralValue()
+{
+ if (!match(GoLexer::OP_LBRACE))
+ return nullptr;
+ std::unique_ptr<GoASTCompositeLit> lit(new GoASTCompositeLit);
+ for (GoASTExpr *e = Element(); e; e = Element())
+ {
+ lit->AddElts(e);
+ if (!match(GoLexer::OP_COMMA))
+ break;
+ }
+ if (!mustMatch(GoLexer::OP_RBRACE))
+ return nullptr;
+ return lit.release();
+}
+
+GoASTExpr *
+GoParser::Element()
+{
+ GoASTExpr *key;
+ if (!((key = Expression()) || (key = LiteralValue())))
+ return nullptr;
+ if (!match(GoLexer::OP_COLON))
+ return key;
+ GoASTExpr *value;
+ if ((value = Expression()) || (value = LiteralValue()))
+ return new GoASTKeyValueExpr(key, value);
+ delete key;
+ return syntaxerror();
+}
+
+GoASTExpr *
+GoParser::Selector(GoASTExpr *e)
+{
+ Rule r("Selector", this);
+ if (match(GoLexer::OP_DOT))
+ {
+ if (auto *name = Identifier())
+ return new GoASTSelectorExpr(e, name);
+ }
+ return r.error();
+}
+
+GoASTExpr *
+GoParser::IndexOrSlice(GoASTExpr *e)
+{
+ Rule r("IndexOrSlice", this);
+ if (match(GoLexer::OP_LBRACK))
+ {
+ std::unique_ptr<GoASTExpr> i1(Expression()), i2, i3;
+ bool slice = false;
+ if (match(GoLexer::OP_COLON))
+ {
+ slice = true;
+ i2.reset(Expression());
+ if (i2 && match(GoLexer::OP_COLON))
+ {
+ i3.reset(Expression());
+ if (!i3)
+ return syntaxerror();
+ }
+ }
+ if (!(slice || i1))
+ return syntaxerror();
+ if (!mustMatch(GoLexer::OP_RBRACK))
+ return nullptr;
+ if (slice)
+ {
+ bool slice3 = i3.get();
+ return new GoASTSliceExpr(e, i1.release(), i2.release(), i3.release(), slice3);
+ }
+ return new GoASTIndexExpr(e, i1.release());
+ }
+ return r.error();
+}
+
+GoASTExpr *
+GoParser::TypeAssertion(GoASTExpr *e)
+{
+ Rule r("TypeAssertion", this);
+ if (match(GoLexer::OP_DOT) && match(GoLexer::OP_LPAREN))
+ {
+ if (auto *t = Type())
+ {
+ if (!mustMatch(GoLexer::OP_RPAREN))
+ return nullptr;
+ return new GoASTTypeAssertExpr(e, t);
+ }
+ return syntaxerror();
+ }
+ return r.error();
+}
+
+GoASTExpr *
+GoParser::Arguments(GoASTExpr *e)
+{
+ if (match(GoLexer::OP_LPAREN))
+ {
+ std::unique_ptr<GoASTCallExpr> call(new GoASTCallExpr(false));
+ GoASTExpr *arg;
+ // ( ExpressionList | Type [ "," ExpressionList ] )
+ for ((arg = Expression()) || (arg = Type()); arg; arg = MoreExpressionList())
+ {
+ call->AddArgs(arg);
+ }
+ if (match(GoLexer::OP_DOTS))
+ call->SetEllipsis(true);
+
+ // Eat trailing comma
+ match(GoLexer::OP_COMMA);
+
+ if (!mustMatch(GoLexer::OP_RPAREN))
+ return nullptr;
+ call->SetFun(e);
+ return call.release();
+ }
+ return nullptr;
+}
+
+GoASTExpr *
+GoParser::Conversion()
+{
+ Rule r("Conversion", this);
+ if (GoASTExpr *t = Type2())
+ {
+ if (match(GoLexer::OP_LPAREN))
+ {
+ GoASTExpr *v = Expression();
+ if (!v)
+ return syntaxerror();
+ match(GoLexer::OP_COMMA);
+ if (!mustMatch(GoLexer::OP_RPAREN))
+ return r.error();
+ GoASTCallExpr *call = new GoASTCallExpr(false);
+ call->SetFun(t);
+ call->AddArgs(v);
+ return call;
+ }
+ }
+ return r.error();
+}
+
+GoASTExpr *
+GoParser::Type2()
+{
+ switch (peek())
+ {
+ case GoLexer::OP_LBRACK:
+ return ArrayOrSliceType(false);
+ case GoLexer::KEYWORD_STRUCT:
+ return StructType();
+ case GoLexer::KEYWORD_FUNC:
+ return FunctionType();
+ case GoLexer::KEYWORD_INTERFACE:
+ return InterfaceType();
+ case GoLexer::KEYWORD_MAP:
+ return MapType();
+ case GoLexer::KEYWORD_CHAN:
+ return ChanType2();
+ default:
+ return nullptr;
+ }
+}
+
+GoASTExpr *
+GoParser::ArrayOrSliceType(bool allowEllipsis)
+{
+ Rule r("ArrayType", this);
+ if (match(GoLexer::OP_LBRACK))
+ {
+ std::unique_ptr<GoASTExpr> len;
+ if (allowEllipsis && match(GoLexer::OP_DOTS))
+ {
+ len.reset(new GoASTEllipsis(nullptr));
+ }
+ else
+ {
+ len.reset(Expression());
+ }
+
+ if (!match(GoLexer::OP_RBRACK))
+ return r.error();
+ GoASTExpr *elem = Type();
+ if (!elem)
+ return syntaxerror();
+ return new GoASTArrayType(len.release(), elem);
+ }
+ return r.error();
+}
+
+GoASTExpr *
+GoParser::StructType()
+{
+ if (!(match(GoLexer::KEYWORD_STRUCT) && mustMatch(GoLexer::OP_LBRACE)))
+ return nullptr;
+ std::unique_ptr<GoASTFieldList> fields(new GoASTFieldList);
+ while (auto *field = FieldDecl())
+ fields->AddList(field);
+ if (!mustMatch(GoLexer::OP_RBRACE))
+ return nullptr;
+ return new GoASTStructType(fields.release());
+}
+
+GoASTField *
+GoParser::FieldDecl()
+{
+ std::unique_ptr<GoASTField> f(new GoASTField);
+ GoASTExpr *t = FieldNamesAndType(f.get());
+ if (!t)
+ t = AnonymousFieldType();
+ if (!t)
+ return nullptr;
+
+ if (auto *tok = match(GoLexer::LIT_STRING))
+ f->SetTag(new GoASTBasicLit(*tok));
+ if (!Semicolon())
+ return syntaxerror();
+ return f.release();
+}
+
+GoASTExpr *
+GoParser::FieldNamesAndType(GoASTField *field)
+{
+ Rule r("FieldNames", this);
+ for (auto *id = Identifier(); id; id = MoreIdentifierList())
+ field->AddNames(id);
+ if (m_failed)
+ return nullptr;
+ GoASTExpr *t = Type();
+ if (t)
+ return t;
+ return r.error();
+}
+
+GoASTExpr *
+GoParser::AnonymousFieldType()
+{
+ bool pointer = match(GoLexer::OP_STAR);
+ GoASTExpr *t = Type();
+ if (!t)
+ return nullptr;
+ if (pointer)
+ return new GoASTStarExpr(t);
+ return t;
+}
+
+GoASTExpr *
+GoParser::FunctionType()
+{
+ if (!match(GoLexer::KEYWORD_FUNC))
+ return nullptr;
+ return Signature();
+}
+
+GoASTFuncType *
+GoParser::Signature()
+{
+ auto *params = Params();
+ if (!params)
+ return syntaxerror();
+ auto *result = Params();
+ if (!result)
+ {
+ if (auto *t = Type())
+ {
+ result = new GoASTFieldList;
+ auto *f = new GoASTField;
+ f->SetType(t);
+ result->AddList(f);
+ }
+ }
+ return new GoASTFuncType(params, result);
+}
+
+GoASTFieldList *
+GoParser::Params()
+{
+ if (!match(GoLexer::OP_LPAREN))
+ return nullptr;
+ std::unique_ptr<GoASTFieldList> l(new GoASTFieldList);
+ while (GoASTField *p = ParamDecl())
+ {
+ l->AddList(p);
+ if (!match(GoLexer::OP_COMMA))
+ break;
+ }
+ if (!mustMatch(GoLexer::OP_RPAREN))
+ return nullptr;
+ return l.release();
+}
+
+GoASTField *
+GoParser::ParamDecl()
+{
+ std::unique_ptr<GoASTField> field(new GoASTField);
+ GoASTIdent *id = Identifier();
+ if (id)
+ {
+ // Try `IdentifierList [ "..." ] Type`.
+ // If that fails, backtrack and try `[ "..." ] Type`.
+ Rule r("NamedParam", this);
+ for (; id; id = MoreIdentifierList())
+ field->AddNames(id);
+ GoASTExpr *t = ParamType();
+ if (t)
+ {
+ field->SetType(t);
+ return field.release();
+ }
+ field.reset(new GoASTField);
+ r.error();
+ }
+ GoASTExpr *t = ParamType();
+ if (t)
+ {
+ field->SetType(t);
+ return field.release();
+ }
+ return nullptr;
+}
+
+GoASTExpr *
+GoParser::ParamType()
+{
+ bool dots = match(GoLexer::OP_DOTS);
+ GoASTExpr *t = Type();
+ if (!dots)
+ return t;
+ if (!t)
+ return syntaxerror();
+ return new GoASTEllipsis(t);
+}
+
+GoASTExpr *
+GoParser::InterfaceType()
+{
+ if (!match(GoLexer::KEYWORD_INTERFACE) || !mustMatch(GoLexer::OP_LBRACE))
+ return nullptr;
+ std::unique_ptr<GoASTFieldList> methods(new GoASTFieldList);
+ while (true)
+ {
+ Rule r("MethodSpec", this);
+ // ( identifier Signature | TypeName ) ;
+ std::unique_ptr<GoASTIdent> id(Identifier());
+ if (!id)
+ break;
+ GoASTExpr *type = Signature();
+ if (!type)
+ {
+ r.error();
+ id.reset();
+ type = Name();
+ }
+ if (!Semicolon())
+ return syntaxerror();
+ auto *f = new GoASTField;
+ if (id)
+ f->AddNames(id.release());
+ f->SetType(type);
+ methods->AddList(f);
+ }
+ if (!mustMatch(GoLexer::OP_RBRACE))
+ return nullptr;
+ return new GoASTInterfaceType(methods.release());
+}
+
+GoASTExpr *
+GoParser::MapType()
+{
+ if (!(match(GoLexer::KEYWORD_MAP) && mustMatch(GoLexer::OP_LBRACK)))
+ return nullptr;
+ std::unique_ptr<GoASTExpr> key(Type());
+ if (!key)
+ return syntaxerror();
+ if (!mustMatch(GoLexer::OP_RBRACK))
+ return nullptr;
+ auto *elem = Type();
+ if (!elem)
+ return syntaxerror();
+ return new GoASTMapType(key.release(), elem);
+}
+
+GoASTExpr *
+GoParser::ChanType()
+{
+ Rule r("chan", this);
+ if (match(GoLexer::OP_LT_MINUS))
+ {
+ if (match(GoLexer::KEYWORD_CHAN))
+ {
+ auto *elem = Type();
+ if (!elem)
+ return syntaxerror();
+ return new GoASTChanType(GoASTNode::eChanRecv, elem);
+ }
+ return r.error();
+ }
+ return ChanType2();
+}
+
+GoASTExpr *
+GoParser::ChanType2()
+{
+ if (!match(GoLexer::KEYWORD_CHAN))
+ return nullptr;
+ auto dir = GoASTNode::eChanBidir;
+ if (match(GoLexer::OP_LT_MINUS))
+ dir = GoASTNode::eChanSend;
+ auto *elem = Type();
+ if (!elem)
+ return syntaxerror();
+ return new GoASTChanType(dir, elem);
+}
+
+GoASTExpr *
+GoParser::Type()
+{
+ if (GoASTExpr *t = Type2())
+ return t;
+ if (GoASTExpr *t = Name())
+ return t;
+ if (GoASTExpr *t = ChanType())
+ return t;
+ if (match(GoLexer::OP_STAR))
+ {
+ GoASTExpr *t = Type();
+ if (!t)
+ return syntaxerror();
+ return new GoASTStarExpr(t);
+ }
+ if (match(GoLexer::OP_LPAREN))
+ {
+ std::unique_ptr<GoASTExpr> t(Type());
+ if (!t || !match(GoLexer::OP_RPAREN))
+ return syntaxerror();
+ return t.release();
+ }
+ return nullptr;
+}
+
+bool
+GoParser::Semicolon()
+{
+ if (match(GoLexer::OP_SEMICOLON))
+ return true;
+ switch (peek())
+ {
+ case GoLexer::OP_RPAREN:
+ case GoLexer::OP_RBRACE:
+ case GoLexer::TOK_EOF:
+ return true;
+ default:
+ return false;
+ }
+}
+
+GoASTExpr *
+GoParser::Name()
+{
+ if (auto *id = Identifier())
+ {
+ if (GoASTExpr *qual = QualifiedIdent(id))
+ return qual;
+ return id;
+ }
+ return nullptr;
+}
+
+GoASTExpr *
+GoParser::QualifiedIdent(lldb_private::GoASTIdent *p)
+{
+ Rule r("QualifiedIdent", this);
+ llvm::SmallString<32> path(p->GetName().m_value);
+ GoLexer::Token *next;
+ bool have_slashes = false;
+ // LLDB extension: support full/package/path.name
+ while (match(GoLexer::OP_SLASH) && (next = match(GoLexer::TOK_IDENTIFIER)))
+ {
+ have_slashes = true;
+ path.append("/");
+ path.append(next->m_value);
+ }
+ if (match(GoLexer::OP_DOT))
+ {
+ auto *name = Identifier();
+ if (name)
+ {
+ if (have_slashes)
+ {
+ p->SetName(GoLexer::Token(GoLexer::TOK_IDENTIFIER, CopyString(path)));
+ }
+ return new GoASTSelectorExpr(p, name);
+ }
+ }
+ return r.error();
+}
+
+llvm::StringRef
+GoParser::CopyString(llvm::StringRef s)
+{
+ return m_strings.insert(std::make_pair(s, 'x')).first->getKey();
+}
+
+void
+GoParser::GetError(Error &error)
+{
+ llvm::StringRef want;
+ if (m_failed)
+ want = m_last_tok == GoLexer::TOK_INVALID ? DescribeToken(m_last_tok) : m_last;
+ else
+ want = m_error;
+ size_t len = m_lexer.BytesRemaining();
+ if (len > 10)
+ len = 10;
+ llvm::StringRef got;
+ if (len == 0)
+ got = "<eof>";
+ else
+ got = m_lexer.GetString(len);
+ error.SetErrorStringWithFormat("Syntax error: expected %s before '%s'.", want.str().c_str(), got.str().c_str());
+}
diff --git a/source/Plugins/ExpressionParser/Go/GoParser.h b/source/Plugins/ExpressionParser/Go/GoParser.h
new file mode 100644
index 000000000000..9ceb670ccd11
--- /dev/null
+++ b/source/Plugins/ExpressionParser/Go/GoParser.h
@@ -0,0 +1,165 @@
+//===-- GoParser.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_GoParser_h
+#define liblldb_GoParser_h
+
+#include "lldb/lldb-private.h"
+#include "Plugins/ExpressionParser/Go/GoAST.h"
+#include "Plugins/ExpressionParser/Go/GoLexer.h"
+
+namespace lldb_private
+{
+class GoParser
+{
+ public:
+ explicit GoParser(const char *src);
+
+ GoASTStmt *Statement();
+
+ GoASTStmt *GoStmt();
+ GoASTStmt *ReturnStmt();
+ GoASTStmt *BranchStmt();
+ GoASTStmt *EmptyStmt();
+ GoASTStmt *ExpressionStmt(GoASTExpr *e);
+ GoASTStmt *IncDecStmt(GoASTExpr *e);
+ GoASTStmt *Assignment(GoASTExpr *e);
+ GoASTBlockStmt *Block();
+
+ GoASTExpr *MoreExpressionList(); // ["," Expression]
+ GoASTIdent *MoreIdentifierList(); // ["," Identifier]
+
+ GoASTExpr *Expression();
+ GoASTExpr *UnaryExpr();
+ GoASTExpr *OrExpr();
+ GoASTExpr *AndExpr();
+ GoASTExpr *RelExpr();
+ GoASTExpr *AddExpr();
+ GoASTExpr *MulExpr();
+ GoASTExpr *PrimaryExpr();
+ GoASTExpr *Operand();
+ GoASTExpr *Conversion();
+
+ GoASTExpr *Selector(GoASTExpr *e);
+ GoASTExpr *IndexOrSlice(GoASTExpr *e);
+ GoASTExpr *TypeAssertion(GoASTExpr *e);
+ GoASTExpr *Arguments(GoASTExpr *e);
+
+ GoASTExpr *Type();
+ GoASTExpr *Type2();
+ GoASTExpr *ArrayOrSliceType(bool allowEllipsis);
+ GoASTExpr *StructType();
+ GoASTExpr *FunctionType();
+ GoASTExpr *InterfaceType();
+ GoASTExpr *MapType();
+ GoASTExpr *ChanType();
+ GoASTExpr *ChanType2();
+
+ GoASTExpr *Name();
+ GoASTExpr *QualifiedIdent(GoASTIdent *p);
+ GoASTIdent *Identifier();
+
+ GoASTField *FieldDecl();
+ GoASTExpr *AnonymousFieldType();
+ GoASTExpr *FieldNamesAndType(GoASTField *f);
+
+ GoASTFieldList *Params();
+ GoASTField *ParamDecl();
+ GoASTExpr *ParamType();
+ GoASTFuncType *Signature();
+ GoASTExpr *CompositeLit();
+ GoASTExpr *FunctionLit();
+ GoASTExpr *Element();
+ GoASTCompositeLit *LiteralValue();
+
+ bool
+ Failed() const
+ {
+ return m_failed;
+ }
+ bool
+ AtEOF() const
+ {
+ return m_lexer.BytesRemaining() == 0 && m_pos == m_tokens.size();
+ }
+
+ void GetError(Error &error);
+
+ private:
+ class Rule;
+ friend class Rule;
+
+ std::nullptr_t
+ syntaxerror()
+ {
+ m_failed = true;
+ return nullptr;
+ }
+ GoLexer::Token &
+ next()
+ {
+ if (m_pos >= m_tokens.size())
+ {
+ if (m_pos != 0 &&
+ (m_tokens.back().m_type == GoLexer::TOK_EOF || m_tokens.back().m_type == GoLexer::TOK_INVALID))
+ return m_tokens.back();
+ m_pos = m_tokens.size();
+ m_tokens.push_back(m_lexer.Lex());
+ }
+ return m_tokens[m_pos++];
+ }
+ GoLexer::TokenType
+ peek()
+ {
+ GoLexer::Token &tok = next();
+ --m_pos;
+ return tok.m_type;
+ }
+ GoLexer::Token *
+ match(GoLexer::TokenType t)
+ {
+ GoLexer::Token &tok = next();
+ if (tok.m_type == t)
+ return &tok;
+ --m_pos;
+ m_last_tok = t;
+ return nullptr;
+ }
+ GoLexer::Token *
+ mustMatch(GoLexer::TokenType t)
+ {
+ GoLexer::Token *tok = match(t);
+ if (tok)
+ return tok;
+ return syntaxerror();
+ }
+ bool Semicolon();
+
+ GoASTStmt *
+ FinishStmt(GoASTStmt *s)
+ {
+ if (!Semicolon())
+ m_failed = true;
+ return s;
+ }
+
+ llvm::StringRef CopyString(llvm::StringRef s);
+
+ GoLexer m_lexer;
+ std::vector<GoLexer::Token> m_tokens;
+ size_t m_pos;
+ llvm::StringRef m_error;
+ llvm::StringRef m_last;
+ GoLexer::TokenType m_last_tok;
+ llvm::StringMap<uint8_t> m_strings;
+ bool m_failed;
+};
+}
+
+#endif
diff --git a/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp b/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
new file mode 100644
index 000000000000..3f12a2b6255b
--- /dev/null
+++ b/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
@@ -0,0 +1,756 @@
+//===-- GoUserExpression.cpp ------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C Includes
+#include <stdio.h>
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+// C++ Includes
+#include <cstdlib>
+#include <memory>
+#include <string>
+#include <vector>
+
+// Other libraries and framework includes
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringMap.h"
+
+// Project includes
+#include "GoUserExpression.h"
+
+#include "lldb/lldb-private.h"
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/DataEncoder.h"
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/StreamFile.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/Core/ValueObjectRegister.h"
+#include "lldb/Expression/ExpressionVariable.h"
+#include "lldb/Symbol/TypeList.h"
+#include "lldb/Symbol/GoASTContext.h"
+#include "lldb/Symbol/VariableList.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/ThreadPlan.h"
+#include "lldb/Target/ThreadPlanCallUserExpression.h"
+
+#include "Plugins/ExpressionParser/Go/GoAST.h"
+#include "Plugins/ExpressionParser/Go/GoParser.h"
+
+using namespace lldb_private;
+using namespace lldb;
+
+class GoUserExpression::GoInterpreter
+{
+ public:
+ GoInterpreter(ExecutionContext &exe_ctx, const char *expr)
+ : m_exe_ctx(exe_ctx), m_frame(exe_ctx.GetFrameSP()), m_parser(expr)
+ {
+ if (m_frame)
+ {
+ const SymbolContext &ctx = m_frame->GetSymbolContext(eSymbolContextFunction);
+ ConstString fname = ctx.GetFunctionName();
+ if (fname.GetLength() > 0)
+ {
+ size_t dot = fname.GetStringRef().find('.');
+ if (dot != llvm::StringRef::npos)
+ m_package = llvm::StringRef(fname.AsCString(), dot);
+ }
+ }
+ }
+
+ void
+ set_use_dynamic(DynamicValueType use_dynamic)
+ {
+ m_use_dynamic = use_dynamic;
+ }
+
+ bool Parse();
+ lldb::ValueObjectSP Evaluate(ExecutionContext &exe_ctx);
+ lldb::ValueObjectSP EvaluateStatement(const GoASTStmt *s);
+ lldb::ValueObjectSP EvaluateExpr(const GoASTExpr *e);
+
+ ValueObjectSP
+ VisitBadExpr(const GoASTBadExpr *e)
+ {
+ m_parser.GetError(m_error);
+ return nullptr;
+ }
+
+ ValueObjectSP VisitParenExpr(const GoASTParenExpr *e);
+ ValueObjectSP VisitIdent(const GoASTIdent *e);
+ ValueObjectSP VisitStarExpr(const GoASTStarExpr *e);
+ ValueObjectSP VisitSelectorExpr(const GoASTSelectorExpr *e);
+ ValueObjectSP VisitBasicLit(const GoASTBasicLit *e);
+ ValueObjectSP VisitIndexExpr(const GoASTIndexExpr *e);
+ ValueObjectSP VisitUnaryExpr(const GoASTUnaryExpr *e);
+ ValueObjectSP VisitCallExpr(const GoASTCallExpr *e);
+
+ ValueObjectSP
+ VisitTypeAssertExpr(const GoASTTypeAssertExpr *e)
+ {
+ return NotImplemented(e);
+ }
+
+ ValueObjectSP
+ VisitBinaryExpr(const GoASTBinaryExpr *e)
+ {
+ return NotImplemented(e);
+ }
+
+ ValueObjectSP
+ VisitArrayType(const GoASTArrayType *e)
+ {
+ return NotImplemented(e);
+ }
+
+ ValueObjectSP
+ VisitChanType(const GoASTChanType *e)
+ {
+ return NotImplemented(e);
+ }
+
+ ValueObjectSP
+ VisitCompositeLit(const GoASTCompositeLit *e)
+ {
+ return NotImplemented(e);
+ }
+
+ ValueObjectSP
+ VisitEllipsis(const GoASTEllipsis *e)
+ {
+ return NotImplemented(e);
+ }
+
+ ValueObjectSP
+ VisitFuncType(const GoASTFuncType *e)
+ {
+ return NotImplemented(e);
+ }
+
+ ValueObjectSP
+ VisitFuncLit(const GoASTFuncLit *e)
+ {
+ return NotImplemented(e);
+ }
+
+ ValueObjectSP
+ VisitInterfaceType(const GoASTInterfaceType *e)
+ {
+ return NotImplemented(e);
+ }
+
+ ValueObjectSP
+ VisitKeyValueExpr(const GoASTKeyValueExpr *e)
+ {
+ return NotImplemented(e);
+ }
+
+ ValueObjectSP
+ VisitMapType(const GoASTMapType *e)
+ {
+ return NotImplemented(e);
+ }
+
+ ValueObjectSP
+ VisitSliceExpr(const GoASTSliceExpr *e)
+ {
+ return NotImplemented(e);
+ }
+
+ ValueObjectSP
+ VisitStructType(const GoASTStructType *e)
+ {
+ return NotImplemented(e);
+ }
+
+ CompilerType EvaluateType(const GoASTExpr *e);
+
+ Error &
+ error()
+ {
+ return m_error;
+ }
+
+ private:
+ std::nullptr_t
+ NotImplemented(const GoASTExpr *e)
+ {
+ m_error.SetErrorStringWithFormat("%s node not implemented", e->GetKindName());
+ return nullptr;
+ }
+
+ ExecutionContext m_exe_ctx;
+ lldb::StackFrameSP m_frame;
+ GoParser m_parser;
+ DynamicValueType m_use_dynamic;
+ Error m_error;
+ llvm::StringRef m_package;
+ std::vector<std::unique_ptr<GoASTStmt>> m_statements;
+};
+
+VariableSP
+FindGlobalVariable(TargetSP target, llvm::Twine name)
+{
+ ConstString fullname(name.str());
+ VariableList variable_list;
+ const bool append = true;
+ if (!target)
+ {
+ return nullptr;
+ }
+ const uint32_t match_count = target->GetImages().FindGlobalVariables(fullname, append, 1, variable_list);
+ if (match_count == 1)
+ {
+ return variable_list.GetVariableAtIndex(0);
+ }
+ return nullptr;
+}
+
+CompilerType
+LookupType(TargetSP target, ConstString name)
+{
+ if (!target)
+ return CompilerType();
+ SymbolContext sc;
+ TypeList type_list;
+ uint32_t num_matches = target->GetImages().FindTypes(sc, name, false, 2, type_list);
+ if (num_matches > 0)
+ {
+ return type_list.GetTypeAtIndex(0)->GetFullCompilerType();
+ }
+ return CompilerType();
+}
+
+GoUserExpression::GoUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
+ lldb::LanguageType language, ResultType desired_type,
+ const EvaluateExpressionOptions &options)
+ : UserExpression(exe_scope, expr, expr_prefix, language, desired_type, options)
+{
+}
+
+bool
+GoUserExpression::Parse(Stream &error_stream, ExecutionContext &exe_ctx, lldb_private::ExecutionPolicy execution_policy,
+ bool keep_result_in_memory, bool generate_debug_info)
+{
+ InstallContext(exe_ctx);
+ m_interpreter.reset(new GoInterpreter(exe_ctx, GetUserText()));
+ if (m_interpreter->Parse())
+ return true;
+ const char *error_cstr = m_interpreter->error().AsCString();
+ if (error_cstr && error_cstr[0])
+ error_stream.Printf("error: %s\n", error_cstr);
+ else
+ error_stream.Printf("error: expression can't be interpreted or run\n");
+ return false;
+}
+
+lldb::ExpressionResults
+GoUserExpression::Execute(Stream &error_stream, ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options,
+ lldb::UserExpressionSP &shared_ptr_to_me, lldb::ExpressionVariableSP &result)
+{
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
+
+ lldb_private::ExecutionPolicy execution_policy = options.GetExecutionPolicy();
+ lldb::ExpressionResults execution_results = lldb::eExpressionSetupError;
+
+ Process *process = exe_ctx.GetProcessPtr();
+ Target *target = exe_ctx.GetTargetPtr();
+
+ if (target == nullptr || process == nullptr || process->GetState() != lldb::eStateStopped)
+ {
+ if (execution_policy == eExecutionPolicyAlways)
+ {
+ if (log)
+ log->Printf("== [GoUserExpression::Evaluate] Expression may not run, but is not constant ==");
+
+ error_stream.Printf("expression needed to run but couldn't");
+
+ return execution_results;
+ }
+ }
+
+ m_interpreter->set_use_dynamic(options.GetUseDynamic());
+ ValueObjectSP result_val_sp = m_interpreter->Evaluate(exe_ctx);
+ Error err = m_interpreter->error();
+ m_interpreter.reset();
+
+ if (!result_val_sp)
+ {
+ const char *error_cstr = err.AsCString();
+ if (error_cstr && error_cstr[0])
+ error_stream.Printf("error: %s\n", error_cstr);
+ else
+ error_stream.Printf("error: expression can't be interpreted or run\n");
+ return lldb::eExpressionDiscarded;
+ }
+ result.reset(new ExpressionVariable(ExpressionVariable::eKindGo));
+ result->m_live_sp = result->m_frozen_sp = result_val_sp;
+ result->m_flags |= ExpressionVariable::EVIsProgramReference;
+ PersistentExpressionState *pv = target->GetPersistentExpressionStateForLanguage(eLanguageTypeGo);
+ if (pv != nullptr)
+ {
+ result->SetName(pv->GetNextPersistentVariableName());
+ pv->AddVariable(result);
+ }
+ return lldb::eExpressionCompleted;
+}
+
+bool
+GoUserExpression::GoInterpreter::Parse()
+{
+ for (std::unique_ptr<GoASTStmt> stmt(m_parser.Statement()); stmt; stmt.reset(m_parser.Statement()))
+ {
+ if (m_parser.Failed())
+ break;
+ m_statements.emplace_back(std::move(stmt));
+ }
+ if (m_parser.Failed() || !m_parser.AtEOF())
+ m_parser.GetError(m_error);
+
+ return m_error.Success();
+}
+
+ValueObjectSP
+GoUserExpression::GoInterpreter::Evaluate(ExecutionContext &exe_ctx)
+{
+ m_exe_ctx = exe_ctx;
+ ValueObjectSP result;
+ for (const std::unique_ptr<GoASTStmt> &stmt : m_statements)
+ {
+ result = EvaluateStatement(stmt.get());
+ if (m_error.Fail())
+ return nullptr;
+ }
+ return result;
+}
+
+ValueObjectSP
+GoUserExpression::GoInterpreter::EvaluateStatement(const lldb_private::GoASTStmt *stmt)
+{
+ ValueObjectSP result;
+ switch (stmt->GetKind())
+ {
+ case GoASTNode::eBlockStmt:
+ {
+ const GoASTBlockStmt *block = llvm::cast<GoASTBlockStmt>(stmt);
+ for (size_t i = 0; i < block->NumList(); ++i)
+ result = EvaluateStatement(block->GetList(i));
+ break;
+ }
+ case GoASTNode::eBadStmt:
+ m_parser.GetError(m_error);
+ break;
+ case GoASTNode::eExprStmt:
+ {
+ const GoASTExprStmt *expr = llvm::cast<GoASTExprStmt>(stmt);
+ return EvaluateExpr(expr->GetX());
+ }
+ default:
+ m_error.SetErrorStringWithFormat("%s node not supported", stmt->GetKindName());
+ }
+ return result;
+}
+
+ValueObjectSP
+GoUserExpression::GoInterpreter::EvaluateExpr(const lldb_private::GoASTExpr *e)
+{
+ if (e)
+ return e->Visit<ValueObjectSP>(this);
+ return ValueObjectSP();
+}
+
+ValueObjectSP
+GoUserExpression::GoInterpreter::VisitParenExpr(const lldb_private::GoASTParenExpr *e)
+{
+ return EvaluateExpr(e->GetX());
+}
+
+ValueObjectSP
+GoUserExpression::GoInterpreter::VisitIdent(const GoASTIdent *e)
+{
+ ValueObjectSP val;
+ if (m_frame)
+ {
+ VariableSP var_sp;
+ std::string varname = e->GetName().m_value.str();
+ if (varname.size() > 1 && varname[0] == '$')
+ {
+ RegisterContextSP reg_ctx_sp = m_frame->GetRegisterContext();
+ const RegisterInfo *reg = reg_ctx_sp->GetRegisterInfoByName(varname.c_str() + 1);
+ if (reg)
+ {
+ std::string type;
+ switch (reg->encoding)
+ {
+ case lldb::eEncodingSint:
+ type.append("int");
+ break;
+ case lldb::eEncodingUint:
+ type.append("uint");
+ break;
+ case lldb::eEncodingIEEE754:
+ type.append("float");
+ break;
+ default:
+ m_error.SetErrorString("Invaild register encoding");
+ return nullptr;
+ }
+ switch (reg->byte_size)
+ {
+ case 8:
+ type.append("64");
+ break;
+ case 4:
+ type.append("32");
+ break;
+ case 2:
+ type.append("16");
+ break;
+ case 1:
+ type.append("8");
+ break;
+ default:
+ m_error.SetErrorString("Invaild register size");
+ return nullptr;
+ }
+ ValueObjectSP regVal =
+ ValueObjectRegister::Create(m_frame.get(), reg_ctx_sp, reg->kinds[eRegisterKindLLDB]);
+ CompilerType goType = LookupType(m_frame->CalculateTarget(), ConstString(type));
+ if (regVal)
+ {
+ regVal = regVal->Cast(goType);
+ return regVal;
+ }
+ }
+ m_error.SetErrorString("Invaild register name");
+ return nullptr;
+ }
+ VariableListSP var_list_sp(m_frame->GetInScopeVariableList(false));
+ if (var_list_sp)
+ {
+ var_sp = var_list_sp->FindVariable(ConstString(varname));
+ if (var_sp)
+ val = m_frame->GetValueObjectForFrameVariable(var_sp, m_use_dynamic);
+ else
+ {
+ // When a variable is on the heap instead of the stack, go records a variable
+ // '&x' instead of 'x'.
+ var_sp = var_list_sp->FindVariable(ConstString("&" + varname));
+ if (var_sp)
+ {
+ val = m_frame->GetValueObjectForFrameVariable(var_sp, m_use_dynamic);
+ if (val)
+ val = val->Dereference(m_error);
+ if (m_error.Fail())
+ return nullptr;
+ }
+ }
+ }
+ if (!val)
+ {
+ m_error.Clear();
+ TargetSP target = m_frame->CalculateTarget();
+ if (!target)
+ {
+ m_error.SetErrorString("No target");
+ return nullptr;
+ }
+ var_sp = FindGlobalVariable(target, m_package + "." + e->GetName().m_value);
+ if (var_sp)
+ return m_frame->TrackGlobalVariable(var_sp, m_use_dynamic);
+ }
+ }
+ if (!val)
+ m_error.SetErrorStringWithFormat("Unknown variable %s", e->GetName().m_value.str().c_str());
+ return val;
+}
+
+ValueObjectSP
+GoUserExpression::GoInterpreter::VisitStarExpr(const GoASTStarExpr *e)
+{
+ ValueObjectSP target = EvaluateExpr(e->GetX());
+ if (!target)
+ return nullptr;
+ return target->Dereference(m_error);
+}
+
+ValueObjectSP
+GoUserExpression::GoInterpreter::VisitSelectorExpr(const lldb_private::GoASTSelectorExpr *e)
+{
+ ValueObjectSP target = EvaluateExpr(e->GetX());
+ if (target)
+ {
+ if (target->GetCompilerType().IsPointerType())
+ {
+ target = target->Dereference(m_error);
+ if (m_error.Fail())
+ return nullptr;
+ }
+ ConstString field(e->GetSel()->GetName().m_value);
+ ValueObjectSP result = target->GetChildMemberWithName(field, true);
+ if (!result)
+ m_error.SetErrorStringWithFormat("Unknown child %s", field.AsCString());
+ return result;
+ }
+ if (const GoASTIdent *package = llvm::dyn_cast<GoASTIdent>(e->GetX()))
+ {
+ if (VariableSP global = FindGlobalVariable(m_exe_ctx.GetTargetSP(),
+ package->GetName().m_value + "." + e->GetSel()->GetName().m_value))
+ {
+ if (m_frame)
+ {
+ m_error.Clear();
+ return m_frame->GetValueObjectForFrameVariable(global, m_use_dynamic);
+ }
+ }
+ }
+ if (const GoASTBasicLit *packageLit = llvm::dyn_cast<GoASTBasicLit>(e->GetX()))
+ {
+ if (packageLit->GetValue().m_type == GoLexer::LIT_STRING)
+ {
+ std::string value = packageLit->GetValue().m_value.str();
+ value = value.substr(1, value.size() - 2);
+ if (VariableSP global =
+ FindGlobalVariable(m_exe_ctx.GetTargetSP(), value + "." + e->GetSel()->GetName().m_value))
+ {
+ if (m_frame)
+ {
+ m_error.Clear();
+ return m_frame->TrackGlobalVariable(global, m_use_dynamic);
+ }
+ }
+ }
+ }
+ // EvaluateExpr should have already set m_error.
+ return target;
+}
+
+ValueObjectSP
+GoUserExpression::GoInterpreter::VisitBasicLit(const lldb_private::GoASTBasicLit *e)
+{
+ std::string value = e->GetValue().m_value.str();
+ if (e->GetValue().m_type != GoLexer::LIT_INTEGER)
+ {
+ m_error.SetErrorStringWithFormat("Unsupported literal %s", value.c_str());
+ return nullptr;
+ }
+ errno = 0;
+ int64_t intvalue = strtol(value.c_str(), nullptr, 0);
+ if (errno != 0)
+ {
+ m_error.SetErrorToErrno();
+ return nullptr;
+ }
+ DataBufferSP buf(new DataBufferHeap(sizeof(intvalue), 0));
+ TargetSP target = m_exe_ctx.GetTargetSP();
+ if (!target)
+ {
+ m_error.SetErrorString("No target");
+ return nullptr;
+ }
+ ByteOrder order = target->GetArchitecture().GetByteOrder();
+ uint8_t addr_size = target->GetArchitecture().GetAddressByteSize();
+ DataEncoder enc(buf, order, addr_size);
+ enc.PutU64(0, static_cast<uint64_t>(intvalue));
+ DataExtractor data(buf, order, addr_size);
+
+ CompilerType type = LookupType(target, ConstString("int64"));
+ return ValueObject::CreateValueObjectFromData(nullptr, data, m_exe_ctx, type);
+}
+
+ValueObjectSP
+GoUserExpression::GoInterpreter::VisitIndexExpr(const lldb_private::GoASTIndexExpr *e)
+{
+ ValueObjectSP target = EvaluateExpr(e->GetX());
+ if (!target)
+ return nullptr;
+ ValueObjectSP index = EvaluateExpr(e->GetIndex());
+ if (!index)
+ return nullptr;
+ bool is_signed;
+ if (!index->GetCompilerType().IsIntegerType(is_signed))
+ {
+ m_error.SetErrorString("Unsupported index");
+ return nullptr;
+ }
+ size_t idx;
+ if (is_signed)
+ idx = index->GetValueAsSigned(0);
+ else
+ idx = index->GetValueAsUnsigned(0);
+ if (GoASTContext::IsGoSlice(target->GetCompilerType()))
+ {
+ target = target->GetStaticValue();
+ ValueObjectSP cap = target->GetChildMemberWithName(ConstString("cap"), true);
+ if (cap)
+ {
+ uint64_t capval = cap->GetValueAsUnsigned(0);
+ if (idx >= capval)
+ {
+ m_error.SetErrorStringWithFormat("Invalid index %" PRIu64 " , cap = %" PRIu64, uint64_t(idx), capval);
+ return nullptr;
+ }
+ }
+ target = target->GetChildMemberWithName(ConstString("array"), true);
+ if (target && m_use_dynamic != eNoDynamicValues)
+ {
+ ValueObjectSP dynamic = target->GetDynamicValue(m_use_dynamic);
+ if (dynamic)
+ target = dynamic;
+ }
+ if (!target)
+ return nullptr;
+ return target->GetSyntheticArrayMember(idx, true);
+ }
+ return target->GetChildAtIndex(idx, true);
+}
+
+ValueObjectSP
+GoUserExpression::GoInterpreter::VisitUnaryExpr(const GoASTUnaryExpr *e)
+{
+ ValueObjectSP x = EvaluateExpr(e->GetX());
+ if (!x)
+ return nullptr;
+ switch (e->GetOp())
+ {
+ case GoLexer::OP_AMP:
+ {
+ CompilerType type = x->GetCompilerType().GetPointerType();
+ uint64_t address = x->GetAddressOf();
+ return ValueObject::CreateValueObjectFromAddress(nullptr, address, m_exe_ctx, type);
+ }
+ case GoLexer::OP_PLUS:
+ return x;
+ default:
+ m_error.SetErrorStringWithFormat("Operator %s not supported",
+ GoLexer::LookupToken(e->GetOp()).str().c_str());
+ return nullptr;
+ }
+}
+
+CompilerType
+GoUserExpression::GoInterpreter::EvaluateType(const GoASTExpr *e)
+{
+ TargetSP target = m_exe_ctx.GetTargetSP();
+ if (auto *id = llvm::dyn_cast<GoASTIdent>(e))
+ {
+ CompilerType result = LookupType(target, ConstString(id->GetName().m_value));
+ if (result.IsValid())
+ return result;
+ std::string fullname = (m_package + "." + id->GetName().m_value).str();
+ result = LookupType(target, ConstString(fullname));
+ if (!result)
+ m_error.SetErrorStringWithFormat("Unknown type %s", fullname.c_str());
+ return result;
+ }
+ if (auto *sel = llvm::dyn_cast<GoASTSelectorExpr>(e))
+ {
+ std::string package;
+ if (auto *pkg_node = llvm::dyn_cast<GoASTIdent>(sel->GetX()))
+ {
+ package = pkg_node->GetName().m_value.str();
+ }
+ else if (auto *str_node = llvm::dyn_cast<GoASTBasicLit>(sel->GetX()))
+ {
+ if (str_node->GetValue().m_type == GoLexer::LIT_STRING)
+ {
+ package = str_node->GetValue().m_value.substr(1).str();
+ package.resize(package.length() - 1);
+ }
+ }
+ if (package.empty())
+ {
+ m_error.SetErrorStringWithFormat("Invalid %s in type expression", sel->GetX()->GetKindName());
+ return CompilerType();
+ }
+ std::string fullname = (package + "." + sel->GetSel()->GetName().m_value).str();
+ CompilerType result = LookupType(target, ConstString(fullname));
+ if (!result)
+ m_error.SetErrorStringWithFormat("Unknown type %s", fullname.c_str());
+ return result;
+ }
+ if (auto *star = llvm::dyn_cast<GoASTStarExpr>(e))
+ {
+ CompilerType elem = EvaluateType(star->GetX());
+ return elem.GetPointerType();
+ }
+ if (auto *paren = llvm::dyn_cast<GoASTParenExpr>(e))
+ return EvaluateType(paren->GetX());
+ if (auto *array = llvm::dyn_cast<GoASTArrayType>(e))
+ {
+ CompilerType elem = EvaluateType(array->GetElt());
+ }
+
+ m_error.SetErrorStringWithFormat("Invalid %s in type expression", e->GetKindName());
+ return CompilerType();
+}
+
+ValueObjectSP
+GoUserExpression::GoInterpreter::VisitCallExpr(const lldb_private::GoASTCallExpr *e)
+{
+ ValueObjectSP x = EvaluateExpr(e->GetFun());
+ if (x || e->NumArgs() != 1)
+ {
+ m_error.SetErrorStringWithFormat("Code execution not supported");
+ return nullptr;
+ }
+ m_error.Clear();
+ CompilerType type = EvaluateType(e->GetFun());
+ if (!type)
+ {
+ return nullptr;
+ }
+ ValueObjectSP value = EvaluateExpr(e->GetArgs(0));
+ if (!value)
+ return nullptr;
+ // TODO: Handle special conversions
+ return value->Cast(type);
+}
+
+GoPersistentExpressionState::GoPersistentExpressionState() : PersistentExpressionState(eKindGo)
+{
+}
+
+ConstString
+GoPersistentExpressionState::GetNextPersistentVariableName()
+{
+ char name_cstr[256];
+ // We can't use the same variable format as clang.
+ ::snprintf(name_cstr, sizeof(name_cstr), "$go%u", m_next_persistent_variable_id++);
+ ConstString name(name_cstr);
+ return name;
+}
+
+void
+GoPersistentExpressionState::RemovePersistentVariable(lldb::ExpressionVariableSP variable)
+{
+ RemoveVariable(variable);
+
+ const char *name = variable->GetName().AsCString();
+
+ if (*(name++) != '$')
+ return;
+ if (*(name++) != 'g')
+ return;
+ if (*(name++) != 'o')
+ return;
+
+ if (strtoul(name, nullptr, 0) == m_next_persistent_variable_id - 1)
+ m_next_persistent_variable_id--;
+}
diff --git a/source/Plugins/ExpressionParser/Go/GoUserExpression.h b/source/Plugins/ExpressionParser/Go/GoUserExpression.h
new file mode 100644
index 000000000000..b429c68f023d
--- /dev/null
+++ b/source/Plugins/ExpressionParser/Go/GoUserExpression.h
@@ -0,0 +1,98 @@
+//===-- GoUserExpression.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_GoUserExpression_h_
+#define liblldb_GoUserExpression_h_
+
+// C Includes
+// C++ Includes
+#include <memory>
+
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-forward.h"
+#include "lldb/lldb-private.h"
+#include "lldb/Expression/UserExpression.h"
+#include "lldb/Expression/ExpressionVariable.h"
+#include "lldb/Target/ExecutionContext.h"
+
+namespace lldb_private
+{
+class GoParser;
+
+class GoPersistentExpressionState : public PersistentExpressionState
+{
+ public:
+ GoPersistentExpressionState();
+
+ ConstString GetNextPersistentVariableName() override;
+
+ void RemovePersistentVariable(lldb::ExpressionVariableSP variable) override;
+
+ lldb::addr_t
+ LookupSymbol(const ConstString &name) override
+ {
+ return LLDB_INVALID_ADDRESS;
+ }
+
+ static bool
+ classof(const PersistentExpressionState *pv)
+ {
+ return pv->getKind() == PersistentExpressionState::eKindGo;
+ }
+
+ private:
+ uint32_t m_next_persistent_variable_id; ///< The counter used by GetNextResultName().
+};
+
+//----------------------------------------------------------------------
+/// @class GoUserExpression GoUserExpression.h "lldb/Expression/GoUserExpression.h"
+/// @brief Encapsulates a single expression for use with Go
+///
+/// LLDB uses expressions for various purposes, notably to call functions
+/// and as a backend for the expr command. GoUserExpression encapsulates
+/// the objects needed to parse and interpret an expression.
+//----------------------------------------------------------------------
+class GoUserExpression : public UserExpression
+{
+ public:
+ GoUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
+ lldb::LanguageType language, ResultType desired_type, const EvaluateExpressionOptions &options);
+
+ bool
+ Parse(Stream &error_stream, ExecutionContext &exe_ctx, lldb_private::ExecutionPolicy execution_policy,
+ bool keep_result_in_memory, bool generate_debug_info) override;
+
+ lldb::ExpressionResults
+ Execute(Stream &error_stream, ExecutionContext &exe_ctx,
+ const EvaluateExpressionOptions &options,
+ lldb::UserExpressionSP &shared_ptr_to_me,
+ lldb::ExpressionVariableSP &result) override;
+
+ bool
+ CanInterpret() override
+ {
+ return true;
+ }
+ bool
+ FinalizeJITExecution(Stream &error_stream, ExecutionContext &exe_ctx, lldb::ExpressionVariableSP &result,
+ lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS,
+ lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS) override
+ {
+ return true;
+ }
+
+ private:
+ class GoInterpreter;
+ std::unique_ptr<GoInterpreter> m_interpreter;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_GoUserExpression_h_
diff --git a/source/Plugins/ExpressionParser/Go/gen_go_ast.py b/source/Plugins/ExpressionParser/Go/gen_go_ast.py
new file mode 100644
index 000000000000..05b589a9976c
--- /dev/null
+++ b/source/Plugins/ExpressionParser/Go/gen_go_ast.py
@@ -0,0 +1,356 @@
+import StringIO
+
+def addNodes():
+ addNode("ArrayType", "Expr", "len", "Expr", "elt", "Expr")
+ addNode("AssignStmt", "Stmt", "lhs", "[]Expr", "rhs", "[]Expr", "define", "bool")
+ addNode("BadDecl", "Decl")
+ addNode("BadExpr", "Expr")
+ addNode("BadStmt", "Stmt")
+ addNode("BasicLit", "Expr", "value", "Token")
+ addNode("BinaryExpr", "Expr", "x", "Expr", "y", "Expr", "op", "TokenType")
+ addNode("BlockStmt", "Stmt", "list", "[]Stmt")
+ addNode("Ident", "Expr", "name", "Token")
+ addNode("BranchStmt", "Stmt", "label", "Ident", "tok", "TokenType")
+ addNode("CallExpr", "Expr", "fun", "Expr", "args", "[]Expr", "ellipsis", "bool")
+ addNode("CaseClause", "Stmt", "list", "[]Expr", "body", "[]Stmt")
+ addNode("ChanType", "Expr", "dir", "ChanDir", "value", "Expr")
+ addNode("CommClause", "Stmt", "comm", "Stmt", "body", "[]Stmt")
+ addNode("CompositeLit", "Expr", "type", "Expr", "elts", "[]Expr")
+ addNode("DeclStmt", "Stmt", "decl", "Decl")
+ addNode("DeferStmt", "Stmt", "call", "CallExpr")
+ addNode("Ellipsis", "Expr", "elt", "Expr")
+ addNode("EmptyStmt", "Stmt")
+ addNode("ExprStmt", "Stmt", "x", "Expr")
+ addNode("Field", "Node", "names", "[]Ident", "type", "Expr", "tag", "BasicLit")
+ addNode("FieldList", "Node", "list", "[]Field")
+ addNode("ForStmt", "Stmt", "init", "Stmt", "cond", "Expr", "post", "Stmt", "body", "BlockStmt")
+ addNode("FuncType", "Expr", "params", "FieldList", "results", "FieldList")
+ addNode("FuncDecl", "Decl", "recv", "FieldList", "name", "Ident", "type", "FuncType", "body", "BlockStmt")
+ addNode("FuncLit", "Expr", "type", "FuncType", "body", "BlockStmt")
+ addNode("GenDecl", "Decl", "tok", "TokenType", "specs", "[]Spec")
+ addNode("GoStmt", "Stmt", "call", "CallExpr")
+ addNode("IfStmt", "Stmt", "init", "Stmt", "cond", "Expr", "body", "BlockStmt", "els", "Stmt")
+ addNode("ImportSpec", "Spec", "name", "Ident", "path", "BasicLit")
+ addNode("IncDecStmt", "Stmt", "x", "Expr", "tok", "TokenType")
+ addNode("IndexExpr", "Expr", "x", "Expr", "index", "Expr")
+ addNode("InterfaceType", "Expr", "methods", "FieldList")
+ addNode("KeyValueExpr", "Expr", "key", "Expr", "value", "Expr")
+ addNode("LabeledStmt", "Stmt", "label", "Ident", "stmt", "Stmt")
+ addNode("MapType", "Expr", "key", "Expr", "value", "Expr")
+ addNode("ParenExpr", "Expr", "x", "Expr")
+ addNode("RangeStmt", "Stmt", "key", "Expr", "value", "Expr", "define", "bool", "x", "Expr", "body", "BlockStmt")
+ addNode("ReturnStmt", "Stmt", "results", "[]Expr")
+ addNode("SelectStmt", "Stmt", "body", "BlockStmt")
+ addNode("SelectorExpr", "Expr", "x", "Expr", "sel", "Ident")
+ addNode("SendStmt", "Stmt", "chan", "Expr", "value", "Expr")
+ addNode("SliceExpr", "Expr", "x", "Expr", "low", "Expr", "high", "Expr", "max", "Expr", "slice3", "bool")
+ addNode("StarExpr", "Expr", "x", "Expr")
+ addNode("StructType", "Expr", "fields", "FieldList")
+ addNode("SwitchStmt", "Stmt", "init", "Stmt", "tag", "Expr", "body", "BlockStmt")
+ addNode("TypeAssertExpr", "Expr", "x", "Expr", "type", "Expr")
+ addNode("TypeSpec", "Spec", "name", "Ident", "type", "Expr")
+ addNode("TypeSwitchStmt", "Stmt", "init", "Stmt", "assign", "Stmt", "body", "BlockStmt")
+ addNode("UnaryExpr", "Expr", "op", "TokenType", "x", "Expr")
+ addNode("ValueSpec", "Spec", "names", "[]Ident", "type", "Expr", "values", "[]Expr")
+ addParent("Decl", "Node")
+ addParent("Expr", "Node")
+ addParent("Spec", "Node")
+ addParent("Stmt", "Node")
+
+
+class Member(object):
+ def __init__(self, name, typename):
+ self.title = name.title()
+ self.sname = name
+ self.mname = 'm_' + name
+ self.is_list = typename.startswith("[]")
+ self.is_value = isValueType(typename)
+ if self.is_value:
+ self.argtype = typename
+ self.mtype = typename
+ elif self.is_list:
+ self.argtype = 'GoAST' + typename[2:]
+ self.mtype = 'std::vector<std::unique_ptr<%s> >' % self.argtype
+ else:
+ self.argtype = 'GoAST' + typename
+ self.mtype = 'std::unique_ptr<%s>' % self.argtype
+ self.mname = self.mname + '_up'
+
+
+kinds = {}
+parentClasses = StringIO.StringIO()
+childClasses = StringIO.StringIO()
+walker = StringIO.StringIO()
+
+def startClass(name, parent, out):
+ out.write("""
+class GoAST%s : public GoAST%s
+{
+ public:
+""" % (name, parent))
+
+def endClass(name, out):
+ out.write("""
+ %(name)s(const %(name)s &) = delete;
+ const %(name)s &operator=(const %(name)s &) = delete;
+};
+""" % {'name': 'GoAST' + name})
+
+def addNode(name, parent, *children):
+ startClass(name, parent, childClasses)
+ l = kinds.setdefault(parent, [])
+ l.append(name)
+ children = createMembers(name, children)
+ addConstructor(name, parent, children)
+ childClasses.write("""
+ const char *
+ GetKindName() const override
+ {
+ return "%(name)s";
+ }
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() == e%(name)s;
+ }
+ """ % {'name':name})
+ addChildren(name, children)
+ endClass(name, childClasses)
+
+def isValueType(typename):
+ if typename[0].islower():
+ return True
+ if typename[0].isupper():
+ return typename.startswith('Token') or typename == 'ChanDir'
+ return False
+
+
+def createMembers(name, children):
+ l = len(children)
+ if (l % 2) != 0:
+ raise Exception("Invalid children for %s: %s" % (name, children))
+ return [Member(children[i], children[i + 1]) for i in xrange(0, l, 2)]
+
+
+def addConstructor(name, parent, children):
+ for c in children:
+ if c.is_list:
+ children = [x for x in children if x.is_value]
+ break
+ childClasses.write(' ')
+ if len(children) == 1:
+ childClasses.write('explicit ')
+ childClasses.write('GoAST%s(' % name)
+ for i in xrange(len(children)):
+ if i > 0:
+ childClasses.write(', ')
+
+ c = children[i]
+ if c.is_value:
+ childClasses.write(c.argtype)
+ childClasses.write(' ')
+ else:
+ childClasses.write('%s *' % c.argtype)
+ childClasses.write(c.sname)
+ childClasses.write(') : GoAST%s(e%s)' % (parent, name))
+ for c in children:
+ childClasses.write(', ')
+ childClasses.write('%(mname)s(%(sname)s)' % c.__dict__)
+ childClasses.write(""" {}
+ ~GoAST%s() override = default;
+""" % name)
+
+
+def addChildren(name, children):
+ if len(children) == 0:
+ return
+ walker.write("""
+ case e%(n)s:
+ {
+ GoAST%(n)s *n = llvm::cast<GoAST%(n)s>(this);
+ (void)n;""" % {'n':name})
+ for c in children:
+ if c.is_list:
+ childClasses.write("""
+ size_t
+ Num%(title)s() const
+ {
+ return %(mname)s.size();
+ }
+ const %(argtype)s *
+ Get%(title)s(int i) const
+ {
+ return %(mname)s[i].get();
+ }
+ void
+ Add%(title)s(%(argtype)s *%(sname)s)
+ {
+ %(mname)s.push_back(std::unique_ptr<%(argtype)s>(%(sname)s));
+ }
+""" % c.__dict__)
+ walker.write("""
+ for (auto& e : n->%s) { v(e.get()); }""" % c.mname)
+ else:
+ const = ''
+ get = ''
+ set = ''
+ t = c.argtype
+ if isValueType(t):
+ set = '%(mname)s = %(sname)s' % c.__dict__
+ t = t + ' '
+ else:
+ t = t + ' *'
+ const = 'const '
+ get = '.get()'
+ set = '%(mname)s.reset(%(sname)s)' % c.__dict__
+ walker.write("""
+ v(n->%s.get());""" % c.mname)
+ childClasses.write("""
+ %(const)s%(type)s
+ Get%(title)s() const
+ {
+ return %(mname)s%(get)s;
+ }
+ void
+ Set%(title)s(%(type)s%(sname)s)
+ {
+ %(set)s;
+ }
+""" % {'const':const, 'title': c.title, 'sname': c.sname, 'get': get, 'set': set, 'type': t, 'mname': c.mname})
+ childClasses.write('\n private:\n friend class GoASTNode;\n')
+ walker.write("""
+ return;
+ }""")
+ for c in children:
+ childClasses.write(' %s %s;\n' %(c.mtype, c.mname))
+
+
+def addParent(name, parent):
+ startClass(name, parent, parentClasses)
+ l = kinds[name]
+ minName = l[0]
+ maxName = l[-1]
+ parentClasses.write(""" template <typename R, typename V> R Visit(V *v) const;
+
+ static bool
+ classof(const GoASTNode *n)
+ {
+ return n->GetKind() >= e%s && n->GetKind() <= e%s;
+ }
+
+ protected:
+ explicit GoAST%s(NodeKind kind) : GoASTNode(kind) { }
+ private:
+""" % (minName, maxName, name))
+ endClass(name, parentClasses)
+
+addNodes()
+
+print """//===-- GoAST.h -------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// DO NOT EDIT.
+// Generated by gen_go_ast.py
+
+#ifndef liblldb_GoAST_h
+#define liblldb_GoAST_h
+
+#include "lldb/lldb-forward.h"
+#include "lldb/lldb-private.h"
+#include "llvm/Support/Casting.h"
+#include "Plugins/ExpressionParser/Go/GoLexer.h"
+
+namespace lldb_private
+{
+
+class GoASTNode
+{
+ public:
+ typedef GoLexer::TokenType TokenType;
+ typedef GoLexer::Token Token;
+ enum ChanDir
+ {
+ eChanBidir,
+ eChanSend,
+ eChanRecv,
+ };
+ enum NodeKind
+ {"""
+for l in kinds.itervalues():
+ for x in l:
+ print " e%s," % x
+print """ };
+
+ virtual ~GoASTNode() = default;
+
+ NodeKind
+ GetKind() const
+ {
+ return m_kind;
+ }
+
+ virtual const char *GetKindName() const = 0;
+
+ template <typename V> void WalkChildren(V &v);
+
+ protected:
+ explicit GoASTNode(NodeKind kind) : m_kind(kind) { }
+
+ private:
+ const NodeKind m_kind;
+
+ GoASTNode(const GoASTNode &) = delete;
+ const GoASTNode &operator=(const GoASTNode &) = delete;
+};
+"""
+
+
+print parentClasses.getvalue()
+print childClasses.getvalue()
+
+for k, l in kinds.iteritems():
+ if k == 'Node':
+ continue
+ print """
+template <typename R, typename V>
+R GoAST%s::Visit(V* v) const
+{
+ switch(GetKind())
+ {""" % k
+ for subtype in l:
+ print """ case e%(n)s:
+ return v->Visit%(n)s(llvm::cast<const GoAST%(n)s>(this));""" % {'n':subtype}
+
+ print """ default:
+ assert(false && "Invalid kind");
+ }
+}"""
+
+print """
+template <typename V>
+void GoASTNode::WalkChildren(V &v)
+{
+ switch (m_kind)
+ {
+"""
+print walker.getvalue()
+print"""
+ case eEmptyStmt:
+ case eBadDecl:
+ case eBadExpr:
+ case eBadStmt:
+ break;
+ }
+}
+
+} // namespace lldb_private
+
+#endif
+"""
diff --git a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
index 95ae549e0e4b..d646d4d4754a 100644
--- a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -290,9 +290,8 @@ EmulateInstructionARM::GetRegisterInfo (lldb::RegisterKind reg_kind, uint32_t re
uint32_t
EmulateInstructionARM::GetFramePointerRegisterNumber () const
{
- if (m_arch.GetTriple().getEnvironment() == llvm::Triple::Android)
+ if (m_arch.GetTriple().isAndroid())
return LLDB_INVALID_REGNUM; // Don't use frame pointer on android
-
bool is_apple = false;
if (m_arch.GetTriple().getVendor() == llvm::Triple::Apple)
is_apple = true;
@@ -301,6 +300,8 @@ EmulateInstructionARM::GetFramePointerRegisterNumber () const
case llvm::Triple::Darwin:
case llvm::Triple::MacOSX:
case llvm::Triple::IOS:
+ case llvm::Triple::TvOS:
+ case llvm::Triple::WatchOS:
is_apple = true;
break;
default:
@@ -387,9 +388,8 @@ EmulateInstructionARM::EmulatePUSH (const uint32_t opcode, const ARMEncoding enc
}
#endif
- bool conditional = false;
bool success = false;
- if (ConditionPassed(opcode, &conditional))
+ if (ConditionPassed(opcode))
{
const uint32_t addr_byte_size = GetAddressByteSize();
const addr_t sp = ReadCoreReg (SP_REG, &success);
@@ -442,10 +442,7 @@ EmulateInstructionARM::EmulatePUSH (const uint32_t opcode, const ARMEncoding enc
uint32_t i;
EmulateInstruction::Context context;
- if (conditional)
- context.type = EmulateInstruction::eContextRegisterStore;
- else
- context.type = EmulateInstruction::eContextPushRegisterOnStack;
+ context.type = EmulateInstruction::eContextPushRegisterOnStack;
RegisterInfo reg_info;
RegisterInfo sp_reg;
GetRegisterInfo (eRegisterKindDWARF, dwarf_sp, sp_reg);
@@ -511,8 +508,7 @@ EmulateInstructionARM::EmulatePOP (const uint32_t opcode, const ARMEncoding enco
bool success = false;
- bool conditional = false;
- if (ConditionPassed(opcode, &conditional))
+ if (ConditionPassed(opcode))
{
const uint32_t addr_byte_size = GetAddressByteSize();
const addr_t sp = ReadCoreReg (SP_REG, &success);
@@ -574,10 +570,7 @@ EmulateInstructionARM::EmulatePOP (const uint32_t opcode, const ARMEncoding enco
uint32_t i, data;
EmulateInstruction::Context context;
- if (conditional)
- context.type = EmulateInstruction::eContextRegisterLoad;
- else
- context.type = EmulateInstruction::eContextPopRegisterOffStack;
+ context.type = EmulateInstruction::eContextPopRegisterOffStack;
RegisterInfo sp_reg;
GetRegisterInfo (eRegisterKindDWARF, dwarf_sp, sp_reg);
@@ -586,7 +579,7 @@ EmulateInstructionARM::EmulatePOP (const uint32_t opcode, const ARMEncoding enco
{
if (BitIsSet (registers, i))
{
- context.SetRegisterPlusOffset (sp_reg, addr - sp);
+ context.SetAddress(addr);
data = MemARead(context, addr, 4, 0, &success);
if (!success)
return false;
@@ -900,12 +893,12 @@ EmulateInstructionARM::EmulateMOVRdImm (const uint32_t opcode, const ARMEncoding
break;
case eEncodingA1:
- // d = UInt(Rd); setflags = (S == Ô1Õ); (imm32, carry) = ARMExpandImm_C(imm12, APSR.C);
+ // d = UInt(Rd); setflags = (S == '1'); (imm32, carry) = ARMExpandImm_C(imm12, APSR.C);
Rd = Bits32 (opcode, 15, 12);
setflags = BitIsSet (opcode, 20);
imm32 = ARMExpandImm_C (opcode, APSR_C, carry);
- // if Rd == Ô1111Õ && S == Ô1Õ then SEE SUBS PC, LR and related instructions;
+ // if Rd == '1111' && S == '1' then SEE SUBS PC, LR and related instructions;
if ((Rd == 15) && setflags)
return EmulateSUBSPcLrEtc (opcode, encoding);
@@ -1971,9 +1964,8 @@ EmulateInstructionARM::EmulateSTRRtSP (const uint32_t opcode, const ARMEncoding
}
#endif
- bool conditional = false;
bool success = false;
- if (ConditionPassed(opcode, &conditional))
+ if (ConditionPassed(opcode))
{
const uint32_t addr_byte_size = GetAddressByteSize();
const addr_t sp = ReadCoreReg (SP_REG, &success);
@@ -2018,10 +2010,7 @@ EmulateInstructionARM::EmulateSTRRtSP (const uint32_t opcode, const ARMEncoding
addr = sp;
EmulateInstruction::Context context;
- if (conditional)
- context.type = EmulateInstruction::eContextRegisterStore;
- else
- context.type = EmulateInstruction::eContextPushRegisterOnStack;
+ context.type = EmulateInstruction::eContextPushRegisterOnStack;
RegisterInfo sp_reg;
RegisterInfo dwarf_reg;
@@ -2082,8 +2071,7 @@ EmulateInstructionARM::EmulateVPUSH (const uint32_t opcode, const ARMEncoding en
#endif
bool success = false;
- bool conditional = false;
- if (ConditionPassed(opcode, &conditional))
+ if (ConditionPassed(opcode))
{
const uint32_t addr_byte_size = GetAddressByteSize();
const addr_t sp = ReadCoreReg (SP_REG, &success);
@@ -2125,10 +2113,8 @@ EmulateInstructionARM::EmulateVPUSH (const uint32_t opcode, const ARMEncoding en
uint32_t i;
EmulateInstruction::Context context;
- if (conditional)
- context.type = EmulateInstruction::eContextRegisterStore;
- else
- context.type = EmulateInstruction::eContextPushRegisterOnStack;
+ context.type = EmulateInstruction::eContextPushRegisterOnStack;
+
RegisterInfo dwarf_reg;
RegisterInfo sp_reg;
GetRegisterInfo (eRegisterKindDWARF, dwarf_sp, sp_reg);
@@ -2178,8 +2164,7 @@ EmulateInstructionARM::EmulateVPOP (const uint32_t opcode, const ARMEncoding enc
#endif
bool success = false;
- bool conditional = false;
- if (ConditionPassed(opcode, &conditional))
+ if (ConditionPassed(opcode))
{
const uint32_t addr_byte_size = GetAddressByteSize();
const addr_t sp = ReadCoreReg (SP_REG, &success);
@@ -2222,17 +2207,15 @@ EmulateInstructionARM::EmulateVPOP (const uint32_t opcode, const ARMEncoding enc
uint64_t data; // uint64_t to accommodate 64-bit registers.
EmulateInstruction::Context context;
- if (conditional)
- context.type = EmulateInstruction::eContextRegisterLoad;
- else
- context.type = EmulateInstruction::eContextPopRegisterOffStack;
+ context.type = EmulateInstruction::eContextPopRegisterOffStack;
+
RegisterInfo dwarf_reg;
RegisterInfo sp_reg;
GetRegisterInfo (eRegisterKindDWARF, dwarf_sp, sp_reg);
for (i=0; i<regs; ++i)
{
GetRegisterInfo (eRegisterKindDWARF, start_reg + d + i, dwarf_reg);
- context.SetRegisterPlusOffset (sp_reg, addr - sp);
+ context.SetAddress(addr);
data = MemARead(context, addr, reg_byte_size, 0, &success);
if (!success)
return false;
@@ -3462,8 +3445,7 @@ EmulateInstructionARM::EmulateLDM (const uint32_t opcode, const ARMEncoding enco
#endif
bool success = false;
- bool conditional = false;
- if (ConditionPassed(opcode, &conditional))
+ if (ConditionPassed(opcode))
{
uint32_t n;
uint32_t registers = 0;
@@ -3536,10 +3518,8 @@ EmulateInstructionARM::EmulateLDM (const uint32_t opcode, const ARMEncoding enco
context.SetRegisterPlusOffset (dwarf_reg, offset);
if (wback && (n == 13)) // Pop Instruction
{
- if (conditional)
- context.type = EmulateInstruction::eContextRegisterLoad;
- else
- context.type = EmulateInstruction::eContextPopRegisterOffStack;
+ context.type = EmulateInstruction::eContextPopRegisterOffStack;
+ context.SetAddress(base_address + offset);
}
// R[i] = MemA [address, 4]; address = address + 4;
@@ -4459,7 +4439,7 @@ EmulateInstructionARM::EmulateSTMDB (const uint32_t opcode, const ARMEncoding en
break;
case eEncodingA1:
- // if W == '1' && Rn == '1101Õ && BitCount(register_list) >= 2 then SEE PUSH;
+ // if W == '1' && Rn == '1101' && BitCount(register_list) >= 2 then SEE PUSH;
if (BitIsSet (opcode, 21) && (Bits32 (opcode, 19, 16) == 13) && BitCount (Bits32 (opcode, 15, 0)) >= 2)
{
// See Push
@@ -4801,7 +4781,11 @@ EmulateInstructionARM::EmulateSTRThumb (const uint32_t opcode, const ARMEncoding
address = base_address;
EmulateInstruction::Context context;
- context.type = eContextRegisterStore;
+ if (n == 13)
+ context.type = eContextPushRegisterOnStack;
+ else
+ context.type = eContextRegisterStore;
+
RegisterInfo base_reg;
GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg);
@@ -4829,8 +4813,12 @@ EmulateInstructionARM::EmulateSTRThumb (const uint32_t opcode, const ARMEncoding
// if wback then R[n] = offset_addr;
if (wback)
{
- context.type = eContextRegisterLoad;
+ if (n == 13)
+ context.type = eContextAdjustStackPointer;
+ else
+ context.type = eContextAdjustBaseRegister;
context.SetAddress (offset_addr);
+
if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + n, offset_addr))
return false;
}
@@ -9579,7 +9567,7 @@ EmulateInstructionARM::EmulateSUBSPReg (const uint32_t opcode, const ARMEncoding
if ConditionPassed() then
EncodingSpecificOperations();
shifted = Shift(R[m], shift_t, shift_n, APSR.C);
- (result, carry, overflow) = AddWithCarry(SP, NOT(shifted), Ô1Õ);
+ (result, carry, overflow) = AddWithCarry(SP, NOT(shifted), '1');
if d == 15 then // Can only occur for ARM encoding
ALUWritePC(result); // setflags is always FALSE here
else
@@ -9604,7 +9592,7 @@ EmulateInstructionARM::EmulateSUBSPReg (const uint32_t opcode, const ARMEncoding
switch (encoding)
{
case eEncodingT1:
- // d = UInt(Rd); m = UInt(Rm); setflags = (S == Ô1Õ);
+ // d = UInt(Rd); m = UInt(Rm); setflags = (S == '1');
d = Bits32 (opcode, 11, 8);
m = Bits32 (opcode, 3, 0);
setflags = BitIsSet (opcode, 20);
@@ -9622,12 +9610,12 @@ EmulateInstructionARM::EmulateSUBSPReg (const uint32_t opcode, const ARMEncoding
break;
case eEncodingA1:
- // d = UInt(Rd); m = UInt(Rm); setflags = (S == Ô1Õ);
+ // d = UInt(Rd); m = UInt(Rm); setflags = (S == '1');
d = Bits32 (opcode, 15, 12);
m = Bits32 (opcode, 3, 0);
setflags = BitIsSet (opcode, 20);
- // if Rd == Ô1111Õ && S == Ô1Õ then SEE SUBS PC, LR and related instructions;
+ // if Rd == '1111' && S == '1' then SEE SUBS PC, LR and related instructions;
if (d == 15 && setflags)
EmulateSUBSPcLrEtc (opcode, encoding);
@@ -9648,7 +9636,7 @@ EmulateInstructionARM::EmulateSUBSPReg (const uint32_t opcode, const ARMEncoding
if (!success)
return false;
- // (result, carry, overflow) = AddWithCarry(SP, NOT(shifted), Ô1Õ);
+ // (result, carry, overflow) = AddWithCarry(SP, NOT(shifted), '1');
uint32_t sp_val = ReadCoreReg (SP_REG, &success);
if (!success)
return false;
@@ -9679,7 +9667,7 @@ EmulateInstructionARM::EmulateADDRegShift (const uint32_t opcode, const ARMEncod
EncodingSpecificOperations();
shift_n = UInt(R[s]<7:0>);
shifted = Shift(R[m], shift_t, shift_n, APSR.C);
- (result, carry, overflow) = AddWithCarry(R[n], shifted, Ô0Õ);
+ (result, carry, overflow) = AddWithCarry(R[n], shifted, '0');
R[d] = result;
if setflags then
APSR.N = result<31>;
@@ -9708,7 +9696,7 @@ EmulateInstructionARM::EmulateADDRegShift (const uint32_t opcode, const ARMEncod
m = Bits32 (opcode, 3, 0);
s = Bits32 (opcode, 11, 8);
- // setflags = (S == Ô1Õ); shift_t = DecodeRegShift(type);
+ // setflags = (S == '1'); shift_t = DecodeRegShift(type);
setflags = BitIsSet (opcode, 20);
shift_t = DecodeRegShift (Bits32 (opcode, 6, 5));
@@ -9737,7 +9725,7 @@ EmulateInstructionARM::EmulateADDRegShift (const uint32_t opcode, const ARMEncod
if (!success)
return false;
- // (result, carry, overflow) = AddWithCarry(R[n], shifted, Ô0Õ);
+ // (result, carry, overflow) = AddWithCarry(R[n], shifted, '0');
uint32_t Rn = ReadCoreReg (n, &success);
if (!success)
return false;
@@ -9776,7 +9764,7 @@ EmulateInstructionARM::EmulateSUBReg (const uint32_t opcode, const ARMEncoding e
if ConditionPassed() then
EncodingSpecificOperations();
shifted = Shift(R[m], shift_t, shift_n, APSR.C);
- (result, carry, overflow) = AddWithCarry(R[n], NOT(shifted), Ô1Õ);
+ (result, carry, overflow) = AddWithCarry(R[n], NOT(shifted), '1');
if d == 15 then // Can only occur for ARM encoding
ALUWritePC(result); // setflags is always FALSE here
else
@@ -9839,14 +9827,14 @@ EmulateInstructionARM::EmulateSUBReg (const uint32_t opcode, const ARMEncoding e
break;
case eEncodingA1:
- // if Rn == Ô1101Õ then SEE SUB (SP minus register);
- // d = UInt(Rd); n = UInt(Rn); m = UInt(Rm); setflags = (S == Ô1Õ);
+ // if Rn == '1101' then SEE SUB (SP minus register);
+ // d = UInt(Rd); n = UInt(Rn); m = UInt(Rm); setflags = (S == '1');
d = Bits32 (opcode, 15, 12);
n = Bits32 (opcode, 19, 16);
m = Bits32 (opcode, 3, 0);
setflags = BitIsSet (opcode, 20);
- // if Rd == Ô1111Õ && S == Ô1Õ then SEE SUBS PC, LR and related instructions;
+ // if Rd == '1111' && S == '1' then SEE SUBS PC, LR and related instructions;
if ((d == 15) && setflags)
EmulateSUBSPcLrEtc (opcode, encoding);
@@ -9868,7 +9856,7 @@ EmulateInstructionARM::EmulateSUBReg (const uint32_t opcode, const ARMEncoding e
if (!success)
return false;
- // (result, carry, overflow) = AddWithCarry(R[n], NOT(shifted), Ô1Õ);
+ // (result, carry, overflow) = AddWithCarry(R[n], NOT(shifted), '1');
uint32_t Rn = ReadCoreReg (n, &success);
if (!success)
return false;
@@ -9929,7 +9917,7 @@ EmulateInstructionARM::EmulateSTREX (const uint32_t opcode, const ARMEncoding en
switch (encoding)
{
case eEncodingT1:
- // d = UInt(Rd); t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm8:Õ00Õ, 32);
+ // d = UInt(Rd); t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm8:'00', 32);
d = Bits32 (opcode, 11, 8);
t = Bits32 (opcode, 15, 12);
n = Bits32 (opcode, 19, 16);
@@ -10037,13 +10025,13 @@ EmulateInstructionARM::EmulateSTRBImmARM (const uint32_t opcode, const ARMEncodi
switch (encoding)
{
case eEncodingA1:
- // if P == Ô0Õ && W == Ô1Õ then SEE STRBT;
+ // if P == '0' && W == '1' then SEE STRBT;
// t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm12, 32);
t = Bits32 (opcode, 15, 12);
n = Bits32 (opcode, 19, 16);
imm32 = Bits32 (opcode, 11, 0);
- // index = (P == Ô1Õ); add = (U == Ô1Õ); wback = (P == Ô0Õ) || (W == Ô1Õ);
+ // index = (P == '1'); add = (U == '1'); wback = (P == '0') || (W == '1');
index = BitIsSet (opcode, 24);
add = BitIsSet (opcode, 23);
wback = BitIsClear (opcode, 24) || BitIsSet (opcode, 21);
@@ -10135,14 +10123,14 @@ EmulateInstructionARM::EmulateSTRImmARM (const uint32_t opcode, const ARMEncodin
switch (encoding)
{
case eEncodingA1:
- // if P == Ô0Õ && W == Ô1Õ then SEE STRT;
- // if Rn == Ô1101Õ && P == Ô1Õ && U == Ô0Õ && W == Ô1Õ && imm12 == Ô000000000100Õ then SEE PUSH;
+ // if P == '0' && W == '1' then SEE STRT;
+ // if Rn == '1101' && P == '1' && U == '0' && W == '1' && imm12 == '000000000100' then SEE PUSH;
// t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm12, 32);
t = Bits32 (opcode, 15, 12);
n = Bits32 (opcode, 19, 16);
imm32 = Bits32 (opcode, 11, 0);
- // index = (P == Ô1Õ); add = (U == Ô1Õ); wback = (P == Ô0Õ) || (W == Ô1Õ);
+ // index = (P == '1'); add = (U == '1'); wback = (P == '0') || (W == '1');
index = BitIsSet (opcode, 24);
add = BitIsSet (opcode, 23);
wback = BitIsClear (opcode, 24) || BitIsSet (opcode, 21);
@@ -10247,15 +10235,15 @@ EmulateInstructionARM::EmulateLDRDImmediate (const uint32_t opcode, const ARMEnc
switch (encoding)
{
case eEncodingT1:
- //if P == Ô0Õ && W == Ô0Õ then SEE ÒRelated encodingsÓ;
- //if Rn == Ô1111Õ then SEE LDRD (literal);
- //t = UInt(Rt); t2 = UInt(Rt2); n = UInt(Rn); imm32 = ZeroExtend(imm8:Õ00Õ, 32);
+ //if P == '0' && W == '0' then SEE 'Related encodings';
+ //if Rn == '1111' then SEE LDRD (literal);
+ //t = UInt(Rt); t2 = UInt(Rt2); n = UInt(Rn); imm32 = ZeroExtend(imm8:'00', 32);
t = Bits32 (opcode, 15, 12);
t2 = Bits32 (opcode, 11, 8);
n = Bits32 (opcode, 19, 16);
imm32 = Bits32 (opcode, 7, 0) << 2;
- //index = (P == Ô1Õ); add = (U == Ô1Õ); wback = (W == Ô1Õ);
+ //index = (P == '1'); add = (U == '1'); wback = (W == '1');
index = BitIsSet (opcode, 24);
add = BitIsSet (opcode, 23);
wback = BitIsSet (opcode, 21);
@@ -10271,8 +10259,8 @@ EmulateInstructionARM::EmulateLDRDImmediate (const uint32_t opcode, const ARMEnc
break;
case eEncodingA1:
- //if Rn == Ô1111Õ then SEE LDRD (literal);
- //if Rt<0> == Ô1Õ then UNPREDICTABLE;
+ //if Rn == '1111' then SEE LDRD (literal);
+ //if Rt<0> == '1' then UNPREDICTABLE;
//t = UInt(Rt); t2 = t+1; n = UInt(Rn); imm32 = ZeroExtend(imm4H:imm4L, 32);
t = Bits32 (opcode, 15, 12);
if (BitIsSet (t, 0))
@@ -10281,12 +10269,12 @@ EmulateInstructionARM::EmulateLDRDImmediate (const uint32_t opcode, const ARMEnc
n = Bits32 (opcode, 19, 16);
imm32 = (Bits32 (opcode, 11, 8) << 4) | Bits32 (opcode, 3, 0);
- //index = (P == Ô1Õ); add = (U == Ô1Õ); wback = (P == Ô0Õ) || (W == Ô1Õ);
+ //index = (P == '1'); add = (U == '1'); wback = (P == '0') || (W == '1');
index = BitIsSet (opcode, 24);
add = BitIsSet (opcode, 23);
wback = BitIsClear (opcode, 24) || BitIsSet (opcode, 21);
- //if P == Ô0Õ && W == Ô1Õ then UNPREDICTABLE;
+ //if P == '0' && W == '1' then UNPREDICTABLE;
if (BitIsClear (opcode, 24) && BitIsSet (opcode, 21))
return false;
@@ -10327,8 +10315,11 @@ EmulateInstructionARM::EmulateLDRDImmediate (const uint32_t opcode, const ARMEnc
GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg);
EmulateInstruction::Context context;
- context.type = eContextRegisterLoad;
- context.SetRegisterPlusOffset (base_reg, address - Rn);
+ if (n == 13)
+ context.type = eContextPopRegisterOffStack;
+ else
+ context.type = eContextRegisterLoad;
+ context.SetAddress(address);
const uint32_t addr_byte_size = GetAddressByteSize();
uint32_t data = MemARead (context, address, addr_byte_size, 0, &success);
@@ -10339,8 +10330,7 @@ EmulateInstructionARM::EmulateLDRDImmediate (const uint32_t opcode, const ARMEnc
return false;
//R[t2] = MemA[address+4,4];
-
- context.SetRegisterPlusOffset (base_reg, (address + 4) - Rn);
+ context.SetAddress(address + 4);
data = MemARead (context, address + 4, addr_byte_size, 0, &success);
if (!success)
return false;
@@ -10392,7 +10382,7 @@ EmulateInstructionARM::EmulateLDRDRegister (const uint32_t opcode, const ARMEnco
switch (encoding)
{
case eEncodingA1:
- // if Rt<0> == Ô1Õ then UNPREDICTABLE;
+ // if Rt<0> == '1' then UNPREDICTABLE;
// t = UInt(Rt); t2 = t+1; n = UInt(Rn); m = UInt(Rm);
t = Bits32 (opcode, 15, 12);
if (BitIsSet (t, 0))
@@ -10401,12 +10391,12 @@ EmulateInstructionARM::EmulateLDRDRegister (const uint32_t opcode, const ARMEnco
n = Bits32 (opcode, 19, 16);
m = Bits32 (opcode, 3, 0);
- // index = (P == Ô1Õ); add = (U == Ô1Õ); wback = (P == Ô0Õ) || (W == Ô1Õ);
+ // index = (P == '1'); add = (U == '1'); wback = (P == '0') || (W == '1');
index = BitIsSet (opcode, 24);
add = BitIsSet (opcode, 23);
wback = BitIsClear (opcode, 24) || BitIsSet (opcode, 21);
- // if P == Ô0Õ && W == Ô1Õ then UNPREDICTABLE;
+ // if P == '0' && W == '1' then UNPREDICTABLE;
if (BitIsClear (opcode, 24) && BitIsSet (opcode, 21))
return false;
@@ -10454,8 +10444,11 @@ EmulateInstructionARM::EmulateLDRDRegister (const uint32_t opcode, const ARMEnco
address = Rn;
EmulateInstruction::Context context;
- context.type = eContextRegisterLoad;
- context.SetRegisterPlusIndirectOffset (base_reg, offset_reg);
+ if (n == 13)
+ context.type = eContextPopRegisterOffStack;
+ else
+ context.type = eContextRegisterLoad;
+ context.SetAddress(address);
// R[t] = MemA[address,4];
const uint32_t addr_byte_size = GetAddressByteSize();
@@ -10519,14 +10512,14 @@ EmulateInstructionARM::EmulateSTRDImm (const uint32_t opcode, const ARMEncoding
switch (encoding)
{
case eEncodingT1:
- // if P == Ô0Õ && W == Ô0Õ then SEE ÒRelated encodingsÓ;
- // t = UInt(Rt); t2 = UInt(Rt2); n = UInt(Rn); imm32 = ZeroExtend(imm8:Õ00Õ, 32);
+ // if P == '0' && W == '0' then SEE 'Related encodings';
+ // t = UInt(Rt); t2 = UInt(Rt2); n = UInt(Rn); imm32 = ZeroExtend(imm8:'00', 32);
t = Bits32 (opcode, 15, 12);
t2 = Bits32 (opcode, 11, 8);
n = Bits32 (opcode, 19, 16);
imm32 = Bits32 (opcode, 7, 0) << 2;
- // index = (P == Ô1Õ); add = (U == Ô1Õ); wback = (W == Ô1Õ);
+ // index = (P == '1'); add = (U == '1'); wback = (W == '1');
index = BitIsSet (opcode, 24);
add = BitIsSet (opcode, 23);
wback = BitIsSet (opcode, 21);
@@ -10542,7 +10535,7 @@ EmulateInstructionARM::EmulateSTRDImm (const uint32_t opcode, const ARMEncoding
break;
case eEncodingA1:
- // if Rt<0> == Ô1Õ then UNPREDICTABLE;
+ // if Rt<0> == '1' then UNPREDICTABLE;
// t = UInt(Rt); t2 = t+1; n = UInt(Rn); imm32 = ZeroExtend(imm4H:imm4L, 32);
t = Bits32 (opcode, 15, 12);
if (BitIsSet (t, 0))
@@ -10552,12 +10545,12 @@ EmulateInstructionARM::EmulateSTRDImm (const uint32_t opcode, const ARMEncoding
n = Bits32 (opcode, 19, 16);
imm32 = (Bits32 (opcode, 11, 8) << 4) | Bits32 (opcode, 3, 0);
- // index = (P == Ô1Õ); add = (U == Ô1Õ); wback = (P == Ô0Õ) || (W == Ô1Õ);
+ // index = (P == '1'); add = (U == '1'); wback = (P == '0') || (W == '1');
index = BitIsSet (opcode, 24);
add = BitIsSet (opcode, 23);
wback = BitIsClear (opcode, 24) || BitIsSet (opcode, 21);
- // if P == Ô0Õ && W == Ô1Õ then UNPREDICTABLE;
+ // if P == '0' && W == '1' then UNPREDICTABLE;
if (BitIsClear (opcode, 24) && BitIsSet (opcode, 21))
return false;
@@ -10605,7 +10598,10 @@ EmulateInstructionARM::EmulateSTRDImm (const uint32_t opcode, const ARMEncoding
return false;
EmulateInstruction::Context context;
- context.type = eContextRegisterStore;
+ if (n == 13)
+ context.type = eContextPushRegisterOnStack;
+ else
+ context.type = eContextRegisterStore;
context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, address - Rn);
const uint32_t addr_byte_size = GetAddressByteSize();
@@ -10627,9 +10623,12 @@ EmulateInstructionARM::EmulateSTRDImm (const uint32_t opcode, const ARMEncoding
//if wback then R[n] = offset_addr;
if (wback)
{
- context.type = eContextAdjustBaseRegister;
+ if (n == 13)
+ context.type = eContextAdjustStackPointer;
+ else
+ context.type = eContextAdjustBaseRegister;
context.SetAddress (offset_addr);
-
+
if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + n, offset_addr))
return false;
}
@@ -10667,7 +10666,7 @@ EmulateInstructionARM::EmulateSTRDReg (const uint32_t opcode, const ARMEncoding
switch (encoding)
{
case eEncodingA1:
- // if Rt<0> == Ô1Õ then UNPREDICTABLE;
+ // if Rt<0> == '1' then UNPREDICTABLE;
// t = UInt(Rt); t2 = t+1; n = UInt(Rn); m = UInt(Rm);
t = Bits32 (opcode, 15, 12);
if (BitIsSet (t, 0))
@@ -10677,12 +10676,12 @@ EmulateInstructionARM::EmulateSTRDReg (const uint32_t opcode, const ARMEncoding
n = Bits32 (opcode, 19, 16);
m = Bits32 (opcode, 3, 0);
- // index = (P == Ô1Õ); add = (U == Ô1Õ); wback = (P == Ô0Õ) || (W == Ô1Õ);
+ // index = (P == '1'); add = (U == '1'); wback = (P == '0') || (W == '1');
index = BitIsSet (opcode, 24);
add = BitIsSet (opcode, 23);
wback = BitIsClear (opcode, 24) || BitIsSet (opcode, 21);
- // if P == Ô0Õ && W == Ô1Õ then UNPREDICTABLE;
+ // if P == '0' && W == '1' then UNPREDICTABLE;
if (BitIsClear (opcode, 24) && BitIsSet (opcode, 21))
return false;
@@ -10737,7 +10736,11 @@ EmulateInstructionARM::EmulateSTRDReg (const uint32_t opcode, const ARMEncoding
return false;
EmulateInstruction::Context context;
- context.type = eContextRegisterStore;
+ if (t == 13)
+ context.type = eContextPushRegisterOnStack;
+ else
+ context.type = eContextRegisterStore;
+
GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + t, data_reg);
context.SetRegisterToRegisterPlusIndirectOffset (base_reg, offset_reg, data_reg);
@@ -10808,25 +10811,25 @@ EmulateInstructionARM::EmulateVLDM (const uint32_t opcode, const ARMEncoding enc
{
case eEncodingT1:
case eEncodingA1:
- // if P == Ô0Õ && U == Ô0Õ && W == Ô0Õ then SEE ÒRelated encodingsÓ;
- // if P == Ô0Õ && U == Ô1Õ && W == Ô1Õ && Rn == Ô1101Õ then SEE VPOP;
- // if P == Ô1Õ && W == Ô0Õ then SEE VLDR;
- // if P == U && W == Ô1Õ then UNDEFINED;
+ // if P == '0' && U == '0' && W == '0' then SEE 'Related encodings';
+ // if P == '0' && U == '1' && W == '1' && Rn == '1101' then SEE VPOP;
+ // if P == '1' && W == '0' then SEE VLDR;
+ // if P == U && W == '1' then UNDEFINED;
if ((Bit32 (opcode, 24) == Bit32 (opcode, 23)) && BitIsSet (opcode, 21))
return false;
// // Remaining combinations are PUW = 010 (IA without !), 011 (IA with !), 101 (DB with !)
- // single_regs = FALSE; add = (U == Ô1Õ); wback = (W == Ô1Õ);
+ // single_regs = FALSE; add = (U == '1'); wback = (W == '1');
single_regs = false;
add = BitIsSet (opcode, 23);
wback = BitIsSet (opcode, 21);
- // d = UInt(D:Vd); n = UInt(Rn); imm32 = ZeroExtend(imm8:Õ00Õ, 32);
+ // d = UInt(D:Vd); n = UInt(Rn); imm32 = ZeroExtend(imm8:'00', 32);
d = (Bit32 (opcode, 22) << 4) | Bits32 (opcode, 15, 12);
n = Bits32 (opcode, 19, 16);
imm32 = Bits32 (opcode, 7, 0) << 2;
- // regs = UInt(imm8) DIV 2; // If UInt(imm8) is odd, see ÒFLDMXÓ.
+ // regs = UInt(imm8) DIV 2; // If UInt(imm8) is odd, see 'FLDMX'.
regs = Bits32 (opcode, 7, 0) / 2;
// if n == 15 && (wback || CurrentInstrSet() != InstrSet_ARM) then UNPREDICTABLE;
@@ -10841,22 +10844,22 @@ EmulateInstructionARM::EmulateVLDM (const uint32_t opcode, const ARMEncoding enc
case eEncodingT2:
case eEncodingA2:
- // if P == Ô0Õ && U == Ô0Õ && W == Ô0Õ then SEE ÒRelated encodingsÓ;
- // if P == Ô0Õ && U == Ô1Õ && W == Ô1Õ && Rn == Ô1101Õ then SEE VPOP;
- // if P == Ô1Õ && W == Ô0Õ then SEE VLDR;
- // if P == U && W == Ô1Õ then UNDEFINED;
+ // if P == '0' && U == '0' && W == '0' then SEE 'Related encodings';
+ // if P == '0' && U == '1' && W == '1' && Rn == '1101' then SEE VPOP;
+ // if P == '1' && W == '0' then SEE VLDR;
+ // if P == U && W == '1' then UNDEFINED;
if ((Bit32 (opcode, 24) == Bit32 (opcode, 23)) && BitIsSet (opcode, 21))
return false;
// // Remaining combinations are PUW = 010 (IA without !), 011 (IA with !), 101 (DB with !)
- // single_regs = TRUE; add = (U == Ô1Õ); wback = (W == Ô1Õ); d = UInt(Vd:D); n = UInt(Rn);
+ // single_regs = TRUE; add = (U == '1'); wback = (W == '1'); d = UInt(Vd:D); n = UInt(Rn);
single_regs = true;
add = BitIsSet (opcode, 23);
wback = BitIsSet (opcode, 21);
d = (Bits32 (opcode, 15, 12) << 1) | Bit32 (opcode, 22);
n = Bits32 (opcode, 19, 16);
- // imm32 = ZeroExtend(imm8:Õ00Õ, 32); regs = UInt(imm8);
+ // imm32 = ZeroExtend(imm8:'00', 32); regs = UInt(imm8);
imm32 = Bits32 (opcode, 7, 0) << 2;
regs = Bits32 (opcode, 7, 0);
@@ -11000,25 +11003,25 @@ EmulateInstructionARM::EmulateVSTM (const uint32_t opcode, const ARMEncoding enc
{
case eEncodingT1:
case eEncodingA1:
- // if P == Ô0Õ && U == Ô0Õ && W == Ô0Õ then SEE ÒRelated encodingsÓ;
- // if P == Ô1Õ && U == Ô0Õ && W == Ô1Õ && Rn == Ô1101Õ then SEE VPUSH;
- // if P == Ô1Õ && W == Ô0Õ then SEE VSTR;
- // if P == U && W == Ô1Õ then UNDEFINED;
+ // if P == '0' && U == '0' && W == '0' then SEE 'Related encodings';
+ // if P == '1' && U == '0' && W == '1' && Rn == '1101' then SEE VPUSH;
+ // if P == '1' && W == '0' then SEE VSTR;
+ // if P == U && W == '1' then UNDEFINED;
if ((Bit32 (opcode, 24) == Bit32 (opcode, 23)) && BitIsSet (opcode, 21))
return false;
// // Remaining combinations are PUW = 010 (IA without !), 011 (IA with !), 101 (DB with !)
- // single_regs = FALSE; add = (U == Ô1Õ); wback = (W == Ô1Õ);
+ // single_regs = FALSE; add = (U == '1'); wback = (W == '1');
single_regs = false;
add = BitIsSet (opcode, 23);
wback = BitIsSet (opcode, 21);
- // d = UInt(D:Vd); n = UInt(Rn); imm32 = ZeroExtend(imm8:Õ00Õ, 32);
+ // d = UInt(D:Vd); n = UInt(Rn); imm32 = ZeroExtend(imm8:'00', 32);
d = (Bit32 (opcode, 22) << 4) | Bits32 (opcode, 15, 12);
n = Bits32 (opcode, 19, 16);
imm32 = Bits32 (opcode, 7, 0) << 2;
- // regs = UInt(imm8) DIV 2; // If UInt(imm8) is odd, see ÒFSTMXÓ.
+ // regs = UInt(imm8) DIV 2; // If UInt(imm8) is odd, see 'FSTMX'.
regs = Bits32 (opcode, 7, 0) / 2;
// if n == 15 && (wback || CurrentInstrSet() != InstrSet_ARM) then UNPREDICTABLE;
@@ -11033,22 +11036,22 @@ EmulateInstructionARM::EmulateVSTM (const uint32_t opcode, const ARMEncoding enc
case eEncodingT2:
case eEncodingA2:
- // if P == Ô0Õ && U == Ô0Õ && W == Ô0Õ then SEE ÒRelated encodingsÓ;
- // if P == Ô1Õ && U == Ô0Õ && W == Ô1Õ && Rn == Ô1101Õ then SEE VPUSH;
- // if P == Ô1Õ && W == Ô0Õ then SEE VSTR;
- // if P == U && W == Ô1Õ then UNDEFINED;
+ // if P == '0' && U == '0' && W == '0' then SEE 'Related encodings';
+ // if P == '1' && U == '0' && W == '1' && Rn == '1101' then SEE VPUSH;
+ // if P == '1' && W == '0' then SEE VSTR;
+ // if P == U && W == '1' then UNDEFINED;
if ((Bit32 (opcode, 24) == Bit32 (opcode, 23)) && BitIsSet (opcode, 21))
return false;
// // Remaining combinations are PUW = 010 (IA without !), 011 (IA with !), 101 (DB with !)
- // single_regs = TRUE; add = (U == Ô1Õ); wback = (W == Ô1Õ); d = UInt(Vd:D); n = UInt(Rn);
+ // single_regs = TRUE; add = (U == '1'); wback = (W == '1'); d = UInt(Vd:D); n = UInt(Rn);
single_regs = true;
add = BitIsSet (opcode, 23);
wback = BitIsSet (opcode, 21);
d = (Bits32 (opcode, 15, 12) << 1) | Bit32 (opcode, 22);
n = Bits32 (opcode, 19, 16);
- // imm32 = ZeroExtend(imm8:Õ00Õ, 32); regs = UInt(imm8);
+ // imm32 = ZeroExtend(imm8:'00', 32); regs = UInt(imm8);
imm32 = Bits32 (opcode, 7, 0) << 2;
regs = Bits32 (opcode, 7, 0);
@@ -11193,7 +11196,7 @@ EmulateInstructionARM::EmulateVLDR (const uint32_t opcode, ARMEncoding encoding)
{
case eEncodingT1:
case eEncodingA1:
- // single_reg = FALSE; add = (U == Ô1Õ); imm32 = ZeroExtend(imm8:Õ00Õ, 32);
+ // single_reg = FALSE; add = (U == '1'); imm32 = ZeroExtend(imm8:'00', 32);
single_reg = false;
add = BitIsSet (opcode, 23);
imm32 = Bits32 (opcode, 7, 0) << 2;
@@ -11206,7 +11209,7 @@ EmulateInstructionARM::EmulateVLDR (const uint32_t opcode, ARMEncoding encoding)
case eEncodingT2:
case eEncodingA2:
- // single_reg = TRUE; add = (U == Ô1Õ); imm32 = ZeroExtend(imm8:Õ00Õ, 32);
+ // single_reg = TRUE; add = (U == '1'); imm32 = ZeroExtend(imm8:'00', 32);
single_reg = true;
add = BitIsSet (opcode, 23);
imm32 = Bits32 (opcode, 7, 0) << 2;
@@ -11322,7 +11325,7 @@ EmulateInstructionARM::EmulateVSTR (const uint32_t opcode, ARMEncoding encoding)
{
case eEncodingT1:
case eEncodingA1:
- // single_reg = FALSE; add = (U == Ô1Õ); imm32 = ZeroExtend(imm8:Õ00Õ, 32);
+ // single_reg = FALSE; add = (U == '1'); imm32 = ZeroExtend(imm8:'00', 32);
single_reg = false;
add = BitIsSet (opcode, 23);
imm32 = Bits32 (opcode, 7, 0) << 2;
@@ -11339,7 +11342,7 @@ EmulateInstructionARM::EmulateVSTR (const uint32_t opcode, ARMEncoding encoding)
case eEncodingT2:
case eEncodingA2:
- // single_reg = TRUE; add = (U == Ô1Õ); imm32 = ZeroExtend(imm8:Õ00Õ, 32);
+ // single_reg = TRUE; add = (U == '1'); imm32 = ZeroExtend(imm8:'00', 32);
single_reg = true;
add = BitIsSet (opcode, 23);
imm32 = Bits32 (opcode, 7, 0) << 2;
@@ -11461,16 +11464,16 @@ EmulateInstructionARM::EmulateVLD1Multiple (const uint32_t opcode, ARMEncoding e
case eEncodingA1:
{
// case type of
- // when Ô0111Õ
- // regs = 1; if align<1> == Ô1Õ then UNDEFINED;
- // when Ô1010Õ
- // regs = 2; if align == Ô11Õ then UNDEFINED;
- // when Ô0110Õ
- // regs = 3; if align<1> == Ô1Õ then UNDEFINED;
- // when Ô0010Õ
+ // when '0111'
+ // regs = 1; if align<1> == '1' then UNDEFINED;
+ // when '1010'
+ // regs = 2; if align == '11' then UNDEFINED;
+ // when '0110'
+ // regs = 3; if align<1> == '1' then UNDEFINED;
+ // when '0010'
// regs = 4;
// otherwise
- // SEE ÒRelated encodingsÓ;
+ // SEE 'Related encodings';
uint32_t type = Bits32 (opcode, 11, 8);
uint32_t align = Bits32 (opcode, 5, 4);
if (type == 7) // '0111'
@@ -11499,7 +11502,7 @@ EmulateInstructionARM::EmulateVLD1Multiple (const uint32_t opcode, ARMEncoding e
else
return false;
- // alignment = if align == Ô00Õ then 1 else 4 << UInt(align);
+ // alignment = if align == '00' then 1 else 4 << UInt(align);
if (align == 0)
alignment = 1;
else
@@ -11624,13 +11627,13 @@ EmulateInstructionARM::EmulateVLD1Single (const uint32_t opcode, const ARMEncodi
{
uint32_t size = Bits32 (opcode, 11, 10);
uint32_t index_align = Bits32 (opcode, 7, 4);
- // if size == Ô11Õ then SEE VLD1 (single element to all lanes);
+ // if size == '11' then SEE VLD1 (single element to all lanes);
if (size == 3)
return EmulateVLD1SingleAll (opcode, encoding);
// case size of
if (size == 0) // when '00'
{
- // if index_align<0> != Ô0Õ then UNDEFINED;
+ // if index_align<0> != '0' then UNDEFINED;
if (BitIsClear (index_align, 0))
return false;
@@ -11640,9 +11643,9 @@ EmulateInstructionARM::EmulateVLD1Single (const uint32_t opcode, const ARMEncodi
index = Bits32 (index_align, 3, 1);
alignment = 1;
}
- else if (size == 1) // when Ô01Õ
+ else if (size == 1) // when '01'
{
- // if index_align<1> != Ô0Õ then UNDEFINED;
+ // if index_align<1> != '0' then UNDEFINED;
if (BitIsClear (index_align, 1))
return false;
@@ -11651,19 +11654,19 @@ EmulateInstructionARM::EmulateVLD1Single (const uint32_t opcode, const ARMEncodi
esize = 16;
index = Bits32 (index_align, 3, 2);
- // alignment = if index_align<0> == Ô0Õ then 1 else 2;
+ // alignment = if index_align<0> == '0' then 1 else 2;
if (BitIsClear (index_align, 0))
alignment = 1;
else
alignment = 2;
}
- else if (size == 2) // when Ô10Õ
+ else if (size == 2) // when '10'
{
- // if index_align<2> != Ô0Õ then UNDEFINED;
+ // if index_align<2> != '0' then UNDEFINED;
if (BitIsClear (index_align, 2))
return false;
- // if index_align<1:0> != Ô00Õ && index_align<1:0> != Ô11Õ then UNDEFINED;
+ // if index_align<1:0> != '00' && index_align<1:0> != '11' then UNDEFINED;
if ((Bits32 (index_align, 1, 0) != 0) && (Bits32 (index_align, 1, 0) != 3))
return false;
@@ -11672,7 +11675,7 @@ EmulateInstructionARM::EmulateVLD1Single (const uint32_t opcode, const ARMEncodi
esize = 32;
index = Bit32 (index_align, 3);
- // alignment = if index_align<1:0> == Ô00Õ then 1 else 4;
+ // alignment = if index_align<1:0> == '00' then 1 else 4;
if (Bits32 (index_align, 1, 0) == 0)
alignment = 1;
else
@@ -11806,35 +11809,35 @@ EmulateInstructionARM::EmulateVST1Multiple (const uint32_t opcode, ARMEncoding e
uint32_t align = Bits32 (opcode, 5, 4);
// case type of
- if (type == 7) // when Ô0111Õ
+ if (type == 7) // when '0111'
{
- // regs = 1; if align<1> == Ô1Õ then UNDEFINED;
+ // regs = 1; if align<1> == '1' then UNDEFINED;
regs = 1;
if (BitIsSet (align, 1))
return false;
}
- else if (type == 10) // when Ô1010Õ
+ else if (type == 10) // when '1010'
{
- // regs = 2; if align == Ô11Õ then UNDEFINED;
+ // regs = 2; if align == '11' then UNDEFINED;
regs = 2;
if (align == 3)
return false;
}
- else if (type == 6) // when Ô0110Õ
+ else if (type == 6) // when '0110'
{
- // regs = 3; if align<1> == Ô1Õ then UNDEFINED;
+ // regs = 3; if align<1> == '1' then UNDEFINED;
regs = 3;
if (BitIsSet (align, 1))
return false;
}
- else if (type == 2) // when Ô0010Õ
+ else if (type == 2) // when '0010'
// regs = 4;
regs = 4;
else // otherwise
- // SEE ÒRelated encodingsÓ;
+ // SEE 'Related encodings';
return false;
- // alignment = if align == Ô00Õ then 1 else 4 << UInt(align);
+ // alignment = if align == '00' then 1 else 4 << UInt(align);
if (align == 0)
alignment = 1;
else
@@ -11964,14 +11967,14 @@ EmulateInstructionARM::EmulateVST1Single (const uint32_t opcode, ARMEncoding enc
uint32_t size = Bits32 (opcode, 11, 10);
uint32_t index_align = Bits32 (opcode, 7, 4);
- // if size == Ô11Õ then UNDEFINED;
+ // if size == '11' then UNDEFINED;
if (size == 3)
return false;
// case size of
- if (size == 0) // when Ô00Õ
+ if (size == 0) // when '00'
{
- // if index_align<0> != Ô0Õ then UNDEFINED;
+ // if index_align<0> != '0' then UNDEFINED;
if (BitIsClear (index_align, 0))
return false;
// ebytes = 1; esize = 8; index = UInt(index_align<3:1>); alignment = 1;
@@ -11980,9 +11983,9 @@ EmulateInstructionARM::EmulateVST1Single (const uint32_t opcode, ARMEncoding enc
index = Bits32 (index_align, 3, 1);
alignment = 1;
}
- else if (size == 1) // when Ô01Õ
+ else if (size == 1) // when '01'
{
- // if index_align<1> != Ô0Õ then UNDEFINED;
+ // if index_align<1> != '0' then UNDEFINED;
if (BitIsClear (index_align, 1))
return false;
@@ -11991,19 +11994,19 @@ EmulateInstructionARM::EmulateVST1Single (const uint32_t opcode, ARMEncoding enc
esize = 16;
index = Bits32 (index_align, 3, 2);
- // alignment = if index_align<0> == Ô0Õ then 1 else 2;
+ // alignment = if index_align<0> == '0' then 1 else 2;
if (BitIsClear (index_align, 0))
alignment = 1;
else
alignment = 2;
}
- else if (size == 2) // when Ô10Õ
+ else if (size == 2) // when '10'
{
- // if index_align<2> != Ô0Õ then UNDEFINED;
+ // if index_align<2> != '0' then UNDEFINED;
if (BitIsClear (index_align, 2))
return false;
- // if index_align<1:0> != Ô00Õ && index_align<1:0> != Ô11Õ then UNDEFINED;
+ // if index_align<1:0> != '00' && index_align<1:0> != '11' then UNDEFINED;
if ((Bits32 (index_align, 1, 0) != 0) && (Bits32 (index_align, 1, 0) != 3))
return false;
@@ -12012,7 +12015,7 @@ EmulateInstructionARM::EmulateVST1Single (const uint32_t opcode, ARMEncoding enc
esize = 32;
index = Bit32 (index_align, 3);
- // alignment = if index_align<1:0> == Ô00Õ then 1 else 4;
+ // alignment = if index_align<1:0> == '00' then 1 else 4;
if (Bits32 (index_align, 1, 0) == 0)
alignment = 1;
else
@@ -12125,12 +12128,12 @@ EmulateInstructionARM::EmulateVLD1SingleAll (const uint32_t opcode, const ARMEnc
case eEncodingT1:
case eEncodingA1:
{
- //if size == Ô11Õ || (size == Ô00Õ && a == Ô1Õ) then UNDEFINED;
+ //if size == '11' || (size == '00' && a == '1') then UNDEFINED;
uint32_t size = Bits32 (opcode, 7, 6);
if ((size == 3) || ((size == 0) && BitIsSet (opcode, 4)))
return false;
- //ebytes = 1 << UInt(size); elements = 8 DIV ebytes; regs = if T == Ô0Õ then 1 else 2;
+ //ebytes = 1 << UInt(size); elements = 8 DIV ebytes; regs = if T == '0' then 1 else 2;
ebytes = 1 << size;
elements = 8 / ebytes;
if (BitIsClear (opcode, 5))
@@ -12138,7 +12141,7 @@ EmulateInstructionARM::EmulateVLD1SingleAll (const uint32_t opcode, const ARMEnc
else
regs = 2;
- //alignment = if a == Ô0Õ then 1 else ebytes;
+ //alignment = if a == '0' then 1 else ebytes;
if (BitIsClear (opcode, 4))
alignment = 1;
else
@@ -12235,19 +12238,19 @@ EmulateInstructionARM::EmulateSUBSPcLrEtc (const uint32_t opcode, const ARMEncod
UNPREDICTABLE;
operand2 = if register_form then Shift(R[m], shift_t, shift_n, APSR.C) else imm32;
case opcode of
- when Ô0000Õ result = R[n] AND operand2; // AND
- when Ô0001Õ result = R[n] EOR operand2; // EOR
- when Ô0010Õ (result, -, -) = AddWithCarry(R[n], NOT(operand2), Ô1Õ); // SUB
- when Ô0011Õ (result, -, -) = AddWithCarry(NOT(R[n]), operand2, Ô1Õ); // RSB
- when Ô0100Õ (result, -, -) = AddWithCarry(R[n], operand2, Ô0Õ); // ADD
- when Ô0101Õ (result, -, -) = AddWithCarry(R[n], operand2, APSR.c); // ADC
- when Ô0110Õ (result, -, -) = AddWithCarry(R[n], NOT(operand2), APSR.C); // SBC
- when Ô0111Õ (result, -, -) = AddWithCarry(NOT(R[n]), operand2, APSR.C); // RSC
- when Ô1100Õ result = R[n] OR operand2; // ORR
- when Ô1101Õ result = operand2; // MOV
- when Ô1110Õ result = R[n] AND NOT(operand2); // BIC
- when Ô1111Õ result = NOT(operand2); // MVN
- CPSRWriteByInstr(SPSR[], Ô1111Õ, TRUE);
+ when '0000' result = R[n] AND operand2; // AND
+ when '0001' result = R[n] EOR operand2; // EOR
+ when '0010' (result, -, -) = AddWithCarry(R[n], NOT(operand2), '1'); // SUB
+ when '0011' (result, -, -) = AddWithCarry(NOT(R[n]), operand2, '1'); // RSB
+ when '0100' (result, -, -) = AddWithCarry(R[n], operand2, '0'); // ADD
+ when '0101' (result, -, -) = AddWithCarry(R[n], operand2, APSR.c); // ADC
+ when '0110' (result, -, -) = AddWithCarry(R[n], NOT(operand2), APSR.C); // SBC
+ when '0111' (result, -, -) = AddWithCarry(NOT(R[n]), operand2, APSR.C); // RSC
+ when '1100' result = R[n] OR operand2; // ORR
+ when '1101' result = operand2; // MOV
+ when '1110' result = R[n] AND NOT(operand2); // BIC
+ when '1111' result = NOT(operand2); // MVN
+ CPSRWriteByInstr(SPSR[], '1111', TRUE);
BranchWritePC(result);
#endif
@@ -12267,7 +12270,7 @@ EmulateInstructionARM::EmulateSUBSPcLrEtc (const uint32_t opcode, const ARMEncod
{
case eEncodingT1:
// if CurrentInstrSet() == InstrSet_ThumbEE then UNPREDICTABLE
- // n = 14; imm32 = ZeroExtend(imm8, 32); register_form = FALSE; opcode = Ô0010Õ; // = SUB
+ // n = 14; imm32 = ZeroExtend(imm8, 32); register_form = FALSE; opcode = '0010'; // = SUB
n = 14;
imm32 = Bits32 (opcode, 7, 0);
register_form = false;
@@ -12329,62 +12332,62 @@ EmulateInstructionARM::EmulateSUBSPcLrEtc (const uint32_t opcode, const ARMEncod
// case opcode of
switch (code)
{
- case 0: // when Ô0000Õ
+ case 0: // when '0000'
// result = R[n] AND operand2; // AND
result.result = Rn & operand2;
break;
- case 1: // when Ô0001Õ
+ case 1: // when '0001'
// result = R[n] EOR operand2; // EOR
result.result = Rn ^ operand2;
break;
- case 2: // when Ô0010Õ
- // (result, -, -) = AddWithCarry(R[n], NOT(operand2), Ô1Õ); // SUB
+ case 2: // when '0010'
+ // (result, -, -) = AddWithCarry(R[n], NOT(operand2), '1'); // SUB
result = AddWithCarry (Rn, ~(operand2), 1);
break;
- case 3: // when Ô0011Õ
- // (result, -, -) = AddWithCarry(NOT(R[n]), operand2, Ô1Õ); // RSB
+ case 3: // when '0011'
+ // (result, -, -) = AddWithCarry(NOT(R[n]), operand2, '1'); // RSB
result = AddWithCarry (~(Rn), operand2, 1);
break;
- case 4: // when Ô0100Õ
- // (result, -, -) = AddWithCarry(R[n], operand2, Ô0Õ); // ADD
+ case 4: // when '0100'
+ // (result, -, -) = AddWithCarry(R[n], operand2, '0'); // ADD
result = AddWithCarry (Rn, operand2, 0);
break;
- case 5: // when Ô0101Õ
+ case 5: // when '0101'
// (result, -, -) = AddWithCarry(R[n], operand2, APSR.c); // ADC
result = AddWithCarry (Rn, operand2, APSR_C);
break;
- case 6: // when Ô0110Õ
+ case 6: // when '0110'
// (result, -, -) = AddWithCarry(R[n], NOT(operand2), APSR.C); // SBC
result = AddWithCarry (Rn, ~(operand2), APSR_C);
break;
- case 7: // when Ô0111Õ
+ case 7: // when '0111'
// (result, -, -) = AddWithCarry(NOT(R[n]), operand2, APSR.C); // RSC
result = AddWithCarry (~(Rn), operand2, APSR_C);
break;
- case 10: // when Ô1100Õ
+ case 10: // when '1100'
// result = R[n] OR operand2; // ORR
result.result = Rn | operand2;
break;
- case 11: // when Ô1101Õ
+ case 11: // when '1101'
// result = operand2; // MOV
result.result = operand2;
break;
- case 12: // when Ô1110Õ
+ case 12: // when '1110'
// result = R[n] AND NOT(operand2); // BIC
result.result = Rn & ~(operand2);
break;
- case 15: // when Ô1111Õ
+ case 15: // when '1111'
// result = NOT(operand2); // MVN
result.result = ~(operand2);
break;
@@ -12392,7 +12395,7 @@ EmulateInstructionARM::EmulateSUBSPcLrEtc (const uint32_t opcode, const ARMEncod
default:
return false;
}
- // CPSRWriteByInstr(SPSR[], Ô1111Õ, TRUE);
+ // CPSRWriteByInstr(SPSR[], '1111', TRUE);
// For now, in emulation mode, we don't have access to the SPSR, so we will use the CPSR instead, and hope for
// the best.
@@ -13076,7 +13079,7 @@ EmulateInstructionARM::ArchVersion ()
}
bool
-EmulateInstructionARM::ConditionPassed (const uint32_t opcode, bool *is_conditional)
+EmulateInstructionARM::ConditionPassed (const uint32_t opcode)
{
// If we are ignoring conditions, then always return true.
// this allows us to iterate over disassembly code and still
@@ -13084,12 +13087,8 @@ EmulateInstructionARM::ConditionPassed (const uint32_t opcode, bool *is_conditio
// bits set in the CPSR register...
if (m_ignore_conditions)
return true;
-
- if (is_conditional)
- *is_conditional = true;
const uint32_t cond = CurrentCond (opcode);
-
if (cond == UINT32_MAX)
return false;
@@ -13149,8 +13148,6 @@ EmulateInstructionARM::ConditionPassed (const uint32_t opcode, bool *is_conditio
case 7:
// Always execute (cond == 0b1110, or the special 0b1111 which gives
// opcodes different meanings, but always means execution happens.
- if (is_conditional)
- *is_conditional = false;
return true;
}
@@ -13643,6 +13640,13 @@ EmulateInstructionARM::EvaluateInstruction (uint32_t evaluate_options)
}
bool
+EmulateInstructionARM::IsInstructionConditional()
+{
+ const uint32_t cond = CurrentCond (m_opcode.GetOpcode32());
+ return cond != 0xe && cond != 0xf && cond != UINT32_MAX;
+}
+
+bool
EmulateInstructionARM::TestEmulation (Stream *out_stream, ArchSpec &arch, OptionValueDictionary *test_data)
{
if (!test_data)
diff --git a/source/Plugins/Instruction/ARM/EmulateInstructionARM.h b/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
index d107ca6bc702..893f43f19977 100644
--- a/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
+++ b/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
@@ -94,20 +94,20 @@ public:
return false;
}
- virtual lldb_private::ConstString
- GetPluginName()
+ lldb_private::ConstString
+ GetPluginName() override
{
return GetPluginNameStatic();
}
- virtual uint32_t
- GetPluginVersion()
+ uint32_t
+ GetPluginVersion() override
{
return 1;
}
bool
- SetTargetTriple (const ArchSpec &arch);
+ SetTargetTriple (const ArchSpec &arch) override;
enum Mode
{
@@ -148,8 +148,8 @@ public:
// {
// }
- virtual bool
- SupportsEmulatingInstructionsOfType (InstructionType inst_type)
+ bool
+ SupportsEmulatingInstructionsOfType (InstructionType inst_type) override
{
return SupportsEmulatingInstructionsOfTypeStatic (inst_type);
}
@@ -157,32 +157,32 @@ public:
virtual bool
SetArchitecture (const ArchSpec &arch);
- virtual bool
- ReadInstruction ();
+ bool
+ ReadInstruction () override;
- virtual bool
- SetInstruction (const Opcode &insn_opcode, const Address &inst_addr, Target *target);
+ bool
+ SetInstruction (const Opcode &insn_opcode, const Address &inst_addr, Target *target) override;
- virtual bool
- EvaluateInstruction (uint32_t evaluate_options);
-
- virtual bool
- TestEmulation (Stream *out_stream, ArchSpec &arch, OptionValueDictionary *test_data);
+ bool
+ EvaluateInstruction (uint32_t evaluate_options) override;
- virtual bool
- GetRegisterInfo (lldb::RegisterKind reg_kind, uint32_t reg_num, RegisterInfo &reg_info);
-
+ bool
+ IsInstructionConditional() override;
- virtual bool
- CreateFunctionEntryUnwind (UnwindPlan &unwind_plan);
+ bool
+ TestEmulation (Stream *out_stream, ArchSpec &arch, OptionValueDictionary *test_data) override;
+
+ bool
+ GetRegisterInfo (lldb::RegisterKind reg_kind, uint32_t reg_num, RegisterInfo &reg_info) override;
+
+ bool
+ CreateFunctionEntryUnwind (UnwindPlan &unwind_plan) override;
uint32_t
ArchVersion();
bool
- ConditionPassed (const uint32_t opcode,
- bool *is_conditional = NULL); // Filled in with true if the opcode is a conditional opcode
- // Filled in with false if the opcode is always executed
+ ConditionPassed (const uint32_t opcode);
uint32_t
CurrentCond (const uint32_t opcode);
diff --git a/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp b/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
index 992df1fba59e..372ccf9b05f4 100644
--- a/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
+++ b/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
@@ -231,58 +231,72 @@ EmulateInstructionARM64::GetOpcodeForInstruction (const uint32_t opcode)
//----------------------------------------------------------------------
// push register(s)
- { 0xff000000, 0xd1000000, No_VFP, &EmulateInstructionARM64::Emulate_addsub_imm, "SUB <Xd|SP>, <Xn|SP>, #<imm> {, <shift>}" },
- { 0xff000000, 0xf1000000, No_VFP, &EmulateInstructionARM64::Emulate_addsub_imm, "SUBS <Xd>, <Xn|SP>, #<imm> {, <shift>}" },
- { 0xff000000, 0x91000000, No_VFP, &EmulateInstructionARM64::Emulate_addsub_imm, "ADD <Xd|SP>, <Xn|SP>, #<imm> {, <shift>}" },
- { 0xff000000, 0xb1000000, No_VFP, &EmulateInstructionARM64::Emulate_addsub_imm, "ADDS <Xd>, <Xn|SP>, #<imm> {, <shift>}" },
-
- { 0xff000000, 0x51000000, No_VFP, &EmulateInstructionARM64::Emulate_addsub_imm, "SUB <Wd|WSP>, <Wn|WSP>, #<imm> {, <shift>}" },
- { 0xff000000, 0x71000000, No_VFP, &EmulateInstructionARM64::Emulate_addsub_imm, "SUBS <Wd>, <Wn|WSP>, #<imm> {, <shift>}" },
- { 0xff000000, 0x11000000, No_VFP, &EmulateInstructionARM64::Emulate_addsub_imm, "ADD <Wd|WSP>, <Wn|WSP>, #<imm> {, <shift>}" },
- { 0xff000000, 0x31000000, No_VFP, &EmulateInstructionARM64::Emulate_addsub_imm, "ADDS <Wd>, <Wn|WSP>, #<imm> {, <shift>}" },
-
- { 0xffc00000, 0x29000000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_off, "STP <Wt>, <Wt2>, [<Xn|SP>{, #<imm>}]" },
- { 0xffc00000, 0xa9000000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_off, "STP <Xt>, <Xt2>, [<Xn|SP>{, #<imm>}]" },
- { 0xffc00000, 0x2d000000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_off, "STP <St>, <St2>, [<Xn|SP>{, #<imm>}]" },
- { 0xffc00000, 0x6d000000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_off, "STP <Dt>, <Dt2>, [<Xn|SP>{, #<imm>}]" },
- { 0xffc00000, 0xad000000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_off, "STP <Qt>, <Qt2>, [<Xn|SP>{, #<imm>}]" },
-
- { 0xffc00000, 0x29800000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_pre, "STP <Wt>, <Wt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0xa9800000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_pre, "STP <Xt>, <Xt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0x2d800000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_pre, "STP <St>, <St2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0x6d800000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_pre, "STP <Dt>, <Dt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0xad800000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_pre, "STP <Qt>, <Qt2>, [<Xn|SP>, #<imm>]!" },
-
- { 0xffc00000, 0x28800000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_post, "STP <Wt>, <Wt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0xa8800000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_post, "STP <Xt>, <Xt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0x2c800000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_post, "STP <St>, <St2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0x6c800000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_post, "STP <Dt>, <Dt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0xac800000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_post, "STP <Qt>, <Qt2>, [<Xn|SP>, #<imm>]!" },
-
- { 0xffc00000, 0x29400000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_off, "LDP <Wt>, <Wt2>, [<Xn|SP>{, #<imm>}]" },
- { 0xffc00000, 0xa9400000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_off, "LDP <Xt>, <Xt2>, [<Xn|SP>{, #<imm>}]" },
- { 0xffc00000, 0x2d400000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_off, "LDP <St>, <St2>, [<Xn|SP>{, #<imm>}]" },
- { 0xffc00000, 0x6d400000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_off, "LDP <Dt>, <Dt2>, [<Xn|SP>{, #<imm>}]" },
- { 0xffc00000, 0xad400000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_off, "LDP <Qt>, <Qt2>, [<Xn|SP>{, #<imm>}]" },
-
- { 0xffc00000, 0x29c00000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_pre, "LDP <Wt>, <Wt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0xa9c00000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_pre, "LDP <Xt>, <Xt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0x2dc00000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_pre, "LDP <St>, <St2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0x6dc00000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_pre, "LDP <Dt>, <Dt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0xadc00000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_pre, "LDP <Qt>, <Qt2>, [<Xn|SP>, #<imm>]!" },
-
- { 0xffc00000, 0x28c00000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_post, "LDP <Wt>, <Wt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0xa8c00000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_post, "LDP <Xt>, <Xt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0x2cc00000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_post, "LDP <St>, <St2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0x6cc00000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_post, "LDP <Dt>, <Dt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0xacc00000, No_VFP, &EmulateInstructionARM64::Emulate_ldstpair_post, "LDP <Qt>, <Qt2>, [<Xn|SP>, #<imm>]!" },
-
- { 0xfc000000, 0x14000000, No_VFP, &EmulateInstructionARM64::EmulateB, "B <label>" },
- { 0xff000010, 0x54000000, No_VFP, &EmulateInstructionARM64::EmulateBcond, "B.<cond> <label>" },
- { 0x7f000000, 0x34000000, No_VFP, &EmulateInstructionARM64::EmulateCBZ, "CBZ <Wt>, <label>" },
- { 0x7f000000, 0x35000000, No_VFP, &EmulateInstructionARM64::EmulateCBZ, "CBNZ <Wt>, <label>" },
- { 0x7f000000, 0x36000000, No_VFP, &EmulateInstructionARM64::EmulateTBZ, "TBZ <R><t>, #<imm>, <label>" },
- { 0x7f000000, 0x37000000, No_VFP, &EmulateInstructionARM64::EmulateTBZ, "TBNZ <R><t>, #<imm>, <label>" },
+ { 0xff000000, 0xd1000000, No_VFP, &EmulateInstructionARM64::EmulateADDSUBImm, "SUB <Xd|SP>, <Xn|SP>, #<imm> {, <shift>}" },
+ { 0xff000000, 0xf1000000, No_VFP, &EmulateInstructionARM64::EmulateADDSUBImm, "SUBS <Xd>, <Xn|SP>, #<imm> {, <shift>}" },
+ { 0xff000000, 0x91000000, No_VFP, &EmulateInstructionARM64::EmulateADDSUBImm, "ADD <Xd|SP>, <Xn|SP>, #<imm> {, <shift>}" },
+ { 0xff000000, 0xb1000000, No_VFP, &EmulateInstructionARM64::EmulateADDSUBImm, "ADDS <Xd>, <Xn|SP>, #<imm> {, <shift>}" },
+
+ { 0xff000000, 0x51000000, No_VFP, &EmulateInstructionARM64::EmulateADDSUBImm, "SUB <Wd|WSP>, <Wn|WSP>, #<imm> {, <shift>}" },
+ { 0xff000000, 0x71000000, No_VFP, &EmulateInstructionARM64::EmulateADDSUBImm, "SUBS <Wd>, <Wn|WSP>, #<imm> {, <shift>}" },
+ { 0xff000000, 0x11000000, No_VFP, &EmulateInstructionARM64::EmulateADDSUBImm, "ADD <Wd|WSP>, <Wn|WSP>, #<imm> {, <shift>}" },
+ { 0xff000000, 0x31000000, No_VFP, &EmulateInstructionARM64::EmulateADDSUBImm, "ADDS <Wd>, <Wn|WSP>, #<imm> {, <shift>}" },
+
+ { 0xffc00000, 0x29000000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>, "STP <Wt>, <Wt2>, [<Xn|SP>{, #<imm>}]" },
+ { 0xffc00000, 0xa9000000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>, "STP <Xt>, <Xt2>, [<Xn|SP>{, #<imm>}]" },
+ { 0xffc00000, 0x2d000000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>, "STP <St>, <St2>, [<Xn|SP>{, #<imm>}]" },
+ { 0xffc00000, 0x6d000000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>, "STP <Dt>, <Dt2>, [<Xn|SP>{, #<imm>}]" },
+ { 0xffc00000, 0xad000000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>, "STP <Qt>, <Qt2>, [<Xn|SP>{, #<imm>}]" },
+
+ { 0xffc00000, 0x29800000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>, "STP <Wt>, <Wt2>, [<Xn|SP>, #<imm>]!" },
+ { 0xffc00000, 0xa9800000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>, "STP <Xt>, <Xt2>, [<Xn|SP>, #<imm>]!" },
+ { 0xffc00000, 0x2d800000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>, "STP <St>, <St2>, [<Xn|SP>, #<imm>]!" },
+ { 0xffc00000, 0x6d800000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>, "STP <Dt>, <Dt2>, [<Xn|SP>, #<imm>]!" },
+ { 0xffc00000, 0xad800000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>, "STP <Qt>, <Qt2>, [<Xn|SP>, #<imm>]!" },
+
+ { 0xffc00000, 0x28800000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>, "STP <Wt>, <Wt2>, [<Xn|SP>, #<imm>]!" },
+ { 0xffc00000, 0xa8800000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>, "STP <Xt>, <Xt2>, [<Xn|SP>, #<imm>]!" },
+ { 0xffc00000, 0x2c800000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>, "STP <St>, <St2>, [<Xn|SP>, #<imm>]!" },
+ { 0xffc00000, 0x6c800000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>, "STP <Dt>, <Dt2>, [<Xn|SP>, #<imm>]!" },
+ { 0xffc00000, 0xac800000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>, "STP <Qt>, <Qt2>, [<Xn|SP>, #<imm>]!" },
+
+ { 0xffc00000, 0x29400000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>, "LDP <Wt>, <Wt2>, [<Xn|SP>{, #<imm>}]" },
+ { 0xffc00000, 0xa9400000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>, "LDP <Xt>, <Xt2>, [<Xn|SP>{, #<imm>}]" },
+ { 0xffc00000, 0x2d400000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>, "LDP <St>, <St2>, [<Xn|SP>{, #<imm>}]" },
+ { 0xffc00000, 0x6d400000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>, "LDP <Dt>, <Dt2>, [<Xn|SP>{, #<imm>}]" },
+ { 0xffc00000, 0xad400000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>, "LDP <Qt>, <Qt2>, [<Xn|SP>{, #<imm>}]" },
+
+ { 0xffc00000, 0x29c00000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>, "LDP <Wt>, <Wt2>, [<Xn|SP>, #<imm>]!" },
+ { 0xffc00000, 0xa9c00000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>, "LDP <Xt>, <Xt2>, [<Xn|SP>, #<imm>]!" },
+ { 0xffc00000, 0x2dc00000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>, "LDP <St>, <St2>, [<Xn|SP>, #<imm>]!" },
+ { 0xffc00000, 0x6dc00000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>, "LDP <Dt>, <Dt2>, [<Xn|SP>, #<imm>]!" },
+ { 0xffc00000, 0xadc00000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>, "LDP <Qt>, <Qt2>, [<Xn|SP>, #<imm>]!" },
+
+ { 0xffc00000, 0x28c00000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>, "LDP <Wt>, <Wt2>, [<Xn|SP>, #<imm>]!" },
+ { 0xffc00000, 0xa8c00000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>, "LDP <Xt>, <Xt2>, [<Xn|SP>, #<imm>]!" },
+ { 0xffc00000, 0x2cc00000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>, "LDP <St>, <St2>, [<Xn|SP>, #<imm>]!" },
+ { 0xffc00000, 0x6cc00000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>, "LDP <Dt>, <Dt2>, [<Xn|SP>, #<imm>]!" },
+ { 0xffc00000, 0xacc00000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>, "LDP <Qt>, <Qt2>, [<Xn|SP>, #<imm>]!" },
+
+ { 0xffe00c00, 0xb8000400, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_POST>, "STR <Wt>, [<Xn|SP>], #<simm>" },
+ { 0xffe00c00, 0xf8000400, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_POST>, "STR <Xt>, [<Xn|SP>], #<simm>" },
+ { 0xffe00c00, 0xb8000c00, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_PRE>, "STR <Wt>, [<Xn|SP>, #<simm>]!" },
+ { 0xffe00c00, 0xf8000c00, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_PRE>, "STR <Xt>, [<Xn|SP>, #<simm>]!" },
+ { 0xffc00000, 0xb9000000, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_OFF>, "STR <Wt>, [<Xn|SP>{, #<pimm>}]" },
+ { 0xffc00000, 0xf9000000, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_OFF>, "STR <Xt>, [<Xn|SP>{, #<pimm>}]" },
+
+ { 0xffe00c00, 0xb8400400, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_POST>, "LDR <Wt>, [<Xn|SP>], #<simm>" },
+ { 0xffe00c00, 0xf8400400, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_POST>, "LDR <Xt>, [<Xn|SP>], #<simm>" },
+ { 0xffe00c00, 0xb8400c00, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_PRE>, "LDR <Wt>, [<Xn|SP>, #<simm>]!" },
+ { 0xffe00c00, 0xf8400c00, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_PRE>, "LDR <Xt>, [<Xn|SP>, #<simm>]!" },
+ { 0xffc00000, 0xb9400000, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_OFF>, "LDR <Wt>, [<Xn|SP>{, #<pimm>}]" },
+ { 0xffc00000, 0xf9400000, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_OFF>, "LDR <Xt>, [<Xn|SP>{, #<pimm>}]" },
+
+ { 0xfc000000, 0x14000000, No_VFP, &EmulateInstructionARM64::EmulateB, "B <label>" },
+ { 0xff000010, 0x54000000, No_VFP, &EmulateInstructionARM64::EmulateBcond, "B.<cond> <label>" },
+ { 0x7f000000, 0x34000000, No_VFP, &EmulateInstructionARM64::EmulateCBZ, "CBZ <Wt>, <label>" },
+ { 0x7f000000, 0x35000000, No_VFP, &EmulateInstructionARM64::EmulateCBZ, "CBNZ <Wt>, <label>" },
+ { 0x7f000000, 0x36000000, No_VFP, &EmulateInstructionARM64::EmulateTBZ, "TBZ <R><t>, #<imm>, <label>" },
+ { 0x7f000000, 0x37000000, No_VFP, &EmulateInstructionARM64::EmulateTBZ, "TBNZ <R><t>, #<imm>, <label>" },
};
static const size_t k_num_arm_opcodes = llvm::array_lengthof(g_opcodes);
@@ -391,7 +405,7 @@ EmulateInstructionARM64::CreateFunctionEntryUnwind (UnwindPlan &unwind_plan)
uint32_t
EmulateInstructionARM64::GetFramePointerRegisterNumber () const
{
- if (m_arch.GetTriple().getEnvironment() == llvm::Triple::Android)
+ if (m_arch.GetTriple().isAndroid())
return LLDB_INVALID_REGNUM; // Don't use frame pointer on android
return arm64_dwarf::sp;
@@ -462,7 +476,7 @@ EmulateInstructionARM64::BranchTo (const Context &context, uint32_t N, addr_t ta
}
bool
-EmulateInstructionARM64::ConditionHolds (const uint32_t cond, bool *is_conditional)
+EmulateInstructionARM64::ConditionHolds (const uint32_t cond)
{
// If we are ignoring conditions, then always return true.
// this allows us to iterate over disassembly code and still
@@ -470,10 +484,7 @@ EmulateInstructionARM64::ConditionHolds (const uint32_t cond, bool *is_condition
// bits set in the CPSR register...
if (m_ignore_conditions)
return true;
-
- if (is_conditional)
- *is_conditional = true;
-
+
bool result = false;
switch (UnsignedBits(cond, 3, 1))
{
@@ -499,19 +510,18 @@ EmulateInstructionARM64::ConditionHolds (const uint32_t cond, bool *is_condition
result = (m_opcode_pstate.N == m_opcode_pstate.V && m_opcode_pstate.Z == 0);
break;
case 7:
- result = true;
- if (is_conditional)
- *is_conditional = false;
- break;
+ // Always execute (cond == 0b1110, or the special 0b1111 which gives
+ // opcodes different meanings, but always means execution happens.
+ return true;
}
- if (cond & 1 && cond != 15)
+ if (cond & 1)
result = !result;
return result;
}
bool
-EmulateInstructionARM64::Emulate_addsub_imm (const uint32_t opcode)
+EmulateInstructionARM64::EmulateADDSUBImm (const uint32_t opcode)
{
// integer d = UInt(Rd);
// integer n = UInt(Rn);
@@ -628,26 +638,8 @@ EmulateInstructionARM64::Emulate_addsub_imm (const uint32_t opcode)
return false;
}
-bool
-EmulateInstructionARM64::Emulate_ldstpair_off (const uint32_t opcode)
-{
- return Emulate_ldstpair (opcode, AddrMode_OFF);
-}
-
-bool
-EmulateInstructionARM64::Emulate_ldstpair_pre (const uint32_t opcode)
-{
- return Emulate_ldstpair (opcode, AddrMode_PRE);
-}
-
-bool
-EmulateInstructionARM64::Emulate_ldstpair_post (const uint32_t opcode)
-{
- return Emulate_ldstpair (opcode, AddrMode_POST);
-}
-
-bool
-EmulateInstructionARM64::Emulate_ldstpair (const uint32_t opcode, AddrMode a_mode)
+template <EmulateInstructionARM64::AddrMode a_mode> bool
+EmulateInstructionARM64::EmulateLDPSTP (const uint32_t opcode)
{
uint32_t opc = Bits32(opcode, 31, 30);
uint32_t V = Bit32(opcode, 26);
@@ -776,10 +768,6 @@ EmulateInstructionARM64::Emulate_ldstpair (const uint32_t opcode, AddrMode a_mod
Context context_t;
Context context_t2;
- context_t.type = eContextRegisterPlusOffset;
- context_t2.type = eContextRegisterPlusOffset;
- context_t.SetRegisterToRegisterPlusOffset (reg_info_Rt, reg_info_base, 0);
- context_t2.SetRegisterToRegisterPlusOffset (reg_info_Rt2, reg_info_base, size);
uint8_t buffer [RegisterValue::kMaxRegisterByteSize];
Error error;
@@ -792,6 +780,13 @@ EmulateInstructionARM64::Emulate_ldstpair (const uint32_t opcode, AddrMode a_mod
context_t.type = eContextPushRegisterOnStack;
context_t2.type = eContextPushRegisterOnStack;
}
+ else
+ {
+ context_t.type = eContextRegisterStore;
+ context_t2.type = eContextRegisterStore;
+ }
+ context_t.SetRegisterToRegisterPlusOffset (reg_info_Rt, reg_info_base, 0);
+ context_t2.SetRegisterToRegisterPlusOffset (reg_info_Rt2, reg_info_base, size);
if (!ReadRegister (&reg_info_Rt, data_Rt))
return false;
@@ -820,6 +815,13 @@ EmulateInstructionARM64::Emulate_ldstpair (const uint32_t opcode, AddrMode a_mod
context_t.type = eContextPopRegisterOffStack;
context_t2.type = eContextPopRegisterOffStack;
}
+ else
+ {
+ context_t.type = eContextRegisterLoad;
+ context_t2.type = eContextRegisterLoad;
+ }
+ context_t.SetAddress(address);
+ context_t2.SetAddress(address + size);
if (rt_unknown)
memset (buffer, 'U', reg_info_Rt.byte_size);
@@ -874,6 +876,132 @@ EmulateInstructionARM64::Emulate_ldstpair (const uint32_t opcode, AddrMode a_mod
return true;
}
+template <EmulateInstructionARM64::AddrMode a_mode> bool
+EmulateInstructionARM64::EmulateLDRSTRImm (const uint32_t opcode)
+{
+ uint32_t size = Bits32(opcode, 31, 30);
+ uint32_t opc = Bits32(opcode, 23, 22);
+ uint32_t n = Bits32(opcode, 9, 5);
+ uint32_t t = Bits32(opcode, 4, 0);
+
+ bool wback;
+ bool postindex;
+ uint64_t offset;
+
+ switch (a_mode)
+ {
+ case AddrMode_POST:
+ wback = true;
+ postindex = true;
+ offset = llvm::SignExtend64<9>(Bits32(opcode, 20, 12));
+ break;
+ case AddrMode_PRE:
+ wback = true;
+ postindex = false;
+ offset = llvm::SignExtend64<9>(Bits32(opcode, 20, 12));
+ break;
+ case AddrMode_OFF:
+ wback = false;
+ postindex = false;
+ offset = LSL(Bits32(opcode, 21, 10), size);
+ break;
+ }
+
+ MemOp memop;
+
+ if (Bit32(opc, 1) == 0)
+ {
+ memop = Bit32(opc, 0) == 1 ? MemOp_LOAD : MemOp_STORE;
+ }
+ else
+ {
+ memop = MemOp_LOAD;
+ if (size == 2 && Bit32(opc, 0) == 1)
+ return false;
+ }
+
+ Error error;
+ bool success = false;
+ uint64_t address;
+ uint8_t buffer[RegisterValue::kMaxRegisterByteSize];
+ RegisterValue data_Rt;
+
+ if (n == 31)
+ address = ReadRegisterUnsigned (eRegisterKindDWARF, arm64_dwarf::sp, 0, &success);
+ else
+ address = ReadRegisterUnsigned (eRegisterKindDWARF, arm64_dwarf::x0 + n, 0, &success);
+
+ if (!success)
+ return false;
+
+ if (!postindex)
+ address += offset;
+
+ RegisterInfo reg_info_base;
+ if (!GetRegisterInfo (eRegisterKindDWARF, arm64_dwarf::x0 + n, reg_info_base))
+ return false;
+
+ RegisterInfo reg_info_Rt;
+ if (!GetRegisterInfo (eRegisterKindDWARF, arm64_dwarf::x0 + t, reg_info_Rt))
+ return false;
+
+ Context context;
+ switch (memop)
+ {
+ case MemOp_STORE:
+ if (n == 31 || n == GetFramePointerRegisterNumber()) // if this store is based off of the sp or fp register
+ context.type = eContextPushRegisterOnStack;
+ else
+ context.type = eContextRegisterStore;
+ context.SetRegisterToRegisterPlusOffset (reg_info_Rt, reg_info_base, postindex ? 0 : offset);
+
+ if (!ReadRegister (&reg_info_Rt, data_Rt))
+ return false;
+
+ if (data_Rt.GetAsMemoryData(&reg_info_Rt, buffer, reg_info_Rt.byte_size, eByteOrderLittle, error) == 0)
+ return false;
+
+ if (!WriteMemory(context, address, buffer, reg_info_Rt.byte_size))
+ return false;
+ break;
+
+ case MemOp_LOAD:
+ if (n == 31 || n == GetFramePointerRegisterNumber()) // if this store is based off of the sp or fp register
+ context.type = eContextPopRegisterOffStack;
+ else
+ context.type = eContextRegisterLoad;
+ context.SetAddress(address);
+
+ if (!ReadMemory (context, address, buffer, reg_info_Rt.byte_size))
+ return false;
+
+ if (data_Rt.SetFromMemoryData(&reg_info_Rt, buffer, reg_info_Rt.byte_size, eByteOrderLittle, error) == 0)
+ return false;
+
+ if (!WriteRegister (context, &reg_info_Rt, data_Rt))
+ return false;
+
+ default:
+ return false;
+ }
+
+ if (wback)
+ {
+ if (postindex)
+ address += offset;
+
+ if (n == 31)
+ context.type = eContextAdjustStackPointer;
+ else
+ context.type = eContextAdjustBaseRegister;
+ context.SetImmediateSigned (offset);
+
+ if (!WriteRegisterUnsigned (context, &reg_info_base, address))
+ return false;
+ }
+ return true;
+}
+
bool
EmulateInstructionARM64::EmulateB (const uint32_t opcode)
{
diff --git a/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h b/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h
index b74eddeaaf63..d9333c2824d2 100644
--- a/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h
+++ b/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h
@@ -1,4 +1,4 @@
-//===-- EmulateInstructionARM64.h ------------------------------------*- C++ -*-===//
+//===-- EmulateInstructionARM64.h -------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,6 +10,10 @@
#ifndef EmulateInstructionARM64_h_
#define EmulateInstructionARM64_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Core/EmulateInstruction.h"
#include "lldb/Core/Error.h"
#include "lldb/Interpreter/OptionValue.h"
@@ -18,6 +22,14 @@
class EmulateInstructionARM64 : public lldb_private::EmulateInstruction
{
public:
+ EmulateInstructionARM64 (const lldb_private::ArchSpec &arch) :
+ EmulateInstruction (arch),
+ m_opcode_pstate (),
+ m_emulated_pstate (),
+ m_ignore_conditions (false)
+ {
+ }
+
static void
Initialize ();
@@ -50,61 +62,46 @@ public:
return false;
}
- virtual lldb_private::ConstString
- GetPluginName();
-
- virtual lldb_private::ConstString
- GetShortPluginName()
- {
- return GetPluginNameStatic();
- }
+ lldb_private::ConstString
+ GetPluginName() override;
- virtual uint32_t
- GetPluginVersion()
+ uint32_t
+ GetPluginVersion() override
{
return 1;
}
bool
- SetTargetTriple (const lldb_private::ArchSpec &arch);
+ SetTargetTriple(const lldb_private::ArchSpec &arch) override;
- EmulateInstructionARM64 (const lldb_private::ArchSpec &arch) :
- EmulateInstruction (arch),
- m_opcode_pstate (),
- m_emulated_pstate (),
- m_ignore_conditions (false)
- {
- }
-
- virtual bool
- SupportsEmulatingInstructionsOfType (lldb_private::InstructionType inst_type)
+ bool
+ SupportsEmulatingInstructionsOfType(lldb_private::InstructionType inst_type) override
{
return SupportsEmulatingInstructionsOfTypeStatic (inst_type);
}
- virtual bool
- ReadInstruction ();
+ bool
+ ReadInstruction() override;
- virtual bool
- EvaluateInstruction (uint32_t evaluate_options);
+ bool
+ EvaluateInstruction(uint32_t evaluate_options) override;
- virtual bool
- TestEmulation (lldb_private::Stream *out_stream,
- lldb_private::ArchSpec &arch,
- lldb_private::OptionValueDictionary *test_data)
+ bool
+ TestEmulation(lldb_private::Stream *out_stream,
+ lldb_private::ArchSpec &arch,
+ lldb_private::OptionValueDictionary *test_data) override
{
return false;
}
- virtual bool
- GetRegisterInfo (lldb::RegisterKind reg_kind,
- uint32_t reg_num,
- lldb_private::RegisterInfo &reg_info);
+ bool
+ GetRegisterInfo(lldb::RegisterKind reg_kind,
+ uint32_t reg_num,
+ lldb_private::RegisterInfo &reg_info) override;
- virtual bool
- CreateFunctionEntryUnwind (lldb_private::UnwindPlan &unwind_plan);
+ bool
+ CreateFunctionEntryUnwind(lldb_private::UnwindPlan &unwind_plan) override;
-
typedef enum
{
AddrMode_OFF,
@@ -141,7 +138,6 @@ public:
BitwiseOp_NOT,
BitwiseOp_RBIT
} BitwiseOp;
-
typedef enum
{
@@ -252,7 +248,6 @@ public:
} ProcState;
protected:
-
typedef struct
{
uint32_t mask;
@@ -272,25 +267,19 @@ protected:
BranchTo (const Context &context, uint32_t N, lldb::addr_t target);
bool
- ConditionHolds (const uint32_t cond, bool *is_conditional = nullptr);
+ ConditionHolds (const uint32_t cond);
bool
UsingAArch32 ();
bool
- Emulate_addsub_imm (const uint32_t opcode);
-
- bool
- Emulate_ldstpair_off (const uint32_t opcode);
+ EmulateADDSUBImm (const uint32_t opcode);
- bool
- Emulate_ldstpair_pre (const uint32_t opcode);
-
- bool
- Emulate_ldstpair_post (const uint32_t opcode);
+ template <AddrMode a_mode> bool
+ EmulateLDPSTP (const uint32_t opcode);
- bool
- Emulate_ldstpair (const uint32_t opcode, AddrMode a_mode);
+ template <AddrMode a_mode> bool
+ EmulateLDRSTRImm (const uint32_t opcode);
bool
EmulateB (const uint32_t opcode);
@@ -309,4 +298,4 @@ protected:
bool m_ignore_conditions;
};
-#endif // EmulateInstructionARM64_h_
+#endif // EmulateInstructionARM64_h_
diff --git a/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp b/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
index 66866c73a5cb..d6485f686e2c 100644
--- a/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
+++ b/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
@@ -29,6 +29,7 @@
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Stream.h"
#include "lldb/Symbol/UnwindPlan.h"
+#include "lldb/Target/Target.h"
#include "llvm/ADT/STLExtras.h"
@@ -132,10 +133,6 @@ EmulateInstructionMIPS::EmulateInstructionMIPS (const lldb_private::ArchSpec &ar
features += "+dsp,";
if (arch_flags & ArchSpec::eMIPSAse_dspr2)
features += "+dspr2,";
- if (arch_flags & ArchSpec::eMIPSAse_mips16)
- features += "+mips16,";
- if (arch_flags & ArchSpec::eMIPSAse_micromips)
- features += "+micromips,";
m_reg_info.reset (target->createMCRegInfo (triple.getTriple()));
assert (m_reg_info.get());
@@ -152,6 +149,21 @@ EmulateInstructionMIPS::EmulateInstructionMIPS (const lldb_private::ArchSpec &ar
m_disasm.reset (target->createMCDisassembler (*m_subtype_info, *m_context));
assert (m_disasm.get());
+
+ /* Create alternate disassembler for microMIPS */
+ if (arch_flags & ArchSpec::eMIPSAse_mips16)
+ features += "+mips16,";
+ else if (arch_flags & ArchSpec::eMIPSAse_micromips)
+ features += "+micromips,";
+
+ m_alt_subtype_info.reset (target->createMCSubtargetInfo (triple.getTriple(), cpu, features));
+ assert (m_alt_subtype_info.get());
+
+ m_alt_disasm.reset (target->createMCDisassembler (*m_alt_subtype_info, *m_context));
+ assert (m_alt_disasm.get());
+
+ m_next_inst_size = 0;
+ m_use_alt_disaasm = false;
}
void
@@ -221,41 +233,76 @@ EmulateInstructionMIPS::GetRegisterName (unsigned reg_num, bool alternate_name)
{
switch (reg_num)
{
- case gcc_dwarf_sp_mips: return "r29";
- case gcc_dwarf_r30_mips: return "r30";
- case gcc_dwarf_ra_mips: return "r31";
- case gcc_dwarf_f0_mips: return "f0";
- case gcc_dwarf_f1_mips: return "f1";
- case gcc_dwarf_f2_mips: return "f2";
- case gcc_dwarf_f3_mips: return "f3";
- case gcc_dwarf_f4_mips: return "f4";
- case gcc_dwarf_f5_mips: return "f5";
- case gcc_dwarf_f6_mips: return "f6";
- case gcc_dwarf_f7_mips: return "f7";
- case gcc_dwarf_f8_mips: return "f8";
- case gcc_dwarf_f9_mips: return "f9";
- case gcc_dwarf_f10_mips: return "f10";
- case gcc_dwarf_f11_mips: return "f11";
- case gcc_dwarf_f12_mips: return "f12";
- case gcc_dwarf_f13_mips: return "f13";
- case gcc_dwarf_f14_mips: return "f14";
- case gcc_dwarf_f15_mips: return "f15";
- case gcc_dwarf_f16_mips: return "f16";
- case gcc_dwarf_f17_mips: return "f17";
- case gcc_dwarf_f18_mips: return "f18";
- case gcc_dwarf_f19_mips: return "f19";
- case gcc_dwarf_f20_mips: return "f20";
- case gcc_dwarf_f21_mips: return "f21";
- case gcc_dwarf_f22_mips: return "f22";
- case gcc_dwarf_f23_mips: return "f23";
- case gcc_dwarf_f24_mips: return "f24";
- case gcc_dwarf_f25_mips: return "f25";
- case gcc_dwarf_f26_mips: return "f26";
- case gcc_dwarf_f27_mips: return "f27";
- case gcc_dwarf_f28_mips: return "f28";
- case gcc_dwarf_f29_mips: return "f29";
- case gcc_dwarf_f30_mips: return "f30";
- case gcc_dwarf_f31_mips: return "f31";
+ case dwarf_sp_mips: return "r29";
+ case dwarf_r30_mips: return "r30";
+ case dwarf_ra_mips: return "r31";
+ case dwarf_f0_mips: return "f0";
+ case dwarf_f1_mips: return "f1";
+ case dwarf_f2_mips: return "f2";
+ case dwarf_f3_mips: return "f3";
+ case dwarf_f4_mips: return "f4";
+ case dwarf_f5_mips: return "f5";
+ case dwarf_f6_mips: return "f6";
+ case dwarf_f7_mips: return "f7";
+ case dwarf_f8_mips: return "f8";
+ case dwarf_f9_mips: return "f9";
+ case dwarf_f10_mips: return "f10";
+ case dwarf_f11_mips: return "f11";
+ case dwarf_f12_mips: return "f12";
+ case dwarf_f13_mips: return "f13";
+ case dwarf_f14_mips: return "f14";
+ case dwarf_f15_mips: return "f15";
+ case dwarf_f16_mips: return "f16";
+ case dwarf_f17_mips: return "f17";
+ case dwarf_f18_mips: return "f18";
+ case dwarf_f19_mips: return "f19";
+ case dwarf_f20_mips: return "f20";
+ case dwarf_f21_mips: return "f21";
+ case dwarf_f22_mips: return "f22";
+ case dwarf_f23_mips: return "f23";
+ case dwarf_f24_mips: return "f24";
+ case dwarf_f25_mips: return "f25";
+ case dwarf_f26_mips: return "f26";
+ case dwarf_f27_mips: return "f27";
+ case dwarf_f28_mips: return "f28";
+ case dwarf_f29_mips: return "f29";
+ case dwarf_f30_mips: return "f30";
+ case dwarf_f31_mips: return "f31";
+ case dwarf_w0_mips: return "w0";
+ case dwarf_w1_mips: return "w1";
+ case dwarf_w2_mips: return "w2";
+ case dwarf_w3_mips: return "w3";
+ case dwarf_w4_mips: return "w4";
+ case dwarf_w5_mips: return "w5";
+ case dwarf_w6_mips: return "w6";
+ case dwarf_w7_mips: return "w7";
+ case dwarf_w8_mips: return "w8";
+ case dwarf_w9_mips: return "w9";
+ case dwarf_w10_mips: return "w10";
+ case dwarf_w11_mips: return "w11";
+ case dwarf_w12_mips: return "w12";
+ case dwarf_w13_mips: return "w13";
+ case dwarf_w14_mips: return "w14";
+ case dwarf_w15_mips: return "w15";
+ case dwarf_w16_mips: return "w16";
+ case dwarf_w17_mips: return "w17";
+ case dwarf_w18_mips: return "w18";
+ case dwarf_w19_mips: return "w19";
+ case dwarf_w20_mips: return "w20";
+ case dwarf_w21_mips: return "w21";
+ case dwarf_w22_mips: return "w22";
+ case dwarf_w23_mips: return "w23";
+ case dwarf_w24_mips: return "w24";
+ case dwarf_w25_mips: return "w25";
+ case dwarf_w26_mips: return "w26";
+ case dwarf_w27_mips: return "w27";
+ case dwarf_w28_mips: return "w28";
+ case dwarf_w29_mips: return "w29";
+ case dwarf_w30_mips: return "w30";
+ case dwarf_w31_mips: return "w31";
+ case dwarf_mir_mips: return "mir";
+ case dwarf_mcsr_mips: return "mcsr";
+ case dwarf_config5_mips: return "config5";
default:
break;
}
@@ -264,78 +311,113 @@ EmulateInstructionMIPS::GetRegisterName (unsigned reg_num, bool alternate_name)
switch (reg_num)
{
- case gcc_dwarf_zero_mips: return "r0";
- case gcc_dwarf_r1_mips: return "r1";
- case gcc_dwarf_r2_mips: return "r2";
- case gcc_dwarf_r3_mips: return "r3";
- case gcc_dwarf_r4_mips: return "r4";
- case gcc_dwarf_r5_mips: return "r5";
- case gcc_dwarf_r6_mips: return "r6";
- case gcc_dwarf_r7_mips: return "r7";
- case gcc_dwarf_r8_mips: return "r8";
- case gcc_dwarf_r9_mips: return "r9";
- case gcc_dwarf_r10_mips: return "r10";
- case gcc_dwarf_r11_mips: return "r11";
- case gcc_dwarf_r12_mips: return "r12";
- case gcc_dwarf_r13_mips: return "r13";
- case gcc_dwarf_r14_mips: return "r14";
- case gcc_dwarf_r15_mips: return "r15";
- case gcc_dwarf_r16_mips: return "r16";
- case gcc_dwarf_r17_mips: return "r17";
- case gcc_dwarf_r18_mips: return "r18";
- case gcc_dwarf_r19_mips: return "r19";
- case gcc_dwarf_r20_mips: return "r20";
- case gcc_dwarf_r21_mips: return "r21";
- case gcc_dwarf_r22_mips: return "r22";
- case gcc_dwarf_r23_mips: return "r23";
- case gcc_dwarf_r24_mips: return "r24";
- case gcc_dwarf_r25_mips: return "r25";
- case gcc_dwarf_r26_mips: return "r26";
- case gcc_dwarf_r27_mips: return "r27";
- case gcc_dwarf_gp_mips: return "gp";
- case gcc_dwarf_sp_mips: return "sp";
- case gcc_dwarf_r30_mips: return "fp";
- case gcc_dwarf_ra_mips: return "ra";
- case gcc_dwarf_sr_mips: return "sr";
- case gcc_dwarf_lo_mips: return "lo";
- case gcc_dwarf_hi_mips: return "hi";
- case gcc_dwarf_bad_mips: return "bad";
- case gcc_dwarf_cause_mips: return "cause";
- case gcc_dwarf_pc_mips: return "pc";
- case gcc_dwarf_f0_mips: return "f0";
- case gcc_dwarf_f1_mips: return "f1";
- case gcc_dwarf_f2_mips: return "f2";
- case gcc_dwarf_f3_mips: return "f3";
- case gcc_dwarf_f4_mips: return "f4";
- case gcc_dwarf_f5_mips: return "f5";
- case gcc_dwarf_f6_mips: return "f6";
- case gcc_dwarf_f7_mips: return "f7";
- case gcc_dwarf_f8_mips: return "f8";
- case gcc_dwarf_f9_mips: return "f9";
- case gcc_dwarf_f10_mips: return "f10";
- case gcc_dwarf_f11_mips: return "f11";
- case gcc_dwarf_f12_mips: return "f12";
- case gcc_dwarf_f13_mips: return "f13";
- case gcc_dwarf_f14_mips: return "f14";
- case gcc_dwarf_f15_mips: return "f15";
- case gcc_dwarf_f16_mips: return "f16";
- case gcc_dwarf_f17_mips: return "f17";
- case gcc_dwarf_f18_mips: return "f18";
- case gcc_dwarf_f19_mips: return "f19";
- case gcc_dwarf_f20_mips: return "f20";
- case gcc_dwarf_f21_mips: return "f21";
- case gcc_dwarf_f22_mips: return "f22";
- case gcc_dwarf_f23_mips: return "f23";
- case gcc_dwarf_f24_mips: return "f24";
- case gcc_dwarf_f25_mips: return "f25";
- case gcc_dwarf_f26_mips: return "f26";
- case gcc_dwarf_f27_mips: return "f27";
- case gcc_dwarf_f28_mips: return "f28";
- case gcc_dwarf_f29_mips: return "f29";
- case gcc_dwarf_f30_mips: return "f30";
- case gcc_dwarf_f31_mips: return "f31";
- case gcc_dwarf_fcsr_mips: return "fcsr";
- case gcc_dwarf_fir_mips: return "fir";
+ case dwarf_zero_mips: return "r0";
+ case dwarf_r1_mips: return "r1";
+ case dwarf_r2_mips: return "r2";
+ case dwarf_r3_mips: return "r3";
+ case dwarf_r4_mips: return "r4";
+ case dwarf_r5_mips: return "r5";
+ case dwarf_r6_mips: return "r6";
+ case dwarf_r7_mips: return "r7";
+ case dwarf_r8_mips: return "r8";
+ case dwarf_r9_mips: return "r9";
+ case dwarf_r10_mips: return "r10";
+ case dwarf_r11_mips: return "r11";
+ case dwarf_r12_mips: return "r12";
+ case dwarf_r13_mips: return "r13";
+ case dwarf_r14_mips: return "r14";
+ case dwarf_r15_mips: return "r15";
+ case dwarf_r16_mips: return "r16";
+ case dwarf_r17_mips: return "r17";
+ case dwarf_r18_mips: return "r18";
+ case dwarf_r19_mips: return "r19";
+ case dwarf_r20_mips: return "r20";
+ case dwarf_r21_mips: return "r21";
+ case dwarf_r22_mips: return "r22";
+ case dwarf_r23_mips: return "r23";
+ case dwarf_r24_mips: return "r24";
+ case dwarf_r25_mips: return "r25";
+ case dwarf_r26_mips: return "r26";
+ case dwarf_r27_mips: return "r27";
+ case dwarf_gp_mips: return "gp";
+ case dwarf_sp_mips: return "sp";
+ case dwarf_r30_mips: return "fp";
+ case dwarf_ra_mips: return "ra";
+ case dwarf_sr_mips: return "sr";
+ case dwarf_lo_mips: return "lo";
+ case dwarf_hi_mips: return "hi";
+ case dwarf_bad_mips: return "bad";
+ case dwarf_cause_mips: return "cause";
+ case dwarf_pc_mips: return "pc";
+ case dwarf_f0_mips: return "f0";
+ case dwarf_f1_mips: return "f1";
+ case dwarf_f2_mips: return "f2";
+ case dwarf_f3_mips: return "f3";
+ case dwarf_f4_mips: return "f4";
+ case dwarf_f5_mips: return "f5";
+ case dwarf_f6_mips: return "f6";
+ case dwarf_f7_mips: return "f7";
+ case dwarf_f8_mips: return "f8";
+ case dwarf_f9_mips: return "f9";
+ case dwarf_f10_mips: return "f10";
+ case dwarf_f11_mips: return "f11";
+ case dwarf_f12_mips: return "f12";
+ case dwarf_f13_mips: return "f13";
+ case dwarf_f14_mips: return "f14";
+ case dwarf_f15_mips: return "f15";
+ case dwarf_f16_mips: return "f16";
+ case dwarf_f17_mips: return "f17";
+ case dwarf_f18_mips: return "f18";
+ case dwarf_f19_mips: return "f19";
+ case dwarf_f20_mips: return "f20";
+ case dwarf_f21_mips: return "f21";
+ case dwarf_f22_mips: return "f22";
+ case dwarf_f23_mips: return "f23";
+ case dwarf_f24_mips: return "f24";
+ case dwarf_f25_mips: return "f25";
+ case dwarf_f26_mips: return "f26";
+ case dwarf_f27_mips: return "f27";
+ case dwarf_f28_mips: return "f28";
+ case dwarf_f29_mips: return "f29";
+ case dwarf_f30_mips: return "f30";
+ case dwarf_f31_mips: return "f31";
+ case dwarf_fcsr_mips: return "fcsr";
+ case dwarf_fir_mips: return "fir";
+ case dwarf_w0_mips: return "w0";
+ case dwarf_w1_mips: return "w1";
+ case dwarf_w2_mips: return "w2";
+ case dwarf_w3_mips: return "w3";
+ case dwarf_w4_mips: return "w4";
+ case dwarf_w5_mips: return "w5";
+ case dwarf_w6_mips: return "w6";
+ case dwarf_w7_mips: return "w7";
+ case dwarf_w8_mips: return "w8";
+ case dwarf_w9_mips: return "w9";
+ case dwarf_w10_mips: return "w10";
+ case dwarf_w11_mips: return "w11";
+ case dwarf_w12_mips: return "w12";
+ case dwarf_w13_mips: return "w13";
+ case dwarf_w14_mips: return "w14";
+ case dwarf_w15_mips: return "w15";
+ case dwarf_w16_mips: return "w16";
+ case dwarf_w17_mips: return "w17";
+ case dwarf_w18_mips: return "w18";
+ case dwarf_w19_mips: return "w19";
+ case dwarf_w20_mips: return "w20";
+ case dwarf_w21_mips: return "w21";
+ case dwarf_w22_mips: return "w22";
+ case dwarf_w23_mips: return "w23";
+ case dwarf_w24_mips: return "w24";
+ case dwarf_w25_mips: return "w25";
+ case dwarf_w26_mips: return "w26";
+ case dwarf_w27_mips: return "w27";
+ case dwarf_w28_mips: return "w28";
+ case dwarf_w29_mips: return "w29";
+ case dwarf_w30_mips: return "w30";
+ case dwarf_w31_mips: return "w31";
+ case dwarf_mcsr_mips: return "mcsr";
+ case dwarf_mir_mips: return "mir";
+ case dwarf_config5_mips: return "config5";
}
return nullptr;
}
@@ -347,11 +429,11 @@ EmulateInstructionMIPS::GetRegisterInfo (RegisterKind reg_kind, uint32_t reg_num
{
switch (reg_num)
{
- case LLDB_REGNUM_GENERIC_PC: reg_kind = eRegisterKindDWARF; reg_num = gcc_dwarf_pc_mips; break;
- case LLDB_REGNUM_GENERIC_SP: reg_kind = eRegisterKindDWARF; reg_num = gcc_dwarf_sp_mips; break;
- case LLDB_REGNUM_GENERIC_FP: reg_kind = eRegisterKindDWARF; reg_num = gcc_dwarf_r30_mips; break;
- case LLDB_REGNUM_GENERIC_RA: reg_kind = eRegisterKindDWARF; reg_num = gcc_dwarf_ra_mips; break;
- case LLDB_REGNUM_GENERIC_FLAGS: reg_kind = eRegisterKindDWARF; reg_num = gcc_dwarf_sr_mips; break;
+ case LLDB_REGNUM_GENERIC_PC: reg_kind = eRegisterKindDWARF; reg_num = dwarf_pc_mips; break;
+ case LLDB_REGNUM_GENERIC_SP: reg_kind = eRegisterKindDWARF; reg_num = dwarf_sp_mips; break;
+ case LLDB_REGNUM_GENERIC_FP: reg_kind = eRegisterKindDWARF; reg_num = dwarf_r30_mips; break;
+ case LLDB_REGNUM_GENERIC_RA: reg_kind = eRegisterKindDWARF; reg_num = dwarf_ra_mips; break;
+ case LLDB_REGNUM_GENERIC_FLAGS: reg_kind = eRegisterKindDWARF; reg_num = dwarf_sr_mips; break;
default:
return false;
}
@@ -362,18 +444,24 @@ EmulateInstructionMIPS::GetRegisterInfo (RegisterKind reg_kind, uint32_t reg_num
::memset (&reg_info, 0, sizeof(RegisterInfo));
::memset (reg_info.kinds, LLDB_INVALID_REGNUM, sizeof(reg_info.kinds));
- if (reg_num == gcc_dwarf_sr_mips || reg_num == gcc_dwarf_fcsr_mips || reg_num == gcc_dwarf_fir_mips)
+ if (reg_num == dwarf_sr_mips || reg_num == dwarf_fcsr_mips || reg_num == dwarf_fir_mips || reg_num == dwarf_mcsr_mips || reg_num == dwarf_mir_mips || reg_num == dwarf_config5_mips)
{
reg_info.byte_size = 4;
reg_info.format = eFormatHex;
reg_info.encoding = eEncodingUint;
}
- else if ((int)reg_num >= gcc_dwarf_zero_mips && (int)reg_num <= gcc_dwarf_f31_mips)
+ else if ((int)reg_num >= dwarf_zero_mips && (int)reg_num <= dwarf_f31_mips)
{
reg_info.byte_size = 4;
reg_info.format = eFormatHex;
reg_info.encoding = eEncodingUint;
}
+ else if ((int)reg_num >= dwarf_w0_mips && (int)reg_num <= dwarf_w31_mips)
+ {
+ reg_info.byte_size = 16;
+ reg_info.format = eFormatVectorOfUInt8;
+ reg_info.encoding = eEncodingVector;
+ }
else
{
return false;
@@ -385,11 +473,11 @@ EmulateInstructionMIPS::GetRegisterInfo (RegisterKind reg_kind, uint32_t reg_num
switch (reg_num)
{
- case gcc_dwarf_r30_mips: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP; break;
- case gcc_dwarf_ra_mips: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_RA; break;
- case gcc_dwarf_sp_mips: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_SP; break;
- case gcc_dwarf_pc_mips: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC; break;
- case gcc_dwarf_sr_mips: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FLAGS; break;
+ case dwarf_r30_mips: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP; break;
+ case dwarf_ra_mips: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_RA; break;
+ case dwarf_sp_mips: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_SP; break;
+ case dwarf_pc_mips: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC; break;
+ case dwarf_sr_mips: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FLAGS; break;
default: break;
}
return true;
@@ -409,6 +497,96 @@ EmulateInstructionMIPS::GetOpcodeForInstruction (const char *op_name)
{ "ADDiu", &EmulateInstructionMIPS::Emulate_ADDiu, "ADDIU rt,rs,immediate" },
{ "SW", &EmulateInstructionMIPS::Emulate_SW, "SW rt,offset(rs)" },
{ "LW", &EmulateInstructionMIPS::Emulate_LW, "LW rt,offset(base)" },
+ //----------------------------------------------------------------------
+ // MicroMIPS Prologue/Epilogue instructions
+ //----------------------------------------------------------------------
+ { "ADDIUSP_MM", &EmulateInstructionMIPS::Emulate_ADDIUSP, "ADDIU immediate" },
+ { "ADDIUS5_MM", &EmulateInstructionMIPS::Emulate_ADDIUS5, "ADDIUS5 rd,immediate" },
+ { "SWSP_MM", &EmulateInstructionMIPS::Emulate_SWSP, "SWSP rt,offset(sp)" },
+ { "SWM16_MM", &EmulateInstructionMIPS::Emulate_SWM16_32, "SWM16 reglist,offset(sp)" },
+ { "SWM32_MM", &EmulateInstructionMIPS::Emulate_SWM16_32, "SWM32 reglist,offset(base)" },
+ { "SWP_MM", &EmulateInstructionMIPS::Emulate_SWM16_32, "SWP rs1,offset(base)" },
+ { "LWSP_MM", &EmulateInstructionMIPS::Emulate_LWSP, "LWSP rt,offset(sp)" },
+ { "LWM16_MM", &EmulateInstructionMIPS::Emulate_LWM16_32, "LWM16 reglist,offset(sp)" },
+ { "LWM32_MM", &EmulateInstructionMIPS::Emulate_LWM16_32, "LWM32 reglist,offset(base)" },
+ { "LWP_MM", &EmulateInstructionMIPS::Emulate_LWM16_32, "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, we have generalised
+ all these instructions in 2 functions depending on their addressing modes */
+
+ { "LB", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LB rt, offset(base)" },
+ { "LBE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LBE rt, offset(base)" },
+ { "LBU", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LBU rt, offset(base)" },
+ { "LBUE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LBUE rt, offset(base)" },
+ { "LDC1", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LDC1 ft, offset(base)" },
+ { "LD", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LD rt, offset(base)" },
+ { "LDL", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LDL rt, offset(base)" },
+ { "LDR", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LDR rt, offset(base)" },
+ { "LLD", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LLD rt, offset(base)" },
+ { "LDC2", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LDC2 rt, offset(base)" },
+ { "LDXC1", &EmulateInstructionMIPS::Emulate_LDST_Reg, "LDXC1 fd, index (base)" },
+ { "LH", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LH rt, offset(base)" },
+ { "LHE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LHE rt, offset(base)" },
+ { "LHU", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LHU rt, offset(base)" },
+ { "LHUE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LHUE rt, offset(base)" },
+ { "LL", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LL rt, offset(base)" },
+ { "LLE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LLE rt, offset(base)" },
+ { "LUXC1", &EmulateInstructionMIPS::Emulate_LDST_Reg, "LUXC1 fd, index (base)" },
+ { "LW", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LW rt, offset(base)" },
+ { "LWC1", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LWC1 ft, offset(base)" },
+ { "LWC2", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LWC2 rt, offset(base)" },
+ { "LWE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LWE rt, offset(base)" },
+ { "LWL", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LWL rt, offset(base)" },
+ { "LWLE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LWLE rt, offset(base)" },
+ { "LWR", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LWR rt, offset(base)" },
+ { "LWRE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LWRE rt, offset(base)" },
+ { "LWXC1", &EmulateInstructionMIPS::Emulate_LDST_Reg, "LWXC1 fd, index (base)" },
+ { "LLX", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LLX rt, offset(base)" },
+ { "LLXE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LLXE rt, offset(base)" },
+ { "LLDX", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LLDX rt, offset(base)" },
+
+ { "SB", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SB rt, offset(base)" },
+ { "SBE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SBE rt, offset(base)" },
+ { "SC", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SC rt, offset(base)" },
+ { "SCE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SCE rt, offset(base)" },
+ { "SCD", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SCD rt, offset(base)" },
+ { "SD", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SD rt, offset(base)" },
+ { "SDL", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SDL rt, offset(base)" },
+ { "SDR", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SDR rt, offset(base)" },
+ { "SDC1", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SDC1 ft, offset(base)" },
+ { "SDC2", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SDC2 rt, offset(base)" },
+ { "SDXC1", &EmulateInstructionMIPS::Emulate_LDST_Reg, "SDXC1 fs, index(base)" },
+ { "SH", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SH rt, offset(base)" },
+ { "SHE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SHE rt, offset(base)" },
+ { "SUXC1", &EmulateInstructionMIPS::Emulate_LDST_Reg, "SUXC1 fs, index (base)" },
+ { "SWC1", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SWC1 ft, offset(base)" },
+ { "SWC2", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SWC2 rt, offset(base)" },
+ { "SWE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SWE rt, offset(base)" },
+ { "SWL", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SWL rt, offset(base)" },
+ { "SWLE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SWLE rt, offset(base)" },
+ { "SWR", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SWR rt, offset(base)" },
+ { "SWRE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SWRE rt, offset(base)" },
+ { "SWXC1", &EmulateInstructionMIPS::Emulate_LDST_Reg, "SWXC1 fs, index (base)" },
+ { "SCX", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SCX rt, offset(base)" },
+ { "SCXE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SCXE rt, offset(base)" },
+ { "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, "LHU16 rt, left_shifted_offset(base)" },
+ { "LW16_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LW16 rt, left_shifted_offset(base)" },
+ { "LWGP_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LWGP rt, left_shifted_offset(gp)" },
+ { "SH16_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SH16 rt, left_shifted_offset(base)" },
+ { "SW16_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SW16 rt, left_shifted_offset(base)" },
+ { "SW_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SWSP rt, left_shifted_offset(base)" },
+ { "SB16_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SB16 rt, offset(base)" },
//----------------------------------------------------------------------
// Branch instructions
@@ -471,6 +649,34 @@ EmulateInstructionMIPS::GetOpcodeForInstruction (const char *op_name)
{ "BC1ANY2T", &EmulateInstructionMIPS::Emulate_BC1ANY2T, "BC1ANY2T cc, offset" },
{ "BC1ANY4F", &EmulateInstructionMIPS::Emulate_BC1ANY4F, "BC1ANY4F cc, offset" },
{ "BC1ANY4T", &EmulateInstructionMIPS::Emulate_BC1ANY4T, "BC1ANY4T cc, offset" },
+ { "BNZ_B", &EmulateInstructionMIPS::Emulate_BNZB, "BNZ.b wt,s16" },
+ { "BNZ_H", &EmulateInstructionMIPS::Emulate_BNZH, "BNZ.h wt,s16" },
+ { "BNZ_W", &EmulateInstructionMIPS::Emulate_BNZW, "BNZ.w wt,s16" },
+ { "BNZ_D", &EmulateInstructionMIPS::Emulate_BNZD, "BNZ.d wt,s16" },
+ { "BZ_B", &EmulateInstructionMIPS::Emulate_BZB, "BZ.b wt,s16" },
+ { "BZ_H", &EmulateInstructionMIPS::Emulate_BZH, "BZ.h wt,s16" },
+ { "BZ_W", &EmulateInstructionMIPS::Emulate_BZW, "BZ.w wt,s16" },
+ { "BZ_D", &EmulateInstructionMIPS::Emulate_BZD, "BZ.d wt,s16" },
+ { "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" },
+ { "BNEZ16_MM", &EmulateInstructionMIPS::Emulate_Branch_MM, "BNEZ16 rs, offset" },
+ { "BEQZC_MM", &EmulateInstructionMIPS::Emulate_Branch_MM, "BEQZC rs, offset" },
+ { "BNEZC_MM", &EmulateInstructionMIPS::Emulate_Branch_MM, "BNEZC rs, offset" },
+ { "BGEZALS_MM", &EmulateInstructionMIPS::Emulate_Branch_MM, "BGEZALS rs, offset" },
+ { "BLTZALS_MM", &EmulateInstructionMIPS::Emulate_Branch_MM, "BLTZALS rs, offset" },
+ { "JALR16_MM", &EmulateInstructionMIPS::Emulate_JALRx16_MM, "JALR16 rs" },
+ { "JALRS16_MM", &EmulateInstructionMIPS::Emulate_JALRx16_MM, "JALRS16 rs" },
+ { "JR16_MM", &EmulateInstructionMIPS::Emulate_JR, "JR16 rs rs" },
+ { "JRC16_MM", &EmulateInstructionMIPS::Emulate_JR, "JRC16 rs rs" },
+ { "JALS_MM", &EmulateInstructionMIPS::Emulate_JALx, "JALS target" },
+ { "JALX_MM", &EmulateInstructionMIPS::Emulate_JALx, "JALX target" },
+ { "JALRS_MM", &EmulateInstructionMIPS::Emulate_JALRS, "JALRS rt, rs" },
};
static const size_t k_num_mips_opcodes = llvm::array_lengthof(g_opcodes);
@@ -484,6 +690,76 @@ EmulateInstructionMIPS::GetOpcodeForInstruction (const char *op_name)
return NULL;
}
+uint32_t
+EmulateInstructionMIPS::GetSizeOfInstruction (lldb_private::DataExtractor& data, uint64_t inst_addr)
+{
+ uint64_t next_inst_size = 0;
+ llvm::MCInst mc_insn;
+ llvm::MCDisassembler::DecodeStatus decode_status;
+ llvm::ArrayRef<uint8_t> raw_insn (data.GetDataStart(), data.GetByteSize());
+
+ if (m_use_alt_disaasm)
+ decode_status = m_alt_disasm->getInstruction (mc_insn, next_inst_size, raw_insn, inst_addr, llvm::nulls(), llvm::nulls());
+ else
+ decode_status = m_disasm->getInstruction (mc_insn, next_inst_size, raw_insn, inst_addr, llvm::nulls(), llvm::nulls());
+
+ if (decode_status != llvm::MCDisassembler::Success)
+ return false;
+
+ return m_insn_info->get(mc_insn.getOpcode()).getSize();
+}
+
+bool
+EmulateInstructionMIPS::SetInstruction (const Opcode &insn_opcode, const Address &inst_addr, Target *target)
+{
+ m_use_alt_disaasm = false;
+
+ if (EmulateInstruction::SetInstruction (insn_opcode, inst_addr, target))
+ {
+ if (inst_addr.GetAddressClass() == eAddressClassCodeAlternateISA)
+ {
+ Error error;
+ lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
+
+ /*
+ * The address belongs to microMIPS function. To find the size of
+ * next instruction use microMIPS disassembler.
+ */
+ m_use_alt_disaasm = true;
+
+ uint32_t current_inst_size = insn_opcode.GetByteSize();
+ uint8_t buf[sizeof(uint32_t)];
+ uint64_t next_inst_addr = (m_addr & (~1ull)) + current_inst_size;
+ Address next_addr (next_inst_addr);
+
+ const size_t bytes_read = target->ReadMemory (next_addr, /* Address of next instruction */
+ true, /* prefer_file_cache */
+ buf,
+ sizeof(uint32_t),
+ error,
+ &load_addr);
+
+ if (bytes_read == 0)
+ return true;
+
+ DataExtractor data (buf, sizeof(uint32_t), GetByteOrder(), GetAddressByteSize());
+ m_next_inst_size = GetSizeOfInstruction (data, next_inst_addr);
+ return true;
+ }
+ else
+ {
+ /*
+ * If the address class is not eAddressClassCodeAlternateISA then
+ * the function is not microMIPS. In this case instruction size is
+ * always 4 bytes.
+ */
+ m_next_inst_size = 4;
+ return true;
+ }
+ }
+ return false;
+}
+
bool
EmulateInstructionMIPS::ReadInstruction ()
{
@@ -514,7 +790,11 @@ EmulateInstructionMIPS::EvaluateInstruction (uint32_t evaluate_options)
{
llvm::MCDisassembler::DecodeStatus decode_status;
llvm::ArrayRef<uint8_t> raw_insn (data.GetDataStart(), data.GetByteSize());
- decode_status = m_disasm->getInstruction (mc_insn, insn_size, raw_insn, m_addr, llvm::nulls(), llvm::nulls());
+ if (m_use_alt_disaasm)
+ decode_status = m_alt_disasm->getInstruction (mc_insn, insn_size, raw_insn, m_addr, llvm::nulls(), llvm::nulls());
+ else
+ decode_status = m_disasm->getInstruction (mc_insn, insn_size, raw_insn, m_addr, llvm::nulls(), llvm::nulls());
+
if (decode_status != llvm::MCDisassembler::Success)
return false;
}
@@ -542,7 +822,7 @@ EmulateInstructionMIPS::EvaluateInstruction (uint32_t evaluate_options)
if (auto_advance_pc)
{
- old_pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ old_pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
}
@@ -554,7 +834,7 @@ EmulateInstructionMIPS::EvaluateInstruction (uint32_t evaluate_options)
if (auto_advance_pc)
{
- new_pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ new_pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
@@ -563,7 +843,7 @@ EmulateInstructionMIPS::EvaluateInstruction (uint32_t evaluate_options)
{
new_pc += 4;
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, new_pc))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, new_pc))
return false;
}
}
@@ -581,10 +861,10 @@ EmulateInstructionMIPS::CreateFunctionEntryUnwind (UnwindPlan &unwind_plan)
const bool can_replace = false;
// Our previous Call Frame Address is the stack pointer
- row->GetCFAValue().SetIsRegisterPlusOffset(gcc_dwarf_sp_mips, 0);
+ row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_sp_mips, 0);
// Our previous PC is in the RA
- row->SetRegisterLocationToRegister(gcc_dwarf_pc_mips, gcc_dwarf_ra_mips, can_replace);
+ row->SetRegisterLocationToRegister(dwarf_pc_mips, dwarf_ra_mips, can_replace);
unwind_plan.AppendRow (row);
@@ -592,6 +872,7 @@ EmulateInstructionMIPS::CreateFunctionEntryUnwind (UnwindPlan &unwind_plan)
unwind_plan.SetSourceName ("EmulateInstructionMIPS");
unwind_plan.SetSourcedFromCompiler (eLazyBoolNo);
unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolYes);
+ unwind_plan.SetReturnAddressRegister (dwarf_ra_mips);
return true;
}
@@ -601,18 +882,18 @@ EmulateInstructionMIPS::nonvolatile_reg_p (uint32_t regnum)
{
switch (regnum)
{
- case gcc_dwarf_r16_mips:
- case gcc_dwarf_r17_mips:
- case gcc_dwarf_r18_mips:
- case gcc_dwarf_r19_mips:
- case gcc_dwarf_r20_mips:
- case gcc_dwarf_r21_mips:
- case gcc_dwarf_r22_mips:
- case gcc_dwarf_r23_mips:
- case gcc_dwarf_gp_mips:
- case gcc_dwarf_sp_mips:
- case gcc_dwarf_r30_mips:
- case gcc_dwarf_ra_mips:
+ case dwarf_r16_mips:
+ case dwarf_r17_mips:
+ case dwarf_r18_mips:
+ case dwarf_r19_mips:
+ case dwarf_r20_mips:
+ case dwarf_r21_mips:
+ case dwarf_r22_mips:
+ case dwarf_r23_mips:
+ case dwarf_gp_mips:
+ case dwarf_sp_mips:
+ case dwarf_r30_mips:
+ case dwarf_ra_mips:
return true;
default:
return false;
@@ -633,10 +914,10 @@ EmulateInstructionMIPS::Emulate_ADDiu (llvm::MCInst& insn)
src = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
/* Check if this is addiu sp,<src>,imm16 */
- if (dst == gcc_dwarf_sp_mips)
+ if (dst == dwarf_sp_mips)
{
/* read <src> register */
- uint64_t src_opd_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + src, 0, &success);
+ uint64_t src_opd_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + src, 0, &success);
if (!success)
return false;
@@ -644,13 +925,13 @@ EmulateInstructionMIPS::Emulate_ADDiu (llvm::MCInst& insn)
Context context;
RegisterInfo reg_info_sp;
- if (GetRegisterInfo (eRegisterKindDWARF, gcc_dwarf_sp_mips, reg_info_sp))
+ if (GetRegisterInfo (eRegisterKindDWARF, dwarf_sp_mips, reg_info_sp))
context.SetRegisterPlusOffset (reg_info_sp, imm);
/* We are allocating bytes on stack */
context.type = eContextAdjustStackPointer;
- WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_sp_mips, result);
+ WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_sp_mips, result);
}
return true;
@@ -663,30 +944,206 @@ EmulateInstructionMIPS::Emulate_SW (llvm::MCInst& insn)
uint32_t imm16 = insn.getOperand(2).getImm();
uint32_t imm = SignedBits(imm16, 15, 0);
uint32_t src, base;
+ int32_t address;
+ Context bad_vaddr_context;
+
+ RegisterInfo reg_info_base;
src = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
base = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
+ if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + base, reg_info_base))
+ return false;
+
+ /* read base register */
+ address = (int32_t)ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
+ if (!success)
+ return false;
+
+ /* destination address */
+ address = address + imm;
+
+ /* Set the bad_vaddr register with base address used in the instruction */
+ bad_vaddr_context.type = eContextInvalid;
+ WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips, address);
+
/* We look for sp based non-volatile register stores */
- if (base == gcc_dwarf_sp_mips && nonvolatile_reg_p (src))
+ if (base == dwarf_sp_mips && nonvolatile_reg_p (src))
+ {
+
+ RegisterInfo reg_info_src;
+
+ if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + src, reg_info_src))
+ return false;
+
+ Context context;
+ RegisterValue data_src;
+ context.type = eContextPushRegisterOnStack;
+ context.SetRegisterToRegisterPlusOffset (reg_info_src, reg_info_base, 0);
+
+ uint8_t buffer [RegisterValue::kMaxRegisterByteSize];
+ Error error;
+
+ if (!ReadRegister (&reg_info_base, data_src))
+ return false;
+
+ if (data_src.GetAsMemoryData (&reg_info_src, buffer, reg_info_src.byte_size, eByteOrderLittle, error) == 0)
+ return false;
+
+ if (!WriteMemory (context, address, buffer, reg_info_src.byte_size))
+ return false;
+
+ return true;
+ }
+
+ return false;
+}
+
+bool
+EmulateInstructionMIPS::Emulate_LW (llvm::MCInst& insn)
+{
+ bool success =false;
+ uint32_t src, base;
+ int32_t imm, address;
+ Context bad_vaddr_context;
+
+ src = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
+ base = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
+ imm = insn.getOperand(2).getImm();
+
+ RegisterInfo reg_info_base;
+ if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + base, reg_info_base))
+ return false;
+
+ /* read base register */
+ address = (int32_t)ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
+ if (!success)
+ return false;
+
+ /* destination address */
+ address = address + imm;
+
+ /* Set the bad_vaddr register with base address used in the instruction */
+ bad_vaddr_context.type = eContextInvalid;
+ WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips, address);
+
+ if (base == dwarf_sp_mips && nonvolatile_reg_p (src))
{
- uint32_t address;
- RegisterInfo reg_info_base;
+ RegisterValue data_src;
RegisterInfo reg_info_src;
- if (!GetRegisterInfo (eRegisterKindDWARF, gcc_dwarf_zero_mips + base, reg_info_base)
- || !GetRegisterInfo (eRegisterKindDWARF, gcc_dwarf_zero_mips + src, reg_info_src))
+ if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + src, reg_info_src))
return false;
- /* read SP */
- address = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + base, 0, &success);
+ Context context;
+ context.type = eContextPopRegisterOffStack;
+ context.SetAddress (address);
+
+ if (!WriteRegister (context, &reg_info_src, data_src))
+ return false;
+
+ return true;
+ }
+
+ return false;
+}
+
+bool
+EmulateInstructionMIPS::Emulate_ADDIUSP (llvm::MCInst& insn)
+{
+ bool success = false;
+ const uint32_t imm9 = insn.getOperand(0).getImm();
+ uint64_t result;
+
+ // This instruction operates implicitly on stack pointer, so read <sp> register.
+ uint64_t src_opd_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_sp_mips, 0, &success);
+ if (!success)
+ return false;
+
+ result = src_opd_val + imm9;
+
+ Context context;
+ RegisterInfo reg_info_sp;
+ if (GetRegisterInfo (eRegisterKindDWARF, dwarf_sp_mips, reg_info_sp))
+ context.SetRegisterPlusOffset (reg_info_sp, imm9);
+
+ // We are adjusting the stack.
+ context.type = eContextAdjustStackPointer;
+
+ WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_sp_mips, result);
+ return true;
+}
+
+bool
+EmulateInstructionMIPS::Emulate_ADDIUS5 (llvm::MCInst& insn)
+{
+ bool success = false;
+ uint32_t base;
+ const uint32_t imm4 = insn.getOperand(2).getImm();
+ uint64_t result;
+
+ // The source and destination register is same for this instruction.
+ base = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
+
+ // We are looking for stack adjustment only
+ if (base == dwarf_sp_mips)
+ {
+ // Read stack pointer register
+ uint64_t src_opd_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
if (!success)
return false;
- /* destination address */
- address = address + imm;
+ result = src_opd_val + imm4;
Context context;
+ RegisterInfo reg_info_sp;
+ if (GetRegisterInfo (eRegisterKindDWARF, dwarf_sp_mips, reg_info_sp))
+ context.SetRegisterPlusOffset (reg_info_sp, imm4);
+
+ // We are adjusting the stack.
+ context.type = eContextAdjustStackPointer;
+
+ WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_sp_mips, result);
+ }
+
+ return true;
+}
+
+bool
+EmulateInstructionMIPS::Emulate_SWSP (llvm::MCInst& insn)
+{
+ bool success = false;
+ uint32_t imm5 = insn.getOperand(2).getImm();
+ uint32_t src, base;
+ Context bad_vaddr_context;
+ uint32_t address;
+
+ src = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
+ base = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
+
+ RegisterInfo reg_info_base;
+
+ if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + base, reg_info_base))
+ return false;
+
+ // read base register
+ address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
+ if (!success)
+ return false;
+
+ // destination address
+ address = address + imm5;
+
+ // We use bad_vaddr_context to store base address which is used by H/W watchpoint
+ // Set the bad_vaddr register with base address used in the instruction
+ bad_vaddr_context.type = eContextInvalid;
+ WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips, address);
+
+ // We look for sp based non-volatile register stores.
+ if (base == dwarf_sp_mips && nonvolatile_reg_p (src))
+ {
+ RegisterInfo reg_info_src;
+ Context context;
RegisterValue data_src;
context.type = eContextPushRegisterOnStack;
context.SetRegisterToRegisterPlusOffset (reg_info_src, reg_info_base, 0);
@@ -709,24 +1166,118 @@ EmulateInstructionMIPS::Emulate_SW (llvm::MCInst& insn)
return false;
}
+/* Emulate SWM16,SWM32 and SWP instruction.
+
+ SWM16 always has stack pointer as a base register (but it is still available in MCInst as an operand).
+ SWM32 and SWP can have base register other than stack pointer.
+*/
bool
-EmulateInstructionMIPS::Emulate_LW (llvm::MCInst& insn)
+EmulateInstructionMIPS::Emulate_SWM16_32 (llvm::MCInst& insn)
{
+ bool success = false;
uint32_t src, base;
+ uint32_t num_operands = insn.getNumOperands(); // No of operands vary based on no of regs to store.
- src = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- base = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
+ // Base register is second last operand of the instruction.
+ base = m_reg_info->getEncodingValue (insn.getOperand(num_operands-2).getReg());
+
+ // We are looking for sp based stores so if base is not a stack pointer then don't proceed.
+ if (base != dwarf_sp_mips)
+ return false;
+
+ // offset is always the last operand.
+ uint32_t offset = insn.getOperand(num_operands-1).getImm();
+
+ RegisterInfo reg_info_base;
+ RegisterInfo reg_info_src;
+
+ if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + base, reg_info_base))
+ return false;
+
+ // read SP
+ uint32_t base_address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
+ if (!success)
+ return false;
+
+ // Resulting base addrss
+ base_address = base_address + offset;
+
+ // Total no of registers to be stored are num_operands-2.
+ for (uint32_t i = 0; i < num_operands - 2; i++)
+ {
+ // Get the register number to be stored.
+ src = m_reg_info->getEncodingValue (insn.getOperand(i).getReg());
+
+ /*
+ Record only non-volatile stores.
+ This check is required for SWP instruction because source operand could be any register.
+ SWM16 and SWM32 instruction always has saved registers as source operands.
+ */
+ if (!nonvolatile_reg_p (src))
+ return false;
+
+ if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + src, reg_info_src))
+ return false;
+
+ Context context;
+ RegisterValue data_src;
+ context.type = eContextPushRegisterOnStack;
+ context.SetRegisterToRegisterPlusOffset (reg_info_src, reg_info_base, 0);
+
+ uint8_t buffer [RegisterValue::kMaxRegisterByteSize];
+ Error error;
+
+ if (!ReadRegister (&reg_info_base, data_src))
+ return false;
+
+ if (data_src.GetAsMemoryData (&reg_info_src, buffer, reg_info_src.byte_size, eByteOrderLittle, error) == 0)
+ return false;
+
+ if (!WriteMemory (context, base_address, buffer, reg_info_src.byte_size))
+ return false;
+
+ // Stack address for next register
+ base_address = base_address + reg_info_src.byte_size;
+ }
+ return true;
+}
+
+bool
+EmulateInstructionMIPS::Emulate_LWSP (llvm::MCInst& insn)
+{
+ bool success = false;
+ uint32_t src = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
+ uint32_t base = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
+ uint32_t imm5 = insn.getOperand(2).getImm();
+ Context bad_vaddr_context;
+
+ RegisterInfo reg_info_base;
+ if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + base, reg_info_base))
+ return false;
- if (base == gcc_dwarf_sp_mips && nonvolatile_reg_p (src))
+ // read base register
+ uint32_t base_address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
+ if (!success)
+ return false;
+
+ base_address = base_address + imm5;
+
+ // We use bad_vaddr_context to store base address which is used by H/W watchpoint
+ // Set the bad_vaddr register with base address used in the instruction
+ bad_vaddr_context.type = eContextInvalid;
+ WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips, base_address);
+
+ if (base == dwarf_sp_mips && nonvolatile_reg_p (src))
{
RegisterValue data_src;
RegisterInfo reg_info_src;
- if (!GetRegisterInfo (eRegisterKindDWARF, gcc_dwarf_zero_mips + src, reg_info_src))
+ if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + src, reg_info_src))
return false;
Context context;
- context.type = eContextRegisterLoad;
+ context.type = eContextPopRegisterOffStack;
+ context.SetAddress (base_address);
if (!WriteRegister (context, &reg_info_src, data_src))
return false;
@@ -737,6 +1288,105 @@ EmulateInstructionMIPS::Emulate_LW (llvm::MCInst& insn)
return false;
}
+/* Emulate LWM16, LWM32 and LWP instructions.
+
+ LWM16 always has stack pointer as a base register (but it is still available in MCInst as an operand).
+ LWM32 and LWP can have base register other than stack pointer.
+*/
+bool
+EmulateInstructionMIPS::Emulate_LWM16_32 (llvm::MCInst& insn)
+{
+ bool success = false;
+ uint32_t dst, base;
+ uint32_t num_operands = insn.getNumOperands(); // No of operands vary based on no of regs to store.
+ uint32_t imm = insn.getOperand(num_operands-1).getImm(); // imm is the last operand in the instruction.
+
+ // Base register is second last operand of the instruction.
+ base = m_reg_info->getEncodingValue (insn.getOperand(num_operands-2).getReg());
+
+ // We are looking for sp based loads so if base is not a stack pointer then don't proceed.
+ if (base != dwarf_sp_mips)
+ return false;
+
+ uint32_t base_address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
+ if (!success)
+ return false;
+
+ base_address = base_address + imm;
+
+ RegisterValue data_dst;
+ RegisterInfo reg_info_dst;
+
+ // Total no of registers to be re-stored are num_operands-2.
+ for (uint32_t i = 0; i < num_operands - 2; i++)
+ {
+ // Get the register number to be re-stored.
+ dst = m_reg_info->getEncodingValue (insn.getOperand(i).getReg());
+
+ /*
+ Record only non-volatile loads.
+ This check is required for LWP instruction because destination operand could be any register.
+ LWM16 and LWM32 instruction always has saved registers as destination operands.
+ */
+ if (!nonvolatile_reg_p (dst))
+ return false;
+
+ if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + dst, reg_info_dst))
+ return false;
+
+ Context context;
+ context.type = eContextPopRegisterOffStack;
+ context.SetAddress (base_address + (i*4));
+
+ if (!WriteRegister (context, &reg_info_dst, data_dst))
+ return false;
+ }
+
+ return true;
+}
+
+bool
+EmulateInstructionMIPS::Emulate_JRADDIUSP (llvm::MCInst& insn)
+{
+ bool success = false;
+ int32_t imm5 = insn.getOperand(0).getImm();
+
+ /* JRADDIUSP immediate
+ * PC <- RA
+ * SP <- SP + zero_extend(Immediate << 2)
+ */
+
+ // This instruction operates implicitly on stack pointer, so read <sp> register.
+ int32_t src_opd_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_sp_mips, 0, &success);
+ if (!success)
+ return false;
+
+ int32_t ra_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_ra_mips, 0, &success);
+ if (!success)
+ return false;
+
+ int32_t result = src_opd_val + imm5;
+
+ Context context;
+
+ // Update the PC
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, ra_val))
+ return false;
+
+ RegisterInfo reg_info_sp;
+ if (GetRegisterInfo (eRegisterKindDWARF, dwarf_sp_mips, reg_info_sp))
+ context.SetRegisterPlusOffset (reg_info_sp, imm5);
+
+ // We are adjusting stack
+ context.type = eContextAdjustStackPointer;
+
+ // update SP
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_sp_mips, result))
+ return false;
+
+ return true;
+}
+
bool
EmulateInstructionMIPS::Emulate_BEQ (llvm::MCInst& insn)
{
@@ -754,15 +1404,15 @@ EmulateInstructionMIPS::Emulate_BEQ (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
- rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rt, 0, &success);
+ rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
if (!success)
return false;
@@ -774,13 +1424,270 @@ EmulateInstructionMIPS::Emulate_BEQ (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
}
bool
+EmulateInstructionMIPS::Emulate_B16_MM (llvm::MCInst& insn)
+{
+ bool success = false;
+ int32_t offset, pc, target;
+ uint32_t current_inst_size = m_insn_info->get(insn.getOpcode()).getSize();
+
+ offset = insn.getOperand(0).getImm();
+
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
+
+ // unconditional branch
+ target = pc + offset;
+
+ Context context;
+ context.type = eContextRelativeBranchImmediate;
+ context.SetImmediate (current_inst_size + offset);
+
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
+ return false;
+
+ return true;
+}
+
+/*
+ BEQZC, BNEZC are 32 bit compact instructions without a delay slot.
+ BEQZ16, BNEZ16 are 16 bit instructions with delay slot.
+ BGEZALS, BLTZALS are 16 bit instructions with short (2-byte) delay slot.
+*/
+bool
+EmulateInstructionMIPS::Emulate_Branch_MM (llvm::MCInst& insn)
+{
+ bool success = false;
+ int32_t target = 0;
+ uint32_t current_inst_size = m_insn_info->get(insn.getOpcode()).getSize();
+ const char *op_name = m_insn_info->getName (insn.getOpcode ());
+ bool update_ra = false;
+ uint32_t ra_offset = 0;
+
+ /*
+ * BEQZ16 rs, offset
+ * condition <- (GPR[rs] = 0)
+ * if condition then
+ * PC = PC + sign_ext (offset || 0)
+ *
+ * BNEZ16 rs, offset
+ * condition <- (GPR[rs] != 0)
+ * if condition then
+ * PC = PC + sign_ext (offset || 0)
+ *
+ * BEQZC rs, offset (compact instruction: No delay slot)
+ * condition <- (GPR[rs] == 0)
+ * if condition then
+ * PC = PC + 4 + sign_ext (offset || 0)
+ */
+
+ uint32_t rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
+ int32_t offset = insn.getOperand(1).getImm();
+
+ int32_t pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
+
+ int32_t rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
+ if (!success)
+ return false;
+
+ if (!strcasecmp (op_name, "BEQZ16_MM"))
+ {
+ if (rs_val == 0)
+ target = pc + offset;
+ else
+ target = pc + current_inst_size + m_next_inst_size; // Skip delay slot instruction.
+ }
+ else if (!strcasecmp (op_name, "BNEZ16_MM"))
+ {
+ if (rs_val != 0)
+ target = pc + offset;
+ else
+ target = pc + current_inst_size + m_next_inst_size; // Skip delay slot instruction.
+ }
+ else if (!strcasecmp (op_name, "BEQZC_MM"))
+ {
+ if (rs_val == 0)
+ target = pc + 4 + offset;
+ else
+ target = pc + 4; // 32 bit instruction and does not have delay slot instruction.
+ }
+ else if (!strcasecmp (op_name, "BNEZC_MM"))
+ {
+ if (rs_val != 0)
+ target = pc + 4 + offset;
+ else
+ target = pc + 4; // 32 bit instruction and does not have delay slot instruction.
+ }
+ else if (!strcasecmp (op_name, "BGEZALS_MM"))
+ {
+ if (rs_val >= 0)
+ target = pc + offset;
+ else
+ target = pc + 6; // 32 bit instruction with short (2-byte) delay slot
+
+ update_ra = true;
+ ra_offset = 6;
+ }
+ else if (!strcasecmp (op_name, "BLTZALS_MM"))
+ {
+ if (rs_val >= 0)
+ target = pc + offset;
+ else
+ target = pc + 6; // 32 bit instruction with short (2-byte) delay slot
+
+ update_ra = true;
+ ra_offset = 6;
+ }
+
+ Context context;
+ context.type = eContextRelativeBranchImmediate;
+ context.SetImmediate (current_inst_size + offset);
+
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
+ return false;
+
+ if (update_ra)
+ {
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + ra_offset))
+ return false;
+ }
+ return true;
+}
+
+/* Emulate micromips jump instructions.
+ JALR16,JALRS16
+*/
+bool
+EmulateInstructionMIPS::Emulate_JALRx16_MM (llvm::MCInst& insn)
+{
+ bool success = false;
+ uint32_t ra_offset = 0;
+ const char *op_name = m_insn_info->getName (insn.getOpcode ());
+
+ uint32_t rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
+
+ uint32_t pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
+
+ uint32_t rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
+ if (!success)
+ return false;
+
+ if (!strcasecmp (op_name, "JALR16_MM"))
+ ra_offset = 6; // 2-byte instruction with 4-byte delay slot.
+ else if (!strcasecmp (op_name, "JALRS16_MM"))
+ ra_offset = 4; // 2-byte instruction with 2-byte delay slot.
+
+ Context context;
+
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, rs_val))
+ return false;
+
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + ra_offset))
+ return false;
+
+ return true;
+}
+
+/* Emulate JALS and JALX instructions.
+ JALS 32 bit instruction with short (2-byte) delay slot.
+ JALX 32 bit instruction with 4-byte delay slot.
+*/
+bool
+EmulateInstructionMIPS::Emulate_JALx (llvm::MCInst& insn)
+{
+ bool success = false;
+ uint32_t offset=0, target=0, pc=0, ra_offset=0;
+ const char *op_name = m_insn_info->getName (insn.getOpcode ());
+
+ /*
+ * JALS target
+ * RA = PC + 6
+ * offset = sign_ext (offset << 1)
+ * PC = PC[31-27] | offset
+ * JALX target
+ * RA = PC + 8
+ * offset = sign_ext (offset << 2)
+ * PC = PC[31-28] | offset
+ */
+ offset = insn.getOperand(0).getImm();
+
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
+
+ // These are PC-region branches and not PC-relative.
+ if (!strcasecmp (op_name, "JALS_MM"))
+ {
+ // target address is in the “current†128 MB-aligned region
+ target = (pc & 0xF8000000UL) | offset;
+ ra_offset = 6;
+ }
+ else if (!strcasecmp (op_name, "JALX_MM"))
+ {
+ // target address is in the “current†256 MB-aligned region
+ target = (pc & 0xF0000000UL) | offset;
+ ra_offset = 8;
+ }
+
+ Context context;
+
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
+ return false;
+
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + ra_offset))
+ return false;
+
+ return true;
+}
+
+bool
+EmulateInstructionMIPS::Emulate_JALRS (llvm::MCInst& insn)
+{
+ bool success = false;
+ uint32_t rs=0, rt=0;
+ int32_t pc=0, rs_val=0;
+
+ /*
+ JALRS rt, rs
+ GPR[rt] <- PC + 6
+ PC <- GPR[rs]
+ */
+
+ rt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
+ rs = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
+
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
+ if (!success)
+ return false;
+
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
+
+ Context context;
+
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, rs_val))
+ return false;
+
+ // This is 4-byte instruction with 2-byte delay slot.
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_zero_mips + rt, pc + 6))
+ return false;
+
+ return true;
+}
+
+bool
EmulateInstructionMIPS::Emulate_BNE (llvm::MCInst& insn)
{
bool success = false;
@@ -797,15 +1704,15 @@ EmulateInstructionMIPS::Emulate_BNE (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
- rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rt, 0, &success);
+ rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
if (!success)
return false;
@@ -817,7 +1724,7 @@ EmulateInstructionMIPS::Emulate_BNE (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -840,15 +1747,15 @@ EmulateInstructionMIPS::Emulate_BEQL (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
- rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rt, 0, &success);
+ rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
if (!success)
return false;
@@ -860,7 +1767,7 @@ EmulateInstructionMIPS::Emulate_BEQL (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -883,15 +1790,15 @@ EmulateInstructionMIPS::Emulate_BNEL (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
- rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rt, 0, &success);
+ rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
if (!success)
return false;
@@ -903,7 +1810,7 @@ EmulateInstructionMIPS::Emulate_BNEL (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -926,11 +1833,11 @@ EmulateInstructionMIPS::Emulate_BGEZL (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -942,7 +1849,7 @@ EmulateInstructionMIPS::Emulate_BGEZL (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -965,11 +1872,11 @@ EmulateInstructionMIPS::Emulate_BLTZL (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -981,7 +1888,7 @@ EmulateInstructionMIPS::Emulate_BLTZL (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -1004,11 +1911,11 @@ EmulateInstructionMIPS::Emulate_BGTZL (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -1020,7 +1927,7 @@ EmulateInstructionMIPS::Emulate_BGTZL (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -1043,11 +1950,11 @@ EmulateInstructionMIPS::Emulate_BLEZL (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -1059,7 +1966,7 @@ EmulateInstructionMIPS::Emulate_BLEZL (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -1082,11 +1989,11 @@ EmulateInstructionMIPS::Emulate_BGTZ (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -1098,7 +2005,7 @@ EmulateInstructionMIPS::Emulate_BGTZ (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -1121,11 +2028,11 @@ EmulateInstructionMIPS::Emulate_BLEZ (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -1137,7 +2044,7 @@ EmulateInstructionMIPS::Emulate_BLEZ (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -1160,11 +2067,11 @@ EmulateInstructionMIPS::Emulate_BLTZ (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -1176,7 +2083,7 @@ EmulateInstructionMIPS::Emulate_BLTZ (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -1199,11 +2106,11 @@ EmulateInstructionMIPS::Emulate_BGEZALL (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -1215,10 +2122,10 @@ EmulateInstructionMIPS::Emulate_BGEZALL (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips, pc + 8))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + 8))
return false;
return true;
@@ -1238,7 +2145,7 @@ EmulateInstructionMIPS::Emulate_BAL (llvm::MCInst& insn)
*/
offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
@@ -1246,10 +2153,10 @@ EmulateInstructionMIPS::Emulate_BAL (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips, pc + 8))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + 8))
return false;
return true;
@@ -1269,7 +2176,7 @@ EmulateInstructionMIPS::Emulate_BALC (llvm::MCInst& insn)
*/
offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
@@ -1277,10 +2184,10 @@ EmulateInstructionMIPS::Emulate_BALC (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips, pc + 4))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + 4))
return false;
return true;
@@ -1305,11 +2212,11 @@ EmulateInstructionMIPS::Emulate_BGEZAL (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -1320,10 +2227,10 @@ EmulateInstructionMIPS::Emulate_BGEZAL (llvm::MCInst& insn)
else
target = pc + 8;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips, pc + 8))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + 8))
return false;
return true;
@@ -1348,11 +2255,11 @@ EmulateInstructionMIPS::Emulate_BLTZAL (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -1363,10 +2270,10 @@ EmulateInstructionMIPS::Emulate_BLTZAL (llvm::MCInst& insn)
else
target = pc + 8;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips, pc + 8))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + 8))
return false;
return true;
@@ -1391,11 +2298,11 @@ EmulateInstructionMIPS::Emulate_BLTZALL (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -1406,10 +2313,10 @@ EmulateInstructionMIPS::Emulate_BLTZALL (llvm::MCInst& insn)
else
target = pc + 8; /* skip delay slot */
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips, pc + 8))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + 8))
return false;
return true;
@@ -1435,11 +2342,11 @@ EmulateInstructionMIPS::Emulate_BLEZALC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -1450,10 +2357,10 @@ EmulateInstructionMIPS::Emulate_BLEZALC (llvm::MCInst& insn)
else
target = pc + 4;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips, pc + 4))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + 4))
return false;
return true;
@@ -1478,11 +2385,11 @@ EmulateInstructionMIPS::Emulate_BGEZALC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -1493,10 +2400,10 @@ EmulateInstructionMIPS::Emulate_BGEZALC (llvm::MCInst& insn)
else
target = pc + 4;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips, pc + 4))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + 4))
return false;
return true;
@@ -1521,11 +2428,11 @@ EmulateInstructionMIPS::Emulate_BLTZALC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -1536,10 +2443,10 @@ EmulateInstructionMIPS::Emulate_BLTZALC (llvm::MCInst& insn)
else
target = pc + 4;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips, pc + 4))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + 4))
return false;
return true;
@@ -1564,11 +2471,11 @@ EmulateInstructionMIPS::Emulate_BGTZALC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -1579,10 +2486,10 @@ EmulateInstructionMIPS::Emulate_BGTZALC (llvm::MCInst& insn)
else
target = pc + 4;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips, pc + 4))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + 4))
return false;
return true;
@@ -1606,11 +2513,11 @@ EmulateInstructionMIPS::Emulate_BEQZALC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -1621,10 +2528,10 @@ EmulateInstructionMIPS::Emulate_BEQZALC (llvm::MCInst& insn)
else
target = pc + 4;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips, pc + 4))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + 4))
return false;
return true;
@@ -1648,11 +2555,11 @@ EmulateInstructionMIPS::Emulate_BNEZALC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -1663,10 +2570,10 @@ EmulateInstructionMIPS::Emulate_BNEZALC (llvm::MCInst& insn)
else
target = pc + 4;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips, pc + 4))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + 4))
return false;
return true;
@@ -1689,11 +2596,11 @@ EmulateInstructionMIPS::Emulate_BGEZ (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -1704,7 +2611,7 @@ EmulateInstructionMIPS::Emulate_BGEZ (llvm::MCInst& insn)
else
target = pc + 8;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -1723,7 +2630,7 @@ EmulateInstructionMIPS::Emulate_BC (llvm::MCInst& insn)
*/
offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
@@ -1731,7 +2638,7 @@ EmulateInstructionMIPS::Emulate_BC (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -1754,15 +2661,15 @@ EmulateInstructionMIPS::Emulate_BEQC (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
- rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rt, 0, &success);
+ rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
if (!success)
return false;
@@ -1774,7 +2681,7 @@ EmulateInstructionMIPS::Emulate_BEQC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -1797,15 +2704,15 @@ EmulateInstructionMIPS::Emulate_BNEC (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
- rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rt, 0, &success);
+ rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
if (!success)
return false;
@@ -1817,7 +2724,7 @@ EmulateInstructionMIPS::Emulate_BNEC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -1841,15 +2748,15 @@ EmulateInstructionMIPS::Emulate_BLTC (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
- rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rt, 0, &success);
+ rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
if (!success)
return false;
@@ -1861,7 +2768,7 @@ EmulateInstructionMIPS::Emulate_BLTC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -1885,15 +2792,15 @@ EmulateInstructionMIPS::Emulate_BGEC (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
- rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rt, 0, &success);
+ rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
if (!success)
return false;
@@ -1905,7 +2812,7 @@ EmulateInstructionMIPS::Emulate_BGEC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -1929,15 +2836,15 @@ EmulateInstructionMIPS::Emulate_BLTUC (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
- rt_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rt, 0, &success);
+ rt_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
if (!success)
return false;
@@ -1949,7 +2856,7 @@ EmulateInstructionMIPS::Emulate_BLTUC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -1973,15 +2880,15 @@ EmulateInstructionMIPS::Emulate_BGEUC (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
- rt_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rt, 0, &success);
+ rt_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
if (!success)
return false;
@@ -1993,7 +2900,7 @@ EmulateInstructionMIPS::Emulate_BGEUC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -2016,11 +2923,11 @@ EmulateInstructionMIPS::Emulate_BLTZC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -2032,7 +2939,7 @@ EmulateInstructionMIPS::Emulate_BLTZC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -2055,11 +2962,11 @@ EmulateInstructionMIPS::Emulate_BLEZC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -2071,7 +2978,7 @@ EmulateInstructionMIPS::Emulate_BLEZC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -2094,11 +3001,11 @@ EmulateInstructionMIPS::Emulate_BGEZC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -2110,7 +3017,7 @@ EmulateInstructionMIPS::Emulate_BGEZC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -2133,11 +3040,11 @@ EmulateInstructionMIPS::Emulate_BGTZC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -2149,7 +3056,7 @@ EmulateInstructionMIPS::Emulate_BGTZC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -2172,11 +3079,11 @@ EmulateInstructionMIPS::Emulate_BEQZC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -2188,7 +3095,7 @@ EmulateInstructionMIPS::Emulate_BEQZC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -2211,11 +3118,11 @@ EmulateInstructionMIPS::Emulate_BNEZC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
@@ -2227,7 +3134,7 @@ EmulateInstructionMIPS::Emulate_BNEZC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -2258,15 +3165,15 @@ EmulateInstructionMIPS::Emulate_BOVC (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
- rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rt, 0, &success);
+ rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
if (!success)
return false;
@@ -2278,7 +3185,7 @@ EmulateInstructionMIPS::Emulate_BOVC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -2302,15 +3209,15 @@ EmulateInstructionMIPS::Emulate_BNVC (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
- rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rt, 0, &success);
+ rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
if (!success)
return false;
@@ -2322,7 +3229,7 @@ EmulateInstructionMIPS::Emulate_BNVC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -2341,7 +3248,7 @@ EmulateInstructionMIPS::Emulate_J (llvm::MCInst& insn)
*/
offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
@@ -2350,7 +3257,7 @@ EmulateInstructionMIPS::Emulate_J (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, pc))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, pc))
return false;
return true;
@@ -2369,7 +3276,7 @@ EmulateInstructionMIPS::Emulate_JAL (llvm::MCInst& insn)
*/
offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
@@ -2378,10 +3285,10 @@ EmulateInstructionMIPS::Emulate_JAL (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips, pc + 8))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + 8))
return false;
return true;
@@ -2402,20 +3309,20 @@ EmulateInstructionMIPS::Emulate_JALR (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
rs = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, rs_val))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, rs_val))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_zero_mips + rt, pc + 8))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_zero_mips + rt, pc + 8))
return false;
return true;
@@ -2437,11 +3344,11 @@ EmulateInstructionMIPS::Emulate_JIALC (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rt, 0, &success);
+ rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
if (!success)
return false;
@@ -2449,10 +3356,10 @@ EmulateInstructionMIPS::Emulate_JIALC (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips, pc + 4))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + 4))
return false;
return true;
@@ -2473,7 +3380,7 @@ EmulateInstructionMIPS::Emulate_JIC (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rt, 0, &success);
+ rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
if (!success)
return false;
@@ -2481,7 +3388,7 @@ EmulateInstructionMIPS::Emulate_JIC (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -2500,13 +3407,13 @@ EmulateInstructionMIPS::Emulate_JR (llvm::MCInst& insn)
*/
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + rs, 0, &success);
+ rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
if (!success)
return false;
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, rs_val))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, rs_val))
return false;
return true;
@@ -2529,11 +3436,11 @@ EmulateInstructionMIPS::Emulate_BC1F (llvm::MCInst& insn)
cc = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- fcsr = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_fcsr_mips, 0, &success);
+ fcsr = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_fcsr_mips, 0, &success);
if (!success)
return false;
@@ -2547,7 +3454,7 @@ EmulateInstructionMIPS::Emulate_BC1F (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -2570,11 +3477,11 @@ EmulateInstructionMIPS::Emulate_BC1T (llvm::MCInst& insn)
cc = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- fcsr = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_fcsr_mips, 0, &success);
+ fcsr = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_fcsr_mips, 0, &success);
if (!success)
return false;
@@ -2588,7 +3495,7 @@ EmulateInstructionMIPS::Emulate_BC1T (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -2611,11 +3518,11 @@ EmulateInstructionMIPS::Emulate_BC1FL (llvm::MCInst& insn)
cc = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- fcsr = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_fcsr_mips, 0, &success);
+ fcsr = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_fcsr_mips, 0, &success);
if (!success)
return false;
@@ -2629,7 +3536,7 @@ EmulateInstructionMIPS::Emulate_BC1FL (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -2652,11 +3559,11 @@ EmulateInstructionMIPS::Emulate_BC1TL (llvm::MCInst& insn)
cc = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- fcsr = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_fcsr_mips, 0, &success);
+ fcsr = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_fcsr_mips, 0, &success);
if (!success)
return false;
@@ -2670,7 +3577,7 @@ EmulateInstructionMIPS::Emulate_BC1TL (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -2694,11 +3601,11 @@ EmulateInstructionMIPS::Emulate_BC1EQZ (llvm::MCInst& insn)
ft = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- ft_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + ft, 0, &success);
+ ft_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + ft, 0, &success);
if (!success)
return false;
@@ -2709,7 +3616,7 @@ EmulateInstructionMIPS::Emulate_BC1EQZ (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -2733,11 +3640,11 @@ EmulateInstructionMIPS::Emulate_BC1NEZ (llvm::MCInst& insn)
ft = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- ft_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips + ft, 0, &success);
+ ft_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + ft, 0, &success);
if (!success)
return false;
@@ -2748,7 +3655,7 @@ EmulateInstructionMIPS::Emulate_BC1NEZ (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -2772,11 +3679,11 @@ EmulateInstructionMIPS::Emulate_BC1ANY2F (llvm::MCInst& insn)
cc = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- fcsr = (uint32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_fcsr_mips, 0, &success);
+ fcsr = (uint32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_fcsr_mips, 0, &success);
if (!success)
return false;
@@ -2791,7 +3698,7 @@ EmulateInstructionMIPS::Emulate_BC1ANY2F (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -2815,11 +3722,11 @@ EmulateInstructionMIPS::Emulate_BC1ANY2T (llvm::MCInst& insn)
cc = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- fcsr = (uint32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_fcsr_mips, 0, &success);
+ fcsr = (uint32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_fcsr_mips, 0, &success);
if (!success)
return false;
@@ -2834,7 +3741,7 @@ EmulateInstructionMIPS::Emulate_BC1ANY2T (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -2860,11 +3767,11 @@ EmulateInstructionMIPS::Emulate_BC1ANY4F (llvm::MCInst& insn)
cc = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- fcsr = (uint32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_fcsr_mips, 0, &success);
+ fcsr = (uint32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_fcsr_mips, 0, &success);
if (!success)
return false;
@@ -2879,7 +3786,7 @@ EmulateInstructionMIPS::Emulate_BC1ANY4F (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
@@ -2905,11 +3812,11 @@ EmulateInstructionMIPS::Emulate_BC1ANY4T (llvm::MCInst& insn)
cc = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
if (!success)
return false;
- fcsr = (uint32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_fcsr_mips, 0, &success);
+ fcsr = (uint32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_fcsr_mips, 0, &success);
if (!success)
return false;
@@ -2924,8 +3831,234 @@ EmulateInstructionMIPS::Emulate_BC1ANY4T (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
+ return false;
+
+ return true;
+}
+
+bool
+EmulateInstructionMIPS::Emulate_BNZB (llvm::MCInst& insn)
+{
+ return Emulate_MSA_Branch_DF(insn, 1, true);
+}
+
+bool
+EmulateInstructionMIPS::Emulate_BNZH (llvm::MCInst& insn)
+{
+ return Emulate_MSA_Branch_DF(insn, 2, true);
+}
+
+bool
+EmulateInstructionMIPS::Emulate_BNZW (llvm::MCInst& insn)
+{
+ return Emulate_MSA_Branch_DF(insn, 4, true);
+}
+
+bool
+EmulateInstructionMIPS::Emulate_BNZD (llvm::MCInst& insn)
+{
+ return Emulate_MSA_Branch_DF(insn, 8, true);
+}
+
+bool
+EmulateInstructionMIPS::Emulate_BZB (llvm::MCInst& insn)
+{
+ return Emulate_MSA_Branch_DF(insn, 1, false);
+}
+
+bool
+EmulateInstructionMIPS::Emulate_BZH (llvm::MCInst& insn)
+{
+ return Emulate_MSA_Branch_DF(insn, 2, false);
+}
+
+bool
+EmulateInstructionMIPS::Emulate_BZW (llvm::MCInst& insn)
+{
+ return Emulate_MSA_Branch_DF(insn, 4, false);
+}
+
+bool
+EmulateInstructionMIPS::Emulate_BZD (llvm::MCInst& insn)
+{
+ return Emulate_MSA_Branch_DF(insn, 8, false);
+}
+
+bool
+EmulateInstructionMIPS::Emulate_MSA_Branch_DF (llvm::MCInst& insn, int element_byte_size, bool bnz)
+{
+ bool success = false, branch_hit = true;
+ int32_t target = 0;
+ RegisterValue reg_value;
+ uint8_t * ptr = NULL;
+
+ uint32_t wt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
+ int32_t offset = insn.getOperand(1).getImm();
+
+ int32_t pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
+
+ if (ReadRegister (eRegisterKindDWARF, dwarf_w0_mips + wt, reg_value))
+ ptr = (uint8_t *)reg_value.GetBytes();
+ else
+ return false;
+
+ for(int i = 0; i < 16 / element_byte_size; i++)
+ {
+ switch(element_byte_size)
+ {
+ case 1:
+ if((*ptr == 0 && bnz) || (*ptr != 0 && !bnz) )
+ branch_hit = false;
+ break;
+ case 2:
+ if((*(uint16_t *)ptr == 0 && bnz) || (*(uint16_t *)ptr != 0 && !bnz))
+ branch_hit = false;
+ break;
+ case 4:
+ if((*(uint32_t *)ptr == 0 && bnz) || (*(uint32_t *)ptr != 0 && !bnz))
+ branch_hit = false;
+ break;
+ case 8:
+ if((*(uint64_t *)ptr == 0 && bnz) || (*(uint64_t *)ptr != 0 && !bnz))
+ branch_hit = false;
+ break;
+ }
+ if(!branch_hit)
+ break;
+ ptr = ptr + element_byte_size;
+ }
+
+ if(branch_hit)
+ target = pc + offset;
+ else
+ target = pc + 8;
+
+ Context context;
+ context.type = eContextRelativeBranchImmediate;
+
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
return false;
return true;
}
+
+bool
+EmulateInstructionMIPS::Emulate_BNZV (llvm::MCInst& insn)
+{
+ return Emulate_MSA_Branch_V (insn, true);
+}
+
+bool
+EmulateInstructionMIPS::Emulate_BZV (llvm::MCInst& insn)
+{
+ return Emulate_MSA_Branch_V (insn, false);
+}
+
+bool
+EmulateInstructionMIPS::Emulate_MSA_Branch_V (llvm::MCInst& insn, bool bnz)
+{
+ bool success = false;
+ int32_t target = 0;
+ llvm::APInt wr_val = llvm::APInt::getNullValue(128);
+ llvm::APInt fail_value = llvm::APInt::getMaxValue(128);
+ llvm::APInt zero_value = llvm::APInt::getNullValue(128);
+ RegisterValue reg_value;
+
+ uint32_t wt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
+ int32_t offset = insn.getOperand(1).getImm();
+
+ int32_t pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
+
+ if (ReadRegister (eRegisterKindDWARF, dwarf_w0_mips + wt, reg_value))
+ wr_val = reg_value.GetAsUInt128(fail_value);
+ else
+ return false;
+
+ if((llvm::APInt::isSameValue(zero_value, wr_val) && !bnz) || (!llvm::APInt::isSameValue(zero_value, wr_val) && bnz))
+ target = pc + offset;
+ else
+ target = pc + 8;
+
+ Context context;
+ context.type = eContextRelativeBranchImmediate;
+
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
+ return false;
+
+ return true;
+}
+
+bool
+EmulateInstructionMIPS::Emulate_LDST_Imm (llvm::MCInst& insn)
+{
+ bool success = false;
+ uint32_t base;
+ int32_t imm, address;
+ Context bad_vaddr_context;
+
+ uint32_t num_operands = insn.getNumOperands();
+ base = m_reg_info->getEncodingValue (insn.getOperand(num_operands-2).getReg());
+ imm = insn.getOperand(num_operands-1).getImm();
+
+ RegisterInfo reg_info_base;
+ if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + base, reg_info_base))
+ return false;
+
+ /* read base register */
+ address =(int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
+ if (!success)
+ return false;
+
+ /* destination address */
+ address = address + imm;
+
+ /* Set the bad_vaddr register with base address used in the instruction */
+ bad_vaddr_context.type = eContextInvalid;
+ WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips, address);
+
+ return true;
+}
+
+bool
+EmulateInstructionMIPS::Emulate_LDST_Reg (llvm::MCInst& insn)
+{
+ bool success = false;
+ uint32_t base, index;
+ int32_t address, index_address;
+ Context bad_vaddr_context;
+
+ uint32_t num_operands = insn.getNumOperands();
+ base = m_reg_info->getEncodingValue (insn.getOperand(num_operands-2).getReg());
+ index = m_reg_info->getEncodingValue (insn.getOperand(num_operands-1).getReg());
+
+ RegisterInfo reg_info_base, reg_info_index;
+ if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + base, reg_info_base))
+ return false;
+
+ if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + index, reg_info_index))
+ return false;
+
+ /* read base register */
+ address =(int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
+ if (!success)
+ return false;
+
+ /* read index register */
+ index_address =(int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + index, 0, &success);
+ if (!success)
+ return false;
+
+ /* destination address */
+ address = address + index_address;
+
+ /* Set the bad_vaddr register with base address used in the instruction */
+ bad_vaddr_context.type = eContextInvalid;
+ WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips, address);
+
+ return true;
+}
diff --git a/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h b/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h
index 25d8fc8891d5..e1340f983278 100644
--- a/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h
+++ b/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h
@@ -60,53 +60,52 @@ public:
return false;
}
- virtual lldb_private::ConstString
- GetPluginName();
+ lldb_private::ConstString
+ GetPluginName() override;
- virtual lldb_private::ConstString
- GetShortPluginName()
- {
- return GetPluginNameStatic();
- }
-
- virtual uint32_t
- GetPluginVersion()
+ uint32_t
+ GetPluginVersion() override
{
return 1;
}
bool
- SetTargetTriple (const lldb_private::ArchSpec &arch);
+ SetTargetTriple (const lldb_private::ArchSpec &arch) override;
EmulateInstructionMIPS (const lldb_private::ArchSpec &arch);
- virtual bool
- SupportsEmulatingInstructionsOfType (lldb_private::InstructionType inst_type)
+ bool
+ SupportsEmulatingInstructionsOfType (lldb_private::InstructionType inst_type) override
{
return SupportsEmulatingInstructionsOfTypeStatic (inst_type);
}
- virtual bool
- ReadInstruction ();
-
- virtual bool
- EvaluateInstruction (uint32_t evaluate_options);
+ bool
+ ReadInstruction () override;
- virtual bool
+ bool
+ EvaluateInstruction (uint32_t evaluate_options) override;
+
+ bool
+ SetInstruction (const lldb_private::Opcode &insn_opcode,
+ const lldb_private::Address &inst_addr,
+ lldb_private::Target *target) override;
+
+ bool
TestEmulation (lldb_private::Stream *out_stream,
lldb_private::ArchSpec &arch,
- lldb_private::OptionValueDictionary *test_data)
+ lldb_private::OptionValueDictionary *test_data) override
{
return false;
}
- virtual bool
+ bool
GetRegisterInfo (lldb::RegisterKind reg_kind,
uint32_t reg_num,
- lldb_private::RegisterInfo &reg_info);
+ lldb_private::RegisterInfo &reg_info) override;
- virtual bool
- CreateFunctionEntryUnwind (lldb_private::UnwindPlan &unwind_plan);
+ bool
+ CreateFunctionEntryUnwind (lldb_private::UnwindPlan &unwind_plan) override;
protected:
@@ -121,6 +120,9 @@ protected:
static MipsOpcode*
GetOpcodeForInstruction (const char *op_name);
+ uint32_t
+ GetSizeOfInstruction (lldb_private::DataExtractor& data, uint64_t inst_addr);
+
bool
Emulate_ADDiu (llvm::MCInst& insn);
@@ -131,6 +133,33 @@ protected:
Emulate_LW (llvm::MCInst& insn);
bool
+ Emulate_ADDIUSP (llvm::MCInst& insn);
+
+ bool
+ Emulate_ADDIUS5 (llvm::MCInst& insn);
+
+ bool
+ Emulate_SWSP (llvm::MCInst& insn);
+
+ bool
+ Emulate_SWM16_32 (llvm::MCInst& insn);
+
+ bool
+ Emulate_LWSP (llvm::MCInst& insn);
+
+ bool
+ Emulate_LWM16_32 (llvm::MCInst& insn);
+
+ bool
+ Emulate_JRADDIUSP (llvm::MCInst& insn);
+
+ bool
+ Emulate_LDST_Imm (llvm::MCInst& insn);
+
+ bool
+ Emulate_LDST_Reg (llvm::MCInst& insn);
+
+ bool
Emulate_BEQ (llvm::MCInst& insn);
bool
@@ -296,6 +325,57 @@ protected:
Emulate_BC1ANY4T (llvm::MCInst& insn);
bool
+ Emulate_BNZB (llvm::MCInst& insn);
+
+ bool
+ Emulate_BNZH (llvm::MCInst& insn);
+
+ bool
+ Emulate_BNZW (llvm::MCInst& insn);
+
+ bool
+ Emulate_BNZD (llvm::MCInst& insn);
+
+ bool
+ Emulate_BZB (llvm::MCInst& insn);
+
+ bool
+ Emulate_BZH (llvm::MCInst& insn);
+
+ bool
+ Emulate_BZW (llvm::MCInst& insn);
+
+ bool
+ Emulate_BZD (llvm::MCInst& insn);
+
+ bool
+ Emulate_MSA_Branch_DF (llvm::MCInst& insn, int element_byte_size, bool bnz);
+
+ bool
+ Emulate_BNZV (llvm::MCInst& insn);
+
+ bool
+ Emulate_BZV (llvm::MCInst& insn);
+
+ bool
+ Emulate_MSA_Branch_V (llvm::MCInst& insn, bool bnz);
+
+ bool
+ Emulate_B16_MM (llvm::MCInst& insn);
+
+ bool
+ Emulate_Branch_MM (llvm::MCInst& insn);
+
+ bool
+ Emulate_JALRx16_MM (llvm::MCInst& insn);
+
+ bool
+ Emulate_JALx (llvm::MCInst& insn);
+
+ bool
+ Emulate_JALRS (llvm::MCInst& insn);
+
+ bool
nonvolatile_reg_p (uint32_t regnum);
const char *
@@ -303,11 +383,15 @@ protected:
private:
std::unique_ptr<llvm::MCDisassembler> m_disasm;
+ std::unique_ptr<llvm::MCDisassembler> m_alt_disasm;
std::unique_ptr<llvm::MCSubtargetInfo> m_subtype_info;
+ std::unique_ptr<llvm::MCSubtargetInfo> m_alt_subtype_info;
std::unique_ptr<llvm::MCRegisterInfo> m_reg_info;
std::unique_ptr<llvm::MCAsmInfo> m_asm_info;
std::unique_ptr<llvm::MCContext> m_context;
std::unique_ptr<llvm::MCInstrInfo> m_insn_info;
+ uint32_t m_next_inst_size;
+ bool m_use_alt_disaasm;
};
#endif // EmulateInstructionMIPS_h_
diff --git a/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp b/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
index a574e7d348e1..28eba093f317 100644
--- a/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
+++ b/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
@@ -221,41 +221,76 @@ EmulateInstructionMIPS64::GetRegisterName (unsigned reg_num, bool alternate_name
{
switch (reg_num)
{
- case gcc_dwarf_sp_mips64: return "r29";
- case gcc_dwarf_r30_mips64: return "r30";
- case gcc_dwarf_ra_mips64: return "r31";
- case gcc_dwarf_f0_mips64: return "f0";
- case gcc_dwarf_f1_mips64: return "f1";
- case gcc_dwarf_f2_mips64: return "f2";
- case gcc_dwarf_f3_mips64: return "f3";
- case gcc_dwarf_f4_mips64: return "f4";
- case gcc_dwarf_f5_mips64: return "f5";
- case gcc_dwarf_f6_mips64: return "f6";
- case gcc_dwarf_f7_mips64: return "f7";
- case gcc_dwarf_f8_mips64: return "f8";
- case gcc_dwarf_f9_mips64: return "f9";
- case gcc_dwarf_f10_mips64: return "f10";
- case gcc_dwarf_f11_mips64: return "f11";
- case gcc_dwarf_f12_mips64: return "f12";
- case gcc_dwarf_f13_mips64: return "f13";
- case gcc_dwarf_f14_mips64: return "f14";
- case gcc_dwarf_f15_mips64: return "f15";
- case gcc_dwarf_f16_mips64: return "f16";
- case gcc_dwarf_f17_mips64: return "f17";
- case gcc_dwarf_f18_mips64: return "f18";
- case gcc_dwarf_f19_mips64: return "f19";
- case gcc_dwarf_f20_mips64: return "f20";
- case gcc_dwarf_f21_mips64: return "f21";
- case gcc_dwarf_f22_mips64: return "f22";
- case gcc_dwarf_f23_mips64: return "f23";
- case gcc_dwarf_f24_mips64: return "f24";
- case gcc_dwarf_f25_mips64: return "f25";
- case gcc_dwarf_f26_mips64: return "f26";
- case gcc_dwarf_f27_mips64: return "f27";
- case gcc_dwarf_f28_mips64: return "f28";
- case gcc_dwarf_f29_mips64: return "f29";
- case gcc_dwarf_f30_mips64: return "f30";
- case gcc_dwarf_f31_mips64: return "f31";
+ case dwarf_sp_mips64: return "r29";
+ case dwarf_r30_mips64: return "r30";
+ case dwarf_ra_mips64: return "r31";
+ case dwarf_f0_mips64: return "f0";
+ case dwarf_f1_mips64: return "f1";
+ case dwarf_f2_mips64: return "f2";
+ case dwarf_f3_mips64: return "f3";
+ case dwarf_f4_mips64: return "f4";
+ case dwarf_f5_mips64: return "f5";
+ case dwarf_f6_mips64: return "f6";
+ case dwarf_f7_mips64: return "f7";
+ case dwarf_f8_mips64: return "f8";
+ case dwarf_f9_mips64: return "f9";
+ case dwarf_f10_mips64: return "f10";
+ case dwarf_f11_mips64: return "f11";
+ case dwarf_f12_mips64: return "f12";
+ case dwarf_f13_mips64: return "f13";
+ case dwarf_f14_mips64: return "f14";
+ case dwarf_f15_mips64: return "f15";
+ case dwarf_f16_mips64: return "f16";
+ case dwarf_f17_mips64: return "f17";
+ case dwarf_f18_mips64: return "f18";
+ case dwarf_f19_mips64: return "f19";
+ case dwarf_f20_mips64: return "f20";
+ case dwarf_f21_mips64: return "f21";
+ case dwarf_f22_mips64: return "f22";
+ case dwarf_f23_mips64: return "f23";
+ case dwarf_f24_mips64: return "f24";
+ case dwarf_f25_mips64: return "f25";
+ case dwarf_f26_mips64: return "f26";
+ case dwarf_f27_mips64: return "f27";
+ case dwarf_f28_mips64: return "f28";
+ case dwarf_f29_mips64: return "f29";
+ case dwarf_f30_mips64: return "f30";
+ case dwarf_f31_mips64: return "f31";
+ case dwarf_w0_mips64: return "w0";
+ case dwarf_w1_mips64: return "w1";
+ case dwarf_w2_mips64: return "w2";
+ case dwarf_w3_mips64: return "w3";
+ case dwarf_w4_mips64: return "w4";
+ case dwarf_w5_mips64: return "w5";
+ case dwarf_w6_mips64: return "w6";
+ case dwarf_w7_mips64: return "w7";
+ case dwarf_w8_mips64: return "w8";
+ case dwarf_w9_mips64: return "w9";
+ case dwarf_w10_mips64: return "w10";
+ case dwarf_w11_mips64: return "w11";
+ case dwarf_w12_mips64: return "w12";
+ case dwarf_w13_mips64: return "w13";
+ case dwarf_w14_mips64: return "w14";
+ case dwarf_w15_mips64: return "w15";
+ case dwarf_w16_mips64: return "w16";
+ case dwarf_w17_mips64: return "w17";
+ case dwarf_w18_mips64: return "w18";
+ case dwarf_w19_mips64: return "w19";
+ case dwarf_w20_mips64: return "w20";
+ case dwarf_w21_mips64: return "w21";
+ case dwarf_w22_mips64: return "w22";
+ case dwarf_w23_mips64: return "w23";
+ case dwarf_w24_mips64: return "w24";
+ case dwarf_w25_mips64: return "w25";
+ case dwarf_w26_mips64: return "w26";
+ case dwarf_w27_mips64: return "w27";
+ case dwarf_w28_mips64: return "w28";
+ case dwarf_w29_mips64: return "w29";
+ case dwarf_w30_mips64: return "w30";
+ case dwarf_w31_mips64: return "w31";
+ case dwarf_mir_mips64: return "mir";
+ case dwarf_mcsr_mips64: return "mcsr";
+ case dwarf_config5_mips64: return "config5";
default:
break;
}
@@ -264,78 +299,113 @@ EmulateInstructionMIPS64::GetRegisterName (unsigned reg_num, bool alternate_name
switch (reg_num)
{
- case gcc_dwarf_zero_mips64: return "r0";
- case gcc_dwarf_r1_mips64: return "r1";
- case gcc_dwarf_r2_mips64: return "r2";
- case gcc_dwarf_r3_mips64: return "r3";
- case gcc_dwarf_r4_mips64: return "r4";
- case gcc_dwarf_r5_mips64: return "r5";
- case gcc_dwarf_r6_mips64: return "r6";
- case gcc_dwarf_r7_mips64: return "r7";
- case gcc_dwarf_r8_mips64: return "r8";
- case gcc_dwarf_r9_mips64: return "r9";
- case gcc_dwarf_r10_mips64: return "r10";
- case gcc_dwarf_r11_mips64: return "r11";
- case gcc_dwarf_r12_mips64: return "r12";
- case gcc_dwarf_r13_mips64: return "r13";
- case gcc_dwarf_r14_mips64: return "r14";
- case gcc_dwarf_r15_mips64: return "r15";
- case gcc_dwarf_r16_mips64: return "r16";
- case gcc_dwarf_r17_mips64: return "r17";
- case gcc_dwarf_r18_mips64: return "r18";
- case gcc_dwarf_r19_mips64: return "r19";
- case gcc_dwarf_r20_mips64: return "r20";
- case gcc_dwarf_r21_mips64: return "r21";
- case gcc_dwarf_r22_mips64: return "r22";
- case gcc_dwarf_r23_mips64: return "r23";
- case gcc_dwarf_r24_mips64: return "r24";
- case gcc_dwarf_r25_mips64: return "r25";
- case gcc_dwarf_r26_mips64: return "r26";
- case gcc_dwarf_r27_mips64: return "r27";
- case gcc_dwarf_gp_mips64: return "gp";
- case gcc_dwarf_sp_mips64: return "sp";
- case gcc_dwarf_r30_mips64: return "fp";
- case gcc_dwarf_ra_mips64: return "ra";
- case gcc_dwarf_sr_mips64: return "sr";
- case gcc_dwarf_lo_mips64: return "lo";
- case gcc_dwarf_hi_mips64: return "hi";
- case gcc_dwarf_bad_mips64: return "bad";
- case gcc_dwarf_cause_mips64: return "cause";
- case gcc_dwarf_pc_mips64: return "pc";
- case gcc_dwarf_f0_mips64: return "f0";
- case gcc_dwarf_f1_mips64: return "f1";
- case gcc_dwarf_f2_mips64: return "f2";
- case gcc_dwarf_f3_mips64: return "f3";
- case gcc_dwarf_f4_mips64: return "f4";
- case gcc_dwarf_f5_mips64: return "f5";
- case gcc_dwarf_f6_mips64: return "f6";
- case gcc_dwarf_f7_mips64: return "f7";
- case gcc_dwarf_f8_mips64: return "f8";
- case gcc_dwarf_f9_mips64: return "f9";
- case gcc_dwarf_f10_mips64: return "f10";
- case gcc_dwarf_f11_mips64: return "f11";
- case gcc_dwarf_f12_mips64: return "f12";
- case gcc_dwarf_f13_mips64: return "f13";
- case gcc_dwarf_f14_mips64: return "f14";
- case gcc_dwarf_f15_mips64: return "f15";
- case gcc_dwarf_f16_mips64: return "f16";
- case gcc_dwarf_f17_mips64: return "f17";
- case gcc_dwarf_f18_mips64: return "f18";
- case gcc_dwarf_f19_mips64: return "f19";
- case gcc_dwarf_f20_mips64: return "f20";
- case gcc_dwarf_f21_mips64: return "f21";
- case gcc_dwarf_f22_mips64: return "f22";
- case gcc_dwarf_f23_mips64: return "f23";
- case gcc_dwarf_f24_mips64: return "f24";
- case gcc_dwarf_f25_mips64: return "f25";
- case gcc_dwarf_f26_mips64: return "f26";
- case gcc_dwarf_f27_mips64: return "f27";
- case gcc_dwarf_f28_mips64: return "f28";
- case gcc_dwarf_f29_mips64: return "f29";
- case gcc_dwarf_f30_mips64: return "f30";
- case gcc_dwarf_f31_mips64: return "f31";
- case gcc_dwarf_fcsr_mips64: return "fcsr";
- case gcc_dwarf_fir_mips64: return "fir";
+ case dwarf_zero_mips64: return "r0";
+ case dwarf_r1_mips64: return "r1";
+ case dwarf_r2_mips64: return "r2";
+ case dwarf_r3_mips64: return "r3";
+ case dwarf_r4_mips64: return "r4";
+ case dwarf_r5_mips64: return "r5";
+ case dwarf_r6_mips64: return "r6";
+ case dwarf_r7_mips64: return "r7";
+ case dwarf_r8_mips64: return "r8";
+ case dwarf_r9_mips64: return "r9";
+ case dwarf_r10_mips64: return "r10";
+ case dwarf_r11_mips64: return "r11";
+ case dwarf_r12_mips64: return "r12";
+ case dwarf_r13_mips64: return "r13";
+ case dwarf_r14_mips64: return "r14";
+ case dwarf_r15_mips64: return "r15";
+ case dwarf_r16_mips64: return "r16";
+ case dwarf_r17_mips64: return "r17";
+ case dwarf_r18_mips64: return "r18";
+ case dwarf_r19_mips64: return "r19";
+ case dwarf_r20_mips64: return "r20";
+ case dwarf_r21_mips64: return "r21";
+ case dwarf_r22_mips64: return "r22";
+ case dwarf_r23_mips64: return "r23";
+ case dwarf_r24_mips64: return "r24";
+ case dwarf_r25_mips64: return "r25";
+ case dwarf_r26_mips64: return "r26";
+ case dwarf_r27_mips64: return "r27";
+ case dwarf_gp_mips64: return "gp";
+ case dwarf_sp_mips64: return "sp";
+ case dwarf_r30_mips64: return "fp";
+ case dwarf_ra_mips64: return "ra";
+ case dwarf_sr_mips64: return "sr";
+ case dwarf_lo_mips64: return "lo";
+ case dwarf_hi_mips64: return "hi";
+ case dwarf_bad_mips64: return "bad";
+ case dwarf_cause_mips64: return "cause";
+ case dwarf_pc_mips64: return "pc";
+ case dwarf_f0_mips64: return "f0";
+ case dwarf_f1_mips64: return "f1";
+ case dwarf_f2_mips64: return "f2";
+ case dwarf_f3_mips64: return "f3";
+ case dwarf_f4_mips64: return "f4";
+ case dwarf_f5_mips64: return "f5";
+ case dwarf_f6_mips64: return "f6";
+ case dwarf_f7_mips64: return "f7";
+ case dwarf_f8_mips64: return "f8";
+ case dwarf_f9_mips64: return "f9";
+ case dwarf_f10_mips64: return "f10";
+ case dwarf_f11_mips64: return "f11";
+ case dwarf_f12_mips64: return "f12";
+ case dwarf_f13_mips64: return "f13";
+ case dwarf_f14_mips64: return "f14";
+ case dwarf_f15_mips64: return "f15";
+ case dwarf_f16_mips64: return "f16";
+ case dwarf_f17_mips64: return "f17";
+ case dwarf_f18_mips64: return "f18";
+ case dwarf_f19_mips64: return "f19";
+ case dwarf_f20_mips64: return "f20";
+ case dwarf_f21_mips64: return "f21";
+ case dwarf_f22_mips64: return "f22";
+ case dwarf_f23_mips64: return "f23";
+ case dwarf_f24_mips64: return "f24";
+ case dwarf_f25_mips64: return "f25";
+ case dwarf_f26_mips64: return "f26";
+ case dwarf_f27_mips64: return "f27";
+ case dwarf_f28_mips64: return "f28";
+ case dwarf_f29_mips64: return "f29";
+ case dwarf_f30_mips64: return "f30";
+ case dwarf_f31_mips64: return "f31";
+ case dwarf_fcsr_mips64: return "fcsr";
+ case dwarf_fir_mips64: return "fir";
+ case dwarf_w0_mips64: return "w0";
+ case dwarf_w1_mips64: return "w1";
+ case dwarf_w2_mips64: return "w2";
+ case dwarf_w3_mips64: return "w3";
+ case dwarf_w4_mips64: return "w4";
+ case dwarf_w5_mips64: return "w5";
+ case dwarf_w6_mips64: return "w6";
+ case dwarf_w7_mips64: return "w7";
+ case dwarf_w8_mips64: return "w8";
+ case dwarf_w9_mips64: return "w9";
+ case dwarf_w10_mips64: return "w10";
+ case dwarf_w11_mips64: return "w11";
+ case dwarf_w12_mips64: return "w12";
+ case dwarf_w13_mips64: return "w13";
+ case dwarf_w14_mips64: return "w14";
+ case dwarf_w15_mips64: return "w15";
+ case dwarf_w16_mips64: return "w16";
+ case dwarf_w17_mips64: return "w17";
+ case dwarf_w18_mips64: return "w18";
+ case dwarf_w19_mips64: return "w19";
+ case dwarf_w20_mips64: return "w20";
+ case dwarf_w21_mips64: return "w21";
+ case dwarf_w22_mips64: return "w22";
+ case dwarf_w23_mips64: return "w23";
+ case dwarf_w24_mips64: return "w24";
+ case dwarf_w25_mips64: return "w25";
+ case dwarf_w26_mips64: return "w26";
+ case dwarf_w27_mips64: return "w27";
+ case dwarf_w28_mips64: return "w28";
+ case dwarf_w29_mips64: return "w29";
+ case dwarf_w30_mips64: return "w30";
+ case dwarf_w31_mips64: return "w31";
+ case dwarf_mcsr_mips64: return "mcsr";
+ case dwarf_mir_mips64: return "mir";
+ case dwarf_config5_mips64: return "config5";
}
return nullptr;
}
@@ -347,11 +417,11 @@ EmulateInstructionMIPS64::GetRegisterInfo (RegisterKind reg_kind, uint32_t reg_n
{
switch (reg_num)
{
- case LLDB_REGNUM_GENERIC_PC: reg_kind = eRegisterKindDWARF; reg_num = gcc_dwarf_pc_mips64; break;
- case LLDB_REGNUM_GENERIC_SP: reg_kind = eRegisterKindDWARF; reg_num = gcc_dwarf_sp_mips64; break;
- case LLDB_REGNUM_GENERIC_FP: reg_kind = eRegisterKindDWARF; reg_num = gcc_dwarf_r30_mips64; break;
- case LLDB_REGNUM_GENERIC_RA: reg_kind = eRegisterKindDWARF; reg_num = gcc_dwarf_ra_mips64; break;
- case LLDB_REGNUM_GENERIC_FLAGS: reg_kind = eRegisterKindDWARF; reg_num = gcc_dwarf_sr_mips64; break;
+ case LLDB_REGNUM_GENERIC_PC: reg_kind = eRegisterKindDWARF; reg_num = dwarf_pc_mips64; break;
+ case LLDB_REGNUM_GENERIC_SP: reg_kind = eRegisterKindDWARF; reg_num = dwarf_sp_mips64; break;
+ case LLDB_REGNUM_GENERIC_FP: reg_kind = eRegisterKindDWARF; reg_num = dwarf_r30_mips64; break;
+ case LLDB_REGNUM_GENERIC_RA: reg_kind = eRegisterKindDWARF; reg_num = dwarf_ra_mips64; break;
+ case LLDB_REGNUM_GENERIC_FLAGS: reg_kind = eRegisterKindDWARF; reg_num = dwarf_sr_mips64; break;
default:
return false;
}
@@ -362,18 +432,24 @@ EmulateInstructionMIPS64::GetRegisterInfo (RegisterKind reg_kind, uint32_t reg_n
::memset (&reg_info, 0, sizeof(RegisterInfo));
::memset (reg_info.kinds, LLDB_INVALID_REGNUM, sizeof(reg_info.kinds));
- if (reg_num == gcc_dwarf_sr_mips64 || reg_num == gcc_dwarf_fcsr_mips64 || reg_num == gcc_dwarf_fir_mips64)
+ if (reg_num == dwarf_sr_mips64 || reg_num == dwarf_fcsr_mips64 || reg_num == dwarf_fir_mips64 || reg_num == dwarf_mcsr_mips64 || reg_num == dwarf_mir_mips64 || reg_num == dwarf_config5_mips64)
{
reg_info.byte_size = 4;
reg_info.format = eFormatHex;
reg_info.encoding = eEncodingUint;
}
- else if ((int)reg_num >= gcc_dwarf_zero_mips64 && (int)reg_num <= gcc_dwarf_f31_mips64)
+ else if ((int)reg_num >= dwarf_zero_mips64 && (int)reg_num <= dwarf_f31_mips64)
{
reg_info.byte_size = 8;
reg_info.format = eFormatHex;
reg_info.encoding = eEncodingUint;
}
+ else if ((int)reg_num >= dwarf_w0_mips64 && (int)reg_num <= dwarf_w31_mips64)
+ {
+ reg_info.byte_size = 16;
+ reg_info.format = eFormatVectorOfUInt8;
+ reg_info.encoding = eEncodingVector;
+ }
else
{
return false;
@@ -385,11 +461,11 @@ EmulateInstructionMIPS64::GetRegisterInfo (RegisterKind reg_kind, uint32_t reg_n
switch (reg_num)
{
- case gcc_dwarf_r30_mips64: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP; break;
- case gcc_dwarf_ra_mips64: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_RA; break;
- case gcc_dwarf_sp_mips64: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_SP; break;
- case gcc_dwarf_pc_mips64: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC; break;
- case gcc_dwarf_sr_mips64: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FLAGS; break;
+ case dwarf_r30_mips64: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP; break;
+ case dwarf_ra_mips64: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_RA; break;
+ case dwarf_sp_mips64: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_SP; break;
+ case dwarf_pc_mips64: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC; break;
+ case dwarf_sr_mips64: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FLAGS; break;
default: break;
}
return true;
@@ -410,8 +486,65 @@ EmulateInstructionMIPS64::GetOpcodeForInstruction (const char *op_name)
{ "SD", &EmulateInstructionMIPS64::Emulate_SD, "SD rt,offset(rs)" },
{ "LD", &EmulateInstructionMIPS64::Emulate_LD, "LD rt,offset(base)" },
- { "SW", &EmulateInstructionMIPS64::Emulate_SW, "SW rt,offset(rs)" },
- { "LW", &EmulateInstructionMIPS64::Emulate_LW, "LW rt,offset(rs)" },
+
+
+
+ //----------------------------------------------------------------------
+ // 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, we have generalised
+ all these instructions in 2 functions depending on their addressing modes */
+
+ { "LB", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LB rt, offset(base)" },
+ { "LBE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LBE rt, offset(base)" },
+ { "LBU", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LBU rt, offset(base)" },
+ { "LBUE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LBUE rt, offset(base)" },
+ { "LDC1", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LDC1 ft, offset(base)" },
+ { "LDL", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LDL rt, offset(base)" },
+ { "LDR", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LDR rt, offset(base)" },
+ { "LLD", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LLD rt, offset(base)" },
+ { "LDC2", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LDC2 rt, offset(base)" },
+ { "LDXC1", &EmulateInstructionMIPS64::Emulate_LDST_Reg, "LDXC1 fd, index (base)" },
+ { "LH", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LH rt, offset(base)" },
+ { "LHE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LHE rt, offset(base)" },
+ { "LHU", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LHU rt, offset(base)" },
+ { "LHUE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LHUE rt, offset(base)" },
+ { "LL", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LL rt, offset(base)" },
+ { "LLE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LLE rt, offset(base)" },
+ { "LUXC1", &EmulateInstructionMIPS64::Emulate_LDST_Reg, "LUXC1 fd, index (base)" },
+ { "LW", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LW rt, offset(rs)" },
+ { "LWC1", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LWC1 ft, offset(base)" },
+ { "LWC2", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LWC2 rt, offset(base)" },
+ { "LWE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LWE rt, offset(base)" },
+ { "LWL", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LWL rt, offset(base)" },
+ { "LWLE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LWLE rt, offset(base)" },
+ { "LWR", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LWR rt, offset(base)" },
+ { "LWRE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LWRE rt, offset(base)" },
+ { "LWXC1", &EmulateInstructionMIPS64::Emulate_LDST_Reg, "LWXC1 fd, index (base)" },
+
+ { "SB", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SB rt, offset(base)" },
+ { "SBE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SBE rt, offset(base)" },
+ { "SC", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SC rt, offset(base)" },
+ { "SCE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SCE rt, offset(base)" },
+ { "SCD", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SCD rt, offset(base)" },
+ { "SDL", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SDL rt, offset(base)" },
+ { "SDR", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SDR rt, offset(base)" },
+ { "SDC1", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SDC1 ft, offset(base)" },
+ { "SDC2", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SDC2 rt, offset(base)" },
+ { "SDXC1", &EmulateInstructionMIPS64::Emulate_LDST_Reg, "SDXC1 fs, index (base)" },
+ { "SH", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SH rt, offset(base)" },
+ { "SHE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SHE rt, offset(base)" },
+ { "SUXC1", &EmulateInstructionMIPS64::Emulate_LDST_Reg, "SUXC1 fs, index (base)" },
+ { "SW", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SW rt, offset(rs)" },
+ { "SWC1", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SWC1 ft, offset(base)" },
+ { "SWC2", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SWC2 rt, offset(base)" },
+ { "SWE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SWE rt, offset(base)" },
+ { "SWL", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SWL rt, offset(base)" },
+ { "SWLE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SWLE rt, offset(base)" },
+ { "SWR", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SWR rt, offset(base)" },
+ { "SWRE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SWRE rt, offset(base)" },
+ { "SWXC1", &EmulateInstructionMIPS64::Emulate_LDST_Reg, "SWXC1 fs, index (base)" },
//----------------------------------------------------------------------
// Branch instructions
@@ -474,6 +607,16 @@ EmulateInstructionMIPS64::GetOpcodeForInstruction (const char *op_name)
{ "BC1ANY2T", &EmulateInstructionMIPS64::Emulate_BC1ANY2T, "BC1ANY2T cc, offset" },
{ "BC1ANY4F", &EmulateInstructionMIPS64::Emulate_BC1ANY4F, "BC1ANY4F cc, offset" },
{ "BC1ANY4T", &EmulateInstructionMIPS64::Emulate_BC1ANY4T, "BC1ANY4T cc, offset" },
+ { "BNZ_B", &EmulateInstructionMIPS64::Emulate_BNZB, "BNZ.b wt,s16" },
+ { "BNZ_H", &EmulateInstructionMIPS64::Emulate_BNZH, "BNZ.h wt,s16" },
+ { "BNZ_W", &EmulateInstructionMIPS64::Emulate_BNZW, "BNZ.w wt,s16" },
+ { "BNZ_D", &EmulateInstructionMIPS64::Emulate_BNZD, "BNZ.d wt,s16" },
+ { "BZ_B", &EmulateInstructionMIPS64::Emulate_BZB, "BZ.b wt,s16" },
+ { "BZ_H", &EmulateInstructionMIPS64::Emulate_BZH, "BZ.h wt,s16" },
+ { "BZ_W", &EmulateInstructionMIPS64::Emulate_BZW, "BZ.w wt,s16" },
+ { "BZ_D", &EmulateInstructionMIPS64::Emulate_BZD, "BZ.d wt,s16" },
+ { "BNZ_V", &EmulateInstructionMIPS64::Emulate_BNZV, "BNZ.V wt,s16" },
+ { "BZ_V", &EmulateInstructionMIPS64::Emulate_BZV, "BZ.V wt,s16" },
};
static const size_t k_num_mips_opcodes = llvm::array_lengthof(g_opcodes);
@@ -545,7 +688,7 @@ EmulateInstructionMIPS64::EvaluateInstruction (uint32_t evaluate_options)
if (auto_advance_pc)
{
- old_pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ old_pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
}
@@ -557,7 +700,7 @@ EmulateInstructionMIPS64::EvaluateInstruction (uint32_t evaluate_options)
if (auto_advance_pc)
{
- new_pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ new_pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
@@ -566,7 +709,7 @@ EmulateInstructionMIPS64::EvaluateInstruction (uint32_t evaluate_options)
{
new_pc += 4;
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, new_pc))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, new_pc))
return false;
}
}
@@ -584,10 +727,10 @@ EmulateInstructionMIPS64::CreateFunctionEntryUnwind (UnwindPlan &unwind_plan)
const bool can_replace = false;
// Our previous Call Frame Address is the stack pointer
- row->GetCFAValue().SetIsRegisterPlusOffset(gcc_dwarf_sp_mips64, 0);
+ row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_sp_mips64, 0);
// Our previous PC is in the RA
- row->SetRegisterLocationToRegister(gcc_dwarf_pc_mips64, gcc_dwarf_ra_mips64, can_replace);
+ row->SetRegisterLocationToRegister(dwarf_pc_mips64, dwarf_ra_mips64, can_replace);
unwind_plan.AppendRow (row);
@@ -595,6 +738,7 @@ EmulateInstructionMIPS64::CreateFunctionEntryUnwind (UnwindPlan &unwind_plan)
unwind_plan.SetSourceName ("EmulateInstructionMIPS64");
unwind_plan.SetSourcedFromCompiler (eLazyBoolNo);
unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolYes);
+ unwind_plan.SetReturnAddressRegister (dwarf_ra_mips64);
return true;
}
@@ -604,18 +748,18 @@ EmulateInstructionMIPS64::nonvolatile_reg_p (uint64_t regnum)
{
switch (regnum)
{
- case gcc_dwarf_r16_mips64:
- case gcc_dwarf_r17_mips64:
- case gcc_dwarf_r18_mips64:
- case gcc_dwarf_r19_mips64:
- case gcc_dwarf_r20_mips64:
- case gcc_dwarf_r21_mips64:
- case gcc_dwarf_r22_mips64:
- case gcc_dwarf_r23_mips64:
- case gcc_dwarf_gp_mips64:
- case gcc_dwarf_sp_mips64:
- case gcc_dwarf_r30_mips64:
- case gcc_dwarf_ra_mips64:
+ case dwarf_r16_mips64:
+ case dwarf_r17_mips64:
+ case dwarf_r18_mips64:
+ case dwarf_r19_mips64:
+ case dwarf_r20_mips64:
+ case dwarf_r21_mips64:
+ case dwarf_r22_mips64:
+ case dwarf_r23_mips64:
+ case dwarf_gp_mips64:
+ case dwarf_sp_mips64:
+ case dwarf_r30_mips64:
+ case dwarf_ra_mips64:
return true;
default:
return false;
@@ -636,10 +780,10 @@ EmulateInstructionMIPS64::Emulate_DADDiu (llvm::MCInst& insn)
src = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
/* Check if this is daddiu sp,<src>,imm16 */
- if (dst == gcc_dwarf_sp_mips64)
+ if (dst == dwarf_sp_mips64)
{
/* read <src> register */
- uint64_t src_opd_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + src, 0, &success);
+ uint64_t src_opd_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + src, 0, &success);
if (!success)
return false;
@@ -647,79 +791,19 @@ EmulateInstructionMIPS64::Emulate_DADDiu (llvm::MCInst& insn)
Context context;
RegisterInfo reg_info_sp;
- if (GetRegisterInfo (eRegisterKindDWARF, gcc_dwarf_sp_mips64, reg_info_sp))
+ if (GetRegisterInfo (eRegisterKindDWARF, dwarf_sp_mips64, reg_info_sp))
context.SetRegisterPlusOffset (reg_info_sp, imm);
/* We are allocating bytes on stack */
context.type = eContextAdjustStackPointer;
- WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_sp_mips64, result);
+ WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_sp_mips64, result);
}
return true;
}
bool
-EmulateInstructionMIPS64::Emulate_SW (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t base;
- int64_t imm, address;
- Context bad_vaddr_context;
-
- base = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
- imm = insn.getOperand(2).getImm();
-
- RegisterInfo reg_info_base;
- if (!GetRegisterInfo (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + base, reg_info_base))
- return false;
-
- /* read base register */
- address = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + base, 0, &success);
- if (!success)
- return false;
-
- /* destination address */
- address = address + imm;
-
- /* Set the bad_vaddr register with base address used in the instruction */
- bad_vaddr_context.type = eContextInvalid;
- WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, gcc_dwarf_bad_mips64, address);
-
- return true;
-}
-
-bool
-EmulateInstructionMIPS64::Emulate_LW (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t base;
- int64_t imm, address;
- Context bad_vaddr_context;
-
- base = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
- imm = insn.getOperand(2).getImm();
-
- RegisterInfo reg_info_base;
- if (!GetRegisterInfo (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + base, reg_info_base))
- return false;
-
- /* read base register */
- address = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + base, 0, &success);
- if (!success)
- return false;
-
- /* destination address */
- address = address + imm;
-
- /* Set the bad_vaddr register with base address used in the instruction */
- bad_vaddr_context.type = eContextInvalid;
- WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, gcc_dwarf_bad_mips64, address);
-
- return true;
-}
-
-bool
EmulateInstructionMIPS64::Emulate_SD (llvm::MCInst& insn)
{
uint64_t address;
@@ -734,12 +818,12 @@ EmulateInstructionMIPS64::Emulate_SD (llvm::MCInst& insn)
src = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
base = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
- if (!GetRegisterInfo (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + base, reg_info_base)
- || !GetRegisterInfo (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + src, reg_info_src))
+ if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips64 + base, reg_info_base)
+ || !GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips64 + src, reg_info_src))
return false;
/* read SP */
- address = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + base, 0, &success);
+ address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + base, 0, &success);
if (!success)
return false;
@@ -747,7 +831,7 @@ EmulateInstructionMIPS64::Emulate_SD (llvm::MCInst& insn)
address = address + imm;
/* We look for sp based non-volatile register stores */
- if (base == gcc_dwarf_sp_mips64 && nonvolatile_reg_p (src))
+ if (base == dwarf_sp_mips64 && nonvolatile_reg_p (src))
{
Context context;
RegisterValue data_src;
@@ -769,7 +853,7 @@ EmulateInstructionMIPS64::Emulate_SD (llvm::MCInst& insn)
/* Set the bad_vaddr register with base address used in the instruction */
bad_vaddr_context.type = eContextInvalid;
- WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, gcc_dwarf_bad_mips64, address);
+ WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips64, address);
return true;
}
@@ -777,17 +861,38 @@ EmulateInstructionMIPS64::Emulate_SD (llvm::MCInst& insn)
bool
EmulateInstructionMIPS64::Emulate_LD (llvm::MCInst& insn)
{
+ bool success =false;
uint32_t src, base;
+ int64_t imm, address;
+ Context bad_vaddr_context;
src = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
base = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
+ imm = insn.getOperand(2).getImm();
+
+ RegisterInfo reg_info_base;
+ if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips64 + base, reg_info_base))
+ return false;
+
+ /* read base register */
+ address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + base, 0, &success);
+ if (!success)
+ return false;
- if (base == gcc_dwarf_sp_mips64 && nonvolatile_reg_p (src))
+ /* destination address */
+ address = address + imm;
+
+ /* Set the bad_vaddr register with base address used in the instruction */
+ bad_vaddr_context.type = eContextInvalid;
+ WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips64, address);
+
+
+ if (base == dwarf_sp_mips64 && nonvolatile_reg_p (src))
{
RegisterValue data_src;
RegisterInfo reg_info_src;
- if (!GetRegisterInfo (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + src, reg_info_src))
+ if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips64 + src, reg_info_src))
return false;
Context context;
@@ -821,15 +926,15 @@ EmulateInstructionMIPS64::Emulate_BEQ (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
- rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rt, 0, &success);
+ rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
if (!success)
return false;
@@ -841,7 +946,7 @@ EmulateInstructionMIPS64::Emulate_BEQ (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -864,15 +969,15 @@ EmulateInstructionMIPS64::Emulate_BNE (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
- rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rt, 0, &success);
+ rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
if (!success)
return false;
@@ -884,7 +989,7 @@ EmulateInstructionMIPS64::Emulate_BNE (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -907,15 +1012,15 @@ EmulateInstructionMIPS64::Emulate_BEQL (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
- rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rt, 0, &success);
+ rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
if (!success)
return false;
@@ -927,7 +1032,7 @@ EmulateInstructionMIPS64::Emulate_BEQL (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -950,15 +1055,15 @@ EmulateInstructionMIPS64::Emulate_BNEL (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
- rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rt, 0, &success);
+ rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
if (!success)
return false;
@@ -970,7 +1075,7 @@ EmulateInstructionMIPS64::Emulate_BNEL (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -993,11 +1098,11 @@ EmulateInstructionMIPS64::Emulate_BGEZL (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -1009,7 +1114,7 @@ EmulateInstructionMIPS64::Emulate_BGEZL (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -1032,11 +1137,11 @@ EmulateInstructionMIPS64::Emulate_BLTZL (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -1048,7 +1153,7 @@ EmulateInstructionMIPS64::Emulate_BLTZL (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -1071,11 +1176,11 @@ EmulateInstructionMIPS64::Emulate_BGTZL (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -1087,7 +1192,7 @@ EmulateInstructionMIPS64::Emulate_BGTZL (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -1110,11 +1215,11 @@ EmulateInstructionMIPS64::Emulate_BLEZL (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -1126,7 +1231,7 @@ EmulateInstructionMIPS64::Emulate_BLEZL (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -1149,11 +1254,11 @@ EmulateInstructionMIPS64::Emulate_BGTZ (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -1165,7 +1270,7 @@ EmulateInstructionMIPS64::Emulate_BGTZ (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -1188,11 +1293,11 @@ EmulateInstructionMIPS64::Emulate_BLEZ (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -1204,7 +1309,7 @@ EmulateInstructionMIPS64::Emulate_BLEZ (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -1227,11 +1332,11 @@ EmulateInstructionMIPS64::Emulate_BLTZ (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -1243,7 +1348,7 @@ EmulateInstructionMIPS64::Emulate_BLTZ (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -1266,11 +1371,11 @@ EmulateInstructionMIPS64::Emulate_BGEZALL (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -1282,10 +1387,10 @@ EmulateInstructionMIPS64::Emulate_BGEZALL (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips64, pc + 8))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips64, pc + 8))
return false;
return true;
@@ -1305,7 +1410,7 @@ EmulateInstructionMIPS64::Emulate_BAL (llvm::MCInst& insn)
*/
offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
@@ -1313,10 +1418,10 @@ EmulateInstructionMIPS64::Emulate_BAL (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips64, pc + 8))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips64, pc + 8))
return false;
return true;
@@ -1336,7 +1441,7 @@ EmulateInstructionMIPS64::Emulate_BALC (llvm::MCInst& insn)
*/
offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
@@ -1344,10 +1449,10 @@ EmulateInstructionMIPS64::Emulate_BALC (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips64, pc + 4))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips64, pc + 4))
return false;
return true;
@@ -1372,11 +1477,11 @@ EmulateInstructionMIPS64::Emulate_BGEZAL (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -1387,10 +1492,10 @@ EmulateInstructionMIPS64::Emulate_BGEZAL (llvm::MCInst& insn)
else
target = pc + 8;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips64, pc + 8))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips64, pc + 8))
return false;
return true;
@@ -1415,11 +1520,11 @@ EmulateInstructionMIPS64::Emulate_BLTZAL (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -1430,10 +1535,10 @@ EmulateInstructionMIPS64::Emulate_BLTZAL (llvm::MCInst& insn)
else
target = pc + 8;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips64, pc + 8))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips64, pc + 8))
return false;
return true;
@@ -1458,11 +1563,11 @@ EmulateInstructionMIPS64::Emulate_BLTZALL (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -1473,10 +1578,10 @@ EmulateInstructionMIPS64::Emulate_BLTZALL (llvm::MCInst& insn)
else
target = pc + 8; /* skip delay slot */
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips64, pc + 8))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips64, pc + 8))
return false;
return true;
@@ -1502,11 +1607,11 @@ EmulateInstructionMIPS64::Emulate_BLEZALC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -1517,10 +1622,10 @@ EmulateInstructionMIPS64::Emulate_BLEZALC (llvm::MCInst& insn)
else
target = pc + 4;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips64, pc + 4))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips64, pc + 4))
return false;
return true;
@@ -1545,11 +1650,11 @@ EmulateInstructionMIPS64::Emulate_BGEZALC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -1560,10 +1665,10 @@ EmulateInstructionMIPS64::Emulate_BGEZALC (llvm::MCInst& insn)
else
target = pc + 4;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips64, pc + 4))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips64, pc + 4))
return false;
return true;
@@ -1588,11 +1693,11 @@ EmulateInstructionMIPS64::Emulate_BLTZALC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -1603,10 +1708,10 @@ EmulateInstructionMIPS64::Emulate_BLTZALC (llvm::MCInst& insn)
else
target = pc + 4;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips64, pc + 4))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips64, pc + 4))
return false;
return true;
@@ -1631,11 +1736,11 @@ EmulateInstructionMIPS64::Emulate_BGTZALC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -1646,10 +1751,10 @@ EmulateInstructionMIPS64::Emulate_BGTZALC (llvm::MCInst& insn)
else
target = pc + 4;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips64, pc + 4))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips64, pc + 4))
return false;
return true;
@@ -1673,11 +1778,11 @@ EmulateInstructionMIPS64::Emulate_BEQZALC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -1688,10 +1793,10 @@ EmulateInstructionMIPS64::Emulate_BEQZALC (llvm::MCInst& insn)
else
target = pc + 4;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips64, pc + 4))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips64, pc + 4))
return false;
return true;
@@ -1715,11 +1820,11 @@ EmulateInstructionMIPS64::Emulate_BNEZALC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -1730,10 +1835,10 @@ EmulateInstructionMIPS64::Emulate_BNEZALC (llvm::MCInst& insn)
else
target = pc + 4;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips64, pc + 4))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips64, pc + 4))
return false;
return true;
@@ -1756,11 +1861,11 @@ EmulateInstructionMIPS64::Emulate_BGEZ (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -1771,7 +1876,7 @@ EmulateInstructionMIPS64::Emulate_BGEZ (llvm::MCInst& insn)
else
target = pc + 8;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -1790,7 +1895,7 @@ EmulateInstructionMIPS64::Emulate_BC (llvm::MCInst& insn)
*/
offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
@@ -1798,7 +1903,7 @@ EmulateInstructionMIPS64::Emulate_BC (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -1821,15 +1926,15 @@ EmulateInstructionMIPS64::Emulate_BEQC (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
- rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rt, 0, &success);
+ rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
if (!success)
return false;
@@ -1841,7 +1946,7 @@ EmulateInstructionMIPS64::Emulate_BEQC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -1864,15 +1969,15 @@ EmulateInstructionMIPS64::Emulate_BNEC (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
- rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rt, 0, &success);
+ rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
if (!success)
return false;
@@ -1884,7 +1989,7 @@ EmulateInstructionMIPS64::Emulate_BNEC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -1908,15 +2013,15 @@ EmulateInstructionMIPS64::Emulate_BLTC (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
- rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rt, 0, &success);
+ rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
if (!success)
return false;
@@ -1928,7 +2033,7 @@ EmulateInstructionMIPS64::Emulate_BLTC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -1952,15 +2057,15 @@ EmulateInstructionMIPS64::Emulate_BGEC (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
- rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rt, 0, &success);
+ rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
if (!success)
return false;
@@ -1972,7 +2077,7 @@ EmulateInstructionMIPS64::Emulate_BGEC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -1996,15 +2101,15 @@ EmulateInstructionMIPS64::Emulate_BLTUC (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
- rt_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rt, 0, &success);
+ rt_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
if (!success)
return false;
@@ -2016,7 +2121,7 @@ EmulateInstructionMIPS64::Emulate_BLTUC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -2040,15 +2145,15 @@ EmulateInstructionMIPS64::Emulate_BGEUC (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
- rt_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rt, 0, &success);
+ rt_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
if (!success)
return false;
@@ -2060,7 +2165,7 @@ EmulateInstructionMIPS64::Emulate_BGEUC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -2083,11 +2188,11 @@ EmulateInstructionMIPS64::Emulate_BLTZC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -2099,7 +2204,7 @@ EmulateInstructionMIPS64::Emulate_BLTZC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -2122,11 +2227,11 @@ EmulateInstructionMIPS64::Emulate_BLEZC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -2138,7 +2243,7 @@ EmulateInstructionMIPS64::Emulate_BLEZC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -2161,11 +2266,11 @@ EmulateInstructionMIPS64::Emulate_BGEZC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -2177,7 +2282,7 @@ EmulateInstructionMIPS64::Emulate_BGEZC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -2200,11 +2305,11 @@ EmulateInstructionMIPS64::Emulate_BGTZC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -2216,7 +2321,7 @@ EmulateInstructionMIPS64::Emulate_BGTZC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -2239,11 +2344,11 @@ EmulateInstructionMIPS64::Emulate_BEQZC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -2255,7 +2360,7 @@ EmulateInstructionMIPS64::Emulate_BEQZC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -2278,11 +2383,11 @@ EmulateInstructionMIPS64::Emulate_BNEZC (llvm::MCInst& insn)
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
@@ -2294,7 +2399,7 @@ EmulateInstructionMIPS64::Emulate_BNEZC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -2325,15 +2430,15 @@ EmulateInstructionMIPS64::Emulate_BOVC (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
- rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rt, 0, &success);
+ rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
if (!success)
return false;
@@ -2345,7 +2450,7 @@ EmulateInstructionMIPS64::Emulate_BOVC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -2369,15 +2474,15 @@ EmulateInstructionMIPS64::Emulate_BNVC (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
- rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rt, 0, &success);
+ rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
if (!success)
return false;
@@ -2389,7 +2494,7 @@ EmulateInstructionMIPS64::Emulate_BNVC (llvm::MCInst& insn)
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -2408,7 +2513,7 @@ EmulateInstructionMIPS64::Emulate_J (llvm::MCInst& insn)
*/
offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
@@ -2417,7 +2522,7 @@ EmulateInstructionMIPS64::Emulate_J (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, pc))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, pc))
return false;
return true;
@@ -2436,7 +2541,7 @@ EmulateInstructionMIPS64::Emulate_JAL (llvm::MCInst& insn)
*/
offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
@@ -2445,10 +2550,10 @@ EmulateInstructionMIPS64::Emulate_JAL (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips64, pc + 8))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips64, pc + 8))
return false;
return true;
@@ -2469,20 +2574,20 @@ EmulateInstructionMIPS64::Emulate_JALR (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
rs = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, rs_val))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, rs_val))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rt, pc + 8))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_zero_mips64 + rt, pc + 8))
return false;
return true;
@@ -2504,11 +2609,11 @@ EmulateInstructionMIPS64::Emulate_JIALC (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rt, 0, &success);
+ rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
if (!success)
return false;
@@ -2516,10 +2621,10 @@ EmulateInstructionMIPS64::Emulate_JIALC (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_ra_mips64, pc + 4))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips64, pc + 4))
return false;
return true;
@@ -2540,7 +2645,7 @@ EmulateInstructionMIPS64::Emulate_JIC (llvm::MCInst& insn)
rt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rt, 0, &success);
+ rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
if (!success)
return false;
@@ -2548,7 +2653,7 @@ EmulateInstructionMIPS64::Emulate_JIC (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -2567,13 +2672,13 @@ EmulateInstructionMIPS64::Emulate_JR (llvm::MCInst& insn)
*/
rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + rs, 0, &success);
+ rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
if (!success)
return false;
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, rs_val))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, rs_val))
return false;
return true;
@@ -2596,11 +2701,11 @@ EmulateInstructionMIPS64::Emulate_BC1F (llvm::MCInst& insn)
cc = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- fcsr = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_fcsr_mips64, 0, &success);
+ fcsr = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_fcsr_mips64, 0, &success);
if (!success)
return false;
@@ -2614,7 +2719,7 @@ EmulateInstructionMIPS64::Emulate_BC1F (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -2637,11 +2742,11 @@ EmulateInstructionMIPS64::Emulate_BC1T (llvm::MCInst& insn)
cc = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- fcsr = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_fcsr_mips64, 0, &success);
+ fcsr = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_fcsr_mips64, 0, &success);
if (!success)
return false;
@@ -2655,7 +2760,7 @@ EmulateInstructionMIPS64::Emulate_BC1T (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -2678,11 +2783,11 @@ EmulateInstructionMIPS64::Emulate_BC1FL (llvm::MCInst& insn)
cc = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- fcsr = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_fcsr_mips64, 0, &success);
+ fcsr = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_fcsr_mips64, 0, &success);
if (!success)
return false;
@@ -2696,7 +2801,7 @@ EmulateInstructionMIPS64::Emulate_BC1FL (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -2719,11 +2824,11 @@ EmulateInstructionMIPS64::Emulate_BC1TL (llvm::MCInst& insn)
cc = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- fcsr = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_fcsr_mips64, 0, &success);
+ fcsr = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_fcsr_mips64, 0, &success);
if (!success)
return false;
@@ -2737,7 +2842,7 @@ EmulateInstructionMIPS64::Emulate_BC1TL (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -2761,11 +2866,11 @@ EmulateInstructionMIPS64::Emulate_BC1EQZ (llvm::MCInst& insn)
ft = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- ft_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + ft, 0, &success);
+ ft_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + ft, 0, &success);
if (!success)
return false;
@@ -2776,7 +2881,7 @@ EmulateInstructionMIPS64::Emulate_BC1EQZ (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -2800,11 +2905,11 @@ EmulateInstructionMIPS64::Emulate_BC1NEZ (llvm::MCInst& insn)
ft = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- ft_val = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_zero_mips64 + ft, 0, &success);
+ ft_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + ft, 0, &success);
if (!success)
return false;
@@ -2815,7 +2920,7 @@ EmulateInstructionMIPS64::Emulate_BC1NEZ (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -2839,11 +2944,11 @@ EmulateInstructionMIPS64::Emulate_BC1ANY2F (llvm::MCInst& insn)
cc = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- fcsr = (uint32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_fcsr_mips64, 0, &success);
+ fcsr = (uint32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_fcsr_mips64, 0, &success);
if (!success)
return false;
@@ -2858,7 +2963,7 @@ EmulateInstructionMIPS64::Emulate_BC1ANY2F (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -2882,11 +2987,11 @@ EmulateInstructionMIPS64::Emulate_BC1ANY2T (llvm::MCInst& insn)
cc = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- fcsr = (uint32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_fcsr_mips64, 0, &success);
+ fcsr = (uint32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_fcsr_mips64, 0, &success);
if (!success)
return false;
@@ -2901,7 +3006,7 @@ EmulateInstructionMIPS64::Emulate_BC1ANY2T (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -2927,11 +3032,11 @@ EmulateInstructionMIPS64::Emulate_BC1ANY4F (llvm::MCInst& insn)
cc = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- fcsr = (uint32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_fcsr_mips64, 0, &success);
+ fcsr = (uint32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_fcsr_mips64, 0, &success);
if (!success)
return false;
@@ -2946,7 +3051,7 @@ EmulateInstructionMIPS64::Emulate_BC1ANY4F (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
@@ -2972,11 +3077,11 @@ EmulateInstructionMIPS64::Emulate_BC1ANY4T (llvm::MCInst& insn)
cc = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_pc_mips64, 0, &success);
+ pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
return false;
- fcsr = (uint32_t) ReadRegisterUnsigned (eRegisterKindDWARF, gcc_dwarf_fcsr_mips64, 0, &success);
+ fcsr = (uint32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_fcsr_mips64, 0, &success);
if (!success)
return false;
@@ -2991,8 +3096,234 @@ EmulateInstructionMIPS64::Emulate_BC1ANY4T (llvm::MCInst& insn)
Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, gcc_dwarf_pc_mips64, target))
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
return false;
return true;
}
+
+bool
+EmulateInstructionMIPS64::Emulate_BNZB (llvm::MCInst& insn)
+{
+ return Emulate_MSA_Branch_DF(insn, 1, true);
+}
+
+bool
+EmulateInstructionMIPS64::Emulate_BNZH (llvm::MCInst& insn)
+{
+ return Emulate_MSA_Branch_DF(insn, 2, true);
+}
+
+bool
+EmulateInstructionMIPS64::Emulate_BNZW (llvm::MCInst& insn)
+{
+ return Emulate_MSA_Branch_DF(insn, 4, true);
+}
+
+bool
+EmulateInstructionMIPS64::Emulate_BNZD (llvm::MCInst& insn)
+{
+ return Emulate_MSA_Branch_DF(insn, 8, true);
+}
+
+bool
+EmulateInstructionMIPS64::Emulate_BZB (llvm::MCInst& insn)
+{
+ return Emulate_MSA_Branch_DF(insn, 1, false);
+}
+
+bool
+EmulateInstructionMIPS64::Emulate_BZH (llvm::MCInst& insn)
+{
+ return Emulate_MSA_Branch_DF(insn, 2, false);
+}
+
+bool
+EmulateInstructionMIPS64::Emulate_BZW (llvm::MCInst& insn)
+{
+ return Emulate_MSA_Branch_DF(insn, 4, false);
+}
+
+bool
+EmulateInstructionMIPS64::Emulate_BZD (llvm::MCInst& insn)
+{
+ return Emulate_MSA_Branch_DF(insn, 8, false);
+}
+
+bool
+EmulateInstructionMIPS64::Emulate_MSA_Branch_DF (llvm::MCInst& insn, int element_byte_size, bool bnz)
+{
+ bool success = false, branch_hit = true;
+ int64_t target = 0;
+ RegisterValue reg_value;
+ uint8_t * ptr = NULL;
+
+ uint32_t wt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
+ int64_t offset = insn.getOperand(1).getImm();
+
+ int64_t pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
+
+ if (ReadRegister (eRegisterKindDWARF, dwarf_w0_mips64 + wt, reg_value))
+ ptr = (uint8_t *)reg_value.GetBytes();
+ else
+ return false;
+
+ for(int i = 0; i < 16 / element_byte_size; i++)
+ {
+ switch(element_byte_size)
+ {
+ case 1:
+ if((*ptr == 0 && bnz) || (*ptr != 0 && !bnz) )
+ branch_hit = false;
+ break;
+ case 2:
+ if((*(uint16_t *)ptr == 0 && bnz) || (*(uint16_t *)ptr != 0 && !bnz))
+ branch_hit = false;
+ break;
+ case 4:
+ if((*(uint32_t *)ptr == 0 && bnz) || (*(uint32_t *)ptr != 0 && !bnz))
+ branch_hit = false;
+ break;
+ case 8:
+ if((*(uint64_t *)ptr == 0 && bnz) || (*(uint64_t *)ptr != 0 && !bnz))
+ branch_hit = false;
+ break;
+ }
+ if(!branch_hit)
+ break;
+ ptr = ptr + element_byte_size;
+ }
+
+ if(branch_hit)
+ target = pc + offset;
+ else
+ target = pc + 8;
+
+ Context context;
+ context.type = eContextRelativeBranchImmediate;
+
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
+ return false;
+
+ return true;
+}
+
+bool
+EmulateInstructionMIPS64::Emulate_BNZV (llvm::MCInst& insn)
+{
+ return Emulate_MSA_Branch_V (insn, true);
+}
+
+bool
+EmulateInstructionMIPS64::Emulate_BZV (llvm::MCInst& insn)
+{
+ return Emulate_MSA_Branch_V (insn, false);
+}
+
+bool
+EmulateInstructionMIPS64::Emulate_MSA_Branch_V (llvm::MCInst& insn, bool bnz)
+{
+ bool success = false;
+ int64_t target = 0;
+ llvm::APInt wr_val = llvm::APInt::getNullValue(128);
+ llvm::APInt fail_value = llvm::APInt::getMaxValue(128);
+ llvm::APInt zero_value = llvm::APInt::getNullValue(128);
+ RegisterValue reg_value;
+
+ uint32_t wt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
+ int64_t offset = insn.getOperand(1).getImm();
+
+ int64_t pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
+
+ if (ReadRegister (eRegisterKindDWARF, dwarf_w0_mips64 + wt, reg_value))
+ wr_val = reg_value.GetAsUInt128(fail_value);
+ else
+ return false;
+
+ if((llvm::APInt::isSameValue(zero_value, wr_val) && !bnz) || (!llvm::APInt::isSameValue(zero_value, wr_val) && bnz))
+ target = pc + offset;
+ else
+ target = pc + 8;
+
+ Context context;
+ context.type = eContextRelativeBranchImmediate;
+
+ if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
+ return false;
+
+ return true;
+}
+
+bool
+EmulateInstructionMIPS64::Emulate_LDST_Imm (llvm::MCInst& insn)
+{
+ bool success = false;
+ uint32_t base;
+ int64_t imm, address;
+ Context bad_vaddr_context;
+
+ uint32_t num_operands = insn.getNumOperands();
+ base = m_reg_info->getEncodingValue (insn.getOperand(num_operands-2).getReg());
+ imm = insn.getOperand(num_operands-1).getImm();
+
+ RegisterInfo reg_info_base;
+ if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + base, reg_info_base))
+ return false;
+
+ /* read base register */
+ address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
+ if (!success)
+ return false;
+
+ /* destination address */
+ address = address + imm;
+
+ /* Set the bad_vaddr register with base address used in the instruction */
+ bad_vaddr_context.type = eContextInvalid;
+ WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips, address);
+
+ return true;
+}
+
+bool
+EmulateInstructionMIPS64::Emulate_LDST_Reg (llvm::MCInst& insn)
+{
+ bool success = false;
+ uint32_t base, index;
+ int64_t address, index_address;
+ Context bad_vaddr_context;
+
+ uint32_t num_operands = insn.getNumOperands();
+ base = m_reg_info->getEncodingValue (insn.getOperand(num_operands-2).getReg());
+ index = m_reg_info->getEncodingValue (insn.getOperand(num_operands-1).getReg());
+
+ RegisterInfo reg_info_base, reg_info_index;
+ if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + base, reg_info_base))
+ return false;
+
+ if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + index, reg_info_index))
+ return false;
+
+ /* read base register */
+ address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
+ if (!success)
+ return false;
+
+ /* read index register */
+ index_address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + index, 0, &success);
+ if (!success)
+ return false;
+
+ /* destination address */
+ address = address + index_address;
+
+ /* Set the bad_vaddr register with base address used in the instruction */
+ bad_vaddr_context.type = eContextInvalid;
+ WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips, address);
+
+ return true;
+}
diff --git a/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h b/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h
index faefd329a8e4..e0b20792ae1f 100644
--- a/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h
+++ b/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h
@@ -1,4 +1,4 @@
-//===-- EmulateInstructionMIPS64.h ------------------------------------*- C++ -*-===//
+//===-- EmulateInstructionMIPS64.h ------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,6 +10,14 @@
#ifndef EmulateInstructionMIPS64_h_
#define EmulateInstructionMIPS64_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/EmulateInstruction.h"
+#include "lldb/Core/Error.h"
+#include "lldb/Interpreter/OptionValue.h"
+
namespace llvm
{
class MCDisassembler;
@@ -19,15 +27,13 @@ namespace llvm
class MCContext;
class MCInstrInfo;
class MCInst;
-}
-
-#include "lldb/Core/EmulateInstruction.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Interpreter/OptionValue.h"
+} // namespace llvm
class EmulateInstructionMIPS64 : public lldb_private::EmulateInstruction
{
public:
+ EmulateInstructionMIPS64(const lldb_private::ArchSpec &arch);
+
static void
Initialize ();
@@ -60,57 +66,47 @@ public:
return false;
}
- virtual lldb_private::ConstString
- GetPluginName();
-
- virtual lldb_private::ConstString
- GetShortPluginName()
- {
- return GetPluginNameStatic();
- }
+ lldb_private::ConstString
+ GetPluginName() override;
- virtual uint32_t
- GetPluginVersion()
+ uint32_t
+ GetPluginVersion() override
{
return 1;
}
bool
- SetTargetTriple (const lldb_private::ArchSpec &arch);
+ SetTargetTriple(const lldb_private::ArchSpec &arch) override;
- EmulateInstructionMIPS64 (const lldb_private::ArchSpec &arch);
-
- virtual bool
- SupportsEmulatingInstructionsOfType (lldb_private::InstructionType inst_type)
+ bool
+ SupportsEmulatingInstructionsOfType(lldb_private::InstructionType inst_type) override
{
return SupportsEmulatingInstructionsOfTypeStatic (inst_type);
}
- virtual bool
- ReadInstruction ();
+ bool
+ ReadInstruction() override;
- virtual bool
- EvaluateInstruction (uint32_t evaluate_options);
+ bool
+ EvaluateInstruction(uint32_t evaluate_options) override;
- virtual bool
- TestEmulation (lldb_private::Stream *out_stream,
- lldb_private::ArchSpec &arch,
- lldb_private::OptionValueDictionary *test_data)
+ bool
+ TestEmulation(lldb_private::Stream *out_stream,
+ lldb_private::ArchSpec &arch,
+ lldb_private::OptionValueDictionary *test_data) override
{
return false;
}
- virtual bool
- GetRegisterInfo (lldb::RegisterKind reg_kind,
- uint32_t reg_num,
- lldb_private::RegisterInfo &reg_info);
-
- virtual bool
- CreateFunctionEntryUnwind (lldb_private::UnwindPlan &unwind_plan);
+ bool
+ GetRegisterInfo(lldb::RegisterKind reg_kind,
+ uint32_t reg_num,
+ lldb_private::RegisterInfo &reg_info) override;
+ bool
+ CreateFunctionEntryUnwind(lldb_private::UnwindPlan &unwind_plan) override;
protected:
-
typedef struct
{
const char *op_name;
@@ -128,13 +124,13 @@ protected:
Emulate_SD (llvm::MCInst& insn);
bool
- Emulate_SW (llvm::MCInst& insn);
+ Emulate_LD (llvm::MCInst& insn);
bool
- Emulate_LW (llvm::MCInst& insn);
+ Emulate_LDST_Imm (llvm::MCInst& insn);
bool
- Emulate_LD (llvm::MCInst& insn);
+ Emulate_LDST_Reg (llvm::MCInst& insn);
bool
Emulate_BEQ (llvm::MCInst& insn);
@@ -302,6 +298,42 @@ protected:
Emulate_BC1ANY4T (llvm::MCInst& insn);
bool
+ Emulate_BNZB (llvm::MCInst& insn);
+
+ bool
+ Emulate_BNZH (llvm::MCInst& insn);
+
+ bool
+ Emulate_BNZW (llvm::MCInst& insn);
+
+ bool
+ Emulate_BNZD (llvm::MCInst& insn);
+
+ bool
+ Emulate_BZB (llvm::MCInst& insn);
+
+ bool
+ Emulate_BZH (llvm::MCInst& insn);
+
+ bool
+ Emulate_BZW (llvm::MCInst& insn);
+
+ bool
+ Emulate_BZD (llvm::MCInst& insn);
+
+ bool
+ Emulate_MSA_Branch_DF (llvm::MCInst& insn, int element_byte_size, bool bnz);
+
+ bool
+ Emulate_BNZV (llvm::MCInst& insn);
+
+ bool
+ Emulate_BZV (llvm::MCInst& insn);
+
+ bool
+ Emulate_MSA_Branch_V (llvm::MCInst& insn, bool bnz);
+
+ bool
nonvolatile_reg_p (uint64_t regnum);
const char *
@@ -316,4 +348,4 @@ private:
std::unique_ptr<llvm::MCInstrInfo> m_insn_info;
};
-#endif // EmulateInstructionMIPS64_h_
+#endif // EmulateInstructionMIPS64_h_
diff --git a/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp b/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
index 9b72ceb71bd0..c2f1f2e95c83 100644
--- a/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
+++ b/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
@@ -66,9 +66,11 @@ AddressSanitizerRuntime::GetTypeStatic()
AddressSanitizerRuntime::AddressSanitizerRuntime(const ProcessSP &process_sp) :
m_is_active(false),
m_runtime_module(),
- m_process(process_sp),
+ m_process_wp(),
m_breakpoint_id(0)
{
+ if (process_sp)
+ m_process_wp = process_sp;
}
AddressSanitizerRuntime::~AddressSanitizerRuntime()
@@ -78,14 +80,11 @@ AddressSanitizerRuntime::~AddressSanitizerRuntime()
bool ModuleContainsASanRuntime(Module * module)
{
- SymbolContextList sc_list;
- const bool include_symbols = true;
- const bool append = true;
- const bool include_inlines = true;
-
- size_t num_matches = module->FindFunctions(ConstString("__asan_get_alloc_stack"), NULL, eFunctionNameTypeAuto, include_symbols, include_inlines, append, sc_list);
-
- return num_matches > 0;
+ const Symbol* symbol = module->FindFirstSymbolWithNameAndType(
+ ConstString("__asan_get_alloc_stack"),
+ lldb::eSymbolTypeAny);
+
+ return symbol != nullptr;
}
void
@@ -164,7 +163,11 @@ t
StructuredData::ObjectSP
AddressSanitizerRuntime::RetrieveReportData()
{
- ThreadSP thread_sp = m_process->GetThreadList().GetSelectedThread();
+ ProcessSP process_sp = GetProcessSP();
+ if (!process_sp)
+ return StructuredData::ObjectSP();
+
+ ThreadSP thread_sp = process_sp->GetThreadList().GetSelectedThread();
StackFrameSP frame_sp = thread_sp->GetSelectedFrame();
if (!frame_sp)
@@ -178,7 +181,7 @@ AddressSanitizerRuntime::RetrieveReportData()
options.SetTimeoutUsec(RETRIEVE_REPORT_DATA_FUNCTION_TIMEOUT_USEC);
ValueObjectSP return_value_sp;
- if (m_process->GetTarget().EvaluateExpression(address_sanitizer_retrieve_report_data_command, frame_sp.get(), return_value_sp, options) != eExpressionCompleted)
+ if (process_sp->GetTarget().EvaluateExpression(address_sanitizer_retrieve_report_data_command, frame_sp.get(), return_value_sp, options) != eExpressionCompleted)
return StructuredData::ObjectSP();
int present = return_value_sp->GetValueForExpressionPath(".present")->GetValueAsUnsigned(0);
@@ -196,7 +199,7 @@ AddressSanitizerRuntime::RetrieveReportData()
addr_t description_ptr = return_value_sp->GetValueForExpressionPath(".description")->GetValueAsUnsigned(0);
std::string description;
Error error;
- m_process->ReadCStringFromMemory(description_ptr, description, error);
+ process_sp->ReadCStringFromMemory(description_ptr, description, error);
StructuredData::Dictionary *dict = new StructuredData::Dictionary();
dict->AddStringItem("instrumentation_class", "AddressSanitizer");
@@ -252,27 +255,31 @@ AddressSanitizerRuntime::NotifyBreakpointHit(void *baton, StoppointCallbackConte
assert (baton && "null baton");
if (!baton)
return false;
-
+
AddressSanitizerRuntime *const instance = static_cast<AddressSanitizerRuntime*>(baton);
-
+
StructuredData::ObjectSP report = instance->RetrieveReportData();
std::string description;
if (report) {
description = instance->FormatDescription(report);
}
- ThreadSP thread = context->exe_ctx_ref.GetThreadSP();
- thread->SetStopInfo(InstrumentationRuntimeStopInfo::CreateStopReasonWithInstrumentationData(*thread, description.c_str(), report));
-
- if (instance->m_process)
+ ProcessSP process_sp = instance->GetProcessSP();
+ // Make sure this is the right process
+ if (process_sp && process_sp == context->exe_ctx_ref.GetProcessSP())
{
- StreamFileSP stream_sp (instance->m_process->GetTarget().GetDebugger().GetOutputFile());
+ ThreadSP thread_sp = context->exe_ctx_ref.GetThreadSP();
+ if (thread_sp)
+ thread_sp->SetStopInfo(InstrumentationRuntimeStopInfo::CreateStopReasonWithInstrumentationData(*thread_sp, description.c_str(), report));
+
+ StreamFileSP stream_sp (process_sp->GetTarget().GetDebugger().GetOutputFile());
if (stream_sp)
{
stream_sp->Printf ("AddressSanitizer report breakpoint hit. Use 'thread info -s' to get extended information about the report.\n");
}
+ return true; // Return true to stop the target
}
- // Return true to stop the target, false to just let the target run.
- return true;
+ else
+ return false; // Let target run
}
void
@@ -281,6 +288,10 @@ AddressSanitizerRuntime::Activate()
if (m_is_active)
return;
+ ProcessSP process_sp = GetProcessSP();
+ if (!process_sp)
+ return;
+
ConstString symbol_name ("__asan::AsanDie()");
const Symbol *symbol = m_runtime_module->FindFirstSymbolWithNameAndType (symbol_name, eSymbolTypeCode);
@@ -290,7 +301,7 @@ AddressSanitizerRuntime::Activate()
if (!symbol->ValueIsAddress() || !symbol->GetAddressRef().IsValid())
return;
- Target &target = m_process->GetTarget();
+ Target &target = process_sp->GetTarget();
addr_t symbol_address = symbol->GetAddressRef().GetOpcodeLoadAddress(&target);
if (symbol_address == LLDB_INVALID_ADDRESS)
@@ -298,18 +309,15 @@ AddressSanitizerRuntime::Activate()
bool internal = true;
bool hardware = false;
- Breakpoint *breakpoint = m_process->GetTarget().CreateBreakpoint(symbol_address, internal, hardware).get();
+ Breakpoint *breakpoint = process_sp->GetTarget().CreateBreakpoint(symbol_address, internal, hardware).get();
breakpoint->SetCallback (AddressSanitizerRuntime::NotifyBreakpointHit, this, true);
breakpoint->SetBreakpointKind ("address-sanitizer-report");
m_breakpoint_id = breakpoint->GetID();
- if (m_process)
+ StreamFileSP stream_sp (process_sp->GetTarget().GetDebugger().GetOutputFile());
+ if (stream_sp)
{
- StreamFileSP stream_sp (m_process->GetTarget().GetDebugger().GetOutputFile());
- if (stream_sp)
- {
- stream_sp->Printf ("AddressSanitizer debugger support is active. Memory error breakpoint has been installed and you can now use the 'memory history' command.\n");
- }
+ stream_sp->Printf ("AddressSanitizer debugger support is active. Memory error breakpoint has been installed and you can now use the 'memory history' command.\n");
}
m_is_active = true;
@@ -320,8 +328,12 @@ AddressSanitizerRuntime::Deactivate()
{
if (m_breakpoint_id != LLDB_INVALID_BREAK_ID)
{
- m_process->GetTarget().RemoveBreakpointByID(m_breakpoint_id);
- m_breakpoint_id = LLDB_INVALID_BREAK_ID;
+ ProcessSP process_sp = GetProcessSP();
+ if (process_sp)
+ {
+ process_sp->GetTarget().RemoveBreakpointByID(m_breakpoint_id);
+ m_breakpoint_id = LLDB_INVALID_BREAK_ID;
+ }
}
m_is_active = false;
}
diff --git a/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h b/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h
index 69c134cbedaf..fe12ab847e76 100644
--- a/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h
+++ b/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h
@@ -10,6 +10,10 @@
#ifndef liblldb_AddressSanitizerRuntime_h_
#define liblldb_AddressSanitizerRuntime_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/InstrumentationRuntime.h"
@@ -21,7 +25,8 @@ namespace lldb_private {
class AddressSanitizerRuntime : public lldb_private::InstrumentationRuntime
{
public:
-
+ ~AddressSanitizerRuntime() override;
+
static lldb::InstrumentationRuntimeSP
CreateInstance (const lldb::ProcessSP &process_sp);
@@ -36,29 +41,37 @@ public:
static lldb::InstrumentationRuntimeType
GetTypeStatic();
-
- virtual
- ~AddressSanitizerRuntime();
-
- virtual lldb_private::ConstString
- GetPluginName() { return GetPluginNameStatic(); }
+
+ lldb_private::ConstString
+ GetPluginName() override
+ {
+ return GetPluginNameStatic();
+ }
virtual lldb::InstrumentationRuntimeType
GetType() { return GetTypeStatic(); }
- virtual uint32_t
- GetPluginVersion() { return 1; }
+ uint32_t
+ GetPluginVersion() override
+ {
+ return 1;
+ }
- virtual void
- ModulesDidLoad(lldb_private::ModuleList &module_list);
+ void
+ ModulesDidLoad(lldb_private::ModuleList &module_list) override;
- virtual bool
- IsActive();
+ bool
+ IsActive() override;
private:
-
AddressSanitizerRuntime(const lldb::ProcessSP &process_sp);
-
+
+ lldb::ProcessSP
+ GetProcessSP ()
+ {
+ return m_process_wp.lock();
+ }
+
void
Activate();
@@ -76,11 +89,10 @@ private:
bool m_is_active;
lldb::ModuleSP m_runtime_module;
- lldb::ProcessSP m_process;
+ lldb::ProcessWP m_process_wp;
lldb::user_id_t m_breakpoint_id;
-
};
} // namespace lldb_private
-#endif // liblldb_InstrumentationRuntime_h_
+#endif // liblldb_AddressSanitizerRuntime_h_
diff --git a/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp b/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
index 8e454e712fe8..143e44794057 100644
--- a/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
+++ b/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
@@ -16,6 +16,7 @@
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/StreamString.h"
+#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Target/Process.h"
@@ -27,6 +28,58 @@
using namespace lldb;
using namespace lldb_private;
+namespace {
+
+ PropertyDefinition
+ g_properties[] =
+ {
+ { "enable-jit-breakpoint", OptionValue::eTypeBoolean, true, true , nullptr, nullptr, "Enable breakpoint on __jit_debug_register_code." },
+ { nullptr , OptionValue::eTypeInvalid, false, 0, nullptr, nullptr, nullptr }
+ };
+
+ enum
+ {
+ ePropertyEnableJITBreakpoint
+ };
+
+
+ class PluginProperties : public Properties
+ {
+ public:
+ static ConstString
+ GetSettingName()
+ {
+ return JITLoaderGDB::GetPluginNameStatic();
+ }
+
+ PluginProperties()
+ {
+ m_collection_sp.reset (new 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);
+ }
+
+ };
+
+ typedef std::shared_ptr<PluginProperties> JITLoaderGDBPropertiesSP;
+
+ static const JITLoaderGDBPropertiesSP&
+ GetGlobalPluginProperties()
+ {
+ static const auto g_settings_sp(std::make_shared<PluginProperties>());
+ return g_settings_sp;
+ }
+
+} // anonymous namespace end
+
//------------------------------------------------------------------
// Debug Interface Structures
//------------------------------------------------------------------
@@ -37,7 +90,6 @@ typedef enum
JIT_UNREGISTER_FN
} jit_actions_t;
-#pragma pack(push, 4)
template <typename ptr_t>
struct jit_code_entry
{
@@ -54,7 +106,6 @@ struct jit_descriptor
ptr_t relevant_entry; // pointer
ptr_t first_entry; // pointer
};
-#pragma pack(pop)
JITLoaderGDB::JITLoaderGDB (lldb_private::Process *process) :
JITLoader(process),
@@ -70,6 +121,19 @@ JITLoaderGDB::~JITLoaderGDB ()
m_process->GetTarget().RemoveBreakpointByID (m_jit_break_id);
}
+void
+JITLoaderGDB::DebuggerInitialize(Debugger &debugger)
+{
+ if (!PluginManager::GetSettingForJITLoaderPlugin(debugger, PluginProperties::GetSettingName()))
+ {
+ const bool is_global_setting = true;
+ PluginManager::CreateSettingForJITLoaderPlugin(debugger,
+ GetGlobalPluginProperties()->GetValueProperties(),
+ ConstString ("Properties for the JIT LoaderGDB plug-in."),
+ is_global_setting);
+ }
+}
+
void JITLoaderGDB::DidAttach()
{
Target &target = m_process->GetTarget();
@@ -88,7 +152,7 @@ void
JITLoaderGDB::ModulesDidLoad(ModuleList &module_list)
{
if (!DidSetJITBreakpoint() && m_process->IsAlive())
- SetJITBreakpoint(module_list);
+ SetJITBreakpoint(module_list);
}
//------------------------------------------------------------------
@@ -97,11 +161,13 @@ JITLoaderGDB::ModulesDidLoad(ModuleList &module_list)
void
JITLoaderGDB::SetJITBreakpoint(lldb_private::ModuleList &module_list)
{
- Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_JIT_LOADER));
+ if (!GetGlobalPluginProperties()->GetEnableJITBreakpoint())
+ return;
if ( DidSetJITBreakpoint() )
return;
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_JIT_LOADER));
if (log)
log->Printf("JITLoaderGDB::%s looking for JIT register hook",
__FUNCTION__);
@@ -407,7 +473,8 @@ JITLoaderGDB::Initialize()
{
PluginManager::RegisterPlugin (GetPluginNameStatic(),
GetPluginDescriptionStatic(),
- CreateInstance);
+ CreateInstance,
+ DebuggerInitialize);
}
void
diff --git a/source/Plugins/JITLoader/GDB/JITLoaderGDB.h b/source/Plugins/JITLoader/GDB/JITLoaderGDB.h
index bfa1721d3349..10bd989c328f 100644
--- a/source/Plugins/JITLoader/GDB/JITLoaderGDB.h
+++ b/source/Plugins/JITLoader/GDB/JITLoaderGDB.h
@@ -13,15 +13,19 @@
// C Includes
// C++ Includes
#include <map>
-#include <vector>
-#include <string>
+// Other libraries and framework includes
+// Project includes
#include "lldb/Target/JITLoader.h"
#include "lldb/Target/Process.h"
class JITLoaderGDB : public lldb_private::JITLoader
{
public:
+ JITLoaderGDB(lldb_private::Process *process);
+
+ ~JITLoaderGDB() override;
+
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
@@ -40,31 +44,29 @@ public:
static lldb::JITLoaderSP
CreateInstance (lldb_private::Process *process, bool force);
- JITLoaderGDB (lldb_private::Process *process);
-
- virtual
- ~JITLoaderGDB ();
+ static void
+ DebuggerInitialize(lldb_private::Debugger &debugger);
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
- virtual lldb_private::ConstString
- GetPluginName();
+ lldb_private::ConstString
+ GetPluginName() override;
- virtual uint32_t
- GetPluginVersion();
+ uint32_t
+ GetPluginVersion() override;
//------------------------------------------------------------------
// JITLoader interface
//------------------------------------------------------------------
- virtual void
- DidAttach ();
+ void
+ DidAttach() override;
- virtual void
- DidLaunch ();
+ void
+ DidLaunch() override;
- virtual void
- ModulesDidLoad (lldb_private::ModuleList &module_list);
+ void
+ ModulesDidLoad(lldb_private::ModuleList &module_list) override;
private:
lldb::addr_t
@@ -105,4 +107,4 @@ private:
};
-#endif
+#endif // liblldb_JITLoaderGDB_h_
diff --git a/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
new file mode 100644
index 000000000000..a554aa57d58e
--- /dev/null
+++ b/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -0,0 +1,792 @@
+//===-- CPlusPlusLanguage.cpp --------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "CPlusPlusLanguage.h"
+
+
+#include "llvm/ADT/StringRef.h"
+
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/RegularExpression.h"
+#include "lldb/Core/UniqueCStringMap.h"
+#include "lldb/DataFormatters/CXXFunctionPointer.h"
+#include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/DataFormatters/VectorType.h"
+
+#include "CxxStringTypes.h"
+#include "LibCxx.h"
+#include "LibStdcpp.h"
+
+#include <cstring>
+#include <cctype>
+#include <functional>
+#include <mutex>
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+void
+CPlusPlusLanguage::Initialize()
+{
+ PluginManager::RegisterPlugin (GetPluginNameStatic(),
+ "C++ Language",
+ CreateInstance);
+}
+
+void
+CPlusPlusLanguage::Terminate()
+{
+ PluginManager::UnregisterPlugin (CreateInstance);
+}
+
+lldb_private::ConstString
+CPlusPlusLanguage::GetPluginNameStatic()
+{
+ static ConstString g_name("cplusplus");
+ return g_name;
+}
+
+
+//------------------------------------------------------------------
+// PluginInterface protocol
+//------------------------------------------------------------------
+lldb_private::ConstString
+CPlusPlusLanguage::GetPluginName()
+{
+ return GetPluginNameStatic();
+}
+
+uint32_t
+CPlusPlusLanguage::GetPluginVersion()
+{
+ return 1;
+}
+
+//------------------------------------------------------------------
+// Static Functions
+//------------------------------------------------------------------
+Language *
+CPlusPlusLanguage::CreateInstance (lldb::LanguageType language)
+{
+ if (Language::LanguageIsCPlusPlus(language))
+ return new CPlusPlusLanguage();
+ return nullptr;
+}
+
+void
+CPlusPlusLanguage::MethodName::Clear()
+{
+ m_full.Clear();
+ m_basename = llvm::StringRef();
+ m_context = llvm::StringRef();
+ m_arguments = llvm::StringRef();
+ m_qualifiers = llvm::StringRef();
+ m_type = eTypeInvalid;
+ m_parsed = false;
+ m_parse_error = false;
+}
+
+bool
+ReverseFindMatchingChars (const llvm::StringRef &s,
+ const llvm::StringRef &left_right_chars,
+ size_t &left_pos,
+ size_t &right_pos,
+ size_t pos = llvm::StringRef::npos)
+{
+ assert (left_right_chars.size() == 2);
+ left_pos = llvm::StringRef::npos;
+ const char left_char = left_right_chars[0];
+ const char right_char = left_right_chars[1];
+ pos = s.find_last_of(left_right_chars, pos);
+ if (pos == llvm::StringRef::npos || s[pos] == left_char)
+ return false;
+ right_pos = pos;
+ uint32_t depth = 1;
+ while (pos > 0 && depth > 0)
+ {
+ pos = s.find_last_of(left_right_chars, pos);
+ if (pos == llvm::StringRef::npos)
+ return false;
+ if (s[pos] == left_char)
+ {
+ if (--depth == 0)
+ {
+ left_pos = pos;
+ return left_pos < right_pos;
+ }
+ }
+ else if (s[pos] == right_char)
+ {
+ ++depth;
+ }
+ }
+ return false;
+}
+
+static bool
+IsValidBasename(const llvm::StringRef& basename)
+{
+ // Check that the basename matches with the following regular expression or is an operator name:
+ // "^~?([A-Za-z_][A-Za-z_0-9]*)(<.*>)?$"
+ // We are using a hand written implementation because it is significantly more efficient then
+ // using the general purpose regular expression library.
+ size_t idx = 0;
+ if (basename.size() > 0 && basename[0] == '~')
+ idx = 1;
+
+ if (basename.size() <= idx)
+ return false; // Empty string or "~"
+
+ if (!std::isalpha(basename[idx]) && basename[idx] != '_')
+ return false; // First charater (after removing the possible '~'') isn't in [A-Za-z_]
+
+ // Read all characters matching [A-Za-z_0-9]
+ ++idx;
+ while (idx < basename.size())
+ {
+ if (!std::isalnum(basename[idx]) && basename[idx] != '_')
+ break;
+ ++idx;
+ }
+
+ // We processed all characters. It is a vaild basename.
+ if (idx == basename.size())
+ return true;
+
+ // Check for basename with template arguments
+ // TODO: Improve the quality of the validation with validating the template arguments
+ if (basename[idx] == '<' && basename.back() == '>')
+ return true;
+
+ // Check if the basename is a vaild C++ operator name
+ if (!basename.startswith("operator"))
+ return false;
+
+ static RegularExpression g_operator_regex("^(operator)( ?)([A-Za-z_][A-Za-z_0-9]*|\\(\\)|\\[\\]|[\\^<>=!\\/*+-]+)(<.*>)?(\\[\\])?$");
+ std::string basename_str(basename.str());
+ return g_operator_regex.Execute(basename_str.c_str(), nullptr);
+}
+
+void
+CPlusPlusLanguage::MethodName::Parse()
+{
+ if (!m_parsed && m_full)
+ {
+// ConstString mangled;
+// m_full.GetMangledCounterpart(mangled);
+// printf ("\n parsing = '%s'\n", m_full.GetCString());
+// if (mangled)
+// printf (" mangled = '%s'\n", mangled.GetCString());
+ m_parse_error = false;
+ m_parsed = true;
+ llvm::StringRef full (m_full.GetCString());
+
+ size_t arg_start, arg_end;
+ llvm::StringRef parens("()", 2);
+ if (ReverseFindMatchingChars (full, parens, arg_start, arg_end))
+ {
+ m_arguments = full.substr(arg_start, arg_end - arg_start + 1);
+ if (arg_end + 1 < full.size())
+ m_qualifiers = full.substr(arg_end + 1);
+ if (arg_start > 0)
+ {
+ size_t basename_end = arg_start;
+ size_t context_start = 0;
+ size_t context_end = llvm::StringRef::npos;
+ if (basename_end > 0 && full[basename_end-1] == '>')
+ {
+ // TODO: handle template junk...
+ // Templated function
+ size_t template_start, template_end;
+ llvm::StringRef lt_gt("<>", 2);
+ if (ReverseFindMatchingChars (full, lt_gt, template_start, template_end, basename_end))
+ {
+ // Check for templated functions that include return type like: 'void foo<Int>()'
+ context_start = full.rfind(' ', template_start);
+ if (context_start == llvm::StringRef::npos)
+ context_start = 0;
+
+ context_end = full.rfind(':', template_start);
+ if (context_end == llvm::StringRef::npos || context_end < context_start)
+ context_end = context_start;
+ }
+ else
+ {
+ context_end = full.rfind(':', basename_end);
+ }
+ }
+ else if (context_end == llvm::StringRef::npos)
+ {
+ context_end = full.rfind(':', basename_end);
+ }
+
+ if (context_end == llvm::StringRef::npos)
+ m_basename = full.substr(0, basename_end);
+ else
+ {
+ if (context_start < context_end)
+ m_context = full.substr(context_start, context_end - 1);
+ const size_t basename_begin = context_end + 1;
+ m_basename = full.substr(basename_begin, basename_end - basename_begin);
+ }
+ m_type = eTypeUnknownMethod;
+ }
+ else
+ {
+ m_parse_error = true;
+ return;
+ }
+
+ if (!IsValidBasename(m_basename))
+ {
+ // The C++ basename doesn't match our regular expressions so this can't
+ // be a valid C++ method, clear everything out and indicate an error
+ m_context = llvm::StringRef();
+ m_basename = llvm::StringRef();
+ m_arguments = llvm::StringRef();
+ m_qualifiers = llvm::StringRef();
+ m_parse_error = true;
+ }
+ }
+ else
+ {
+ m_parse_error = true;
+ }
+ }
+}
+
+llvm::StringRef
+CPlusPlusLanguage::MethodName::GetBasename ()
+{
+ if (!m_parsed)
+ Parse();
+ return m_basename;
+}
+
+llvm::StringRef
+CPlusPlusLanguage::MethodName::GetContext ()
+{
+ if (!m_parsed)
+ Parse();
+ return m_context;
+}
+
+llvm::StringRef
+CPlusPlusLanguage::MethodName::GetArguments ()
+{
+ if (!m_parsed)
+ Parse();
+ return m_arguments;
+}
+
+llvm::StringRef
+CPlusPlusLanguage::MethodName::GetQualifiers ()
+{
+ if (!m_parsed)
+ Parse();
+ return m_qualifiers;
+}
+
+bool
+CPlusPlusLanguage::IsCPPMangledName (const char *name)
+{
+ // FIXME, we should really run through all the known C++ Language plugins and ask each one if
+ // this is a C++ mangled name, but we can put that off till there is actually more than one
+ // we care about.
+
+ if (name && name[0] == '_' && name[1] == 'Z')
+ return true;
+ else
+ return false;
+}
+
+bool
+CPlusPlusLanguage::ExtractContextAndIdentifier (const char *name, llvm::StringRef &context, llvm::StringRef &identifier)
+{
+ static RegularExpression g_basename_regex("^(([A-Za-z_][A-Za-z_0-9]*::)*)([A-Za-z_][A-Za-z_0-9]*)$");
+ RegularExpression::Match match(4);
+ if (g_basename_regex.Execute (name, &match))
+ {
+ match.GetMatchAtIndex(name, 1, context);
+ match.GetMatchAtIndex(name, 3, identifier);
+ return true;
+ }
+ return false;
+}
+
+class CPPRuntimeEquivalents
+{
+public:
+ CPPRuntimeEquivalents ()
+ {
+
+ m_impl.Append(ConstString("std::basic_string<char, std::char_traits<char>, std::allocator<char> >").AsCString(), ConstString("basic_string<char>"));
+
+ // these two (with a prefixed std::) occur when c++stdlib string class occurs as a template argument in some STL container
+ m_impl.Append(ConstString("std::basic_string<char, std::char_traits<char>, std::allocator<char> >").AsCString(), ConstString("std::basic_string<char>"));
+
+ m_impl.Sort();
+ }
+
+ void
+ Add (ConstString& type_name,
+ ConstString& type_equivalent)
+ {
+ m_impl.Insert(type_name.AsCString(), type_equivalent);
+ }
+
+ uint32_t
+ FindExactMatches (ConstString& type_name,
+ std::vector<ConstString>& equivalents)
+ {
+
+ uint32_t count = 0;
+
+ for (ImplData match = m_impl.FindFirstValueForName(type_name.AsCString());
+ match != NULL;
+ match = m_impl.FindNextValueForName(match))
+ {
+ equivalents.push_back(match->value);
+ count++;
+ }
+
+ return count;
+ }
+
+ // partial matches can occur when a name with equivalents is a template argument.
+ // e.g. we may have "class Foo" be a match for "struct Bar". if we have a typename
+ // such as "class Templatized<class Foo, Anything>" we want this to be replaced with
+ // "class Templatized<struct Bar, Anything>". Since partial matching is time consuming
+ // once we get a partial match, we add it to the exact matches list for faster retrieval
+ uint32_t
+ FindPartialMatches (ConstString& type_name,
+ std::vector<ConstString>& equivalents)
+ {
+
+ uint32_t count = 0;
+
+ const char* type_name_cstr = type_name.AsCString();
+
+ size_t items_count = m_impl.GetSize();
+
+ for (size_t item = 0; item < items_count; item++)
+ {
+ const char* key_cstr = m_impl.GetCStringAtIndex(item);
+ if ( strstr(type_name_cstr,key_cstr) )
+ {
+ count += AppendReplacements(type_name_cstr,
+ key_cstr,
+ equivalents);
+ }
+ }
+
+ return count;
+
+ }
+
+private:
+
+ std::string& replace (std::string& target,
+ std::string& pattern,
+ std::string& with)
+ {
+ size_t pos;
+ size_t pattern_len = pattern.size();
+
+ while ( (pos = target.find(pattern)) != std::string::npos )
+ target.replace(pos, pattern_len, with);
+
+ return target;
+ }
+
+ uint32_t
+ AppendReplacements (const char* original,
+ const char *matching_key,
+ std::vector<ConstString>& equivalents)
+ {
+
+ std::string matching_key_str(matching_key);
+ ConstString original_const(original);
+
+ uint32_t count = 0;
+
+ for (ImplData match = m_impl.FindFirstValueForName(matching_key);
+ match != NULL;
+ match = m_impl.FindNextValueForName(match))
+ {
+ std::string target(original);
+ std::string equiv_class(match->value.AsCString());
+
+ replace (target, matching_key_str, equiv_class);
+
+ ConstString target_const(target.c_str());
+
+// you will most probably want to leave this off since it might make this map grow indefinitely
+#ifdef ENABLE_CPP_EQUIVALENTS_MAP_TO_GROW
+ Add(original_const, target_const);
+#endif
+ equivalents.push_back(target_const);
+
+ count++;
+ }
+
+ return count;
+ }
+
+ typedef UniqueCStringMap<ConstString> Impl;
+ typedef const Impl::Entry* ImplData;
+ Impl m_impl;
+};
+
+static CPPRuntimeEquivalents&
+GetEquivalentsMap ()
+{
+ static CPPRuntimeEquivalents g_equivalents_map;
+ return g_equivalents_map;
+}
+
+
+uint32_t
+CPlusPlusLanguage::FindEquivalentNames(ConstString type_name, std::vector<ConstString>& equivalents)
+{
+ uint32_t count = GetEquivalentsMap().FindExactMatches(type_name, equivalents);
+
+ bool might_have_partials=
+ ( count == 0 ) // if we have a full name match just use it
+ && (strchr(type_name.AsCString(), '<') != NULL // we should only have partial matches when templates are involved, check that we have
+ && strchr(type_name.AsCString(), '>') != NULL); // angle brackets in the type_name before trying to scan for partial matches
+
+ if ( might_have_partials )
+ count = GetEquivalentsMap().FindPartialMatches(type_name, equivalents);
+
+ return count;
+}
+
+static void
+LoadLibCxxFormatters (lldb::TypeCategoryImplSP cpp_category_sp)
+{
+ if (!cpp_category_sp)
+ return;
+
+ TypeSummaryImpl::Flags stl_summary_flags;
+ stl_summary_flags.SetCascades(true)
+ .SetSkipPointers(false)
+ .SetSkipReferences(false)
+ .SetDontShowChildren(true)
+ .SetDontShowValue(true)
+ .SetShowMembersOneLiner(false)
+ .SetHideItemNames(false);
+
+#ifndef LLDB_DISABLE_PYTHON
+ lldb::TypeSummaryImplSP std_string_summary_sp(new CXXFunctionSummaryFormat(stl_summary_flags, lldb_private::formatters::LibcxxStringSummaryProvider, "std::string summary provider"));
+ lldb::TypeSummaryImplSP std_wstring_summary_sp(new CXXFunctionSummaryFormat(stl_summary_flags, lldb_private::formatters::LibcxxWStringSummaryProvider, "std::wstring summary provider"));
+
+ cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::__1::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::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);
+
+ SyntheticChildren::Flags stl_synth_flags;
+ stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(false);
+
+ AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxStdVectorSyntheticFrontEndCreator, "libc++ std::vector synthetic children", ConstString("^std::__1::vector<.+>(( )?&)?$"), stl_synth_flags, true);
+ AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxStdListSyntheticFrontEndCreator, "libc++ std::list synthetic children", ConstString("^std::__1::list<.+>(( )?&)?$"), stl_synth_flags, true);
+ AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator, "libc++ std::map synthetic children", ConstString("^std::__1::map<.+> >(( )?&)?$"), stl_synth_flags, true);
+ AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator, "libc++ std::vector<bool> synthetic children", ConstString("std::__1::vector<std::__1::allocator<bool> >"), stl_synth_flags);
+ AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator, "libc++ std::vector<bool> synthetic children", ConstString("std::__1::vector<bool, std::__1::allocator<bool> >"), stl_synth_flags);
+ AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator, "libc++ std::set synthetic children", ConstString("^std::__1::set<.+> >(( )?&)?$"), stl_synth_flags, true);
+ AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator, "libc++ std::multiset synthetic children", ConstString("^std::__1::multiset<.+> >(( )?&)?$"), stl_synth_flags, true);
+ AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator, "libc++ std::multimap synthetic children", ConstString("^std::__1::multimap<.+> >(( )?&)?$"), stl_synth_flags, true);
+ AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEndCreator, "libc++ std::unordered containers synthetic children", ConstString("^(std::__1::)unordered_(multi)?(map|set)<.+> >$"), stl_synth_flags, true);
+ AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxInitializerListSyntheticFrontEndCreator, "libc++ std::initializer_list synthetic children", ConstString("^std::initializer_list<.+>(( )?&)?$"), stl_synth_flags, true);
+
+ cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(RegularExpressionSP(new RegularExpression("^(std::__1::)deque<.+>(( )?&)?$")),
+ SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
+ "lldb.formatters.cpp.libcxx.stddeque_SynthProvider")));
+
+ AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator, "shared_ptr synthetic children", ConstString("^(std::__1::)shared_ptr<.+>(( )?&)?$"), stl_synth_flags, true);
+ AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator, "weak_ptr synthetic children", ConstString("^(std::__1::)weak_ptr<.+>(( )?&)?$"), stl_synth_flags, true);
+
+ stl_summary_flags.SetDontShowChildren(false);stl_summary_flags.SetSkipPointers(false);
+ AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator, "libc++ std::vector<bool> synthetic children", ConstString("std::__1::vector<bool, std::__1::allocator<bool> >"), stl_synth_flags);
+
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::vector summary provider", ConstString("^std::__1::vector<.+>(( )?&)?$"), stl_summary_flags, true);
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::list summary provider", ConstString("^std::__1::list<.+>(( )?&)?$"), stl_summary_flags, true);
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::map summary provider", ConstString("^std::__1::map<.+>(( )?&)?$"), stl_summary_flags, true);
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::deque summary provider", ConstString("^std::__1::deque<.+>(( )?&)?$"), stl_summary_flags, true);
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::vector<bool> summary provider", ConstString("std::__1::vector<std::__1::allocator<bool> >"), stl_summary_flags);
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::vector<bool> summary provider", ConstString("std::__1::vector<bool, std::__1::allocator<bool> >"), stl_summary_flags);
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::set summary provider", ConstString("^std::__1::set<.+>(( )?&)?$"), stl_summary_flags, true);
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::multiset summary provider", ConstString("^std::__1::multiset<.+>(( )?&)?$"), stl_summary_flags, true);
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::multimap summary provider", ConstString("^std::__1::multimap<.+>(( )?&)?$"), stl_summary_flags, true);
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::unordered containers summary provider", ConstString("^(std::__1::)unordered_(multi)?(map|set)<.+> >$"), stl_summary_flags, true);
+
+ stl_summary_flags.SetSkipPointers(true);
+
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxSmartPointerSummaryProvider, "libc++ std::shared_ptr summary provider", ConstString("^std::__1::shared_ptr<.+>(( )?&)?$"), stl_summary_flags, true);
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxSmartPointerSummaryProvider, "libc++ std::weak_ptr summary provider", ConstString("^std::__1::weak_ptr<.+>(( )?&)?$"), stl_summary_flags, true);
+
+ AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibCxxVectorIteratorSyntheticFrontEndCreator, "std::vector iterator synthetic children", ConstString("^std::__1::__wrap_iter<.+>$"), stl_synth_flags, true);
+
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::vector<bool> summary provider", ConstString("std::__1::vector<bool, std::__1::allocator<bool> >"), stl_summary_flags);
+ AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEndCreator, "std::map iterator synthetic children", ConstString("^std::__1::__map_iterator<.+>$"), stl_synth_flags, true);
+
+ AddFilter(cpp_category_sp, {"__a_"}, "libc++ std::atomic filter", ConstString("^std::__1::atomic<.*>$"), stl_synth_flags, true);
+#endif
+}
+
+static void
+LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp)
+{
+ if (!cpp_category_sp)
+ return;
+
+ TypeSummaryImpl::Flags stl_summary_flags;
+ stl_summary_flags.SetCascades(true)
+ .SetSkipPointers(false)
+ .SetSkipReferences(false)
+ .SetDontShowChildren(true)
+ .SetDontShowValue(true)
+ .SetShowMembersOneLiner(false)
+ .SetHideItemNames(false);
+
+ lldb::TypeSummaryImplSP std_string_summary_sp(new StringSummaryFormat(stl_summary_flags,
+ "${var._M_dataplus._M_p}"));
+
+ lldb::TypeSummaryImplSP cxx11_string_summary_sp(new CXXFunctionSummaryFormat(stl_summary_flags,
+ LibStdcppStringSummaryProvider,
+ "libstdc++ c++11 std::string summary provider"));
+ lldb::TypeSummaryImplSP cxx11_wstring_summary_sp(new CXXFunctionSummaryFormat(stl_summary_flags,
+ LibStdcppWStringSummaryProvider,
+ "libstdc++ c++11 std::wstring summary provider"));
+
+ cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::string"),
+ std_string_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::basic_string<char>"),
+ std_string_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::basic_string<char,std::char_traits<char>,std::allocator<char> >"),
+ std_string_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::basic_string<char, std::char_traits<char>, std::allocator<char> >"),
+ std_string_summary_sp);
+
+ cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::__cxx11::string"),
+ cxx11_string_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >"),
+ cxx11_string_summary_sp);
+
+ // making sure we force-pick the summary for printing wstring (_M_p is a wchar_t*)
+ lldb::TypeSummaryImplSP std_wstring_summary_sp(new StringSummaryFormat(stl_summary_flags,
+ "${var._M_dataplus._M_p%S}"));
+
+ cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::wstring"),
+ std_wstring_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::basic_string<wchar_t>"),
+ std_wstring_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >"),
+ std_wstring_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >"),
+ std_wstring_summary_sp);
+
+ cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::__cxx11::wstring"),
+ cxx11_wstring_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::__cxx11::basic_string<wchar_t, 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);
+
+ cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(RegularExpressionSP(new RegularExpression("^std::vector<.+>(( )?&)?$")),
+ SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
+ "lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider")));
+ cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(RegularExpressionSP(new RegularExpression("^std::map<.+> >(( )?&)?$")),
+ SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
+ "lldb.formatters.cpp.gnu_libstdcpp.StdMapSynthProvider")));
+ cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(RegularExpressionSP(new RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$")),
+ SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
+ "lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider")));
+ stl_summary_flags.SetDontShowChildren(false);stl_summary_flags.SetSkipPointers(true);
+ cpp_category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression("^std::vector<.+>(( )?&)?$")),
+ TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags,
+ "size=${svar%#}")));
+ cpp_category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression("^std::map<.+> >(( )?&)?$")),
+ TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags,
+ "size=${svar%#}")));
+ cpp_category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$")),
+ TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags,
+ "size=${svar%#}")));
+
+ AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibStdcppVectorIteratorSyntheticFrontEndCreator, "std::vector iterator synthetic children", ConstString("^__gnu_cxx::__normal_iterator<.+>$"), stl_synth_flags, true);
+
+ AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibstdcppMapIteratorSyntheticFrontEndCreator, "std::map iterator synthetic children", ConstString("^std::_Rb_tree_iterator<.+>$"), stl_synth_flags, true);
+#endif
+}
+
+static void
+LoadSystemFormatters(lldb::TypeCategoryImplSP cpp_category_sp)
+{
+ if (!cpp_category_sp)
+ return;
+
+ TypeSummaryImpl::Flags string_flags;
+ string_flags.SetCascades(true)
+ .SetSkipPointers(true)
+ .SetSkipReferences(false)
+ .SetDontShowChildren(true)
+ .SetDontShowValue(false)
+ .SetShowMembersOneLiner(false)
+ .SetHideItemNames(false);
+
+ TypeSummaryImpl::Flags string_array_flags;
+ string_array_flags.SetCascades(true)
+ .SetSkipPointers(true)
+ .SetSkipReferences(false)
+ .SetDontShowChildren(true)
+ .SetDontShowValue(true)
+ .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(cpp_category_sp, lldb_private::formatters::Char16StringSummaryProvider, "char16_t * summary provider", ConstString("char16_t *"), string_flags);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::Char16StringSummaryProvider,
+ "char16_t [] summary provider",
+ ConstString("char16_t \\[[0-9]+\\]"),
+ string_array_flags,
+ true);
+
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::Char32StringSummaryProvider, "char32_t * summary provider", ConstString("char32_t *"), string_flags);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::Char32StringSummaryProvider,
+ "char32_t [] summary provider",
+ ConstString("char32_t \\[[0-9]+\\]"),
+ string_array_flags,
+ true);
+
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::WCharStringSummaryProvider, "wchar_t * summary provider", ConstString("wchar_t *"), string_flags);
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::WCharStringSummaryProvider, "wchar_t * summary provider", ConstString("wchar_t \\[[0-9]+\\]"), string_array_flags, true);
+
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::Char16StringSummaryProvider, "unichar * summary provider", ConstString("unichar *"), string_flags);
+
+ TypeSummaryImpl::Flags widechar_flags;
+ widechar_flags.SetDontShowValue(true)
+ .SetSkipPointers(true)
+ .SetSkipReferences(false)
+ .SetCascades(true)
+ .SetDontShowChildren(true)
+ .SetHideItemNames(true)
+ .SetShowMembersOneLiner(false);
+
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::Char16SummaryProvider, "char16_t summary provider", ConstString("char16_t"), widechar_flags);
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::Char32SummaryProvider, "char32_t summary provider", ConstString("char32_t"), widechar_flags);
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::WCharSummaryProvider, "wchar_t summary provider", ConstString("wchar_t"), widechar_flags);
+
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::Char16SummaryProvider, "unichar summary provider", ConstString("unichar"), widechar_flags);
+#endif
+}
+
+lldb::TypeCategoryImplSP
+CPlusPlusLanguage::GetFormatters ()
+{
+ static std::once_flag g_initialize;
+ static TypeCategoryImplSP g_category;
+
+ std::call_once(g_initialize, [this] () -> void {
+ DataVisualization::Categories::GetCategory(GetPluginName(), g_category);
+ if (g_category)
+ {
+ LoadLibCxxFormatters(g_category);
+ LoadLibStdcppFormatters(g_category);
+ LoadSystemFormatters(g_category);
+ }
+ });
+ return g_category;
+}
+
+HardcodedFormatters::HardcodedSummaryFinder
+CPlusPlusLanguage::GetHardcodedSummaries ()
+{
+ static std::once_flag g_initialize;
+ static ConstString g_vectortypes("VectorTypes");
+ static HardcodedFormatters::HardcodedSummaryFinder g_formatters;
+
+ std::call_once(g_initialize, [] () -> void {
+ g_formatters.push_back(
+ [](lldb_private::ValueObject& valobj,
+ lldb::DynamicValueType,
+ FormatManager&) -> TypeSummaryImpl::SharedPointer {
+ static CXXFunctionSummaryFormat::SharedPointer formatter_sp(new CXXFunctionSummaryFormat(TypeSummaryImpl::Flags(), lldb_private::formatters::CXXFunctionPointerSummaryProvider, "Function pointer summary provider"));
+ if (valobj.GetCompilerType().IsFunctionPointerType())
+ {
+ return formatter_sp;
+ }
+ return nullptr;
+ });
+ g_formatters.push_back(
+ [](lldb_private::ValueObject& valobj,
+ lldb::DynamicValueType,
+ FormatManager& fmt_mgr) -> TypeSummaryImpl::SharedPointer {
+ static CXXFunctionSummaryFormat::SharedPointer formatter_sp(new CXXFunctionSummaryFormat(TypeSummaryImpl::Flags()
+ .SetCascades(true)
+ .SetDontShowChildren(true)
+ .SetHideItemNames(true)
+ .SetShowMembersOneLiner(true)
+ .SetSkipPointers(true)
+ .SetSkipReferences(false),
+ lldb_private::formatters::VectorTypeSummaryProvider,
+ "vector_type pointer summary provider"));
+ if (valobj.GetCompilerType().IsVectorType(nullptr, nullptr))
+ {
+ if (fmt_mgr.GetCategory(g_vectortypes)->IsEnabled())
+ return formatter_sp;
+ }
+ return nullptr;
+ });
+ });
+
+ return g_formatters;
+}
+
+HardcodedFormatters::HardcodedSyntheticFinder
+CPlusPlusLanguage::GetHardcodedSynthetics ()
+{
+ static std::once_flag g_initialize;
+ static ConstString g_vectortypes("VectorTypes");
+ static HardcodedFormatters::HardcodedSyntheticFinder g_formatters;
+
+ std::call_once(g_initialize, [] () -> void {
+ g_formatters.push_back(
+ [](lldb_private::ValueObject& valobj,
+ lldb::DynamicValueType,
+ FormatManager& fmt_mgr) -> SyntheticChildren::SharedPointer {
+ static CXXSyntheticChildren::SharedPointer formatter_sp(new CXXSyntheticChildren(SyntheticChildren::Flags().SetCascades(true).SetSkipPointers(true).SetSkipReferences(true).SetNonCacheable(true),
+ "vector_type synthetic children",
+ lldb_private::formatters::VectorTypeSyntheticFrontEndCreator));
+ if (valobj.GetCompilerType().IsVectorType(nullptr, nullptr))
+ {
+ if (fmt_mgr.GetCategory(g_vectortypes)->IsEnabled())
+ return formatter_sp;
+ }
+ return nullptr;
+ });
+ });
+
+ return g_formatters;
+}
+
diff --git a/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h b/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
new file mode 100644
index 000000000000..1a8c0f6938a5
--- /dev/null
+++ b/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
@@ -0,0 +1,186 @@
+//===-- CPlusPlusLanguage.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_CPlusPlusLanguage_h_
+#define liblldb_CPlusPlusLanguage_h_
+
+// C Includes
+// C++ Includes
+#include <vector>
+
+// Other libraries and framework includes
+#include "llvm/ADT/StringRef.h"
+
+// Project includes
+#include "lldb/lldb-private.h"
+#include "lldb/Core/ConstString.h"
+#include "lldb/Target/Language.h"
+
+namespace lldb_private {
+
+class CPlusPlusLanguage :
+ public Language
+{
+public:
+ class MethodName
+ {
+ public:
+ enum Type
+ {
+ eTypeInvalid,
+ eTypeUnknownMethod,
+ eTypeClassMethod,
+ eTypeInstanceMethod
+ };
+
+ MethodName () :
+ m_full(),
+ m_basename(),
+ m_context(),
+ m_arguments(),
+ m_qualifiers(),
+ m_type (eTypeInvalid),
+ m_parsed (false),
+ m_parse_error (false)
+ {
+ }
+
+ MethodName (const ConstString &s) :
+ m_full(s),
+ m_basename(),
+ m_context(),
+ m_arguments(),
+ m_qualifiers(),
+ m_type (eTypeInvalid),
+ m_parsed (false),
+ m_parse_error (false)
+ {
+ }
+
+ void
+ Clear();
+
+ bool
+ IsValid ()
+ {
+ if (!m_parsed)
+ Parse();
+ if (m_parse_error)
+ return false;
+ if (m_type == eTypeInvalid)
+ return false;
+ return (bool)m_full;
+ }
+
+ Type
+ GetType () const
+ {
+ return m_type;
+ }
+
+ const ConstString &
+ GetFullName () const
+ {
+ return m_full;
+ }
+
+ llvm::StringRef
+ GetBasename ();
+
+ llvm::StringRef
+ GetContext ();
+
+ llvm::StringRef
+ GetArguments ();
+
+ llvm::StringRef
+ GetQualifiers ();
+
+ protected:
+ void
+ Parse();
+
+ ConstString m_full; // Full name: "lldb::SBTarget::GetBreakpointAtIndex(unsigned int) const"
+ llvm::StringRef m_basename; // Basename: "GetBreakpointAtIndex"
+ llvm::StringRef m_context; // Decl context: "lldb::SBTarget"
+ llvm::StringRef m_arguments; // Arguments: "(unsigned int)"
+ llvm::StringRef m_qualifiers; // Qualifiers: "const"
+ Type m_type;
+ bool m_parsed;
+ bool m_parse_error;
+ };
+
+ CPlusPlusLanguage() = default;
+
+ ~CPlusPlusLanguage() override = default;
+
+ lldb::LanguageType
+ GetLanguageType () const override
+ {
+ return lldb::eLanguageTypeC_plus_plus;
+ }
+
+ lldb::TypeCategoryImplSP
+ GetFormatters () override;
+
+ HardcodedFormatters::HardcodedSummaryFinder
+ GetHardcodedSummaries () override;
+
+ HardcodedFormatters::HardcodedSyntheticFinder
+ GetHardcodedSynthetics () override;
+
+ //------------------------------------------------------------------
+ // Static Functions
+ //------------------------------------------------------------------
+ static void
+ Initialize();
+
+ static void
+ Terminate();
+
+ static lldb_private::Language *
+ CreateInstance (lldb::LanguageType language);
+
+ static lldb_private::ConstString
+ GetPluginNameStatic();
+
+ static bool
+ IsCPPMangledName(const char *name);
+
+ // Extract C++ context and identifier from a string using heuristic matching (as opposed to
+ // CPlusPlusLanguage::MethodName which has to have a fully qualified C++ name with parens and arguments.
+ // If the name is a lone C identifier (e.g. C) or a qualified C identifier (e.g. A::B::C) it will return true,
+ // and identifier will be the identifier (C and C respectively) and the context will be "" and "A::B::" respectively.
+ // If the name fails the heuristic matching for a qualified or unqualified C/C++ identifier, then it will return false
+ // and identifier and context will be unchanged.
+
+ static bool
+ ExtractContextAndIdentifier (const char *name, llvm::StringRef &context, llvm::StringRef &identifier);
+
+ // in some cases, compilers will output different names for one same type. when that happens, it might be impossible
+ // to construct SBType objects for a valid type, because the name that is available is not the same as the name that
+ // can be used as a search key in FindTypes(). the equivalents map here is meant to return possible alternative names
+ // for a type through which a search can be conducted. Currently, this is only enabled for C++ but can be extended
+ // to ObjC or other languages if necessary
+ static uint32_t
+ FindEquivalentNames(ConstString type_name, std::vector<ConstString>& equivalents);
+
+ //------------------------------------------------------------------
+ // PluginInterface protocol
+ //------------------------------------------------------------------
+ ConstString
+ GetPluginName() override;
+
+ uint32_t
+ GetPluginVersion() override;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_CPlusPlusLanguage_h_
diff --git a/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp b/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
new file mode 100644
index 000000000000..7e8d9582a2b5
--- /dev/null
+++ b/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
@@ -0,0 +1,204 @@
+//===-- CXXStringTypes.cpp --------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "CxxStringTypes.h"
+
+#include "llvm/Support/ConvertUTF.h"
+
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/Error.h"
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/StringPrinter.h"
+#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/Host/Endian.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Target/SectionLoadList.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ProcessStructReader.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+
+#include <algorithm>
+
+#if __ANDROID_NDK__
+#include <sys/types.h>
+#endif
+
+#include "lldb/Host/Time.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+bool
+lldb_private::formatters::Char16StringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions&)
+{
+ ProcessSP process_sp = valobj.GetProcessSP();
+ if (!process_sp)
+ return false;
+
+ lldb::addr_t valobj_addr = GetArrayAddressOrPointerValue(valobj);
+ if (valobj_addr == 0 || valobj_addr == LLDB_INVALID_ADDRESS)
+ return false;
+
+ StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
+ options.SetLocation(valobj_addr);
+ options.SetProcessSP(process_sp);
+ options.SetStream(&stream);
+ options.SetPrefixToken("u");
+
+ if (!StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF16>(options))
+ {
+ stream.Printf("Summary Unavailable");
+ return true;
+ }
+
+ return true;
+}
+
+bool
+lldb_private::formatters::Char32StringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions&)
+{
+ ProcessSP process_sp = valobj.GetProcessSP();
+ if (!process_sp)
+ return false;
+
+ lldb::addr_t valobj_addr = GetArrayAddressOrPointerValue(valobj);
+ if (valobj_addr == 0 || valobj_addr == LLDB_INVALID_ADDRESS)
+ return false;
+
+ StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
+ options.SetLocation(valobj_addr);
+ options.SetProcessSP(process_sp);
+ options.SetStream(&stream);
+ options.SetPrefixToken("U");
+
+ if (!StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF32>(options))
+ {
+ stream.Printf("Summary Unavailable");
+ return true;
+ }
+
+ return true;
+}
+
+bool
+lldb_private::formatters::WCharStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions&)
+{
+ ProcessSP process_sp = valobj.GetProcessSP();
+ if (!process_sp)
+ return false;
+
+ lldb::addr_t valobj_addr = GetArrayAddressOrPointerValue(valobj);
+ if (valobj_addr == 0 || valobj_addr == LLDB_INVALID_ADDRESS)
+ return false;
+
+ // Get a wchar_t basic type from the current type system
+ CompilerType wchar_compiler_type = valobj.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeWChar);
+
+ if (!wchar_compiler_type)
+ return false;
+
+ const uint32_t wchar_size = wchar_compiler_type.GetBitSize(nullptr); // Safe to pass NULL for exe_scope here
+
+ StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
+ options.SetLocation(valobj_addr);
+ options.SetProcessSP(process_sp);
+ options.SetStream(&stream);
+ options.SetPrefixToken("L");
+
+ switch (wchar_size)
+ {
+ case 8:
+ return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF8>(options);
+ case 16:
+ return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF16>(options);
+ case 32:
+ return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF32>(options);
+ default:
+ stream.Printf("size for wchar_t is not valid");
+ return true;
+ }
+ return true;
+}
+
+bool
+lldb_private::formatters::Char16SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions&)
+{
+ DataExtractor data;
+ Error error;
+ valobj.GetData(data, error);
+
+ if (error.Fail())
+ return false;
+
+ std::string value;
+ valobj.GetValueAsCString(lldb::eFormatUnicode16, value);
+ if (!value.empty())
+ stream.Printf("%s ", value.c_str());
+
+ StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
+ options.SetData(data);
+ options.SetStream(&stream);
+ options.SetPrefixToken("u");
+ options.SetQuote('\'');
+ options.SetSourceSize(1);
+ options.SetBinaryZeroIsTerminator(false);
+
+ return StringPrinter::ReadBufferAndDumpToStream<StringPrinter::StringElementType::UTF16>(options);
+}
+
+bool
+lldb_private::formatters::Char32SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions&)
+{
+ DataExtractor data;
+ Error error;
+ valobj.GetData(data, error);
+
+ if (error.Fail())
+ return false;
+
+ std::string value;
+ valobj.GetValueAsCString(lldb::eFormatUnicode32, value);
+ if (!value.empty())
+ stream.Printf("%s ", value.c_str());
+
+ StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
+ options.SetData(data);
+ options.SetStream(&stream);
+ options.SetPrefixToken("U");
+ options.SetQuote('\'');
+ options.SetSourceSize(1);
+ options.SetBinaryZeroIsTerminator(false);
+
+ return StringPrinter::ReadBufferAndDumpToStream<StringPrinter::StringElementType::UTF32>(options);
+}
+
+bool
+lldb_private::formatters::WCharSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions&)
+{
+ DataExtractor data;
+ Error error;
+ valobj.GetData(data, error);
+
+ if (error.Fail())
+ return false;
+
+ StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
+ options.SetData(data);
+ options.SetStream(&stream);
+ options.SetPrefixToken("L");
+ options.SetQuote('\'');
+ options.SetSourceSize(1);
+ options.SetBinaryZeroIsTerminator(false);
+
+ return StringPrinter::ReadBufferAndDumpToStream<StringPrinter::StringElementType::UTF16>(options);
+}
diff --git a/source/Plugins/Language/CPlusPlus/CxxStringTypes.h b/source/Plugins/Language/CPlusPlus/CxxStringTypes.h
new file mode 100644
index 000000000000..bfb03bda7ee0
--- /dev/null
+++ b/source/Plugins/Language/CPlusPlus/CxxStringTypes.h
@@ -0,0 +1,41 @@
+//===-- CxxStringTypes.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_CxxStringTypes_h_
+#define liblldb_CxxStringTypes_h_
+
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/TypeSummary.h"
+
+namespace lldb_private {
+ namespace formatters
+ {
+ bool
+ Char16StringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char16_t* and unichar*
+
+ bool
+ Char32StringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char32_t*
+
+ bool
+ WCharStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // wchar_t*
+
+ bool
+ Char16SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char16_t and unichar
+
+ bool
+ Char32SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char32_t
+
+ bool
+ WCharSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // wchar_t
+
+ } // namespace formatters
+} // namespace lldb_private
+
+#endif // liblldb_CxxStringTypes_h_
diff --git a/source/DataFormatters/LibCxx.cpp b/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index a04b4ff6b8c7..950bd62c5c9f 100644
--- a/source/DataFormatters/LibCxx.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/DataFormatters/CXXFormatterFunctions.h"
+#include "LibCxx.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Debugger.h"
@@ -16,9 +16,12 @@
#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/DataFormatters/StringPrinter.h"
+#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/DataFormatters/VectorIterator.h"
#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
using namespace lldb;
@@ -81,7 +84,7 @@ m_children()
if (valobj_sp)
{
Update();
- m_bool_type = valobj_sp->GetClangType().GetBasicTypeFromAST(lldb::eBasicTypeBool);
+ m_bool_type = valobj_sp->GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeBool);
}
}
@@ -377,7 +380,7 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex (siz
return lldb::ValueObjectSP();
uint64_t count = 1 + shared_owners_sp->GetValueAsUnsigned(0);
DataExtractor data(&count, 8, m_byte_order, m_ptr_size);
- m_count_sp = CreateValueObjectFromData("count", data, valobj_sp->GetExecutionContextRef(), shared_owners_sp->GetClangType());
+ m_count_sp = CreateValueObjectFromData("count", data, valobj_sp->GetExecutionContextRef(), shared_owners_sp->GetCompilerType());
}
return m_count_sp;
}
@@ -390,7 +393,7 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex (siz
return lldb::ValueObjectSP();
uint64_t count = 1 + shared_weak_owners_sp->GetValueAsUnsigned(0);
DataExtractor data(&count, 8, m_byte_order, m_ptr_size);
- m_weak_count_sp = CreateValueObjectFromData("count", data, valobj_sp->GetExecutionContextRef(), shared_weak_owners_sp->GetClangType());
+ m_weak_count_sp = CreateValueObjectFromData("count", data, valobj_sp->GetExecutionContextRef(), shared_weak_owners_sp->GetCompilerType());
}
return m_weak_count_sp;
}
@@ -461,3 +464,190 @@ lldb_private::formatters::LibcxxContainerSummaryProvider (ValueObject& valobj, S
}
return FormatEntity::FormatStringRef("size=${svar%#}", stream, NULL, NULL, NULL, &valobj, false, false);
}
+
+// the field layout in a libc++ string (cap, side, data or data, size, cap)
+enum LibcxxStringLayoutMode
+{
+ eLibcxxStringLayoutModeCSD = 0,
+ eLibcxxStringLayoutModeDSC = 1,
+ eLibcxxStringLayoutModeInvalid = 0xffff
+};
+
+// this function abstracts away the layout and mode details of a libc++ string
+// and returns the address of the data and the size ready for callers to consume
+static bool
+ExtractLibcxxStringInfo (ValueObject& valobj,
+ ValueObjectSP &location_sp,
+ uint64_t& size)
+{
+ ValueObjectSP D(valobj.GetChildAtIndexPath({0,0,0,0}));
+ if (!D)
+ return false;
+
+ ValueObjectSP layout_decider(D->GetChildAtIndexPath({0,0}));
+
+ // this child should exist
+ if (!layout_decider)
+ return false;
+
+ ConstString g_data_name("__data_");
+ ConstString g_size_name("__size_");
+ bool short_mode = false; // this means the string is in short-mode and the data is stored inline
+ LibcxxStringLayoutMode layout = (layout_decider->GetName() == g_data_name) ? eLibcxxStringLayoutModeDSC : eLibcxxStringLayoutModeCSD;
+ uint64_t size_mode_value = 0;
+
+ if (layout == eLibcxxStringLayoutModeDSC)
+ {
+ ValueObjectSP size_mode(D->GetChildAtIndexPath({1,1,0}));
+ if (!size_mode)
+ return false;
+
+ if (size_mode->GetName() != g_size_name)
+ {
+ // we are hitting the padding structure, move along
+ size_mode = D->GetChildAtIndexPath({1,1,1});
+ if (!size_mode)
+ return false;
+ }
+
+ size_mode_value = (size_mode->GetValueAsUnsigned(0));
+ short_mode = ((size_mode_value & 0x80) == 0);
+ }
+ else
+ {
+ ValueObjectSP size_mode(D->GetChildAtIndexPath({1,0,0}));
+ if (!size_mode)
+ return false;
+
+ size_mode_value = (size_mode->GetValueAsUnsigned(0));
+ short_mode = ((size_mode_value & 1) == 0);
+ }
+
+ if (short_mode)
+ {
+ ValueObjectSP s(D->GetChildAtIndex(1, true));
+ if (!s)
+ return false;
+ location_sp = s->GetChildAtIndex((layout == eLibcxxStringLayoutModeDSC) ? 0 : 1, true);
+ size = (layout == eLibcxxStringLayoutModeDSC) ? size_mode_value : ((size_mode_value >> 1) % 256);
+ return (location_sp.get() != nullptr);
+ }
+ else
+ {
+ ValueObjectSP l(D->GetChildAtIndex(0, true));
+ if (!l)
+ return false;
+ // we can use the layout_decider object as the data pointer
+ location_sp = (layout == eLibcxxStringLayoutModeDSC) ? layout_decider : l->GetChildAtIndex(2, true);
+ ValueObjectSP size_vo(l->GetChildAtIndex(1, true));
+ if (!size_vo || !location_sp)
+ return false;
+ size = size_vo->GetValueAsUnsigned(0);
+ return true;
+ }
+}
+
+bool
+lldb_private::formatters::LibcxxWStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& summary_options)
+{
+ uint64_t size = 0;
+ ValueObjectSP location_sp((ValueObject*)nullptr);
+ if (!ExtractLibcxxStringInfo(valobj, location_sp, size))
+ return false;
+ if (size == 0)
+ {
+ stream.Printf("L\"\"");
+ return true;
+ }
+ if (!location_sp)
+ return false;
+
+ DataExtractor extractor;
+
+ StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
+
+ if (summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryCapped)
+ {
+ const auto max_size = valobj.GetTargetSP()->GetMaximumSizeOfStringSummary();
+ if (size > max_size)
+ {
+ size = max_size;
+ options.SetIsTruncated(true);
+ }
+ }
+ location_sp->GetPointeeData(extractor, 0, size);
+
+ // std::wstring::size() is measured in 'characters', not bytes
+ auto wchar_t_size = valobj.GetTargetSP()->GetScratchClangASTContext()->GetBasicType(lldb::eBasicTypeWChar).GetByteSize(nullptr);
+
+ options.SetData(extractor);
+ options.SetStream(&stream);
+ options.SetPrefixToken("L");
+ options.SetQuote('"');
+ options.SetSourceSize(size);
+ options.SetBinaryZeroIsTerminator(false);
+
+ switch (wchar_t_size)
+ {
+ case 1:
+ StringPrinter::ReadBufferAndDumpToStream<lldb_private::formatters::StringPrinter::StringElementType::UTF8>(options);
+ break;
+
+ case 2:
+ lldb_private::formatters::StringPrinter::ReadBufferAndDumpToStream<lldb_private::formatters::StringPrinter::StringElementType::UTF16>(options);
+ break;
+
+ case 4:
+ lldb_private::formatters::StringPrinter::ReadBufferAndDumpToStream<lldb_private::formatters::StringPrinter::StringElementType::UTF32>(options);
+ break;
+
+ default:
+ stream.Printf("size for wchar_t is not valid");
+ return true;
+ }
+
+ return true;
+}
+
+bool
+lldb_private::formatters::LibcxxStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& summary_options)
+{
+ uint64_t size = 0;
+ ValueObjectSP location_sp((ValueObject*)nullptr);
+
+ if (!ExtractLibcxxStringInfo(valobj, location_sp, size))
+ return false;
+
+ if (size == 0)
+ {
+ stream.Printf("\"\"");
+ return true;
+ }
+
+ if (!location_sp)
+ return false;
+
+ StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
+
+ DataExtractor extractor;
+ if (summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryCapped)
+ {
+ const auto max_size = valobj.GetTargetSP()->GetMaximumSizeOfStringSummary();
+ if (size > max_size)
+ {
+ size = max_size;
+ options.SetIsTruncated(true);
+ }
+ }
+ location_sp->GetPointeeData(extractor, 0, size);
+
+ options.SetData(extractor);
+ options.SetStream(&stream);
+ options.SetPrefixToken(0);
+ options.SetQuote('"');
+ options.SetSourceSize(size);
+ options.SetBinaryZeroIsTerminator(false);
+ StringPrinter::ReadBufferAndDumpToStream<StringPrinter::StringElementType::ASCII>(options);
+
+ return true;
+}
diff --git a/source/Plugins/Language/CPlusPlus/LibCxx.h b/source/Plugins/Language/CPlusPlus/LibCxx.h
new file mode 100644
index 000000000000..ae00bc0ade34
--- /dev/null
+++ b/source/Plugins/Language/CPlusPlus/LibCxx.h
@@ -0,0 +1,141 @@
+//===-- LibCxx.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_LibCxx_h_
+#define liblldb_LibCxx_h_
+
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
+
+namespace lldb_private {
+ namespace formatters
+ {
+
+ bool
+ LibcxxStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libc++ std::string
+
+ bool
+ LibcxxWStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libc++ std::wstring
+
+ bool
+ LibcxxSmartPointerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libc++ std::shared_ptr<> and std::weak_ptr<>
+
+ class LibcxxVectorBoolSyntheticFrontEnd : public SyntheticChildrenFrontEnd
+ {
+ public:
+ LibcxxVectorBoolSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+
+ size_t
+ CalculateNumChildren() override;
+
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
+
+ bool
+ Update() override;
+
+ bool
+ MightHaveChildren() override;
+
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
+
+ ~LibcxxVectorBoolSyntheticFrontEnd() override;
+
+ private:
+ CompilerType m_bool_type;
+ ExecutionContextRef m_exe_ctx_ref;
+ uint64_t m_count;
+ lldb::addr_t m_base_data_address;
+ std::map<size_t,lldb::ValueObjectSP> m_children;
+ };
+
+ SyntheticChildrenFrontEnd* LibcxxVectorBoolSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
+
+ bool
+ LibcxxContainerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ class LibCxxMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd
+ {
+ public:
+ LibCxxMapIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+
+ size_t
+ CalculateNumChildren() override;
+
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
+
+ bool
+ Update() override;
+
+ bool
+ MightHaveChildren() override;
+
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
+
+ ~LibCxxMapIteratorSyntheticFrontEnd() override;
+
+ private:
+ ValueObject *m_pair_ptr;
+ };
+
+ SyntheticChildrenFrontEnd* LibCxxMapIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
+
+ SyntheticChildrenFrontEnd* LibCxxVectorIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
+
+ class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd
+ {
+ public:
+ LibcxxSharedPtrSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+
+ size_t
+ CalculateNumChildren() override;
+
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
+
+ bool
+ Update() override;
+
+ bool
+ MightHaveChildren() override;
+
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
+
+ ~LibcxxSharedPtrSyntheticFrontEnd() override;
+
+ private:
+ ValueObject* m_cntrl;
+ lldb::ValueObjectSP m_count_sp;
+ lldb::ValueObjectSP m_weak_count_sp;
+ uint8_t m_ptr_size;
+ lldb::ByteOrder m_byte_order;
+ };
+
+ SyntheticChildrenFrontEnd* LibcxxSharedPtrSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
+
+ SyntheticChildrenFrontEnd* LibcxxStdVectorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
+
+ SyntheticChildrenFrontEnd* LibcxxStdListSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
+
+ SyntheticChildrenFrontEnd* LibcxxStdMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
+
+ SyntheticChildrenFrontEnd* LibcxxStdUnorderedMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
+
+ SyntheticChildrenFrontEnd* LibcxxInitializerListSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
+
+ } // namespace formatters
+} // namespace lldb_private
+
+#endif // liblldb_LibCxx_h_
diff --git a/source/DataFormatters/LibCxxInitializerList.cpp b/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
index 0dcef981e5e5..9970d49dac62 100644
--- a/source/DataFormatters/LibCxxInitializerList.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxInitializerList.cpp ----------------------------------*- C++ -*-===//
+//===-- LibCxxInitializerList.cpp -------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,10 +7,15 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/DataFormatters/CXXFormatterFunctions.h"
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "LibCxx.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
using namespace lldb;
using namespace lldb_private;
@@ -22,33 +27,33 @@ namespace lldb_private {
{
public:
LibcxxInitializerListSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+
+ ~LibcxxInitializerListSyntheticFrontEnd() override;
+
+ size_t
+ CalculateNumChildren() override;
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
- virtual bool
- Update();
+ bool
+ Update() override;
- virtual bool
- MightHaveChildren ();
+ bool
+ MightHaveChildren() override;
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
- virtual
- ~LibcxxInitializerListSyntheticFrontEnd ();
private:
ValueObject* m_start;
- ClangASTType m_element_type;
+ CompilerType m_element_type;
uint32_t m_element_size;
size_t m_num_elements;
std::map<size_t,lldb::ValueObjectSP> m_children;
};
- }
-}
+ } // namespace formatters
+} // namespace lldb_private
lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::LibcxxInitializerListSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
SyntheticChildrenFrontEnd(*valobj_sp.get()),
@@ -62,6 +67,12 @@ m_children()
Update();
}
+lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::~LibcxxInitializerListSyntheticFrontEnd()
+{
+ // this needs to stay around because it's a child object who will follow its parent's life cycle
+ // delete m_start;
+}
+
size_t
lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::CalculateNumChildren ()
{
@@ -101,7 +112,7 @@ lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::Update()
m_num_elements = 0;
m_children.clear();
lldb::TemplateArgumentKind kind;
- m_element_type = m_backend.GetClangType().GetTemplateArgument(0, kind);
+ m_element_type = m_backend.GetCompilerType().GetTemplateArgument(0, kind);
if (kind != lldb::eTemplateArgumentKindType || false == m_element_type.IsValid())
return false;
@@ -127,12 +138,6 @@ lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::GetIndexOfChil
return ExtractIndexFromString(name.GetCString());
}
-lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::~LibcxxInitializerListSyntheticFrontEnd ()
-{
- // this needs to stay around because it's a child object who will follow its parent's life cycle
- // delete m_start;
-}
-
lldb_private::SyntheticChildrenFrontEnd*
lldb_private::formatters::LibcxxInitializerListSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
{
@@ -140,4 +145,3 @@ lldb_private::formatters::LibcxxInitializerListSyntheticFrontEndCreator (CXXSynt
return NULL;
return (new LibcxxInitializerListSyntheticFrontEnd(valobj_sp));
}
-
diff --git a/source/DataFormatters/LibCxxList.cpp b/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
index f3e07fe7a017..f86f968ea857 100644
--- a/source/DataFormatters/LibCxxList.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxList.cpp -------------------------------------------*- C++ -*-===//
+//===-- LibCxxList.cpp ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,184 +7,204 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/DataFormatters/CXXFormatterFunctions.h"
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "LibCxx.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
+namespace {
+
+ class ListEntry
+ {
+ public:
+ ListEntry() = default;
+ ListEntry (ValueObjectSP entry_sp) : m_entry_sp(entry_sp) {}
+ ListEntry (const ListEntry& rhs) : m_entry_sp(rhs.m_entry_sp) {}
+ ListEntry (ValueObject* entry) : m_entry_sp(entry ? entry->GetSP() : ValueObjectSP()) {}
+
+ ListEntry
+ next ()
+ {
+ if (!m_entry_sp)
+ return ListEntry();
+ return ListEntry(m_entry_sp->GetChildAtIndexPath({0,1}));
+ }
+
+ ListEntry
+ prev ()
+ {
+ if (!m_entry_sp)
+ return ListEntry();
+ return ListEntry(m_entry_sp->GetChildAtIndexPath({0,0}));
+ }
+
+ uint64_t
+ value () const
+ {
+ if (!m_entry_sp)
+ return 0;
+ return m_entry_sp->GetValueAsUnsigned(0);
+ }
+
+ bool
+ null()
+ {
+ return (value() == 0);
+ }
+
+ explicit operator bool ()
+ {
+ return GetEntry().get() != nullptr && null() == false;
+ }
+
+ ValueObjectSP
+ GetEntry ()
+ {
+ return m_entry_sp;
+ }
+
+ void
+ SetEntry (ValueObjectSP entry)
+ {
+ m_entry_sp = entry;
+ }
+
+ bool
+ operator == (const ListEntry& rhs) const
+ {
+ return value() == rhs.value();
+ }
+
+ bool
+ operator != (const ListEntry& rhs) const
+ {
+ return !(*this == rhs);
+ }
+
+ private:
+ ValueObjectSP m_entry_sp;
+ };
+
+ class ListIterator
+ {
+ public:
+ ListIterator() = default;
+ ListIterator (ListEntry entry) : m_entry(entry) {}
+ ListIterator (ValueObjectSP entry) : m_entry(entry) {}
+ ListIterator (const ListIterator& rhs) : m_entry(rhs.m_entry) {}
+ ListIterator (ValueObject* entry) : m_entry(entry) {}
+
+ ValueObjectSP
+ value ()
+ {
+ return m_entry.GetEntry();
+ }
+
+ ValueObjectSP
+ advance (size_t count)
+ {
+ if (count == 0)
+ return m_entry.GetEntry();
+ if (count == 1)
+ {
+ next ();
+ return m_entry.GetEntry();
+ }
+ while (count > 0)
+ {
+ next ();
+ count--;
+ if (m_entry.null())
+ return lldb::ValueObjectSP();
+ }
+ return m_entry.GetEntry();
+ }
+
+ bool
+ operator == (const ListIterator& rhs) const
+ {
+ return (rhs.m_entry == m_entry);
+ }
+
+ protected:
+ void
+ next ()
+ {
+ m_entry = m_entry.next();
+ }
+
+ void
+ prev ()
+ {
+ m_entry = m_entry.prev();
+ }
+
+ private:
+ ListEntry m_entry;
+ };
+
+} // end anonymous namespace
+
namespace lldb_private {
namespace formatters {
class LibcxxStdListSyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
public:
LibcxxStdListSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+
+ ~LibcxxStdListSyntheticFrontEnd() override = default;
+
+ size_t
+ CalculateNumChildren() override;
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
- virtual bool
- Update();
+ bool
+ Update() override;
- virtual bool
- MightHaveChildren ();
+ bool
+ MightHaveChildren() override;
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
- virtual
- ~LibcxxStdListSyntheticFrontEnd ();
private:
bool
- HasLoop(size_t);
+ HasLoop(size_t count);
size_t m_list_capping_size;
static const bool g_use_loop_detect = true;
- size_t m_loop_detected;
+
+ size_t m_loop_detected; // The number of elements that have had loop detection run over them.
+ ListEntry m_slow_runner; // Used for loop detection
+ ListEntry m_fast_runner; // Used for loop detection
+
lldb::addr_t m_node_address;
ValueObject* m_head;
ValueObject* m_tail;
- ClangASTType m_element_type;
+ CompilerType m_element_type;
size_t m_count;
std::map<size_t,lldb::ValueObjectSP> m_children;
+ std::map<size_t, ListIterator> m_iterators;
};
- }
-}
-
-class ListEntry
-{
-public:
- ListEntry () {}
- ListEntry (ValueObjectSP entry_sp) : m_entry_sp(entry_sp) {}
- ListEntry (const ListEntry& rhs) : m_entry_sp(rhs.m_entry_sp) {}
- ListEntry (ValueObject* entry) : m_entry_sp(entry ? entry->GetSP() : ValueObjectSP()) {}
-
- ListEntry
- next ()
- {
- if (!m_entry_sp)
- return ListEntry();
- return ListEntry(m_entry_sp->GetChildMemberWithName(ConstString("__next_"), true));
- }
-
- ListEntry
- prev ()
- {
- if (!m_entry_sp)
- return ListEntry();
- return ListEntry(m_entry_sp->GetChildMemberWithName(ConstString("__prev_"), true));
- }
-
- uint64_t
- value ()
- {
- if (!m_entry_sp)
- return 0;
- return m_entry_sp->GetValueAsUnsigned(0);
- }
-
- bool
- null()
- {
- return (value() == 0);
- }
-
- explicit operator bool ()
- {
- return GetEntry().get() != nullptr && null() == false;
- }
-
- ValueObjectSP
- GetEntry ()
- {
- return m_entry_sp;
- }
-
- void
- SetEntry (ValueObjectSP entry)
- {
- m_entry_sp = entry;
- }
-
- bool
- operator == (const ListEntry& rhs) const
- {
- return (rhs.m_entry_sp.get() == m_entry_sp.get());
- }
-
-private:
- ValueObjectSP m_entry_sp;
-};
-
-class ListIterator
-{
-public:
- ListIterator () {}
- ListIterator (ListEntry entry) : m_entry(entry) {}
- ListIterator (ValueObjectSP entry) : m_entry(entry) {}
- ListIterator (const ListIterator& rhs) : m_entry(rhs.m_entry) {}
- ListIterator (ValueObject* entry) : m_entry(entry) {}
-
- ValueObjectSP
- value ()
- {
- return m_entry.GetEntry();
- }
-
- ValueObjectSP
- advance (size_t count)
- {
- if (count == 0)
- return m_entry.GetEntry();
- if (count == 1)
- {
- next ();
- return m_entry.GetEntry();
- }
- while (count > 0)
- {
- next ();
- count--;
- if (m_entry.null())
- return lldb::ValueObjectSP();
- }
- return m_entry.GetEntry();
- }
-
- bool
- operator == (const ListIterator& rhs) const
- {
- return (rhs.m_entry == m_entry);
- }
-
-protected:
- void
- next ()
- {
- m_entry = m_entry.next();
- }
-
- void
- prev ()
- {
- m_entry = m_entry.prev();
- }
-private:
- ListEntry m_entry;
-};
+ } // namespace formatters
+} // namespace lldb_private
lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::LibcxxStdListSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
SyntheticChildrenFrontEnd(*valobj_sp.get()),
@@ -195,7 +215,8 @@ m_head(NULL),
m_tail(NULL),
m_element_type(),
m_count(UINT32_MAX),
-m_children()
+m_children(),
+m_iterators()
{
if (valobj_sp)
Update();
@@ -209,25 +230,34 @@ lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::HasLoop(size_t count)
// don't bother checking for a loop if we won't actually need to jump nodes
if (m_count < 2)
return false;
- auto steps_left = std::min(count,m_count);
- auto steps_left_save = steps_left;
- ListEntry slow(m_head);
- ListEntry fast(m_head);
- while (steps_left-- > 0)
+
+ if (m_loop_detected == 0)
{
- slow = slow.next();
- fast = fast.next();
- if (fast.next())
- fast = fast.next().next();
- else
- fast = nullptr;
- if (!slow || !fast)
- return false;
- if (slow == fast)
- return true;
+ // This is the first time we are being run (after the last update). Set up the loop
+ // invariant for the first element.
+ m_slow_runner = ListEntry(m_head).next();
+ m_fast_runner = m_slow_runner.next();
+ m_loop_detected = 1;
}
- m_loop_detected = steps_left_save;
- return false;
+
+ // Loop invariant:
+ // Loop detection has been run over the first m_loop_detected elements. If m_slow_runner ==
+ // m_fast_runner then the loop has been detected after m_loop_detected elements.
+ const size_t steps_to_run = std::min(count,m_count);
+ while (m_loop_detected < steps_to_run
+ && m_slow_runner
+ && m_fast_runner
+ && m_slow_runner != m_fast_runner) {
+
+ m_slow_runner = m_slow_runner.next();
+ m_fast_runner = m_fast_runner.next().next();
+ m_loop_detected++;
+ }
+ if (count <= m_loop_detected)
+ return false; // No loop in the first m_loop_detected elements.
+ if (!m_slow_runner || !m_fast_runner)
+ return false; // Reached the end of the list. Definitely no loops.
+ return m_slow_runner == m_fast_runner;
}
size_t
@@ -286,15 +316,29 @@ lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::GetChildAtIndex (size_
if (cached != m_children.end())
return cached->second;
- if (m_loop_detected <= idx)
- if (HasLoop(idx))
- return lldb::ValueObjectSP();
-
+ if (HasLoop(idx+1))
+ return lldb::ValueObjectSP();
+
+ size_t actual_advance = idx;
+
ListIterator current(m_head);
- ValueObjectSP current_sp(current.advance(idx));
+ if (idx > 0)
+ {
+ auto cached_iterator = m_iterators.find(idx-1);
+ if (cached_iterator != m_iterators.end())
+ {
+ current = cached_iterator->second;
+ actual_advance = 1;
+ }
+ }
+
+ ValueObjectSP current_sp(current.advance(actual_advance));
if (!current_sp)
return lldb::ValueObjectSP();
- current_sp = current_sp->GetChildMemberWithName(ConstString("__value_"), true);
+
+ m_iterators[idx] = current;
+
+ current_sp = current_sp->GetChildAtIndex(1, true); // get the __value_ child
if (!current_sp)
return lldb::ValueObjectSP();
// we need to copy current_sp into a new object otherwise we will end up with all items named __value_
@@ -312,10 +356,15 @@ lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::GetChildAtIndex (size_
bool
lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::Update()
{
+ m_children.clear();
+ m_iterators.clear();
m_head = m_tail = NULL;
m_node_address = 0;
m_count = UINT32_MAX;
- m_loop_detected = false;
+ m_loop_detected = 0;
+ m_slow_runner.SetEntry(nullptr);
+ m_fast_runner.SetEntry(nullptr);
+
Error err;
ValueObjectSP backend_addr(m_backend.AddressOf(err));
m_list_capping_size = 0;
@@ -331,7 +380,7 @@ lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::Update()
ValueObjectSP impl_sp(m_backend.GetChildMemberWithName(ConstString("__end_"),true));
if (!impl_sp)
return false;
- ClangASTType list_type = m_backend.GetClangType();
+ CompilerType list_type = m_backend.GetCompilerType();
if (list_type.IsReferenceType())
list_type = list_type.GetNonReferenceType();
@@ -356,9 +405,6 @@ lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::GetIndexOfChildWithNam
return ExtractIndexFromString(name.GetCString());
}
-lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::~LibcxxStdListSyntheticFrontEnd ()
-{}
-
SyntheticChildrenFrontEnd*
lldb_private::formatters::LibcxxStdListSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
{
@@ -366,4 +412,3 @@ lldb_private::formatters::LibcxxStdListSyntheticFrontEndCreator (CXXSyntheticChi
return NULL;
return (new LibcxxStdListSyntheticFrontEnd(valobj_sp));
}
-
diff --git a/source/DataFormatters/LibCxxMap.cpp b/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
index 2ff623284845..aa82557edb02 100644
--- a/source/DataFormatters/LibCxxMap.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxList.cpp -------------------------------------------*- C++ -*-===//
+//===-- LibCxxList.cpp ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,67 +7,30 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/DataFormatters/CXXFormatterFunctions.h"
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "LibCxx.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
-namespace lldb_private {
- namespace formatters {
- class LibcxxStdMapSyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- LibcxxStdMapSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
-
- virtual bool
- MightHaveChildren ();
-
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
-
- virtual
- ~LibcxxStdMapSyntheticFrontEnd ();
- private:
- bool
- GetDataType();
-
- void
- GetValueOffset (const lldb::ValueObjectSP& node);
-
- ValueObject* m_tree;
- ValueObject* m_root_node;
- ClangASTType m_element_type;
- uint32_t m_skip_size;
- size_t m_count;
- std::map<size_t,lldb::ValueObjectSP> m_children;
- };
- }
-}
-
class MapEntry
{
public:
- MapEntry () {}
+ MapEntry() = default;
explicit MapEntry (ValueObjectSP entry_sp) : m_entry_sp(entry_sp) {}
MapEntry (const MapEntry& rhs) : m_entry_sp(rhs.m_entry_sp) {}
explicit MapEntry (ValueObject* entry) : m_entry_sp(entry ? entry->GetSP() : ValueObjectSP()) {}
@@ -146,7 +109,7 @@ private:
class MapIterator
{
public:
- MapIterator () {}
+ MapIterator() = default;
MapIterator (MapEntry entry, size_t depth = 0) : m_entry(entry), m_max_depth(depth), m_error(false) {}
MapIterator (ValueObjectSP entry, size_t depth = 0) : m_entry(entry), m_max_depth(depth), m_error(false) {}
MapIterator (const MapIterator& rhs) : m_entry(rhs.m_entry),m_max_depth(rhs.m_max_depth), m_error(false) {}
@@ -176,6 +139,7 @@ public:
}
return m_entry.GetEntry();
}
+
protected:
void
next ()
@@ -206,7 +170,7 @@ protected:
}
m_entry = MapEntry(m_entry.parent());
}
-
+
private:
MapEntry
tree_min (MapEntry&& x)
@@ -230,7 +194,7 @@ private:
}
return x;
}
-
+
bool
is_left_child (const MapEntry& x)
{
@@ -246,6 +210,48 @@ private:
bool m_error;
};
+namespace lldb_private {
+ namespace formatters {
+ class LibcxxStdMapSyntheticFrontEnd : public SyntheticChildrenFrontEnd
+ {
+ public:
+ LibcxxStdMapSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+
+ ~LibcxxStdMapSyntheticFrontEnd() override = default;
+
+ size_t
+ CalculateNumChildren() override;
+
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
+
+ bool
+ Update() override;
+
+ bool
+ MightHaveChildren() override;
+
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
+
+ private:
+ bool
+ GetDataType();
+
+ void
+ GetValueOffset (const lldb::ValueObjectSP& node);
+
+ ValueObject* m_tree;
+ ValueObject* m_root_node;
+ CompilerType m_element_type;
+ uint32_t m_skip_size;
+ size_t m_count;
+ std::map<size_t, lldb::ValueObjectSP> m_children;
+ std::map<size_t, MapIterator> m_iterators;
+ };
+ } // namespace formatters
+} // namespace lldb_private
+
lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::LibcxxStdMapSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
SyntheticChildrenFrontEnd(*valobj_sp.get()),
m_tree(NULL),
@@ -253,7 +259,8 @@ m_root_node(NULL),
m_element_type(),
m_skip_size(UINT32_MAX),
m_count(UINT32_MAX),
-m_children()
+m_children(),
+m_iterators()
{
if (valobj_sp)
Update();
@@ -262,14 +269,17 @@ m_children()
size_t
lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::CalculateNumChildren ()
{
+ static ConstString g___pair3_("__pair3_");
+ static ConstString g___first_("__first_");
+
if (m_count != UINT32_MAX)
return m_count;
if (m_tree == NULL)
return 0;
- ValueObjectSP m_item(m_tree->GetChildMemberWithName(ConstString("__pair3_"), true));
+ ValueObjectSP m_item(m_tree->GetChildMemberWithName(g___pair3_, true));
if (!m_item)
return 0;
- m_item = m_item->GetChildMemberWithName(ConstString("__first_"), true);
+ m_item = m_item->GetChildMemberWithName(g___first_, true);
if (!m_item)
return 0;
m_count = m_item->GetValueAsUnsigned(0);
@@ -279,7 +289,9 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::CalculateNumChildren ()
bool
lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetDataType()
{
- if (m_element_type.GetOpaqueQualType() && m_element_type.GetASTContext())
+ static ConstString g___value_("__value_");
+
+ if (m_element_type.GetOpaqueQualType() && m_element_type.GetTypeSystem())
return true;
m_element_type.Clear();
ValueObjectSP deref;
@@ -287,10 +299,10 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetDataType()
deref = m_root_node->Dereference(error);
if (!deref || error.Fail())
return false;
- deref = deref->GetChildMemberWithName(ConstString("__value_"), true);
+ deref = deref->GetChildMemberWithName(g___value_, true);
if (!deref)
return false;
- m_element_type = deref->GetClangType();
+ m_element_type = deref->GetCompilerType();
return true;
}
@@ -301,7 +313,7 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetValueOffset (const l
return;
if (!node)
return;
- ClangASTType node_type(node->GetClangType());
+ CompilerType node_type(node->GetCompilerType());
uint64_t bit_offset;
if (node_type.GetIndexOfFieldWithName("__value_", NULL, &bit_offset) == UINT32_MAX)
return;
@@ -313,6 +325,7 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex (size_t
{
static ConstString g___cc("__cc");
static ConstString g___nc("__nc");
+ static ConstString g___value_("__value_");
if (idx >= CalculateNumChildren())
@@ -323,10 +336,22 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex (size_t
auto cached = m_children.find(idx);
if (cached != m_children.end())
return cached->second;
-
- bool need_to_skip = (idx > 0);
+
MapIterator iterator(m_root_node, CalculateNumChildren());
- ValueObjectSP iterated_sp(iterator.advance(idx));
+
+ const bool need_to_skip = (idx > 0);
+ size_t actual_advancde = idx;
+ if (need_to_skip)
+ {
+ auto cached_iterator = m_iterators.find(idx-1);
+ if (cached_iterator != m_iterators.end())
+ {
+ iterator = cached_iterator->second;
+ actual_advancde = 1;
+ }
+ }
+
+ ValueObjectSP iterated_sp(iterator.advance(actual_advancde));
if (iterated_sp.get() == NULL)
{
// this tree is garbage - stop
@@ -345,7 +370,7 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex (size_t
return lldb::ValueObjectSP();
}
GetValueOffset(iterated_sp);
- iterated_sp = iterated_sp->GetChildMemberWithName(ConstString("__value_"), true);
+ iterated_sp = iterated_sp->GetChildMemberWithName(g___value_, true);
if (!iterated_sp)
{
m_tree = NULL;
@@ -412,19 +437,23 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex (size_t
}
potential_child_sp->SetName(ConstString(name.GetData()));
}
+ m_iterators[idx] = iterator;
return (m_children[idx] = potential_child_sp);
}
bool
lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::Update()
{
+ static ConstString g___tree_("__tree_");
+ static ConstString g___begin_node_("__begin_node_");
m_count = UINT32_MAX;
m_tree = m_root_node = NULL;
m_children.clear();
- m_tree = m_backend.GetChildMemberWithName(ConstString("__tree_"), true).get();
+ m_iterators.clear();
+ m_tree = m_backend.GetChildMemberWithName(g___tree_, true).get();
if (!m_tree)
return false;
- m_root_node = m_tree->GetChildMemberWithName(ConstString("__begin_node_"), true).get();
+ m_root_node = m_tree->GetChildMemberWithName(g___begin_node_, true).get();
return false;
}
@@ -440,9 +469,6 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetIndexOfChildWithName
return ExtractIndexFromString(name.GetCString());
}
-lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::~LibcxxStdMapSyntheticFrontEnd ()
-{}
-
SyntheticChildrenFrontEnd*
lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
{
diff --git a/source/DataFormatters/LibCxxUnorderedMap.cpp b/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
index 43669803195e..8ad806d52bce 100644
--- a/source/DataFormatters/LibCxxUnorderedMap.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxUnorderedMap.cpp -----------------------------------*- C++ -*-===//
+//===-- LibCxxUnorderedMap.cpp ----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,16 +7,20 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/DataFormatters/CXXFormatterFunctions.h"
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "LibCxx.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
using namespace lldb;
@@ -29,34 +33,33 @@ namespace lldb_private {
{
public:
LibcxxStdUnorderedMapSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+
+ ~LibcxxStdUnorderedMapSyntheticFrontEnd() override = default;
+
+ size_t
+ CalculateNumChildren() override;
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
- virtual bool
- MightHaveChildren ();
+ bool
+ Update() override;
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
+ bool
+ MightHaveChildren() override;
- virtual
- ~LibcxxStdUnorderedMapSyntheticFrontEnd ();
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
+
private:
-
ValueObject* m_tree;
size_t m_num_elements;
ValueObject* m_next_element;
std::map<size_t,lldb::ValueObjectSP> m_children;
std::vector<std::pair<ValueObject*, uint64_t> > m_elements_cache;
};
- }
-}
+ } // namespace formatters
+} // namespace lldb_private
lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::LibcxxStdUnorderedMapSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
SyntheticChildrenFrontEnd(*valobj_sp.get()),
@@ -125,7 +128,7 @@ lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::GetChildAtInde
return val_hash.first->CreateValueObjectFromData(stream.GetData(),
data,
exe_ctx,
- val_hash.first->GetClangType());
+ val_hash.first->GetCompilerType());
}
bool
@@ -160,9 +163,6 @@ lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::GetIndexOfChil
return ExtractIndexFromString(name.GetCString());
}
-lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::~LibcxxStdUnorderedMapSyntheticFrontEnd ()
-{}
-
SyntheticChildrenFrontEnd*
lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
{
diff --git a/source/DataFormatters/LibCxxVector.cpp b/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
index 6ccb732f6779..9fb4f48e9090 100644
--- a/source/DataFormatters/LibCxxVector.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxVector.cpp -----------------------------------------*- C++ -*-===//
+//===-- LibCxxVector.cpp ----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,10 +7,15 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/DataFormatters/CXXFormatterFunctions.h"
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "LibCxx.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
using namespace lldb;
using namespace lldb_private;
@@ -22,33 +27,33 @@ namespace lldb_private {
{
public:
LibcxxStdVectorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+
+ ~LibcxxStdVectorSyntheticFrontEnd() override;
+
+ size_t
+ CalculateNumChildren() override;
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
- virtual bool
- MightHaveChildren ();
+ bool
+ Update() override;
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
+ bool
+ MightHaveChildren() override;
- virtual
- ~LibcxxStdVectorSyntheticFrontEnd ();
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
+
private:
ValueObject* m_start;
ValueObject* m_finish;
- ClangASTType m_element_type;
+ CompilerType m_element_type;
uint32_t m_element_size;
std::map<size_t,lldb::ValueObjectSP> m_children;
};
- }
-}
+ } // namespace formatters
+} // namespace lldb_private
lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::LibcxxStdVectorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
SyntheticChildrenFrontEnd(*valobj_sp.get()),
@@ -62,6 +67,13 @@ m_children()
Update();
}
+lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::~LibcxxStdVectorSyntheticFrontEnd()
+{
+ // these need to stay around because they are child objects who will follow their parent's life cycle
+ // delete m_start;
+ // delete m_finish;
+}
+
size_t
lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::CalculateNumChildren ()
{
@@ -112,7 +124,7 @@ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::Update()
data_type_finder_sp = data_type_finder_sp->GetChildMemberWithName(ConstString("__first_"),true);
if (!data_type_finder_sp)
return false;
- m_element_type = data_type_finder_sp->GetClangType().GetPointeeType();
+ m_element_type = data_type_finder_sp->GetCompilerType().GetPointeeType();
m_element_size = m_element_type.GetByteSize(nullptr);
if (m_element_size > 0)
@@ -138,13 +150,6 @@ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::GetIndexOfChildWithN
return ExtractIndexFromString(name.GetCString());
}
-lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::~LibcxxStdVectorSyntheticFrontEnd ()
-{
- // these need to stay around because they are child objects who will follow their parent's life cycle
- // delete m_start;
- // delete m_finish;
-}
-
lldb_private::SyntheticChildrenFrontEnd*
lldb_private::formatters::LibcxxStdVectorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
{
@@ -152,4 +157,3 @@ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEndCreator (CXXSyntheticC
return NULL;
return (new LibcxxStdVectorSyntheticFrontEnd(valobj_sp));
}
-
diff --git a/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
new file mode 100644
index 000000000000..ed89c5c84ea3
--- /dev/null
+++ b/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
@@ -0,0 +1,373 @@
+//===-- LibStdcpp.cpp ---------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "LibStdcpp.h"
+
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/Error.h"
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/StringPrinter.h"
+#include "lldb/DataFormatters/VectorIterator.h"
+#include "lldb/Host/Endian.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Target/Target.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+class LibstdcppMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd
+{
+public:
+ LibstdcppMapIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+
+ size_t
+ CalculateNumChildren() override;
+
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
+
+ bool
+ Update() override;
+
+ bool
+ MightHaveChildren() override;
+
+ size_t
+ GetIndexOfChildWithName (const ConstString &name) override;
+
+ ~LibstdcppMapIteratorSyntheticFrontEnd() override;
+
+private:
+ ExecutionContextRef m_exe_ctx_ref;
+ lldb::addr_t m_pair_address;
+ CompilerType m_pair_type;
+ EvaluateExpressionOptions m_options;
+ lldb::ValueObjectSP m_pair_sp;
+};
+
+/*
+ (std::_Rb_tree_iterator<std::pair<const int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >) ibeg = {
+ (_Base_ptr) _M_node = 0x0000000100103910 {
+ (std::_Rb_tree_color) _M_color = _S_black
+ (std::_Rb_tree_node_base::_Base_ptr) _M_parent = 0x00000001001038c0
+ (std::_Rb_tree_node_base::_Base_ptr) _M_left = 0x0000000000000000
+ (std::_Rb_tree_node_base::_Base_ptr) _M_right = 0x0000000000000000
+ }
+ }
+ */
+
+LibstdcppMapIteratorSyntheticFrontEnd::LibstdcppMapIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
+ SyntheticChildrenFrontEnd(*valobj_sp.get()),
+ m_exe_ctx_ref(),
+ m_pair_address(0),
+ m_pair_type(),
+ m_options(),
+ m_pair_sp()
+{
+ if (valobj_sp)
+ Update();
+ m_options.SetCoerceToId(false);
+ m_options.SetUnwindOnError(true);
+ m_options.SetKeepInMemory(true);
+ m_options.SetUseDynamic(lldb::eDynamicCanRunTarget);
+}
+
+bool
+LibstdcppMapIteratorSyntheticFrontEnd::Update()
+{
+ ValueObjectSP valobj_sp = m_backend.GetSP();
+ if (!valobj_sp)
+ return false;
+
+ TargetSP target_sp(valobj_sp->GetTargetSP());
+
+ if (!target_sp)
+ return false;
+
+ bool is_64bit = (target_sp->GetArchitecture().GetAddressByteSize() == 8);
+
+ if (!valobj_sp)
+ return false;
+ m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
+
+ ValueObjectSP _M_node_sp(valobj_sp->GetChildMemberWithName(ConstString("_M_node"), true));
+ if (!_M_node_sp)
+ return false;
+
+ m_pair_address = _M_node_sp->GetValueAsUnsigned(0);
+ if (m_pair_address == 0)
+ return false;
+
+ m_pair_address += (is_64bit ? 32 : 16);
+
+ CompilerType my_type(valobj_sp->GetCompilerType());
+ if (my_type.GetNumTemplateArguments() >= 1)
+ {
+ TemplateArgumentKind kind;
+ CompilerType pair_type = my_type.GetTemplateArgument(0, kind);
+ if (kind != eTemplateArgumentKindType && kind != eTemplateArgumentKindTemplate && kind != eTemplateArgumentKindTemplateExpansion)
+ return false;
+ m_pair_type = pair_type;
+ }
+ else
+ return false;
+
+ return true;
+}
+
+size_t
+LibstdcppMapIteratorSyntheticFrontEnd::CalculateNumChildren ()
+{
+ return 2;
+}
+
+lldb::ValueObjectSP
+LibstdcppMapIteratorSyntheticFrontEnd::GetChildAtIndex (size_t idx)
+{
+ if (m_pair_address != 0 && m_pair_type)
+ {
+ if (!m_pair_sp)
+ m_pair_sp = CreateValueObjectFromAddress("pair", m_pair_address, m_exe_ctx_ref, m_pair_type);
+ if (m_pair_sp)
+ return m_pair_sp->GetChildAtIndex(idx, true);
+ }
+ return lldb::ValueObjectSP();
+}
+
+bool
+LibstdcppMapIteratorSyntheticFrontEnd::MightHaveChildren ()
+{
+ return true;
+}
+
+size_t
+LibstdcppMapIteratorSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
+{
+ if (name == ConstString("first"))
+ return 0;
+ if (name == ConstString("second"))
+ return 1;
+ return UINT32_MAX;
+}
+
+LibstdcppMapIteratorSyntheticFrontEnd::~LibstdcppMapIteratorSyntheticFrontEnd ()
+{}
+
+SyntheticChildrenFrontEnd*
+lldb_private::formatters::LibstdcppMapIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
+{
+ if (!valobj_sp)
+ return NULL;
+ return (new LibstdcppMapIteratorSyntheticFrontEnd(valobj_sp));
+}
+
+/*
+ (lldb) fr var ibeg --ptr-depth 1
+ (__gnu_cxx::__normal_iterator<int *, std::vector<int, std::allocator<int> > >) ibeg = {
+ _M_current = 0x00000001001037a0 {
+ *_M_current = 1
+ }
+ }
+ */
+
+SyntheticChildrenFrontEnd*
+lldb_private::formatters::LibStdcppVectorIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
+{
+ static ConstString g_item_name;
+ if (!g_item_name)
+ g_item_name.SetCString("_M_current");
+ if (!valobj_sp)
+ return NULL;
+ return (new VectorIteratorSyntheticFrontEnd(valobj_sp,g_item_name));
+}
+
+lldb_private::formatters::VectorIteratorSyntheticFrontEnd::VectorIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp,
+ ConstString item_name) :
+SyntheticChildrenFrontEnd(*valobj_sp.get()),
+m_exe_ctx_ref(),
+m_item_name(item_name),
+m_item_sp()
+{
+ if (valobj_sp)
+ Update();
+}
+
+bool
+lldb_private::formatters::VectorIteratorSyntheticFrontEnd::Update()
+{
+ m_item_sp.reset();
+
+ ValueObjectSP valobj_sp = m_backend.GetSP();
+ if (!valobj_sp)
+ return false;
+
+ if (!valobj_sp)
+ return false;
+
+ ValueObjectSP item_ptr(valobj_sp->GetChildMemberWithName(m_item_name,true));
+ if (!item_ptr)
+ return false;
+ if (item_ptr->GetValueAsUnsigned(0) == 0)
+ return false;
+ Error err;
+ m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
+ m_item_sp = CreateValueObjectFromAddress("item", item_ptr->GetValueAsUnsigned(0), m_exe_ctx_ref, item_ptr->GetCompilerType().GetPointeeType());
+ if (err.Fail())
+ m_item_sp.reset();
+ return false;
+}
+
+size_t
+lldb_private::formatters::VectorIteratorSyntheticFrontEnd::CalculateNumChildren ()
+{
+ return 1;
+}
+
+lldb::ValueObjectSP
+lldb_private::formatters::VectorIteratorSyntheticFrontEnd::GetChildAtIndex (size_t idx)
+{
+ if (idx == 0)
+ return m_item_sp;
+ return lldb::ValueObjectSP();
+}
+
+bool
+lldb_private::formatters::VectorIteratorSyntheticFrontEnd::MightHaveChildren ()
+{
+ return true;
+}
+
+size_t
+lldb_private::formatters::VectorIteratorSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
+{
+ if (name == ConstString("item"))
+ return 0;
+ return UINT32_MAX;
+}
+
+lldb_private::formatters::VectorIteratorSyntheticFrontEnd::~VectorIteratorSyntheticFrontEnd ()
+{
+}
+
+bool
+lldb_private::formatters::LibStdcppStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
+{
+ const bool scalar_is_load_addr = true;
+ AddressType addr_type;
+ lldb::addr_t addr_of_string = valobj.GetAddressOf(scalar_is_load_addr, &addr_type);
+ if (addr_of_string != LLDB_INVALID_ADDRESS)
+ {
+ switch (addr_type)
+ {
+ case eAddressTypeLoad:
+ {
+ ProcessSP process_sp(valobj.GetProcessSP());
+ if (!process_sp)
+ return false;
+
+ StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
+ Error error;
+ lldb::addr_t addr_of_data = process_sp->ReadPointerFromMemory(addr_of_string, error);
+ if (error.Fail() || addr_of_data == 0 || addr_of_data == LLDB_INVALID_ADDRESS)
+ return false;
+ options.SetLocation(addr_of_data);
+ options.SetProcessSP(process_sp);
+ options.SetStream(&stream);
+ options.SetNeedsZeroTermination(false);
+ options.SetBinaryZeroIsTerminator(true);
+ lldb::addr_t size_of_data = process_sp->ReadPointerFromMemory(addr_of_string + process_sp->GetAddressByteSize(), error);
+ if (error.Fail())
+ return false;
+ options.SetSourceSize(size_of_data);
+
+ if (!StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF8>(options))
+ {
+ stream.Printf("Summary Unavailable");
+ return true;
+ }
+ else
+ return true;
+ }
+ break;
+ case eAddressTypeHost:
+ break;
+ case eAddressTypeInvalid:
+ case eAddressTypeFile:
+ break;
+ }
+ }
+ return false;
+}
+
+bool
+lldb_private::formatters::LibStdcppWStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
+{
+ const bool scalar_is_load_addr = true;
+ AddressType addr_type;
+ lldb::addr_t addr_of_string = valobj.GetAddressOf(scalar_is_load_addr, &addr_type);
+ if (addr_of_string != LLDB_INVALID_ADDRESS)
+ {
+ switch (addr_type)
+ {
+ case eAddressTypeLoad:
+ {
+ ProcessSP process_sp(valobj.GetProcessSP());
+ if (!process_sp)
+ return false;
+
+ CompilerType wchar_compiler_type = valobj.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeWChar);
+
+ if (!wchar_compiler_type)
+ return false;
+
+ const uint32_t wchar_size = wchar_compiler_type.GetBitSize(nullptr); // Safe to pass NULL for exe_scope here
+
+ StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
+ Error error;
+ lldb::addr_t addr_of_data = process_sp->ReadPointerFromMemory(addr_of_string, error);
+ if (error.Fail() || addr_of_data == 0 || addr_of_data == LLDB_INVALID_ADDRESS)
+ return false;
+ options.SetLocation(addr_of_data);
+ options.SetProcessSP(process_sp);
+ options.SetStream(&stream);
+ options.SetNeedsZeroTermination(false);
+ options.SetBinaryZeroIsTerminator(false);
+ lldb::addr_t size_of_data = process_sp->ReadPointerFromMemory(addr_of_string + process_sp->GetAddressByteSize(), error);
+ if (error.Fail())
+ return false;
+ options.SetSourceSize(size_of_data);
+ options.SetPrefixToken("L");
+
+ switch (wchar_size)
+ {
+ case 8:
+ return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF8>(options);
+ case 16:
+ return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF16>(options);
+ case 32:
+ return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF32>(options);
+ default:
+ stream.Printf("size for wchar_t is not valid");
+ return true;
+ }
+ return true;
+ }
+ break;
+ case eAddressTypeHost:
+ break;
+ case eAddressTypeInvalid:
+ case eAddressTypeFile:
+ break;
+ }
+ }
+ return false;
+}
diff --git a/source/Plugins/Language/CPlusPlus/LibStdcpp.h b/source/Plugins/Language/CPlusPlus/LibStdcpp.h
new file mode 100644
index 000000000000..347856a1695c
--- /dev/null
+++ b/source/Plugins/Language/CPlusPlus/LibStdcpp.h
@@ -0,0 +1,33 @@
+//===-- LibStdCpp.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_LibStdCpp_h_
+#define liblldb_LibStdCpp_h_
+
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
+
+namespace lldb_private {
+ namespace formatters
+ {
+ bool
+ LibStdcppStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libcstdc++ c++11 std::string
+
+ bool
+ LibStdcppWStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libcstdc++ c++11 std::wstring
+
+ SyntheticChildrenFrontEnd* LibstdcppMapIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
+
+ SyntheticChildrenFrontEnd* LibStdcppVectorIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
+ } // namespace formatters
+} // namespace lldb_private
+
+#endif // liblldb_LibStdCpp_h_
diff --git a/source/Plugins/Language/Go/GoFormatterFunctions.cpp b/source/Plugins/Language/Go/GoFormatterFunctions.cpp
new file mode 100644
index 000000000000..1d7cd76b9739
--- /dev/null
+++ b/source/Plugins/Language/Go/GoFormatterFunctions.cpp
@@ -0,0 +1,173 @@
+//===-- GoFormatterFunctions.cpp---------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C Includes
+// C++ Includes
+#include <map>
+
+// Other libraries and framework includes
+// Project includes
+#include "GoFormatterFunctions.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/DataFormatters/StringPrinter.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+namespace
+{
+class GoSliceSyntheticFrontEnd : public SyntheticChildrenFrontEnd
+{
+ public:
+ GoSliceSyntheticFrontEnd(ValueObject &valobj)
+ : SyntheticChildrenFrontEnd(valobj)
+ {
+ Update();
+ }
+
+ ~GoSliceSyntheticFrontEnd() override = default;
+
+ size_t
+ CalculateNumChildren() override
+ {
+ return m_len;
+ }
+
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override
+ {
+ if (idx < m_len)
+ {
+ ValueObjectSP &cached = m_children[idx];
+ if (!cached)
+ {
+ StreamString idx_name;
+ idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
+ lldb::addr_t object_at_idx = m_base_data_address;
+ object_at_idx += idx * m_type.GetByteSize(nullptr);
+ cached = CreateValueObjectFromAddress(idx_name.GetData(), object_at_idx,
+ m_backend.GetExecutionContextRef(), m_type);
+ }
+ return cached;
+ }
+ return ValueObjectSP();
+ }
+
+ bool
+ Update() override
+ {
+ size_t old_count = m_len;
+
+ ConstString array_const_str("array");
+ ValueObjectSP array_sp = m_backend.GetChildMemberWithName(array_const_str, true);
+ if (!array_sp)
+ {
+ m_children.clear();
+ return old_count == 0;
+ }
+ m_type = array_sp->GetCompilerType().GetPointeeType();
+ m_base_data_address = array_sp->GetPointerValue();
+
+ ConstString len_const_str("len");
+ ValueObjectSP len_sp = m_backend.GetChildMemberWithName(len_const_str, true);
+ if (len_sp)
+ {
+ m_len = len_sp->GetValueAsUnsigned(0);
+ m_children.clear();
+ }
+
+ return old_count == m_len;
+ }
+
+ bool
+ MightHaveChildren() override
+ {
+ return true;
+ }
+
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override
+ {
+ return ExtractIndexFromString(name.AsCString());
+ }
+
+ private:
+ CompilerType m_type;
+ lldb::addr_t m_base_data_address;
+ size_t m_len;
+ std::map<size_t, lldb::ValueObjectSP> m_children;
+};
+
+} // anonymous namespace
+
+bool
+lldb_private::formatters::GoStringSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &opts)
+{
+ ProcessSP process_sp = valobj.GetProcessSP();
+ if (!process_sp)
+ return false;
+
+ if (valobj.IsPointerType())
+ {
+ Error err;
+ ValueObjectSP deref = valobj.Dereference(err);
+ if (!err.Success())
+ return false;
+ return GoStringSummaryProvider(*deref, stream, opts);
+ }
+
+ ConstString str_name("str");
+ ConstString len_name("len");
+
+ ValueObjectSP data_sp = valobj.GetChildMemberWithName(str_name, true);
+ ValueObjectSP len_sp = valobj.GetChildMemberWithName(len_name, true);
+ if (!data_sp || !len_sp)
+ return false;
+ bool success;
+ lldb::addr_t valobj_addr = data_sp->GetValueAsUnsigned(0, &success);
+
+ if (!success)
+ return false;
+
+ uint64_t length = len_sp->GetValueAsUnsigned(0);
+ if (length == 0)
+ {
+ stream.Printf("\"\"");
+ return true;
+ }
+
+ StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
+ options.SetLocation(valobj_addr);
+ options.SetProcessSP(process_sp);
+ options.SetStream(&stream);
+ options.SetSourceSize(length);
+ options.SetNeedsZeroTermination(false);
+ options.SetLanguage(eLanguageTypeGo);
+
+ if (!StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF8>(options))
+ {
+ stream.Printf("Summary Unavailable");
+ return true;
+ }
+
+ return true;
+}
+
+SyntheticChildrenFrontEnd *
+lldb_private::formatters::GoSliceSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp)
+{
+ if (!valobj_sp)
+ return nullptr;
+
+ lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
+ if (!process_sp)
+ return nullptr;
+ return new GoSliceSyntheticFrontEnd(*valobj_sp);
+}
diff --git a/source/Plugins/Language/Go/GoFormatterFunctions.h b/source/Plugins/Language/Go/GoFormatterFunctions.h
new file mode 100644
index 000000000000..ae1eda0f0c54
--- /dev/null
+++ b/source/Plugins/Language/Go/GoFormatterFunctions.h
@@ -0,0 +1,43 @@
+//===-- GoFormatterFunctions.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_GoFormatterFunctions_h_
+#define liblldb_GoFormatterFunctions_h_
+
+// C Includes
+#include <stdint.h>
+#include <time.h>
+
+// C++ Includes
+// Other libraries and framework includes
+#include "clang/AST/ASTContext.h"
+
+// Project includes
+#include "lldb/lldb-forward.h"
+
+#include "lldb/Core/ConstString.h"
+#include "lldb/DataFormatters/FormatClasses.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Target/Target.h"
+
+namespace lldb_private
+{
+namespace formatters
+{
+
+bool GoStringSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options);
+
+SyntheticChildrenFrontEnd *GoSliceSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP);
+
+} // namespace formatters
+} // namespace lldb_private
+
+#endif // liblldb_GoFormatterFunctions_h_
diff --git a/source/Plugins/Language/Go/GoLanguage.cpp b/source/Plugins/Language/Go/GoLanguage.cpp
new file mode 100644
index 000000000000..ed010ffa4b2e
--- /dev/null
+++ b/source/Plugins/Language/Go/GoLanguage.cpp
@@ -0,0 +1,146 @@
+//===-- GoLanguage.cpp ------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C Includes
+#include <string.h>
+// C++ Includes
+#include <functional>
+#include <mutex>
+
+// Other libraries and framework includes
+#include "llvm/ADT/StringRef.h"
+
+// Project includes
+#include "GoLanguage.h"
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/Symbol/GoASTContext.h"
+#include "Plugins/Language/Go/GoFormatterFunctions.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+void
+GoLanguage::Initialize()
+{
+ PluginManager::RegisterPlugin(GetPluginNameStatic(), "Go Language", CreateInstance);
+}
+
+void
+GoLanguage::Terminate()
+{
+ PluginManager::UnregisterPlugin(CreateInstance);
+}
+
+lldb_private::ConstString
+GoLanguage::GetPluginNameStatic()
+{
+ static ConstString g_name("Go");
+ return g_name;
+}
+
+//------------------------------------------------------------------
+// PluginInterface protocol
+//------------------------------------------------------------------
+lldb_private::ConstString
+GoLanguage::GetPluginName()
+{
+ return GetPluginNameStatic();
+}
+
+uint32_t
+GoLanguage::GetPluginVersion()
+{
+ return 1;
+}
+
+//------------------------------------------------------------------
+// Static Functions
+//------------------------------------------------------------------
+Language *
+GoLanguage::CreateInstance(lldb::LanguageType language)
+{
+ if (language == eLanguageTypeGo)
+ return new GoLanguage();
+ return nullptr;
+}
+
+HardcodedFormatters::HardcodedSummaryFinder
+GoLanguage::GetHardcodedSummaries()
+{
+ static std::once_flag g_initialize;
+ static HardcodedFormatters::HardcodedSummaryFinder g_formatters;
+
+ std::call_once(g_initialize, []() -> void
+ {
+ g_formatters.push_back(
+ [](lldb_private::ValueObject &valobj, lldb::DynamicValueType,
+ FormatManager &) -> TypeSummaryImpl::SharedPointer
+ {
+ static CXXFunctionSummaryFormat::SharedPointer formatter_sp(new CXXFunctionSummaryFormat(
+ TypeSummaryImpl::Flags().SetDontShowChildren(true),
+ lldb_private::formatters::GoStringSummaryProvider, "Go string summary provider"));
+ if (GoASTContext::IsGoString(valobj.GetCompilerType()))
+ {
+ return formatter_sp;
+ }
+ if (GoASTContext::IsGoString(valobj.GetCompilerType().GetPointeeType()))
+ {
+ return formatter_sp;
+ }
+ return nullptr;
+ });
+ g_formatters.push_back(
+ [](lldb_private::ValueObject &valobj, lldb::DynamicValueType,
+ FormatManager &) -> TypeSummaryImpl::SharedPointer
+ {
+ static lldb::TypeSummaryImplSP formatter_sp(
+ new StringSummaryFormat(TypeSummaryImpl::Flags().SetHideItemNames(true),
+ "(len ${var.len}, cap ${var.cap})"));
+ if (GoASTContext::IsGoSlice(valobj.GetCompilerType()))
+ {
+ return formatter_sp;
+ }
+ if (GoASTContext::IsGoSlice(valobj.GetCompilerType().GetPointeeType()))
+ {
+ return formatter_sp;
+ }
+ return nullptr;
+ });
+ });
+ return g_formatters;
+}
+
+HardcodedFormatters::HardcodedSyntheticFinder
+GoLanguage::GetHardcodedSynthetics()
+{
+ static std::once_flag g_initialize;
+ static HardcodedFormatters::HardcodedSyntheticFinder g_formatters;
+
+ std::call_once(g_initialize, []() -> void
+ {
+ g_formatters.push_back(
+ [](lldb_private::ValueObject &valobj, lldb::DynamicValueType,
+ FormatManager &fmt_mgr) -> SyntheticChildren::SharedPointer
+ {
+ static CXXSyntheticChildren::SharedPointer formatter_sp(
+ new CXXSyntheticChildren(SyntheticChildren::Flags(), "slice synthetic children",
+ lldb_private::formatters::GoSliceSyntheticFrontEndCreator));
+ if (GoASTContext::IsGoSlice(valobj.GetCompilerType()))
+ {
+ return formatter_sp;
+ }
+ return nullptr;
+ });
+ });
+
+ return g_formatters;
+}
diff --git a/source/Plugins/Language/Go/GoLanguage.h b/source/Plugins/Language/Go/GoLanguage.h
new file mode 100644
index 000000000000..67dd04c2a22e
--- /dev/null
+++ b/source/Plugins/Language/Go/GoLanguage.h
@@ -0,0 +1,66 @@
+//===-- GoLanguage.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_GoLanguage_h_
+#define liblldb_GoLanguage_h_
+
+// C Includes
+// C++ Includes
+#include <vector>
+
+// Other libraries and framework includes
+#include "llvm/ADT/StringRef.h"
+
+// Project includes
+#include "lldb/lldb-private.h"
+#include "lldb/Core/ConstString.h"
+#include "lldb/Target/Language.h"
+
+namespace lldb_private
+{
+
+class GoLanguage : public Language
+{
+ public:
+ GoLanguage() = default;
+
+ ~GoLanguage() override = default;
+
+ lldb::LanguageType
+ GetLanguageType() const override
+ {
+ return lldb::eLanguageTypeGo;
+ }
+
+ HardcodedFormatters::HardcodedSummaryFinder GetHardcodedSummaries() override;
+
+ HardcodedFormatters::HardcodedSyntheticFinder GetHardcodedSynthetics() override;
+
+ //------------------------------------------------------------------
+ // Static Functions
+ //------------------------------------------------------------------
+ static void Initialize();
+
+ static void Terminate();
+
+ static lldb_private::Language *CreateInstance(lldb::LanguageType language);
+
+ static lldb_private::ConstString GetPluginNameStatic();
+
+ //------------------------------------------------------------------
+ // PluginInterface protocol
+ //------------------------------------------------------------------
+ ConstString GetPluginName() override;
+
+ uint32_t GetPluginVersion() override;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_GoLanguage_h_
diff --git a/source/DataFormatters/CF.cpp b/source/Plugins/Language/ObjC/CF.cpp
index 6ab9013268bd..614eb29a0f7a 100644
--- a/source/DataFormatters/CF.cpp
+++ b/source/Plugins/Language/ObjC/CF.cpp
@@ -7,16 +7,19 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/DataFormatters/CXXFormatterFunctions.h"
+#include "CF.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Host/Endian.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"
using namespace lldb;
@@ -41,6 +44,8 @@ lldb_private::formatters::CFAbsoluteTimeSummaryProvider (ValueObject& valobj, St
bool
lldb_private::formatters::CFBagSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
{
+ static ConstString g_TypeHint("CFBag");
+
ProcessSP process_sp = valobj.GetProcessSP();
if (!process_sp)
return false;
@@ -83,7 +88,9 @@ lldb_private::formatters::CFBagSummaryProvider (ValueObject& valobj, Stream& str
ValueObjectSP count_sp;
StreamString expr;
expr.Printf("(int)CFBagGetCount((void*)0x%" PRIx64 ")",valobj.GetPointerValue());
- if (process_sp->GetTarget().EvaluateExpression(expr.GetData(), frame_sp.get(), count_sp) != eExpressionCompleted)
+ EvaluateExpressionOptions options;
+ options.SetResultIsInternal(true);
+ if (process_sp->GetTarget().EvaluateExpression(expr.GetData(), frame_sp.get(), count_sp, options) != eExpressionCompleted)
return false;
if (!count_sp)
return false;
@@ -97,8 +104,21 @@ lldb_private::formatters::CFBagSummaryProvider (ValueObject& valobj, Stream& str
if (error.Fail())
return false;
}
- stream.Printf("@\"%u value%s\"",
- count,(count == 1 ? "" : "s"));
+
+ std::string prefix,suffix;
+ if (Language* language = Language::FindPlugin(options.GetLanguage()))
+ {
+ if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix, suffix))
+ {
+ prefix.clear();
+ suffix.clear();
+ }
+ }
+
+ stream.Printf("%s\"%u value%s\"%s",
+ prefix.c_str(),
+ count,(count == 1 ? "" : "s"),
+ suffix.c_str());
return true;
}
@@ -235,6 +255,8 @@ lldb_private::formatters::CFBitVectorSummaryProvider (ValueObject& valobj, Strea
bool
lldb_private::formatters::CFBinaryHeapSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
{
+ static ConstString g_TypeHint("CFBinaryHeap");
+
ProcessSP process_sp = valobj.GetProcessSP();
if (!process_sp)
return false;
@@ -277,7 +299,9 @@ lldb_private::formatters::CFBinaryHeapSummaryProvider (ValueObject& valobj, Stre
ValueObjectSP count_sp;
StreamString expr;
expr.Printf("(int)CFBinaryHeapGetCount((void*)0x%" PRIx64 ")",valobj.GetPointerValue());
- if (process_sp->GetTarget().EvaluateExpression(expr.GetData(), frame_sp.get(), count_sp) != eExpressionCompleted)
+ EvaluateExpressionOptions options;
+ options.SetResultIsInternal(true);
+ if (process_sp->GetTarget().EvaluateExpression(expr.GetData(), frame_sp.get(), count_sp, options) != eExpressionCompleted)
return false;
if (!count_sp)
return false;
@@ -291,7 +315,20 @@ lldb_private::formatters::CFBinaryHeapSummaryProvider (ValueObject& valobj, Stre
if (error.Fail())
return false;
}
- stream.Printf("@\"%u item%s\"",
- count,(count == 1 ? "" : "s"));
+
+ std::string prefix,suffix;
+ if (Language* language = Language::FindPlugin(options.GetLanguage()))
+ {
+ if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix, suffix))
+ {
+ prefix.clear();
+ suffix.clear();
+ }
+ }
+
+ stream.Printf("%s\"%u item%s\"%s",
+ prefix.c_str(),
+ count,(count == 1 ? "" : "s"),
+ suffix.c_str());
return true;
}
diff --git a/source/Plugins/Language/ObjC/CF.h b/source/Plugins/Language/ObjC/CF.h
new file mode 100644
index 000000000000..4044f09f585e
--- /dev/null
+++ b/source/Plugins/Language/ObjC/CF.h
@@ -0,0 +1,34 @@
+//===-- CF.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_CF_h_
+#define liblldb_CF_h_
+
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/TypeSummary.h"
+
+namespace lldb_private {
+ namespace formatters
+ {
+ bool
+ CFBagSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ bool
+ CFBinaryHeapSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ bool
+ CFBitVectorSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ bool
+ CFAbsoluteTimeSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+ } // namespace formatters
+} // namespace lldb_private
+
+#endif // liblldb_CF_h_
diff --git a/source/DataFormatters/Cocoa.cpp b/source/Plugins/Language/ObjC/Cocoa.cpp
index 28f3d4f1d41b..aa6e476b6131 100644
--- a/source/DataFormatters/Cocoa.cpp
+++ b/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -1,4 +1,4 @@
-//===-- Cocoa.cpp -------------------------------------------------*- C++ -*-===//
+//===-- Cocoa.cpp -----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,17 +7,30 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/DataFormatters/CXXFormatterFunctions.h"
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "Cocoa.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Error.h"
+#include "lldb/Core/Mangled.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/DataFormatters/StringPrinter.h"
+#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Target/Language.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Utility/ProcessStructReader.h"
+
+#include "NSString.h"
using namespace lldb;
using namespace lldb_private;
@@ -55,8 +68,8 @@ lldb_private::formatters::NSBundleSummaryProvider (ValueObject& valobj, Stream&
if (!strcmp(class_name,"NSBundle"))
{
uint64_t offset = 5 * ptr_size;
- ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset, valobj.GetClangType().GetBasicTypeFromAST(lldb::eBasicTypeObjCID), true));
-
+ ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset, valobj.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeObjCID), true));
+
StreamString summary_stream;
bool was_nsstring_ok = NSStringSummaryProvider(*text.get(), summary_stream, options);
if (was_nsstring_ok && summary_stream.GetSize() > 0)
@@ -67,7 +80,7 @@ lldb_private::formatters::NSBundleSummaryProvider (ValueObject& valobj, Stream&
}
// this is either an unknown subclass or an NSBundle that comes from [NSBundle mainBundle]
// which is encoded differently and needs to be handled by running code
- return ExtractSummaryFromObjCExpression(valobj, "NSString*", "bundlePath", stream);
+ return ExtractSummaryFromObjCExpression(valobj, "NSString*", "bundlePath", stream, options.GetLanguage());
}
bool
@@ -102,7 +115,7 @@ lldb_private::formatters::NSTimeZoneSummaryProvider (ValueObject& valobj, Stream
if (!strcmp(class_name,"__NSTimeZone"))
{
uint64_t offset = ptr_size;
- ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset, valobj.GetClangType(), true));
+ ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset, valobj.GetCompilerType(), true));
StreamString summary_stream;
bool was_nsstring_ok = NSStringSummaryProvider(*text.get(), summary_stream, options);
if (was_nsstring_ok && summary_stream.GetSize() > 0)
@@ -111,7 +124,7 @@ lldb_private::formatters::NSTimeZoneSummaryProvider (ValueObject& valobj, Stream
return true;
}
}
- return ExtractSummaryFromObjCExpression(valobj, "NSString*", "name", stream);
+ return ExtractSummaryFromObjCExpression(valobj, "NSString*", "name", stream, options.GetLanguage());
}
bool
@@ -146,7 +159,7 @@ lldb_private::formatters::NSNotificationSummaryProvider (ValueObject& valobj, St
if (!strcmp(class_name,"NSConcreteNotification"))
{
uint64_t offset = ptr_size;
- ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset, valobj.GetClangType(), true));
+ ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset, valobj.GetCompilerType(), true));
StreamString summary_stream;
bool was_nsstring_ok = NSStringSummaryProvider(*text.get(), summary_stream, options);
if (was_nsstring_ok && summary_stream.GetSize() > 0)
@@ -157,7 +170,7 @@ lldb_private::formatters::NSNotificationSummaryProvider (ValueObject& valobj, St
}
// this is either an unknown subclass or an NSBundle that comes from [NSBundle mainBundle]
// which is encoded differently and needs to be handled by running code
- return ExtractSummaryFromObjCExpression(valobj, "NSString*", "name", stream);
+ return ExtractSummaryFromObjCExpression(valobj, "NSString*", "name", stream, options.GetLanguage());
}
bool
@@ -287,6 +300,150 @@ lldb_private::formatters::NSIndexSetSummaryProvider (ValueObject& valobj, Stream
return true;
}
+static void
+NSNumber_FormatChar (ValueObject& valobj,
+ Stream& stream,
+ char value,
+ lldb::LanguageType lang)
+{
+ static ConstString g_TypeHint("NSNumber:char");
+
+ std::string prefix,suffix;
+ if (Language* language = Language::FindPlugin(lang))
+ {
+ if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix, suffix))
+ {
+ prefix.clear();
+ suffix.clear();
+ }
+ }
+
+ stream.Printf("%s%hhd%s",
+ prefix.c_str(),
+ value,
+ suffix.c_str());
+}
+
+static void
+NSNumber_FormatShort (ValueObject& valobj,
+ Stream& stream,
+ short value,
+ lldb::LanguageType lang)
+{
+ static ConstString g_TypeHint("NSNumber:short");
+
+ std::string prefix,suffix;
+ if (Language* language = Language::FindPlugin(lang))
+ {
+ if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix, suffix))
+ {
+ prefix.clear();
+ suffix.clear();
+ }
+ }
+
+ stream.Printf("%s%hd%s",
+ prefix.c_str(),
+ value,
+ suffix.c_str());
+}
+
+static void
+NSNumber_FormatInt (ValueObject& valobj,
+ Stream& stream,
+ int value,
+ lldb::LanguageType lang)
+{
+ static ConstString g_TypeHint("NSNumber:int");
+
+ std::string prefix,suffix;
+ if (Language* language = Language::FindPlugin(lang))
+ {
+ if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix, suffix))
+ {
+ prefix.clear();
+ suffix.clear();
+ }
+ }
+
+ stream.Printf("%s%d%s",
+ prefix.c_str(),
+ value,
+ suffix.c_str());
+}
+
+static void
+NSNumber_FormatLong (ValueObject& valobj,
+ Stream& stream,
+ uint64_t value,
+ lldb::LanguageType lang)
+{
+ static ConstString g_TypeHint("NSNumber:long");
+
+ std::string prefix,suffix;
+ if (Language* language = Language::FindPlugin(lang))
+ {
+ if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix, suffix))
+ {
+ prefix.clear();
+ suffix.clear();
+ }
+ }
+
+ stream.Printf("%s%" PRId64 "%s",
+ prefix.c_str(),
+ value,
+ suffix.c_str());
+}
+
+static void
+NSNumber_FormatFloat (ValueObject& valobj,
+ Stream& stream,
+ float value,
+ lldb::LanguageType lang)
+{
+ static ConstString g_TypeHint("NSNumber:float");
+
+ std::string prefix,suffix;
+ if (Language* language = Language::FindPlugin(lang))
+ {
+ if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix, suffix))
+ {
+ prefix.clear();
+ suffix.clear();
+ }
+ }
+
+ stream.Printf("%s%f%s",
+ prefix.c_str(),
+ value,
+ suffix.c_str());
+}
+
+static void
+NSNumber_FormatDouble (ValueObject& valobj,
+ Stream& stream,
+ double value,
+ lldb::LanguageType lang)
+{
+ static ConstString g_TypeHint("NSNumber:double");
+
+ std::string prefix,suffix;
+ if (Language* language = Language::FindPlugin(lang))
+ {
+ if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix, suffix))
+ {
+ prefix.clear();
+ suffix.clear();
+ }
+ }
+
+ stream.Printf("%s%g%s",
+ prefix.c_str(),
+ value,
+ suffix.c_str());
+}
+
bool
lldb_private::formatters::NSNumberSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
{
@@ -325,19 +482,19 @@ lldb_private::formatters::NSNumberSummaryProvider (ValueObject& valobj, Stream&
switch (i_bits)
{
case 0:
- stream.Printf("(char)%hhd",(char)value);
+ NSNumber_FormatChar(valobj, stream, (char)value, options.GetLanguage());
break;
case 1:
case 4:
- stream.Printf("(short)%hd",(short)value);
+ NSNumber_FormatShort(valobj, stream, (short)value, options.GetLanguage());
break;
case 2:
case 8:
- stream.Printf("(int)%d",(int)value);
+ NSNumber_FormatInt(valobj, stream, (int)value, options.GetLanguage());
break;
case 3:
case 12:
- stream.Printf("(long)%" PRId64,value);
+ NSNumber_FormatLong(valobj, stream, value, options.GetLanguage());
break;
default:
return false;
@@ -358,19 +515,19 @@ lldb_private::formatters::NSNumberSummaryProvider (ValueObject& valobj, Stream&
value = process_sp->ReadUnsignedIntegerFromMemory(data_location, 1, 0, error);
if (error.Fail())
return false;
- stream.Printf("(char)%hhd",(char)value);
+ NSNumber_FormatChar(valobj, stream, (char)value, options.GetLanguage());
break;
case 2: // 0B0010
value = process_sp->ReadUnsignedIntegerFromMemory(data_location, 2, 0, error);
if (error.Fail())
return false;
- stream.Printf("(short)%hd",(short)value);
+ NSNumber_FormatShort(valobj, stream, (short)value, options.GetLanguage());
break;
case 3: // 0B0011
value = process_sp->ReadUnsignedIntegerFromMemory(data_location, 4, 0, error);
if (error.Fail())
return false;
- stream.Printf("(int)%d",(int)value);
+ NSNumber_FormatInt(valobj, stream, (int)value, options.GetLanguage());
break;
case 17: // 0B10001
data_location += 8;
@@ -378,7 +535,7 @@ lldb_private::formatters::NSNumberSummaryProvider (ValueObject& valobj, Stream&
value = process_sp->ReadUnsignedIntegerFromMemory(data_location, 8, 0, error);
if (error.Fail())
return false;
- stream.Printf("(long)%" PRId64,value);
+ NSNumber_FormatLong(valobj, stream, value, options.GetLanguage());
break;
case 5: // 0B0101
{
@@ -386,7 +543,7 @@ lldb_private::formatters::NSNumberSummaryProvider (ValueObject& valobj, Stream&
if (error.Fail())
return false;
float flt_value = *((float*)&flt_as_int);
- stream.Printf("(float)%f",flt_value);
+ NSNumber_FormatFloat(valobj, stream, flt_value, options.GetLanguage());
break;
}
case 6: // 0B0110
@@ -395,7 +552,7 @@ lldb_private::formatters::NSNumberSummaryProvider (ValueObject& valobj, Stream&
if (error.Fail())
return false;
double dbl_value = *((double*)&dbl_as_lng);
- stream.Printf("(double)%g",dbl_value);
+ NSNumber_FormatDouble(valobj, stream, dbl_value, options.GetLanguage());
break;
}
default:
@@ -406,7 +563,7 @@ lldb_private::formatters::NSNumberSummaryProvider (ValueObject& valobj, Stream&
}
else
{
- return ExtractSummaryFromObjCExpression(valobj, "NSString*", "stringValue", stream);
+ return ExtractSummaryFromObjCExpression(valobj, "NSString*", "stringValue", stream, options.GetLanguage());
}
}
@@ -443,7 +600,7 @@ lldb_private::formatters::NSURLSummaryProvider (ValueObject& valobj, Stream& str
{
uint64_t offset_text = ptr_size + ptr_size + 8; // ISA + pointer + 8 bytes of data (even on 32bit)
uint64_t offset_base = offset_text + ptr_size;
- ClangASTType type(valobj.GetClangType());
+ CompilerType type(valobj.GetCompilerType());
ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset_text, type, true));
ValueObjectSP base(valobj.GetSyntheticChildAtOffset(offset_base, type, true));
if (!text)
@@ -470,7 +627,7 @@ lldb_private::formatters::NSURLSummaryProvider (ValueObject& valobj, Stream& str
}
else
{
- return ExtractSummaryFromObjCExpression(valobj, "NSString*", "description", stream);
+ return ExtractSummaryFromObjCExpression(valobj, "NSString*", "description", stream, options.GetLanguage());
}
return false;
}
@@ -559,3 +716,252 @@ lldb_private::formatters::NSDateSummaryProvider (ValueObject& valobj, Stream& st
stream.Printf("%04d-%02d-%02d %02d:%02d:%02d %s", tm_date->tm_year+1900, tm_date->tm_mon+1, tm_date->tm_mday, tm_date->tm_hour, tm_date->tm_min, tm_date->tm_sec, buffer.c_str());
return true;
}
+
+bool
+lldb_private::formatters::ObjCClassSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
+{
+ ProcessSP process_sp = valobj.GetProcessSP();
+ if (!process_sp)
+ return false;
+
+ ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
+
+ if (!runtime)
+ return false;
+
+ ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptorFromISA(valobj.GetValueAsUnsigned(0)));
+
+ if (!descriptor.get() || !descriptor->IsValid())
+ return false;
+
+ ConstString class_name = descriptor->GetClassName();
+
+ if (class_name.IsEmpty())
+ return false;
+
+ if (ConstString cs = Mangled(class_name).GetDemangledName(lldb::eLanguageTypeUnknown))
+ class_name = cs;
+
+ stream.Printf("%s",class_name.AsCString("<unknown class>"));
+ return true;
+}
+
+class ObjCClassSyntheticChildrenFrontEnd : public SyntheticChildrenFrontEnd
+{
+public:
+ ObjCClassSyntheticChildrenFrontEnd (lldb::ValueObjectSP valobj_sp) :
+ SyntheticChildrenFrontEnd(*valobj_sp.get())
+ {
+ }
+
+ ~ObjCClassSyntheticChildrenFrontEnd() override = default;
+
+ size_t
+ CalculateNumChildren() override
+ {
+ return 0;
+ }
+
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override
+ {
+ return lldb::ValueObjectSP();
+ }
+
+ bool
+ Update() override
+ {
+ return false;
+ }
+
+ bool
+ MightHaveChildren() override
+ {
+ return false;
+ }
+
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override
+ {
+ return UINT32_MAX;
+ }
+};
+
+SyntheticChildrenFrontEnd*
+lldb_private::formatters::ObjCClassSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
+{
+ return new ObjCClassSyntheticChildrenFrontEnd(valobj_sp);
+}
+
+template<bool needs_at>
+bool
+lldb_private::formatters::NSDataSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
+{
+ ProcessSP process_sp = valobj.GetProcessSP();
+ if (!process_sp)
+ return false;
+
+ ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
+
+ if (!runtime)
+ return false;
+
+ ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
+
+ if (!descriptor.get() || !descriptor->IsValid())
+ return false;
+
+ bool is_64bit = (process_sp->GetAddressByteSize() == 8);
+ lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
+
+ if (!valobj_addr)
+ return false;
+
+ uint64_t value = 0;
+
+ const char* class_name = descriptor->GetClassName().GetCString();
+
+ if (!class_name || !*class_name)
+ return false;
+
+ if (!strcmp(class_name,"NSConcreteData") ||
+ !strcmp(class_name,"NSConcreteMutableData") ||
+ !strcmp(class_name,"__NSCFData"))
+ {
+ uint32_t offset = (is_64bit ? 16 : 8);
+ Error error;
+ value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + offset, is_64bit ? 8 : 4, 0, error);
+ if (error.Fail())
+ return false;
+ }
+ else
+ {
+ if (!ExtractValueFromObjCExpression(valobj, "int", "length", value))
+ return false;
+ }
+
+ stream.Printf("%s%" PRIu64 " byte%s%s",
+ (needs_at ? "@\"" : ""),
+ value,
+ (value != 1 ? "s" : ""),
+ (needs_at ? "\"" : ""));
+
+ return true;
+}
+
+bool
+lldb_private::formatters::ObjCBOOLSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
+{
+ const uint32_t type_info = valobj.GetCompilerType().GetTypeInfo();
+
+ ValueObjectSP real_guy_sp = valobj.GetSP();
+
+ if (type_info & eTypeIsPointer)
+ {
+ Error err;
+ real_guy_sp = valobj.Dereference(err);
+ if (err.Fail() || !real_guy_sp)
+ return false;
+ }
+ else if (type_info & eTypeIsReference)
+ {
+ real_guy_sp = valobj.GetChildAtIndex(0, true);
+ if (!real_guy_sp)
+ return false;
+ }
+ uint64_t value = real_guy_sp->GetValueAsUnsigned(0);
+ if (value == 0)
+ {
+ stream.Printf("NO");
+ return true;
+ }
+ stream.Printf("YES");
+ return true;
+}
+
+template <bool is_sel_ptr>
+bool
+lldb_private::formatters::ObjCSELSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
+{
+ lldb::ValueObjectSP valobj_sp;
+
+ CompilerType charstar (valobj.GetCompilerType().GetBasicTypeFromAST(eBasicTypeChar).GetPointerType());
+
+ if (!charstar)
+ return false;
+
+ ExecutionContext exe_ctx(valobj.GetExecutionContextRef());
+
+ if (is_sel_ptr)
+ {
+ lldb::addr_t data_address = valobj.GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
+ if (data_address == LLDB_INVALID_ADDRESS)
+ return false;
+ valobj_sp = ValueObject::CreateValueObjectFromAddress("text", data_address, exe_ctx, charstar);
+ }
+ else
+ {
+ DataExtractor data;
+ Error error;
+ valobj.GetData(data, error);
+ if (error.Fail())
+ return false;
+ valobj_sp = ValueObject::CreateValueObjectFromData("text", data, exe_ctx, charstar);
+ }
+
+ if (!valobj_sp)
+ return false;
+
+ stream.Printf("%s",valobj_sp->GetSummaryAsCString());
+ return true;
+}
+
+// POSIX has an epoch on Jan-1-1970, but Cocoa prefers Jan-1-2001
+// this call gives the POSIX equivalent of the Cocoa epoch
+time_t
+lldb_private::formatters::GetOSXEpoch ()
+{
+ static time_t epoch = 0;
+ if (!epoch)
+ {
+#ifndef _WIN32
+ tzset();
+ tm tm_epoch;
+ tm_epoch.tm_sec = 0;
+ tm_epoch.tm_hour = 0;
+ tm_epoch.tm_min = 0;
+ tm_epoch.tm_mon = 0;
+ tm_epoch.tm_mday = 1;
+ tm_epoch.tm_year = 2001-1900; // for some reason, we need to subtract 1900 from this field. not sure why.
+ tm_epoch.tm_isdst = -1;
+ tm_epoch.tm_gmtoff = 0;
+ tm_epoch.tm_zone = NULL;
+ epoch = timegm(&tm_epoch);
+#endif
+ }
+ return epoch;
+}
+
+bool
+lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
+{
+ if (const char* description = valobj.GetObjectDescription())
+ {
+ stream.Printf("%s", description);
+ return true;
+ }
+ else
+ return false;
+}
+
+template bool
+lldb_private::formatters::NSDataSummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&);
+
+template bool
+lldb_private::formatters::NSDataSummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&);
+
+template bool
+lldb_private::formatters::ObjCSELSummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&);
+
+template bool
+lldb_private::formatters::ObjCSELSummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&);
diff --git a/source/Plugins/Language/ObjC/Cocoa.h b/source/Plugins/Language/ObjC/Cocoa.h
new file mode 100644
index 000000000000..0caacf3453d4
--- /dev/null
+++ b/source/Plugins/Language/ObjC/Cocoa.h
@@ -0,0 +1,97 @@
+//===-- Cocoa.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_Cocoa_h_
+#define liblldb_Cocoa_h_
+
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
+
+namespace lldb_private {
+ namespace formatters
+ {
+ bool
+ NSIndexSetSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ bool
+ NSArraySummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ template<bool needs_at>
+ bool
+ NSDataSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ bool
+ NSNumberSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ bool
+ NSNotificationSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ bool
+ NSTimeZoneSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ bool
+ NSMachPortSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ bool
+ NSDateSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ bool
+ NSBundleSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ bool
+ NSURLSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ extern template bool
+ NSDataSummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&) ;
+
+ extern template bool
+ NSDataSummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&) ;
+
+ SyntheticChildrenFrontEnd* NSArraySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
+
+ SyntheticChildrenFrontEnd* NSIndexPathSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
+
+ bool
+ ObjCClassSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ SyntheticChildrenFrontEnd* ObjCClassSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
+
+ bool
+ ObjCBOOLSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ template <bool is_sel_ptr>
+ bool
+ ObjCSELSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ extern template bool
+ ObjCSELSummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&);
+
+ extern template bool
+ ObjCSELSummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&);
+
+ bool
+ RuntimeSpecificDescriptionSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ bool
+ NSError_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ bool
+ NSException_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ SyntheticChildrenFrontEnd*
+ NSErrorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp);
+
+ SyntheticChildrenFrontEnd*
+ NSExceptionSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp);
+ } // namespace formatters
+} // namespace lldb_private
+
+#endif // liblldb_Cocoa_h_
diff --git a/source/DataFormatters/CoreMedia.cpp b/source/Plugins/Language/ObjC/CoreMedia.cpp
index 5c33c0b69f72..4103067b8d58 100644
--- a/source/DataFormatters/CoreMedia.cpp
+++ b/source/Plugins/Language/ObjC/CoreMedia.cpp
@@ -7,11 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/DataFormatters/CXXFormatterFunctions.h"
+#include "CoreMedia.h"
#include "lldb/Core/Flags.h"
-#include "lldb/Symbol/ClangASTContext.h"
-
+#include "lldb/Symbol/TypeSystem.h"
+#include "lldb/Target/Target.h"
#include <inttypes.h>
using namespace lldb;
@@ -21,13 +21,17 @@ using namespace lldb_private::formatters;
bool
lldb_private::formatters::CMTimeSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
{
- ClangASTContext *ast_ctx = ClangASTContext::GetASTContext(valobj.GetClangType().GetASTContext());
- if (!ast_ctx)
+ CompilerType type = valobj.GetCompilerType();
+ if (!type.IsValid())
+ return false;
+
+ TypeSystem *type_system = valobj.GetExecutionContextRef().GetTargetSP()->GetScratchTypeSystemForLanguage(nullptr, lldb::eLanguageTypeC);
+ if (!type_system)
return false;
// fetch children by offset to compensate for potential lack of debug info
- auto int64_ty = ast_ctx->GetIntTypeFromBitSize(64, true);
- auto int32_ty = ast_ctx->GetIntTypeFromBitSize(32, true);
+ auto int64_ty = type_system->GetBuiltinTypeForEncodingAndBitSize(eEncodingSint, 64);
+ auto int32_ty = type_system->GetBuiltinTypeForEncodingAndBitSize(eEncodingSint, 32);
auto value_sp(valobj.GetSyntheticChildAtOffset(0, int64_ty, true));
auto timescale_sp(valobj.GetSyntheticChildAtOffset(8, int32_ty, true));
diff --git a/source/Plugins/Language/ObjC/CoreMedia.h b/source/Plugins/Language/ObjC/CoreMedia.h
new file mode 100644
index 000000000000..2ffabaadccf5
--- /dev/null
+++ b/source/Plugins/Language/ObjC/CoreMedia.h
@@ -0,0 +1,26 @@
+//===-- CoreMedia.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_CoreMedia_h_
+#define liblldb_CoreMedia_h_
+
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/TypeSummary.h"
+
+namespace lldb_private {
+ namespace formatters
+ {
+
+ bool
+ CMTimeSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+ } // namespace formatters
+} // namespace lldb_private
+
+#endif // liblldb_CF_h_
diff --git a/source/DataFormatters/NSArray.cpp b/source/Plugins/Language/ObjC/NSArray.cpp
index 640982efdb3c..ccc82ab95ecc 100644
--- a/source/DataFormatters/NSArray.cpp
+++ b/source/Plugins/Language/ObjC/NSArray.cpp
@@ -7,21 +7,28 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/DataFormatters/CXXFormatterFunctions.h"
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+#include "clang/AST/ASTContext.h"
+
+// Project includes
+#include "Cocoa.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Target/Language.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
#include "lldb/Target/Target.h"
-#include "clang/AST/ASTContext.h"
-
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
@@ -32,24 +39,23 @@ namespace lldb_private {
{
public:
NSArrayMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+
+ ~NSArrayMSyntheticFrontEnd() override = default;
+
+ size_t
+ CalculateNumChildren() override;
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update() = 0;
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
- virtual bool
- MightHaveChildren ();
+ bool
+ Update() override = 0;
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
+ bool
+ MightHaveChildren() override;
- virtual
- ~NSArrayMSyntheticFrontEnd () {}
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
protected:
virtual lldb::addr_t
@@ -66,12 +72,33 @@ namespace lldb_private {
ExecutionContextRef m_exe_ctx_ref;
uint8_t m_ptr_size;
- ClangASTType m_id_type;
+ CompilerType m_id_type;
std::vector<lldb::ValueObjectSP> m_children;
};
class NSArrayMSyntheticFrontEnd_109 : public NSArrayMSyntheticFrontEnd
{
+ public:
+ NSArrayMSyntheticFrontEnd_109 (lldb::ValueObjectSP valobj_sp);
+
+ ~NSArrayMSyntheticFrontEnd_109() override;
+
+ bool
+ Update() override;
+
+ protected:
+ lldb::addr_t
+ GetDataAddress() override;
+
+ uint64_t
+ GetUsedCount() override;
+
+ uint64_t
+ GetOffset() override;
+
+ uint64_t
+ GetSize() override;
+
private:
struct DataDescriptor_32
{
@@ -83,6 +110,7 @@ namespace lldb_private {
uint32_t _priv3;
uint32_t _data;
};
+
struct DataDescriptor_64
{
uint64_t _used;
@@ -93,36 +121,35 @@ namespace lldb_private {
uint32_t _priv3;
uint64_t _data;
};
+
+ DataDescriptor_32 *m_data_32;
+ DataDescriptor_64 *m_data_64;
+ };
+
+ class NSArrayMSyntheticFrontEnd_1010 : public NSArrayMSyntheticFrontEnd
+ {
public:
- NSArrayMSyntheticFrontEnd_109 (lldb::ValueObjectSP valobj_sp);
-
- virtual bool
- Update();
-
- virtual
- ~NSArrayMSyntheticFrontEnd_109 ();
+ NSArrayMSyntheticFrontEnd_1010 (lldb::ValueObjectSP valobj_sp);
+
+ ~NSArrayMSyntheticFrontEnd_1010() override;
+
+ bool
+ Update() override;
protected:
- virtual lldb::addr_t
- GetDataAddress ();
+ lldb::addr_t
+ GetDataAddress() override;
- virtual uint64_t
- GetUsedCount ();
+ uint64_t
+ GetUsedCount() override;
- virtual uint64_t
- GetOffset ();
+ uint64_t
+ GetOffset() override;
- virtual uint64_t
- GetSize ();
+ uint64_t
+ GetSize() override;
private:
- DataDescriptor_32 *m_data_32;
- DataDescriptor_64 *m_data_64;
- };
-
- class NSArrayMSyntheticFrontEnd_1010 : public NSArrayMSyntheticFrontEnd
- {
- private:
struct DataDescriptor_32
{
uint32_t _used;
@@ -132,6 +159,7 @@ namespace lldb_private {
uint32_t _priv2;
uint32_t _data;
};
+
struct DataDescriptor_64
{
uint64_t _used;
@@ -141,29 +169,7 @@ namespace lldb_private {
uint32_t _priv2;
uint64_t _data;
};
- public:
- NSArrayMSyntheticFrontEnd_1010 (lldb::ValueObjectSP valobj_sp);
-
- virtual bool
- Update();
-
- virtual
- ~NSArrayMSyntheticFrontEnd_1010 ();
-
- protected:
- virtual lldb::addr_t
- GetDataAddress ();
-
- virtual uint64_t
- GetUsedCount ();
-
- virtual uint64_t
- GetOffset ();
-
- virtual uint64_t
- GetSize ();
-
- private:
+
DataDescriptor_32 *m_data_32;
DataDescriptor_64 *m_data_64;
};
@@ -172,62 +178,86 @@ namespace lldb_private {
{
public:
NSArrayISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+
+ ~NSArrayISyntheticFrontEnd() override = default;
+
+ size_t
+ CalculateNumChildren() override;
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
- virtual bool
- MightHaveChildren ();
+ bool
+ Update() override;
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
+ bool
+ MightHaveChildren() override;
- virtual
- ~NSArrayISyntheticFrontEnd ();
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
+
private:
ExecutionContextRef m_exe_ctx_ref;
uint8_t m_ptr_size;
uint64_t m_items;
lldb::addr_t m_data_ptr;
- ClangASTType m_id_type;
+ CompilerType m_id_type;
std::vector<lldb::ValueObjectSP> m_children;
};
- class NSArrayCodeRunningSyntheticFrontEnd : public SyntheticChildrenFrontEnd
+ class NSArray0SyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
public:
- NSArrayCodeRunningSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+ NSArray0SyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+
+ ~NSArray0SyntheticFrontEnd() override = default;
+
+ size_t
+ CalculateNumChildren() override;
- virtual size_t
- CalculateNumChildren ();
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
+ bool
+ Update() override;
- virtual bool
- Update();
+ bool
+ MightHaveChildren() override;
- virtual bool
- MightHaveChildren ();
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
+ };
+
+ class NSArrayCodeRunningSyntheticFrontEnd : public SyntheticChildrenFrontEnd
+ {
+ public:
+ NSArrayCodeRunningSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+
+ ~NSArrayCodeRunningSyntheticFrontEnd() override = default;
+
+ size_t
+ CalculateNumChildren() override;
+
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
+
+ bool
+ Update() override;
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
+ bool
+ MightHaveChildren() override;
- virtual
- ~NSArrayCodeRunningSyntheticFrontEnd ();
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
};
- }
-}
+ } // namespace formatters
+} // namespace lldb_private
bool
lldb_private::formatters::NSArraySummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
{
+ static ConstString g_TypeHint("NSArray");
+
ProcessSP process_sp = valobj.GetProcessSP();
if (!process_sp)
return false;
@@ -270,6 +300,10 @@ lldb_private::formatters::NSArraySummaryProvider (ValueObject& valobj, Stream& s
if (error.Fail())
return false;
}
+ else if (!strcmp(class_name,"__NSArray0"))
+ {
+ value = 0;
+ }
else if (!strcmp(class_name,"__NSCFArray"))
{
Error error;
@@ -283,16 +317,29 @@ lldb_private::formatters::NSArraySummaryProvider (ValueObject& valobj, Stream& s
return false;
}
- stream.Printf("@\"%" PRIu64 " object%s\"",
+ std::string prefix,suffix;
+ if (Language* language = Language::FindPlugin(options.GetLanguage()))
+ {
+ if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix, suffix))
+ {
+ prefix.clear();
+ suffix.clear();
+ }
+ }
+
+ stream.Printf("%s%" PRIu64 " %s%s%s",
+ prefix.c_str(),
value,
- value == 1 ? "" : "s");
+ "element",
+ value == 1 ? "" : "s",
+ suffix.c_str());
return true;
}
lldb_private::formatters::NSArrayMSyntheticFrontEnd::NSArrayMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
SyntheticChildrenFrontEnd(*valobj_sp),
- m_exe_ctx_ref(),
- m_ptr_size(8),
+m_exe_ctx_ref(),
+m_ptr_size(8),
m_id_type(),
m_children()
{
@@ -300,7 +347,7 @@ m_children()
{
clang::ASTContext *ast = valobj_sp->GetExecutionContextRef().GetTargetSP()->GetScratchClangASTContext()->getASTContext();
if (ast)
- m_id_type = ClangASTType(ast, ast->ObjCBuiltinIdTy);
+ m_id_type = CompilerType(ast, ast->ObjCBuiltinIdTy);
if (valobj_sp->GetProcessSP())
m_ptr_size = valobj_sp->GetProcessSP()->GetAddressByteSize();
}
@@ -433,6 +480,14 @@ lldb_private::formatters::NSArrayMSyntheticFrontEnd::GetIndexOfChildWithName (co
return idx;
}
+lldb_private::formatters::NSArrayMSyntheticFrontEnd_109::~NSArrayMSyntheticFrontEnd_109()
+{
+ delete m_data_32;
+ m_data_32 = NULL;
+ delete m_data_64;
+ m_data_64 = NULL;
+}
+
lldb::addr_t
lldb_private::formatters::NSArrayMSyntheticFrontEnd_109::GetDataAddress ()
{
@@ -469,7 +524,7 @@ lldb_private::formatters::NSArrayMSyntheticFrontEnd_109::GetSize ()
m_data_64->_size;
}
-lldb_private::formatters::NSArrayMSyntheticFrontEnd_109::~NSArrayMSyntheticFrontEnd_109 ()
+lldb_private::formatters::NSArrayMSyntheticFrontEnd_1010::~NSArrayMSyntheticFrontEnd_1010()
{
delete m_data_32;
m_data_32 = NULL;
@@ -513,33 +568,25 @@ lldb_private::formatters::NSArrayMSyntheticFrontEnd_1010::GetSize ()
m_data_64->_size;
}
-lldb_private::formatters::NSArrayMSyntheticFrontEnd_1010::~NSArrayMSyntheticFrontEnd_1010 ()
-{
- delete m_data_32;
- m_data_32 = NULL;
- delete m_data_64;
- m_data_64 = NULL;
-}
-
lldb_private::formatters::NSArrayISyntheticFrontEnd::NSArrayISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
- SyntheticChildrenFrontEnd (*valobj_sp.get()),
- m_exe_ctx_ref (),
- m_ptr_size (8),
- m_items (0),
- m_data_ptr (0)
+SyntheticChildrenFrontEnd (*valobj_sp.get()),
+m_exe_ctx_ref (),
+m_ptr_size (8),
+m_items (0),
+m_data_ptr (0)
{
if (valobj_sp)
{
- clang::ASTContext *ast = valobj_sp->GetClangType().GetASTContext();
- if (ast)
- m_id_type = ClangASTType(ast, ast->ObjCBuiltinIdTy);
+ CompilerType type = valobj_sp->GetCompilerType();
+ if (type)
+ {
+ ClangASTContext *ast = valobj_sp->GetExecutionContextRef().GetTargetSP()->GetScratchClangASTContext();
+ if (ast)
+ m_id_type = CompilerType(ast->getASTContext(), ast->getASTContext()->ObjCBuiltinIdTy);
+ }
}
}
-lldb_private::formatters::NSArrayISyntheticFrontEnd::~NSArrayISyntheticFrontEnd ()
-{
-}
-
size_t
lldb_private::formatters::NSArrayISyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
{
@@ -610,6 +657,41 @@ lldb_private::formatters::NSArrayISyntheticFrontEnd::GetChildAtIndex (size_t idx
return retval_sp;
}
+lldb_private::formatters::NSArray0SyntheticFrontEnd::NSArray0SyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
+SyntheticChildrenFrontEnd (*valobj_sp.get())
+{
+}
+
+size_t
+lldb_private::formatters::NSArray0SyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
+{
+ return UINT32_MAX;
+}
+
+size_t
+lldb_private::formatters::NSArray0SyntheticFrontEnd::CalculateNumChildren ()
+{
+ return 0;
+}
+
+bool
+lldb_private::formatters::NSArray0SyntheticFrontEnd::Update()
+{
+ return false;
+}
+
+bool
+lldb_private::formatters::NSArray0SyntheticFrontEnd::MightHaveChildren ()
+{
+ return false;
+}
+
+lldb::ValueObjectSP
+lldb_private::formatters::NSArray0SyntheticFrontEnd::GetChildAtIndex (size_t idx)
+{
+ return lldb::ValueObjectSP();
+}
+
SyntheticChildrenFrontEnd* lldb_private::formatters::NSArraySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
{
if (!valobj_sp)
@@ -618,11 +700,11 @@ SyntheticChildrenFrontEnd* lldb_private::formatters::NSArraySyntheticFrontEndCre
lldb::ProcessSP process_sp (valobj_sp->GetProcessSP());
if (!process_sp)
return NULL;
- AppleObjCRuntime *runtime = (AppleObjCRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
+ AppleObjCRuntime *runtime = llvm::dyn_cast_or_null<AppleObjCRuntime>(process_sp->GetObjCLanguageRuntime());
if (!runtime)
return NULL;
- ClangASTType valobj_type(valobj_sp->GetClangType());
+ CompilerType valobj_type(valobj_sp->GetCompilerType());
Flags flags(valobj_type.GetTypeInfo());
if (flags.IsClear(eTypeIsPointer))
@@ -647,6 +729,10 @@ SyntheticChildrenFrontEnd* lldb_private::formatters::NSArraySyntheticFrontEndCre
{
return (new NSArrayISyntheticFrontEnd(valobj_sp));
}
+ else if (!strcmp(class_name,"__NSArray0"))
+ {
+ return (new NSArray0SyntheticFrontEnd(valobj_sp));
+ }
else if (!strcmp(class_name,"__NSArrayM"))
{
if (runtime->GetFoundationVersion() >= 1100)
@@ -680,7 +766,10 @@ lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::GetChildAtIndex (
idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
lldb::ValueObjectSP valobj_sp = CallSelectorOnObject(m_backend,"id","objectAtIndex:",idx);
if (valobj_sp)
+ {
+ valobj_sp->SetPreferredDisplayLanguage(m_backend.GetPreferredDisplayLanguage());
valobj_sp->SetName(ConstString(idx_name.GetData()));
+ }
return valobj_sp;
}
@@ -701,6 +790,3 @@ lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::GetIndexOfChildWi
{
return 0;
}
-
-lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::~NSArrayCodeRunningSyntheticFrontEnd ()
-{}
diff --git a/source/DataFormatters/NSDictionary.cpp b/source/Plugins/Language/ObjC/NSDictionary.cpp
index 30bc3acfbec7..e4a7425329f5 100644
--- a/source/DataFormatters/NSDictionary.cpp
+++ b/source/Plugins/Language/ObjC/NSDictionary.cpp
@@ -1,4 +1,4 @@
-//===-- NSDictionary.cpp ------------------------------------------*- C++ -*-===//
+//===-- NSDictionary.cpp ----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,110 +7,153 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/DataFormatters/CXXFormatterFunctions.h"
+// C Includes
+// C++ Includes
+#include <mutex>
+
+// Other libraries and framework includes
+#include "clang/AST/DeclCXX.h"
+
+// Project includes
+#include "NSDictionary.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Host/Endian.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 "clang/AST/DeclCXX.h"
-
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
-static ClangASTType
-GetLLDBNSPairType (TargetSP target_sp)
+std::map<ConstString, CXXFunctionSummaryFormat::Callback>&
+NSDictionary_Additionals::GetAdditionalSummaries ()
{
- ClangASTType clang_type;
+ static std::map<ConstString, CXXFunctionSummaryFormat::Callback> g_map;
+ return g_map;
+}
- ClangASTContext *target_ast_context = target_sp->GetScratchClangASTContext();
+std::map<ConstString, CXXSyntheticChildren::CreateFrontEndCallback>&
+NSDictionary_Additionals::GetAdditionalSynthetics ()
+{
+ static std::map<ConstString, CXXSyntheticChildren::CreateFrontEndCallback> g_map;
+ return g_map;
+}
+static CompilerType
+GetLLDBNSPairType (TargetSP target_sp)
+{
+ CompilerType compiler_type;
+
+ ClangASTContext *target_ast_context = target_sp->GetScratchClangASTContext();
+
if (target_ast_context)
{
ConstString g___lldb_autogen_nspair("__lldb_autogen_nspair");
-
- clang_type = target_ast_context->GetTypeForIdentifier<clang::CXXRecordDecl>(g___lldb_autogen_nspair);
- if (!clang_type)
+ compiler_type = target_ast_context->GetTypeForIdentifier<clang::CXXRecordDecl>(g___lldb_autogen_nspair);
+
+ if (!compiler_type)
{
- clang_type = target_ast_context->CreateRecordType(NULL, lldb::eAccessPublic, g___lldb_autogen_nspair.GetCString(), clang::TTK_Struct, lldb::eLanguageTypeC);
+ compiler_type = target_ast_context->CreateRecordType(NULL, lldb::eAccessPublic, g___lldb_autogen_nspair.GetCString(), clang::TTK_Struct, lldb::eLanguageTypeC);
- if (clang_type)
+ if (compiler_type)
{
- clang_type.StartTagDeclarationDefinition();
- ClangASTType id_clang_type = target_ast_context->GetBasicType (eBasicTypeObjCID);
- clang_type.AddFieldToRecordType("key", id_clang_type, lldb::eAccessPublic, 0);
- clang_type.AddFieldToRecordType("value", id_clang_type, lldb::eAccessPublic, 0);
- clang_type.CompleteTagDeclarationDefinition();
+ ClangASTContext::StartTagDeclarationDefinition(compiler_type);
+ CompilerType id_compiler_type = target_ast_context->GetBasicType (eBasicTypeObjCID);
+ ClangASTContext::AddFieldToRecordType(compiler_type, "key", id_compiler_type, lldb::eAccessPublic, 0);
+ ClangASTContext::AddFieldToRecordType(compiler_type, "value", id_compiler_type, lldb::eAccessPublic, 0);
+ ClangASTContext::CompleteTagDeclarationDefinition(compiler_type);
}
}
}
- return clang_type;
+ return compiler_type;
}
namespace lldb_private {
namespace formatters {
class NSDictionaryISyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
+ public:
+ NSDictionaryISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+
+ ~NSDictionaryISyntheticFrontEnd() override;
+
+ size_t
+ CalculateNumChildren() override;
+
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
+
+ bool
+ Update() override;
+
+ bool
+ MightHaveChildren() override;
+
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
+
private:
struct DataDescriptor_32
{
uint32_t _used : 26;
uint32_t _szidx : 6;
};
+
struct DataDescriptor_64
{
uint64_t _used : 58;
uint32_t _szidx : 6;
};
-
+
struct DictionaryItemDescriptor
{
lldb::addr_t key_ptr;
lldb::addr_t val_ptr;
lldb::ValueObjectSP valobj_sp;
};
-
- public:
- NSDictionaryISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
-
- virtual bool
- MightHaveChildren ();
-
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
-
- virtual
- ~NSDictionaryISyntheticFrontEnd ();
- private:
+
ExecutionContextRef m_exe_ctx_ref;
uint8_t m_ptr_size;
lldb::ByteOrder m_order;
DataDescriptor_32 *m_data_32;
DataDescriptor_64 *m_data_64;
lldb::addr_t m_data_ptr;
- ClangASTType m_pair_type;
+ CompilerType m_pair_type;
std::vector<DictionaryItemDescriptor> m_children;
};
class NSDictionaryMSyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
+ public:
+ NSDictionaryMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+
+ ~NSDictionaryMSyntheticFrontEnd() override;
+
+ size_t
+ CalculateNumChildren() override;
+
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
+
+ bool
+ Update() override;
+
+ bool
+ MightHaveChildren() override;
+
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
+
private:
struct DataDescriptor_32
{
@@ -121,6 +164,7 @@ namespace lldb_private {
uint32_t _objs_addr;
uint32_t _keys_addr;
};
+
struct DataDescriptor_64
{
uint64_t _used : 58;
@@ -130,39 +174,20 @@ namespace lldb_private {
uint64_t _objs_addr;
uint64_t _keys_addr;
};
+
struct DictionaryItemDescriptor
{
lldb::addr_t key_ptr;
lldb::addr_t val_ptr;
lldb::ValueObjectSP valobj_sp;
};
- public:
- NSDictionaryMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
-
- virtual bool
- MightHaveChildren ();
-
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
-
- virtual
- ~NSDictionaryMSyntheticFrontEnd ();
- private:
+
ExecutionContextRef m_exe_ctx_ref;
uint8_t m_ptr_size;
lldb::ByteOrder m_order;
DataDescriptor_32 *m_data_32;
DataDescriptor_64 *m_data_64;
- ClangASTType m_pair_type;
+ CompilerType m_pair_type;
std::vector<DictionaryItemDescriptor> m_children;
};
@@ -170,32 +195,32 @@ namespace lldb_private {
{
public:
NSDictionaryCodeRunningSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+
+ ~NSDictionaryCodeRunningSyntheticFrontEnd() override = default;
+
+ size_t
+ CalculateNumChildren() override;
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
- virtual bool
- MightHaveChildren ();
+ bool
+ Update() override;
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
+ bool
+ MightHaveChildren() override;
- virtual
- ~NSDictionaryCodeRunningSyntheticFrontEnd ();
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
};
- }
-}
+ } // namespace formatters
+} // namespace lldb_private
template<bool name_entries>
bool
lldb_private::formatters::NSDictionarySummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
{
+ static ConstString g_TypeHint("NSDictionary");
ProcessSP process_sp = valobj.GetProcessSP();
if (!process_sp)
return false;
@@ -220,7 +245,8 @@ lldb_private::formatters::NSDictionarySummaryProvider (ValueObject& valobj, Stre
uint64_t value = 0;
- const char* class_name = descriptor->GetClassName().GetCString();
+ ConstString class_name_cs = descriptor->GetClassName();
+ const char* class_name = class_name_cs.GetCString();
if (!class_name || !*class_name)
return false;
@@ -242,31 +268,45 @@ lldb_private::formatters::NSDictionarySummaryProvider (ValueObject& valobj, Stre
value &= (is_64bit ? ~0xFC00000000000000UL : ~0xFC000000U);
}
/*else if (!strcmp(class_name,"__NSCFDictionary"))
- {
- Error error;
- value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + (is_64bit ? 20 : 12), 4, 0, error);
- if (error.Fail())
- return false;
- if (is_64bit)
- value &= ~0x0f1f000000000000UL;
- }*/
+ {
+ Error error;
+ value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + (is_64bit ? 20 : 12), 4, 0, error);
+ if (error.Fail())
+ return false;
+ if (is_64bit)
+ value &= ~0x0f1f000000000000UL;
+ }*/
else
{
+ auto& map(NSDictionary_Additionals::GetAdditionalSummaries());
+ auto iter = map.find(class_name_cs), end = map.end();
+ if (iter != end)
+ return iter->second(valobj, stream, options);
if (!ExtractValueFromObjCExpression(valobj, "int", "count", value))
return false;
}
- stream.Printf("%s%" PRIu64 " %s%s",
- (name_entries ? "@\"" : ""),
+ std::string prefix,suffix;
+ if (Language* language = Language::FindPlugin(options.GetLanguage()))
+ {
+ if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix, suffix))
+ {
+ prefix.clear();
+ suffix.clear();
+ }
+ }
+
+ stream.Printf("%s%" PRIu64 " %s%s%s",
+ prefix.c_str(),
value,
- (name_entries ? (value == 1 ? "entry" : "entries") : (value == 1 ? "key/value pair" : "key/value pairs")),
- (name_entries ? "\"" : ""));
+ "key/value pair",
+ value == 1 ? "" : "s",
+ suffix.c_str());
return true;
}
-SyntheticChildrenFrontEnd* lldb_private::formatters::NSDictionarySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
+SyntheticChildrenFrontEnd* lldb_private::formatters::NSDictionarySyntheticFrontEndCreator (CXXSyntheticChildren* synth, lldb::ValueObjectSP valobj_sp)
{
-
lldb::ProcessSP process_sp (valobj_sp->GetProcessSP());
if (!process_sp)
return NULL;
@@ -274,7 +314,10 @@ SyntheticChildrenFrontEnd* lldb_private::formatters::NSDictionarySyntheticFrontE
if (!runtime)
return NULL;
- if (!valobj_sp->IsPointerType())
+ CompilerType valobj_type(valobj_sp->GetCompilerType());
+ Flags flags(valobj_type.GetTypeInfo());
+
+ if (flags.IsClear(eTypeIsPointer))
{
Error error;
valobj_sp = valobj_sp->AddressOf(error);
@@ -287,7 +330,8 @@ SyntheticChildrenFrontEnd* lldb_private::formatters::NSDictionarySyntheticFrontE
if (!descriptor.get() || !descriptor->IsValid())
return NULL;
- const char* class_name = descriptor->GetClassName().GetCString();
+ ConstString class_name_cs = descriptor->GetClassName();
+ const char* class_name = class_name_cs.GetCString();
if (!class_name || !*class_name)
return NULL;
@@ -302,6 +346,10 @@ SyntheticChildrenFrontEnd* lldb_private::formatters::NSDictionarySyntheticFrontE
}
else
{
+ auto& map(NSDictionary_Additionals::GetAdditionalSynthetics());
+ auto iter = map.find(class_name_cs), end = map.end();
+ if (iter != end)
+ return iter->second(synth, valobj_sp);
return (new NSDictionaryCodeRunningSyntheticFrontEnd(valobj_sp));
}
}
@@ -333,6 +381,8 @@ lldb_private::formatters::NSDictionaryCodeRunningSyntheticFrontEnd::GetChildAtIn
lldb::ValueObjectSP child_sp;
EvaluateExpressionOptions options;
options.SetKeepInMemory(true);
+ options.SetLanguage(lldb::eLanguageTypeObjC_plus_plus);
+ options.SetResultIsInternal(true);
m_backend.GetTargetSP()->EvaluateExpression(object_fetcher_expr.GetData(),
GetViableFrame(m_backend.GetTargetSP().get()),
child_sp,
@@ -360,9 +410,6 @@ lldb_private::formatters::NSDictionaryCodeRunningSyntheticFrontEnd::GetIndexOfCh
return 0;
}
-lldb_private::formatters::NSDictionaryCodeRunningSyntheticFrontEnd::~NSDictionaryCodeRunningSyntheticFrontEnd ()
-{}
-
lldb_private::formatters::NSDictionaryISyntheticFrontEnd::NSDictionaryISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
SyntheticChildrenFrontEnd(*valobj_sp.get()),
m_exe_ctx_ref(),
@@ -696,7 +743,7 @@ lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::GetChildAtIndex (size_
}
template bool
-lldb_private::formatters::NSDictionarySummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&) ;
+lldb_private::formatters::NSDictionarySummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&);
template bool
-lldb_private::formatters::NSDictionarySummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&) ;
+lldb_private::formatters::NSDictionarySummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&);
diff --git a/source/Plugins/Language/ObjC/NSDictionary.h b/source/Plugins/Language/ObjC/NSDictionary.h
new file mode 100644
index 000000000000..e96c25a97b2b
--- /dev/null
+++ b/source/Plugins/Language/ObjC/NSDictionary.h
@@ -0,0 +1,48 @@
+//===-- NSDictionary.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_NSDictionary_h_
+#define liblldb_NSDictionary_h_
+
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
+
+#include <map>
+
+namespace lldb_private {
+ namespace formatters
+ {
+ template<bool name_entries>
+ bool
+ NSDictionarySummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ extern template bool
+ NSDictionarySummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&) ;
+
+ extern template bool
+ NSDictionarySummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&) ;
+
+ SyntheticChildrenFrontEnd* NSDictionarySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
+
+ class NSDictionary_Additionals
+ {
+ public:
+ static std::map<ConstString, CXXFunctionSummaryFormat::Callback>&
+ GetAdditionalSummaries ();
+
+ static std::map<ConstString, CXXSyntheticChildren::CreateFrontEndCallback>&
+ GetAdditionalSynthetics ();
+ };
+ } // namespace formatters
+} // namespace lldb_private
+
+#endif // liblldb_NSDictionary_h_
diff --git a/source/Plugins/Language/ObjC/NSError.cpp b/source/Plugins/Language/ObjC/NSError.cpp
new file mode 100644
index 000000000000..c627cd031926
--- /dev/null
+++ b/source/Plugins/Language/ObjC/NSError.cpp
@@ -0,0 +1,218 @@
+//===-- NSError.cpp ---------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+#include "clang/AST/DeclCXX.h"
+
+// Project includes
+#include "Cocoa.h"
+
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/Error.h"
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/Host/Endian.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Target/Target.h"
+
+#include "lldb/Utility/ProcessStructReader.h"
+
+#include "Plugins/Language/ObjC/NSString.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+bool
+lldb_private::formatters::NSError_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
+{
+ ProcessSP process_sp(valobj.GetProcessSP());
+ if (!process_sp)
+ return false;
+
+ lldb::addr_t ptr_value = LLDB_INVALID_ADDRESS;
+
+ CompilerType valobj_type(valobj.GetCompilerType());
+ Flags type_flags(valobj_type.GetTypeInfo());
+ if (type_flags.AllClear(eTypeHasValue))
+ {
+ if (valobj.IsBaseClass() && valobj.GetParent())
+ ptr_value = valobj.GetParent()->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
+ }
+ else
+ ptr_value = valobj.GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
+
+ if (ptr_value == LLDB_INVALID_ADDRESS)
+ return false;
+ size_t ptr_size = process_sp->GetAddressByteSize();
+ lldb::addr_t code_location = ptr_value + 2 * ptr_size;
+ lldb::addr_t domain_location = ptr_value + 3 * ptr_size;
+
+ Error error;
+ uint64_t code = process_sp->ReadUnsignedIntegerFromMemory(code_location, ptr_size, 0, error);
+ if (error.Fail())
+ return false;
+
+ lldb::addr_t domain_str_value = process_sp->ReadPointerFromMemory(domain_location, error);
+ if (error.Fail() || domain_str_value == LLDB_INVALID_ADDRESS)
+ return false;
+
+ if (!domain_str_value)
+ {
+ stream.Printf("domain: nil - code: %" PRIu64, code);
+ return true;
+ }
+
+ InferiorSizedWord isw(domain_str_value, *process_sp);
+
+ ValueObjectSP domain_str_sp = ValueObject::CreateValueObjectFromData("domain_str", isw.GetAsData(process_sp->GetByteOrder()), valobj.GetExecutionContextRef(), process_sp->GetTarget().GetScratchClangASTContext()->GetBasicType(lldb::eBasicTypeVoid).GetPointerType());
+
+ if (!domain_str_sp)
+ return false;
+
+ StreamString domain_str_summary;
+ if (NSStringSummaryProvider(*domain_str_sp, domain_str_summary, options) && !domain_str_summary.Empty())
+ {
+ stream.Printf("domain: %s - code: %" PRIu64, domain_str_summary.GetData(), code);
+ return true;
+ }
+ else
+ {
+ stream.Printf("domain: nil - code: %" PRIu64, code);
+ return true;
+ }
+}
+
+class NSErrorSyntheticFrontEnd : public SyntheticChildrenFrontEnd
+{
+public:
+ NSErrorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
+ SyntheticChildrenFrontEnd(*valobj_sp)
+ {}
+
+ ~NSErrorSyntheticFrontEnd() override = default;
+ // no need to delete m_child_ptr - it's kept alive by the cluster manager on our behalf
+
+ size_t
+ CalculateNumChildren() override
+ {
+ if (m_child_ptr)
+ return 1;
+ if (m_child_sp)
+ return 1;
+ return 0;
+ }
+
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override
+ {
+ if (idx != 0)
+ return lldb::ValueObjectSP();
+
+ if (m_child_ptr)
+ return m_child_ptr->GetSP();
+ return m_child_sp;
+ }
+
+ bool
+ Update() override
+ {
+ m_child_ptr = nullptr;
+ m_child_sp.reset();
+
+ ProcessSP process_sp(m_backend.GetProcessSP());
+ if (!process_sp)
+ return false;
+
+ lldb::addr_t userinfo_location = LLDB_INVALID_ADDRESS;
+
+ CompilerType valobj_type(m_backend.GetCompilerType());
+ Flags type_flags(valobj_type.GetTypeInfo());
+ if (type_flags.AllClear(eTypeHasValue))
+ {
+ if (m_backend.IsBaseClass() && m_backend.GetParent())
+ userinfo_location = m_backend.GetParent()->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
+ }
+ else
+ userinfo_location = m_backend.GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
+
+ if (userinfo_location == LLDB_INVALID_ADDRESS)
+ return false;
+
+ size_t ptr_size = process_sp->GetAddressByteSize();
+
+ userinfo_location += 4 * ptr_size;
+ Error error;
+ lldb::addr_t userinfo = process_sp->ReadPointerFromMemory(userinfo_location, error);
+ if (userinfo == LLDB_INVALID_ADDRESS || error.Fail())
+ return false;
+ InferiorSizedWord isw(userinfo,*process_sp);
+ m_child_sp = ValueObject::CreateValueObjectFromData("_userInfo",
+ isw.GetAsData(process_sp->GetByteOrder()),
+ m_backend.GetExecutionContextRef(),
+ process_sp->GetTarget().GetScratchClangASTContext()->GetBasicType(lldb::eBasicTypeObjCID));
+ return false;
+ }
+
+ bool
+ MightHaveChildren() override
+ {
+ return true;
+ }
+
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override
+ {
+ static ConstString g___userInfo("_userInfo");
+ if (name == g___userInfo)
+ return 0;
+ return UINT32_MAX;
+ }
+
+private:
+ // the child here can be "real" (i.e. an actual child of the root) or synthetized from raw memory
+ // if the former, I need to store a plain pointer to it - or else a loop of references will cause this entire hierarchy of values to leak
+ // if the latter, then I need to store a SharedPointer to it - so that it only goes away when everyone else in the cluster goes away
+ // oh joy!
+ ValueObject* m_child_ptr;
+ ValueObjectSP m_child_sp;
+};
+
+SyntheticChildrenFrontEnd*
+lldb_private::formatters::NSErrorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
+{
+ lldb::ProcessSP process_sp (valobj_sp->GetProcessSP());
+ if (!process_sp)
+ return nullptr;
+ ObjCLanguageRuntime *runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
+ if (!runtime)
+ return nullptr;
+
+ ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(*valobj_sp.get()));
+
+ if (!descriptor.get() || !descriptor->IsValid())
+ return nullptr;
+
+ const char* class_name = descriptor->GetClassName().GetCString();
+
+ if (!class_name || !*class_name)
+ return nullptr;
+
+ if (!strcmp(class_name,"NSError"))
+ return (new NSErrorSyntheticFrontEnd(valobj_sp));
+ else if (!strcmp(class_name,"__NSCFError"))
+ return (new NSErrorSyntheticFrontEnd(valobj_sp));
+
+ return nullptr;
+}
diff --git a/source/Plugins/Language/ObjC/NSException.cpp b/source/Plugins/Language/ObjC/NSException.cpp
new file mode 100644
index 000000000000..e58223a4d461
--- /dev/null
+++ b/source/Plugins/Language/ObjC/NSException.cpp
@@ -0,0 +1,219 @@
+//===-- NSException.cpp -----------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+#include "clang/AST/DeclCXX.h"
+
+// Project includes
+#include "Cocoa.h"
+
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/Error.h"
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/Host/Endian.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Target/Target.h"
+
+#include "lldb/Utility/ProcessStructReader.h"
+
+#include "Plugins/Language/ObjC/NSString.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+bool
+lldb_private::formatters::NSException_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
+{
+ ProcessSP process_sp(valobj.GetProcessSP());
+ if (!process_sp)
+ return false;
+
+ lldb::addr_t ptr_value = LLDB_INVALID_ADDRESS;
+
+ CompilerType valobj_type(valobj.GetCompilerType());
+ Flags type_flags(valobj_type.GetTypeInfo());
+ if (type_flags.AllClear(eTypeHasValue))
+ {
+ if (valobj.IsBaseClass() && valobj.GetParent())
+ ptr_value = valobj.GetParent()->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
+ }
+ else
+ ptr_value = valobj.GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
+
+ if (ptr_value == LLDB_INVALID_ADDRESS)
+ return false;
+ size_t ptr_size = process_sp->GetAddressByteSize();
+ lldb::addr_t name_location = ptr_value + 1 * ptr_size;
+ lldb::addr_t reason_location = ptr_value + 2 * ptr_size;
+
+ Error error;
+ lldb::addr_t name = process_sp->ReadPointerFromMemory(name_location, error);
+ if (error.Fail() || name == LLDB_INVALID_ADDRESS)
+ return false;
+
+ lldb::addr_t reason = process_sp->ReadPointerFromMemory(reason_location, error);
+ if (error.Fail() || reason == LLDB_INVALID_ADDRESS)
+ return false;
+
+ InferiorSizedWord name_isw(name, *process_sp);
+ InferiorSizedWord reason_isw(reason, *process_sp);
+
+ CompilerType voidstar = process_sp->GetTarget().GetScratchClangASTContext()->GetBasicType(lldb::eBasicTypeVoid).GetPointerType();
+
+ ValueObjectSP name_sp = ValueObject::CreateValueObjectFromData("name_str", name_isw.GetAsData(process_sp->GetByteOrder()), valobj.GetExecutionContextRef(), voidstar);
+ ValueObjectSP reason_sp = ValueObject::CreateValueObjectFromData("reason_str", reason_isw.GetAsData(process_sp->GetByteOrder()), valobj.GetExecutionContextRef(), voidstar);
+
+ if (!name_sp || !reason_sp)
+ return false;
+
+ StreamString name_str_summary;
+ StreamString reason_str_summary;
+ if (NSStringSummaryProvider(*name_sp, name_str_summary, options) &&
+ NSStringSummaryProvider(*reason_sp, reason_str_summary, options) &&
+ !name_str_summary.Empty() &&
+ !reason_str_summary.Empty())
+ {
+ stream.Printf("name: %s - reason: %s", name_str_summary.GetData(), reason_str_summary.GetData());
+ return true;
+ }
+ else
+ return false;
+}
+
+class NSExceptionSyntheticFrontEnd : public SyntheticChildrenFrontEnd
+{
+public:
+ NSExceptionSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
+ SyntheticChildrenFrontEnd(*valobj_sp)
+ {}
+
+ ~NSExceptionSyntheticFrontEnd() override = default;
+ // no need to delete m_child_ptr - it's kept alive by the cluster manager on our behalf
+
+ size_t
+ CalculateNumChildren() override
+ {
+ if (m_child_ptr)
+ return 1;
+ if (m_child_sp)
+ return 1;
+ return 0;
+ }
+
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override
+ {
+ if (idx != 0)
+ return lldb::ValueObjectSP();
+
+ if (m_child_ptr)
+ return m_child_ptr->GetSP();
+ return m_child_sp;
+ }
+
+ bool
+ Update() override
+ {
+ m_child_ptr = nullptr;
+ m_child_sp.reset();
+
+ ProcessSP process_sp(m_backend.GetProcessSP());
+ if (!process_sp)
+ return false;
+
+ lldb::addr_t userinfo_location = LLDB_INVALID_ADDRESS;
+
+ CompilerType valobj_type(m_backend.GetCompilerType());
+ Flags type_flags(valobj_type.GetTypeInfo());
+ if (type_flags.AllClear(eTypeHasValue))
+ {
+ if (m_backend.IsBaseClass() && m_backend.GetParent())
+ userinfo_location = m_backend.GetParent()->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
+ }
+ else
+ userinfo_location = m_backend.GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
+
+ if (userinfo_location == LLDB_INVALID_ADDRESS)
+ return false;
+
+ size_t ptr_size = process_sp->GetAddressByteSize();
+
+ userinfo_location += 3 * ptr_size;
+ Error error;
+ lldb::addr_t userinfo = process_sp->ReadPointerFromMemory(userinfo_location, error);
+ if (userinfo == LLDB_INVALID_ADDRESS || error.Fail())
+ return false;
+ InferiorSizedWord isw(userinfo,*process_sp);
+ m_child_sp = ValueObject::CreateValueObjectFromData("userInfo",
+ isw.GetAsData(process_sp->GetByteOrder()),
+ m_backend.GetExecutionContextRef(),
+ process_sp->GetTarget().GetScratchClangASTContext()->GetBasicType(lldb::eBasicTypeObjCID));
+ return false;
+ }
+
+ bool
+ MightHaveChildren() override
+ {
+ return true;
+ }
+
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override
+ {
+ static ConstString g___userInfo("userInfo");
+ if (name == g___userInfo)
+ return 0;
+ return UINT32_MAX;
+ }
+
+private:
+ // the child here can be "real" (i.e. an actual child of the root) or synthetized from raw memory
+ // if the former, I need to store a plain pointer to it - or else a loop of references will cause this entire hierarchy of values to leak
+ // if the latter, then I need to store a SharedPointer to it - so that it only goes away when everyone else in the cluster goes away
+ // oh joy!
+ ValueObject* m_child_ptr;
+ ValueObjectSP m_child_sp;
+};
+
+SyntheticChildrenFrontEnd*
+lldb_private::formatters::NSExceptionSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
+{
+ lldb::ProcessSP process_sp (valobj_sp->GetProcessSP());
+ if (!process_sp)
+ return nullptr;
+ ObjCLanguageRuntime *runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
+ if (!runtime)
+ return nullptr;
+
+ ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(*valobj_sp.get()));
+
+ if (!descriptor.get() || !descriptor->IsValid())
+ return nullptr;
+
+ const char* class_name = descriptor->GetClassName().GetCString();
+
+ if (!class_name || !*class_name)
+ return nullptr;
+
+ if (!strcmp(class_name,"NSException"))
+ return (new NSExceptionSyntheticFrontEnd(valobj_sp));
+ else if (!strcmp(class_name,"NSCFException"))
+ return (new NSExceptionSyntheticFrontEnd(valobj_sp));
+ else if (!strcmp(class_name,"__NSCFException"))
+ return (new NSExceptionSyntheticFrontEnd(valobj_sp));
+
+ return nullptr;
+}
diff --git a/source/DataFormatters/NSIndexPath.cpp b/source/Plugins/Language/ObjC/NSIndexPath.cpp
index 363bd5c0527e..245f6da80c7f 100644
--- a/source/DataFormatters/NSIndexPath.cpp
+++ b/source/Plugins/Language/ObjC/NSIndexPath.cpp
@@ -1,4 +1,4 @@
-//===-- NSIndexPath.cpp ------------------------------------------*- C++ -*-===//
+//===-- NSIndexPath.cpp -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,14 +7,20 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/DataFormatters/CXXFormatterFunctions.h"
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "Cocoa.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
+#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/Symbol/ClangASTContext.h"
+#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
@@ -26,34 +32,39 @@ public:
NSIndexPathSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
SyntheticChildrenFrontEnd (*valobj_sp.get()),
m_ptr_size(0),
- m_ast_ctx(nullptr),
m_uint_star_type()
{
m_ptr_size = m_backend.GetTargetSP()->GetArchitecture().GetAddressByteSize();
}
-
- virtual size_t
- CalculateNumChildren ()
+
+ ~NSIndexPathSyntheticFrontEnd() override = default;
+
+ size_t
+ CalculateNumChildren() override
{
return m_impl.GetNumIndexes();
}
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx)
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override
{
return m_impl.GetIndexAtIndex(idx, m_uint_star_type);
}
- virtual bool
- Update()
+ bool
+ Update() override
{
m_impl.Clear();
- m_ast_ctx = ClangASTContext::GetASTContext(m_backend.GetClangType().GetASTContext());
- if (!m_ast_ctx)
+ TypeSystem* type_system = m_backend.GetCompilerType().GetTypeSystem();
+ if (!type_system)
return false;
-
- m_uint_star_type = m_ast_ctx->GetPointerSizedIntType(false);
+
+ ClangASTContext *ast = m_backend.GetExecutionContextRef().GetTargetSP()->GetScratchClangASTContext();
+ if (!ast)
+ return false;
+
+ m_uint_star_type = ast->GetPointerSizedIntType(false);
static ConstString g__indexes("_indexes");
static ConstString g__length("_length");
@@ -125,16 +136,16 @@ public:
return false;
}
- virtual bool
- MightHaveChildren ()
+ bool
+ MightHaveChildren() override
{
if (m_impl.m_mode == Mode::Invalid)
return false;
return true;
}
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name)
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override
{
const char* item_name = name.GetCString();
uint32_t idx = ExtractIndexFromString(item_name);
@@ -143,12 +154,12 @@ public:
return idx;
}
- virtual lldb::ValueObjectSP
- GetSyntheticValue () { return nullptr; }
-
- virtual
- ~NSIndexPathSyntheticFrontEnd () {}
-
+ lldb::ValueObjectSP
+ GetSyntheticValue() override
+ {
+ return nullptr;
+ }
+
protected:
ObjCLanguageRuntime::ClassDescriptorSP m_descriptor_sp;
@@ -176,7 +187,7 @@ protected:
}
lldb::ValueObjectSP
- GetIndexAtIndex (size_t idx, const ClangASTType& desired_type)
+ GetIndexAtIndex (size_t idx, const CompilerType& desired_type)
{
if (idx >= GetNumIndexes())
return nullptr;
@@ -206,7 +217,7 @@ protected:
}
lldb::ValueObjectSP
- GetIndexAtIndex (size_t idx, const ClangASTType& desired_type)
+ GetIndexAtIndex (size_t idx, const CompilerType& desired_type)
{
std::pair<uint64_t, bool> value(_indexAtPositionForInlinePayload(idx));
if (!value.second)
@@ -224,7 +235,7 @@ protected:
v = Value(scalar);
}
- v.SetClangType(desired_type);
+ v.SetCompilerType(desired_type);
StreamString idx_name;
idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
@@ -241,7 +252,7 @@ protected:
m_process = nullptr;
}
- private:
+ private:
uint64_t m_indexes;
size_t m_count;
uint32_t m_ptr_size;
@@ -321,8 +332,7 @@ protected:
} m_impl;
uint32_t m_ptr_size;
- ClangASTContext* m_ast_ctx;
- ClangASTType m_uint_star_type;
+ CompilerType m_uint_star_type;
};
namespace lldb_private {
@@ -334,5 +344,6 @@ namespace lldb_private {
return new NSIndexPathSyntheticFrontEnd(valobj_sp);
return nullptr;
}
- }
-}
+
+ } // namespace formatters
+} // namespace lldb_private
diff --git a/source/DataFormatters/NSSet.cpp b/source/Plugins/Language/ObjC/NSSet.cpp
index 116904ce99b4..93115957e329 100644
--- a/source/DataFormatters/NSSet.cpp
+++ b/source/Plugins/Language/ObjC/NSSet.cpp
@@ -1,4 +1,4 @@
-//===-- NSSet.cpp ------------------------------------------------*- C++ -*-===//
+//===-- NSSet.cpp -----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,15 +7,21 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/DataFormatters/CXXFormatterFunctions.h"
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "NSSet.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Target/Language.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
@@ -23,49 +29,63 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
+std::map<ConstString, CXXFunctionSummaryFormat::Callback>&
+NSSet_Additionals::GetAdditionalSummaries ()
+{
+ static std::map<ConstString, CXXFunctionSummaryFormat::Callback> g_map;
+ return g_map;
+}
+
+std::map<ConstString, CXXSyntheticChildren::CreateFrontEndCallback>&
+NSSet_Additionals::GetAdditionalSynthetics ()
+{
+ static std::map<ConstString, CXXSyntheticChildren::CreateFrontEndCallback> g_map;
+ return g_map;
+}
+
namespace lldb_private {
namespace formatters {
class NSSetISyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
+ public:
+ NSSetISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+
+ ~NSSetISyntheticFrontEnd() override;
+
+ size_t
+ CalculateNumChildren() override;
+
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
+
+ bool
+ Update() override;
+
+ bool
+ MightHaveChildren() override;
+
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
+
private:
struct DataDescriptor_32
{
uint32_t _used : 26;
uint32_t _szidx : 6;
};
+
struct DataDescriptor_64
{
uint64_t _used : 58;
uint32_t _szidx : 6;
};
-
+
struct SetItemDescriptor
{
lldb::addr_t item_ptr;
lldb::ValueObjectSP valobj_sp;
};
-
- public:
- NSSetISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
-
- virtual bool
- MightHaveChildren ();
-
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
-
- virtual
- ~NSSetISyntheticFrontEnd ();
- private:
+
ExecutionContextRef m_exe_ctx_ref;
uint8_t m_ptr_size;
DataDescriptor_32 *m_data_32;
@@ -76,28 +96,26 @@ namespace lldb_private {
class NSOrderedSetSyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
- private:
-
public:
NSOrderedSetSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+
+ ~NSOrderedSetSyntheticFrontEnd() override = default;
+
+ size_t
+ CalculateNumChildren() override;
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
- virtual bool
- MightHaveChildren ();
+ bool
+ Update() override;
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
+ bool
+ MightHaveChildren() override;
- virtual
- ~NSOrderedSetSyntheticFrontEnd ();
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
+
private:
uint32_t m_count;
std::map<uint32_t,lldb::ValueObjectSP> m_children;
@@ -105,6 +123,26 @@ namespace lldb_private {
class NSSetMSyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
+ public:
+ NSSetMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+
+ ~NSSetMSyntheticFrontEnd() override;
+
+ size_t
+ CalculateNumChildren() override;
+
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
+
+ bool
+ Update() override;
+
+ bool
+ MightHaveChildren() override;
+
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
+
private:
struct DataDescriptor_32
{
@@ -113,6 +151,7 @@ namespace lldb_private {
uint32_t _mutations;
uint32_t _objs_addr;
};
+
struct DataDescriptor_64
{
uint64_t _used : 58;
@@ -120,32 +159,13 @@ namespace lldb_private {
uint64_t _mutations;
uint64_t _objs_addr;
};
+
struct SetItemDescriptor
{
lldb::addr_t item_ptr;
lldb::ValueObjectSP valobj_sp;
};
- public:
- NSSetMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
-
- virtual bool
- MightHaveChildren ();
-
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
-
- virtual
- ~NSSetMSyntheticFrontEnd ();
- private:
+
ExecutionContextRef m_exe_ctx_ref;
uint8_t m_ptr_size;
DataDescriptor_32 *m_data_32;
@@ -157,32 +177,33 @@ namespace lldb_private {
{
public:
NSSetCodeRunningSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+
+ ~NSSetCodeRunningSyntheticFrontEnd() override;
+
+ size_t
+ CalculateNumChildren() override;
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
+ lldb::ValueObjectSP
+ GetChildAtIndex(size_t idx) override;
- virtual bool
- MightHaveChildren ();
+ bool
+ Update() override;
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
+ bool
+ MightHaveChildren() override;
- virtual
- ~NSSetCodeRunningSyntheticFrontEnd ();
+ size_t
+ GetIndexOfChildWithName(const ConstString &name) override;
};
- }
-}
+ } // namespace formatters
+} // namespace lldb_private
template<bool cf_style>
bool
lldb_private::formatters::NSSetSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
{
+ static ConstString g_TypeHint("NSSet");
+
ProcessSP process_sp = valobj.GetProcessSP();
if (!process_sp)
return false;
@@ -207,7 +228,8 @@ lldb_private::formatters::NSSetSummaryProvider (ValueObject& valobj, Stream& str
uint64_t value = 0;
- const char* class_name = descriptor->GetClassName().GetCString();
+ ConstString class_name_cs = descriptor->GetClassName();
+ const char* class_name = class_name_cs.GetCString();
if (!class_name || !*class_name)
return false;
@@ -229,41 +251,56 @@ lldb_private::formatters::NSSetSummaryProvider (ValueObject& valobj, Stream& str
value &= (is_64bit ? ~0xFC00000000000000UL : ~0xFC000000U);
}
/*else if (!strcmp(class_name,"__NSCFSet"))
- {
- Error error;
- value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + (is_64bit ? 20 : 12), 4, 0, error);
- if (error.Fail())
- return false;
- if (is_64bit)
- value &= ~0x1fff000000000000UL;
- }
- else if (!strcmp(class_name,"NSCountedSet"))
- {
- Error error;
- value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size, ptr_size, 0, error);
- if (error.Fail())
- return false;
- value = process_sp->ReadUnsignedIntegerFromMemory(value + (is_64bit ? 20 : 12), 4, 0, error);
- if (error.Fail())
- return false;
- if (is_64bit)
- value &= ~0x1fff000000000000UL;
- }*/
+ {
+ Error error;
+ value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + (is_64bit ? 20 : 12), 4, 0, error);
+ if (error.Fail())
+ return false;
+ if (is_64bit)
+ value &= ~0x1fff000000000000UL;
+ }
+ else if (!strcmp(class_name,"NSCountedSet"))
+ {
+ Error error;
+ value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size, ptr_size, 0, error);
+ if (error.Fail())
+ return false;
+ value = process_sp->ReadUnsignedIntegerFromMemory(value + (is_64bit ? 20 : 12), 4, 0, error);
+ if (error.Fail())
+ return false;
+ if (is_64bit)
+ value &= ~0x1fff000000000000UL;
+ }*/
else
{
+ auto& map(NSSet_Additionals::GetAdditionalSummaries());
+ auto iter = map.find(class_name_cs), end = map.end();
+ if (iter != end)
+ return iter->second(valobj, stream, options);
if (!ExtractValueFromObjCExpression(valobj, "int", "count", value))
return false;
}
- stream.Printf("%s%" PRIu64 " %s%s",
- (cf_style ? "@\"" : ""),
+ std::string prefix,suffix;
+ if (Language* language = Language::FindPlugin(options.GetLanguage()))
+ {
+ if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix, suffix))
+ {
+ prefix.clear();
+ suffix.clear();
+ }
+ }
+
+ stream.Printf("%s%" PRIu64 " %s%s%s",
+ prefix.c_str(),
value,
- (cf_style ? (value == 1 ? "value" : "values") : (value == 1 ? "object" : "objects")),
- (cf_style ? "\"" : ""));
+ "element",
+ value == 1 ? "" : "s",
+ suffix.c_str());
return true;
}
-SyntheticChildrenFrontEnd* lldb_private::formatters::NSSetSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
+SyntheticChildrenFrontEnd* lldb_private::formatters::NSSetSyntheticFrontEndCreator (CXXSyntheticChildren* synth, lldb::ValueObjectSP valobj_sp)
{
lldb::ProcessSP process_sp (valobj_sp->GetProcessSP());
if (!process_sp)
@@ -272,7 +309,10 @@ SyntheticChildrenFrontEnd* lldb_private::formatters::NSSetSyntheticFrontEndCreat
if (!runtime)
return NULL;
- if (!valobj_sp->IsPointerType())
+ CompilerType valobj_type(valobj_sp->GetCompilerType());
+ Flags flags(valobj_type.GetTypeInfo());
+
+ if (flags.IsClear(eTypeIsPointer))
{
Error error;
valobj_sp = valobj_sp->AddressOf(error);
@@ -285,7 +325,8 @@ SyntheticChildrenFrontEnd* lldb_private::formatters::NSSetSyntheticFrontEndCreat
if (!descriptor.get() || !descriptor->IsValid())
return NULL;
- const char* class_name = descriptor->GetClassName().GetCString();
+ ConstString class_name_cs = descriptor->GetClassName();
+ const char* class_name = class_name_cs.GetCString();
if (!class_name || !*class_name)
return NULL;
@@ -304,6 +345,10 @@ SyntheticChildrenFrontEnd* lldb_private::formatters::NSSetSyntheticFrontEndCreat
}
else
{
+ auto& map(NSSet_Additionals::GetAdditionalSynthetics());
+ auto iter = map.find(class_name_cs), end = map.end();
+ if (iter != end)
+ return iter->second(synth, valobj_sp);
return /*(new NSSetCodeRunningSyntheticFrontEnd(valobj_sp))*/ NULL;
}
}
@@ -467,10 +512,10 @@ lldb_private::formatters::NSSetISyntheticFrontEnd::GetChildAtIndex (size_t idx)
process_sp->GetAddressByteSize());
set_item.valobj_sp =
- CreateValueObjectFromData(idx_name.GetData(),
- data,
- m_exe_ctx_ref,
- m_backend.GetClangType().GetBasicTypeFromAST(lldb::eBasicTypeObjCID));
+ CreateValueObjectFromData(idx_name.GetData(),
+ data,
+ m_exe_ctx_ref,
+ m_backend.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeObjCID));
}
return set_item.valobj_sp;
}
@@ -565,7 +610,7 @@ lldb::ValueObjectSP
lldb_private::formatters::NSSetMSyntheticFrontEnd::GetChildAtIndex (size_t idx)
{
lldb::addr_t m_objs_addr = (m_data_32 ? m_data_32->_objs_addr : m_data_64->_objs_addr);
-
+
uint32_t num_children = CalculateNumChildren();
if (idx >= num_children)
@@ -635,10 +680,10 @@ lldb_private::formatters::NSSetMSyntheticFrontEnd::GetChildAtIndex (size_t idx)
process_sp->GetAddressByteSize());
set_item.valobj_sp =
- CreateValueObjectFromData(idx_name.GetData(),
- data,
- m_exe_ctx_ref,
- m_backend.GetClangType().GetBasicTypeFromAST(lldb::eBasicTypeObjCID));
+ CreateValueObjectFromData(idx_name.GetData(),
+ data,
+ m_exe_ctx_ref,
+ m_backend.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeObjCID));
}
return set_item.valobj_sp;
}
@@ -706,10 +751,6 @@ lldb_private::formatters::NSOrderedSetSyntheticFrontEnd::GetIndexOfChildWithName
return idx;
}
-lldb_private::formatters::NSOrderedSetSyntheticFrontEnd::~NSOrderedSetSyntheticFrontEnd ()
-{
-}
-
template bool
lldb_private::formatters::NSSetSummaryProvider<true> (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
diff --git a/source/Plugins/Language/ObjC/NSSet.h b/source/Plugins/Language/ObjC/NSSet.h
new file mode 100644
index 000000000000..c8622706e860
--- /dev/null
+++ b/source/Plugins/Language/ObjC/NSSet.h
@@ -0,0 +1,40 @@
+//===-- NSSet.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_NSSet_h_
+#define liblldb_NSSet_h_
+
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
+
+namespace lldb_private {
+ namespace formatters
+ {
+ template<bool cf_style>
+ bool
+ NSSetSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ SyntheticChildrenFrontEnd* NSSetSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
+
+ class NSSet_Additionals
+ {
+ public:
+ static std::map<ConstString, CXXFunctionSummaryFormat::Callback>&
+ GetAdditionalSummaries ();
+
+ static std::map<ConstString, CXXSyntheticChildren::CreateFrontEndCallback>&
+ GetAdditionalSynthetics ();
+ };
+ } // namespace formatters
+} // namespace lldb_private
+
+#endif // liblldb_NSSet_h_
diff --git a/source/Plugins/Language/ObjC/NSString.cpp b/source/Plugins/Language/ObjC/NSString.cpp
new file mode 100644
index 000000000000..80896631baf3
--- /dev/null
+++ b/source/Plugins/Language/ObjC/NSString.cpp
@@ -0,0 +1,405 @@
+//===-- NSString.cpp ----------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "NSString.h"
+
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/Error.h"
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/DataFormatters/StringPrinter.h"
+#include "lldb/Host/Endian.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Target/Language.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/ProcessStructReader.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+std::map<ConstString, CXXFunctionSummaryFormat::Callback>&
+NSString_Additionals::GetAdditionalSummaries ()
+{
+ static std::map<ConstString, CXXFunctionSummaryFormat::Callback> g_map;
+ return g_map;
+}
+
+static CompilerType
+GetNSPathStore2Type (Target &target)
+{
+ static ConstString g_type_name("__lldb_autogen_nspathstore2");
+
+ ClangASTContext *ast_ctx = target.GetScratchClangASTContext();
+
+ if (!ast_ctx)
+ return CompilerType();
+
+ CompilerType voidstar = ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType();
+ CompilerType uint32 = ast_ctx->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 32);
+
+ return ast_ctx->GetOrCreateStructForIdentifier(g_type_name, {
+ {"isa",voidstar},
+ {"lengthAndRef",uint32},
+ {"buffer",voidstar}
+ });
+}
+
+bool
+lldb_private::formatters::NSStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& summary_options)
+{
+ static ConstString g_TypeHint("NSString");
+
+ ProcessSP process_sp = valobj.GetProcessSP();
+ if (!process_sp)
+ return false;
+
+ ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
+
+ if (!runtime)
+ return false;
+
+ ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
+
+ if (!descriptor.get() || !descriptor->IsValid())
+ return false;
+
+ uint32_t ptr_size = process_sp->GetAddressByteSize();
+
+ lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
+
+ if (!valobj_addr)
+ return false;
+
+ ConstString class_name_cs = descriptor->GetClassName();
+ const char* class_name = class_name_cs.GetCString();
+
+ if (!class_name || !*class_name)
+ return false;
+
+ bool is_tagged_ptr = (0 == strcmp(class_name,"NSTaggedPointerString")) && descriptor->GetTaggedPointerInfo();
+ // for a tagged pointer, the descriptor has everything we need
+ if (is_tagged_ptr)
+ return NSTaggedString_SummaryProvider(valobj, descriptor, stream, summary_options);
+
+ auto& additionals_map(NSString_Additionals::GetAdditionalSummaries());
+ auto iter = additionals_map.find(class_name_cs), end = additionals_map.end();
+ if (iter != end)
+ return iter->second(valobj, stream, summary_options);
+
+ // if not a tagged pointer that we know about, try the normal route
+ uint64_t info_bits_location = valobj_addr + ptr_size;
+ if (process_sp->GetByteOrder() != lldb::eByteOrderLittle)
+ info_bits_location += 3;
+
+ Error error;
+
+ uint8_t info_bits = process_sp->ReadUnsignedIntegerFromMemory(info_bits_location, 1, 0, error);
+ if (error.Fail())
+ return false;
+
+ bool is_mutable = (info_bits & 1) == 1;
+ bool is_inline = (info_bits & 0x60) == 0;
+ bool has_explicit_length = (info_bits & (1 | 4)) != 4;
+ bool is_unicode = (info_bits & 0x10) == 0x10;
+ bool is_path_store = strcmp(class_name,"NSPathStore2") == 0;
+ bool has_null = (info_bits & 8) == 8;
+
+ size_t explicit_length = 0;
+ if (!has_null && has_explicit_length && !is_path_store)
+ {
+ lldb::addr_t explicit_length_offset = 2*ptr_size;
+ if (is_mutable && !is_inline)
+ explicit_length_offset = explicit_length_offset + ptr_size; // notInlineMutable.length;
+ else if (is_inline)
+ explicit_length = explicit_length + 0; // inline1.length;
+ else if (!is_inline && !is_mutable)
+ explicit_length_offset = explicit_length_offset + ptr_size; // notInlineImmutable1.length;
+ else
+ explicit_length_offset = 0;
+
+ if (explicit_length_offset)
+ {
+ explicit_length_offset = valobj_addr + explicit_length_offset;
+ explicit_length = process_sp->ReadUnsignedIntegerFromMemory(explicit_length_offset, 4, 0, error);
+ }
+ }
+
+ if (strcmp(class_name,"NSString") &&
+ strcmp(class_name,"CFStringRef") &&
+ strcmp(class_name,"CFMutableStringRef") &&
+ strcmp(class_name,"__NSCFConstantString") &&
+ strcmp(class_name,"__NSCFString") &&
+ strcmp(class_name,"NSCFConstantString") &&
+ strcmp(class_name,"NSCFString") &&
+ strcmp(class_name,"NSPathStore2"))
+ {
+ // not one of us - but tell me class name
+ stream.Printf("class name = %s",class_name);
+ return true;
+ }
+
+ std::string prefix,suffix;
+ if (Language* language = Language::FindPlugin(summary_options.GetLanguage()))
+ {
+ if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix, suffix))
+ {
+ prefix.clear();
+ suffix.clear();
+ }
+ }
+
+ StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
+ options.SetPrefixToken(prefix);
+ options.SetSuffixToken(suffix);
+
+ if (is_mutable)
+ {
+ uint64_t location = 2 * ptr_size + valobj_addr;
+ location = process_sp->ReadPointerFromMemory(location, error);
+ if (error.Fail())
+ return false;
+ if (has_explicit_length && is_unicode)
+ {
+ options.SetLocation(location);
+ options.SetProcessSP(process_sp);
+ options.SetStream(&stream);
+ options.SetQuote('"');
+ options.SetSourceSize(explicit_length);
+ options.SetNeedsZeroTermination(false);
+ options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped);
+ options.SetBinaryZeroIsTerminator(false);
+ options.SetLanguage(summary_options.GetLanguage());
+ return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF16>(options);
+ }
+ else
+ {
+ options.SetLocation(location+1);
+ options.SetProcessSP(process_sp);
+ options.SetStream(&stream);
+ options.SetSourceSize(explicit_length);
+ options.SetNeedsZeroTermination(false);
+ options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped);
+ options.SetBinaryZeroIsTerminator(false);
+ options.SetLanguage(summary_options.GetLanguage());
+ return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::ASCII>(options);
+ }
+ }
+ else if (is_inline && has_explicit_length && !is_unicode && !is_path_store && !is_mutable)
+ {
+ uint64_t location = 3 * ptr_size + valobj_addr;
+
+ options.SetLocation(location);
+ options.SetProcessSP(process_sp);
+ options.SetStream(&stream);
+ options.SetQuote('"');
+ options.SetSourceSize(explicit_length);
+ options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped);
+ options.SetLanguage(summary_options.GetLanguage());
+ return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::ASCII> (options);
+ }
+ else if (is_unicode)
+ {
+ uint64_t location = valobj_addr + 2*ptr_size;
+ if (is_inline)
+ {
+ if (!has_explicit_length)
+ {
+ stream.Printf("found new combo");
+ return true;
+ }
+ else
+ location += ptr_size;
+ }
+ else
+ {
+ location = process_sp->ReadPointerFromMemory(location, error);
+ if (error.Fail())
+ return false;
+ }
+ options.SetLocation(location);
+ options.SetProcessSP(process_sp);
+ options.SetStream(&stream);
+ options.SetQuote('"');
+ options.SetSourceSize(explicit_length);
+ options.SetNeedsZeroTermination(has_explicit_length == false);
+ options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped);
+ options.SetBinaryZeroIsTerminator(has_explicit_length == false);
+ options.SetLanguage(summary_options.GetLanguage());
+ return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF16> (options);
+ }
+ else if (is_path_store)
+ {
+ ProcessStructReader reader(valobj.GetProcessSP().get(), valobj.GetValueAsUnsigned(0), GetNSPathStore2Type(*valobj.GetTargetSP()));
+ explicit_length = reader.GetField<uint32_t>(ConstString("lengthAndRef")) >> 20;
+ lldb::addr_t location = valobj.GetValueAsUnsigned(0) + ptr_size + 4;
+
+ options.SetLocation(location);
+ options.SetProcessSP(process_sp);
+ options.SetStream(&stream);
+ options.SetQuote('"');
+ options.SetSourceSize(explicit_length);
+ options.SetNeedsZeroTermination(has_explicit_length == false);
+ options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped);
+ options.SetBinaryZeroIsTerminator(has_explicit_length == false);
+ options.SetLanguage(summary_options.GetLanguage());
+ return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF16> (options);
+ }
+ else if (is_inline)
+ {
+ uint64_t location = valobj_addr + 2*ptr_size;
+ if (!has_explicit_length)
+ {
+ // in this kind of string, the byte before the string content is a length byte
+ // so let's try and use it to handle the embedded NUL case
+ Error error;
+ explicit_length = process_sp->ReadUnsignedIntegerFromMemory(location, 1, 0, error);
+ if (error.Fail() || explicit_length == 0)
+ has_explicit_length = false;
+ else
+ has_explicit_length = true;
+ location++;
+ }
+ options.SetLocation(location);
+ options.SetProcessSP(process_sp);
+ options.SetStream(&stream);
+ options.SetSourceSize(explicit_length);
+ options.SetNeedsZeroTermination(!has_explicit_length);
+ options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped);
+ options.SetBinaryZeroIsTerminator(!has_explicit_length);
+ options.SetLanguage(summary_options.GetLanguage());
+ if (has_explicit_length)
+ return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF8>(options);
+ else
+ return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::ASCII>(options);
+ }
+ else
+ {
+ uint64_t location = valobj_addr + 2*ptr_size;
+ location = process_sp->ReadPointerFromMemory(location, error);
+ if (error.Fail())
+ return false;
+ if (has_explicit_length && !has_null)
+ explicit_length++; // account for the fact that there is no NULL and we need to have one added
+ options.SetLocation(location);
+ options.SetProcessSP(process_sp);
+ options.SetStream(&stream);
+ options.SetSourceSize(explicit_length);
+ options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped);
+ options.SetLanguage(summary_options.GetLanguage());
+ return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::ASCII>(options);
+ }
+}
+
+bool
+lldb_private::formatters::NSAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
+{
+ TargetSP target_sp(valobj.GetTargetSP());
+ if (!target_sp)
+ return false;
+ uint32_t addr_size = target_sp->GetArchitecture().GetAddressByteSize();
+ uint64_t pointer_value = valobj.GetValueAsUnsigned(0);
+ if (!pointer_value)
+ return false;
+ pointer_value += addr_size;
+ CompilerType type(valobj.GetCompilerType());
+ ExecutionContext exe_ctx(target_sp,false);
+ ValueObjectSP child_ptr_sp(valobj.CreateValueObjectFromAddress("string_ptr", pointer_value, exe_ctx, type));
+ if (!child_ptr_sp)
+ return false;
+ DataExtractor data;
+ Error error;
+ child_ptr_sp->GetData(data, error);
+ if (error.Fail())
+ return false;
+ ValueObjectSP child_sp(child_ptr_sp->CreateValueObjectFromData("string_data", data, exe_ctx, type));
+ child_sp->GetValueAsUnsigned(0);
+ if (child_sp)
+ return NSStringSummaryProvider(*child_sp, stream, options);
+ return false;
+}
+
+bool
+lldb_private::formatters::NSMutableAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
+{
+ return NSAttributedStringSummaryProvider(valobj, stream, options);
+}
+
+bool
+lldb_private::formatters::NSTaggedString_SummaryProvider (ValueObject& valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, Stream& stream, const TypeSummaryOptions& summary_options)
+{
+ static ConstString g_TypeHint("NSString");
+
+ if (!descriptor)
+ return false;
+ uint64_t len_bits = 0, data_bits = 0;
+ if (!descriptor->GetTaggedPointerInfo(&len_bits,&data_bits,nullptr))
+ return false;
+
+ static const int g_MaxNonBitmaskedLen = 7; //TAGGED_STRING_UNPACKED_MAXLEN
+ static const int g_SixbitMaxLen = 9;
+ static const int g_fiveBitMaxLen = 11;
+
+ static const char *sixBitToCharLookup = "eilotrm.apdnsIc ufkMShjTRxgC4013" "bDNvwyUL2O856P-B79AFKEWV_zGJ/HYX";
+
+ if (len_bits > g_fiveBitMaxLen)
+ return false;
+
+ std::string prefix,suffix;
+ if (Language* language = Language::FindPlugin(summary_options.GetLanguage()))
+ {
+ if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix, suffix))
+ {
+ prefix.clear();
+ suffix.clear();
+ }
+ }
+
+ // this is a fairly ugly trick - pretend that the numeric value is actually a char*
+ // this works under a few assumptions:
+ // little endian architecture
+ // sizeof(uint64_t) > g_MaxNonBitmaskedLen
+ if (len_bits <= g_MaxNonBitmaskedLen)
+ {
+ stream.Printf("%s",prefix.c_str());
+ stream.Printf("\"%s\"",(const char*)&data_bits);
+ stream.Printf("%s",suffix.c_str());
+ return true;
+ }
+
+ // if the data is bitmasked, we need to actually process the bytes
+ uint8_t bitmask = 0;
+ uint8_t shift_offset = 0;
+
+ if (len_bits <= g_SixbitMaxLen)
+ {
+ bitmask = 0x03f;
+ shift_offset = 6;
+ }
+ else
+ {
+ bitmask = 0x01f;
+ shift_offset = 5;
+ }
+
+ std::vector<uint8_t> bytes;
+ bytes.resize(len_bits);
+ for (; len_bits > 0; data_bits >>= shift_offset, --len_bits)
+ {
+ uint8_t packed = data_bits & bitmask;
+ bytes.insert(bytes.begin(), sixBitToCharLookup[packed]);
+ }
+
+ stream.Printf("%s",prefix.c_str());
+ stream.Printf("\"%s\"",&bytes[0]);
+ stream.Printf("%s",suffix.c_str());
+ return true;
+}
diff --git a/source/Plugins/Language/ObjC/NSString.h b/source/Plugins/Language/ObjC/NSString.h
new file mode 100644
index 000000000000..6a767a55e009
--- /dev/null
+++ b/source/Plugins/Language/ObjC/NSString.h
@@ -0,0 +1,42 @@
+//===-- NSString.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_NSString_h_
+#define liblldb_NSString_h_
+
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
+
+namespace lldb_private {
+ namespace formatters
+ {
+ bool
+ NSStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ bool
+ NSTaggedString_SummaryProvider (ValueObject& valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, Stream& stream, const TypeSummaryOptions& summary_options);
+
+ bool
+ NSAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ bool
+ NSMutableAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
+
+ class NSString_Additionals
+ {
+ public:
+ static std::map<ConstString, CXXFunctionSummaryFormat::Callback>&
+ GetAdditionalSummaries ();
+ };
+ } // namespace formatters
+} // namespace lldb_private
+
+#endif // liblldb_CF_h_
diff --git a/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/source/Plugins/Language/ObjC/ObjCLanguage.cpp
new file mode 100644
index 000000000000..91a3a0fb4299
--- /dev/null
+++ b/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -0,0 +1,877 @@
+//===-- ObjCLanguage.cpp ----------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C Includes
+// C++ Includes
+#include <mutex>
+
+// Other libraries and framework includes
+// Project includes
+#include "ObjCLanguage.h"
+
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Symbol/ClangASTContext.h"
+
+#include "CF.h"
+#include "Cocoa.h"
+#include "CoreMedia.h"
+#include "NSDictionary.h"
+#include "NSSet.h"
+#include "NSString.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+void
+ObjCLanguage::Initialize()
+{
+ PluginManager::RegisterPlugin (GetPluginNameStatic(),
+ "Objective-C Language",
+ CreateInstance);
+}
+
+void
+ObjCLanguage::Terminate()
+{
+ PluginManager::UnregisterPlugin (CreateInstance);
+}
+
+lldb_private::ConstString
+ObjCLanguage::GetPluginNameStatic()
+{
+ static ConstString g_name("objc");
+ return g_name;
+}
+
+//------------------------------------------------------------------
+// PluginInterface protocol
+//------------------------------------------------------------------
+lldb_private::ConstString
+ObjCLanguage::GetPluginName()
+{
+ return GetPluginNameStatic();
+}
+
+uint32_t
+ObjCLanguage::GetPluginVersion()
+{
+ return 1;
+}
+
+//------------------------------------------------------------------
+// Static Functions
+//------------------------------------------------------------------
+Language *
+ObjCLanguage::CreateInstance (lldb::LanguageType language)
+{
+ switch (language)
+ {
+ case lldb::eLanguageTypeObjC:
+ return new ObjCLanguage();
+ default:
+ return nullptr;
+ }
+}
+
+void
+ObjCLanguage::MethodName::Clear()
+{
+ m_full.Clear();
+ m_class.Clear();
+ m_category.Clear();
+ m_selector.Clear();
+ m_type = eTypeUnspecified;
+ m_category_is_valid = false;
+}
+
+bool
+ObjCLanguage::MethodName::SetName (const char *name, bool strict)
+{
+ Clear();
+ if (name && name[0])
+ {
+ // If "strict" is true. then the method must be specified with a
+ // '+' or '-' at the beginning. If "strict" is false, then the '+'
+ // or '-' can be omitted
+ bool valid_prefix = false;
+
+ if (name[0] == '+' || name[0] == '-')
+ {
+ valid_prefix = name[1] == '[';
+ if (name[0] == '+')
+ m_type = eTypeClassMethod;
+ else
+ m_type = eTypeInstanceMethod;
+ }
+ else if (!strict)
+ {
+ // "strict" is false, the name just needs to start with '['
+ valid_prefix = name[0] == '[';
+ }
+
+ if (valid_prefix)
+ {
+ int name_len = strlen (name);
+ // Objective C methods must have at least:
+ // "-[" or "+[" prefix
+ // One character for a class name
+ // One character for the space between the class name
+ // One character for the method name
+ // "]" suffix
+ if (name_len >= (5 + (strict ? 1 : 0)) && name[name_len - 1] == ']')
+ {
+ m_full.SetCStringWithLength(name, name_len);
+ }
+ }
+ }
+ return IsValid(strict);
+}
+
+const ConstString &
+ObjCLanguage::MethodName::GetClassName ()
+{
+ if (!m_class)
+ {
+ if (IsValid(false))
+ {
+ const char *full = m_full.GetCString();
+ const char *class_start = (full[0] == '[' ? full + 1 : full + 2);
+ const char *paren_pos = strchr (class_start, '(');
+ if (paren_pos)
+ {
+ m_class.SetCStringWithLength (class_start, paren_pos - class_start);
+ }
+ else
+ {
+ // No '(' was found in the full name, we can definitively say
+ // that our category was valid (and empty).
+ m_category_is_valid = true;
+ const char *space_pos = strchr (full, ' ');
+ if (space_pos)
+ {
+ m_class.SetCStringWithLength (class_start, space_pos - class_start);
+ if (!m_class_category)
+ {
+ // No category in name, so we can also fill in the m_class_category
+ m_class_category = m_class;
+ }
+ }
+ }
+ }
+ }
+ return m_class;
+}
+
+const ConstString &
+ObjCLanguage::MethodName::GetClassNameWithCategory ()
+{
+ if (!m_class_category)
+ {
+ if (IsValid(false))
+ {
+ const char *full = m_full.GetCString();
+ const char *class_start = (full[0] == '[' ? full + 1 : full + 2);
+ const char *space_pos = strchr (full, ' ');
+ if (space_pos)
+ {
+ m_class_category.SetCStringWithLength (class_start, space_pos - class_start);
+ // If m_class hasn't been filled in and the class with category doesn't
+ // contain a '(', then we can also fill in the m_class
+ if (!m_class && strchr (m_class_category.GetCString(), '(') == NULL)
+ {
+ m_class = m_class_category;
+ // No '(' was found in the full name, we can definitively say
+ // that our category was valid (and empty).
+ m_category_is_valid = true;
+
+ }
+ }
+ }
+ }
+ return m_class_category;
+}
+
+const ConstString &
+ObjCLanguage::MethodName::GetSelector ()
+{
+ if (!m_selector)
+ {
+ if (IsValid(false))
+ {
+ const char *full = m_full.GetCString();
+ const char *space_pos = strchr (full, ' ');
+ if (space_pos)
+ {
+ ++space_pos; // skip the space
+ m_selector.SetCStringWithLength (space_pos, m_full.GetLength() - (space_pos - full) - 1);
+ }
+ }
+ }
+ return m_selector;
+}
+
+const ConstString &
+ObjCLanguage::MethodName::GetCategory ()
+{
+ if (!m_category_is_valid && !m_category)
+ {
+ if (IsValid(false))
+ {
+ m_category_is_valid = true;
+ const char *full = m_full.GetCString();
+ const char *class_start = (full[0] == '[' ? full + 1 : full + 2);
+ const char *open_paren_pos = strchr (class_start, '(');
+ if (open_paren_pos)
+ {
+ ++open_paren_pos; // Skip the open paren
+ const char *close_paren_pos = strchr (open_paren_pos, ')');
+ if (close_paren_pos)
+ m_category.SetCStringWithLength (open_paren_pos, close_paren_pos - open_paren_pos);
+ }
+ }
+ }
+ return m_category;
+}
+
+ConstString
+ObjCLanguage::MethodName::GetFullNameWithoutCategory (bool empty_if_no_category)
+{
+ if (IsValid(false))
+ {
+ if (HasCategory())
+ {
+ StreamString strm;
+ if (m_type == eTypeClassMethod)
+ strm.PutChar('+');
+ else if (m_type == eTypeInstanceMethod)
+ strm.PutChar('-');
+ strm.Printf("[%s %s]", GetClassName().GetCString(), GetSelector().GetCString());
+ return ConstString(strm.GetString().c_str());
+ }
+
+ if (!empty_if_no_category)
+ {
+ // Just return the full name since it doesn't have a category
+ return GetFullName();
+ }
+ }
+ return ConstString();
+}
+
+size_t
+ObjCLanguage::MethodName::GetFullNames (std::vector<ConstString> &names, bool append)
+{
+ if (!append)
+ names.clear();
+ if (IsValid(false))
+ {
+ 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.push_back(ConstString(strm.GetString().c_str()));
+ }
+ }
+ else
+ {
+ const ConstString &class_name = GetClassName();
+ const ConstString &selector = GetSelector();
+ strm.Printf("+[%s %s]", class_name.GetCString(), selector.GetCString());
+ names.push_back(ConstString(strm.GetString().c_str()));
+ strm.Clear();
+ strm.Printf("-[%s %s]", class_name.GetCString(), selector.GetCString());
+ names.push_back(ConstString(strm.GetString().c_str()));
+ strm.Clear();
+ if (category)
+ {
+ strm.Printf("+[%s(%s) %s]", class_name.GetCString(), category.GetCString(), selector.GetCString());
+ names.push_back(ConstString(strm.GetString().c_str()));
+ strm.Clear();
+ strm.Printf("-[%s(%s) %s]", class_name.GetCString(), category.GetCString(), selector.GetCString());
+ names.push_back(ConstString(strm.GetString().c_str()));
+ }
+ }
+ }
+ return names.size();
+}
+
+static void
+LoadObjCFormatters(TypeCategoryImplSP objc_category_sp)
+{
+ if (!objc_category_sp)
+ return;
+
+ TypeSummaryImpl::Flags objc_flags;
+ objc_flags.SetCascades(false)
+ .SetSkipPointers(true)
+ .SetSkipReferences(true)
+ .SetDontShowChildren(true)
+ .SetDontShowValue(true)
+ .SetShowMembersOneLiner(false)
+ .SetHideItemNames(false);
+
+ lldb::TypeSummaryImplSP ObjC_BOOL_summary(new CXXFunctionSummaryFormat(objc_flags, lldb_private::formatters::ObjCBOOLSummaryProvider,""));
+ objc_category_sp->GetTypeSummariesContainer()->Add(ConstString("BOOL"),
+ ObjC_BOOL_summary);
+ objc_category_sp->GetTypeSummariesContainer()->Add(ConstString("BOOL &"),
+ ObjC_BOOL_summary);
+ 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);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<false>, "SEL summary provider", ConstString("SEL"), objc_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<false>, "SEL summary provider", ConstString("struct objc_selector"), objc_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<false>, "SEL summary provider", ConstString("objc_selector"), objc_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<true>, "SEL summary provider", ConstString("objc_selector *"), objc_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<true>, "SEL summary provider", ConstString("SEL *"), objc_flags);
+
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCClassSummaryProvider, "Class summary provider", ConstString("Class"), objc_flags);
+
+ SyntheticChildren::Flags class_synth_flags;
+ class_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(false);
+
+ AddCXXSynthetic(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);
+ objc_flags.SetSkipReferences(false);
+
+ AddStringSummary (objc_category_sp,
+ "${var.__FuncPtr%A}",
+ ConstString("__block_literal_generic"),
+ objc_flags);
+
+ AddStringSummary(objc_category_sp,
+ "${var.years} years, ${var.months} months, ${var.days} days, ${var.hours} hours, ${var.minutes} minutes ${var.seconds} seconds",
+ ConstString("CFGregorianUnits"),
+ objc_flags);
+ AddStringSummary(objc_category_sp,
+ "location=${var.location} length=${var.length}",
+ ConstString("CFRange"),
+ objc_flags);
+
+ AddStringSummary(objc_category_sp,
+ "location=${var.location}, length=${var.length}",
+ ConstString("NSRange"),
+ objc_flags);
+ AddStringSummary(objc_category_sp,
+ "(${var.origin}, ${var.size}), ...",
+ ConstString("NSRectArray"),
+ objc_flags);
+
+ AddOneLineSummary (objc_category_sp,
+ ConstString("NSPoint"),
+ objc_flags);
+ AddOneLineSummary (objc_category_sp,
+ ConstString("NSSize"),
+ objc_flags);
+ AddOneLineSummary (objc_category_sp,
+ ConstString("NSRect"),
+ objc_flags);
+
+ AddOneLineSummary (objc_category_sp,
+ ConstString("CGSize"),
+ objc_flags);
+ AddOneLineSummary (objc_category_sp,
+ ConstString("CGPoint"),
+ objc_flags);
+ AddOneLineSummary (objc_category_sp,
+ ConstString("CGRect"),
+ objc_flags);
+
+ AddStringSummary(objc_category_sp,
+ "red=${var.red} green=${var.green} blue=${var.blue}",
+ ConstString("RGBColor"),
+ objc_flags);
+ AddStringSummary(objc_category_sp,
+ "(t=${var.top}, l=${var.left}, b=${var.bottom}, r=${var.right})",
+ ConstString("Rect"),
+ objc_flags);
+ AddStringSummary(objc_category_sp,
+ "{(v=${var.v}, h=${var.h})}",
+ ConstString("Point"),
+ objc_flags);
+ AddStringSummary(objc_category_sp,
+ "${var.month}/${var.day}/${var.year} ${var.hour} :${var.minute} :${var.second} dayOfWeek:${var.dayOfWeek}",
+ ConstString("DateTimeRect *"),
+ objc_flags);
+ AddStringSummary(objc_category_sp,
+ "${var.ld.month}/${var.ld.day}/${var.ld.year} ${var.ld.hour} :${var.ld.minute} :${var.ld.second} dayOfWeek:${var.ld.dayOfWeek}",
+ ConstString("LongDateRect"),
+ objc_flags);
+ AddStringSummary(objc_category_sp,
+ "(x=${var.x}, y=${var.y})",
+ ConstString("HIPoint"),
+ objc_flags);
+ AddStringSummary(objc_category_sp,
+ "origin=${var.origin} size=${var.size}",
+ ConstString("HIRect"),
+ objc_flags);
+
+ TypeSummaryImpl::Flags appkit_flags;
+ appkit_flags.SetCascades(true)
+ .SetSkipPointers(false)
+ .SetSkipReferences(false)
+ .SetDontShowChildren(true)
+ .SetDontShowValue(false)
+ .SetShowMembersOneLiner(false)
+ .SetHideItemNames(false);
+
+ appkit_flags.SetDontShowChildren(false);
+
+#ifndef LLDB_DISABLE_PYTHON
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("NSArray"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("NSMutableArray"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("__NSArrayI"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("__NSArray0"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("__NSArrayM"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("__NSCFArray"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("CFArrayRef"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("CFMutableArrayRef"), appkit_flags);
+
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<false>, "NSDictionary summary provider", ConstString("NSDictionary"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<false>, "NSDictionary summary provider", ConstString("NSMutableDictionary"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<false>, "NSDictionary summary provider", ConstString("__NSCFDictionary"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<false>, "NSDictionary summary provider", ConstString("__NSDictionaryI"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<false>, "NSDictionary summary provider", ConstString("__NSDictionaryM"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<true>, "NSDictionary summary provider", ConstString("CFDictionaryRef"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<true>, "NSDictionary summary provider", ConstString("CFMutableDictionaryRef"), appkit_flags);
+
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "NSSet summary", ConstString("NSSet"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "NSMutableSet summary", ConstString("NSMutableSet"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSSetSummaryProvider<true>, "CFSetRef summary", ConstString("CFSetRef"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSSetSummaryProvider<true>, "CFMutableSetRef summary", ConstString("CFMutableSetRef"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "__NSCFSet summary", ConstString("__NSCFSet"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "__NSSetI summary", ConstString("__NSSetI"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "__NSSetM summary", ConstString("__NSSetM"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "NSCountedSet summary", ConstString("NSCountedSet"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "NSMutableSet summary", ConstString("NSMutableSet"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "NSOrderedSet summary", ConstString("NSOrderedSet"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "__NSOrderedSetI summary", ConstString("__NSOrderedSetI"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>, "__NSOrderedSetM summary", ConstString("__NSOrderedSetM"), appkit_flags);
+
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSError_SummaryProvider, "NSError summary provider", ConstString("NSError"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSException_SummaryProvider, "NSException summary provider", ConstString("NSException"), appkit_flags);
+
+ // AddSummary(appkit_category_sp, "${var.key%@} -> ${var.value%@}", ConstString("$_lldb_typegen_nspair"), appkit_flags);
+
+ appkit_flags.SetDontShowChildren(true);
+
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSArrayM"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSArrayI"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSArray0"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("NSArray"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("NSMutableArray"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSCFArray"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("CFMutableArrayRef"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("CFArrayRef"), ScriptedSyntheticChildren::Flags());
+
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("__NSDictionaryM"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("__NSDictionaryI"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("__NSCFDictionary"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("NSDictionary"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("NSMutableDictionary"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("CFDictionaryRef"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("CFMutableDictionaryRef"), ScriptedSyntheticChildren::Flags());
+
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSErrorSyntheticFrontEndCreator, "NSError synthetic children", ConstString("NSError"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSExceptionSyntheticFrontEndCreator, "NSException synthetic children", ConstString("NSException"), ScriptedSyntheticChildren::Flags());
+
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator, "NSSet synthetic children", ConstString("NSSet"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator, "__NSSetI synthetic children", ConstString("__NSSetI"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator, "__NSSetM synthetic children", ConstString("__NSSetM"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator, "NSMutableSet synthetic children", ConstString("NSMutableSet"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator, "NSOrderedSet synthetic children", ConstString("NSOrderedSet"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator, "__NSOrderedSetI synthetic children", ConstString("__NSOrderedSetI"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator, "__NSOrderedSetM synthetic children", ConstString("__NSOrderedSetM"), ScriptedSyntheticChildren::Flags());
+
+ AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSIndexPathSyntheticFrontEndCreator, "NSIndexPath synthetic children", ConstString("NSIndexPath"), ScriptedSyntheticChildren::Flags());
+
+ AddCXXSummary(objc_category_sp,lldb_private::formatters::CFBagSummaryProvider, "CFBag summary provider", ConstString("CFBagRef"), appkit_flags);
+ AddCXXSummary(objc_category_sp,lldb_private::formatters::CFBagSummaryProvider, "CFBag summary provider", ConstString("__CFBag"), appkit_flags);
+ AddCXXSummary(objc_category_sp,lldb_private::formatters::CFBagSummaryProvider, "CFBag summary provider", ConstString("const struct __CFBag"), appkit_flags);
+ AddCXXSummary(objc_category_sp,lldb_private::formatters::CFBagSummaryProvider, "CFBag summary provider", ConstString("CFMutableBagRef"), appkit_flags);
+
+ AddCXXSummary(objc_category_sp,lldb_private::formatters::CFBinaryHeapSummaryProvider, "CFBinaryHeap summary provider", ConstString("CFBinaryHeapRef"), appkit_flags);
+ AddCXXSummary(objc_category_sp,lldb_private::formatters::CFBinaryHeapSummaryProvider, "CFBinaryHeap summary provider", ConstString("__CFBinaryHeap"), appkit_flags);
+
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("NSString"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("CFStringRef"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("__CFString"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("CFMutableStringRef"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("NSMutableString"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("__NSCFConstantString"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("__NSCFString"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("NSCFConstantString"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("NSCFString"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("NSPathStore2"), appkit_flags);
+
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSAttributedStringSummaryProvider, "NSAttributedString summary provider", ConstString("NSAttributedString"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSMutableAttributedStringSummaryProvider, "NSMutableAttributedString summary provider", ConstString("NSMutableAttributedString"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSMutableAttributedStringSummaryProvider, "NSMutableAttributedString summary provider", ConstString("NSConcreteMutableAttributedString"), appkit_flags);
+
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSBundleSummaryProvider, "NSBundle summary provider", ConstString("NSBundle"), appkit_flags);
+
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("NSData"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("NSConcreteData"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("NSConcreteMutableData"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("NSMutableData"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("__NSCFData"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDataSummaryProvider<true>, "NSData summary provider", ConstString("CFDataRef"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDataSummaryProvider<true>, "NSData summary provider", ConstString("CFMutableDataRef"), appkit_flags);
+
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSMachPortSummaryProvider, "NSMachPort summary provider", ConstString("NSMachPort"), appkit_flags);
+
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSNotificationSummaryProvider, "NSNotification summary provider", ConstString("NSNotification"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSNotificationSummaryProvider, "NSNotification summary provider", ConstString("NSConcreteNotification"), appkit_flags);
+
+ AddStringSummary(objc_category_sp, "domain: ${var._domain} - code: ${var._code}", ConstString("NSError"), appkit_flags);
+ AddStringSummary(objc_category_sp,"name:${var.name%S} reason:${var.reason%S}",ConstString("NSException"),appkit_flags);
+
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("NSNumber"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "CFNumberRef summary provider", ConstString("CFNumberRef"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("__NSCFBoolean"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("__NSCFNumber"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("NSCFBoolean"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("NSCFNumber"), appkit_flags);
+
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSDecimalNumber summary provider", ConstString("NSDecimalNumber"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSHost summary provider", ConstString("NSHost"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSTask summary provider", ConstString("NSTask"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSValue summary provider", ConstString("NSValue"), appkit_flags);
+
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSURLSummaryProvider, "NSURL summary provider", ConstString("NSURL"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSURLSummaryProvider, "NSURL summary provider", ConstString("CFURLRef"), appkit_flags);
+
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDateSummaryProvider, "NSDate summary provider", ConstString("NSDate"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDateSummaryProvider, "NSDate summary provider", ConstString("__NSDate"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDateSummaryProvider, "NSDate summary provider", ConstString("__NSTaggedDate"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDateSummaryProvider, "NSDate summary provider", ConstString("NSCalendarDate"), appkit_flags);
+
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSTimeZoneSummaryProvider, "NSTimeZone summary provider", ConstString("NSTimeZone"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSTimeZoneSummaryProvider, "NSTimeZone summary provider", ConstString("CFTimeZoneRef"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSTimeZoneSummaryProvider, "NSTimeZone summary provider", ConstString("__NSTimeZone"), appkit_flags);
+
+ // CFAbsoluteTime is actually a double rather than a pointer to an object
+ // we do not care about the numeric value, since it is probably meaningless to users
+ appkit_flags.SetDontShowValue(true);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::CFAbsoluteTimeSummaryProvider, "CFAbsoluteTime summary provider", ConstString("CFAbsoluteTime"), appkit_flags);
+ appkit_flags.SetDontShowValue(false);
+
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSIndexSetSummaryProvider, "NSIndexSet summary provider", ConstString("NSIndexSet"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSIndexSetSummaryProvider, "NSIndexSet summary provider", ConstString("NSMutableIndexSet"), appkit_flags);
+
+ AddStringSummary(objc_category_sp,
+ "@\"${var.month%d}/${var.day%d}/${var.year%d} ${var.hour%d}:${var.minute%d}:${var.second}\"",
+ ConstString("CFGregorianDate"),
+ appkit_flags);
+
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::CFBitVectorSummaryProvider, "CFBitVector summary provider", ConstString("CFBitVectorRef"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::CFBitVectorSummaryProvider, "CFBitVector summary provider", ConstString("CFMutableBitVectorRef"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::CFBitVectorSummaryProvider, "CFBitVector summary provider", ConstString("__CFBitVector"), appkit_flags);
+ AddCXXSummary(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)
+{
+ if (!objc_category_sp)
+ return;
+
+ TypeSummaryImpl::Flags cm_flags;
+ cm_flags.SetCascades(true)
+ .SetDontShowChildren(false)
+ .SetDontShowValue(false)
+ .SetHideItemNames(false)
+ .SetShowMembersOneLiner(false)
+ .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 ()
+{
+ static std::once_flag g_initialize;
+ static TypeCategoryImplSP g_category;
+
+ std::call_once(g_initialize, [this] () -> void {
+ DataVisualization::Categories::GetCategory(GetPluginName(), g_category);
+ if (g_category)
+ {
+ LoadCoreMediaFormatters(g_category);
+ LoadObjCFormatters(g_category);
+ }
+ });
+ return g_category;
+}
+
+std::vector<ConstString>
+ObjCLanguage::GetPossibleFormattersMatches (ValueObject& valobj, lldb::DynamicValueType use_dynamic)
+{
+ std::vector<ConstString> result;
+
+ if (use_dynamic == lldb::eNoDynamicValues)
+ return result;
+
+ CompilerType compiler_type(valobj.GetCompilerType());
+
+ const bool check_cpp = false;
+ const bool check_objc = true;
+ bool canBeObjCDynamic = compiler_type.IsPossibleDynamicType(nullptr, check_cpp, check_objc);
+
+ if (canBeObjCDynamic)
+ {
+ do {
+ lldb::ProcessSP process_sp = valobj.GetProcessSP();
+ if (!process_sp)
+ break;
+ ObjCLanguageRuntime* runtime = process_sp->GetObjCLanguageRuntime();
+ if (runtime == nullptr)
+ break;
+ ObjCLanguageRuntime::ClassDescriptorSP objc_class_sp (runtime->GetClassDescriptor(valobj));
+ if (!objc_class_sp)
+ break;
+ if (ConstString name = objc_class_sp->GetClassName())
+ result.push_back(name);
+ } while (false);
+ }
+
+ return result;
+}
+
+std::unique_ptr<Language::TypeScavenger>
+ObjCLanguage::GetTypeScavenger ()
+{
+ class ObjCTypeScavenger : public Language::TypeScavenger
+ {
+ private:
+ class ObjCScavengerResult : public Language::TypeScavenger::Result
+ {
+ public:
+ ObjCScavengerResult (CompilerType type) :
+ Language::TypeScavenger::Result(),
+ m_compiler_type(type)
+ {
+ }
+
+ bool
+ IsValid () override
+ {
+ return m_compiler_type.IsValid();
+ }
+
+ bool
+ DumpToStream (Stream& stream,
+ bool print_help_if_available) override
+ {
+ if (IsValid())
+ {
+ m_compiler_type.DumpTypeDescription(&stream);
+ stream.EOL();
+ return true;
+ }
+ return false;
+ }
+
+ ~ObjCScavengerResult() override = default;
+
+ private:
+ CompilerType m_compiler_type;
+ };
+
+ protected:
+ ObjCTypeScavenger() = default;
+
+ ~ObjCTypeScavenger() override = default;
+
+ bool
+ Find_Impl (ExecutionContextScope *exe_scope,
+ const char *key,
+ ResultSet &results) override
+ {
+ bool result = false;
+
+ Target* target = exe_scope->CalculateTarget().get();
+ if (target)
+ {
+ 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.size() > 0)
+ {
+ CompilerType module_type = ClangASTContext::GetTypeForDecl(decls.front());
+ result = true;
+ std::unique_ptr<Language::TypeScavenger::Result> result(new ObjCScavengerResult(module_type));
+ results.insert(std::move(result));
+ }
+ }
+ }
+
+ if (!result)
+ {
+ 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;
+ 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));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ friend class lldb_private::ObjCLanguage;
+ };
+
+ return std::unique_ptr<TypeScavenger>(new ObjCTypeScavenger());
+}
+
+bool
+ObjCLanguage::GetFormatterPrefixSuffix (ValueObject& valobj, ConstString type_hint,
+ std::string& prefix, std::string& suffix)
+{
+ static ConstString g_CFBag("CFBag");
+ static ConstString g_CFBinaryHeap("CFBinaryHeap");
+
+ static ConstString g_NSNumberChar("NSNumber:char");
+ static ConstString g_NSNumberShort("NSNumber:short");
+ static ConstString g_NSNumberInt("NSNumber:int");
+ static ConstString g_NSNumberLong("NSNumber:long");
+ static ConstString g_NSNumberFloat("NSNumber:float");
+ static ConstString g_NSNumberDouble("NSNumber:double");
+
+ static ConstString g_NSData("NSData");
+ static ConstString g_NSArray("NSArray");
+ static ConstString g_NSString("NSString");
+ static ConstString g_NSStringStar("NSString*");
+
+ if (type_hint.IsEmpty())
+ return false;
+
+ prefix.clear();
+ suffix.clear();
+
+ if (type_hint == g_CFBag ||
+ type_hint == g_CFBinaryHeap)
+ {
+ prefix = "@";
+ return true;
+ }
+
+ if (type_hint == g_NSNumberChar)
+ {
+ prefix = "(char)";
+ return true;
+ }
+ if (type_hint == g_NSNumberShort)
+ {
+ prefix = "(short)";
+ return true;
+ }
+ if (type_hint == g_NSNumberInt)
+ {
+ prefix = "(int)";
+ return true;
+ }
+ if (type_hint == g_NSNumberLong)
+ {
+ prefix = "(long)";
+ return true;
+ }
+ if (type_hint == g_NSNumberFloat)
+ {
+ prefix = "(float)";
+ return true;
+ }
+ if (type_hint == g_NSNumberDouble)
+ {
+ prefix = "(double)";
+ return true;
+ }
+
+ if (type_hint == g_NSData ||
+ type_hint == g_NSArray)
+ {
+ prefix = "@\"";
+ suffix = "\"";
+ return true;
+ }
+
+ if (type_hint == g_NSString ||
+ type_hint == g_NSStringStar)
+ {
+ prefix = "@";
+ return true;
+ }
+
+ return false;
+}
+
+bool
+ObjCLanguage::IsNilReference (ValueObject& valobj)
+{
+ const uint32_t mask = eTypeIsObjC | eTypeIsPointer;
+ bool isObjCpointer = (((valobj.GetCompilerType().GetTypeInfo(nullptr)) & mask) == mask);
+ if (!isObjCpointer)
+ return false;
+ bool canReadValue = true;
+ bool isZero = valobj.GetValueAsUnsigned(0,&canReadValue) == 0;
+ return canReadValue && isZero;
+}
diff --git a/source/Plugins/Language/ObjC/ObjCLanguage.h b/source/Plugins/Language/ObjC/ObjCLanguage.h
new file mode 100644
index 000000000000..e30aa18c0443
--- /dev/null
+++ b/source/Plugins/Language/ObjC/ObjCLanguage.h
@@ -0,0 +1,210 @@
+//===-- ObjCLanguage.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_ObjCLanguage_h_
+#define liblldb_ObjCLanguage_h_
+
+// C Includes
+// C++ Includes
+#include <vector>
+
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-private.h"
+#include "lldb/Core/ConstString.h"
+#include "lldb/Target/Language.h"
+
+namespace lldb_private {
+
+class ObjCLanguage :
+ public Language
+{
+public:
+ class MethodName
+ {
+ public:
+ enum Type
+ {
+ eTypeUnspecified,
+ eTypeClassMethod,
+ eTypeInstanceMethod
+ };
+
+ MethodName () :
+ m_full(),
+ m_class(),
+ m_category(),
+ m_selector(),
+ m_type (eTypeUnspecified),
+ m_category_is_valid (false)
+ {
+ }
+
+ MethodName (const char *name, bool strict) :
+ m_full(),
+ m_class(),
+ m_category(),
+ m_selector(),
+ m_type (eTypeUnspecified),
+ m_category_is_valid (false)
+ {
+ SetName (name, strict);
+ }
+
+ void
+ Clear();
+
+ bool
+ IsValid (bool strict) const
+ {
+ // If "strict" is true, the name must have everything specified including
+ // the leading "+" or "-" on the method name
+ if (strict && m_type == eTypeUnspecified)
+ return false;
+ // Other than that, m_full will only be filled in if the objective C
+ // name is valid.
+ return (bool)m_full;
+ }
+
+ bool
+ HasCategory()
+ {
+ return !GetCategory().IsEmpty();
+ }
+
+ Type
+ GetType () const
+ {
+ return m_type;
+ }
+
+ const ConstString &
+ GetFullName () const
+ {
+ return m_full;
+ }
+
+ ConstString
+ GetFullNameWithoutCategory (bool empty_if_no_category);
+
+ bool
+ SetName (const char *name, bool strict);
+
+ const ConstString &
+ GetClassName ();
+
+ const ConstString &
+ GetClassNameWithCategory ();
+
+ const ConstString &
+ GetCategory ();
+
+ const ConstString &
+ GetSelector ();
+
+ // 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);
+
+ protected:
+ ConstString m_full; // Full name: "+[NSString(my_additions) myStringWithCString:]"
+ ConstString m_class; // Class name: "NSString"
+ ConstString m_class_category; // Class with category: "NSString(my_additions)"
+ ConstString m_category; // Category: "my_additions"
+ ConstString m_selector; // Selector: "myStringWithCString:"
+ Type m_type;
+ bool m_category_is_valid;
+ };
+
+ ObjCLanguage() = default;
+
+ ~ObjCLanguage() override = default;
+
+ lldb::LanguageType
+ GetLanguageType () const override
+ {
+ return lldb::eLanguageTypeObjC;
+ }
+
+ lldb::TypeCategoryImplSP
+ GetFormatters () override;
+
+ std::vector<ConstString>
+ GetPossibleFormattersMatches (ValueObject& valobj, lldb::DynamicValueType use_dynamic) override;
+
+ std::unique_ptr<TypeScavenger>
+ GetTypeScavenger () override;
+
+ bool
+ GetFormatterPrefixSuffix (ValueObject& valobj, ConstString type_hint,
+ std::string& prefix, std::string& suffix) override;
+
+ bool
+ IsNilReference (ValueObject& valobj) override;
+
+ //------------------------------------------------------------------
+ // Static Functions
+ //------------------------------------------------------------------
+ static void
+ Initialize();
+
+ static void
+ Terminate();
+
+ static lldb_private::Language *
+ CreateInstance (lldb::LanguageType language);
+
+ static lldb_private::ConstString
+ GetPluginNameStatic();
+
+ static bool
+ IsPossibleObjCMethodName (const char *name)
+ {
+ if (!name)
+ return false;
+ bool starts_right = (name[0] == '+' || name[0] == '-') && name[1] == '[';
+ bool ends_right = (name[strlen(name) - 1] == ']');
+ return (starts_right && ends_right);
+ }
+
+ static bool
+ IsPossibleObjCSelector (const char *name)
+ {
+ if (!name)
+ return false;
+
+ if (strchr(name, ':') == NULL)
+ return true;
+ else if (name[strlen(name) - 1] == ':')
+ return true;
+ else
+ return false;
+ }
+
+ //------------------------------------------------------------------
+ // PluginInterface protocol
+ //------------------------------------------------------------------
+ ConstString
+ GetPluginName() override;
+
+ uint32_t
+ GetPluginVersion() override;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_ObjCLanguage_h_
diff --git a/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp b/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
new file mode 100644
index 000000000000..62ddafefad97
--- /dev/null
+++ b/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
@@ -0,0 +1,68 @@
+//===-- ObjCPlusPlusLanguage.cpp --------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "ObjCPlusPlusLanguage.h"
+
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/PluginManager.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+void
+ObjCPlusPlusLanguage::Initialize()
+{
+ PluginManager::RegisterPlugin (GetPluginNameStatic(),
+ "Objective-C++ Language",
+ CreateInstance);
+}
+
+void
+ObjCPlusPlusLanguage::Terminate()
+{
+ PluginManager::UnregisterPlugin (CreateInstance);
+}
+
+lldb_private::ConstString
+ObjCPlusPlusLanguage::GetPluginNameStatic()
+{
+ static ConstString g_name("objcplusplus");
+ 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:
+ return new ObjCPlusPlusLanguage();
+ default:
+ return nullptr;
+ }
+}
diff --git a/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h b/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
new file mode 100644
index 000000000000..0e1db66b0899
--- /dev/null
+++ b/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
@@ -0,0 +1,63 @@
+//===-- ObjCPlusPlusLanguage.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_ObjCPlusPlusLanguage_h_
+#define liblldb_ObjCPlusPlusLanguage_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-private.h"
+#include "lldb/Target/Language.h"
+
+namespace lldb_private {
+
+class ObjCPlusPlusLanguage :
+ public Language
+{
+public:
+ ObjCPlusPlusLanguage() = default;
+
+ ~ObjCPlusPlusLanguage() override = default;
+
+ lldb::LanguageType
+ GetLanguageType() const override
+ {
+ return lldb::eLanguageTypeObjC_plus_plus;
+ }
+
+ //------------------------------------------------------------------
+ // Static Functions
+ //------------------------------------------------------------------
+ static void
+ Initialize();
+
+ static void
+ Terminate();
+
+ static lldb_private::Language *
+ CreateInstance (lldb::LanguageType language);
+
+ static lldb_private::ConstString
+ GetPluginNameStatic();
+
+ //------------------------------------------------------------------
+ // PluginInterface protocol
+ //------------------------------------------------------------------
+ ConstString
+ GetPluginName() override;
+
+ uint32_t
+ GetPluginVersion() override;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_CPlusPlusLanguage_h_
diff --git a/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp b/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
index 3a3878ef09a1..a5fa004493a2 100644
--- a/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
+++ b/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
@@ -40,14 +40,15 @@ ItaniumABILanguageRuntime::CouldHaveDynamicValue (ValueObject &in_value)
{
const bool check_cxx = true;
const bool check_objc = false;
- return in_value.GetClangType().IsPossibleDynamicType (NULL, check_cxx, check_objc);
+ return in_value.GetCompilerType().IsPossibleDynamicType (NULL, check_cxx, check_objc);
}
bool
ItaniumABILanguageRuntime::GetDynamicTypeAndAddress (ValueObject &in_value,
lldb::DynamicValueType use_dynamic,
TypeAndOrName &class_type_or_name,
- Address &dynamic_address)
+ Address &dynamic_address,
+ Value::ValueType &value_type)
{
// For Itanium, if the type has a vtable pointer in the object, it will be at offset 0
// in the object. That will point to the "address point" within the vtable (not the beginning of the
@@ -58,6 +59,7 @@ ItaniumABILanguageRuntime::GetDynamicTypeAndAddress (ValueObject &in_value,
//
class_type_or_name.Clear();
+ value_type = Value::ValueType::eValueTypeScalar;
// Only a pointer or reference type can have a different dynamic and static type:
if (CouldHaveDynamicValue (in_value))
@@ -189,7 +191,7 @@ ItaniumABILanguageRuntime::GetDynamicTypeAndAddress (ValueObject &in_value,
type_sp = class_types.GetTypeAtIndex(i);
if (type_sp)
{
- if (type_sp->GetClangFullType().IsCXXClassType())
+ if (ClangASTContext::IsCXXClassType(type_sp->GetFullCompilerType ()))
{
if (log)
log->Printf ("0x%16.16" PRIx64 ": static-type = '%s' has multiple matching dynamic types, picking this one: uid={0x%" PRIx64 "}, type-name='%s'\n",
@@ -221,8 +223,8 @@ ItaniumABILanguageRuntime::GetDynamicTypeAndAddress (ValueObject &in_value,
// the value we were handed.
if (type_sp)
{
- if (ClangASTContext::AreTypesSame (in_value.GetClangType(),
- type_sp->GetClangFullType()))
+ if (ClangASTContext::AreTypesSame (in_value.GetCompilerType(),
+ type_sp->GetFullCompilerType ()))
{
// The dynamic type we found was the same type,
// so we don't have a dynamic type here...
@@ -268,6 +270,42 @@ ItaniumABILanguageRuntime::GetDynamicTypeAndAddress (ValueObject &in_value,
return class_type_or_name.IsEmpty() == false;
}
+TypeAndOrName
+ItaniumABILanguageRuntime::FixUpDynamicType(const TypeAndOrName& type_and_or_name,
+ ValueObject& static_value)
+{
+ CompilerType static_type(static_value.GetCompilerType());
+ Flags static_type_flags(static_type.GetTypeInfo());
+
+ TypeAndOrName ret(type_and_or_name);
+ if (type_and_or_name.HasType())
+ {
+ // The type will always be the type of the dynamic object. If our parent's type was a pointer,
+ // then our type should be a pointer to the type of the dynamic object. If a reference, then the original type
+ // should be okay...
+ CompilerType orig_type = type_and_or_name.GetCompilerType();
+ CompilerType corrected_type = orig_type;
+ if (static_type_flags.AllSet(eTypeIsPointer))
+ corrected_type = orig_type.GetPointerType ();
+ else if (static_type_flags.AllSet(eTypeIsReference))
+ corrected_type = orig_type.GetLValueReferenceType();
+ ret.SetCompilerType(corrected_type);
+ }
+ else
+ {
+ // If we are here we need to adjust our dynamic type name to include the correct & or * symbol
+ std::string corrected_name (type_and_or_name.GetName().GetCString());
+ if (static_type_flags.AllSet(eTypeIsPointer))
+ corrected_name.append(" *");
+ else if (static_type_flags.AllSet(eTypeIsReference))
+ corrected_name.append(" &");
+ // the parent type should be a correctly pointer'ed or referenc'ed type
+ ret.SetCompilerType(static_type);
+ ret.SetName(corrected_name.c_str());
+ }
+ return ret;
+}
+
bool
ItaniumABILanguageRuntime::IsVTableName (const char *name)
{
@@ -420,6 +458,7 @@ ItaniumABILanguageRuntime::CreateExceptionResolver (Breakpoint *bkpt, bool catch
exception_names.data(),
exception_names.size(),
eFunctionNameTypeBase,
+ eLanguageTypeUnknown,
eLazyBoolNo));
return resolver_sp;
diff --git a/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h b/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
index bc5d83be4bf5..519a3cee36d6 100644
--- a/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
+++ b/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
@@ -1,4 +1,4 @@
-//===-- ItaniumABILanguageRuntime.h ----------------------------------------*- C++ -*-===//
+//===-- ItaniumABILanguageRuntime.h -----------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -12,6 +12,8 @@
// C Includes
// C++ Includes
+#include <vector>
+
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
@@ -20,28 +22,13 @@
#include "lldb/Target/CPPLanguageRuntime.h"
#include "lldb/Core/Value.h"
-#include <map>
-#include <vector>
-
namespace lldb_private {
class ItaniumABILanguageRuntime :
public lldb_private::CPPLanguageRuntime
{
public:
- ~ItaniumABILanguageRuntime() { }
-
- virtual bool
- IsVTableName (const char *name);
-
- virtual bool
- GetDynamicTypeAndAddress (ValueObject &in_value,
- lldb::DynamicValueType use_dynamic,
- TypeAndOrName &class_type_or_name,
- Address &address);
-
- virtual bool
- CouldHaveDynamicValue (ValueObject &in_value);
+ ~ItaniumABILanguageRuntime() override = default;
//------------------------------------------------------------------
// Static Functions
@@ -58,38 +45,54 @@ namespace lldb_private {
static lldb_private::ConstString
GetPluginNameStatic();
- //------------------------------------------------------------------
- // PluginInterface protocol
- //------------------------------------------------------------------
- virtual lldb_private::ConstString
- GetPluginName();
+ bool
+ IsVTableName(const char *name) override;
- virtual uint32_t
- GetPluginVersion();
+ bool
+ GetDynamicTypeAndAddress(ValueObject &in_value,
+ lldb::DynamicValueType use_dynamic,
+ TypeAndOrName &class_type_or_name,
+ Address &address,
+ Value::ValueType &value_type) override;
- virtual void
- SetExceptionBreakpoints ();
+ TypeAndOrName
+ FixUpDynamicType(const TypeAndOrName& type_and_or_name,
+ ValueObject& static_value) override;
- virtual void
- ClearExceptionBreakpoints ();
+ bool
+ CouldHaveDynamicValue(ValueObject &in_value) override;
- virtual bool
- ExceptionBreakpointsAreSet ();
+ void
+ SetExceptionBreakpoints() override;
- virtual bool
- ExceptionBreakpointsExplainStop (lldb::StopInfoSP stop_reason);
+ void
+ ClearExceptionBreakpoints() override;
+
+ bool
+ ExceptionBreakpointsAreSet() override;
+
+ bool
+ ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override;
- virtual lldb::BreakpointResolverSP
- CreateExceptionResolver (Breakpoint *bkpt, bool catch_bp, bool throw_bp);
+ lldb::BreakpointResolverSP
+ CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp, bool throw_bp) override;
- virtual lldb::SearchFilterSP
- CreateExceptionSearchFilter ();
+ lldb::SearchFilterSP
+ CreateExceptionSearchFilter() override;
- virtual size_t
- GetAlternateManglings(const ConstString &mangled, std::vector<ConstString> &alternates);
+ size_t
+ GetAlternateManglings(const ConstString &mangled, std::vector<ConstString> &alternates) override;
- protected:
+ //------------------------------------------------------------------
+ // PluginInterface protocol
+ //------------------------------------------------------------------
+ lldb_private::ConstString
+ GetPluginName() override;
+
+ uint32_t
+ GetPluginVersion() override;
+ protected:
lldb::BreakpointResolverSP
CreateExceptionResolver (Breakpoint *bkpt, bool catch_bp, bool throw_bp, bool for_expressions);
@@ -107,4 +110,4 @@ namespace lldb_private {
} // namespace lldb_private
-#endif // liblldb_ItaniumABILanguageRuntime_h_
+#endif // liblldb_ItaniumABILanguageRuntime_h_
diff --git a/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.cpp b/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.cpp
new file mode 100644
index 000000000000..d59f292e7a08
--- /dev/null
+++ b/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.cpp
@@ -0,0 +1,238 @@
+//===-- GoLanguageRuntime.cpp --------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "GoLanguageRuntime.h"
+
+#include "lldb/Breakpoint/BreakpointLocation.h"
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/Error.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Scalar.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Core/ValueObjectMemory.h"
+#include "lldb/Symbol/GoASTContext.h"
+#include "lldb/Symbol/Symbol.h"
+#include "lldb/Symbol/TypeList.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/SectionLoadList.h"
+#include "lldb/Target/StopInfo.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
+#include "llvm/ADT/Twine.h"
+
+#include <vector>
+
+using namespace lldb;
+using namespace lldb_private;
+
+namespace {
+ValueObjectSP GetChild(ValueObject& obj, const char* name, bool dereference = true) {
+ ConstString name_const_str(name);
+ ValueObjectSP result = obj.GetChildMemberWithName(name_const_str, true);
+ if (dereference && result && result->IsPointerType()) {
+ Error err;
+ result = result->Dereference(err);
+ if (err.Fail())
+ result.reset();
+ }
+ return result;
+}
+
+ConstString ReadString(ValueObject& str, Process* process) {
+ ConstString result;
+ ValueObjectSP data = GetChild(str, "str", false);
+ ValueObjectSP len = GetChild(str, "len");
+ if (len && data)
+ {
+ Error err;
+ lldb::addr_t addr = data->GetPointerValue();
+ if (addr == LLDB_INVALID_ADDRESS)
+ return result;
+ uint64_t byte_size = len->GetValueAsUnsigned(0);
+ char* buf = new char[byte_size + 1];
+ buf[byte_size] = 0;
+ size_t bytes_read = process->ReadMemory (addr,
+ buf,
+ byte_size,
+ err);
+ if (!(err.Fail() || bytes_read != byte_size))
+ result = ConstString(buf, bytes_read);
+ delete[] buf;
+ }
+ return result;
+}
+
+ConstString
+ReadTypeName(ValueObjectSP type, Process* process)
+{
+ if (ValueObjectSP uncommon = GetChild(*type, "x"))
+ {
+ ValueObjectSP name = GetChild(*uncommon, "name");
+ ValueObjectSP package = GetChild(*uncommon, "pkgpath");
+ if (name && name->GetPointerValue() != 0 && package && package->GetPointerValue() != 0)
+ {
+ ConstString package_const_str = ReadString(*package, process);
+ ConstString name_const_str = ReadString(*name, process);
+ if (package_const_str.GetLength() == 0)
+ return name_const_str;
+ return ConstString((package_const_str.GetStringRef() + "." + name_const_str.GetStringRef()).str());
+ }
+ }
+ ValueObjectSP name = GetChild(*type, "_string");
+ if (name)
+ return ReadString(*name, process);
+ return ConstString("");
+}
+
+CompilerType
+LookupRuntimeType(ValueObjectSP type, ExecutionContext* exe_ctx, bool* is_direct)
+{
+ uint8_t kind = GetChild(*type, "kind")->GetValueAsUnsigned(0);
+ *is_direct = GoASTContext::IsDirectIface(kind);
+ if (GoASTContext::IsPointerKind(kind))
+ {
+ CompilerType type_ptr = type->GetCompilerType().GetPointerType();
+ Error err;
+ ValueObjectSP elem = type->CreateValueObjectFromAddress("elem", type->GetAddressOf() + type->GetByteSize(), *exe_ctx, type_ptr)->Dereference(err);
+ if (err.Fail())
+ return CompilerType();
+ bool tmp_direct;
+ return LookupRuntimeType(elem, exe_ctx, &tmp_direct).GetPointerType();
+ }
+ Target *target = exe_ctx->GetTargetPtr();
+ Process *process = exe_ctx->GetProcessPtr();
+
+ ConstString const_typename = ReadTypeName(type, process);
+ if (const_typename.GetLength() == 0)
+ return CompilerType();
+
+ SymbolContext sc;
+ TypeList type_list;
+ uint32_t num_matches = target->GetImages().FindTypes (sc,
+ const_typename,
+ false,
+ 2,
+ type_list);
+ if (num_matches > 0) {
+ return type_list.GetTypeAtIndex(0)->GetFullCompilerType();
+ }
+ return CompilerType();
+}
+
+}
+
+bool
+GoLanguageRuntime::CouldHaveDynamicValue (ValueObject &in_value)
+{
+ return GoASTContext::IsGoInterface(in_value.GetCompilerType());
+}
+
+bool
+GoLanguageRuntime::GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic,
+ TypeAndOrName &class_type_or_name, Address &dynamic_address,
+ Value::ValueType &value_type)
+{
+ value_type = Value::eValueTypeScalar;
+ class_type_or_name.Clear();
+ if (CouldHaveDynamicValue (in_value))
+ {
+ Error err;
+ ValueObjectSP iface = in_value.GetStaticValue();
+ ValueObjectSP data_sp = GetChild(*iface, "data", false);
+ if (!data_sp)
+ return false;
+
+ if (ValueObjectSP tab = GetChild(*iface, "tab"))
+ iface = tab;
+ ValueObjectSP type = GetChild(*iface, "_type");
+ if (!type)
+ {
+ return false;
+ }
+
+ bool direct;
+ ExecutionContext exe_ctx (in_value.GetExecutionContextRef());
+ CompilerType final_type = LookupRuntimeType(type, &exe_ctx, &direct);
+ if (!final_type)
+ return false;
+ if (direct)
+ {
+ class_type_or_name.SetCompilerType(final_type);
+ }
+ else
+ {
+ // TODO: implement reference types or fix caller to support dynamic types that aren't pointers
+ // so we don't have to introduce this extra pointer.
+ class_type_or_name.SetCompilerType(final_type.GetPointerType());
+ }
+
+ dynamic_address.SetLoadAddress(data_sp->GetPointerValue(), exe_ctx.GetTargetPtr());
+
+ return true;
+ }
+ return false;
+}
+
+TypeAndOrName
+GoLanguageRuntime::FixUpDynamicType(const TypeAndOrName &type_and_or_name, ValueObject &static_value)
+{
+ return type_and_or_name;
+}
+
+//------------------------------------------------------------------
+// Static Functions
+//------------------------------------------------------------------
+LanguageRuntime *
+GoLanguageRuntime::CreateInstance (Process *process, lldb::LanguageType language)
+{
+ if (language == eLanguageTypeGo)
+ return new GoLanguageRuntime (process);
+ else
+ return NULL;
+}
+
+void
+GoLanguageRuntime::Initialize()
+{
+ PluginManager::RegisterPlugin (GetPluginNameStatic(),
+ "Go Language Runtime",
+ CreateInstance);
+}
+
+void
+GoLanguageRuntime::Terminate()
+{
+ PluginManager::UnregisterPlugin (CreateInstance);
+}
+
+lldb_private::ConstString
+GoLanguageRuntime::GetPluginNameStatic()
+{
+ static ConstString g_name("golang");
+ return g_name;
+}
+
+//------------------------------------------------------------------
+// PluginInterface protocol
+//------------------------------------------------------------------
+lldb_private::ConstString
+GoLanguageRuntime::GetPluginName()
+{
+ return GetPluginNameStatic();
+}
+
+uint32_t
+GoLanguageRuntime::GetPluginVersion()
+{
+ return 1;
+}
+
diff --git a/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.h b/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.h
new file mode 100644
index 000000000000..596d2888dc85
--- /dev/null
+++ b/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.h
@@ -0,0 +1,93 @@
+//===-- GoLanguageRuntime.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_GoLanguageRuntime_h_
+#define liblldb_GoLanguageRuntime_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-private.h"
+#include "lldb/Breakpoint/BreakpointResolver.h"
+#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Core/Value.h"
+
+namespace lldb_private {
+
+ class GoLanguageRuntime :
+ public lldb_private::LanguageRuntime
+ {
+ public:
+ ~GoLanguageRuntime() override = default;
+
+ //------------------------------------------------------------------
+ // Static Functions
+ //------------------------------------------------------------------
+ static void
+ Initialize();
+
+ static void
+ Terminate();
+
+ static lldb_private::LanguageRuntime *
+ CreateInstance(Process *process, lldb::LanguageType language);
+
+ static lldb_private::ConstString
+ GetPluginNameStatic();
+
+ lldb::LanguageType
+ GetLanguageType() const override
+ {
+ return lldb::eLanguageTypeGo;
+ }
+
+ bool
+ GetObjectDescription(Stream &str, ValueObject &object) override
+ {
+ // TODO(ribrdb): Maybe call String() method?
+ return false;
+ }
+
+ bool
+ GetObjectDescription(Stream &str, Value &value, ExecutionContextScope *exe_scope) override
+ {
+ return false;
+ }
+
+ bool GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic,
+ TypeAndOrName &class_type_or_name, Address &address,
+ Value::ValueType &value_type) override;
+
+ bool CouldHaveDynamicValue(ValueObject &in_value) override;
+
+ lldb::BreakpointResolverSP
+ CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp, bool throw_bp) override
+ {
+ return lldb::BreakpointResolverSP();
+ }
+
+ TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name, ValueObject &static_value) override;
+
+ //------------------------------------------------------------------
+ // PluginInterface protocol
+ //------------------------------------------------------------------
+ lldb_private::ConstString
+ GetPluginName() override;
+
+ uint32_t
+ GetPluginVersion() override;
+
+ private:
+ GoLanguageRuntime(Process *process) : lldb_private::LanguageRuntime(process) { } // Call CreateInstance instead.
+ };
+
+} // namespace lldb_private
+
+#endif // liblldb_GoLanguageRuntime_h_
diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
index 2490cf31409b..149244df30c2 100644
--- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "RenderScriptRuntime.h"
#include "lldb/Core/ConstString.h"
@@ -14,10 +18,15 @@
#include "lldb/Core/Error.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/ValueObjectVariable.h"
+#include "lldb/Core/RegularExpression.h"
+#include "lldb/DataFormatters/DumpValueObjectOptions.h"
+#include "lldb/Host/StringConvert.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -25,11 +34,350 @@
#include "lldb/Interpreter/CommandObjectMultiword.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Target/RegisterContext.h"
-
+#include "lldb/Expression/UserExpression.h"
#include "lldb/Symbol/VariableList.h"
using namespace lldb;
using namespace lldb_private;
+using namespace lldb_renderscript;
+
+namespace {
+
+// The empirical_type adds a basic level of validation to arbitrary data
+// allowing us to track if data has been discovered and stored or not.
+// An empirical_type will be marked as valid only if it has been explicitly assigned to.
+template <typename type_t>
+class empirical_type
+{
+public:
+ // Ctor. Contents is invalid when constructed.
+ empirical_type()
+ : valid(false)
+ {}
+
+ // Return true and copy contents to out if valid, else return false.
+ bool get(type_t& out) const
+ {
+ if (valid)
+ out = data;
+ return valid;
+ }
+
+ // Return a pointer to the contents or nullptr if it was not valid.
+ const type_t* get() const
+ {
+ return valid ? &data : nullptr;
+ }
+
+ // Assign data explicitly.
+ void set(const type_t in)
+ {
+ data = in;
+ valid = true;
+ }
+
+ // Mark contents as invalid.
+ void invalidate()
+ {
+ valid = false;
+ }
+
+ // Returns true if this type contains valid data.
+ bool isValid() const
+ {
+ return valid;
+ }
+
+ // Assignment operator.
+ empirical_type<type_t>& operator = (const type_t in)
+ {
+ set(in);
+ return *this;
+ }
+
+ // Dereference operator returns contents.
+ // Warning: Will assert if not valid so use only when you know data is valid.
+ const type_t& operator * () const
+ {
+ assert(valid);
+ return data;
+ }
+
+protected:
+ bool valid;
+ type_t data;
+};
+
+} // anonymous namespace
+
+// The ScriptDetails class collects data associated with a single script instance.
+struct RenderScriptRuntime::ScriptDetails
+{
+ ~ScriptDetails() = default;
+
+ enum ScriptType
+ {
+ eScript,
+ eScriptC
+ };
+
+ // The derived type of the script.
+ empirical_type<ScriptType> type;
+ // The name of the original source file.
+ empirical_type<std::string> resName;
+ // Path to script .so file on the device.
+ empirical_type<std::string> scriptDyLib;
+ // Directory where kernel objects are cached on device.
+ empirical_type<std::string> cacheDir;
+ // Pointer to the context which owns this script.
+ empirical_type<lldb::addr_t> context;
+ // Pointer to the script object itself.
+ empirical_type<lldb::addr_t> script;
+};
+
+// This Element class represents the Element object in RS,
+// defining the type associated with an Allocation.
+struct RenderScriptRuntime::Element
+{
+ // Taken from rsDefines.h
+ enum DataKind
+ {
+ RS_KIND_USER,
+ RS_KIND_PIXEL_L = 7,
+ RS_KIND_PIXEL_A,
+ RS_KIND_PIXEL_LA,
+ RS_KIND_PIXEL_RGB,
+ RS_KIND_PIXEL_RGBA,
+ RS_KIND_PIXEL_DEPTH,
+ RS_KIND_PIXEL_YUV,
+ RS_KIND_INVALID = 100
+ };
+
+ // Taken from rsDefines.h
+ enum DataType
+ {
+ RS_TYPE_NONE = 0,
+ RS_TYPE_FLOAT_16,
+ RS_TYPE_FLOAT_32,
+ RS_TYPE_FLOAT_64,
+ RS_TYPE_SIGNED_8,
+ RS_TYPE_SIGNED_16,
+ RS_TYPE_SIGNED_32,
+ RS_TYPE_SIGNED_64,
+ RS_TYPE_UNSIGNED_8,
+ RS_TYPE_UNSIGNED_16,
+ RS_TYPE_UNSIGNED_32,
+ RS_TYPE_UNSIGNED_64,
+ RS_TYPE_BOOLEAN,
+
+ RS_TYPE_UNSIGNED_5_6_5,
+ RS_TYPE_UNSIGNED_5_5_5_1,
+ RS_TYPE_UNSIGNED_4_4_4_4,
+
+ RS_TYPE_MATRIX_4X4,
+ RS_TYPE_MATRIX_3X3,
+ RS_TYPE_MATRIX_2X2,
+
+ RS_TYPE_ELEMENT = 1000,
+ RS_TYPE_TYPE,
+ RS_TYPE_ALLOCATION,
+ RS_TYPE_SAMPLER,
+ RS_TYPE_SCRIPT,
+ RS_TYPE_MESH,
+ RS_TYPE_PROGRAM_FRAGMENT,
+ RS_TYPE_PROGRAM_VERTEX,
+ RS_TYPE_PROGRAM_RASTER,
+ RS_TYPE_PROGRAM_STORE,
+ RS_TYPE_FONT,
+
+ RS_TYPE_INVALID = 10000
+ };
+
+ std::vector<Element> children; // Child Element fields for structs
+ empirical_type<lldb::addr_t> element_ptr; // Pointer to the RS Element of the Type
+ empirical_type<DataType> type; // Type of each data pointer stored by the allocation
+ empirical_type<DataKind> type_kind; // Defines pixel type if Allocation is created from an image
+ empirical_type<uint32_t> type_vec_size; // Vector size of each data point, e.g '4' for uchar4
+ empirical_type<uint32_t> field_count; // Number of Subelements
+ empirical_type<uint32_t> datum_size; // Size of a single Element with padding
+ empirical_type<uint32_t> padding; // Number of padding bytes
+ empirical_type<uint32_t> array_size; // Number of items in array, only needed for strucrs
+ ConstString type_name; // Name of type, only needed for structs
+
+ static const ConstString &GetFallbackStructName(); // Print this as the type name of a struct Element
+ // If we can't resolve the actual struct name
+
+ bool shouldRefresh() const
+ {
+ const bool valid_ptr = element_ptr.isValid() && *element_ptr.get() != 0x0;
+ const bool valid_type = type.isValid() && type_vec_size.isValid() && type_kind.isValid();
+ return !valid_ptr || !valid_type || !datum_size.isValid();
+ }
+};
+
+// This AllocationDetails class collects data associated with a single
+// allocation instance.
+struct RenderScriptRuntime::AllocationDetails
+{
+ struct Dimension
+ {
+ uint32_t dim_1;
+ uint32_t dim_2;
+ uint32_t dim_3;
+ uint32_t cubeMap;
+
+ Dimension()
+ {
+ dim_1 = 0;
+ dim_2 = 0;
+ dim_3 = 0;
+ cubeMap = 0;
+ }
+ };
+
+ // Header for reading and writing allocation contents
+ // to a binary file.
+ struct FileHeader
+ {
+ uint8_t ident[4]; // ASCII 'RSAD' identifying the file
+ uint16_t hdr_size; // Header size in bytes, for backwards compatability
+ uint16_t type; // DataType enum
+ uint32_t kind; // DataKind enum
+ uint32_t dims[3]; // Dimensions
+ uint32_t element_size; // Size of a single element, including padding
+ };
+
+ // Monotonically increasing from 1
+ static unsigned int ID;
+
+ // Maps Allocation DataType enum and vector size to printable strings
+ // using mapping from RenderScript numerical types summary documentation
+ static const char* RsDataTypeToString[][4];
+
+ // Maps Allocation DataKind enum to printable strings
+ static const char* RsDataKindToString[];
+
+ // Maps allocation types to format sizes for printing.
+ static const unsigned int RSTypeToFormat[][3];
+
+ // Give each allocation an ID as a way
+ // for commands to reference it.
+ const unsigned int id;
+
+ RenderScriptRuntime::Element element; // Allocation Element type
+ empirical_type<Dimension> dimension; // Dimensions of the Allocation
+ empirical_type<lldb::addr_t> address; // Pointer to address of the RS Allocation
+ empirical_type<lldb::addr_t> data_ptr; // Pointer to the data held by the Allocation
+ empirical_type<lldb::addr_t> type_ptr; // Pointer to the RS Type of the Allocation
+ empirical_type<lldb::addr_t> context; // Pointer to the RS Context of the Allocation
+ empirical_type<uint32_t> size; // Size of the allocation
+ empirical_type<uint32_t> stride; // Stride between rows of the allocation
+
+ // Give each allocation an id, so we can reference it in user commands.
+ AllocationDetails(): id(ID++)
+ {
+ }
+
+ bool shouldRefresh() const
+ {
+ bool valid_ptrs = data_ptr.isValid() && *data_ptr.get() != 0x0;
+ valid_ptrs = valid_ptrs && type_ptr.isValid() && *type_ptr.get() != 0x0;
+ return !valid_ptrs || !dimension.isValid() || !size.isValid() || element.shouldRefresh();
+ }
+};
+
+
+const ConstString &
+RenderScriptRuntime::Element::GetFallbackStructName()
+{
+ static const ConstString FallbackStructName("struct");
+ return FallbackStructName;
+}
+
+unsigned int RenderScriptRuntime::AllocationDetails::ID = 1;
+
+const char* RenderScriptRuntime::AllocationDetails::RsDataKindToString[] =
+{
+ "User",
+ "Undefined", "Undefined", "Undefined", // Enum jumps from 0 to 7
+ "Undefined", "Undefined", "Undefined",
+ "L Pixel",
+ "A Pixel",
+ "LA Pixel",
+ "RGB Pixel",
+ "RGBA Pixel",
+ "Pixel Depth",
+ "YUV Pixel"
+};
+
+const char* RenderScriptRuntime::AllocationDetails::RsDataTypeToString[][4] =
+{
+ {"None", "None", "None", "None"},
+ {"half", "half2", "half3", "half4"},
+ {"float", "float2", "float3", "float4"},
+ {"double", "double2", "double3", "double4"},
+ {"char", "char2", "char3", "char4"},
+ {"short", "short2", "short3", "short4"},
+ {"int", "int2", "int3", "int4"},
+ {"long", "long2", "long3", "long4"},
+ {"uchar", "uchar2", "uchar3", "uchar4"},
+ {"ushort", "ushort2", "ushort3", "ushort4"},
+ {"uint", "uint2", "uint3", "uint4"},
+ {"ulong", "ulong2", "ulong3", "ulong4"},
+ {"bool", "bool2", "bool3", "bool4"},
+ {"packed_565", "packed_565", "packed_565", "packed_565"},
+ {"packed_5551", "packed_5551", "packed_5551", "packed_5551"},
+ {"packed_4444", "packed_4444", "packed_4444", "packed_4444"},
+ {"rs_matrix4x4", "rs_matrix4x4", "rs_matrix4x4", "rs_matrix4x4"},
+ {"rs_matrix3x3", "rs_matrix3x3", "rs_matrix3x3", "rs_matrix3x3"},
+ {"rs_matrix2x2", "rs_matrix2x2", "rs_matrix2x2", "rs_matrix2x2"},
+
+ // Handlers
+ {"RS Element", "RS Element", "RS Element", "RS Element"},
+ {"RS Type", "RS Type", "RS Type", "RS Type"},
+ {"RS Allocation", "RS Allocation", "RS Allocation", "RS Allocation"},
+ {"RS Sampler", "RS Sampler", "RS Sampler", "RS Sampler"},
+ {"RS Script", "RS Script", "RS Script", "RS Script"},
+
+ // Deprecated
+ {"RS Mesh", "RS Mesh", "RS Mesh", "RS Mesh"},
+ {"RS Program Fragment", "RS Program Fragment", "RS Program Fragment", "RS Program Fragment"},
+ {"RS Program Vertex", "RS Program Vertex", "RS Program Vertex", "RS Program Vertex"},
+ {"RS Program Raster", "RS Program Raster", "RS Program Raster", "RS Program Raster"},
+ {"RS Program Store", "RS Program Store", "RS Program Store", "RS Program Store"},
+ {"RS Font", "RS Font", "RS Font", "RS Font"}
+};
+
+// Used as an index into the RSTypeToFormat array elements
+enum TypeToFormatIndex {
+ eFormatSingle = 0,
+ eFormatVector,
+ eElementSize
+};
+
+// { format enum of single element, format enum of element vector, size of element}
+const unsigned int RenderScriptRuntime::AllocationDetails::RSTypeToFormat[][3] =
+{
+ {eFormatHex, eFormatHex, 1}, // RS_TYPE_NONE
+ {eFormatFloat, eFormatVectorOfFloat16, 2}, // RS_TYPE_FLOAT_16
+ {eFormatFloat, eFormatVectorOfFloat32, sizeof(float)}, // RS_TYPE_FLOAT_32
+ {eFormatFloat, eFormatVectorOfFloat64, sizeof(double)}, // RS_TYPE_FLOAT_64
+ {eFormatDecimal, eFormatVectorOfSInt8, sizeof(int8_t)}, // RS_TYPE_SIGNED_8
+ {eFormatDecimal, eFormatVectorOfSInt16, sizeof(int16_t)}, // RS_TYPE_SIGNED_16
+ {eFormatDecimal, eFormatVectorOfSInt32, sizeof(int32_t)}, // RS_TYPE_SIGNED_32
+ {eFormatDecimal, eFormatVectorOfSInt64, sizeof(int64_t)}, // RS_TYPE_SIGNED_64
+ {eFormatDecimal, eFormatVectorOfUInt8, sizeof(uint8_t)}, // RS_TYPE_UNSIGNED_8
+ {eFormatDecimal, eFormatVectorOfUInt16, sizeof(uint16_t)}, // RS_TYPE_UNSIGNED_16
+ {eFormatDecimal, eFormatVectorOfUInt32, sizeof(uint32_t)}, // RS_TYPE_UNSIGNED_32
+ {eFormatDecimal, eFormatVectorOfUInt64, sizeof(uint64_t)}, // RS_TYPE_UNSIGNED_64
+ {eFormatBoolean, eFormatBoolean, 1}, // RS_TYPE_BOOL
+ {eFormatHex, eFormatHex, sizeof(uint16_t)}, // RS_TYPE_UNSIGNED_5_6_5
+ {eFormatHex, eFormatHex, sizeof(uint16_t)}, // RS_TYPE_UNSIGNED_5_5_5_1
+ {eFormatHex, eFormatHex, sizeof(uint16_t)}, // RS_TYPE_UNSIGNED_4_4_4_4
+ {eFormatVectorOfFloat32, eFormatVectorOfFloat32, sizeof(float) * 16}, // RS_TYPE_MATRIX_4X4
+ {eFormatVectorOfFloat32, eFormatVectorOfFloat32, sizeof(float) * 9}, // RS_TYPE_MATRIX_3X3
+ {eFormatVectorOfFloat32, eFormatVectorOfFloat32, sizeof(float) * 4} // RS_TYPE_MATRIX_2X2
+};
//------------------------------------------------------------------
// Static Functions
@@ -44,6 +392,47 @@ RenderScriptRuntime::CreateInstance(Process *process, lldb::LanguageType languag
return NULL;
}
+// Callback with a module to search for matching symbols.
+// We first check that the module contains RS kernels.
+// Then look for a symbol which matches our kernel name.
+// The breakpoint address is finally set using the address of this symbol.
+Searcher::CallbackReturn
+RSBreakpointResolver::SearchCallback(SearchFilter &filter,
+ SymbolContext &context,
+ Address*,
+ bool)
+{
+ ModuleSP module = context.module_sp;
+
+ if (!module)
+ return Searcher::eCallbackReturnContinue;
+
+ // Is this a module containing renderscript kernels?
+ if (nullptr == module->FindFirstSymbolWithNameAndType(ConstString(".rs.info"), eSymbolTypeData))
+ return Searcher::eCallbackReturnContinue;
+
+ // Attempt to set a breakpoint on the kernel name symbol within the module library.
+ // If it's not found, it's likely debug info is unavailable - try to set a
+ // breakpoint on <name>.expand.
+
+ const Symbol* kernel_sym = module->FindFirstSymbolWithNameAndType(m_kernel_name, eSymbolTypeCode);
+ if (!kernel_sym)
+ {
+ std::string kernel_name_expanded(m_kernel_name.AsCString());
+ kernel_name_expanded.append(".expand");
+ kernel_sym = module->FindFirstSymbolWithNameAndType(ConstString(kernel_name_expanded.c_str()), eSymbolTypeCode);
+ }
+
+ if (kernel_sym)
+ {
+ Address bp_addr = kernel_sym->GetAddress();
+ if (filter.AddressPasses(bp_addr))
+ m_breakpoint->AddLocation(bp_addr);
+ }
+
+ return Searcher::eCallbackReturnContinue;
+}
+
void
RenderScriptRuntime::Initialize()
{
@@ -88,7 +477,7 @@ RenderScriptRuntime::GetModuleKind(const lldb::ModuleSP &module_sp)
return eModuleKindDriver;
}
- const ConstString rs_cpureflib("libRSCPURef.so");
+ const ConstString rs_cpureflib("libRSCpuRef.so");
if (module_sp->GetFileSpec().GetFilename() == rs_cpureflib)
{
return eModuleKindImpl;
@@ -104,7 +493,6 @@ RenderScriptRuntime::IsRenderScriptModule(const lldb::ModuleSP &module_sp)
return GetModuleKind(module_sp) != eModuleKindIgnored;
}
-
void
RenderScriptRuntime::ModulesDidLoad(const ModuleList &module_list )
{
@@ -121,7 +509,6 @@ RenderScriptRuntime::ModulesDidLoad(const ModuleList &module_list )
}
}
-
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
@@ -145,11 +532,19 @@ RenderScriptRuntime::IsVTableName(const char *name)
bool
RenderScriptRuntime::GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic,
- TypeAndOrName &class_type_or_name, Address &address)
+ TypeAndOrName &class_type_or_name, Address &address,
+ Value::ValueType &value_type)
{
return false;
}
+TypeAndOrName
+RenderScriptRuntime::FixUpDynamicType (const TypeAndOrName& type_and_or_name,
+ ValueObject& static_value)
+{
+ return type_and_or_name;
+}
+
bool
RenderScriptRuntime::CouldHaveDynamicValue(ValueObject &in_value)
{
@@ -163,22 +558,78 @@ RenderScriptRuntime::CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp, bo
return resolver_sp;
}
-
const RenderScriptRuntime::HookDefn RenderScriptRuntime::s_runtimeHookDefns[] =
{
//rsdScript
- {"rsdScriptInit", "_Z13rsdScriptInitPKN7android12renderscript7ContextEPNS0_7ScriptCEPKcS7_PKhjj", 0, RenderScriptRuntime::eModuleKindDriver, &lldb_private::RenderScriptRuntime::CaptureScriptInit1},
- {"rsdScriptInvokeForEach", "_Z22rsdScriptInvokeForEachPKN7android12renderscript7ContextEPNS0_6ScriptEjPKNS0_10AllocationEPS6_PKvjPK12RsScriptCall", 0, RenderScriptRuntime::eModuleKindDriver, nullptr},
- {"rsdScriptInvokeForEachMulti", "_Z27rsdScriptInvokeForEachMultiPKN7android12renderscript7ContextEPNS0_6ScriptEjPPKNS0_10AllocationEjPS6_PKvjPK12RsScriptCall", 0, RenderScriptRuntime::eModuleKindDriver, nullptr},
- {"rsdScriptInvokeFunction", "_Z23rsdScriptInvokeFunctionPKN7android12renderscript7ContextEPNS0_6ScriptEjPKvj", 0, RenderScriptRuntime::eModuleKindDriver, nullptr},
- {"rsdScriptSetGlobalVar", "_Z21rsdScriptSetGlobalVarPKN7android12renderscript7ContextEPKNS0_6ScriptEjPvj", 0, RenderScriptRuntime::eModuleKindDriver, &lldb_private::RenderScriptRuntime::CaptureSetGlobalVar1},
+ {
+ "rsdScriptInit", //name
+ "_Z13rsdScriptInitPKN7android12renderscript7ContextEPNS0_7ScriptCEPKcS7_PKhjj", // symbol name 32 bit
+ "_Z13rsdScriptInitPKN7android12renderscript7ContextEPNS0_7ScriptCEPKcS7_PKhmj", // symbol name 64 bit
+ 0, // version
+ RenderScriptRuntime::eModuleKindDriver, // type
+ &lldb_private::RenderScriptRuntime::CaptureScriptInit1 // handler
+ },
+ {
+ "rsdScriptInvokeForEach", // name
+ "_Z22rsdScriptInvokeForEachPKN7android12renderscript7ContextEPNS0_6ScriptEjPKNS0_10AllocationEPS6_PKvjPK12RsScriptCall", // symbol name 32bit
+ "_Z22rsdScriptInvokeForEachPKN7android12renderscript7ContextEPNS0_6ScriptEjPKNS0_10AllocationEPS6_PKvmPK12RsScriptCall", // symbol name 64bit
+ 0, // version
+ RenderScriptRuntime::eModuleKindDriver, // type
+ nullptr // handler
+ },
+ {
+ "rsdScriptInvokeForEachMulti", // name
+ "_Z27rsdScriptInvokeForEachMultiPKN7android12renderscript7ContextEPNS0_6ScriptEjPPKNS0_10AllocationEjPS6_PKvjPK12RsScriptCall", // symbol name 32bit
+ "_Z27rsdScriptInvokeForEachMultiPKN7android12renderscript7ContextEPNS0_6ScriptEjPPKNS0_10AllocationEmPS6_PKvmPK12RsScriptCall", // symbol name 64bit
+ 0, // version
+ RenderScriptRuntime::eModuleKindDriver, // type
+ nullptr // handler
+ },
+ {
+ "rsdScriptInvokeFunction", // name
+ "_Z23rsdScriptInvokeFunctionPKN7android12renderscript7ContextEPNS0_6ScriptEjPKvj", // symbol name 32bit
+ "_Z23rsdScriptInvokeFunctionPKN7android12renderscript7ContextEPNS0_6ScriptEjPKvm", // symbol name 64bit
+ 0, // version
+ RenderScriptRuntime::eModuleKindDriver, // type
+ nullptr // handler
+ },
+ {
+ "rsdScriptSetGlobalVar", // name
+ "_Z21rsdScriptSetGlobalVarPKN7android12renderscript7ContextEPKNS0_6ScriptEjPvj", // symbol name 32bit
+ "_Z21rsdScriptSetGlobalVarPKN7android12renderscript7ContextEPKNS0_6ScriptEjPvm", // symbol name 64bit
+ 0, // version
+ RenderScriptRuntime::eModuleKindDriver, // type
+ &lldb_private::RenderScriptRuntime::CaptureSetGlobalVar1 // handler
+ },
//rsdAllocation
- {"rsdAllocationInit", "_Z17rsdAllocationInitPKN7android12renderscript7ContextEPNS0_10AllocationEb", 0, RenderScriptRuntime::eModuleKindDriver, &lldb_private::RenderScriptRuntime::CaptureAllocationInit1},
- {"rsdAllocationRead2D", "_Z19rsdAllocationRead2DPKN7android12renderscript7ContextEPKNS0_10AllocationEjjj23RsAllocationCubemapFacejjPvjj", 0, RenderScriptRuntime::eModuleKindDriver, nullptr},
+ {
+ "rsdAllocationInit", // name
+ "_Z17rsdAllocationInitPKN7android12renderscript7ContextEPNS0_10AllocationEb", // symbol name 32bit
+ "_Z17rsdAllocationInitPKN7android12renderscript7ContextEPNS0_10AllocationEb", // symbol name 64bit
+ 0, // version
+ RenderScriptRuntime::eModuleKindDriver, // type
+ &lldb_private::RenderScriptRuntime::CaptureAllocationInit1 // handler
+ },
+ {
+ "rsdAllocationRead2D", //name
+ "_Z19rsdAllocationRead2DPKN7android12renderscript7ContextEPKNS0_10AllocationEjjj23RsAllocationCubemapFacejjPvjj", // symbol name 32bit
+ "_Z19rsdAllocationRead2DPKN7android12renderscript7ContextEPKNS0_10AllocationEjjj23RsAllocationCubemapFacejjPvmm", // symbol name 64bit
+ 0, // version
+ RenderScriptRuntime::eModuleKindDriver, // type
+ nullptr // handler
+ },
+ {
+ "rsdAllocationDestroy", // name
+ "_Z20rsdAllocationDestroyPKN7android12renderscript7ContextEPNS0_10AllocationE", // symbol name 32bit
+ "_Z20rsdAllocationDestroyPKN7android12renderscript7ContextEPNS0_10AllocationE", // symbol name 64bit
+ 0, // version
+ RenderScriptRuntime::eModuleKindDriver, // type
+ &lldb_private::RenderScriptRuntime::CaptureAllocationDestroy // handler
+ },
};
-const size_t RenderScriptRuntime::s_runtimeHookCount = sizeof(s_runtimeHookDefns)/sizeof(s_runtimeHookDefns[0]);
+const size_t RenderScriptRuntime::s_runtimeHookCount = sizeof(s_runtimeHookDefns)/sizeof(s_runtimeHookDefns[0]);
bool
RenderScriptRuntime::HookCallback(void *baton, StoppointCallbackContext *ctx, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
@@ -193,13 +644,12 @@ RenderScriptRuntime::HookCallback(void *baton, StoppointCallbackContext *ctx, ll
return false;
}
-
void
RenderScriptRuntime::HookCallback(RuntimeHook* hook_info, ExecutionContext& context)
{
Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
- if(log)
+ if (log)
log->Printf ("RenderScriptRuntime::HookCallback - '%s' .", hook_info->defn->name);
if (hook_info->defn->grabber)
@@ -208,56 +658,241 @@ RenderScriptRuntime::HookCallback(RuntimeHook* hook_info, ExecutionContext& cont
}
}
-
bool
-RenderScriptRuntime::GetArg32Simple(ExecutionContext& context, uint32_t arg, uint32_t *data)
+RenderScriptRuntime::GetArgSimple(ExecutionContext &context, uint32_t arg, uint64_t *data)
{
- Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+ // Get a positional integer argument.
+ // Given an ExecutionContext, ``context`` which should be a RenderScript
+ // frame, get the value of the positional argument ``arg`` and save its value
+ // to the address pointed to by ``data``.
+ // returns true on success, false otherwise.
+ // If unsuccessful, the value pointed to by ``data`` is undefined. Otherwise,
+ // ``data`` will be set to the value of the the given ``arg``.
+ // NOTE: only natural width integer arguments for the machine are supported.
+ // Behaviour with non primitive arguments is undefined.
if (!data)
return false;
+ Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
Error error;
RegisterContext* reg_ctx = context.GetRegisterContext();
Process* process = context.GetProcessPtr();
+ bool success = false; // return value
- if (context.GetTargetPtr()->GetArchitecture().GetMachine() == llvm::Triple::ArchType::x86)
+ if (!context.GetTargetPtr())
{
- uint64_t sp = reg_ctx->GetSP();
+ if (log)
+ log->Printf("RenderScriptRuntime::GetArgSimple - Invalid target");
+
+ return false;
+ }
+
+ switch (context.GetTargetPtr()->GetArchitecture().GetMachine())
+ {
+ case llvm::Triple::ArchType::x86:
{
+ uint64_t sp = reg_ctx->GetSP();
uint32_t offset = (1 + arg) * sizeof(uint32_t);
- process->ReadMemory(sp + offset, data, sizeof(uint32_t), error);
- if(error.Fail())
+ uint32_t result = 0;
+ process->ReadMemory(sp + offset, &result, sizeof(uint32_t), error);
+ if (error.Fail())
{
- if(log)
- log->Printf ("RenderScriptRuntime:: GetArg32Simple - error reading X86 stack: %s.", error.AsCString());
+ if (log)
+ log->Printf("RenderScriptRuntime::GetArgSimple - error reading X86 stack: %s.", error.AsCString());
}
+ else
+ {
+ *data = result;
+ success = true;
+ }
+
+ break;
}
- }
- else if (context.GetTargetPtr()->GetArchitecture().GetMachine() == llvm::Triple::ArchType::arm)
- {
- if (arg < 4)
+ case llvm::Triple::ArchType::x86_64:
{
- const RegisterInfo* rArg = reg_ctx->GetRegisterInfoAtIndex(arg);
+ // amd64 has 6 integer registers, and 8 XMM registers for parameter passing.
+ // Surplus args are spilled onto the stack.
+ // rdi, rsi, rdx, rcx, r8, r9, (zmm0 - 7 for vectors)
+ // ref: AMD64 ABI Draft 0.99.6 – October 7, 2013 – 10:35; Figure 3.4. Retrieved from
+ // http://www.x86-64.org/documentation/abi.pdf
+ if (arg > 5)
+ {
+ if (log)
+ log->Warning("X86_64 register spill is not supported.");
+ break;
+ }
+ const char * regnames[] = {"rdi", "rsi", "rdx", "rcx", "r8", "r9"};
+ assert((sizeof(regnames) / sizeof(const char *)) > arg);
+ const RegisterInfo *rArg = reg_ctx->GetRegisterInfoByName(regnames[arg]);
RegisterValue rVal;
- reg_ctx->ReadRegister(rArg, rVal);
- (*data) = rVal.GetAsUInt32();
+ success = reg_ctx->ReadRegister(rArg, rVal);
+ if (success)
+ {
+ *data = rVal.GetAsUInt64(0u, &success);
+ }
+ else
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::GetArgSimple - error reading x86_64 register: %d.", arg);
+ }
+ break;
}
- else
+ case llvm::Triple::ArchType::arm:
{
- uint64_t sp = reg_ctx->GetSP();
+ // arm 32 bit
+ if (arg < 4)
{
+ const RegisterInfo* rArg = reg_ctx->GetRegisterInfoAtIndex(arg);
+ RegisterValue rVal;
+ success = reg_ctx->ReadRegister(rArg, rVal);
+ if (success)
+ {
+ (*data) = rVal.GetAsUInt32(0u, &success);
+ }
+ else
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::GetArgSimple - error reading ARM register: %d.", arg);
+ }
+ }
+ else
+ {
+ uint64_t sp = reg_ctx->GetSP();
uint32_t offset = (arg-4) * sizeof(uint32_t);
process->ReadMemory(sp + offset, &data, sizeof(uint32_t), error);
- if(error.Fail())
+ if (error.Fail())
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::GetArgSimple - error reading ARM stack: %s.", error.AsCString());
+ }
+ else
{
- if(log)
- log->Printf ("RenderScriptRuntime:: GetArg32Simple - error reading ARM stack: %s.", error.AsCString());
+ success = true;
}
}
- }
+
+ break;
+ }
+ case llvm::Triple::ArchType::aarch64:
+ {
+ // arm 64 bit
+ // first 8 arguments are in the registers
+ if (arg < 8)
+ {
+ const RegisterInfo* rArg = reg_ctx->GetRegisterInfoAtIndex(arg);
+ RegisterValue rVal;
+ success = reg_ctx->ReadRegister(rArg, rVal);
+ if (success)
+ {
+ *data = rVal.GetAsUInt64(0u, &success);
+ }
+ else
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::GetArgSimple() - AARCH64 - Error while reading the argument #%d", arg);
+ }
+ }
+ else
+ {
+ // @TODO: need to find the argument in the stack
+ if (log)
+ log->Printf("RenderScriptRuntime::GetArgSimple - AARCH64 - FOR #ARG >= 8 NOT IMPLEMENTED YET. Argument number: %d", arg);
+ }
+ break;
+ }
+ case llvm::Triple::ArchType::mipsel:
+ {
+
+ // read from the registers
+ if (arg < 4){
+ const RegisterInfo* rArg = reg_ctx->GetRegisterInfoAtIndex(arg + 4);
+ RegisterValue rVal;
+ success = reg_ctx->ReadRegister(rArg, rVal);
+ if (success)
+ {
+ *data = rVal.GetAsUInt64(0u, &success);
+ }
+ else
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::GetArgSimple() - Mips - Error while reading the argument #%d", arg);
+ }
+
+ }
+
+ // read from the stack
+ else
+ {
+ uint64_t sp = reg_ctx->GetSP();
+ uint32_t offset = arg * sizeof(uint32_t);
+ process->ReadMemory(sp + offset, &data, sizeof(uint32_t), error);
+ if (error.Fail())
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::GetArgSimple - error reading Mips stack: %s.", error.AsCString());
+ }
+ else
+ {
+ success = true;
+ }
+ }
+
+ break;
+ }
+ case llvm::Triple::ArchType::mips64el:
+ {
+ // read from the registers
+ if (arg < 8)
+ {
+ const RegisterInfo* rArg = reg_ctx->GetRegisterInfoAtIndex(arg + 4);
+ RegisterValue rVal;
+ success = reg_ctx->ReadRegister(rArg, rVal);
+ if (success)
+ {
+ (*data) = rVal.GetAsUInt64(0u, &success);
+ }
+ else
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::GetArgSimple - Mips64 - Error reading the argument #%d", arg);
+ }
+ }
+
+ // read from the stack
+ else
+ {
+ uint64_t sp = reg_ctx->GetSP();
+ uint32_t offset = (arg - 8) * sizeof(uint64_t);
+ process->ReadMemory(sp + offset, &data, sizeof(uint64_t), error);
+ if (error.Fail())
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::GetArgSimple - Mips64 - Error reading Mips64 stack: %s.", error.AsCString());
+ }
+ else
+ {
+ success = true;
+ }
+ }
+
+ break;
+ }
+ default:
+ {
+ // invalid architecture
+ if (log)
+ log->Printf("RenderScriptRuntime::GetArgSimple - Architecture not supported");
+
+ }
}
- return true;
+
+ if (!success)
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::GetArgSimple - failed to get argument at index %" PRIu32, arg);
+ }
+ return success;
}
void
@@ -267,35 +902,38 @@ RenderScriptRuntime::CaptureSetGlobalVar1(RuntimeHook* hook_info, ExecutionConte
//Context, Script, int, data, length
- Error error;
-
- uint32_t rs_context_u32 = 0U;
- uint32_t rs_script_u32 = 0U;
- uint32_t rs_id_u32 = 0U;
- uint32_t rs_data_u32 = 0U;
- uint32_t rs_length_u32 = 0U;
+ uint64_t rs_context_u64 = 0U;
+ uint64_t rs_script_u64 = 0U;
+ uint64_t rs_id_u64 = 0U;
+ uint64_t rs_data_u64 = 0U;
+ uint64_t rs_length_u64 = 0U;
- std::string resname;
- std::string cachedir;
+ bool success =
+ GetArgSimple(context, 0, &rs_context_u64) &&
+ GetArgSimple(context, 1, &rs_script_u64) &&
+ GetArgSimple(context, 2, &rs_id_u64) &&
+ GetArgSimple(context, 3, &rs_data_u64) &&
+ GetArgSimple(context, 4, &rs_length_u64);
- GetArg32Simple(context, 0, &rs_context_u32);
- GetArg32Simple(context, 1, &rs_script_u32);
- GetArg32Simple(context, 2, &rs_id_u32);
- GetArg32Simple(context, 3, &rs_data_u32);
- GetArg32Simple(context, 4, &rs_length_u32);
+ if (!success)
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::CaptureSetGlobalVar1 - Error while reading the function parameters");
+ return;
+ }
- if(log)
+ if (log)
{
log->Printf ("RenderScriptRuntime::CaptureSetGlobalVar1 - 0x%" PRIx64 ",0x%" PRIx64 " slot %" PRIu64 " = 0x%" PRIx64 ":%" PRIu64 "bytes.",
- (uint64_t)rs_context_u32, (uint64_t)rs_script_u32, (uint64_t)rs_id_u32, (uint64_t)rs_data_u32, (uint64_t)rs_length_u32);
+ rs_context_u64, rs_script_u64, rs_id_u64, rs_data_u64, rs_length_u64);
- addr_t script_addr = (addr_t)rs_script_u32;
+ addr_t script_addr = (addr_t)rs_script_u64;
if (m_scriptMappings.find( script_addr ) != m_scriptMappings.end())
{
auto rsm = m_scriptMappings[script_addr];
- if (rs_id_u32 < rsm->m_globals.size())
+ if (rs_id_u64 < rsm->m_globals.size())
{
- auto rsg = rsm->m_globals[rs_id_u32];
+ auto rsg = rsm->m_globals[rs_id_u64];
log->Printf ("RenderScriptRuntime::CaptureSetGlobalVar1 - Setting of '%s' within '%s' inferred", rsg.m_name.AsCString(),
rsm->m_module->GetFileSpec().GetFilename().AsCString());
}
@@ -310,19 +948,65 @@ RenderScriptRuntime::CaptureAllocationInit1(RuntimeHook* hook_info, ExecutionCon
//Context, Alloc, bool
- Error error;
-
- uint32_t rs_context_u32 = 0U;
- uint32_t rs_alloc_u32 = 0U;
- uint32_t rs_forceZero_u32 = 0U;
-
- GetArg32Simple(context, 0, &rs_context_u32);
- GetArg32Simple(context, 1, &rs_alloc_u32);
- GetArg32Simple(context, 2, &rs_forceZero_u32);
-
- if(log)
+ uint64_t rs_context_u64 = 0U;
+ uint64_t rs_alloc_u64 = 0U;
+ uint64_t rs_forceZero_u64 = 0U;
+
+ bool success =
+ GetArgSimple(context, 0, &rs_context_u64) &&
+ GetArgSimple(context, 1, &rs_alloc_u64) &&
+ GetArgSimple(context, 2, &rs_forceZero_u64);
+ if (!success) // error case
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::CaptureAllocationInit1 - Error while reading the function parameters");
+ return; // abort
+ }
+
+ if (log)
log->Printf ("RenderScriptRuntime::CaptureAllocationInit1 - 0x%" PRIx64 ",0x%" PRIx64 ",0x%" PRIx64 " .",
- (uint64_t)rs_context_u32, (uint64_t)rs_alloc_u32, (uint64_t)rs_forceZero_u32);
+ rs_context_u64, rs_alloc_u64, rs_forceZero_u64);
+
+ AllocationDetails* alloc = LookUpAllocation(rs_alloc_u64, true);
+ if (alloc)
+ alloc->context = rs_context_u64;
+}
+
+void
+RenderScriptRuntime::CaptureAllocationDestroy(RuntimeHook* hook_info, ExecutionContext& context)
+{
+ Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+ // Context, Alloc
+ uint64_t rs_context_u64 = 0U;
+ uint64_t rs_alloc_u64 = 0U;
+
+ bool success = GetArgSimple(context, 0, &rs_context_u64) && GetArgSimple(context, 1, &rs_alloc_u64);
+ if (!success) // error case
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::CaptureAllocationDestroy - Error while reading the function parameters");
+ return; // abort
+ }
+
+ if (log)
+ log->Printf("RenderScriptRuntime::CaptureAllocationDestroy - 0x%" PRIx64 ", 0x%" PRIx64 ".",
+ rs_context_u64, rs_alloc_u64);
+
+ 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() == rs_alloc_u64)
+ {
+ m_allocations.erase(iter);
+ if (log)
+ log->Printf("RenderScriptRuntime::CaptureAllocationDestroy - Deleted allocation entry");
+ return;
+ }
+ }
+
+ if (log)
+ log->Printf("RenderScriptRuntime::CaptureAllocationDestroy - Couldn't find destroyed allocation");
}
void
@@ -334,64 +1018,72 @@ RenderScriptRuntime::CaptureScriptInit1(RuntimeHook* hook_info, ExecutionContext
Error error;
Process* process = context.GetProcessPtr();
- uint32_t rs_context_u32 = 0U;
- uint32_t rs_script_u32 = 0U;
- uint32_t rs_resnameptr_u32 = 0U;
- uint32_t rs_cachedirptr_u32 = 0U;
+ uint64_t rs_context_u64 = 0U;
+ uint64_t rs_script_u64 = 0U;
+ uint64_t rs_resnameptr_u64 = 0U;
+ uint64_t rs_cachedirptr_u64 = 0U;
std::string resname;
std::string cachedir;
- GetArg32Simple(context, 0, &rs_context_u32);
- GetArg32Simple(context, 1, &rs_script_u32);
- GetArg32Simple(context, 2, &rs_resnameptr_u32);
- GetArg32Simple(context, 3, &rs_cachedirptr_u32);
+ // read the function parameters
+ bool success =
+ GetArgSimple(context, 0, &rs_context_u64) &&
+ GetArgSimple(context, 1, &rs_script_u64) &&
+ GetArgSimple(context, 2, &rs_resnameptr_u64) &&
+ GetArgSimple(context, 3, &rs_cachedirptr_u64);
- process->ReadCStringFromMemory((lldb::addr_t)rs_resnameptr_u32, resname, error);
+ if (!success)
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::CaptureScriptInit1 - Error while reading the function parameters");
+ return;
+ }
+
+ process->ReadCStringFromMemory((lldb::addr_t)rs_resnameptr_u64, resname, error);
if (error.Fail())
{
- if(log)
+ if (log)
log->Printf ("RenderScriptRuntime::CaptureScriptInit1 - error reading resname: %s.", error.AsCString());
}
- process->ReadCStringFromMemory((lldb::addr_t)rs_cachedirptr_u32, cachedir, error);
+ process->ReadCStringFromMemory((lldb::addr_t)rs_cachedirptr_u64, cachedir, error);
if (error.Fail())
{
- if(log)
+ if (log)
log->Printf ("RenderScriptRuntime::CaptureScriptInit1 - error reading cachedir: %s.", error.AsCString());
}
if (log)
log->Printf ("RenderScriptRuntime::CaptureScriptInit1 - 0x%" PRIx64 ",0x%" PRIx64 " => '%s' at '%s' .",
- (uint64_t)rs_context_u32, (uint64_t)rs_script_u32, resname.c_str(), cachedir.c_str());
+ rs_context_u64, rs_script_u64, resname.c_str(), cachedir.c_str());
if (resname.size() > 0)
{
StreamString strm;
strm.Printf("librs.%s.so", resname.c_str());
- ScriptDetails script;
- script.cachedir = cachedir;
- script.resname = resname;
- script.scriptDyLib.assign(strm.GetData());
- script.script = rs_script_u32;
- script.context = rs_context_u32;
-
- m_scripts.push_back(script);
+ ScriptDetails* script = LookUpScript(rs_script_u64, true);
+ if (script)
+ {
+ script->type = ScriptDetails::eScriptC;
+ script->cacheDir = cachedir;
+ script->resName = resname;
+ script->scriptDyLib = strm.GetData();
+ script->context = addr_t(rs_context_u64);
+ }
if (log)
log->Printf ("RenderScriptRuntime::CaptureScriptInit1 - '%s' tagged with context 0x%" PRIx64 " and script 0x%" PRIx64 ".",
- strm.GetData(), (uint64_t)rs_context_u32, (uint64_t)rs_script_u32);
+ strm.GetData(), rs_context_u64, rs_script_u64);
}
else if (log)
{
log->Printf ("RenderScriptRuntime::CaptureScriptInit1 - resource name invalid, Script not tagged");
}
-
}
-
void
RenderScriptRuntime::LoadRuntimeHooks(lldb::ModuleSP module, ModuleKind kind)
{
@@ -402,16 +1094,24 @@ RenderScriptRuntime::LoadRuntimeHooks(lldb::ModuleSP module, ModuleKind kind)
return;
}
- if ((GetProcess()->GetTarget().GetArchitecture().GetMachine() != llvm::Triple::ArchType::x86)
- && (GetProcess()->GetTarget().GetArchitecture().GetMachine() != llvm::Triple::ArchType::arm))
+ Target &target = GetProcess()->GetTarget();
+ llvm::Triple::ArchType targetArchType = target.GetArchitecture().GetMachine();
+
+ if (targetArchType != llvm::Triple::ArchType::x86
+ && targetArchType != llvm::Triple::ArchType::arm
+ && targetArchType != llvm::Triple::ArchType::aarch64
+ && targetArchType != llvm::Triple::ArchType::mipsel
+ && targetArchType != llvm::Triple::ArchType::mips64el
+ && targetArchType != llvm::Triple::ArchType::x86_64
+ )
{
if (log)
- log->Printf ("RenderScriptRuntime::LoadRuntimeHooks - Unable to hook runtime. Only X86, ARM supported currently.");
+ log->Printf ("RenderScriptRuntime::LoadRuntimeHooks - Unable to hook runtime. Only X86, ARM, Mips supported currently.");
return;
}
- Target &target = GetProcess()->GetTarget();
+ uint32_t archByteSize = target.GetArchitecture().GetAddressByteSize();
for (size_t idx = 0; idx < s_runtimeHookCount; idx++)
{
@@ -420,16 +1120,29 @@ RenderScriptRuntime::LoadRuntimeHooks(lldb::ModuleSP module, ModuleKind kind)
continue;
}
- const Symbol *sym = module->FindFirstSymbolWithNameAndType(ConstString(hook_defn->symbol_name), eSymbolTypeCode);
+ const char* symbol_name = (archByteSize == 4) ? hook_defn->symbol_name_m32 : hook_defn->symbol_name_m64;
+
+ const Symbol *sym = module->FindFirstSymbolWithNameAndType(ConstString(symbol_name), eSymbolTypeCode);
+ if (!sym){
+ if (log){
+ log->Printf("RenderScriptRuntime::LoadRuntimeHooks - ERROR: Symbol '%s' related to the function %s not found", symbol_name, hook_defn->name);
+ }
+ continue;
+ }
addr_t addr = sym->GetLoadAddress(&target);
if (addr == LLDB_INVALID_ADDRESS)
{
- if(log)
+ if (log)
log->Printf ("RenderScriptRuntime::LoadRuntimeHooks - Unable to resolve the address of hook function '%s' with symbol '%s'.",
- hook_defn->name, hook_defn->symbol_name);
+ hook_defn->name, symbol_name);
continue;
}
+ else
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::LoadRuntimeHooks - Function %s, address resolved at 0x%" PRIx64, hook_defn->name, addr);
+ }
RuntimeHookSP hook(new RuntimeHook());
hook->address = addr;
@@ -455,35 +1168,1082 @@ RenderScriptRuntime::FixupScriptDetails(RSModuleDescriptorSP rsmodule_sp)
const ModuleSP module = rsmodule_sp->m_module;
const FileSpec& file = module->GetPlatformFileSpec();
-
- for (const auto &rs_script : m_scripts)
+
+ // Iterate over all of the scripts that we currently know of.
+ // Note: We cant push or pop to m_scripts here or it may invalidate rs_script.
+ for (const auto & rs_script : m_scripts)
+ {
+ // Extract the expected .so file path for this script.
+ std::string dylib;
+ if (!rs_script->scriptDyLib.get(dylib))
+ continue;
+
+ // Only proceed if the module that has loaded corresponds to this script.
+ if (file.GetFilename() != ConstString(dylib.c_str()))
+ continue;
+
+ // Obtain the script address which we use as a key.
+ lldb::addr_t script;
+ if (!rs_script->script.get(script))
+ continue;
+
+ // If we have a script mapping for the current script.
+ if (m_scriptMappings.find(script) != m_scriptMappings.end())
+ {
+ // if the module we have stored is different to the one we just received.
+ if (m_scriptMappings[script] != rsmodule_sp)
+ {
+ if (log)
+ log->Printf ("RenderScriptRuntime::FixupScriptDetails - Error: script %" PRIx64 " wants reassigned to new rsmodule '%s'.",
+ (uint64_t)script, rsmodule_sp->m_module->GetFileSpec().GetFilename().AsCString());
+ }
+ }
+ // We don't have a script mapping for the current script.
+ else
+ {
+ // Obtain the script resource name.
+ std::string resName;
+ if (rs_script->resName.get(resName))
+ // Set the modules resource name.
+ rsmodule_sp->m_resname = resName;
+ // Add Script/Module pair to map.
+ m_scriptMappings[script] = rsmodule_sp;
+ if (log)
+ log->Printf ("RenderScriptRuntime::FixupScriptDetails - script %" PRIx64 " associated with rsmodule '%s'.",
+ (uint64_t)script, rsmodule_sp->m_module->GetFileSpec().GetFilename().AsCString());
+ }
+ }
+}
+
+// Uses the Target API to evaluate the expression passed as a parameter to the function
+// The result of that expression is returned an unsigned 64 bit int, via the result* paramter.
+// Function returns true on success, and false on failure
+bool
+RenderScriptRuntime::EvalRSExpression(const char* expression, StackFrame* frame_ptr, uint64_t* result)
+{
+ Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+ if (log)
+ log->Printf("RenderScriptRuntime::EvalRSExpression(%s)", expression);
+
+ ValueObjectSP expr_result;
+ // Perform the actual expression evaluation
+ GetProcess()->GetTarget().EvaluateExpression(expression, frame_ptr, expr_result);
+
+ if (!expr_result)
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::EvalRSExpression - Error: Couldn't evaluate expression");
+ return false;
+ }
+
+ // The result of the expression is invalid
+ if (!expr_result->GetError().Success())
+ {
+ Error err = expr_result->GetError();
+ if (err.GetError() == UserExpression::kNoResult) // Expression returned void, so this is actually a success
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::EvalRSExpression - Expression returned void");
+
+ result = nullptr;
+ return true;
+ }
+
+ if (log)
+ log->Printf("RenderScriptRuntime::EvalRSExpression - Error evaluating expression result: %s", err.AsCString());
+ return false;
+ }
+
+ bool success = false;
+ *result = expr_result->GetValueAsUnsigned(0, &success); // We only read the result as an unsigned int.
+
+ if (!success)
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::EvalRSExpression - Error: Couldn't convert expression result to unsigned int");
+ return false;
+ }
+
+ return true;
+}
+
+namespace // anonymous
+{
+ // max length of an expanded expression
+ const int jit_max_expr_size = 768;
+
+ // Format strings containing the expressions we may need to evaluate.
+ const char runtimeExpressions[][256] =
+ {
+ // Mangled GetOffsetPointer(Allocation*, xoff, yoff, zoff, lod, cubemap)
+ "(int*)_Z12GetOffsetPtrPKN7android12renderscript10AllocationEjjjj23RsAllocationCubemapFace(0x%lx, %u, %u, %u, 0, 0)",
+
+ // Type* rsaAllocationGetType(Context*, Allocation*)
+ "(void*)rsaAllocationGetType(0x%lx, 0x%lx)",
+
+ // rsaTypeGetNativeData(Context*, Type*, void* typeData, size)
+ // Pack the data in the following way mHal.state.dimX; mHal.state.dimY; mHal.state.dimZ;
+ // mHal.state.lodCount; mHal.state.faces; mElement; into typeData
+ // Need to specify 32 or 64 bit for uint_t since this differs between devices
+ "uint%u_t data[6]; (void*)rsaTypeGetNativeData(0x%lx, 0x%lx, data, 6); data[0]", // X dim
+ "uint%u_t data[6]; (void*)rsaTypeGetNativeData(0x%lx, 0x%lx, data, 6); data[1]", // Y dim
+ "uint%u_t data[6]; (void*)rsaTypeGetNativeData(0x%lx, 0x%lx, data, 6); data[2]", // Z dim
+ "uint%u_t data[6]; (void*)rsaTypeGetNativeData(0x%lx, 0x%lx, data, 6); data[5]", // Element ptr
+
+ // rsaElementGetNativeData(Context*, Element*, uint32_t* elemData,size)
+ // Pack mType; mKind; mNormalized; mVectorSize; NumSubElements into elemData
+ "uint32_t data[5]; (void*)rsaElementGetNativeData(0x%lx, 0x%lx, data, 5); data[0]", // Type
+ "uint32_t data[5]; (void*)rsaElementGetNativeData(0x%lx, 0x%lx, data, 5); data[1]", // Kind
+ "uint32_t data[5]; (void*)rsaElementGetNativeData(0x%lx, 0x%lx, data, 5); data[3]", // Vector Size
+ "uint32_t data[5]; (void*)rsaElementGetNativeData(0x%lx, 0x%lx, data, 5); data[4]", // Field Count
+
+ // rsaElementGetSubElements(RsContext con, RsElement elem, uintptr_t *ids, const char **names,
+ // size_t *arraySizes, uint32_t dataSize)
+ // Needed for Allocations of structs to gather details about fields/Subelements
+ "void* ids[%u]; const char* names[%u]; size_t arr_size[%u];"
+ "(void*)rsaElementGetSubElements(0x%lx, 0x%lx, ids, names, arr_size, %u); ids[%u]", // Element* of field
+
+ "void* ids[%u]; const char* names[%u]; size_t arr_size[%u];"
+ "(void*)rsaElementGetSubElements(0x%lx, 0x%lx, ids, names, arr_size, %u); names[%u]", // Name of field
+
+ "void* ids[%u]; const char* names[%u]; size_t arr_size[%u];"
+ "(void*)rsaElementGetSubElements(0x%lx, 0x%lx, ids, names, arr_size, %u); arr_size[%u]" // Array size of field
+ };
+
+
+ // Temporary workaround for MIPS, until the compiler emits the JAL instruction when invoking directly the function.
+ // At the moment, when evaluating an expression involving a function call, the LLVM codegen for Mips emits a JAL
+ // instruction, which is able to jump in the range +/- 128MB with respect to the current program counter ($pc). If
+ // the requested function happens to reside outside the above region, the function address will be truncated and the
+ // function invocation will fail. This is a problem in the RS plugin as we rely on the RS API to probe the number and
+ // the nature of allocations. A proper solution in the MIPS compiler is currently being investigated. As temporary
+ // work around for this context, we'll invoke the RS API through function pointers, which cause the compiler to emit a
+ // register based JALR instruction.
+ const char runtimeExpressions_mips[][512] =
+ {
+ // Mangled GetOffsetPointer(Allocation*, xoff, yoff, zoff, lod, cubemap)
+ "int* (*f) (void*, int, int, int, int, int) = (int* (*) (void*, int, int, int, int, int)) "
+ "_Z12GetOffsetPtrPKN7android12renderscript10AllocationEjjjj23RsAllocationCubemapFace; "
+ "(int*) f((void*) 0x%lx, %u, %u, %u, 0, 0)",
+
+ // Type* rsaAllocationGetType(Context*, Allocation*)
+ "void* (*f) (void*, void*) = (void* (*) (void*, void*)) rsaAllocationGetType; (void*) f((void*) 0x%lx, (void*) 0x%lx)",
+
+ // rsaTypeGetNativeData(Context*, Type*, void* typeData, size)
+ // Pack the data in the following way mHal.state.dimX; mHal.state.dimY; mHal.state.dimZ;
+ // mHal.state.lodCount; mHal.state.faces; mElement; into typeData
+ // Need to specify 32 or 64 bit for uint_t since this differs between devices
+ "uint%u_t data[6]; void* (*f)(void*, void*, uintptr_t*, uint32_t) = (void* (*)(void*, void*, uintptr_t*, uint32_t)) "
+ "rsaTypeGetNativeData; (void*) f((void*) 0x%lx, (void*) 0x%lx, data, 6); data[0]",
+ "uint%u_t data[6]; void* (*f)(void*, void*, uintptr_t*, uint32_t) = (void* (*)(void*, void*, uintptr_t*, uint32_t)) "
+ "rsaTypeGetNativeData; (void*) f((void*) 0x%lx, (void*) 0x%lx, data, 6); data[1]",
+ "uint%u_t data[6]; void* (*f)(void*, void*, uintptr_t*, uint32_t) = (void* (*)(void*, void*, uintptr_t*, uint32_t)) "
+ "rsaTypeGetNativeData; (void*) f((void*) 0x%lx, (void*) 0x%lx, data, 6); data[2]",
+ "uint%u_t data[6]; void* (*f)(void*, void*, uintptr_t*, uint32_t) = (void* (*)(void*, void*, uintptr_t*, uint32_t)) "
+ "rsaTypeGetNativeData; (void*) f((void*) 0x%lx, (void*) 0x%lx, data, 6); data[5]",
+
+ // rsaElementGetNativeData(Context*, Element*, uint32_t* elemData,size)
+ // Pack mType; mKind; mNormalized; mVectorSize; NumSubElements into elemData
+ "uint32_t data[5]; void* (*f)(void*, void*, uint32_t*, uint32_t) = (void* (*)(void*, void*, uint32_t*, uint32_t)) "
+ "rsaElementGetNativeData; (void*) f((void*) 0x%lx, (void*) 0x%lx, data, 5); data[0]", // Type
+ "uint32_t data[5]; void* (*f)(void*, void*, uint32_t*, uint32_t) = (void* (*)(void*, void*, uint32_t*, uint32_t)) "
+ "rsaElementGetNativeData; (void*) f((void*) 0x%lx, (void*) 0x%lx, data, 5); data[1]", // Kind
+ "uint32_t data[5]; void* (*f)(void*, void*, uint32_t*, uint32_t) = (void* (*)(void*, void*, uint32_t*, uint32_t)) "
+ "rsaElementGetNativeData; (void*) f((void*) 0x%lx, (void*) 0x%lx, data, 5); data[3]", // Vector size
+ "uint32_t data[5]; void* (*f)(void*, void*, uint32_t*, uint32_t) = (void* (*)(void*, void*, uint32_t*, uint32_t)) "
+ "rsaElementGetNativeData; (void*) f((void*) 0x%lx, (void*) 0x%lx, data, 5); data[4]", // Field count
+
+ // rsaElementGetSubElements(RsContext con, RsElement elem, uintptr_t *ids, const char **names,
+ // size_t *arraySizes, uint32_t dataSize)
+ // Needed for Allocations of structs to gather details about fields/Subelements
+ "void* ids[%u]; const char* names[%u]; size_t arr_size[%u];"
+ "void* (*f) (void*, void*, uintptr_t*, const char**, size_t*, uint32_t) = "
+ "(void* (*) (void*, void*, uintptr_t*, const char**, size_t*, uint32_t)) rsaElementGetSubElements;"
+ "(void*) f((void*) 0x%lx, (void*) 0x%lx, (uintptr_t*) ids, names, arr_size, (uint32_t) %u);"
+ "ids[%u]", // Element* of field
+ "void* ids[%u]; const char* names[%u]; size_t arr_size[%u];"
+ "void* (*f) (void*, void*, uintptr_t*, const char**, size_t*, uint32_t) = "
+ "(void* (*) (void*, void*, uintptr_t*, const char**, size_t*, uint32_t)) rsaElementGetSubElements;"
+ "(void*) f((void*) 0x%lx, (void*) 0x%lx, (uintptr_t*) ids, names, arr_size, (uint32_t) %u);"
+ "names[%u]", // Name of field
+ "void* ids[%u]; const char* names[%u]; size_t arr_size[%u];"
+ "void* (*f) (void*, void*, uintptr_t*, const char**, size_t*, uint32_t) = "
+ "(void* (*) (void*, void*, uintptr_t*, const char**, size_t*, uint32_t)) rsaElementGetSubElements;"
+ "(void*) f((void*) 0x%lx, (void*) 0x%lx, (uintptr_t*) ids, names, arr_size, (uint32_t) %u);"
+ "arr_size[%u]" // Array size of field
+ };
+
+} // end of the anonymous namespace
+
+
+// Retrieve the string to JIT for the given expression
+const char*
+RenderScriptRuntime::JITTemplate(ExpressionStrings e)
+{
+ // be nice to your Mips friend when adding new expression strings
+ static_assert(sizeof(runtimeExpressions)/sizeof(runtimeExpressions[0]) ==
+ sizeof(runtimeExpressions_mips)/sizeof(runtimeExpressions_mips[0]),
+ "#runtimeExpressions != #runtimeExpressions_mips");
+
+ assert((e >= eExprGetOffsetPtr && e <= eExprSubelementsArrSize) &&
+ "Expression string out of bounds");
+
+ llvm::Triple::ArchType arch = GetTargetRef().GetArchitecture().GetMachine();
+
+ // mips JAL workaround
+ if(arch == llvm::Triple::ArchType::mips64el || arch == llvm::Triple::ArchType::mipsel)
+ return runtimeExpressions_mips[e];
+ else
+ return runtimeExpressions[e];
+}
+
+
+// JITs the RS runtime for the internal data pointer of an allocation.
+// Is passed x,y,z coordinates for the pointer to a specific element.
+// Then sets the data_ptr member in Allocation with the result.
+// Returns true on success, false otherwise
+bool
+RenderScriptRuntime::JITDataPointer(AllocationDetails* allocation, StackFrame* frame_ptr,
+ unsigned int x, unsigned int y, unsigned int z)
+{
+ Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+ if (!allocation->address.isValid())
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::JITDataPointer - Failed to find allocation details");
+ return false;
+ }
+
+ const char* expr_cstr = JITTemplate(eExprGetOffsetPtr);
+ char buffer[jit_max_expr_size];
+
+ int chars_written = snprintf(buffer, jit_max_expr_size, expr_cstr, *allocation->address.get(), x, y, z);
+ if (chars_written < 0)
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::JITDataPointer - Encoding error in snprintf()");
+ return false;
+ }
+ else if (chars_written >= jit_max_expr_size)
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::JITDataPointer - Expression too long");
+ return false;
+ }
+
+ uint64_t result = 0;
+ if (!EvalRSExpression(buffer, frame_ptr, &result))
+ return false;
+
+ addr_t mem_ptr = static_cast<lldb::addr_t>(result);
+ allocation->data_ptr = mem_ptr;
+
+ return true;
+}
+
+// JITs the RS runtime for the internal pointer to the RS Type of an allocation
+// Then sets the type_ptr member in Allocation with the result.
+// Returns true on success, false otherwise
+bool
+RenderScriptRuntime::JITTypePointer(AllocationDetails* allocation, StackFrame* frame_ptr)
+{
+ Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+ if (!allocation->address.isValid() || !allocation->context.isValid())
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::JITTypePointer - Failed to find allocation details");
+ return false;
+ }
+
+ const char* expr_cstr = JITTemplate(eExprAllocGetType);
+ char buffer[jit_max_expr_size];
+
+ int chars_written = snprintf(buffer, jit_max_expr_size, expr_cstr, *allocation->context.get(), *allocation->address.get());
+ if (chars_written < 0)
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::JITDataPointer - Encoding error in snprintf()");
+ return false;
+ }
+ else if (chars_written >= jit_max_expr_size)
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::JITTypePointer - Expression too long");
+ return false;
+ }
+
+ uint64_t result = 0;
+ if (!EvalRSExpression(buffer, frame_ptr, &result))
+ return false;
+
+ addr_t type_ptr = static_cast<lldb::addr_t>(result);
+ allocation->type_ptr = type_ptr;
+
+ return true;
+}
+
+// JITs the RS runtime for information about the dimensions and type of an allocation
+// Then sets dimension and element_ptr members in Allocation with the result.
+// Returns true on success, false otherwise
+bool
+RenderScriptRuntime::JITTypePacked(AllocationDetails* allocation, StackFrame* frame_ptr)
+{
+ Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+ if (!allocation->type_ptr.isValid() || !allocation->context.isValid())
{
- if (file.GetFilename() == ConstString(rs_script.scriptDyLib.c_str()))
+ if (log)
+ log->Printf("RenderScriptRuntime::JITTypePacked - Failed to find allocation details");
+ return false;
+ }
+
+ // Expression is different depending on if device is 32 or 64 bit
+ uint32_t archByteSize = GetProcess()->GetTarget().GetArchitecture().GetAddressByteSize();
+ const unsigned int bits = archByteSize == 4 ? 32 : 64;
+
+ // We want 4 elements from packed data
+ const unsigned int num_exprs = 4;
+ assert(num_exprs == (eExprTypeElemPtr - eExprTypeDimX + 1) && "Invalid number of expressions");
+
+ char buffer[num_exprs][jit_max_expr_size];
+ uint64_t results[num_exprs];
+
+ for (unsigned int i = 0; i < num_exprs; ++i)
+ {
+ const char* expr_cstr = JITTemplate((ExpressionStrings) (eExprTypeDimX + i));
+ int chars_written = snprintf(buffer[i], jit_max_expr_size, expr_cstr, bits,
+ *allocation->context.get(), *allocation->type_ptr.get());
+ if (chars_written < 0)
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::JITDataPointer - Encoding error in snprintf()");
+ return false;
+ }
+ else if (chars_written >= jit_max_expr_size)
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::JITTypePacked - Expression too long");
+ return false;
+ }
+
+ // Perform expression evaluation
+ if (!EvalRSExpression(buffer[i], frame_ptr, &results[i]))
+ return false;
+ }
+
+ // Assign results to allocation members
+ AllocationDetails::Dimension dims;
+ dims.dim_1 = static_cast<uint32_t>(results[0]);
+ dims.dim_2 = static_cast<uint32_t>(results[1]);
+ dims.dim_3 = static_cast<uint32_t>(results[2]);
+ allocation->dimension = dims;
+
+ addr_t elem_ptr = static_cast<lldb::addr_t>(results[3]);
+ allocation->element.element_ptr = elem_ptr;
+
+ if (log)
+ log->Printf("RenderScriptRuntime::JITTypePacked - dims (%u, %u, %u) Element*: 0x%" PRIx64,
+ dims.dim_1, dims.dim_2, dims.dim_3, elem_ptr);
+
+ return true;
+}
+
+// JITs the RS runtime for information about the Element of an allocation
+// Then sets type, type_vec_size, field_count and type_kind members in Element with the result.
+// Returns true on success, false otherwise
+bool
+RenderScriptRuntime::JITElementPacked(Element& elem, const lldb::addr_t context, StackFrame* frame_ptr)
+{
+ Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+ if (!elem.element_ptr.isValid())
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::JITElementPacked - Failed to find allocation details");
+ return false;
+ }
+
+ // We want 4 elements from packed data
+ const unsigned int num_exprs = 4;
+ assert(num_exprs == (eExprElementFieldCount - eExprElementType + 1) && "Invalid number of expressions");
+
+ char buffer[num_exprs][jit_max_expr_size];
+ uint64_t results[num_exprs];
+
+ for (unsigned int i = 0; i < num_exprs; i++)
+ {
+ const char* expr_cstr = JITTemplate((ExpressionStrings) (eExprElementType + i));
+ int chars_written = snprintf(buffer[i], jit_max_expr_size, expr_cstr, context, *elem.element_ptr.get());
+ if (chars_written < 0)
{
- if (m_scriptMappings.find( rs_script.script ) != m_scriptMappings.end())
+ if (log)
+ log->Printf("RenderScriptRuntime::JITElementPacked - Encoding error in snprintf()");
+ return false;
+ }
+ else if (chars_written >= jit_max_expr_size)
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::JITElementPacked - Expression too long");
+ return false;
+ }
+
+ // Perform expression evaluation
+ if (!EvalRSExpression(buffer[i], frame_ptr, &results[i]))
+ return false;
+ }
+
+ // Assign results to allocation members
+ elem.type = static_cast<RenderScriptRuntime::Element::DataType>(results[0]);
+ elem.type_kind = static_cast<RenderScriptRuntime::Element::DataKind>(results[1]);
+ elem.type_vec_size = static_cast<uint32_t>(results[2]);
+ elem.field_count = static_cast<uint32_t>(results[3]);
+
+ if (log)
+ log->Printf("RenderScriptRuntime::JITElementPacked - data type %u, pixel type %u, vector size %u, field count %u",
+ *elem.type.get(), *elem.type_kind.get(), *elem.type_vec_size.get(), *elem.field_count.get());
+
+ // If this Element has subelements then JIT rsaElementGetSubElements() for details about its fields
+ if (*elem.field_count.get() > 0 && !JITSubelements(elem, context, frame_ptr))
+ return false;
+
+ return true;
+}
+
+// JITs the RS runtime for information about the subelements/fields of a struct allocation
+// This is necessary for infering the struct type so we can pretty print the allocation's contents.
+// Returns true on success, false otherwise
+bool
+RenderScriptRuntime::JITSubelements(Element& elem, const lldb::addr_t context, StackFrame* frame_ptr)
+{
+ Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+ if (!elem.element_ptr.isValid() || !elem.field_count.isValid())
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::JITSubelements - Failed to find allocation details");
+ return false;
+ }
+
+ const short num_exprs = 3;
+ assert(num_exprs == (eExprSubelementsArrSize - eExprSubelementsId + 1) && "Invalid number of expressions");
+
+ char expr_buffer[jit_max_expr_size];
+ uint64_t results;
+
+ // Iterate over struct fields.
+ const uint32_t field_count = *elem.field_count.get();
+ for (unsigned int field_index = 0; field_index < field_count; ++field_index)
+ {
+ Element child;
+ for (unsigned int expr_index = 0; expr_index < num_exprs; ++expr_index)
+ {
+ const char* expr_cstr = JITTemplate((ExpressionStrings) (eExprSubelementsId + expr_index));
+ int chars_written = snprintf(expr_buffer, jit_max_expr_size, expr_cstr,
+ field_count, field_count, field_count,
+ context, *elem.element_ptr.get(), field_count, field_index);
+ if (chars_written < 0)
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::JITSubelements - Encoding error in snprintf()");
+ return false;
+ }
+ else if (chars_written >= jit_max_expr_size)
{
- if (m_scriptMappings[rs_script.script] != rsmodule_sp)
+ if (log)
+ log->Printf("RenderScriptRuntime::JITSubelements - Expression too long");
+ return false;
+ }
+
+ // Perform expression evaluation
+ if (!EvalRSExpression(expr_buffer, frame_ptr, &results))
+ return false;
+
+ if (log)
+ log->Printf("RenderScriptRuntime::JITSubelements - Expr result 0x%" PRIx64, results);
+
+ switch(expr_index)
+ {
+ case 0: // Element* of child
+ child.element_ptr = static_cast<addr_t>(results);
+ break;
+ case 1: // Name of child
{
- if (log)
+ lldb::addr_t address = static_cast<addr_t>(results);
+ Error err;
+ std::string name;
+ GetProcess()->ReadCStringFromMemory(address, name, err);
+ if (!err.Fail())
+ child.type_name = ConstString(name);
+ else
{
- log->Printf ("RenderScriptRuntime::FixupScriptDetails - Error: script %" PRIx64 " wants reassigned to new rsmodule '%s'.",
- (uint64_t)rs_script.script, rsmodule_sp->m_module->GetFileSpec().GetFilename().AsCString());
+ if (log)
+ log->Printf("RenderScriptRuntime::JITSubelements - Warning: Couldn't read field name");
}
+ break;
}
+ case 2: // Array size of child
+ child.array_size = static_cast<uint32_t>(results);
+ break;
}
- else
+ }
+
+ // We need to recursively JIT each Element field of the struct since
+ // structs can be nested inside structs.
+ if (!JITElementPacked(child, context, frame_ptr))
+ return false;
+ elem.children.push_back(child);
+ }
+
+ // Try to infer the name of the struct type so we can pretty print the allocation contents.
+ FindStructTypeName(elem, frame_ptr);
+
+ return true;
+}
+
+// JITs the RS runtime for the address of the last element in the allocation.
+// The `elem_size` paramter represents the size of a single element, including padding.
+// Which is needed as an offset from the last element pointer.
+// Using this offset minus the starting address we can calculate the size of the allocation.
+// Returns true on success, false otherwise
+bool
+RenderScriptRuntime::JITAllocationSize(AllocationDetails* allocation, StackFrame* frame_ptr)
+{
+ Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+ if (!allocation->address.isValid() || !allocation->dimension.isValid()
+ || !allocation->data_ptr.isValid() || !allocation->element.datum_size.isValid())
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::JITAllocationSize - Failed to find allocation details");
+ return false;
+ }
+
+ // Find dimensions
+ unsigned int dim_x = allocation->dimension.get()->dim_1;
+ unsigned int dim_y = allocation->dimension.get()->dim_2;
+ unsigned int dim_z = allocation->dimension.get()->dim_3;
+
+ // Our plan of jitting the last element address doesn't seem to work for struct Allocations
+ // Instead try to infer the size ourselves without any inter element padding.
+ if (allocation->element.children.size() > 0)
+ {
+ if (dim_x == 0) dim_x = 1;
+ if (dim_y == 0) dim_y = 1;
+ if (dim_z == 0) dim_z = 1;
+
+ allocation->size = dim_x * dim_y * dim_z * *allocation->element.datum_size.get();
+
+ if (log)
+ log->Printf("RenderScriptRuntime::JITAllocationSize - Infered size of struct allocation %u", *allocation->size.get());
+
+ return true;
+ }
+
+ const char* expr_cstr = JITTemplate(eExprGetOffsetPtr);
+ char buffer[jit_max_expr_size];
+
+ // Calculate last element
+ dim_x = dim_x == 0 ? 0 : dim_x - 1;
+ dim_y = dim_y == 0 ? 0 : dim_y - 1;
+ dim_z = dim_z == 0 ? 0 : dim_z - 1;
+
+ int chars_written = snprintf(buffer, jit_max_expr_size, expr_cstr, *allocation->address.get(),
+ dim_x, dim_y, dim_z);
+ if (chars_written < 0)
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::JITAllocationSize - Encoding error in snprintf()");
+ return false;
+ }
+ else if (chars_written >= jit_max_expr_size)
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::JITAllocationSize - Expression too long");
+ return false;
+ }
+
+ uint64_t result = 0;
+ if (!EvalRSExpression(buffer, frame_ptr, &result))
+ return false;
+
+ addr_t mem_ptr = static_cast<lldb::addr_t>(result);
+ // Find pointer to last element and add on size of an element
+ allocation->size = static_cast<uint32_t>(mem_ptr - *allocation->data_ptr.get()) + *allocation->element.datum_size.get();
+
+ return true;
+}
+
+// JITs the RS runtime for information about the stride between rows in the allocation.
+// This is done to detect padding, since allocated memory is 16-byte aligned.
+// Returns true on success, false otherwise
+bool
+RenderScriptRuntime::JITAllocationStride(AllocationDetails* allocation, StackFrame* frame_ptr)
+{
+ Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+ if (!allocation->address.isValid() || !allocation->data_ptr.isValid())
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::JITAllocationStride - Failed to find allocation details");
+ return false;
+ }
+
+ const char* expr_cstr = JITTemplate(eExprGetOffsetPtr);
+ char buffer[jit_max_expr_size];
+
+ int chars_written = snprintf(buffer, jit_max_expr_size, expr_cstr, *allocation->address.get(),
+ 0, 1, 0);
+ if (chars_written < 0)
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::JITAllocationStride - Encoding error in snprintf()");
+ return false;
+ }
+ else if (chars_written >= jit_max_expr_size)
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::JITAllocationStride - Expression too long");
+ return false;
+ }
+
+ uint64_t result = 0;
+ if (!EvalRSExpression(buffer, frame_ptr, &result))
+ return false;
+
+ addr_t mem_ptr = static_cast<lldb::addr_t>(result);
+ allocation->stride = static_cast<uint32_t>(mem_ptr - *allocation->data_ptr.get());
+
+ return true;
+}
+
+// JIT all the current runtime info regarding an allocation
+bool
+RenderScriptRuntime::RefreshAllocation(AllocationDetails* allocation, StackFrame* frame_ptr)
+{
+ // GetOffsetPointer()
+ if (!JITDataPointer(allocation, frame_ptr))
+ return false;
+
+ // rsaAllocationGetType()
+ if (!JITTypePointer(allocation, frame_ptr))
+ return false;
+
+ // rsaTypeGetNativeData()
+ if (!JITTypePacked(allocation, frame_ptr))
+ return false;
+
+ // rsaElementGetNativeData()
+ if (!JITElementPacked(allocation->element, *allocation->context.get(), frame_ptr))
+ return false;
+
+ // Sets the datum_size member in Element
+ SetElementSize(allocation->element);
+
+ // Use GetOffsetPointer() to infer size of the allocation
+ if (!JITAllocationSize(allocation, frame_ptr))
+ return false;
+
+ return true;
+}
+
+// Function attempts to set the type_name member of the paramaterised Element object.
+// This string should be the name of the struct type the Element represents.
+// We need this string for pretty printing the Element to users.
+void
+RenderScriptRuntime::FindStructTypeName(Element& elem, StackFrame* frame_ptr)
+{
+ Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+ if (!elem.type_name.IsEmpty()) // Name already set
+ return;
+ else
+ elem.type_name = Element::GetFallbackStructName(); // Default type name if we don't succeed
+
+ // Find all the global variables from the script rs modules
+ VariableList variable_list;
+ for (auto module_sp : m_rsmodules)
+ module_sp->m_module->FindGlobalVariables(RegularExpression("."), true, UINT32_MAX, variable_list);
+
+ // Iterate over all the global variables looking for one with a matching type to the Element.
+ // We make the assumption a match exists since there needs to be a global variable to reflect the
+ // struct type back into java host code.
+ for (uint32_t var_index = 0; var_index < variable_list.GetSize(); ++var_index)
+ {
+ const VariableSP var_sp(variable_list.GetVariableAtIndex(var_index));
+ if (!var_sp)
+ continue;
+
+ ValueObjectSP valobj_sp = ValueObjectVariable::Create(frame_ptr, var_sp);
+ if (!valobj_sp)
+ continue;
+
+ // Find the number of variable fields.
+ // If it has no fields, or more fields than our Element, then it can't be the struct we're looking for.
+ // Don't check for equality since RS can add extra struct members for padding.
+ size_t num_children = valobj_sp->GetNumChildren();
+ if (num_children > elem.children.size() || num_children == 0)
+ continue;
+
+ // Iterate over children looking for members with matching field names.
+ // If all the field names match, this is likely the struct we want.
+ //
+ // TODO: This could be made more robust by also checking children data sizes, or array size
+ bool found = true;
+ for (size_t child_index = 0; child_index < num_children; ++child_index)
+ {
+ ValueObjectSP child = valobj_sp->GetChildAtIndex(child_index, true);
+ if (!child || (child->GetName() != elem.children[child_index].type_name))
{
- m_scriptMappings[rs_script.script] = rsmodule_sp;
- rsmodule_sp->m_resname = rs_script.resname;
- if (log)
- {
- log->Printf ("RenderScriptRuntime::FixupScriptDetails - script %" PRIx64 " associated with rsmodule '%s'.",
- (uint64_t)rs_script.script, rsmodule_sp->m_module->GetFileSpec().GetFilename().AsCString());
- }
+ found = false;
+ break;
+ }
+ }
+
+ // RS can add extra struct members for padding in the format '#rs_padding_[0-9]+'
+ if (found && num_children < elem.children.size())
+ {
+ const unsigned int size_diff = elem.children.size() - num_children;
+ if (log)
+ log->Printf("RenderScriptRuntime::FindStructTypeName - %u padding struct entries", size_diff);
+
+ for (unsigned int padding_index = 0; padding_index < size_diff; ++padding_index)
+ {
+ const ConstString& name = elem.children[num_children + padding_index].type_name;
+ if (strcmp(name.AsCString(), "#rs_padding") < 0)
+ found = false;
}
}
+
+ // We've found a global var with matching type
+ if (found)
+ {
+ // Dereference since our Element type isn't a pointer.
+ if (valobj_sp->IsPointerType())
+ {
+ Error err;
+ ValueObjectSP deref_valobj = valobj_sp->Dereference(err);
+ if (!err.Fail())
+ valobj_sp = deref_valobj;
+ }
+
+ // Save name of variable in Element.
+ elem.type_name = valobj_sp->GetTypeName();
+ if (log)
+ log->Printf("RenderScriptRuntime::FindStructTypeName - Element name set to %s", elem.type_name.AsCString());
+
+ return;
+ }
}
-
+}
+
+// Function sets the datum_size member of Element. Representing the size of a single instance including padding.
+// Assumes the relevant allocation information has already been jitted.
+void
+RenderScriptRuntime::SetElementSize(Element& elem)
+{
+ Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+ const Element::DataType type = *elem.type.get();
+ assert(type >= Element::RS_TYPE_NONE && type <= Element::RS_TYPE_FONT
+ && "Invalid allocation type");
+
+ const unsigned int vec_size = *elem.type_vec_size.get();
+ unsigned int data_size = 0;
+ unsigned int padding = 0;
+
+ // Element is of a struct type, calculate size recursively.
+ if ((type == Element::RS_TYPE_NONE) && (elem.children.size() > 0))
+ {
+ for (Element& child : elem.children)
+ {
+ SetElementSize(child);
+ const unsigned int array_size = child.array_size.isValid() ? *child.array_size.get() : 1;
+ data_size += *child.datum_size.get() * array_size;
+ }
+ }
+ else if (type == Element::RS_TYPE_UNSIGNED_5_6_5 || type == Element::RS_TYPE_UNSIGNED_5_5_5_1 ||
+ type == Element::RS_TYPE_UNSIGNED_4_4_4_4) // These have been packed already
+ {
+ data_size = AllocationDetails::RSTypeToFormat[type][eElementSize];
+ }
+ else if (type < Element::RS_TYPE_ELEMENT)
+ {
+ data_size = vec_size * AllocationDetails::RSTypeToFormat[type][eElementSize];
+ if (vec_size == 3)
+ padding = AllocationDetails::RSTypeToFormat[type][eElementSize];
+ }
+ else
+ data_size = GetProcess()->GetTarget().GetArchitecture().GetAddressByteSize();
+
+ elem.padding = padding;
+ elem.datum_size = data_size + padding;
+ if (log)
+ log->Printf("RenderScriptRuntime::SetElementSize - element size set to %u", data_size + padding);
+}
+
+// Given an allocation, this function copies the allocation contents from device into a buffer on the heap.
+// Returning a shared pointer to the buffer containing the data.
+std::shared_ptr<uint8_t>
+RenderScriptRuntime::GetAllocationData(AllocationDetails* allocation, StackFrame* frame_ptr)
+{
+ Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+ // JIT all the allocation details
+ if (allocation->shouldRefresh())
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::GetAllocationData - Allocation details not calculated yet, jitting info");
+
+ if (!RefreshAllocation(allocation, frame_ptr))
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::GetAllocationData - Couldn't JIT allocation details");
+ return nullptr;
+ }
+ }
+
+ assert(allocation->data_ptr.isValid() && allocation->element.type.isValid() && allocation->element.type_vec_size.isValid()
+ && allocation->size.isValid() && "Allocation information not available");
+
+ // Allocate a buffer to copy data into
+ const unsigned int size = *allocation->size.get();
+ std::shared_ptr<uint8_t> buffer(new uint8_t[size]);
+ if (!buffer)
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::GetAllocationData - Couldn't allocate a %u byte buffer", size);
+ return nullptr;
+ }
+
+ // Read the inferior memory
+ Error error;
+ lldb::addr_t data_ptr = *allocation->data_ptr.get();
+ GetProcess()->ReadMemory(data_ptr, buffer.get(), size, error);
+ if (error.Fail())
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::GetAllocationData - '%s' Couldn't read %u bytes of allocation data from 0x%" PRIx64,
+ error.AsCString(), size, data_ptr);
+ return nullptr;
+ }
+
+ return buffer;
+}
+
+// Function copies data from a binary file into an allocation.
+// There is a header at the start of the file, FileHeader, before the data content itself.
+// Information from this header is used to display warnings to the user about incompatabilities
+bool
+RenderScriptRuntime::LoadAllocation(Stream &strm, const uint32_t alloc_id, const char* filename, StackFrame* frame_ptr)
+{
+ Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+ // Find allocation with the given id
+ AllocationDetails* alloc = FindAllocByID(strm, alloc_id);
+ if (!alloc)
+ return false;
+
+ if (log)
+ log->Printf("RenderScriptRuntime::LoadAllocation - Found allocation 0x%" PRIx64, *alloc->address.get());
+
+ // JIT all the allocation details
+ if (alloc->shouldRefresh())
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::LoadAllocation - Allocation details not calculated yet, jitting info");
+
+ if (!RefreshAllocation(alloc, frame_ptr))
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::LoadAllocation - Couldn't JIT allocation details");
+ return false;
+ }
+ }
+
+ assert(alloc->data_ptr.isValid() && alloc->element.type.isValid() && alloc->element.type_vec_size.isValid()
+ && alloc->size.isValid() && alloc->element.datum_size.isValid() && "Allocation information not available");
+
+ // Check we can read from file
+ FileSpec file(filename, true);
+ if (!file.Exists())
+ {
+ strm.Printf("Error: File %s does not exist", filename);
+ strm.EOL();
+ return false;
+ }
+
+ if (!file.Readable())
+ {
+ strm.Printf("Error: File %s does not have readable permissions", filename);
+ strm.EOL();
+ return false;
+ }
+
+ // Read file into data buffer
+ DataBufferSP data_sp(file.ReadFileContents());
+
+ // Cast start of buffer to FileHeader and use pointer to read metadata
+ void* file_buffer = data_sp->GetBytes();
+ const AllocationDetails::FileHeader* head = static_cast<AllocationDetails::FileHeader*>(file_buffer);
+
+ // Advance buffer past header
+ file_buffer = static_cast<uint8_t*>(file_buffer) + head->hdr_size;
+
+ if (log)
+ log->Printf("RenderScriptRuntime::LoadAllocation - header type %u, element size %u",
+ head->type, head->element_size);
+
+ // Check if the target allocation and file both have the same number of bytes for an Element
+ if (*alloc->element.datum_size.get() != head->element_size)
+ {
+ strm.Printf("Warning: Mismatched Element sizes - file %u bytes, allocation %u bytes",
+ head->element_size, *alloc->element.datum_size.get());
+ strm.EOL();
+ }
+
+ // Check if the target allocation and file both have the same integral type
+ const unsigned int type = static_cast<unsigned int>(*alloc->element.type.get());
+ if (type != head->type)
+ {
+ // Enum value isn't monotonous, so doesn't always index RsDataTypeToString array
+ unsigned int printable_target_type_index = type;
+ unsigned int printable_head_type_index = head->type;
+ if (type >= Element::RS_TYPE_ELEMENT && type <= Element::RS_TYPE_FONT)
+ printable_target_type_index = static_cast<Element::DataType>(
+ (type - Element::RS_TYPE_ELEMENT) + Element::RS_TYPE_MATRIX_2X2 + 1);
+
+ if (head->type >= Element::RS_TYPE_ELEMENT && head->type <= Element::RS_TYPE_FONT)
+ printable_head_type_index = static_cast<Element::DataType>(
+ (head->type - Element::RS_TYPE_ELEMENT) + Element::RS_TYPE_MATRIX_2X2 + 1);
+
+ const char* file_type_cstr = AllocationDetails::RsDataTypeToString[printable_head_type_index][0];
+ const char* target_type_cstr = AllocationDetails::RsDataTypeToString[printable_target_type_index][0];
+
+ strm.Printf("Warning: Mismatched Types - file '%s' type, allocation '%s' type",
+ file_type_cstr, target_type_cstr);
+ strm.EOL();
+ }
+
+ // Calculate size of allocation data in file
+ size_t length = data_sp->GetByteSize() - head->hdr_size;
+
+ // Check if the target allocation and file both have the same total data size.
+ const unsigned int alloc_size = *alloc->size.get();
+ if (alloc_size != length)
+ {
+ strm.Printf("Warning: Mismatched allocation sizes - file 0x%" PRIx64 " bytes, allocation 0x%x bytes",
+ (uint64_t) length, alloc_size);
+ strm.EOL();
+ length = alloc_size < length ? alloc_size : length; // Set length to copy to minimum
+ }
+
+ // Copy file data from our buffer into the target allocation.
+ lldb::addr_t alloc_data = *alloc->data_ptr.get();
+ Error error;
+ size_t bytes_written = GetProcess()->WriteMemory(alloc_data, file_buffer, length, error);
+ if (!error.Success() || bytes_written != length)
+ {
+ strm.Printf("Error: Couldn't write data to allocation %s", error.AsCString());
+ strm.EOL();
+ return false;
+ }
+
+ strm.Printf("Contents of file '%s' read into allocation %u", filename, alloc->id);
+ strm.EOL();
+
+ return true;
+}
+
+// Function copies allocation contents into a binary file.
+// This file can then be loaded later into a different allocation.
+// There is a header, FileHeader, before the allocation data containing meta-data.
+bool
+RenderScriptRuntime::SaveAllocation(Stream &strm, const uint32_t alloc_id, const char* filename, StackFrame* frame_ptr)
+{
+ Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+ // Find allocation with the given id
+ AllocationDetails* alloc = FindAllocByID(strm, alloc_id);
+ if (!alloc)
+ return false;
+
+ if (log)
+ log->Printf("RenderScriptRuntime::SaveAllocation - Found allocation 0x%" PRIx64, *alloc->address.get());
+
+ // JIT all the allocation details
+ if (alloc->shouldRefresh())
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::SaveAllocation - Allocation details not calculated yet, jitting info");
+
+ if (!RefreshAllocation(alloc, frame_ptr))
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::SaveAllocation - Couldn't JIT allocation details");
+ return false;
+ }
+ }
+
+ assert(alloc->data_ptr.isValid() && alloc->element.type.isValid() && alloc->element.type_vec_size.isValid() && alloc->element.datum_size.get()
+ && alloc->element.type_kind.isValid() && alloc->dimension.isValid() && "Allocation information not available");
+
+ // Check we can create writable file
+ FileSpec file_spec(filename, true);
+ File file(file_spec, File::eOpenOptionWrite | File::eOpenOptionCanCreate | File::eOpenOptionTruncate);
+ if (!file)
+ {
+ strm.Printf("Error: Failed to open '%s' for writing", filename);
+ strm.EOL();
+ return false;
+ }
+
+ // Read allocation into buffer of heap memory
+ const std::shared_ptr<uint8_t> buffer = GetAllocationData(alloc, frame_ptr);
+ if (!buffer)
+ {
+ strm.Printf("Error: Couldn't read allocation data into buffer");
+ strm.EOL();
+ return false;
+ }
+
+ // Create the file header
+ AllocationDetails::FileHeader head;
+ head.ident[0] = 'R'; head.ident[1] = 'S'; head.ident[2] = 'A'; head.ident[3] = 'D';
+ head.hdr_size = static_cast<uint16_t>(sizeof(AllocationDetails::FileHeader));
+ head.type = static_cast<uint16_t>(*alloc->element.type.get());
+ head.kind = static_cast<uint32_t>(*alloc->element.type_kind.get());
+ head.dims[0] = static_cast<uint32_t>(alloc->dimension.get()->dim_1);
+ head.dims[1] = static_cast<uint32_t>(alloc->dimension.get()->dim_2);
+ head.dims[2] = static_cast<uint32_t>(alloc->dimension.get()->dim_3);
+ head.element_size = static_cast<uint32_t>(*alloc->element.datum_size.get());
+
+ // Write the file header
+ size_t num_bytes = sizeof(AllocationDetails::FileHeader);
+ Error err = file.Write(static_cast<const void*>(&head), num_bytes);
+ if (!err.Success())
+ {
+ strm.Printf("Error: '%s' when writing to file '%s'", err.AsCString(), filename);
+ strm.EOL();
+ return false;
+ }
+
+ // Write allocation data to file
+ num_bytes = static_cast<size_t>(*alloc->size.get());
+ if (log)
+ log->Printf("RenderScriptRuntime::SaveAllocation - Writing 0x%" PRIx64 " bytes from %p", (uint64_t) num_bytes, buffer.get());
+
+ err = file.Write(buffer.get(), num_bytes);
+ if (!err.Success())
+ {
+ strm.Printf("Error: '%s' when writing to file '%s'", err.AsCString(), filename);
+ strm.EOL();
+ return false;
+ }
+
+ strm.Printf("Allocation written to file '%s'", filename);
+ strm.EOL();
+ return true;
}
bool
@@ -496,7 +2256,14 @@ RenderScriptRuntime::LoadModule(const lldb::ModuleSP &module_sp)
for (const auto &rs_module : m_rsmodules)
{
if (rs_module->m_module == module_sp)
+ {
+ // Check if the user has enabled automatically breaking on
+ // all RS kernels.
+ if (m_breakAllKernels)
+ BreakOnModuleKernels(rs_module);
+
return false;
+ }
}
bool module_loaded = false;
switch (GetModuleKind(module_sp))
@@ -585,7 +2352,6 @@ RenderScriptRuntime::Update()
}
}
-
// The maximum line length of an .rs.info packet
#define MAXLINE 500
@@ -609,12 +2375,12 @@ RSModuleDescriptor::ParseRSInfo()
std::string info((const char *)buffer->GetBytes());
std::vector<std::string> info_lines;
- size_t lpos = info.find_first_of("\n");
+ size_t lpos = info.find('\n');
while (lpos != std::string::npos)
{
info_lines.push_back(info.substr(0, lpos));
info = info.substr(lpos + 1);
- lpos = info.find_first_of("\n");
+ lpos = info.find('\n');
}
size_t offset = 0;
while (offset < info_lines.size())
@@ -710,7 +2476,6 @@ RenderScriptRuntime::Status(Stream &strm) const
strm.Indent(b.second->defn->name);
strm.EOL();
}
- strm.EOL();
}
else
{
@@ -728,15 +2493,21 @@ RenderScriptRuntime::DumpContexts(Stream &strm) const
std::map<addr_t, uint64_t> contextReferences;
- for (const auto &script : m_scripts)
+ // Iterate over all of the currently discovered scripts.
+ // Note: We cant push or pop from m_scripts inside this loop or it may invalidate script.
+ for (const auto & script : m_scripts)
{
- if (contextReferences.find(script.context) != contextReferences.end())
+ if (!script->context.isValid())
+ continue;
+ lldb::addr_t context = *script->context;
+
+ if (contextReferences.find(context) != contextReferences.end())
{
- contextReferences[script.context]++;
+ contextReferences[context]++;
}
else
{
- contextReferences[script.context] = 1;
+ contextReferences[context] = 1;
}
}
@@ -767,69 +2538,502 @@ RenderScriptRuntime::DumpKernels(Stream &strm) const
strm.IndentLess();
}
-void
-RenderScriptRuntime::AttemptBreakpointAtKernelName(Stream &strm, const char* name, Error& error)
+RenderScriptRuntime::AllocationDetails*
+RenderScriptRuntime::FindAllocByID(Stream &strm, const uint32_t alloc_id)
{
- if (!name)
+ AllocationDetails* alloc = nullptr;
+
+ // See if we can find allocation using id as an index;
+ if (alloc_id <= m_allocations.size() && alloc_id != 0
+ && m_allocations[alloc_id-1]->id == alloc_id)
{
- error.SetErrorString("invalid kernel name");
- return;
+ alloc = m_allocations[alloc_id-1].get();
+ return alloc;
}
- bool kernels_found;
- ConstString kernel_name(name);
- for (const auto &module : m_rsmodules)
+ // Fallback to searching
+ for (const auto & a : m_allocations)
{
- for (const auto &kernel : module->m_kernels)
+ if (a->id == alloc_id)
+ {
+ alloc = a.get();
+ break;
+ }
+ }
+
+ if (alloc == nullptr)
+ {
+ strm.Printf("Error: Couldn't find allocation with id matching %u", alloc_id);
+ strm.EOL();
+ }
+
+ return alloc;
+}
+
+// Prints the contents of an allocation to the output stream, which may be a file
+bool
+RenderScriptRuntime::DumpAllocation(Stream &strm, StackFrame* frame_ptr, const uint32_t id)
+{
+ Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+ // Check we can find the desired allocation
+ AllocationDetails* alloc = FindAllocByID(strm, id);
+ if (!alloc)
+ return false; // FindAllocByID() will print error message for us here
+
+ if (log)
+ log->Printf("RenderScriptRuntime::DumpAllocation - Found allocation 0x%" PRIx64, *alloc->address.get());
+
+ // Check we have information about the allocation, if not calculate it
+ if (alloc->shouldRefresh())
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::DumpAllocation - Allocation details not calculated yet, jitting info");
+
+ // JIT all the allocation information
+ if (!RefreshAllocation(alloc, frame_ptr))
{
- if (kernel.m_name == kernel_name)
- {
- //Attempt to set a breakpoint on this symbol, within the module library
- //If it's not found, it's likely debug info is unavailable - set a
- //breakpoint on <name>.expand and emit a warning.
+ strm.Printf("Error: Couldn't JIT allocation details");
+ strm.EOL();
+ return false;
+ }
+ }
+
+ // Establish format and size of each data element
+ const unsigned int vec_size = *alloc->element.type_vec_size.get();
+ const Element::DataType type = *alloc->element.type.get();
+
+ assert(type >= Element::RS_TYPE_NONE && type <= Element::RS_TYPE_FONT
+ && "Invalid allocation type");
+
+ lldb::Format format;
+ if (type >= Element::RS_TYPE_ELEMENT)
+ format = eFormatHex;
+ else
+ format = vec_size == 1 ? static_cast<lldb::Format>(AllocationDetails::RSTypeToFormat[type][eFormatSingle])
+ : static_cast<lldb::Format>(AllocationDetails::RSTypeToFormat[type][eFormatVector]);
+
+ const unsigned int data_size = *alloc->element.datum_size.get();
+
+ if (log)
+ log->Printf("RenderScriptRuntime::DumpAllocation - Element size %u bytes, including padding", data_size);
+
+ // Allocate a buffer to copy data into
+ std::shared_ptr<uint8_t> buffer = GetAllocationData(alloc, frame_ptr);
+ if (!buffer)
+ {
+ strm.Printf("Error: Couldn't read allocation data");
+ strm.EOL();
+ return false;
+ }
+
+ // Calculate stride between rows as there may be padding at end of rows since
+ // allocated memory is 16-byte aligned
+ if (!alloc->stride.isValid())
+ {
+ if (alloc->dimension.get()->dim_2 == 0) // We only have one dimension
+ alloc->stride = 0;
+ else if (!JITAllocationStride(alloc, frame_ptr))
+ {
+ strm.Printf("Error: Couldn't calculate allocation row stride");
+ strm.EOL();
+ return false;
+ }
+ }
+ const unsigned int stride = *alloc->stride.get();
+ const unsigned int size = *alloc->size.get(); // Size of whole allocation
+ const unsigned int padding = alloc->element.padding.isValid() ? *alloc->element.padding.get() : 0;
+ if (log)
+ log->Printf("RenderScriptRuntime::DumpAllocation - stride %u bytes, size %u bytes, padding %u", stride, size, padding);
+
+ // Find dimensions used to index loops, so need to be non-zero
+ unsigned int dim_x = alloc->dimension.get()->dim_1;
+ dim_x = dim_x == 0 ? 1 : dim_x;
- const Symbol* kernel_sym = module->m_module->FindFirstSymbolWithNameAndType(kernel_name, eSymbolTypeCode);
+ unsigned int dim_y = alloc->dimension.get()->dim_2;
+ dim_y = dim_y == 0 ? 1 : dim_y;
- if (!kernel_sym)
+ unsigned int dim_z = alloc->dimension.get()->dim_3;
+ dim_z = dim_z == 0 ? 1 : dim_z;
+
+ // Use data extractor to format output
+ const uint32_t archByteSize = GetProcess()->GetTarget().GetArchitecture().GetAddressByteSize();
+ DataExtractor alloc_data(buffer.get(), size, GetProcess()->GetByteOrder(), archByteSize);
+
+ unsigned int offset = 0; // Offset in buffer to next element to be printed
+ unsigned int prev_row = 0; // Offset to the start of the previous row
+
+ // Iterate over allocation dimensions, printing results to user
+ strm.Printf("Data (X, Y, Z):");
+ for (unsigned int z = 0; z < dim_z; ++z)
+ {
+ for (unsigned int y = 0; y < dim_y; ++y)
+ {
+ // Use stride to index start of next row.
+ if (!(y==0 && z==0))
+ offset = prev_row + stride;
+ prev_row = offset;
+
+ // Print each element in the row individually
+ for (unsigned int x = 0; x < dim_x; ++x)
+ {
+ strm.Printf("\n(%u, %u, %u) = ", x, y, z);
+ if ((type == Element::RS_TYPE_NONE) && (alloc->element.children.size() > 0) &&
+ (alloc->element.type_name != Element::GetFallbackStructName()))
{
- std::string kernel_name_expanded(name);
- kernel_name_expanded.append(".expand");
- kernel_sym = module->m_module->FindFirstSymbolWithNameAndType(ConstString(kernel_name_expanded.c_str()), eSymbolTypeCode);
+ // Here we are dumping an Element of struct type.
+ // This is done using expression evaluation with the name of the struct type and pointer to element.
- if (kernel_sym)
- {
- strm.Printf("Kernel '%s' could not be found, but expansion exists. ", name);
- strm.Printf("Breakpoint placed on expanded kernel. Have you compiled in debug mode?");
- strm.EOL();
- }
- else
+ // Don't print the name of the resulting expression, since this will be '$[0-9]+'
+ DumpValueObjectOptions expr_options;
+ expr_options.SetHideName(true);
+
+ // Setup expression as derefrencing a pointer cast to element address.
+ char expr_char_buffer[jit_max_expr_size];
+ int chars_written = snprintf(expr_char_buffer, jit_max_expr_size, "*(%s*) 0x%" PRIx64,
+ alloc->element.type_name.AsCString(), *alloc->data_ptr.get() + offset);
+
+ if (chars_written < 0 || chars_written >= jit_max_expr_size)
{
- error.SetErrorStringWithFormat("Could not locate symbols for loaded kernel '%s'.", name);
- return;
+ if (log)
+ log->Printf("RenderScriptRuntime::DumpAllocation- Error in snprintf()");
+ continue;
}
- }
- addr_t bp_addr = kernel_sym->GetLoadAddress(&GetProcess()->GetTarget());
- if (bp_addr == LLDB_INVALID_ADDRESS)
+ // Evaluate expression
+ ValueObjectSP expr_result;
+ GetProcess()->GetTarget().EvaluateExpression(expr_char_buffer, frame_ptr, expr_result);
+
+ // Print the results to our stream.
+ expr_result->Dump(strm, expr_options);
+ }
+ else
{
- error.SetErrorStringWithFormat("Could not locate load address for symbols of kernel '%s'.", name);
- return;
+ alloc_data.Dump(&strm, offset, format, data_size - padding, 1, 1, LLDB_INVALID_ADDRESS, 0, 0);
}
+ offset += data_size;
+ }
+ }
+ }
+ strm.EOL();
+
+ return true;
+}
+
+// Prints infomation regarding all the currently loaded allocations.
+// These details are gathered by jitting the runtime, which has as latency.
+void
+RenderScriptRuntime::ListAllocations(Stream &strm, StackFrame* frame_ptr, bool recompute)
+{
+ strm.Printf("RenderScript Allocations:");
+ strm.EOL();
+ strm.IndentMore();
+
+ for (auto &alloc : m_allocations)
+ {
+ // JIT the allocation info if we haven't done it, or the user forces us to.
+ bool do_refresh = alloc->shouldRefresh() || recompute;
+
+ // JIT current allocation information
+ if (do_refresh && !RefreshAllocation(alloc.get(), frame_ptr))
+ {
+ strm.Printf("Error: Couldn't evaluate details for allocation %u\n", alloc->id);
+ continue;
+ }
- BreakpointSP bp = GetProcess()->GetTarget().CreateBreakpoint(bp_addr, false, false);
- strm.Printf("Breakpoint %" PRIu64 ": kernel '%s' within script '%s'", (uint64_t)bp->GetID(), name, module->m_resname.c_str());
- strm.EOL();
+ strm.Printf("%u:\n",alloc->id);
+ strm.IndentMore();
- kernels_found = true;
+ strm.Indent("Context: ");
+ if (!alloc->context.isValid())
+ strm.Printf("unknown\n");
+ else
+ strm.Printf("0x%" PRIx64 "\n", *alloc->context.get());
+
+ strm.Indent("Address: ");
+ if (!alloc->address.isValid())
+ strm.Printf("unknown\n");
+ else
+ strm.Printf("0x%" PRIx64 "\n", *alloc->address.get());
+
+ strm.Indent("Data pointer: ");
+ if (!alloc->data_ptr.isValid())
+ strm.Printf("unknown\n");
+ else
+ strm.Printf("0x%" PRIx64 "\n", *alloc->data_ptr.get());
+
+ strm.Indent("Dimensions: ");
+ if (!alloc->dimension.isValid())
+ strm.Printf("unknown\n");
+ else
+ strm.Printf("(%d, %d, %d)\n", alloc->dimension.get()->dim_1,
+ alloc->dimension.get()->dim_2,
+ alloc->dimension.get()->dim_3);
+
+ strm.Indent("Data Type: ");
+ if (!alloc->element.type.isValid() || !alloc->element.type_vec_size.isValid())
+ strm.Printf("unknown\n");
+ else
+ {
+ const int vector_size = *alloc->element.type_vec_size.get();
+ Element::DataType type = *alloc->element.type.get();
+
+ if (!alloc->element.type_name.IsEmpty())
+ strm.Printf("%s\n", alloc->element.type_name.AsCString());
+ else
+ {
+ // Enum value isn't monotonous, so doesn't always index RsDataTypeToString array
+ if (type >= Element::RS_TYPE_ELEMENT && type <= Element::RS_TYPE_FONT)
+ type = static_cast<Element::DataType>((type - Element::RS_TYPE_ELEMENT) + Element::RS_TYPE_MATRIX_2X2 + 1);
+
+ if (type >= (sizeof(AllocationDetails::RsDataTypeToString) / sizeof(AllocationDetails::RsDataTypeToString[0]))
+ || vector_size > 4 || vector_size < 1)
+ strm.Printf("invalid type\n");
+ else
+ strm.Printf("%s\n", AllocationDetails::RsDataTypeToString[static_cast<unsigned int>(type)][vector_size-1]);
}
}
+
+ strm.Indent("Data Kind: ");
+ if (!alloc->element.type_kind.isValid())
+ strm.Printf("unknown\n");
+ else
+ {
+ const Element::DataKind kind = *alloc->element.type_kind.get();
+ if (kind < Element::RS_KIND_USER || kind > Element::RS_KIND_PIXEL_YUV)
+ strm.Printf("invalid kind\n");
+ else
+ strm.Printf("%s\n", AllocationDetails::RsDataKindToString[static_cast<unsigned int>(kind)]);
+ }
+
+ strm.EOL();
+ strm.IndentLess();
}
+ strm.IndentLess();
+}
- if (!kernels_found)
+// Set breakpoints on every kernel found in RS module
+void
+RenderScriptRuntime::BreakOnModuleKernels(const RSModuleDescriptorSP rsmodule_sp)
+{
+ for (const auto &kernel : rsmodule_sp->m_kernels)
{
- error.SetErrorString("kernel name not found");
+ // Don't set breakpoint on 'root' kernel
+ if (strcmp(kernel.m_name.AsCString(), "root") == 0)
+ continue;
+
+ CreateKernelBreakpoint(kernel.m_name);
}
- return;
+}
+
+// Method is internally called by the 'kernel breakpoint all' command to
+// enable or disable breaking on all kernels.
+//
+// When do_break is true we want to enable this functionality.
+// When do_break is false we want to disable it.
+void
+RenderScriptRuntime::SetBreakAllKernels(bool do_break, TargetSP target)
+{
+ Log* log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_LANGUAGE | LIBLLDB_LOG_BREAKPOINTS));
+
+ InitSearchFilter(target);
+
+ // Set breakpoints on all the kernels
+ if (do_break && !m_breakAllKernels)
+ {
+ m_breakAllKernels = true;
+
+ for (const auto &module : m_rsmodules)
+ BreakOnModuleKernels(module);
+
+ if (log)
+ log->Printf("RenderScriptRuntime::SetBreakAllKernels(True)"
+ "- breakpoints set on all currently loaded kernels");
+ }
+ else if (!do_break && m_breakAllKernels) // Breakpoints won't be set on any new kernels.
+ {
+ m_breakAllKernels = false;
+
+ if (log)
+ log->Printf("RenderScriptRuntime::SetBreakAllKernels(False) - breakpoints no longer automatically set");
+ }
+}
+
+// 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)
+{
+ Log* log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_LANGUAGE | LIBLLDB_LOG_BREAKPOINTS));
+
+ if (!m_filtersp)
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::CreateKernelBreakpoint - Error: No breakpoint search filter set");
+ return nullptr;
+ }
+
+ BreakpointResolverSP resolver_sp(new RSBreakpointResolver(nullptr, name));
+ BreakpointSP bp = GetProcess()->GetTarget().CreateBreakpoint(m_filtersp, resolver_sp, false, false, false);
+
+ // Give RS breakpoints a specific name, so the user can manipulate them as a group.
+ Error err;
+ if (!bp->AddName("RenderScriptKernel", err) && log)
+ log->Printf("RenderScriptRuntime::CreateKernelBreakpoint: Error setting break name, %s", err.AsCString());
+
+ return bp;
+}
+
+// Given an expression for a variable this function tries to calculate the variable's value.
+// If this is possible it returns true and sets the uint64_t parameter to the variables unsigned value.
+// Otherwise function returns false.
+bool
+RenderScriptRuntime::GetFrameVarAsUnsigned(const StackFrameSP frame_sp, const char* var_name, uint64_t& val)
+{
+ Log* log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+ Error error;
+ VariableSP var_sp;
+
+ // Find variable in stack frame
+ ValueObjectSP value_sp(frame_sp->GetValueForVariableExpressionPath(var_name,
+ eNoDynamicValues,
+ StackFrame::eExpressionPathOptionCheckPtrVsMember |
+ StackFrame::eExpressionPathOptionsAllowDirectIVarAccess,
+ var_sp,
+ error));
+ if (!error.Success())
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::GetFrameVarAsUnsigned - Error, couldn't find '%s' in frame", var_name);
+
+ return false;
+ }
+
+ // Find the unsigned int value for the variable
+ bool success = false;
+ val = value_sp->GetValueAsUnsigned(0, &success);
+ if (!success)
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::GetFrameVarAsUnsigned - Error, couldn't parse '%s' as an unsigned int", var_name);
+
+ return false;
+ }
+
+ return true;
+}
+
+// Callback when a kernel breakpoint hits and we're looking for a specific coordinate.
+// Baton parameter contains a pointer to the target coordinate we want to break on.
+// Function then checks the .expand frame for the current coordinate and breaks to user if it matches.
+// Parameter 'break_id' is the id of the Breakpoint which made the callback.
+// Parameter 'break_loc_id' is the id for the BreakpointLocation which was hit,
+// a single logical breakpoint can have multiple addresses.
+bool
+RenderScriptRuntime::KernelBreakpointHit(void *baton, StoppointCallbackContext *ctx,
+ user_id_t break_id, user_id_t break_loc_id)
+{
+ Log* log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_LANGUAGE | LIBLLDB_LOG_BREAKPOINTS));
+
+ assert(baton && "Error: null baton in conditional kernel breakpoint callback");
+
+ // Coordinate we want to stop on
+ const int* target_coord = static_cast<const int*>(baton);
+
+ if (log)
+ log->Printf("RenderScriptRuntime::KernelBreakpointHit - Break ID %" PRIu64 ", target coord (%d, %d, %d)",
+ break_id, target_coord[0], target_coord[1], target_coord[2]);
+
+ // Go up one stack frame to .expand kernel
+ ExecutionContext context(ctx->exe_ctx_ref);
+ ThreadSP thread_sp = context.GetThreadSP();
+ if (!thread_sp->SetSelectedFrameByIndex(1))
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::KernelBreakpointHit - Error, couldn't go up stack frame");
+
+ return false;
+ }
+
+ StackFrameSP frame_sp = thread_sp->GetSelectedFrame();
+ if (!frame_sp)
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::KernelBreakpointHit - Error, couldn't select .expand stack frame");
+
+ return false;
+ }
+
+ // Get values for variables in .expand frame that tell us the current kernel invocation
+ const char* coord_expressions[] = {"rsIndex", "p->current.y", "p->current.z"};
+ uint64_t current_coord[3] = {0, 0, 0};
+
+ for(int i = 0; i < 3; ++i)
+ {
+ if (!GetFrameVarAsUnsigned(frame_sp, coord_expressions[i], current_coord[i]))
+ return false;
+
+ if (log)
+ log->Printf("RenderScriptRuntime::KernelBreakpointHit, %s = %" PRIu64, coord_expressions[i], current_coord[i]);
+ }
+
+ // Check if the current kernel invocation coordinate matches our target coordinate
+ if (current_coord[0] == static_cast<uint64_t>(target_coord[0]) &&
+ current_coord[1] == static_cast<uint64_t>(target_coord[1]) &&
+ current_coord[2] == static_cast<uint64_t>(target_coord[2]))
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::KernelBreakpointHit, BREAKING %" PRIu64 ", %" PRIu64 ", %" PRIu64,
+ current_coord[0], current_coord[1], current_coord[2]);
+
+ BreakpointSP breakpoint_sp = context.GetTargetPtr()->GetBreakpointByID(break_id);
+ assert(breakpoint_sp != nullptr && "Error: Couldn't find breakpoint matching break id for callback");
+ breakpoint_sp->SetEnabled(false); // Optimise since conditional breakpoint should only be hit once.
+ return true;
+ }
+
+ // No match on coordinate
+ return false;
+}
+
+// Tries to set a breakpoint on the start of a kernel, resolved using the kernel name.
+// Argument 'coords', represents a three dimensional coordinate which can be used to specify
+// a single kernel instance to break on. If this is set then we add a callback to the breakpoint.
+void
+RenderScriptRuntime::PlaceBreakpointOnKernel(Stream &strm, const char* name, const std::array<int,3> coords,
+ Error& error, TargetSP target)
+{
+ if (!name)
+ {
+ error.SetErrorString("invalid kernel name");
+ return;
+ }
+
+ InitSearchFilter(target);
+
+ ConstString kernel_name(name);
+ BreakpointSP bp = CreateKernelBreakpoint(kernel_name);
+
+ // We have a conditional breakpoint on a specific coordinate
+ if (coords[0] != -1)
+ {
+ strm.Printf("Conditional kernel breakpoint on coordinate %d, %d, %d", coords[0], coords[1], coords[2]);
+ strm.EOL();
+
+ // Allocate memory for the baton, and copy over coordinate
+ int* baton = new int[3];
+ baton[0] = coords[0]; baton[1] = coords[1]; baton[2] = coords[2];
+
+ // Create a callback that will be invoked everytime the breakpoint is hit.
+ // The baton object passed to the handler is the target coordinate we want to break on.
+ bp->SetCallback(KernelBreakpointHit, baton, true);
+
+ // Store a shared pointer to the baton, so the memory will eventually be cleaned up after destruction
+ m_conditional_breaks[bp->GetID()] = std::shared_ptr<int>(baton);
+ }
+
+ if (bp)
+ bp->GetDescription(&strm, lldb::eDescriptionLevelInitial, false);
}
void
@@ -845,12 +3049,49 @@ RenderScriptRuntime::DumpModules(Stream &strm) const
strm.IndentLess();
}
+RenderScriptRuntime::ScriptDetails*
+RenderScriptRuntime::LookUpScript(addr_t address, bool create)
+{
+ for (const auto & s : m_scripts)
+ {
+ if (s->script.isValid())
+ if (*s->script == address)
+ return s.get();
+ }
+ if (create)
+ {
+ std::unique_ptr<ScriptDetails> s(new ScriptDetails);
+ s->script = address;
+ m_scripts.push_back(std::move(s));
+ return m_scripts.back().get();
+ }
+ return nullptr;
+}
+
+RenderScriptRuntime::AllocationDetails*
+RenderScriptRuntime::LookUpAllocation(addr_t address, bool create)
+{
+ for (const auto & a : m_allocations)
+ {
+ if (a->address.isValid())
+ if (*a->address == address)
+ return a.get();
+ }
+ if (create)
+ {
+ std::unique_ptr<AllocationDetails> a(new AllocationDetails);
+ a->address = address;
+ m_allocations.push_back(std::move(a));
+ return m_allocations.back().get();
+ }
+ return nullptr;
+}
+
void
RSModuleDescriptor::Dump(Stream &strm) const
{
strm.Indent();
m_module->GetFileSpec().Dump(&strm);
- m_module->ParseAllDebugSymbols();
if(m_module->GetNumCompileUnits())
{
strm.Indent("Debug info loaded.");
@@ -931,8 +3172,7 @@ RSKernelDescriptor::Dump(Stream &strm) const
class CommandObjectRenderScriptRuntimeModuleProbe : public CommandObjectParsed
{
- private:
- public:
+public:
CommandObjectRenderScriptRuntimeModuleProbe(CommandInterpreter &interpreter)
: CommandObjectParsed(interpreter, "renderscript module probe",
"Initiates a Probe of all loaded modules for kernels and other renderscript objects.",
@@ -941,10 +3181,10 @@ class CommandObjectRenderScriptRuntimeModuleProbe : public CommandObjectParsed
{
}
- ~CommandObjectRenderScriptRuntimeModuleProbe() {}
+ ~CommandObjectRenderScriptRuntimeModuleProbe() override = default;
bool
- DoExecute(Args &command, CommandReturnObject &result)
+ DoExecute(Args &command, CommandReturnObject &result) override
{
const size_t argc = command.GetArgumentCount();
if (argc == 0)
@@ -970,8 +3210,7 @@ class CommandObjectRenderScriptRuntimeModuleProbe : public CommandObjectParsed
class CommandObjectRenderScriptRuntimeModuleDump : public CommandObjectParsed
{
- private:
- public:
+public:
CommandObjectRenderScriptRuntimeModuleDump(CommandInterpreter &interpreter)
: CommandObjectParsed(interpreter, "renderscript module dump",
"Dumps renderscript specific information for all modules.", "renderscript module dump",
@@ -979,10 +3218,10 @@ class CommandObjectRenderScriptRuntimeModuleDump : public CommandObjectParsed
{
}
- ~CommandObjectRenderScriptRuntimeModuleDump() {}
+ ~CommandObjectRenderScriptRuntimeModuleDump() override = default;
bool
- DoExecute(Args &command, CommandReturnObject &result)
+ DoExecute(Args &command, CommandReturnObject &result) override
{
RenderScriptRuntime *runtime =
(RenderScriptRuntime *)m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(eLanguageTypeExtRenderScript);
@@ -994,8 +3233,7 @@ class CommandObjectRenderScriptRuntimeModuleDump : public CommandObjectParsed
class CommandObjectRenderScriptRuntimeModule : public CommandObjectMultiword
{
- private:
- public:
+public:
CommandObjectRenderScriptRuntimeModule(CommandInterpreter &interpreter)
: CommandObjectMultiword(interpreter, "renderscript module", "Commands that deal with renderscript modules.",
NULL)
@@ -1004,13 +3242,12 @@ class CommandObjectRenderScriptRuntimeModule : public CommandObjectMultiword
LoadSubCommand("dump", CommandObjectSP(new CommandObjectRenderScriptRuntimeModuleDump(interpreter)));
}
- ~CommandObjectRenderScriptRuntimeModule() {}
+ ~CommandObjectRenderScriptRuntimeModule() override = default;
};
class CommandObjectRenderScriptRuntimeKernelList : public CommandObjectParsed
{
- private:
- public:
+public:
CommandObjectRenderScriptRuntimeKernelList(CommandInterpreter &interpreter)
: CommandObjectParsed(interpreter, "renderscript kernel list",
"Lists renderscript kernel names and associated script resources.", "renderscript kernel list",
@@ -1018,10 +3255,10 @@ class CommandObjectRenderScriptRuntimeKernelList : public CommandObjectParsed
{
}
- ~CommandObjectRenderScriptRuntimeKernelList() {}
+ ~CommandObjectRenderScriptRuntimeKernelList() override = default;
bool
- DoExecute(Args &command, CommandReturnObject &result)
+ DoExecute(Args &command, CommandReturnObject &result) override
{
RenderScriptRuntime *runtime =
(RenderScriptRuntime *)m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(eLanguageTypeExtRenderScript);
@@ -1031,52 +3268,213 @@ class CommandObjectRenderScriptRuntimeKernelList : public CommandObjectParsed
}
};
-class CommandObjectRenderScriptRuntimeKernelBreakpoint : public CommandObjectParsed
+class CommandObjectRenderScriptRuntimeKernelBreakpointSet : public CommandObjectParsed
{
- private:
- public:
- CommandObjectRenderScriptRuntimeKernelBreakpoint(CommandInterpreter &interpreter)
- : CommandObjectParsed(interpreter, "renderscript kernel breakpoint",
- "Sets a breakpoint on a renderscript kernel.", "renderscript kernel breakpoint",
- eCommandRequiresProcess | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused)
+public:
+ CommandObjectRenderScriptRuntimeKernelBreakpointSet(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "renderscript kernel breakpoint set",
+ "Sets a breakpoint on a renderscript kernel.", "renderscript kernel breakpoint set <kernel_name> [-c x,y,z]",
+ eCommandRequiresProcess | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused), m_options(interpreter)
{
}
- ~CommandObjectRenderScriptRuntimeKernelBreakpoint() {}
+ ~CommandObjectRenderScriptRuntimeKernelBreakpointSet() override = default;
- bool
- DoExecute(Args &command, CommandReturnObject &result)
+ Options*
+ GetOptions() override
{
- const size_t argc = command.GetArgumentCount();
- if (argc == 1)
+ return &m_options;
+ }
+
+ class CommandOptions : public Options
+ {
+ public:
+ CommandOptions(CommandInterpreter &interpreter) : Options(interpreter)
{
- RenderScriptRuntime *runtime =
- (RenderScriptRuntime *)m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(eLanguageTypeExtRenderScript);
+ }
+
+ ~CommandOptions() override = default;
+ Error
+ SetOptionValue(uint32_t option_idx, const char *option_arg) override
+ {
Error error;
- runtime->AttemptBreakpointAtKernelName(result.GetOutputStream(), command.GetArgumentAtIndex(0), error);
+ const int short_option = m_getopt_table[option_idx].val;
- if (error.Success())
+ switch (short_option)
{
- result.AppendMessage("Breakpoint(s) created");
- result.SetStatus(eReturnStatusSuccessFinishResult);
- return true;
+ case 'c':
+ if (!ParseCoordinate(option_arg))
+ error.SetErrorStringWithFormat("Couldn't parse coordinate '%s', should be in format 'x,y,z'.", option_arg);
+ break;
+ default:
+ error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
+ break;
}
+ return error;
+ }
+
+ // -c takes an argument of the form 'num[,num][,num]'.
+ // Where 'id_cstr' is this argument with the whitespace trimmed.
+ // Missing coordinates are defaulted to zero.
+ bool
+ ParseCoordinate(const char* id_cstr)
+ {
+ RegularExpression regex;
+ RegularExpression::Match regex_match(3);
+
+ bool matched = false;
+ if(regex.Compile("^([0-9]+),([0-9]+),([0-9]+)$") && regex.Execute(id_cstr, &regex_match))
+ matched = true;
+ else if(regex.Compile("^([0-9]+),([0-9]+)$") && regex.Execute(id_cstr, &regex_match))
+ matched = true;
+ else if(regex.Compile("^([0-9]+)$") && regex.Execute(id_cstr, &regex_match))
+ matched = true;
+ for(uint32_t i = 0; i < 3; i++)
+ {
+ std::string group;
+ if(regex_match.GetMatchAtIndex(id_cstr, i + 1, group))
+ m_coord[i] = (uint32_t)strtoul(group.c_str(), NULL, 0);
+ else
+ m_coord[i] = 0;
+ }
+ return matched;
+ }
+
+ void
+ OptionParsingStarting() override
+ {
+ // -1 means the -c option hasn't been set
+ m_coord[0] = -1;
+ m_coord[1] = -1;
+ m_coord[2] = -1;
+ }
+
+ const OptionDefinition*
+ GetDefinitions() override
+ {
+ return g_option_table;
+ }
+
+ static OptionDefinition g_option_table[];
+ std::array<int,3> m_coord;
+ };
+
+ bool
+ DoExecute(Args &command, CommandReturnObject &result) override
+ {
+ const size_t argc = command.GetArgumentCount();
+ if (argc < 1)
+ {
+ result.AppendErrorWithFormat("'%s' takes 1 argument of kernel name, and an optional coordinate.", m_cmd_name.c_str());
result.SetStatus(eReturnStatusFailed);
- result.AppendErrorWithFormat("Error: %s", error.AsCString());
return false;
}
- result.AppendErrorWithFormat("'%s' takes 1 argument of kernel name", m_cmd_name.c_str());
+ RenderScriptRuntime *runtime =
+ (RenderScriptRuntime *)m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(eLanguageTypeExtRenderScript);
+
+ Error error;
+ runtime->PlaceBreakpointOnKernel(result.GetOutputStream(), command.GetArgumentAtIndex(0), m_options.m_coord,
+ error, m_exe_ctx.GetTargetSP());
+
+ if (error.Success())
+ {
+ result.AppendMessage("Breakpoint(s) created");
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ return true;
+ }
result.SetStatus(eReturnStatusFailed);
+ result.AppendErrorWithFormat("Error: %s", error.AsCString());
return false;
}
+
+private:
+ CommandOptions m_options;
+};
+
+OptionDefinition
+CommandObjectRenderScriptRuntimeKernelBreakpointSet::CommandOptions::g_option_table[] =
+{
+ { LLDB_OPT_SET_1, false, "coordinate", 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeValue,
+ "Set a breakpoint on a single invocation of the kernel with specified coordinate.\n"
+ "Coordinate takes the form 'x[,y][,z] where x,y,z are positive integers representing kernel dimensions. "
+ "Any unset dimensions will be defaulted to zero."},
+ { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+};
+
+class CommandObjectRenderScriptRuntimeKernelBreakpointAll : public CommandObjectParsed
+{
+public:
+ CommandObjectRenderScriptRuntimeKernelBreakpointAll(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "renderscript kernel breakpoint all",
+ "Automatically sets a breakpoint on all renderscript kernels that are or will be loaded.\n"
+ "Disabling option means breakpoints will no longer be set on any kernels loaded in the future, "
+ "but does not remove currently set breakpoints.",
+ "renderscript kernel breakpoint all <enable/disable>",
+ eCommandRequiresProcess | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused)
+ {
+ }
+
+ ~CommandObjectRenderScriptRuntimeKernelBreakpointAll() override = default;
+
+ bool
+ DoExecute(Args &command, CommandReturnObject &result) override
+ {
+ const size_t argc = command.GetArgumentCount();
+ if (argc != 1)
+ {
+ result.AppendErrorWithFormat("'%s' takes 1 argument of 'enable' or 'disable'", m_cmd_name.c_str());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ RenderScriptRuntime *runtime =
+ static_cast<RenderScriptRuntime *>(m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(eLanguageTypeExtRenderScript));
+
+ bool do_break = false;
+ const char* argument = command.GetArgumentAtIndex(0);
+ if (strcmp(argument, "enable") == 0)
+ {
+ do_break = true;
+ result.AppendMessage("Breakpoints will be set on all kernels.");
+ }
+ else if (strcmp(argument, "disable") == 0)
+ {
+ do_break = false;
+ result.AppendMessage("Breakpoints will not be set on any new kernels.");
+ }
+ else
+ {
+ result.AppendErrorWithFormat("Argument must be either 'enable' or 'disable'");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ runtime->SetBreakAllKernels(do_break, m_exe_ctx.GetTargetSP());
+
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ return true;
+ }
+};
+
+class CommandObjectRenderScriptRuntimeKernelBreakpoint : public CommandObjectMultiword
+{
+public:
+ CommandObjectRenderScriptRuntimeKernelBreakpoint(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "renderscript kernel", "Commands that generate breakpoints on renderscript kernels.",
+ nullptr)
+ {
+ LoadSubCommand("set", CommandObjectSP(new CommandObjectRenderScriptRuntimeKernelBreakpointSet(interpreter)));
+ LoadSubCommand("all", CommandObjectSP(new CommandObjectRenderScriptRuntimeKernelBreakpointAll(interpreter)));
+ }
+
+ ~CommandObjectRenderScriptRuntimeKernelBreakpoint() override = default;
};
class CommandObjectRenderScriptRuntimeKernel : public CommandObjectMultiword
{
- private:
- public:
+public:
CommandObjectRenderScriptRuntimeKernel(CommandInterpreter &interpreter)
: CommandObjectMultiword(interpreter, "renderscript kernel", "Commands that deal with renderscript kernels.",
NULL)
@@ -1085,13 +3483,12 @@ class CommandObjectRenderScriptRuntimeKernel : public CommandObjectMultiword
LoadSubCommand("breakpoint", CommandObjectSP(new CommandObjectRenderScriptRuntimeKernelBreakpoint(interpreter)));
}
- ~CommandObjectRenderScriptRuntimeKernel() {}
+ ~CommandObjectRenderScriptRuntimeKernel() override = default;
};
class CommandObjectRenderScriptRuntimeContextDump : public CommandObjectParsed
{
- private:
- public:
+public:
CommandObjectRenderScriptRuntimeContextDump(CommandInterpreter &interpreter)
: CommandObjectParsed(interpreter, "renderscript context dump",
"Dumps renderscript context information.", "renderscript context dump",
@@ -1099,10 +3496,10 @@ class CommandObjectRenderScriptRuntimeContextDump : public CommandObjectParsed
{
}
- ~CommandObjectRenderScriptRuntimeContextDump() {}
+ ~CommandObjectRenderScriptRuntimeContextDump() override = default;
bool
- DoExecute(Args &command, CommandReturnObject &result)
+ DoExecute(Args &command, CommandReturnObject &result) override
{
RenderScriptRuntime *runtime =
(RenderScriptRuntime *)m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(eLanguageTypeExtRenderScript);
@@ -1114,8 +3511,7 @@ class CommandObjectRenderScriptRuntimeContextDump : public CommandObjectParsed
class CommandObjectRenderScriptRuntimeContext : public CommandObjectMultiword
{
- private:
- public:
+public:
CommandObjectRenderScriptRuntimeContext(CommandInterpreter &interpreter)
: CommandObjectMultiword(interpreter, "renderscript context", "Commands that deal with renderscript contexts.",
NULL)
@@ -1123,13 +3519,345 @@ class CommandObjectRenderScriptRuntimeContext : public CommandObjectMultiword
LoadSubCommand("dump", CommandObjectSP(new CommandObjectRenderScriptRuntimeContextDump(interpreter)));
}
- ~CommandObjectRenderScriptRuntimeContext() {}
+ ~CommandObjectRenderScriptRuntimeContext() override = default;
+};
+
+class CommandObjectRenderScriptRuntimeAllocationDump : public CommandObjectParsed
+{
+public:
+ CommandObjectRenderScriptRuntimeAllocationDump(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "renderscript allocation dump",
+ "Displays the contents of a particular allocation", "renderscript allocation dump <ID>",
+ eCommandRequiresProcess | eCommandProcessMustBeLaunched), m_options(interpreter)
+ {
+ }
+
+ ~CommandObjectRenderScriptRuntimeAllocationDump() override = default;
+
+ Options*
+ GetOptions() override
+ {
+ return &m_options;
+ }
+
+ class CommandOptions : public Options
+ {
+ public:
+ CommandOptions(CommandInterpreter &interpreter) : Options(interpreter)
+ {
+ }
+
+ ~CommandOptions() override = default;
+
+ Error
+ SetOptionValue(uint32_t option_idx, const char *option_arg) override
+ {
+ Error error;
+ const int short_option = m_getopt_table[option_idx].val;
+
+ switch (short_option)
+ {
+ case 'f':
+ m_outfile.SetFile(option_arg, true);
+ if (m_outfile.Exists())
+ {
+ m_outfile.Clear();
+ error.SetErrorStringWithFormat("file already exists: '%s'", option_arg);
+ }
+ break;
+ default:
+ error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
+ break;
+ }
+ return error;
+ }
+
+ void
+ OptionParsingStarting() override
+ {
+ m_outfile.Clear();
+ }
+
+ const OptionDefinition*
+ GetDefinitions() override
+ {
+ return g_option_table;
+ }
+
+ static OptionDefinition g_option_table[];
+ FileSpec m_outfile;
+ };
+
+ bool
+ DoExecute(Args &command, CommandReturnObject &result) override
+ {
+ const size_t argc = command.GetArgumentCount();
+ if (argc < 1)
+ {
+ result.AppendErrorWithFormat("'%s' takes 1 argument, an allocation ID. As well as an optional -f argument",
+ m_cmd_name.c_str());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ RenderScriptRuntime *runtime =
+ static_cast<RenderScriptRuntime *>(m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(eLanguageTypeExtRenderScript));
+
+ const char* id_cstr = command.GetArgumentAtIndex(0);
+ bool convert_complete = false;
+ const uint32_t id = StringConvert::ToUInt32(id_cstr, UINT32_MAX, 0, &convert_complete);
+ if (!convert_complete)
+ {
+ result.AppendErrorWithFormat("invalid allocation id argument '%s'", id_cstr);
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ Stream* output_strm = nullptr;
+ StreamFile outfile_stream;
+ const FileSpec &outfile_spec = m_options.m_outfile; // Dump allocation to file instead
+ if (outfile_spec)
+ {
+ // Open output file
+ char path[256];
+ outfile_spec.GetPath(path, sizeof(path));
+ if (outfile_stream.GetFile().Open(path, File::eOpenOptionWrite | File::eOpenOptionCanCreate).Success())
+ {
+ output_strm = &outfile_stream;
+ result.GetOutputStream().Printf("Results written to '%s'", path);
+ result.GetOutputStream().EOL();
+ }
+ else
+ {
+ result.AppendErrorWithFormat("Couldn't open file '%s'", path);
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ }
+ else
+ output_strm = &result.GetOutputStream();
+
+ assert(output_strm != nullptr);
+ bool success = runtime->DumpAllocation(*output_strm, m_exe_ctx.GetFramePtr(), id);
+
+ if (success)
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ else
+ result.SetStatus(eReturnStatusFailed);
+
+ return true;
+ }
+
+private:
+ CommandOptions m_options;
+};
+
+OptionDefinition
+CommandObjectRenderScriptRuntimeAllocationDump::CommandOptions::g_option_table[] =
+{
+ { LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFilename,
+ "Print results to specified file instead of command line."},
+ { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+};
+
+class CommandObjectRenderScriptRuntimeAllocationList : public CommandObjectParsed
+{
+public:
+ CommandObjectRenderScriptRuntimeAllocationList(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "renderscript allocation list",
+ "List renderscript allocations and their information.", "renderscript allocation list",
+ eCommandRequiresProcess | eCommandProcessMustBeLaunched), m_options(interpreter)
+ {
+ }
+
+ ~CommandObjectRenderScriptRuntimeAllocationList() override = default;
+
+ Options*
+ GetOptions() override
+ {
+ return &m_options;
+ }
+
+ class CommandOptions : public Options
+ {
+ public:
+ CommandOptions(CommandInterpreter &interpreter) : Options(interpreter), m_refresh(false)
+ {
+ }
+
+ ~CommandOptions() override = default;
+
+ Error
+ SetOptionValue(uint32_t option_idx, const char *option_arg) override
+ {
+ Error error;
+ const int short_option = m_getopt_table[option_idx].val;
+
+ switch (short_option)
+ {
+ case 'r':
+ m_refresh = true;
+ break;
+ default:
+ error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
+ break;
+ }
+ return error;
+ }
+
+ void
+ OptionParsingStarting() override
+ {
+ m_refresh = false;
+ }
+
+ const OptionDefinition*
+ GetDefinitions() override
+ {
+ return g_option_table;
+ }
+
+ static OptionDefinition g_option_table[];
+ bool m_refresh;
+ };
+
+ bool
+ DoExecute(Args &command, CommandReturnObject &result) override
+ {
+ RenderScriptRuntime *runtime =
+ static_cast<RenderScriptRuntime *>(m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(eLanguageTypeExtRenderScript));
+ runtime->ListAllocations(result.GetOutputStream(), m_exe_ctx.GetFramePtr(), m_options.m_refresh);
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ return true;
+ }
+
+private:
+ CommandOptions m_options;
+};
+
+OptionDefinition
+CommandObjectRenderScriptRuntimeAllocationList::CommandOptions::g_option_table[] =
+{
+ { LLDB_OPT_SET_1, false, "refresh", 'r', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,
+ "Recompute allocation details."},
+ { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+};
+
+class CommandObjectRenderScriptRuntimeAllocationLoad : public CommandObjectParsed
+{
+public:
+ CommandObjectRenderScriptRuntimeAllocationLoad(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "renderscript allocation load",
+ "Loads renderscript allocation contents from a file.", "renderscript allocation load <ID> <filename>",
+ eCommandRequiresProcess | eCommandProcessMustBeLaunched)
+ {
+ }
+
+ ~CommandObjectRenderScriptRuntimeAllocationLoad() override = default;
+
+ bool
+ DoExecute(Args &command, CommandReturnObject &result) override
+ {
+ const size_t argc = command.GetArgumentCount();
+ if (argc != 2)
+ {
+ result.AppendErrorWithFormat("'%s' takes 2 arguments, an allocation ID and filename to read from.", m_cmd_name.c_str());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ RenderScriptRuntime *runtime =
+ static_cast<RenderScriptRuntime *>(m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(eLanguageTypeExtRenderScript));
+
+ const char* id_cstr = command.GetArgumentAtIndex(0);
+ bool convert_complete = false;
+ const uint32_t id = StringConvert::ToUInt32(id_cstr, UINT32_MAX, 0, &convert_complete);
+ if (!convert_complete)
+ {
+ result.AppendErrorWithFormat ("invalid allocation id argument '%s'", id_cstr);
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+
+ const char* filename = command.GetArgumentAtIndex(1);
+ bool success = runtime->LoadAllocation(result.GetOutputStream(), id, filename, m_exe_ctx.GetFramePtr());
+
+ if (success)
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ else
+ result.SetStatus(eReturnStatusFailed);
+
+ return true;
+ }
+};
+
+class CommandObjectRenderScriptRuntimeAllocationSave : public CommandObjectParsed
+{
+public:
+ CommandObjectRenderScriptRuntimeAllocationSave(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "renderscript allocation save",
+ "Write renderscript allocation contents to a file.", "renderscript allocation save <ID> <filename>",
+ eCommandRequiresProcess | eCommandProcessMustBeLaunched)
+ {
+ }
+
+ ~CommandObjectRenderScriptRuntimeAllocationSave() override = default;
+
+ bool
+ DoExecute(Args &command, CommandReturnObject &result) override
+ {
+ const size_t argc = command.GetArgumentCount();
+ if (argc != 2)
+ {
+ result.AppendErrorWithFormat("'%s' takes 2 arguments, an allocation ID and filename to read from.", m_cmd_name.c_str());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ RenderScriptRuntime *runtime =
+ static_cast<RenderScriptRuntime *>(m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(eLanguageTypeExtRenderScript));
+
+ const char* id_cstr = command.GetArgumentAtIndex(0);
+ bool convert_complete = false;
+ const uint32_t id = StringConvert::ToUInt32(id_cstr, UINT32_MAX, 0, &convert_complete);
+ if (!convert_complete)
+ {
+ result.AppendErrorWithFormat ("invalid allocation id argument '%s'", id_cstr);
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+
+ const char* filename = command.GetArgumentAtIndex(1);
+ bool success = runtime->SaveAllocation(result.GetOutputStream(), id, filename, m_exe_ctx.GetFramePtr());
+
+ if (success)
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ else
+ result.SetStatus(eReturnStatusFailed);
+
+ return true;
+ }
+};
+
+class CommandObjectRenderScriptRuntimeAllocation : public CommandObjectMultiword
+{
+public:
+ CommandObjectRenderScriptRuntimeAllocation(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "renderscript allocation", "Commands that deal with renderscript allocations.",
+ NULL)
+ {
+ LoadSubCommand("list", CommandObjectSP(new CommandObjectRenderScriptRuntimeAllocationList(interpreter)));
+ LoadSubCommand("dump", CommandObjectSP(new CommandObjectRenderScriptRuntimeAllocationDump(interpreter)));
+ LoadSubCommand("save", CommandObjectSP(new CommandObjectRenderScriptRuntimeAllocationSave(interpreter)));
+ LoadSubCommand("load", CommandObjectSP(new CommandObjectRenderScriptRuntimeAllocationLoad(interpreter)));
+ }
+
+ ~CommandObjectRenderScriptRuntimeAllocation() override = default;
};
class CommandObjectRenderScriptRuntimeStatus : public CommandObjectParsed
{
- private:
- public:
+public:
CommandObjectRenderScriptRuntimeStatus(CommandInterpreter &interpreter)
: CommandObjectParsed(interpreter, "renderscript status",
"Displays current renderscript runtime status.", "renderscript status",
@@ -1137,10 +3865,10 @@ class CommandObjectRenderScriptRuntimeStatus : public CommandObjectParsed
{
}
- ~CommandObjectRenderScriptRuntimeStatus() {}
+ ~CommandObjectRenderScriptRuntimeStatus() override = default;
bool
- DoExecute(Args &command, CommandReturnObject &result)
+ DoExecute(Args &command, CommandReturnObject &result) override
{
RenderScriptRuntime *runtime =
(RenderScriptRuntime *)m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(eLanguageTypeExtRenderScript);
@@ -1152,7 +3880,7 @@ class CommandObjectRenderScriptRuntimeStatus : public CommandObjectParsed
class CommandObjectRenderScriptRuntime : public CommandObjectMultiword
{
- public:
+public:
CommandObjectRenderScriptRuntime(CommandInterpreter &interpreter)
: CommandObjectMultiword(interpreter, "renderscript", "A set of commands for operating on renderscript.",
"renderscript <subcommand> [<subcommand-options>]")
@@ -1161,9 +3889,10 @@ class CommandObjectRenderScriptRuntime : public CommandObjectMultiword
LoadSubCommand("status", CommandObjectSP(new CommandObjectRenderScriptRuntimeStatus(interpreter)));
LoadSubCommand("kernel", CommandObjectSP(new CommandObjectRenderScriptRuntimeKernel(interpreter)));
LoadSubCommand("context", CommandObjectSP(new CommandObjectRenderScriptRuntimeContext(interpreter)));
+ LoadSubCommand("allocation", CommandObjectSP(new CommandObjectRenderScriptRuntimeAllocation(interpreter)));
}
- ~CommandObjectRenderScriptRuntime() {}
+ ~CommandObjectRenderScriptRuntime() override = default;
};
void
@@ -1173,7 +3902,8 @@ RenderScriptRuntime::Initiate()
}
RenderScriptRuntime::RenderScriptRuntime(Process *process)
- : lldb_private::CPPLanguageRuntime(process), m_initiated(false), m_debuggerPresentFlagged(false)
+ : lldb_private::CPPLanguageRuntime(process), m_initiated(false), m_debuggerPresentFlagged(false),
+ m_breakAllKernels(false)
{
ModulesDidLoad(process->GetTarget().GetImages());
}
@@ -1189,3 +3919,4 @@ RenderScriptRuntime::GetCommandObject(lldb_private::CommandInterpreter& interpre
return command_object;
}
+RenderScriptRuntime::~RenderScriptRuntime() = default;
diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
index 2a01e744e976..0ca268c93b00 100644
--- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -12,6 +12,12 @@
// C Includes
// C++ Includes
+#include <array>
+#include <map>
+#include <memory>
+#include <string>
+#include <vector>
+
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
@@ -19,8 +25,8 @@
#include "lldb/Target/CPPLanguageRuntime.h"
#include "lldb/Core/Module.h"
-namespace lldb_private
-{
+namespace lldb_private {
+namespace lldb_renderscript {
typedef uint32_t RSSlot;
class RSModuleDescriptor;
@@ -31,11 +37,56 @@ typedef std::shared_ptr<RSModuleDescriptor> RSModuleDescriptorSP;
typedef std::shared_ptr<RSGlobalDescriptor> RSGlobalDescriptorSP;
typedef std::shared_ptr<RSKernelDescriptor> RSKernelDescriptorSP;
+// Breakpoint Resolvers decide where a breakpoint is placed,
+// so having our own allows us to limit the search scope to RS kernel modules.
+// As well as check for .expand kernels as a fallback.
+class RSBreakpointResolver : public BreakpointResolver
+{
+public:
+ RSBreakpointResolver(Breakpoint *bkpt, ConstString name):
+ BreakpointResolver (bkpt, BreakpointResolver::NameResolver),
+ m_kernel_name(name)
+ {
+ }
+
+ void
+ GetDescription(Stream *strm) override
+ {
+ if (strm)
+ strm->Printf("RenderScript kernel breakpoint for '%s'", m_kernel_name.AsCString());
+ }
+
+ void
+ Dump(Stream *s) const override
+ {
+ }
+
+ Searcher::CallbackReturn
+ SearchCallback(SearchFilter &filter,
+ SymbolContext &context,
+ Address *addr,
+ bool containing) override;
+
+ Searcher::Depth
+ GetDepth() override
+ {
+ return Searcher::eDepthModule;
+ }
+
+ lldb::BreakpointResolverSP
+ CopyForBreakpoint(Breakpoint &breakpoint) override
+ {
+ lldb::BreakpointResolverSP ret_sp(new RSBreakpointResolver(&breakpoint, m_kernel_name));
+ return ret_sp;
+ }
+protected:
+ ConstString m_kernel_name;
+};
struct RSKernelDescriptor
{
- public:
+public:
RSKernelDescriptor(const RSModuleDescriptor *module, const char *name, uint32_t slot)
: m_module(module)
, m_name(name)
@@ -52,7 +103,7 @@ struct RSKernelDescriptor
struct RSGlobalDescriptor
{
- public:
+public:
RSGlobalDescriptor(const RSModuleDescriptor *module, const char *name )
: m_module(module)
, m_name(name)
@@ -67,13 +118,13 @@ struct RSGlobalDescriptor
class RSModuleDescriptor
{
- public:
+public:
RSModuleDescriptor(const lldb::ModuleSP &module)
: m_module(module)
{
}
- ~RSModuleDescriptor() {}
+ ~RSModuleDescriptor() = default;
bool ParseRSInfo();
@@ -86,10 +137,11 @@ class RSModuleDescriptor
std::string m_resname;
};
+} // namespace lldb_renderscript
+
class RenderScriptRuntime : public lldb_private::CPPLanguageRuntime
{
- public:
-
+public:
enum ModuleKind
{
eModuleKindIgnored,
@@ -99,8 +151,7 @@ class RenderScriptRuntime : public lldb_private::CPPLanguageRuntime
eModuleKindKernelObj
};
-
- ~RenderScriptRuntime() {}
+ ~RenderScriptRuntime() override;
//------------------------------------------------------------------
// Static Functions
@@ -121,21 +172,19 @@ class RenderScriptRuntime : public lldb_private::CPPLanguageRuntime
static void ModulesDidLoad(const lldb::ProcessSP& process_sp, const ModuleList &module_list );
- //------------------------------------------------------------------
- // PluginInterface protocol
- //------------------------------------------------------------------
- virtual lldb_private::ConstString GetPluginName();
-
- virtual uint32_t GetPluginVersion();
+ bool IsVTableName(const char *name) override;
- virtual bool IsVTableName(const char *name);
-
- virtual bool GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic,
- TypeAndOrName &class_type_or_name, Address &address);
+ bool GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic,
+ TypeAndOrName &class_type_or_name, Address &address,
+ Value::ValueType &value_type) override;
+
+ TypeAndOrName
+ FixUpDynamicType(const TypeAndOrName& type_and_or_name,
+ ValueObject& static_value) override;
- virtual bool CouldHaveDynamicValue(ValueObject &in_value);
+ bool CouldHaveDynamicValue(ValueObject &in_value) override;
- virtual lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp, bool throw_bp);
+ lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp, bool throw_bp) override;
bool LoadModule(const lldb::ModuleSP &module_sp);
@@ -147,25 +196,60 @@ class RenderScriptRuntime : public lldb_private::CPPLanguageRuntime
void DumpKernels(Stream &strm) const;
- void AttemptBreakpointAtKernelName(Stream &strm, const char *name, Error &error);
+ bool DumpAllocation(Stream &strm, StackFrame* frame_ptr, const uint32_t id);
+
+ void ListAllocations(Stream &strm, StackFrame* frame_ptr, bool recompute);
+
+ void PlaceBreakpointOnKernel(Stream &strm, const char *name, const std::array<int,3> coords,
+ Error &error, lldb::TargetSP target);
+
+ void SetBreakAllKernels(bool do_break, lldb::TargetSP target);
void Status(Stream &strm) const;
- virtual size_t GetAlternateManglings(const ConstString &mangled, std::vector<ConstString> &alternates) {
+ size_t GetAlternateManglings(const ConstString &mangled, std::vector<ConstString> &alternates) override {
return static_cast<size_t>(0);
}
- virtual void ModulesDidLoad(const ModuleList &module_list );
+ void ModulesDidLoad(const ModuleList &module_list) override;
+
+ bool LoadAllocation(Stream &strm, const uint32_t alloc_id, const char* filename, StackFrame* frame_ptr);
+
+ bool SaveAllocation(Stream &strm, const uint32_t alloc_id, const char* filename, StackFrame* frame_ptr);
void Update();
void Initiate();
+
+ //------------------------------------------------------------------
+ // PluginInterface protocol
+ //------------------------------------------------------------------
+ lldb_private::ConstString GetPluginName() override;
+
+ uint32_t GetPluginVersion() override;
+
+protected:
+ struct ScriptDetails;
+ struct AllocationDetails;
+ struct Element;
+
+ void InitSearchFilter(lldb::TargetSP target)
+ {
+ if (!m_filtersp)
+ m_filtersp.reset(new SearchFilterForUnconstrainedSearches(target));
+ }
- protected:
-
- void FixupScriptDetails(RSModuleDescriptorSP rsmodule_sp);
+ void FixupScriptDetails(lldb_renderscript::RSModuleDescriptorSP rsmodule_sp);
void LoadRuntimeHooks(lldb::ModuleSP module, ModuleKind kind);
+
+ bool RefreshAllocation(AllocationDetails* allocation, StackFrame* frame_ptr);
+
+ bool EvalRSExpression(const char* expression, StackFrame* frame_ptr, uint64_t* result);
+
+ lldb::BreakpointSP CreateKernelBreakpoint(const ConstString& name);
+
+ void BreakOnModuleKernels(const lldb_renderscript::RSModuleDescriptorSP rsmodule_sp);
struct RuntimeHook;
typedef void (RenderScriptRuntime::*CaptureStateFn)(RuntimeHook* hook_info, ExecutionContext &context); // Please do this!
@@ -173,7 +257,8 @@ class RenderScriptRuntime : public lldb_private::CPPLanguageRuntime
struct HookDefn
{
const char * name;
- const char * symbol_name;
+ const char * symbol_name_m32; // mangled name for the 32 bit architectures
+ const char * symbol_name_m64; // mangled name for the 64 bit archs
uint32_t version;
ModuleKind kind;
CaptureStateFn grabber;
@@ -185,46 +270,102 @@ class RenderScriptRuntime : public lldb_private::CPPLanguageRuntime
const HookDefn *defn;
lldb::BreakpointSP bp_sp;
};
-
- typedef std::shared_ptr<RuntimeHook> RuntimeHookSP;
- struct ScriptDetails
- {
- std::string resname;
- std::string scriptDyLib;
- std::string cachedir;
- lldb::addr_t context;
- lldb::addr_t script;
- };
+ typedef std::shared_ptr<RuntimeHook> RuntimeHookSP;
lldb::ModuleSP m_libRS;
lldb::ModuleSP m_libRSDriver;
lldb::ModuleSP m_libRSCpuRef;
- std::vector<RSModuleDescriptorSP> m_rsmodules;
- std::vector<ScriptDetails> m_scripts;
+ std::vector<lldb_renderscript::RSModuleDescriptorSP> m_rsmodules;
+
+ std::vector<std::unique_ptr<ScriptDetails>> m_scripts;
+ std::vector<std::unique_ptr<AllocationDetails>> m_allocations;
- std::map<lldb::addr_t, RSModuleDescriptorSP> m_scriptMappings;
+ std::map<lldb::addr_t, lldb_renderscript::RSModuleDescriptorSP> m_scriptMappings;
std::map<lldb::addr_t, RuntimeHookSP> m_runtimeHooks;
+ std::map<lldb::user_id_t, std::shared_ptr<int>> m_conditional_breaks;
+
+ lldb::SearchFilterSP m_filtersp; // Needed to create breakpoints through Target API
bool m_initiated;
bool m_debuggerPresentFlagged;
+ bool m_breakAllKernels;
static const HookDefn s_runtimeHookDefns[];
static const size_t s_runtimeHookCount;
- private:
+private:
+ // Used to index expression format strings
+ enum ExpressionStrings
+ {
+ eExprGetOffsetPtr = 0,
+ eExprAllocGetType,
+ eExprTypeDimX,
+ eExprTypeDimY,
+ eExprTypeDimZ,
+ eExprTypeElemPtr,
+ eExprElementType,
+ eExprElementKind,
+ eExprElementVec,
+ eExprElementFieldCount,
+ eExprSubelementsId,
+ eExprSubelementsName,
+ eExprSubelementsArrSize
+ };
+
RenderScriptRuntime(Process *process); // Call CreateInstance instead.
static bool HookCallback(void *baton, StoppointCallbackContext *ctx, lldb::user_id_t break_id,
lldb::user_id_t break_loc_id);
+ static bool KernelBreakpointHit(void *baton, StoppointCallbackContext *ctx,
+ lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
+
void HookCallback(RuntimeHook* hook_info, ExecutionContext& context);
- bool GetArg32Simple(ExecutionContext& context, uint32_t arg, uint32_t *data);
+ bool GetArgSimple(ExecutionContext& context, uint32_t arg, uint64_t* data);
void CaptureScriptInit1(RuntimeHook* hook_info, ExecutionContext& context);
void CaptureAllocationInit1(RuntimeHook* hook_info, ExecutionContext& context);
+ void CaptureAllocationDestroy(RuntimeHook* hook_info, ExecutionContext& context);
void CaptureSetGlobalVar1(RuntimeHook* hook_info, ExecutionContext& context);
+ AllocationDetails* FindAllocByID(Stream &strm, const uint32_t alloc_id);
+ std::shared_ptr<uint8_t> GetAllocationData(AllocationDetails* allocation, StackFrame* frame_ptr);
+ void SetElementSize(Element& elem);
+ static bool GetFrameVarAsUnsigned(const lldb::StackFrameSP, const char* var_name, uint64_t& val);
+ void FindStructTypeName(Element& elem, StackFrame* frame_ptr);
+
+ //
+ // Helper functions for jitting the runtime
+ //
+ const char* JITTemplate(ExpressionStrings e);
+
+ bool JITDataPointer(AllocationDetails* allocation, StackFrame* frame_ptr,
+ unsigned int x = 0, unsigned int y = 0, unsigned int z = 0);
+
+ bool JITTypePointer(AllocationDetails* allocation, StackFrame* frame_ptr);
+
+ bool JITTypePacked(AllocationDetails* allocation, StackFrame* frame_ptr);
+
+ bool JITElementPacked(Element& elem, const lldb::addr_t context, StackFrame* frame_ptr);
+
+ bool JITAllocationSize(AllocationDetails* allocation, StackFrame* frame_ptr);
+
+ bool JITSubelements(Element& elem, const lldb::addr_t context, StackFrame* frame_ptr);
+
+ bool JITAllocationStride(AllocationDetails* allocation, StackFrame* frame_ptr);
+
+ // Search for a script detail object using a target address.
+ // If a script does not currently exist this function will return nullptr.
+ // If 'create' is true and there is no previous script with this address,
+ // then a new Script detail object will be created for this address and returned.
+ ScriptDetails* LookUpScript(lldb::addr_t address, bool create);
+
+ // Search for a previously saved allocation detail object using a target address.
+ // If an allocation does not exist for this address then nullptr will be returned.
+ // If 'create' is true and there is no previous allocation then a new allocation
+ // detail object will be created for this address and returned.
+ AllocationDetails* LookUpAllocation(lldb::addr_t address, bool create);
};
} // namespace lldb_private
diff --git a/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp b/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
index c7c64ed54d87..c57519871624 100644
--- a/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
+++ b/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
@@ -30,36 +30,25 @@ MemoryHistoryASan::CreateInstance (const ProcessSP &process_sp)
{
if (!process_sp.get())
return NULL;
-
+
Target & target = process_sp->GetTarget();
-
- bool found_asan_runtime = false;
-
+
const ModuleList &target_modules = target.GetImages();
Mutex::Locker modules_locker(target_modules.GetMutex());
const size_t num_modules = target_modules.GetSize();
for (size_t i = 0; i < num_modules; ++i)
{
Module *module_pointer = target_modules.GetModulePointerAtIndexUnlocked(i);
-
- SymbolContextList sc_list;
- const bool include_symbols = true;
- const bool append = true;
- const bool include_inlines = true;
- size_t num_matches = module_pointer->FindFunctions(ConstString("__asan_get_alloc_stack"), NULL, eFunctionNameTypeAuto, include_symbols, include_inlines, append, sc_list);
-
- if (num_matches)
- {
- found_asan_runtime = true;
- break;
- }
+ const Symbol* symbol = module_pointer->FindFirstSymbolWithNameAndType(
+ ConstString("__asan_get_alloc_stack"),
+ lldb::eSymbolTypeAny);
+
+ if (symbol != nullptr)
+ return MemoryHistorySP(new MemoryHistoryASan(process_sp));
}
-
- if (! found_asan_runtime)
- return MemoryHistorySP();
- return MemoryHistorySP(new MemoryHistoryASan(process_sp));
+ return MemoryHistorySP();
}
void
@@ -86,7 +75,8 @@ MemoryHistoryASan::GetPluginNameStatic()
MemoryHistoryASan::MemoryHistoryASan(const ProcessSP &process_sp)
{
- this->m_process_sp = process_sp;
+ if (process_sp)
+ m_process_wp = process_sp;
}
const char *
@@ -112,14 +102,23 @@ static void CreateHistoryThreadFromValueObject(ProcessSP process_sp, ValueObject
std::string count_path = "." + std::string(type) + "_count";
std::string tid_path = "." + std::string(type) + "_tid";
std::string trace_path = "." + std::string(type) + "_trace";
+
+ ValueObjectSP count_sp = return_value_sp->GetValueForExpressionPath(count_path.c_str());
+ ValueObjectSP tid_sp = return_value_sp->GetValueForExpressionPath(tid_path.c_str());
+
+ if (!count_sp || !tid_sp)
+ return;
- int count = return_value_sp->GetValueForExpressionPath(count_path.c_str())->GetValueAsUnsigned(0);
- tid_t tid = return_value_sp->GetValueForExpressionPath(tid_path.c_str())->GetValueAsUnsigned(0);
+ int count = count_sp->GetValueAsUnsigned(0);
+ tid_t tid = tid_sp->GetValueAsUnsigned(0);
if (count <= 0)
return;
ValueObjectSP trace_sp = return_value_sp->GetValueForExpressionPath(trace_path.c_str());
+
+ if (!trace_sp)
+ return;
std::vector<lldb::addr_t> pcs;
for (int i = 0; i < count; i++)
@@ -144,40 +143,41 @@ static void CreateHistoryThreadFromValueObject(ProcessSP process_sp, ValueObject
HistoryThreads
MemoryHistoryASan::GetHistoryThreads(lldb::addr_t address)
{
- ProcessSP process_sp = m_process_sp;
- ThreadSP thread_sp = m_process_sp->GetThreadList().GetSelectedThread();
- StackFrameSP frame_sp = thread_sp->GetSelectedFrame();
+ HistoryThreads result;
- if (!frame_sp)
+ ProcessSP process_sp = m_process_wp.lock();
+ if (process_sp)
{
- return HistoryThreads();
- }
+ ThreadSP thread_sp = process_sp->GetThreadList().GetSelectedThread();
- ExecutionContext exe_ctx (frame_sp);
- ValueObjectSP return_value_sp;
- StreamString expr;
- expr.Printf(memory_history_asan_command_format, address, address);
-
- EvaluateExpressionOptions options;
- options.SetUnwindOnError(true);
- options.SetTryAllThreads(true);
- options.SetStopOthers(true);
- options.SetIgnoreBreakpoints(true);
- options.SetTimeoutUsec(GET_STACK_FUNCTION_TIMEOUT_USEC);
-
- if (m_process_sp->GetTarget().EvaluateExpression(expr.GetData(), frame_sp.get(), return_value_sp, options) != eExpressionCompleted)
- {
- return HistoryThreads();
- }
- if (!return_value_sp)
- {
- return HistoryThreads();
+ if (thread_sp)
+ {
+ StackFrameSP frame_sp = thread_sp->GetSelectedFrame();
+
+ if (frame_sp)
+ {
+ ExecutionContext exe_ctx (frame_sp);
+ ValueObjectSP return_value_sp;
+ StreamString expr;
+ expr.Printf(memory_history_asan_command_format, address, address);
+
+ EvaluateExpressionOptions options;
+ options.SetUnwindOnError(true);
+ options.SetTryAllThreads(true);
+ options.SetStopOthers(true);
+ options.SetIgnoreBreakpoints(true);
+ options.SetTimeoutUsec(GET_STACK_FUNCTION_TIMEOUT_USEC);
+
+ if (process_sp->GetTarget().EvaluateExpression(expr.GetData(), frame_sp.get(), return_value_sp, options) == eExpressionCompleted)
+ {
+ if (return_value_sp)
+ {
+ CreateHistoryThreadFromValueObject(process_sp, return_value_sp, "free", "Memory deallocated at", result);
+ CreateHistoryThreadFromValueObject(process_sp, return_value_sp, "alloc", "Memory allocated at", result);
+ }
+ }
+ }
+ }
}
-
- HistoryThreads result;
-
- CreateHistoryThreadFromValueObject(process_sp, return_value_sp, "alloc", "Memory allocated at", result);
- CreateHistoryThreadFromValueObject(process_sp, return_value_sp, "free", "Memory deallocated at", result);
-
return result;
}
diff --git a/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h b/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h
index 5307e0b34081..b38f95ed744e 100644
--- a/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h
+++ b/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h
@@ -1,4 +1,4 @@
-//===-- MemoryHistoryASan.h ----------------------------------------*- C++ -*-===//
+//===-- MemoryHistoryASan.h -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -24,7 +24,8 @@ namespace lldb_private {
class MemoryHistoryASan : public lldb_private::MemoryHistory
{
public:
-
+ ~MemoryHistoryASan() override = default;
+
static lldb::MemoryHistorySP
CreateInstance (const lldb::ProcessSP &process_sp);
@@ -36,27 +37,28 @@ public:
static lldb_private::ConstString
GetPluginNameStatic();
+
+ lldb_private::ConstString
+ GetPluginName() override
+ {
+ return GetPluginNameStatic();
+ }
- virtual
- ~MemoryHistoryASan () {}
-
- virtual lldb_private::ConstString
- GetPluginName() { return GetPluginNameStatic(); }
-
- virtual uint32_t
- GetPluginVersion() { return 1; }
+ uint32_t
+ GetPluginVersion() override
+ {
+ return 1;
+ }
- virtual lldb_private::HistoryThreads
- GetHistoryThreads(lldb::addr_t address);
+ lldb_private::HistoryThreads
+ GetHistoryThreads(lldb::addr_t address) override;
private:
-
MemoryHistoryASan(const lldb::ProcessSP &process_sp);
- lldb::ProcessSP m_process_sp;
-
+ lldb::ProcessWP m_process_wp;
};
} // namespace lldb_private
-#endif // liblldb_MemoryHistoryASan_h_
+#endif // liblldb_MemoryHistoryASan_h_
diff --git a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
index 8209d23c0aee..f2a74b05fe26 100644
--- a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
+++ b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
@@ -103,9 +103,13 @@ ObjectContainerBSDArchive::Object::Extract (const DataExtractor& data, lldb::off
}
else
{
- // Strip off any spaces (if the object file name contains spaces it
- // will use the extended format above).
- str.erase (str.find(' '));
+ // Strip off any trailing spaces.
+ const size_t last_pos = str.find_last_not_of(' ');
+ if (last_pos != std::string::npos)
+ {
+ if (last_pos + 1 < 16)
+ str.erase (last_pos + 1);
+ }
ar_name.SetCString(str.c_str());
}
diff --git a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
index 8093c580ff97..cbb3848dc7cd 100644
--- a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
+++ b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
@@ -10,8 +10,11 @@
#ifndef liblldb_ObjectContainerBSDArchive_h_
#define liblldb_ObjectContainerBSDArchive_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Symbol/ObjectContainer.h"
-
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Host/FileSpec.h"
@@ -22,6 +25,14 @@ class ObjectContainerBSDArchive :
public lldb_private::ObjectContainer
{
public:
+ ObjectContainerBSDArchive(const lldb::ModuleSP &module_sp,
+ lldb::DataBufferSP& data_sp,
+ lldb::offset_t data_offset,
+ const lldb_private::FileSpec *file,
+ lldb::offset_t offset,
+ lldb::offset_t length);
+
+ ~ObjectContainerBSDArchive() override;
//------------------------------------------------------------------
// Static Functions
@@ -60,43 +71,33 @@ public:
//------------------------------------------------------------------
// Member Functions
//------------------------------------------------------------------
- ObjectContainerBSDArchive (const lldb::ModuleSP &module_sp,
- lldb::DataBufferSP& data_sp,
- lldb::offset_t data_offset,
- const lldb_private::FileSpec *file,
- lldb::offset_t offset,
- lldb::offset_t length);
-
- virtual
- ~ObjectContainerBSDArchive();
+ bool
+ ParseHeader() override;
- virtual bool
- ParseHeader ();
-
- virtual size_t
- GetNumObjects () const
+ size_t
+ GetNumObjects() const override
{
if (m_archive_sp)
return m_archive_sp->GetNumObjects();
return 0;
}
- virtual void
- Dump (lldb_private::Stream *s) const;
- virtual lldb::ObjectFileSP
- GetObjectFile (const lldb_private::FileSpec *file);
+ void
+ Dump(lldb_private::Stream *s) const override;
+
+ lldb::ObjectFileSP
+ GetObjectFile(const lldb_private::FileSpec *file) override;
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
- virtual lldb_private::ConstString
- GetPluginName();
+ lldb_private::ConstString
+ GetPluginName() override;
- virtual uint32_t
- GetPluginVersion();
+ uint32_t
+ GetPluginVersion() override;
protected:
-
struct Object
{
Object();
@@ -127,6 +128,13 @@ protected:
typedef std::shared_ptr<Archive> shared_ptr;
typedef std::multimap<lldb_private::FileSpec, shared_ptr> Map;
+ Archive(const lldb_private::ArchSpec &arch,
+ const lldb_private::TimeValue &mod_time,
+ lldb::offset_t file_offset,
+ lldb_private::DataExtractor &data);
+
+ ~Archive();
+
static Map &
GetArchiveCache ();
@@ -146,13 +154,6 @@ protected:
lldb::offset_t file_offset,
lldb_private::DataExtractor &data);
- Archive (const lldb_private::ArchSpec &arch,
- const lldb_private::TimeValue &mod_time,
- lldb::offset_t file_offset,
- lldb_private::DataExtractor &data);
-
- ~Archive ();
-
size_t
GetNumObjects () const
{
@@ -226,4 +227,4 @@ protected:
Archive::shared_ptr m_archive_sp;
};
-#endif // liblldb_ObjectContainerBSDArchive_h_
+#endif // liblldb_ObjectContainerBSDArchive_h_
diff --git a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 789fd4913301..44fe6615a361 100644
--- a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -11,6 +11,7 @@
#include <cassert>
#include <algorithm>
+#include <unordered_map>
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/DataBuffer.h"
@@ -48,6 +49,8 @@ const char *const LLDB_NT_OWNER_GNU = "GNU";
const char *const LLDB_NT_OWNER_NETBSD = "NetBSD";
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";
// ELF note type definitions
const elf_word LLDB_NT_FREEBSD_ABI_TAG = 0x01;
@@ -66,6 +69,41 @@ const elf_word LLDB_NT_GNU_ABI_OS_LINUX = 0x00;
const elf_word LLDB_NT_GNU_ABI_OS_HURD = 0x01;
const elf_word LLDB_NT_GNU_ABI_OS_SOLARIS = 0x02;
+// LLDB_NT_OWNER_CORE and LLDB_NT_OWNER_LINUX note contants
+#define NT_PRSTATUS 1
+#define NT_PRFPREG 2
+#define NT_PRPSINFO 3
+#define NT_TASKSTRUCT 4
+#define NT_AUXV 6
+#define NT_SIGINFO 0x53494749
+#define NT_FILE 0x46494c45
+#define NT_PRXFPREG 0x46e62b7f
+#define NT_PPC_VMX 0x100
+#define NT_PPC_SPE 0x101
+#define NT_PPC_VSX 0x102
+#define NT_386_TLS 0x200
+#define NT_386_IOPERM 0x201
+#define NT_X86_XSTATE 0x202
+#define NT_S390_HIGH_GPRS 0x300
+#define NT_S390_TIMER 0x301
+#define NT_S390_TODCMP 0x302
+#define NT_S390_TODPREG 0x303
+#define NT_S390_CTRS 0x304
+#define NT_S390_PREFIX 0x305
+#define NT_S390_LAST_BREAK 0x306
+#define NT_S390_SYSTEM_CALL 0x307
+#define NT_S390_TDB 0x308
+#define NT_S390_VXRS_LOW 0x309
+#define NT_S390_VXRS_HIGH 0x30a
+#define NT_ARM_VFP 0x400
+#define NT_ARM_TLS 0x401
+#define NT_ARM_HW_BREAK 0x402
+#define NT_ARM_HW_WATCH 0x403
+#define NT_ARM_SYSTEM_CALL 0x404
+#define NT_METAG_CBUF 0x500
+#define NT_METAG_RPIPE 0x501
+#define NT_METAG_TLS 0x502
+
//===----------------------------------------------------------------------===//
/// @class ELFRelocation
/// @brief Generic wrapper for ELFRel and ELFRela.
@@ -290,6 +328,11 @@ mipsVariantFromElfFlags(const elf::elf_word e_flags, uint32_t endian)
switch (mips_arch)
{
+ case llvm::ELF::EF_MIPS_ARCH_1:
+ case llvm::ELF::EF_MIPS_ARCH_2:
+ case llvm::ELF::EF_MIPS_ARCH_3:
+ case llvm::ELF::EF_MIPS_ARCH_4:
+ case llvm::ELF::EF_MIPS_ARCH_5:
case llvm::ELF::EF_MIPS_ARCH_32:
return (endian == ELFDATA2LSB) ? ArchSpec::eMIPSSubType_mips32el : ArchSpec::eMIPSSubType_mips32;
case llvm::ELF::EF_MIPS_ARCH_32R2:
@@ -847,40 +890,52 @@ ObjectFileELF::SetLoadAddress (Target &target,
SectionList *section_list = GetSectionList ();
if (section_list)
{
- if (value_is_offset)
+ if (!value_is_offset)
{
- const size_t num_sections = section_list->GetSize();
- size_t sect_idx = 0;
-
- for (sect_idx = 0; sect_idx < num_sections; ++sect_idx)
+ bool found_offset = false;
+ for (size_t i = 0, count = GetProgramHeaderCount(); i < count; ++i)
{
- // Iterate through the object file sections to find all
- // of the sections that have SHF_ALLOC in their flag bits.
- SectionSP section_sp (section_list->GetSectionAtIndex (sect_idx));
- // if (section_sp && !section_sp->IsThreadSpecific())
- if (section_sp && section_sp->Test(SHF_ALLOC))
- {
- lldb::addr_t load_addr = section_sp->GetFileAddress() + value;
-
- // On 32-bit systems the load address have to fit into 4 bytes. The rest of
- // the bytes are the overflow from the addition.
- if (GetAddressByteSize() == 4)
- load_addr &= 0xFFFFFFFF;
-
- if (target.GetSectionLoadList().SetSectionLoadAddress (section_sp, load_addr))
- ++num_loaded_sections;
- }
+ const elf::ELFProgramHeader* header = GetProgramHeaderByIndex(i);
+ if (header == nullptr)
+ continue;
+
+ if (header->p_type != PT_LOAD || header->p_offset != 0)
+ continue;
+
+ value = value - header->p_vaddr;
+ found_offset = true;
+ break;
}
- return num_loaded_sections > 0;
+ if (!found_offset)
+ return false;
}
- else
+
+ const size_t num_sections = section_list->GetSize();
+ size_t sect_idx = 0;
+
+ for (sect_idx = 0; sect_idx < num_sections; ++sect_idx)
{
- // Not sure how to slide an ELF file given the base address
- // of the ELF file in memory
+ // Iterate through the object file sections to find all
+ // of the sections that have SHF_ALLOC in their flag bits.
+ SectionSP section_sp (section_list->GetSectionAtIndex (sect_idx));
+ // if (section_sp && !section_sp->IsThreadSpecific())
+ if (section_sp && section_sp->Test(SHF_ALLOC))
+ {
+ lldb::addr_t load_addr = section_sp->GetFileAddress() + value;
+
+ // On 32-bit systems the load address have to fit into 4 bytes. The rest of
+ // the bytes are the overflow from the addition.
+ if (GetAddressByteSize() == 4)
+ load_addr &= 0xFFFFFFFF;
+
+ if (target.GetSectionLoadList().SetSectionLoadAddress (section_sp, load_addr))
+ ++num_loaded_sections;
+ }
}
+ return num_loaded_sections > 0;
}
}
- return false; // If it changed
+ return false;
}
ByteOrder
@@ -905,8 +960,17 @@ ObjectFileELF::GetAddressByteSize() const
AddressClass
ObjectFileELF::GetAddressClass (addr_t file_addr)
{
- auto res = ObjectFile::GetAddressClass (file_addr);
+ Symtab* symtab = GetSymtab();
+ if (!symtab)
+ return eAddressClassUnknown;
+
+ // The address class is determined based on the symtab. Ask it from the object file what
+ // contains the symtab information.
+ ObjectFile* symtab_objfile = symtab->GetObjectFile();
+ if (symtab_objfile != nullptr && symtab_objfile != this)
+ return symtab_objfile->GetAddressClass(file_addr);
+ auto res = ObjectFile::GetAddressClass (file_addr);
if (res != eAddressClassCode)
return res;
@@ -1076,16 +1140,35 @@ ObjectFileELF::GetImageInfoAddress(Target *target)
addr_t offset = i * dynsym_hdr->sh_entsize + GetAddressByteSize();
return Address(dynsym_section_sp, offset);
}
- else if (symbol.d_tag == DT_MIPS_RLD_MAP && target)
+ // MIPS executables uses DT_MIPS_RLD_MAP_REL to support PIE. DT_MIPS_RLD_MAP exists in non-PIE.
+ else if ((symbol.d_tag == DT_MIPS_RLD_MAP || symbol.d_tag == DT_MIPS_RLD_MAP_REL) && target)
{
addr_t offset = i * dynsym_hdr->sh_entsize + GetAddressByteSize();
addr_t dyn_base = dynsym_section_sp->GetLoadBaseAddress(target);
if (dyn_base == LLDB_INVALID_ADDRESS)
return Address();
- Address addr;
+
Error error;
- if (target->ReadPointerFromMemory(dyn_base + offset, false, error, addr))
- return addr;
+ if (symbol.d_tag == DT_MIPS_RLD_MAP)
+ {
+ // DT_MIPS_RLD_MAP tag stores an absolute address of the debug pointer.
+ Address addr;
+ if (target->ReadPointerFromMemory(dyn_base + offset, false, error, addr))
+ return addr;
+ }
+ if (symbol.d_tag == DT_MIPS_RLD_MAP_REL)
+ {
+ // DT_MIPS_RLD_MAP_REL tag stores the offset to the debug pointer, relative to the address of the tag.
+ uint64_t rel_offset;
+ rel_offset = target->ReadUnsignedIntegerFromMemory(dyn_base + offset, false, GetAddressByteSize(), UINT64_MAX, error);
+ if (error.Success() && rel_offset != UINT64_MAX)
+ {
+ Address addr;
+ addr_t debug_ptr_address = dyn_base + (offset - GetAddressByteSize()) + rel_offset;
+ addr.SetOffset (debug_ptr_address);
+ return addr;
+ }
+ }
}
}
@@ -1232,6 +1315,7 @@ ObjectFileELF::RefineModuleDetailsFromNote (lldb_private::DataExtractor &data, l
while (true)
{
// Parse the note header. If this fails, bail out.
+ const lldb::offset_t note_offset = offset;
ELFNote note = ELFNote();
if (!note.Parse(data, &offset))
{
@@ -1239,11 +1323,6 @@ ObjectFileELF::RefineModuleDetailsFromNote (lldb_private::DataExtractor &data, l
return error;
}
- // If a tag processor handles the tag, it should set processed to true, and
- // the loop will assume the tag processing has moved entirely past the note's payload.
- // Otherwise, leave it false and the end of the loop will handle the offset properly.
- bool processed = false;
-
if (log)
log->Printf ("ObjectFileELF::%s parsing note name='%s', type=%" PRIu32, __FUNCTION__, note.n_name.c_str (), note.n_type);
@@ -1252,9 +1331,6 @@ ObjectFileELF::RefineModuleDetailsFromNote (lldb_private::DataExtractor &data, l
(note.n_type == LLDB_NT_FREEBSD_ABI_TAG) &&
(note.n_descsz == LLDB_NT_FREEBSD_ABI_SIZE))
{
- // We'll consume the payload below.
- processed = true;
-
// Pull out the min version info.
uint32_t version_info;
if (data.GetU32 (&offset, &version_info, 1) == nullptr)
@@ -1285,9 +1361,6 @@ ObjectFileELF::RefineModuleDetailsFromNote (lldb_private::DataExtractor &data, l
case LLDB_NT_GNU_ABI_TAG:
if (note.n_descsz == LLDB_NT_GNU_ABI_SIZE)
{
- // We'll consume the payload below.
- processed = true;
-
// Pull out the min OS version supporting the ABI.
uint32_t version_info[4];
if (data.GetU32 (&offset, &version_info[0], note.n_descsz / 4) == nullptr)
@@ -1330,9 +1403,6 @@ ObjectFileELF::RefineModuleDetailsFromNote (lldb_private::DataExtractor &data, l
// Only bother processing this if we don't already have the uuid set.
if (!uuid.IsValid())
{
- // We'll consume the payload below.
- processed = true;
-
// 16 bytes is UUID|MD5, 20 bytes is SHA1
if ((note.n_descsz == 16 || note.n_descsz == 20))
{
@@ -1355,10 +1425,6 @@ ObjectFileELF::RefineModuleDetailsFromNote (lldb_private::DataExtractor &data, l
(note.n_type == LLDB_NT_NETBSD_ABI_TAG) &&
(note.n_descsz == LLDB_NT_NETBSD_ABI_SIZE))
{
-
- // We'll consume the payload below.
- processed = true;
-
// Pull out the min version info.
uint32_t version_info;
if (data.GetU32 (&offset, &version_info, 1) == nullptr)
@@ -1378,8 +1444,6 @@ ObjectFileELF::RefineModuleDetailsFromNote (lldb_private::DataExtractor &data, l
else if ((note.n_type == LLDB_NT_GNU_ABI_TAG) &&
(note.n_name == LLDB_NT_OWNER_CSR))
{
- // We'll consume the payload below.
- processed = true;
arch_spec.GetTriple().setOS(llvm::Triple::OSType::UnknownOS);
arch_spec.GetTriple().setVendor(llvm::Triple::VendorType::CSR);
@@ -1397,9 +1461,48 @@ ObjectFileELF::RefineModuleDetailsFromNote (lldb_private::DataExtractor &data, l
arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux);
arch_spec.GetTriple().setEnvironment(llvm::Triple::EnvironmentType::Android);
}
+ else if (note.n_name == LLDB_NT_OWNER_LINUX)
+ {
+ // This is sometimes found in core files and usually contains extended register info
+ arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux);
+ }
+ else if (note.n_name == LLDB_NT_OWNER_CORE)
+ {
+ // Parse the NT_FILE to look for stuff in paths to shared libraries
+ // As the contents look like:
+ // 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
+ // [ 3] 0x00007fa79c9ed000 0x00007fa79cba8000 0x0000000000000000 /lib/x86_64-linux-gnu/libc-2.19.so
+ // [ 4] 0x00007fa79cba8000 0x00007fa79cda7000 0x00000000000001bb /lib/x86_64-linux-gnu/libc-2.19.so
+ // [ 5] 0x00007fa79cda7000 0x00007fa79cdab000 0x00000000000001ba /lib/x86_64-linux-gnu/libc-2.19.so
+ // [ 6] 0x00007fa79cdab000 0x00007fa79cdad000 0x00000000000001be /lib/x86_64-linux-gnu/libc-2.19.so
+ // [ 7] 0x00007fa79cdb2000 0x00007fa79cdd5000 0x0000000000000000 /lib/x86_64-linux-gnu/ld-2.19.so
+ // [ 8] 0x00007fa79cfd4000 0x00007fa79cfd5000 0x0000000000000022 /lib/x86_64-linux-gnu/ld-2.19.so
+ // [ 9] 0x00007fa79cfd5000 0x00007fa79cfd6000 0x0000000000000023 /lib/x86_64-linux-gnu/ld-2.19.so
+ if (note.n_type == NT_FILE)
+ {
+ uint64_t count = data.GetU64(&offset);
+ offset += 8 + 3*8*count; // Skip page size and all start/end/file_ofs
+ for (size_t i=0; i<count; ++i)
+ {
+ llvm::StringRef path(data.GetCStr(&offset));
+ if (path.startswith("/lib/x86_64-linux-gnu"))
+ {
+ arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux);
+ break;
+ }
+ }
+ }
+ }
- if (!processed)
- offset += llvm::RoundUpToAlignment(note.n_descsz, 4);
+ // Calculate the offset of the next note just in case "offset" has been used
+ // to poke at the contents of the note data
+ offset = note_offset + note.GetByteSize();
}
return error;
@@ -1496,8 +1599,8 @@ ObjectFileELF::GetSectionHeaderInfo(SectionHeaderColl &section_headers,
I != section_headers.end(); ++I)
{
static ConstString g_sect_name_gnu_debuglink (".gnu_debuglink");
- const ELFSectionHeaderInfo &header = *I;
- const uint64_t section_size = header.sh_type == SHT_NOBITS ? 0 : header.sh_size;
+ const ELFSectionHeaderInfo &sheader = *I;
+ const uint64_t section_size = sheader.sh_type == SHT_NOBITS ? 0 : sheader.sh_size;
ConstString name(shstr_data.PeekCStr(I->sh_name));
I->section_name = name;
@@ -1505,23 +1608,33 @@ ObjectFileELF::GetSectionHeaderInfo(SectionHeaderColl &section_headers,
if (arch_spec.GetMachine() == llvm::Triple::mips || arch_spec.GetMachine() == llvm::Triple::mipsel
|| arch_spec.GetMachine() == llvm::Triple::mips64 || arch_spec.GetMachine() == llvm::Triple::mips64el)
{
- if (header.sh_type == SHT_MIPS_ABIFLAGS)
+ uint32_t arch_flags = arch_spec.GetFlags ();
+ DataExtractor data;
+ if (sheader.sh_type == SHT_MIPS_ABIFLAGS)
{
- DataExtractor data;
- if (section_size && (data.SetData (object_data, header.sh_offset, section_size) == section_size))
+
+ if (section_size && (data.SetData (object_data, sheader.sh_offset, section_size) == section_size))
{
lldb::offset_t ase_offset = 12; // MIPS ABI Flags Version: 0
- uint32_t arch_flags = arch_spec.GetFlags ();
arch_flags |= data.GetU32 (&ase_offset);
- arch_spec.SetFlags (arch_flags);
}
}
+ // Settings appropriate ArchSpec ABI Flags
+ if (header.e_flags & llvm::ELF::EF_MIPS_ABI2)
+ {
+ arch_flags |= lldb_private::ArchSpec::eMIPSABI_N32;
+ }
+ else if (header.e_flags & llvm::ELF::EF_MIPS_ABI_O32)
+ {
+ arch_flags |= lldb_private::ArchSpec::eMIPSABI_O32;
+ }
+ arch_spec.SetFlags (arch_flags);
}
if (name == g_sect_name_gnu_debuglink)
{
DataExtractor data;
- if (section_size && (data.SetData (object_data, header.sh_offset, section_size) == section_size))
+ if (section_size && (data.SetData (object_data, sheader.sh_offset, section_size) == section_size))
{
lldb::offset_t gnu_debuglink_offset = 0;
gnu_debuglink_file = data.GetCStr (&gnu_debuglink_offset);
@@ -1531,7 +1644,7 @@ ObjectFileELF::GetSectionHeaderInfo(SectionHeaderColl &section_headers,
}
// Process ELF note section entries.
- bool is_note_header = (header.sh_type == SHT_NOTE);
+ bool is_note_header = (sheader.sh_type == SHT_NOTE);
// The section header ".note.android.ident" is stored as a
// PROGBITS type header but it is actually a note header.
@@ -1543,7 +1656,7 @@ ObjectFileELF::GetSectionHeaderInfo(SectionHeaderColl &section_headers,
{
// Allow notes to refine module info.
DataExtractor data;
- if (section_size && (data.SetData (object_data, header.sh_offset, section_size) == section_size))
+ if (section_size && (data.SetData (object_data, sheader.sh_offset, section_size) == section_size))
{
Error error = RefineModuleDetailsFromNote (data, arch_spec, uuid);
if (error.Fail ())
@@ -1555,6 +1668,12 @@ ObjectFileELF::GetSectionHeaderInfo(SectionHeaderColl &section_headers,
}
}
+ // Make any unknown triple components to be unspecified unknowns.
+ if (arch_spec.GetTriple().getVendor() == llvm::Triple::UnknownVendor)
+ arch_spec.GetTriple().setVendorName (llvm::StringRef());
+ if (arch_spec.GetTriple().getOS() == llvm::Triple::UnknownOS)
+ arch_spec.GetTriple().setOSName (llvm::StringRef());
+
return section_headers.size();
}
}
@@ -1651,17 +1770,30 @@ ObjectFileELF::CreateSections(SectionList &unified_section_list)
static ConstString g_sect_name_tdata (".tdata");
static ConstString g_sect_name_tbss (".tbss");
static ConstString g_sect_name_dwarf_debug_abbrev (".debug_abbrev");
+ static ConstString g_sect_name_dwarf_debug_addr (".debug_addr");
static ConstString g_sect_name_dwarf_debug_aranges (".debug_aranges");
static ConstString g_sect_name_dwarf_debug_frame (".debug_frame");
static ConstString g_sect_name_dwarf_debug_info (".debug_info");
static ConstString g_sect_name_dwarf_debug_line (".debug_line");
static ConstString g_sect_name_dwarf_debug_loc (".debug_loc");
static ConstString g_sect_name_dwarf_debug_macinfo (".debug_macinfo");
+ static ConstString g_sect_name_dwarf_debug_macro (".debug_macro");
static ConstString g_sect_name_dwarf_debug_pubnames (".debug_pubnames");
static ConstString g_sect_name_dwarf_debug_pubtypes (".debug_pubtypes");
static ConstString g_sect_name_dwarf_debug_ranges (".debug_ranges");
static ConstString g_sect_name_dwarf_debug_str (".debug_str");
+ static ConstString g_sect_name_dwarf_debug_str_offsets (".debug_str_offsets");
+ static ConstString g_sect_name_dwarf_debug_abbrev_dwo (".debug_abbrev.dwo");
+ static ConstString g_sect_name_dwarf_debug_info_dwo (".debug_info.dwo");
+ static ConstString g_sect_name_dwarf_debug_line_dwo (".debug_line.dwo");
+ static ConstString g_sect_name_dwarf_debug_macro_dwo (".debug_macro.dwo");
+ static ConstString g_sect_name_dwarf_debug_loc_dwo (".debug_loc.dwo");
+ static ConstString g_sect_name_dwarf_debug_str_dwo (".debug_str.dwo");
+ static ConstString g_sect_name_dwarf_debug_str_offsets_dwo (".debug_str_offsets.dwo");
static ConstString g_sect_name_eh_frame (".eh_frame");
+ static ConstString g_sect_name_arm_exidx (".ARM.exidx");
+ static ConstString g_sect_name_arm_extab (".ARM.extab");
+ static ConstString g_sect_name_go_symtab (".gosymtab");
SectionType sect_type = eSectionTypeOther;
@@ -1694,18 +1826,31 @@ ObjectFileELF::CreateSections(SectionList &unified_section_list)
// MISSING? .gnu_debugdata - "mini debuginfo / MiniDebugInfo" section, http://sourceware.org/gdb/onlinedocs/gdb/MiniDebugInfo.html
// MISSING? .debug-index - http://src.chromium.org/viewvc/chrome/trunk/src/build/gdb-add-index?pathrev=144644
// MISSING? .debug_types - Type descriptions from DWARF 4? See http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo
- else if (name == g_sect_name_dwarf_debug_abbrev) sect_type = eSectionTypeDWARFDebugAbbrev;
- else if (name == g_sect_name_dwarf_debug_aranges) sect_type = eSectionTypeDWARFDebugAranges;
- else if (name == g_sect_name_dwarf_debug_frame) sect_type = eSectionTypeDWARFDebugFrame;
- else if (name == g_sect_name_dwarf_debug_info) sect_type = eSectionTypeDWARFDebugInfo;
- else if (name == g_sect_name_dwarf_debug_line) sect_type = eSectionTypeDWARFDebugLine;
- else if (name == g_sect_name_dwarf_debug_loc) sect_type = eSectionTypeDWARFDebugLoc;
- else if (name == g_sect_name_dwarf_debug_macinfo) sect_type = eSectionTypeDWARFDebugMacInfo;
- else if (name == g_sect_name_dwarf_debug_pubnames) sect_type = eSectionTypeDWARFDebugPubNames;
- else if (name == g_sect_name_dwarf_debug_pubtypes) sect_type = eSectionTypeDWARFDebugPubTypes;
- else if (name == g_sect_name_dwarf_debug_ranges) sect_type = eSectionTypeDWARFDebugRanges;
- else if (name == g_sect_name_dwarf_debug_str) sect_type = eSectionTypeDWARFDebugStr;
- else if (name == g_sect_name_eh_frame) sect_type = eSectionTypeEHFrame;
+ else if (name == g_sect_name_dwarf_debug_abbrev) sect_type = eSectionTypeDWARFDebugAbbrev;
+ else if (name == g_sect_name_dwarf_debug_addr) sect_type = eSectionTypeDWARFDebugAddr;
+ else if (name == g_sect_name_dwarf_debug_aranges) sect_type = eSectionTypeDWARFDebugAranges;
+ else if (name == g_sect_name_dwarf_debug_frame) sect_type = eSectionTypeDWARFDebugFrame;
+ else if (name == g_sect_name_dwarf_debug_info) sect_type = eSectionTypeDWARFDebugInfo;
+ else if (name == g_sect_name_dwarf_debug_line) sect_type = eSectionTypeDWARFDebugLine;
+ else if (name == g_sect_name_dwarf_debug_loc) sect_type = eSectionTypeDWARFDebugLoc;
+ else if (name == g_sect_name_dwarf_debug_macinfo) sect_type = eSectionTypeDWARFDebugMacInfo;
+ else if (name == g_sect_name_dwarf_debug_macro) sect_type = eSectionTypeDWARFDebugMacro;
+ else if (name == g_sect_name_dwarf_debug_pubnames) sect_type = eSectionTypeDWARFDebugPubNames;
+ else if (name == g_sect_name_dwarf_debug_pubtypes) sect_type = eSectionTypeDWARFDebugPubTypes;
+ else if (name == g_sect_name_dwarf_debug_ranges) sect_type = eSectionTypeDWARFDebugRanges;
+ else if (name == g_sect_name_dwarf_debug_str) sect_type = eSectionTypeDWARFDebugStr;
+ else if (name == g_sect_name_dwarf_debug_str_offsets) sect_type = eSectionTypeDWARFDebugStrOffsets;
+ else if (name == g_sect_name_dwarf_debug_abbrev_dwo) sect_type = eSectionTypeDWARFDebugAbbrev;
+ else if (name == g_sect_name_dwarf_debug_info_dwo) sect_type = eSectionTypeDWARFDebugInfo;
+ else if (name == g_sect_name_dwarf_debug_line_dwo) sect_type = eSectionTypeDWARFDebugLine;
+ else if (name == g_sect_name_dwarf_debug_macro_dwo) sect_type = eSectionTypeDWARFDebugMacro;
+ else if (name == g_sect_name_dwarf_debug_loc_dwo) sect_type = eSectionTypeDWARFDebugLoc;
+ else if (name == g_sect_name_dwarf_debug_str_dwo) sect_type = eSectionTypeDWARFDebugStr;
+ else if (name == g_sect_name_dwarf_debug_str_offsets_dwo) sect_type = eSectionTypeDWARFDebugStrOffsets;
+ else if (name == g_sect_name_eh_frame) sect_type = eSectionTypeEHFrame;
+ else if (name == g_sect_name_arm_exidx) sect_type = eSectionTypeARMexidx;
+ else if (name == g_sect_name_arm_extab) sect_type = eSectionTypeARMextab;
+ else if (name == g_sect_name_go_symtab) sect_type = eSectionTypeGoSymtab;
switch (header.sh_type)
{
@@ -1731,7 +1876,7 @@ ObjectFileELF::CreateSections(SectionList &unified_section_list)
if (eSectionTypeOther == sect_type)
{
// the kalimba toolchain assumes that ELF section names are free-form. It does
- // supports linkscripts which (can) give rise to various arbitarily named
+ // support linkscripts which (can) give rise to various arbitrarily named
// sections being "Code" or "Data".
sect_type = kalimbaSectionType(m_header, header);
}
@@ -1770,17 +1915,19 @@ ObjectFileELF::CreateSections(SectionList &unified_section_list)
{
static const SectionType g_sections[] =
{
- eSectionTypeDWARFDebugAranges,
- eSectionTypeDWARFDebugInfo,
eSectionTypeDWARFDebugAbbrev,
+ eSectionTypeDWARFDebugAddr,
+ eSectionTypeDWARFDebugAranges,
eSectionTypeDWARFDebugFrame,
+ eSectionTypeDWARFDebugInfo,
eSectionTypeDWARFDebugLine,
- eSectionTypeDWARFDebugStr,
eSectionTypeDWARFDebugLoc,
eSectionTypeDWARFDebugMacInfo,
eSectionTypeDWARFDebugPubNames,
eSectionTypeDWARFDebugPubTypes,
eSectionTypeDWARFDebugRanges,
+ eSectionTypeDWARFDebugStr,
+ eSectionTypeDWARFDebugStrOffsets,
eSectionTypeELFSymbolTable,
};
SectionList *elf_section_list = m_sections_ap.get();
@@ -1805,6 +1952,29 @@ ObjectFileELF::CreateSections(SectionList &unified_section_list)
}
}
+// Find the arm/aarch64 mapping symbol character in the given symbol name. Mapping symbols have the
+// form of "$<char>[.<any>]*". Additionally we recognize cases when the mapping symbol prefixed by
+// an arbitrary string because if a symbol prefix added to each symbol in the object file with
+// objcopy then the mapping symbols are also prefixed.
+static char
+FindArmAarch64MappingSymbol(const char* symbol_name)
+{
+ if (!symbol_name)
+ return '\0';
+
+ const char* dollar_pos = ::strchr(symbol_name, '$');
+ if (!dollar_pos || dollar_pos[1] == '\0')
+ return '\0';
+
+ if (dollar_pos[2] == '\0' || dollar_pos[2] == '.')
+ return dollar_pos[1];
+ return '\0';
+}
+
+#define STO_MIPS_ISA (3 << 6)
+#define STO_MICROMIPS (2 << 6)
+#define IS_MICROMIPS(ST_OTHER) (((ST_OTHER) & STO_MIPS_ISA) == STO_MICROMIPS)
+
// private
unsigned
ObjectFileELF::ParseSymbols (Symtab *symtab,
@@ -1840,6 +2010,13 @@ ObjectFileELF::ParseSymbols (Symtab *symtab,
// makes it highly unlikely that this will collide with anything else.
bool skip_oatdata_oatexec = m_file.GetFilename() == ConstString("system@framework@boot.oat");
+ ArchSpec arch;
+ GetArchitecture(arch);
+
+ // Local cache to avoid doing a FindSectionByName for each symbol. The "const char*" key must
+ // came from a ConstString object so they can be compared by pointer
+ std::unordered_map<const char*, lldb::SectionSP> section_name_to_section;
+
unsigned i;
for (i = 0; i < num_symbols; ++i)
{
@@ -1945,64 +2122,58 @@ ObjectFileELF::ParseSymbols (Symtab *symtab,
int64_t symbol_value_offset = 0;
uint32_t additional_flags = 0;
- ArchSpec arch;
- if (GetArchitecture(arch))
+ if (arch.IsValid())
{
if (arch.GetMachine() == llvm::Triple::arm)
{
- if (symbol.getBinding() == STB_LOCAL && symbol_name && symbol_name[0] == '$')
+ if (symbol.getBinding() == STB_LOCAL)
{
- // These are reserved for the specification (e.g.: mapping
- // symbols). We don't want to add them to the symbol table.
-
+ char mapping_symbol = FindArmAarch64MappingSymbol(symbol_name);
if (symbol_type == eSymbolTypeCode)
{
- llvm::StringRef symbol_name_ref(symbol_name);
- if (symbol_name_ref == "$a" || symbol_name_ref.startswith("$a."))
- {
- // $a[.<any>]* - marks an ARM instruction sequence
- m_address_class_map[symbol.st_value] = eAddressClassCode;
- }
- else if (symbol_name_ref == "$b" || symbol_name_ref.startswith("$b.") ||
- symbol_name_ref == "$t" || symbol_name_ref.startswith("$t."))
+ switch (mapping_symbol)
{
- // $b[.<any>]* - marks a THUMB BL instruction sequence
- // $t[.<any>]* - marks a THUMB instruction sequence
- m_address_class_map[symbol.st_value] = eAddressClassCodeAlternateISA;
- }
- else if (symbol_name_ref == "$d" || symbol_name_ref.startswith("$d."))
- {
- // $d[.<any>]* - marks a data item sequence (e.g. lit pool)
- m_address_class_map[symbol.st_value] = eAddressClassData;
+ case 'a':
+ // $a[.<any>]* - marks an ARM instruction sequence
+ m_address_class_map[symbol.st_value] = eAddressClassCode;
+ break;
+ case 'b':
+ case 't':
+ // $b[.<any>]* - marks a THUMB BL instruction sequence
+ // $t[.<any>]* - marks a THUMB instruction sequence
+ m_address_class_map[symbol.st_value] = eAddressClassCodeAlternateISA;
+ break;
+ case 'd':
+ // $d[.<any>]* - marks a data item sequence (e.g. lit pool)
+ m_address_class_map[symbol.st_value] = eAddressClassData;
+ break;
}
}
-
- continue;
+ if (mapping_symbol)
+ continue;
}
}
else if (arch.GetMachine() == llvm::Triple::aarch64)
{
- if (symbol.getBinding() == STB_LOCAL && symbol_name && symbol_name[0] == '$')
+ if (symbol.getBinding() == STB_LOCAL)
{
- // These are reserved for the specification (e.g.: mapping
- // symbols). We don't want to add them to the symbol table.
-
+ char mapping_symbol = FindArmAarch64MappingSymbol(symbol_name);
if (symbol_type == eSymbolTypeCode)
{
- llvm::StringRef symbol_name_ref(symbol_name);
- if (symbol_name_ref == "$x" || symbol_name_ref.startswith("$x."))
+ switch (mapping_symbol)
{
- // $x[.<any>]* - marks an A64 instruction sequence
- m_address_class_map[symbol.st_value] = eAddressClassCode;
- }
- else if (symbol_name_ref == "$d" || symbol_name_ref.startswith("$d."))
- {
- // $d[.<any>]* - marks a data item sequence (e.g. lit pool)
- m_address_class_map[symbol.st_value] = eAddressClassData;
+ case 'x':
+ // $x[.<any>]* - marks an A64 instruction sequence
+ m_address_class_map[symbol.st_value] = eAddressClassCode;
+ break;
+ case 'd':
+ // $d[.<any>]* - marks a data item sequence (e.g. lit pool)
+ m_address_class_map[symbol.st_value] = eAddressClassData;
+ break;
}
}
-
- continue;
+ if (mapping_symbol)
+ continue;
}
}
@@ -2029,11 +2200,46 @@ ObjectFileELF::ParseSymbols (Symtab *symtab,
}
}
}
+
+ /*
+ * MIPS:
+ * The bit #0 of an address is used for ISA mode (1 for microMIPS, 0 for MIPS).
+ * This allows processer to switch between microMIPS and MIPS without any need
+ * for special mode-control register. However, apart from .debug_line, none of
+ * the ELF/DWARF sections set the ISA bit (for symbol or section). Use st_other
+ * flag to check whether the symbol is microMIPS and then set the address 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 (IS_MICROMIPS(symbol.st_other))
+ m_address_class_map[symbol.st_value] = eAddressClassCodeAlternateISA;
+ else if ((symbol.st_value & 1) && (symbol_type == eSymbolTypeCode))
+ {
+ symbol.st_value = symbol.st_value & (~1ull);
+ m_address_class_map[symbol.st_value] = eAddressClassCodeAlternateISA;
+ }
+ else
+ {
+ if (symbol_type == eSymbolTypeCode)
+ m_address_class_map[symbol.st_value] = eAddressClassCode;
+ else if (symbol_type == eSymbolTypeData)
+ m_address_class_map[symbol.st_value] = eAddressClassData;
+ else
+ m_address_class_map[symbol.st_value] = eAddressClassUnknown;
+ }
+ }
}
- // If the symbol section we've found has no data (SHT_NOBITS), then check the module section
- // list. This can happen if we're parsing the debug file and it has no .text section, for example.
- if (symbol_section_sp && (symbol_section_sp->GetFileSize() == 0))
+ // symbol_value_offset may contain 0 for ARM symbols or -1 for
+ // THUMB symbols. See above for more details.
+ uint64_t symbol_value = symbol.st_value + symbol_value_offset;
+ if (symbol_section_sp && CalculateType() != ObjectFile::Type::eTypeObjectFile)
+ symbol_value -= symbol_section_sp->GetFileAddress();
+
+ if (symbol_section_sp)
{
ModuleSP module_sp(GetModule());
if (module_sp)
@@ -2042,20 +2248,17 @@ ObjectFileELF::ParseSymbols (Symtab *symtab,
if (module_section_list && module_section_list != section_list)
{
const ConstString &sect_name = symbol_section_sp->GetName();
- lldb::SectionSP section_sp (module_section_list->FindSectionByName (sect_name));
- if (section_sp && section_sp->GetFileSize())
- {
- symbol_section_sp = section_sp;
- }
+ auto section_it = section_name_to_section.find(sect_name.GetCString());
+ if (section_it == section_name_to_section.end())
+ section_it = section_name_to_section.emplace(
+ sect_name.GetCString(),
+ module_section_list->FindSectionByName (sect_name)).first;
+ if (section_it->second && section_it->second->GetFileSize())
+ symbol_section_sp = section_it->second;
}
}
}
- // symbol_value_offset may contain 0 for ARM symbols or -1 for
- // THUMB symbols. See above for more details.
- uint64_t symbol_value = symbol.st_value + symbol_value_offset;
- if (symbol_section_sp && CalculateType() != ObjectFile::Type::eTypeObjectFile)
- symbol_value -= symbol_section_sp->GetFileAddress();
bool is_global = symbol.getBinding() == STB_GLOBAL;
uint32_t flags = symbol.st_other << 8 | symbol.st_info | additional_flags;
bool is_mangled = symbol_name ? (symbol_name[0] == '_' && symbol_name[1] == 'Z') : false;
@@ -2069,7 +2272,7 @@ ObjectFileELF::ParseSymbols (Symtab *symtab,
Mangled mangled(ConstString(symbol_bare), is_mangled);
// Now append the suffix back to mangled and unmangled names. Only do it if the
- // demangling was sucessful (string is not empty).
+ // demangling was successful (string is not empty).
if (has_suffix)
{
llvm::StringRef suffix = symbol_ref.substr(version_pos);
@@ -2221,7 +2424,7 @@ ObjectFileELF::PLTRelocationType()
}
// Returns the size of the normal plt entries and the offset of the first normal plt entry. The
-// 0th entry in the plt table is ususally a resolution entry which have different size in some
+// 0th entry in the plt table is usually a resolution entry which have different size in some
// architectures then the rest of the plt entries.
static std::pair<uint64_t, uint64_t>
GetPltEntrySizeAndOffset(const ELFSectionHeader* rel_hdr, const ELFSectionHeader* plt_hdr)
@@ -2237,8 +2440,8 @@ GetPltEntrySizeAndOffset(const ELFSectionHeader* rel_hdr, const ELFSectionHeader
{
// The linker haven't set the plt_hdr->sh_entsize field. Try to guess the size of the plt
// entries based on the number of entries and the size of the plt section with the
- // asumption that the size of the 0th entry is at least as big as the size of the normal
- // entries and it isn't mutch bigger then that.
+ // assumption that the size of the 0th entry is at least as big as the size of the normal
+ // entries and it isn't much bigger then that.
if (plt_hdr->sh_addralign)
plt_entsize = plt_hdr->sh_size / plt_hdr->sh_addralign / (num_relocations + 1) * plt_hdr->sh_addralign;
else
@@ -2563,8 +2766,6 @@ ObjectFileELF::GetSymtab()
uint64_t symbol_id = 0;
lldb_private::Mutex::Locker locker(module_sp->GetMutex());
- m_symtab_ap.reset(new Symtab(this));
-
// Sharable objects and dynamic executables usually have 2 distinct symbol
// tables, one named ".symtab", and the other ".dynsym". The dynsym is a smaller
// version of the symtab that only contains global symbols. The information found
@@ -2578,7 +2779,10 @@ ObjectFileELF::GetSymtab()
symtab = section_list->FindSectionByType (eSectionTypeELFDynamicSymbols, true).get();
}
if (symtab)
+ {
+ m_symtab_ap.reset(new Symtab(symtab->GetObjectFile()));
symbol_id += ParseSymbolTable (m_symtab_ap.get(), symbol_id, symtab);
+ }
// DT_JMPREL
// If present, this entry's d_ptr member holds the address of relocation
@@ -2598,10 +2802,19 @@ ObjectFileELF::GetSymtab()
user_id_t reloc_id = reloc_section->GetID();
const ELFSectionHeaderInfo *reloc_header = GetSectionHeaderByIndex(reloc_id);
assert(reloc_header);
+
+ if (m_symtab_ap == nullptr)
+ m_symtab_ap.reset(new Symtab(reloc_section->GetObjectFile()));
ParseTrampolineSymbols (m_symtab_ap.get(), symbol_id, reloc_header, reloc_id);
}
}
+
+ // 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));
+
m_symtab_ap->CalculateSymbolSizes();
}
@@ -3000,6 +3213,27 @@ ObjectFileELF::GetArchitecture (ArchSpec &arch)
ParseSectionHeaders();
}
+ if (CalculateType() == eTypeCoreFile && m_arch_spec.TripleOSIsUnspecifiedUnknown())
+ {
+ // Core files don't have section headers yet they have PT_NOTE program headers
+ // that might shed more light on the architecture
+ if (ParseProgramHeaders())
+ {
+ for (size_t i = 0, count = GetProgramHeaderCount(); i < count; ++i)
+ {
+ const elf::ELFProgramHeader* header = GetProgramHeaderByIndex(i);
+ if (header && header->p_type == PT_NOTE && header->p_offset != 0 && header->p_filesz > 0)
+ {
+ DataExtractor data;
+ if (data.SetData (m_data, header->p_offset, header->p_filesz) == header->p_filesz)
+ {
+ lldb_private::UUID uuid;
+ RefineModuleDetailsFromNote (data, m_arch_spec, uuid);
+ }
+ }
+ }
+ }
+ }
arch = m_arch_spec;
return true;
}
diff --git a/source/Plugins/ObjectFile/ELF/ObjectFileELF.h b/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
index 99088d166b12..4b97f92c6c5c 100644
--- a/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ b/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -10,9 +10,14 @@
#ifndef liblldb_ObjectFileELF_h_
#define liblldb_ObjectFileELF_h_
+// C Includes
#include <stdint.h>
+
+// C++ Includes
#include <vector>
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -47,6 +52,12 @@ struct ELFNote
/// True if the ELFRel entry was successfully read and false otherwise.
bool
Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset);
+
+ size_t
+ GetByteSize() const
+ {
+ return 12 + llvm::RoundUpToAlignment (n_namesz, 4) + llvm::RoundUpToAlignment (n_descsz, 4);
+ }
};
//------------------------------------------------------------------------------
@@ -59,6 +70,8 @@ class ObjectFileELF :
public lldb_private::ObjectFile
{
public:
+ ~ObjectFileELF() override;
+
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
@@ -113,9 +126,6 @@ public:
//------------------------------------------------------------------
// ObjectFile Protocol.
//------------------------------------------------------------------
- virtual
- ~ObjectFileELF();
-
bool
ParseHeader() override;
@@ -211,6 +221,7 @@ private:
{
lldb_private::ConstString section_name;
};
+
typedef std::vector<ELFSectionHeaderInfo> SectionHeaderColl;
typedef SectionHeaderColl::iterator SectionHeaderCollIter;
typedef SectionHeaderColl::const_iterator SectionHeaderCollConstIter;
@@ -428,4 +439,4 @@ private:
RefineModuleDetailsFromNote (lldb_private::DataExtractor &data, lldb_private::ArchSpec &arch_spec, lldb_private::UUID &uuid);
};
-#endif // #ifndef liblldb_ObjectFileELF_h_
+#endif // liblldb_ObjectFileELF_h_
diff --git a/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h b/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
index 47140f5bcaff..39dbb3fb047b 100644
--- a/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
+++ b/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
@@ -10,10 +10,13 @@
#ifndef liblldb_ObjectFileJIT_h_
#define liblldb_ObjectFileJIT_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#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
@@ -22,6 +25,11 @@ class ObjectFileJIT :
public lldb_private::ObjectFile
{
public:
+ ObjectFileJIT(const lldb::ModuleSP &module_sp,
+ const lldb::ObjectFileJITDelegateSP &delegate_sp);
+
+ ~ObjectFileJIT() override;
+
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
@@ -62,81 +70,77 @@ public:
//------------------------------------------------------------------
// Member Functions
//------------------------------------------------------------------
- ObjectFileJIT (const lldb::ModuleSP &module_sp,
- const lldb::ObjectFileJITDelegateSP &delegate_sp);
-
- virtual
- ~ObjectFileJIT();
-
- virtual bool
- ParseHeader ();
+ bool
+ ParseHeader() override;
- virtual bool
+ bool
SetLoadAddress(lldb_private::Target &target,
lldb::addr_t value,
- bool value_is_offset);
+ bool value_is_offset) override;
- virtual lldb::ByteOrder
- GetByteOrder () const;
+ lldb::ByteOrder
+ GetByteOrder() const override;
- virtual bool
- IsExecutable () const;
+ bool
+ IsExecutable() const override;
- virtual uint32_t
- GetAddressByteSize () const;
+ uint32_t
+ GetAddressByteSize() const override;
- virtual lldb_private::Symtab *
- GetSymtab();
+ lldb_private::Symtab *
+ GetSymtab() override;
- virtual bool
- IsStripped ();
+ bool
+ IsStripped() override;
- virtual void
- CreateSections (lldb_private::SectionList &unified_section_list);
+ void
+ CreateSections(lldb_private::SectionList &unified_section_list) override;
- virtual void
- Dump (lldb_private::Stream *s);
+ void
+ Dump(lldb_private::Stream *s) override;
- virtual bool
- GetArchitecture (lldb_private::ArchSpec &arch);
+ bool
+ GetArchitecture(lldb_private::ArchSpec &arch) override;
- virtual bool
- GetUUID (lldb_private::UUID* uuid);
+ bool
+ GetUUID(lldb_private::UUID* uuid) override;
- virtual uint32_t
- GetDependentModules (lldb_private::FileSpecList& files);
+ uint32_t
+ GetDependentModules(lldb_private::FileSpecList& files) override;
+
+ size_t
+ ReadSectionData(const lldb_private::Section *section,
+ lldb::offset_t section_offset,
+ void *dst,
+ size_t dst_len) const override;
+
+ size_t
+ ReadSectionData(const lldb_private::Section *section,
+ lldb_private::DataExtractor& section_data) const override;
- virtual size_t
- ReadSectionData (const lldb_private::Section *section,
- lldb::offset_t section_offset,
- void *dst,
- size_t dst_len) const;
- virtual size_t
- ReadSectionData (const lldb_private::Section *section,
- lldb_private::DataExtractor& section_data) const;
+ lldb_private::Address
+ GetEntryPointAddress() override;
+ lldb_private::Address
+ GetHeaderAddress() override;
+
+ ObjectFile::Type
+ CalculateType() override;
+
+ ObjectFile::Strata
+ CalculateStrata() override;
+
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
- virtual lldb_private::ConstString
- GetPluginName();
+ lldb_private::ConstString
+ GetPluginName() override;
- virtual uint32_t
- GetPluginVersion();
+ uint32_t
+ GetPluginVersion() override;
- virtual lldb_private::Address
- GetEntryPointAddress ();
-
- virtual lldb_private::Address
- GetHeaderAddress ();
-
- virtual ObjectFile::Type
- CalculateType();
-
- virtual ObjectFile::Strata
- CalculateStrata();
protected:
lldb::ObjectFileJITDelegateWP m_delegate_wp;
};
-#endif // liblldb_ObjectFileJIT_h_
+#endif // liblldb_ObjectFileJIT_h_
diff --git a/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp b/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp
new file mode 100644
index 000000000000..86c574f2776c
--- /dev/null
+++ b/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp
@@ -0,0 +1,559 @@
+//===-- OperatingSystemGo.cpp -----------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C Includes
+// C++ Includes
+#include <unordered_map>
+
+// Other libraries and framework includes
+// Project includes
+#include "OperatingSystemGo.h"
+
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/RegisterValue.h"
+#include "lldb/Core/Section.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Core/ValueObjectVariable.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/OptionValueProperties.h"
+#include "lldb/Interpreter/Options.h"
+#include "lldb/Interpreter/OptionGroupBoolean.h"
+#include "lldb/Interpreter/OptionGroupUInt64.h"
+#include "lldb/Interpreter/Property.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/VariableList.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/StopInfo.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/ThreadList.h"
+#include "lldb/Target/Thread.h"
+#include "Plugins/Process/Utility/DynamicRegisterInfo.h"
+#include "Plugins/Process/Utility/RegisterContextMemory.h"
+#include "Plugins/Process/Utility/ThreadMemory.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+namespace
+{
+
+static PropertyDefinition g_properties[] = {{"enable", OptionValue::eTypeBoolean, true, true, nullptr, nullptr,
+ "Specify whether goroutines should be treated as threads."},
+ {NULL, OptionValue::eTypeInvalid, false, 0, NULL, NULL, NULL}};
+
+enum
+{
+ ePropertyEnableGoroutines,
+};
+
+class PluginProperties : public Properties
+{
+public:
+ PluginProperties()
+ : Properties()
+ {
+ m_collection_sp.reset(new OptionValueProperties(GetSettingName()));
+ m_collection_sp->Initialize(g_properties);
+ }
+
+ ~PluginProperties() override = default;
+
+ static ConstString
+ GetSettingName()
+ {
+ return OperatingSystemGo::GetPluginNameStatic();
+ }
+
+ bool
+ GetEnableGoroutines()
+ {
+ const uint32_t idx = ePropertyEnableGoroutines;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(NULL, idx, g_properties[idx].default_uint_value);
+ }
+
+ bool
+ SetEnableGoroutines(bool enable)
+ {
+ const uint32_t idx = ePropertyEnableGoroutines;
+ return m_collection_sp->SetPropertyAtIndexAsUInt64(NULL, idx, enable);
+ }
+};
+
+typedef std::shared_ptr<PluginProperties> OperatingSystemGoPropertiesSP;
+
+static const OperatingSystemGoPropertiesSP &
+GetGlobalPluginProperties()
+{
+ static OperatingSystemGoPropertiesSP g_settings_sp;
+ if (!g_settings_sp)
+ g_settings_sp.reset(new PluginProperties());
+ return g_settings_sp;
+}
+
+class RegisterContextGo : public RegisterContextMemory
+{
+public:
+ RegisterContextGo(lldb_private::Thread &thread, uint32_t concrete_frame_idx, DynamicRegisterInfo &reg_info,
+ lldb::addr_t reg_data_addr)
+ : RegisterContextMemory(thread, concrete_frame_idx, reg_info, reg_data_addr)
+ {
+ const RegisterInfo *sp = reg_info.GetRegisterInfoAtIndex(
+ reg_info.ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP));
+ const RegisterInfo *pc = reg_info.GetRegisterInfoAtIndex(
+ reg_info.ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC));
+ size_t byte_size = std::max(sp->byte_offset + sp->byte_size, pc->byte_offset + pc->byte_size);
+
+ DataBufferSP reg_data_sp(new DataBufferHeap(byte_size, 0));
+ m_reg_data.SetData(reg_data_sp);
+ }
+
+ ~RegisterContextGo() override = default;
+
+ bool
+ ReadRegister(const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &reg_value) override
+ {
+ switch (reg_info->kinds[eRegisterKindGeneric])
+ {
+ case LLDB_REGNUM_GENERIC_SP:
+ case LLDB_REGNUM_GENERIC_PC:
+ return RegisterContextMemory::ReadRegister(reg_info, reg_value);
+ default:
+ reg_value.SetValueToInvalid();
+ return true;
+ }
+ }
+
+ bool
+ WriteRegister(const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &reg_value) override
+ {
+ switch (reg_info->kinds[eRegisterKindGeneric])
+ {
+ case LLDB_REGNUM_GENERIC_SP:
+ case LLDB_REGNUM_GENERIC_PC:
+ return RegisterContextMemory::WriteRegister(reg_info, reg_value);
+ default:
+ return false;
+ }
+ }
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(RegisterContextGo);
+};
+
+} // anonymous namespace
+
+struct OperatingSystemGo::Goroutine
+{
+ uint64_t m_lostack;
+ uint64_t m_histack;
+ uint64_t m_goid;
+ addr_t m_gobuf;
+ uint32_t m_status;
+};
+
+void
+OperatingSystemGo::Initialize()
+{
+ PluginManager::RegisterPlugin(GetPluginNameStatic(), GetPluginDescriptionStatic(), CreateInstance,
+ DebuggerInitialize);
+}
+
+void
+OperatingSystemGo::DebuggerInitialize(Debugger &debugger)
+{
+ if (!PluginManager::GetSettingForOperatingSystemPlugin(debugger, PluginProperties::GetSettingName()))
+ {
+ const bool is_global_setting = true;
+ PluginManager::CreateSettingForOperatingSystemPlugin(
+ debugger, GetGlobalPluginProperties()->GetValueProperties(),
+ ConstString("Properties for the goroutine thread plug-in."), is_global_setting);
+ }
+}
+
+void
+OperatingSystemGo::Terminate()
+{
+ PluginManager::UnregisterPlugin(CreateInstance);
+}
+
+OperatingSystem *
+OperatingSystemGo::CreateInstance(Process *process, bool force)
+{
+ if (!force)
+ {
+ TargetSP target_sp = process->CalculateTarget();
+ if (!target_sp)
+ return nullptr;
+ ModuleList &module_list = target_sp->GetImages();
+ Mutex::Locker modules_locker(module_list.GetMutex());
+ const size_t num_modules = module_list.GetSize();
+ bool found_go_runtime = false;
+ for (size_t i = 0; i < num_modules; ++i)
+ {
+ Module *module = module_list.GetModulePointerAtIndexUnlocked(i);
+ const SectionList *section_list = module->GetSectionList();
+ if (section_list)
+ {
+ SectionSP section_sp(section_list->FindSectionByType(eSectionTypeGoSymtab, true));
+ if (section_sp)
+ {
+ found_go_runtime = true;
+ break;
+ }
+ }
+ }
+ if (!found_go_runtime)
+ return nullptr;
+ }
+ return new OperatingSystemGo(process);
+}
+
+OperatingSystemGo::OperatingSystemGo(lldb_private::Process *process)
+ : OperatingSystem(process)
+ , m_reginfo(new DynamicRegisterInfo)
+{
+}
+
+OperatingSystemGo::~OperatingSystemGo() = default;
+
+ConstString
+OperatingSystemGo::GetPluginNameStatic()
+{
+ static ConstString g_name("goroutines");
+ return g_name;
+}
+
+const char *
+OperatingSystemGo::GetPluginDescriptionStatic()
+{
+ return "Operating system plug-in that reads runtime data-structures for goroutines.";
+}
+
+bool
+OperatingSystemGo::Init(ThreadList &threads)
+{
+ if (threads.GetSize(false) < 1)
+ return false;
+ TargetSP target_sp = m_process->CalculateTarget();
+ if (!target_sp)
+ return false;
+ m_allg_sp = FindGlobal(target_sp, "runtime.allg");
+ m_allglen_sp = FindGlobal(target_sp, "runtime.allglen");
+
+ if (m_allg_sp && !m_allglen_sp)
+ {
+ StreamSP error_sp = target_sp->GetDebugger().GetAsyncErrorStream();
+ error_sp->Printf("Unsupported Go runtime version detected.");
+ return false;
+ }
+
+ if (!m_allg_sp)
+ return false;
+
+ RegisterContextSP real_registers_sp = threads.GetThreadAtIndex(0, false)->GetRegisterContext();
+
+ std::unordered_map<size_t, ConstString> register_sets;
+ for (size_t set_idx = 0; set_idx < real_registers_sp->GetRegisterSetCount(); ++set_idx)
+ {
+ const RegisterSet *set = real_registers_sp->GetRegisterSet(set_idx);
+ ConstString name(set->name);
+ for (size_t reg_idx = 0; reg_idx < set->num_registers; ++reg_idx)
+ {
+ register_sets[reg_idx] = name;
+ }
+ }
+ TypeSP gobuf_sp = FindType(target_sp, "runtime.gobuf");
+ if (!gobuf_sp)
+ {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OS));
+
+ if (log)
+ log->Printf("OperatingSystemGo unable to find struct Gobuf");
+ return false;
+ }
+ CompilerType gobuf_type(gobuf_sp->GetLayoutCompilerType());
+ for (size_t idx = 0; idx < real_registers_sp->GetRegisterCount(); ++idx)
+ {
+ RegisterInfo reg = *real_registers_sp->GetRegisterInfoAtIndex(idx);
+ int field_index = -1;
+ if (reg.kinds[eRegisterKindGeneric] == LLDB_REGNUM_GENERIC_SP)
+ {
+ field_index = 0;
+ }
+ else if (reg.kinds[eRegisterKindGeneric] == LLDB_REGNUM_GENERIC_PC)
+ {
+ field_index = 1;
+ }
+ if (field_index == -1)
+ {
+ reg.byte_offset = ~0;
+ }
+ else
+ {
+ std::string field_name;
+ uint64_t bit_offset = 0;
+ CompilerType field_type =
+ gobuf_type.GetFieldAtIndex(field_index, field_name, &bit_offset, nullptr, nullptr);
+ reg.byte_size = field_type.GetByteSize(nullptr);
+ reg.byte_offset = bit_offset / 8;
+ }
+ ConstString name(reg.name);
+ ConstString alt_name(reg.alt_name);
+ m_reginfo->AddRegister(reg, name, alt_name, register_sets[idx]);
+ }
+ return true;
+}
+
+//------------------------------------------------------------------
+// PluginInterface protocol
+//------------------------------------------------------------------
+ConstString
+OperatingSystemGo::GetPluginName()
+{
+ return GetPluginNameStatic();
+}
+
+uint32_t
+OperatingSystemGo::GetPluginVersion()
+{
+ return 1;
+}
+
+bool
+OperatingSystemGo::UpdateThreadList(ThreadList &old_thread_list, ThreadList &real_thread_list,
+ ThreadList &new_thread_list)
+{
+ new_thread_list = real_thread_list;
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OS));
+
+ if (!(m_allg_sp || Init(real_thread_list)) || (m_allg_sp && !m_allglen_sp) ||
+ !GetGlobalPluginProperties()->GetEnableGoroutines())
+ {
+ return new_thread_list.GetSize(false) > 0;
+ }
+
+ if (log)
+ log->Printf("OperatingSystemGo::UpdateThreadList(%d, %d, %d) fetching thread data from Go for pid %" PRIu64,
+ old_thread_list.GetSize(false), real_thread_list.GetSize(false), new_thread_list.GetSize(0),
+ m_process->GetID());
+ uint64_t allglen = m_allglen_sp->GetValueAsUnsigned(0);
+ if (allglen == 0)
+ {
+ return new_thread_list.GetSize(false) > 0;
+ }
+ std::vector<Goroutine> goroutines;
+ // The threads that are in "new_thread_list" upon entry are the threads from the
+ // lldb_private::Process subclass, no memory threads will be in this list.
+
+ Error err;
+ for (uint64_t i = 0; i < allglen; ++i)
+ {
+ goroutines.push_back(CreateGoroutineAtIndex(i, err));
+ if (err.Fail())
+ {
+ err.PutToLog(log, "OperatingSystemGo::UpdateThreadList");
+ return new_thread_list.GetSize(false) > 0;
+ }
+ }
+ // Make a map so we can match goroutines with backing threads.
+ std::map<uint64_t, ThreadSP> stack_map;
+ for (uint32_t i = 0; i < real_thread_list.GetSize(false); ++i)
+ {
+ ThreadSP thread = real_thread_list.GetThreadAtIndex(i, false);
+ stack_map[thread->GetRegisterContext()->GetSP()] = thread;
+ }
+ for (const Goroutine &goroutine : goroutines)
+ {
+ if (0 /* Gidle */ == goroutine.m_status || 6 /* Gdead */ == goroutine.m_status)
+ {
+ continue;
+ }
+ ThreadSP memory_thread = old_thread_list.FindThreadByID(goroutine.m_goid, false);
+ if (memory_thread && IsOperatingSystemPluginThread(memory_thread) && memory_thread->IsValid())
+ {
+ memory_thread->ClearBackingThread();
+ }
+ else
+ {
+ memory_thread.reset(new ThreadMemory(*m_process, goroutine.m_goid, nullptr, nullptr, goroutine.m_gobuf));
+ }
+ // Search for the backing thread if the goroutine is running.
+ if (2 == (goroutine.m_status & 0xfff))
+ {
+ auto backing_it = stack_map.lower_bound(goroutine.m_lostack);
+ if (backing_it != stack_map.end())
+ {
+ if (goroutine.m_histack >= backing_it->first)
+ {
+ if (log)
+ log->Printf("OperatingSystemGo::UpdateThreadList found backing thread %" PRIx64 " (%" PRIx64
+ ") for thread %" PRIx64 "",
+ backing_it->second->GetID(), backing_it->second->GetProtocolID(),
+ memory_thread->GetID());
+ memory_thread->SetBackingThread(backing_it->second);
+ new_thread_list.RemoveThreadByID(backing_it->second->GetID(), false);
+ }
+ }
+ }
+ new_thread_list.AddThread(memory_thread);
+ }
+
+ return new_thread_list.GetSize(false) > 0;
+}
+
+void
+OperatingSystemGo::ThreadWasSelected(Thread *thread)
+{
+}
+
+RegisterContextSP
+OperatingSystemGo::CreateRegisterContextForThread(Thread *thread, addr_t reg_data_addr)
+{
+ RegisterContextSP reg_ctx_sp;
+ if (!thread)
+ return reg_ctx_sp;
+
+ if (!IsOperatingSystemPluginThread(thread->shared_from_this()))
+ return reg_ctx_sp;
+
+ reg_ctx_sp.reset(new RegisterContextGo(*thread, 0, *m_reginfo, reg_data_addr));
+ return reg_ctx_sp;
+}
+
+StopInfoSP
+OperatingSystemGo::CreateThreadStopReason(lldb_private::Thread *thread)
+{
+ StopInfoSP stop_info_sp;
+ return stop_info_sp;
+}
+
+lldb::ThreadSP
+OperatingSystemGo::CreateThread(lldb::tid_t tid, addr_t context)
+{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OS));
+
+ if (log)
+ log->Printf("OperatingSystemGo::CreateThread (tid = 0x%" PRIx64 ", context = 0x%" PRIx64 ") not implemented",
+ tid, context);
+
+ return ThreadSP();
+}
+
+ValueObjectSP
+OperatingSystemGo::FindGlobal(TargetSP target, const char *name)
+{
+ VariableList variable_list;
+ const bool append = true;
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OS));
+
+ if (log)
+ {
+ log->Printf("exe: %s", target->GetExecutableModule()->GetSpecificationDescription().c_str());
+ log->Printf("modules: %zu", target->GetImages().GetSize());
+ }
+
+ uint32_t match_count = target->GetImages().FindGlobalVariables(ConstString(name), append, 1, variable_list);
+ if (match_count > 0)
+ {
+ ExecutionContextScope *exe_scope = target->GetProcessSP().get();
+ if (exe_scope == NULL)
+ exe_scope = target.get();
+ return ValueObjectVariable::Create(exe_scope, variable_list.GetVariableAtIndex(0));
+ }
+ return ValueObjectSP();
+}
+
+TypeSP
+OperatingSystemGo::FindType(TargetSP target_sp, const char *name)
+{
+ ConstString const_typename(name);
+ SymbolContext sc;
+ const bool exact_match = false;
+
+ const ModuleList &module_list = target_sp->GetImages();
+ size_t count = module_list.GetSize();
+ for (size_t idx = 0; idx < count; idx++)
+ {
+ ModuleSP module_sp(module_list.GetModuleAtIndex(idx));
+ if (module_sp)
+ {
+ TypeSP type_sp(module_sp->FindFirstType(sc, const_typename, exact_match));
+ if (type_sp)
+ return type_sp;
+ }
+ }
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OS));
+
+ if (log)
+ log->Printf("OperatingSystemGo::FindType(%s): not found", name);
+ return TypeSP();
+}
+
+OperatingSystemGo::Goroutine
+OperatingSystemGo::CreateGoroutineAtIndex(uint64_t idx, Error &err)
+{
+ err.Clear();
+ Goroutine result;
+ ValueObjectSP g = m_allg_sp->GetSyntheticArrayMember(idx, true)->Dereference(err);
+ if (err.Fail())
+ {
+ return result;
+ }
+
+ ConstString name("goid");
+ ValueObjectSP val = g->GetChildMemberWithName(name, true);
+ bool success = false;
+ result.m_goid = val->GetValueAsUnsigned(0, &success);
+ if (!success)
+ {
+ err.SetErrorToGenericError();
+ err.SetErrorString("unable to read goid");
+ return result;
+ }
+ name.SetCString("atomicstatus");
+ val = g->GetChildMemberWithName(name, true);
+ result.m_status = (uint32_t)val->GetValueAsUnsigned(0, &success);
+ if (!success)
+ {
+ err.SetErrorToGenericError();
+ err.SetErrorString("unable to read atomicstatus");
+ return result;
+ }
+ name.SetCString("sched");
+ val = g->GetChildMemberWithName(name, true);
+ result.m_gobuf = val->GetAddressOf(false);
+ name.SetCString("stack");
+ val = g->GetChildMemberWithName(name, true);
+ name.SetCString("lo");
+ ValueObjectSP child = val->GetChildMemberWithName(name, true);
+ result.m_lostack = child->GetValueAsUnsigned(0, &success);
+ if (!success)
+ {
+ err.SetErrorToGenericError();
+ err.SetErrorString("unable to read stack.lo");
+ return result;
+ }
+ name.SetCString("hi");
+ child = val->GetChildMemberWithName(name, true);
+ result.m_histack = child->GetValueAsUnsigned(0, &success);
+ if (!success)
+ {
+ err.SetErrorToGenericError();
+ err.SetErrorString("unable to read stack.hi");
+ return result;
+ }
+ return result;
+}
diff --git a/source/Plugins/OperatingSystem/Go/OperatingSystemGo.h b/source/Plugins/OperatingSystem/Go/OperatingSystemGo.h
new file mode 100644
index 000000000000..d3391d907dfe
--- /dev/null
+++ b/source/Plugins/OperatingSystem/Go/OperatingSystemGo.h
@@ -0,0 +1,87 @@
+//===-- OperatingSystemGo.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_OperatingSystemGo_h_
+#define _liblldb_OperatingSystemGo_h_
+
+// C Includes
+// C++ Includes
+#include <memory>
+
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Target/OperatingSystem.h"
+
+class DynamicRegisterInfo;
+
+class OperatingSystemGo : public lldb_private::OperatingSystem
+{
+public:
+ OperatingSystemGo(lldb_private::Process *process);
+
+ ~OperatingSystemGo() override;
+
+ //------------------------------------------------------------------
+ // Static Functions
+ //------------------------------------------------------------------
+ static lldb_private::OperatingSystem *CreateInstance(lldb_private::Process *process, bool force);
+
+ static void Initialize();
+
+ static void DebuggerInitialize(lldb_private::Debugger &debugger);
+
+ static void Terminate();
+
+ static lldb_private::ConstString GetPluginNameStatic();
+
+ 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;
+
+ void ThreadWasSelected(lldb_private::Thread *thread) override;
+
+ lldb::RegisterContextSP CreateRegisterContextForThread(lldb_private::Thread *thread,
+ lldb::addr_t reg_data_addr) override;
+
+ 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;
+
+private:
+ struct Goroutine;
+
+ static lldb::ValueObjectSP FindGlobal(lldb::TargetSP target, const char *name);
+
+ static lldb::TypeSP FindType(lldb::TargetSP target_sp, const char *name);
+
+ bool Init(lldb_private::ThreadList &threads);
+
+ Goroutine CreateGoroutineAtIndex(uint64_t idx, lldb_private::Error &err);
+
+ std::unique_ptr<DynamicRegisterInfo> m_reginfo;
+ lldb::ValueObjectSP m_allg_sp;
+ lldb::ValueObjectSP m_allglen_sp;
+};
+
+#endif // liblldb_OperatingSystemGo_h_
diff --git a/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp b/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
index e744d13deec1..a556b0e84e83 100644
--- a/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
+++ b/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
@@ -24,7 +24,6 @@
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
-#include "lldb/Symbol/ClangNamespaceDecl.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/Process.h"
@@ -43,9 +42,7 @@ using namespace lldb_private;
void
OperatingSystemPython::Initialize()
{
- PluginManager::RegisterPlugin (GetPluginNameStatic(),
- GetPluginDescriptionStatic(),
- CreateInstance);
+ PluginManager::RegisterPlugin(GetPluginNameStatic(), GetPluginDescriptionStatic(), CreateInstance, nullptr);
}
void
diff --git a/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h b/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
index e29bf8054f6c..1b33c42cf0fe 100644
--- a/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
+++ b/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
@@ -1,4 +1,4 @@
-//===-- OperatingSystemPython.h ---------------------------*- C++ -*-===//
+//===-- OperatingSystemPython.h ---------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -6,14 +6,16 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_DISABLE_PYTHON
#ifndef liblldb_OperatingSystemPython_h_
#define liblldb_OperatingSystemPython_h_
+#ifndef LLDB_DISABLE_PYTHON
+
// C Includes
// C++ Includes
// Other libraries and framework includes
+// Project includes
#include "lldb/Core/StructuredData.h"
#include "lldb/Target/OperatingSystem.h"
@@ -27,6 +29,11 @@ class ScriptInterpreter;
class OperatingSystemPython : public lldb_private::OperatingSystem
{
public:
+ OperatingSystemPython(lldb_private::Process *process,
+ const lldb_private::FileSpec &python_module_path);
+
+ ~OperatingSystemPython() override;
+
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
@@ -46,49 +53,39 @@ public:
GetPluginDescriptionStatic();
//------------------------------------------------------------------
- // Class Methods
- //------------------------------------------------------------------
- OperatingSystemPython (lldb_private::Process *process,
- const lldb_private::FileSpec &python_module_path);
-
- virtual
- ~OperatingSystemPython ();
-
- //------------------------------------------------------------------
// lldb_private::PluginInterface Methods
//------------------------------------------------------------------
- virtual lldb_private::ConstString
- GetPluginName();
+ lldb_private::ConstString
+ GetPluginName() override;
- virtual uint32_t
- GetPluginVersion();
+ uint32_t
+ GetPluginVersion() override;
//------------------------------------------------------------------
// lldb_private::OperatingSystem Methods
//------------------------------------------------------------------
- virtual bool
- UpdateThreadList (lldb_private::ThreadList &old_thread_list,
- lldb_private::ThreadList &real_thread_list,
- lldb_private::ThreadList &new_thread_list);
+ bool
+ UpdateThreadList(lldb_private::ThreadList &old_thread_list,
+ lldb_private::ThreadList &real_thread_list,
+ lldb_private::ThreadList &new_thread_list) override;
- virtual void
- ThreadWasSelected (lldb_private::Thread *thread);
+ void
+ ThreadWasSelected(lldb_private::Thread *thread) override;
- virtual lldb::RegisterContextSP
- CreateRegisterContextForThread (lldb_private::Thread *thread,
- lldb::addr_t reg_data_addr);
+ lldb::RegisterContextSP
+ CreateRegisterContextForThread(lldb_private::Thread *thread,
+ lldb::addr_t reg_data_addr) override;
- virtual lldb::StopInfoSP
- CreateThreadStopReason (lldb_private::Thread *thread);
+ lldb::StopInfoSP
+ CreateThreadStopReason(lldb_private::Thread *thread) override;
//------------------------------------------------------------------
// Method for lazy creation of threads on demand
//------------------------------------------------------------------
- virtual lldb::ThreadSP
- CreateThread (lldb::tid_t tid, lldb::addr_t context);
+ lldb::ThreadSP
+ CreateThread(lldb::tid_t tid, lldb::addr_t context) override;
protected:
-
bool IsValid() const
{
return m_python_object_sp && m_python_object_sp->IsValid();
@@ -107,5 +104,6 @@ protected:
lldb_private::StructuredData::ObjectSP m_python_object_sp;
};
-#endif // #ifndef liblldb_OperatingSystemPython_h_
-#endif // #ifndef LLDB_DISABLE_PYTHON
+#endif // LLDB_DISABLE_PYTHON
+
+#endif // liblldb_OperatingSystemPython_h_
diff --git a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
index 67156e6ae37b..d1bfc438a341 100644
--- a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
+++ b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
@@ -22,6 +22,9 @@ namespace platform_freebsd {
class PlatformFreeBSD : public Platform
{
public:
+ PlatformFreeBSD(bool is_host);
+
+ ~PlatformFreeBSD() override;
//------------------------------------------------------------
// Class functions
@@ -42,14 +45,6 @@ namespace platform_freebsd {
GetDescriptionStatic (bool is_host);
//------------------------------------------------------------
- // Class Methods
- //------------------------------------------------------------
- PlatformFreeBSD (bool is_host);
-
- virtual
- ~PlatformFreeBSD();
-
- //------------------------------------------------------------
// lldb_private::PluginInterface functions
//------------------------------------------------------------
ConstString
@@ -179,4 +174,4 @@ namespace platform_freebsd {
} // namespace platform_freebsd
} // namespace lldb_private
-#endif // liblldb_PlatformFreeBSD_h_
+#endif // liblldb_PlatformFreeBSD_h_
diff --git a/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp b/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
new file mode 100644
index 000000000000..2979d1e438b7
--- /dev/null
+++ b/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
@@ -0,0 +1,685 @@
+//===-- PlatformNetBSD.cpp -------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "PlatformNetBSD.h"
+#include "lldb/Host/Config.h"
+
+// C Includes
+#include <stdio.h>
+#ifndef LLDB_DISABLE_POSIX
+#include <sys/utsname.h>
+#endif
+
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Breakpoint/BreakpointLocation.h"
+#include "lldb/Breakpoint/BreakpointSite.h"
+#include "lldb/Core/Error.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/Process.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::platform_netbsd;
+
+PlatformSP
+PlatformNetBSD::CreateInstance(bool force, const ArchSpec *arch)
+{
+ // The only time we create an instance is when we are creating a remote
+ // netbsd platform
+ const bool is_host = false;
+
+ bool create = force;
+ if (create == false && arch && arch->IsValid())
+ {
+ const llvm::Triple &triple = arch->GetTriple();
+ switch (triple.getOS())
+ {
+ case llvm::Triple::NetBSD:
+ create = true;
+ break;
+
+ default:
+ break;
+ }
+ }
+ if (create)
+ return PlatformSP(new PlatformNetBSD (is_host));
+ return PlatformSP();
+
+}
+
+ConstString
+PlatformNetBSD::GetPluginNameStatic(bool is_host)
+{
+ if (is_host)
+ {
+ static ConstString g_host_name(Platform::GetHostPlatformName ());
+ return g_host_name;
+ }
+ else
+ {
+ static ConstString g_remote_name("remote-netbsd");
+ return g_remote_name;
+ }
+}
+
+const char *
+PlatformNetBSD::GetDescriptionStatic (bool is_host)
+{
+ if (is_host)
+ return "Local NetBSD user platform plug-in.";
+ else
+ return "Remote NetBSD user platform plug-in.";
+}
+
+static uint32_t g_initialize_count = 0;
+
+void
+PlatformNetBSD::Initialize ()
+{
+ Platform::Initialize ();
+
+ if (g_initialize_count++ == 0)
+ {
+#if defined(__NetBSD__)
+ // Force a host flag to true for the default platform object.
+ PlatformSP default_platform_sp (new PlatformNetBSD(true));
+ default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
+ Platform::SetHostPlatform (default_platform_sp);
+#endif
+ PluginManager::RegisterPlugin(PlatformNetBSD::GetPluginNameStatic(false),
+ PlatformNetBSD::GetDescriptionStatic(false),
+ PlatformNetBSD::CreateInstance);
+ }
+}
+
+void
+PlatformNetBSD::Terminate ()
+{
+ if (g_initialize_count > 0 && --g_initialize_count == 0)
+ PluginManager::UnregisterPlugin (PlatformNetBSD::CreateInstance);
+
+ Platform::Terminate ();
+}
+
+bool
+PlatformNetBSD::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);
+}
+
+Error
+PlatformNetBSD::RunShellCommand(const char *command,
+ const FileSpec &working_dir,
+ int *status_ptr,
+ int *signo_ptr,
+ std::string *command_output,
+ uint32_t timeout_sec)
+{
+ if (IsHost())
+ return Host::RunShellCommand(command, working_dir, status_ptr, signo_ptr, command_output, timeout_sec);
+ else
+ {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->RunShellCommand(command, working_dir, status_ptr, signo_ptr, command_output, timeout_sec);
+ else
+ return Error("unable to run a remote command without a platform");
+ }
+}
+
+Error
+PlatformNetBSD::ResolveExecutable (const ModuleSpec &module_spec,
+ lldb::ModuleSP &exe_module_sp,
+ const FileSpecList *module_search_paths_ptr)
+{
+ Error error;
+ // Nothing special to do here, just use the actual file and architecture
+
+ char exe_path[PATH_MAX];
+ ModuleSpec resolved_module_spec(module_spec);
+
+ if (IsHost())
+ {
+ // If we have "ls" as the module_spec's file, resolve the executable location based on
+ // the current path variables
+ if (!resolved_module_spec.GetFileSpec().Exists())
+ {
+ module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
+ resolved_module_spec.GetFileSpec().SetFile(exe_path, true);
+ }
+
+ if (!resolved_module_spec.GetFileSpec().Exists())
+ resolved_module_spec.GetFileSpec().ResolveExecutableLocation ();
+
+ if (resolved_module_spec.GetFileSpec().Exists())
+ error.Clear();
+ else
+ {
+ error.SetErrorStringWithFormat("unable to find executable for '%s'", resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+ }
+ else
+ {
+ if (m_remote_platform_sp)
+ {
+ error = GetCachedExecutable (resolved_module_spec, exe_module_sp, module_search_paths_ptr, *m_remote_platform_sp);
+ }
+ else
+ {
+ // We may connect to a process and use the provided executable (Don't use local $PATH).
+
+ // Resolve any executable within a bundle on MacOSX
+ Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec());
+
+ if (resolved_module_spec.GetFileSpec().Exists())
+ {
+ error.Clear();
+ }
+ else
+ {
+ error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+ }
+ }
+
+ if (error.Success())
+ {
+ if (resolved_module_spec.GetArchitecture().IsValid())
+ {
+ error = ModuleList::GetSharedModule (resolved_module_spec,
+ exe_module_sp,
+ module_search_paths_ptr,
+ NULL,
+ NULL);
+
+ if (!exe_module_sp || exe_module_sp->GetObjectFile() == NULL)
+ {
+ exe_module_sp.reset();
+ error.SetErrorStringWithFormat ("'%s' doesn't contain the architecture %s",
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ resolved_module_spec.GetArchitecture().GetArchitectureName());
+ }
+ }
+ else
+ {
+ // No valid architecture was specified, ask the platform for
+ // the architectures that we should be using (in the correct order)
+ // and see if we can find a match that way
+ StreamString arch_names;
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, resolved_module_spec.GetArchitecture()); ++idx)
+ {
+ error = ModuleList::GetSharedModule (resolved_module_spec,
+ exe_module_sp,
+ module_search_paths_ptr,
+ NULL,
+ NULL);
+ // Did we find an executable using one of the
+ if (error.Success())
+ {
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ break;
+ else
+ error.SetErrorToGenericError();
+ }
+
+ if (idx > 0)
+ arch_names.PutCString (", ");
+ arch_names.PutCString (resolved_module_spec.GetArchitecture().GetArchitectureName());
+ }
+
+ if (error.Fail() || !exe_module_sp)
+ {
+ if (resolved_module_spec.GetFileSpec().Readable())
+ {
+ error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ GetPluginName().GetCString(),
+ arch_names.GetString().c_str());
+ }
+ else
+ {
+ error.SetErrorStringWithFormat("'%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+ }
+ }
+ }
+
+ return error;
+}
+
+// From PlatformMacOSX only
+Error
+PlatformNetBSD::GetFileWithUUID (const FileSpec &platform_file,
+ const UUID *uuid_ptr,
+ FileSpec &local_file)
+{
+ if (IsRemote())
+ {
+ if (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 Error();
+}
+
+
+//------------------------------------------------------------------
+/// Default Constructor
+//------------------------------------------------------------------
+PlatformNetBSD::PlatformNetBSD (bool is_host) :
+ Platform(is_host),
+ m_remote_platform_sp()
+{
+}
+
+bool
+PlatformNetBSD::GetRemoteOSVersion ()
+{
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetOSVersion (m_major_os_version,
+ m_minor_os_version,
+ m_update_os_version);
+ return false;
+}
+
+bool
+PlatformNetBSD::GetRemoteOSBuildString (std::string &s)
+{
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteOSBuildString (s);
+ s.clear();
+ return false;
+}
+
+bool
+PlatformNetBSD::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
+PlatformNetBSD::GetRemoteSystemArchitecture ()
+{
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteSystemArchitecture ();
+ return ArchSpec();
+}
+
+
+const char *
+PlatformNetBSD::GetHostname ()
+{
+ if (IsHost())
+ return Platform::GetHostname();
+
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetHostname ();
+ return NULL;
+}
+
+bool
+PlatformNetBSD::IsConnected () const
+{
+ if (IsHost())
+ return true;
+ else if (m_remote_platform_sp)
+ return m_remote_platform_sp->IsConnected();
+ return false;
+}
+
+Error
+PlatformNetBSD::ConnectRemote (Args& args)
+{
+ Error error;
+ if (IsHost())
+ {
+ error.SetErrorStringWithFormat ("can't connect to the host platform '%s', always connected", GetPluginName().GetCString());
+ }
+ else
+ {
+ if (!m_remote_platform_sp)
+ m_remote_platform_sp = Platform::Create (ConstString("remote-gdb-server"), error);
+
+ if (m_remote_platform_sp)
+ {
+ if (error.Success())
+ {
+ if (m_remote_platform_sp)
+ {
+ error = m_remote_platform_sp->ConnectRemote (args);
+ }
+ else
+ {
+ error.SetErrorString ("\"platform connect\" takes a single argument: <connect-url>");
+ }
+ }
+ }
+ else
+ error.SetErrorString ("failed to create a 'remote-gdb-server' platform");
+
+ if (error.Fail())
+ m_remote_platform_sp.reset();
+ }
+
+ return error;
+}
+
+Error
+PlatformNetBSD::DisconnectRemote ()
+{
+ Error error;
+
+ if (IsHost())
+ {
+ error.SetErrorStringWithFormat ("can't disconnect from the host platform '%s', always connected", GetPluginName().GetCString());
+ }
+ else
+ {
+ if (m_remote_platform_sp)
+ error = m_remote_platform_sp->DisconnectRemote ();
+ else
+ error.SetErrorString ("the platform is not currently connected");
+ }
+ return error;
+}
+
+bool
+PlatformNetBSD::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
+{
+ bool success = false;
+ if (IsHost())
+ {
+ success = Platform::GetProcessInfo (pid, process_info);
+ }
+ else if (m_remote_platform_sp)
+ {
+ success = m_remote_platform_sp->GetProcessInfo (pid, process_info);
+ }
+ return success;
+}
+
+uint32_t
+PlatformNetBSD::FindProcesses (const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos)
+{
+ uint32_t match_count = 0;
+ if (IsHost())
+ {
+ // Let the base class figure out the host details
+ match_count = Platform::FindProcesses (match_info, process_infos);
+ }
+ else
+ {
+ // If we are remote, we can only return results if we are connected
+ if (m_remote_platform_sp)
+ match_count = m_remote_platform_sp->FindProcesses (match_info, process_infos);
+ }
+ return match_count;
+}
+
+const char *
+PlatformNetBSD::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 *
+PlatformNetBSD::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;
+}
+
+
+Error
+PlatformNetBSD::GetSharedModule (const ModuleSpec &module_spec,
+ Process* process,
+ ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr,
+ ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr)
+{
+ Error error;
+ module_sp.reset();
+
+ if (IsRemote())
+ {
+ // If we have a remote platform always, let it try and locate
+ // the shared module first.
+ if (m_remote_platform_sp)
+ {
+ error = m_remote_platform_sp->GetSharedModule (module_spec,
+ process,
+ module_sp,
+ module_search_paths_ptr,
+ old_module_sp_ptr,
+ did_create_ptr);
+ }
+ }
+
+ if (!module_sp)
+ {
+ // Fall back to the local platform and find the file locally
+ error = Platform::GetSharedModule (module_spec,
+ process,
+ module_sp,
+ module_search_paths_ptr,
+ old_module_sp_ptr,
+ did_create_ptr);
+ }
+ if (module_sp)
+ module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
+ return error;
+}
+
+
+bool
+PlatformNetBSD::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
+{
+ if (IsHost())
+ {
+ ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
+ if (hostArch.GetTriple().isOSNetBSD())
+ {
+ if (idx == 0)
+ {
+ arch = hostArch;
+ return arch.IsValid();
+ }
+ else if (idx == 1)
+ {
+ // If the default host architecture is 64-bit, look for a 32-bit variant
+ if (hostArch.IsValid() && hostArch.GetTriple().isArch64Bit())
+ {
+ arch = HostInfo::GetArchitecture(HostInfo::eArchKind32);
+ return arch.IsValid();
+ }
+ }
+ }
+ }
+ else
+ {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetSupportedArchitectureAtIndex(idx, arch);
+
+ llvm::Triple triple;
+ // Set the OS to NetBSD
+ triple.setOS(llvm::Triple::NetBSD);
+ // Set the architecture
+ switch (idx)
+ {
+ case 0: triple.setArchName("x86_64"); break;
+ case 1: triple.setArchName("i386"); break;
+ default: return false;
+ }
+ // Leave the vendor as "llvm::Triple:UnknownVendor" and don't specify the vendor by
+ // calling triple.SetVendorName("unknown") so that it is a "unspecified unknown".
+ // This means when someone calls triple.GetVendorName() it will return an empty string
+ // which indicates that the vendor can be set when two architectures are merged
+
+ // Now set the triple into "arch" and return true
+ arch.SetTriple(triple);
+ return true;
+ }
+ return false;
+}
+
+void
+PlatformNetBSD::GetStatus (Stream &strm)
+{
+#ifndef LLDB_DISABLE_POSIX
+ struct ::utsname un;
+
+ strm << " Host: ";
+
+ ::memset(&un, 0, sizeof(utsname));
+ if (::uname(&un) == -1) {
+ strm << "NetBSD" << '\n';
+ } else {
+ strm << un.sysname << ' ' << un.release;
+ if (un.nodename[0] != '\0')
+ strm << " (" << un.nodename << ')';
+ strm << '\n';
+
+ // Dump a common information about the platform status.
+ strm << "Host: " << un.sysname << ' ' << un.release << ' ' << un.version << '\n';
+ }
+#endif
+
+ Platform::GetStatus(strm);
+}
+
+size_t
+PlatformNetBSD::GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site)
+{
+ ArchSpec arch = target.GetArchitecture();
+ const uint8_t *trap_opcode = NULL;
+ size_t trap_opcode_size = 0;
+
+ switch (arch.GetMachine())
+ {
+ default:
+ assert(false && "Unhandled architecture in PlatformNetBSD::GetSoftwareBreakpointTrapOpcode()");
+ break;
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
+ {
+ static const uint8_t g_i386_opcode[] = { 0xCC };
+ trap_opcode = g_i386_opcode;
+ trap_opcode_size = sizeof(g_i386_opcode);
+ }
+ break;
+ }
+
+ if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size))
+ return trap_opcode_size;
+ return 0;
+}
+
+
+void
+PlatformNetBSD::CalculateTrapHandlerSymbolNames ()
+{
+ m_trap_handlers.push_back (ConstString ("_sigtramp"));
+}
+
+Error
+PlatformNetBSD::LaunchProcess (ProcessLaunchInfo &launch_info)
+{
+ Error 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::ProcessSP
+PlatformNetBSD::Attach(ProcessAttachInfo &attach_info,
+ Debugger &debugger,
+ Target *target,
+ Error &error)
+{
+ lldb::ProcessSP process_sp;
+ if (IsHost())
+ {
+ if (target == NULL)
+ {
+ TargetSP new_target_sp;
+ ArchSpec emptyArchSpec;
+
+ error = debugger.GetTargetList().CreateTarget (debugger,
+ NULL,
+ emptyArchSpec,
+ false,
+ m_remote_platform_sp,
+ new_target_sp);
+ target = new_target_sp.get();
+ }
+ else
+ error.Clear();
+
+ if (target && error.Success())
+ {
+ debugger.GetTargetList().SetSelectedTarget(target);
+ // The netbsd always currently uses the GDB remote debugger plug-in
+ // so even when debugging locally we are debugging remotely!
+ // Just like the darwin plugin.
+ process_sp = target->CreateProcess (attach_info.GetListenerForProcess(debugger), "gdb-remote", NULL);
+
+ if (process_sp)
+ error = process_sp->Attach (attach_info);
+ }
+ }
+ else
+ {
+ if (m_remote_platform_sp)
+ process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, error);
+ else
+ error.SetErrorString ("the platform is not currently connected");
+ }
+ return process_sp;
+}
diff --git a/source/Plugins/Platform/NetBSD/PlatformNetBSD.h b/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
new file mode 100644
index 000000000000..b0187be99b05
--- /dev/null
+++ b/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
@@ -0,0 +1,177 @@
+//===-- PlatformNetBSD.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_PlatformNetBSD_h_
+#define liblldb_PlatformNetBSD_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Target/Platform.h"
+
+namespace lldb_private {
+namespace platform_netbsd {
+
+ class PlatformNetBSD : public Platform
+ {
+ public:
+ PlatformNetBSD (bool is_host);
+
+ ~PlatformNetBSD() override = default;
+
+ //------------------------------------------------------------
+ // Class functions
+ //------------------------------------------------------------
+ static lldb::PlatformSP
+ CreateInstance(bool force, const ArchSpec *arch);
+
+ static void
+ Initialize ();
+
+ static void
+ Terminate ();
+
+ static ConstString
+ GetPluginNameStatic (bool is_host);
+
+ static const char *
+ GetDescriptionStatic (bool is_host);
+
+ //------------------------------------------------------------
+ // lldb_private::PluginInterface functions
+ //------------------------------------------------------------
+ ConstString
+ GetPluginName() override
+ {
+ return GetPluginNameStatic (IsHost());
+ }
+
+ uint32_t
+ GetPluginVersion() override
+ {
+ return 1;
+ }
+
+ const char *
+ GetDescription () override
+ {
+ return GetDescriptionStatic(IsHost());
+ }
+
+ //------------------------------------------------------------
+ // lldb_private::Platform functions
+ //------------------------------------------------------------
+ bool
+ GetModuleSpec(const FileSpec& module_file_spec,
+ const ArchSpec& arch,
+ ModuleSpec &module_spec) override;
+
+ Error
+ RunShellCommand(const char *command,
+ const FileSpec &working_dir,
+ int *status_ptr,
+ int *signo_ptr,
+ std::string *command_output,
+ uint32_t timeout_sec) override;
+
+ Error
+ ResolveExecutable(const ModuleSpec &module_spec,
+ lldb::ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr) override;
+
+ size_t
+ GetSoftwareBreakpointTrapOpcode(Target &target,
+ BreakpointSite *bp_site) override;
+
+ bool
+ GetRemoteOSVersion () override;
+
+ bool
+ GetRemoteOSBuildString (std::string &s) override;
+
+ bool
+ GetRemoteOSKernelDescription (std::string &s) override;
+
+ // Remote Platform subclasses need to override this function
+ ArchSpec
+ GetRemoteSystemArchitecture() override;
+
+ bool
+ IsConnected () const override;
+
+ Error
+ ConnectRemote(Args& args) override;
+
+ Error
+ DisconnectRemote() override;
+
+ const char *
+ GetHostname () override;
+
+ const char *
+ GetUserName (uint32_t uid) override;
+
+ const char *
+ GetGroupName (uint32_t gid) override;
+
+ bool
+ GetProcessInfo(lldb::pid_t pid,
+ ProcessInstanceInfo &proc_info) override;
+
+ uint32_t
+ FindProcesses(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) override;
+
+ Error
+ LaunchProcess(ProcessLaunchInfo &launch_info) override;
+
+ lldb::ProcessSP
+ Attach(ProcessAttachInfo &attach_info,
+ Debugger &debugger,
+ Target *target,
+ Error &error) override;
+
+ // NetBSD processes can not be launched by spawning and attaching.
+ bool
+ CanDebugProcess () override { return false; }
+
+ // Only on PlatformMacOSX:
+ Error
+ GetFileWithUUID(const FileSpec &platform_file,
+ const UUID* uuid, FileSpec &local_file) override;
+
+ Error
+ GetSharedModule(const ModuleSpec &module_spec,
+ Process* process,
+ lldb::ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr,
+ lldb::ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr) override;
+
+ bool
+ GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override;
+
+ void
+ GetStatus(Stream &strm) override;
+
+ void
+ CalculateTrapHandlerSymbolNames () override;
+
+ protected:
+ lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a remote netbsd OS
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN (PlatformNetBSD);
+ };
+
+} // namespace platform_netbsd
+} // namespace lldb_private
+
+#endif // liblldb_PlatformNetBSD_h_
diff --git a/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index b4f841a16dec..c7564655a11b 100644
--- a/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -19,13 +19,18 @@
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamString.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Expression/UserExpression.h"
#include "lldb/Host/File.h"
#include "lldb/Host/FileCache.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.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"
using namespace lldb;
using namespace lldb_private;
@@ -673,9 +678,12 @@ PlatformPOSIX::ConnectRemote (Args& args)
if (m_options.get())
{
OptionGroupOptions* options = m_options.get();
- const OptionGroupPlatformRSync* m_rsync_options = (OptionGroupPlatformRSync*)options->GetGroupWithOption('r');
- const OptionGroupPlatformSSH* m_ssh_options = (OptionGroupPlatformSSH*)options->GetGroupWithOption('s');
- const OptionGroupPlatformCaching* m_cache_options = (OptionGroupPlatformCaching*)options->GetGroupWithOption('c');
+ const OptionGroupPlatformRSync *m_rsync_options =
+ static_cast<const OptionGroupPlatformRSync *>(options->GetGroupWithOption('r'));
+ const OptionGroupPlatformSSH *m_ssh_options =
+ static_cast<const OptionGroupPlatformSSH *>(options->GetGroupWithOption('s'));
+ const OptionGroupPlatformCaching *m_cache_options =
+ static_cast<const OptionGroupPlatformCaching *>(options->GetGroupWithOption('c'));
if (m_rsync_options->m_rsync)
{
@@ -843,6 +851,175 @@ PlatformPOSIX::DebugProcess (ProcessLaunchInfo &launch_info,
void
PlatformPOSIX::CalculateTrapHandlerSymbolNames ()
-{
+{
m_trap_handlers.push_back (ConstString ("_sigtramp"));
+}
+
+Error
+PlatformPOSIX::EvaluateLibdlExpression(lldb_private::Process* process,
+ const char* expr_cstr,
+ const char* expr_prefix,
+ lldb::ValueObjectSP& result_valobj_sp)
+{
+ DynamicLoader *loader = process->GetDynamicLoader();
+ if (loader)
+ {
+ Error error = loader->CanLoadImage();
+ if (error.Fail())
+ return error;
+ }
+
+ ThreadSP thread_sp(process->GetThreadList().GetSelectedThread());
+ if (!thread_sp)
+ return Error("Selected thread isn't valid");
+
+ StackFrameSP frame_sp(thread_sp->GetStackFrameAtIndex(0));
+ if (!frame_sp)
+ return Error("Frame 0 isn't valid");
+
+ ExecutionContext exe_ctx;
+ frame_sp->CalculateExecutionContext(exe_ctx);
+ EvaluateExpressionOptions expr_options;
+ expr_options.SetUnwindOnError(true);
+ expr_options.SetIgnoreBreakpoints(true);
+ expr_options.SetExecutionPolicy(eExecutionPolicyAlways);
+ expr_options.SetLanguage(eLanguageTypeC_plus_plus);
+
+ Error expr_error;
+ UserExpression::Evaluate(exe_ctx,
+ expr_options,
+ expr_cstr,
+ expr_prefix,
+ result_valobj_sp,
+ expr_error);
+ if (result_valobj_sp->GetError().Fail())
+ return result_valobj_sp->GetError();
+ return Error();
+}
+
+uint32_t
+PlatformPOSIX::DoLoadImage(lldb_private::Process* process,
+ const lldb_private::FileSpec& remote_file,
+ lldb_private::Error& error)
+{
+ char path[PATH_MAX];
+ remote_file.GetPath(path, sizeof(path));
+
+ StreamString expr;
+ expr.Printf(R"(
+ struct __lldb_dlopen_result { void *image_ptr; const char *error_str; } the_result;
+ the_result.image_ptr = dlopen ("%s", 2);
+ if (the_result.image_ptr == (void *) 0x0)
+ {
+ the_result.error_str = dlerror();
+ }
+ else
+ {
+ the_result.error_str = (const char *) 0x0;
+ }
+ the_result;
+ )",
+ path);
+ const char *prefix = GetLibdlFunctionDeclarations();
+ lldb::ValueObjectSP result_valobj_sp;
+ error = EvaluateLibdlExpression(process, expr.GetData(), prefix, result_valobj_sp);
+ if (error.Fail())
+ return LLDB_INVALID_IMAGE_TOKEN;
+
+ error = result_valobj_sp->GetError();
+ if (error.Fail())
+ return LLDB_INVALID_IMAGE_TOKEN;
+
+ Scalar scalar;
+ ValueObjectSP image_ptr_sp = result_valobj_sp->GetChildAtIndex(0, true);
+ if (!image_ptr_sp || !image_ptr_sp->ResolveValue(scalar))
+ {
+ error.SetErrorStringWithFormat("unable to load '%s'", path);
+ return LLDB_INVALID_IMAGE_TOKEN;
+ }
+
+ addr_t image_ptr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
+ if (image_ptr != 0 && image_ptr != LLDB_INVALID_ADDRESS)
+ return process->AddImageToken(image_ptr);
+
+ if (image_ptr == 0)
+ {
+ ValueObjectSP error_str_sp = result_valobj_sp->GetChildAtIndex(1, true);
+ if (error_str_sp && error_str_sp->IsCStringContainer(true))
+ {
+ DataBufferSP buffer_sp(new DataBufferHeap(10240,0));
+ size_t num_chars = error_str_sp->ReadPointedString (buffer_sp, error, 10240).first;
+ if (error.Success() && num_chars > 0)
+ error.SetErrorStringWithFormat("dlopen error: %s", buffer_sp->GetBytes());
+ else
+ error.SetErrorStringWithFormat("dlopen failed for unknown reasons.");
+ return LLDB_INVALID_IMAGE_TOKEN;
+ }
+ }
+ error.SetErrorStringWithFormat("unable to load '%s'", path);
+ return LLDB_INVALID_IMAGE_TOKEN;
+}
+
+Error
+PlatformPOSIX::UnloadImage (lldb_private::Process* process, uint32_t image_token)
+{
+ const addr_t image_addr = process->GetImagePtrFromToken(image_token);
+ if (image_addr == LLDB_INVALID_ADDRESS)
+ return Error("Invalid image token");
+
+ StreamString expr;
+ expr.Printf("dlclose((void *)0x%" PRIx64 ")", image_addr);
+ const char *prefix = GetLibdlFunctionDeclarations();
+ lldb::ValueObjectSP result_valobj_sp;
+ Error error = EvaluateLibdlExpression(process, expr.GetData(), prefix, result_valobj_sp);
+ if (error.Fail())
+ return error;
+
+ if (result_valobj_sp->GetError().Fail())
+ return result_valobj_sp->GetError();
+
+ Scalar scalar;
+ if (result_valobj_sp->ResolveValue(scalar))
+ {
+ if (scalar.UInt(1))
+ return Error("expression failed: \"%s\"", expr.GetData());
+ process->ResetImageToken(image_token);
+ }
+ return Error();
}
+
+lldb::ProcessSP
+PlatformPOSIX::ConnectProcess (const char* connect_url,
+ const char* plugin_name,
+ lldb_private::Debugger &debugger,
+ lldb_private::Target *target,
+ lldb_private::Error &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);
+}
+
+const char*
+PlatformPOSIX::GetLibdlFunctionDeclarations() const
+{
+ return R"(
+ extern "C" void* dlopen(const char*, int);
+ extern "C" void* dlsym(void*, const char*);
+ extern "C" int dlclose(void*);
+ extern "C" char* dlerror(void);
+ )";
+}
+
+size_t
+PlatformPOSIX::ConnectToWaitingProcesses(Debugger& debugger, Error& error)
+{
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->ConnectToWaitingProcesses(debugger, error);
+ return Platform::ConnectToWaitingProcesses(debugger, error);
+}
diff --git a/source/Plugins/Platform/POSIX/PlatformPOSIX.h b/source/Plugins/Platform/POSIX/PlatformPOSIX.h
index 82686dcef6b0..60f6207d140b 100644
--- a/source/Plugins/Platform/POSIX/PlatformPOSIX.h
+++ b/source/Plugins/Platform/POSIX/PlatformPOSIX.h
@@ -12,7 +12,6 @@
// C Includes
// C++ Includes
-
#include <memory>
// Other libraries and framework includes
@@ -23,11 +22,10 @@
class PlatformPOSIX : public lldb_private::Platform
{
public:
- PlatformPOSIX (bool is_host);
-
- virtual
- ~PlatformPOSIX();
-
+ PlatformPOSIX(bool is_host);
+
+ ~PlatformPOSIX() override;
+
//------------------------------------------------------------
// lldb_private::Platform functions
//------------------------------------------------------------
@@ -37,9 +35,8 @@ public:
const lldb_private::ArchSpec& arch,
lldb_private::ModuleSpec &module_spec) override;
- lldb_private::OptionGroupOptions
- *GetConnectionOptions(
- lldb_private::CommandInterpreter &interpreter) override;
+ lldb_private::OptionGroupOptions*
+ GetConnectionOptions(lldb_private::CommandInterpreter &interpreter) override;
const char *
GetHostname () override;
@@ -119,11 +116,11 @@ public:
IsConnected () const override;
lldb_private::Error
- RunShellCommand(const char *command, // Shouldn't be NULL
+ 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 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
+ int *status_ptr, // Pass nullptr if you don't want the process exit status
+ int *signo_ptr, // Pass nullptr if you don't want the signal that caused the process to exit
+ std::string *command_output, // Pass nullptr if you don't want the command output
uint32_t timeout_sec) override; // Timeout in seconds to wait for shell program to finish
lldb_private::Error
@@ -150,13 +147,13 @@ public:
lldb::ProcessSP
Attach (lldb_private::ProcessAttachInfo &attach_info,
lldb_private::Debugger &debugger,
- lldb_private::Target *target, // Can be NULL, if NULL create a new target, else use existing one
+ lldb_private::Target *target, // Can be nullptr, if nullptr create a new target, else use existing one
lldb_private::Error &error) override;
lldb::ProcessSP
DebugProcess (lldb_private::ProcessLaunchInfo &launch_info,
lldb_private::Debugger &debugger,
- lldb_private::Target *target, // Can be NULL, if NULL create a new target, else use existing one
+ lldb_private::Target *target, // Can be nullptr, if nullptr create a new target, else use existing one
lldb_private::Error &error) override;
std::string
@@ -176,14 +173,39 @@ public:
lldb_private::Error
DisconnectRemote () override;
+ uint32_t
+ DoLoadImage (lldb_private::Process* process,
+ const lldb_private::FileSpec& remote_file,
+ lldb_private::Error& error) override;
+
+ lldb_private::Error
+ UnloadImage (lldb_private::Process* process, uint32_t image_token) override;
+
+ lldb::ProcessSP
+ ConnectProcess (const char* connect_url,
+ const char* plugin_name,
+ lldb_private::Debugger &debugger,
+ lldb_private::Target *target,
+ lldb_private::Error &error) override;
+
+ size_t
+ ConnectToWaitingProcesses(lldb_private::Debugger& debugger, lldb_private::Error& error) override;
+
protected:
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::Error
+ EvaluateLibdlExpression(lldb_private::Process* process,
+ const char *expr_cstr,
+ const char *expr_prefix,
+ lldb::ValueObjectSP& result_valobj_sp);
+
+ virtual const char*
+ GetLibdlFunctionDeclarations() const;
+
private:
DISALLOW_COPY_AND_ASSIGN (PlatformPOSIX);
-
};
-#endif // liblldb_PlatformPOSIX_h_
+#endif // liblldb_PlatformPOSIX_h_
diff --git a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index b0e75d4f3457..f16ea017676f 100644
--- a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -21,6 +21,7 @@
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/StreamFile.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/FileSpec.h"
@@ -40,23 +41,6 @@ using namespace lldb_private::platform_gdb_server;
static bool g_initialized = false;
-static std::string MakeGdbServerUrl(
- const std::string &platform_scheme,
- const std::string &platform_hostname,
- uint16_t port)
-{
- const char *override_scheme = getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_SCHEME");
- const char *override_hostname = getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_HOSTNAME");
- const char *port_offset_c_str = getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_PORT_OFFSET");
- int port_offset = port_offset_c_str ? ::atoi(port_offset_c_str) : 0;
- StreamString result;
- result.Printf("%s://%s:%u",
- override_scheme ? override_scheme : platform_scheme.c_str(),
- override_hostname ? override_hostname : platform_hostname.c_str(),
- port + port_offset);
- return result.GetString();
-}
-
void
PlatformRemoteGDBServer::Initialize ()
{
@@ -590,9 +574,8 @@ PlatformRemoteGDBServer::DebugProcess (ProcessLaunchInfo &launch_info,
if (IsConnected())
{
lldb::pid_t debugserver_pid = LLDB_INVALID_PROCESS_ID;
- uint16_t port = LaunchGDBserverAndGetPort(debugserver_pid);
-
- if (port == 0)
+ std::string connect_url;
+ if (!LaunchGDBServer(debugserver_pid, connect_url))
{
error.SetErrorStringWithFormat ("unable to launch a GDB server on '%s'", GetHostname ());
}
@@ -623,8 +606,6 @@ PlatformRemoteGDBServer::DebugProcess (ProcessLaunchInfo &launch_info,
if (process_sp)
{
- std::string connect_url =
- MakeGdbServerUrl(m_platform_scheme, m_platform_hostname, port);
error = process_sp->ConnectRemote (nullptr, connect_url.c_str());
// Retry the connect remote one time...
if (error.Fail())
@@ -649,23 +630,36 @@ PlatformRemoteGDBServer::DebugProcess (ProcessLaunchInfo &launch_info,
}
-uint16_t
-PlatformRemoteGDBServer::LaunchGDBserverAndGetPort (lldb::pid_t &pid)
+bool
+PlatformRemoteGDBServer::LaunchGDBServer (lldb::pid_t &pid, std::string &connect_url)
{
ArchSpec remote_arch = GetRemoteSystemArchitecture ();
llvm::Triple &remote_triple = remote_arch.GetTriple ();
+
+ uint16_t port = 0;
+ std::string socket_name;
+ bool launch_result = false;
if (remote_triple.getVendor () == llvm::Triple::Apple && remote_triple.getOS () == llvm::Triple::IOS)
{
// When remote debugging to iOS, we use a USB mux that always talks
// to localhost, so we will need the remote debugserver to accept connections
// only from localhost, no matter what our current hostname is
- return m_gdb_client.LaunchGDBserverAndGetPort (pid, "127.0.0.1");
+ launch_result = m_gdb_client.LaunchGDBServer ("127.0.0.1", pid, port, socket_name);
}
else
{
// All other hosts should use their actual hostname
- return m_gdb_client.LaunchGDBserverAndGetPort (pid, NULL);
+ launch_result = m_gdb_client.LaunchGDBServer (nullptr, pid, port, socket_name);
}
+
+ if (!launch_result)
+ return false;
+
+ connect_url = MakeGdbServerUrl(m_platform_scheme,
+ m_platform_hostname,
+ port,
+ (socket_name.empty()) ? nullptr : socket_name.c_str());
+ return true;
}
bool
@@ -686,9 +680,8 @@ PlatformRemoteGDBServer::Attach (ProcessAttachInfo &attach_info,
if (IsConnected())
{
lldb::pid_t debugserver_pid = LLDB_INVALID_PROCESS_ID;
- uint16_t port = LaunchGDBserverAndGetPort(debugserver_pid);
-
- if (port == 0)
+ std::string connect_url;
+ if (!LaunchGDBServer(debugserver_pid, connect_url))
{
error.SetErrorStringWithFormat ("unable to launch a GDB server on '%s'", GetHostname ());
}
@@ -716,11 +709,8 @@ PlatformRemoteGDBServer::Attach (ProcessAttachInfo &attach_info,
// 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);
-
if (process_sp)
{
- std::string connect_url =
- MakeGdbServerUrl(m_platform_scheme, m_platform_hostname, port);
error = process_sp->ConnectRemote(nullptr, connect_url.c_str());
if (error.Success())
{
@@ -931,13 +921,8 @@ PlatformRemoteGDBServer::GetRemoteUnixSignals()
return false;
// We can live without short_name, description, etc.
- std::string short_name{""};
- auto object_sp = dict->GetValueForKey("short_name");
- if (object_sp && object_sp->IsValid())
- short_name = object_sp->GetStringValue();
-
bool suppress{false};
- object_sp = dict->GetValueForKey("suppress");
+ auto object_sp = dict->GetValueForKey("suppress");
if (object_sp && object_sp->IsValid())
suppress = object_sp->GetBooleanValue();
@@ -958,7 +943,6 @@ PlatformRemoteGDBServer::GetRemoteUnixSignals()
remote_signals_sp->AddSignal(signo,
name.c_str(),
- short_name.c_str(),
suppress, stop, notify,
description.c_str());
return true;
@@ -969,3 +953,66 @@ PlatformRemoteGDBServer::GetRemoteUnixSignals()
return m_remote_signals_sp;
}
+
+std::string
+PlatformRemoteGDBServer::MakeGdbServerUrl(const std::string &platform_scheme,
+ const std::string &platform_hostname,
+ uint16_t port,
+ const char* socket_name)
+{
+ const char *override_scheme = getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_SCHEME");
+ const char *override_hostname = getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_HOSTNAME");
+ const char *port_offset_c_str = getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_PORT_OFFSET");
+ int port_offset = port_offset_c_str ? ::atoi(port_offset_c_str) : 0;
+
+ return MakeUrl(override_scheme ? override_scheme : platform_scheme.c_str(),
+ override_hostname ? override_hostname : platform_hostname.c_str(),
+ port + port_offset,
+ socket_name);
+}
+
+std::string
+PlatformRemoteGDBServer::MakeUrl(const char* scheme,
+ const char* hostname,
+ uint16_t port,
+ const char* path)
+{
+ StreamString result;
+ result.Printf("%s://%s", scheme, hostname);
+ if (port != 0)
+ result.Printf(":%u", port);
+ if (path)
+ result.Write(path, strlen(path));
+ return result.GetString();
+}
+
+lldb::ProcessSP
+PlatformRemoteGDBServer::ConnectProcess(const char* connect_url,
+ const char* plugin_name,
+ lldb_private::Debugger &debugger,
+ lldb_private::Target *target,
+ lldb_private::Error &error)
+{
+ if (!IsRemote() || !IsConnected())
+ {
+ error.SetErrorString("Not connected to remote gdb server");
+ return nullptr;
+ }
+ return Platform::ConnectProcess(connect_url, plugin_name, debugger, target, error);
+}
+
+size_t
+PlatformRemoteGDBServer::GetPendingGdbServerList(std::vector<std::string>& connection_urls)
+{
+ std::vector<std::pair<uint16_t, std::string>> remote_servers;
+ m_gdb_client.QueryGDBServer(remote_servers);
+ for (const auto& gdbserver : remote_servers)
+ {
+ const char* socket_name_cstr = gdbserver.second.empty() ? nullptr : gdbserver.second.c_str();
+ connection_urls.emplace_back(MakeGdbServerUrl(m_platform_scheme,
+ m_platform_hostname,
+ gdbserver.first,
+ socket_name_cstr));
+ }
+ return connection_urls.size();
+}
diff --git a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
index 0bf013fdfb68..61136f1185e6 100644
--- a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
+++ b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
@@ -217,6 +217,16 @@ public:
const lldb::UnixSignalsSP &
GetRemoteUnixSignals() override;
+ lldb::ProcessSP
+ ConnectProcess (const char* connect_url,
+ const char* plugin_name,
+ lldb_private::Debugger &debugger,
+ lldb_private::Target *target,
+ lldb_private::Error &error) override;
+
+ virtual size_t
+ GetPendingGdbServerList(std::vector<std::string>& connection_urls);
+
protected:
process_gdb_remote::GDBRemoteCommunicationClient m_gdb_client;
std::string m_platform_description; // After we connect we can get a more complete description of what we are connected to
@@ -225,16 +235,29 @@ protected:
lldb::UnixSignalsSP m_remote_signals_sp;
- // Launch the lldb-gdbserver on the remote host and return the port it is listening on or 0 on
- // failure. Subclasses should override this method if they want to do extra actions before or
- // after launching the lldb-gdbserver.
- virtual uint16_t
- LaunchGDBserverAndGetPort (lldb::pid_t &pid);
+ // Launch the debug server on the remote host - caller connects to launched
+ // debug server using connect_url.
+ // Subclasses should override this method if they want to do extra actions before or
+ // after launching the debug server.
+ virtual bool
+ LaunchGDBServer (lldb::pid_t &pid, std::string &connect_url);
virtual bool
KillSpawnedProcess (lldb::pid_t pid);
+ virtual std::string
+ MakeUrl(const char* scheme,
+ const char* hostname,
+ uint16_t port,
+ const char* path);
+
private:
+ std::string
+ MakeGdbServerUrl(const std::string &platform_scheme,
+ const std::string &platform_hostname,
+ uint16_t port,
+ const char* socket_name);
+
DISALLOW_COPY_AND_ASSIGN (PlatformRemoteGDBServer);
};
diff --git a/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp b/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp
index 5e46c836beac..2b292442399f 100644
--- a/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp
+++ b/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp
@@ -8,33 +8,288 @@
//===----------------------------------------------------------------------===//
// C Includes
+#include <errno.h>
+
// C++ Includes
// Other libraries and framework includes
#include "lldb/Core/State.h"
#include "lldb/Target/UnixSignals.h"
// Project includes
+#include "lldb/Breakpoint/Watchpoint.h"
+#include "lldb/Breakpoint/BreakpointLocation.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/State.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Host/HostNativeThread.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/StopInfo.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/ThreadSpec.h"
+#include "llvm/ADT/SmallString.h"
+#include "POSIXStopInfo.h"
#include "FreeBSDThread.h"
#include "ProcessFreeBSD.h"
#include "ProcessPOSIXLog.h"
+#include "ProcessMonitor.h"
+#include "RegisterContextPOSIXProcessMonitor_arm.h"
+#include "RegisterContextPOSIXProcessMonitor_arm64.h"
+#include "RegisterContextPOSIXProcessMonitor_mips64.h"
+#include "RegisterContextPOSIXProcessMonitor_powerpc.h"
+#include "RegisterContextPOSIXProcessMonitor_x86.h"
+#include "Plugins/Process/Utility/RegisterContextFreeBSD_arm.h"
+#include "Plugins/Process/Utility/RegisterContextFreeBSD_arm64.h"
+#include "Plugins/Process/Utility/RegisterContextFreeBSD_i386.h"
+#include "Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h"
+#include "Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h"
+#include "Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h"
+#include "Plugins/Process/Utility/UnwindLLDB.h"
using namespace lldb;
using namespace lldb_private;
-//------------------------------------------------------------------------------
-// Constructors and destructors.
-
FreeBSDThread::FreeBSDThread(Process &process, lldb::tid_t tid)
- : POSIXThread(process, tid)
+ : Thread(process, tid),
+ m_frame_ap (),
+ m_breakpoint (),
+ m_thread_name_valid (false),
+ m_thread_name (),
+ m_posix_thread(NULL)
{
+ Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
+ if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
+ log->Printf ("FreeBSDThread::%s (tid = %" PRIi64 ")", __FUNCTION__, tid);
+
+ // Set the current watchpoints for this thread.
+ Target &target = GetProcess()->GetTarget();
+ const WatchpointList &wp_list = target.GetWatchpointList();
+ size_t wp_size = wp_list.GetSize();
+
+ for (uint32_t wp_idx = 0; wp_idx < wp_size; wp_idx++)
+ {
+ lldb::WatchpointSP wp = wp_list.GetByIndex(wp_idx);
+ if (wp.get() && wp->IsEnabled())
+ {
+ // This watchpoint as been enabled; obviously this "new" thread
+ // has been created since that watchpoint was enabled. Since
+ // the POSIXBreakpointProtocol has yet to be initialized, its
+ // m_watchpoints_initialized member will be FALSE. Attempting to
+ // read the debug status register to determine if a watchpoint
+ // has been hit would result in the zeroing of that register.
+ // Since the active debug registers would have been cloned when
+ // this thread was created, simply force the m_watchpoints_initized
+ // member to TRUE and avoid resetting dr6 and dr7.
+ GetPOSIXBreakpointProtocol()->ForceWatchpointsInitialized();
+ }
+ }
}
FreeBSDThread::~FreeBSDThread()
{
+ DestroyThread();
+}
+
+ProcessMonitor &
+FreeBSDThread::GetMonitor()
+{
+ ProcessSP base = GetProcess();
+ ProcessFreeBSD &process = static_cast<ProcessFreeBSD&>(*base);
+ return process.GetMonitor();
+}
+
+void
+FreeBSDThread::RefreshStateAfterStop()
+{
+ // Invalidate all registers in our register context. We don't set "force" to
+ // true because the stop reply packet might have had some register values
+ // that were expedited and these will already be copied into the register
+ // context by the time this function gets called. The KDPRegisterContext
+ // class has been made smart enough to detect when it needs to invalidate
+ // which registers are valid by putting hooks in the register read and
+ // register supply functions where they check the process stop ID and do
+ // the right thing.
+ //if (StateIsStoppedState(GetState())
+ {
+ const bool force = false;
+ GetRegisterContext()->InvalidateIfNeeded (force);
+ }
}
-//------------------------------------------------------------------------------
-// ProcessInterface protocol.
+const char *
+FreeBSDThread::GetInfo()
+{
+ return NULL;
+}
+
+void
+FreeBSDThread::SetName (const char *name)
+{
+ m_thread_name_valid = (name && name[0]);
+ if (m_thread_name_valid)
+ m_thread_name.assign (name);
+ else
+ m_thread_name.clear();
+}
+
+const char *
+FreeBSDThread::GetName ()
+{
+ if (!m_thread_name_valid)
+ {
+ llvm::SmallString<32> thread_name;
+ HostNativeThread::GetName(GetID(), thread_name);
+ m_thread_name = thread_name.c_str();
+ m_thread_name_valid = true;
+ }
+
+ if (m_thread_name.empty())
+ return NULL;
+ return m_thread_name.c_str();
+}
+
+lldb::RegisterContextSP
+FreeBSDThread::GetRegisterContext()
+{
+ if (!m_reg_context_sp)
+ {
+ m_posix_thread = NULL;
+
+ RegisterInfoInterface *reg_interface = NULL;
+ const ArchSpec &target_arch = GetProcess()->GetTarget().GetArchitecture();
+
+ assert(target_arch.GetTriple().getOS() == llvm::Triple::FreeBSD);
+ switch (target_arch.GetMachine())
+ {
+ case llvm::Triple::aarch64:
+ reg_interface = new RegisterContextFreeBSD_arm64(target_arch);
+ break;
+ case llvm::Triple::arm:
+ reg_interface = new RegisterContextFreeBSD_arm(target_arch);
+ break;
+ case llvm::Triple::ppc:
+#ifndef __powerpc64__
+ reg_interface = new RegisterContextFreeBSD_powerpc32(target_arch);
+ break;
+#endif
+ case llvm::Triple::ppc64:
+ reg_interface = new RegisterContextFreeBSD_powerpc64(target_arch);
+ break;
+ case llvm::Triple::mips64:
+ reg_interface = new RegisterContextFreeBSD_mips64(target_arch);
+ break;
+ case llvm::Triple::x86:
+ reg_interface = new RegisterContextFreeBSD_i386(target_arch);
+ break;
+ case llvm::Triple::x86_64:
+ reg_interface = new RegisterContextFreeBSD_x86_64(target_arch);
+ break;
+ default:
+ llvm_unreachable("CPU not supported");
+ }
+
+ switch (target_arch.GetMachine())
+ {
+ case llvm::Triple::aarch64:
+ {
+ RegisterContextPOSIXProcessMonitor_arm64 *reg_ctx = new RegisterContextPOSIXProcessMonitor_arm64(*this, 0, reg_interface);
+ m_posix_thread = reg_ctx;
+ m_reg_context_sp.reset(reg_ctx);
+ break;
+ }
+ case llvm::Triple::arm:
+ {
+ RegisterContextPOSIXProcessMonitor_arm *reg_ctx = new RegisterContextPOSIXProcessMonitor_arm(*this, 0, reg_interface);
+ m_posix_thread = reg_ctx;
+ m_reg_context_sp.reset(reg_ctx);
+ break;
+ }
+ case llvm::Triple::mips64:
+ {
+ RegisterContextPOSIXProcessMonitor_mips64 *reg_ctx = new RegisterContextPOSIXProcessMonitor_mips64(*this, 0, reg_interface);
+ m_posix_thread = reg_ctx;
+ m_reg_context_sp.reset(reg_ctx);
+ break;
+ }
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
+ {
+ RegisterContextPOSIXProcessMonitor_powerpc *reg_ctx = new RegisterContextPOSIXProcessMonitor_powerpc(*this, 0, reg_interface);
+ m_posix_thread = reg_ctx;
+ m_reg_context_sp.reset(reg_ctx);
+ break;
+ }
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
+ {
+ RegisterContextPOSIXProcessMonitor_x86_64 *reg_ctx = new RegisterContextPOSIXProcessMonitor_x86_64(*this, 0, reg_interface);
+ m_posix_thread = reg_ctx;
+ m_reg_context_sp.reset(reg_ctx);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ return m_reg_context_sp;
+}
+
+lldb::RegisterContextSP
+FreeBSDThread::CreateRegisterContextForFrame(lldb_private::StackFrame *frame)
+{
+ lldb::RegisterContextSP reg_ctx_sp;
+ uint32_t concrete_frame_idx = 0;
+
+ Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
+ if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
+ log->Printf ("FreeBSDThread::%s ()", __FUNCTION__);
+
+ if (frame)
+ concrete_frame_idx = frame->GetConcreteFrameIndex();
+
+ if (concrete_frame_idx == 0)
+ reg_ctx_sp = GetRegisterContext();
+ else
+ {
+ assert(GetUnwinder());
+ reg_ctx_sp = GetUnwinder()->CreateRegisterContextForFrame(frame);
+ }
+
+ return reg_ctx_sp;
+}
+
+lldb::addr_t
+FreeBSDThread::GetThreadPointer ()
+{
+ ProcessMonitor &monitor = GetMonitor();
+ addr_t addr;
+ if (monitor.ReadThreadPointer (GetID(), addr))
+ return addr;
+ else
+ return LLDB_INVALID_ADDRESS;
+}
+
+bool
+FreeBSDThread::CalculateStopInfo()
+{
+ SetStopInfo (m_stop_info_sp);
+ return true;
+}
+
+Unwind *
+FreeBSDThread::GetUnwinder()
+{
+ if (m_unwinder_ap.get() == NULL)
+ m_unwinder_ap.reset(new UnwindLLDB(*this));
+
+ return m_unwinder_ap.get();
+}
+
+void
+FreeBSDThread::DidStop()
+{
+ // Don't set the thread state to stopped unless we really stopped.
+}
void
FreeBSDThread::WillResume(lldb::StateType resume_state)
@@ -68,3 +323,359 @@ FreeBSDThread::WillResume(lldb::StateType resume_state)
break;
}
}
+
+bool
+FreeBSDThread::Resume()
+{
+ lldb::StateType resume_state = GetResumeState();
+ ProcessMonitor &monitor = GetMonitor();
+ bool status;
+
+ Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
+ if (log)
+ log->Printf ("FreeBSDThread::%s (), resume_state = %s", __FUNCTION__,
+ StateAsCString(resume_state));
+
+ switch (resume_state)
+ {
+ default:
+ assert(false && "Unexpected state for resume!");
+ status = false;
+ break;
+
+ case lldb::eStateRunning:
+ SetState(resume_state);
+ status = monitor.Resume(GetID(), GetResumeSignal());
+ break;
+
+ case lldb::eStateStepping:
+ SetState(resume_state);
+ status = monitor.SingleStep(GetID(), GetResumeSignal());
+ break;
+ case lldb::eStateStopped:
+ case lldb::eStateSuspended:
+ status = true;
+ break;
+ }
+
+ return status;
+}
+
+void
+FreeBSDThread::Notify(const ProcessMessage &message)
+{
+ Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
+ if (log)
+ log->Printf ("FreeBSDThread::%s () message kind = '%s' for tid %" PRIu64,
+ __FUNCTION__, message.PrintKind(), GetID());
+
+ switch (message.GetKind())
+ {
+ default:
+ assert(false && "Unexpected message kind!");
+ break;
+
+ case ProcessMessage::eExitMessage:
+ // Nothing to be done.
+ break;
+
+ case ProcessMessage::eLimboMessage:
+ LimboNotify(message);
+ break;
+
+ case ProcessMessage::eSignalMessage:
+ SignalNotify(message);
+ break;
+
+ case ProcessMessage::eSignalDeliveredMessage:
+ SignalDeliveredNotify(message);
+ break;
+
+ case ProcessMessage::eTraceMessage:
+ TraceNotify(message);
+ break;
+
+ case ProcessMessage::eBreakpointMessage:
+ BreakNotify(message);
+ break;
+
+ case ProcessMessage::eWatchpointMessage:
+ WatchNotify(message);
+ break;
+
+ case ProcessMessage::eCrashMessage:
+ CrashNotify(message);
+ break;
+
+ case ProcessMessage::eExecMessage:
+ ExecNotify(message);
+ break;
+ }
+}
+
+bool
+FreeBSDThread::EnableHardwareWatchpoint(Watchpoint *wp)
+{
+ bool wp_set = false;
+ if (wp)
+ {
+ addr_t wp_addr = wp->GetLoadAddress();
+ size_t wp_size = wp->GetByteSize();
+ bool wp_read = wp->WatchpointRead();
+ bool wp_write = wp->WatchpointWrite();
+ uint32_t wp_hw_index = wp->GetHardwareIndex();
+ POSIXBreakpointProtocol* reg_ctx = GetPOSIXBreakpointProtocol();
+ if (reg_ctx)
+ wp_set = reg_ctx->SetHardwareWatchpointWithIndex(wp_addr, wp_size,
+ wp_read, wp_write,
+ wp_hw_index);
+ }
+ return wp_set;
+}
+
+bool
+FreeBSDThread::DisableHardwareWatchpoint(Watchpoint *wp)
+{
+ bool result = false;
+ if (wp)
+ {
+ lldb::RegisterContextSP reg_ctx_sp = GetRegisterContext();
+ if (reg_ctx_sp.get())
+ result = reg_ctx_sp->ClearHardwareWatchpoint(wp->GetHardwareIndex());
+ }
+ return result;
+}
+
+uint32_t
+FreeBSDThread::NumSupportedHardwareWatchpoints()
+{
+ lldb::RegisterContextSP reg_ctx_sp = GetRegisterContext();
+ if (reg_ctx_sp.get())
+ return reg_ctx_sp->NumSupportedHardwareWatchpoints();
+ return 0;
+}
+
+uint32_t
+FreeBSDThread::FindVacantWatchpointIndex()
+{
+ uint32_t hw_index = LLDB_INVALID_INDEX32;
+ uint32_t num_hw_wps = NumSupportedHardwareWatchpoints();
+ uint32_t wp_idx;
+ POSIXBreakpointProtocol* reg_ctx = GetPOSIXBreakpointProtocol();
+ if (reg_ctx)
+ {
+ for (wp_idx = 0; wp_idx < num_hw_wps; wp_idx++)
+ {
+ if (reg_ctx->IsWatchpointVacant(wp_idx))
+ {
+ hw_index = wp_idx;
+ break;
+ }
+ }
+ }
+ return hw_index;
+}
+
+void
+FreeBSDThread::BreakNotify(const ProcessMessage &message)
+{
+ bool status;
+ Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
+
+ assert(GetRegisterContext());
+ status = GetPOSIXBreakpointProtocol()->UpdateAfterBreakpoint();
+ assert(status && "Breakpoint update failed!");
+
+ // With our register state restored, resolve the breakpoint object
+ // corresponding to our current PC.
+ assert(GetRegisterContext());
+ lldb::addr_t pc = GetRegisterContext()->GetPC();
+ if (log)
+ log->Printf ("FreeBSDThread::%s () PC=0x%8.8" PRIx64, __FUNCTION__, pc);
+ lldb::BreakpointSiteSP bp_site(GetProcess()->GetBreakpointSiteList().FindByAddress(pc));
+
+ // If the breakpoint is for this thread, then we'll report the hit, but if it is for another thread,
+ // we create a stop reason with should_stop=false. If there is no breakpoint location, then report
+ // an invalid stop reason. We don't need to worry about stepping over the breakpoint here, that will
+ // be taken care of when the thread resumes and notices that there's a breakpoint under the pc.
+ if (bp_site)
+ {
+ lldb::break_id_t bp_id = bp_site->GetID();
+ // If we have an operating system plug-in, we might have set a thread specific breakpoint using the
+ // operating system thread ID, so we can't make any assumptions about the thread ID so we must always
+ // report the breakpoint regardless of the thread.
+ if (bp_site->ValidForThisThread(this) || GetProcess()->GetOperatingSystem () != NULL)
+ SetStopInfo (StopInfo::CreateStopReasonWithBreakpointSiteID(*this, bp_id));
+ else
+ {
+ const bool should_stop = false;
+ SetStopInfo (StopInfo::CreateStopReasonWithBreakpointSiteID(*this, bp_id, should_stop));
+ }
+ }
+ else
+ SetStopInfo(StopInfoSP());
+}
+
+void
+FreeBSDThread::WatchNotify(const ProcessMessage &message)
+{
+ Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
+
+ lldb::addr_t halt_addr = message.GetHWAddress();
+ if (log)
+ log->Printf ("FreeBSDThread::%s () Hardware Watchpoint Address = 0x%8.8"
+ PRIx64, __FUNCTION__, halt_addr);
+
+ POSIXBreakpointProtocol* reg_ctx = GetPOSIXBreakpointProtocol();
+ if (reg_ctx)
+ {
+ uint32_t num_hw_wps = reg_ctx->NumSupportedHardwareWatchpoints();
+ uint32_t wp_idx;
+ for (wp_idx = 0; wp_idx < num_hw_wps; wp_idx++)
+ {
+ if (reg_ctx->IsWatchpointHit(wp_idx))
+ {
+ // Clear the watchpoint hit here
+ reg_ctx->ClearWatchpointHits();
+ break;
+ }
+ }
+
+ if (wp_idx == num_hw_wps)
+ return;
+
+ Target &target = GetProcess()->GetTarget();
+ lldb::addr_t wp_monitor_addr = reg_ctx->GetWatchpointAddress(wp_idx);
+ const WatchpointList &wp_list = target.GetWatchpointList();
+ lldb::WatchpointSP wp_sp = wp_list.FindByAddress(wp_monitor_addr);
+
+ assert(wp_sp.get() && "No watchpoint found");
+ SetStopInfo (StopInfo::CreateStopReasonWithWatchpointID(*this,
+ wp_sp->GetID()));
+ }
+}
+
+void
+FreeBSDThread::TraceNotify(const ProcessMessage &message)
+{
+ POSIXBreakpointProtocol* reg_ctx = GetPOSIXBreakpointProtocol();
+ if (reg_ctx)
+ {
+ uint32_t num_hw_wps = reg_ctx->NumSupportedHardwareWatchpoints();
+ uint32_t wp_idx;
+ for (wp_idx = 0; wp_idx < num_hw_wps; wp_idx++)
+ {
+ if (reg_ctx->IsWatchpointHit(wp_idx))
+ {
+ WatchNotify(message);
+ return;
+ }
+ }
+ }
+
+ SetStopInfo (StopInfo::CreateStopReasonToTrace(*this));
+}
+
+void
+FreeBSDThread::LimboNotify(const ProcessMessage &message)
+{
+ SetStopInfo (lldb::StopInfoSP(new POSIXLimboStopInfo(*this)));
+}
+
+void
+FreeBSDThread::SignalNotify(const ProcessMessage &message)
+{
+ int signo = message.GetSignal();
+ SetStopInfo (StopInfo::CreateStopReasonWithSignal(*this, signo));
+}
+
+void
+FreeBSDThread::SignalDeliveredNotify(const ProcessMessage &message)
+{
+ int signo = message.GetSignal();
+ SetStopInfo (StopInfo::CreateStopReasonWithSignal(*this, signo));
+}
+
+void
+FreeBSDThread::CrashNotify(const ProcessMessage &message)
+{
+ // FIXME: Update stop reason as per bugzilla 14598
+ int signo = message.GetSignal();
+
+ assert(message.GetKind() == ProcessMessage::eCrashMessage);
+
+ Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
+ if (log)
+ log->Printf ("FreeBSDThread::%s () signo = %i, reason = '%s'",
+ __FUNCTION__, signo, message.PrintCrashReason());
+
+ SetStopInfo (lldb::StopInfoSP(new POSIXCrashStopInfo(*this, signo,
+ message.GetCrashReason(),
+ message.GetFaultAddress())));
+}
+
+unsigned
+FreeBSDThread::GetRegisterIndexFromOffset(unsigned offset)
+{
+ unsigned reg = LLDB_INVALID_REGNUM;
+ ArchSpec arch = HostInfo::GetArchitecture();
+
+ switch (arch.GetMachine())
+ {
+ default:
+ llvm_unreachable("CPU type not supported!");
+ break;
+
+ case llvm::Triple::aarch64:
+ case llvm::Triple::arm:
+ case llvm::Triple::mips64:
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
+ {
+ POSIXBreakpointProtocol* reg_ctx = GetPOSIXBreakpointProtocol();
+ reg = reg_ctx->GetRegisterIndexFromOffset(offset);
+ }
+ break;
+ }
+ return reg;
+}
+
+void
+FreeBSDThread::ExecNotify(const ProcessMessage &message)
+{
+ SetStopInfo (StopInfo::CreateStopReasonWithExec(*this));
+}
+
+const char *
+FreeBSDThread::GetRegisterName(unsigned reg)
+{
+ const char * name = nullptr;
+ ArchSpec arch = HostInfo::GetArchitecture();
+
+ switch (arch.GetMachine())
+ {
+ default:
+ assert(false && "CPU type not supported!");
+ break;
+
+ case llvm::Triple::aarch64:
+ case llvm::Triple::arm:
+ case llvm::Triple::mips64:
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
+ name = GetRegisterContext()->GetRegisterName(reg);
+ break;
+ }
+ return name;
+}
+
+const char *
+FreeBSDThread::GetRegisterNameFromOffset(unsigned offset)
+{
+ return GetRegisterName(GetRegisterIndexFromOffset(offset));
+}
+
diff --git a/source/Plugins/Process/FreeBSD/FreeBSDThread.h b/source/Plugins/Process/FreeBSD/FreeBSDThread.h
index 8741075cb60b..90c11dbefcb0 100644
--- a/source/Plugins/Process/FreeBSD/FreeBSDThread.h
+++ b/source/Plugins/Process/FreeBSD/FreeBSDThread.h
@@ -10,14 +10,23 @@
#ifndef liblldb_FreeBSDThread_H_
#define liblldb_FreeBSDThread_H_
+// C++ Includes
+#include <memory>
+#include <string>
+
// Other libraries and framework includes
-#include "POSIXThread.h"
+#include "lldb/Target/Thread.h"
+#include "RegisterContextPOSIX.h"
+
+class ProcessMessage;
+class ProcessMonitor;
+class POSIXBreakpointProtocol;
//------------------------------------------------------------------------------
// @class FreeBSDThread
// @brief Abstraction of a FreeBSD thread.
class FreeBSDThread
- : public POSIXThread
+ : public lldb_private::Thread
{
public:
@@ -28,12 +37,106 @@ public:
virtual ~FreeBSDThread();
+ // POSIXThread
+ void
+ RefreshStateAfterStop() override;
+
+ // This notifies the thread when a private stop occurs.
+ void
+ DidStop () override;
+
+ const char *
+ GetInfo() override;
+
+ void
+ SetName (const char *name) override;
+
+ const char *
+ GetName () override;
+
+ lldb::RegisterContextSP
+ GetRegisterContext() override;
+
+ lldb::RegisterContextSP
+ CreateRegisterContextForFrame (lldb_private::StackFrame *frame) override;
+
+ 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.
+
+ unsigned
+ GetRegisterIndexFromOffset(unsigned offset);
+
+ const char *
+ GetRegisterName(unsigned reg);
+
+ 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);
+
+ bool DisableHardwareWatchpoint(lldb_private::Watchpoint *wp);
+
+ uint32_t NumSupportedHardwareWatchpoints();
+
+ uint32_t FindVacantWatchpointIndex();
+
+protected:
+ POSIXBreakpointProtocol *
+ GetPOSIXBreakpointProtocol ()
+ {
+ if (!m_reg_context_sp)
+ m_reg_context_sp = GetRegisterContext();
+ return m_posix_thread;
+ }
+
+ std::unique_ptr<lldb_private::StackFrame> m_frame_ap;
+
+ lldb::BreakpointSiteSP m_breakpoint;
+
+ bool m_thread_name_valid;
+ std::string m_thread_name;
+ POSIXBreakpointProtocol *m_posix_thread;
+
+ ProcessMonitor &
+ GetMonitor();
+
+ bool
+ CalculateStopInfo() override;
+
+ void BreakNotify(const ProcessMessage &message);
+ void WatchNotify(const ProcessMessage &message);
+ virtual void TraceNotify(const ProcessMessage &message);
+ void LimboNotify(const ProcessMessage &message);
+ void SignalNotify(const ProcessMessage &message);
+ void SignalDeliveredNotify(const ProcessMessage &message);
+ void CrashNotify(const ProcessMessage &message);
+ void ExitNotify(const ProcessMessage &message);
+ void ExecNotify(const ProcessMessage &message);
+
+ lldb_private::Unwind *
+ GetUnwinder() override;
+
//--------------------------------------------------------------------------
// FreeBSDThread internal API.
// POSIXThread override
virtual void
- WillResume(lldb::StateType resume_state);
+ WillResume(lldb::StateType resume_state) override;
};
#endif // #ifndef liblldb_FreeBSDThread_H_
diff --git a/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp b/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp
index 3b8cea737bcb..409cf8c46b03 100644
--- a/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp
+++ b/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp
@@ -45,7 +45,7 @@ POSIXLimboStopInfo::ShouldNotify(Event *event_ptr)
//===----------------------------------------------------------------------===//
// POSIXCrashStopInfo
-POSIXCrashStopInfo::POSIXCrashStopInfo(POSIXThread &thread,
+POSIXCrashStopInfo::POSIXCrashStopInfo(FreeBSDThread &thread,
uint32_t status,
CrashReason reason,
lldb::addr_t fault_addr)
diff --git a/source/Plugins/Process/FreeBSD/POSIXStopInfo.h b/source/Plugins/Process/FreeBSD/POSIXStopInfo.h
index a1ee2ea68524..ace6c98017b7 100644
--- a/source/Plugins/Process/FreeBSD/POSIXStopInfo.h
+++ b/source/Plugins/Process/FreeBSD/POSIXStopInfo.h
@@ -17,7 +17,7 @@
#include "lldb/Target/StopInfo.h"
#include "CrashReason.h"
-#include "POSIXThread.h"
+#include "FreeBSDThread.h"
#include <string>
@@ -42,7 +42,7 @@ class POSIXLimboStopInfo
: public POSIXStopInfo
{
public:
- POSIXLimboStopInfo(POSIXThread &thread)
+ POSIXLimboStopInfo(FreeBSDThread &thread)
: POSIXStopInfo(thread, 0)
{ }
@@ -70,7 +70,7 @@ class POSIXCrashStopInfo
: public POSIXStopInfo
{
public:
- POSIXCrashStopInfo(POSIXThread &thread, uint32_t status,
+ POSIXCrashStopInfo(FreeBSDThread &thread, uint32_t status,
CrashReason reason,
lldb::addr_t fault_addr);
~POSIXCrashStopInfo();
@@ -88,7 +88,7 @@ class POSIXNewThreadStopInfo
: public POSIXStopInfo
{
public:
- POSIXNewThreadStopInfo (POSIXThread &thread)
+ POSIXNewThreadStopInfo (FreeBSDThread &thread)
: POSIXStopInfo (thread, 0)
{ }
diff --git a/source/Plugins/Process/FreeBSD/POSIXThread.cpp b/source/Plugins/Process/FreeBSD/POSIXThread.cpp
deleted file mode 100644
index 854796fb7448..000000000000
--- a/source/Plugins/Process/FreeBSD/POSIXThread.cpp
+++ /dev/null
@@ -1,661 +0,0 @@
-//===-- POSIXThread.cpp -----------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// C Includes
-#include <errno.h>
-
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Breakpoint/Watchpoint.h"
-#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Core/Debugger.h"
-#include "lldb/Core/State.h"
-#include "lldb/Host/Host.h"
-#include "lldb/Host/HostNativeThread.h"
-#include "lldb/Host/HostInfo.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/StopInfo.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/ThreadSpec.h"
-#include "llvm/ADT/SmallString.h"
-#include "POSIXStopInfo.h"
-#include "POSIXThread.h"
-#include "ProcessPOSIX.h"
-#include "ProcessPOSIXLog.h"
-#include "ProcessMonitor.h"
-#include "RegisterContextPOSIXProcessMonitor_arm.h"
-#include "RegisterContextPOSIXProcessMonitor_arm64.h"
-#include "RegisterContextPOSIXProcessMonitor_mips64.h"
-#include "RegisterContextPOSIXProcessMonitor_powerpc.h"
-#include "RegisterContextPOSIXProcessMonitor_x86.h"
-#include "Plugins/Process/Utility/RegisterContextFreeBSD_arm.h"
-#include "Plugins/Process/Utility/RegisterContextFreeBSD_i386.h"
-#include "Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h"
-#include "Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h"
-#include "Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h"
-#include "Plugins/Process/Utility/UnwindLLDB.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-
-POSIXThread::POSIXThread(Process &process, lldb::tid_t tid)
- : Thread(process, tid),
- m_frame_ap (),
- m_breakpoint (),
- m_thread_name_valid (false),
- m_thread_name (),
- m_posix_thread(NULL)
-{
- Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
- if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
- log->Printf ("POSIXThread::%s (tid = %" PRIi64 ")", __FUNCTION__, tid);
-
- // Set the current watchpoints for this thread.
- Target &target = GetProcess()->GetTarget();
- const WatchpointList &wp_list = target.GetWatchpointList();
- size_t wp_size = wp_list.GetSize();
-
- for (uint32_t wp_idx = 0; wp_idx < wp_size; wp_idx++)
- {
- lldb::WatchpointSP wp = wp_list.GetByIndex(wp_idx);
- if (wp.get() && wp->IsEnabled())
- {
- // This watchpoint as been enabled; obviously this "new" thread
- // has been created since that watchpoint was enabled. Since
- // the POSIXBreakpointProtocol has yet to be initialized, its
- // m_watchpoints_initialized member will be FALSE. Attempting to
- // read the debug status register to determine if a watchpoint
- // has been hit would result in the zeroing of that register.
- // Since the active debug registers would have been cloned when
- // this thread was created, simply force the m_watchpoints_initized
- // member to TRUE and avoid resetting dr6 and dr7.
- GetPOSIXBreakpointProtocol()->ForceWatchpointsInitialized();
- }
- }
-}
-
-POSIXThread::~POSIXThread()
-{
- DestroyThread();
-}
-
-ProcessMonitor &
-POSIXThread::GetMonitor()
-{
- ProcessSP base = GetProcess();
- ProcessPOSIX &process = static_cast<ProcessPOSIX&>(*base);
- return process.GetMonitor();
-}
-
-void
-POSIXThread::RefreshStateAfterStop()
-{
- // Invalidate all registers in our register context. We don't set "force" to
- // true because the stop reply packet might have had some register values
- // that were expedited and these will already be copied into the register
- // context by the time this function gets called. The KDPRegisterContext
- // class has been made smart enough to detect when it needs to invalidate
- // which registers are valid by putting hooks in the register read and
- // register supply functions where they check the process stop ID and do
- // the right thing.
- //if (StateIsStoppedState(GetState())
- {
- const bool force = false;
- GetRegisterContext()->InvalidateIfNeeded (force);
- }
-}
-
-const char *
-POSIXThread::GetInfo()
-{
- return NULL;
-}
-
-void
-POSIXThread::SetName (const char *name)
-{
- m_thread_name_valid = (name && name[0]);
- if (m_thread_name_valid)
- m_thread_name.assign (name);
- else
- m_thread_name.clear();
-}
-
-const char *
-POSIXThread::GetName ()
-{
- if (!m_thread_name_valid)
- {
- llvm::SmallString<32> thread_name;
- HostNativeThread::GetName(GetID(), thread_name);
- m_thread_name = thread_name.c_str();
- m_thread_name_valid = true;
- }
-
- if (m_thread_name.empty())
- return NULL;
- return m_thread_name.c_str();
-}
-
-lldb::RegisterContextSP
-POSIXThread::GetRegisterContext()
-{
- if (!m_reg_context_sp)
- {
- m_posix_thread = NULL;
-
- RegisterInfoInterface *reg_interface = NULL;
- const ArchSpec &target_arch = GetProcess()->GetTarget().GetArchitecture();
-
- switch (target_arch.GetTriple().getOS())
- {
- case llvm::Triple::FreeBSD:
- switch (target_arch.GetMachine())
- {
- case llvm::Triple::arm:
- reg_interface = new RegisterContextFreeBSD_arm(target_arch);
- break;
- case llvm::Triple::ppc:
-#ifndef __powerpc64__
- reg_interface = new RegisterContextFreeBSD_powerpc32(target_arch);
- break;
-#endif
- case llvm::Triple::ppc64:
- reg_interface = new RegisterContextFreeBSD_powerpc64(target_arch);
- break;
- case llvm::Triple::mips64:
- reg_interface = new RegisterContextFreeBSD_mips64(target_arch);
- break;
- case llvm::Triple::x86:
- reg_interface = new RegisterContextFreeBSD_i386(target_arch);
- break;
- case llvm::Triple::x86_64:
- reg_interface = new RegisterContextFreeBSD_x86_64(target_arch);
- break;
- default:
- break;
- }
- break;
-
- default:
- break;
- }
-
- assert(reg_interface && "OS or CPU not supported!");
-
- switch (target_arch.GetMachine())
- {
- case llvm::Triple::aarch64:
- {
- RegisterContextPOSIXProcessMonitor_arm64 *reg_ctx = new RegisterContextPOSIXProcessMonitor_arm64(*this, 0, reg_interface);
- m_posix_thread = reg_ctx;
- m_reg_context_sp.reset(reg_ctx);
- break;
- }
- case llvm::Triple::arm:
- {
- RegisterContextPOSIXProcessMonitor_arm *reg_ctx = new RegisterContextPOSIXProcessMonitor_arm(*this, 0, reg_interface);
- m_posix_thread = reg_ctx;
- m_reg_context_sp.reset(reg_ctx);
- break;
- }
- case llvm::Triple::mips64:
- {
- RegisterContextPOSIXProcessMonitor_mips64 *reg_ctx = new RegisterContextPOSIXProcessMonitor_mips64(*this, 0, reg_interface);
- m_posix_thread = reg_ctx;
- m_reg_context_sp.reset(reg_ctx);
- break;
- }
- case llvm::Triple::ppc:
- case llvm::Triple::ppc64:
- {
- RegisterContextPOSIXProcessMonitor_powerpc *reg_ctx = new RegisterContextPOSIXProcessMonitor_powerpc(*this, 0, reg_interface);
- m_posix_thread = reg_ctx;
- m_reg_context_sp.reset(reg_ctx);
- break;
- }
- case llvm::Triple::x86:
- case llvm::Triple::x86_64:
- {
- RegisterContextPOSIXProcessMonitor_x86_64 *reg_ctx = new RegisterContextPOSIXProcessMonitor_x86_64(*this, 0, reg_interface);
- m_posix_thread = reg_ctx;
- m_reg_context_sp.reset(reg_ctx);
- break;
- }
- default:
- break;
- }
- }
- return m_reg_context_sp;
-}
-
-lldb::RegisterContextSP
-POSIXThread::CreateRegisterContextForFrame(lldb_private::StackFrame *frame)
-{
- lldb::RegisterContextSP reg_ctx_sp;
- uint32_t concrete_frame_idx = 0;
-
- Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
- if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
- log->Printf ("POSIXThread::%s ()", __FUNCTION__);
-
- if (frame)
- concrete_frame_idx = frame->GetConcreteFrameIndex();
-
- if (concrete_frame_idx == 0)
- reg_ctx_sp = GetRegisterContext();
- else
- {
- assert(GetUnwinder());
- reg_ctx_sp = GetUnwinder()->CreateRegisterContextForFrame(frame);
- }
-
- return reg_ctx_sp;
-}
-
-lldb::addr_t
-POSIXThread::GetThreadPointer ()
-{
- ProcessMonitor &monitor = GetMonitor();
- addr_t addr;
- if (monitor.ReadThreadPointer (GetID(), addr))
- return addr;
- else
- return LLDB_INVALID_ADDRESS;
-}
-
-bool
-POSIXThread::CalculateStopInfo()
-{
- SetStopInfo (m_stop_info_sp);
- return true;
-}
-
-Unwind *
-POSIXThread::GetUnwinder()
-{
- if (m_unwinder_ap.get() == NULL)
- m_unwinder_ap.reset(new UnwindLLDB(*this));
-
- return m_unwinder_ap.get();
-}
-
-void
-POSIXThread::DidStop()
-{
- // Don't set the thread state to stopped unless we really stopped.
-}
-
-bool
-POSIXThread::Resume()
-{
- lldb::StateType resume_state = GetResumeState();
- ProcessMonitor &monitor = GetMonitor();
- bool status;
-
- Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
- if (log)
- log->Printf ("POSIXThread::%s (), resume_state = %s", __FUNCTION__,
- StateAsCString(resume_state));
-
- switch (resume_state)
- {
- default:
- assert(false && "Unexpected state for resume!");
- status = false;
- break;
-
- case lldb::eStateRunning:
- SetState(resume_state);
- status = monitor.Resume(GetID(), GetResumeSignal());
- break;
-
- case lldb::eStateStepping:
- SetState(resume_state);
- status = monitor.SingleStep(GetID(), GetResumeSignal());
- break;
- case lldb::eStateStopped:
- case lldb::eStateSuspended:
- status = true;
- break;
- }
-
- return status;
-}
-
-void
-POSIXThread::Notify(const ProcessMessage &message)
-{
- Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
- if (log)
- log->Printf ("POSIXThread::%s () message kind = '%s' for tid %" PRIu64,
- __FUNCTION__, message.PrintKind(), GetID());
-
- switch (message.GetKind())
- {
- default:
- assert(false && "Unexpected message kind!");
- break;
-
- case ProcessMessage::eExitMessage:
- // Nothing to be done.
- break;
-
- case ProcessMessage::eLimboMessage:
- LimboNotify(message);
- break;
-
- case ProcessMessage::eSignalMessage:
- SignalNotify(message);
- break;
-
- case ProcessMessage::eSignalDeliveredMessage:
- SignalDeliveredNotify(message);
- break;
-
- case ProcessMessage::eTraceMessage:
- TraceNotify(message);
- break;
-
- case ProcessMessage::eBreakpointMessage:
- BreakNotify(message);
- break;
-
- case ProcessMessage::eWatchpointMessage:
- WatchNotify(message);
- break;
-
- case ProcessMessage::eCrashMessage:
- CrashNotify(message);
- break;
-
- case ProcessMessage::eNewThreadMessage:
- ThreadNotify(message);
- break;
-
- case ProcessMessage::eExecMessage:
- ExecNotify(message);
- break;
- }
-}
-
-bool
-POSIXThread::EnableHardwareWatchpoint(Watchpoint *wp)
-{
- bool wp_set = false;
- if (wp)
- {
- addr_t wp_addr = wp->GetLoadAddress();
- size_t wp_size = wp->GetByteSize();
- bool wp_read = wp->WatchpointRead();
- bool wp_write = wp->WatchpointWrite();
- uint32_t wp_hw_index = wp->GetHardwareIndex();
- POSIXBreakpointProtocol* reg_ctx = GetPOSIXBreakpointProtocol();
- if (reg_ctx)
- wp_set = reg_ctx->SetHardwareWatchpointWithIndex(wp_addr, wp_size,
- wp_read, wp_write,
- wp_hw_index);
- }
- return wp_set;
-}
-
-bool
-POSIXThread::DisableHardwareWatchpoint(Watchpoint *wp)
-{
- bool result = false;
- if (wp)
- {
- lldb::RegisterContextSP reg_ctx_sp = GetRegisterContext();
- if (reg_ctx_sp.get())
- result = reg_ctx_sp->ClearHardwareWatchpoint(wp->GetHardwareIndex());
- }
- return result;
-}
-
-uint32_t
-POSIXThread::NumSupportedHardwareWatchpoints()
-{
- lldb::RegisterContextSP reg_ctx_sp = GetRegisterContext();
- if (reg_ctx_sp.get())
- return reg_ctx_sp->NumSupportedHardwareWatchpoints();
- return 0;
-}
-
-uint32_t
-POSIXThread::FindVacantWatchpointIndex()
-{
- uint32_t hw_index = LLDB_INVALID_INDEX32;
- uint32_t num_hw_wps = NumSupportedHardwareWatchpoints();
- uint32_t wp_idx;
- POSIXBreakpointProtocol* reg_ctx = GetPOSIXBreakpointProtocol();
- if (reg_ctx)
- {
- for (wp_idx = 0; wp_idx < num_hw_wps; wp_idx++)
- {
- if (reg_ctx->IsWatchpointVacant(wp_idx))
- {
- hw_index = wp_idx;
- break;
- }
- }
- }
- return hw_index;
-}
-
-void
-POSIXThread::BreakNotify(const ProcessMessage &message)
-{
- bool status;
- Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
-
- assert(GetRegisterContext());
- status = GetPOSIXBreakpointProtocol()->UpdateAfterBreakpoint();
- assert(status && "Breakpoint update failed!");
-
- // With our register state restored, resolve the breakpoint object
- // corresponding to our current PC.
- assert(GetRegisterContext());
- lldb::addr_t pc = GetRegisterContext()->GetPC();
- if (log)
- log->Printf ("POSIXThread::%s () PC=0x%8.8" PRIx64, __FUNCTION__, pc);
- lldb::BreakpointSiteSP bp_site(GetProcess()->GetBreakpointSiteList().FindByAddress(pc));
-
- // If the breakpoint is for this thread, then we'll report the hit, but if it is for another thread,
- // we create a stop reason with should_stop=false. If there is no breakpoint location, then report
- // an invalid stop reason. We don't need to worry about stepping over the breakpoint here, that will
- // be taken care of when the thread resumes and notices that there's a breakpoint under the pc.
- if (bp_site)
- {
- lldb::break_id_t bp_id = bp_site->GetID();
- // If we have an operating system plug-in, we might have set a thread specific breakpoint using the
- // operating system thread ID, so we can't make any assumptions about the thread ID so we must always
- // report the breakpoint regardless of the thread.
- if (bp_site->ValidForThisThread(this) || GetProcess()->GetOperatingSystem () != NULL)
- SetStopInfo (StopInfo::CreateStopReasonWithBreakpointSiteID(*this, bp_id));
- else
- {
- const bool should_stop = false;
- SetStopInfo (StopInfo::CreateStopReasonWithBreakpointSiteID(*this, bp_id, should_stop));
- }
- }
- else
- SetStopInfo(StopInfoSP());
-}
-
-void
-POSIXThread::WatchNotify(const ProcessMessage &message)
-{
- Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
-
- lldb::addr_t halt_addr = message.GetHWAddress();
- if (log)
- log->Printf ("POSIXThread::%s () Hardware Watchpoint Address = 0x%8.8"
- PRIx64, __FUNCTION__, halt_addr);
-
- POSIXBreakpointProtocol* reg_ctx = GetPOSIXBreakpointProtocol();
- if (reg_ctx)
- {
- uint32_t num_hw_wps = reg_ctx->NumSupportedHardwareWatchpoints();
- uint32_t wp_idx;
- for (wp_idx = 0; wp_idx < num_hw_wps; wp_idx++)
- {
- if (reg_ctx->IsWatchpointHit(wp_idx))
- {
- // Clear the watchpoint hit here
- reg_ctx->ClearWatchpointHits();
- break;
- }
- }
-
- if (wp_idx == num_hw_wps)
- return;
-
- Target &target = GetProcess()->GetTarget();
- lldb::addr_t wp_monitor_addr = reg_ctx->GetWatchpointAddress(wp_idx);
- const WatchpointList &wp_list = target.GetWatchpointList();
- lldb::WatchpointSP wp_sp = wp_list.FindByAddress(wp_monitor_addr);
-
- assert(wp_sp.get() && "No watchpoint found");
- SetStopInfo (StopInfo::CreateStopReasonWithWatchpointID(*this,
- wp_sp->GetID()));
- }
-}
-
-void
-POSIXThread::TraceNotify(const ProcessMessage &message)
-{
- POSIXBreakpointProtocol* reg_ctx = GetPOSIXBreakpointProtocol();
- if (reg_ctx)
- {
- uint32_t num_hw_wps = reg_ctx->NumSupportedHardwareWatchpoints();
- uint32_t wp_idx;
- for (wp_idx = 0; wp_idx < num_hw_wps; wp_idx++)
- {
- if (reg_ctx->IsWatchpointHit(wp_idx))
- {
- WatchNotify(message);
- return;
- }
- }
- }
-
- SetStopInfo (StopInfo::CreateStopReasonToTrace(*this));
-}
-
-void
-POSIXThread::LimboNotify(const ProcessMessage &message)
-{
- SetStopInfo (lldb::StopInfoSP(new POSIXLimboStopInfo(*this)));
-}
-
-void
-POSIXThread::SignalNotify(const ProcessMessage &message)
-{
- int signo = message.GetSignal();
- SetStopInfo (StopInfo::CreateStopReasonWithSignal(*this, signo));
-}
-
-void
-POSIXThread::SignalDeliveredNotify(const ProcessMessage &message)
-{
- int signo = message.GetSignal();
- SetStopInfo (StopInfo::CreateStopReasonWithSignal(*this, signo));
-}
-
-void
-POSIXThread::CrashNotify(const ProcessMessage &message)
-{
- // FIXME: Update stop reason as per bugzilla 14598
- int signo = message.GetSignal();
-
- assert(message.GetKind() == ProcessMessage::eCrashMessage);
-
- Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
- if (log)
- log->Printf ("POSIXThread::%s () signo = %i, reason = '%s'",
- __FUNCTION__, signo, message.PrintCrashReason());
-
- SetStopInfo (lldb::StopInfoSP(new POSIXCrashStopInfo(*this, signo,
- message.GetCrashReason(),
- message.GetFaultAddress())));
-}
-
-void
-POSIXThread::ThreadNotify(const ProcessMessage &message)
-{
- SetStopInfo (lldb::StopInfoSP(new POSIXNewThreadStopInfo(*this)));
-}
-
-unsigned
-POSIXThread::GetRegisterIndexFromOffset(unsigned offset)
-{
- unsigned reg = LLDB_INVALID_REGNUM;
- ArchSpec arch = HostInfo::GetArchitecture();
-
- switch (arch.GetMachine())
- {
- default:
- llvm_unreachable("CPU type not supported!");
- break;
-
- case llvm::Triple::aarch64:
- case llvm::Triple::arm:
- case llvm::Triple::mips64:
- case llvm::Triple::ppc:
- case llvm::Triple::ppc64:
- case llvm::Triple::x86:
- case llvm::Triple::x86_64:
- {
- POSIXBreakpointProtocol* reg_ctx = GetPOSIXBreakpointProtocol();
- reg = reg_ctx->GetRegisterIndexFromOffset(offset);
- }
- break;
- }
- return reg;
-}
-
-void
-POSIXThread::ExecNotify(const ProcessMessage &message)
-{
- SetStopInfo (StopInfo::CreateStopReasonWithExec(*this));
-}
-
-const char *
-POSIXThread::GetRegisterName(unsigned reg)
-{
- const char * name = nullptr;
- ArchSpec arch = HostInfo::GetArchitecture();
-
- switch (arch.GetMachine())
- {
- default:
- assert(false && "CPU type not supported!");
- break;
-
- case llvm::Triple::aarch64:
- case llvm::Triple::arm:
- case llvm::Triple::mips64:
- case llvm::Triple::ppc:
- case llvm::Triple::ppc64:
- case llvm::Triple::x86:
- case llvm::Triple::x86_64:
- name = GetRegisterContext()->GetRegisterName(reg);
- break;
- }
- return name;
-}
-
-const char *
-POSIXThread::GetRegisterNameFromOffset(unsigned offset)
-{
- return GetRegisterName(GetRegisterIndexFromOffset(offset));
-}
-
diff --git a/source/Plugins/Process/FreeBSD/POSIXThread.h b/source/Plugins/Process/FreeBSD/POSIXThread.h
deleted file mode 100644
index c38d194dbd19..000000000000
--- a/source/Plugins/Process/FreeBSD/POSIXThread.h
+++ /dev/null
@@ -1,132 +0,0 @@
-//===-- POSIXThread.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_POSIXThread_H_
-#define liblldb_POSIXThread_H_
-
-// C Includes
-// C++ Includes
-#include <memory>
-#include <string>
-
-// Other libraries and framework includes
-#include "lldb/Target/Thread.h"
-#include "Plugins/Process/Utility/RegisterContextPOSIX.h"
-
-class ProcessMessage;
-class ProcessMonitor;
-class POSIXBreakpointProtocol;
-
-//------------------------------------------------------------------------------
-// @class POSIXThread
-// @brief Abstraction of a POSIX thread.
-class POSIXThread
- : public lldb_private::Thread
-{
-public:
- POSIXThread(lldb_private::Process &process, lldb::tid_t tid);
-
- virtual ~POSIXThread();
-
- void
- RefreshStateAfterStop() override;
-
- // This notifies the thread when a private stop occurs.
- void
- DidStop () override;
-
- const char *
- GetInfo() override;
-
- void
- SetName (const char *name) override;
-
- const char *
- GetName () override;
-
- lldb::RegisterContextSP
- GetRegisterContext() override;
-
- lldb::RegisterContextSP
- CreateRegisterContextForFrame (lldb_private::StackFrame *frame) override;
-
- 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.
-
- unsigned
- GetRegisterIndexFromOffset(unsigned offset);
-
- const char *
- GetRegisterName(unsigned reg);
-
- 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);
-
- bool DisableHardwareWatchpoint(lldb_private::Watchpoint *wp);
-
- uint32_t NumSupportedHardwareWatchpoints();
-
- uint32_t FindVacantWatchpointIndex();
-
-protected:
- POSIXBreakpointProtocol *
- GetPOSIXBreakpointProtocol ()
- {
- if (!m_reg_context_sp)
- m_reg_context_sp = GetRegisterContext();
- return m_posix_thread;
- }
-
- std::unique_ptr<lldb_private::StackFrame> m_frame_ap;
-
- lldb::BreakpointSiteSP m_breakpoint;
-
- bool m_thread_name_valid;
- std::string m_thread_name;
- POSIXBreakpointProtocol *m_posix_thread;
-
- ProcessMonitor &
- GetMonitor();
-
- bool
- CalculateStopInfo() override;
-
- void BreakNotify(const ProcessMessage &message);
- void WatchNotify(const ProcessMessage &message);
- virtual void TraceNotify(const ProcessMessage &message);
- void LimboNotify(const ProcessMessage &message);
- void SignalNotify(const ProcessMessage &message);
- void SignalDeliveredNotify(const ProcessMessage &message);
- void CrashNotify(const ProcessMessage &message);
- void ThreadNotify(const ProcessMessage &message);
- void ExitNotify(const ProcessMessage &message);
- void ExecNotify(const ProcessMessage &message);
-
- lldb_private::Unwind *
- GetUnwinder() override;
-};
-
-#endif // #ifndef liblldb_POSIXThread_H_
diff --git a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
index a0458f16e558..769ccd7248ac 100644
--- a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
+++ b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
@@ -28,6 +28,23 @@
#include "ProcessMonitor.h"
#include "FreeBSDThread.h"
+// Other libraries and framework includes
+#include "lldb/Breakpoint/BreakpointLocation.h"
+#include "lldb/Breakpoint/Watchpoint.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/State.h"
+#include "lldb/Host/FileSpec.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Target/DynamicLoader.h"
+#include "lldb/Target/Platform.h"
+#include "lldb/Target/Target.h"
+
+#include "lldb/Host/posix/Fcntl.h"
+
+
using namespace lldb;
using namespace lldb_private;
@@ -45,13 +62,13 @@ namespace
// Static functions.
lldb::ProcessSP
-ProcessFreeBSD::CreateInstance(Target& target,
+ProcessFreeBSD::CreateInstance(lldb::TargetSP target_sp,
Listener &listener,
const FileSpec *crash_file_path)
{
lldb::ProcessSP process_sp;
if (crash_file_path == NULL)
- process_sp.reset(new ProcessFreeBSD (target, listener));
+ process_sp.reset(new ProcessFreeBSD (target_sp, listener, GetFreeBSDSignals()));
return process_sp;
}
@@ -97,32 +114,6 @@ ProcessFreeBSD::GetPluginVersion()
}
void
-ProcessFreeBSD::GetPluginCommandHelp(const char *command, Stream *strm)
-{
-}
-
-Error
-ProcessFreeBSD::ExecutePluginCommand(Args &command, Stream *strm)
-{
- return Error(1, eErrorTypeGeneric);
-}
-
-Log *
-ProcessFreeBSD::EnablePluginLogging(Stream *strm, Args &command)
-{
- return NULL;
-}
-
-//------------------------------------------------------------------------------
-// Constructors and destructors.
-
-ProcessFreeBSD::ProcessFreeBSD(Target& target, Listener &listener)
- : ProcessPOSIX(target, listener, GetFreeBSDSignals ()),
- m_resume_signo(0)
-{
-}
-
-void
ProcessFreeBSD::Terminate()
{
}
@@ -232,7 +223,7 @@ ProcessFreeBSD::WillResume()
m_suspend_tids.clear();
m_run_tids.clear();
m_step_tids.clear();
- return ProcessPOSIX::WillResume();
+ return Process::WillResume();
}
void
@@ -264,7 +255,7 @@ ProcessFreeBSD::SendMessage(const ProcessMessage &message)
break;
case ProcessMessage::eNewThreadMessage:
- assert(0 && "eNewThreadMessage unexpected on FreeBSD");
+ llvm_unreachable("eNewThreadMessage unexpected on FreeBSD");
break;
case ProcessMessage::eExecMessage:
@@ -274,3 +265,781 @@ ProcessFreeBSD::SendMessage(const ProcessMessage &message)
m_message_queue.push(message);
}
+
+//------------------------------------------------------------------------------
+// Constructors and destructors.
+
+ProcessFreeBSD::ProcessFreeBSD(lldb::TargetSP target_sp, Listener &listener, UnixSignalsSP &unix_signals_sp)
+ : Process(target_sp, listener, unix_signals_sp),
+ m_byte_order(endian::InlHostByteOrder()),
+ m_monitor(NULL),
+ m_module(NULL),
+ m_message_mutex (Mutex::eMutexTypeRecursive),
+ m_exit_now(false),
+ m_seen_initial_stop(),
+ m_resume_signo(0)
+{
+ // FIXME: Putting this code in the ctor and saving the byte order in a
+ // member variable is a hack to avoid const qual issues in GetByteOrder.
+ lldb::ModuleSP module = GetTarget().GetExecutableModule();
+ if (module && module->GetObjectFile())
+ m_byte_order = module->GetObjectFile()->GetByteOrder();
+}
+
+ProcessFreeBSD::~ProcessFreeBSD()
+{
+ delete m_monitor;
+}
+
+//------------------------------------------------------------------------------
+// Process protocol.
+void
+ProcessFreeBSD::Finalize()
+{
+ Process::Finalize();
+
+ if (m_monitor)
+ m_monitor->StopMonitor();
+}
+
+bool
+ProcessFreeBSD::CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name)
+{
+ // For now we are just making sure the file exists for a given module
+ ModuleSP exe_module_sp(target_sp->GetExecutableModule());
+ if (exe_module_sp.get())
+ return exe_module_sp->GetFileSpec().Exists();
+ // If there is no executable module, we return true since we might be preparing to attach.
+ return true;
+}
+
+Error
+ProcessFreeBSD::DoAttachToProcessWithID (lldb::pid_t pid, const ProcessAttachInfo &attach_info)
+{
+ Error error;
+ assert(m_monitor == NULL);
+
+ Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
+ if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
+ log->Printf ("ProcessFreeBSD::%s(pid = %" PRIi64 ")", __FUNCTION__, GetID());
+
+ m_monitor = new ProcessMonitor(this, pid, error);
+
+ if (!error.Success())
+ return error;
+
+ PlatformSP platform_sp (GetTarget().GetPlatform ());
+ assert (platform_sp.get());
+ if (!platform_sp)
+ return error; // FIXME: Detatch?
+
+ // Find out what we can about this process
+ ProcessInstanceInfo process_info;
+ platform_sp->GetProcessInfo (pid, process_info);
+
+ // Resolve the executable module
+ ModuleSP exe_module_sp;
+ FileSpecList executable_search_paths (Target::GetDefaultExecutableSearchPaths());
+ ModuleSpec exe_module_spec(process_info.GetExecutableFile(), GetTarget().GetArchitecture());
+ error = platform_sp->ResolveExecutable(exe_module_spec,
+ exe_module_sp,
+ executable_search_paths.GetSize() ? &executable_search_paths : NULL);
+ if (!error.Success())
+ return error;
+
+ // Fix the target architecture if necessary
+ const ArchSpec &module_arch = exe_module_sp->GetArchitecture();
+ if (module_arch.IsValid() && !GetTarget().GetArchitecture().IsExactMatch(module_arch))
+ GetTarget().SetArchitecture(module_arch);
+
+ // Initialize the target module list
+ GetTarget().SetExecutableModule (exe_module_sp, true);
+
+ SetSTDIOFileDescriptor(m_monitor->GetTerminalFD());
+
+ SetID(pid);
+
+ return error;
+}
+
+Error
+ProcessFreeBSD::WillLaunch(Module* module)
+{
+ Error error;
+ return error;
+}
+
+FileSpec
+ProcessFreeBSD::GetFileSpec(const lldb_private::FileAction *file_action,
+ const FileSpec &default_file_spec,
+ const FileSpec &dbg_pts_file_spec)
+{
+ FileSpec file_spec{};
+
+ if (file_action && file_action->GetAction() == FileAction::eFileActionOpen)
+ {
+ file_spec = file_action->GetFileSpec();
+ // By default the stdio paths passed in will be pseudo-terminal
+ // (/dev/pts). If so, convert to using a different default path
+ // instead to redirect I/O to the debugger console. This should
+ // also handle user overrides to /dev/null or a different file.
+ if (!file_spec || file_spec == dbg_pts_file_spec)
+ file_spec = default_file_spec;
+ }
+ return file_spec;
+}
+
+Error
+ProcessFreeBSD::DoLaunch (Module *module,
+ ProcessLaunchInfo &launch_info)
+{
+ Error error;
+ assert(m_monitor == NULL);
+
+ FileSpec working_dir = launch_info.GetWorkingDirectory();
+ if (working_dir &&
+ (!working_dir.ResolvePath() ||
+ working_dir.GetFileType() != FileSpec::eFileTypeDirectory))
+ {
+ error.SetErrorStringWithFormat("No such file or directory: %s",
+ working_dir.GetCString());
+ return error;
+ }
+
+ SetPrivateState(eStateLaunching);
+
+ const lldb_private::FileAction *file_action;
+
+ // Default of empty will mean to use existing open file descriptors
+ FileSpec stdin_file_spec{};
+ FileSpec stdout_file_spec{};
+ FileSpec stderr_file_spec{};
+
+ const FileSpec dbg_pts_file_spec{launch_info.GetPTY().GetSlaveName(NULL,0), false};
+
+ file_action = launch_info.GetFileActionForFD (STDIN_FILENO);
+ stdin_file_spec = GetFileSpec(file_action, stdin_file_spec, dbg_pts_file_spec);
+
+ file_action = launch_info.GetFileActionForFD (STDOUT_FILENO);
+ stdout_file_spec = GetFileSpec(file_action, stdout_file_spec, dbg_pts_file_spec);
+
+ file_action = launch_info.GetFileActionForFD (STDERR_FILENO);
+ stderr_file_spec = GetFileSpec(file_action, stderr_file_spec, dbg_pts_file_spec);
+
+ m_monitor = new ProcessMonitor(this,
+ module,
+ launch_info.GetArguments().GetConstArgumentVector(),
+ launch_info.GetEnvironmentEntries().GetConstArgumentVector(),
+ stdin_file_spec,
+ stdout_file_spec,
+ stderr_file_spec,
+ working_dir,
+ launch_info,
+ error);
+
+ m_module = module;
+
+ if (!error.Success())
+ return error;
+
+ int terminal = m_monitor->GetTerminalFD();
+ if (terminal >= 0) {
+ // The reader thread will close the file descriptor when done, so we pass it a copy.
+#ifdef F_DUPFD_CLOEXEC
+ int stdio = fcntl(terminal, F_DUPFD_CLOEXEC, 0);
+ if (stdio == -1) {
+ error.SetErrorToErrno();
+ return error;
+ }
+#else
+ // Special case when F_DUPFD_CLOEXEC does not exist (Debian kFreeBSD)
+ int stdio = fcntl(terminal, F_DUPFD, 0);
+ if (stdio == -1) {
+ error.SetErrorToErrno();
+ return error;
+ }
+ stdio = fcntl(terminal, F_SETFD, FD_CLOEXEC);
+ if (stdio == -1) {
+ error.SetErrorToErrno();
+ return error;
+ }
+#endif
+ SetSTDIOFileDescriptor(stdio);
+ }
+
+ SetID(m_monitor->GetPID());
+ return error;
+}
+
+void
+ProcessFreeBSD::DidLaunch()
+{
+}
+
+addr_t
+ProcessFreeBSD::GetImageInfoAddress()
+{
+ Target *target = &GetTarget();
+ ObjectFile *obj_file = target->GetExecutableModule()->GetObjectFile();
+ Address addr = obj_file->GetImageInfoAddress(target);
+
+ if (addr.IsValid())
+ return addr.GetLoadAddress(target);
+ return LLDB_INVALID_ADDRESS;
+}
+
+Error
+ProcessFreeBSD::DoHalt(bool &caused_stop)
+{
+ Error error;
+
+ if (IsStopped())
+ {
+ caused_stop = false;
+ }
+ else if (kill(GetID(), SIGSTOP))
+ {
+ caused_stop = false;
+ error.SetErrorToErrno();
+ }
+ else
+ {
+ caused_stop = true;
+ }
+ return error;
+}
+
+Error
+ProcessFreeBSD::DoSignal(int signal)
+{
+ Error error;
+
+ if (kill(GetID(), signal))
+ error.SetErrorToErrno();
+
+ return error;
+}
+
+Error
+ProcessFreeBSD::DoDestroy()
+{
+ Error error;
+
+ if (!HasExited())
+ {
+ assert(m_monitor);
+ m_exit_now = true;
+ if (GetID() == LLDB_INVALID_PROCESS_ID)
+ {
+ error.SetErrorString("invalid process id");
+ return error;
+ }
+ if (!m_monitor->Kill())
+ {
+ error.SetErrorToErrno();
+ return error;
+ }
+
+ SetPrivateState(eStateExited);
+ }
+
+ return error;
+}
+
+void
+ProcessFreeBSD::DoDidExec()
+{
+ Target *target = &GetTarget();
+ if (target)
+ {
+ PlatformSP platform_sp (target->GetPlatform());
+ assert (platform_sp.get());
+ if (platform_sp)
+ {
+ ProcessInstanceInfo process_info;
+ platform_sp->GetProcessInfo(GetID(), process_info);
+ ModuleSP exe_module_sp;
+ ModuleSpec exe_module_spec(process_info.GetExecutableFile(), target->GetArchitecture());
+ FileSpecList executable_search_paths (Target::GetDefaultExecutableSearchPaths());
+ Error error = platform_sp->ResolveExecutable(exe_module_spec,
+ exe_module_sp,
+ executable_search_paths.GetSize() ? &executable_search_paths : NULL);
+ if (!error.Success())
+ return;
+ target->SetExecutableModule(exe_module_sp, true);
+ }
+ }
+}
+
+bool
+ProcessFreeBSD::AddThreadForInitialStopIfNeeded(lldb::tid_t stop_tid)
+{
+ bool added_to_set = false;
+ ThreadStopSet::iterator it = m_seen_initial_stop.find(stop_tid);
+ if (it == m_seen_initial_stop.end())
+ {
+ m_seen_initial_stop.insert(stop_tid);
+ added_to_set = true;
+ }
+ return added_to_set;
+}
+
+bool
+ProcessFreeBSD::WaitingForInitialStop(lldb::tid_t stop_tid)
+{
+ return (m_seen_initial_stop.find(stop_tid) == m_seen_initial_stop.end());
+}
+
+FreeBSDThread *
+ProcessFreeBSD::CreateNewFreeBSDThread(lldb_private::Process &process, lldb::tid_t tid)
+{
+ return new FreeBSDThread(process, tid);
+}
+
+void
+ProcessFreeBSD::RefreshStateAfterStop()
+{
+ Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
+ if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
+ log->Printf ("ProcessFreeBSD::%s(), message_queue size = %d", __FUNCTION__, (int)m_message_queue.size());
+
+ Mutex::Locker lock(m_message_mutex);
+
+ // This method used to only handle one message. Changing it to loop allows
+ // it to handle the case where we hit a breakpoint while handling a different
+ // breakpoint.
+ while (!m_message_queue.empty())
+ {
+ ProcessMessage &message = m_message_queue.front();
+
+ // Resolve the thread this message corresponds to and pass it along.
+ lldb::tid_t tid = message.GetTID();
+ if (log)
+ log->Printf ("ProcessFreeBSD::%s(), message_queue size = %d, pid = %" PRIi64, __FUNCTION__, (int)m_message_queue.size(), tid);
+
+ m_thread_list.RefreshStateAfterStop();
+
+ FreeBSDThread *thread = static_cast<FreeBSDThread*>(
+ GetThreadList().FindThreadByID(tid, false).get());
+ if (thread)
+ thread->Notify(message);
+
+ if (message.GetKind() == ProcessMessage::eExitMessage)
+ {
+ // FIXME: We should tell the user about this, but the limbo message is probably better for that.
+ if (log)
+ log->Printf ("ProcessFreeBSD::%s() removing thread, tid = %" PRIi64, __FUNCTION__, tid);
+
+ Mutex::Locker lock(m_thread_list.GetMutex());
+
+ ThreadSP thread_sp = m_thread_list.RemoveThreadByID(tid, false);
+ thread_sp.reset();
+ m_seen_initial_stop.erase(tid);
+ }
+
+ m_message_queue.pop();
+ }
+}
+
+bool
+ProcessFreeBSD::IsAlive()
+{
+ StateType state = GetPrivateState();
+ return state != eStateDetached
+ && state != eStateExited
+ && state != eStateInvalid
+ && state != eStateUnloaded;
+}
+
+size_t
+ProcessFreeBSD::DoReadMemory(addr_t vm_addr,
+ void *buf, size_t size, Error &error)
+{
+ assert(m_monitor);
+ return m_monitor->ReadMemory(vm_addr, buf, size, error);
+}
+
+size_t
+ProcessFreeBSD::DoWriteMemory(addr_t vm_addr, const void *buf, size_t size,
+ Error &error)
+{
+ assert(m_monitor);
+ return m_monitor->WriteMemory(vm_addr, buf, size, error);
+}
+
+addr_t
+ProcessFreeBSD::DoAllocateMemory(size_t size, uint32_t permissions,
+ Error &error)
+{
+ addr_t allocated_addr = LLDB_INVALID_ADDRESS;
+
+ unsigned prot = 0;
+ if (permissions & lldb::ePermissionsReadable)
+ prot |= eMmapProtRead;
+ if (permissions & lldb::ePermissionsWritable)
+ prot |= eMmapProtWrite;
+ if (permissions & lldb::ePermissionsExecutable)
+ prot |= eMmapProtExec;
+
+ if (InferiorCallMmap(this, allocated_addr, 0, size, prot,
+ eMmapFlagsAnon | eMmapFlagsPrivate, -1, 0)) {
+ m_addr_to_mmap_size[allocated_addr] = size;
+ error.Clear();
+ } else {
+ allocated_addr = LLDB_INVALID_ADDRESS;
+ error.SetErrorStringWithFormat("unable to allocate %zu bytes of memory with permissions %s", size, GetPermissionsAsCString (permissions));
+ }
+
+ return allocated_addr;
+}
+
+Error
+ProcessFreeBSD::DoDeallocateMemory(lldb::addr_t addr)
+{
+ Error error;
+ MMapMap::iterator pos = m_addr_to_mmap_size.find(addr);
+ if (pos != m_addr_to_mmap_size.end() &&
+ InferiorCallMunmap(this, addr, pos->second))
+ m_addr_to_mmap_size.erase (pos);
+ else
+ error.SetErrorStringWithFormat("unable to deallocate memory at 0x%" PRIx64, addr);
+
+ return error;
+}
+
+size_t
+ProcessFreeBSD::GetSoftwareBreakpointTrapOpcode(BreakpointSite* bp_site)
+{
+ static const uint8_t g_aarch64_opcode[] = { 0x00, 0x00, 0x20, 0xD4 };
+ static const uint8_t g_i386_opcode[] = { 0xCC };
+
+ ArchSpec arch = GetTarget().GetArchitecture();
+ const uint8_t *opcode = NULL;
+ size_t opcode_size = 0;
+
+ switch (arch.GetMachine())
+ {
+ default:
+ assert(false && "CPU type not supported!");
+ break;
+
+ case llvm::Triple::arm:
+ {
+ // The ARM reference recommends the use of 0xe7fddefe and 0xdefe
+ // but the linux kernel does otherwise.
+ static const uint8_t g_arm_breakpoint_opcode[] = { 0xf0, 0x01, 0xf0, 0xe7 };
+ static const uint8_t g_thumb_breakpoint_opcode[] = { 0x01, 0xde };
+
+ lldb::BreakpointLocationSP bp_loc_sp (bp_site->GetOwnerAtIndex (0));
+ AddressClass addr_class = eAddressClassUnknown;
+
+ if (bp_loc_sp)
+ addr_class = bp_loc_sp->GetAddress ().GetAddressClass ();
+
+ if (addr_class == eAddressClassCodeAlternateISA
+ || (addr_class == eAddressClassUnknown
+ && bp_loc_sp->GetAddress().GetOffset() & 1))
+ {
+ opcode = g_thumb_breakpoint_opcode;
+ opcode_size = sizeof(g_thumb_breakpoint_opcode);
+ }
+ else
+ {
+ opcode = g_arm_breakpoint_opcode;
+ opcode_size = sizeof(g_arm_breakpoint_opcode);
+ }
+ }
+ break;
+ case llvm::Triple::aarch64:
+ opcode = g_aarch64_opcode;
+ opcode_size = sizeof(g_aarch64_opcode);
+ break;
+
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
+ opcode = g_i386_opcode;
+ opcode_size = sizeof(g_i386_opcode);
+ break;
+ }
+
+ bp_site->SetTrapOpcode(opcode, opcode_size);
+ return opcode_size;
+}
+
+Error
+ProcessFreeBSD::EnableBreakpointSite(BreakpointSite *bp_site)
+{
+ return EnableSoftwareBreakpoint(bp_site);
+}
+
+Error
+ProcessFreeBSD::DisableBreakpointSite(BreakpointSite *bp_site)
+{
+ return DisableSoftwareBreakpoint(bp_site);
+}
+
+Error
+ProcessFreeBSD::EnableWatchpoint(Watchpoint *wp, bool notify)
+{
+ Error error;
+ if (wp)
+ {
+ user_id_t watchID = wp->GetID();
+ addr_t addr = wp->GetLoadAddress();
+ Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
+ if (log)
+ log->Printf ("ProcessFreeBSD::EnableWatchpoint(watchID = %" PRIu64 ")",
+ watchID);
+ if (wp->IsEnabled())
+ {
+ if (log)
+ log->Printf("ProcessFreeBSD::EnableWatchpoint(watchID = %" PRIu64
+ ") addr = 0x%8.8" PRIx64 ": watchpoint already enabled.",
+ watchID, (uint64_t)addr);
+ return error;
+ }
+
+ // Try to find a vacant watchpoint slot in the inferiors' main thread
+ uint32_t wp_hw_index = LLDB_INVALID_INDEX32;
+ Mutex::Locker lock(m_thread_list.GetMutex());
+ FreeBSDThread *thread = static_cast<FreeBSDThread*>(
+ m_thread_list.GetThreadAtIndex(0, false).get());
+
+ if (thread)
+ wp_hw_index = thread->FindVacantWatchpointIndex();
+
+ if (wp_hw_index == LLDB_INVALID_INDEX32)
+ {
+ error.SetErrorString("Setting hardware watchpoint failed.");
+ }
+ else
+ {
+ wp->SetHardwareIndex(wp_hw_index);
+ bool wp_enabled = true;
+ uint32_t thread_count = m_thread_list.GetSize(false);
+ for (uint32_t i = 0; i < thread_count; ++i)
+ {
+ thread = static_cast<FreeBSDThread*>(
+ m_thread_list.GetThreadAtIndex(i, false).get());
+ if (thread)
+ wp_enabled &= thread->EnableHardwareWatchpoint(wp);
+ else
+ wp_enabled = false;
+ }
+ if (wp_enabled)
+ {
+ wp->SetEnabled(true, notify);
+ return error;
+ }
+ else
+ {
+ // Watchpoint enabling failed on at least one
+ // of the threads so roll back all of them
+ DisableWatchpoint(wp, false);
+ error.SetErrorString("Setting hardware watchpoint failed");
+ }
+ }
+ }
+ else
+ error.SetErrorString("Watchpoint argument was NULL.");
+ return error;
+}
+
+Error
+ProcessFreeBSD::DisableWatchpoint(Watchpoint *wp, bool notify)
+{
+ Error error;
+ if (wp)
+ {
+ user_id_t watchID = wp->GetID();
+ addr_t addr = wp->GetLoadAddress();
+ Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
+ if (log)
+ log->Printf("ProcessFreeBSD::DisableWatchpoint(watchID = %" PRIu64 ")",
+ watchID);
+ if (!wp->IsEnabled())
+ {
+ if (log)
+ log->Printf("ProcessFreeBSD::DisableWatchpoint(watchID = %" PRIu64
+ ") addr = 0x%8.8" PRIx64 ": watchpoint already disabled.",
+ watchID, (uint64_t)addr);
+ // This is needed (for now) to keep watchpoints disabled correctly
+ wp->SetEnabled(false, notify);
+ return error;
+ }
+
+ if (wp->IsHardware())
+ {
+ bool wp_disabled = true;
+ Mutex::Locker lock(m_thread_list.GetMutex());
+ uint32_t thread_count = m_thread_list.GetSize(false);
+ for (uint32_t i = 0; i < thread_count; ++i)
+ {
+ FreeBSDThread *thread = static_cast<FreeBSDThread*>(
+ m_thread_list.GetThreadAtIndex(i, false).get());
+ if (thread)
+ wp_disabled &= thread->DisableHardwareWatchpoint(wp);
+ else
+ wp_disabled = false;
+ }
+ if (wp_disabled)
+ {
+ wp->SetHardwareIndex(LLDB_INVALID_INDEX32);
+ wp->SetEnabled(false, notify);
+ return error;
+ }
+ else
+ error.SetErrorString("Disabling hardware watchpoint failed");
+ }
+ }
+ else
+ error.SetErrorString("Watchpoint argument was NULL.");
+ return error;
+}
+
+Error
+ProcessFreeBSD::GetWatchpointSupportInfo(uint32_t &num)
+{
+ Error error;
+ Mutex::Locker lock(m_thread_list.GetMutex());
+ FreeBSDThread *thread = static_cast<FreeBSDThread*>(
+ m_thread_list.GetThreadAtIndex(0, false).get());
+ if (thread)
+ num = thread->NumSupportedHardwareWatchpoints();
+ else
+ error.SetErrorString("Process does not exist.");
+ return error;
+}
+
+Error
+ProcessFreeBSD::GetWatchpointSupportInfo(uint32_t &num, bool &after)
+{
+ Error error = GetWatchpointSupportInfo(num);
+ // Watchpoints trigger and halt the inferior after
+ // the corresponding instruction has been executed.
+ after = true;
+ return error;
+}
+
+uint32_t
+ProcessFreeBSD::UpdateThreadListIfNeeded()
+{
+ Mutex::Locker lock(m_thread_list.GetMutex());
+ // Do not allow recursive updates.
+ return m_thread_list.GetSize(false);
+}
+
+#if 0
+bool
+ProcessFreeBSD::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list)
+{
+ Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
+ if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
+ log->Printf ("ProcessFreeBSD::%s() (pid = %" PRIi64 ")", __FUNCTION__, GetID());
+
+ bool has_updated = false;
+ // Update the process thread list with this new thread.
+ // FIXME: We should be using tid, not pid.
+ assert(m_monitor);
+ ThreadSP thread_sp (old_thread_list.FindThreadByID (GetID(), false));
+ if (!thread_sp) {
+ thread_sp.reset(CreateNewFreeBSDThread(*this, GetID()));
+ has_updated = true;
+ }
+
+ if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
+ log->Printf ("ProcessFreeBSD::%s() updated pid = %" PRIi64, __FUNCTION__, GetID());
+ new_thread_list.AddThread(thread_sp);
+
+ return has_updated; // the list has been updated
+}
+#endif
+
+ByteOrder
+ProcessFreeBSD::GetByteOrder() const
+{
+ // FIXME: We should be able to extract this value directly. See comment in
+ // ProcessFreeBSD().
+ return m_byte_order;
+}
+
+size_t
+ProcessFreeBSD::PutSTDIN(const char *buf, size_t len, Error &error)
+{
+ ssize_t status;
+ if ((status = write(m_monitor->GetTerminalFD(), buf, len)) < 0)
+ {
+ error.SetErrorToErrno();
+ return 0;
+ }
+ return status;
+}
+
+//------------------------------------------------------------------------------
+// Utility functions.
+
+bool
+ProcessFreeBSD::HasExited()
+{
+ switch (GetPrivateState())
+ {
+ default:
+ break;
+
+ case eStateDetached:
+ case eStateExited:
+ return true;
+ }
+
+ return false;
+}
+
+bool
+ProcessFreeBSD::IsStopped()
+{
+ switch (GetPrivateState())
+ {
+ default:
+ break;
+
+ case eStateStopped:
+ case eStateCrashed:
+ case eStateSuspended:
+ return true;
+ }
+
+ return false;
+}
+
+bool
+ProcessFreeBSD::IsAThreadRunning()
+{
+ bool is_running = false;
+ Mutex::Locker lock(m_thread_list.GetMutex());
+ uint32_t thread_count = m_thread_list.GetSize(false);
+ for (uint32_t i = 0; i < thread_count; ++i)
+ {
+ FreeBSDThread *thread = static_cast<FreeBSDThread*>(
+ m_thread_list.GetThreadAtIndex(i, false).get());
+ StateType thread_state = thread->GetState();
+ if (thread_state == eStateRunning || thread_state == eStateStepping)
+ {
+ is_running = true;
+ break;
+ }
+ }
+ return is_running;
+}
+
+const DataBufferSP
+ProcessFreeBSD::GetAuxvData ()
+{
+ // If we're the local platform, we can ask the host for auxv data.
+ PlatformSP platform_sp = GetTarget().GetPlatform ();
+ if (platform_sp && platform_sp->IsHost ())
+ return lldb_private::Host::GetAuxvData(this);
+
+ // Somewhat unexpected - the process is not running locally or we don't have a platform.
+ assert (false && "no platform or not the host - how did we get here with ProcessFreeBSD?");
+ return DataBufferSP ();
+}
diff --git a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
index d6ae3462c73b..3cc46f489875 100644
--- a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
+++ b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
@@ -13,18 +13,20 @@
// C Includes
// C++ Includes
+#include <set>
#include <queue>
// Other libraries and framework includes
#include "lldb/Target/Process.h"
#include "lldb/Target/ThreadList.h"
#include "ProcessMessage.h"
-#include "ProcessPOSIX.h"
+#include "ProcessFreeBSD.h"
class ProcessMonitor;
+class FreeBSDThread;
class ProcessFreeBSD :
- public ProcessPOSIX
+ public lldb_private::Process
{
public:
@@ -32,7 +34,7 @@ public:
// Static functions.
//------------------------------------------------------------------
static lldb::ProcessSP
- CreateInstance(lldb_private::Target& target,
+ CreateInstance(lldb::TargetSP target_sp,
lldb_private::Listener &listener,
const lldb_private::FileSpec *crash_file_path);
@@ -51,45 +53,188 @@ public:
//------------------------------------------------------------------
// Constructors and destructors
//------------------------------------------------------------------
- ProcessFreeBSD(lldb_private::Target& target,
- lldb_private::Listener &listener);
-
- virtual lldb_private::Error
- DoDetach(bool keep_stopped);
-
- virtual bool
- UpdateThreadList(lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &new_thread_list);
+ ProcessFreeBSD(lldb::TargetSP target_sp,
+ lldb_private::Listener &listener,
+ lldb::UnixSignalsSP &unix_signals_sp);
- virtual lldb_private::Error
- DoResume();
+ ~ProcessFreeBSD();
virtual lldb_private::Error
- WillResume();
-
- virtual void
- SendMessage(const ProcessMessage &message);
+ WillResume() override;
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
virtual lldb_private::ConstString
- GetPluginName();
+ GetPluginName() override;
virtual uint32_t
- GetPluginVersion();
+ GetPluginVersion() override;
+
+public:
+ //------------------------------------------------------------------
+ // Process protocol.
+ //------------------------------------------------------------------
+ void
+ Finalize() override;
+
+ bool
+ CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override;
+
+ lldb_private::Error
+ WillLaunch(lldb_private::Module *module) override;
+
+ lldb_private::Error
+ DoAttachToProcessWithID (lldb::pid_t pid, const lldb_private::ProcessAttachInfo &attach_info) override;
+
+ lldb_private::Error
+ DoLaunch (lldb_private::Module *exe_module,
+ lldb_private::ProcessLaunchInfo &launch_info) override;
+
+ void
+ DidLaunch() override;
+
+ lldb_private::Error
+ DoResume() override;
+
+ lldb_private::Error
+ DoHalt(bool &caused_stop) override;
+
+ lldb_private::Error
+ DoDetach(bool keep_stopped) override;
+
+ lldb_private::Error
+ DoSignal(int signal) override;
+
+ lldb_private::Error
+ DoDestroy() override;
+
+ void
+ DoDidExec() override;
+
+ void
+ RefreshStateAfterStop() override;
+
+ bool
+ IsAlive() override;
+
+ size_t
+ DoReadMemory(lldb::addr_t vm_addr,
+ void *buf,
+ size_t size,
+ lldb_private::Error &error) override;
+
+ size_t
+ DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
+ lldb_private::Error &error) override;
+
+ lldb::addr_t
+ DoAllocateMemory(size_t size, uint32_t permissions,
+ lldb_private::Error &error) override;
+
+ lldb_private::Error
+ DoDeallocateMemory(lldb::addr_t ptr) override;
+
+ virtual size_t
+ GetSoftwareBreakpointTrapOpcode(lldb_private::BreakpointSite* bp_site);
+ lldb_private::Error
+ EnableBreakpointSite(lldb_private::BreakpointSite *bp_site) override;
+
+ lldb_private::Error
+ DisableBreakpointSite(lldb_private::BreakpointSite *bp_site) override;
+
+ lldb_private::Error
+ EnableWatchpoint(lldb_private::Watchpoint *wp, bool notify = true) override;
+
+ lldb_private::Error
+ DisableWatchpoint(lldb_private::Watchpoint *wp, bool notify = true) override;
+
+ lldb_private::Error
+ GetWatchpointSupportInfo(uint32_t &num) override;
+
+ lldb_private::Error
+ GetWatchpointSupportInfo(uint32_t &num, bool &after) override;
+
+ virtual uint32_t
+ UpdateThreadListIfNeeded();
+
+ bool
+ UpdateThreadList(lldb_private::ThreadList &old_thread_list,
+ lldb_private::ThreadList &new_thread_list) override;
+
+ virtual lldb::ByteOrder
+ GetByteOrder() const;
+
+ lldb::addr_t
+ GetImageInfoAddress() override;
+
+ size_t
+ PutSTDIN(const char *buf, size_t len, lldb_private::Error &error) override;
+
+ const lldb::DataBufferSP
+ GetAuxvData () override;
+
+ //--------------------------------------------------------------------------
+ // ProcessFreeBSD internal API.
+
+ /// Registers the given message with this process.
virtual void
- GetPluginCommandHelp(const char *command, lldb_private::Stream *strm);
+ SendMessage(const ProcessMessage &message);
- virtual lldb_private::Error
- ExecutePluginCommand(lldb_private::Args &command,
- lldb_private::Stream *strm);
+ ProcessMonitor &
+ GetMonitor() { assert(m_monitor); return *m_monitor; }
+
+ lldb_private::FileSpec
+ GetFileSpec(const lldb_private::FileAction *file_action,
+ const lldb_private::FileSpec &default_file_spec,
+ const lldb_private::FileSpec &dbg_pts_file_spec);
+
+ /// Adds the thread to the list of threads for which we have received the initial stopping signal.
+ /// The \p stop_tid parameter indicates the thread which the stop happened for.
+ bool
+ AddThreadForInitialStopIfNeeded(lldb::tid_t stop_tid);
+
+ bool
+ WaitingForInitialStop(lldb::tid_t stop_tid);
- virtual lldb_private::Log *
- EnablePluginLogging(lldb_private::Stream *strm,
- lldb_private::Args &command);
+ virtual FreeBSDThread *
+ CreateNewFreeBSDThread(lldb_private::Process &process, lldb::tid_t tid);
protected:
+ /// Target byte order.
+ lldb::ByteOrder m_byte_order;
+
+ /// Process monitor;
+ ProcessMonitor *m_monitor;
+
+ /// The module we are executing.
+ lldb_private::Module *m_module;
+
+ /// Message queue notifying this instance of inferior process state changes.
+ lldb_private::Mutex m_message_mutex;
+ std::queue<ProcessMessage> m_message_queue;
+
+ /// Drive any exit events to completion.
+ bool m_exit_now;
+
+ /// Returns true if the process has exited.
+ bool HasExited();
+
+ /// Returns true if the process is stopped.
+ bool IsStopped();
+
+ /// Returns true if at least one running is currently running
+ bool IsAThreadRunning();
+
+ typedef std::map<lldb::addr_t, lldb::addr_t> MMapMap;
+ MMapMap m_addr_to_mmap_size;
+
+ typedef std::set<lldb::tid_t> ThreadStopSet;
+ /// Every thread begins with a stop signal. This keeps track
+ /// of the threads for which we have received the stop signal.
+ ThreadStopSet m_seen_initial_stop;
+
friend class FreeBSDThread;
typedef std::vector<lldb::tid_t> tid_collection;
diff --git a/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp b/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
index 427c66ce3e6b..ceb527b61d80 100644
--- a/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
+++ b/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
@@ -32,7 +32,7 @@
#include "lldb/Utility/PseudoTerminal.h"
#include "Plugins/Process/POSIX/CrashReason.h"
-#include "POSIXThread.h"
+#include "FreeBSDThread.h"
#include "ProcessFreeBSD.h"
#include "ProcessPOSIXLog.h"
#include "ProcessMonitor.h"
@@ -804,7 +804,7 @@ ProcessMonitor::AttachArgs::~AttachArgs()
/// launching or attaching to the inferior process, and then 2) servicing
/// operations such as register reads/writes, stepping, etc. See the comments
/// on the Operation class for more info as to why this is needed.
-ProcessMonitor::ProcessMonitor(ProcessPOSIX *process,
+ProcessMonitor::ProcessMonitor(ProcessFreeBSD *process,
Module *module,
const char *argv[],
const char *envp[],
@@ -865,7 +865,7 @@ WAIT_AGAIN:
}
}
-ProcessMonitor::ProcessMonitor(ProcessPOSIX *process,
+ProcessMonitor::ProcessMonitor(ProcessFreeBSD *process,
lldb::pid_t pid,
lldb_private::Error &error)
: m_process(static_cast<ProcessFreeBSD *>(process)),
diff --git a/source/Plugins/Process/FreeBSD/ProcessMonitor.h b/source/Plugins/Process/FreeBSD/ProcessMonitor.h
index 20ce582d973e..07fa6b7869ad 100644
--- a/source/Plugins/Process/FreeBSD/ProcessMonitor.h
+++ b/source/Plugins/Process/FreeBSD/ProcessMonitor.h
@@ -49,7 +49,7 @@ public:
/// Launches an inferior process ready for debugging. Forms the
/// implementation of Process::DoLaunch.
- ProcessMonitor(ProcessPOSIX *process,
+ ProcessMonitor(ProcessFreeBSD *process,
lldb_private::Module *module,
char const *argv[],
char const *envp[],
@@ -60,7 +60,7 @@ public:
const lldb_private::ProcessLaunchInfo &launch_info,
lldb_private::Error &error);
- ProcessMonitor(ProcessPOSIX *process,
+ ProcessMonitor(ProcessFreeBSD *process,
lldb::pid_t pid,
lldb_private::Error &error);
diff --git a/source/Plugins/Process/FreeBSD/ProcessPOSIX.cpp b/source/Plugins/Process/FreeBSD/ProcessPOSIX.cpp
deleted file mode 100644
index 360382e2e63a..000000000000
--- a/source/Plugins/Process/FreeBSD/ProcessPOSIX.cpp
+++ /dev/null
@@ -1,939 +0,0 @@
-//===-- ProcessPOSIX.cpp ----------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// C Includes
-#include <errno.h>
-
-// C++ Includes
-// Other libraries and framework includes
-#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Breakpoint/Watchpoint.h"
-#include "lldb/Core/Module.h"
-#include "lldb/Core/ModuleSpec.h"
-#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/State.h"
-#include "lldb/Host/FileSpec.h"
-#include "lldb/Host/Host.h"
-#include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Target/DynamicLoader.h"
-#include "lldb/Target/Platform.h"
-#include "lldb/Target/Target.h"
-
-#include "ProcessPOSIX.h"
-#include "ProcessPOSIXLog.h"
-#include "Plugins/Process/Utility/InferiorCallPOSIX.h"
-#include "POSIXThread.h"
-#include "ProcessMonitor.h"
-
-#include "lldb/Host/posix/Fcntl.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-//------------------------------------------------------------------------------
-// Constructors and destructors.
-
-ProcessPOSIX::ProcessPOSIX(Target& target, Listener &listener, UnixSignalsSP &unix_signals_sp)
- : Process(target, listener, unix_signals_sp),
- m_byte_order(lldb::endian::InlHostByteOrder()),
- m_monitor(NULL),
- m_module(NULL),
- m_message_mutex (Mutex::eMutexTypeRecursive),
- m_exit_now(false),
- m_seen_initial_stop()
-{
- // FIXME: Putting this code in the ctor and saving the byte order in a
- // member variable is a hack to avoid const qual issues in GetByteOrder.
- lldb::ModuleSP module = GetTarget().GetExecutableModule();
- if (module && module->GetObjectFile())
- m_byte_order = module->GetObjectFile()->GetByteOrder();
-}
-
-ProcessPOSIX::~ProcessPOSIX()
-{
- delete m_monitor;
-}
-
-//------------------------------------------------------------------------------
-// Process protocol.
-void
-ProcessPOSIX::Finalize()
-{
- Process::Finalize();
-
- if (m_monitor)
- m_monitor->StopMonitor();
-}
-
-bool
-ProcessPOSIX::CanDebug(Target &target, bool plugin_specified_by_name)
-{
- // For now we are just making sure the file exists for a given module
- ModuleSP exe_module_sp(target.GetExecutableModule());
- if (exe_module_sp.get())
- return exe_module_sp->GetFileSpec().Exists();
- // If there is no executable module, we return true since we might be preparing to attach.
- return true;
-}
-
-Error
-ProcessPOSIX::DoAttachToProcessWithID (lldb::pid_t pid, const ProcessAttachInfo &attach_info)
-{
- Error error;
- assert(m_monitor == NULL);
-
- Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
- if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
- log->Printf ("ProcessPOSIX::%s(pid = %" PRIi64 ")", __FUNCTION__, GetID());
-
- m_monitor = new ProcessMonitor(this, pid, error);
-
- if (!error.Success())
- return error;
-
- PlatformSP platform_sp (m_target.GetPlatform ());
- assert (platform_sp.get());
- if (!platform_sp)
- return error; // FIXME: Detatch?
-
- // Find out what we can about this process
- ProcessInstanceInfo process_info;
- platform_sp->GetProcessInfo (pid, process_info);
-
- // Resolve the executable module
- ModuleSP exe_module_sp;
- FileSpecList executable_search_paths (Target::GetDefaultExecutableSearchPaths());
- ModuleSpec exe_module_spec(process_info.GetExecutableFile(), m_target.GetArchitecture());
- error = platform_sp->ResolveExecutable(exe_module_spec,
- exe_module_sp,
- executable_search_paths.GetSize() ? &executable_search_paths : NULL);
- if (!error.Success())
- return error;
-
- // Fix the target architecture if necessary
- const ArchSpec &module_arch = exe_module_sp->GetArchitecture();
- if (module_arch.IsValid() && !m_target.GetArchitecture().IsExactMatch(module_arch))
- m_target.SetArchitecture(module_arch);
-
- // Initialize the target module list
- m_target.SetExecutableModule (exe_module_sp, true);
-
- SetSTDIOFileDescriptor(m_monitor->GetTerminalFD());
-
- SetID(pid);
-
- return error;
-}
-
-Error
-ProcessPOSIX::WillLaunch(Module* module)
-{
- Error error;
- return error;
-}
-
-FileSpec
-ProcessPOSIX::GetFileSpec(const lldb_private::FileAction *file_action,
- const FileSpec &default_file_spec,
- const FileSpec &dbg_pts_file_spec)
-{
- FileSpec file_spec{};
-
- if (file_action && file_action->GetAction() == FileAction::eFileActionOpen)
- {
- file_spec = file_action->GetFileSpec();
- // By default the stdio paths passed in will be pseudo-terminal
- // (/dev/pts). If so, convert to using a different default path
- // instead to redirect I/O to the debugger console. This should
- // also handle user overrides to /dev/null or a different file.
- if (!file_spec || file_spec == dbg_pts_file_spec)
- file_spec = default_file_spec;
- }
- return file_spec;
-}
-
-Error
-ProcessPOSIX::DoLaunch (Module *module,
- ProcessLaunchInfo &launch_info)
-{
- Error error;
- assert(m_monitor == NULL);
-
- FileSpec working_dir = launch_info.GetWorkingDirectory();
- if (working_dir &&
- (!working_dir.ResolvePath() ||
- working_dir.GetFileType() != FileSpec::eFileTypeDirectory))
- {
- error.SetErrorStringWithFormat("No such file or directory: %s",
- working_dir.GetCString());
- return error;
- }
-
- SetPrivateState(eStateLaunching);
-
- const lldb_private::FileAction *file_action;
-
- // Default of empty will mean to use existing open file descriptors
- FileSpec stdin_file_spec{};
- FileSpec stdout_file_spec{};
- FileSpec stderr_file_spec{};
-
- const FileSpec dbg_pts_file_spec{launch_info.GetPTY().GetSlaveName(NULL,0), false};
-
- file_action = launch_info.GetFileActionForFD (STDIN_FILENO);
- stdin_file_spec = GetFileSpec(file_action, stdin_file_spec, dbg_pts_file_spec);
-
- file_action = launch_info.GetFileActionForFD (STDOUT_FILENO);
- stdout_file_spec = GetFileSpec(file_action, stdout_file_spec, dbg_pts_file_spec);
-
- file_action = launch_info.GetFileActionForFD (STDERR_FILENO);
- stderr_file_spec = GetFileSpec(file_action, stderr_file_spec, dbg_pts_file_spec);
-
- m_monitor = new ProcessMonitor(this,
- module,
- launch_info.GetArguments().GetConstArgumentVector(),
- launch_info.GetEnvironmentEntries().GetConstArgumentVector(),
- stdin_file_spec,
- stdout_file_spec,
- stderr_file_spec,
- working_dir,
- launch_info,
- error);
-
- m_module = module;
-
- if (!error.Success())
- return error;
-
- int terminal = m_monitor->GetTerminalFD();
- if (terminal >= 0) {
- // The reader thread will close the file descriptor when done, so we pass it a copy.
- int stdio = fcntl(terminal, F_DUPFD_CLOEXEC, 0);
- if (stdio == -1) {
- error.SetErrorToErrno();
- return error;
- }
- SetSTDIOFileDescriptor(stdio);
- }
-
- SetID(m_monitor->GetPID());
- return error;
-}
-
-void
-ProcessPOSIX::DidLaunch()
-{
-}
-
-Error
-ProcessPOSIX::DoResume()
-{
- StateType state = GetPrivateState();
-
- assert(state == eStateStopped);
-
- SetPrivateState(eStateRunning);
-
- bool did_resume = false;
-
- Mutex::Locker lock(m_thread_list.GetMutex());
-
- uint32_t thread_count = m_thread_list.GetSize(false);
- for (uint32_t i = 0; i < thread_count; ++i)
- {
- POSIXThread *thread = static_cast<POSIXThread*>(
- m_thread_list.GetThreadAtIndex(i, false).get());
- did_resume = thread->Resume() || did_resume;
- }
- assert(did_resume && "Process resume failed!");
-
- return Error();
-}
-
-addr_t
-ProcessPOSIX::GetImageInfoAddress()
-{
- Target *target = &GetTarget();
- ObjectFile *obj_file = target->GetExecutableModule()->GetObjectFile();
- Address addr = obj_file->GetImageInfoAddress(target);
-
- if (addr.IsValid())
- return addr.GetLoadAddress(target);
- return LLDB_INVALID_ADDRESS;
-}
-
-Error
-ProcessPOSIX::DoHalt(bool &caused_stop)
-{
- Error error;
-
- if (IsStopped())
- {
- caused_stop = false;
- }
- else if (kill(GetID(), SIGSTOP))
- {
- caused_stop = false;
- error.SetErrorToErrno();
- }
- else
- {
- caused_stop = true;
- }
- return error;
-}
-
-Error
-ProcessPOSIX::DoSignal(int signal)
-{
- Error error;
-
- if (kill(GetID(), signal))
- error.SetErrorToErrno();
-
- return error;
-}
-
-Error
-ProcessPOSIX::DoDestroy()
-{
- Error error;
-
- if (!HasExited())
- {
- assert(m_monitor);
- m_exit_now = true;
- if (GetID() == LLDB_INVALID_PROCESS_ID)
- {
- error.SetErrorString("invalid process id");
- return error;
- }
- if (!m_monitor->Kill())
- {
- error.SetErrorToErrno();
- return error;
- }
-
- SetPrivateState(eStateExited);
- }
-
- return error;
-}
-
-void
-ProcessPOSIX::DoDidExec()
-{
- Target *target = &GetTarget();
- if (target)
- {
- PlatformSP platform_sp (target->GetPlatform());
- assert (platform_sp.get());
- if (platform_sp)
- {
- ProcessInstanceInfo process_info;
- platform_sp->GetProcessInfo(GetID(), process_info);
- ModuleSP exe_module_sp;
- ModuleSpec exe_module_spec(process_info.GetExecutableFile(), target->GetArchitecture());
- FileSpecList executable_search_paths (Target::GetDefaultExecutableSearchPaths());
- Error error = platform_sp->ResolveExecutable(exe_module_spec,
- exe_module_sp,
- executable_search_paths.GetSize() ? &executable_search_paths : NULL);
- if (!error.Success())
- return;
- target->SetExecutableModule(exe_module_sp, true);
- }
- }
-}
-
-void
-ProcessPOSIX::SendMessage(const ProcessMessage &message)
-{
- Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
-
- Mutex::Locker lock(m_message_mutex);
-
- Mutex::Locker thread_lock(m_thread_list.GetMutex());
-
- POSIXThread *thread = static_cast<POSIXThread*>(
- m_thread_list.FindThreadByID(message.GetTID(), false).get());
-
- switch (message.GetKind())
- {
- case ProcessMessage::eInvalidMessage:
- return;
-
- case ProcessMessage::eAttachMessage:
- SetPrivateState(eStateStopped);
- return;
-
- case ProcessMessage::eLimboMessage:
- assert(thread);
- thread->SetState(eStateStopped);
- if (message.GetTID() == GetID())
- {
- m_exit_status = message.GetExitStatus();
- if (m_exit_now)
- {
- SetPrivateState(eStateExited);
- m_monitor->Detach(GetID());
- }
- else
- {
- SetPrivateState(eStateStopped);
- }
- }
- else
- {
- SetPrivateState(eStateStopped);
- }
- break;
-
- case ProcessMessage::eExitMessage:
- if (thread != nullptr)
- thread->SetState(eStateExited);
- else
- {
- if (log)
- log->Warning ("ProcessPOSIX::%s eExitMessage for TID %" PRIu64 " failed to find a thread to mark as eStateExited, ignoring", __FUNCTION__, message.GetTID ());
- }
-
- // FIXME: I'm not sure we need to do this.
- if (message.GetTID() == GetID())
- {
- SetExitStatus(message.GetExitStatus(), NULL);
- }
- else if (!IsAThreadRunning())
- SetPrivateState(eStateStopped);
- break;
-
- case ProcessMessage::eSignalMessage:
- case ProcessMessage::eSignalDeliveredMessage:
- if (message.GetSignal() == SIGSTOP &&
- AddThreadForInitialStopIfNeeded(message.GetTID()))
- return;
- // Intentional fall-through
-
- case ProcessMessage::eBreakpointMessage:
- case ProcessMessage::eTraceMessage:
- case ProcessMessage::eWatchpointMessage:
- case ProcessMessage::eCrashMessage:
- assert(thread);
- thread->SetState(eStateStopped);
- SetPrivateState(eStateStopped);
- break;
-
- case ProcessMessage::eNewThreadMessage:
- {
- lldb::tid_t new_tid = message.GetChildTID();
- if (WaitingForInitialStop(new_tid))
- {
- m_monitor->WaitForInitialTIDStop(new_tid);
- }
- assert(thread);
- thread->SetState(eStateStopped);
- SetPrivateState(eStateStopped);
- break;
- }
-
- case ProcessMessage::eExecMessage:
- {
- assert(thread);
- thread->SetState(eStateStopped);
- SetPrivateState(eStateStopped);
- break;
- }
- }
-
-
- m_message_queue.push(message);
-}
-
-bool
-ProcessPOSIX::AddThreadForInitialStopIfNeeded(lldb::tid_t stop_tid)
-{
- bool added_to_set = false;
- ThreadStopSet::iterator it = m_seen_initial_stop.find(stop_tid);
- if (it == m_seen_initial_stop.end())
- {
- m_seen_initial_stop.insert(stop_tid);
- added_to_set = true;
- }
- return added_to_set;
-}
-
-bool
-ProcessPOSIX::WaitingForInitialStop(lldb::tid_t stop_tid)
-{
- return (m_seen_initial_stop.find(stop_tid) == m_seen_initial_stop.end());
-}
-
-POSIXThread *
-ProcessPOSIX::CreateNewPOSIXThread(lldb_private::Process &process, lldb::tid_t tid)
-{
- return new POSIXThread(process, tid);
-}
-
-void
-ProcessPOSIX::RefreshStateAfterStop()
-{
- Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
- if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
- log->Printf ("ProcessPOSIX::%s(), message_queue size = %d", __FUNCTION__, (int)m_message_queue.size());
-
- Mutex::Locker lock(m_message_mutex);
-
- // This method used to only handle one message. Changing it to loop allows
- // it to handle the case where we hit a breakpoint while handling a different
- // breakpoint.
- while (!m_message_queue.empty())
- {
- ProcessMessage &message = m_message_queue.front();
-
- // Resolve the thread this message corresponds to and pass it along.
- lldb::tid_t tid = message.GetTID();
- if (log)
- log->Printf ("ProcessPOSIX::%s(), message_queue size = %d, pid = %" PRIi64, __FUNCTION__, (int)m_message_queue.size(), tid);
-
- if (message.GetKind() == ProcessMessage::eNewThreadMessage)
- {
- if (log)
- log->Printf ("ProcessPOSIX::%s() adding thread, tid = %" PRIi64, __FUNCTION__, message.GetChildTID());
- lldb::tid_t child_tid = message.GetChildTID();
- ThreadSP thread_sp;
- thread_sp.reset(CreateNewPOSIXThread(*this, child_tid));
-
- Mutex::Locker lock(m_thread_list.GetMutex());
-
- m_thread_list.AddThread(thread_sp);
- }
-
- m_thread_list.RefreshStateAfterStop();
-
- POSIXThread *thread = static_cast<POSIXThread*>(
- GetThreadList().FindThreadByID(tid, false).get());
- if (thread)
- thread->Notify(message);
-
- if (message.GetKind() == ProcessMessage::eExitMessage)
- {
- // FIXME: We should tell the user about this, but the limbo message is probably better for that.
- if (log)
- log->Printf ("ProcessPOSIX::%s() removing thread, tid = %" PRIi64, __FUNCTION__, tid);
-
- Mutex::Locker lock(m_thread_list.GetMutex());
-
- ThreadSP thread_sp = m_thread_list.RemoveThreadByID(tid, false);
- thread_sp.reset();
- m_seen_initial_stop.erase(tid);
- }
-
- m_message_queue.pop();
- }
-}
-
-bool
-ProcessPOSIX::IsAlive()
-{
- StateType state = GetPrivateState();
- return state != eStateDetached
- && state != eStateExited
- && state != eStateInvalid
- && state != eStateUnloaded;
-}
-
-size_t
-ProcessPOSIX::DoReadMemory(addr_t vm_addr,
- void *buf, size_t size, Error &error)
-{
- assert(m_monitor);
- return m_monitor->ReadMemory(vm_addr, buf, size, error);
-}
-
-size_t
-ProcessPOSIX::DoWriteMemory(addr_t vm_addr, const void *buf, size_t size,
- Error &error)
-{
- assert(m_monitor);
- return m_monitor->WriteMemory(vm_addr, buf, size, error);
-}
-
-addr_t
-ProcessPOSIX::DoAllocateMemory(size_t size, uint32_t permissions,
- Error &error)
-{
- addr_t allocated_addr = LLDB_INVALID_ADDRESS;
-
- unsigned prot = 0;
- if (permissions & lldb::ePermissionsReadable)
- prot |= eMmapProtRead;
- if (permissions & lldb::ePermissionsWritable)
- prot |= eMmapProtWrite;
- if (permissions & lldb::ePermissionsExecutable)
- prot |= eMmapProtExec;
-
- if (InferiorCallMmap(this, allocated_addr, 0, size, prot,
- eMmapFlagsAnon | eMmapFlagsPrivate, -1, 0)) {
- m_addr_to_mmap_size[allocated_addr] = size;
- error.Clear();
- } else {
- allocated_addr = LLDB_INVALID_ADDRESS;
- error.SetErrorStringWithFormat("unable to allocate %zu bytes of memory with permissions %s", size, GetPermissionsAsCString (permissions));
- }
-
- return allocated_addr;
-}
-
-Error
-ProcessPOSIX::DoDeallocateMemory(lldb::addr_t addr)
-{
- Error error;
- MMapMap::iterator pos = m_addr_to_mmap_size.find(addr);
- if (pos != m_addr_to_mmap_size.end() &&
- InferiorCallMunmap(this, addr, pos->second))
- m_addr_to_mmap_size.erase (pos);
- else
- error.SetErrorStringWithFormat("unable to deallocate memory at 0x%" PRIx64, addr);
-
- return error;
-}
-
-size_t
-ProcessPOSIX::GetSoftwareBreakpointTrapOpcode(BreakpointSite* bp_site)
-{
- static const uint8_t g_aarch64_opcode[] = { 0x00, 0x00, 0x20, 0xD4 };
- static const uint8_t g_i386_opcode[] = { 0xCC };
-
- ArchSpec arch = GetTarget().GetArchitecture();
- const uint8_t *opcode = NULL;
- size_t opcode_size = 0;
-
- switch (arch.GetMachine())
- {
- default:
- assert(false && "CPU type not supported!");
- break;
-
- case llvm::Triple::arm:
- {
- // The ARM reference recommends the use of 0xe7fddefe and 0xdefe
- // but the linux kernel does otherwise.
- static const uint8_t g_arm_breakpoint_opcode[] = { 0xf0, 0x01, 0xf0, 0xe7 };
- static const uint8_t g_thumb_breakpoint_opcode[] = { 0x01, 0xde };
-
- lldb::BreakpointLocationSP bp_loc_sp (bp_site->GetOwnerAtIndex (0));
- AddressClass addr_class = eAddressClassUnknown;
-
- if (bp_loc_sp)
- addr_class = bp_loc_sp->GetAddress ().GetAddressClass ();
-
- if (addr_class == eAddressClassCodeAlternateISA
- || (addr_class == eAddressClassUnknown
- && bp_loc_sp->GetAddress().GetOffset() & 1))
- {
- opcode = g_thumb_breakpoint_opcode;
- opcode_size = sizeof(g_thumb_breakpoint_opcode);
- }
- else
- {
- opcode = g_arm_breakpoint_opcode;
- opcode_size = sizeof(g_arm_breakpoint_opcode);
- }
- }
- break;
- case llvm::Triple::aarch64:
- opcode = g_aarch64_opcode;
- opcode_size = sizeof(g_aarch64_opcode);
- break;
-
- case llvm::Triple::x86:
- case llvm::Triple::x86_64:
- opcode = g_i386_opcode;
- opcode_size = sizeof(g_i386_opcode);
- break;
- }
-
- bp_site->SetTrapOpcode(opcode, opcode_size);
- return opcode_size;
-}
-
-Error
-ProcessPOSIX::EnableBreakpointSite(BreakpointSite *bp_site)
-{
- return EnableSoftwareBreakpoint(bp_site);
-}
-
-Error
-ProcessPOSIX::DisableBreakpointSite(BreakpointSite *bp_site)
-{
- return DisableSoftwareBreakpoint(bp_site);
-}
-
-Error
-ProcessPOSIX::EnableWatchpoint(Watchpoint *wp, bool notify)
-{
- Error error;
- if (wp)
- {
- user_id_t watchID = wp->GetID();
- addr_t addr = wp->GetLoadAddress();
- Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
- if (log)
- log->Printf ("ProcessPOSIX::EnableWatchpoint(watchID = %" PRIu64 ")",
- watchID);
- if (wp->IsEnabled())
- {
- if (log)
- log->Printf("ProcessPOSIX::EnableWatchpoint(watchID = %" PRIu64
- ") addr = 0x%8.8" PRIx64 ": watchpoint already enabled.",
- watchID, (uint64_t)addr);
- return error;
- }
-
- // Try to find a vacant watchpoint slot in the inferiors' main thread
- uint32_t wp_hw_index = LLDB_INVALID_INDEX32;
- Mutex::Locker lock(m_thread_list.GetMutex());
- POSIXThread *thread = static_cast<POSIXThread*>(
- m_thread_list.GetThreadAtIndex(0, false).get());
-
- if (thread)
- wp_hw_index = thread->FindVacantWatchpointIndex();
-
- if (wp_hw_index == LLDB_INVALID_INDEX32)
- {
- error.SetErrorString("Setting hardware watchpoint failed.");
- }
- else
- {
- wp->SetHardwareIndex(wp_hw_index);
- bool wp_enabled = true;
- uint32_t thread_count = m_thread_list.GetSize(false);
- for (uint32_t i = 0; i < thread_count; ++i)
- {
- thread = static_cast<POSIXThread*>(
- m_thread_list.GetThreadAtIndex(i, false).get());
- if (thread)
- wp_enabled &= thread->EnableHardwareWatchpoint(wp);
- else
- wp_enabled = false;
- }
- if (wp_enabled)
- {
- wp->SetEnabled(true, notify);
- return error;
- }
- else
- {
- // Watchpoint enabling failed on at least one
- // of the threads so roll back all of them
- DisableWatchpoint(wp, false);
- error.SetErrorString("Setting hardware watchpoint failed");
- }
- }
- }
- else
- error.SetErrorString("Watchpoint argument was NULL.");
- return error;
-}
-
-Error
-ProcessPOSIX::DisableWatchpoint(Watchpoint *wp, bool notify)
-{
- Error error;
- if (wp)
- {
- user_id_t watchID = wp->GetID();
- addr_t addr = wp->GetLoadAddress();
- Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
- if (log)
- log->Printf("ProcessPOSIX::DisableWatchpoint(watchID = %" PRIu64 ")",
- watchID);
- if (!wp->IsEnabled())
- {
- if (log)
- log->Printf("ProcessPOSIX::DisableWatchpoint(watchID = %" PRIu64
- ") addr = 0x%8.8" PRIx64 ": watchpoint already disabled.",
- watchID, (uint64_t)addr);
- // This is needed (for now) to keep watchpoints disabled correctly
- wp->SetEnabled(false, notify);
- return error;
- }
-
- if (wp->IsHardware())
- {
- bool wp_disabled = true;
- Mutex::Locker lock(m_thread_list.GetMutex());
- uint32_t thread_count = m_thread_list.GetSize(false);
- for (uint32_t i = 0; i < thread_count; ++i)
- {
- POSIXThread *thread = static_cast<POSIXThread*>(
- m_thread_list.GetThreadAtIndex(i, false).get());
- if (thread)
- wp_disabled &= thread->DisableHardwareWatchpoint(wp);
- else
- wp_disabled = false;
- }
- if (wp_disabled)
- {
- wp->SetHardwareIndex(LLDB_INVALID_INDEX32);
- wp->SetEnabled(false, notify);
- return error;
- }
- else
- error.SetErrorString("Disabling hardware watchpoint failed");
- }
- }
- else
- error.SetErrorString("Watchpoint argument was NULL.");
- return error;
-}
-
-Error
-ProcessPOSIX::GetWatchpointSupportInfo(uint32_t &num)
-{
- Error error;
- Mutex::Locker lock(m_thread_list.GetMutex());
- POSIXThread *thread = static_cast<POSIXThread*>(
- m_thread_list.GetThreadAtIndex(0, false).get());
- if (thread)
- num = thread->NumSupportedHardwareWatchpoints();
- else
- error.SetErrorString("Process does not exist.");
- return error;
-}
-
-Error
-ProcessPOSIX::GetWatchpointSupportInfo(uint32_t &num, bool &after)
-{
- Error error = GetWatchpointSupportInfo(num);
- // Watchpoints trigger and halt the inferior after
- // the corresponding instruction has been executed.
- after = true;
- return error;
-}
-
-uint32_t
-ProcessPOSIX::UpdateThreadListIfNeeded()
-{
- Mutex::Locker lock(m_thread_list.GetMutex());
- // Do not allow recursive updates.
- return m_thread_list.GetSize(false);
-}
-
-bool
-ProcessPOSIX::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list)
-{
- Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
- if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
- log->Printf ("ProcessPOSIX::%s() (pid = %" PRIi64 ")", __FUNCTION__, GetID());
-
- bool has_updated = false;
- // Update the process thread list with this new thread.
- // FIXME: We should be using tid, not pid.
- assert(m_monitor);
- ThreadSP thread_sp (old_thread_list.FindThreadByID (GetID(), false));
- if (!thread_sp) {
- thread_sp.reset(CreateNewPOSIXThread(*this, GetID()));
- has_updated = true;
- }
-
- if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
- log->Printf ("ProcessPOSIX::%s() updated pid = %" PRIi64, __FUNCTION__, GetID());
- new_thread_list.AddThread(thread_sp);
-
- return has_updated; // the list has been updated
-}
-
-ByteOrder
-ProcessPOSIX::GetByteOrder() const
-{
- // FIXME: We should be able to extract this value directly. See comment in
- // ProcessPOSIX().
- return m_byte_order;
-}
-
-size_t
-ProcessPOSIX::PutSTDIN(const char *buf, size_t len, Error &error)
-{
- ssize_t status;
- if ((status = write(m_monitor->GetTerminalFD(), buf, len)) < 0)
- {
- error.SetErrorToErrno();
- return 0;
- }
- return status;
-}
-
-//------------------------------------------------------------------------------
-// Utility functions.
-
-bool
-ProcessPOSIX::HasExited()
-{
- switch (GetPrivateState())
- {
- default:
- break;
-
- case eStateDetached:
- case eStateExited:
- return true;
- }
-
- return false;
-}
-
-bool
-ProcessPOSIX::IsStopped()
-{
- switch (GetPrivateState())
- {
- default:
- break;
-
- case eStateStopped:
- case eStateCrashed:
- case eStateSuspended:
- return true;
- }
-
- return false;
-}
-
-bool
-ProcessPOSIX::IsAThreadRunning()
-{
- bool is_running = false;
- Mutex::Locker lock(m_thread_list.GetMutex());
- uint32_t thread_count = m_thread_list.GetSize(false);
- for (uint32_t i = 0; i < thread_count; ++i)
- {
- POSIXThread *thread = static_cast<POSIXThread*>(
- m_thread_list.GetThreadAtIndex(i, false).get());
- StateType thread_state = thread->GetState();
- if (thread_state == eStateRunning || thread_state == eStateStepping)
- {
- is_running = true;
- break;
- }
- }
- return is_running;
-}
-
-const DataBufferSP
-ProcessPOSIX::GetAuxvData ()
-{
- // If we're the local platform, we can ask the host for auxv data.
- PlatformSP platform_sp = m_target.GetPlatform ();
- if (platform_sp && platform_sp->IsHost ())
- return lldb_private::Host::GetAuxvData(this);
-
- // Somewhat unexpected - the process is not running locally or we don't have a platform.
- assert (false && "no platform or not the host - how did we get here with ProcessPOSIX?");
- return DataBufferSP ();
-}
diff --git a/source/Plugins/Process/FreeBSD/ProcessPOSIX.h b/source/Plugins/Process/FreeBSD/ProcessPOSIX.h
deleted file mode 100644
index 627017c547dc..000000000000
--- a/source/Plugins/Process/FreeBSD/ProcessPOSIX.h
+++ /dev/null
@@ -1,205 +0,0 @@
-//===-- ProcessPOSIX.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_ProcessPOSIX_H_
-#define liblldb_ProcessPOSIX_H_
-
-// C Includes
-
-// C++ Includes
-#include <queue>
-#include <set>
-
-// Other libraries and framework includes
-#include "lldb/Target/Process.h"
-#include "ProcessMessage.h"
-
-class ProcessMonitor;
-class POSIXThread;
-
-class ProcessPOSIX :
- public lldb_private::Process
-{
-public:
-
- //------------------------------------------------------------------
- // Constructors and destructors
- //------------------------------------------------------------------
- ProcessPOSIX(lldb_private::Target& target,
- lldb_private::Listener &listener,
- lldb::UnixSignalsSP &unix_signals_sp);
-
- virtual
- ~ProcessPOSIX();
-
- //------------------------------------------------------------------
- // Process protocol.
- //------------------------------------------------------------------
- void
- Finalize() override;
-
- bool
- CanDebug(lldb_private::Target &target, bool plugin_specified_by_name) override;
-
- lldb_private::Error
- WillLaunch(lldb_private::Module *module) override;
-
- lldb_private::Error
- DoAttachToProcessWithID (lldb::pid_t pid, const lldb_private::ProcessAttachInfo &attach_info) override;
-
- lldb_private::Error
- DoLaunch (lldb_private::Module *exe_module,
- lldb_private::ProcessLaunchInfo &launch_info) override;
-
- void
- DidLaunch() override;
-
- lldb_private::Error
- DoResume() override;
-
- lldb_private::Error
- DoHalt(bool &caused_stop) override;
-
- lldb_private::Error
- DoDetach(bool keep_stopped) override = 0;
-
- lldb_private::Error
- DoSignal(int signal) override;
-
- lldb_private::Error
- DoDestroy() override;
-
- void
- DoDidExec() override;
-
- void
- RefreshStateAfterStop() override;
-
- bool
- IsAlive() override;
-
- size_t
- DoReadMemory(lldb::addr_t vm_addr,
- void *buf,
- size_t size,
- lldb_private::Error &error) override;
-
- size_t
- DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
- lldb_private::Error &error) override;
-
- lldb::addr_t
- DoAllocateMemory(size_t size, uint32_t permissions,
- lldb_private::Error &error) override;
-
- lldb_private::Error
- DoDeallocateMemory(lldb::addr_t ptr) override;
-
- virtual size_t
- GetSoftwareBreakpointTrapOpcode(lldb_private::BreakpointSite* bp_site);
-
- lldb_private::Error
- EnableBreakpointSite(lldb_private::BreakpointSite *bp_site) override;
-
- lldb_private::Error
- DisableBreakpointSite(lldb_private::BreakpointSite *bp_site) override;
-
- lldb_private::Error
- EnableWatchpoint(lldb_private::Watchpoint *wp, bool notify = true) override;
-
- lldb_private::Error
- DisableWatchpoint(lldb_private::Watchpoint *wp, bool notify = true) override;
-
- lldb_private::Error
- GetWatchpointSupportInfo(uint32_t &num) override;
-
- lldb_private::Error
- GetWatchpointSupportInfo(uint32_t &num, bool &after) override;
-
- virtual uint32_t
- UpdateThreadListIfNeeded();
-
- bool
- UpdateThreadList(lldb_private::ThreadList &old_thread_list,
- lldb_private::ThreadList &new_thread_list) override = 0;
-
- virtual lldb::ByteOrder
- GetByteOrder() const;
-
- lldb::addr_t
- GetImageInfoAddress() override;
-
- size_t
- PutSTDIN(const char *buf, size_t len, lldb_private::Error &error) override;
-
- const lldb::DataBufferSP
- GetAuxvData () override;
-
- //--------------------------------------------------------------------------
- // ProcessPOSIX internal API.
-
- /// Registers the given message with this process.
- virtual void
- SendMessage(const ProcessMessage &message);
-
- ProcessMonitor &
- GetMonitor() { assert(m_monitor); return *m_monitor; }
-
- lldb_private::FileSpec
- GetFileSpec(const lldb_private::FileAction *file_action,
- const lldb_private::FileSpec &default_file_spec,
- const lldb_private::FileSpec &dbg_pts_file_spec);
-
- /// Adds the thread to the list of threads for which we have received the initial stopping signal.
- /// The \p stop_tid parameter indicates the thread which the stop happened for.
- bool
- AddThreadForInitialStopIfNeeded(lldb::tid_t stop_tid);
-
- bool
- WaitingForInitialStop(lldb::tid_t stop_tid);
-
- virtual POSIXThread *
- CreateNewPOSIXThread(lldb_private::Process &process, lldb::tid_t tid);
-
-protected:
- /// Target byte order.
- lldb::ByteOrder m_byte_order;
-
- /// Process monitor;
- ProcessMonitor *m_monitor;
-
- /// The module we are executing.
- lldb_private::Module *m_module;
-
- /// Message queue notifying this instance of inferior process state changes.
- lldb_private::Mutex m_message_mutex;
- std::queue<ProcessMessage> m_message_queue;
-
- /// Drive any exit events to completion.
- bool m_exit_now;
-
- /// Returns true if the process has exited.
- bool HasExited();
-
- /// Returns true if the process is stopped.
- bool IsStopped();
-
- /// Returns true if at least one running is currently running
- bool IsAThreadRunning();
-
- typedef std::map<lldb::addr_t, lldb::addr_t> MMapMap;
- MMapMap m_addr_to_mmap_size;
-
- typedef std::set<lldb::tid_t> ThreadStopSet;
- /// Every thread begins with a stop signal. This keeps track
- /// of the threads for which we have received the stop signal.
- ThreadStopSet m_seen_initial_stop;
-};
-
-#endif // liblldb_MacOSXProcess_H_
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIX.h
index 6ddd9cfe4c21..6ddd9cfe4c21 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX.h
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIX.h
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp
index ac2f81d53929..9922311fd9db 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp
@@ -12,7 +12,7 @@
#include "lldb/Target/Thread.h"
#include "RegisterContextPOSIX_arm.h"
-#include "ProcessPOSIX.h"
+#include "ProcessFreeBSD.h"
#include "RegisterContextPOSIXProcessMonitor_arm.h"
#include "ProcessMonitor.h"
@@ -32,7 +32,7 @@ ProcessMonitor &
RegisterContextPOSIXProcessMonitor_arm::GetMonitor()
{
ProcessSP base = CalculateProcess();
- ProcessPOSIX *process = static_cast<ProcessPOSIX*>(base.get());
+ ProcessFreeBSD *process = static_cast<ProcessFreeBSD*>(base.get());
return process->GetMonitor();
}
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.h
index 12a43c77837c..3787502a390c 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.h
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.h
@@ -10,6 +10,7 @@
#ifndef liblldb_RegisterContextPOSIXProcessMonitor_arm_H_
#define liblldb_RegisterContextPOSIXProcessMonitor_arm_H_
+#include "RegisterContextPOSIX.h"
#include "Plugins/Process/Utility/RegisterContextPOSIX_arm.h"
class RegisterContextPOSIXProcessMonitor_arm:
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp
index d79def52499f..012f4b6e1555 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp
@@ -12,7 +12,7 @@
#include "lldb/Target/Thread.h"
#include "Plugins/Process/Utility/RegisterContextPOSIX_arm64.h"
-#include "ProcessPOSIX.h"
+#include "ProcessFreeBSD.h"
#include "ProcessMonitor.h"
#include "RegisterContextPOSIXProcessMonitor_arm64.h"
@@ -32,7 +32,7 @@ ProcessMonitor &
RegisterContextPOSIXProcessMonitor_arm64::GetMonitor()
{
lldb::ProcessSP base = CalculateProcess();
- ProcessPOSIX *process = static_cast<ProcessPOSIX*>(base.get());
+ ProcessFreeBSD *process = static_cast<ProcessFreeBSD*>(base.get());
return process->GetMonitor();
}
@@ -260,13 +260,11 @@ RegisterContextPOSIXProcessMonitor_arm64::HardwareSingleStep(bool enable)
bool
RegisterContextPOSIXProcessMonitor_arm64::UpdateAfterBreakpoint()
{
- // PC points one byte past the int3 responsible for the breakpoint.
lldb::addr_t pc;
if ((pc = GetPC()) == LLDB_INVALID_ADDRESS)
return false;
- SetPC(pc - 1);
return true;
}
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h
index eb24d4852ab8..729385c4a76e 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h
@@ -10,6 +10,7 @@
#ifndef liblldb_RegisterContextPOSIXProcessMonitor_arm64_H_
#define liblldb_RegisterContextPOSIXProcessMonitor_arm64_H_
+#include "RegisterContextPOSIX.h"
#include "Plugins/Process/Utility/RegisterContextPOSIX_arm64.h"
class RegisterContextPOSIXProcessMonitor_arm64:
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp
index 893a0f22b6f8..eeada4b16337 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp
@@ -12,7 +12,7 @@
#include "lldb/Target/Thread.h"
#include "Plugins/Process/Utility/RegisterContextPOSIX_mips64.h"
-#include "ProcessPOSIX.h"
+#include "ProcessFreeBSD.h"
#include "ProcessMonitor.h"
#include "RegisterContextPOSIXProcessMonitor_mips64.h"
@@ -32,7 +32,7 @@ ProcessMonitor &
RegisterContextPOSIXProcessMonitor_mips64::GetMonitor()
{
ProcessSP base = CalculateProcess();
- ProcessPOSIX *process = static_cast<ProcessPOSIX*>(base.get());
+ ProcessFreeBSD *process = static_cast<ProcessFreeBSD*>(base.get());
return process->GetMonitor();
}
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h
index 79e4468b1adf..e61621bec197 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h
@@ -10,6 +10,7 @@
#ifndef liblldb_RegisterContextPOSIXProcessMonitor_mips64_H_
#define liblldb_RegisterContextPOSIXProcessMonitor_mips64_H_
+#include "RegisterContextPOSIX.h"
#include "Plugins/Process/Utility/RegisterContextPOSIX_mips64.h"
class RegisterContextPOSIXProcessMonitor_mips64:
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp
index 8c12b62a202f..321e6ea262ce 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp
@@ -12,7 +12,7 @@
#include "lldb/Target/Thread.h"
#include "RegisterContextPOSIX_powerpc.h"
-#include "ProcessPOSIX.h"
+#include "ProcessFreeBSD.h"
#include "RegisterContextPOSIXProcessMonitor_powerpc.h"
#include "ProcessMonitor.h"
@@ -32,7 +32,7 @@ ProcessMonitor &
RegisterContextPOSIXProcessMonitor_powerpc::GetMonitor()
{
ProcessSP base = CalculateProcess();
- ProcessPOSIX *process = static_cast<ProcessPOSIX*>(base.get());
+ ProcessFreeBSD *process = static_cast<ProcessFreeBSD*>(base.get());
return process->GetMonitor();
}
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.h
index 5c686df4836f..ff1d0f36171b 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.h
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.h
@@ -10,6 +10,7 @@
#ifndef liblldb_RegisterContextPOSIXProcessMonitor_powerpc_H_
#define liblldb_RegisterContextPOSIXProcessMonitor_powerpc_H_
+#include "RegisterContextPOSIX.h"
#include "Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h"
class RegisterContextPOSIXProcessMonitor_powerpc:
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp
index 9245441f659f..31b9e7a38b21 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp
@@ -11,7 +11,7 @@
#include "lldb/Core/RegisterValue.h"
#include "lldb/Target/Thread.h"
-#include "Plugins/Process/FreeBSD/ProcessPOSIX.h"
+#include "Plugins/Process/FreeBSD/ProcessFreeBSD.h"
#include "RegisterContextPOSIXProcessMonitor_x86.h"
#include "Plugins/Process/FreeBSD/ProcessMonitor.h"
@@ -58,13 +58,16 @@ RegisterContextPOSIXProcessMonitor_x86_64::RegisterContextPOSIXProcessMonitor_x8
lldb_private::RegisterInfoInterface *register_info)
: RegisterContextPOSIX_x86(thread, concrete_frame_idx, register_info)
{
+ // Store byte offset of fctrl (i.e. first register of FPR) wrt 'UserArea'
+ const RegisterInfo *reg_info_fctrl = GetRegisterInfoByName("fctrl");
+ m_fctrl_offset_in_userarea = reg_info_fctrl->byte_offset;
}
ProcessMonitor &
RegisterContextPOSIXProcessMonitor_x86_64::GetMonitor()
{
ProcessSP base = CalculateProcess();
- ProcessPOSIX *process = static_cast<ProcessPOSIX*>(base.get());
+ ProcessFreeBSD *process = static_cast<ProcessFreeBSD*>(base.get());
return process->GetMonitor();
}
@@ -254,10 +257,20 @@ RegisterContextPOSIXProcessMonitor_x86_64::ReadRegister(const RegisterInfo *reg_
}
// Get pointer to m_fpr.xstate.fxsave variable and set the data from it.
- assert (reg_info->byte_offset < sizeof(m_fpr));
- uint8_t *src = (uint8_t *)&m_fpr + reg_info->byte_offset;
+ // Byte offsets of all registers are calculated wrt 'UserArea' structure.
+ // However, ReadFPR() reads fpu registers {using ptrace(PT_GETFPREGS,..)}
+ // and stores them in 'm_fpr' (of type FPR structure). To extract values of fpu
+ // registers, m_fpr should be read at byte offsets calculated wrt to FPR structure.
+
+ // Since, FPR structure is also one of the member of UserArea structure.
+ // byte_offset(fpu wrt FPR) = byte_offset(fpu wrt UserArea) - byte_offset(fctrl wrt UserArea)
+ assert ( (reg_info->byte_offset - m_fctrl_offset_in_userarea) < sizeof(m_fpr));
+ uint8_t *src = (uint8_t *)&m_fpr + reg_info->byte_offset - m_fctrl_offset_in_userarea;
switch (reg_info->byte_size)
{
+ case 1:
+ value.SetUInt8(*(uint8_t *)src);
+ return true;
case 2:
value.SetUInt16(*(uint16_t *)src);
return true;
@@ -308,10 +321,20 @@ RegisterContextPOSIXProcessMonitor_x86_64::WriteRegister(const RegisterInfo *reg
else
{
// Get pointer to m_fpr.xstate.fxsave variable and set the data to it.
- assert (reg_info->byte_offset < sizeof(m_fpr));
- uint8_t *dst = (uint8_t *)&m_fpr + reg_info->byte_offset;
+ // Byte offsets of all registers are calculated wrt 'UserArea' structure.
+ // However, WriteFPR() takes m_fpr (of type FPR structure) and writes only fpu
+ // registers using ptrace(PT_SETFPREGS,..) API. Hence fpu registers should
+ // be written in m_fpr at byte offsets calculated wrt FPR structure.
+
+ // Since, FPR structure is also one of the member of UserArea structure.
+ // byte_offset(fpu wrt FPR) = byte_offset(fpu wrt UserArea) - byte_offset(fctrl wrt UserArea)
+ assert ( (reg_info->byte_offset - m_fctrl_offset_in_userarea) < sizeof(m_fpr));
+ uint8_t *dst = (uint8_t *)&m_fpr + reg_info->byte_offset - m_fctrl_offset_in_userarea;
switch (reg_info->byte_size)
{
+ case 1:
+ *(uint8_t *)dst = value.GetAsUInt8();
+ break;
case 2:
*(uint16_t *)dst = value.GetAsUInt16();
break;
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h
index 2afb195c4c36..f55d917ee75d 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h
@@ -10,6 +10,7 @@
#ifndef liblldb_RegisterContextPOSIXProcessMonitor_x86_H_
#define liblldb_RegisterContextPOSIXProcessMonitor_x86_H_
+#include "RegisterContextPOSIX.h"
#include "Plugins/Process/Utility/RegisterContextPOSIX_x86.h"
class RegisterContextPOSIXProcessMonitor_x86_64:
@@ -90,6 +91,7 @@ protected:
private:
ProcessMonitor &
GetMonitor();
+ uint32_t m_fctrl_offset_in_userarea; // Offset of 'fctrl' in 'UserArea' Structure
};
#endif
diff --git a/source/Plugins/Process/POSIX/CrashReason.cpp b/source/Plugins/Process/POSIX/CrashReason.cpp
index 6de13f470c5e..44409a4ce552 100644
--- a/source/Plugins/Process/POSIX/CrashReason.cpp
+++ b/source/Plugins/Process/POSIX/CrashReason.cpp
@@ -28,11 +28,12 @@ GetCrashReasonForSIGSEGV(const siginfo_t& info)
switch (info.si_code)
{
+#ifdef SI_KERNEL
case SI_KERNEL:
- // Linux will occasionally send spurious SI_KERNEL codes.
- // (this is poorly documented in sigaction)
+ // Some platforms will occasionally send nonstandard spurious SI_KERNEL codes.
// One way to get this is via unaligned SIMD loads.
return CrashReason::eInvalidAddress; // for lack of anything better
+#endif
case SEGV_MAPERR:
return CrashReason::eInvalidAddress;
case SEGV_ACCERR:
diff --git a/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp b/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
index 4eff442c1a0d..26de4b549c9f 100644
--- a/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ b/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -99,7 +99,7 @@ DynamicRegisterInfo::SetRegisterInfo(const StructuredData::Dictionary &dict, con
return 0;
}
- // { 'name':'rcx' , 'bitsize' : 64, 'offset' : 16, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 2,
+ // { 'name':'rcx' , 'bitsize' : 64, 'offset' : 16, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'ehframe' : 2,
// 'dwarf' : 2, 'generic':'arg4', 'alt-name':'arg4', },
RegisterInfo reg_info;
std::vector<uint32_t> value_regs;
@@ -325,8 +325,12 @@ DynamicRegisterInfo::SetRegisterInfo(const StructuredData::Dictionary &dict, con
// Fill in the register numbers
reg_info.kinds[lldb::eRegisterKindLLDB] = i;
- reg_info.kinds[lldb::eRegisterKindGDB] = i;
- reg_info_dict->GetValueForKeyAsInteger("gcc", reg_info.kinds[lldb::eRegisterKindGCC], LLDB_INVALID_REGNUM);
+ reg_info.kinds[lldb::eRegisterKindProcessPlugin] = i;
+ uint32_t eh_frame_regno = LLDB_INVALID_REGNUM;
+ reg_info_dict->GetValueForKeyAsInteger("gcc", eh_frame_regno, LLDB_INVALID_REGNUM);
+ if (eh_frame_regno == LLDB_INVALID_REGNUM)
+ reg_info_dict->GetValueForKeyAsInteger("ehframe", eh_frame_regno, LLDB_INVALID_REGNUM);
+ reg_info.kinds[lldb::eRegisterKindEHFrame] = eh_frame_regno;
reg_info_dict->GetValueForKeyAsInteger("dwarf", reg_info.kinds[lldb::eRegisterKindDWARF], LLDB_INVALID_REGNUM);
std::string generic_str;
if (reg_info_dict->GetValueForKeyAsString("generic", generic_str))
@@ -703,12 +707,12 @@ DynamicRegisterInfo::Dump () const
m_regs[i].byte_offset,
m_regs[i].encoding,
FormatManager::GetFormatAsCString (m_regs[i].format));
- if (m_regs[i].kinds[eRegisterKindGDB] != LLDB_INVALID_REGNUM)
- s.Printf(", gdb = %3u", m_regs[i].kinds[eRegisterKindGDB]);
+ if (m_regs[i].kinds[eRegisterKindProcessPlugin] != LLDB_INVALID_REGNUM)
+ s.Printf(", process plugin = %3u", m_regs[i].kinds[eRegisterKindProcessPlugin]);
if (m_regs[i].kinds[eRegisterKindDWARF] != LLDB_INVALID_REGNUM)
s.Printf(", dwarf = %3u", m_regs[i].kinds[eRegisterKindDWARF]);
- if (m_regs[i].kinds[eRegisterKindGCC] != LLDB_INVALID_REGNUM)
- s.Printf(", gcc = %3u", m_regs[i].kinds[eRegisterKindGCC]);
+ if (m_regs[i].kinds[eRegisterKindEHFrame] != LLDB_INVALID_REGNUM)
+ s.Printf(", ehframe = %3u", m_regs[i].kinds[eRegisterKindEHFrame]);
if (m_regs[i].kinds[eRegisterKindGeneric] != LLDB_INVALID_REGNUM)
s.Printf(", generic = %3u", m_regs[i].kinds[eRegisterKindGeneric]);
if (m_regs[i].alt_name)
diff --git a/source/Plugins/Process/Utility/FreeBSDSignals.cpp b/source/Plugins/Process/Utility/FreeBSDSignals.cpp
index c143d36e87c7..e575e2c6a496 100644
--- a/source/Plugins/Process/Utility/FreeBSDSignals.cpp
+++ b/source/Plugins/Process/Utility/FreeBSDSignals.cpp
@@ -26,70 +26,70 @@ FreeBSDSignals::Reset()
{
UnixSignals::Reset();
- // SIGNO NAME SHORT NAME SUPPRESS STOP NOTIFY DESCRIPTION
- // ====== ============ ========== ======== ====== ====== ===================================================
- AddSignal (32, "SIGTHR", "THR", false, true , true , "thread interrupt");
- AddSignal (33, "SIGLIBRT", "LIBRT", false, true , true , "reserved by real-time library");
- AddSignal (65, "SIGRTMIN", "RTMIN", false, true , true , "real time signal 0");
- AddSignal (66, "SIGRTMIN+1", "RTMIN+1", false, true , true , "real time signal 1");
- AddSignal (67, "SIGRTMIN+2", "RTMIN+2", false, true , true , "real time signal 2");
- AddSignal (68, "SIGRTMIN+3", "RTMIN+3", false, true , true , "real time signal 3");
- AddSignal (69, "SIGRTMIN+4", "RTMIN+4", false, true , true , "real time signal 4");
- AddSignal (70, "SIGRTMIN+5", "RTMIN+5", false, true , true , "real time signal 5");
- AddSignal (71, "SIGRTMIN+6", "RTMIN+6", false, true , true , "real time signal 6");
- AddSignal (72, "SIGRTMIN+7", "RTMIN+7", false, true , true , "real time signal 7");
- AddSignal (73, "SIGRTMIN+8", "RTMIN+8", false, true , true , "real time signal 8");
- AddSignal (74, "SIGRTMIN+9", "RTMIN+9", false, true , true , "real time signal 9");
- AddSignal (75, "SIGRTMIN+10", "RTMIN+10", false, true , true , "real time signal 10");
- AddSignal (76, "SIGRTMIN+11", "RTMIN+11", false, true , true , "real time signal 11");
- AddSignal (77, "SIGRTMIN+12", "RTMIN+12", false, true , true , "real time signal 12");
- AddSignal (78, "SIGRTMIN+13", "RTMIN+13", false, true , true , "real time signal 13");
- AddSignal (79, "SIGRTMIN+14", "RTMIN+14", false, true , true , "real time signal 14");
- AddSignal (80, "SIGRTMIN+15", "RTMIN+15", false, true , true , "real time signal 15");
- AddSignal (81, "SIGRTMIN+16", "RTMIN+16", false, true , true , "real time signal 16");
- AddSignal (82, "SIGRTMIN+17", "RTMIN+17", false, true , true , "real time signal 17");
- AddSignal (83, "SIGRTMIN+18", "RTMIN+18", false, true , true , "real time signal 18");
- AddSignal (84, "SIGRTMIN+19", "RTMIN+19", false, true , true , "real time signal 19");
- AddSignal (85, "SIGRTMIN+20", "RTMIN+20", false, true , true , "real time signal 20");
- AddSignal (86, "SIGRTMIN+21", "RTMIN+21", false, true , true , "real time signal 21");
- AddSignal (87, "SIGRTMIN+22", "RTMIN+22", false, true , true , "real time signal 22");
- AddSignal (88, "SIGRTMIN+23", "RTMIN+23", false, true , true , "real time signal 23");
- AddSignal (89, "SIGRTMIN+24", "RTMIN+24", false, true , true , "real time signal 24");
- AddSignal (90, "SIGRTMIN+25", "RTMIN+25", false, true , true , "real time signal 25");
- AddSignal (91, "SIGRTMIN+26", "RTMIN+26", false, true , true , "real time signal 26");
- AddSignal (92, "SIGRTMIN+27", "RTMIN+27", false, true , true , "real time signal 27");
- AddSignal (93, "SIGRTMIN+28", "RTMIN+28", false, true , true , "real time signal 28");
- AddSignal (94, "SIGRTMIN+29", "RTMIN+29", false, true , true , "real time signal 29");
- AddSignal (95, "SIGRTMIN+30", "RTMIN+30", false, true , true , "real time signal 30");
- AddSignal (96, "SIGRTMAX-30", "RTMAX-30", false, true , true , "real time signal 31");
- AddSignal (97, "SIGRTMAX-29", "RTMAX-29", false, true , true , "real time signal 32");
- AddSignal (98, "SIGRTMAX-28", "RTMAX-28", false, true , true , "real time signal 33");
- AddSignal (99, "SIGRTMAX-27", "RTMAX-27", false, true , true , "real time signal 34");
- AddSignal (100, "SIGRTMAX-26", "RTMAX-26", false, true , true , "real time signal 35");
- AddSignal (101, "SIGRTMAX-25", "RTMAX-25", false, true , true , "real time signal 36");
- AddSignal (102, "SIGRTMAX-24", "RTMAX-24", false, true , true , "real time signal 37");
- AddSignal (103, "SIGRTMAX-23", "RTMAX-23", false, true , true , "real time signal 38");
- AddSignal (104, "SIGRTMAX-22", "RTMAX-22", false, true , true , "real time signal 39");
- AddSignal (105, "SIGRTMAX-21", "RTMAX-21", false, true , true , "real time signal 40");
- AddSignal (106, "SIGRTMAX-20", "RTMAX-20", false, true , true , "real time signal 41");
- AddSignal (107, "SIGRTMAX-19", "RTMAX-19", false, true , true , "real time signal 42");
- AddSignal (108, "SIGRTMAX-18", "RTMAX-18", false, true , true , "real time signal 43");
- AddSignal (109, "SIGRTMAX-17", "RTMAX-17", false, true , true , "real time signal 44");
- AddSignal (110, "SIGRTMAX-16", "RTMAX-16", false, true , true , "real time signal 45");
- AddSignal (111, "SIGRTMAX-15", "RTMAX-15", false, true , true , "real time signal 46");
- AddSignal (112, "SIGRTMAX-14", "RTMAX-14", false, true , true , "real time signal 47");
- AddSignal (113, "SIGRTMAX-13", "RTMAX-13", false, true , true , "real time signal 48");
- AddSignal (114, "SIGRTMAX-12", "RTMAX-12", false, true , true , "real time signal 49");
- AddSignal (115, "SIGRTMAX-11", "RTMAX-11", false, true , true , "real time signal 50");
- AddSignal (116, "SIGRTMAX-10", "RTMAX-10", false, true , true , "real time signal 51");
- AddSignal (117, "SIGRTMAX-9", "RTMAX-9", false, true , true , "real time signal 52");
- AddSignal (118, "SIGRTMAX-8", "RTMAX-8", false, true , true , "real time signal 53");
- AddSignal (119, "SIGRTMAX-7", "RTMAX-7", false, true , true , "real time signal 54");
- AddSignal (120, "SIGRTMAX-6", "RTMAX-6", false, true , true , "real time signal 55");
- AddSignal (121, "SIGRTMAX-5", "RTMAX-5", false, true , true , "real time signal 56");
- AddSignal (122, "SIGRTMAX-4", "RTMAX-4", false, true , true , "real time signal 57");
- AddSignal (123, "SIGRTMAX-3", "RTMAX-3", false, true , true , "real time signal 58");
- AddSignal (124, "SIGRTMAX-2", "RTMAX-2", false, true , true , "real time signal 59");
- AddSignal (125, "SIGRTMAX-1", "RTMAX-1", false, true , true , "real time signal 60");
- AddSignal (126, "SIGRTMAX", "RTMAX", false, true , true , "real time signal 61");
+ // SIGNO NAME SUPPRESS STOP NOTIFY DESCRIPTION
+ // ====== ============ ======== ====== ====== ===================================================
+ AddSignal (32, "SIGTHR", false, false, false, "thread interrupt");
+ AddSignal (33, "SIGLIBRT", false, false, false, "reserved by real-time library");
+ AddSignal (65, "SIGRTMIN", false, false, false, "real time signal 0");
+ AddSignal (66, "SIGRTMIN+1", false, false, false, "real time signal 1");
+ AddSignal (67, "SIGRTMIN+2", false, false, false, "real time signal 2");
+ AddSignal (68, "SIGRTMIN+3", false, false, false, "real time signal 3");
+ AddSignal (69, "SIGRTMIN+4", false, false, false, "real time signal 4");
+ AddSignal (70, "SIGRTMIN+5", false, false, false, "real time signal 5");
+ AddSignal (71, "SIGRTMIN+6", false, false, false, "real time signal 6");
+ AddSignal (72, "SIGRTMIN+7", false, false, false, "real time signal 7");
+ AddSignal (73, "SIGRTMIN+8", false, false, false, "real time signal 8");
+ AddSignal (74, "SIGRTMIN+9", false, false, false, "real time signal 9");
+ AddSignal (75, "SIGRTMIN+10", false, false, false, "real time signal 10");
+ AddSignal (76, "SIGRTMIN+11", false, false, false, "real time signal 11");
+ AddSignal (77, "SIGRTMIN+12", false, false, false, "real time signal 12");
+ AddSignal (78, "SIGRTMIN+13", false, false, false, "real time signal 13");
+ AddSignal (79, "SIGRTMIN+14", false, false, false, "real time signal 14");
+ AddSignal (80, "SIGRTMIN+15", false, false, false, "real time signal 15");
+ AddSignal (81, "SIGRTMIN+16", false, false, false, "real time signal 16");
+ AddSignal (82, "SIGRTMIN+17", false, false, false, "real time signal 17");
+ AddSignal (83, "SIGRTMIN+18", false, false, false, "real time signal 18");
+ AddSignal (84, "SIGRTMIN+19", false, false, false, "real time signal 19");
+ AddSignal (85, "SIGRTMIN+20", false, false, false, "real time signal 20");
+ AddSignal (86, "SIGRTMIN+21", false, false, false, "real time signal 21");
+ AddSignal (87, "SIGRTMIN+22", false, false, false, "real time signal 22");
+ AddSignal (88, "SIGRTMIN+23", false, false, false, "real time signal 23");
+ AddSignal (89, "SIGRTMIN+24", false, false, false, "real time signal 24");
+ AddSignal (90, "SIGRTMIN+25", false, false, false, "real time signal 25");
+ AddSignal (91, "SIGRTMIN+26", false, false, false, "real time signal 26");
+ AddSignal (92, "SIGRTMIN+27", false, false, false, "real time signal 27");
+ AddSignal (93, "SIGRTMIN+28", false, false, false, "real time signal 28");
+ AddSignal (94, "SIGRTMIN+29", false, false, false, "real time signal 29");
+ AddSignal (95, "SIGRTMIN+30", false, false, false, "real time signal 30");
+ AddSignal (96, "SIGRTMAX-30", false, false, false, "real time signal 31");
+ AddSignal (97, "SIGRTMAX-29", false, false, false, "real time signal 32");
+ AddSignal (98, "SIGRTMAX-28", false, false, false, "real time signal 33");
+ AddSignal (99, "SIGRTMAX-27", false, false, false, "real time signal 34");
+ AddSignal (100, "SIGRTMAX-26", false, false, false, "real time signal 35");
+ AddSignal (101, "SIGRTMAX-25", false, false, false, "real time signal 36");
+ AddSignal (102, "SIGRTMAX-24", false, false, false, "real time signal 37");
+ AddSignal (103, "SIGRTMAX-23", false, false, false, "real time signal 38");
+ AddSignal (104, "SIGRTMAX-22", false, false, false, "real time signal 39");
+ AddSignal (105, "SIGRTMAX-21", false, false, false, "real time signal 40");
+ AddSignal (106, "SIGRTMAX-20", false, false, false, "real time signal 41");
+ AddSignal (107, "SIGRTMAX-19", false, false, false, "real time signal 42");
+ AddSignal (108, "SIGRTMAX-18", false, false, false, "real time signal 43");
+ AddSignal (109, "SIGRTMAX-17", false, false, false, "real time signal 44");
+ AddSignal (110, "SIGRTMAX-16", false, false, false, "real time signal 45");
+ AddSignal (111, "SIGRTMAX-15", false, false, false, "real time signal 46");
+ AddSignal (112, "SIGRTMAX-14", false, false, false, "real time signal 47");
+ AddSignal (113, "SIGRTMAX-13", false, false, false, "real time signal 48");
+ AddSignal (114, "SIGRTMAX-12", false, false, false, "real time signal 49");
+ AddSignal (115, "SIGRTMAX-11", false, false, false, "real time signal 50");
+ AddSignal (116, "SIGRTMAX-10", false, false, false, "real time signal 51");
+ AddSignal (117, "SIGRTMAX-9", false, false, false, "real time signal 52");
+ AddSignal (118, "SIGRTMAX-8", false, false, false, "real time signal 53");
+ AddSignal (119, "SIGRTMAX-7", false, false, false, "real time signal 54");
+ AddSignal (120, "SIGRTMAX-6", false, false, false, "real time signal 55");
+ AddSignal (121, "SIGRTMAX-5", false, false, false, "real time signal 56");
+ AddSignal (122, "SIGRTMAX-4", false, false, false, "real time signal 57");
+ AddSignal (123, "SIGRTMAX-3", false, false, false, "real time signal 58");
+ AddSignal (124, "SIGRTMAX-2", false, false, false, "real time signal 59");
+ AddSignal (125, "SIGRTMAX-1", false, false, false, "real time signal 60");
+ AddSignal (126, "SIGRTMAX", false, false, false, "real time signal 61");
}
diff --git a/source/Plugins/Process/Utility/HistoryThread.h b/source/Plugins/Process/Utility/HistoryThread.h
index 51173c626d71..e87f6496134b 100644
--- a/source/Plugins/Process/Utility/HistoryThread.h
+++ b/source/Plugins/Process/Utility/HistoryThread.h
@@ -10,6 +10,10 @@
#ifndef liblldb_HistoryThread_h_
#define liblldb_HistoryThread_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Core/Broadcaster.h"
@@ -37,52 +41,55 @@ 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);
- virtual ~HistoryThread ();
+ ~HistoryThread() override;
- virtual lldb::RegisterContextSP
- GetRegisterContext ();
+ lldb::RegisterContextSP
+ GetRegisterContext() override;
- virtual lldb::RegisterContextSP
- CreateRegisterContextForFrame (StackFrame *frame);
+ lldb::RegisterContextSP
+ CreateRegisterContextForFrame(StackFrame *frame) override;
- virtual void
- RefreshStateAfterStop() { }
+ void
+ RefreshStateAfterStop() override { }
bool
- CalculateStopInfo () { return false; }
+ CalculateStopInfo() override
+ {
+ return false;
+ }
void
- SetExtendedBacktraceToken (uint64_t token)
+ SetExtendedBacktraceToken(uint64_t token) override
{
m_extended_unwind_token = token;
}
uint64_t
- GetExtendedBacktraceToken ()
+ GetExtendedBacktraceToken() override
{
return m_extended_unwind_token;
}
const char *
- GetQueueName ()
+ GetQueueName() override
{
return m_queue_name.c_str();
}
void
- SetQueueName (const char *name)
+ SetQueueName(const char *name) override
{
m_queue_name = name;
}
lldb::queue_id_t
- GetQueueID ()
+ GetQueueID() override
{
return m_queue_id;
}
void
- SetQueueID (lldb::queue_id_t queue)
+ SetQueueID(lldb::queue_id_t queue) override
{
m_queue_id = queue;
}
@@ -94,7 +101,7 @@ public:
}
uint32_t
- GetExtendedBacktraceOriginatingIndexID ();
+ GetExtendedBacktraceOriginatingIndexID() override;
void
SetThreadName (const char *name)
@@ -102,14 +109,14 @@ public:
m_thread_name = name;
}
- virtual const char *
- GetName ()
+ const char *
+ GetName() override
{
return m_thread_name.c_str();
}
- virtual void
- SetName(const char *name)
+ void
+ SetName(const char *name) override
{
m_thread_name = name;
}
@@ -133,4 +140,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_HistoryThread_h_
+#endif // liblldb_HistoryThread_h_
diff --git a/source/Plugins/Process/Utility/HistoryUnwind.h b/source/Plugins/Process/Utility/HistoryUnwind.h
index 733f93e1ff87..2cb78bc1dc63 100644
--- a/source/Plugins/Process/Utility/HistoryUnwind.h
+++ b/source/Plugins/Process/Utility/HistoryUnwind.h
@@ -10,8 +10,12 @@
#ifndef liblldb_HistoryUnwind_h_
#define liblldb_HistoryUnwind_h_
+// C Includes
+// C++ Includes
#include <vector>
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Target/Unwind.h"
@@ -23,21 +27,21 @@ class HistoryUnwind : public lldb_private::Unwind
public:
HistoryUnwind (Thread &thread, std::vector<lldb::addr_t> pcs, bool stop_id_is_valid);
- virtual ~HistoryUnwind ();
+ ~HistoryUnwind() override;
protected:
void
- DoClear();
+ DoClear() override;
lldb::RegisterContextSP
- DoCreateRegisterContextForFrame (StackFrame *frame);
+ DoCreateRegisterContextForFrame(StackFrame *frame) override;
bool
- DoGetFrameInfoAtIndex (uint32_t frame_idx,
- lldb::addr_t& cfa,
- lldb::addr_t& pc);
+ DoGetFrameInfoAtIndex(uint32_t frame_idx,
+ lldb::addr_t& cfa,
+ lldb::addr_t& pc) override;
uint32_t
- DoGetFrameCount ();
+ DoGetFrameCount() override;
private:
@@ -47,4 +51,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_HistoryUnwind_h_
+#endif // liblldb_HistoryUnwind_h_
diff --git a/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp b/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
index 3923c5433406..bd3978cc0ab4 100644
--- a/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
+++ b/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
@@ -93,7 +93,7 @@ lldb_private::InferiorCallMmap (Process *process,
if (sc.GetAddressRange(range_scope, 0, use_inline_block_range, mmap_range))
{
ClangASTContext *clang_ast_context = process->GetTarget().GetScratchClangASTContext();
- ClangASTType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
+ CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
lldb::addr_t args[] = { addr, length, prot_arg, flags_arg, fd, offset };
lldb::ThreadPlanSP call_plan_sp (new ThreadPlanCallFunction (*thread,
mmap_range.GetBaseAddress(),
@@ -103,9 +103,6 @@ lldb_private::InferiorCallMmap (Process *process,
if (call_plan_sp)
{
StreamFile error_strm;
- // This plan is a utility plan, so set it to discard itself when done.
- call_plan_sp->SetIsMasterPlan (true);
- call_plan_sp->SetOkayToDiscard(true);
StackFrame *frame = thread->GetStackFrameAtIndex (0).get();
if (frame)
@@ -182,15 +179,12 @@ lldb_private::InferiorCallMunmap (Process *process,
lldb::addr_t args[] = { addr, length };
lldb::ThreadPlanSP call_plan_sp (new ThreadPlanCallFunction (*thread,
munmap_range.GetBaseAddress(),
- ClangASTType(),
+ CompilerType(),
args,
options));
if (call_plan_sp)
{
StreamFile error_strm;
- // This plan is a utility plan, so set it to discard itself when done.
- call_plan_sp->SetIsMasterPlan (true);
- call_plan_sp->SetOkayToDiscard(true);
StackFrame *frame = thread->GetStackFrameAtIndex (0).get();
if (frame)
@@ -235,7 +229,7 @@ lldb_private::InferiorCall (Process *process,
options.SetTimeoutUsec(500000);
ClangASTContext *clang_ast_context = process->GetTarget().GetScratchClangASTContext();
- ClangASTType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
+ CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
lldb::ThreadPlanSP call_plan_sp (new ThreadPlanCallFunction (*thread,
*address,
clang_void_ptr_type,
@@ -244,9 +238,6 @@ lldb_private::InferiorCall (Process *process,
if (call_plan_sp)
{
StreamString error_strm;
- // This plan is a utility plan, so set it to discard itself when done.
- call_plan_sp->SetIsMasterPlan (true);
- call_plan_sp->SetOkayToDiscard(true);
StackFrame *frame = thread->GetStackFrameAtIndex (0).get();
if (frame)
diff --git a/source/Plugins/Process/Utility/LinuxSignals.cpp b/source/Plugins/Process/Utility/LinuxSignals.cpp
index cd1fc8165eb9..5687577f9d16 100644
--- a/source/Plugins/Process/Utility/LinuxSignals.cpp
+++ b/source/Plugins/Process/Utility/LinuxSignals.cpp
@@ -24,72 +24,70 @@ void
LinuxSignals::Reset()
{
m_signals.clear();
-
- AddSignal (1, "SIGHUP", "HUP", false, true , true , "hangup");
- AddSignal (2, "SIGINT", "INT", true , true , true , "interrupt");
- AddSignal (3, "SIGQUIT", "QUIT", false, true , true , "quit");
- AddSignal (4, "SIGILL", "ILL", false, true , true , "illegal instruction");
- AddSignal (5, "SIGTRAP", "TRAP", true , true , true , "trace trap (not reset when caught)");
- AddSignal (6, "SIGABRT", "ABRT", false, true , true , "abort()");
- AddSignal (6, "SIGIOT", "IOT", false, true , true , "IOT trap");
- AddSignal (7, "SIGBUS", "BUS", false, true , true , "bus error");
- AddSignal (8, "SIGFPE", "FPE", false, true , true , "floating point exception");
- AddSignal (9, "SIGKILL", "KILL", false, true , true , "kill");
- AddSignal (10, "SIGUSR1", "USR1", false, true , true , "user defined signal 1");
- AddSignal (11, "SIGSEGV", "SEGV", false, true , true , "segmentation violation");
- AddSignal (12, "SIGUSR2", "USR2", false, true , true , "user defined signal 2");
- AddSignal (13, "SIGPIPE", "PIPE", false, true , true , "write to pipe with reading end closed");
- AddSignal (14, "SIGALRM", "ALRM", false, false, false, "alarm");
- AddSignal (15, "SIGTERM", "TERM", false, true , true , "termination requested");
- AddSignal (16, "SIGSTKFLT", "STKFLT", false, true , true , "stack fault");
- AddSignal (16, "SIGCLD", "CLD", false, false, true , "same as SIGCHLD");
- AddSignal (17, "SIGCHLD", "CHLD", false, false, true , "child status has changed");
- AddSignal (18, "SIGCONT", "CONT", false, true , true , "process continue");
- AddSignal (19, "SIGSTOP", "STOP", true , true , true , "process stop");
- AddSignal (20, "SIGTSTP", "TSTP", false, true , true , "tty stop");
- AddSignal (21, "SIGTTIN", "TTIN", false, true , true , "background tty read");
- AddSignal (22, "SIGTTOU", "TTOU", false, true , true , "background tty write");
- AddSignal (23, "SIGURG", "URG", false, true , true , "urgent data on socket");
- AddSignal (24, "SIGXCPU", "XCPU", false, true , true , "CPU resource exceeded");
- AddSignal (25, "SIGXFSZ", "XFSZ", false, true , true , "file size limit exceeded");
- AddSignal (26, "SIGVTALRM", "VTALRM", false, true , true , "virtual time alarm");
- AddSignal (27, "SIGPROF", "PROF", false, false, false, "profiling time alarm");
- AddSignal (28, "SIGWINCH", "WINCH", false, true , true , "window size changes");
- AddSignal (29, "SIGPOLL", "POLL", false, true , true , "pollable event");
- AddSignal (29, "SIGIO", "IO", false, true , true , "input/output ready");
- AddSignal (30, "SIGPWR", "PWR", false, true , true , "power failure");
- AddSignal (31, "SIGSYS", "SYS", false, true , true , "invalid system call");
- AddSignal (32, "SIG32", "SIG32", false, true , true , "threading library internal signal 1");
- AddSignal (33, "SIG33", "SIG33", false, true , true , "threading library internal signal 2");
- AddSignal (34, "SIGRTMIN", "RTMIN", false, true , true , "real time signal 0");
- AddSignal (35, "SIGRTMIN+1", "RTMIN+1", false, true , true , "real time signal 1");
- AddSignal (36, "SIGRTMIN+2", "RTMIN+2", false, true , true , "real time signal 2");
- AddSignal (37, "SIGRTMIN+3", "RTMIN+3", false, true , true , "real time signal 3");
- AddSignal (38, "SIGRTMIN+4", "RTMIN+4", false, true , true , "real time signal 4");
- AddSignal (39, "SIGRTMIN+5", "RTMIN+5", false, true , true , "real time signal 5");
- AddSignal (40, "SIGRTMIN+6", "RTMIN+6", false, true , true , "real time signal 6");
- AddSignal (41, "SIGRTMIN+7", "RTMIN+7", false, true , true , "real time signal 7");
- AddSignal (42, "SIGRTMIN+8", "RTMIN+8", false, true , true , "real time signal 8");
- AddSignal (43, "SIGRTMIN+9", "RTMIN+9", false, true , true , "real time signal 9");
- AddSignal (44, "SIGRTMIN+10", "RTMIN+10", false, true , true , "real time signal 10");
- AddSignal (45, "SIGRTMIN+11", "RTMIN+11", false, true , true , "real time signal 11");
- AddSignal (46, "SIGRTMIN+12", "RTMIN+12", false, true , true , "real time signal 12");
- AddSignal (47, "SIGRTMIN+13", "RTMIN+13", false, true , true , "real time signal 13");
- AddSignal (48, "SIGRTMIN+14", "RTMIN+14", false, true , true , "real time signal 14");
- AddSignal (49, "SIGRTMIN+15", "RTMIN+15", false, true , true , "real time signal 15");
- AddSignal (50, "SIGRTMAX-14", "RTMAX-14", false, true , true , "real time signal 16"); // switching to SIGRTMAX-xxx to match "kill -l" output
- AddSignal (51, "SIGRTMAX-13", "RTMAX-13", false, true , true , "real time signal 17");
- AddSignal (52, "SIGRTMAX-12", "RTMAX-12", false, true , true , "real time signal 18");
- AddSignal (53, "SIGRTMAX-11", "RTMAX-11", false, true , true , "real time signal 19");
- AddSignal (54, "SIGRTMAX-10", "RTMAX-10", false, true , true , "real time signal 20");
- AddSignal (55, "SIGRTMAX-9", "RTMAX-9", false, true , true , "real time signal 21");
- AddSignal (56, "SIGRTMAX-8", "RTMAX-8", false, true , true , "real time signal 22");
- AddSignal (57, "SIGRTMAX-7", "RTMAX-7", false, true , true , "real time signal 23");
- AddSignal (58, "SIGRTMAX-6", "RTMAX-6", false, true , true , "real time signal 24");
- AddSignal (59, "SIGRTMAX-5", "RTMAX-5", false, true , true , "real time signal 25");
- AddSignal (60, "SIGRTMAX-4", "RTMAX-4", false, true , true , "real time signal 26");
- AddSignal (61, "SIGRTMAX-3", "RTMAX-3", false, true , true , "real time signal 27");
- AddSignal (62, "SIGRTMAX-2", "RTMAX-2", false, true , true , "real time signal 28");
- AddSignal (63, "SIGRTMAX-1", "RTMAX-1", false, true , true , "real time signal 29");
- AddSignal (64, "SIGRTMAX", "RTMAX", false, true , true , "real time signal 30");
+ // SIGNO NAME SUPPRESS STOP NOTIFY DESCRIPTION ALIAS
+ // ===== =========== ======== ===== ====== ====================================== ======
+ AddSignal (1, "SIGHUP", false, true , true , "hangup" );
+ AddSignal (2, "SIGINT", true , true , true , "interrupt" );
+ AddSignal (3, "SIGQUIT", false, true , true , "quit" );
+ AddSignal (4, "SIGILL", false, true , true , "illegal instruction" );
+ AddSignal (5, "SIGTRAP", true , true , true , "trace trap (not reset when caught)" );
+ AddSignal (6, "SIGABRT", false, true , true , "abort()/IOT trap", "SIGIOT");
+ AddSignal (7, "SIGBUS", false, true , true , "bus error" );
+ AddSignal (8, "SIGFPE", false, true , true , "floating point exception" );
+ AddSignal (9, "SIGKILL", false, true , true , "kill" );
+ AddSignal (10, "SIGUSR1", false, true , true , "user defined signal 1" );
+ AddSignal (11, "SIGSEGV", false, true , true , "segmentation violation" );
+ AddSignal (12, "SIGUSR2", false, true , true , "user defined signal 2" );
+ AddSignal (13, "SIGPIPE", false, true , true , "write to pipe with reading end closed" );
+ AddSignal (14, "SIGALRM", false, false, false, "alarm" );
+ AddSignal (15, "SIGTERM", false, true , true , "termination requested" );
+ AddSignal (16, "SIGSTKFLT", false, true , true , "stack fault" );
+ AddSignal (17, "SIGCHLD", false, false, true , "child status has changed", "SIGCLD");
+ AddSignal (18, "SIGCONT", false, true , true , "process continue" );
+ AddSignal (19, "SIGSTOP", true , true , true , "process stop" );
+ AddSignal (20, "SIGTSTP", false, true , true , "tty stop" );
+ AddSignal (21, "SIGTTIN", false, true , true , "background tty read" );
+ AddSignal (22, "SIGTTOU", false, true , true , "background tty write" );
+ AddSignal (23, "SIGURG", false, true , true , "urgent data on socket" );
+ AddSignal (24, "SIGXCPU", false, true , true , "CPU resource exceeded" );
+ AddSignal (25, "SIGXFSZ", false, true , true , "file size limit exceeded" );
+ AddSignal (26, "SIGVTALRM", false, true , true , "virtual time alarm" );
+ AddSignal (27, "SIGPROF", false, false, false, "profiling time alarm" );
+ AddSignal (28, "SIGWINCH", false, true , true , "window size changes" );
+ AddSignal (29, "SIGIO", false, true , true , "input/output ready/Pollable event", "SIGPOLL");
+ AddSignal (30, "SIGPWR", false, true , true , "power failure" );
+ AddSignal (31, "SIGSYS", false, true , true , "invalid system call" );
+ AddSignal (32, "SIG32", false, false, false, "threading library internal signal 1" );
+ AddSignal (33, "SIG33", false, false, false, "threading library internal signal 2" );
+ AddSignal (34, "SIGRTMIN", false, false, false, "real time signal 0" );
+ AddSignal (35, "SIGRTMIN+1", false, false, false, "real time signal 1" );
+ AddSignal (36, "SIGRTMIN+2", false, false, false, "real time signal 2" );
+ AddSignal (37, "SIGRTMIN+3", false, false, false, "real time signal 3" );
+ AddSignal (38, "SIGRTMIN+4", false, false, false, "real time signal 4" );
+ AddSignal (39, "SIGRTMIN+5", false, false, false, "real time signal 5" );
+ AddSignal (40, "SIGRTMIN+6", false, false, false, "real time signal 6" );
+ AddSignal (41, "SIGRTMIN+7", false, false, false, "real time signal 7" );
+ AddSignal (42, "SIGRTMIN+8", false, false, false, "real time signal 8" );
+ AddSignal (43, "SIGRTMIN+9", false, false, false, "real time signal 9" );
+ AddSignal (44, "SIGRTMIN+10", false, false, false, "real time signal 10" );
+ AddSignal (45, "SIGRTMIN+11", false, false, false, "real time signal 11" );
+ AddSignal (46, "SIGRTMIN+12", false, false, false, "real time signal 12" );
+ AddSignal (47, "SIGRTMIN+13", false, false, false, "real time signal 13" );
+ AddSignal (48, "SIGRTMIN+14", false, false, false, "real time signal 14" );
+ AddSignal (49, "SIGRTMIN+15", false, false, false, "real time signal 15" );
+ AddSignal (50, "SIGRTMAX-14", false, false, false, "real time signal 16" ); // switching to SIGRTMAX-xxx to match "kill -l" output
+ AddSignal (51, "SIGRTMAX-13", false, false, false, "real time signal 17" );
+ AddSignal (52, "SIGRTMAX-12", false, false, false, "real time signal 18" );
+ AddSignal (53, "SIGRTMAX-11", false, false, false, "real time signal 19" );
+ AddSignal (54, "SIGRTMAX-10", false, false, false, "real time signal 20" );
+ AddSignal (55, "SIGRTMAX-9", false, false, false, "real time signal 21" );
+ AddSignal (56, "SIGRTMAX-8", false, false, false, "real time signal 22" );
+ AddSignal (57, "SIGRTMAX-7", false, false, false, "real time signal 23" );
+ AddSignal (58, "SIGRTMAX-6", false, false, false, "real time signal 24" );
+ AddSignal (59, "SIGRTMAX-5", false, false, false, "real time signal 25" );
+ AddSignal (60, "SIGRTMAX-4", false, false, false, "real time signal 26" );
+ AddSignal (61, "SIGRTMAX-3", false, false, false, "real time signal 27" );
+ AddSignal (62, "SIGRTMAX-2", false, false, false, "real time signal 28" );
+ AddSignal (63, "SIGRTMAX-1", false, false, false, "real time signal 29" );
+ AddSignal (64, "SIGRTMAX", false, false, false, "real time signal 30" );
}
diff --git a/source/Plugins/Process/Utility/MipsLinuxSignals.cpp b/source/Plugins/Process/Utility/MipsLinuxSignals.cpp
index 1dc0be81c0ae..422fc9b642d0 100644
--- a/source/Plugins/Process/Utility/MipsLinuxSignals.cpp
+++ b/source/Plugins/Process/Utility/MipsLinuxSignals.cpp
@@ -24,72 +24,70 @@ void
MipsLinuxSignals::Reset()
{
m_signals.clear();
-
- AddSignal (1, "SIGHUP", "HUP", false, true , true , "hangup");
- AddSignal (2, "SIGINT", "INT", true , true , true , "interrupt");
- AddSignal (3, "SIGQUIT", "QUIT", false, true , true , "quit");
- AddSignal (4, "SIGILL", "ILL", false, true , true , "illegal instruction");
- AddSignal (5, "SIGTRAP", "TRAP", true , true , true , "trace trap (not reset when caught)");
- AddSignal (6, "SIGABRT", "ABRT", false, true , true , "abort()");
- AddSignal (6, "SIGIOT", "IOT", false, true , true , "IOT trap");
- AddSignal (7, "SIGEMT", "EMT", false, true , true , "terminate process with core dump");
- AddSignal (8, "SIGFPE", "FPE", false, true , true , "floating point exception");
- AddSignal (9, "SIGKILL", "KILL", false, true , true , "kill");
- AddSignal (10, "SIGBUS", "BUS", false, true , true , "bus error");
- AddSignal (11, "SIGSEGV", "SEGV", false, true , true , "segmentation violation");
- AddSignal (12, "SIGSYS", "SYS", false, true , true , "invalid system call");
- AddSignal (13, "SIGPIPE", "PIPE", false, true , true , "write to pipe with reading end closed");
- AddSignal (14, "SIGALRM", "ALRM", false, false, false, "alarm");
- AddSignal (15, "SIGTERM", "TERM", false, true , true , "termination requested");
- AddSignal (16, "SIGUSR1", "USR1", false, true , true , "user defined signal 1");
- AddSignal (17, "SIGUSR2", "USR2", false, true , true , "user defined signal 2");
- AddSignal (18, "SIGCLD", "CLD", false, false, true , "same as SIGCHLD");
- AddSignal (18, "SIGCHLD", "CHLD", false, false, true , "child status has changed");
- AddSignal (19, "SIGPWR", "PWR", false, true , true , "power failure");
- AddSignal (20, "SIGWINCH", "WINCH", false, true , true , "window size changes");
- AddSignal (21, "SIGURG", "URG", false, true , true , "urgent data on socket");
- AddSignal (22, "SIGIO", "IO", false, true , true , "input/output ready");
- AddSignal (22, "SIGPOLL", "POLL", false, true , true , "pollable event");
- AddSignal (23, "SIGSTOP", "STOP", true , true , true , "process stop");
- AddSignal (24, "SIGTSTP", "TSTP", false, true , true , "tty stop");
- AddSignal (25, "SIGCONT", "CONT", false, true , true , "process continue");
- AddSignal (26, "SIGTTIN", "TTIN", false, true , true , "background tty read");
- AddSignal (27, "SIGTTOU", "TTOU", false, true , true , "background tty write");
- AddSignal (28, "SIGVTALRM", "VTALRM", false, true , true , "virtual time alarm");
- AddSignal (29, "SIGPROF", "PROF", false, false, false, "profiling time alarm");
- AddSignal (30, "SIGXCPU", "XCPU", false, true , true , "CPU resource exceeded");
- AddSignal (31, "SIGXFSZ", "XFSZ", false, true , true , "file size limit exceeded");
- AddSignal (32, "SIG32", "SIG32", false, true , true , "threading library internal signal 1");
- AddSignal (33, "SIG33", "SIG33", false, true , true , "threading library internal signal 2");
- AddSignal (34, "SIGRTMIN", "RTMIN", false, true , true , "real time signal 0");
- AddSignal (35, "SIGRTMIN+1", "RTMIN+1", false, true , true , "real time signal 1");
- AddSignal (36, "SIGRTMIN+2", "RTMIN+2", false, true , true , "real time signal 2");
- AddSignal (37, "SIGRTMIN+3", "RTMIN+3", false, true , true , "real time signal 3");
- AddSignal (38, "SIGRTMIN+4", "RTMIN+4", false, true , true , "real time signal 4");
- AddSignal (39, "SIGRTMIN+5", "RTMIN+5", false, true , true , "real time signal 5");
- AddSignal (40, "SIGRTMIN+6", "RTMIN+6", false, true , true , "real time signal 6");
- AddSignal (41, "SIGRTMIN+7", "RTMIN+7", false, true , true , "real time signal 7");
- AddSignal (42, "SIGRTMIN+8", "RTMIN+8", false, true , true , "real time signal 8");
- AddSignal (43, "SIGRTMIN+9", "RTMIN+9", false, true , true , "real time signal 9");
- AddSignal (44, "SIGRTMIN+10", "RTMIN+10", false, true , true , "real time signal 10");
- AddSignal (45, "SIGRTMIN+11", "RTMIN+11", false, true , true , "real time signal 11");
- AddSignal (46, "SIGRTMIN+12", "RTMIN+12", false, true , true , "real time signal 12");
- AddSignal (47, "SIGRTMIN+13", "RTMIN+13", false, true , true , "real time signal 13");
- AddSignal (48, "SIGRTMIN+14", "RTMIN+14", false, true , true , "real time signal 14");
- AddSignal (49, "SIGRTMIN+15", "RTMIN+15", false, true , true , "real time signal 15");
- AddSignal (50, "SIGRTMAX-14", "RTMAX-14", false, true , true , "real time signal 16"); // switching to SIGRTMAX-xxx to match "kill -l" output
- AddSignal (51, "SIGRTMAX-13", "RTMAX-13", false, true , true , "real time signal 17");
- AddSignal (52, "SIGRTMAX-12", "RTMAX-12", false, true , true , "real time signal 18");
- AddSignal (53, "SIGRTMAX-11", "RTMAX-11", false, true , true , "real time signal 19");
- AddSignal (54, "SIGRTMAX-10", "RTMAX-10", false, true , true , "real time signal 20");
- AddSignal (55, "SIGRTMAX-9", "RTMAX-9", false, true , true , "real time signal 21");
- AddSignal (56, "SIGRTMAX-8", "RTMAX-8", false, true , true , "real time signal 22");
- AddSignal (57, "SIGRTMAX-7", "RTMAX-7", false, true , true , "real time signal 23");
- AddSignal (58, "SIGRTMAX-6", "RTMAX-6", false, true , true , "real time signal 24");
- AddSignal (59, "SIGRTMAX-5", "RTMAX-5", false, true , true , "real time signal 25");
- AddSignal (60, "SIGRTMAX-4", "RTMAX-4", false, true , true , "real time signal 26");
- AddSignal (61, "SIGRTMAX-3", "RTMAX-3", false, true , true , "real time signal 27");
- AddSignal (62, "SIGRTMAX-2", "RTMAX-2", false, true , true , "real time signal 28");
- AddSignal (63, "SIGRTMAX-1", "RTMAX-1", false, true , true , "real time signal 29");
- AddSignal (64, "SIGRTMAX", "RTMAX", false, true , true , "real time signal 30");
+ // SIGNO NAME SUPPRESS STOP NOTIFY DESCRIPTION ALIAS
+ // ===== =========== ======== ===== ====== ====================================== ========
+ AddSignal (1, "SIGHUP", false, true , true , "hangup" );
+ AddSignal (2, "SIGINT", true , true , true , "interrupt" );
+ AddSignal (3, "SIGQUIT", false, true , true , "quit" );
+ AddSignal (4, "SIGILL", false, true , true , "illegal instruction" );
+ AddSignal (5, "SIGTRAP", true , true , true , "trace trap (not reset when caught)" );
+ AddSignal (6, "SIGABRT", false, true , true , "abort()/IOT trap", "SIGIOT");
+ AddSignal (7, "SIGEMT", false, true , true , "terminate process with core dump" );
+ AddSignal (8, "SIGFPE", false, true , true , "floating point exception" );
+ AddSignal (9, "SIGKILL", false, true , true , "kill" );
+ AddSignal (10, "SIGBUS", false, true , true , "bus error" );
+ AddSignal (11, "SIGSEGV", false, true , true , "segmentation violation" );
+ AddSignal (12, "SIGSYS", false, true , true , "invalid system call" );
+ AddSignal (13, "SIGPIPE", false, true , true , "write to pipe with reading end closed" );
+ AddSignal (14, "SIGALRM", false, false, false, "alarm" );
+ AddSignal (15, "SIGTERM", false, true , true , "termination requested" );
+ AddSignal (16, "SIGUSR1", false, true , true , "user defined signal 1" );
+ AddSignal (17, "SIGUSR2", false, true , true , "user defined signal 2" );
+ AddSignal (18, "SIGCHLD", false, false, true , "child status has changed", "SIGCLD");
+ AddSignal (19, "SIGPWR", false, true , true , "power failure" );
+ AddSignal (20, "SIGWINCH", false, true , true , "window size changes" );
+ AddSignal (21, "SIGURG", false, true , true , "urgent data on socket" );
+ AddSignal (22, "SIGIO", false, true , true , "input/output ready/Pollable event", "SIGPOLL");
+ AddSignal (23, "SIGSTOP", true , true , true , "process stop" );
+ AddSignal (24, "SIGTSTP", false, true , true , "tty stop" );
+ AddSignal (25, "SIGCONT", false, true , true , "process continue" );
+ AddSignal (26, "SIGTTIN", false, true , true , "background tty read" );
+ AddSignal (27, "SIGTTOU", false, true , true , "background tty write" );
+ AddSignal (28, "SIGVTALRM", false, true , true , "virtual time alarm" );
+ AddSignal (29, "SIGPROF", false, false, false, "profiling time alarm" );
+ AddSignal (30, "SIGXCPU", false, true , true , "CPU resource exceeded" );
+ AddSignal (31, "SIGXFSZ", false, true , true , "file size limit exceeded" );
+ AddSignal (32, "SIG32", false, false, false, "threading library internal signal 1" );
+ AddSignal (33, "SIG33", false, false, false, "threading library internal signal 2" );
+ AddSignal (34, "SIGRTMIN", false, false, false, "real time signal 0" );
+ AddSignal (35, "SIGRTMIN+1", false, false, false, "real time signal 1" );
+ AddSignal (36, "SIGRTMIN+2", false, false, false, "real time signal 2" );
+ AddSignal (37, "SIGRTMIN+3", false, false, false, "real time signal 3" );
+ AddSignal (38, "SIGRTMIN+4", false, false, false, "real time signal 4" );
+ AddSignal (39, "SIGRTMIN+5", false, false, false, "real time signal 5" );
+ AddSignal (40, "SIGRTMIN+6", false, false, false, "real time signal 6" );
+ AddSignal (41, "SIGRTMIN+7", false, false, false, "real time signal 7" );
+ AddSignal (42, "SIGRTMIN+8", false, false, false, "real time signal 8" );
+ AddSignal (43, "SIGRTMIN+9", false, false, false, "real time signal 9" );
+ AddSignal (44, "SIGRTMIN+10", false, false, false, "real time signal 10" );
+ AddSignal (45, "SIGRTMIN+11", false, false, false, "real time signal 11" );
+ AddSignal (46, "SIGRTMIN+12", false, false, false, "real time signal 12" );
+ AddSignal (47, "SIGRTMIN+13", false, false, false, "real time signal 13" );
+ AddSignal (48, "SIGRTMIN+14", false, false, false, "real time signal 14" );
+ AddSignal (49, "SIGRTMIN+15", false, false, false, "real time signal 15" );
+ AddSignal (50, "SIGRTMAX-14", false, false, false, "real time signal 16" ); // switching to SIGRTMAX-xxx to match "kill -l" output
+ AddSignal (51, "SIGRTMAX-13", false, false, false, "real time signal 17" );
+ AddSignal (52, "SIGRTMAX-12", false, false, false, "real time signal 18" );
+ AddSignal (53, "SIGRTMAX-11", false, false, false, "real time signal 19" );
+ AddSignal (54, "SIGRTMAX-10", false, false, false, "real time signal 20" );
+ AddSignal (55, "SIGRTMAX-9", false, false, false, "real time signal 21" );
+ AddSignal (56, "SIGRTMAX-8", false, false, false, "real time signal 22" );
+ AddSignal (57, "SIGRTMAX-7", false, false, false, "real time signal 23" );
+ AddSignal (58, "SIGRTMAX-6", false, false, false, "real time signal 24" );
+ AddSignal (59, "SIGRTMAX-5", false, false, false, "real time signal 25" );
+ AddSignal (60, "SIGRTMAX-4", false, false, false, "real time signal 26" );
+ AddSignal (61, "SIGRTMAX-3", false, false, false, "real time signal 27" );
+ AddSignal (62, "SIGRTMAX-2", false, false, false, "real time signal 28" );
+ AddSignal (63, "SIGRTMAX-1", false, false, false, "real time signal 29" );
+ AddSignal (64, "SIGRTMAX", false, false, false, "real time signal 30" );
}
diff --git a/source/Plugins/Process/Utility/NetBSDSignals.cpp b/source/Plugins/Process/Utility/NetBSDSignals.cpp
new file mode 100644
index 000000000000..5dce51616c4e
--- /dev/null
+++ b/source/Plugins/Process/Utility/NetBSDSignals.cpp
@@ -0,0 +1,34 @@
+//===-- NetBSDSignals.cpp --------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "NetBSDSignals.h"
+
+using namespace lldb_private;
+
+NetBSDSignals::NetBSDSignals()
+ : UnixSignals()
+{
+ Reset();
+}
+
+void
+NetBSDSignals::Reset()
+{
+ UnixSignals::Reset();
+ // SIGNO NAME SUPPRESS STOP NOTIFY DESCRIPTION
+ // ====== ============ ======== ====== ====== ===================================================
+ AddSignal (32, "SIGPWR", false, true , true , "power fail/restart (not reset when caught)");
+#ifdef SIGRTMIN /* SIGRTMAX */
+ /* Kernel only; not exposed to userland yet */
+#endif
+}
diff --git a/source/Plugins/Process/Utility/NetBSDSignals.h b/source/Plugins/Process/Utility/NetBSDSignals.h
new file mode 100644
index 000000000000..441402b056db
--- /dev/null
+++ b/source/Plugins/Process/Utility/NetBSDSignals.h
@@ -0,0 +1,31 @@
+//===-- NetBSDSignals.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_NetBSDSignals_H_
+#define liblldb_NetBSDSignals_H_
+
+// Project includes
+#include "lldb/Target/UnixSignals.h"
+
+namespace lldb_private {
+
+/// NetBSD specific set of Unix signals.
+class NetBSDSignals : public UnixSignals
+{
+public:
+ NetBSDSignals();
+
+private:
+ void
+ Reset() override;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_NetBSDSignals_H_
diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp b/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
index 4138a6aaa2aa..452fb47ebc8a 100644
--- a/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
@@ -34,8 +34,8 @@
#endif
// Project includes
-#include "ARM_GCC_Registers.h"
#include "ARM_DWARF_Registers.h"
+#include "Utility/ARM_ehframe_Registers.h"
#include "llvm/ADT/STLExtras.h"
@@ -172,89 +172,69 @@ enum
};
-RegisterContextDarwin_arm::RegisterContextDarwin_arm(Thread &thread, uint32_t concrete_frame_idx) :
- RegisterContext(thread, concrete_frame_idx),
- gpr(),
- fpu(),
- exc()
-{
- uint32_t i;
- for (i=0; i<kNumErrors; i++)
- {
- gpr_errs[i] = -1;
- fpu_errs[i] = -1;
- exc_errs[i] = -1;
- }
-}
-
-RegisterContextDarwin_arm::~RegisterContextDarwin_arm()
-{
-}
-
-
#define GPR_OFFSET(idx) ((idx) * 4)
#define FPU_OFFSET(idx) ((idx) * 4 + sizeof (RegisterContextDarwin_arm::GPR))
#define EXC_OFFSET(idx) ((idx) * 4 + sizeof (RegisterContextDarwin_arm::GPR) + sizeof (RegisterContextDarwin_arm::FPU))
#define DBG_OFFSET(reg) ((LLVM_EXTENSION offsetof (RegisterContextDarwin_arm::DBG, reg) + sizeof (RegisterContextDarwin_arm::GPR) + sizeof (RegisterContextDarwin_arm::FPU) + sizeof (RegisterContextDarwin_arm::EXC)))
-#define DEFINE_DBG(reg, i) #reg, NULL, sizeof(((RegisterContextDarwin_arm::DBG *)NULL)->reg[i]), DBG_OFFSET(reg[i]), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, dbg_##reg##i }, NULL, NULL
+#define DEFINE_DBG(reg, i) #reg, NULL, sizeof(((RegisterContextDarwin_arm::DBG *)NULL)->reg[i]), DBG_OFFSET(reg[i]), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL
#define REG_CONTEXT_SIZE (sizeof (RegisterContextDarwin_arm::GPR) + sizeof (RegisterContextDarwin_arm::FPU) + sizeof (RegisterContextDarwin_arm::EXC))
static RegisterInfo g_register_infos[] = {
// General purpose registers
-// NAME ALT SZ OFFSET ENCODING FORMAT COMPILER DWARF GENERIC GDB LLDB NATIVE VALUE REGS INVALIDATE REGS
+// NAME ALT SZ OFFSET ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB NATIVE VALUE REGS INVALIDATE REGS
// ====== ======= == ============= ============= ============ =============== =============== ========================= ===================== ============= ========== ===============
-{ "r0", NULL, 4, GPR_OFFSET(0), eEncodingUint, eFormatHex, { gcc_r0, dwarf_r0, LLDB_INVALID_REGNUM, gdb_arm_r0, gpr_r0 }, NULL, NULL},
-{ "r1", NULL, 4, GPR_OFFSET(1), eEncodingUint, eFormatHex, { gcc_r1, dwarf_r1, LLDB_INVALID_REGNUM, gdb_arm_r1, gpr_r1 }, NULL, NULL},
-{ "r2", NULL, 4, GPR_OFFSET(2), eEncodingUint, eFormatHex, { gcc_r2, dwarf_r2, LLDB_INVALID_REGNUM, gdb_arm_r2, gpr_r2 }, NULL, NULL},
-{ "r3", NULL, 4, GPR_OFFSET(3), eEncodingUint, eFormatHex, { gcc_r3, dwarf_r3, LLDB_INVALID_REGNUM, gdb_arm_r3, gpr_r3 }, NULL, NULL},
-{ "r4", NULL, 4, GPR_OFFSET(4), eEncodingUint, eFormatHex, { gcc_r4, dwarf_r4, LLDB_INVALID_REGNUM, gdb_arm_r4, gpr_r4 }, NULL, NULL},
-{ "r5", NULL, 4, GPR_OFFSET(5), eEncodingUint, eFormatHex, { gcc_r5, dwarf_r5, LLDB_INVALID_REGNUM, gdb_arm_r5, gpr_r5 }, NULL, NULL},
-{ "r6", NULL, 4, GPR_OFFSET(6), eEncodingUint, eFormatHex, { gcc_r6, dwarf_r6, LLDB_INVALID_REGNUM, gdb_arm_r6, gpr_r6 }, NULL, NULL},
-{ "r7", NULL, 4, GPR_OFFSET(7), eEncodingUint, eFormatHex, { gcc_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP, gdb_arm_r7, gpr_r7 }, NULL, NULL},
-{ "r8", NULL, 4, GPR_OFFSET(8), eEncodingUint, eFormatHex, { gcc_r8, dwarf_r8, LLDB_INVALID_REGNUM, gdb_arm_r8, gpr_r8 }, NULL, NULL},
-{ "r9", NULL, 4, GPR_OFFSET(9), eEncodingUint, eFormatHex, { gcc_r9, dwarf_r9, LLDB_INVALID_REGNUM, gdb_arm_r9, gpr_r9 }, NULL, NULL},
-{ "r10", NULL, 4, GPR_OFFSET(10), eEncodingUint, eFormatHex, { gcc_r10, dwarf_r10, LLDB_INVALID_REGNUM, gdb_arm_r10, gpr_r10 }, NULL, NULL},
-{ "r11", NULL, 4, GPR_OFFSET(11), eEncodingUint, eFormatHex, { gcc_r11, dwarf_r11, LLDB_INVALID_REGNUM, gdb_arm_r11, gpr_r11 }, NULL, NULL},
-{ "r12", NULL, 4, GPR_OFFSET(12), eEncodingUint, eFormatHex, { gcc_r12, dwarf_r12, LLDB_INVALID_REGNUM, gdb_arm_r12, gpr_r12 }, NULL, NULL},
-{ "sp", "r13", 4, GPR_OFFSET(13), eEncodingUint, eFormatHex, { gcc_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, gdb_arm_sp, gpr_sp }, NULL, NULL},
-{ "lr", "r14", 4, GPR_OFFSET(14), eEncodingUint, eFormatHex, { gcc_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, gdb_arm_lr, gpr_lr }, NULL, NULL},
-{ "pc", "r15", 4, GPR_OFFSET(15), eEncodingUint, eFormatHex, { gcc_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, gdb_arm_pc, gpr_pc }, NULL, NULL},
-{ "cpsr", "psr", 4, GPR_OFFSET(16), eEncodingUint, eFormatHex, { gcc_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS, gdb_arm_cpsr, gpr_cpsr }, NULL, NULL},
-
-{ "s0", NULL, 4, FPU_OFFSET(0), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, gdb_arm_s0, fpu_s0 }, NULL, NULL},
-{ "s1", NULL, 4, FPU_OFFSET(1), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, gdb_arm_s1, fpu_s1 }, NULL, NULL},
-{ "s2", NULL, 4, FPU_OFFSET(2), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, gdb_arm_s2, fpu_s2 }, NULL, NULL},
-{ "s3", NULL, 4, FPU_OFFSET(3), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, gdb_arm_s3, fpu_s3 }, NULL, NULL},
-{ "s4", NULL, 4, FPU_OFFSET(4), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, gdb_arm_s4, fpu_s4 }, NULL, NULL},
-{ "s5", NULL, 4, FPU_OFFSET(5), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, gdb_arm_s5, fpu_s5 }, NULL, NULL},
-{ "s6", NULL, 4, FPU_OFFSET(6), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, gdb_arm_s6, fpu_s6 }, NULL, NULL},
-{ "s7", NULL, 4, FPU_OFFSET(7), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, gdb_arm_s7, fpu_s7 }, NULL, NULL},
-{ "s8", NULL, 4, FPU_OFFSET(8), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, gdb_arm_s8, fpu_s8 }, NULL, NULL},
-{ "s9", NULL, 4, FPU_OFFSET(9), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, gdb_arm_s9, fpu_s9 }, NULL, NULL},
-{ "s10", NULL, 4, FPU_OFFSET(10), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, gdb_arm_s10, fpu_s10 }, NULL, NULL},
-{ "s11", NULL, 4, FPU_OFFSET(11), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, gdb_arm_s11, fpu_s11 }, NULL, NULL},
-{ "s12", NULL, 4, FPU_OFFSET(12), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, gdb_arm_s12, fpu_s12 }, NULL, NULL},
-{ "s13", NULL, 4, FPU_OFFSET(13), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, gdb_arm_s13, fpu_s13 }, NULL, NULL},
-{ "s14", NULL, 4, FPU_OFFSET(14), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, gdb_arm_s14, fpu_s14 }, NULL, NULL},
-{ "s15", NULL, 4, FPU_OFFSET(15), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, gdb_arm_s15, fpu_s15 }, NULL, NULL},
-{ "s16", NULL, 4, FPU_OFFSET(16), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, gdb_arm_s16, fpu_s16 }, NULL, NULL},
-{ "s17", NULL, 4, FPU_OFFSET(17), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, gdb_arm_s17, fpu_s17 }, NULL, NULL},
-{ "s18", NULL, 4, FPU_OFFSET(18), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, gdb_arm_s18, fpu_s18 }, NULL, NULL},
-{ "s19", NULL, 4, FPU_OFFSET(19), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, gdb_arm_s19, fpu_s19 }, NULL, NULL},
-{ "s20", NULL, 4, FPU_OFFSET(20), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, gdb_arm_s20, fpu_s20 }, NULL, NULL},
-{ "s21", NULL, 4, FPU_OFFSET(21), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, gdb_arm_s21, fpu_s21 }, NULL, NULL},
-{ "s22", NULL, 4, FPU_OFFSET(22), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, gdb_arm_s22, fpu_s22 }, NULL, NULL},
-{ "s23", NULL, 4, FPU_OFFSET(23), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, gdb_arm_s23, fpu_s23 }, NULL, NULL},
-{ "s24", NULL, 4, FPU_OFFSET(24), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, gdb_arm_s24, fpu_s24 }, NULL, NULL},
-{ "s25", NULL, 4, FPU_OFFSET(25), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, gdb_arm_s25, fpu_s25 }, NULL, NULL},
-{ "s26", NULL, 4, FPU_OFFSET(26), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, gdb_arm_s26, fpu_s26 }, NULL, NULL},
-{ "s27", NULL, 4, FPU_OFFSET(27), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, gdb_arm_s27, fpu_s27 }, NULL, NULL},
-{ "s28", NULL, 4, FPU_OFFSET(28), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, gdb_arm_s28, fpu_s28 }, NULL, NULL},
-{ "s29", NULL, 4, FPU_OFFSET(29), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, gdb_arm_s29, fpu_s29 }, NULL, NULL},
-{ "s30", NULL, 4, FPU_OFFSET(30), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, gdb_arm_s30, fpu_s30 }, NULL, NULL},
-{ "s31", NULL, 4, FPU_OFFSET(31), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, gdb_arm_s31, fpu_s31 }, NULL, NULL},
-{ "fpscr", NULL, 4, FPU_OFFSET(32), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM, gdb_arm_fpscr, fpu_fpscr }, NULL, NULL},
+{ "r0", NULL, 4, GPR_OFFSET(0), eEncodingUint, eFormatHex, { ehframe_r0, dwarf_r0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r0 }, NULL, NULL},
+{ "r1", NULL, 4, GPR_OFFSET(1), eEncodingUint, eFormatHex, { ehframe_r1, dwarf_r1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r1 }, NULL, NULL},
+{ "r2", NULL, 4, GPR_OFFSET(2), eEncodingUint, eFormatHex, { ehframe_r2, dwarf_r2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r2 }, NULL, NULL},
+{ "r3", NULL, 4, GPR_OFFSET(3), eEncodingUint, eFormatHex, { ehframe_r3, dwarf_r3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r3 }, NULL, NULL},
+{ "r4", NULL, 4, GPR_OFFSET(4), eEncodingUint, eFormatHex, { ehframe_r4, dwarf_r4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r4 }, NULL, NULL},
+{ "r5", NULL, 4, GPR_OFFSET(5), eEncodingUint, eFormatHex, { ehframe_r5, dwarf_r5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r5 }, NULL, NULL},
+{ "r6", NULL, 4, GPR_OFFSET(6), eEncodingUint, eFormatHex, { ehframe_r6, dwarf_r6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r6 }, NULL, NULL},
+{ "r7", NULL, 4, GPR_OFFSET(7), eEncodingUint, eFormatHex, { ehframe_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, gpr_r7 }, NULL, NULL},
+{ "r8", NULL, 4, GPR_OFFSET(8), eEncodingUint, eFormatHex, { ehframe_r8, dwarf_r8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r8 }, NULL, NULL},
+{ "r9", NULL, 4, GPR_OFFSET(9), eEncodingUint, eFormatHex, { ehframe_r9, dwarf_r9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r9 }, NULL, NULL},
+{ "r10", NULL, 4, GPR_OFFSET(10), eEncodingUint, eFormatHex, { ehframe_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r10 }, NULL, NULL},
+{ "r11", NULL, 4, GPR_OFFSET(11), eEncodingUint, eFormatHex, { ehframe_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r11 }, NULL, NULL},
+{ "r12", NULL, 4, GPR_OFFSET(12), eEncodingUint, eFormatHex, { ehframe_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r12 }, NULL, NULL},
+{ "sp", "r13", 4, GPR_OFFSET(13), eEncodingUint, eFormatHex, { ehframe_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, gpr_sp }, NULL, NULL},
+{ "lr", "r14", 4, GPR_OFFSET(14), eEncodingUint, eFormatHex, { ehframe_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM, gpr_lr }, NULL, NULL},
+{ "pc", "r15", 4, GPR_OFFSET(15), eEncodingUint, eFormatHex, { ehframe_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, gpr_pc }, NULL, NULL},
+{ "cpsr", "psr", 4, GPR_OFFSET(16), eEncodingUint, eFormatHex, { ehframe_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, gpr_cpsr }, NULL, NULL},
+
+{ "s0", NULL, 4, FPU_OFFSET(0), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s0 }, NULL, NULL},
+{ "s1", NULL, 4, FPU_OFFSET(1), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s1 }, NULL, NULL},
+{ "s2", NULL, 4, FPU_OFFSET(2), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s2 }, NULL, NULL},
+{ "s3", NULL, 4, FPU_OFFSET(3), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s3 }, NULL, NULL},
+{ "s4", NULL, 4, FPU_OFFSET(4), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s4 }, NULL, NULL},
+{ "s5", NULL, 4, FPU_OFFSET(5), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s5 }, NULL, NULL},
+{ "s6", NULL, 4, FPU_OFFSET(6), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s6 }, NULL, NULL},
+{ "s7", NULL, 4, FPU_OFFSET(7), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s7 }, NULL, NULL},
+{ "s8", NULL, 4, FPU_OFFSET(8), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s8 }, NULL, NULL},
+{ "s9", NULL, 4, FPU_OFFSET(9), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s9 }, NULL, NULL},
+{ "s10", NULL, 4, FPU_OFFSET(10), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s10 }, NULL, NULL},
+{ "s11", NULL, 4, FPU_OFFSET(11), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s11 }, NULL, NULL},
+{ "s12", NULL, 4, FPU_OFFSET(12), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s12 }, NULL, NULL},
+{ "s13", NULL, 4, FPU_OFFSET(13), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s13 }, NULL, NULL},
+{ "s14", NULL, 4, FPU_OFFSET(14), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s14 }, NULL, NULL},
+{ "s15", NULL, 4, FPU_OFFSET(15), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s15 }, NULL, NULL},
+{ "s16", NULL, 4, FPU_OFFSET(16), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s16 }, NULL, NULL},
+{ "s17", NULL, 4, FPU_OFFSET(17), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s17 }, NULL, NULL},
+{ "s18", NULL, 4, FPU_OFFSET(18), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s18 }, NULL, NULL},
+{ "s19", NULL, 4, FPU_OFFSET(19), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s19 }, NULL, NULL},
+{ "s20", NULL, 4, FPU_OFFSET(20), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s20 }, NULL, NULL},
+{ "s21", NULL, 4, FPU_OFFSET(21), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s21 }, NULL, NULL},
+{ "s22", NULL, 4, FPU_OFFSET(22), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s22 }, NULL, NULL},
+{ "s23", NULL, 4, FPU_OFFSET(23), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s23 }, NULL, NULL},
+{ "s24", NULL, 4, FPU_OFFSET(24), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s24 }, NULL, NULL},
+{ "s25", NULL, 4, FPU_OFFSET(25), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s25 }, NULL, NULL},
+{ "s26", NULL, 4, FPU_OFFSET(26), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s26 }, NULL, NULL},
+{ "s27", NULL, 4, FPU_OFFSET(27), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s27 }, NULL, NULL},
+{ "s28", NULL, 4, FPU_OFFSET(28), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s28 }, NULL, NULL},
+{ "s29", NULL, 4, FPU_OFFSET(29), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s29 }, NULL, NULL},
+{ "s30", NULL, 4, FPU_OFFSET(30), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s30 }, NULL, NULL},
+{ "s31", NULL, 4, FPU_OFFSET(31), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s31 }, NULL, NULL},
+{ "fpscr", NULL, 4, FPU_OFFSET(32), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_fpscr }, NULL, NULL},
{ "exception",NULL, 4, EXC_OFFSET(0), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_exception }, NULL, NULL},
{ "fsr", NULL, 4, EXC_OFFSET(1), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_fsr }, NULL, NULL},
@@ -403,6 +383,26 @@ g_exc_regnums[] =
static size_t k_num_register_infos = llvm::array_lengthof(g_register_infos);
+RegisterContextDarwin_arm::RegisterContextDarwin_arm(Thread &thread, uint32_t concrete_frame_idx) :
+ RegisterContext(thread, concrete_frame_idx),
+ gpr(),
+ fpu(),
+ exc()
+{
+ uint32_t i;
+ for (i=0; i<kNumErrors; i++)
+ {
+ gpr_errs[i] = -1;
+ fpu_errs[i] = -1;
+ exc_errs[i] = -1;
+ }
+}
+
+RegisterContextDarwin_arm::~RegisterContextDarwin_arm()
+{
+}
+
+
void
RegisterContextDarwin_arm::InvalidateAllRegisters ()
{
@@ -940,27 +940,27 @@ RegisterContextDarwin_arm::ConvertRegisterKindToRegisterNumber (lldb::RegisterKi
break;
}
}
- else if (kind == eRegisterKindGCC)
+ else if (kind == eRegisterKindEHFrame)
{
switch (reg)
{
- case gcc_r0: return gpr_r0;
- case gcc_r1: return gpr_r1;
- case gcc_r2: return gpr_r2;
- case gcc_r3: return gpr_r3;
- case gcc_r4: return gpr_r4;
- case gcc_r5: return gpr_r5;
- case gcc_r6: return gpr_r6;
- case gcc_r7: return gpr_r7;
- case gcc_r8: return gpr_r8;
- case gcc_r9: return gpr_r9;
- case gcc_r10: return gpr_r10;
- case gcc_r11: return gpr_r11;
- case gcc_r12: return gpr_r12;
- case gcc_sp: return gpr_sp;
- case gcc_lr: return gpr_lr;
- case gcc_pc: return gpr_pc;
- case gcc_cpsr: return gpr_cpsr;
+ case ehframe_r0: return gpr_r0;
+ case ehframe_r1: return gpr_r1;
+ case ehframe_r2: return gpr_r2;
+ case ehframe_r3: return gpr_r3;
+ case ehframe_r4: return gpr_r4;
+ case ehframe_r5: return gpr_r5;
+ case ehframe_r6: return gpr_r6;
+ case ehframe_r7: return gpr_r7;
+ case ehframe_r8: return gpr_r8;
+ case ehframe_r9: return gpr_r9;
+ case ehframe_r10: return gpr_r10;
+ case ehframe_r11: return gpr_r11;
+ case ehframe_r12: return gpr_r12;
+ case ehframe_sp: return gpr_sp;
+ case ehframe_lr: return gpr_lr;
+ case ehframe_pc: return gpr_pc;
+ case ehframe_cpsr: return gpr_cpsr;
}
}
else if (kind == eRegisterKindLLDB)
diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h b/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h
index 23134efd43e6..f4d82259f9df 100644
--- a/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h
+++ b/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h
@@ -51,61 +51,59 @@
class RegisterContextDarwin_arm : public lldb_private::RegisterContext
{
public:
-
RegisterContextDarwin_arm(lldb_private::Thread &thread, uint32_t concrete_frame_idx);
- virtual
- ~RegisterContextDarwin_arm();
+ ~RegisterContextDarwin_arm() override;
- virtual void
- InvalidateAllRegisters ();
+ void
+ InvalidateAllRegisters() override;
- virtual size_t
- GetRegisterCount ();
+ size_t
+ GetRegisterCount() override;
- virtual const lldb_private::RegisterInfo *
- GetRegisterInfoAtIndex (size_t reg);
+ const lldb_private::RegisterInfo *
+ GetRegisterInfoAtIndex(size_t reg) override;
- virtual size_t
- GetRegisterSetCount ();
+ size_t
+ GetRegisterSetCount() override;
- virtual const lldb_private::RegisterSet *
- GetRegisterSet (size_t set);
+ const lldb_private::RegisterSet *
+ GetRegisterSet(size_t set) override;
- virtual bool
- ReadRegister (const lldb_private::RegisterInfo *reg_info,
- lldb_private::RegisterValue &reg_value);
+ bool
+ ReadRegister(const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &reg_value) override;
- virtual bool
- WriteRegister (const lldb_private::RegisterInfo *reg_info,
- const lldb_private::RegisterValue &reg_value);
+ bool
+ WriteRegister(const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &reg_value) override;
- virtual bool
- ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
+ bool
+ ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
- virtual bool
- WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
+ bool
+ WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
- virtual uint32_t
- ConvertRegisterKindToRegisterNumber (lldb::RegisterKind kind, uint32_t num);
+ uint32_t
+ ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override;
- virtual uint32_t
- NumSupportedHardwareBreakpoints ();
+ uint32_t
+ NumSupportedHardwareBreakpoints() override;
- virtual uint32_t
- SetHardwareBreakpoint (lldb::addr_t addr, size_t size);
+ uint32_t
+ SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
- virtual bool
- ClearHardwareBreakpoint (uint32_t hw_idx);
+ bool
+ ClearHardwareBreakpoint(uint32_t hw_idx) override;
- virtual uint32_t
- NumSupportedHardwareWatchpoints ();
+ uint32_t
+ NumSupportedHardwareWatchpoints() override;
- virtual uint32_t
- SetHardwareWatchpoint (lldb::addr_t addr, size_t size, bool read, bool write);
+ uint32_t
+ SetHardwareWatchpoint(lldb::addr_t addr, size_t size, bool read, bool write) override;
- virtual bool
- ClearHardwareWatchpoint (uint32_t hw_index);
+ bool
+ ClearHardwareWatchpoint(uint32_t hw_index) override;
struct GPR
{
@@ -113,7 +111,6 @@ public:
uint32_t cpsr; // CPSR
};
-
struct QReg
{
uint8_t bytes[16];
@@ -163,7 +160,6 @@ public:
LogDBGRegisters (lldb_private::Log *log, const DBG& dbg);
protected:
-
enum
{
GPRRegSet = 1, // ARM_THREAD_STATE
@@ -330,4 +326,4 @@ protected:
GetRegisterInfos ();
};
-#endif // liblldb_RegisterContextDarwin_arm_h_
+#endif // liblldb_RegisterContextDarwin_arm_h_
diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp b/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
index e08a87369e4d..7de042dd11a9 100644
--- a/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
@@ -36,31 +36,11 @@
#endif
// Project includes
-#include "ARM64_GCC_Registers.h"
#include "ARM64_DWARF_Registers.h"
using namespace lldb;
using namespace lldb_private;
-RegisterContextDarwin_arm64::RegisterContextDarwin_arm64(Thread &thread, uint32_t concrete_frame_idx) :
- RegisterContext(thread, concrete_frame_idx),
- gpr(),
- fpu(),
- exc()
-{
- uint32_t i;
- for (i=0; i<kNumErrors; i++)
- {
- gpr_errs[i] = -1;
- fpu_errs[i] = -1;
- exc_errs[i] = -1;
- }
-}
-
-RegisterContextDarwin_arm64::~RegisterContextDarwin_arm64()
-{
-}
-
#define GPR_OFFSET(idx) ((idx) * 8)
#define GPR_OFFSET_NAME(reg) (LLVM_EXTENSION offsetof (RegisterContextDarwin_arm64::GPR, reg))
@@ -71,7 +51,7 @@ RegisterContextDarwin_arm64::~RegisterContextDarwin_arm64()
#define EXC_OFFSET_NAME(reg) (LLVM_EXTENSION offsetof (RegisterContextDarwin_arm64::EXC, reg) + sizeof (RegisterContextDarwin_arm64::GPR) + sizeof (RegisterContextDarwin_arm64::FPU))
#define DBG_OFFSET_NAME(reg) (LLVM_EXTENSION offsetof (RegisterContextDarwin_arm64::DBG, reg) + sizeof (RegisterContextDarwin_arm64::GPR) + sizeof (RegisterContextDarwin_arm64::FPU) + sizeof (RegisterContextDarwin_arm64::EXC))
-#define DEFINE_DBG(reg, i) #reg, NULL, sizeof(((RegisterContextDarwin_arm64::DBG *)NULL)->reg[i]), DBG_OFFSET_NAME(reg[i]), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, dbg_##reg##i }, NULL, NULL
+#define DEFINE_DBG(reg, i) #reg, NULL, sizeof(((RegisterContextDarwin_arm64::DBG *)NULL)->reg[i]), DBG_OFFSET_NAME(reg[i]), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL
#define REG_CONTEXT_SIZE (sizeof (RegisterContextDarwin_arm64::GPR) + sizeof (RegisterContextDarwin_arm64::FPU) + sizeof (RegisterContextDarwin_arm64::EXC))
//-----------------------------------------------------------------------------
@@ -173,6 +153,26 @@ g_exc_regnums[] =
static size_t k_num_register_infos = llvm::array_lengthof(g_register_infos_arm64);
+RegisterContextDarwin_arm64::RegisterContextDarwin_arm64(Thread &thread, uint32_t concrete_frame_idx) :
+ RegisterContext(thread, concrete_frame_idx),
+ gpr(),
+ fpu(),
+ exc()
+{
+ uint32_t i;
+ for (i=0; i<kNumErrors; i++)
+ {
+ gpr_errs[i] = -1;
+ fpu_errs[i] = -1;
+ exc_errs[i] = -1;
+ }
+}
+
+RegisterContextDarwin_arm64::~RegisterContextDarwin_arm64()
+{
+}
+
+
void
RegisterContextDarwin_arm64::InvalidateAllRegisters ()
{
@@ -488,7 +488,7 @@ RegisterContextDarwin_arm64::ReadRegister (const RegisterInfo *reg_info, Registe
case fpu_v29:
case fpu_v30:
case fpu_v31:
- value.SetBytes(fpu.v[reg].bytes, reg_info->byte_size, lldb::endian::InlHostByteOrder());
+ value.SetBytes(fpu.v[reg].bytes, reg_info->byte_size, endian::InlHostByteOrder());
break;
case fpu_fpsr:
@@ -770,44 +770,44 @@ RegisterContextDarwin_arm64::ConvertRegisterKindToRegisterNumber (RegisterKind k
break;
}
}
- else if (kind == eRegisterKindGCC)
+ else if (kind == eRegisterKindEHFrame)
{
switch (reg)
{
- case arm64_gcc::x0: return gpr_x0;
- case arm64_gcc::x1: return gpr_x1;
- case arm64_gcc::x2: return gpr_x2;
- case arm64_gcc::x3: return gpr_x3;
- case arm64_gcc::x4: return gpr_x4;
- case arm64_gcc::x5: return gpr_x5;
- case arm64_gcc::x6: return gpr_x6;
- case arm64_gcc::x7: return gpr_x7;
- case arm64_gcc::x8: return gpr_x8;
- case arm64_gcc::x9: return gpr_x9;
- case arm64_gcc::x10: return gpr_x10;
- case arm64_gcc::x11: return gpr_x11;
- case arm64_gcc::x12: return gpr_x12;
- case arm64_gcc::x13: return gpr_x13;
- case arm64_gcc::x14: return gpr_x14;
- case arm64_gcc::x15: return gpr_x15;
- case arm64_gcc::x16: return gpr_x16;
- case arm64_gcc::x17: return gpr_x17;
- case arm64_gcc::x18: return gpr_x18;
- case arm64_gcc::x19: return gpr_x19;
- case arm64_gcc::x20: return gpr_x20;
- case arm64_gcc::x21: return gpr_x21;
- case arm64_gcc::x22: return gpr_x22;
- case arm64_gcc::x23: return gpr_x23;
- case arm64_gcc::x24: return gpr_x24;
- case arm64_gcc::x25: return gpr_x25;
- case arm64_gcc::x26: return gpr_x26;
- case arm64_gcc::x27: return gpr_x27;
- case arm64_gcc::x28: return gpr_x28;
- case arm64_gcc::fp: return gpr_fp;
- case arm64_gcc::sp: return gpr_sp;
- case arm64_gcc::lr: return gpr_lr;
- case arm64_gcc::pc: return gpr_pc;
- case arm64_gcc::cpsr: return gpr_cpsr;
+ case arm64_ehframe::x0: return gpr_x0;
+ case arm64_ehframe::x1: return gpr_x1;
+ case arm64_ehframe::x2: return gpr_x2;
+ case arm64_ehframe::x3: return gpr_x3;
+ case arm64_ehframe::x4: return gpr_x4;
+ case arm64_ehframe::x5: return gpr_x5;
+ case arm64_ehframe::x6: return gpr_x6;
+ case arm64_ehframe::x7: return gpr_x7;
+ case arm64_ehframe::x8: return gpr_x8;
+ case arm64_ehframe::x9: return gpr_x9;
+ case arm64_ehframe::x10: return gpr_x10;
+ case arm64_ehframe::x11: return gpr_x11;
+ case arm64_ehframe::x12: return gpr_x12;
+ case arm64_ehframe::x13: return gpr_x13;
+ case arm64_ehframe::x14: return gpr_x14;
+ case arm64_ehframe::x15: return gpr_x15;
+ case arm64_ehframe::x16: return gpr_x16;
+ case arm64_ehframe::x17: return gpr_x17;
+ case arm64_ehframe::x18: return gpr_x18;
+ case arm64_ehframe::x19: return gpr_x19;
+ case arm64_ehframe::x20: return gpr_x20;
+ case arm64_ehframe::x21: return gpr_x21;
+ case arm64_ehframe::x22: return gpr_x22;
+ case arm64_ehframe::x23: return gpr_x23;
+ case arm64_ehframe::x24: return gpr_x24;
+ case arm64_ehframe::x25: return gpr_x25;
+ case arm64_ehframe::x26: return gpr_x26;
+ case arm64_ehframe::x27: return gpr_x27;
+ case arm64_ehframe::x28: return gpr_x28;
+ case arm64_ehframe::fp: return gpr_fp;
+ case arm64_ehframe::sp: return gpr_sp;
+ case arm64_ehframe::lr: return gpr_lr;
+ case arm64_ehframe::pc: return gpr_pc;
+ case arm64_ehframe::cpsr: return gpr_cpsr;
}
}
else if (kind == eRegisterKindLLDB)
diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.h b/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.h
index aeac15e9b09a..b228c42ade53 100644
--- a/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.h
+++ b/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.h
@@ -32,52 +32,50 @@
class RegisterContextDarwin_arm64 : public lldb_private::RegisterContext
{
public:
-
RegisterContextDarwin_arm64(lldb_private::Thread &thread, uint32_t concrete_frame_idx);
- virtual
- ~RegisterContextDarwin_arm64();
+ ~RegisterContextDarwin_arm64() override;
- virtual void
- InvalidateAllRegisters ();
+ void
+ InvalidateAllRegisters() override;
- virtual size_t
- GetRegisterCount ();
+ size_t
+ GetRegisterCount() override;
- virtual const lldb_private::RegisterInfo *
- GetRegisterInfoAtIndex (size_t reg);
+ const lldb_private::RegisterInfo *
+ GetRegisterInfoAtIndex(size_t reg) override;
- virtual size_t
- GetRegisterSetCount ();
+ size_t
+ GetRegisterSetCount() override;
- virtual const lldb_private::RegisterSet *
- GetRegisterSet (size_t set);
+ const lldb_private::RegisterSet *
+ GetRegisterSet(size_t set) override;
- virtual bool
- ReadRegister (const lldb_private::RegisterInfo *reg_info,
- lldb_private::RegisterValue &reg_value);
+ bool
+ ReadRegister(const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &reg_value) override;
- virtual bool
- WriteRegister (const lldb_private::RegisterInfo *reg_info,
- const lldb_private::RegisterValue &reg_value);
+ bool
+ WriteRegister(const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &reg_value) override;
- virtual bool
- ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
+ bool
+ ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
- virtual bool
- WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
+ bool
+ WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
- virtual uint32_t
- ConvertRegisterKindToRegisterNumber (lldb::RegisterKind kind, uint32_t num);
+ uint32_t
+ ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override;
- virtual uint32_t
- NumSupportedHardwareWatchpoints ();
+ uint32_t
+ NumSupportedHardwareWatchpoints() override;
- virtual uint32_t
- SetHardwareWatchpoint (lldb::addr_t addr, size_t size, bool read, bool write);
+ uint32_t
+ SetHardwareWatchpoint(lldb::addr_t addr, size_t size, bool read, bool write) override;
- virtual bool
- ClearHardwareWatchpoint (uint32_t hw_index);
+ bool
+ ClearHardwareWatchpoint(uint32_t hw_index) override;
// mirrors <mach/arm/thread_status.h> arm_thread_state64_t
struct GPR
@@ -90,7 +88,6 @@ public:
uint32_t cpsr; // cpsr
};
-
struct VReg
{
uint8_t bytes[16];
@@ -126,7 +123,6 @@ public:
LogDBGRegisters (lldb_private::Log *log, const DBG& dbg);
protected:
-
enum
{
GPRRegSet = 6, // ARM_THREAD_STATE64
@@ -293,4 +289,4 @@ protected:
GetRegisterInfos ();
};
-#endif // liblldb_RegisterContextDarwin_arm64_h_
+#endif // liblldb_RegisterContextDarwin_arm64_h_
diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp b/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp
index 08144bf7ec26..1b01c28b5d96 100644
--- a/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp
@@ -98,16 +98,16 @@ enum
enum
{
- gcc_eax = 0,
- gcc_ecx,
- gcc_edx,
- gcc_ebx,
- gcc_ebp,
- gcc_esp,
- gcc_esi,
- gcc_edi,
- gcc_eip,
- gcc_eflags
+ ehframe_eax = 0,
+ ehframe_ecx,
+ ehframe_edx,
+ ehframe_ebx,
+ ehframe_ebp,
+ ehframe_esp,
+ ehframe_esi,
+ ehframe_edi,
+ ehframe_eip,
+ ehframe_eflags
};
enum
@@ -140,79 +140,6 @@ enum
dwarf_xmm7
};
-enum
-{
- gdb_eax = 0,
- gdb_ecx = 1,
- gdb_edx = 2,
- gdb_ebx = 3,
- gdb_esp = 4,
- gdb_ebp = 5,
- gdb_esi = 6,
- gdb_edi = 7,
- gdb_eip = 8,
- gdb_eflags = 9,
- gdb_cs = 10,
- gdb_ss = 11,
- gdb_ds = 12,
- gdb_es = 13,
- gdb_fs = 14,
- gdb_gs = 15,
- gdb_stmm0 = 16,
- gdb_stmm1 = 17,
- gdb_stmm2 = 18,
- gdb_stmm3 = 19,
- gdb_stmm4 = 20,
- gdb_stmm5 = 21,
- gdb_stmm6 = 22,
- gdb_stmm7 = 23,
- gdb_fctrl = 24, gdb_fcw = gdb_fctrl,
- gdb_fstat = 25, gdb_fsw = gdb_fstat,
- gdb_ftag = 26, gdb_ftw = gdb_ftag,
- gdb_fiseg = 27, gdb_fpu_cs = gdb_fiseg,
- gdb_fioff = 28, gdb_ip = gdb_fioff,
- gdb_foseg = 29, gdb_fpu_ds = gdb_foseg,
- gdb_fooff = 30, gdb_dp = gdb_fooff,
- gdb_fop = 31,
- gdb_xmm0 = 32,
- gdb_xmm1 = 33,
- gdb_xmm2 = 34,
- gdb_xmm3 = 35,
- gdb_xmm4 = 36,
- gdb_xmm5 = 37,
- gdb_xmm6 = 38,
- gdb_xmm7 = 39,
- gdb_mxcsr = 40,
- gdb_mm0 = 41,
- gdb_mm1 = 42,
- gdb_mm2 = 43,
- gdb_mm3 = 44,
- gdb_mm4 = 45,
- gdb_mm5 = 46,
- gdb_mm6 = 47,
- gdb_mm7 = 48
-};
-
-RegisterContextDarwin_i386::RegisterContextDarwin_i386 (Thread &thread, uint32_t concrete_frame_idx) :
- RegisterContext(thread, concrete_frame_idx),
- gpr(),
- fpu(),
- exc()
-{
- uint32_t i;
- for (i=0; i<kNumErrors; i++)
- {
- gpr_errs[i] = -1;
- fpu_errs[i] = -1;
- exc_errs[i] = -1;
- }
-}
-
-RegisterContextDarwin_i386::~RegisterContextDarwin_i386()
-{
-}
-
-
#define GPR_OFFSET(reg) (LLVM_EXTENSION offsetof (RegisterContextDarwin_i386::GPR, reg))
#define FPU_OFFSET(reg) (LLVM_EXTENSION offsetof (RegisterContextDarwin_i386::FPU, reg) + sizeof (RegisterContextDarwin_i386::GPR))
@@ -224,42 +151,42 @@ RegisterContextDarwin_i386::~RegisterContextDarwin_i386()
// sizes and offsets.
#define DEFINE_GPR(reg, alt) #reg, alt, sizeof(((RegisterContextDarwin_i386::GPR *)NULL)->reg), GPR_OFFSET(reg), eEncodingUint, eFormatHex
#define DEFINE_FPU_UINT(reg) #reg, NULL, sizeof(((RegisterContextDarwin_i386::FPU *)NULL)->reg), FPU_OFFSET(reg), eEncodingUint, eFormatHex
-#define DEFINE_FPU_VECT(reg, i) #reg#i, NULL, sizeof(((RegisterContextDarwin_i386::FPU *)NULL)->reg[i].bytes), FPU_OFFSET(reg[i]), eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_##reg##i, LLDB_INVALID_REGNUM, gdb_##reg##i, fpu_##reg##i }, NULL, NULL
+#define DEFINE_FPU_VECT(reg, i) #reg#i, NULL, sizeof(((RegisterContextDarwin_i386::FPU *)NULL)->reg[i].bytes), FPU_OFFSET(reg[i]), eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_##reg##i, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_##reg##i }, NULL, NULL
#define DEFINE_EXC(reg) #reg, NULL, sizeof(((RegisterContextDarwin_i386::EXC *)NULL)->reg), EXC_OFFSET(reg), eEncodingUint, eFormatHex
#define REG_CONTEXT_SIZE (sizeof (RegisterContextDarwin_i386::GPR) + sizeof (RegisterContextDarwin_i386::FPU) + sizeof (RegisterContextDarwin_i386::EXC))
static RegisterInfo g_register_infos[] =
{
-// Macro auto defines most stuff GCC DWARF GENERIC GDB LLDB VALUE REGS INVALIDATE REGS
+// Macro auto defines most stuff eh_frame DWARF GENERIC PROCESS PLUGIN LLDB VALUE REGS INVALIDATE REGS
// =============================== ======================= =================== ========================= ================== ================= ========== ===============
- { DEFINE_GPR(eax , NULL) , { gcc_eax , dwarf_eax , LLDB_INVALID_REGNUM , gdb_eax , gpr_eax }, NULL, NULL},
- { DEFINE_GPR(ebx , NULL) , { gcc_ebx , dwarf_ebx , LLDB_INVALID_REGNUM , gdb_ebx , gpr_ebx }, NULL, NULL},
- { DEFINE_GPR(ecx , NULL) , { gcc_ecx , dwarf_ecx , LLDB_INVALID_REGNUM , gdb_ecx , gpr_ecx }, NULL, NULL},
- { DEFINE_GPR(edx , NULL) , { gcc_edx , dwarf_edx , LLDB_INVALID_REGNUM , gdb_edx , gpr_edx }, NULL, NULL},
- { DEFINE_GPR(edi , NULL) , { gcc_edi , dwarf_edi , LLDB_INVALID_REGNUM , gdb_edi , gpr_edi }, NULL, NULL},
- { DEFINE_GPR(esi , NULL) , { gcc_esi , dwarf_esi , LLDB_INVALID_REGNUM , gdb_esi , gpr_esi }, NULL, NULL},
- { DEFINE_GPR(ebp , "fp") , { gcc_ebp , dwarf_ebp , LLDB_REGNUM_GENERIC_FP , gdb_ebp , gpr_ebp }, NULL, NULL},
- { DEFINE_GPR(esp , "sp") , { gcc_esp , dwarf_esp , LLDB_REGNUM_GENERIC_SP , gdb_esp , gpr_esp }, NULL, NULL},
- { DEFINE_GPR(ss , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_ss , gpr_ss }, NULL, NULL},
- { DEFINE_GPR(eflags , "flags") , { gcc_eflags , dwarf_eflags , LLDB_REGNUM_GENERIC_FLAGS , gdb_eflags , gpr_eflags }, NULL, NULL},
- { DEFINE_GPR(eip , "pc") , { gcc_eip , dwarf_eip , LLDB_REGNUM_GENERIC_PC , gdb_eip , gpr_eip }, NULL, NULL},
- { DEFINE_GPR(cs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_cs , gpr_cs }, NULL, NULL},
- { DEFINE_GPR(ds , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_ds , gpr_ds }, NULL, NULL},
- { DEFINE_GPR(es , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_es , gpr_es }, NULL, NULL},
- { DEFINE_GPR(fs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fs , gpr_fs }, NULL, NULL},
- { DEFINE_GPR(gs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_gs , gpr_gs }, NULL, NULL},
-
- { DEFINE_FPU_UINT(fcw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fcw , fpu_fcw }, NULL, NULL},
- { DEFINE_FPU_UINT(fsw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fsw , fpu_fsw }, NULL, NULL},
- { DEFINE_FPU_UINT(ftw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_ftw , fpu_ftw }, NULL, NULL},
- { DEFINE_FPU_UINT(fop) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fop , fpu_fop }, NULL, NULL},
- { DEFINE_FPU_UINT(ip) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_ip , fpu_ip }, NULL, NULL},
- { DEFINE_FPU_UINT(cs) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_cs , fpu_cs }, NULL, NULL},
- { DEFINE_FPU_UINT(dp) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_dp , fpu_dp }, NULL, NULL},
- { DEFINE_FPU_UINT(ds) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_ds , fpu_ds }, NULL, NULL},
- { DEFINE_FPU_UINT(mxcsr) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_mxcsr , fpu_mxcsr }, NULL, NULL},
- { DEFINE_FPU_UINT(mxcsrmask) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_mxcsrmask}, NULL, NULL},
+ { DEFINE_GPR(eax , NULL) , { ehframe_eax , dwarf_eax , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_eax }, NULL, NULL},
+ { DEFINE_GPR(ebx , NULL) , { ehframe_ebx , dwarf_ebx , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_ebx }, NULL, NULL},
+ { DEFINE_GPR(ecx , NULL) , { ehframe_ecx , dwarf_ecx , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_ecx }, NULL, NULL},
+ { DEFINE_GPR(edx , NULL) , { ehframe_edx , dwarf_edx , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_edx }, NULL, NULL},
+ { DEFINE_GPR(edi , NULL) , { ehframe_edi , dwarf_edi , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_edi }, NULL, NULL},
+ { DEFINE_GPR(esi , NULL) , { ehframe_esi , dwarf_esi , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_esi }, NULL, NULL},
+ { DEFINE_GPR(ebp , "fp") , { ehframe_ebp , dwarf_ebp , LLDB_REGNUM_GENERIC_FP , LLDB_INVALID_REGNUM, gpr_ebp }, NULL, NULL},
+ { DEFINE_GPR(esp , "sp") , { ehframe_esp , dwarf_esp , LLDB_REGNUM_GENERIC_SP , LLDB_INVALID_REGNUM, gpr_esp }, NULL, NULL},
+ { DEFINE_GPR(ss , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_ss }, NULL, NULL},
+ { DEFINE_GPR(eflags , "flags") , { ehframe_eflags , dwarf_eflags , LLDB_REGNUM_GENERIC_FLAGS , LLDB_INVALID_REGNUM, gpr_eflags }, NULL, NULL},
+ { DEFINE_GPR(eip , "pc") , { ehframe_eip , dwarf_eip , LLDB_REGNUM_GENERIC_PC , LLDB_INVALID_REGNUM, gpr_eip }, NULL, NULL},
+ { DEFINE_GPR(cs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_cs }, NULL, NULL},
+ { DEFINE_GPR(ds , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_ds }, NULL, NULL},
+ { DEFINE_GPR(es , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_es }, NULL, NULL},
+ { DEFINE_GPR(fs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_fs }, NULL, NULL},
+ { DEFINE_GPR(gs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_gs }, NULL, NULL},
+
+ { DEFINE_FPU_UINT(fcw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_fcw }, NULL, NULL},
+ { DEFINE_FPU_UINT(fsw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_fsw }, NULL, NULL},
+ { DEFINE_FPU_UINT(ftw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_ftw }, NULL, NULL},
+ { DEFINE_FPU_UINT(fop) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_fop }, NULL, NULL},
+ { DEFINE_FPU_UINT(ip) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_ip }, NULL, NULL},
+ { DEFINE_FPU_UINT(cs) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_cs }, NULL, NULL},
+ { DEFINE_FPU_UINT(dp) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_dp }, NULL, NULL},
+ { DEFINE_FPU_UINT(ds) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_ds }, NULL, NULL},
+ { DEFINE_FPU_UINT(mxcsr) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_mxcsr }, NULL, NULL},
+ { DEFINE_FPU_UINT(mxcsrmask) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_mxcsrmask}, NULL, NULL},
{ DEFINE_FPU_VECT(stmm,0) },
{ DEFINE_FPU_VECT(stmm,1) },
{ DEFINE_FPU_VECT(stmm,2) },
@@ -277,13 +204,33 @@ static RegisterInfo g_register_infos[] =
{ DEFINE_FPU_VECT(xmm,6) },
{ DEFINE_FPU_VECT(xmm,7) },
- { DEFINE_EXC(trapno) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, exc_trapno }, NULL, NULL},
- { DEFINE_EXC(err) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, exc_err }, NULL, NULL},
- { DEFINE_EXC(faultvaddr) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, exc_faultvaddr }, NULL, NULL}
+ { DEFINE_EXC(trapno) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, exc_trapno }, NULL, NULL},
+ { DEFINE_EXC(err) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, exc_err }, NULL, NULL},
+ { DEFINE_EXC(faultvaddr) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, exc_faultvaddr }, NULL, NULL}
};
static size_t k_num_register_infos = llvm::array_lengthof(g_register_infos);
+RegisterContextDarwin_i386::RegisterContextDarwin_i386 (Thread &thread, uint32_t concrete_frame_idx) :
+ RegisterContext(thread, concrete_frame_idx),
+ gpr(),
+ fpu(),
+ exc()
+{
+ uint32_t i;
+ for (i=0; i<kNumErrors; i++)
+ {
+ gpr_errs[i] = -1;
+ fpu_errs[i] = -1;
+ exc_errs[i] = -1;
+ }
+}
+
+RegisterContextDarwin_i386::~RegisterContextDarwin_i386()
+{
+}
+
+
void
RegisterContextDarwin_i386::InvalidateAllRegisters ()
{
@@ -859,7 +806,7 @@ RegisterContextDarwin_i386::ConvertRegisterKindToRegisterNumber (lldb::RegisterK
break;
}
}
- else if (kind == eRegisterKindGCC || kind == eRegisterKindDWARF)
+ else if (kind == eRegisterKindEHFrame || kind == eRegisterKindDWARF)
{
switch (reg)
{
@@ -893,55 +840,6 @@ RegisterContextDarwin_i386::ConvertRegisterKindToRegisterNumber (lldb::RegisterK
break;
}
}
- else if (kind == eRegisterKindGDB)
- {
- switch (reg)
- {
- case gdb_eax : return gpr_eax;
- case gdb_ebx : return gpr_ebx;
- case gdb_ecx : return gpr_ecx;
- case gdb_edx : return gpr_edx;
- case gdb_esi : return gpr_esi;
- case gdb_edi : return gpr_edi;
- case gdb_ebp : return gpr_ebp;
- case gdb_esp : return gpr_esp;
- case gdb_eip : return gpr_eip;
- case gdb_eflags : return gpr_eflags;
- case gdb_cs : return gpr_cs;
- case gdb_ss : return gpr_ss;
- case gdb_ds : return gpr_ds;
- case gdb_es : return gpr_es;
- case gdb_fs : return gpr_fs;
- case gdb_gs : return gpr_gs;
- case gdb_stmm0 : return fpu_stmm0;
- case gdb_stmm1 : return fpu_stmm1;
- case gdb_stmm2 : return fpu_stmm2;
- case gdb_stmm3 : return fpu_stmm3;
- case gdb_stmm4 : return fpu_stmm4;
- case gdb_stmm5 : return fpu_stmm5;
- case gdb_stmm6 : return fpu_stmm6;
- case gdb_stmm7 : return fpu_stmm7;
- case gdb_fctrl : return fpu_fctrl;
- case gdb_fstat : return fpu_fstat;
- case gdb_ftag : return fpu_ftag;
- case gdb_fiseg : return fpu_fiseg;
- case gdb_fioff : return fpu_fioff;
- case gdb_foseg : return fpu_foseg;
- case gdb_fooff : return fpu_fooff;
- case gdb_fop : return fpu_fop;
- case gdb_xmm0 : return fpu_xmm0;
- case gdb_xmm1 : return fpu_xmm1;
- case gdb_xmm2 : return fpu_xmm2;
- case gdb_xmm3 : return fpu_xmm3;
- case gdb_xmm4 : return fpu_xmm4;
- case gdb_xmm5 : return fpu_xmm5;
- case gdb_xmm6 : return fpu_xmm6;
- case gdb_xmm7 : return fpu_xmm7;
- case gdb_mxcsr : return fpu_mxcsr;
- default:
- break;
- }
- }
else if (kind == eRegisterKindLLDB)
{
return reg;
diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h b/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h
index 1d03feb9f3dd..9568b0332b4c 100644
--- a/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h
+++ b/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h
@@ -20,45 +20,45 @@
class RegisterContextDarwin_i386 : public lldb_private::RegisterContext
{
public:
-
RegisterContextDarwin_i386(lldb_private::Thread &thread,
- uint32_t concrete_frame_idx);
+ uint32_t concrete_frame_idx);
- virtual
- ~RegisterContextDarwin_i386();
+ ~RegisterContextDarwin_i386() override;
- virtual void
- InvalidateAllRegisters ();
+ void
+ InvalidateAllRegisters() override;
- virtual size_t
- GetRegisterCount ();
+ size_t
+ GetRegisterCount() override;
- virtual const lldb_private::RegisterInfo *
- GetRegisterInfoAtIndex (size_t reg);
+ const lldb_private::RegisterInfo *
+ GetRegisterInfoAtIndex(size_t reg) override;
- virtual size_t
- GetRegisterSetCount ();
+ size_t
+ GetRegisterSetCount() override;
- virtual const lldb_private::RegisterSet *
- GetRegisterSet (size_t set);
+ const lldb_private::RegisterSet *
+ GetRegisterSet(size_t set) override;
- virtual bool
- ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
+ bool
+ ReadRegister(const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &value) override;
- virtual bool
- WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
+ bool
+ WriteRegister(const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &value) override;
- virtual bool
- ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
+ bool
+ ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
- virtual bool
- WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
+ bool
+ WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
- virtual uint32_t
- ConvertRegisterKindToRegisterNumber (lldb::RegisterKind kind, uint32_t num);
+ uint32_t
+ ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override;
- virtual bool
- HardwareSingleStep (bool enable);
+ bool
+ HardwareSingleStep(bool enable) override;
struct GPR
{
@@ -121,7 +121,6 @@ public:
};
protected:
-
enum
{
GPRRegSet = 1,
@@ -266,4 +265,4 @@ protected:
GetRegisterInfos ();
};
-#endif // liblldb_RegisterContextDarwin_i386_h_
+#endif // liblldb_RegisterContextDarwin_i386_h_
diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp b/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
index 54124d187d54..aee6e1228d2a 100644
--- a/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
@@ -111,132 +111,52 @@ enum
fpu_fooff = fpu_dp
};
-enum gcc_dwarf_regnums
-{
- gcc_dwarf_gpr_rax = 0,
- gcc_dwarf_gpr_rdx,
- gcc_dwarf_gpr_rcx,
- gcc_dwarf_gpr_rbx,
- gcc_dwarf_gpr_rsi,
- gcc_dwarf_gpr_rdi,
- gcc_dwarf_gpr_rbp,
- gcc_dwarf_gpr_rsp,
- gcc_dwarf_gpr_r8,
- gcc_dwarf_gpr_r9,
- gcc_dwarf_gpr_r10,
- gcc_dwarf_gpr_r11,
- gcc_dwarf_gpr_r12,
- gcc_dwarf_gpr_r13,
- gcc_dwarf_gpr_r14,
- gcc_dwarf_gpr_r15,
- gcc_dwarf_gpr_rip,
- gcc_dwarf_fpu_xmm0,
- gcc_dwarf_fpu_xmm1,
- gcc_dwarf_fpu_xmm2,
- gcc_dwarf_fpu_xmm3,
- gcc_dwarf_fpu_xmm4,
- gcc_dwarf_fpu_xmm5,
- gcc_dwarf_fpu_xmm6,
- gcc_dwarf_fpu_xmm7,
- gcc_dwarf_fpu_xmm8,
- gcc_dwarf_fpu_xmm9,
- gcc_dwarf_fpu_xmm10,
- gcc_dwarf_fpu_xmm11,
- gcc_dwarf_fpu_xmm12,
- gcc_dwarf_fpu_xmm13,
- gcc_dwarf_fpu_xmm14,
- gcc_dwarf_fpu_xmm15,
- gcc_dwarf_fpu_stmm0,
- gcc_dwarf_fpu_stmm1,
- gcc_dwarf_fpu_stmm2,
- gcc_dwarf_fpu_stmm3,
- gcc_dwarf_fpu_stmm4,
- gcc_dwarf_fpu_stmm5,
- gcc_dwarf_fpu_stmm6,
- gcc_dwarf_fpu_stmm7
-
-};
+enum ehframe_dwarf_regnums
+{
+ ehframe_dwarf_gpr_rax = 0,
+ ehframe_dwarf_gpr_rdx,
+ ehframe_dwarf_gpr_rcx,
+ ehframe_dwarf_gpr_rbx,
+ ehframe_dwarf_gpr_rsi,
+ ehframe_dwarf_gpr_rdi,
+ ehframe_dwarf_gpr_rbp,
+ ehframe_dwarf_gpr_rsp,
+ ehframe_dwarf_gpr_r8,
+ ehframe_dwarf_gpr_r9,
+ ehframe_dwarf_gpr_r10,
+ ehframe_dwarf_gpr_r11,
+ ehframe_dwarf_gpr_r12,
+ ehframe_dwarf_gpr_r13,
+ ehframe_dwarf_gpr_r14,
+ ehframe_dwarf_gpr_r15,
+ ehframe_dwarf_gpr_rip,
+ ehframe_dwarf_fpu_xmm0,
+ ehframe_dwarf_fpu_xmm1,
+ ehframe_dwarf_fpu_xmm2,
+ ehframe_dwarf_fpu_xmm3,
+ ehframe_dwarf_fpu_xmm4,
+ ehframe_dwarf_fpu_xmm5,
+ ehframe_dwarf_fpu_xmm6,
+ ehframe_dwarf_fpu_xmm7,
+ ehframe_dwarf_fpu_xmm8,
+ ehframe_dwarf_fpu_xmm9,
+ ehframe_dwarf_fpu_xmm10,
+ ehframe_dwarf_fpu_xmm11,
+ ehframe_dwarf_fpu_xmm12,
+ ehframe_dwarf_fpu_xmm13,
+ ehframe_dwarf_fpu_xmm14,
+ ehframe_dwarf_fpu_xmm15,
+ ehframe_dwarf_fpu_stmm0,
+ ehframe_dwarf_fpu_stmm1,
+ ehframe_dwarf_fpu_stmm2,
+ ehframe_dwarf_fpu_stmm3,
+ ehframe_dwarf_fpu_stmm4,
+ ehframe_dwarf_fpu_stmm5,
+ ehframe_dwarf_fpu_stmm6,
+ ehframe_dwarf_fpu_stmm7
-enum gdb_regnums
-{
- gdb_gpr_rax = 0,
- gdb_gpr_rbx = 1,
- gdb_gpr_rcx = 2,
- gdb_gpr_rdx = 3,
- gdb_gpr_rsi = 4,
- gdb_gpr_rdi = 5,
- gdb_gpr_rbp = 6,
- gdb_gpr_rsp = 7,
- gdb_gpr_r8 = 8,
- gdb_gpr_r9 = 9,
- gdb_gpr_r10 = 10,
- gdb_gpr_r11 = 11,
- gdb_gpr_r12 = 12,
- gdb_gpr_r13 = 13,
- gdb_gpr_r14 = 14,
- gdb_gpr_r15 = 15,
- gdb_gpr_rip = 16,
- gdb_gpr_rflags = 17,
- gdb_gpr_cs = 18,
- gdb_gpr_ss = 19,
- gdb_gpr_ds = 20,
- gdb_gpr_es = 21,
- gdb_gpr_fs = 22,
- gdb_gpr_gs = 23,
- gdb_fpu_stmm0 = 24,
- gdb_fpu_stmm1 = 25,
- gdb_fpu_stmm2 = 26,
- gdb_fpu_stmm3 = 27,
- gdb_fpu_stmm4 = 28,
- gdb_fpu_stmm5 = 29,
- gdb_fpu_stmm6 = 30,
- gdb_fpu_stmm7 = 31,
- gdb_fpu_fctrl = 32, gdb_fpu_fcw = gdb_fpu_fctrl,
- gdb_fpu_fstat = 33, gdb_fpu_fsw = gdb_fpu_fstat,
- gdb_fpu_ftag = 34, gdb_fpu_ftw = gdb_fpu_ftag,
- gdb_fpu_fiseg = 35, gdb_fpu_cs = gdb_fpu_fiseg,
- gdb_fpu_fioff = 36, gdb_fpu_ip = gdb_fpu_fioff,
- gdb_fpu_foseg = 37, gdb_fpu_ds = gdb_fpu_foseg,
- gdb_fpu_fooff = 38, gdb_fpu_dp = gdb_fpu_fooff,
- gdb_fpu_fop = 39,
- gdb_fpu_xmm0 = 40,
- gdb_fpu_xmm1 = 41,
- gdb_fpu_xmm2 = 42,
- gdb_fpu_xmm3 = 43,
- gdb_fpu_xmm4 = 44,
- gdb_fpu_xmm5 = 45,
- gdb_fpu_xmm6 = 46,
- gdb_fpu_xmm7 = 47,
- gdb_fpu_xmm8 = 48,
- gdb_fpu_xmm9 = 49,
- gdb_fpu_xmm10 = 50,
- gdb_fpu_xmm11 = 51,
- gdb_fpu_xmm12 = 52,
- gdb_fpu_xmm13 = 53,
- gdb_fpu_xmm14 = 54,
- gdb_fpu_xmm15 = 55,
- gdb_fpu_mxcsr = 56
};
-RegisterContextDarwin_x86_64::RegisterContextDarwin_x86_64 (Thread &thread, uint32_t concrete_frame_idx) :
- RegisterContext (thread, concrete_frame_idx),
- gpr(),
- fpu(),
- exc()
-{
- uint32_t i;
- for (i=0; i<kNumErrors; i++)
- {
- gpr_errs[i] = -1;
- fpu_errs[i] = -1;
- exc_errs[i] = -1;
- }
-}
-
-RegisterContextDarwin_x86_64::~RegisterContextDarwin_x86_64()
-{
-}
-
#define GPR_OFFSET(reg) (LLVM_EXTENSION offsetof (RegisterContextDarwin_x86_64::GPR, reg))
#define FPU_OFFSET(reg) (LLVM_EXTENSION offsetof (RegisterContextDarwin_x86_64::FPU, reg) + sizeof (RegisterContextDarwin_x86_64::GPR))
#define EXC_OFFSET(reg) (LLVM_EXTENSION offsetof (RegisterContextDarwin_x86_64::EXC, reg) + sizeof (RegisterContextDarwin_x86_64::GPR) + sizeof (RegisterContextDarwin_x86_64::FPU))
@@ -247,7 +167,7 @@ RegisterContextDarwin_x86_64::~RegisterContextDarwin_x86_64()
// sizes and offsets.
#define DEFINE_GPR(reg, alt) #reg, alt, sizeof(((RegisterContextDarwin_x86_64::GPR *)NULL)->reg), GPR_OFFSET(reg), eEncodingUint, eFormatHex
#define DEFINE_FPU_UINT(reg) #reg, NULL, sizeof(((RegisterContextDarwin_x86_64::FPU *)NULL)->reg), FPU_OFFSET(reg), eEncodingUint, eFormatHex
-#define DEFINE_FPU_VECT(reg, i) #reg#i, NULL, sizeof(((RegisterContextDarwin_x86_64::FPU *)NULL)->reg[i].bytes), FPU_OFFSET(reg[i]), eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_fpu_##reg##i, gcc_dwarf_fpu_##reg##i, LLDB_INVALID_REGNUM, gdb_fpu_##reg##i, fpu_##reg##i }, NULL, NULL
+#define DEFINE_FPU_VECT(reg, i) #reg#i, NULL, sizeof(((RegisterContextDarwin_x86_64::FPU *)NULL)->reg[i].bytes), FPU_OFFSET(reg[i]), eEncodingVector, eFormatVectorOfUInt8, { ehframe_dwarf_fpu_##reg##i, ehframe_dwarf_fpu_##reg##i, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_##reg##i }, NULL, NULL
#define DEFINE_EXC(reg) #reg, NULL, sizeof(((RegisterContextDarwin_x86_64::EXC *)NULL)->reg), EXC_OFFSET(reg), eEncodingUint, eFormatHex
#define REG_CONTEXT_SIZE (sizeof (RegisterContextDarwin_x86_64::GPR) + sizeof (RegisterContextDarwin_x86_64::FPU) + sizeof (RegisterContextDarwin_x86_64::EXC))
@@ -255,39 +175,39 @@ RegisterContextDarwin_x86_64::~RegisterContextDarwin_x86_64()
// General purpose registers for 64 bit
static RegisterInfo g_register_infos[] =
{
-// Macro auto defines most stuff GCC DWARF GENERIC GDB LLDB VALUE REGS INVALIDATE REGS
-// =============================== ====================== =================== ========================== ==================== =================== ========== ===============
- { DEFINE_GPR (rax , NULL) , { gcc_dwarf_gpr_rax , gcc_dwarf_gpr_rax , LLDB_INVALID_REGNUM , gdb_gpr_rax , gpr_rax }, NULL, NULL},
- { DEFINE_GPR (rbx , NULL) , { gcc_dwarf_gpr_rbx , gcc_dwarf_gpr_rbx , LLDB_INVALID_REGNUM , gdb_gpr_rbx , gpr_rbx }, NULL, NULL},
- { DEFINE_GPR (rcx , NULL) , { gcc_dwarf_gpr_rcx , gcc_dwarf_gpr_rcx , LLDB_INVALID_REGNUM , gdb_gpr_rcx , gpr_rcx }, NULL, NULL},
- { DEFINE_GPR (rdx , NULL) , { gcc_dwarf_gpr_rdx , gcc_dwarf_gpr_rdx , LLDB_INVALID_REGNUM , gdb_gpr_rdx , gpr_rdx }, NULL, NULL},
- { DEFINE_GPR (rdi , NULL) , { gcc_dwarf_gpr_rdi , gcc_dwarf_gpr_rdi , LLDB_INVALID_REGNUM , gdb_gpr_rdi , gpr_rdi }, NULL, NULL},
- { DEFINE_GPR (rsi , NULL) , { gcc_dwarf_gpr_rsi , gcc_dwarf_gpr_rsi , LLDB_INVALID_REGNUM , gdb_gpr_rsi , gpr_rsi }, NULL, NULL},
- { DEFINE_GPR (rbp , "fp") , { gcc_dwarf_gpr_rbp , gcc_dwarf_gpr_rbp , LLDB_REGNUM_GENERIC_FP , gdb_gpr_rbp , gpr_rbp }, NULL, NULL},
- { DEFINE_GPR (rsp , "sp") , { gcc_dwarf_gpr_rsp , gcc_dwarf_gpr_rsp , LLDB_REGNUM_GENERIC_SP , gdb_gpr_rsp , gpr_rsp }, NULL, NULL},
- { DEFINE_GPR (r8 , NULL) , { gcc_dwarf_gpr_r8 , gcc_dwarf_gpr_r8 , LLDB_INVALID_REGNUM , gdb_gpr_r8 , gpr_r8 }, NULL, NULL},
- { DEFINE_GPR (r9 , NULL) , { gcc_dwarf_gpr_r9 , gcc_dwarf_gpr_r9 , LLDB_INVALID_REGNUM , gdb_gpr_r9 , gpr_r9 }, NULL, NULL},
- { DEFINE_GPR (r10 , NULL) , { gcc_dwarf_gpr_r10 , gcc_dwarf_gpr_r10 , LLDB_INVALID_REGNUM , gdb_gpr_r10 , gpr_r10 }, NULL, NULL},
- { DEFINE_GPR (r11 , NULL) , { gcc_dwarf_gpr_r11 , gcc_dwarf_gpr_r11 , LLDB_INVALID_REGNUM , gdb_gpr_r11 , gpr_r11 }, NULL, NULL},
- { DEFINE_GPR (r12 , NULL) , { gcc_dwarf_gpr_r12 , gcc_dwarf_gpr_r12 , LLDB_INVALID_REGNUM , gdb_gpr_r12 , gpr_r12 }, NULL, NULL},
- { DEFINE_GPR (r13 , NULL) , { gcc_dwarf_gpr_r13 , gcc_dwarf_gpr_r13 , LLDB_INVALID_REGNUM , gdb_gpr_r13 , gpr_r13 }, NULL, NULL},
- { DEFINE_GPR (r14 , NULL) , { gcc_dwarf_gpr_r14 , gcc_dwarf_gpr_r14 , LLDB_INVALID_REGNUM , gdb_gpr_r14 , gpr_r14 }, NULL, NULL},
- { DEFINE_GPR (r15 , NULL) , { gcc_dwarf_gpr_r15 , gcc_dwarf_gpr_r15 , LLDB_INVALID_REGNUM , gdb_gpr_r15 , gpr_r15 }, NULL, NULL},
- { DEFINE_GPR (rip , "pc") , { gcc_dwarf_gpr_rip , gcc_dwarf_gpr_rip , LLDB_REGNUM_GENERIC_PC , gdb_gpr_rip , gpr_rip }, NULL, NULL},
- { DEFINE_GPR (rflags, "flags") , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_REGNUM_GENERIC_FLAGS, gdb_gpr_rflags , gpr_rflags }, NULL, NULL},
- { DEFINE_GPR (cs , NULL) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_gpr_cs , gpr_cs }, NULL, NULL},
- { DEFINE_GPR (fs , NULL) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_gpr_fs , gpr_fs }, NULL, NULL},
- { DEFINE_GPR (gs , NULL) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_gpr_gs , gpr_gs }, NULL, NULL},
-
- { DEFINE_FPU_UINT(fcw) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fpu_fcw , fpu_fcw }, NULL, NULL},
- { DEFINE_FPU_UINT(fsw) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fpu_fsw , fpu_fsw }, NULL, NULL},
- { DEFINE_FPU_UINT(ftw) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fpu_ftw , fpu_ftw }, NULL, NULL},
- { DEFINE_FPU_UINT(fop) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fpu_fop , fpu_fop }, NULL, NULL},
- { DEFINE_FPU_UINT(ip) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fpu_ip , fpu_ip }, NULL, NULL},
- { DEFINE_FPU_UINT(cs) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fpu_cs , fpu_cs }, NULL, NULL},
- { DEFINE_FPU_UINT(dp) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fpu_dp , fpu_dp }, NULL, NULL},
- { DEFINE_FPU_UINT(ds) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fpu_ds , fpu_ds }, NULL, NULL},
- { DEFINE_FPU_UINT(mxcsr) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , gdb_fpu_mxcsr , fpu_mxcsr }, NULL, NULL},
+// Macro auto defines most stuff EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB VALUE REGS INVALIDATE REGS
+// =============================== ====================== =================== ========================== ==================== =================== ========== ===============
+ { DEFINE_GPR (rax , NULL) , { ehframe_dwarf_gpr_rax , ehframe_dwarf_gpr_rax , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_rax }, NULL, NULL},
+ { DEFINE_GPR (rbx , NULL) , { ehframe_dwarf_gpr_rbx , ehframe_dwarf_gpr_rbx , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_rbx }, NULL, NULL},
+ { DEFINE_GPR (rcx , NULL) , { ehframe_dwarf_gpr_rcx , ehframe_dwarf_gpr_rcx , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_rcx }, NULL, NULL},
+ { DEFINE_GPR (rdx , NULL) , { ehframe_dwarf_gpr_rdx , ehframe_dwarf_gpr_rdx , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_rdx }, NULL, NULL},
+ { DEFINE_GPR (rdi , NULL) , { ehframe_dwarf_gpr_rdi , ehframe_dwarf_gpr_rdi , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_rdi }, NULL, NULL},
+ { DEFINE_GPR (rsi , NULL) , { ehframe_dwarf_gpr_rsi , ehframe_dwarf_gpr_rsi , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_rsi }, NULL, NULL},
+ { DEFINE_GPR (rbp , "fp") , { ehframe_dwarf_gpr_rbp , ehframe_dwarf_gpr_rbp , LLDB_REGNUM_GENERIC_FP , LLDB_INVALID_REGNUM, gpr_rbp }, NULL, NULL},
+ { DEFINE_GPR (rsp , "sp") , { ehframe_dwarf_gpr_rsp , ehframe_dwarf_gpr_rsp , LLDB_REGNUM_GENERIC_SP , LLDB_INVALID_REGNUM, gpr_rsp }, NULL, NULL},
+ { DEFINE_GPR (r8 , NULL) , { ehframe_dwarf_gpr_r8 , ehframe_dwarf_gpr_r8 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_r8 }, NULL, NULL},
+ { DEFINE_GPR (r9 , NULL) , { ehframe_dwarf_gpr_r9 , ehframe_dwarf_gpr_r9 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_r9 }, NULL, NULL},
+ { DEFINE_GPR (r10 , NULL) , { ehframe_dwarf_gpr_r10 , ehframe_dwarf_gpr_r10 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_r10 }, NULL, NULL},
+ { DEFINE_GPR (r11 , NULL) , { ehframe_dwarf_gpr_r11 , ehframe_dwarf_gpr_r11 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_r11 }, NULL, NULL},
+ { DEFINE_GPR (r12 , NULL) , { ehframe_dwarf_gpr_r12 , ehframe_dwarf_gpr_r12 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_r12 }, NULL, NULL},
+ { DEFINE_GPR (r13 , NULL) , { ehframe_dwarf_gpr_r13 , ehframe_dwarf_gpr_r13 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_r13 }, NULL, NULL},
+ { DEFINE_GPR (r14 , NULL) , { ehframe_dwarf_gpr_r14 , ehframe_dwarf_gpr_r14 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_r14 }, NULL, NULL},
+ { DEFINE_GPR (r15 , NULL) , { ehframe_dwarf_gpr_r15 , ehframe_dwarf_gpr_r15 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_r15 }, NULL, NULL},
+ { DEFINE_GPR (rip , "pc") , { ehframe_dwarf_gpr_rip , ehframe_dwarf_gpr_rip , LLDB_REGNUM_GENERIC_PC , LLDB_INVALID_REGNUM, gpr_rip }, NULL, NULL},
+ { DEFINE_GPR (rflags, "flags") , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, gpr_rflags }, NULL, NULL},
+ { DEFINE_GPR (cs , NULL) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_cs }, NULL, NULL},
+ { DEFINE_GPR (fs , NULL) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_fs }, NULL, NULL},
+ { DEFINE_GPR (gs , NULL) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, gpr_gs }, NULL, NULL},
+
+ { DEFINE_FPU_UINT(fcw) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_fcw }, NULL, NULL},
+ { DEFINE_FPU_UINT(fsw) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_fsw }, NULL, NULL},
+ { DEFINE_FPU_UINT(ftw) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_ftw }, NULL, NULL},
+ { DEFINE_FPU_UINT(fop) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_fop }, NULL, NULL},
+ { DEFINE_FPU_UINT(ip) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_ip }, NULL, NULL},
+ { DEFINE_FPU_UINT(cs) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_cs }, NULL, NULL},
+ { DEFINE_FPU_UINT(dp) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_dp }, NULL, NULL},
+ { DEFINE_FPU_UINT(ds) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_ds }, NULL, NULL},
+ { DEFINE_FPU_UINT(mxcsr) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_mxcsr }, NULL, NULL},
{ DEFINE_FPU_UINT(mxcsrmask) , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, fpu_mxcsrmask }, NULL, NULL},
{ DEFINE_FPU_VECT(stmm,0) },
{ DEFINE_FPU_VECT(stmm,1) },
@@ -321,6 +241,25 @@ static RegisterInfo g_register_infos[] =
static size_t k_num_register_infos = llvm::array_lengthof(g_register_infos);
+RegisterContextDarwin_x86_64::RegisterContextDarwin_x86_64 (Thread &thread, uint32_t concrete_frame_idx) :
+ RegisterContext (thread, concrete_frame_idx),
+ gpr(),
+ fpu(),
+ exc()
+{
+ uint32_t i;
+ for (i=0; i<kNumErrors; i++)
+ {
+ gpr_errs[i] = -1;
+ fpu_errs[i] = -1;
+ exc_errs[i] = -1;
+ }
+}
+
+RegisterContextDarwin_x86_64::~RegisterContextDarwin_x86_64()
+{
+}
+
void
RegisterContextDarwin_x86_64::InvalidateAllRegisters ()
@@ -687,7 +626,7 @@ RegisterContextDarwin_x86_64::ReadRegister (const RegisterInfo *reg_info,
case fpu_stmm5:
case fpu_stmm6:
case fpu_stmm7:
- value.SetBytes(fpu.stmm[reg - fpu_stmm0].bytes, reg_info->byte_size, lldb::endian::InlHostByteOrder());
+ value.SetBytes(fpu.stmm[reg - fpu_stmm0].bytes, reg_info->byte_size, endian::InlHostByteOrder());
break;
case fpu_xmm0:
@@ -706,7 +645,7 @@ RegisterContextDarwin_x86_64::ReadRegister (const RegisterInfo *reg_info,
case fpu_xmm13:
case fpu_xmm14:
case fpu_xmm15:
- value.SetBytes(fpu.xmm[reg - fpu_xmm0].bytes, reg_info->byte_size, lldb::endian::InlHostByteOrder());
+ value.SetBytes(fpu.xmm[reg - fpu_xmm0].bytes, reg_info->byte_size, endian::InlHostByteOrder());
break;
case exc_trapno:
@@ -919,116 +858,51 @@ RegisterContextDarwin_x86_64::ConvertRegisterKindToRegisterNumber (lldb::Registe
break;
}
}
- else if (kind == eRegisterKindGCC || kind == eRegisterKindDWARF)
- {
- switch (reg)
- {
- case gcc_dwarf_gpr_rax: return gpr_rax;
- case gcc_dwarf_gpr_rdx: return gpr_rdx;
- case gcc_dwarf_gpr_rcx: return gpr_rcx;
- case gcc_dwarf_gpr_rbx: return gpr_rbx;
- case gcc_dwarf_gpr_rsi: return gpr_rsi;
- case gcc_dwarf_gpr_rdi: return gpr_rdi;
- case gcc_dwarf_gpr_rbp: return gpr_rbp;
- case gcc_dwarf_gpr_rsp: return gpr_rsp;
- case gcc_dwarf_gpr_r8: return gpr_r8;
- case gcc_dwarf_gpr_r9: return gpr_r9;
- case gcc_dwarf_gpr_r10: return gpr_r10;
- case gcc_dwarf_gpr_r11: return gpr_r11;
- case gcc_dwarf_gpr_r12: return gpr_r12;
- case gcc_dwarf_gpr_r13: return gpr_r13;
- case gcc_dwarf_gpr_r14: return gpr_r14;
- case gcc_dwarf_gpr_r15: return gpr_r15;
- case gcc_dwarf_gpr_rip: return gpr_rip;
- case gcc_dwarf_fpu_xmm0: return fpu_xmm0;
- case gcc_dwarf_fpu_xmm1: return fpu_xmm1;
- case gcc_dwarf_fpu_xmm2: return fpu_xmm2;
- case gcc_dwarf_fpu_xmm3: return fpu_xmm3;
- case gcc_dwarf_fpu_xmm4: return fpu_xmm4;
- case gcc_dwarf_fpu_xmm5: return fpu_xmm5;
- case gcc_dwarf_fpu_xmm6: return fpu_xmm6;
- case gcc_dwarf_fpu_xmm7: return fpu_xmm7;
- case gcc_dwarf_fpu_xmm8: return fpu_xmm8;
- case gcc_dwarf_fpu_xmm9: return fpu_xmm9;
- case gcc_dwarf_fpu_xmm10: return fpu_xmm10;
- case gcc_dwarf_fpu_xmm11: return fpu_xmm11;
- case gcc_dwarf_fpu_xmm12: return fpu_xmm12;
- case gcc_dwarf_fpu_xmm13: return fpu_xmm13;
- case gcc_dwarf_fpu_xmm14: return fpu_xmm14;
- case gcc_dwarf_fpu_xmm15: return fpu_xmm15;
- case gcc_dwarf_fpu_stmm0: return fpu_stmm0;
- case gcc_dwarf_fpu_stmm1: return fpu_stmm1;
- case gcc_dwarf_fpu_stmm2: return fpu_stmm2;
- case gcc_dwarf_fpu_stmm3: return fpu_stmm3;
- case gcc_dwarf_fpu_stmm4: return fpu_stmm4;
- case gcc_dwarf_fpu_stmm5: return fpu_stmm5;
- case gcc_dwarf_fpu_stmm6: return fpu_stmm6;
- case gcc_dwarf_fpu_stmm7: return fpu_stmm7;
- default:
- break;
- }
- }
- else if (kind == eRegisterKindGDB)
+ else if (kind == eRegisterKindEHFrame || kind == eRegisterKindDWARF)
{
switch (reg)
{
- case gdb_gpr_rax : return gpr_rax;
- case gdb_gpr_rbx : return gpr_rbx;
- case gdb_gpr_rcx : return gpr_rcx;
- case gdb_gpr_rdx : return gpr_rdx;
- case gdb_gpr_rsi : return gpr_rsi;
- case gdb_gpr_rdi : return gpr_rdi;
- case gdb_gpr_rbp : return gpr_rbp;
- case gdb_gpr_rsp : return gpr_rsp;
- case gdb_gpr_r8 : return gpr_r8;
- case gdb_gpr_r9 : return gpr_r9;
- case gdb_gpr_r10 : return gpr_r10;
- case gdb_gpr_r11 : return gpr_r11;
- case gdb_gpr_r12 : return gpr_r12;
- case gdb_gpr_r13 : return gpr_r13;
- case gdb_gpr_r14 : return gpr_r14;
- case gdb_gpr_r15 : return gpr_r15;
- case gdb_gpr_rip : return gpr_rip;
- case gdb_gpr_rflags : return gpr_rflags;
- case gdb_gpr_cs : return gpr_cs;
- case gdb_gpr_ss : return gpr_gs; // HACK: For now for "ss", just copy what is in "gs"
- case gdb_gpr_ds : return gpr_gs; // HACK: For now for "ds", just copy what is in "gs"
- case gdb_gpr_es : return gpr_gs; // HACK: For now for "es", just copy what is in "gs"
- case gdb_gpr_fs : return gpr_fs;
- case gdb_gpr_gs : return gpr_gs;
- case gdb_fpu_stmm0 : return fpu_stmm0;
- case gdb_fpu_stmm1 : return fpu_stmm1;
- case gdb_fpu_stmm2 : return fpu_stmm2;
- case gdb_fpu_stmm3 : return fpu_stmm3;
- case gdb_fpu_stmm4 : return fpu_stmm4;
- case gdb_fpu_stmm5 : return fpu_stmm5;
- case gdb_fpu_stmm6 : return fpu_stmm6;
- case gdb_fpu_stmm7 : return fpu_stmm7;
- case gdb_fpu_fctrl : return fpu_fctrl;
- case gdb_fpu_fstat : return fpu_fstat;
- case gdb_fpu_ftag : return fpu_ftag;
- case gdb_fpu_fiseg : return fpu_fiseg;
- case gdb_fpu_fioff : return fpu_fioff;
- case gdb_fpu_foseg : return fpu_foseg;
- case gdb_fpu_fooff : return fpu_fooff;
- case gdb_fpu_fop : return fpu_fop;
- case gdb_fpu_xmm0 : return fpu_xmm0;
- case gdb_fpu_xmm1 : return fpu_xmm1;
- case gdb_fpu_xmm2 : return fpu_xmm2;
- case gdb_fpu_xmm3 : return fpu_xmm3;
- case gdb_fpu_xmm4 : return fpu_xmm4;
- case gdb_fpu_xmm5 : return fpu_xmm5;
- case gdb_fpu_xmm6 : return fpu_xmm6;
- case gdb_fpu_xmm7 : return fpu_xmm7;
- case gdb_fpu_xmm8 : return fpu_xmm8;
- case gdb_fpu_xmm9 : return fpu_xmm9;
- case gdb_fpu_xmm10 : return fpu_xmm10;
- case gdb_fpu_xmm11 : return fpu_xmm11;
- case gdb_fpu_xmm12 : return fpu_xmm12;
- case gdb_fpu_xmm13 : return fpu_xmm13;
- case gdb_fpu_xmm14 : return fpu_xmm14;
- case gdb_fpu_xmm15 : return fpu_xmm15;
- case gdb_fpu_mxcsr : return fpu_mxcsr;
+ case ehframe_dwarf_gpr_rax: return gpr_rax;
+ case ehframe_dwarf_gpr_rdx: return gpr_rdx;
+ case ehframe_dwarf_gpr_rcx: return gpr_rcx;
+ case ehframe_dwarf_gpr_rbx: return gpr_rbx;
+ case ehframe_dwarf_gpr_rsi: return gpr_rsi;
+ case ehframe_dwarf_gpr_rdi: return gpr_rdi;
+ case ehframe_dwarf_gpr_rbp: return gpr_rbp;
+ case ehframe_dwarf_gpr_rsp: return gpr_rsp;
+ case ehframe_dwarf_gpr_r8: return gpr_r8;
+ case ehframe_dwarf_gpr_r9: return gpr_r9;
+ case ehframe_dwarf_gpr_r10: return gpr_r10;
+ case ehframe_dwarf_gpr_r11: return gpr_r11;
+ case ehframe_dwarf_gpr_r12: return gpr_r12;
+ case ehframe_dwarf_gpr_r13: return gpr_r13;
+ case ehframe_dwarf_gpr_r14: return gpr_r14;
+ case ehframe_dwarf_gpr_r15: return gpr_r15;
+ case ehframe_dwarf_gpr_rip: return gpr_rip;
+ case ehframe_dwarf_fpu_xmm0: return fpu_xmm0;
+ case ehframe_dwarf_fpu_xmm1: return fpu_xmm1;
+ case ehframe_dwarf_fpu_xmm2: return fpu_xmm2;
+ case ehframe_dwarf_fpu_xmm3: return fpu_xmm3;
+ case ehframe_dwarf_fpu_xmm4: return fpu_xmm4;
+ case ehframe_dwarf_fpu_xmm5: return fpu_xmm5;
+ case ehframe_dwarf_fpu_xmm6: return fpu_xmm6;
+ case ehframe_dwarf_fpu_xmm7: return fpu_xmm7;
+ case ehframe_dwarf_fpu_xmm8: return fpu_xmm8;
+ case ehframe_dwarf_fpu_xmm9: return fpu_xmm9;
+ case ehframe_dwarf_fpu_xmm10: return fpu_xmm10;
+ case ehframe_dwarf_fpu_xmm11: return fpu_xmm11;
+ case ehframe_dwarf_fpu_xmm12: return fpu_xmm12;
+ case ehframe_dwarf_fpu_xmm13: return fpu_xmm13;
+ case ehframe_dwarf_fpu_xmm14: return fpu_xmm14;
+ case ehframe_dwarf_fpu_xmm15: return fpu_xmm15;
+ case ehframe_dwarf_fpu_stmm0: return fpu_stmm0;
+ case ehframe_dwarf_fpu_stmm1: return fpu_stmm1;
+ case ehframe_dwarf_fpu_stmm2: return fpu_stmm2;
+ case ehframe_dwarf_fpu_stmm3: return fpu_stmm3;
+ case ehframe_dwarf_fpu_stmm4: return fpu_stmm4;
+ case ehframe_dwarf_fpu_stmm5: return fpu_stmm5;
+ case ehframe_dwarf_fpu_stmm6: return fpu_stmm6;
+ case ehframe_dwarf_fpu_stmm7: return fpu_stmm7;
default:
break;
}
diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h b/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h
index 09e35e9c423e..ed627e194a26 100644
--- a/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h
+++ b/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h
@@ -23,41 +23,42 @@ public:
RegisterContextDarwin_x86_64 (lldb_private::Thread &thread,
uint32_t concrete_frame_idx);
- virtual
- ~RegisterContextDarwin_x86_64();
+ ~RegisterContextDarwin_x86_64() override;
- virtual void
- InvalidateAllRegisters ();
+ void
+ InvalidateAllRegisters() override;
- virtual size_t
- GetRegisterCount ();
+ size_t
+ GetRegisterCount() override;
- virtual const lldb_private::RegisterInfo *
- GetRegisterInfoAtIndex (size_t reg);
+ const lldb_private::RegisterInfo *
+ GetRegisterInfoAtIndex(size_t reg) override;
- virtual size_t
- GetRegisterSetCount ();
+ size_t
+ GetRegisterSetCount() override;
- virtual const lldb_private::RegisterSet *
- GetRegisterSet (size_t set);
+ const lldb_private::RegisterSet *
+ GetRegisterSet(size_t set) override;
- virtual bool
- ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
+ bool
+ ReadRegister(const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &value) override;
- virtual bool
- WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
+ bool
+ WriteRegister(const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &value) override;
- virtual bool
- ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
+ bool
+ ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
- virtual bool
- WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
+ bool
+ WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
- virtual uint32_t
- ConvertRegisterKindToRegisterNumber (lldb::RegisterKind kind, uint32_t num);
+ uint32_t
+ ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override;
- virtual bool
- HardwareSingleStep (bool enable);
+ bool
+ HardwareSingleStep(bool enable) override;
struct GPR
{
@@ -268,7 +269,6 @@ protected:
static const lldb_private::RegisterInfo *
GetRegisterInfos ();
-
};
-#endif // liblldb_RegisterContextDarwin_x86_64_h_
+#endif // liblldb_RegisterContextDarwin_x86_64_h_
diff --git a/source/Plugins/Process/Utility/RegisterContextDummy.cpp b/source/Plugins/Process/Utility/RegisterContextDummy.cpp
index 329b0a7968a2..0859e4e9419c 100644
--- a/source/Plugins/Process/Utility/RegisterContextDummy.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextDummy.cpp
@@ -51,10 +51,10 @@ RegisterContext (thread, concrete_frame_idx)
m_pc_reg_info.format = eFormatPointer;
m_pc_reg_info.invalidate_regs = NULL;
m_pc_reg_info.value_regs = NULL;
- m_pc_reg_info.kinds[eRegisterKindGCC] = LLDB_INVALID_REGNUM;
+ 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;
- m_pc_reg_info.kinds[eRegisterKindGDB] = LLDB_INVALID_REGNUM;
+ m_pc_reg_info.kinds[eRegisterKindProcessPlugin] = LLDB_INVALID_REGNUM;
m_pc_reg_info.kinds[eRegisterKindLLDB] = LLDB_INVALID_REGNUM;
}
diff --git a/source/Plugins/Process/Utility/RegisterContextDummy.h b/source/Plugins/Process/Utility/RegisterContextDummy.h
index ddf466713048..9f6a8dc347b5 100644
--- a/source/Plugins/Process/Utility/RegisterContextDummy.h
+++ b/source/Plugins/Process/Utility/RegisterContextDummy.h
@@ -10,8 +10,12 @@
#ifndef lldb_RegisterContextDummy_h_
#define lldb_RegisterContextDummy_h_
+// C Includes
+// C++ Includes
#include <vector>
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Symbol/SymbolContext.h"
@@ -25,42 +29,39 @@ public:
RegisterContextDummy (Thread &thread, uint32_t concrete_frame_idx, uint32_t address_byte_size);
- ///
- // pure virtual functions from the base class that we must implement
- ///
+ ~RegisterContextDummy() override;
- virtual
- ~RegisterContextDummy ();
+ void
+ InvalidateAllRegisters() override;
- virtual void
- InvalidateAllRegisters ();
+ size_t
+ GetRegisterCount() override;
- virtual size_t
- GetRegisterCount ();
+ const lldb_private::RegisterInfo *
+ GetRegisterInfoAtIndex(size_t reg) override;
- virtual const lldb_private::RegisterInfo *
- GetRegisterInfoAtIndex (size_t reg);
+ size_t
+ GetRegisterSetCount() override;
- virtual size_t
- GetRegisterSetCount ();
+ const lldb_private::RegisterSet *
+ GetRegisterSet(size_t reg_set) override;
- virtual const lldb_private::RegisterSet *
- GetRegisterSet (size_t reg_set);
+ bool
+ ReadRegister(const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &value) override;
- virtual bool
- ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
+ bool
+ WriteRegister(const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &value) override;
- virtual bool
- WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
+ bool
+ ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
- virtual bool
- ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
+ bool
+ WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
- virtual bool
- WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
-
- virtual uint32_t
- ConvertRegisterKindToRegisterNumber (lldb::RegisterKind kind, uint32_t num);
+ uint32_t
+ ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override;
private:
//------------------------------------------------------------------
@@ -72,6 +73,7 @@ private:
DISALLOW_COPY_AND_ASSIGN (RegisterContextDummy);
};
+
} // namespace lldb_private
-#endif // lldb_RegisterContextDummy_h_
+#endif // lldb_RegisterContextDummy_h_
diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_arm.cpp b/source/Plugins/Process/Utility/RegisterContextFreeBSD_arm.cpp
index 8005a6339f6d..a507dad69f60 100644
--- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_arm.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_arm.cpp
@@ -23,6 +23,7 @@ using namespace lldb_private;
// http://svnweb.freebsd.org/base/head/sys/arm/include/reg.h
#define GPR_OFFSET(idx) ((idx) * 4)
#define FPU_OFFSET(idx) ((idx) * 4 + sizeof (RegisterContextFreeBSD_arm::GPR))
+#define FPSCR_OFFSET (LLVM_EXTENSION offsetof (RegisterContextFreeBSD_arm::FPU, fpscr) + sizeof (RegisterContextFreeBSD_arm::GPR))
#define EXC_OFFSET(idx) ((idx) * 4 + sizeof (RegisterContextFreeBSD_arm::GPR) + sizeof (RegisterContextFreeBSD_arm::FPU))
#define DBG_OFFSET(reg) ((LLVM_EXTENSION offsetof (RegisterContextFreeBSD_arm::DBG, reg) + sizeof (RegisterContextFreeBSD_arm::GPR) + sizeof (RegisterContextFreeBSD_arm::FPU) + sizeof (RegisterContextFreeBSD_arm::EXC)))
diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_arm.h b/source/Plugins/Process/Utility/RegisterContextFreeBSD_arm.h
index c4287e9f0a47..f2d9364b3ce6 100644
--- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_arm.h
+++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_arm.h
@@ -12,7 +12,6 @@
#include "lldb/lldb-private.h"
#include "lldb/Target/RegisterContext.h"
-#include "RegisterContextPOSIX.h"
#include "RegisterInfoInterface.h"
class RegisterContextFreeBSD_arm
diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_arm64.h b/source/Plugins/Process/Utility/RegisterContextFreeBSD_arm64.h
index 249027aaa76c..cfdae4d2b557 100644
--- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_arm64.h
+++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_arm64.h
@@ -10,7 +10,7 @@
#ifndef liblldb_RegisterContextFreeBSD_arm64_H_
#define liblldb_RegisterContextFreeBSD_arm64_H_
-#include "RegisterContextPOSIX.h"
+#include "RegisterInfoInterface.h"
class RegisterContextFreeBSD_arm64:
public lldb_private::RegisterInfoInterface
diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.h b/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.h
index 62792c02e2b9..9527fc03f728 100644
--- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.h
+++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.h
@@ -10,7 +10,7 @@
#ifndef liblldb_RegisterContextFreeBSD_i386_H_
#define liblldb_RegisterContextFreeBSD_i386_H_
-#include "RegisterContextPOSIX.h"
+#include "RegisterInfoInterface.h"
class RegisterContextFreeBSD_i386
: public lldb_private::RegisterInfoInterface
diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h b/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h
index f9a3ce09c5b1..5c042af20eac 100644
--- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h
+++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h
@@ -10,7 +10,7 @@
#ifndef liblldb_RegisterContextFreeBSD_mips64_H_
#define liblldb_RegisterContextFreeBSD_mips64_H_
-#include "RegisterContextPOSIX.h"
+#include "RegisterInfoInterface.h"
class RegisterContextFreeBSD_mips64:
public lldb_private::RegisterInfoInterface
diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h b/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h
index b907fe99b5e0..930683f8a870 100644
--- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h
+++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h
@@ -7,17 +7,21 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextFreeBSD_powerpc_H_
-#define liblldb_RegisterContextFreeBSD_powerpc_H_
+#ifndef liblldb_RegisterContextFreeBSD_powerpc_h_
+#define liblldb_RegisterContextFreeBSD_powerpc_h_
-#include "RegisterContextPOSIX.h"
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "RegisterInfoInterface.h"
class RegisterContextFreeBSD_powerpc:
public lldb_private::RegisterInfoInterface
{
public:
RegisterContextFreeBSD_powerpc(const lldb_private::ArchSpec &target_arch);
- virtual ~RegisterContextFreeBSD_powerpc();
+ ~RegisterContextFreeBSD_powerpc() override;
size_t
GetGPRSize() const override;
@@ -34,7 +38,7 @@ class RegisterContextFreeBSD_powerpc32:
{
public:
RegisterContextFreeBSD_powerpc32(const lldb_private::ArchSpec &target_arch);
- virtual ~RegisterContextFreeBSD_powerpc32();
+ ~RegisterContextFreeBSD_powerpc32() override;
size_t
GetGPRSize() const override;
@@ -51,7 +55,7 @@ class RegisterContextFreeBSD_powerpc64:
{
public:
RegisterContextFreeBSD_powerpc64(const lldb_private::ArchSpec &target_arch);
- virtual ~RegisterContextFreeBSD_powerpc64();
+ ~RegisterContextFreeBSD_powerpc64() override;
size_t
GetGPRSize() const override;
@@ -63,4 +67,4 @@ public:
GetRegisterCount() const override;
};
-#endif
+#endif // liblldb_RegisterContextFreeBSD_powerpc_h_
diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h b/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h
index 21fbdb4681b3..e739fa50ed6c 100644
--- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h
+++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h
@@ -10,7 +10,7 @@
#ifndef liblldb_RegisterContextFreeBSD_x86_64_H_
#define liblldb_RegisterContextFreeBSD_x86_64_H_
-#include "RegisterContextPOSIX.h"
+#include "RegisterInfoInterface.h"
class RegisterContextFreeBSD_x86_64:
public lldb_private::RegisterInfoInterface
diff --git a/source/Plugins/Process/Utility/RegisterContextHistory.cpp b/source/Plugins/Process/Utility/RegisterContextHistory.cpp
index 3c370103629e..9d2181376e09 100644
--- a/source/Plugins/Process/Utility/RegisterContextHistory.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextHistory.cpp
@@ -52,10 +52,10 @@ RegisterContext (thread, concrete_frame_idx),
m_pc_reg_info.format = eFormatPointer;
m_pc_reg_info.invalidate_regs = NULL;
m_pc_reg_info.value_regs = NULL;
- m_pc_reg_info.kinds[eRegisterKindGCC] = LLDB_INVALID_REGNUM;
+ 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;
- m_pc_reg_info.kinds[eRegisterKindGDB] = LLDB_INVALID_REGNUM;
+ m_pc_reg_info.kinds[eRegisterKindProcessPlugin] = LLDB_INVALID_REGNUM;
m_pc_reg_info.kinds[eRegisterKindLLDB] = LLDB_INVALID_REGNUM;
}
diff --git a/source/Plugins/Process/Utility/RegisterContextHistory.h b/source/Plugins/Process/Utility/RegisterContextHistory.h
index 04842c62aff1..3f44a1fde68b 100644
--- a/source/Plugins/Process/Utility/RegisterContextHistory.h
+++ b/source/Plugins/Process/Utility/RegisterContextHistory.h
@@ -10,8 +10,12 @@
#ifndef lldb_RegisterContextHistory_h_
#define lldb_RegisterContextHistory_h_
+// C Includes
+// C++ Includes
#include <vector>
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Symbol/SymbolContext.h"
@@ -25,42 +29,39 @@ public:
RegisterContextHistory (Thread &thread, uint32_t concrete_frame_idx, uint32_t address_byte_size, lldb::addr_t pc_value);
- ///
- // pure virtual functions from the base class that we must implement
- ///
+ ~RegisterContextHistory() override;
- virtual
- ~RegisterContextHistory ();
+ void
+ InvalidateAllRegisters() override;
- virtual void
- InvalidateAllRegisters ();
+ size_t
+ GetRegisterCount() override;
- virtual size_t
- GetRegisterCount ();
+ const lldb_private::RegisterInfo *
+ GetRegisterInfoAtIndex(size_t reg) override;
- virtual const lldb_private::RegisterInfo *
- GetRegisterInfoAtIndex (size_t reg);
+ size_t
+ GetRegisterSetCount() override;
- virtual size_t
- GetRegisterSetCount ();
+ const lldb_private::RegisterSet *
+ GetRegisterSet(size_t reg_set) override;
- virtual const lldb_private::RegisterSet *
- GetRegisterSet (size_t reg_set);
+ bool
+ ReadRegister(const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &value) override;
- virtual bool
- ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
+ bool
+ WriteRegister(const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &value) override;
- virtual bool
- WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
+ bool
+ ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
- virtual bool
- ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
+ bool
+ WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
- virtual bool
- WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
-
- virtual uint32_t
- ConvertRegisterKindToRegisterNumber (lldb::RegisterKind kind, uint32_t num);
+ uint32_t
+ ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override;
private:
//------------------------------------------------------------------
@@ -76,4 +77,4 @@ private:
};
} // namespace lldb_private
-#endif // lldb_RegisterContextHistory_h_
+#endif // lldb_RegisterContextHistory_h_
diff --git a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
index 37b007cfffcf..278a1d5dabf6 100644
--- a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -17,6 +17,7 @@
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Value.h"
#include "lldb/Expression/DWARFExpression.h"
+#include "lldb/Symbol/ArmUnwindInfo.h"
#include "lldb/Symbol/DWARFCallFrameInfo.h"
#include "lldb/Symbol/FuncUnwinders.h"
#include "lldb/Symbol/Function.h"
@@ -634,28 +635,30 @@ bool
RegisterContextLLDB::CheckIfLoopingStack ()
{
// If we have a bad stack setup, we can get the same CFA value multiple times -- or even
- // more devious, we can actually oscillate between two CFA values. Detect that here and
+ // more devious, we can actually oscillate between two CFA values. Detect that here and
// break out to avoid a possible infinite loop in lldb trying to unwind the stack.
- addr_t next_frame_cfa;
- addr_t next_next_frame_cfa = LLDB_INVALID_ADDRESS;
- if (GetNextFrame().get() && GetNextFrame()->GetCFA(next_frame_cfa))
+ // To detect when we have the same CFA value multiple times, we compare the CFA of the current
+ // frame with the 2nd next frame because in some specail case (e.g. signal hanlders, hand
+ // written assembly without ABI compiance) we can have 2 frames with the same CFA (in theory we
+ // can have arbitrary number of frames with the same CFA, but more then 2 is very very unlikely)
+
+ RegisterContextLLDB::SharedPtr next_frame = GetNextFrame();
+ if (next_frame)
{
- if (next_frame_cfa == m_cfa)
+ RegisterContextLLDB::SharedPtr next_next_frame = next_frame->GetNextFrame();
+ addr_t next_next_frame_cfa = LLDB_INVALID_ADDRESS;
+ if (next_next_frame && next_next_frame->GetCFA(next_next_frame_cfa))
{
- // We have a loop in the stack unwind
- return true;
- }
- if (GetNextFrame()->GetNextFrame().get() && GetNextFrame()->GetNextFrame()->GetCFA(next_next_frame_cfa)
- && next_next_frame_cfa == m_cfa)
- {
- // We have a loop in the stack unwind
- return true;
+ if (next_next_frame_cfa == m_cfa)
+ {
+ // We have a loop in the stack unwind
+ return true;
+ }
}
}
return false;
}
-
bool
RegisterContextLLDB::IsFrameZero () const
{
@@ -792,24 +795,38 @@ RegisterContextLLDB::GetFullUnwindPlanForFrame ()
func_unwinders_sp = pc_module_sp->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx);
}
- // No FuncUnwinders available for this pc (i.e. a stripped function symbol and -fomit-frame-pointer).
- // Try using the eh_frame information relative to the current PC,
- // and finally fall back on the architectural default unwind.
+ // No FuncUnwinders available for this pc (stripped function symbols, lldb could not augment its
+ // function table with another source, like LC_FUNCTION_STARTS or eh_frame in ObjectFileMachO).
+ // See if eh_frame or the .ARM.exidx tables have unwind information for this address, else fall
+ // back to the architectural default unwind.
if (!func_unwinders_sp)
{
- DWARFCallFrameInfo *eh_frame = pc_module_sp && pc_module_sp->GetObjectFile() ?
- pc_module_sp->GetObjectFile()->GetUnwindTable().GetEHFrameInfo() : nullptr;
-
m_frame_type = eNormalFrame;
- if (eh_frame && m_current_pc.IsValid())
+
+ if (!pc_module_sp || !pc_module_sp->GetObjectFile() || !m_current_pc.IsValid())
+ return arch_default_unwind_plan_sp;
+
+ // Even with -fomit-frame-pointer, we can try eh_frame to get back on track.
+ DWARFCallFrameInfo *eh_frame = pc_module_sp->GetObjectFile()->GetUnwindTable().GetEHFrameInfo();
+ if (eh_frame)
{
unwind_plan_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric));
- // Even with -fomit-frame-pointer, we can try eh_frame to get back on track.
if (eh_frame->GetUnwindPlan (m_current_pc, *unwind_plan_sp))
return unwind_plan_sp;
else
unwind_plan_sp.reset();
}
+
+ ArmUnwindInfo *arm_exidx = pc_module_sp->GetObjectFile()->GetUnwindTable().GetArmUnwindInfo();
+ if (arm_exidx)
+ {
+ unwind_plan_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric));
+ if (arm_exidx->GetUnwindPlan (exe_ctx.GetTargetRef(), m_current_pc, *unwind_plan_sp))
+ return unwind_plan_sp;
+ else
+ unwind_plan_sp.reset();
+ }
+
return arch_default_unwind_plan_sp;
}
@@ -864,12 +881,12 @@ RegisterContextLLDB::GetFullUnwindPlanForFrame ()
// then the architecture default plan and for hand written assembly 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 eh_frame_unwind_plan = func_unwinders_sp->GetEHFrameUnwindPlan (process->GetTarget(), m_current_offset_backed_up_one);
- if (eh_frame_unwind_plan &&
- eh_frame_unwind_plan.get() != unwind_plan_sp.get() &&
- eh_frame_unwind_plan->GetSourceName() != unwind_plan_sp->GetSourceName())
+ UnwindPlanSP call_site_unwind_plan = func_unwinders_sp->GetUnwindPlanAtCallSite(process->GetTarget(), m_current_offset_backed_up_one);
+ if (call_site_unwind_plan &&
+ call_site_unwind_plan.get() != unwind_plan_sp.get() &&
+ call_site_unwind_plan->GetSourceName() != unwind_plan_sp->GetSourceName())
{
- m_fallback_unwind_plan_sp = eh_frame_unwind_plan;
+ m_fallback_unwind_plan_sp = call_site_unwind_plan;
}
else
{
@@ -909,12 +926,12 @@ RegisterContextLLDB::GetFullUnwindPlanForFrame ()
// more reliable even on non call sites then the architecture default plan and for hand
// written assembly 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 eh_frame_unwind_plan = func_unwinders_sp->GetEHFrameUnwindPlan (process->GetTarget(), m_current_offset_backed_up_one);
- if (eh_frame_unwind_plan &&
- eh_frame_unwind_plan.get() != unwind_plan_sp.get() &&
- eh_frame_unwind_plan->GetSourceName() != unwind_plan_sp->GetSourceName())
+ UnwindPlanSP call_site_unwind_plan = func_unwinders_sp->GetUnwindPlanAtCallSite(process->GetTarget(), m_current_offset_backed_up_one);
+ if (call_site_unwind_plan &&
+ call_site_unwind_plan.get() != unwind_plan_sp.get() &&
+ call_site_unwind_plan->GetSourceName() != unwind_plan_sp->GetSourceName())
{
- m_fallback_unwind_plan_sp = eh_frame_unwind_plan;
+ m_fallback_unwind_plan_sp = call_site_unwind_plan;
}
else
{
@@ -1488,7 +1505,11 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, lldb_privat
unwindplan_regloc.GetDWARFExpressionLength(),
process->GetByteOrder(), process->GetAddressByteSize());
ModuleSP opcode_ctx;
- DWARFExpression dwarfexpr (opcode_ctx, dwarfdata, 0, unwindplan_regloc.GetDWARFExpressionLength());
+ DWARFExpression dwarfexpr (opcode_ctx,
+ dwarfdata,
+ nullptr,
+ 0,
+ unwindplan_regloc.GetDWARFExpressionLength());
dwarfexpr.SetRegisterKind (unwindplan_registerkind);
Value result;
Error error;
@@ -1784,7 +1805,11 @@ RegisterContextLLDB::ReadCFAValueForRow (lldb::RegisterKind row_register_kind,
row->GetCFAValue().GetDWARFExpressionLength(),
process->GetByteOrder(), process->GetAddressByteSize());
ModuleSP opcode_ctx;
- DWARFExpression dwarfexpr (opcode_ctx, dwarfdata, 0, row->GetCFAValue().GetDWARFExpressionLength());
+ DWARFExpression dwarfexpr (opcode_ctx,
+ dwarfdata,
+ nullptr,
+ 0,
+ row->GetCFAValue().GetDWARFExpressionLength());
dwarfexpr.SetRegisterKind (row_register_kind);
Value result;
Error error;
diff --git a/source/Plugins/Process/Utility/RegisterContextLLDB.h b/source/Plugins/Process/Utility/RegisterContextLLDB.h
index 5f94a977448d..68dca3d4965f 100644
--- a/source/Plugins/Process/Utility/RegisterContextLLDB.h
+++ b/source/Plugins/Process/Utility/RegisterContextLLDB.h
@@ -10,8 +10,12 @@
#ifndef lldb_RegisterContextLLDB_h_
#define lldb_RegisterContextLLDB_h_
+// C Includes
+// C++ Includes
#include <vector>
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Symbol/UnwindPlan.h"
@@ -33,42 +37,39 @@ public:
lldb_private::SymbolContext& sym_ctx,
uint32_t frame_number, lldb_private::UnwindLLDB& unwind_lldb);
- ///
- // pure virtual functions from the base class that we must implement
- ///
-
- virtual
- ~RegisterContextLLDB () { }
+ ~RegisterContextLLDB() override = default;
- virtual void
- InvalidateAllRegisters ();
+ void
+ InvalidateAllRegisters() override;
- virtual size_t
- GetRegisterCount ();
+ size_t
+ GetRegisterCount() override;
- virtual const lldb_private::RegisterInfo *
- GetRegisterInfoAtIndex (size_t reg);
+ const lldb_private::RegisterInfo *
+ GetRegisterInfoAtIndex(size_t reg) override;
- virtual size_t
- GetRegisterSetCount ();
+ size_t
+ GetRegisterSetCount() override;
- virtual const lldb_private::RegisterSet *
- GetRegisterSet (size_t reg_set);
+ const lldb_private::RegisterSet *
+ GetRegisterSet(size_t reg_set) override;
- virtual bool
- ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
+ bool
+ ReadRegister(const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &value) override;
- virtual bool
- WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
+ bool
+ WriteRegister(const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &value) override;
- virtual bool
- ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
+ bool
+ ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
- virtual bool
- WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
+ bool
+ WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
- virtual uint32_t
- ConvertRegisterKindToRegisterNumber (lldb::RegisterKind kind, uint32_t num);
+ uint32_t
+ ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override;
bool
IsValid () const;
@@ -99,7 +100,6 @@ private:
// UnwindLLDB needs to pass around references to RegisterLocations
friend class UnwindLLDB;
-
// Returns true if we have an unwind loop -- the same stack frame unwinding
// multiple times.
bool
@@ -130,7 +130,6 @@ private:
bool
IsSkipFrame () const;
-
//------------------------------------------------------------------
/// Determines if a SymbolContext is a trap handler or not
///
@@ -221,7 +220,6 @@ private:
bool
IsUnwindPlanValidForCurrentPC(lldb::UnwindPlanSP unwind_plan_sp, int &valid_pc_offset);
-
lldb_private::Thread& m_thread;
///
@@ -269,4 +267,4 @@ private:
} // namespace lldb_private
-#endif // lldb_RegisterContextLLDB_h_
+#endif // lldb_RegisterContextLLDB_h_
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_arm.cpp b/source/Plugins/Process/Utility/RegisterContextLinux_arm.cpp
index e7784b1712c3..f8d97aa3482c 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_arm.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_arm.cpp
@@ -22,6 +22,7 @@ using namespace lldb_private;
// Based on RegisterContextDarwin_arm.cpp
#define GPR_OFFSET(idx) ((idx) * 4)
#define FPU_OFFSET(idx) ((idx) * 4 + sizeof (RegisterContextLinux_arm::GPR))
+#define FPSCR_OFFSET (LLVM_EXTENSION offsetof (RegisterContextLinux_arm::FPU, fpscr) + sizeof (RegisterContextLinux_arm::GPR))
#define EXC_OFFSET(idx) ((idx) * 4 + sizeof (RegisterContextLinux_arm::GPR) + sizeof (RegisterContextLinux_arm::FPU))
#define DBG_OFFSET(reg) ((LLVM_EXTENSION offsetof (RegisterContextLinux_arm::DBG, reg) + sizeof (RegisterContextLinux_arm::GPR) + sizeof (RegisterContextLinux_arm::FPU) + sizeof (RegisterContextLinux_arm::EXC)))
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_arm.h b/source/Plugins/Process/Utility/RegisterContextLinux_arm.h
index 7087eb4c3dcc..c3d41f686dcd 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_arm.h
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_arm.h
@@ -12,7 +12,6 @@
#include "lldb/lldb-private.h"
#include "lldb/Target/RegisterContext.h"
-#include "RegisterContextPOSIX.h"
#include "RegisterInfoInterface.h"
class RegisterContextLinux_arm
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_arm64.cpp b/source/Plugins/Process/Utility/RegisterContextLinux_arm64.cpp
index 8c23e39ff013..a4ab083995f6 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_arm64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_arm64.cpp
@@ -21,7 +21,7 @@
#define GPR_OFFSET_NAME(reg) (LLVM_EXTENSION offsetof (RegisterContextLinux_arm64::GPR, reg))
#define FPU_OFFSET(idx) ((idx) * 16 + sizeof (RegisterContextLinux_arm64::GPR))
-#define FPU_OFFSET_NAME(reg) (LLVM_EXTENSION offsetof (RegisterContextLinux_arm64::FPU, reg))
+#define FPU_OFFSET_NAME(reg) (LLVM_EXTENSION offsetof (RegisterContextLinux_arm64::FPU, reg) + sizeof (RegisterContextLinux_arm64::GPR))
#define EXC_OFFSET_NAME(reg) (LLVM_EXTENSION offsetof (RegisterContextLinux_arm64::EXC, reg) + sizeof (RegisterContextLinux_arm64::GPR) + sizeof (RegisterContextLinux_arm64::FPU))
#define DBG_OFFSET_NAME(reg) (LLVM_EXTENSION offsetof (RegisterContextLinux_arm64::DBG, reg) + sizeof (RegisterContextLinux_arm64::GPR) + sizeof (RegisterContextLinux_arm64::FPU) + sizeof (RegisterContextLinux_arm64::EXC))
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_arm64.h b/source/Plugins/Process/Utility/RegisterContextLinux_arm64.h
index a9a5a0985f25..3de94b862583 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_arm64.h
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_arm64.h
@@ -12,7 +12,6 @@
#include "lldb/lldb-private.h"
#include "lldb/Target/RegisterContext.h"
-#include "RegisterContextPOSIX.h"
#include "RegisterInfoInterface.h"
class RegisterContextLinux_arm64
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp b/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
index 4f6bbc8f8ab8..e39beef42888 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
@@ -26,7 +26,7 @@ struct GPR
uint32_t es;
uint32_t fs;
uint32_t gs;
- uint32_t orig_ax;
+ uint32_t orig_eax;
uint32_t eip;
uint32_t cs;
uint32_t eflags;
@@ -38,7 +38,8 @@ struct FPR_i386
{
uint16_t fctrl; // FPU Control Word (fcw)
uint16_t fstat; // FPU Status Word (fsw)
- uint16_t ftag; // FPU Tag Word (ftw)
+ uint8_t ftag; // FPU Tag Word (ftw)
+ uint8_t reserved_1; // Reserved
uint16_t fop; // Last Instruction Opcode (fop)
union
{
@@ -98,6 +99,9 @@ struct UserArea
RegisterContextLinux_i386::RegisterContextLinux_i386(const ArchSpec &target_arch) :
RegisterInfoInterface(target_arch)
{
+ RegisterInfo orig_ax = { "orig_eax", NULL, sizeof(((GPR*)NULL)->orig_eax), (LLVM_EXTENSION offsetof(GPR, orig_eax)), eEncodingUint, \
+ eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL };
+ d_register_infos.push_back(orig_ax);
}
size_t
@@ -131,3 +135,9 @@ RegisterContextLinux_i386::GetUserRegisterCount () const
{
return static_cast<uint32_t> (k_num_user_registers_i386);
}
+
+const std::vector<lldb_private::RegisterInfo> *
+RegisterContextLinux_i386::GetDynamicRegisterInfoP() const
+{
+ return &d_register_infos;
+}
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_i386.h b/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
index cb71d7993e17..6c4768f49ac1 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
@@ -10,7 +10,7 @@
#ifndef liblldb_RegisterContextLinux_i386_H_
#define liblldb_RegisterContextLinux_i386_H_
-#include "RegisterContextPOSIX.h"
+#include "RegisterInfoInterface.h"
class RegisterContextLinux_i386
: public lldb_private::RegisterInfoInterface
@@ -29,6 +29,12 @@ public:
uint32_t
GetUserRegisterCount () const override;
+
+ const std::vector<lldb_private::RegisterInfo> *
+ GetDynamicRegisterInfoP() const override;
+
+private:
+ std::vector<lldb_private::RegisterInfo> d_register_infos;
};
#endif
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp b/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp
index 4d58b85b5665..1b2281004d26 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp
@@ -10,7 +10,7 @@
#include <vector>
#include <stddef.h>
-// For GDB, GCC and DWARF Register numbers
+// For eh_frame and DWARF Register numbers
#include "RegisterContextLinux_mips.h"
// Internal codes for mips registers
@@ -29,8 +29,17 @@ using namespace lldb;
#include "RegisterInfos_mips.h"
#undef DECLARE_REGISTER_INFOS_MIPS_STRUCT
-RegisterContextLinux_mips::RegisterContextLinux_mips(const ArchSpec &target_arch) :
- RegisterInfoInterface(target_arch)
+uint32_t
+GetUserRegisterInfoCount (bool msa_present)
+{
+ if (msa_present)
+ return static_cast<uint32_t> (k_num_user_registers_mips);
+ return static_cast<uint32_t> (k_num_user_registers_mips - k_num_msa_registers_mips);
+}
+
+RegisterContextLinux_mips::RegisterContextLinux_mips(const ArchSpec &target_arch, bool msa_present) :
+ RegisterInfoInterface(target_arch),
+ m_user_register_count (GetUserRegisterInfoCount (msa_present))
{
}
@@ -63,5 +72,5 @@ RegisterContextLinux_mips::GetRegisterCount () const
uint32_t
RegisterContextLinux_mips::GetUserRegisterCount () const
{
- return static_cast<uint32_t> (k_num_user_registers_mips);
+ return static_cast<uint32_t> (m_user_register_count);
}
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_mips.h b/source/Plugins/Process/Utility/RegisterContextLinux_mips.h
index bcc2d002c854..c0bd5ad4f4f9 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_mips.h
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_mips.h
@@ -17,7 +17,7 @@ class RegisterContextLinux_mips
: public lldb_private::RegisterInfoInterface
{
public:
- RegisterContextLinux_mips(const lldb_private::ArchSpec &target_arch);
+ RegisterContextLinux_mips(const lldb_private::ArchSpec &target_arch, bool msa_present = true);
size_t
GetGPRSize() const override;
@@ -30,6 +30,9 @@ public:
uint32_t
GetUserRegisterCount () const override;
+
+private:
+ uint32_t m_user_register_count;
};
#endif
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp b/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp
index 7f512f82be80..f2871e3b7352 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp
@@ -12,7 +12,7 @@
#include <vector>
#include <stddef.h>
-// For GDB, GCC and DWARF Register numbers
+// For eh_frame and DWARF Register numbers
#include "RegisterContextLinux_mips64.h"
// For GP and FP buffers
@@ -75,27 +75,31 @@ GetRegisterInfoCount (const ArchSpec &target_arch)
}
uint32_t
-GetUserRegisterInfoCount (const ArchSpec &target_arch)
+GetUserRegisterInfoCount (const ArchSpec &target_arch, bool msa_present)
{
switch (target_arch.GetMachine())
{
case llvm::Triple::mips:
case llvm::Triple::mipsel:
- return static_cast<uint32_t> (k_num_user_registers_mips);
+ if (msa_present)
+ return static_cast<uint32_t> (k_num_user_registers_mips);
+ return static_cast<uint32_t> (k_num_user_registers_mips - k_num_msa_registers_mips);
case llvm::Triple::mips64el:
case llvm::Triple::mips64:
- return static_cast<uint32_t> (k_num_user_registers_mips64);
+ if (msa_present)
+ return static_cast<uint32_t> (k_num_user_registers_mips64);
+ return static_cast<uint32_t> (k_num_user_registers_mips64 - k_num_msa_registers_mips64);
default:
assert(false && "Unhandled target architecture.");
return 0;
}
}
-RegisterContextLinux_mips64::RegisterContextLinux_mips64(const ArchSpec &target_arch) :
+RegisterContextLinux_mips64::RegisterContextLinux_mips64(const ArchSpec &target_arch, bool msa_present) :
lldb_private::RegisterInfoInterface(target_arch),
m_register_info_p (GetRegisterInfoPtr (target_arch)),
m_register_info_count (GetRegisterInfoCount (target_arch)),
- m_user_register_count (GetUserRegisterInfoCount (target_arch))
+ m_user_register_count (GetUserRegisterInfoCount (target_arch, msa_present))
{
}
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h b/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h
index 86c662c52cea..843328c92e43 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h
@@ -19,7 +19,7 @@ class RegisterContextLinux_mips64
: public lldb_private::RegisterInfoInterface
{
public:
- RegisterContextLinux_mips64(const lldb_private::ArchSpec &target_arch);
+ RegisterContextLinux_mips64(const lldb_private::ArchSpec &target_arch, bool msa_present = true);
size_t
GetGPRSize() const override;
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp b/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
index c0993b47a126..78afe72fcfa9 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
@@ -32,7 +32,7 @@ typedef struct _GPR
uint64_t rdx;
uint64_t rsi;
uint64_t rdi;
- uint64_t orig_ax;
+ uint64_t orig_rax;
uint64_t rip;
uint64_t cs;
uint64_t rflags;
@@ -171,6 +171,9 @@ RegisterContextLinux_x86_64::RegisterContextLinux_x86_64(const ArchSpec &target_
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), (LLVM_EXTENSION offsetof(GPR, orig_rax)), eEncodingUint, \
+ eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL };
+ d_register_infos.push_back(orig_ax);
}
size_t
@@ -179,6 +182,12 @@ RegisterContextLinux_x86_64::GetGPRSize() const
return sizeof(GPR);
}
+const std::vector<lldb_private::RegisterInfo> *
+RegisterContextLinux_x86_64::GetDynamicRegisterInfoP() const
+{
+ return &d_register_infos;
+}
+
const RegisterInfo *
RegisterContextLinux_x86_64::GetRegisterInfo() const
{
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h b/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
index 0cdfae9ac943..ed0b7de9aae8 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
@@ -10,7 +10,7 @@
#ifndef liblldb_RegisterContextLinux_x86_64_H_
#define liblldb_RegisterContextLinux_x86_64_H_
-#include "RegisterContextPOSIX.h"
+#include "RegisterInfoInterface.h"
class RegisterContextLinux_x86_64
: public lldb_private::RegisterInfoInterface
@@ -30,10 +30,15 @@ public:
uint32_t
GetUserRegisterCount () const override;
+ const std::vector<lldb_private::RegisterInfo> *
+ GetDynamicRegisterInfoP() const override;
+
private:
const lldb_private::RegisterInfo *m_register_info_p;
uint32_t m_register_info_count;
uint32_t m_user_register_count;
+ std::vector<lldb_private::RegisterInfo> d_register_infos;
+
};
#endif
diff --git a/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h b/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h
index 505b8d44a27a..0ddadbed01e0 100644
--- a/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h
+++ b/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h
@@ -22,56 +22,49 @@
class RegisterContextMacOSXFrameBackchain : public lldb_private::RegisterContext
{
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
RegisterContextMacOSXFrameBackchain (lldb_private::Thread &thread,
uint32_t concrete_frame_idx,
const UnwindMacOSXFrameBackchain::Cursor &cursor);
- virtual
- ~RegisterContextMacOSXFrameBackchain ();
+ ~RegisterContextMacOSXFrameBackchain() override;
- //------------------------------------------------------------------
- // Subclasses must override these functions
- //------------------------------------------------------------------
- virtual void
- InvalidateAllRegisters ();
+ void
+ InvalidateAllRegisters() override;
- virtual size_t
- GetRegisterCount ();
+ size_t
+ GetRegisterCount() override;
- virtual const lldb_private::RegisterInfo *
- GetRegisterInfoAtIndex (size_t reg);
+ const lldb_private::RegisterInfo *
+ GetRegisterInfoAtIndex(size_t reg) override;
- virtual size_t
- GetRegisterSetCount ();
+ size_t
+ GetRegisterSetCount() override;
- virtual const lldb_private::RegisterSet *
- GetRegisterSet (size_t reg_set);
+ const lldb_private::RegisterSet *
+ GetRegisterSet(size_t reg_set) override;
- virtual bool
- ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
+ bool
+ ReadRegister(const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &value) override;
- virtual bool
- WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
+ bool
+ WriteRegister(const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &value) override;
- virtual bool
- ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
+ bool
+ ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
- virtual bool
- WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
+ bool
+ WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
- virtual uint32_t
- ConvertRegisterKindToRegisterNumber (lldb::RegisterKind kind, uint32_t num);
+ uint32_t
+ ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override;
private:
UnwindMacOSXFrameBackchain::Cursor m_cursor;
bool m_cursor_is_valid;
- //------------------------------------------------------------------
- // For RegisterContextMacOSXFrameBackchain only
- //------------------------------------------------------------------
+
DISALLOW_COPY_AND_ASSIGN (RegisterContextMacOSXFrameBackchain);
};
-#endif // lldb_RegisterContextMacOSXFrameBackchain_h_
+#endif // lldb_RegisterContextMacOSXFrameBackchain_h_
diff --git a/source/Plugins/Process/Utility/RegisterContextMemory.h b/source/Plugins/Process/Utility/RegisterContextMemory.h
index 9d97dfa723be..d61aba9543d4 100644
--- a/source/Plugins/Process/Utility/RegisterContextMemory.h
+++ b/source/Plugins/Process/Utility/RegisterContextMemory.h
@@ -25,39 +25,31 @@ class DynamicRegisterInfo;
class RegisterContextMemory : public lldb_private::RegisterContext
{
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
RegisterContextMemory (lldb_private::Thread &thread,
uint32_t concrete_frame_idx,
DynamicRegisterInfo &reg_info,
lldb::addr_t reg_data_addr);
- virtual
- ~RegisterContextMemory ();
+ ~RegisterContextMemory() override;
- //------------------------------------------------------------------
- // Subclasses must override these functions
- //------------------------------------------------------------------
- virtual void
- InvalidateAllRegisters ();
+ void
+ InvalidateAllRegisters() override;
- virtual size_t
- GetRegisterCount ();
+ size_t
+ GetRegisterCount() override;
- virtual const lldb_private::RegisterInfo *
- GetRegisterInfoAtIndex (size_t reg);
+ const lldb_private::RegisterInfo *
+ GetRegisterInfoAtIndex(size_t reg) override;
- virtual size_t
- GetRegisterSetCount ();
+ size_t
+ GetRegisterSetCount() override;
- virtual const lldb_private::RegisterSet *
- GetRegisterSet (size_t reg_set);
+ const lldb_private::RegisterSet *
+ GetRegisterSet(size_t reg_set) override;
- virtual uint32_t
- ConvertRegisterKindToRegisterNumber (lldb::RegisterKind kind, uint32_t num);
+ 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
@@ -66,24 +58,24 @@ public:
// class and modify the read/write functions as needed.
//------------------------------------------------------------------
- virtual bool
- ReadRegister (const lldb_private::RegisterInfo *reg_info,
- lldb_private::RegisterValue &reg_value);
+ bool
+ ReadRegister(const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &reg_value) override;
- virtual bool
- WriteRegister (const lldb_private::RegisterInfo *reg_info,
- const lldb_private::RegisterValue &reg_value);
+ bool
+ WriteRegister(const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &reg_value) override;
- virtual bool
- ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
+ bool
+ ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
- virtual bool
- WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
+ bool
+ WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
void
SetAllRegisterData (const lldb::DataBufferSP &data_sp);
+
protected:
-
void
SetAllRegisterValid (bool b);
@@ -93,10 +85,7 @@ protected:
lldb::addr_t m_reg_data_addr; // If this is valid, then we have a register context that is stored in memmory
private:
- //------------------------------------------------------------------
- // For RegisterContextMemory only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (RegisterContextMemory);
};
-#endif // lldb_RegisterContextMemory_h_
+#endif // lldb_RegisterContextMemory_h_
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp
index d306f86256bc..029a0e7352ec 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp
@@ -88,6 +88,54 @@ static const uint32_t g_fpu_regnums_arm[] =
fpu_s30_arm,
fpu_s31_arm,
fpu_fpscr_arm,
+ fpu_d0_arm,
+ fpu_d1_arm,
+ fpu_d2_arm,
+ fpu_d3_arm,
+ fpu_d4_arm,
+ fpu_d5_arm,
+ fpu_d6_arm,
+ fpu_d7_arm,
+ fpu_d8_arm,
+ fpu_d9_arm,
+ fpu_d10_arm,
+ fpu_d11_arm,
+ fpu_d12_arm,
+ fpu_d13_arm,
+ fpu_d14_arm,
+ fpu_d15_arm,
+ fpu_d16_arm,
+ fpu_d17_arm,
+ fpu_d18_arm,
+ fpu_d19_arm,
+ fpu_d20_arm,
+ fpu_d21_arm,
+ fpu_d22_arm,
+ fpu_d23_arm,
+ fpu_d24_arm,
+ fpu_d25_arm,
+ fpu_d26_arm,
+ fpu_d27_arm,
+ fpu_d28_arm,
+ fpu_d29_arm,
+ fpu_d30_arm,
+ fpu_d31_arm,
+ fpu_q0_arm,
+ fpu_q1_arm,
+ fpu_q2_arm,
+ fpu_q3_arm,
+ fpu_q4_arm,
+ fpu_q5_arm,
+ fpu_q6_arm,
+ fpu_q7_arm,
+ fpu_q8_arm,
+ fpu_q9_arm,
+ fpu_q10_arm,
+ fpu_q11_arm,
+ fpu_q12_arm,
+ fpu_q13_arm,
+ fpu_q14_arm,
+ fpu_q15_arm,
LLDB_INVALID_REGNUM // register sets need to end with this flag
};
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h
index a3a2926262f7..fbbcb9402911 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h
@@ -1,4 +1,4 @@
-//===-- RegisterContextPOSIX_arm.h ----------------------------*- C++ -*-===//
+//===-- RegisterContextPOSIX_arm.h ------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,12 +7,17 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextPOSIX_arm_H_
-#define liblldb_RegisterContextPOSIX_arm_H_
+#ifndef liblldb_RegisterContextPOSIX_arm_h_
+#define liblldb_RegisterContextPOSIX_arm_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Core/Log.h"
+#include "lldb/Target/RegisterContext.h"
+#include "RegisterInfoInterface.h"
#include "lldb-arm-register-enums.h"
-#include "RegisterContextPOSIX.h"
class ProcessMonitor;
@@ -24,16 +29,16 @@ public:
uint32_t concrete_frame_idx,
lldb_private::RegisterInfoInterface *register_info);
- ~RegisterContextPOSIX_arm();
+ ~RegisterContextPOSIX_arm() override;
void
Invalidate();
void
- InvalidateAllRegisters();
+ InvalidateAllRegisters() override;
size_t
- GetRegisterCount();
+ GetRegisterCount() override;
virtual size_t
GetGPRSize();
@@ -45,19 +50,19 @@ public:
GetRegisterOffset(unsigned reg);
const lldb_private::RegisterInfo *
- GetRegisterInfoAtIndex(size_t reg);
+ GetRegisterInfoAtIndex(size_t reg) override;
size_t
- GetRegisterSetCount();
+ GetRegisterSetCount() override;
const lldb_private::RegisterSet *
- GetRegisterSet(size_t set);
+ GetRegisterSet(size_t set) override;
const char *
GetRegisterName(unsigned reg);
uint32_t
- ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num);
+ ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override;
protected:
struct RegInfo
@@ -117,5 +122,4 @@ protected:
virtual bool WriteFPR() = 0;
};
-#endif // #ifndef liblldb_RegisterContextPOSIX_arm_H_
-
+#endif // liblldb_RegisterContextPOSIX_arm_h_
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
index 29e7a7d21e02..225d4f25168e 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
@@ -7,12 +7,17 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextPOSIX_arm64_H_
-#define liblldb_RegisterContextPOSIX_arm64_H_
+#ifndef liblldb_RegisterContextPOSIX_arm64_h_
+#define liblldb_RegisterContextPOSIX_arm64_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Core/Log.h"
+#include "lldb/Target/RegisterContext.h"
+#include "RegisterInfoInterface.h"
#include "lldb-arm64-register-enums.h"
-#include "RegisterContextPOSIX.h"
class ProcessMonitor;
@@ -24,16 +29,16 @@ public:
uint32_t concrete_frame_idx,
lldb_private::RegisterInfoInterface *register_info);
- ~RegisterContextPOSIX_arm64();
+ ~RegisterContextPOSIX_arm64() override;
void
Invalidate();
void
- InvalidateAllRegisters();
+ InvalidateAllRegisters() override;
size_t
- GetRegisterCount();
+ GetRegisterCount() override;
virtual size_t
GetGPRSize();
@@ -45,19 +50,19 @@ public:
GetRegisterOffset(unsigned reg);
const lldb_private::RegisterInfo *
- GetRegisterInfoAtIndex(size_t reg);
+ GetRegisterInfoAtIndex(size_t reg) override;
size_t
- GetRegisterSetCount();
+ GetRegisterSetCount() override;
const lldb_private::RegisterSet *
- GetRegisterSet(size_t set);
+ GetRegisterSet(size_t set) override;
const char *
GetRegisterName(unsigned reg);
uint32_t
- ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num);
+ ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override;
protected:
struct RegInfo
@@ -116,4 +121,4 @@ protected:
virtual bool WriteFPR() = 0;
};
-#endif // #ifndef liblldb_RegisterContextPOSIX_arm64_H_
+#endif // liblldb_RegisterContextPOSIX_arm64_h_
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h
index 612a03466983..07552d8d681d 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h
@@ -7,11 +7,16 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextPOSIX_mips64_H_
-#define liblldb_RegisterContextPOSIX_mips64_H_
+#ifndef liblldb_RegisterContextPOSIX_mips64_h_
+#define liblldb_RegisterContextPOSIX_mips64_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Core/Log.h"
-#include "RegisterContextPOSIX.h"
+#include "lldb/Target/RegisterContext.h"
+#include "RegisterInfoInterface.h"
#include "RegisterContext_mips.h"
#include "lldb-mips-freebsd-register-enums.h"
@@ -27,16 +32,16 @@ public:
uint32_t concrete_frame_idx,
lldb_private::RegisterInfoInterface *register_info);
- ~RegisterContextPOSIX_mips64();
+ ~RegisterContextPOSIX_mips64() override;
void
Invalidate();
void
- InvalidateAllRegisters();
+ InvalidateAllRegisters() override;
size_t
- GetRegisterCount();
+ GetRegisterCount() override;
virtual size_t
GetGPRSize();
@@ -48,19 +53,19 @@ public:
GetRegisterOffset(unsigned reg);
const lldb_private::RegisterInfo *
- GetRegisterInfoAtIndex(size_t reg);
+ GetRegisterInfoAtIndex(size_t reg) override;
size_t
- GetRegisterSetCount();
+ GetRegisterSetCount() override;
const lldb_private::RegisterSet *
- GetRegisterSet(size_t set);
+ GetRegisterSet(size_t set) override;
const char *
GetRegisterName(unsigned reg);
uint32_t
- ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num);
+ ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override;
protected:
uint64_t m_gpr_mips64[k_num_gpr_registers_mips64]; // general purpose registers.
@@ -87,4 +92,4 @@ protected:
virtual bool WriteFPR() = 0;
};
-#endif // #ifndef liblldb_RegisterContextPOSIX_mips64_H_
+#endif // liblldb_RegisterContextPOSIX_mips64_h_
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h
index c7a2451d7811..4168e46ebd9a 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h
@@ -1,4 +1,4 @@
-//===-- RegisterContextPOSIX_powerpc.h ---------------------------*- C++ -*-===//
+//===-- RegisterContextPOSIX_powerpc.h --------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,11 +7,16 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextPOSIX_powerpc_H_
-#define liblldb_RegisterContextPOSIX_powerpc_H_
+#ifndef liblldb_RegisterContextPOSIX_powerpc_h_
+#define liblldb_RegisterContextPOSIX_powerpc_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Core/Log.h"
-#include "RegisterContextPOSIX.h"
+#include "lldb/Target/RegisterContext.h"
+#include "RegisterInfoInterface.h"
#include "RegisterContext_powerpc.h"
class ProcessMonitor;
@@ -148,16 +153,16 @@ public:
uint32_t concrete_frame_idx,
lldb_private::RegisterInfoInterface *register_info);
- ~RegisterContextPOSIX_powerpc();
+ ~RegisterContextPOSIX_powerpc() override;
void
Invalidate();
void
- InvalidateAllRegisters();
+ InvalidateAllRegisters() override;
size_t
- GetRegisterCount();
+ GetRegisterCount() override;
virtual size_t
GetGPRSize();
@@ -169,19 +174,19 @@ public:
GetRegisterOffset(unsigned reg);
const lldb_private::RegisterInfo *
- GetRegisterInfoAtIndex(size_t reg);
+ GetRegisterInfoAtIndex(size_t reg) override;
size_t
- GetRegisterSetCount();
+ GetRegisterSetCount() override;
const lldb_private::RegisterSet *
- GetRegisterSet(size_t set);
+ GetRegisterSet(size_t set) override;
const char *
GetRegisterName(unsigned reg);
uint32_t
- ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num);
+ ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override;
protected:
uint64_t m_gpr_powerpc[k_num_gpr_registers_powerpc]; // general purpose registers.
@@ -215,4 +220,4 @@ protected:
virtual bool WriteVMX() = 0;
};
-#endif // #ifndef liblldb_RegisterContextPOSIX_powerpc_H_
+#endif // liblldb_RegisterContextPOSIX_powerpc_h_
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h
index 0eec1d909c1a..b4708255a566 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h
@@ -7,13 +7,18 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextPOSIX_x86_H_
-#define liblldb_RegisterContextPOSIX_x86_H_
+#ifndef liblldb_RegisterContextPOSIX_x86_h_
+#define liblldb_RegisterContextPOSIX_x86_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Core/Log.h"
-#include "lldb-x86-register-enums.h"
-#include "RegisterContextPOSIX.h"
+#include "lldb/Target/RegisterContext.h"
+#include "RegisterInfoInterface.h"
#include "RegisterContext_x86.h"
+#include "lldb-x86-register-enums.h"
class ProcessMonitor;
@@ -25,16 +30,16 @@ public:
uint32_t concrete_frame_idx,
lldb_private::RegisterInfoInterface *register_info);
- ~RegisterContextPOSIX_x86();
+ ~RegisterContextPOSIX_x86() override;
void
Invalidate();
void
- InvalidateAllRegisters();
+ InvalidateAllRegisters() override;
size_t
- GetRegisterCount();
+ GetRegisterCount() override;
virtual size_t
GetGPRSize();
@@ -46,19 +51,19 @@ public:
GetRegisterOffset(unsigned reg);
const lldb_private::RegisterInfo *
- GetRegisterInfoAtIndex(size_t reg);
+ GetRegisterInfoAtIndex(size_t reg) override;
size_t
- GetRegisterSetCount();
+ GetRegisterSetCount() override;
const lldb_private::RegisterSet *
- GetRegisterSet(size_t set);
+ GetRegisterSet(size_t set) override;
const char *
GetRegisterName(unsigned reg);
uint32_t
- ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num);
+ ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override;
//---------------------------------------------------------------------------
// Note: prefer kernel definitions over user-land
@@ -186,4 +191,4 @@ protected:
virtual bool WriteFPR() = 0;
};
-#endif // #ifndef liblldb_RegisterContextPOSIX_x86_H_
+#endif // liblldb_RegisterContextPOSIX_x86_h_
diff --git a/source/Plugins/Process/Utility/RegisterContextThreadMemory.h b/source/Plugins/Process/Utility/RegisterContextThreadMemory.h
index 161ef040e651..b4680de79514 100644
--- a/source/Plugins/Process/Utility/RegisterContextThreadMemory.h
+++ b/source/Plugins/Process/Utility/RegisterContextThreadMemory.h
@@ -10,8 +10,12 @@
#ifndef lldb_RegisterContextThreadMemory_h_
#define lldb_RegisterContextThreadMemory_h_
+// C Includes
+// C++ Includes
#include <vector>
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Symbol/SymbolContext.h"
@@ -24,30 +28,28 @@ public:
RegisterContextThreadMemory (Thread &thread,
lldb::addr_t register_data_addr);
- virtual ~RegisterContextThreadMemory();
- //------------------------------------------------------------------
- // Subclasses must override these functions
- //------------------------------------------------------------------
- virtual void
- InvalidateAllRegisters ();
+ ~RegisterContextThreadMemory() override;
+
+ void
+ InvalidateAllRegisters() override;
- virtual size_t
- GetRegisterCount ();
+ size_t
+ GetRegisterCount() override;
- virtual const RegisterInfo *
- GetRegisterInfoAtIndex (size_t reg);
+ const RegisterInfo *
+ GetRegisterInfoAtIndex(size_t reg) override;
- virtual size_t
- GetRegisterSetCount ();
+ size_t
+ GetRegisterSetCount() override;
- virtual const RegisterSet *
- GetRegisterSet (size_t reg_set);
+ const RegisterSet *
+ GetRegisterSet(size_t reg_set) override;
- virtual bool
- ReadRegister (const RegisterInfo *reg_info, RegisterValue &reg_value);
+ bool
+ ReadRegister(const RegisterInfo *reg_info, RegisterValue &reg_value) override;
- virtual bool
- WriteRegister (const RegisterInfo *reg_info, const RegisterValue &reg_value);
+ bool
+ WriteRegister(const RegisterInfo *reg_info, const RegisterValue &reg_value) override;
// These two functions are used to implement "push" and "pop" of register states. They are used primarily
// for expression evaluation, where we need to push a new state (storing the old one in data_sp) and then
@@ -56,48 +58,50 @@ public:
// may mean e.g. interrupting a thread that is sitting in a kernel trap. That is a somewhat disruptive operation,
// so these API's should only be used when this behavior is needed.
- virtual bool
- ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
+ bool
+ ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
- virtual bool
- WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
+ bool
+ WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
bool
CopyFromRegisterContext (lldb::RegisterContextSP context);
- virtual uint32_t
- ConvertRegisterKindToRegisterNumber (lldb::RegisterKind kind, uint32_t num);
-
- //------------------------------------------------------------------
- // Subclasses can override these functions if desired
- //------------------------------------------------------------------
- virtual uint32_t
- NumSupportedHardwareBreakpoints ();
-
- virtual uint32_t
- SetHardwareBreakpoint (lldb::addr_t addr, size_t size);
+ uint32_t
+ ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override;
- virtual bool
- ClearHardwareBreakpoint (uint32_t hw_idx);
+ uint32_t
+ NumSupportedHardwareBreakpoints() override;
- virtual uint32_t
- NumSupportedHardwareWatchpoints ();
+ uint32_t
+ SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
- virtual uint32_t
- SetHardwareWatchpoint (lldb::addr_t addr, size_t size, bool read, bool write);
-
- virtual bool
- ClearHardwareWatchpoint (uint32_t hw_index);
+ bool
+ ClearHardwareBreakpoint(uint32_t hw_idx) override;
- virtual bool
- HardwareSingleStep (bool enable);
+ uint32_t
+ NumSupportedHardwareWatchpoints() override;
- virtual Error
- ReadRegisterValueFromMemory (const lldb_private::RegisterInfo *reg_info, lldb::addr_t src_addr, uint32_t src_len, RegisterValue &reg_value);
+ uint32_t
+ SetHardwareWatchpoint(lldb::addr_t addr, size_t size, bool read, bool write) override;
- virtual Error
- WriteRegisterValueToMemory (const lldb_private::RegisterInfo *reg_info, lldb::addr_t dst_addr, uint32_t dst_len, const RegisterValue &reg_value);
+ bool
+ ClearHardwareWatchpoint(uint32_t hw_index) override;
+ bool
+ HardwareSingleStep(bool enable) override;
+
+ Error
+ ReadRegisterValueFromMemory(const lldb_private::RegisterInfo *reg_info,
+ lldb::addr_t src_addr,
+ uint32_t src_len,
+ RegisterValue &reg_value) override;
+
+ Error
+ WriteRegisterValueToMemory(const lldb_private::RegisterInfo *reg_info,
+ lldb::addr_t dst_addr, uint32_t dst_len,
+ const RegisterValue &reg_value) override;
+
protected:
void
UpdateRegisterContext ();
@@ -106,9 +110,11 @@ protected:
lldb::RegisterContextSP m_reg_ctx_sp;
lldb::addr_t m_register_data_addr;
uint32_t m_stop_id;
+
private:
DISALLOW_COPY_AND_ASSIGN (RegisterContextThreadMemory);
};
+
} // namespace lldb_private
-#endif // lldb_RegisterContextThreadMemory_h_
+#endif // lldb_RegisterContextThreadMemory_h_
diff --git a/source/Plugins/Process/Utility/RegisterContext_mips.h b/source/Plugins/Process/Utility/RegisterContext_mips.h
index de2b4d6dccee..3603227d5e73 100644
--- a/source/Plugins/Process/Utility/RegisterContext_mips.h
+++ b/source/Plugins/Process/Utility/RegisterContext_mips.h
@@ -15,455 +15,228 @@
enum
{
// GP Registers
- gcc_dwarf_zero_mips = 0,
- gcc_dwarf_r1_mips,
- gcc_dwarf_r2_mips,
- gcc_dwarf_r3_mips,
- gcc_dwarf_r4_mips,
- gcc_dwarf_r5_mips,
- gcc_dwarf_r6_mips,
- gcc_dwarf_r7_mips,
- gcc_dwarf_r8_mips,
- gcc_dwarf_r9_mips,
- gcc_dwarf_r10_mips,
- gcc_dwarf_r11_mips,
- gcc_dwarf_r12_mips,
- gcc_dwarf_r13_mips,
- gcc_dwarf_r14_mips,
- gcc_dwarf_r15_mips,
- gcc_dwarf_r16_mips,
- gcc_dwarf_r17_mips,
- gcc_dwarf_r18_mips,
- gcc_dwarf_r19_mips,
- gcc_dwarf_r20_mips,
- gcc_dwarf_r21_mips,
- gcc_dwarf_r22_mips,
- gcc_dwarf_r23_mips,
- gcc_dwarf_r24_mips,
- gcc_dwarf_r25_mips,
- gcc_dwarf_r26_mips,
- gcc_dwarf_r27_mips,
- gcc_dwarf_gp_mips,
- gcc_dwarf_sp_mips,
- gcc_dwarf_r30_mips,
- gcc_dwarf_ra_mips,
- gcc_dwarf_sr_mips,
- gcc_dwarf_lo_mips,
- gcc_dwarf_hi_mips,
- gcc_dwarf_bad_mips,
- gcc_dwarf_cause_mips,
- gcc_dwarf_pc_mips,
- gcc_dwarf_f0_mips,
- gcc_dwarf_f1_mips,
- gcc_dwarf_f2_mips,
- gcc_dwarf_f3_mips,
- gcc_dwarf_f4_mips,
- gcc_dwarf_f5_mips,
- gcc_dwarf_f6_mips,
- gcc_dwarf_f7_mips,
- gcc_dwarf_f8_mips,
- gcc_dwarf_f9_mips,
- gcc_dwarf_f10_mips,
- gcc_dwarf_f11_mips,
- gcc_dwarf_f12_mips,
- gcc_dwarf_f13_mips,
- gcc_dwarf_f14_mips,
- gcc_dwarf_f15_mips,
- gcc_dwarf_f16_mips,
- gcc_dwarf_f17_mips,
- gcc_dwarf_f18_mips,
- gcc_dwarf_f19_mips,
- gcc_dwarf_f20_mips,
- gcc_dwarf_f21_mips,
- gcc_dwarf_f22_mips,
- gcc_dwarf_f23_mips,
- gcc_dwarf_f24_mips,
- gcc_dwarf_f25_mips,
- gcc_dwarf_f26_mips,
- gcc_dwarf_f27_mips,
- gcc_dwarf_f28_mips,
- gcc_dwarf_f29_mips,
- gcc_dwarf_f30_mips,
- gcc_dwarf_f31_mips,
- gcc_dwarf_fcsr_mips,
- gcc_dwarf_fir_mips,
- gcc_dwarf_w0_mips,
- gcc_dwarf_w1_mips,
- gcc_dwarf_w2_mips,
- gcc_dwarf_w3_mips,
- gcc_dwarf_w4_mips,
- gcc_dwarf_w5_mips,
- gcc_dwarf_w6_mips,
- gcc_dwarf_w7_mips,
- gcc_dwarf_w8_mips,
- gcc_dwarf_w9_mips,
- gcc_dwarf_w10_mips,
- gcc_dwarf_w11_mips,
- gcc_dwarf_w12_mips,
- gcc_dwarf_w13_mips,
- gcc_dwarf_w14_mips,
- gcc_dwarf_w15_mips,
- gcc_dwarf_w16_mips,
- gcc_dwarf_w17_mips,
- gcc_dwarf_w18_mips,
- gcc_dwarf_w19_mips,
- gcc_dwarf_w20_mips,
- gcc_dwarf_w21_mips,
- gcc_dwarf_w22_mips,
- gcc_dwarf_w23_mips,
- gcc_dwarf_w24_mips,
- gcc_dwarf_w25_mips,
- gcc_dwarf_w26_mips,
- gcc_dwarf_w27_mips,
- gcc_dwarf_w28_mips,
- gcc_dwarf_w29_mips,
- gcc_dwarf_w30_mips,
- gcc_dwarf_w31_mips,
- gcc_dwarf_mcsr_mips,
- gcc_dwarf_mir_mips,
- gcc_dwarf_config5_mips,
- gcc_dwarf_ic_mips,
- gcc_dwarf_dummy_mips
+ dwarf_zero_mips = 0,
+ dwarf_r1_mips,
+ dwarf_r2_mips,
+ dwarf_r3_mips,
+ dwarf_r4_mips,
+ dwarf_r5_mips,
+ dwarf_r6_mips,
+ dwarf_r7_mips,
+ dwarf_r8_mips,
+ dwarf_r9_mips,
+ dwarf_r10_mips,
+ dwarf_r11_mips,
+ dwarf_r12_mips,
+ dwarf_r13_mips,
+ dwarf_r14_mips,
+ dwarf_r15_mips,
+ dwarf_r16_mips,
+ dwarf_r17_mips,
+ dwarf_r18_mips,
+ dwarf_r19_mips,
+ dwarf_r20_mips,
+ dwarf_r21_mips,
+ dwarf_r22_mips,
+ dwarf_r23_mips,
+ dwarf_r24_mips,
+ dwarf_r25_mips,
+ dwarf_r26_mips,
+ dwarf_r27_mips,
+ dwarf_gp_mips,
+ dwarf_sp_mips,
+ dwarf_r30_mips,
+ dwarf_ra_mips,
+ dwarf_sr_mips,
+ dwarf_lo_mips,
+ dwarf_hi_mips,
+ dwarf_bad_mips,
+ dwarf_cause_mips,
+ dwarf_pc_mips,
+ dwarf_f0_mips,
+ dwarf_f1_mips,
+ dwarf_f2_mips,
+ dwarf_f3_mips,
+ dwarf_f4_mips,
+ dwarf_f5_mips,
+ dwarf_f6_mips,
+ dwarf_f7_mips,
+ dwarf_f8_mips,
+ dwarf_f9_mips,
+ dwarf_f10_mips,
+ dwarf_f11_mips,
+ dwarf_f12_mips,
+ dwarf_f13_mips,
+ dwarf_f14_mips,
+ dwarf_f15_mips,
+ dwarf_f16_mips,
+ dwarf_f17_mips,
+ dwarf_f18_mips,
+ dwarf_f19_mips,
+ dwarf_f20_mips,
+ dwarf_f21_mips,
+ dwarf_f22_mips,
+ dwarf_f23_mips,
+ dwarf_f24_mips,
+ dwarf_f25_mips,
+ dwarf_f26_mips,
+ dwarf_f27_mips,
+ dwarf_f28_mips,
+ dwarf_f29_mips,
+ dwarf_f30_mips,
+ dwarf_f31_mips,
+ dwarf_fcsr_mips,
+ dwarf_fir_mips,
+ dwarf_w0_mips,
+ dwarf_w1_mips,
+ dwarf_w2_mips,
+ dwarf_w3_mips,
+ dwarf_w4_mips,
+ dwarf_w5_mips,
+ dwarf_w6_mips,
+ dwarf_w7_mips,
+ dwarf_w8_mips,
+ dwarf_w9_mips,
+ dwarf_w10_mips,
+ dwarf_w11_mips,
+ dwarf_w12_mips,
+ dwarf_w13_mips,
+ dwarf_w14_mips,
+ dwarf_w15_mips,
+ dwarf_w16_mips,
+ dwarf_w17_mips,
+ dwarf_w18_mips,
+ dwarf_w19_mips,
+ dwarf_w20_mips,
+ dwarf_w21_mips,
+ dwarf_w22_mips,
+ dwarf_w23_mips,
+ dwarf_w24_mips,
+ dwarf_w25_mips,
+ dwarf_w26_mips,
+ dwarf_w27_mips,
+ dwarf_w28_mips,
+ dwarf_w29_mips,
+ dwarf_w30_mips,
+ dwarf_w31_mips,
+ dwarf_mcsr_mips,
+ dwarf_mir_mips,
+ dwarf_config5_mips,
+ dwarf_ic_mips,
+ dwarf_dummy_mips
};
enum
{
- gcc_dwarf_zero_mips64 = 0,
- gcc_dwarf_r1_mips64,
- gcc_dwarf_r2_mips64,
- gcc_dwarf_r3_mips64,
- gcc_dwarf_r4_mips64,
- gcc_dwarf_r5_mips64,
- gcc_dwarf_r6_mips64,
- gcc_dwarf_r7_mips64,
- gcc_dwarf_r8_mips64,
- gcc_dwarf_r9_mips64,
- gcc_dwarf_r10_mips64,
- gcc_dwarf_r11_mips64,
- gcc_dwarf_r12_mips64,
- gcc_dwarf_r13_mips64,
- gcc_dwarf_r14_mips64,
- gcc_dwarf_r15_mips64,
- gcc_dwarf_r16_mips64,
- gcc_dwarf_r17_mips64,
- gcc_dwarf_r18_mips64,
- gcc_dwarf_r19_mips64,
- gcc_dwarf_r20_mips64,
- gcc_dwarf_r21_mips64,
- gcc_dwarf_r22_mips64,
- gcc_dwarf_r23_mips64,
- gcc_dwarf_r24_mips64,
- gcc_dwarf_r25_mips64,
- gcc_dwarf_r26_mips64,
- gcc_dwarf_r27_mips64,
- gcc_dwarf_gp_mips64,
- gcc_dwarf_sp_mips64,
- gcc_dwarf_r30_mips64,
- gcc_dwarf_ra_mips64,
- gcc_dwarf_sr_mips64,
- gcc_dwarf_lo_mips64,
- gcc_dwarf_hi_mips64,
- gcc_dwarf_bad_mips64,
- gcc_dwarf_cause_mips64,
- gcc_dwarf_pc_mips64,
- gcc_dwarf_f0_mips64,
- gcc_dwarf_f1_mips64,
- gcc_dwarf_f2_mips64,
- gcc_dwarf_f3_mips64,
- gcc_dwarf_f4_mips64,
- gcc_dwarf_f5_mips64,
- gcc_dwarf_f6_mips64,
- gcc_dwarf_f7_mips64,
- gcc_dwarf_f8_mips64,
- gcc_dwarf_f9_mips64,
- gcc_dwarf_f10_mips64,
- gcc_dwarf_f11_mips64,
- gcc_dwarf_f12_mips64,
- gcc_dwarf_f13_mips64,
- gcc_dwarf_f14_mips64,
- gcc_dwarf_f15_mips64,
- gcc_dwarf_f16_mips64,
- gcc_dwarf_f17_mips64,
- gcc_dwarf_f18_mips64,
- gcc_dwarf_f19_mips64,
- gcc_dwarf_f20_mips64,
- gcc_dwarf_f21_mips64,
- gcc_dwarf_f22_mips64,
- gcc_dwarf_f23_mips64,
- gcc_dwarf_f24_mips64,
- gcc_dwarf_f25_mips64,
- gcc_dwarf_f26_mips64,
- gcc_dwarf_f27_mips64,
- gcc_dwarf_f28_mips64,
- gcc_dwarf_f29_mips64,
- gcc_dwarf_f30_mips64,
- gcc_dwarf_f31_mips64,
- gcc_dwarf_fcsr_mips64,
- gcc_dwarf_fir_mips64,
- gcc_dwarf_ic_mips64,
- gcc_dwarf_dummy_mips64,
- gcc_dwarf_w0_mips64,
- gcc_dwarf_w1_mips64,
- gcc_dwarf_w2_mips64,
- gcc_dwarf_w3_mips64,
- gcc_dwarf_w4_mips64,
- gcc_dwarf_w5_mips64,
- gcc_dwarf_w6_mips64,
- gcc_dwarf_w7_mips64,
- gcc_dwarf_w8_mips64,
- gcc_dwarf_w9_mips64,
- gcc_dwarf_w10_mips64,
- gcc_dwarf_w11_mips64,
- gcc_dwarf_w12_mips64,
- gcc_dwarf_w13_mips64,
- gcc_dwarf_w14_mips64,
- gcc_dwarf_w15_mips64,
- gcc_dwarf_w16_mips64,
- gcc_dwarf_w17_mips64,
- gcc_dwarf_w18_mips64,
- gcc_dwarf_w19_mips64,
- gcc_dwarf_w20_mips64,
- gcc_dwarf_w21_mips64,
- gcc_dwarf_w22_mips64,
- gcc_dwarf_w23_mips64,
- gcc_dwarf_w24_mips64,
- gcc_dwarf_w25_mips64,
- gcc_dwarf_w26_mips64,
- gcc_dwarf_w27_mips64,
- gcc_dwarf_w28_mips64,
- gcc_dwarf_w29_mips64,
- gcc_dwarf_w30_mips64,
- gcc_dwarf_w31_mips64,
- gcc_dwarf_mcsr_mips64,
- gcc_dwarf_mir_mips64,
- gcc_dwarf_config5_mips64,
-};
-
-// GDB Register numbers (eRegisterKindGDB)
-enum
-{
- gdb_zero_mips = 0,
- gdb_r1_mips,
- gdb_r2_mips,
- gdb_r3_mips,
- gdb_r4_mips,
- gdb_r5_mips,
- gdb_r6_mips,
- gdb_r7_mips,
- gdb_r8_mips,
- gdb_r9_mips,
- gdb_r10_mips,
- gdb_r11_mips,
- gdb_r12_mips,
- gdb_r13_mips,
- gdb_r14_mips,
- gdb_r15_mips,
- gdb_r16_mips,
- gdb_r17_mips,
- gdb_r18_mips,
- gdb_r19_mips,
- gdb_r20_mips,
- gdb_r21_mips,
- gdb_r22_mips,
- gdb_r23_mips,
- gdb_r24_mips,
- gdb_r25_mips,
- gdb_r26_mips,
- gdb_r27_mips,
- gdb_gp_mips,
- gdb_sp_mips,
- gdb_r30_mips,
- gdb_ra_mips,
- gdb_sr_mips,
- gdb_lo_mips,
- gdb_hi_mips,
- gdb_bad_mips,
- gdb_cause_mips,
- gdb_pc_mips,
- gdb_f0_mips,
- gdb_f1_mips,
- gdb_f2_mips,
- gdb_f3_mips,
- gdb_f4_mips,
- gdb_f5_mips,
- gdb_f6_mips,
- gdb_f7_mips,
- gdb_f8_mips,
- gdb_f9_mips,
- gdb_f10_mips,
- gdb_f11_mips,
- gdb_f12_mips,
- gdb_f13_mips,
- gdb_f14_mips,
- gdb_f15_mips,
- gdb_f16_mips,
- gdb_f17_mips,
- gdb_f18_mips,
- gdb_f19_mips,
- gdb_f20_mips,
- gdb_f21_mips,
- gdb_f22_mips,
- gdb_f23_mips,
- gdb_f24_mips,
- gdb_f25_mips,
- gdb_f26_mips,
- gdb_f27_mips,
- gdb_f28_mips,
- gdb_f29_mips,
- gdb_f30_mips,
- gdb_f31_mips,
- gdb_fcsr_mips,
- gdb_fir_mips,
- gdb_w0_mips,
- gdb_w1_mips,
- gdb_w2_mips,
- gdb_w3_mips,
- gdb_w4_mips,
- gdb_w5_mips,
- gdb_w6_mips,
- gdb_w7_mips,
- gdb_w8_mips,
- gdb_w9_mips,
- gdb_w10_mips,
- gdb_w11_mips,
- gdb_w12_mips,
- gdb_w13_mips,
- gdb_w14_mips,
- gdb_w15_mips,
- gdb_w16_mips,
- gdb_w17_mips,
- gdb_w18_mips,
- gdb_w19_mips,
- gdb_w20_mips,
- gdb_w21_mips,
- gdb_w22_mips,
- gdb_w23_mips,
- gdb_w24_mips,
- gdb_w25_mips,
- gdb_w26_mips,
- gdb_w27_mips,
- gdb_w28_mips,
- gdb_w29_mips,
- gdb_w30_mips,
- gdb_w31_mips,
- gdb_mcsr_mips,
- gdb_mir_mips,
- gdb_config5_mips,
- gdb_ic_mips,
- gdb_dummy_mips
-};
-
-enum
-{
- gdb_zero_mips64 = 0,
- gdb_r1_mips64,
- gdb_r2_mips64,
- gdb_r3_mips64,
- gdb_r4_mips64,
- gdb_r5_mips64,
- gdb_r6_mips64,
- gdb_r7_mips64,
- gdb_r8_mips64,
- gdb_r9_mips64,
- gdb_r10_mips64,
- gdb_r11_mips64,
- gdb_r12_mips64,
- gdb_r13_mips64,
- gdb_r14_mips64,
- gdb_r15_mips64,
- gdb_r16_mips64,
- gdb_r17_mips64,
- gdb_r18_mips64,
- gdb_r19_mips64,
- gdb_r20_mips64,
- gdb_r21_mips64,
- gdb_r22_mips64,
- gdb_r23_mips64,
- gdb_r24_mips64,
- gdb_r25_mips64,
- gdb_r26_mips64,
- gdb_r27_mips64,
- gdb_gp_mips64,
- gdb_sp_mips64,
- gdb_r30_mips64,
- gdb_ra_mips64,
- gdb_sr_mips64,
- gdb_lo_mips64,
- gdb_hi_mips64,
- gdb_bad_mips64,
- gdb_cause_mips64,
- gdb_pc_mips64,
- gdb_f0_mips64,
- gdb_f1_mips64,
- gdb_f2_mips64,
- gdb_f3_mips64,
- gdb_f4_mips64,
- gdb_f5_mips64,
- gdb_f6_mips64,
- gdb_f7_mips64,
- gdb_f8_mips64,
- gdb_f9_mips64,
- gdb_f10_mips64,
- gdb_f11_mips64,
- gdb_f12_mips64,
- gdb_f13_mips64,
- gdb_f14_mips64,
- gdb_f15_mips64,
- gdb_f16_mips64,
- gdb_f17_mips64,
- gdb_f18_mips64,
- gdb_f19_mips64,
- gdb_f20_mips64,
- gdb_f21_mips64,
- gdb_f22_mips64,
- gdb_f23_mips64,
- gdb_f24_mips64,
- gdb_f25_mips64,
- gdb_f26_mips64,
- gdb_f27_mips64,
- gdb_f28_mips64,
- gdb_f29_mips64,
- gdb_f30_mips64,
- gdb_f31_mips64,
- gdb_fcsr_mips64,
- gdb_fir_mips64,
- gdb_ic_mips64,
- gdb_dummy_mips64,
- gdb_w0_mips64,
- gdb_w1_mips64,
- gdb_w2_mips64,
- gdb_w3_mips64,
- gdb_w4_mips64,
- gdb_w5_mips64,
- gdb_w6_mips64,
- gdb_w7_mips64,
- gdb_w8_mips64,
- gdb_w9_mips64,
- gdb_w10_mips64,
- gdb_w11_mips64,
- gdb_w12_mips64,
- gdb_w13_mips64,
- gdb_w14_mips64,
- gdb_w15_mips64,
- gdb_w16_mips64,
- gdb_w17_mips64,
- gdb_w18_mips64,
- gdb_w19_mips64,
- gdb_w20_mips64,
- gdb_w21_mips64,
- gdb_w22_mips64,
- gdb_w23_mips64,
- gdb_w24_mips64,
- gdb_w25_mips64,
- gdb_w26_mips64,
- gdb_w27_mips64,
- gdb_w28_mips64,
- gdb_w29_mips64,
- gdb_w30_mips64,
- gdb_w31_mips64,
- gdb_mcsr_mips64,
- gdb_mir_mips64,
- gdb_config5_mips64,
+ dwarf_zero_mips64 = 0,
+ dwarf_r1_mips64,
+ dwarf_r2_mips64,
+ dwarf_r3_mips64,
+ dwarf_r4_mips64,
+ dwarf_r5_mips64,
+ dwarf_r6_mips64,
+ dwarf_r7_mips64,
+ dwarf_r8_mips64,
+ dwarf_r9_mips64,
+ dwarf_r10_mips64,
+ dwarf_r11_mips64,
+ dwarf_r12_mips64,
+ dwarf_r13_mips64,
+ dwarf_r14_mips64,
+ dwarf_r15_mips64,
+ dwarf_r16_mips64,
+ dwarf_r17_mips64,
+ dwarf_r18_mips64,
+ dwarf_r19_mips64,
+ dwarf_r20_mips64,
+ dwarf_r21_mips64,
+ dwarf_r22_mips64,
+ dwarf_r23_mips64,
+ dwarf_r24_mips64,
+ dwarf_r25_mips64,
+ dwarf_r26_mips64,
+ dwarf_r27_mips64,
+ dwarf_gp_mips64,
+ dwarf_sp_mips64,
+ dwarf_r30_mips64,
+ dwarf_ra_mips64,
+ dwarf_sr_mips64,
+ dwarf_lo_mips64,
+ dwarf_hi_mips64,
+ dwarf_bad_mips64,
+ dwarf_cause_mips64,
+ dwarf_pc_mips64,
+ dwarf_f0_mips64,
+ dwarf_f1_mips64,
+ dwarf_f2_mips64,
+ dwarf_f3_mips64,
+ dwarf_f4_mips64,
+ dwarf_f5_mips64,
+ dwarf_f6_mips64,
+ dwarf_f7_mips64,
+ dwarf_f8_mips64,
+ dwarf_f9_mips64,
+ dwarf_f10_mips64,
+ dwarf_f11_mips64,
+ dwarf_f12_mips64,
+ dwarf_f13_mips64,
+ dwarf_f14_mips64,
+ dwarf_f15_mips64,
+ dwarf_f16_mips64,
+ dwarf_f17_mips64,
+ dwarf_f18_mips64,
+ dwarf_f19_mips64,
+ dwarf_f20_mips64,
+ dwarf_f21_mips64,
+ dwarf_f22_mips64,
+ dwarf_f23_mips64,
+ dwarf_f24_mips64,
+ dwarf_f25_mips64,
+ dwarf_f26_mips64,
+ dwarf_f27_mips64,
+ dwarf_f28_mips64,
+ dwarf_f29_mips64,
+ dwarf_f30_mips64,
+ dwarf_f31_mips64,
+ dwarf_fcsr_mips64,
+ dwarf_fir_mips64,
+ dwarf_ic_mips64,
+ dwarf_dummy_mips64,
+ dwarf_w0_mips64,
+ dwarf_w1_mips64,
+ dwarf_w2_mips64,
+ dwarf_w3_mips64,
+ dwarf_w4_mips64,
+ dwarf_w5_mips64,
+ dwarf_w6_mips64,
+ dwarf_w7_mips64,
+ dwarf_w8_mips64,
+ dwarf_w9_mips64,
+ dwarf_w10_mips64,
+ dwarf_w11_mips64,
+ dwarf_w12_mips64,
+ dwarf_w13_mips64,
+ dwarf_w14_mips64,
+ dwarf_w15_mips64,
+ dwarf_w16_mips64,
+ dwarf_w17_mips64,
+ dwarf_w18_mips64,
+ dwarf_w19_mips64,
+ dwarf_w20_mips64,
+ dwarf_w21_mips64,
+ dwarf_w22_mips64,
+ dwarf_w23_mips64,
+ dwarf_w24_mips64,
+ dwarf_w25_mips64,
+ dwarf_w26_mips64,
+ dwarf_w27_mips64,
+ dwarf_w28_mips64,
+ dwarf_w29_mips64,
+ dwarf_w30_mips64,
+ dwarf_w31_mips64,
+ dwarf_mcsr_mips64,
+ dwarf_mir_mips64,
+ dwarf_config5_mips64,
};
struct IOVEC_mips
diff --git a/source/Plugins/Process/Utility/RegisterContext_powerpc.h b/source/Plugins/Process/Utility/RegisterContext_powerpc.h
index 7438b88971b3..2e3053cf37bc 100644
--- a/source/Plugins/Process/Utility/RegisterContext_powerpc.h
+++ b/source/Plugins/Process/Utility/RegisterContext_powerpc.h
@@ -10,223 +10,114 @@
#ifndef liblldb_RegisterContext_powerpc_H_
#define liblldb_RegisterContext_powerpc_H_
-// GCC and DWARF Register numbers (eRegisterKindGCC & eRegisterKindDWARF)
+// eh_frame and DWARF Register numbers (eRegisterKindEHFrame & eRegisterKindDWARF)
enum
{
- gcc_dwarf_r0_powerpc = 0,
- gcc_dwarf_r1_powerpc,
- gcc_dwarf_r2_powerpc,
- gcc_dwarf_r3_powerpc,
- gcc_dwarf_r4_powerpc,
- gcc_dwarf_r5_powerpc,
- gcc_dwarf_r6_powerpc,
- gcc_dwarf_r7_powerpc,
- gcc_dwarf_r8_powerpc,
- gcc_dwarf_r9_powerpc,
- gcc_dwarf_r10_powerpc,
- gcc_dwarf_r11_powerpc,
- gcc_dwarf_r12_powerpc,
- gcc_dwarf_r13_powerpc,
- gcc_dwarf_r14_powerpc,
- gcc_dwarf_r15_powerpc,
- gcc_dwarf_r16_powerpc,
- gcc_dwarf_r17_powerpc,
- gcc_dwarf_r18_powerpc,
- gcc_dwarf_r19_powerpc,
- gcc_dwarf_r20_powerpc,
- gcc_dwarf_r21_powerpc,
- gcc_dwarf_r22_powerpc,
- gcc_dwarf_r23_powerpc,
- gcc_dwarf_r24_powerpc,
- gcc_dwarf_r25_powerpc,
- gcc_dwarf_r26_powerpc,
- gcc_dwarf_r27_powerpc,
- gcc_dwarf_r28_powerpc,
- gcc_dwarf_r29_powerpc,
- gcc_dwarf_r30_powerpc,
- gcc_dwarf_r31_powerpc,
- gcc_dwarf_f0_powerpc,
- gcc_dwarf_f1_powerpc,
- gcc_dwarf_f2_powerpc,
- gcc_dwarf_f3_powerpc,
- gcc_dwarf_f4_powerpc,
- gcc_dwarf_f5_powerpc,
- gcc_dwarf_f6_powerpc,
- gcc_dwarf_f7_powerpc,
- gcc_dwarf_f8_powerpc,
- gcc_dwarf_f9_powerpc,
- gcc_dwarf_f10_powerpc,
- gcc_dwarf_f11_powerpc,
- gcc_dwarf_f12_powerpc,
- gcc_dwarf_f13_powerpc,
- gcc_dwarf_f14_powerpc,
- gcc_dwarf_f15_powerpc,
- gcc_dwarf_f16_powerpc,
- gcc_dwarf_f17_powerpc,
- gcc_dwarf_f18_powerpc,
- gcc_dwarf_f19_powerpc,
- gcc_dwarf_f20_powerpc,
- gcc_dwarf_f21_powerpc,
- gcc_dwarf_f22_powerpc,
- gcc_dwarf_f23_powerpc,
- gcc_dwarf_f24_powerpc,
- gcc_dwarf_f25_powerpc,
- gcc_dwarf_f26_powerpc,
- gcc_dwarf_f27_powerpc,
- gcc_dwarf_f28_powerpc,
- gcc_dwarf_f29_powerpc,
- gcc_dwarf_f30_powerpc,
- gcc_dwarf_f31_powerpc,
- gcc_dwarf_cr_powerpc,
- gcc_dwarf_fpscr_powerpc,
- gcc_dwarf_msr_powerpc,
- gcc_dwarf_vscr_powerpc,
- gcc_dwarf_xer_powerpc = 101,
- gcc_dwarf_lr_powerpc = 108,
- gcc_dwarf_ctr_powerpc,
- gcc_dwarf_pc_powerpc,
- gcc_dwarf_vrsave_powerpc = 356,
- gcc_dwarf_v0_powerpc = 1124,
- gcc_dwarf_v1_powerpc,
- gcc_dwarf_v2_powerpc,
- gcc_dwarf_v3_powerpc,
- gcc_dwarf_v4_powerpc,
- gcc_dwarf_v5_powerpc,
- gcc_dwarf_v6_powerpc,
- gcc_dwarf_v7_powerpc,
- gcc_dwarf_v8_powerpc,
- gcc_dwarf_v9_powerpc,
- gcc_dwarf_v10_powerpc,
- gcc_dwarf_v11_powerpc,
- gcc_dwarf_v12_powerpc,
- gcc_dwarf_v13_powerpc,
- gcc_dwarf_v14_powerpc,
- gcc_dwarf_v15_powerpc,
- gcc_dwarf_v16_powerpc,
- gcc_dwarf_v17_powerpc,
- gcc_dwarf_v18_powerpc,
- gcc_dwarf_v19_powerpc,
- gcc_dwarf_v20_powerpc,
- gcc_dwarf_v21_powerpc,
- gcc_dwarf_v22_powerpc,
- gcc_dwarf_v23_powerpc,
- gcc_dwarf_v24_powerpc,
- gcc_dwarf_v25_powerpc,
- gcc_dwarf_v26_powerpc,
- gcc_dwarf_v27_powerpc,
- gcc_dwarf_v28_powerpc,
- gcc_dwarf_v29_powerpc,
- gcc_dwarf_v30_powerpc,
- gcc_dwarf_v31_powerpc,
-};
-
-// GDB Register numbers (eRegisterKindGDB)
-enum
-{
- gdb_r0_powerpc = 0,
- gdb_r1_powerpc,
- gdb_r2_powerpc,
- gdb_r3_powerpc,
- gdb_r4_powerpc,
- gdb_r5_powerpc,
- gdb_r6_powerpc,
- gdb_r7_powerpc,
- gdb_r8_powerpc,
- gdb_r9_powerpc,
- gdb_r10_powerpc,
- gdb_r11_powerpc,
- gdb_r12_powerpc,
- gdb_r13_powerpc,
- gdb_r14_powerpc,
- gdb_r15_powerpc,
- gdb_r16_powerpc,
- gdb_r17_powerpc,
- gdb_r18_powerpc,
- gdb_r19_powerpc,
- gdb_r20_powerpc,
- gdb_r21_powerpc,
- gdb_r22_powerpc,
- gdb_r23_powerpc,
- gdb_r24_powerpc,
- gdb_r25_powerpc,
- gdb_r26_powerpc,
- gdb_r27_powerpc,
- gdb_r28_powerpc,
- gdb_r29_powerpc,
- gdb_r30_powerpc,
- gdb_r31_powerpc,
- gdb_f0_powerpc,
- gdb_f1_powerpc,
- gdb_f2_powerpc,
- gdb_f3_powerpc,
- gdb_f4_powerpc,
- gdb_f5_powerpc,
- gdb_f6_powerpc,
- gdb_f7_powerpc,
- gdb_f8_powerpc,
- gdb_f9_powerpc,
- gdb_f10_powerpc,
- gdb_f11_powerpc,
- gdb_f12_powerpc,
- gdb_f13_powerpc,
- gdb_f14_powerpc,
- gdb_f15_powerpc,
- gdb_f16_powerpc,
- gdb_f17_powerpc,
- gdb_f18_powerpc,
- gdb_f19_powerpc,
- gdb_f20_powerpc,
- gdb_f21_powerpc,
- gdb_f22_powerpc,
- gdb_f23_powerpc,
- gdb_f24_powerpc,
- gdb_f25_powerpc,
- gdb_f26_powerpc,
- gdb_f27_powerpc,
- gdb_f28_powerpc,
- gdb_f29_powerpc,
- gdb_f30_powerpc,
- gdb_f31_powerpc,
- gdb_pc_powerpc,
- gdb_cr_powerpc = 66,
- gdb_lr_powerpc,
- gdb_ctr_powerpc,
- gdb_xer_powerpc,
- gdb_fpscr_powerpc,
- gdb_v0_powerpc = 106,
- gdb_v1_powerpc,
- gdb_v2_powerpc,
- gdb_v3_powerpc,
- gdb_v4_powerpc,
- gdb_v5_powerpc,
- gdb_v6_powerpc,
- gdb_v7_powerpc,
- gdb_v8_powerpc,
- gdb_v9_powerpc,
- gdb_v10_powerpc,
- gdb_v11_powerpc,
- gdb_v12_powerpc,
- gdb_v13_powerpc,
- gdb_v14_powerpc,
- gdb_v15_powerpc,
- gdb_v16_powerpc,
- gdb_v17_powerpc,
- gdb_v18_powerpc,
- gdb_v19_powerpc,
- gdb_v20_powerpc,
- gdb_v21_powerpc,
- gdb_v22_powerpc,
- gdb_v23_powerpc,
- gdb_v24_powerpc,
- gdb_v25_powerpc,
- gdb_v26_powerpc,
- gdb_v27_powerpc,
- gdb_v28_powerpc,
- gdb_v29_powerpc,
- gdb_v30_powerpc,
- gdb_v31_powerpc,
- gdb_vscr_powerpc,
- gdb_vrsave_powerpc,
+ dwarf_r0_powerpc = 0,
+ dwarf_r1_powerpc,
+ dwarf_r2_powerpc,
+ dwarf_r3_powerpc,
+ dwarf_r4_powerpc,
+ dwarf_r5_powerpc,
+ dwarf_r6_powerpc,
+ dwarf_r7_powerpc,
+ dwarf_r8_powerpc,
+ dwarf_r9_powerpc,
+ dwarf_r10_powerpc,
+ dwarf_r11_powerpc,
+ dwarf_r12_powerpc,
+ dwarf_r13_powerpc,
+ dwarf_r14_powerpc,
+ dwarf_r15_powerpc,
+ dwarf_r16_powerpc,
+ dwarf_r17_powerpc,
+ dwarf_r18_powerpc,
+ dwarf_r19_powerpc,
+ dwarf_r20_powerpc,
+ dwarf_r21_powerpc,
+ dwarf_r22_powerpc,
+ dwarf_r23_powerpc,
+ dwarf_r24_powerpc,
+ dwarf_r25_powerpc,
+ dwarf_r26_powerpc,
+ dwarf_r27_powerpc,
+ dwarf_r28_powerpc,
+ dwarf_r29_powerpc,
+ dwarf_r30_powerpc,
+ dwarf_r31_powerpc,
+ dwarf_f0_powerpc,
+ dwarf_f1_powerpc,
+ dwarf_f2_powerpc,
+ dwarf_f3_powerpc,
+ dwarf_f4_powerpc,
+ dwarf_f5_powerpc,
+ dwarf_f6_powerpc,
+ dwarf_f7_powerpc,
+ dwarf_f8_powerpc,
+ dwarf_f9_powerpc,
+ dwarf_f10_powerpc,
+ dwarf_f11_powerpc,
+ dwarf_f12_powerpc,
+ dwarf_f13_powerpc,
+ dwarf_f14_powerpc,
+ dwarf_f15_powerpc,
+ dwarf_f16_powerpc,
+ dwarf_f17_powerpc,
+ dwarf_f18_powerpc,
+ dwarf_f19_powerpc,
+ dwarf_f20_powerpc,
+ dwarf_f21_powerpc,
+ dwarf_f22_powerpc,
+ dwarf_f23_powerpc,
+ dwarf_f24_powerpc,
+ dwarf_f25_powerpc,
+ dwarf_f26_powerpc,
+ dwarf_f27_powerpc,
+ dwarf_f28_powerpc,
+ dwarf_f29_powerpc,
+ dwarf_f30_powerpc,
+ dwarf_f31_powerpc,
+ dwarf_cr_powerpc,
+ dwarf_fpscr_powerpc,
+ dwarf_msr_powerpc,
+ dwarf_vscr_powerpc,
+ dwarf_xer_powerpc = 101,
+ dwarf_lr_powerpc = 108,
+ dwarf_ctr_powerpc,
+ dwarf_pc_powerpc,
+ dwarf_vrsave_powerpc = 356,
+ dwarf_v0_powerpc = 1124,
+ dwarf_v1_powerpc,
+ dwarf_v2_powerpc,
+ dwarf_v3_powerpc,
+ dwarf_v4_powerpc,
+ dwarf_v5_powerpc,
+ dwarf_v6_powerpc,
+ dwarf_v7_powerpc,
+ dwarf_v8_powerpc,
+ dwarf_v9_powerpc,
+ dwarf_v10_powerpc,
+ dwarf_v11_powerpc,
+ dwarf_v12_powerpc,
+ dwarf_v13_powerpc,
+ dwarf_v14_powerpc,
+ dwarf_v15_powerpc,
+ dwarf_v16_powerpc,
+ dwarf_v17_powerpc,
+ dwarf_v18_powerpc,
+ dwarf_v19_powerpc,
+ dwarf_v20_powerpc,
+ dwarf_v21_powerpc,
+ dwarf_v22_powerpc,
+ dwarf_v23_powerpc,
+ dwarf_v24_powerpc,
+ dwarf_v25_powerpc,
+ dwarf_v26_powerpc,
+ dwarf_v27_powerpc,
+ dwarf_v28_powerpc,
+ dwarf_v29_powerpc,
+ dwarf_v30_powerpc,
+ dwarf_v31_powerpc,
};
#endif // liblldb_RegisterContext_powerpc_H_
diff --git a/source/Plugins/Process/Utility/RegisterContext_x86.h b/source/Plugins/Process/Utility/RegisterContext_x86.h
index 6b3f6fb43e33..252f1253a086 100644
--- a/source/Plugins/Process/Utility/RegisterContext_x86.h
+++ b/source/Plugins/Process/Utility/RegisterContext_x86.h
@@ -11,67 +11,56 @@
#define liblldb_RegisterContext_x86_H_
//---------------------------------------------------------------------------
-// i386 gcc, dwarf, gdb enums
+// i386 ehframe, dwarf regnums
//---------------------------------------------------------------------------
-// Register numbers seen in eh_frame (eRegisterKindGCC)
+// Register numbers seen in eh_frame (eRegisterKindEHFrame) on i386 systems (non-Darwin)
//
-// From Jason Molenda: "gcc registers" is the register numbering used in the eh_frame
-// CFI. The only registers that are described in eh_frame CFI are those that are
-// preserved across function calls aka callee-saved aka non-volatile. And none
-// of the floating point registers on x86 are preserved across function calls.
-//
-// The only reason there is a "gcc register" and a "dwarf register" is because of a
-// mistake years and years ago with i386 where they got esp and ebp
-// backwards when they emitted the eh_frame instructions. Once there were
-// binaries In The Wild using the reversed numbering, we had to stick with it
-// forever.
enum
{
- // 2nd parameter in DwarfRegNum() is regnum for exception handling on x86-32.
- // See http://llvm.org/docs/WritingAnLLVMBackend.html#defining-a-register
- gcc_eax_i386 = 0,
- gcc_ecx_i386,
- gcc_edx_i386,
- gcc_ebx_i386,
+ ehframe_eax_i386 = 0,
+ ehframe_ecx_i386,
+ ehframe_edx_i386,
+ ehframe_ebx_i386,
// on Darwin esp & ebp are reversed in the eh_frame section for i386 (versus dwarf's reg numbering).
// To be specific:
// i386+darwin eh_frame: 4 is ebp, 5 is esp
// i386+everyone else eh_frame: 4 is esp, 5 is ebp
// i386 dwarf: 4 is esp, 5 is ebp
- // lldb will get the darwin-specific eh_frame reg numberings from debugserver instead of here so we
- // only encode the 4 == esp, 5 == ebp numbers in this generic header.
- gcc_esp_i386,
- gcc_ebp_i386,
- gcc_esi_i386,
- gcc_edi_i386,
- gcc_eip_i386,
- gcc_eflags_i386,
- gcc_st0_i386 = 12,
- gcc_st1_i386,
- gcc_st2_i386,
- gcc_st3_i386,
- gcc_st4_i386,
- gcc_st5_i386,
- gcc_st6_i386,
- gcc_st7_i386,
- gcc_xmm0_i386 = 21,
- gcc_xmm1_i386,
- gcc_xmm2_i386,
- gcc_xmm3_i386,
- gcc_xmm4_i386,
- gcc_xmm5_i386,
- gcc_xmm6_i386,
- gcc_xmm7_i386,
- gcc_mm0_i386 = 29,
- gcc_mm1_i386,
- gcc_mm2_i386,
- gcc_mm3_i386,
- gcc_mm4_i386,
- gcc_mm5_i386,
- gcc_mm6_i386,
- gcc_mm7_i386,
+ // lldb will get the darwin-specific eh_frame reg numberings from debugserver, or the ABI, so we
+ // only encode the generally correct 4 == esp, 5 == ebp numbers in this generic header.
+
+ ehframe_esp_i386,
+ ehframe_ebp_i386,
+ ehframe_esi_i386,
+ ehframe_edi_i386,
+ ehframe_eip_i386,
+ ehframe_eflags_i386,
+ ehframe_st0_i386 = 12,
+ ehframe_st1_i386,
+ ehframe_st2_i386,
+ ehframe_st3_i386,
+ ehframe_st4_i386,
+ ehframe_st5_i386,
+ ehframe_st6_i386,
+ ehframe_st7_i386,
+ ehframe_xmm0_i386 = 21,
+ ehframe_xmm1_i386,
+ ehframe_xmm2_i386,
+ ehframe_xmm3_i386,
+ ehframe_xmm4_i386,
+ ehframe_xmm5_i386,
+ ehframe_xmm6_i386,
+ ehframe_xmm7_i386,
+ ehframe_mm0_i386 = 29,
+ ehframe_mm1_i386,
+ ehframe_mm2_i386,
+ ehframe_mm3_i386,
+ ehframe_mm4_i386,
+ ehframe_mm5_i386,
+ ehframe_mm6_i386,
+ ehframe_mm7_i386,
};
// DWARF register numbers (eRegisterKindDWARF)
@@ -130,258 +119,109 @@ enum
// then differentiate based on size of the register.
};
-// Register numbers GDB uses (eRegisterKindGDB)
-//
-// From Jason Molenda: The "gdb numbers" are what you would see in the stabs debug format.
-enum
-{
- gdb_eax_i386,
- gdb_ecx_i386,
- gdb_edx_i386,
- gdb_ebx_i386,
- gdb_esp_i386,
- gdb_ebp_i386,
- gdb_esi_i386,
- gdb_edi_i386,
- gdb_eip_i386,
- gdb_eflags_i386,
- gdb_cs_i386,
- gdb_ss_i386,
- gdb_ds_i386,
- gdb_es_i386,
- gdb_fs_i386,
- gdb_gs_i386,
- gdb_st0_i386 = 16,
- gdb_st1_i386,
- gdb_st2_i386,
- gdb_st3_i386,
- gdb_st4_i386,
- gdb_st5_i386,
- gdb_st6_i386,
- gdb_st7_i386,
- gdb_fctrl_i386, // FPU Control Word
- gdb_fstat_i386, // FPU Status Word
- gdb_ftag_i386, // FPU Tag Word
- gdb_fiseg_i386, // FPU IP Selector
- gdb_fioff_i386, // FPU IP Offset
- gdb_foseg_i386, // FPU Operand Pointer Selector
- gdb_fooff_i386, // FPU Operand Pointer Offset
- gdb_fop_i386, // Last Instruction Opcode
- gdb_xmm0_i386 = 32,
- gdb_xmm1_i386,
- gdb_xmm2_i386,
- gdb_xmm3_i386,
- gdb_xmm4_i386,
- gdb_xmm5_i386,
- gdb_xmm6_i386,
- gdb_xmm7_i386,
- gdb_mxcsr_i386 = 40,
- gdb_ymm0h_i386,
- gdb_ymm1h_i386,
- gdb_ymm2h_i386,
- gdb_ymm3h_i386,
- gdb_ymm4h_i386,
- gdb_ymm5h_i386,
- gdb_ymm6h_i386,
- gdb_ymm7h_i386,
- gdb_mm0_i386,
- gdb_mm1_i386,
- gdb_mm2_i386,
- gdb_mm3_i386,
- gdb_mm4_i386,
- gdb_mm5_i386,
- gdb_mm6_i386,
- gdb_mm7_i386,
-};
-
//---------------------------------------------------------------------------
-// AMD x86_64, AMD64, Intel EM64T, or Intel 64 gcc, dwarf, gdb enums
+// AMD x86_64, AMD64, Intel EM64T, or Intel 64 ehframe, dwarf regnums
//---------------------------------------------------------------------------
-// GCC and DWARF Register numbers (eRegisterKindGCC & eRegisterKindDWARF)
+// EHFrame and DWARF Register numbers (eRegisterKindEHFrame & eRegisterKindDWARF)
// This is the spec I used (as opposed to x86-64-abi-0.99.pdf):
// http://software.intel.com/sites/default/files/article/402129/mpx-linux64-abi.pdf
enum
{
// GP Registers
- gcc_dwarf_rax_x86_64 = 0,
- gcc_dwarf_rdx_x86_64,
- gcc_dwarf_rcx_x86_64,
- gcc_dwarf_rbx_x86_64,
- gcc_dwarf_rsi_x86_64,
- gcc_dwarf_rdi_x86_64,
- gcc_dwarf_rbp_x86_64,
- gcc_dwarf_rsp_x86_64,
+ dwarf_rax_x86_64 = 0,
+ dwarf_rdx_x86_64,
+ dwarf_rcx_x86_64,
+ dwarf_rbx_x86_64,
+ dwarf_rsi_x86_64,
+ dwarf_rdi_x86_64,
+ dwarf_rbp_x86_64,
+ dwarf_rsp_x86_64,
// Extended GP Registers
- gcc_dwarf_r8_x86_64 = 8,
- gcc_dwarf_r9_x86_64,
- gcc_dwarf_r10_x86_64,
- gcc_dwarf_r11_x86_64,
- gcc_dwarf_r12_x86_64,
- gcc_dwarf_r13_x86_64,
- gcc_dwarf_r14_x86_64,
- gcc_dwarf_r15_x86_64,
+ dwarf_r8_x86_64 = 8,
+ dwarf_r9_x86_64,
+ dwarf_r10_x86_64,
+ dwarf_r11_x86_64,
+ dwarf_r12_x86_64,
+ dwarf_r13_x86_64,
+ dwarf_r14_x86_64,
+ dwarf_r15_x86_64,
// Return Address (RA) mapped to RIP
- gcc_dwarf_rip_x86_64 = 16,
+ dwarf_rip_x86_64 = 16,
// SSE Vector Registers
- gcc_dwarf_xmm0_x86_64 = 17,
- gcc_dwarf_xmm1_x86_64,
- gcc_dwarf_xmm2_x86_64,
- gcc_dwarf_xmm3_x86_64,
- gcc_dwarf_xmm4_x86_64,
- gcc_dwarf_xmm5_x86_64,
- gcc_dwarf_xmm6_x86_64,
- gcc_dwarf_xmm7_x86_64,
- gcc_dwarf_xmm8_x86_64,
- gcc_dwarf_xmm9_x86_64,
- gcc_dwarf_xmm10_x86_64,
- gcc_dwarf_xmm11_x86_64,
- gcc_dwarf_xmm12_x86_64,
- gcc_dwarf_xmm13_x86_64,
- gcc_dwarf_xmm14_x86_64,
- gcc_dwarf_xmm15_x86_64,
+ dwarf_xmm0_x86_64 = 17,
+ dwarf_xmm1_x86_64,
+ dwarf_xmm2_x86_64,
+ dwarf_xmm3_x86_64,
+ dwarf_xmm4_x86_64,
+ dwarf_xmm5_x86_64,
+ dwarf_xmm6_x86_64,
+ dwarf_xmm7_x86_64,
+ dwarf_xmm8_x86_64,
+ dwarf_xmm9_x86_64,
+ dwarf_xmm10_x86_64,
+ dwarf_xmm11_x86_64,
+ dwarf_xmm12_x86_64,
+ dwarf_xmm13_x86_64,
+ dwarf_xmm14_x86_64,
+ dwarf_xmm15_x86_64,
// Floating Point Registers
- gcc_dwarf_st0_x86_64 = 33,
- gcc_dwarf_st1_x86_64,
- gcc_dwarf_st2_x86_64,
- gcc_dwarf_st3_x86_64,
- gcc_dwarf_st4_x86_64,
- gcc_dwarf_st5_x86_64,
- gcc_dwarf_st6_x86_64,
- gcc_dwarf_st7_x86_64,
+ dwarf_st0_x86_64 = 33,
+ dwarf_st1_x86_64,
+ dwarf_st2_x86_64,
+ dwarf_st3_x86_64,
+ dwarf_st4_x86_64,
+ dwarf_st5_x86_64,
+ dwarf_st6_x86_64,
+ dwarf_st7_x86_64,
// MMX Registers
- gcc_dwarf_mm0_x86_64 = 41,
- gcc_dwarf_mm1_x86_64,
- gcc_dwarf_mm2_x86_64,
- gcc_dwarf_mm3_x86_64,
- gcc_dwarf_mm4_x86_64,
- gcc_dwarf_mm5_x86_64,
- gcc_dwarf_mm6_x86_64,
- gcc_dwarf_mm7_x86_64,
+ dwarf_mm0_x86_64 = 41,
+ dwarf_mm1_x86_64,
+ dwarf_mm2_x86_64,
+ dwarf_mm3_x86_64,
+ dwarf_mm4_x86_64,
+ dwarf_mm5_x86_64,
+ dwarf_mm6_x86_64,
+ dwarf_mm7_x86_64,
// Control and Status Flags Register
- gcc_dwarf_rflags_x86_64 = 49,
+ dwarf_rflags_x86_64 = 49,
// selector registers
- gcc_dwarf_es_x86_64 = 50,
- gcc_dwarf_cs_x86_64,
- gcc_dwarf_ss_x86_64,
- gcc_dwarf_ds_x86_64,
- gcc_dwarf_fs_x86_64,
- gcc_dwarf_gs_x86_64,
+ dwarf_es_x86_64 = 50,
+ dwarf_cs_x86_64,
+ dwarf_ss_x86_64,
+ dwarf_ds_x86_64,
+ dwarf_fs_x86_64,
+ dwarf_gs_x86_64,
// Floating point control registers
- gcc_dwarf_mxcsr_x86_64 = 64, // Media Control and Status
- gcc_dwarf_fctrl_x86_64, // x87 control word
- gcc_dwarf_fstat_x86_64, // x87 status word
+ dwarf_mxcsr_x86_64 = 64, // Media Control and Status
+ dwarf_fctrl_x86_64, // x87 control word
+ dwarf_fstat_x86_64, // x87 status word
// Upper Vector Registers
- gcc_dwarf_ymm0h_x86_64 = 67,
- gcc_dwarf_ymm1h_x86_64,
- gcc_dwarf_ymm2h_x86_64,
- gcc_dwarf_ymm3h_x86_64,
- gcc_dwarf_ymm4h_x86_64,
- gcc_dwarf_ymm5h_x86_64,
- gcc_dwarf_ymm6h_x86_64,
- gcc_dwarf_ymm7h_x86_64,
- gcc_dwarf_ymm8h_x86_64,
- gcc_dwarf_ymm9h_x86_64,
- gcc_dwarf_ymm10h_x86_64,
- gcc_dwarf_ymm11h_x86_64,
- gcc_dwarf_ymm12h_x86_64,
- gcc_dwarf_ymm13h_x86_64,
- gcc_dwarf_ymm14h_x86_64,
- gcc_dwarf_ymm15h_x86_64,
+ dwarf_ymm0h_x86_64 = 67,
+ dwarf_ymm1h_x86_64,
+ dwarf_ymm2h_x86_64,
+ dwarf_ymm3h_x86_64,
+ dwarf_ymm4h_x86_64,
+ dwarf_ymm5h_x86_64,
+ dwarf_ymm6h_x86_64,
+ dwarf_ymm7h_x86_64,
+ dwarf_ymm8h_x86_64,
+ dwarf_ymm9h_x86_64,
+ dwarf_ymm10h_x86_64,
+ dwarf_ymm11h_x86_64,
+ dwarf_ymm12h_x86_64,
+ dwarf_ymm13h_x86_64,
+ dwarf_ymm14h_x86_64,
+ dwarf_ymm15h_x86_64,
// AVX2 Vector Mask Registers
- // gcc_dwarf_k0_x86_64 = 118,
- // gcc_dwarf_k1_x86_64,
- // gcc_dwarf_k2_x86_64,
- // gcc_dwarf_k3_x86_64,
- // gcc_dwarf_k4_x86_64,
- // gcc_dwarf_k5_x86_64,
- // gcc_dwarf_k6_x86_64,
- // gcc_dwarf_k7_x86_64,
-};
-
-// GDB Register numbers (eRegisterKindGDB)
-enum
-{
- // GP Registers
- gdb_rax_x86_64 = 0,
- gdb_rbx_x86_64,
- gdb_rcx_x86_64,
- gdb_rdx_x86_64,
- gdb_rsi_x86_64,
- gdb_rdi_x86_64,
- gdb_rbp_x86_64,
- gdb_rsp_x86_64,
- // Extended GP Registers
- gdb_r8_x86_64,
- gdb_r9_x86_64,
- gdb_r10_x86_64,
- gdb_r11_x86_64,
- gdb_r12_x86_64,
- gdb_r13_x86_64,
- gdb_r14_x86_64,
- gdb_r15_x86_64,
- // Return Address (RA) mapped to RIP
- gdb_rip_x86_64,
- // Control and Status Flags Register
- gdb_rflags_x86_64,
- gdb_cs_x86_64,
- gdb_ss_x86_64,
- gdb_ds_x86_64,
- gdb_es_x86_64,
- gdb_fs_x86_64,
- gdb_gs_x86_64,
- // Floating Point Registers
- gdb_st0_x86_64,
- gdb_st1_x86_64,
- gdb_st2_x86_64,
- gdb_st3_x86_64,
- gdb_st4_x86_64,
- gdb_st5_x86_64,
- gdb_st6_x86_64,
- gdb_st7_x86_64,
- gdb_fctrl_x86_64,
- gdb_fstat_x86_64,
- gdb_ftag_x86_64,
- gdb_fiseg_x86_64,
- gdb_fioff_x86_64,
- gdb_foseg_x86_64,
- gdb_fooff_x86_64,
- gdb_fop_x86_64,
- // SSE Vector Registers
- gdb_xmm0_x86_64 = 40,
- gdb_xmm1_x86_64,
- gdb_xmm2_x86_64,
- gdb_xmm3_x86_64,
- gdb_xmm4_x86_64,
- gdb_xmm5_x86_64,
- gdb_xmm6_x86_64,
- gdb_xmm7_x86_64,
- gdb_xmm8_x86_64,
- gdb_xmm9_x86_64,
- gdb_xmm10_x86_64,
- gdb_xmm11_x86_64,
- gdb_xmm12_x86_64,
- gdb_xmm13_x86_64,
- gdb_xmm14_x86_64,
- gdb_xmm15_x86_64,
- // Floating point control registers
- gdb_mxcsr_x86_64 = 56,
- gdb_ymm0h_x86_64,
- gdb_ymm1h_x86_64,
- gdb_ymm2h_x86_64,
- gdb_ymm3h_x86_64,
- gdb_ymm4h_x86_64,
- gdb_ymm5h_x86_64,
- gdb_ymm6h_x86_64,
- gdb_ymm7h_x86_64,
- gdb_ymm8h_x86_64,
- gdb_ymm9h_x86_64,
- gdb_ymm10h_x86_64,
- gdb_ymm11h_x86_64,
- gdb_ymm12h_x86_64,
- gdb_ymm13h_x86_64,
- gdb_ymm14h_x86_64,
- gdb_ymm15h_x86_64
+ // dwarf_k0_x86_64 = 118,
+ // dwarf_k1_x86_64,
+ // dwarf_k2_x86_64,
+ // dwarf_k3_x86_64,
+ // dwarf_k4_x86_64,
+ // dwarf_k5_x86_64,
+ // dwarf_k6_x86_64,
+ // dwarf_k7_x86_64,
};
//---------------------------------------------------------------------------
@@ -404,7 +244,8 @@ struct FXSAVE
{
uint16_t fctrl; // FPU Control Word (fcw)
uint16_t fstat; // FPU Status Word (fsw)
- uint16_t ftag; // FPU Tag Word (ftw)
+ uint8_t ftag; // FPU Tag Word (ftw)
+ uint8_t reserved_1; // Reserved
uint16_t fop; // Last Instruction Opcode (fop)
union
{
diff --git a/source/Plugins/Process/Utility/RegisterInfoInterface.h b/source/Plugins/Process/Utility/RegisterInfoInterface.h
index 94cb5cc791c6..801885d5f4c5 100644
--- a/source/Plugins/Process/Utility/RegisterInfoInterface.h
+++ b/source/Plugins/Process/Utility/RegisterInfoInterface.h
@@ -10,6 +10,8 @@
#ifndef lldb_RegisterInfoInterface_h
#define lldb_RegisterInfoInterface_h
+#include <vector>
+
#include "lldb/Core/ArchSpec.h"
namespace lldb_private
@@ -50,6 +52,26 @@ namespace lldb_private
GetTargetArchitecture() const
{ return m_target_arch; }
+ virtual const lldb_private::RegisterInfo *
+ GetDynamicRegisterInfo(const char *reg_name) const
+ {
+ const std::vector <lldb_private::RegisterInfo> * d_register_infos = GetDynamicRegisterInfoP();
+ if(d_register_infos != nullptr)
+ {
+ std::vector <lldb_private::RegisterInfo> ::const_iterator pos = d_register_infos->begin();
+ for(; pos < d_register_infos->end() ; pos++)
+ {
+ if(::strcmp(reg_name, pos->name) == 0)
+ return(d_register_infos->data() + (pos - d_register_infos->begin()) );
+ }
+ }
+ return nullptr;
+ }
+
+ virtual const std::vector<lldb_private::RegisterInfo> *
+ GetDynamicRegisterInfoP() const
+ { return nullptr; }
+
public:
// FIXME make private.
lldb_private::ArchSpec m_target_arch;
diff --git a/source/Plugins/Process/Utility/RegisterInfos_arm.h b/source/Plugins/Process/Utility/RegisterInfos_arm.h
index 3d144d669415..03457728b632 100644
--- a/source/Plugins/Process/Utility/RegisterInfos_arm.h
+++ b/source/Plugins/Process/Utility/RegisterInfos_arm.h
@@ -1,21 +1,25 @@
-//===-- RegisterInfos_arm.h ----------------------------------*- C++ -*-===//
+//===-- 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.
//
-//===---------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
#ifdef DECLARE_REGISTER_INFOS_ARM_STRUCT
+// C Includes
#include <stddef.h>
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-enumerations.h"
-#include "Utility/ARM_GCC_Registers.h"
+#include "Utility/ARM_ehframe_Registers.h"
#include "Utility/ARM_DWARF_Registers.h"
using namespace lldb;
@@ -25,17 +29,16 @@ using namespace lldb_private;
#error GPR_OFFSET must be defined before including this header file
#endif
-
#ifndef FPU_OFFSET
#error FPU_OFFSET must be defined before including this header file
#endif
-#ifndef EXC_OFFSET
-#error EXC_OFFSET_NAME must be defined before including this header file
+#ifndef FPSCR_OFFSET
+#error FPSCR_OFFSET must be defined before including this header file
#endif
-#ifndef DBG_OFFSET
-#error DBG_OFFSET_NAME must be defined before including this header file
+#ifndef EXC_OFFSET
+#error EXC_OFFSET_NAME must be defined before including this header file
#endif
#ifndef DEFINE_DBG
@@ -96,6 +99,56 @@ enum
fpu_s31,
fpu_fpscr,
+ fpu_d0,
+ fpu_d1,
+ fpu_d2,
+ fpu_d3,
+ fpu_d4,
+ fpu_d5,
+ fpu_d6,
+ fpu_d7,
+ fpu_d8,
+ fpu_d9,
+ fpu_d10,
+ fpu_d11,
+ fpu_d12,
+ fpu_d13,
+ fpu_d14,
+ fpu_d15,
+ fpu_d16,
+ fpu_d17,
+ fpu_d18,
+ fpu_d19,
+ fpu_d20,
+ fpu_d21,
+ fpu_d22,
+ fpu_d23,
+ fpu_d24,
+ fpu_d25,
+ fpu_d26,
+ fpu_d27,
+ fpu_d28,
+ fpu_d29,
+ fpu_d30,
+ fpu_d31,
+
+ fpu_q0,
+ fpu_q1,
+ fpu_q2,
+ fpu_q3,
+ fpu_q4,
+ fpu_q5,
+ fpu_q6,
+ fpu_q7,
+ fpu_q8,
+ fpu_q9,
+ fpu_q10,
+ fpu_q11,
+ fpu_q12,
+ fpu_q13,
+ fpu_q14,
+ fpu_q15,
+
exc_exception,
exc_fsr,
exc_far,
@@ -171,65 +224,214 @@ enum
k_num_registers
};
+static uint32_t g_s0_invalidates[] = { fpu_d0, fpu_q0, LLDB_INVALID_REGNUM };
+static uint32_t g_s1_invalidates[] = { fpu_d0, fpu_q0, LLDB_INVALID_REGNUM };
+static uint32_t g_s2_invalidates[] = { fpu_d1, fpu_q0, LLDB_INVALID_REGNUM };
+static uint32_t g_s3_invalidates[] = { fpu_d1, fpu_q0, LLDB_INVALID_REGNUM };
+static uint32_t g_s4_invalidates[] = { fpu_d2, fpu_q1, LLDB_INVALID_REGNUM };
+static uint32_t g_s5_invalidates[] = { fpu_d2, fpu_q1, LLDB_INVALID_REGNUM };
+static uint32_t g_s6_invalidates[] = { fpu_d3, fpu_q1, LLDB_INVALID_REGNUM };
+static uint32_t g_s7_invalidates[] = { fpu_d3, fpu_q1, LLDB_INVALID_REGNUM };
+static uint32_t g_s8_invalidates[] = { fpu_d4, fpu_q2, LLDB_INVALID_REGNUM };
+static uint32_t g_s9_invalidates[] = { fpu_d4, fpu_q2, LLDB_INVALID_REGNUM };
+static uint32_t g_s10_invalidates[] = { fpu_d5, fpu_q2, LLDB_INVALID_REGNUM };
+static uint32_t g_s11_invalidates[] = { fpu_d5, fpu_q2, LLDB_INVALID_REGNUM };
+static uint32_t g_s12_invalidates[] = { fpu_d6, fpu_q3, LLDB_INVALID_REGNUM };
+static uint32_t g_s13_invalidates[] = { fpu_d6, fpu_q3, LLDB_INVALID_REGNUM };
+static uint32_t g_s14_invalidates[] = { fpu_d7, fpu_q3, LLDB_INVALID_REGNUM };
+static uint32_t g_s15_invalidates[] = { fpu_d7, fpu_q3, LLDB_INVALID_REGNUM };
+static uint32_t g_s16_invalidates[] = { fpu_d8, fpu_q4, LLDB_INVALID_REGNUM };
+static uint32_t g_s17_invalidates[] = { fpu_d8, fpu_q4, LLDB_INVALID_REGNUM };
+static uint32_t g_s18_invalidates[] = { fpu_d9, fpu_q4, LLDB_INVALID_REGNUM };
+static uint32_t g_s19_invalidates[] = { fpu_d9, fpu_q4, LLDB_INVALID_REGNUM };
+static uint32_t g_s20_invalidates[] = { fpu_d10, fpu_q5, LLDB_INVALID_REGNUM };
+static uint32_t g_s21_invalidates[] = { fpu_d10, fpu_q5, LLDB_INVALID_REGNUM };
+static uint32_t g_s22_invalidates[] = { fpu_d11, fpu_q5, LLDB_INVALID_REGNUM };
+static uint32_t g_s23_invalidates[] = { fpu_d11, fpu_q5, LLDB_INVALID_REGNUM };
+static uint32_t g_s24_invalidates[] = { fpu_d12, fpu_q6, LLDB_INVALID_REGNUM };
+static uint32_t g_s25_invalidates[] = { fpu_d12, fpu_q6, LLDB_INVALID_REGNUM };
+static uint32_t g_s26_invalidates[] = { fpu_d13, fpu_q6, LLDB_INVALID_REGNUM };
+static uint32_t g_s27_invalidates[] = { fpu_d13, fpu_q6, LLDB_INVALID_REGNUM };
+static uint32_t g_s28_invalidates[] = { fpu_d14, fpu_q7, LLDB_INVALID_REGNUM };
+static uint32_t g_s29_invalidates[] = { fpu_d14, fpu_q7, LLDB_INVALID_REGNUM };
+static uint32_t g_s30_invalidates[] = { fpu_d15, fpu_q7, LLDB_INVALID_REGNUM };
+static uint32_t g_s31_invalidates[] = { fpu_d15, fpu_q7, LLDB_INVALID_REGNUM };
+
+static uint32_t g_d0_contains[] = { fpu_s0, fpu_s1, LLDB_INVALID_REGNUM };
+static uint32_t g_d1_contains[] = { fpu_s2, fpu_s3, LLDB_INVALID_REGNUM };
+static uint32_t g_d2_contains[] = { fpu_s4, fpu_s5, LLDB_INVALID_REGNUM };
+static uint32_t g_d3_contains[] = { fpu_s6, fpu_s7, LLDB_INVALID_REGNUM };
+static uint32_t g_d4_contains[] = { fpu_s8, fpu_s9, LLDB_INVALID_REGNUM };
+static uint32_t g_d5_contains[] = { fpu_s10, fpu_s11, LLDB_INVALID_REGNUM };
+static uint32_t g_d6_contains[] = { fpu_s12, fpu_s13, LLDB_INVALID_REGNUM };
+static uint32_t g_d7_contains[] = { fpu_s14, fpu_s15, LLDB_INVALID_REGNUM };
+static uint32_t g_d8_contains[] = { fpu_s16, fpu_s17, LLDB_INVALID_REGNUM };
+static uint32_t g_d9_contains[] = { fpu_s18, fpu_s19, LLDB_INVALID_REGNUM };
+static uint32_t g_d10_contains[] = { fpu_s20, fpu_s21, LLDB_INVALID_REGNUM };
+static uint32_t g_d11_contains[] = { fpu_s22, fpu_s23, LLDB_INVALID_REGNUM };
+static uint32_t g_d12_contains[] = { fpu_s24, fpu_s25, LLDB_INVALID_REGNUM };
+static uint32_t g_d13_contains[] = { fpu_s26, fpu_s27, LLDB_INVALID_REGNUM };
+static uint32_t g_d14_contains[] = { fpu_s28, fpu_s29, LLDB_INVALID_REGNUM };
+static uint32_t g_d15_contains[] = { fpu_s30, fpu_s31, LLDB_INVALID_REGNUM };
+
+static uint32_t g_d0_invalidates[] = { fpu_q0, LLDB_INVALID_REGNUM };
+static uint32_t g_d1_invalidates[] = { fpu_q0, LLDB_INVALID_REGNUM };
+static uint32_t g_d2_invalidates[] = { fpu_q1, LLDB_INVALID_REGNUM };
+static uint32_t g_d3_invalidates[] = { fpu_q1, LLDB_INVALID_REGNUM };
+static uint32_t g_d4_invalidates[] = { fpu_q2, LLDB_INVALID_REGNUM };
+static uint32_t g_d5_invalidates[] = { fpu_q2, LLDB_INVALID_REGNUM };
+static uint32_t g_d6_invalidates[] = { fpu_q3, LLDB_INVALID_REGNUM };
+static uint32_t g_d7_invalidates[] = { fpu_q3, LLDB_INVALID_REGNUM };
+static uint32_t g_d8_invalidates[] = { fpu_q4, LLDB_INVALID_REGNUM };
+static uint32_t g_d9_invalidates[] = { fpu_q4, LLDB_INVALID_REGNUM };
+static uint32_t g_d10_invalidates[] = { fpu_q5, LLDB_INVALID_REGNUM };
+static uint32_t g_d11_invalidates[] = { fpu_q5, LLDB_INVALID_REGNUM };
+static uint32_t g_d12_invalidates[] = { fpu_q6, LLDB_INVALID_REGNUM };
+static uint32_t g_d13_invalidates[] = { fpu_q6, LLDB_INVALID_REGNUM };
+static uint32_t g_d14_invalidates[] = { fpu_q7, LLDB_INVALID_REGNUM };
+static uint32_t g_d15_invalidates[] = { fpu_q7, LLDB_INVALID_REGNUM };
+static uint32_t g_d16_invalidates[] = { fpu_q8, LLDB_INVALID_REGNUM };
+static uint32_t g_d17_invalidates[] = { fpu_q8, LLDB_INVALID_REGNUM };
+static uint32_t g_d18_invalidates[] = { fpu_q9, LLDB_INVALID_REGNUM };
+static uint32_t g_d19_invalidates[] = { fpu_q9, LLDB_INVALID_REGNUM };
+static uint32_t g_d20_invalidates[] = { fpu_q10, LLDB_INVALID_REGNUM };
+static uint32_t g_d21_invalidates[] = { fpu_q10, LLDB_INVALID_REGNUM };
+static uint32_t g_d22_invalidates[] = { fpu_q11, LLDB_INVALID_REGNUM };
+static uint32_t g_d23_invalidates[] = { fpu_q11, LLDB_INVALID_REGNUM };
+static uint32_t g_d24_invalidates[] = { fpu_q12, LLDB_INVALID_REGNUM };
+static uint32_t g_d25_invalidates[] = { fpu_q12, LLDB_INVALID_REGNUM };
+static uint32_t g_d26_invalidates[] = { fpu_q13, LLDB_INVALID_REGNUM };
+static uint32_t g_d27_invalidates[] = { fpu_q13, LLDB_INVALID_REGNUM };
+static uint32_t g_d28_invalidates[] = { fpu_q14, LLDB_INVALID_REGNUM };
+static uint32_t g_d29_invalidates[] = { fpu_q14, LLDB_INVALID_REGNUM };
+static uint32_t g_d30_invalidates[] = { fpu_q15, LLDB_INVALID_REGNUM };
+static uint32_t g_d31_invalidates[] = { fpu_q15, LLDB_INVALID_REGNUM };
+
+static uint32_t g_q0_contains[] = { fpu_d0, fpu_d1, fpu_s0, fpu_s1, fpu_s2, fpu_s3, LLDB_INVALID_REGNUM };
+static uint32_t g_q1_contains[] = { fpu_d2, fpu_d3, fpu_s4, fpu_s5, fpu_s6, fpu_s7, LLDB_INVALID_REGNUM };
+static uint32_t g_q2_contains[] = { fpu_d4, fpu_d5, fpu_s8, fpu_s9, fpu_s10, fpu_s11, LLDB_INVALID_REGNUM };
+static uint32_t g_q3_contains[] = { fpu_d6, fpu_d7, fpu_s12, fpu_s13, fpu_s14, fpu_s15, LLDB_INVALID_REGNUM };
+static uint32_t g_q4_contains[] = { fpu_d8, fpu_d9, fpu_s16, fpu_s17, fpu_s18, fpu_s19, LLDB_INVALID_REGNUM };
+static uint32_t g_q5_contains[] = { fpu_d10, fpu_d11, fpu_s20, fpu_s21, fpu_s22, fpu_s23, LLDB_INVALID_REGNUM };
+static uint32_t g_q6_contains[] = { fpu_d12, fpu_d13, fpu_s24, fpu_s25, fpu_s26, fpu_s27, LLDB_INVALID_REGNUM };
+static uint32_t g_q7_contains[] = { fpu_d14, fpu_d15, fpu_s28, fpu_s29, fpu_s30, fpu_s31, LLDB_INVALID_REGNUM };
+static uint32_t g_q8_contains[] = { fpu_d16, fpu_d17, LLDB_INVALID_REGNUM };
+static uint32_t g_q9_contains[] = { fpu_d18, fpu_d19, LLDB_INVALID_REGNUM };
+static uint32_t g_q10_contains[] = { fpu_d20, fpu_d21, LLDB_INVALID_REGNUM };
+static uint32_t g_q11_contains[] = { fpu_d22, fpu_d23, LLDB_INVALID_REGNUM };
+static uint32_t g_q12_contains[] = { fpu_d24, fpu_d25, LLDB_INVALID_REGNUM };
+static uint32_t g_q13_contains[] = { fpu_d26, fpu_d27, LLDB_INVALID_REGNUM };
+static uint32_t g_q14_contains[] = { fpu_d28, fpu_d29, LLDB_INVALID_REGNUM };
+static uint32_t g_q15_contains[] = { fpu_d30, fpu_d31, LLDB_INVALID_REGNUM };
+
static RegisterInfo g_register_infos_arm[] = {
-// General purpose registers
-// NAME ALT SZ OFFSET ENCODING FORMAT COMPILER DWARF GENERIC GDB LLDB NATIVE VALUE REGS INVALIDATE REGS
-// ====== ======= == ============= ============= ============ =============== =============== ========================= ===================== ============= ========== ===============
-{ "r0", NULL, 4, GPR_OFFSET(0), eEncodingUint, eFormatHex, { gcc_r0, dwarf_r0, LLDB_REGNUM_GENERIC_ARG1, gdb_arm_r0, gpr_r0 }, NULL, NULL},
-{ "r1", NULL, 4, GPR_OFFSET(1), eEncodingUint, eFormatHex, { gcc_r1, dwarf_r1, LLDB_REGNUM_GENERIC_ARG2, gdb_arm_r1, gpr_r1 }, NULL, NULL},
-{ "r2", NULL, 4, GPR_OFFSET(2), eEncodingUint, eFormatHex, { gcc_r2, dwarf_r2, LLDB_REGNUM_GENERIC_ARG3, gdb_arm_r2, gpr_r2 }, NULL, NULL},
-{ "r3", NULL, 4, GPR_OFFSET(3), eEncodingUint, eFormatHex, { gcc_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG4, gdb_arm_r3, gpr_r3 }, NULL, NULL},
-{ "r4", NULL, 4, GPR_OFFSET(4), eEncodingUint, eFormatHex, { gcc_r4, dwarf_r4, LLDB_INVALID_REGNUM, gdb_arm_r4, gpr_r4 }, NULL, NULL},
-{ "r5", NULL, 4, GPR_OFFSET(5), eEncodingUint, eFormatHex, { gcc_r5, dwarf_r5, LLDB_INVALID_REGNUM, gdb_arm_r5, gpr_r5 }, NULL, NULL},
-{ "r6", NULL, 4, GPR_OFFSET(6), eEncodingUint, eFormatHex, { gcc_r6, dwarf_r6, LLDB_INVALID_REGNUM, gdb_arm_r6, gpr_r6 }, NULL, NULL},
-{ "r7", NULL, 4, GPR_OFFSET(7), eEncodingUint, eFormatHex, { gcc_r7, dwarf_r7, LLDB_INVALID_REGNUM, gdb_arm_r7, gpr_r7 }, NULL, NULL},
-{ "r8", NULL, 4, GPR_OFFSET(8), eEncodingUint, eFormatHex, { gcc_r8, dwarf_r8, LLDB_INVALID_REGNUM, gdb_arm_r8, gpr_r8 }, NULL, NULL},
-{ "r9", NULL, 4, GPR_OFFSET(9), eEncodingUint, eFormatHex, { gcc_r9, dwarf_r9, LLDB_INVALID_REGNUM, gdb_arm_r9, gpr_r9 }, NULL, NULL},
-{ "r10", NULL, 4, GPR_OFFSET(10), eEncodingUint, eFormatHex, { gcc_r10, dwarf_r10, LLDB_INVALID_REGNUM, gdb_arm_r10, gpr_r10 }, NULL, NULL},
-{ "r11", NULL, 4, GPR_OFFSET(11), eEncodingUint, eFormatHex, { gcc_r11, dwarf_r11, LLDB_REGNUM_GENERIC_FP, gdb_arm_r11, gpr_r11 }, NULL, NULL},
-{ "r12", NULL, 4, GPR_OFFSET(12), eEncodingUint, eFormatHex, { gcc_r12, dwarf_r12, LLDB_INVALID_REGNUM, gdb_arm_r12, gpr_r12 }, NULL, NULL},
-{ "sp", "r13", 4, GPR_OFFSET(13), eEncodingUint, eFormatHex, { gcc_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, gdb_arm_sp, gpr_sp }, NULL, NULL},
-{ "lr", "r14", 4, GPR_OFFSET(14), eEncodingUint, eFormatHex, { gcc_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, gdb_arm_lr, gpr_lr }, NULL, NULL},
-{ "pc", "r15", 4, GPR_OFFSET(15), eEncodingUint, eFormatHex, { gcc_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, gdb_arm_pc, gpr_pc }, NULL, NULL},
-{ "cpsr", "psr", 4, GPR_OFFSET(16), eEncodingUint, eFormatHex, { gcc_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS, gdb_arm_cpsr, gpr_cpsr }, NULL, NULL},
-
-{ "s0", NULL, 4, FPU_OFFSET(0), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, gdb_arm_s0, fpu_s0 }, NULL, NULL},
-{ "s1", NULL, 4, FPU_OFFSET(1), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, gdb_arm_s1, fpu_s1 }, NULL, NULL},
-{ "s2", NULL, 4, FPU_OFFSET(2), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, gdb_arm_s2, fpu_s2 }, NULL, NULL},
-{ "s3", NULL, 4, FPU_OFFSET(3), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, gdb_arm_s3, fpu_s3 }, NULL, NULL},
-{ "s4", NULL, 4, FPU_OFFSET(4), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, gdb_arm_s4, fpu_s4 }, NULL, NULL},
-{ "s5", NULL, 4, FPU_OFFSET(5), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, gdb_arm_s5, fpu_s5 }, NULL, NULL},
-{ "s6", NULL, 4, FPU_OFFSET(6), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, gdb_arm_s6, fpu_s6 }, NULL, NULL},
-{ "s7", NULL, 4, FPU_OFFSET(7), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, gdb_arm_s7, fpu_s7 }, NULL, NULL},
-{ "s8", NULL, 4, FPU_OFFSET(8), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, gdb_arm_s8, fpu_s8 }, NULL, NULL},
-{ "s9", NULL, 4, FPU_OFFSET(9), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, gdb_arm_s9, fpu_s9 }, NULL, NULL},
-{ "s10", NULL, 4, FPU_OFFSET(10), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, gdb_arm_s10, fpu_s10 }, NULL, NULL},
-{ "s11", NULL, 4, FPU_OFFSET(11), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, gdb_arm_s11, fpu_s11 }, NULL, NULL},
-{ "s12", NULL, 4, FPU_OFFSET(12), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, gdb_arm_s12, fpu_s12 }, NULL, NULL},
-{ "s13", NULL, 4, FPU_OFFSET(13), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, gdb_arm_s13, fpu_s13 }, NULL, NULL},
-{ "s14", NULL, 4, FPU_OFFSET(14), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, gdb_arm_s14, fpu_s14 }, NULL, NULL},
-{ "s15", NULL, 4, FPU_OFFSET(15), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, gdb_arm_s15, fpu_s15 }, NULL, NULL},
-{ "s16", NULL, 4, FPU_OFFSET(16), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, gdb_arm_s16, fpu_s16 }, NULL, NULL},
-{ "s17", NULL, 4, FPU_OFFSET(17), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, gdb_arm_s17, fpu_s17 }, NULL, NULL},
-{ "s18", NULL, 4, FPU_OFFSET(18), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, gdb_arm_s18, fpu_s18 }, NULL, NULL},
-{ "s19", NULL, 4, FPU_OFFSET(19), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, gdb_arm_s19, fpu_s19 }, NULL, NULL},
-{ "s20", NULL, 4, FPU_OFFSET(20), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, gdb_arm_s20, fpu_s20 }, NULL, NULL},
-{ "s21", NULL, 4, FPU_OFFSET(21), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, gdb_arm_s21, fpu_s21 }, NULL, NULL},
-{ "s22", NULL, 4, FPU_OFFSET(22), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, gdb_arm_s22, fpu_s22 }, NULL, NULL},
-{ "s23", NULL, 4, FPU_OFFSET(23), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, gdb_arm_s23, fpu_s23 }, NULL, NULL},
-{ "s24", NULL, 4, FPU_OFFSET(24), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, gdb_arm_s24, fpu_s24 }, NULL, NULL},
-{ "s25", NULL, 4, FPU_OFFSET(25), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, gdb_arm_s25, fpu_s25 }, NULL, NULL},
-{ "s26", NULL, 4, FPU_OFFSET(26), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, gdb_arm_s26, fpu_s26 }, NULL, NULL},
-{ "s27", NULL, 4, FPU_OFFSET(27), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, gdb_arm_s27, fpu_s27 }, NULL, NULL},
-{ "s28", NULL, 4, FPU_OFFSET(28), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, gdb_arm_s28, fpu_s28 }, NULL, NULL},
-{ "s29", NULL, 4, FPU_OFFSET(29), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, gdb_arm_s29, fpu_s29 }, NULL, NULL},
-{ "s30", NULL, 4, FPU_OFFSET(30), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, gdb_arm_s30, fpu_s30 }, NULL, NULL},
-{ "s31", NULL, 4, FPU_OFFSET(31), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, gdb_arm_s31, fpu_s31 }, NULL, NULL},
-{ "fpscr", NULL, 4, FPU_OFFSET(32), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM, gdb_arm_fpscr, fpu_fpscr }, NULL, NULL},
-
-{ "exception",NULL, 4, EXC_OFFSET(0), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_exception }, NULL, NULL},
-{ "fsr", NULL, 4, EXC_OFFSET(1), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_fsr }, NULL, NULL},
-{ "far", NULL, 4, EXC_OFFSET(2), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_far }, NULL, NULL},
+// NAME ALT SZ OFFSET ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB NATIVE VALUE REGS INVALIDATE REGS
+// =========== ======= == ============== ================ ==================== =================== =================== ========================== =================== ============= ============== =================
+{ "r0", nullptr, 4, GPR_OFFSET(0), eEncodingUint, eFormatHex, { ehframe_r0, dwarf_r0, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, gpr_r0 }, nullptr, nullptr },
+{ "r1", nullptr, 4, GPR_OFFSET(1), eEncodingUint, eFormatHex, { ehframe_r1, dwarf_r1, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, gpr_r1 }, nullptr, nullptr },
+{ "r2", nullptr, 4, GPR_OFFSET(2), eEncodingUint, eFormatHex, { ehframe_r2, dwarf_r2, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, gpr_r2 }, nullptr, nullptr },
+{ "r3", nullptr, 4, GPR_OFFSET(3), eEncodingUint, eFormatHex, { ehframe_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, gpr_r3 }, nullptr, nullptr },
+{ "r4", nullptr, 4, GPR_OFFSET(4), eEncodingUint, eFormatHex, { ehframe_r4, dwarf_r4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r4 }, nullptr, nullptr },
+{ "r5", nullptr, 4, GPR_OFFSET(5), eEncodingUint, eFormatHex, { ehframe_r5, dwarf_r5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r5 }, nullptr, nullptr },
+{ "r6", nullptr, 4, GPR_OFFSET(6), eEncodingUint, eFormatHex, { ehframe_r6, dwarf_r6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r6 }, nullptr, nullptr },
+{ "r7", nullptr, 4, GPR_OFFSET(7), eEncodingUint, eFormatHex, { ehframe_r7, dwarf_r7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r7 }, nullptr, nullptr },
+{ "r8", nullptr, 4, GPR_OFFSET(8), eEncodingUint, eFormatHex, { ehframe_r8, dwarf_r8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r8 }, nullptr, nullptr },
+{ "r9", nullptr, 4, GPR_OFFSET(9), eEncodingUint, eFormatHex, { ehframe_r9, dwarf_r9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r9 }, nullptr, nullptr },
+{ "r10", nullptr, 4, GPR_OFFSET(10), eEncodingUint, eFormatHex, { ehframe_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r10 }, nullptr, nullptr },
+{ "r11", nullptr, 4, GPR_OFFSET(11), eEncodingUint, eFormatHex, { ehframe_r11, dwarf_r11, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, gpr_r11 }, nullptr, nullptr },
+{ "r12", nullptr, 4, GPR_OFFSET(12), eEncodingUint, eFormatHex, { ehframe_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r12 }, nullptr, nullptr },
+{ "sp", "r13", 4, GPR_OFFSET(13), eEncodingUint, eFormatHex, { ehframe_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, gpr_sp }, nullptr, nullptr },
+{ "lr", "r14", 4, GPR_OFFSET(14), eEncodingUint, eFormatHex, { ehframe_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM, gpr_lr }, nullptr, nullptr },
+{ "pc", "r15", 4, GPR_OFFSET(15), eEncodingUint, eFormatHex, { ehframe_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, gpr_pc }, nullptr, nullptr },
+{ "cpsr", "psr", 4, GPR_OFFSET(16), eEncodingUint, eFormatHex, { ehframe_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, gpr_cpsr }, nullptr, nullptr },
+
+{ "s0", nullptr, 4, FPU_OFFSET(0), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s0 }, nullptr, g_s0_invalidates },
+{ "s1", nullptr, 4, FPU_OFFSET(1), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s1 }, nullptr, g_s1_invalidates },
+{ "s2", nullptr, 4, FPU_OFFSET(2), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s2 }, nullptr, g_s2_invalidates },
+{ "s3", nullptr, 4, FPU_OFFSET(3), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s3 }, nullptr, g_s3_invalidates },
+{ "s4", nullptr, 4, FPU_OFFSET(4), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s4 }, nullptr, g_s4_invalidates },
+{ "s5", nullptr, 4, FPU_OFFSET(5), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s5 }, nullptr, g_s5_invalidates },
+{ "s6", nullptr, 4, FPU_OFFSET(6), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s6 }, nullptr, g_s6_invalidates },
+{ "s7", nullptr, 4, FPU_OFFSET(7), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s7 }, nullptr, g_s7_invalidates },
+{ "s8", nullptr, 4, FPU_OFFSET(8), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s8 }, nullptr, g_s8_invalidates },
+{ "s9", nullptr, 4, FPU_OFFSET(9), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s9 }, nullptr, g_s9_invalidates },
+{ "s10", nullptr, 4, FPU_OFFSET(10), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s10 }, nullptr, g_s10_invalidates },
+{ "s11", nullptr, 4, FPU_OFFSET(11), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s11 }, nullptr, g_s11_invalidates },
+{ "s12", nullptr, 4, FPU_OFFSET(12), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s12 }, nullptr, g_s12_invalidates },
+{ "s13", nullptr, 4, FPU_OFFSET(13), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s13 }, nullptr, g_s13_invalidates },
+{ "s14", nullptr, 4, FPU_OFFSET(14), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s14 }, nullptr, g_s14_invalidates },
+{ "s15", nullptr, 4, FPU_OFFSET(15), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s15 }, nullptr, g_s15_invalidates },
+{ "s16", nullptr, 4, FPU_OFFSET(16), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s16 }, nullptr, g_s16_invalidates },
+{ "s17", nullptr, 4, FPU_OFFSET(17), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s17 }, nullptr, g_s17_invalidates },
+{ "s18", nullptr, 4, FPU_OFFSET(18), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s18 }, nullptr, g_s18_invalidates },
+{ "s19", nullptr, 4, FPU_OFFSET(19), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s19 }, nullptr, g_s19_invalidates },
+{ "s20", nullptr, 4, FPU_OFFSET(20), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s20 }, nullptr, g_s20_invalidates },
+{ "s21", nullptr, 4, FPU_OFFSET(21), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s21 }, nullptr, g_s21_invalidates },
+{ "s22", nullptr, 4, FPU_OFFSET(22), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s22 }, nullptr, g_s22_invalidates },
+{ "s23", nullptr, 4, FPU_OFFSET(23), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s23 }, nullptr, g_s23_invalidates },
+{ "s24", nullptr, 4, FPU_OFFSET(24), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s24 }, nullptr, g_s24_invalidates },
+{ "s25", nullptr, 4, FPU_OFFSET(25), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s25 }, nullptr, g_s25_invalidates },
+{ "s26", nullptr, 4, FPU_OFFSET(26), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s26 }, nullptr, g_s26_invalidates },
+{ "s27", nullptr, 4, FPU_OFFSET(27), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s27 }, nullptr, g_s27_invalidates },
+{ "s28", nullptr, 4, FPU_OFFSET(28), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s28 }, nullptr, g_s28_invalidates },
+{ "s29", nullptr, 4, FPU_OFFSET(29), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s29 }, nullptr, g_s29_invalidates },
+{ "s30", nullptr, 4, FPU_OFFSET(30), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s30 }, nullptr, g_s30_invalidates },
+{ "s31", nullptr, 4, FPU_OFFSET(31), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_s31 }, nullptr, g_s31_invalidates },
+{ "fpscr", nullptr, 4, FPSCR_OFFSET, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_fpscr }, nullptr, nullptr },
+
+{ "d0", nullptr, 8, FPU_OFFSET(0), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d0 }, g_d0_contains, g_d0_invalidates },
+{ "d1", nullptr, 8, FPU_OFFSET(2), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d1 }, g_d1_contains, g_d1_invalidates },
+{ "d2", nullptr, 8, FPU_OFFSET(4), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d2 }, g_d2_contains, g_d2_invalidates },
+{ "d3", nullptr, 8, FPU_OFFSET(6), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d3 }, g_d3_contains, g_d3_invalidates },
+{ "d4", nullptr, 8, FPU_OFFSET(8), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d4 }, g_d4_contains, g_d4_invalidates },
+{ "d5", nullptr, 8, FPU_OFFSET(10), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d5 }, g_d5_contains, g_d5_invalidates },
+{ "d6", nullptr, 8, FPU_OFFSET(12), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d6 }, g_d6_contains, g_d6_invalidates },
+{ "d7", nullptr, 8, FPU_OFFSET(14), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d7 }, g_d7_contains, g_d7_invalidates },
+{ "d8", nullptr, 8, FPU_OFFSET(16), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d8 }, g_d8_contains, g_d8_invalidates },
+{ "d9", nullptr, 8, FPU_OFFSET(18), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d9 }, g_d9_contains, g_d9_invalidates },
+{ "d10", nullptr, 8, FPU_OFFSET(20), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d10 }, g_d10_contains, g_d10_invalidates },
+{ "d11", nullptr, 8, FPU_OFFSET(22), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d11 }, g_d11_contains, g_d11_invalidates },
+{ "d12", nullptr, 8, FPU_OFFSET(24), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d12 }, g_d12_contains, g_d12_invalidates },
+{ "d13", nullptr, 8, FPU_OFFSET(26), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d13 }, g_d13_contains, g_d13_invalidates },
+{ "d14", nullptr, 8, FPU_OFFSET(28), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d14 }, g_d14_contains, g_d14_invalidates },
+{ "d15", nullptr, 8, FPU_OFFSET(30), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d15 }, g_d15_contains, g_d15_invalidates },
+{ "d16", nullptr, 8, FPU_OFFSET(32), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d16 }, nullptr, g_d16_invalidates },
+{ "d17", nullptr, 8, FPU_OFFSET(34), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d17 }, nullptr, g_d17_invalidates },
+{ "d18", nullptr, 8, FPU_OFFSET(36), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d18 }, nullptr, g_d18_invalidates },
+{ "d19", nullptr, 8, FPU_OFFSET(38), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d19 }, nullptr, g_d19_invalidates },
+{ "d20", nullptr, 8, FPU_OFFSET(40), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d20 }, nullptr, g_d20_invalidates },
+{ "d21", nullptr, 8, FPU_OFFSET(42), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d21 }, nullptr, g_d21_invalidates },
+{ "d22", nullptr, 8, FPU_OFFSET(44), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d22 }, nullptr, g_d22_invalidates },
+{ "d23", nullptr, 8, FPU_OFFSET(46), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d23 }, nullptr, g_d23_invalidates },
+{ "d24", nullptr, 8, FPU_OFFSET(48), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d24 }, nullptr, g_d24_invalidates },
+{ "d25", nullptr, 8, FPU_OFFSET(50), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d25 }, nullptr, g_d25_invalidates },
+{ "d26", nullptr, 8, FPU_OFFSET(52), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d26 }, nullptr, g_d26_invalidates },
+{ "d27", nullptr, 8, FPU_OFFSET(54), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d27 }, nullptr, g_d27_invalidates },
+{ "d28", nullptr, 8, FPU_OFFSET(56), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d28 }, nullptr, g_d28_invalidates },
+{ "d29", nullptr, 8, FPU_OFFSET(58), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d29 }, nullptr, g_d29_invalidates },
+{ "d30", nullptr, 8, FPU_OFFSET(60), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d30 }, nullptr, g_d30_invalidates },
+{ "d31", nullptr, 8, FPU_OFFSET(62), eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_d31 }, nullptr, g_d31_invalidates },
+
+{ "q0", nullptr, 16, FPU_OFFSET(0), eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_q0 }, g_q0_contains, nullptr, },
+{ "q1", nullptr, 16, FPU_OFFSET(4), eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_q1 }, g_q1_contains, nullptr, },
+{ "q2", nullptr, 16, FPU_OFFSET(8), eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_q2 }, g_q2_contains, nullptr, },
+{ "q3", nullptr, 16, FPU_OFFSET(12), eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_q3 }, g_q3_contains, nullptr, },
+{ "q4", nullptr, 16, FPU_OFFSET(16), eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_q4 }, g_q4_contains, nullptr, },
+{ "q5", nullptr, 16, FPU_OFFSET(20), eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_q5 }, g_q5_contains, nullptr, },
+{ "q6", nullptr, 16, FPU_OFFSET(24), eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_q6 }, g_q6_contains, nullptr, },
+{ "q7", nullptr, 16, FPU_OFFSET(28), eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_q7 }, g_q7_contains, nullptr, },
+{ "q8", nullptr, 16, FPU_OFFSET(32), eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_q8 }, g_q8_contains, nullptr, },
+{ "q9", nullptr, 16, FPU_OFFSET(36), eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_q9 }, g_q9_contains, nullptr, },
+{ "q10", nullptr, 16, FPU_OFFSET(40), eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_q10 }, g_q10_contains, nullptr, },
+{ "q11", nullptr, 16, FPU_OFFSET(44), eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_q11 }, g_q11_contains, nullptr, },
+{ "q12", nullptr, 16, FPU_OFFSET(48), eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_q12 }, g_q12_contains, nullptr, },
+{ "q13", nullptr, 16, FPU_OFFSET(52), eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_q13 }, g_q13_contains, nullptr, },
+{ "q14", nullptr, 16, FPU_OFFSET(56), eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_q14 }, g_q14_contains, nullptr, },
+{ "q15", nullptr, 16, FPU_OFFSET(60), eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_q15 }, g_q15_contains, nullptr, },
+
+{ "exception", nullptr, 4, EXC_OFFSET(0), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_exception }, nullptr, nullptr },
+{ "fsr", nullptr, 4, EXC_OFFSET(1), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_fsr }, nullptr, nullptr },
+{ "far", nullptr, 4, EXC_OFFSET(2), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_far }, nullptr, nullptr },
{ DEFINE_DBG (bvr, 0) },
{ DEFINE_DBG (bvr, 1) },
diff --git a/source/Plugins/Process/Utility/RegisterInfos_arm64.h b/source/Plugins/Process/Utility/RegisterInfos_arm64.h
index 0255a3bc7d60..715321149a73 100644
--- a/source/Plugins/Process/Utility/RegisterInfos_arm64.h
+++ b/source/Plugins/Process/Utility/RegisterInfos_arm64.h
@@ -1,22 +1,26 @@
-//===-- RegisterInfos_arm64.h ----------------------------------*- C++ -*-===//
+//===-- 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.
//
-//===---------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
#ifdef DECLARE_REGISTER_INFOS_ARM64_STRUCT
+// C Includes
#include <stddef.h>
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-enumerations.h"
-#include "Utility/ARM64_GCC_Registers.h"
#include "Utility/ARM64_DWARF_Registers.h"
+#include "Utility/ARM64_ehframe_Registers.h"
#ifndef GPR_OFFSET
#error GPR_OFFSET must be defined before including this header file
@@ -196,84 +200,84 @@ enum
static lldb_private::RegisterInfo g_register_infos_arm64[] = {
// General purpose registers
-// NAME ALT SZ OFFSET ENCODING FORMAT COMPILER DWARF GENERIC GDB LLDB NATIVE VALUE REGS INVALIDATE REGS
-// ====== ======= == ============= ============= ============ =============== =============== ========================= ===================== ============= ========== ===============
-{ "x0", NULL, 8, GPR_OFFSET(0), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x0, arm64_dwarf::x0, LLDB_REGNUM_GENERIC_ARG1, arm64_gcc::x0, gpr_x0 }, NULL, NULL},
-{ "x1", NULL, 8, GPR_OFFSET(1), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x1, arm64_dwarf::x1, LLDB_REGNUM_GENERIC_ARG2, arm64_gcc::x1, gpr_x1 }, NULL, NULL},
-{ "x2", NULL, 8, GPR_OFFSET(2), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x2, arm64_dwarf::x2, LLDB_REGNUM_GENERIC_ARG3, arm64_gcc::x2, gpr_x2 }, NULL, NULL},
-{ "x3", NULL, 8, GPR_OFFSET(3), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x3, arm64_dwarf::x3, LLDB_REGNUM_GENERIC_ARG4, arm64_gcc::x3, gpr_x3 }, NULL, NULL},
-{ "x4", NULL, 8, GPR_OFFSET(4), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x4, arm64_dwarf::x4, LLDB_REGNUM_GENERIC_ARG5, arm64_gcc::x4, gpr_x4 }, NULL, NULL},
-{ "x5", NULL, 8, GPR_OFFSET(5), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x5, arm64_dwarf::x5, LLDB_REGNUM_GENERIC_ARG6, arm64_gcc::x5, gpr_x5 }, NULL, NULL},
-{ "x6", NULL, 8, GPR_OFFSET(6), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x6, arm64_dwarf::x6, LLDB_REGNUM_GENERIC_ARG7, arm64_gcc::x6, gpr_x6 }, NULL, NULL},
-{ "x7", NULL, 8, GPR_OFFSET(7), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x7, arm64_dwarf::x7, LLDB_REGNUM_GENERIC_ARG8, arm64_gcc::x7, gpr_x7 }, NULL, NULL},
-{ "x8", NULL, 8, GPR_OFFSET(8), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x8, arm64_dwarf::x8, LLDB_INVALID_REGNUM, arm64_gcc::x8, gpr_x8 }, NULL, NULL},
-{ "x9", NULL, 8, GPR_OFFSET(9), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x9, arm64_dwarf::x9, LLDB_INVALID_REGNUM, arm64_gcc::x9, gpr_x9 }, NULL, NULL},
-{ "x10", NULL, 8, GPR_OFFSET(10), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x10, arm64_dwarf::x10, LLDB_INVALID_REGNUM, arm64_gcc::x10, gpr_x10 }, NULL, NULL},
-{ "x11", NULL, 8, GPR_OFFSET(11), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x11, arm64_dwarf::x11, LLDB_INVALID_REGNUM, arm64_gcc::x11, gpr_x11 }, NULL, NULL},
-{ "x12", NULL, 8, GPR_OFFSET(12), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x12, arm64_dwarf::x12, LLDB_INVALID_REGNUM, arm64_gcc::x12, gpr_x12 }, NULL, NULL},
-{ "x13", NULL, 8, GPR_OFFSET(13), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x13, arm64_dwarf::x13, LLDB_INVALID_REGNUM, arm64_gcc::x13, gpr_x13 }, NULL, NULL},
-{ "x14", NULL, 8, GPR_OFFSET(14), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x14, arm64_dwarf::x14, LLDB_INVALID_REGNUM, arm64_gcc::x14, gpr_x14 }, NULL, NULL},
-{ "x15", NULL, 8, GPR_OFFSET(15), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x15, arm64_dwarf::x15, LLDB_INVALID_REGNUM, arm64_gcc::x15, gpr_x15 }, NULL, NULL},
-{ "x16", NULL, 8, GPR_OFFSET(16), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x16, arm64_dwarf::x16, LLDB_INVALID_REGNUM, arm64_gcc::x16, gpr_x16 }, NULL, NULL},
-{ "x17", NULL, 8, GPR_OFFSET(17), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x17, arm64_dwarf::x17, LLDB_INVALID_REGNUM, arm64_gcc::x17, gpr_x17 }, NULL, NULL},
-{ "x18", NULL, 8, GPR_OFFSET(18), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x18, arm64_dwarf::x18, LLDB_INVALID_REGNUM, arm64_gcc::x18, gpr_x18 }, NULL, NULL},
-{ "x19", NULL, 8, GPR_OFFSET(19), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x19, arm64_dwarf::x19, LLDB_INVALID_REGNUM, arm64_gcc::x19, gpr_x19 }, NULL, NULL},
-{ "x20", NULL, 8, GPR_OFFSET(20), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x20, arm64_dwarf::x20, LLDB_INVALID_REGNUM, arm64_gcc::x20, gpr_x20 }, NULL, NULL},
-{ "x21", NULL, 8, GPR_OFFSET(21), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x21, arm64_dwarf::x21, LLDB_INVALID_REGNUM, arm64_gcc::x21, gpr_x21 }, NULL, NULL},
-{ "x22", NULL, 8, GPR_OFFSET(22), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x22, arm64_dwarf::x22, LLDB_INVALID_REGNUM, arm64_gcc::x22, gpr_x22 }, NULL, NULL},
-{ "x23", NULL, 8, GPR_OFFSET(23), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x23, arm64_dwarf::x23, LLDB_INVALID_REGNUM, arm64_gcc::x23, gpr_x23 }, NULL, NULL},
-{ "x24", NULL, 8, GPR_OFFSET(24), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x24, arm64_dwarf::x24, LLDB_INVALID_REGNUM, arm64_gcc::x24, gpr_x24 }, NULL, NULL},
-{ "x25", NULL, 8, GPR_OFFSET(25), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x25, arm64_dwarf::x25, LLDB_INVALID_REGNUM, arm64_gcc::x25, gpr_x25 }, NULL, NULL},
-{ "x26", NULL, 8, GPR_OFFSET(26), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x26, arm64_dwarf::x26, LLDB_INVALID_REGNUM, arm64_gcc::x26, gpr_x26 }, NULL, NULL},
-{ "x27", NULL, 8, GPR_OFFSET(27), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x27, arm64_dwarf::x27, LLDB_INVALID_REGNUM, arm64_gcc::x27, gpr_x27 }, NULL, NULL},
-{ "x28", NULL, 8, GPR_OFFSET(28), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::x28, arm64_dwarf::x28, LLDB_INVALID_REGNUM, arm64_gcc::x28, gpr_x28 }, NULL, NULL},
+// NAME ALT SZ OFFSET ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB NATIVE VALUE REGS INVALIDATE REGS
+// ====== ======= == ============= ============= ============ =============== =============== ========================= ===================== ============= ========== ===============
+{ "x0", nullptr, 8, GPR_OFFSET(0), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x0, arm64_dwarf::x0, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, gpr_x0 }, nullptr, nullptr},
+{ "x1", nullptr, 8, GPR_OFFSET(1), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x1, arm64_dwarf::x1, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, gpr_x1 }, nullptr, nullptr},
+{ "x2", nullptr, 8, GPR_OFFSET(2), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x2, arm64_dwarf::x2, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, gpr_x2 }, nullptr, nullptr},
+{ "x3", nullptr, 8, GPR_OFFSET(3), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x3, arm64_dwarf::x3, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, gpr_x3 }, nullptr, nullptr},
+{ "x4", nullptr, 8, GPR_OFFSET(4), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x4, arm64_dwarf::x4, LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM, gpr_x4 }, nullptr, nullptr},
+{ "x5", nullptr, 8, GPR_OFFSET(5), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x5, arm64_dwarf::x5, LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM, gpr_x5 }, nullptr, nullptr},
+{ "x6", nullptr, 8, GPR_OFFSET(6), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x6, arm64_dwarf::x6, LLDB_REGNUM_GENERIC_ARG7, LLDB_INVALID_REGNUM, gpr_x6 }, nullptr, nullptr},
+{ "x7", nullptr, 8, GPR_OFFSET(7), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x7, arm64_dwarf::x7, LLDB_REGNUM_GENERIC_ARG8, LLDB_INVALID_REGNUM, gpr_x7 }, nullptr, nullptr},
+{ "x8", nullptr, 8, GPR_OFFSET(8), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x8, arm64_dwarf::x8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_x8 }, nullptr, nullptr},
+{ "x9", nullptr, 8, GPR_OFFSET(9), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x9, arm64_dwarf::x9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_x9 }, nullptr, nullptr},
+{ "x10", nullptr, 8, GPR_OFFSET(10), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x10, arm64_dwarf::x10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_x10 }, nullptr, nullptr},
+{ "x11", nullptr, 8, GPR_OFFSET(11), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x11, arm64_dwarf::x11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_x11 }, nullptr, nullptr},
+{ "x12", nullptr, 8, GPR_OFFSET(12), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x12, arm64_dwarf::x12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_x12 }, nullptr, nullptr},
+{ "x13", nullptr, 8, GPR_OFFSET(13), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x13, arm64_dwarf::x13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_x13 }, nullptr, nullptr},
+{ "x14", nullptr, 8, GPR_OFFSET(14), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x14, arm64_dwarf::x14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_x14 }, nullptr, nullptr},
+{ "x15", nullptr, 8, GPR_OFFSET(15), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x15, arm64_dwarf::x15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_x15 }, nullptr, nullptr},
+{ "x16", nullptr, 8, GPR_OFFSET(16), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x16, arm64_dwarf::x16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_x16 }, nullptr, nullptr},
+{ "x17", nullptr, 8, GPR_OFFSET(17), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x17, arm64_dwarf::x17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_x17 }, nullptr, nullptr},
+{ "x18", nullptr, 8, GPR_OFFSET(18), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x18, arm64_dwarf::x18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_x18 }, nullptr, nullptr},
+{ "x19", nullptr, 8, GPR_OFFSET(19), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x19, arm64_dwarf::x19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_x19 }, nullptr, nullptr},
+{ "x20", nullptr, 8, GPR_OFFSET(20), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x20, arm64_dwarf::x20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_x20 }, nullptr, nullptr},
+{ "x21", nullptr, 8, GPR_OFFSET(21), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x21, arm64_dwarf::x21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_x21 }, nullptr, nullptr},
+{ "x22", nullptr, 8, GPR_OFFSET(22), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x22, arm64_dwarf::x22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_x22 }, nullptr, nullptr},
+{ "x23", nullptr, 8, GPR_OFFSET(23), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x23, arm64_dwarf::x23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_x23 }, nullptr, nullptr},
+{ "x24", nullptr, 8, GPR_OFFSET(24), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x24, arm64_dwarf::x24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_x24 }, nullptr, nullptr},
+{ "x25", nullptr, 8, GPR_OFFSET(25), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x25, arm64_dwarf::x25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_x25 }, nullptr, nullptr},
+{ "x26", nullptr, 8, GPR_OFFSET(26), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x26, arm64_dwarf::x26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_x26 }, nullptr, nullptr},
+{ "x27", nullptr, 8, GPR_OFFSET(27), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x27, arm64_dwarf::x27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_x27 }, nullptr, nullptr},
+{ "x28", nullptr, 8, GPR_OFFSET(28), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::x28, arm64_dwarf::x28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_x28 }, nullptr, nullptr},
-{ "fp", "x29", 8, GPR_OFFSET(29), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::fp, arm64_dwarf::fp, LLDB_REGNUM_GENERIC_FP, arm64_gcc::fp, gpr_fp }, NULL, NULL},
-{ "lr", "x30", 8, GPR_OFFSET(30), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::lr, arm64_dwarf::lr, LLDB_REGNUM_GENERIC_RA, arm64_gcc::lr, gpr_lr }, NULL, NULL},
-{ "sp", "x31", 8, GPR_OFFSET(31), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::sp, arm64_dwarf::sp, LLDB_REGNUM_GENERIC_SP, arm64_gcc::sp, gpr_sp }, NULL, NULL},
-{ "pc", NULL, 8, GPR_OFFSET(32), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::pc, arm64_dwarf::pc, LLDB_REGNUM_GENERIC_PC, arm64_gcc::pc, gpr_pc }, NULL, NULL},
+{ "fp", "x29", 8, GPR_OFFSET(29), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::fp, arm64_dwarf::fp, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, gpr_fp }, nullptr, nullptr},
+{ "lr", "x30", 8, GPR_OFFSET(30), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::lr, arm64_dwarf::lr, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM, gpr_lr }, nullptr, nullptr},
+{ "sp", "x31", 8, GPR_OFFSET(31), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::sp, arm64_dwarf::sp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, gpr_sp }, nullptr, nullptr},
+{ "pc", nullptr, 8, GPR_OFFSET(32), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::pc, arm64_dwarf::pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, gpr_pc }, nullptr, nullptr},
-{ "cpsr", NULL, 4, GPR_OFFSET_NAME(cpsr), lldb::eEncodingUint, lldb::eFormatHex, { arm64_gcc::cpsr, arm64_dwarf::cpsr, LLDB_REGNUM_GENERIC_FLAGS, arm64_gcc::cpsr, gpr_cpsr }, NULL, NULL},
+{ "cpsr", nullptr, 4, GPR_OFFSET_NAME(cpsr), lldb::eEncodingUint, lldb::eFormatHex, { arm64_ehframe::cpsr, arm64_dwarf::cpsr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, gpr_cpsr }, nullptr, nullptr},
-{ "v0", NULL, 16, FPU_OFFSET(0), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v0, LLDB_INVALID_REGNUM, arm64_gcc::v0, fpu_v0 }, NULL, NULL},
-{ "v1", NULL, 16, FPU_OFFSET(1), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v1, LLDB_INVALID_REGNUM, arm64_gcc::v1, fpu_v1 }, NULL, NULL},
-{ "v2", NULL, 16, FPU_OFFSET(2), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v2, LLDB_INVALID_REGNUM, arm64_gcc::v2, fpu_v2 }, NULL, NULL},
-{ "v3", NULL, 16, FPU_OFFSET(3), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v3, LLDB_INVALID_REGNUM, arm64_gcc::v3, fpu_v3 }, NULL, NULL},
-{ "v4", NULL, 16, FPU_OFFSET(4), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v4, LLDB_INVALID_REGNUM, arm64_gcc::v4, fpu_v4 }, NULL, NULL},
-{ "v5", NULL, 16, FPU_OFFSET(5), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v5, LLDB_INVALID_REGNUM, arm64_gcc::v5, fpu_v5 }, NULL, NULL},
-{ "v6", NULL, 16, FPU_OFFSET(6), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v6, LLDB_INVALID_REGNUM, arm64_gcc::v6, fpu_v6 }, NULL, NULL},
-{ "v7", NULL, 16, FPU_OFFSET(7), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v7, LLDB_INVALID_REGNUM, arm64_gcc::v7, fpu_v7 }, NULL, NULL},
-{ "v8", NULL, 16, FPU_OFFSET(8), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v8, LLDB_INVALID_REGNUM, arm64_gcc::v8, fpu_v8 }, NULL, NULL},
-{ "v9", NULL, 16, FPU_OFFSET(9), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v9, LLDB_INVALID_REGNUM, arm64_gcc::v9, fpu_v9 }, NULL, NULL},
-{ "v10", NULL, 16, FPU_OFFSET(10), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v10, LLDB_INVALID_REGNUM, arm64_gcc::v10, fpu_v10 }, NULL, NULL},
-{ "v11", NULL, 16, FPU_OFFSET(11), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v11, LLDB_INVALID_REGNUM, arm64_gcc::v11, fpu_v11 }, NULL, NULL},
-{ "v12", NULL, 16, FPU_OFFSET(12), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v12, LLDB_INVALID_REGNUM, arm64_gcc::v12, fpu_v12 }, NULL, NULL},
-{ "v13", NULL, 16, FPU_OFFSET(13), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v13, LLDB_INVALID_REGNUM, arm64_gcc::v13, fpu_v13 }, NULL, NULL},
-{ "v14", NULL, 16, FPU_OFFSET(14), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v14, LLDB_INVALID_REGNUM, arm64_gcc::v14, fpu_v14 }, NULL, NULL},
-{ "v15", NULL, 16, FPU_OFFSET(15), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v15, LLDB_INVALID_REGNUM, arm64_gcc::v15, fpu_v15 }, NULL, NULL},
-{ "v16", NULL, 16, FPU_OFFSET(16), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v16, LLDB_INVALID_REGNUM, arm64_gcc::v16, fpu_v16 }, NULL, NULL},
-{ "v17", NULL, 16, FPU_OFFSET(17), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v17, LLDB_INVALID_REGNUM, arm64_gcc::v17, fpu_v17 }, NULL, NULL},
-{ "v18", NULL, 16, FPU_OFFSET(18), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v18, LLDB_INVALID_REGNUM, arm64_gcc::v18, fpu_v18 }, NULL, NULL},
-{ "v19", NULL, 16, FPU_OFFSET(19), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v19, LLDB_INVALID_REGNUM, arm64_gcc::v19, fpu_v19 }, NULL, NULL},
-{ "v20", NULL, 16, FPU_OFFSET(20), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v20, LLDB_INVALID_REGNUM, arm64_gcc::v20, fpu_v20 }, NULL, NULL},
-{ "v21", NULL, 16, FPU_OFFSET(21), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v21, LLDB_INVALID_REGNUM, arm64_gcc::v21, fpu_v21 }, NULL, NULL},
-{ "v22", NULL, 16, FPU_OFFSET(22), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v22, LLDB_INVALID_REGNUM, arm64_gcc::v22, fpu_v22 }, NULL, NULL},
-{ "v23", NULL, 16, FPU_OFFSET(23), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v23, LLDB_INVALID_REGNUM, arm64_gcc::v23, fpu_v23 }, NULL, NULL},
-{ "v24", NULL, 16, FPU_OFFSET(24), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v24, LLDB_INVALID_REGNUM, arm64_gcc::v24, fpu_v24 }, NULL, NULL},
-{ "v25", NULL, 16, FPU_OFFSET(25), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v25, LLDB_INVALID_REGNUM, arm64_gcc::v25, fpu_v25 }, NULL, NULL},
-{ "v26", NULL, 16, FPU_OFFSET(26), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v26, LLDB_INVALID_REGNUM, arm64_gcc::v26, fpu_v26 }, NULL, NULL},
-{ "v27", NULL, 16, FPU_OFFSET(27), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v27, LLDB_INVALID_REGNUM, arm64_gcc::v27, fpu_v27 }, NULL, NULL},
-{ "v28", NULL, 16, FPU_OFFSET(28), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v28, LLDB_INVALID_REGNUM, arm64_gcc::v28, fpu_v28 }, NULL, NULL},
-{ "v29", NULL, 16, FPU_OFFSET(29), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v29, LLDB_INVALID_REGNUM, arm64_gcc::v29, fpu_v29 }, NULL, NULL},
-{ "v30", NULL, 16, FPU_OFFSET(30), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v30, LLDB_INVALID_REGNUM, arm64_gcc::v30, fpu_v30 }, NULL, NULL},
-{ "v31", NULL, 16, FPU_OFFSET(31), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v31, LLDB_INVALID_REGNUM, arm64_gcc::v31, fpu_v31 }, NULL, NULL},
+{ "v0", nullptr, 16, FPU_OFFSET(0), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v0 }, nullptr, nullptr},
+{ "v1", nullptr, 16, FPU_OFFSET(1), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v1 }, nullptr, nullptr},
+{ "v2", nullptr, 16, FPU_OFFSET(2), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v2 }, nullptr, nullptr},
+{ "v3", nullptr, 16, FPU_OFFSET(3), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v3 }, nullptr, nullptr},
+{ "v4", nullptr, 16, FPU_OFFSET(4), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v4 }, nullptr, nullptr},
+{ "v5", nullptr, 16, FPU_OFFSET(5), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v5 }, nullptr, nullptr},
+{ "v6", nullptr, 16, FPU_OFFSET(6), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v6 }, nullptr, nullptr},
+{ "v7", nullptr, 16, FPU_OFFSET(7), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v7 }, nullptr, nullptr},
+{ "v8", nullptr, 16, FPU_OFFSET(8), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v8 }, nullptr, nullptr},
+{ "v9", nullptr, 16, FPU_OFFSET(9), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v9 }, nullptr, nullptr},
+{ "v10", nullptr, 16, FPU_OFFSET(10), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v10 }, nullptr, nullptr},
+{ "v11", nullptr, 16, FPU_OFFSET(11), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v11 }, nullptr, nullptr},
+{ "v12", nullptr, 16, FPU_OFFSET(12), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v12 }, nullptr, nullptr},
+{ "v13", nullptr, 16, FPU_OFFSET(13), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v13 }, nullptr, nullptr},
+{ "v14", nullptr, 16, FPU_OFFSET(14), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v14 }, nullptr, nullptr},
+{ "v15", nullptr, 16, FPU_OFFSET(15), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v15 }, nullptr, nullptr},
+{ "v16", nullptr, 16, FPU_OFFSET(16), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v16 }, nullptr, nullptr},
+{ "v17", nullptr, 16, FPU_OFFSET(17), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v17 }, nullptr, nullptr},
+{ "v18", nullptr, 16, FPU_OFFSET(18), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v18 }, nullptr, nullptr},
+{ "v19", nullptr, 16, FPU_OFFSET(19), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v19 }, nullptr, nullptr},
+{ "v20", nullptr, 16, FPU_OFFSET(20), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v20 }, nullptr, nullptr},
+{ "v21", nullptr, 16, FPU_OFFSET(21), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v21 }, nullptr, nullptr},
+{ "v22", nullptr, 16, FPU_OFFSET(22), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v22 }, nullptr, nullptr},
+{ "v23", nullptr, 16, FPU_OFFSET(23), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v23 }, nullptr, nullptr},
+{ "v24", nullptr, 16, FPU_OFFSET(24), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v24 }, nullptr, nullptr},
+{ "v25", nullptr, 16, FPU_OFFSET(25), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v25 }, nullptr, nullptr},
+{ "v26", nullptr, 16, FPU_OFFSET(26), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v26 }, nullptr, nullptr},
+{ "v27", nullptr, 16, FPU_OFFSET(27), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v27 }, nullptr, nullptr},
+{ "v28", nullptr, 16, FPU_OFFSET(28), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v28 }, nullptr, nullptr},
+{ "v29", nullptr, 16, FPU_OFFSET(29), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v29 }, nullptr, nullptr},
+{ "v30", nullptr, 16, FPU_OFFSET(30), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v30 }, nullptr, nullptr},
+{ "v31", nullptr, 16, FPU_OFFSET(31), lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_v31 }, nullptr, nullptr},
-{ "fpsr", NULL, 4, FPU_OFFSET_NAME(fpsr), lldb::eEncodingUint, lldb::eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_fpsr }, NULL, NULL},
-{ "fpcr", NULL, 4, FPU_OFFSET_NAME(fpcr), lldb::eEncodingUint, lldb::eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_fpcr }, NULL, NULL},
+{ "fpsr", nullptr, 4, FPU_OFFSET_NAME(fpsr), lldb::eEncodingUint, lldb::eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_fpsr }, nullptr, nullptr},
+{ "fpcr", nullptr, 4, FPU_OFFSET_NAME(fpcr), lldb::eEncodingUint, lldb::eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_fpcr }, nullptr, nullptr},
-{ "far", NULL, 8, EXC_OFFSET_NAME(far), lldb::eEncodingUint, lldb::eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_far }, NULL, NULL},
-{ "esr", NULL, 4, EXC_OFFSET_NAME(esr), lldb::eEncodingUint, lldb::eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_esr }, NULL, NULL},
-{ "exception",NULL, 4, EXC_OFFSET_NAME(exception), lldb::eEncodingUint, lldb::eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_exception }, NULL, NULL},
+{ "far", nullptr, 8, EXC_OFFSET_NAME(far), lldb::eEncodingUint, lldb::eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_far }, nullptr, nullptr},
+{ "esr", nullptr, 4, EXC_OFFSET_NAME(esr), lldb::eEncodingUint, lldb::eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_esr }, nullptr, nullptr},
+{ "exception",nullptr, 4, EXC_OFFSET_NAME(exception), lldb::eEncodingUint, lldb::eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_exception }, nullptr, nullptr},
{ DEFINE_DBG (bvr, 0) },
{ DEFINE_DBG (bvr, 1) },
diff --git a/source/Plugins/Process/Utility/RegisterInfos_i386.h b/source/Plugins/Process/Utility/RegisterInfos_i386.h
index 69825362134b..904ec4d1f0bd 100644
--- a/source/Plugins/Process/Utility/RegisterInfos_i386.h
+++ b/source/Plugins/Process/Utility/RegisterInfos_i386.h
@@ -1,15 +1,21 @@
-//===-- RegisterInfos_i386.h -----------------------------------*- C++ -*-===//
+//===-- 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.
//
-//===---------------------------------------------------------------------===//
-#include "llvm/Support/Compiler.h"
+//===----------------------------------------------------------------------===//
+// C Includes
#include <stddef.h>
+// C++ Includes
+// Other libraries and framework includes
+#include "llvm/Support/Compiler.h"
+
+// Project includes
+
#ifdef DECLARE_REGISTER_INFOS_I386_STRUCT
// Computes the offset of the given GPR in the user data area.
@@ -52,31 +58,31 @@
{ #name, NULL, FPR_SIZE(reg), FPR_OFFSET(reg), eEncodingUint, \
eFormatHex, { kind1, kind2, kind3, kind4, lldb_##name##_i386 }, NULL, NULL }
-// RegisterKind: GCC, DWARF, Generic, GDB, LLDB
+// RegisterKind: EHFrame, DWARF, Generic, Process Plugin, LLDB
#define DEFINE_FP_ST(reg, i) \
{ #reg#i, NULL, FP_SIZE, LLVM_EXTENSION FPR_OFFSET(stmm[i]), \
eEncodingVector, eFormatVectorOfUInt8, \
- { gcc_st##i##_i386, dwarf_st##i##_i386, LLDB_INVALID_REGNUM, gdb_st##i##_i386, lldb_st##i##_i386 }, \
+ { ehframe_st##i##_i386, dwarf_st##i##_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_st##i##_i386 }, \
NULL, NULL }
#define DEFINE_FP_MM(reg, i) \
{ #reg#i, NULL, sizeof(uint64_t), LLVM_EXTENSION FPR_OFFSET(stmm[i]), \
eEncodingUint, eFormatHex, \
- { gcc_mm##i##_i386, dwarf_mm##i##_i386, LLDB_INVALID_REGNUM, gdb_mm##i##_i386, lldb_mm##i##_i386 }, \
+ { ehframe_mm##i##_i386, dwarf_mm##i##_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_mm##i##_i386 }, \
NULL, NULL }
#define DEFINE_XMM(reg, i) \
{ #reg#i, NULL, XMM_SIZE, LLVM_EXTENSION FPR_OFFSET(reg[i]), \
eEncodingVector, eFormatVectorOfUInt8, \
- { gcc_##reg##i##_i386, dwarf_##reg##i##_i386, LLDB_INVALID_REGNUM, gdb_##reg##i##_i386, lldb_##reg##i##_i386}, \
+ { ehframe_##reg##i##_i386, dwarf_##reg##i##_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_##reg##i##_i386}, \
NULL, NULL }
// I believe the YMM registers use dwarf_xmm_%_i386 register numbers and then differentiate based on register size.
#define DEFINE_YMM(reg, i) \
{ #reg#i, NULL, YMM_SIZE, LLVM_EXTENSION YMM_OFFSET(i), \
eEncodingVector, eFormatVectorOfUInt8, \
- { LLDB_INVALID_REGNUM, dwarf_xmm##i##_i386, LLDB_INVALID_REGNUM, gdb_##reg##i##h_i386, lldb_##reg##i##_i386 }, \
+ { LLDB_INVALID_REGNUM, dwarf_xmm##i##_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_##reg##i##_i386 }, \
NULL, NULL }
#define DEFINE_DR(reg, i) \
@@ -98,22 +104,22 @@ static RegisterInfo
g_register_infos_i386[] =
{
// General purpose registers.
- DEFINE_GPR(eax, NULL, gcc_eax_i386, dwarf_eax_i386, LLDB_INVALID_REGNUM, gdb_eax_i386),
- DEFINE_GPR(ebx, NULL, gcc_ebx_i386, dwarf_ebx_i386, LLDB_INVALID_REGNUM, gdb_ebx_i386),
- DEFINE_GPR(ecx, NULL, gcc_ecx_i386, dwarf_ecx_i386, LLDB_INVALID_REGNUM, gdb_ecx_i386),
- DEFINE_GPR(edx, NULL, gcc_edx_i386, dwarf_edx_i386, LLDB_INVALID_REGNUM, gdb_edx_i386),
- DEFINE_GPR(edi, NULL, gcc_edi_i386, dwarf_edi_i386, LLDB_INVALID_REGNUM, gdb_edi_i386),
- DEFINE_GPR(esi, NULL, gcc_esi_i386, dwarf_esi_i386, LLDB_INVALID_REGNUM, gdb_esi_i386),
- DEFINE_GPR(ebp, "fp", gcc_ebp_i386, dwarf_ebp_i386, LLDB_REGNUM_GENERIC_FP, gdb_ebp_i386),
- DEFINE_GPR(esp, "sp", gcc_esp_i386, dwarf_esp_i386, LLDB_REGNUM_GENERIC_SP, gdb_esp_i386),
- DEFINE_GPR(eip, "pc", gcc_eip_i386, dwarf_eip_i386, LLDB_REGNUM_GENERIC_PC, gdb_eip_i386),
- DEFINE_GPR(eflags, "flags", gcc_eflags_i386, dwarf_eflags_i386, LLDB_REGNUM_GENERIC_FLAGS, gdb_eflags_i386),
- DEFINE_GPR(cs, NULL, LLDB_INVALID_REGNUM, dwarf_cs_i386, LLDB_INVALID_REGNUM, gdb_cs_i386),
- DEFINE_GPR(fs, NULL, LLDB_INVALID_REGNUM, dwarf_fs_i386, LLDB_INVALID_REGNUM, gdb_fs_i386),
- DEFINE_GPR(gs, NULL, LLDB_INVALID_REGNUM, dwarf_gs_i386, LLDB_INVALID_REGNUM, gdb_gs_i386),
- DEFINE_GPR(ss, NULL, LLDB_INVALID_REGNUM, dwarf_ss_i386, LLDB_INVALID_REGNUM, gdb_ss_i386),
- DEFINE_GPR(ds, NULL, LLDB_INVALID_REGNUM, dwarf_ds_i386, LLDB_INVALID_REGNUM, gdb_ds_i386),
- DEFINE_GPR(es, NULL, LLDB_INVALID_REGNUM, dwarf_es_i386, LLDB_INVALID_REGNUM, gdb_es_i386),
+ DEFINE_GPR(eax, nullptr, ehframe_eax_i386, dwarf_eax_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(ebx, nullptr, ehframe_ebx_i386, dwarf_ebx_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(ecx, nullptr, ehframe_ecx_i386, dwarf_ecx_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(edx, nullptr, ehframe_edx_i386, dwarf_edx_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(edi, nullptr, ehframe_edi_i386, dwarf_edi_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(esi, nullptr, ehframe_esi_i386, dwarf_esi_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(ebp, "fp", ehframe_ebp_i386, dwarf_ebp_i386, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(esp, "sp", ehframe_esp_i386, dwarf_esp_i386, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(eip, "pc", ehframe_eip_i386, dwarf_eip_i386, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(eflags, "flags", ehframe_eflags_i386, dwarf_eflags_i386, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(cs, nullptr, LLDB_INVALID_REGNUM, dwarf_cs_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(fs, nullptr, LLDB_INVALID_REGNUM, dwarf_fs_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(gs, nullptr, LLDB_INVALID_REGNUM, dwarf_gs_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(ss, nullptr, LLDB_INVALID_REGNUM, dwarf_ss_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(ds, nullptr, LLDB_INVALID_REGNUM, dwarf_ds_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(es, nullptr, LLDB_INVALID_REGNUM, dwarf_es_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
DEFINE_GPR_PSEUDO_16(ax, eax),
DEFINE_GPR_PSEUDO_16(bx, ebx),
@@ -133,15 +139,15 @@ g_register_infos_i386[] =
DEFINE_GPR_PSEUDO_8L(dl, edx),
// i387 Floating point registers.
- DEFINE_FPR(fctrl, fctrl, LLDB_INVALID_REGNUM, dwarf_fctrl_i386, LLDB_INVALID_REGNUM, gdb_fctrl_i386),
- DEFINE_FPR(fstat, fstat, LLDB_INVALID_REGNUM, dwarf_fstat_i386, LLDB_INVALID_REGNUM, gdb_fstat_i386),
- DEFINE_FPR(ftag, ftag, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_ftag_i386),
- DEFINE_FPR(fop, fop, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_fop_i386),
- DEFINE_FPR(fiseg, ptr.i386_.fiseg, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_fiseg_i386),
- DEFINE_FPR(fioff, ptr.i386_.fioff, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_fioff_i386),
- DEFINE_FPR(foseg, ptr.i386_.foseg, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_foseg_i386),
- DEFINE_FPR(fooff, ptr.i386_.fooff, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_fooff_i386),
- DEFINE_FPR(mxcsr, mxcsr, LLDB_INVALID_REGNUM, dwarf_mxcsr_i386, LLDB_INVALID_REGNUM, gdb_mxcsr_i386),
+ DEFINE_FPR(fctrl, fctrl, LLDB_INVALID_REGNUM, dwarf_fctrl_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(fstat, fstat, LLDB_INVALID_REGNUM, dwarf_fstat_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(ftag, ftag, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(fop, fop, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(fiseg, ptr.i386_.fiseg, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(fioff, ptr.i386_.fioff, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(foseg, ptr.i386_.foseg, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(fooff, ptr.i386_.fooff, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(mxcsr, mxcsr, LLDB_INVALID_REGNUM, dwarf_mxcsr_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
DEFINE_FPR(mxcsrmask, mxcsrmask, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
// FP registers.
@@ -192,6 +198,7 @@ g_register_infos_i386[] =
DEFINE_DR(dr, 6),
DEFINE_DR(dr, 7)
};
+
static_assert((sizeof(g_register_infos_i386) / sizeof(g_register_infos_i386[0])) == k_num_registers_i386,
"g_register_infos_x86_64 has wrong number of register infos");
diff --git a/source/Plugins/Process/Utility/RegisterInfos_mips.h b/source/Plugins/Process/Utility/RegisterInfos_mips.h
index 83ce6f0d4327..eef27f0208e0 100644
--- a/source/Plugins/Process/Utility/RegisterInfos_mips.h
+++ b/source/Plugins/Process/Utility/RegisterInfos_mips.h
@@ -6,10 +6,16 @@
// License. See LICENSE.TXT for details.
//
//===---------------------------------------------------------------------===//
-#include "llvm/Support/Compiler.h"
+// C Includes
#include <stddef.h>
+// C++ Includes
+// Other libraries and framework includes
+#include "llvm/Support/Compiler.h"
+
+// Project includes
+
#ifdef DECLARE_REGISTER_INFOS_MIPS_STRUCT
// Computes the offset of the given GPR in the user data area.
@@ -44,123 +50,124 @@
{ #reg, alt, sizeof(((MSA_linux_mips*)0)->reg), MSA_OFFSET(reg), eEncodingUint, \
eFormatHex, { kind1, kind2, kind3, kind4, msa_##reg##_mips }, NULL, NULL }
-// RegisterKind: GCC, DWARF, Generic, GDB, LLDB
+// RegisterKind: EH_Frame, DWARF, Generic, Procss Plugin, LLDB
static RegisterInfo
g_register_infos_mips[] =
{
- DEFINE_GPR (zero, "zero", gcc_dwarf_zero_mips, gcc_dwarf_zero_mips, LLDB_INVALID_REGNUM, gdb_zero_mips),
- DEFINE_GPR (r1, "at", gcc_dwarf_r1_mips, gcc_dwarf_r1_mips, LLDB_INVALID_REGNUM, gdb_r1_mips),
- DEFINE_GPR (r2, NULL, gcc_dwarf_r2_mips, gcc_dwarf_r2_mips, LLDB_INVALID_REGNUM, gdb_r2_mips),
- DEFINE_GPR (r3, NULL, gcc_dwarf_r3_mips, gcc_dwarf_r3_mips, LLDB_INVALID_REGNUM, gdb_r3_mips),
- DEFINE_GPR (r4, NULL, gcc_dwarf_r4_mips, gcc_dwarf_r4_mips, LLDB_REGNUM_GENERIC_ARG1, gdb_r4_mips),
- DEFINE_GPR (r5, NULL, gcc_dwarf_r5_mips, gcc_dwarf_r5_mips, LLDB_REGNUM_GENERIC_ARG2, gdb_r5_mips),
- DEFINE_GPR (r6, NULL, gcc_dwarf_r6_mips, gcc_dwarf_r6_mips, LLDB_REGNUM_GENERIC_ARG3, gdb_r6_mips),
- DEFINE_GPR (r7, NULL, gcc_dwarf_r7_mips, gcc_dwarf_r7_mips, LLDB_REGNUM_GENERIC_ARG4, gdb_r7_mips),
- DEFINE_GPR (r8, NULL, gcc_dwarf_r8_mips, gcc_dwarf_r8_mips, LLDB_INVALID_REGNUM, gdb_r8_mips),
- DEFINE_GPR (r9, NULL, gcc_dwarf_r9_mips, gcc_dwarf_r9_mips, LLDB_INVALID_REGNUM, gdb_r9_mips),
- DEFINE_GPR (r10, NULL, gcc_dwarf_r10_mips, gcc_dwarf_r10_mips, LLDB_INVALID_REGNUM, gdb_r10_mips),
- DEFINE_GPR (r11, NULL, gcc_dwarf_r11_mips, gcc_dwarf_r11_mips, LLDB_INVALID_REGNUM, gdb_r11_mips),
- DEFINE_GPR (r12, NULL, gcc_dwarf_r12_mips, gcc_dwarf_r12_mips, LLDB_INVALID_REGNUM, gdb_r12_mips),
- DEFINE_GPR (r13, NULL, gcc_dwarf_r13_mips, gcc_dwarf_r13_mips, LLDB_INVALID_REGNUM, gdb_r13_mips),
- DEFINE_GPR (r14, NULL, gcc_dwarf_r14_mips, gcc_dwarf_r14_mips, LLDB_INVALID_REGNUM, gdb_r14_mips),
- DEFINE_GPR (r15, NULL, gcc_dwarf_r15_mips, gcc_dwarf_r15_mips, LLDB_INVALID_REGNUM, gdb_r15_mips),
- DEFINE_GPR (r16, NULL, gcc_dwarf_r16_mips, gcc_dwarf_r16_mips, LLDB_INVALID_REGNUM, gdb_r16_mips),
- DEFINE_GPR (r17, NULL, gcc_dwarf_r17_mips, gcc_dwarf_r17_mips, LLDB_INVALID_REGNUM, gdb_r17_mips),
- DEFINE_GPR (r18, NULL, gcc_dwarf_r18_mips, gcc_dwarf_r18_mips, LLDB_INVALID_REGNUM, gdb_r18_mips),
- DEFINE_GPR (r19, NULL, gcc_dwarf_r19_mips, gcc_dwarf_r19_mips, LLDB_INVALID_REGNUM, gdb_r19_mips),
- DEFINE_GPR (r20, NULL, gcc_dwarf_r20_mips, gcc_dwarf_r20_mips, LLDB_INVALID_REGNUM, gdb_r20_mips),
- DEFINE_GPR (r21, NULL, gcc_dwarf_r21_mips, gcc_dwarf_r21_mips, LLDB_INVALID_REGNUM, gdb_r21_mips),
- DEFINE_GPR (r22, NULL, gcc_dwarf_r22_mips, gcc_dwarf_r22_mips, LLDB_INVALID_REGNUM, gdb_r22_mips),
- DEFINE_GPR (r23, NULL, gcc_dwarf_r23_mips, gcc_dwarf_r23_mips, LLDB_INVALID_REGNUM, gdb_r23_mips),
- DEFINE_GPR (r24, NULL, gcc_dwarf_r24_mips, gcc_dwarf_r24_mips, LLDB_INVALID_REGNUM, gdb_r24_mips),
- DEFINE_GPR (r25, NULL, gcc_dwarf_r25_mips, gcc_dwarf_r25_mips, LLDB_INVALID_REGNUM, gdb_r25_mips),
- DEFINE_GPR (r26, NULL, gcc_dwarf_r26_mips, gcc_dwarf_r26_mips, LLDB_INVALID_REGNUM, gdb_r26_mips),
- DEFINE_GPR (r27, NULL, gcc_dwarf_r27_mips, gcc_dwarf_r27_mips, LLDB_INVALID_REGNUM, gdb_r27_mips),
- DEFINE_GPR (gp, "gp", gcc_dwarf_gp_mips, gcc_dwarf_gp_mips, LLDB_INVALID_REGNUM, gdb_gp_mips),
- DEFINE_GPR (sp, "sp", gcc_dwarf_sp_mips, gcc_dwarf_sp_mips, LLDB_REGNUM_GENERIC_SP, gdb_sp_mips),
- DEFINE_GPR (r30, "fp", gcc_dwarf_r30_mips, gcc_dwarf_r30_mips, LLDB_REGNUM_GENERIC_FP, gdb_r30_mips),
- DEFINE_GPR (ra, "ra", gcc_dwarf_ra_mips, gcc_dwarf_ra_mips, LLDB_REGNUM_GENERIC_RA, gdb_ra_mips),
- DEFINE_GPR (sr, "status", gcc_dwarf_sr_mips, gcc_dwarf_sr_mips, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
- DEFINE_GPR (mullo, NULL, gcc_dwarf_lo_mips, gcc_dwarf_lo_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (mulhi, NULL, gcc_dwarf_hi_mips, gcc_dwarf_hi_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (badvaddr, NULL, gcc_dwarf_bad_mips, gcc_dwarf_bad_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (cause, NULL, gcc_dwarf_cause_mips, gcc_dwarf_cause_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (pc, NULL, gcc_dwarf_pc_mips, gcc_dwarf_pc_mips, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
- DEFINE_GPR (config5, NULL, gcc_dwarf_config5_mips, gcc_dwarf_config5_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f0, NULL, gcc_dwarf_f0_mips, gcc_dwarf_f0_mips, LLDB_INVALID_REGNUM, gdb_f0_mips),
- DEFINE_FPR (f1, NULL, gcc_dwarf_f1_mips, gcc_dwarf_f1_mips, LLDB_INVALID_REGNUM, gdb_f1_mips),
- DEFINE_FPR (f2, NULL, gcc_dwarf_f2_mips, gcc_dwarf_f2_mips, LLDB_INVALID_REGNUM, gdb_f2_mips),
- DEFINE_FPR (f3, NULL, gcc_dwarf_f3_mips, gcc_dwarf_f3_mips, LLDB_INVALID_REGNUM, gdb_f3_mips),
- DEFINE_FPR (f4, NULL, gcc_dwarf_f4_mips, gcc_dwarf_f4_mips, LLDB_INVALID_REGNUM, gdb_f4_mips),
- DEFINE_FPR (f5, NULL, gcc_dwarf_f5_mips, gcc_dwarf_f5_mips, LLDB_INVALID_REGNUM, gdb_f5_mips),
- DEFINE_FPR (f6, NULL, gcc_dwarf_f6_mips, gcc_dwarf_f6_mips, LLDB_INVALID_REGNUM, gdb_f6_mips),
- DEFINE_FPR (f7, NULL, gcc_dwarf_f7_mips, gcc_dwarf_f7_mips, LLDB_INVALID_REGNUM, gdb_f7_mips),
- DEFINE_FPR (f8, NULL, gcc_dwarf_f8_mips, gcc_dwarf_f8_mips, LLDB_INVALID_REGNUM, gdb_f8_mips),
- DEFINE_FPR (f9, NULL, gcc_dwarf_f9_mips, gcc_dwarf_f9_mips, LLDB_INVALID_REGNUM, gdb_f9_mips),
- DEFINE_FPR (f10, NULL, gcc_dwarf_f10_mips, gcc_dwarf_f10_mips, LLDB_INVALID_REGNUM, gdb_f10_mips),
- DEFINE_FPR (f11, NULL, gcc_dwarf_f11_mips, gcc_dwarf_f11_mips, LLDB_INVALID_REGNUM, gdb_f11_mips),
- DEFINE_FPR (f12, NULL, gcc_dwarf_f12_mips, gcc_dwarf_f12_mips, LLDB_INVALID_REGNUM, gdb_f12_mips),
- DEFINE_FPR (f13, NULL, gcc_dwarf_f13_mips, gcc_dwarf_f13_mips, LLDB_INVALID_REGNUM, gdb_f13_mips),
- DEFINE_FPR (f14, NULL, gcc_dwarf_f14_mips, gcc_dwarf_f14_mips, LLDB_INVALID_REGNUM, gdb_f14_mips),
- DEFINE_FPR (f15, NULL, gcc_dwarf_f15_mips, gcc_dwarf_f15_mips, LLDB_INVALID_REGNUM, gdb_f15_mips),
- DEFINE_FPR (f16, NULL, gcc_dwarf_f16_mips, gcc_dwarf_f16_mips, LLDB_INVALID_REGNUM, gdb_f16_mips),
- DEFINE_FPR (f17, NULL, gcc_dwarf_f17_mips, gcc_dwarf_f17_mips, LLDB_INVALID_REGNUM, gdb_f17_mips),
- DEFINE_FPR (f18, NULL, gcc_dwarf_f18_mips, gcc_dwarf_f18_mips, LLDB_INVALID_REGNUM, gdb_f18_mips),
- DEFINE_FPR (f19, NULL, gcc_dwarf_f19_mips, gcc_dwarf_f19_mips, LLDB_INVALID_REGNUM, gdb_f19_mips),
- DEFINE_FPR (f20, NULL, gcc_dwarf_f20_mips, gcc_dwarf_f20_mips, LLDB_INVALID_REGNUM, gdb_f20_mips),
- DEFINE_FPR (f21, NULL, gcc_dwarf_f21_mips, gcc_dwarf_f21_mips, LLDB_INVALID_REGNUM, gdb_f21_mips),
- DEFINE_FPR (f22, NULL, gcc_dwarf_f22_mips, gcc_dwarf_f22_mips, LLDB_INVALID_REGNUM, gdb_f22_mips),
- DEFINE_FPR (f23, NULL, gcc_dwarf_f23_mips, gcc_dwarf_f23_mips, LLDB_INVALID_REGNUM, gdb_f23_mips),
- DEFINE_FPR (f24, NULL, gcc_dwarf_f24_mips, gcc_dwarf_f24_mips, LLDB_INVALID_REGNUM, gdb_f24_mips),
- DEFINE_FPR (f25, NULL, gcc_dwarf_f25_mips, gcc_dwarf_f25_mips, LLDB_INVALID_REGNUM, gdb_f25_mips),
- DEFINE_FPR (f26, NULL, gcc_dwarf_f26_mips, gcc_dwarf_f26_mips, LLDB_INVALID_REGNUM, gdb_f26_mips),
- DEFINE_FPR (f27, NULL, gcc_dwarf_f27_mips, gcc_dwarf_f27_mips, LLDB_INVALID_REGNUM, gdb_f27_mips),
- DEFINE_FPR (f28, NULL, gcc_dwarf_f28_mips, gcc_dwarf_f28_mips, LLDB_INVALID_REGNUM, gdb_f28_mips),
- DEFINE_FPR (f29, NULL, gcc_dwarf_f29_mips, gcc_dwarf_f29_mips, LLDB_INVALID_REGNUM, gdb_f29_mips),
- DEFINE_FPR (f30, NULL, gcc_dwarf_f30_mips, gcc_dwarf_f30_mips, LLDB_INVALID_REGNUM, gdb_f30_mips),
- DEFINE_FPR (f31, NULL, gcc_dwarf_f31_mips, gcc_dwarf_f31_mips, LLDB_INVALID_REGNUM, gdb_f31_mips),
- DEFINE_FPR (fcsr, NULL, gcc_dwarf_fcsr_mips, gcc_dwarf_fcsr_mips, LLDB_INVALID_REGNUM, gdb_fcsr_mips),
- DEFINE_FPR (fir, NULL, gcc_dwarf_fir_mips, gcc_dwarf_fir_mips, LLDB_INVALID_REGNUM, gdb_fir_mips),
- DEFINE_FPR (config5, NULL, gcc_dwarf_config5_mips, gcc_dwarf_config5_mips, LLDB_INVALID_REGNUM, gdb_config5_mips),
- DEFINE_MSA (w0, NULL, gcc_dwarf_w0_mips, gcc_dwarf_w0_mips, LLDB_INVALID_REGNUM, gdb_w0_mips),
- DEFINE_MSA (w1, NULL, gcc_dwarf_w1_mips, gcc_dwarf_w1_mips, LLDB_INVALID_REGNUM, gdb_w1_mips),
- DEFINE_MSA (w2, NULL, gcc_dwarf_w2_mips, gcc_dwarf_w2_mips, LLDB_INVALID_REGNUM, gdb_w2_mips),
- DEFINE_MSA (w3, NULL, gcc_dwarf_w3_mips, gcc_dwarf_w3_mips, LLDB_INVALID_REGNUM, gdb_w3_mips),
- DEFINE_MSA (w4, NULL, gcc_dwarf_w4_mips, gcc_dwarf_w4_mips, LLDB_INVALID_REGNUM, gdb_w4_mips),
- DEFINE_MSA (w5, NULL, gcc_dwarf_w5_mips, gcc_dwarf_w5_mips, LLDB_INVALID_REGNUM, gdb_w5_mips),
- DEFINE_MSA (w6, NULL, gcc_dwarf_w6_mips, gcc_dwarf_w6_mips, LLDB_INVALID_REGNUM, gdb_w6_mips),
- DEFINE_MSA (w7, NULL, gcc_dwarf_w7_mips, gcc_dwarf_w7_mips, LLDB_INVALID_REGNUM, gdb_w7_mips),
- DEFINE_MSA (w8, NULL, gcc_dwarf_w8_mips, gcc_dwarf_w8_mips, LLDB_INVALID_REGNUM, gdb_w8_mips),
- DEFINE_MSA (w9, NULL, gcc_dwarf_w9_mips, gcc_dwarf_w9_mips, LLDB_INVALID_REGNUM, gdb_w9_mips),
- DEFINE_MSA (w10, NULL, gcc_dwarf_w10_mips, gcc_dwarf_w10_mips, LLDB_INVALID_REGNUM, gdb_w10_mips),
- DEFINE_MSA (w11, NULL, gcc_dwarf_w11_mips, gcc_dwarf_w11_mips, LLDB_INVALID_REGNUM, gdb_w11_mips),
- DEFINE_MSA (w12, NULL, gcc_dwarf_w12_mips, gcc_dwarf_w12_mips, LLDB_INVALID_REGNUM, gdb_w12_mips),
- DEFINE_MSA (w13, NULL, gcc_dwarf_w13_mips, gcc_dwarf_w13_mips, LLDB_INVALID_REGNUM, gdb_w13_mips),
- DEFINE_MSA (w14, NULL, gcc_dwarf_w14_mips, gcc_dwarf_w14_mips, LLDB_INVALID_REGNUM, gdb_w14_mips),
- DEFINE_MSA (w15, NULL, gcc_dwarf_w15_mips, gcc_dwarf_w15_mips, LLDB_INVALID_REGNUM, gdb_w15_mips),
- DEFINE_MSA (w16, NULL, gcc_dwarf_w16_mips, gcc_dwarf_w16_mips, LLDB_INVALID_REGNUM, gdb_w16_mips),
- DEFINE_MSA (w17, NULL, gcc_dwarf_w17_mips, gcc_dwarf_w17_mips, LLDB_INVALID_REGNUM, gdb_w17_mips),
- DEFINE_MSA (w18, NULL, gcc_dwarf_w18_mips, gcc_dwarf_w18_mips, LLDB_INVALID_REGNUM, gdb_w18_mips),
- DEFINE_MSA (w19, NULL, gcc_dwarf_w19_mips, gcc_dwarf_w19_mips, LLDB_INVALID_REGNUM, gdb_w19_mips),
- DEFINE_MSA (w20, NULL, gcc_dwarf_w10_mips, gcc_dwarf_w20_mips, LLDB_INVALID_REGNUM, gdb_w20_mips),
- DEFINE_MSA (w21, NULL, gcc_dwarf_w21_mips, gcc_dwarf_w21_mips, LLDB_INVALID_REGNUM, gdb_w21_mips),
- DEFINE_MSA (w22, NULL, gcc_dwarf_w22_mips, gcc_dwarf_w22_mips, LLDB_INVALID_REGNUM, gdb_w22_mips),
- DEFINE_MSA (w23, NULL, gcc_dwarf_w23_mips, gcc_dwarf_w23_mips, LLDB_INVALID_REGNUM, gdb_w23_mips),
- DEFINE_MSA (w24, NULL, gcc_dwarf_w24_mips, gcc_dwarf_w24_mips, LLDB_INVALID_REGNUM, gdb_w24_mips),
- DEFINE_MSA (w25, NULL, gcc_dwarf_w25_mips, gcc_dwarf_w25_mips, LLDB_INVALID_REGNUM, gdb_w25_mips),
- DEFINE_MSA (w26, NULL, gcc_dwarf_w26_mips, gcc_dwarf_w26_mips, LLDB_INVALID_REGNUM, gdb_w26_mips),
- DEFINE_MSA (w27, NULL, gcc_dwarf_w27_mips, gcc_dwarf_w27_mips, LLDB_INVALID_REGNUM, gdb_w27_mips),
- DEFINE_MSA (w28, NULL, gcc_dwarf_w28_mips, gcc_dwarf_w28_mips, LLDB_INVALID_REGNUM, gdb_w28_mips),
- DEFINE_MSA (w29, NULL, gcc_dwarf_w29_mips, gcc_dwarf_w29_mips, LLDB_INVALID_REGNUM, gdb_w29_mips),
- DEFINE_MSA (w30, NULL, gcc_dwarf_w30_mips, gcc_dwarf_w30_mips, LLDB_INVALID_REGNUM, gdb_w30_mips),
- DEFINE_MSA (w31, NULL, gcc_dwarf_w31_mips, gcc_dwarf_w31_mips, LLDB_INVALID_REGNUM, gdb_w31_mips),
- DEFINE_MSA_INFO (mcsr, NULL, gcc_dwarf_mcsr_mips, gcc_dwarf_mcsr_mips, LLDB_INVALID_REGNUM, gdb_mcsr_mips),
- DEFINE_MSA_INFO (mir, NULL, gcc_dwarf_mir_mips, gcc_dwarf_mir_mips, LLDB_INVALID_REGNUM, gdb_mir_mips),
- DEFINE_MSA_INFO (fcsr, NULL, gcc_dwarf_fcsr_mips, gcc_dwarf_fcsr_mips, LLDB_INVALID_REGNUM, gdb_fcsr_mips),
- DEFINE_MSA_INFO (fir, NULL, gcc_dwarf_fir_mips, gcc_dwarf_fir_mips, LLDB_INVALID_REGNUM, gdb_fir_mips),
- DEFINE_MSA_INFO (config5, NULL, gcc_dwarf_config5_mips, gcc_dwarf_config5_mips, LLDB_INVALID_REGNUM, gdb_config5_mips)
+ DEFINE_GPR (zero, "zero", dwarf_zero_mips, dwarf_zero_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r1, "at", dwarf_r1_mips, dwarf_r1_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r2, nullptr, dwarf_r2_mips, dwarf_r2_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r3, nullptr, dwarf_r3_mips, dwarf_r3_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r4, nullptr, dwarf_r4_mips, dwarf_r4_mips, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r5, nullptr, dwarf_r5_mips, dwarf_r5_mips, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r6, nullptr, dwarf_r6_mips, dwarf_r6_mips, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r7, nullptr, dwarf_r7_mips, dwarf_r7_mips, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r8, nullptr, dwarf_r8_mips, dwarf_r8_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r9, nullptr, dwarf_r9_mips, dwarf_r9_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r10, nullptr, dwarf_r10_mips, dwarf_r10_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r11, nullptr, dwarf_r11_mips, dwarf_r11_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r12, nullptr, dwarf_r12_mips, dwarf_r12_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r13, nullptr, dwarf_r13_mips, dwarf_r13_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r14, nullptr, dwarf_r14_mips, dwarf_r14_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r15, nullptr, dwarf_r15_mips, dwarf_r15_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r16, nullptr, dwarf_r16_mips, dwarf_r16_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r17, nullptr, dwarf_r17_mips, dwarf_r17_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r18, nullptr, dwarf_r18_mips, dwarf_r18_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r19, nullptr, dwarf_r19_mips, dwarf_r19_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r20, nullptr, dwarf_r20_mips, dwarf_r20_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r21, nullptr, dwarf_r21_mips, dwarf_r21_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r22, nullptr, dwarf_r22_mips, dwarf_r22_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r23, nullptr, dwarf_r23_mips, dwarf_r23_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r24, nullptr, dwarf_r24_mips, dwarf_r24_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r25, nullptr, dwarf_r25_mips, dwarf_r25_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r26, nullptr, dwarf_r26_mips, dwarf_r26_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r27, nullptr, dwarf_r27_mips, dwarf_r27_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (gp, "gp", dwarf_gp_mips, dwarf_gp_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (sp, "sp", dwarf_sp_mips, dwarf_sp_mips, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (r30, "fp", dwarf_r30_mips, dwarf_r30_mips, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (ra, "ra", dwarf_ra_mips, dwarf_ra_mips, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (sr, "status", dwarf_sr_mips, dwarf_sr_mips, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (mullo, nullptr, dwarf_lo_mips, dwarf_lo_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (mulhi, nullptr, dwarf_hi_mips, dwarf_hi_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (badvaddr, nullptr, dwarf_bad_mips, dwarf_bad_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (cause, nullptr, dwarf_cause_mips, dwarf_cause_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (pc, nullptr, dwarf_pc_mips, dwarf_pc_mips, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
+ DEFINE_GPR (config5, nullptr, dwarf_config5_mips, dwarf_config5_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f0, nullptr, dwarf_f0_mips, dwarf_f0_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f1, nullptr, dwarf_f1_mips, dwarf_f1_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f2, nullptr, dwarf_f2_mips, dwarf_f2_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f3, nullptr, dwarf_f3_mips, dwarf_f3_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f4, nullptr, dwarf_f4_mips, dwarf_f4_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f5, nullptr, dwarf_f5_mips, dwarf_f5_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f6, nullptr, dwarf_f6_mips, dwarf_f6_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f7, nullptr, dwarf_f7_mips, dwarf_f7_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f8, nullptr, dwarf_f8_mips, dwarf_f8_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f9, nullptr, dwarf_f9_mips, dwarf_f9_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f10, nullptr, dwarf_f10_mips, dwarf_f10_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f11, nullptr, dwarf_f11_mips, dwarf_f11_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f12, nullptr, dwarf_f12_mips, dwarf_f12_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f13, nullptr, dwarf_f13_mips, dwarf_f13_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f14, nullptr, dwarf_f14_mips, dwarf_f14_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f15, nullptr, dwarf_f15_mips, dwarf_f15_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f16, nullptr, dwarf_f16_mips, dwarf_f16_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f17, nullptr, dwarf_f17_mips, dwarf_f17_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f18, nullptr, dwarf_f18_mips, dwarf_f18_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f19, nullptr, dwarf_f19_mips, dwarf_f19_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f20, nullptr, dwarf_f20_mips, dwarf_f20_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f21, nullptr, dwarf_f21_mips, dwarf_f21_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f22, nullptr, dwarf_f22_mips, dwarf_f22_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f23, nullptr, dwarf_f23_mips, dwarf_f23_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f24, nullptr, dwarf_f24_mips, dwarf_f24_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f25, nullptr, dwarf_f25_mips, dwarf_f25_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f26, nullptr, dwarf_f26_mips, dwarf_f26_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f27, nullptr, dwarf_f27_mips, dwarf_f27_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f28, nullptr, dwarf_f28_mips, dwarf_f28_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f29, nullptr, dwarf_f29_mips, dwarf_f29_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f30, nullptr, dwarf_f30_mips, dwarf_f30_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f31, nullptr, dwarf_f31_mips, dwarf_f31_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (fcsr, nullptr, dwarf_fcsr_mips, dwarf_fcsr_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (fir, nullptr, dwarf_fir_mips, dwarf_fir_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (config5, nullptr, dwarf_config5_mips, dwarf_config5_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w0, nullptr, dwarf_w0_mips, dwarf_w0_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w1, nullptr, dwarf_w1_mips, dwarf_w1_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w2, nullptr, dwarf_w2_mips, dwarf_w2_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w3, nullptr, dwarf_w3_mips, dwarf_w3_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w4, nullptr, dwarf_w4_mips, dwarf_w4_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w5, nullptr, dwarf_w5_mips, dwarf_w5_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w6, nullptr, dwarf_w6_mips, dwarf_w6_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w7, nullptr, dwarf_w7_mips, dwarf_w7_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w8, nullptr, dwarf_w8_mips, dwarf_w8_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w9, nullptr, dwarf_w9_mips, dwarf_w9_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w10, nullptr, dwarf_w10_mips, dwarf_w10_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w11, nullptr, dwarf_w11_mips, dwarf_w11_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w12, nullptr, dwarf_w12_mips, dwarf_w12_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w13, nullptr, dwarf_w13_mips, dwarf_w13_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w14, nullptr, dwarf_w14_mips, dwarf_w14_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w15, nullptr, dwarf_w15_mips, dwarf_w15_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w16, nullptr, dwarf_w16_mips, dwarf_w16_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w17, nullptr, dwarf_w17_mips, dwarf_w17_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w18, nullptr, dwarf_w18_mips, dwarf_w18_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w19, nullptr, dwarf_w19_mips, dwarf_w19_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w20, nullptr, dwarf_w10_mips, dwarf_w20_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w21, nullptr, dwarf_w21_mips, dwarf_w21_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w22, nullptr, dwarf_w22_mips, dwarf_w22_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w23, nullptr, dwarf_w23_mips, dwarf_w23_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w24, nullptr, dwarf_w24_mips, dwarf_w24_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w25, nullptr, dwarf_w25_mips, dwarf_w25_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w26, nullptr, dwarf_w26_mips, dwarf_w26_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w27, nullptr, dwarf_w27_mips, dwarf_w27_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w28, nullptr, dwarf_w28_mips, dwarf_w28_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w29, nullptr, dwarf_w29_mips, dwarf_w29_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w30, nullptr, dwarf_w30_mips, dwarf_w30_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w31, nullptr, dwarf_w31_mips, dwarf_w31_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA_INFO (mcsr, nullptr, dwarf_mcsr_mips, dwarf_mcsr_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA_INFO (mir, nullptr, dwarf_mir_mips, dwarf_mir_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA_INFO (fcsr, nullptr, dwarf_fcsr_mips, dwarf_fcsr_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA_INFO (fir, nullptr, dwarf_fir_mips, dwarf_fir_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA_INFO (config5, nullptr, dwarf_config5_mips, dwarf_config5_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM)
};
+
static_assert((sizeof(g_register_infos_mips) / sizeof(g_register_infos_mips[0])) == k_num_registers_mips,
"g_register_infos_mips has wrong number of register infos");
diff --git a/source/Plugins/Process/Utility/RegisterInfos_mips64.h b/source/Plugins/Process/Utility/RegisterInfos_mips64.h
index 101842e66d49..45853d7931dd 100644
--- a/source/Plugins/Process/Utility/RegisterInfos_mips64.h
+++ b/source/Plugins/Process/Utility/RegisterInfos_mips64.h
@@ -1,15 +1,21 @@
-//===-- RegisterInfos_mips64.h ---------------------------------*- C++ -*-===//
+//===-- 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.
//
-//===---------------------------------------------------------------------===//
-#include "llvm/Support/Compiler.h"
+//===----------------------------------------------------------------------===//
+// C Includes
#include <stddef.h>
+// C++ Includes
+// Other libraries and framework includes
+#include "llvm/Support/Compiler.h"
+
+// Project includes
+
#ifdef DECLARE_REGISTER_INFOS_MIPS64_STRUCT
// Computes the offset of the given GPR in the user data area.
@@ -32,7 +38,7 @@
(LLVM_EXTENSION offsetof(UserArea, msa) + \
LLVM_EXTENSION offsetof(MSA_linux_mips, regname))
-// RegisterKind: GCC, DWARF, Generic, GDB, LLDB
+// RegisterKind: EHFrame, DWARF, Generic, Process Plugin, LLDB
// Note that the size and offset will be updated by platform-specific classes.
#ifdef LINUX_MIPS64
@@ -64,161 +70,160 @@
static RegisterInfo
g_register_infos_mips64[] =
{
- // General purpose registers. GCC, DWARF, Generic, GDB
+ // General purpose registers. EH_Frame, DWARF, Generic, Process Plugin
#ifndef LINUX_MIPS64
- DEFINE_GPR(zero, "r0", gcc_dwarf_zero_mips64, gcc_dwarf_zero_mips64, LLDB_INVALID_REGNUM, gdb_zero_mips64),
- DEFINE_GPR(r1, NULL, gcc_dwarf_r1_mips64, gcc_dwarf_r1_mips64, LLDB_INVALID_REGNUM, gdb_r1_mips64),
- DEFINE_GPR(r2, NULL, gcc_dwarf_r2_mips64, gcc_dwarf_r2_mips64, LLDB_INVALID_REGNUM, gdb_r2_mips64),
- DEFINE_GPR(r3, NULL, gcc_dwarf_r3_mips64, gcc_dwarf_r3_mips64, LLDB_INVALID_REGNUM, gdb_r3_mips64),
- DEFINE_GPR(r4, NULL, gcc_dwarf_r4_mips64, gcc_dwarf_r4_mips64, LLDB_REGNUM_GENERIC_ARG1, gdb_r4_mips64),
- DEFINE_GPR(r5, NULL, gcc_dwarf_r5_mips64, gcc_dwarf_r5_mips64, LLDB_REGNUM_GENERIC_ARG2, gdb_r5_mips64),
- DEFINE_GPR(r6, NULL, gcc_dwarf_r6_mips64, gcc_dwarf_r6_mips64, LLDB_REGNUM_GENERIC_ARG3, gdb_r6_mips64),
- DEFINE_GPR(r7, NULL, gcc_dwarf_r7_mips64, gcc_dwarf_r7_mips64, LLDB_REGNUM_GENERIC_ARG4, gdb_r7_mips64),
- DEFINE_GPR(r8, NULL, gcc_dwarf_r8_mips64, gcc_dwarf_r8_mips64, LLDB_REGNUM_GENERIC_ARG5, gdb_r8_mips64),
- DEFINE_GPR(r9, NULL, gcc_dwarf_r9_mips64, gcc_dwarf_r9_mips64, LLDB_REGNUM_GENERIC_ARG6, gdb_r9_mips64),
- DEFINE_GPR(r10, NULL, gcc_dwarf_r10_mips64, gcc_dwarf_r10_mips64, LLDB_REGNUM_GENERIC_ARG7, gdb_r10_mips64),
- DEFINE_GPR(r11, NULL, gcc_dwarf_r11_mips64, gcc_dwarf_r11_mips64, LLDB_REGNUM_GENERIC_ARG8, gdb_r11_mips64),
- DEFINE_GPR(r12, NULL, gcc_dwarf_r12_mips64, gcc_dwarf_r12_mips64, LLDB_INVALID_REGNUM, gdb_r12_mips64),
- DEFINE_GPR(r13, NULL, gcc_dwarf_r13_mips64, gcc_dwarf_r13_mips64, LLDB_INVALID_REGNUM, gdb_r13_mips64),
- DEFINE_GPR(r14, NULL, gcc_dwarf_r14_mips64, gcc_dwarf_r14_mips64, LLDB_INVALID_REGNUM, gdb_r14_mips64),
- DEFINE_GPR(r15, NULL, gcc_dwarf_r15_mips64, gcc_dwarf_r15_mips64, LLDB_INVALID_REGNUM, gdb_r15_mips64),
- DEFINE_GPR(r16, NULL, gcc_dwarf_r16_mips64, gcc_dwarf_r16_mips64, LLDB_INVALID_REGNUM, gdb_r16_mips64),
- DEFINE_GPR(r17, NULL, gcc_dwarf_r17_mips64, gcc_dwarf_r17_mips64, LLDB_INVALID_REGNUM, gdb_r17_mips64),
- DEFINE_GPR(r18, NULL, gcc_dwarf_r18_mips64, gcc_dwarf_r18_mips64, LLDB_INVALID_REGNUM, gdb_r18_mips64),
- DEFINE_GPR(r19, NULL, gcc_dwarf_r19_mips64, gcc_dwarf_r19_mips64, LLDB_INVALID_REGNUM, gdb_r19_mips64),
- DEFINE_GPR(r20, NULL, gcc_dwarf_r20_mips64, gcc_dwarf_r20_mips64, LLDB_INVALID_REGNUM, gdb_r20_mips64),
- DEFINE_GPR(r21, NULL, gcc_dwarf_r21_mips64, gcc_dwarf_r21_mips64, LLDB_INVALID_REGNUM, gdb_r21_mips64),
- DEFINE_GPR(r22, NULL, gcc_dwarf_r22_mips64, gcc_dwarf_r22_mips64, LLDB_INVALID_REGNUM, gdb_r22_mips64),
- DEFINE_GPR(r23, NULL, gcc_dwarf_r23_mips64, gcc_dwarf_r23_mips64, LLDB_INVALID_REGNUM, gdb_r23_mips64),
- DEFINE_GPR(r24, NULL, gcc_dwarf_r24_mips64, gcc_dwarf_r24_mips64, LLDB_INVALID_REGNUM, gdb_r24_mips64),
- DEFINE_GPR(r25, NULL, gcc_dwarf_r25_mips64, gcc_dwarf_r25_mips64, LLDB_INVALID_REGNUM, gdb_r25_mips64),
- DEFINE_GPR(r26, NULL, gcc_dwarf_r26_mips64, gcc_dwarf_r26_mips64, LLDB_INVALID_REGNUM, gdb_r26_mips64),
- DEFINE_GPR(r27, NULL, gcc_dwarf_r27_mips64, gcc_dwarf_r27_mips64, LLDB_INVALID_REGNUM, gdb_r27_mips64),
- DEFINE_GPR(gp, "r28", gcc_dwarf_gp_mips64, gcc_dwarf_gp_mips64, LLDB_INVALID_REGNUM, gdb_gp_mips64),
- DEFINE_GPR(sp, "r29", gcc_dwarf_sp_mips64, gcc_dwarf_sp_mips64, LLDB_REGNUM_GENERIC_SP, gdb_sp_mips64),
- DEFINE_GPR(r30, NULL, gcc_dwarf_r30_mips64, gcc_dwarf_r30_mips64, LLDB_REGNUM_GENERIC_FP, gdb_r30_mips64),
- DEFINE_GPR(ra, "r31", gcc_dwarf_ra_mips64, gcc_dwarf_ra_mips64, LLDB_REGNUM_GENERIC_RA, gdb_ra_mips64),
- DEFINE_GPR(sr, NULL, gcc_dwarf_sr_mips64, gcc_dwarf_sr_mips64, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
- DEFINE_GPR(mullo, NULL, gcc_dwarf_lo_mips64, gcc_dwarf_lo_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(mulhi, NULL, gcc_dwarf_hi_mips64, gcc_dwarf_hi_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(badvaddr, NULL, gcc_dwarf_bad_mips64, gcc_dwarf_bad_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(cause, NULL, gcc_dwarf_cause_mips64, gcc_dwarf_cause_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(pc, "pc", gcc_dwarf_pc_mips64, gcc_dwarf_pc_mips64, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
- DEFINE_GPR(ic, NULL, gcc_dwarf_ic_mips64, gcc_dwarf_ic_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(dummy, NULL, gcc_dwarf_dummy_mips64, gcc_dwarf_dummy_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(zero, "r0", dwarf_zero_mips64, dwarf_zero_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r1, nullptr, dwarf_r1_mips64, dwarf_r1_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r2, nullptr, dwarf_r2_mips64, dwarf_r2_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r3, nullptr, dwarf_r3_mips64, dwarf_r3_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r4, nullptr, dwarf_r4_mips64, dwarf_r4_mips64, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r5, nullptr, dwarf_r5_mips64, dwarf_r5_mips64, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r6, nullptr, dwarf_r6_mips64, dwarf_r6_mips64, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r7, nullptr, dwarf_r7_mips64, dwarf_r7_mips64, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r8, nullptr, dwarf_r8_mips64, dwarf_r8_mips64, LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r9, nullptr, dwarf_r9_mips64, dwarf_r9_mips64, LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r10, nullptr, dwarf_r10_mips64, dwarf_r10_mips64, LLDB_REGNUM_GENERIC_ARG7, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r11, nullptr, dwarf_r11_mips64, dwarf_r11_mips64, LLDB_REGNUM_GENERIC_ARG8, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r12, nullptr, dwarf_r12_mips64, dwarf_r12_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r13, nullptr, dwarf_r13_mips64, dwarf_r13_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r14, nullptr, dwarf_r14_mips64, dwarf_r14_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r15, nullptr, dwarf_r15_mips64, dwarf_r15_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r16, nullptr, dwarf_r16_mips64, dwarf_r16_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r17, nullptr, dwarf_r17_mips64, dwarf_r17_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r18, nullptr, dwarf_r18_mips64, dwarf_r18_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r19, nullptr, dwarf_r19_mips64, dwarf_r19_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r20, nullptr, dwarf_r20_mips64, dwarf_r20_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r21, nullptr, dwarf_r21_mips64, dwarf_r21_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r22, nullptr, dwarf_r22_mips64, dwarf_r22_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r23, nullptr, dwarf_r23_mips64, dwarf_r23_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r24, nullptr, dwarf_r24_mips64, dwarf_r24_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r25, nullptr, dwarf_r25_mips64, dwarf_r25_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r26, nullptr, dwarf_r26_mips64, dwarf_r26_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r27, nullptr, dwarf_r27_mips64, dwarf_r27_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(gp, "r28", dwarf_gp_mips64, dwarf_gp_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(sp, "r29", dwarf_sp_mips64, dwarf_sp_mips64, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r30, nullptr, dwarf_r30_mips64, dwarf_r30_mips64, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(ra, "r31", dwarf_ra_mips64, dwarf_ra_mips64, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(sr, nullptr, dwarf_sr_mips64, dwarf_sr_mips64, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(mullo, nullptr, dwarf_lo_mips64, dwarf_lo_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(mulhi, nullptr, dwarf_hi_mips64, dwarf_hi_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(badvaddr, nullptr, dwarf_bad_mips64, dwarf_bad_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(cause, nullptr, dwarf_cause_mips64, dwarf_cause_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(pc, "pc", dwarf_pc_mips64, dwarf_pc_mips64, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(ic, nullptr, dwarf_ic_mips64, dwarf_ic_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(dummy, nullptr, dwarf_dummy_mips64, dwarf_dummy_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
#else
-
- DEFINE_GPR(zero, "r0", gcc_dwarf_zero_mips64, gcc_dwarf_zero_mips64, LLDB_INVALID_REGNUM, gdb_zero_mips64),
- DEFINE_GPR(r1, NULL, gcc_dwarf_r1_mips64, gcc_dwarf_r1_mips64, LLDB_INVALID_REGNUM, gdb_r1_mips64),
- DEFINE_GPR(r2, NULL, gcc_dwarf_r2_mips64, gcc_dwarf_r2_mips64, LLDB_INVALID_REGNUM, gdb_r2_mips64),
- DEFINE_GPR(r3, NULL, gcc_dwarf_r3_mips64, gcc_dwarf_r3_mips64, LLDB_INVALID_REGNUM, gdb_r3_mips64),
- DEFINE_GPR(r4, NULL, gcc_dwarf_r4_mips64, gcc_dwarf_r4_mips64, LLDB_REGNUM_GENERIC_ARG1, gdb_r4_mips64),
- DEFINE_GPR(r5, NULL, gcc_dwarf_r5_mips64, gcc_dwarf_r5_mips64, LLDB_REGNUM_GENERIC_ARG2, gdb_r5_mips64),
- DEFINE_GPR(r6, NULL, gcc_dwarf_r6_mips64, gcc_dwarf_r6_mips64, LLDB_REGNUM_GENERIC_ARG3, gdb_r6_mips64),
- DEFINE_GPR(r7, NULL, gcc_dwarf_r7_mips64, gcc_dwarf_r7_mips64, LLDB_REGNUM_GENERIC_ARG4, gdb_r7_mips64),
- DEFINE_GPR(r8, NULL, gcc_dwarf_r8_mips64, gcc_dwarf_r8_mips64, LLDB_REGNUM_GENERIC_ARG5, gdb_r8_mips64),
- DEFINE_GPR(r9, NULL, gcc_dwarf_r9_mips64, gcc_dwarf_r9_mips64, LLDB_REGNUM_GENERIC_ARG6, gdb_r9_mips64),
- DEFINE_GPR(r10, NULL, gcc_dwarf_r10_mips64, gcc_dwarf_r10_mips64, LLDB_REGNUM_GENERIC_ARG7, gdb_r10_mips64),
- DEFINE_GPR(r11, NULL, gcc_dwarf_r11_mips64, gcc_dwarf_r11_mips64, LLDB_REGNUM_GENERIC_ARG8, gdb_r11_mips64),
- DEFINE_GPR(r12, NULL, gcc_dwarf_r12_mips64, gcc_dwarf_r12_mips64, LLDB_INVALID_REGNUM, gdb_r12_mips64),
- DEFINE_GPR(r13, NULL, gcc_dwarf_r13_mips64, gcc_dwarf_r13_mips64, LLDB_INVALID_REGNUM, gdb_r13_mips64),
- DEFINE_GPR(r14, NULL, gcc_dwarf_r14_mips64, gcc_dwarf_r14_mips64, LLDB_INVALID_REGNUM, gdb_r14_mips64),
- DEFINE_GPR(r15, NULL, gcc_dwarf_r15_mips64, gcc_dwarf_r15_mips64, LLDB_INVALID_REGNUM, gdb_r15_mips64),
- DEFINE_GPR(r16, NULL, gcc_dwarf_r16_mips64, gcc_dwarf_r16_mips64, LLDB_INVALID_REGNUM, gdb_r16_mips64),
- DEFINE_GPR(r17, NULL, gcc_dwarf_r17_mips64, gcc_dwarf_r17_mips64, LLDB_INVALID_REGNUM, gdb_r17_mips64),
- DEFINE_GPR(r18, NULL, gcc_dwarf_r18_mips64, gcc_dwarf_r18_mips64, LLDB_INVALID_REGNUM, gdb_r18_mips64),
- DEFINE_GPR(r19, NULL, gcc_dwarf_r19_mips64, gcc_dwarf_r19_mips64, LLDB_INVALID_REGNUM, gdb_r19_mips64),
- DEFINE_GPR(r20, NULL, gcc_dwarf_r20_mips64, gcc_dwarf_r20_mips64, LLDB_INVALID_REGNUM, gdb_r20_mips64),
- DEFINE_GPR(r21, NULL, gcc_dwarf_r21_mips64, gcc_dwarf_r21_mips64, LLDB_INVALID_REGNUM, gdb_r21_mips64),
- DEFINE_GPR(r22, NULL, gcc_dwarf_r22_mips64, gcc_dwarf_r22_mips64, LLDB_INVALID_REGNUM, gdb_r22_mips64),
- DEFINE_GPR(r23, NULL, gcc_dwarf_r23_mips64, gcc_dwarf_r23_mips64, LLDB_INVALID_REGNUM, gdb_r23_mips64),
- DEFINE_GPR(r24, NULL, gcc_dwarf_r24_mips64, gcc_dwarf_r24_mips64, LLDB_INVALID_REGNUM, gdb_r24_mips64),
- DEFINE_GPR(r25, NULL, gcc_dwarf_r25_mips64, gcc_dwarf_r25_mips64, LLDB_INVALID_REGNUM, gdb_r25_mips64),
- DEFINE_GPR(r26, NULL, gcc_dwarf_r26_mips64, gcc_dwarf_r26_mips64, LLDB_INVALID_REGNUM, gdb_r26_mips64),
- DEFINE_GPR(r27, NULL, gcc_dwarf_r27_mips64, gcc_dwarf_r27_mips64, LLDB_INVALID_REGNUM, gdb_r27_mips64),
- DEFINE_GPR(gp, "r28", gcc_dwarf_gp_mips64, gcc_dwarf_gp_mips64, LLDB_INVALID_REGNUM, gdb_gp_mips64),
- DEFINE_GPR(sp, "r29", gcc_dwarf_sp_mips64, gcc_dwarf_sp_mips64, LLDB_REGNUM_GENERIC_SP, gdb_sp_mips64),
- DEFINE_GPR(r30, NULL, gcc_dwarf_r30_mips64, gcc_dwarf_r30_mips64, LLDB_REGNUM_GENERIC_FP, gdb_r30_mips64),
- DEFINE_GPR(ra, "r31", gcc_dwarf_ra_mips64, gcc_dwarf_ra_mips64, LLDB_REGNUM_GENERIC_RA, gdb_ra_mips64),
- DEFINE_GPR_INFO(sr, NULL, gcc_dwarf_sr_mips64, gcc_dwarf_sr_mips64, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
- DEFINE_GPR(mullo, NULL, gcc_dwarf_lo_mips64, gcc_dwarf_lo_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(mulhi, NULL, gcc_dwarf_hi_mips64, gcc_dwarf_hi_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(badvaddr, NULL, gcc_dwarf_bad_mips64, gcc_dwarf_bad_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR_INFO(cause, NULL, gcc_dwarf_cause_mips64, gcc_dwarf_cause_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(pc, "pc", gcc_dwarf_pc_mips64, gcc_dwarf_pc_mips64, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
- DEFINE_GPR_INFO(config5, NULL, gcc_dwarf_config5_mips64, gcc_dwarf_config5_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f0, NULL, gcc_dwarf_f0_mips64, gcc_dwarf_f0_mips64, LLDB_INVALID_REGNUM, gdb_f0_mips64),
- DEFINE_FPR (f1, NULL, gcc_dwarf_f1_mips64, gcc_dwarf_f1_mips64, LLDB_INVALID_REGNUM, gdb_f1_mips64),
- DEFINE_FPR (f2, NULL, gcc_dwarf_f2_mips64, gcc_dwarf_f2_mips64, LLDB_INVALID_REGNUM, gdb_f2_mips64),
- DEFINE_FPR (f3, NULL, gcc_dwarf_f3_mips64, gcc_dwarf_f3_mips64, LLDB_INVALID_REGNUM, gdb_f3_mips64),
- DEFINE_FPR (f4, NULL, gcc_dwarf_f4_mips64, gcc_dwarf_f4_mips64, LLDB_INVALID_REGNUM, gdb_f4_mips64),
- DEFINE_FPR (f5, NULL, gcc_dwarf_f5_mips64, gcc_dwarf_f5_mips64, LLDB_INVALID_REGNUM, gdb_f5_mips64),
- DEFINE_FPR (f6, NULL, gcc_dwarf_f6_mips64, gcc_dwarf_f6_mips64, LLDB_INVALID_REGNUM, gdb_f6_mips64),
- DEFINE_FPR (f7, NULL, gcc_dwarf_f7_mips64, gcc_dwarf_f7_mips64, LLDB_INVALID_REGNUM, gdb_f7_mips64),
- DEFINE_FPR (f8, NULL, gcc_dwarf_f8_mips64, gcc_dwarf_f8_mips64, LLDB_INVALID_REGNUM, gdb_f8_mips64),
- DEFINE_FPR (f9, NULL, gcc_dwarf_f9_mips64, gcc_dwarf_f9_mips64, LLDB_INVALID_REGNUM, gdb_f9_mips64),
- DEFINE_FPR (f10, NULL, gcc_dwarf_f10_mips64, gcc_dwarf_f10_mips64, LLDB_INVALID_REGNUM, gdb_f10_mips64),
- DEFINE_FPR (f11, NULL, gcc_dwarf_f11_mips64, gcc_dwarf_f11_mips64, LLDB_INVALID_REGNUM, gdb_f11_mips64),
- DEFINE_FPR (f12, NULL, gcc_dwarf_f12_mips64, gcc_dwarf_f12_mips64, LLDB_INVALID_REGNUM, gdb_f12_mips64),
- DEFINE_FPR (f13, NULL, gcc_dwarf_f13_mips64, gcc_dwarf_f13_mips64, LLDB_INVALID_REGNUM, gdb_f13_mips64),
- DEFINE_FPR (f14, NULL, gcc_dwarf_f14_mips64, gcc_dwarf_f14_mips64, LLDB_INVALID_REGNUM, gdb_f14_mips64),
- DEFINE_FPR (f15, NULL, gcc_dwarf_f15_mips64, gcc_dwarf_f15_mips64, LLDB_INVALID_REGNUM, gdb_f15_mips64),
- DEFINE_FPR (f16, NULL, gcc_dwarf_f16_mips64, gcc_dwarf_f16_mips64, LLDB_INVALID_REGNUM, gdb_f16_mips64),
- DEFINE_FPR (f17, NULL, gcc_dwarf_f17_mips64, gcc_dwarf_f17_mips64, LLDB_INVALID_REGNUM, gdb_f17_mips64),
- DEFINE_FPR (f18, NULL, gcc_dwarf_f18_mips64, gcc_dwarf_f18_mips64, LLDB_INVALID_REGNUM, gdb_f18_mips64),
- DEFINE_FPR (f19, NULL, gcc_dwarf_f19_mips64, gcc_dwarf_f19_mips64, LLDB_INVALID_REGNUM, gdb_f19_mips64),
- DEFINE_FPR (f20, NULL, gcc_dwarf_f20_mips64, gcc_dwarf_f20_mips64, LLDB_INVALID_REGNUM, gdb_f20_mips64),
- DEFINE_FPR (f21, NULL, gcc_dwarf_f21_mips64, gcc_dwarf_f21_mips64, LLDB_INVALID_REGNUM, gdb_f21_mips64),
- DEFINE_FPR (f22, NULL, gcc_dwarf_f22_mips64, gcc_dwarf_f22_mips64, LLDB_INVALID_REGNUM, gdb_f22_mips64),
- DEFINE_FPR (f23, NULL, gcc_dwarf_f23_mips64, gcc_dwarf_f23_mips64, LLDB_INVALID_REGNUM, gdb_f23_mips64),
- DEFINE_FPR (f24, NULL, gcc_dwarf_f24_mips64, gcc_dwarf_f24_mips64, LLDB_INVALID_REGNUM, gdb_f24_mips64),
- DEFINE_FPR (f25, NULL, gcc_dwarf_f25_mips64, gcc_dwarf_f25_mips64, LLDB_INVALID_REGNUM, gdb_f25_mips64),
- DEFINE_FPR (f26, NULL, gcc_dwarf_f26_mips64, gcc_dwarf_f26_mips64, LLDB_INVALID_REGNUM, gdb_f26_mips64),
- DEFINE_FPR (f27, NULL, gcc_dwarf_f27_mips64, gcc_dwarf_f27_mips64, LLDB_INVALID_REGNUM, gdb_f27_mips64),
- DEFINE_FPR (f28, NULL, gcc_dwarf_f28_mips64, gcc_dwarf_f28_mips64, LLDB_INVALID_REGNUM, gdb_f28_mips64),
- DEFINE_FPR (f29, NULL, gcc_dwarf_f29_mips64, gcc_dwarf_f29_mips64, LLDB_INVALID_REGNUM, gdb_f29_mips64),
- DEFINE_FPR (f30, NULL, gcc_dwarf_f30_mips64, gcc_dwarf_f30_mips64, LLDB_INVALID_REGNUM, gdb_f30_mips64),
- DEFINE_FPR (f31, NULL, gcc_dwarf_f31_mips64, gcc_dwarf_f31_mips64, LLDB_INVALID_REGNUM, gdb_f31_mips64),
- DEFINE_FPR (fcsr, NULL, gcc_dwarf_fcsr_mips64, gcc_dwarf_fcsr_mips64, LLDB_INVALID_REGNUM, gdb_fcsr_mips64),
- DEFINE_FPR (fir, NULL, gcc_dwarf_fir_mips64, gcc_dwarf_fir_mips64, LLDB_INVALID_REGNUM, gdb_fir_mips64),
- DEFINE_FPR (config5, NULL, gcc_dwarf_config5_mips64, gcc_dwarf_config5_mips64, LLDB_INVALID_REGNUM, gdb_config5_mips64),
- DEFINE_MSA (w0, NULL, gcc_dwarf_w0_mips64, gcc_dwarf_w0_mips64, LLDB_INVALID_REGNUM, gdb_w0_mips64),
- DEFINE_MSA (w1, NULL, gcc_dwarf_w1_mips64, gcc_dwarf_w1_mips64, LLDB_INVALID_REGNUM, gdb_w1_mips64),
- DEFINE_MSA (w2, NULL, gcc_dwarf_w2_mips64, gcc_dwarf_w2_mips64, LLDB_INVALID_REGNUM, gdb_w2_mips64),
- DEFINE_MSA (w3, NULL, gcc_dwarf_w3_mips64, gcc_dwarf_w3_mips64, LLDB_INVALID_REGNUM, gdb_w3_mips64),
- DEFINE_MSA (w4, NULL, gcc_dwarf_w4_mips64, gcc_dwarf_w4_mips64, LLDB_INVALID_REGNUM, gdb_w4_mips64),
- DEFINE_MSA (w5, NULL, gcc_dwarf_w5_mips64, gcc_dwarf_w5_mips64, LLDB_INVALID_REGNUM, gdb_w5_mips64),
- DEFINE_MSA (w6, NULL, gcc_dwarf_w6_mips64, gcc_dwarf_w6_mips64, LLDB_INVALID_REGNUM, gdb_w6_mips64),
- DEFINE_MSA (w7, NULL, gcc_dwarf_w7_mips64, gcc_dwarf_w7_mips64, LLDB_INVALID_REGNUM, gdb_w7_mips64),
- DEFINE_MSA (w8, NULL, gcc_dwarf_w8_mips64, gcc_dwarf_w8_mips64, LLDB_INVALID_REGNUM, gdb_w8_mips64),
- DEFINE_MSA (w9, NULL, gcc_dwarf_w9_mips64, gcc_dwarf_w9_mips64, LLDB_INVALID_REGNUM, gdb_w9_mips64),
- DEFINE_MSA (w10, NULL, gcc_dwarf_w10_mips64, gcc_dwarf_w10_mips64, LLDB_INVALID_REGNUM, gdb_w10_mips64),
- DEFINE_MSA (w11, NULL, gcc_dwarf_w11_mips64, gcc_dwarf_w11_mips64, LLDB_INVALID_REGNUM, gdb_w11_mips64),
- DEFINE_MSA (w12, NULL, gcc_dwarf_w12_mips64, gcc_dwarf_w12_mips64, LLDB_INVALID_REGNUM, gdb_w12_mips64),
- DEFINE_MSA (w13, NULL, gcc_dwarf_w13_mips64, gcc_dwarf_w13_mips64, LLDB_INVALID_REGNUM, gdb_w13_mips64),
- DEFINE_MSA (w14, NULL, gcc_dwarf_w14_mips64, gcc_dwarf_w14_mips64, LLDB_INVALID_REGNUM, gdb_w14_mips64),
- DEFINE_MSA (w15, NULL, gcc_dwarf_w15_mips64, gcc_dwarf_w15_mips64, LLDB_INVALID_REGNUM, gdb_w15_mips64),
- DEFINE_MSA (w16, NULL, gcc_dwarf_w16_mips64, gcc_dwarf_w16_mips64, LLDB_INVALID_REGNUM, gdb_w16_mips64),
- DEFINE_MSA (w17, NULL, gcc_dwarf_w17_mips64, gcc_dwarf_w17_mips64, LLDB_INVALID_REGNUM, gdb_w17_mips64),
- DEFINE_MSA (w18, NULL, gcc_dwarf_w18_mips64, gcc_dwarf_w18_mips64, LLDB_INVALID_REGNUM, gdb_w18_mips64),
- DEFINE_MSA (w19, NULL, gcc_dwarf_w19_mips64, gcc_dwarf_w19_mips64, LLDB_INVALID_REGNUM, gdb_w19_mips64),
- DEFINE_MSA (w20, NULL, gcc_dwarf_w10_mips64, gcc_dwarf_w20_mips64, LLDB_INVALID_REGNUM, gdb_w20_mips64),
- DEFINE_MSA (w21, NULL, gcc_dwarf_w21_mips64, gcc_dwarf_w21_mips64, LLDB_INVALID_REGNUM, gdb_w21_mips64),
- DEFINE_MSA (w22, NULL, gcc_dwarf_w22_mips64, gcc_dwarf_w22_mips64, LLDB_INVALID_REGNUM, gdb_w22_mips64),
- DEFINE_MSA (w23, NULL, gcc_dwarf_w23_mips64, gcc_dwarf_w23_mips64, LLDB_INVALID_REGNUM, gdb_w23_mips64),
- DEFINE_MSA (w24, NULL, gcc_dwarf_w24_mips64, gcc_dwarf_w24_mips64, LLDB_INVALID_REGNUM, gdb_w24_mips64),
- DEFINE_MSA (w25, NULL, gcc_dwarf_w25_mips64, gcc_dwarf_w25_mips64, LLDB_INVALID_REGNUM, gdb_w25_mips64),
- DEFINE_MSA (w26, NULL, gcc_dwarf_w26_mips64, gcc_dwarf_w26_mips64, LLDB_INVALID_REGNUM, gdb_w26_mips64),
- DEFINE_MSA (w27, NULL, gcc_dwarf_w27_mips64, gcc_dwarf_w27_mips64, LLDB_INVALID_REGNUM, gdb_w27_mips64),
- DEFINE_MSA (w28, NULL, gcc_dwarf_w28_mips64, gcc_dwarf_w28_mips64, LLDB_INVALID_REGNUM, gdb_w28_mips64),
- DEFINE_MSA (w29, NULL, gcc_dwarf_w29_mips64, gcc_dwarf_w29_mips64, LLDB_INVALID_REGNUM, gdb_w29_mips64),
- DEFINE_MSA (w30, NULL, gcc_dwarf_w30_mips64, gcc_dwarf_w30_mips64, LLDB_INVALID_REGNUM, gdb_w30_mips64),
- DEFINE_MSA (w31, NULL, gcc_dwarf_w31_mips64, gcc_dwarf_w31_mips64, LLDB_INVALID_REGNUM, gdb_w31_mips64),
- DEFINE_MSA_INFO (mcsr, NULL, gcc_dwarf_mcsr_mips64, gcc_dwarf_mcsr_mips64, LLDB_INVALID_REGNUM, gdb_mcsr_mips64),
- DEFINE_MSA_INFO (mir, NULL, gcc_dwarf_mir_mips64, gcc_dwarf_mir_mips64, LLDB_INVALID_REGNUM, gdb_mir_mips64),
- DEFINE_MSA_INFO (fcsr, NULL, gcc_dwarf_fcsr_mips64, gcc_dwarf_fcsr_mips64, LLDB_INVALID_REGNUM, gdb_fcsr_mips64),
- DEFINE_MSA_INFO (fir, NULL, gcc_dwarf_fir_mips64, gcc_dwarf_fir_mips64, LLDB_INVALID_REGNUM, gdb_fir_mips64),
- DEFINE_MSA_INFO (config5, NULL, gcc_dwarf_config5_mips64, gcc_dwarf_config5_mips64, LLDB_INVALID_REGNUM, gdb_config5_mips64)
+ DEFINE_GPR(zero, "r0", dwarf_zero_mips64, dwarf_zero_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r1, nullptr, dwarf_r1_mips64, dwarf_r1_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r2, nullptr, dwarf_r2_mips64, dwarf_r2_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r3, nullptr, dwarf_r3_mips64, dwarf_r3_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r4, nullptr, dwarf_r4_mips64, dwarf_r4_mips64, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r5, nullptr, dwarf_r5_mips64, dwarf_r5_mips64, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r6, nullptr, dwarf_r6_mips64, dwarf_r6_mips64, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r7, nullptr, dwarf_r7_mips64, dwarf_r7_mips64, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r8, nullptr, dwarf_r8_mips64, dwarf_r8_mips64, LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r9, nullptr, dwarf_r9_mips64, dwarf_r9_mips64, LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r10, nullptr, dwarf_r10_mips64, dwarf_r10_mips64, LLDB_REGNUM_GENERIC_ARG7, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r11, nullptr, dwarf_r11_mips64, dwarf_r11_mips64, LLDB_REGNUM_GENERIC_ARG8, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r12, nullptr, dwarf_r12_mips64, dwarf_r12_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r13, nullptr, dwarf_r13_mips64, dwarf_r13_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r14, nullptr, dwarf_r14_mips64, dwarf_r14_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r15, nullptr, dwarf_r15_mips64, dwarf_r15_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r16, nullptr, dwarf_r16_mips64, dwarf_r16_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r17, nullptr, dwarf_r17_mips64, dwarf_r17_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r18, nullptr, dwarf_r18_mips64, dwarf_r18_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r19, nullptr, dwarf_r19_mips64, dwarf_r19_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r20, nullptr, dwarf_r20_mips64, dwarf_r20_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r21, nullptr, dwarf_r21_mips64, dwarf_r21_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r22, nullptr, dwarf_r22_mips64, dwarf_r22_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r23, nullptr, dwarf_r23_mips64, dwarf_r23_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r24, nullptr, dwarf_r24_mips64, dwarf_r24_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r25, nullptr, dwarf_r25_mips64, dwarf_r25_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r26, nullptr, dwarf_r26_mips64, dwarf_r26_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r27, nullptr, dwarf_r27_mips64, dwarf_r27_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(gp, "r28", dwarf_gp_mips64, dwarf_gp_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(sp, "r29", dwarf_sp_mips64, dwarf_sp_mips64, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r30, nullptr, dwarf_r30_mips64, dwarf_r30_mips64, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(ra, "r31", dwarf_ra_mips64, dwarf_ra_mips64, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM),
+ DEFINE_GPR_INFO(sr, nullptr, dwarf_sr_mips64, dwarf_sr_mips64, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(mullo, nullptr, dwarf_lo_mips64, dwarf_lo_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(mulhi, nullptr, dwarf_hi_mips64, dwarf_hi_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(badvaddr, nullptr, dwarf_bad_mips64, dwarf_bad_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR_INFO(cause, nullptr, dwarf_cause_mips64, dwarf_cause_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(pc, "pc", dwarf_pc_mips64, dwarf_pc_mips64, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
+ DEFINE_GPR_INFO(config5, nullptr, dwarf_config5_mips64, dwarf_config5_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f0, nullptr, dwarf_f0_mips64, dwarf_f0_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f1, nullptr, dwarf_f1_mips64, dwarf_f1_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f2, nullptr, dwarf_f2_mips64, dwarf_f2_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f3, nullptr, dwarf_f3_mips64, dwarf_f3_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f4, nullptr, dwarf_f4_mips64, dwarf_f4_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f5, nullptr, dwarf_f5_mips64, dwarf_f5_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f6, nullptr, dwarf_f6_mips64, dwarf_f6_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f7, nullptr, dwarf_f7_mips64, dwarf_f7_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f8, nullptr, dwarf_f8_mips64, dwarf_f8_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f9, nullptr, dwarf_f9_mips64, dwarf_f9_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f10, nullptr, dwarf_f10_mips64, dwarf_f10_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f11, nullptr, dwarf_f11_mips64, dwarf_f11_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f12, nullptr, dwarf_f12_mips64, dwarf_f12_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f13, nullptr, dwarf_f13_mips64, dwarf_f13_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f14, nullptr, dwarf_f14_mips64, dwarf_f14_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f15, nullptr, dwarf_f15_mips64, dwarf_f15_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f16, nullptr, dwarf_f16_mips64, dwarf_f16_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f17, nullptr, dwarf_f17_mips64, dwarf_f17_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f18, nullptr, dwarf_f18_mips64, dwarf_f18_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f19, nullptr, dwarf_f19_mips64, dwarf_f19_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f20, nullptr, dwarf_f20_mips64, dwarf_f20_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f21, nullptr, dwarf_f21_mips64, dwarf_f21_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f22, nullptr, dwarf_f22_mips64, dwarf_f22_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f23, nullptr, dwarf_f23_mips64, dwarf_f23_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f24, nullptr, dwarf_f24_mips64, dwarf_f24_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f25, nullptr, dwarf_f25_mips64, dwarf_f25_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f26, nullptr, dwarf_f26_mips64, dwarf_f26_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f27, nullptr, dwarf_f27_mips64, dwarf_f27_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f28, nullptr, dwarf_f28_mips64, dwarf_f28_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f29, nullptr, dwarf_f29_mips64, dwarf_f29_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f30, nullptr, dwarf_f30_mips64, dwarf_f30_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (f31, nullptr, dwarf_f31_mips64, dwarf_f31_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (fcsr, nullptr, dwarf_fcsr_mips64, dwarf_fcsr_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (fir, nullptr, dwarf_fir_mips64, dwarf_fir_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR (config5, nullptr, dwarf_config5_mips64, dwarf_config5_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w0, nullptr, dwarf_w0_mips64, dwarf_w0_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w1, nullptr, dwarf_w1_mips64, dwarf_w1_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w2, nullptr, dwarf_w2_mips64, dwarf_w2_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w3, nullptr, dwarf_w3_mips64, dwarf_w3_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w4, nullptr, dwarf_w4_mips64, dwarf_w4_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w5, nullptr, dwarf_w5_mips64, dwarf_w5_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w6, nullptr, dwarf_w6_mips64, dwarf_w6_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w7, nullptr, dwarf_w7_mips64, dwarf_w7_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w8, nullptr, dwarf_w8_mips64, dwarf_w8_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w9, nullptr, dwarf_w9_mips64, dwarf_w9_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w10, nullptr, dwarf_w10_mips64, dwarf_w10_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w11, nullptr, dwarf_w11_mips64, dwarf_w11_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w12, nullptr, dwarf_w12_mips64, dwarf_w12_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w13, nullptr, dwarf_w13_mips64, dwarf_w13_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w14, nullptr, dwarf_w14_mips64, dwarf_w14_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w15, nullptr, dwarf_w15_mips64, dwarf_w15_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w16, nullptr, dwarf_w16_mips64, dwarf_w16_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w17, nullptr, dwarf_w17_mips64, dwarf_w17_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w18, nullptr, dwarf_w18_mips64, dwarf_w18_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w19, nullptr, dwarf_w19_mips64, dwarf_w19_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w20, nullptr, dwarf_w10_mips64, dwarf_w20_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w21, nullptr, dwarf_w21_mips64, dwarf_w21_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w22, nullptr, dwarf_w22_mips64, dwarf_w22_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w23, nullptr, dwarf_w23_mips64, dwarf_w23_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w24, nullptr, dwarf_w24_mips64, dwarf_w24_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w25, nullptr, dwarf_w25_mips64, dwarf_w25_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w26, nullptr, dwarf_w26_mips64, dwarf_w26_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w27, nullptr, dwarf_w27_mips64, dwarf_w27_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w28, nullptr, dwarf_w28_mips64, dwarf_w28_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w29, nullptr, dwarf_w29_mips64, dwarf_w29_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w30, nullptr, dwarf_w30_mips64, dwarf_w30_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA (w31, nullptr, dwarf_w31_mips64, dwarf_w31_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA_INFO (mcsr, nullptr, dwarf_mcsr_mips64, dwarf_mcsr_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA_INFO (mir, nullptr, dwarf_mir_mips64, dwarf_mir_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA_INFO (fcsr, nullptr, dwarf_fcsr_mips64, dwarf_fcsr_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA_INFO (fir, nullptr, dwarf_fir_mips64, dwarf_fir_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA_INFO (config5, nullptr, dwarf_config5_mips64, dwarf_config5_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM)
#endif
};
diff --git a/source/Plugins/Process/Utility/RegisterInfos_powerpc.h b/source/Plugins/Process/Utility/RegisterInfos_powerpc.h
index fe145e99588b..95347ae51592 100644
--- a/source/Plugins/Process/Utility/RegisterInfos_powerpc.h
+++ b/source/Plugins/Process/Utility/RegisterInfos_powerpc.h
@@ -24,15 +24,15 @@
// Note that the size and offset will be updated by platform-specific classes.
#define DEFINE_GPR(reg, alt, lldb_kind) \
{ #reg, alt, GPR_SIZE(reg), GPR_OFFSET(reg), eEncodingUint, \
- eFormatHex, { gcc_dwarf_##reg##_powerpc, gcc_dwarf_##reg##_powerpc, lldb_kind, gdb_##reg##_powerpc, gpr_##reg##_powerpc }, NULL, NULL }
+ eFormatHex, { dwarf_##reg##_powerpc, dwarf_##reg##_powerpc, lldb_kind, LLDB_INVALID_REGNUM, gpr_##reg##_powerpc }, NULL, NULL }
#define DEFINE_FPR(reg, lldb_kind) \
{ #reg, NULL, 8, FPR_OFFSET(reg), eEncodingIEEE754, \
- eFormatFloat, { gcc_dwarf_##reg##_powerpc, gcc_dwarf_##reg##_powerpc, lldb_kind, gdb_##reg##_powerpc, fpr_##reg##_powerpc }, NULL, NULL }
+ eFormatFloat, { dwarf_##reg##_powerpc, dwarf_##reg##_powerpc, lldb_kind, LLDB_INVALID_REGNUM, fpr_##reg##_powerpc }, NULL, NULL }
#define DEFINE_VMX(reg, lldb_kind) \
{ #reg, NULL, 16, VMX_OFFSET(reg), eEncodingVector, \
- eFormatVectorOfUInt32, { gcc_dwarf_##reg##_powerpc, gcc_dwarf_##reg##_powerpc, lldb_kind, gdb_##reg##_powerpc, vmx_##reg##_powerpc }, NULL, NULL }
+ eFormatVectorOfUInt32, { dwarf_##reg##_powerpc, dwarf_##reg##_powerpc, lldb_kind, LLDB_INVALID_REGNUM, vmx_##reg##_powerpc }, NULL, NULL }
- // General purpose registers. GCC, DWARF, Generic, GDB
+ // General purpose registers. EH_Frame, DWARF, Generic, Process Plugin
#define POWERPC_REGS \
DEFINE_GPR(r0, NULL, LLDB_INVALID_REGNUM), \
DEFINE_GPR(r1, "sp", LLDB_REGNUM_GENERIC_SP), \
@@ -103,7 +103,7 @@
DEFINE_FPR(f29, LLDB_INVALID_REGNUM), \
DEFINE_FPR(f30, LLDB_INVALID_REGNUM), \
DEFINE_FPR(f31, LLDB_INVALID_REGNUM), \
- { "fpscr", NULL, 8, FPR_OFFSET(fpscr), eEncodingUint, eFormatHex, { gcc_dwarf_fpscr_powerpc, gcc_dwarf_fpscr_powerpc, LLDB_INVALID_REGNUM, gdb_fpscr_powerpc, fpr_fpscr_powerpc }, NULL, NULL }, \
+ { "fpscr", NULL, 8, FPR_OFFSET(fpscr), eEncodingUint, eFormatHex, { dwarf_fpscr_powerpc, dwarf_fpscr_powerpc, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpr_fpscr_powerpc }, NULL, NULL }, \
DEFINE_VMX(v0, LLDB_INVALID_REGNUM), \
DEFINE_VMX(v1, LLDB_INVALID_REGNUM), \
DEFINE_VMX(v2, LLDB_INVALID_REGNUM), \
@@ -136,8 +136,8 @@
DEFINE_VMX(v29, LLDB_INVALID_REGNUM), \
DEFINE_VMX(v30, LLDB_INVALID_REGNUM), \
DEFINE_VMX(v31, LLDB_INVALID_REGNUM), \
- { "vrsave", NULL, 4, VMX_OFFSET(vrsave), eEncodingUint, eFormatHex, { gcc_dwarf_vrsave_powerpc, gcc_dwarf_vrsave_powerpc, LLDB_INVALID_REGNUM, gdb_vrsave_powerpc, vmx_vrsave_powerpc }, NULL, NULL }, \
- { "vscr", NULL, 4, VMX_OFFSET(vscr), eEncodingUint, eFormatHex, { gcc_dwarf_vscr_powerpc, gcc_dwarf_vscr_powerpc, LLDB_INVALID_REGNUM, gdb_vscr_powerpc, vmx_vscr_powerpc }, NULL, NULL },
+ { "vrsave", NULL, 4, VMX_OFFSET(vrsave), eEncodingUint, eFormatHex, { dwarf_vrsave_powerpc, dwarf_vrsave_powerpc, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, vmx_vrsave_powerpc }, NULL, NULL }, \
+ { "vscr", NULL, 4, VMX_OFFSET(vscr), eEncodingUint, eFormatHex, { dwarf_vscr_powerpc, dwarf_vscr_powerpc, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, vmx_vscr_powerpc }, NULL, NULL },
static RegisterInfo
g_register_infos_powerpc64[] =
diff --git a/source/Plugins/Process/Utility/RegisterInfos_x86_64.h b/source/Plugins/Process/Utility/RegisterInfos_x86_64.h
index 5da74ff83487..a393089dd129 100644
--- a/source/Plugins/Process/Utility/RegisterInfos_x86_64.h
+++ b/source/Plugins/Process/Utility/RegisterInfos_x86_64.h
@@ -1,15 +1,21 @@
-//===-- RegisterInfos_x86_64.h ---------------------------------*- C++ -*-===//
+//===-- 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.
//
-//===---------------------------------------------------------------------===//
-#include "llvm/Support/Compiler.h"
+//===----------------------------------------------------------------------===//
+// C Includes
#include <stddef.h>
+// C++ Includes
+// Other libraries and framework includes
+#include "llvm/Support/Compiler.h"
+
+// Project includes
+
// Computes the offset of the given GPR in the user data area.
#define GPR_OFFSET(regname) \
(LLVM_EXTENSION offsetof(GPR, regname))
@@ -44,7 +50,7 @@
#define DR_SIZE sizeof(((DBG*)NULL)->dr[0])
-// RegisterKind: GCC, DWARF, Generic, GDB, LLDB
+// RegisterKind: EHFrame, DWARF, Generic, Process Plugin, LLDB
// Note that the size and offset will be updated by platform-specific classes.
#define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \
@@ -58,25 +64,25 @@
#define DEFINE_FP_ST(reg, i) \
{ #reg#i, NULL, FP_SIZE, LLVM_EXTENSION FPR_OFFSET(stmm[i]), \
eEncodingVector, eFormatVectorOfUInt8, \
- { gcc_dwarf_st##i##_x86_64, gcc_dwarf_st##i##_x86_64, LLDB_INVALID_REGNUM, gdb_st##i##_x86_64, lldb_st##i##_x86_64 }, \
+ { dwarf_st##i##_x86_64, dwarf_st##i##_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_st##i##_x86_64 }, \
NULL, NULL }
#define DEFINE_FP_MM(reg, i) \
{ #reg#i, NULL, sizeof(uint64_t), LLVM_EXTENSION FPR_OFFSET(stmm[i]), \
eEncodingUint, eFormatHex, \
- { gcc_dwarf_mm##i##_x86_64, gcc_dwarf_mm##i##_x86_64, LLDB_INVALID_REGNUM, gdb_st##i##_x86_64, lldb_mm##i##_x86_64 }, \
+ { dwarf_mm##i##_x86_64, dwarf_mm##i##_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_mm##i##_x86_64 }, \
NULL, NULL }
#define DEFINE_XMM(reg, i) \
{ #reg#i, NULL, XMM_SIZE, LLVM_EXTENSION FPR_OFFSET(reg[i]), \
eEncodingVector, eFormatVectorOfUInt8, \
- { gcc_dwarf_##reg##i##_x86_64, gcc_dwarf_##reg##i##_x86_64, LLDB_INVALID_REGNUM, gdb_##reg##i##_x86_64, lldb_##reg##i##_x86_64}, \
+ { dwarf_##reg##i##_x86_64, dwarf_##reg##i##_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_##reg##i##_x86_64}, \
NULL, NULL }
#define DEFINE_YMM(reg, i) \
{ #reg#i, NULL, YMM_SIZE, LLVM_EXTENSION YMM_OFFSET(i), \
eEncodingVector, eFormatVectorOfUInt8, \
- { gcc_dwarf_##reg##i##h_x86_64, gcc_dwarf_##reg##i##h_x86_64, LLDB_INVALID_REGNUM, gdb_##reg##i##h_x86_64, lldb_##reg##i##_x86_64 }, \
+ { dwarf_##reg##i##h_x86_64, dwarf_##reg##i##h_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_##reg##i##_x86_64 }, \
NULL, NULL }
#define DEFINE_DR(reg, i) \
@@ -100,31 +106,31 @@
static RegisterInfo
g_register_infos_x86_64[] =
{
- // General purpose registers. GCC, DWARF, Generic, GDB
- DEFINE_GPR(rax, NULL, gcc_dwarf_rax_x86_64, gcc_dwarf_rax_x86_64, LLDB_INVALID_REGNUM, gdb_rax_x86_64),
- DEFINE_GPR(rbx, NULL, gcc_dwarf_rbx_x86_64, gcc_dwarf_rbx_x86_64, LLDB_INVALID_REGNUM, gdb_rbx_x86_64),
- DEFINE_GPR(rcx, "arg4", gcc_dwarf_rcx_x86_64, gcc_dwarf_rcx_x86_64, LLDB_REGNUM_GENERIC_ARG4, gdb_rcx_x86_64),
- DEFINE_GPR(rdx, "arg3", gcc_dwarf_rdx_x86_64, gcc_dwarf_rdx_x86_64, LLDB_REGNUM_GENERIC_ARG3, gdb_rdx_x86_64),
- DEFINE_GPR(rdi, "arg1", gcc_dwarf_rdi_x86_64, gcc_dwarf_rdi_x86_64, LLDB_REGNUM_GENERIC_ARG1, gdb_rdi_x86_64),
- DEFINE_GPR(rsi, "arg2", gcc_dwarf_rsi_x86_64, gcc_dwarf_rsi_x86_64, LLDB_REGNUM_GENERIC_ARG2, gdb_rsi_x86_64),
- DEFINE_GPR(rbp, "fp", gcc_dwarf_rbp_x86_64, gcc_dwarf_rbp_x86_64, LLDB_REGNUM_GENERIC_FP, gdb_rbp_x86_64),
- DEFINE_GPR(rsp, "sp", gcc_dwarf_rsp_x86_64, gcc_dwarf_rsp_x86_64, LLDB_REGNUM_GENERIC_SP, gdb_rsp_x86_64),
- DEFINE_GPR(r8, "arg5", gcc_dwarf_r8_x86_64, gcc_dwarf_r8_x86_64, LLDB_REGNUM_GENERIC_ARG5, gdb_r8_x86_64),
- DEFINE_GPR(r9, "arg6", gcc_dwarf_r9_x86_64, gcc_dwarf_r9_x86_64, LLDB_REGNUM_GENERIC_ARG6, gdb_r9_x86_64),
- DEFINE_GPR(r10, NULL, gcc_dwarf_r10_x86_64, gcc_dwarf_r10_x86_64, LLDB_INVALID_REGNUM, gdb_r10_x86_64),
- DEFINE_GPR(r11, NULL, gcc_dwarf_r11_x86_64, gcc_dwarf_r11_x86_64, LLDB_INVALID_REGNUM, gdb_r11_x86_64),
- DEFINE_GPR(r12, NULL, gcc_dwarf_r12_x86_64, gcc_dwarf_r12_x86_64, LLDB_INVALID_REGNUM, gdb_r12_x86_64),
- DEFINE_GPR(r13, NULL, gcc_dwarf_r13_x86_64, gcc_dwarf_r13_x86_64, LLDB_INVALID_REGNUM, gdb_r13_x86_64),
- DEFINE_GPR(r14, NULL, gcc_dwarf_r14_x86_64, gcc_dwarf_r14_x86_64, LLDB_INVALID_REGNUM, gdb_r14_x86_64),
- DEFINE_GPR(r15, NULL, gcc_dwarf_r15_x86_64, gcc_dwarf_r15_x86_64, LLDB_INVALID_REGNUM, gdb_r15_x86_64),
- DEFINE_GPR(rip, "pc", gcc_dwarf_rip_x86_64, gcc_dwarf_rip_x86_64, LLDB_REGNUM_GENERIC_PC, gdb_rip_x86_64),
- DEFINE_GPR(rflags, "flags", gcc_dwarf_rflags_x86_64, gcc_dwarf_rflags_x86_64, LLDB_REGNUM_GENERIC_FLAGS, gdb_rflags_x86_64),
- DEFINE_GPR(cs, NULL, gcc_dwarf_cs_x86_64, gcc_dwarf_cs_x86_64, LLDB_INVALID_REGNUM, gdb_cs_x86_64),
- DEFINE_GPR(fs, NULL, gcc_dwarf_fs_x86_64, gcc_dwarf_fs_x86_64, LLDB_INVALID_REGNUM, gdb_fs_x86_64),
- DEFINE_GPR(gs, NULL, gcc_dwarf_gs_x86_64, gcc_dwarf_gs_x86_64, LLDB_INVALID_REGNUM, gdb_gs_x86_64),
- DEFINE_GPR(ss, NULL, gcc_dwarf_ss_x86_64, gcc_dwarf_ss_x86_64, LLDB_INVALID_REGNUM, gdb_ss_x86_64),
- DEFINE_GPR(ds, NULL, gcc_dwarf_ds_x86_64, gcc_dwarf_ds_x86_64, LLDB_INVALID_REGNUM, gdb_ds_x86_64),
- DEFINE_GPR(es, NULL, gcc_dwarf_es_x86_64, gcc_dwarf_es_x86_64, LLDB_INVALID_REGNUM, gdb_es_x86_64),
+ // General purpose registers. EH_Frame, DWARF, Generic, Process Plugin
+ DEFINE_GPR(rax, nullptr, dwarf_rax_x86_64, dwarf_rax_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(rbx, nullptr, dwarf_rbx_x86_64, dwarf_rbx_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(rcx, "arg4", dwarf_rcx_x86_64, dwarf_rcx_x86_64, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(rdx, "arg3", dwarf_rdx_x86_64, dwarf_rdx_x86_64, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(rdi, "arg1", dwarf_rdi_x86_64, dwarf_rdi_x86_64, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(rsi, "arg2", dwarf_rsi_x86_64, dwarf_rsi_x86_64, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(rbp, "fp", dwarf_rbp_x86_64, dwarf_rbp_x86_64, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(rsp, "sp", dwarf_rsp_x86_64, dwarf_rsp_x86_64, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r8, "arg5", dwarf_r8_x86_64, dwarf_r8_x86_64, LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r9, "arg6", dwarf_r9_x86_64, dwarf_r9_x86_64, LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r10, nullptr, dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r11, nullptr, dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r12, nullptr, dwarf_r12_x86_64, dwarf_r12_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r13, nullptr, dwarf_r13_x86_64, dwarf_r13_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r14, nullptr, dwarf_r14_x86_64, dwarf_r14_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r15, nullptr, dwarf_r15_x86_64, dwarf_r15_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(rip, "pc", dwarf_rip_x86_64, dwarf_rip_x86_64, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(rflags, "flags", dwarf_rflags_x86_64, dwarf_rflags_x86_64, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(cs, nullptr, dwarf_cs_x86_64, dwarf_cs_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(fs, nullptr, dwarf_fs_x86_64, dwarf_fs_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(gs, nullptr, dwarf_gs_x86_64, dwarf_gs_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(ss, nullptr, dwarf_ss_x86_64, dwarf_ss_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(ds, nullptr, dwarf_ds_x86_64, dwarf_ds_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(es, nullptr, dwarf_es_x86_64, dwarf_es_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
DEFINE_GPR_PSEUDO_32(eax, rax),
DEFINE_GPR_PSEUDO_32(ebx, rbx),
@@ -179,16 +185,16 @@ g_register_infos_x86_64[] =
DEFINE_GPR_PSEUDO_8L(r14l, r14),
DEFINE_GPR_PSEUDO_8L(r15l, r15),
- // i387 Floating point registers. GCC, DWARF, Generic, GDB
- DEFINE_FPR(fctrl, fctrl, gcc_dwarf_fctrl_x86_64, gcc_dwarf_fctrl_x86_64, LLDB_INVALID_REGNUM, gdb_fctrl_x86_64),
- DEFINE_FPR(fstat, fstat, gcc_dwarf_fstat_x86_64, gcc_dwarf_fstat_x86_64, LLDB_INVALID_REGNUM, gdb_fstat_x86_64),
- DEFINE_FPR(ftag, ftag, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_ftag_x86_64),
- DEFINE_FPR(fop, fop, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_fop_x86_64),
- DEFINE_FPR(fiseg, ptr.i386_.fiseg, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_fiseg_x86_64),
- DEFINE_FPR(fioff, ptr.i386_.fioff, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_fioff_x86_64),
- DEFINE_FPR(foseg, ptr.i386_.foseg, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_foseg_x86_64),
- DEFINE_FPR(fooff, ptr.i386_.fooff, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_fooff_x86_64),
- DEFINE_FPR(mxcsr, mxcsr, gcc_dwarf_mxcsr_x86_64, gcc_dwarf_mxcsr_x86_64, LLDB_INVALID_REGNUM, gdb_mxcsr_x86_64),
+ // i387 Floating point registers. EH_frame, DWARF, Generic, Process Plugin
+ DEFINE_FPR(fctrl, fctrl, dwarf_fctrl_x86_64, dwarf_fctrl_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(fstat, fstat, dwarf_fstat_x86_64, dwarf_fstat_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(ftag, ftag, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(fop, fop, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(fiseg, ptr.i386_.fiseg, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(fioff, ptr.i386_.fioff, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(foseg, ptr.i386_.foseg, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(fooff, ptr.i386_.fooff, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(mxcsr, mxcsr, dwarf_mxcsr_x86_64, dwarf_mxcsr_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
DEFINE_FPR(mxcsrmask, mxcsrmask, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
// FP registers.
@@ -255,6 +261,7 @@ g_register_infos_x86_64[] =
DEFINE_DR(dr, 6),
DEFINE_DR(dr, 7)
};
+
static_assert((sizeof(g_register_infos_x86_64) / sizeof(g_register_infos_x86_64[0])) == k_num_registers_x86_64,
"g_register_infos_x86_64 has wrong number of register infos");
@@ -275,7 +282,6 @@ static_assert((sizeof(g_register_infos_x86_64) / sizeof(g_register_infos_x86_64[
#endif // DECLARE_REGISTER_INFOS_X86_64_STRUCT
-
#ifdef UPDATE_REGISTER_INFOS_I386_STRUCT_WITH_X86_64_OFFSETS
#define UPDATE_GPR_INFO(reg, reg64) \
diff --git a/source/Plugins/Process/Utility/StopInfoMachException.cpp b/source/Plugins/Process/Utility/StopInfoMachException.cpp
index 7c68d0d07821..3bf766e875c9 100644
--- a/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ b/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -58,6 +58,7 @@ StopInfoMachException::GetDescription ()
}
break;
case llvm::Triple::arm:
+ case llvm::Triple::thumb:
switch (m_exc_code)
{
case 0x101: code_desc = "EXC_ARM_DA_ALIGN"; break;
@@ -104,6 +105,7 @@ StopInfoMachException::GetDescription ()
break;
case llvm::Triple::arm:
+ case llvm::Triple::thumb:
if (m_exc_code == 1)
code_desc = "EXC_ARM_UNDEFINED";
break;
@@ -188,6 +190,7 @@ StopInfoMachException::GetDescription ()
break;
case llvm::Triple::arm:
+ case llvm::Triple::thumb:
switch (m_exc_code)
{
case 0x101: code_desc = "EXC_ARM_DA_ALIGN"; break;
@@ -408,6 +411,7 @@ StopInfoMachException::CreateStopReasonWithMachException
break;
case llvm::Triple::arm:
+ case llvm::Triple::thumb:
if (exc_code == 0x102) // EXC_ARM_DA_DEBUG
{
// It's a watchpoint, then, if the exc_sub_code indicates a known/enabled
diff --git a/source/Plugins/Process/Utility/StopInfoMachException.h b/source/Plugins/Process/Utility/StopInfoMachException.h
index 130ee0b709b0..25e05ecc1ec7 100644
--- a/source/Plugins/Process/Utility/StopInfoMachException.h
+++ b/source/Plugins/Process/Utility/StopInfoMachException.h
@@ -38,19 +38,16 @@ public:
{
}
- virtual ~StopInfoMachException()
- {
- }
+ ~StopInfoMachException() override = default;
-
- virtual lldb::StopReason
- GetStopReason () const
+ lldb::StopReason
+ GetStopReason() const override
{
return lldb::eStopReasonException;
}
- virtual const char *
- GetDescription ();
+ const char *
+ GetDescription() override;
// Since some mach exceptions will be reported as breakpoints, signals,
// or trace, we use this static accessor which will translate the mach
@@ -71,7 +68,6 @@ protected:
uint64_t m_exc_subcode;
};
-
} // namespace lldb_private
-#endif // liblldb_StopInfoMachException_h_
+#endif // liblldb_StopInfoMachException_h_
diff --git a/source/Plugins/Process/Utility/ThreadMemory.h b/source/Plugins/Process/Utility/ThreadMemory.h
index 07eb45dcb431..1e7cbfa44815 100644
--- a/source/Plugins/Process/Utility/ThreadMemory.h
+++ b/source/Plugins/Process/Utility/ThreadMemory.h
@@ -1,4 +1,4 @@
-//===-- ThreadMemory.h -----------------------------------------*- C++ -*-===//
+//===-- ThreadMemory.h ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,13 +10,18 @@
#ifndef liblldb_ThreadMemory_h_
#define liblldb_ThreadMemory_h_
+// C Includes
+// C++ Includes
+#include <string>
+
+// Other libraries and framework includes
+// Project includes
#include "lldb/Target/Thread.h"
class ThreadMemory :
public lldb_private::Thread
{
public:
-
ThreadMemory (lldb_private::Process &process,
lldb::tid_t tid,
const lldb::ValueObjectSP &thread_info_valobj_sp);
@@ -27,69 +32,65 @@ public:
const char *queue,
lldb::addr_t register_data_addr);
- virtual
- ~ThreadMemory();
+ ~ThreadMemory() override;
- //------------------------------------------------------------------
- // lldb_private::Thread methods
- //------------------------------------------------------------------
- virtual lldb::RegisterContextSP
- GetRegisterContext ();
+ lldb::RegisterContextSP
+ GetRegisterContext() override;
- virtual lldb::RegisterContextSP
- CreateRegisterContextForFrame (lldb_private::StackFrame *frame);
+ lldb::RegisterContextSP
+ CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
- virtual bool
- CalculateStopInfo ();
+ bool
+ CalculateStopInfo() override;
- virtual const char *
- GetInfo ()
+ const char *
+ GetInfo() override
{
if (m_backing_thread_sp)
m_backing_thread_sp->GetInfo();
- return NULL;
+ return nullptr;
}
- virtual const char *
- GetName ()
+ const char *
+ GetName() override
{
if (!m_name.empty())
return m_name.c_str();
if (m_backing_thread_sp)
m_backing_thread_sp->GetName();
- return NULL;
+ return nullptr;
}
- virtual const char *
- GetQueueName ()
+ const char *
+ GetQueueName() override
{
if (!m_queue.empty())
return m_queue.c_str();
if (m_backing_thread_sp)
m_backing_thread_sp->GetQueueName();
- return NULL;
+ return nullptr;
}
- virtual void
- WillResume (lldb::StateType resume_state);
+ void
+ WillResume(lldb::StateType resume_state) override;
- virtual void
- DidResume ()
+ void
+ DidResume() override
{
if (m_backing_thread_sp)
m_backing_thread_sp->DidResume();
}
- virtual lldb::user_id_t
- GetProtocolID () const
+ lldb::user_id_t
+ GetProtocolID() const override
{
if (m_backing_thread_sp)
return m_backing_thread_sp->GetProtocolID();
return Thread::GetProtocolID();
}
- virtual void
- RefreshStateAfterStop();
+ void
+ RefreshStateAfterStop() override;
lldb::ValueObjectSP &
GetValueObject ()
@@ -97,41 +98,36 @@ public:
return m_thread_info_valobj_sp;
}
- virtual void
- ClearStackFrames ();
+ void
+ ClearStackFrames() override;
- virtual void
- ClearBackingThread ()
+ void
+ ClearBackingThread() override
{
m_backing_thread_sp.reset();
}
- virtual bool
- SetBackingThread (const lldb::ThreadSP &thread_sp)
+ bool
+ SetBackingThread(const lldb::ThreadSP &thread_sp) override
{
//printf ("Thread 0x%llx is being backed by thread 0x%llx\n", GetID(), thread_sp->GetID());
m_backing_thread_sp = thread_sp;
return (bool)thread_sp;
}
- virtual lldb::ThreadSP
- GetBackingThread () const
+ lldb::ThreadSP
+ GetBackingThread() const override
{
return m_backing_thread_sp;
}
protected:
-
- virtual bool
- IsOperatingSystemPluginThread () const
+ bool
+ IsOperatingSystemPluginThread() const override
{
return true;
}
-
- //------------------------------------------------------------------
- // For ThreadMemory and subclasses
- //------------------------------------------------------------------
// If this memory thread is actually represented by a thread from the
// lldb_private::Process subclass, then fill in the thread here and
// all APIs will be routed through this thread object. If m_backing_thread_sp
@@ -142,11 +138,9 @@ protected:
std::string m_name;
std::string m_queue;
lldb::addr_t m_register_data_addr;
+
private:
- //------------------------------------------------------------------
- // For ThreadMemory only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (ThreadMemory);
};
-#endif // liblldb_ThreadMemory_h_
+#endif // liblldb_ThreadMemory_h_
diff --git a/source/Plugins/Process/Utility/UnwindLLDB.cpp b/source/Plugins/Process/Utility/UnwindLLDB.cpp
index 1cdae9011673..9be09c478a0e 100644
--- a/source/Plugins/Process/Utility/UnwindLLDB.cpp
+++ b/source/Plugins/Process/Utility/UnwindLLDB.cpp
@@ -86,6 +86,9 @@ UnwindLLDB::AddFirstFrame ()
if (m_frames.size() > 0)
return true;
+ ProcessSP process_sp (m_thread.GetProcess());
+ ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
+
// First, set up the 0th (initial) frame
CursorSP first_cursor_sp(new Cursor ());
RegisterContextLLDBSP reg_ctx_sp (new RegisterContextLLDB (m_thread,
@@ -108,6 +111,10 @@ UnwindLLDB::AddFirstFrame ()
// cursor own it in its shared pointer
first_cursor_sp->reg_ctx_lldb_sp = reg_ctx_sp;
m_frames.push_back (first_cursor_sp);
+
+ // Update the Full Unwind Plan for this frame if not valid
+ UpdateUnwindPlanForFirstFrameIfInvalid(abi);
+
return true;
unwind_done:
@@ -161,7 +168,14 @@ UnwindLLDB::GetOneMoreFrame (ABI* abi)
// If the RegisterContextLLDB has a fallback UnwindPlan, it will switch to that and return
// true. Subsequent calls to TryFallbackUnwindPlan() will return false.
if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan())
+ {
+ // TryFallbackUnwindPlan for prev_frame succeeded and updated reg_ctx_lldb_sp field of
+ // prev_frame. However, cfa field of prev_frame still needs to be updated. Hence updating it.
+ if ( !(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa)))
+ return nullptr;
+
return GetOneMoreFrame (abi);
+ }
if (log)
log->Printf ("%*sFrame %d did not get a RegisterContext, stopping.",
@@ -175,7 +189,14 @@ UnwindLLDB::GetOneMoreFrame (ABI* abi)
// See if the regctx below this on the stack has a fallback unwind plan it can use.
// Subsequent calls to TryFallbackUnwindPlan() will return false.
if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan())
+ {
+ // TryFallbackUnwindPlan for prev_frame succeeded and updated reg_ctx_lldb_sp field of
+ // prev_frame. However, cfa field of prev_frame still needs to be updated. Hence updating it.
+ if ( !(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa)))
+ return nullptr;
+
return GetOneMoreFrame (abi);
+ }
if (log)
log->Printf("%*sFrame %d invalid RegisterContext for this frame, stopping stack walk",
@@ -187,7 +208,14 @@ UnwindLLDB::GetOneMoreFrame (ABI* abi)
// If the RegisterContextLLDB has a fallback UnwindPlan, it will switch to that and return
// true. Subsequent calls to TryFallbackUnwindPlan() will return false.
if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan())
+ {
+ // TryFallbackUnwindPlan for prev_frame succeeded and updated reg_ctx_lldb_sp field of
+ // prev_frame. However, cfa field of prev_frame still needs to be updated. Hence updating it.
+ if ( !(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa)))
+ return nullptr;
+
return GetOneMoreFrame (abi);
+ }
if (log)
log->Printf("%*sFrame %d did not get CFA for this frame, stopping stack walk",
@@ -212,7 +240,14 @@ UnwindLLDB::GetOneMoreFrame (ABI* abi)
|| abi->CallFrameAddressIsValid(cursor_sp->cfa) == false)
{
if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan())
+ {
+ // TryFallbackUnwindPlan for prev_frame succeeded and updated reg_ctx_lldb_sp field of
+ // prev_frame. However, cfa field of prev_frame still needs to be updated. Hence updating it.
+ if ( !(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa)))
+ return nullptr;
+
return GetOneMoreFrame (abi);
+ }
if (log)
log->Printf("%*sFrame %d did not get a valid CFA for this frame, stopping stack walk",
@@ -232,7 +267,14 @@ UnwindLLDB::GetOneMoreFrame (ABI* abi)
// If the RegisterContextLLDB has a fallback UnwindPlan, it will switch to that and return
// true. Subsequent calls to TryFallbackUnwindPlan() will return false.
if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan())
+ {
+ // TryFallbackUnwindPlan for prev_frame succeeded and updated reg_ctx_lldb_sp field of
+ // prev_frame. However, cfa field of prev_frame still needs to be updated. Hence updating it.
+ if ( !(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa)))
+ return nullptr;
+
return GetOneMoreFrame (abi);
+ }
if (log)
log->Printf("%*sFrame %d did not get PC for this frame, stopping stack walk",
@@ -244,7 +286,14 @@ UnwindLLDB::GetOneMoreFrame (ABI* abi)
// If the RegisterContextLLDB has a fallback UnwindPlan, it will switch to that and return
// true. Subsequent calls to TryFallbackUnwindPlan() will return false.
if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan())
+ {
+ // TryFallbackUnwindPlan for prev_frame succeeded and updated reg_ctx_lldb_sp field of
+ // prev_frame. However, cfa field of prev_frame still needs to be updated. Hence updating it.
+ if ( !(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa)))
+ return nullptr;
+
return GetOneMoreFrame (abi);
+ }
if (log)
log->Printf("%*sFrame %d did not get a valid PC, stopping stack walk",
@@ -263,6 +312,33 @@ UnwindLLDB::GetOneMoreFrame (ABI* abi)
return cursor_sp;
}
+void
+UnwindLLDB::UpdateUnwindPlanForFirstFrameIfInvalid (ABI *abi)
+{
+ // This function is called for First Frame only.
+ assert (m_frames.size() == 1 && "No. of cursor frames are not 1");
+
+ bool old_m_unwind_complete = m_unwind_complete;
+ CursorSP old_m_candidate_frame = m_candidate_frame;
+
+ // Try to unwind 2 more frames using the Unwinder. It uses Full UnwindPlan
+ // and if Full UnwindPlan fails, then uses FallBack UnwindPlan. Also
+ // update the cfa of Frame 0 (if required).
+ AddOneMoreFrame(abi);
+
+ // Remove all the frames added by above function as the purpose of
+ // using above function was just to check whether Unwinder of Frame 0
+ // works or not.
+ for(uint32_t i=1; i<m_frames.size(); i++)
+ m_frames.pop_back();
+
+ // Restore status after calling AddOneMoreFrame
+ m_unwind_complete = old_m_unwind_complete;
+ m_candidate_frame = old_m_candidate_frame;
+ return;
+}
+
+
bool
UnwindLLDB::AddOneMoreFrame (ABI *abi)
{
@@ -321,9 +397,17 @@ UnwindLLDB::AddOneMoreFrame (ABI *abi)
m_frames.push_back(new_frame_v2);
m_candidate_frame = GetOneMoreFrame(abi);
if (m_candidate_frame)
+ {
+ // If control reached here then TryFallbackUnwindPlan had succeeded for Cursor::m_frames[m_frames.size() - 2].
+ // It also succeeded to Unwind next 2 frames i.e. m_frames[m_frames.size() - 1] and a frame after that.
+ // For Cursor::m_frames[m_frames.size() - 2], reg_ctx_lldb_sp field was already updated during TryFallbackUnwindPlan
+ // call above. However, cfa field still needs to be updated. Hence updating it here and then returning.
+ if ( !(m_frames[m_frames.size() - 2]->reg_ctx_lldb_sp->GetCFA(m_frames[m_frames.size() - 2]->cfa)))
+ return false;
return true;
+ }
- // The new frame isn't helped in unwinding. Fall back to the original one as the default unwind
+ // The new frame hasn't helped in unwinding. Fall back to the original one as the default unwind
// plan is usually more reliable then the fallback one.
m_frames.pop_back();
m_frames.push_back(new_frame);
diff --git a/source/Plugins/Process/Utility/UnwindLLDB.h b/source/Plugins/Process/Utility/UnwindLLDB.h
index ce897cd82423..d3c07078759b 100644
--- a/source/Plugins/Process/Utility/UnwindLLDB.h
+++ b/source/Plugins/Process/Utility/UnwindLLDB.h
@@ -10,8 +10,12 @@
#ifndef lldb_UnwindLLDB_h_
#define lldb_UnwindLLDB_h_
+// C Includes
+// C++ Includes
#include <vector>
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-public.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Symbol/FuncUnwinders.h"
@@ -27,9 +31,8 @@ class UnwindLLDB : public lldb_private::Unwind
{
public:
UnwindLLDB (lldb_private::Thread &thread);
-
- virtual
- ~UnwindLLDB() { }
+
+ ~UnwindLLDB() override = default;
enum RegisterSearchResult
{
@@ -62,23 +65,23 @@ protected:
};
void
- DoClear()
+ DoClear() override
{
m_frames.clear();
m_candidate_frame.reset();
m_unwind_complete = false;
}
- virtual uint32_t
- DoGetFrameCount();
+ uint32_t
+ DoGetFrameCount() override;
bool
- DoGetFrameInfoAtIndex (uint32_t frame_idx,
- lldb::addr_t& cfa,
- lldb::addr_t& start_pc);
+ DoGetFrameInfoAtIndex(uint32_t frame_idx,
+ lldb::addr_t& cfa,
+ lldb::addr_t& start_pc) override;
lldb::RegisterContextSP
- DoCreateRegisterContextForFrame (lldb_private::StackFrame *frame);
+ DoCreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
typedef std::shared_ptr<RegisterContextLLDB> RegisterContextLLDBSP;
@@ -112,7 +115,6 @@ protected:
}
private:
-
struct Cursor
{
lldb::addr_t start_pc; // The start address of the function/symbol for this frame - current pc if unknown
@@ -134,6 +136,15 @@ 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);
@@ -149,6 +160,6 @@ private:
DISALLOW_COPY_AND_ASSIGN (UnwindLLDB);
};
-} // namespace lldb_private
+} // namespace lldb_private
-#endif // lldb_UnwindLLDB_h_
+#endif // lldb_UnwindLLDB_h_
diff --git a/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h b/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h
index 2695376fd6e0..f195514ed1ba 100644
--- a/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h
+++ b/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h
@@ -15,7 +15,6 @@
#include <vector>
// Other libraries and framework includes
-
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Target/Unwind.h"
@@ -24,29 +23,26 @@ class UnwindMacOSXFrameBackchain : public lldb_private::Unwind
{
public:
UnwindMacOSXFrameBackchain (lldb_private::Thread &thread);
-
- virtual
- ~UnwindMacOSXFrameBackchain()
- {
- }
-
+
+ ~UnwindMacOSXFrameBackchain() override = default;
+
protected:
- virtual void
- DoClear()
+ void
+ DoClear() override
{
m_cursors.clear();
}
- virtual uint32_t
- DoGetFrameCount();
+ uint32_t
+ DoGetFrameCount() override;
bool
- DoGetFrameInfoAtIndex (uint32_t frame_idx,
- lldb::addr_t& cfa,
- lldb::addr_t& pc);
+ DoGetFrameInfoAtIndex(uint32_t frame_idx,
+ lldb::addr_t& cfa,
+ lldb::addr_t& pc) override;
lldb::RegisterContextSP
- DoCreateRegisterContextForFrame (lldb_private::StackFrame *frame);
+ DoCreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
friend class RegisterContextMacOSXFrameBackchain;
@@ -71,4 +67,4 @@ private:
DISALLOW_COPY_AND_ASSIGN (UnwindMacOSXFrameBackchain);
};
-#endif // lldb_UnwindMacOSXFrameBackchain_h_
+#endif // lldb_UnwindMacOSXFrameBackchain_h_
diff --git a/source/Plugins/Process/Utility/lldb-arm-register-enums.h b/source/Plugins/Process/Utility/lldb-arm-register-enums.h
index a617f6550f65..4d82c10a78ea 100644
--- a/source/Plugins/Process/Utility/lldb-arm-register-enums.h
+++ b/source/Plugins/Process/Utility/lldb-arm-register-enums.h
@@ -74,7 +74,55 @@ namespace lldb_private
fpu_s30_arm,
fpu_s31_arm,
fpu_fpscr_arm,
- k_last_fpr_arm = fpu_fpscr_arm,
+ fpu_d0_arm,
+ fpu_d1_arm,
+ fpu_d2_arm,
+ fpu_d3_arm,
+ fpu_d4_arm,
+ fpu_d5_arm,
+ fpu_d6_arm,
+ fpu_d7_arm,
+ fpu_d8_arm,
+ fpu_d9_arm,
+ fpu_d10_arm,
+ fpu_d11_arm,
+ fpu_d12_arm,
+ fpu_d13_arm,
+ fpu_d14_arm,
+ fpu_d15_arm,
+ fpu_d16_arm,
+ fpu_d17_arm,
+ fpu_d18_arm,
+ fpu_d19_arm,
+ fpu_d20_arm,
+ fpu_d21_arm,
+ fpu_d22_arm,
+ fpu_d23_arm,
+ fpu_d24_arm,
+ fpu_d25_arm,
+ fpu_d26_arm,
+ fpu_d27_arm,
+ fpu_d28_arm,
+ fpu_d29_arm,
+ fpu_d30_arm,
+ fpu_d31_arm,
+ fpu_q0_arm,
+ fpu_q1_arm,
+ fpu_q2_arm,
+ fpu_q3_arm,
+ fpu_q4_arm,
+ fpu_q5_arm,
+ fpu_q6_arm,
+ fpu_q7_arm,
+ fpu_q8_arm,
+ fpu_q9_arm,
+ fpu_q10_arm,
+ fpu_q11_arm,
+ fpu_q12_arm,
+ fpu_q13_arm,
+ fpu_q14_arm,
+ fpu_q15_arm,
+ k_last_fpr_arm = fpu_q15_arm,
exc_exception_arm,
exc_fsr_arm,
exc_far_arm,
diff --git a/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index bf5cad8e39c5..5b5d98a86d5e 100644
--- a/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -57,7 +57,7 @@ ProcessElfCore::Terminate()
lldb::ProcessSP
-ProcessElfCore::CreateInstance (Target &target, Listener &listener, const FileSpec *crash_file)
+ProcessElfCore::CreateInstance (lldb::TargetSP target_sp, Listener &listener, const FileSpec *crash_file)
{
lldb::ProcessSP process_sp;
if (crash_file)
@@ -75,7 +75,7 @@ ProcessElfCore::CreateInstance (Target &target, Listener &listener, const FileSp
if (elf_header.Parse(data, &data_offset))
{
if (elf_header.e_type == llvm::ELF::ET_CORE)
- process_sp.reset(new ProcessElfCore (target, listener, *crash_file));
+ process_sp.reset(new ProcessElfCore (target_sp, listener, *crash_file));
}
}
}
@@ -83,12 +83,12 @@ ProcessElfCore::CreateInstance (Target &target, Listener &listener, const FileSp
}
bool
-ProcessElfCore::CanDebug(Target &target, bool plugin_specified_by_name)
+ProcessElfCore::CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name)
{
// For now we are just making sure the file exists for a given module
if (!m_core_module_sp && m_core_file.Exists())
{
- ModuleSpec core_module_spec(m_core_file, target.GetArchitecture());
+ ModuleSpec core_module_spec(m_core_file, target_sp->GetArchitecture());
Error error (ModuleList::GetSharedModule (core_module_spec, m_core_module_sp,
NULL, NULL, NULL));
if (m_core_module_sp)
@@ -104,9 +104,9 @@ ProcessElfCore::CanDebug(Target &target, bool plugin_specified_by_name)
//----------------------------------------------------------------------
// ProcessElfCore constructor
//----------------------------------------------------------------------
-ProcessElfCore::ProcessElfCore(Target& target, Listener &listener,
+ProcessElfCore::ProcessElfCore(lldb::TargetSP target_sp, Listener &listener,
const FileSpec &core_file) :
- Process (target, listener),
+ Process (target_sp, listener),
m_core_module_sp (),
m_core_file (core_file),
m_dyld_plugin_name (),
@@ -233,10 +233,29 @@ ProcessElfCore::DoLoadCore ()
// it to match the core file which is always single arch.
ArchSpec arch (m_core_module_sp->GetArchitecture());
if (arch.IsValid())
- m_target.SetArchitecture(arch);
+ GetTarget().SetArchitecture(arch);
SetUnixSignals(UnixSignals::Create(GetArchitecture()));
+ // Core files are useless without the main executable. See if we can locate the main
+ // executable using data we found in the core file notes.
+ lldb::ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
+ if (!exe_module_sp)
+ {
+ // The first entry in the NT_FILE might be our executable
+ if (!m_nt_file_entries.empty())
+ {
+ ModuleSpec exe_module_spec;
+ exe_module_spec.GetArchitecture() = arch;
+ exe_module_spec.GetFileSpec().SetFile(m_nt_file_entries[0].path.GetCString(), false);
+ if (exe_module_spec.GetFileSpec())
+ {
+ exe_module_sp = GetTarget().GetSharedModule(exe_module_spec);
+ if (exe_module_sp)
+ GetTarget().SetExecutableModule(exe_module_sp, false);
+ }
+ }
+ }
return error;
}
@@ -258,7 +277,7 @@ ProcessElfCore::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_t
for (lldb::tid_t tid = 0; tid < num_threads; ++tid)
{
const ThreadData &td = m_thread_data[tid];
- lldb::ThreadSP thread_sp(new ThreadElfCore (*this, tid, td));
+ lldb::ThreadSP thread_sp(new ThreadElfCore (*this, td));
new_thread_list.AddThread (thread_sp);
}
return new_thread_list.GetSize(false) > 0;
@@ -352,8 +371,7 @@ ProcessElfCore::Clear()
m_thread_list.Clear();
m_os = llvm::Triple::UnknownOS;
- static const auto s_default_unix_signals_sp = std::make_shared<UnixSignals>();
- SetUnixSignals(s_default_unix_signals_sp);
+ SetUnixSignals(std::make_shared<UnixSignals>());
}
void
@@ -371,12 +389,11 @@ ProcessElfCore::Initialize()
lldb::addr_t
ProcessElfCore::GetImageInfoAddress()
{
- Target *target = &GetTarget();
- ObjectFile *obj_file = target->GetExecutableModule()->GetObjectFile();
- Address addr = obj_file->GetImageInfoAddress(target);
+ ObjectFile *obj_file = GetTarget().GetExecutableModule()->GetObjectFile();
+ Address addr = obj_file->GetImageInfoAddress(&GetTarget());
if (addr.IsValid())
- return addr.GetLoadAddress(target);
+ return addr.GetLoadAddress(&GetTarget());
return LLDB_INVALID_ADDRESS;
}
@@ -387,7 +404,8 @@ enum {
NT_PRPSINFO,
NT_TASKSTRUCT,
NT_PLATFORM,
- NT_AUXV
+ NT_AUXV,
+ NT_FILE = 0x46494c45
};
namespace FREEBSD {
@@ -429,7 +447,7 @@ ParseFreeBSDPrStatus(ThreadData &thread_data, DataExtractor &data,
offset += 16;
thread_data.signo = data.GetU32(&offset); // pr_cursig
- offset += 4; // pr_pid
+ thread_data.tid = data.GetU32(&offset); // pr_pid
if (lp64)
offset += 4;
@@ -503,6 +521,7 @@ ProcessElfCore::ParseThreadContextsFromNoteSegment(const elf::ELFProgramHeader *
// Store the NOTE information in the current thread
DataExtractor note_data (segment_data, note_start, note_size);
+ note_data.SetAddressByteSize(m_core_module_sp->GetArchitecture().GetAddressByteSize());
if (note.n_name == "FreeBSD")
{
m_os = llvm::Triple::FreeBSD;
@@ -532,7 +551,7 @@ ProcessElfCore::ParseThreadContextsFromNoteSegment(const elf::ELFProgramHeader *
break;
}
}
- else
+ else if (note.n_name == "CORE")
{
switch (note.n_type)
{
@@ -543,6 +562,8 @@ ProcessElfCore::ParseThreadContextsFromNoteSegment(const elf::ELFProgramHeader *
header_size = ELFLinuxPrStatus::GetSize(arch);
len = note_data.GetByteSize() - header_size;
thread_data->gpregset = DataExtractor(note_data, header_size, len);
+ // FIXME: Obtain actual tid on Linux
+ thread_data->tid = m_thread_data.size();
break;
case NT_FPREGSET:
thread_data->fpregset = note_data;
@@ -555,6 +576,28 @@ ProcessElfCore::ParseThreadContextsFromNoteSegment(const elf::ELFProgramHeader *
case NT_AUXV:
m_auxv = DataExtractor(note_data);
break;
+ case NT_FILE:
+ {
+ m_nt_file_entries.clear();
+ lldb::offset_t offset = 0;
+ const uint64_t count = note_data.GetAddress(&offset);
+ note_data.GetAddress(&offset); // Skip page size
+ for (uint64_t i = 0; i<count; ++i)
+ {
+ NT_FILE_Entry entry;
+ entry.start = note_data.GetAddress(&offset);
+ entry.end = note_data.GetAddress(&offset);
+ entry.file_ofs = note_data.GetAddress(&offset);
+ m_nt_file_entries.push_back(entry);
+ }
+ for (uint64_t i = 0; i<count; ++i)
+ {
+ const char *path = note_data.GetCStr(&offset);
+ if (path && path[0])
+ m_nt_file_entries[i].path.SetCString(path);
+ }
+ }
+ break;
default:
break;
}
diff --git a/source/Plugins/Process/elf-core/ProcessElfCore.h b/source/Plugins/Process/elf-core/ProcessElfCore.h
index 775d9e94dd8e..12ce04c5ce38 100644
--- a/source/Plugins/Process/elf-core/ProcessElfCore.h
+++ b/source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -1,4 +1,4 @@
-//===-- ProcessElfCore.h ---------------------------------------*- C++ -*-===//
+//===-- ProcessElfCore.h ----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,18 +10,20 @@
// 2) The ELF file's PT_NOTE and PT_LOAD segments describes the program's
// address space and thread contexts.
// 3) PT_NOTE segment contains note entries which describes a thread context.
-// 4) PT_LOAD segment describes a valid contigous range of process address
+// 4) PT_LOAD segment describes a valid contiguous range of process address
// space.
//===----------------------------------------------------------------------===//
#ifndef liblldb_ProcessElfCore_h_
#define liblldb_ProcessElfCore_h_
+// C Includes
// C++ Includes
#include <list>
#include <vector>
// Other libraries and framework includes
+// Project includes
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Error.h"
#include "lldb/Target/Process.h"
@@ -37,7 +39,7 @@ public:
// Constructors and Destructors
//------------------------------------------------------------------
static lldb::ProcessSP
- CreateInstance (lldb_private::Target& target,
+ CreateInstance (lldb::TargetSP target_sp,
lldb_private::Listener &listener,
const lldb_private::FileSpec *crash_file_path);
@@ -56,17 +58,16 @@ public:
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
- ProcessElfCore(lldb_private::Target& target,
- lldb_private::Listener &listener,
- const lldb_private::FileSpec &core_file);
+ ProcessElfCore(lldb::TargetSP target_sp,
+ lldb_private::Listener &listener,
+ const lldb_private::FileSpec &core_file);
- virtual
- ~ProcessElfCore();
+ ~ProcessElfCore() override;
//------------------------------------------------------------------
// Check if a given Process
//------------------------------------------------------------------
- bool CanDebug(lldb_private::Target &target, bool plugin_specified_by_name) override;
+ bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override;
//------------------------------------------------------------------
// Creating a new process, or attaching to an existing one
@@ -118,6 +119,14 @@ protected:
lldb_private::ThreadList &new_thread_list) override;
private:
+ struct NT_FILE_Entry
+ {
+ lldb::addr_t start;
+ lldb::addr_t end;
+ lldb::addr_t file_ofs;
+ lldb_private::ConstString path;
+ };
+
//------------------------------------------------------------------
// For ProcessElfCore only
//------------------------------------------------------------------
@@ -143,6 +152,9 @@ private:
// Address ranges found in the core
VMRangeToFileOffset m_core_aranges;
+ // NT_FILE entries found from the NOTE segment
+ std::vector<NT_FILE_Entry> m_nt_file_entries;
+
// Parse thread(s) data structures(prstatus, prpsinfo) from given NOTE segment
void
ParseThreadContextsFromNoteSegment (const elf::ELFProgramHeader *segment_header,
@@ -157,4 +169,4 @@ private:
AddAddressRangeFromLoadSegment(const elf::ELFProgramHeader *header);
};
-#endif // liblldb_ProcessElffCore_h_
+#endif // liblldb_ProcessElfCore_h_
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp
index f046c112d8b6..6778aeaaac00 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp
@@ -10,7 +10,6 @@
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Target/Thread.h"
-#include "Plugins/Process/Utility/RegisterContextPOSIX.h"
#include "RegisterContextPOSIXCore_arm.h"
using namespace lldb_private;
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h
index 73e2ef7c3a93..0e74897b5b5c 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h
@@ -1,15 +1,19 @@
-//===-- RegisterContextCorePOSIX_arm.h -----------------------*- C++ -*-===//
+//===-- RegisterContextCorePOSIX_arm.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_RegisterContextCorePOSIX_arm_H_
-#define liblldb_RegisterContextCorePOSIX_arm_H_
+#ifndef liblldb_RegisterContextCorePOSIX_arm_h_
+#define liblldb_RegisterContextCorePOSIX_arm_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Core/DataBufferHeap.h"
#include "Plugins/Process/Utility/RegisterContextPOSIX_arm.h"
@@ -22,39 +26,41 @@ public:
const lldb_private::DataExtractor &gpregset,
const lldb_private::DataExtractor &fpregset);
- ~RegisterContextCorePOSIX_arm();
+ ~RegisterContextCorePOSIX_arm() override;
- virtual bool
- ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
+ bool
+ ReadRegister(const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &value) override;
- virtual bool
- WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
+ bool
+ WriteRegister(const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &value) override;
bool
- ReadAllRegisterValues(lldb::DataBufferSP &data_sp);
+ ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
bool
- WriteAllRegisterValues(const lldb::DataBufferSP &data_sp);
+ WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
bool
- HardwareSingleStep(bool enable);
+ HardwareSingleStep(bool enable) override;
protected:
bool
- ReadGPR();
+ ReadGPR() override;
bool
- ReadFPR();
+ ReadFPR() override;
bool
- WriteGPR();
+ WriteGPR() override;
bool
- WriteFPR();
+ WriteFPR() override;
private:
lldb::DataBufferSP m_gpr_buffer;
lldb_private::DataExtractor m_gpr;
};
-#endif // #ifndef liblldb_RegisterContextCorePOSIX_arm_H_
+#endif // liblldb_RegisterContextCorePOSIX_arm_h_
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
index 53c0c83c264a..7cfdd415ad5b 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
@@ -10,7 +10,6 @@
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Target/Thread.h"
-#include "Plugins/Process/Utility/RegisterContextPOSIX.h"
#include "RegisterContextPOSIXCore_arm64.h"
using namespace lldb_private;
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
index 2e1d6b4f9ca8..9b05edb1935f 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
@@ -1,15 +1,19 @@
-//===-- RegisterContextCorePOSIX_arm64.h -----------------------*- C++ -*-===//
+//===-- RegisterContextCorePOSIX_arm64.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_RegisterContextCorePOSIX_arm64_H_
-#define liblldb_RegisterContextCorePOSIX_arm64_H_
+#ifndef liblldb_RegisterContextCorePOSIX_arm64_h_
+#define liblldb_RegisterContextCorePOSIX_arm64_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Core/DataBufferHeap.h"
#include "Plugins/Process/Utility/RegisterContextPOSIX_arm64.h"
@@ -22,39 +26,41 @@ public:
const lldb_private::DataExtractor &gpregset,
const lldb_private::DataExtractor &fpregset);
- ~RegisterContextCorePOSIX_arm64();
+ ~RegisterContextCorePOSIX_arm64() override;
- virtual bool
- ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
+ bool
+ ReadRegister(const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &value) override;
- virtual bool
- WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
+ bool
+ WriteRegister(const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &value) override;
bool
- ReadAllRegisterValues(lldb::DataBufferSP &data_sp);
+ ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
bool
- WriteAllRegisterValues(const lldb::DataBufferSP &data_sp);
+ WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
bool
- HardwareSingleStep(bool enable);
+ HardwareSingleStep(bool enable) override;
protected:
bool
- ReadGPR();
+ ReadGPR() override;
bool
- ReadFPR();
+ ReadFPR() override;
bool
- WriteGPR();
+ WriteGPR() override;
bool
- WriteFPR();
+ WriteFPR() override;
private:
lldb::DataBufferSP m_gpr_buffer;
lldb_private::DataExtractor m_gpr;
};
-#endif // #ifndef liblldb_RegisterContextCorePOSIX_arm64_H_
+#endif // liblldb_RegisterContextCorePOSIX_arm64_h_
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp
index f0750a0cee18..9d908e371a32 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp
@@ -10,7 +10,6 @@
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Target/Thread.h"
-#include "Plugins/Process/Utility/RegisterContextPOSIX.h"
#include "RegisterContextPOSIXCore_mips64.h"
using namespace lldb_private;
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h
index ca29d4f0febd..6cbfd504b7db 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h
@@ -1,15 +1,19 @@
-//===-- RegisterContextCorePOSIX_mips64.h ----------------------*- C++ -*-===//
+//===-- RegisterContextCorePOSIX_mips64.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_RegisterContextCorePOSIX_mips64_H_
-#define liblldb_RegisterContextCorePOSIX_mips64_H_
+#ifndef liblldb_RegisterContextCorePOSIX_mips64_h_
+#define liblldb_RegisterContextCorePOSIX_mips64_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Core/DataBufferHeap.h"
#include "Plugins/Process/Utility/RegisterContextPOSIX_mips64.h"
@@ -22,39 +26,41 @@ public:
const lldb_private::DataExtractor &gpregset,
const lldb_private::DataExtractor &fpregset);
- ~RegisterContextCorePOSIX_mips64();
+ ~RegisterContextCorePOSIX_mips64() override;
- virtual bool
- ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
+ bool
+ ReadRegister(const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &value) override;
- virtual bool
- WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
+ bool
+ WriteRegister(const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &value) override;
bool
- ReadAllRegisterValues(lldb::DataBufferSP &data_sp);
+ ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
bool
- WriteAllRegisterValues(const lldb::DataBufferSP &data_sp);
+ WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
bool
- HardwareSingleStep(bool enable);
+ HardwareSingleStep(bool enable) override;
protected:
bool
- ReadGPR();
+ ReadGPR() override;
bool
- ReadFPR();
+ ReadFPR() override;
bool
- WriteGPR();
+ WriteGPR() override;
bool
- WriteFPR();
+ WriteFPR() override;
private:
lldb::DataBufferSP m_gpr_buffer;
lldb_private::DataExtractor m_gpr;
};
-#endif // #ifndef liblldb_RegisterContextCorePOSIX_mips64_H_
+#endif // liblldb_RegisterContextCorePOSIX_mips64_h_
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp
index d12df21a8664..9d8c97849ff8 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp
@@ -10,7 +10,6 @@
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Target/Thread.h"
-#include "RegisterContextPOSIX.h"
#include "RegisterContextPOSIXCore_powerpc.h"
using namespace lldb_private;
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h
index a3590601fa7e..0f587fd1459c 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h
@@ -5,11 +5,15 @@
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
-//===---------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextCorePOSIX_powerpc_H_
-#define liblldb_RegisterContextCorePOSIX_powerpc_H_
+#ifndef liblldb_RegisterContextCorePOSIX_powerpc_h_
+#define liblldb_RegisterContextCorePOSIX_powerpc_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Core/DataBufferHeap.h"
#include "Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h"
@@ -23,41 +27,43 @@ public:
const lldb_private::DataExtractor &fpregset,
const lldb_private::DataExtractor &vregset);
- ~RegisterContextCorePOSIX_powerpc();
+ ~RegisterContextCorePOSIX_powerpc() override;
- virtual bool
- ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
+ bool
+ ReadRegister(const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &value) override;
- virtual bool
- WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
+ bool
+ WriteRegister(const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &value) override;
bool
- ReadAllRegisterValues(lldb::DataBufferSP &data_sp);
+ ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
bool
- WriteAllRegisterValues(const lldb::DataBufferSP &data_sp);
+ WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
bool
- HardwareSingleStep(bool enable);
+ HardwareSingleStep(bool enable) override;
protected:
bool
- ReadGPR();
+ ReadGPR() override;
bool
- ReadFPR();
+ ReadFPR() override;
bool
- ReadVMX();
+ ReadVMX() override;
bool
- WriteGPR();
+ WriteGPR() override;
bool
- WriteFPR();
+ WriteFPR() override;
bool
- WriteVMX();
+ WriteVMX() override;
private:
lldb::DataBufferSP m_gpr_buffer;
@@ -68,4 +74,4 @@ private:
lldb_private::DataExtractor m_vec;
};
-#endif // #ifndef liblldb_RegisterContextCorePOSIX_powerpc_H_
+#endif // liblldb_RegisterContextCorePOSIX_powerpc_h_
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
index 412c7ade8295..926c7aff3603 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
@@ -10,7 +10,6 @@
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Target/Thread.h"
-#include "Plugins/Process/Utility/RegisterContextPOSIX.h"
#include "RegisterContextPOSIXCore_x86_64.h"
using namespace lldb_private;
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
index ac0f49c3db52..60f2ad33b4a5 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
@@ -1,15 +1,19 @@
-//===-- RegisterContextCorePOSIX_x86_64.h ----------------------*- C++ -*-===//
+//===-- RegisterContextCorePOSIX_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.
//
-//===---------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextCorePOSIX_x86_64_H_
-#define liblldb_RegisterContextCorePOSIX_x86_64_H_
+#ifndef liblldb_RegisterContextCorePOSIX_x86_64_h_
+#define liblldb_RegisterContextCorePOSIX_x86_64_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "Plugins/Process/Utility/RegisterContextPOSIX_x86.h"
class RegisterContextCorePOSIX_x86_64 :
@@ -21,38 +25,40 @@ public:
const lldb_private::DataExtractor &gpregset,
const lldb_private::DataExtractor &fpregset);
- ~RegisterContextCorePOSIX_x86_64();
+ ~RegisterContextCorePOSIX_x86_64() override;
- virtual bool
- ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
+ bool
+ ReadRegister(const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &value) override;
- virtual bool
- WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
+ bool
+ WriteRegister(const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &value) override;
bool
- ReadAllRegisterValues(lldb::DataBufferSP &data_sp);
+ ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
bool
- WriteAllRegisterValues(const lldb::DataBufferSP &data_sp);
+ WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
bool
- HardwareSingleStep(bool enable);
+ HardwareSingleStep(bool enable) override;
protected:
bool
- ReadGPR();
+ ReadGPR() override;
bool
- ReadFPR();
+ ReadFPR() override;
bool
- WriteGPR();
+ WriteGPR() override;
bool
- WriteFPR();
+ WriteFPR() override;
private:
uint8_t *m_gpregset;
};
-#endif // #ifndef liblldb_RegisterContextCorePOSIX_x86_64_H_
+#endif // liblldb_RegisterContextCorePOSIX_x86_64_h_
diff --git a/source/Plugins/Process/elf-core/ThreadElfCore.cpp b/source/Plugins/Process/elf-core/ThreadElfCore.cpp
index 2abb6ba5decd..9cc7829fc391 100644
--- a/source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ b/source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -37,9 +37,8 @@ using namespace lldb_private;
//----------------------------------------------------------------------
// Construct a Thread object with given data
//----------------------------------------------------------------------
-ThreadElfCore::ThreadElfCore (Process &process, tid_t tid,
- const ThreadData &td) :
- Thread(process, tid),
+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),
diff --git a/source/Plugins/Process/elf-core/ThreadElfCore.h b/source/Plugins/Process/elf-core/ThreadElfCore.h
index 50502c101daf..d3a42e0eb54d 100644
--- a/source/Plugins/Process/elf-core/ThreadElfCore.h
+++ b/source/Plugins/Process/elf-core/ThreadElfCore.h
@@ -1,4 +1,4 @@
-//===-- ThreadElfCore.h ----------------------------------------*- C++ -*-===//
+//===-- ThreadElfCore.h -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,8 +10,12 @@
#ifndef liblldb_ThreadElfCore_h_
#define liblldb_ThreadElfCore_h_
+// C Includes
+// C++ Includes
#include <string>
+// Other libraries and framework includes
+// Project includes
#include "lldb/Target/Thread.h"
#include "lldb/Core/DataExtractor.h"
@@ -104,7 +108,6 @@ struct ELFLinuxPrPsInfo
return 0;
}
}
-
};
struct ThreadData
@@ -112,6 +115,7 @@ struct ThreadData
lldb_private::DataExtractor gpregset;
lldb_private::DataExtractor fpregset;
lldb_private::DataExtractor vregset;
+ lldb::tid_t tid;
int signo;
std::string name;
};
@@ -119,23 +123,21 @@ struct ThreadData
class ThreadElfCore : public lldb_private::Thread
{
public:
- ThreadElfCore (lldb_private::Process &process, lldb::tid_t tid,
- const ThreadData &td);
+ ThreadElfCore (lldb_private::Process &process, const ThreadData &td);
- virtual
- ~ThreadElfCore ();
+ ~ThreadElfCore() override;
- virtual void
- RefreshStateAfterStop();
+ void
+ RefreshStateAfterStop() override;
- virtual lldb::RegisterContextSP
- GetRegisterContext ();
+ lldb::RegisterContextSP
+ GetRegisterContext() override;
- virtual lldb::RegisterContextSP
- CreateRegisterContextForFrame (lldb_private::StackFrame *frame);
+ lldb::RegisterContextSP
+ CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
- virtual void
- ClearStackFrames ();
+ void
+ ClearStackFrames() override;
static bool
ThreadIDIsValid (lldb::tid_t thread)
@@ -143,8 +145,8 @@ public:
return thread != 0;
}
- virtual const char *
- GetName ()
+ const char *
+ GetName() override
{
if (m_thread_name.empty())
return NULL;
@@ -152,7 +154,7 @@ public:
}
void
- SetName (const char *name)
+ SetName(const char *name) override
{
if (name && name[0])
m_thread_name.assign (name);
@@ -173,8 +175,7 @@ protected:
lldb_private::DataExtractor m_fpregset_data;
lldb_private::DataExtractor m_vregset_data;
- virtual bool CalculateStopInfo();
-
+ bool CalculateStopInfo() override;
};
-#endif // liblldb_ThreadElfCore_h_
+#endif // liblldb_ThreadElfCore_h_
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 9c263c8c4087..2ea1f206008a 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -30,6 +30,7 @@
#include "lldb/Host/StringConvert.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Host/TimeValue.h"
+#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "llvm/ADT/SmallString.h"
@@ -574,15 +575,24 @@ GDBRemoteCommunication::DecompressPacket ()
return true;
if (m_bytes[1] != 'C' && m_bytes[1] != 'N')
return true;
- if (m_bytes[pkt_size - 3] != '#')
+
+ size_t hash_mark_idx = m_bytes.find ('#');
+ if (hash_mark_idx == std::string::npos)
+ return true;
+ if (hash_mark_idx + 2 >= m_bytes.size())
return true;
- if (!::isxdigit (m_bytes[pkt_size - 2]) || !::isxdigit (m_bytes[pkt_size - 1]))
+
+ if (!::isxdigit (m_bytes[hash_mark_idx + 1]) || !::isxdigit (m_bytes[hash_mark_idx + 2]))
return true;
- size_t content_length = pkt_size - 5; // not counting '$', 'C' | 'N', '#', & the two hex checksum chars
- size_t content_start = 2; // The first character of the compressed/not-compressed text of the packet
- size_t hash_mark_idx = pkt_size - 3; // The '#' character marking the end of the packet
- size_t checksum_idx = pkt_size - 2; // The first character of the two hex checksum characters
+ size_t content_length = pkt_size - 5; // not counting '$', 'C' | 'N', '#', & the two hex checksum chars
+ size_t content_start = 2; // The first character of the compressed/not-compressed text of the packet
+ size_t checksum_idx = hash_mark_idx + 1; // The first character of the two hex checksum characters
+
+ // Normally size_of_first_packet == m_bytes.size() but m_bytes may contain multiple packets.
+ // size_of_first_packet is the size of the initial packet which we'll replace with the decompressed
+ // version of, leaving the rest of m_bytes unmodified.
+ size_t size_of_first_packet = hash_mark_idx + 3;
// Compressed packets ("$C") start with a base10 number which is the size of the uncompressed payload,
// then a : and then the compressed data. e.g. $C1024:<binary>#00
@@ -604,7 +614,7 @@ GDBRemoteCommunication::DecompressPacket ()
decompressed_bufsize = ::strtoul (bufsize_str.c_str(), NULL, 10);
if (errno != 0 || decompressed_bufsize == ULONG_MAX)
{
- m_bytes.erase (0, pkt_size);
+ m_bytes.erase (0, size_of_first_packet);
return false;
}
}
@@ -633,7 +643,7 @@ GDBRemoteCommunication::DecompressPacket ()
if (!success)
{
SendNack();
- m_bytes.erase (0, pkt_size);
+ m_bytes.erase (0, size_of_first_packet);
return false;
}
else
@@ -677,7 +687,7 @@ GDBRemoteCommunication::DecompressPacket ()
decompressed_buffer = (uint8_t *) malloc (decompressed_bufsize + 1);
if (decompressed_buffer == nullptr)
{
- m_bytes.erase (0, pkt_size);
+ m_bytes.erase (0, size_of_first_packet);
return false;
}
@@ -751,7 +761,7 @@ GDBRemoteCommunication::DecompressPacket ()
{
if (decompressed_buffer)
free (decompressed_buffer);
- m_bytes.erase (0, pkt_size);
+ m_bytes.erase (0, size_of_first_packet);
return false;
}
@@ -773,7 +783,7 @@ GDBRemoteCommunication::DecompressPacket ()
new_packet.push_back ('0');
}
- m_bytes = new_packet;
+ m_bytes.replace (0, size_of_first_packet, new_packet.data(), new_packet.size());
free (decompressed_buffer);
return true;
@@ -927,8 +937,10 @@ GDBRemoteCommunication::CheckForPacket (const uint8_t *src, size_t src_len, Stri
{
for (size_t i=0; !binary && i<total_length; ++i)
{
- if (isprint(m_bytes[i]) == 0)
+ if (isprint (m_bytes[i]) == 0 && isspace (m_bytes[i]) == 0)
+ {
binary = true;
+ }
}
}
if (binary)
@@ -1100,16 +1112,16 @@ GDBRemoteCommunication::ListenThread (lldb::thread_arg_t arg)
}
Error
-GDBRemoteCommunication::StartDebugserverProcess (const char *hostname,
- uint16_t in_port,
+GDBRemoteCommunication::StartDebugserverProcess (const char *url,
+ Platform *platform,
ProcessLaunchInfo &launch_info,
- uint16_t &out_port)
+ uint16_t *port,
+ const Args& inferior_args)
{
Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS));
if (log)
- log->Printf ("GDBRemoteCommunication::%s(hostname=%s, in_port=%" PRIu16 ", out_port=%" PRIu16, __FUNCTION__, hostname ? hostname : "<empty>", in_port, out_port);
+ log->Printf ("GDBRemoteCommunication::%s(url=%s, port=%" PRIu16, __FUNCTION__, url ? url : "<empty>", port ? *port : uint16_t(0));
- out_port = in_port;
Error error;
// If we locate debugserver, keep that located version around
static FileSpec g_debugserver_file_spec;
@@ -1146,11 +1158,20 @@ GDBRemoteCommunication::StartDebugserverProcess (const char *hostname,
}
else
{
- if (log)
- log->Printf ("GDBRemoteCommunication::%s() could not find gdb-remote stub exe '%s'", __FUNCTION__, debugserver_file_spec.GetPath ().c_str ());
-
+ debugserver_file_spec = platform->LocateExecutable(DEBUGSERVER_BASENAME);
+ if (debugserver_file_spec)
+ {
+ // Platform::LocateExecutable() wouldn't return a path if it doesn't exist
+ debugserver_exists = true;
+ }
+ else
+ {
+ if (log)
+ log->Printf ("GDBRemoteCommunication::%s() could not find gdb-remote stub exe '%s'", __FUNCTION__, debugserver_file_spec.GetPath ().c_str ());
+ }
+ // Don't cache the platform specific GDB server binary as it could change
+ // from platform to platform
g_debugserver_file_spec.Clear();
- debugserver_file_spec.Clear();
}
}
}
@@ -1171,17 +1192,9 @@ GDBRemoteCommunication::StartDebugserverProcess (const char *hostname,
debugserver_args.AppendArgument("gdbserver");
#endif
- // If a host and port is supplied then use it
- char host_and_port[128];
- if (hostname)
- {
- snprintf (host_and_port, sizeof(host_and_port), "%s:%u", hostname, in_port);
- debugserver_args.AppendArgument(host_and_port);
- }
- else
- {
- host_and_port[0] = '\0';
- }
+ // If a url is supplied then use it
+ if (url)
+ debugserver_args.AppendArgument(url);
// use native registers, not the GDB registers
debugserver_args.AppendArgument("--native-regs");
@@ -1192,30 +1205,41 @@ GDBRemoteCommunication::StartDebugserverProcess (const char *hostname,
}
llvm::SmallString<PATH_MAX> named_pipe_path;
- Pipe port_pipe;
-
- if (host_and_port[0] && in_port == 0)
+ // socket_pipe is used by debug server to communicate back either
+ // TCP port or domain socket name which it listens on.
+ // The second purpose of the pipe to serve as a synchronization point -
+ // once data is written to the pipe, debug server is up and running.
+ Pipe socket_pipe;
+
+ // port is null when debug server should listen on domain socket -
+ // we're not interested in port value but rather waiting for debug server
+ // to become available.
+ if ((port != nullptr && *port == 0) || port == nullptr)
{
- // Create a temporary file to get the stdout/stderr and redirect the
- // output of the command into this file. We will later read this file
- // if all goes well and fill the data into "command_output_ptr"
-
- // Binding to port zero, we need to figure out what port it ends up
- // using using a named pipe...
- error = port_pipe.CreateWithUniqueName("debugserver-named-pipe", false, named_pipe_path);
- if (error.Success())
+ if (url)
{
+ // Create a temporary file to get the stdout/stderr and redirect the
+ // output of the command into this file. We will later read this file
+ // if all goes well and fill the data into "command_output_ptr"
+
+#if defined(__APPLE__)
+ // Binding to port zero, we need to figure out what port it ends up
+ // using using a named pipe...
+ error = socket_pipe.CreateWithUniqueName("debugserver-named-pipe", false, named_pipe_path);
+ if (error.Fail())
+ {
+ if (log)
+ log->Printf("GDBRemoteCommunication::%s() "
+ "named pipe creation failed: %s",
+ __FUNCTION__, error.AsCString());
+ return error;
+ }
debugserver_args.AppendArgument("--named-pipe");
debugserver_args.AppendArgument(named_pipe_path.c_str());
- }
- else
- {
- if (log)
- log->Printf("GDBRemoteCommunication::%s() "
- "named pipe creation failed: %s",
- __FUNCTION__, error.AsCString());
- // let's try an unnamed pipe
- error = port_pipe.CreateNew(true);
+#else
+ // Binding to port zero, we need to figure out what port it ends up
+ // using using an unnamed pipe...
+ error = socket_pipe.CreateNew(true);
if (error.Fail())
{
if (log)
@@ -1224,42 +1248,43 @@ GDBRemoteCommunication::StartDebugserverProcess (const char *hostname,
__FUNCTION__, error.AsCString());
return error;
}
- int write_fd = port_pipe.GetWriteFileDescriptor();
+ int write_fd = socket_pipe.GetWriteFileDescriptor();
debugserver_args.AppendArgument("--pipe");
debugserver_args.AppendArgument(std::to_string(write_fd).c_str());
- launch_info.AppendCloseFileAction(port_pipe.GetReadFileDescriptor());
- }
- }
- else
- {
- // No host and port given, so lets listen on our end and make the debugserver
- // connect to us..
- error = StartListenThread ("127.0.0.1", 0);
- if (error.Fail())
- {
- if (log)
- log->Printf ("GDBRemoteCommunication::%s() unable to start listen thread: %s", __FUNCTION__, error.AsCString());
- return error;
- }
-
- ConnectionFileDescriptor *connection = (ConnectionFileDescriptor *)GetConnection ();
- // Wait for 10 seconds to resolve the bound port
- out_port = connection->GetListeningPort(10);
- if (out_port > 0)
- {
- char port_cstr[32];
- snprintf(port_cstr, sizeof(port_cstr), "127.0.0.1:%i", out_port);
- // Send the host and port down that debugserver and specify an option
- // so that it connects back to the port we are listening to in this process
- debugserver_args.AppendArgument("--reverse-connect");
- debugserver_args.AppendArgument(port_cstr);
+ launch_info.AppendCloseFileAction(socket_pipe.GetReadFileDescriptor());
+#endif
}
else
{
- error.SetErrorString ("failed to bind to port 0 on 127.0.0.1");
- if (log)
- log->Printf ("GDBRemoteCommunication::%s() failed: %s", __FUNCTION__, error.AsCString());
- return error;
+ // No host and port given, so lets listen on our end and make the debugserver
+ // connect to us..
+ error = StartListenThread ("127.0.0.1", 0);
+ if (error.Fail())
+ {
+ if (log)
+ log->Printf ("GDBRemoteCommunication::%s() unable to start listen thread: %s", __FUNCTION__, error.AsCString());
+ return error;
+ }
+
+ ConnectionFileDescriptor *connection = (ConnectionFileDescriptor *)GetConnection ();
+ // Wait for 10 seconds to resolve the bound port
+ *port = connection->GetListeningPort(10);
+ if (*port > 0)
+ {
+ char port_cstr[32];
+ snprintf(port_cstr, sizeof(port_cstr), "127.0.0.1:%i", *port);
+ // Send the host and port down that debugserver and specify an option
+ // so that it connects back to the port we are listening to in this process
+ debugserver_args.AppendArgument("--reverse-connect");
+ debugserver_args.AppendArgument(port_cstr);
+ }
+ else
+ {
+ error.SetErrorString ("failed to bind to port 0 on 127.0.0.1");
+ if (log)
+ log->Printf ("GDBRemoteCommunication::%s() failed: %s", __FUNCTION__, error.AsCString());
+ return error;
+ }
}
}
@@ -1304,6 +1329,20 @@ GDBRemoteCommunication::StartDebugserverProcess (const char *hostname,
}
} while (has_env_var);
+ if (inferior_args.GetArgumentCount() > 0)
+ {
+ debugserver_args.AppendArgument ("--");
+ debugserver_args.AppendArguments (inferior_args);
+ }
+
+ // Copy the current environment to the gdbserver/debugserver instance
+ StringList env;
+ if (Host::GetEnvironment(env))
+ {
+ for (size_t i = 0; i < env.GetSize(); ++i)
+ launch_info.GetEnvironmentEntries().AppendArgument(env[i].c_str());
+ }
+
// Close STDIN, STDOUT and STDERR.
launch_info.AppendCloseFileAction (STDIN_FILENO);
launch_info.AppendCloseFileAction (STDOUT_FILENO);
@@ -1316,11 +1355,12 @@ GDBRemoteCommunication::StartDebugserverProcess (const char *hostname,
error = Host::LaunchProcess(launch_info);
- if (error.Success() && launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID)
+ if (error.Success() &&
+ launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID)
{
if (named_pipe_path.size() > 0)
{
- error = port_pipe.OpenAsReader(named_pipe_path, false);
+ error = socket_pipe.OpenAsReader(named_pipe_path, false);
if (error.Fail())
if (log)
log->Printf("GDBRemoteCommunication::%s() "
@@ -1328,24 +1368,24 @@ GDBRemoteCommunication::StartDebugserverProcess (const char *hostname,
__FUNCTION__, named_pipe_path.c_str(), error.AsCString());
}
- if (port_pipe.CanWrite())
- port_pipe.CloseWriteFileDescriptor();
- if (port_pipe.CanRead())
+ if (socket_pipe.CanWrite())
+ socket_pipe.CloseWriteFileDescriptor();
+ if (socket_pipe.CanRead())
{
- char port_cstr[256];
+ char port_cstr[PATH_MAX] = {0};
port_cstr[0] = '\0';
size_t num_bytes = sizeof(port_cstr);
// Read port from pipe with 10 second timeout.
- error = port_pipe.ReadWithTimeout(port_cstr, num_bytes,
+ error = socket_pipe.ReadWithTimeout(port_cstr, num_bytes,
std::chrono::seconds{10}, num_bytes);
- if (error.Success())
+ if (error.Success() && (port != nullptr))
{
assert(num_bytes > 0 && port_cstr[num_bytes-1] == '\0');
- out_port = StringConvert::ToUInt32(port_cstr, 0);
+ *port = StringConvert::ToUInt32(port_cstr, 0);
if (log)
log->Printf("GDBRemoteCommunication::%s() "
- "debugserver listens %u port",
- __FUNCTION__, out_port);
+ "debugserver listens %u port",
+ __FUNCTION__, *port);
}
else
{
@@ -1355,12 +1395,12 @@ GDBRemoteCommunication::StartDebugserverProcess (const char *hostname,
__FUNCTION__, named_pipe_path.c_str(), error.AsCString());
}
- port_pipe.Close();
+ socket_pipe.Close();
}
if (named_pipe_path.size() > 0)
{
- const auto err = port_pipe.Delete(named_pipe_path);
+ const auto err = socket_pipe.Delete(named_pipe_path);
if (err.Fail())
{
if (log)
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
index 7379bb3aa09b..2a01bcec260c 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
@@ -12,9 +12,9 @@
// C Includes
// C++ Includes
-#include <list>
#include <string>
#include <queue>
+#include <vector>
// Other libraries and framework includes
// Project includes
@@ -25,6 +25,7 @@
#include "lldb/Host/Mutex.h"
#include "lldb/Host/Predicate.h"
#include "lldb/Host/TimeValue.h"
+#include "lldb/Interpreter/Args.h"
#include "Utility/StringExtractorGDBRemote.h"
@@ -94,14 +95,10 @@ public:
uint32_t m_saved_timeout;
};
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
GDBRemoteCommunication(const char *comm_name,
const char *listener_name);
- virtual
- ~GDBRemoteCommunication();
+ ~GDBRemoteCommunication() override;
PacketResult
GetAck ();
@@ -117,12 +114,13 @@ public:
size_t payload_length);
bool
- GetSequenceMutex (Mutex::Locker& locker, const char *failure_message = NULL);
+ GetSequenceMutex(Mutex::Locker& locker, const char *failure_message = nullptr);
PacketType
CheckForPacket (const uint8_t *src,
size_t src_len,
StringExtractorGDBRemote &packet);
+
bool
IsRunning() const
{
@@ -162,21 +160,22 @@ public:
{
return m_packet_timeout * TimeValue::MicroSecPerSec;
}
+
//------------------------------------------------------------------
// Start a debugserver instance on the current host using the
// supplied connection URL.
//------------------------------------------------------------------
Error
- StartDebugserverProcess (const char *hostname,
- uint16_t in_port, // If set to zero, then out_port will contain the bound port on exit
- ProcessLaunchInfo &launch_info,
- uint16_t &out_port);
+ StartDebugserverProcess(const char *url,
+ Platform *platform, // If non nullptr, then check with the platform for the GDB server binary if it can't be located
+ ProcessLaunchInfo &launch_info,
+ uint16_t *port,
+ const Args& inferior_args = Args());
void
DumpHistory(Stream &strm);
protected:
-
class History
{
public:
@@ -223,6 +222,7 @@ protected:
AddPacket (char packet_char,
PacketType type,
uint32_t bytes_transmitted);
+
void
AddPacket (const std::string &src,
uint32_t src_len,
@@ -241,7 +241,7 @@ protected:
return m_dumped_to_log;
}
-protected:
+ protected:
uint32_t
GetFirstSavedPacketIndex () const
{
@@ -275,13 +275,30 @@ protected:
return i % m_packets.size();
}
-
std::vector<Entry> m_packets;
uint32_t m_curr_idx;
uint32_t m_total_packet_count;
mutable bool m_dumped_to_log;
};
+ uint32_t m_packet_timeout;
+ uint32_t m_echo_number;
+ LazyBool m_supports_qEcho;
+#ifdef ENABLE_MUTEX_ERROR_CHECKING
+ TrackingMutex m_sequence_mutex;
+#else
+ Mutex m_sequence_mutex; // Restrict access to sending/receiving packets to a single thread at a time
+#endif
+ Predicate<bool> m_public_is_running;
+ Predicate<bool> m_private_is_running;
+ History m_history;
+ bool m_send_acks;
+ bool m_is_platform; // Set to true if this class represents a platform,
+ // false if this class represents a debug session for
+ // a single process
+
+ CompressionType m_compression_type;
+
PacketResult
SendPacket (const char *payload,
size_t payload_length);
@@ -321,27 +338,6 @@ protected:
bool
DecompressPacket ();
- //------------------------------------------------------------------
- // Classes that inherit from GDBRemoteCommunication can see and modify these
- //------------------------------------------------------------------
- uint32_t m_packet_timeout;
- uint32_t m_echo_number;
- LazyBool m_supports_qEcho;
-#ifdef ENABLE_MUTEX_ERROR_CHECKING
- TrackingMutex m_sequence_mutex;
-#else
- Mutex m_sequence_mutex; // Restrict access to sending/receiving packets to a single thread at a time
-#endif
- Predicate<bool> m_public_is_running;
- Predicate<bool> m_private_is_running;
- History m_history;
- bool m_send_acks;
- bool m_is_platform; // Set to true if this class represents a platform,
- // false if this class represents a debug session for
- // a single process
-
- CompressionType m_compression_type;
-
Error
StartListenThread (const char *hostname = "127.0.0.1", uint16_t port = 0);
@@ -361,10 +357,12 @@ protected:
// This method is defined as part of communication.h
// when the read thread gets any bytes it will pass them on to this function
- virtual void AppendBytesToCache (const uint8_t * bytes, size_t len, bool broadcast, lldb::ConnectionStatus status);
+ void AppendBytesToCache(const uint8_t * bytes,
+ size_t len,
+ bool broadcast,
+ lldb::ConnectionStatus status) override;
private:
-
std::queue<StringExtractorGDBRemote> m_packet_queue; // The packet queue
lldb_private::Mutex m_packet_queue_mutex; // Mutex for accessing queue
Condition m_condition_queue_not_empty; // Condition variable to wait for packets
@@ -372,13 +370,10 @@ private:
HostThread m_listen_thread;
std::string m_listen_url;
- //------------------------------------------------------------------
- // For GDBRemoteCommunication only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunication);
};
} // namespace process_gdb_remote
} // namespace lldb_private
-#endif // liblldb_GDBRemoteCommunication_h_
+#endif // liblldb_GDBRemoteCommunication_h_
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index b8c67c593b1f..5c7f6caca511 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -619,7 +619,6 @@ GDBRemoteCommunicationClient::GetThreadsInfo()
if (m_supports_jThreadsInfo)
{
StringExtractorGDBRemote response;
- m_supports_jThreadExtendedInfo = eLazyBoolNo;
if (SendPacketAndWaitForResponse("jThreadsInfo", response, false) == PacketResult::Success)
{
if (response.IsUnsupportedResponse())
@@ -782,7 +781,7 @@ GDBRemoteCommunicationClient::SendPacketAndWaitForResponse
Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS));
// In order to stop async notifications from being processed in the middle of the
- // send/recieve sequence Hijack the broadcast. Then rebroadcast any events when we are done.
+ // send/receive sequence Hijack the broadcast. Then rebroadcast any events when we are done.
static Listener hijack_listener("lldb.NotifyHijacker");
HijackBroadcaster(&hijack_listener, eBroadcastBitGdbReadThreadGotNotify);
@@ -878,10 +877,10 @@ GDBRemoteCommunicationClient::SendPacketAndWaitForResponse
}
}
- // Remove our Hijacking listner from the broadcast.
+ // Remove our Hijacking listener from the broadcast.
RestoreBroadcaster();
- // If a notification event occured, rebroadcast since it can now be processed safely.
+ // If a notification event occurred, rebroadcast since it can now be processed safely.
EventSP event_sp;
if (hijack_listener.GetNextEvent(event_sp))
BroadcastEvent(event_sp);
@@ -1050,7 +1049,6 @@ GDBRemoteCommunicationClient::SendContinuePacketAndWaitForResponse
Mutex::Locker locker(m_sequence_mutex);
StateType state = eStateRunning;
- BroadcastEvent(eBroadcastBitRunPacketSent, NULL);
m_public_is_running.SetValue (true, eBroadcastNever);
// Set the starting continue packet into "continue_packet". This packet
// may change if we are interrupted and we continue after an async packet...
@@ -1060,6 +1058,7 @@ GDBRemoteCommunicationClient::SendContinuePacketAndWaitForResponse
const auto sigint_signo = process->GetUnixSignals()->GetSignalNumberFromName("SIGINT");
bool got_async_packet = false;
+ bool broadcast_sent = false;
while (state == eStateRunning)
{
@@ -1072,6 +1071,12 @@ GDBRemoteCommunicationClient::SendContinuePacketAndWaitForResponse
else
m_interrupt_sent = false;
+ if (! broadcast_sent)
+ {
+ BroadcastEvent(eBroadcastBitRunPacketSent, NULL);
+ broadcast_sent = true;
+ }
+
m_private_is_running.SetValue (true, eBroadcastAlways);
}
@@ -1133,10 +1138,10 @@ GDBRemoteCommunicationClient::SendContinuePacketAndWaitForResponse
continue_after_async = false;
// We didn't get a SIGINT or SIGSTOP, so try for a
- // very brief time (1 ms) to get another stop reply
+ // very brief time (0.1s) to get another stop reply
// packet to make sure it doesn't get in the way
StringExtractorGDBRemote extra_stop_reply_packet;
- uint32_t timeout_usec = 1000;
+ uint32_t timeout_usec = 100000;
if (ReadPacket (extra_stop_reply_packet, timeout_usec, false) == PacketResult::Success)
{
switch (extra_stop_reply_packet.GetChar())
@@ -1262,9 +1267,13 @@ GDBRemoteCommunicationClient::SendContinuePacketAndWaitForResponse
got_async_packet = true;
std::string inferior_stdout;
inferior_stdout.reserve(response.GetBytesLeft () / 2);
- char ch;
- while ((ch = response.GetHexU8()) != '\0')
- inferior_stdout.append(1, ch);
+
+ uint8_t ch;
+ while (response.GetHexU8Ex(ch))
+ {
+ if (ch != 0)
+ inferior_stdout.append(1, (char)ch);
+ }
process->AppendSTDOUT (inferior_stdout.c_str(), inferior_stdout.size());
}
break;
@@ -1574,6 +1583,8 @@ GDBRemoteCommunicationClient::SendEnvironmentPacket (char const *name_equal_valu
{
case '$':
case '#':
+ case '*':
+ case '}':
send_hex_encoding = true;
break;
default:
@@ -2308,7 +2319,8 @@ GDBRemoteCommunicationClient::Detach (bool keep_stopped)
const int packet_len = ::snprintf(packet, sizeof(packet), "qSupportsDetachAndStayStopped:");
assert (packet_len < (int)sizeof(packet));
StringExtractorGDBRemote response;
- if (SendPacketAndWaitForResponse (packet, packet_len, response, false) == PacketResult::Success)
+ if (SendPacketAndWaitForResponse (packet, packet_len, response, false) == PacketResult::Success
+ && response.IsOKResponse())
{
m_supports_detach_stay_stopped = eLazyBoolYes;
}
@@ -2326,7 +2338,7 @@ GDBRemoteCommunicationClient::Detach (bool keep_stopped)
else
{
StringExtractorGDBRemote response;
- PacketResult packet_result = SendPacketAndWaitForResponse ("D1", 1, response, false);
+ PacketResult packet_result = SendPacketAndWaitForResponse ("D1", 2, response, false);
if (packet_result != PacketResult::Success)
error.SetErrorString ("Sending extended disconnect packet failed.");
}
@@ -3311,10 +3323,16 @@ GDBRemoteCommunicationClient::SendSpeedTestPacket (uint32_t send_size, uint32_t
return SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false) == PacketResult::Success;
}
-uint16_t
-GDBRemoteCommunicationClient::LaunchGDBserverAndGetPort (lldb::pid_t &pid, const char *remote_accept_hostname)
+bool
+GDBRemoteCommunicationClient::LaunchGDBServer (const char *remote_accept_hostname,
+ lldb::pid_t &pid,
+ uint16_t &port,
+ std::string &socket_name)
{
pid = LLDB_INVALID_PROCESS_ID;
+ port = 0;
+ socket_name.clear();
+
StringExtractorGDBRemote response;
StreamString stream;
stream.PutCString("qLaunchGDBServer;");
@@ -3339,22 +3357,67 @@ GDBRemoteCommunicationClient::LaunchGDBserverAndGetPort (lldb::pid_t &pid, const
// give the process a few seconds to startup
GDBRemoteCommunication::ScopedTimeout timeout (*this, 10);
-
+
if (SendPacketAndWaitForResponse(packet, packet_len, response, false) == PacketResult::Success)
{
std::string name;
std::string value;
- uint16_t port = 0;
+ StringExtractor extractor;
while (response.GetNameColonValue(name, value))
{
if (name.compare("port") == 0)
port = StringConvert::ToUInt32(value.c_str(), 0, 0);
else if (name.compare("pid") == 0)
pid = StringConvert::ToUInt64(value.c_str(), LLDB_INVALID_PROCESS_ID, 0);
+ else if (name.compare("socket_name") == 0)
+ {
+ extractor.GetStringRef().swap(value);
+ extractor.SetFilePos(0);
+ extractor.GetHexByteString(value);
+
+ socket_name = value;
+ }
}
- return port;
+ return true;
}
- return 0;
+ return false;
+}
+
+size_t
+GDBRemoteCommunicationClient::QueryGDBServer (std::vector<std::pair<uint16_t, std::string>>& connection_urls)
+{
+ connection_urls.clear();
+
+ StringExtractorGDBRemote response;
+ if (SendPacketAndWaitForResponse("qQueryGDBServer", response, false) != PacketResult::Success)
+ return 0;
+
+ StructuredData::ObjectSP data = StructuredData::ParseJSON(response.GetStringRef());
+ if (!data)
+ return 0;
+
+ StructuredData::Array* array = data->GetAsArray();
+ if (!array)
+ return 0;
+
+ for (size_t i = 0, count = array->GetSize(); i < count; ++i)
+ {
+ StructuredData::Dictionary* element = nullptr;
+ if (!array->GetItemAtIndexAsDictionary(i, element))
+ continue;
+
+ uint16_t port = 0;
+ if (StructuredData::ObjectSP port_osp = element->GetValueForKey(llvm::StringRef("port")))
+ port = port_osp->GetIntegerValue(0);
+
+ std::string socket_name;
+ if (StructuredData::ObjectSP socket_name_osp = element->GetValueForKey(llvm::StringRef("socket_name")))
+ socket_name = socket_name_osp->GetStringValue();
+
+ if (port != 0 || !socket_name.empty())
+ connection_urls.emplace_back(port, socket_name);
+ }
+ return connection_urls.size();
}
bool
@@ -3395,6 +3458,17 @@ GDBRemoteCommunicationClient::SetCurrentThread (uint64_t tid)
m_curr_tid = tid;
return true;
}
+
+ /*
+ * Connected bare-iron target (like YAMON gdb-stub) may not have support for Hg packet.
+ * The reply from '?' packet could be as simple as 'S05'. There is no packet which can
+ * give us pid and/or tid. Assume pid=tid=1 in such cases.
+ */
+ if (response.IsUnsupportedResponse() && IsConnected())
+ {
+ m_curr_tid = 1;
+ return true;
+ }
}
return false;
}
@@ -3421,6 +3495,17 @@ GDBRemoteCommunicationClient::SetCurrentThreadForRun (uint64_t tid)
m_curr_tid_run = tid;
return true;
}
+
+ /*
+ * Connected bare-iron target (like YAMON gdb-stub) may not have support for Hc packet.
+ * The reply from '?' packet could be as simple as 'S05'. There is no packet which can
+ * give us pid and/or tid. Assume pid=tid=1 in such cases.
+ */
+ if (response.IsUnsupportedResponse() && IsConnected())
+ {
+ m_curr_tid_run = 1;
+ return true;
+ }
}
return false;
}
@@ -3546,6 +3631,17 @@ GDBRemoteCommunicationClient::GetCurrentThreadIDs (std::vector<lldb::tid_t> &thr
} while (ch == ','); // Make sure we got a comma separator
}
}
+
+ /*
+ * Connected bare-iron target (like YAMON gdb-stub) may not have support for
+ * qProcessInfo, qC and qfThreadInfo packets. The reply from '?' packet could
+ * be as simple as 'S05'. There is no packet which can give us pid and/or tid.
+ * Assume pid=tid=1 in such cases.
+ */
+ if (response.IsUnsupportedResponse() && thread_ids.size() == 0 && IsConnected())
+ {
+ thread_ids.push_back (1);
+ }
}
else
{
@@ -4347,100 +4443,97 @@ GDBRemoteCommunicationClient::ServeSymbolLookups(lldb_private::Process *process)
{
StreamString packet;
packet.PutCString ("qSymbol::");
- while (1)
+ StringExtractorGDBRemote response;
+ while (SendPacketAndWaitForResponseNoLock(packet.GetData(), packet.GetSize(), response) == PacketResult::Success)
{
- StringExtractorGDBRemote response;
- if (SendPacketAndWaitForResponseNoLock(packet.GetData(), packet.GetSize(), response) == PacketResult::Success)
+ if (response.IsOKResponse())
{
- if (response.IsOKResponse())
- {
- // We are done serving symbols requests
- return;
- }
+ // We are done serving symbols requests
+ return;
+ }
- if (response.IsUnsupportedResponse())
- {
- // qSymbol is not supported by the current GDB server we are connected to
- m_supports_qSymbol = false;
- return;
- }
- else
+ if (response.IsUnsupportedResponse())
+ {
+ // qSymbol is not supported by the current GDB server we are connected to
+ m_supports_qSymbol = false;
+ return;
+ }
+ else
+ {
+ llvm::StringRef response_str(response.GetStringRef());
+ if (response_str.startswith("qSymbol:"))
{
- llvm::StringRef response_str(response.GetStringRef());
- if (response_str.startswith("qSymbol:"))
+ response.SetFilePos(strlen("qSymbol:"));
+ std::string symbol_name;
+ if (response.GetHexByteString(symbol_name))
{
- response.SetFilePos(strlen("qSymbol:"));
- std::string symbol_name;
- if (response.GetHexByteString(symbol_name))
- {
- if (symbol_name.empty())
- return;
+ if (symbol_name.empty())
+ return;
- addr_t symbol_load_addr = LLDB_INVALID_ADDRESS;
- lldb_private::SymbolContextList sc_list;
- if (process->GetTarget().GetImages().FindSymbolsWithNameAndType(ConstString(symbol_name), eSymbolTypeAny, sc_list))
+ addr_t symbol_load_addr = LLDB_INVALID_ADDRESS;
+ lldb_private::SymbolContextList sc_list;
+ if (process->GetTarget().GetImages().FindSymbolsWithNameAndType(ConstString(symbol_name), eSymbolTypeAny, sc_list))
+ {
+ const size_t num_scs = sc_list.GetSize();
+ for (size_t sc_idx=0; sc_idx<num_scs && symbol_load_addr == LLDB_INVALID_ADDRESS; ++sc_idx)
{
- const size_t num_scs = sc_list.GetSize();
- for (size_t sc_idx=0; sc_idx<num_scs && symbol_load_addr == LLDB_INVALID_ADDRESS; ++sc_idx)
+ SymbolContext sc;
+ if (sc_list.GetContextAtIndex(sc_idx, sc))
{
- SymbolContext sc;
- if (sc_list.GetContextAtIndex(sc_idx, sc))
+ if (sc.symbol)
{
- if (sc.symbol)
+ switch (sc.symbol->GetType())
{
- switch (sc.symbol->GetType())
- {
- case eSymbolTypeInvalid:
- case eSymbolTypeAbsolute:
- case eSymbolTypeUndefined:
- case eSymbolTypeSourceFile:
- case eSymbolTypeHeaderFile:
- case eSymbolTypeObjectFile:
- case eSymbolTypeCommonBlock:
- case eSymbolTypeBlock:
- case eSymbolTypeLocal:
- case eSymbolTypeParam:
- case eSymbolTypeVariable:
- case eSymbolTypeVariableType:
- case eSymbolTypeLineEntry:
- case eSymbolTypeLineHeader:
- case eSymbolTypeScopeBegin:
- case eSymbolTypeScopeEnd:
- case eSymbolTypeAdditional:
- case eSymbolTypeCompiler:
- case eSymbolTypeInstrumentation:
- case eSymbolTypeTrampoline:
- break;
-
- case eSymbolTypeCode:
- case eSymbolTypeResolver:
- case eSymbolTypeData:
- case eSymbolTypeRuntime:
- case eSymbolTypeException:
- case eSymbolTypeObjCClass:
- case eSymbolTypeObjCMetaClass:
- case eSymbolTypeObjCIVar:
- case eSymbolTypeReExported:
- symbol_load_addr = sc.symbol->GetLoadAddress(&process->GetTarget());
- break;
- }
+ case eSymbolTypeInvalid:
+ case eSymbolTypeAbsolute:
+ case eSymbolTypeUndefined:
+ case eSymbolTypeSourceFile:
+ case eSymbolTypeHeaderFile:
+ case eSymbolTypeObjectFile:
+ case eSymbolTypeCommonBlock:
+ case eSymbolTypeBlock:
+ case eSymbolTypeLocal:
+ case eSymbolTypeParam:
+ case eSymbolTypeVariable:
+ case eSymbolTypeVariableType:
+ case eSymbolTypeLineEntry:
+ case eSymbolTypeLineHeader:
+ case eSymbolTypeScopeBegin:
+ case eSymbolTypeScopeEnd:
+ case eSymbolTypeAdditional:
+ case eSymbolTypeCompiler:
+ case eSymbolTypeInstrumentation:
+ case eSymbolTypeTrampoline:
+ break;
+
+ case eSymbolTypeCode:
+ case eSymbolTypeResolver:
+ case eSymbolTypeData:
+ case eSymbolTypeRuntime:
+ case eSymbolTypeException:
+ case eSymbolTypeObjCClass:
+ case eSymbolTypeObjCMetaClass:
+ case eSymbolTypeObjCIVar:
+ case eSymbolTypeReExported:
+ symbol_load_addr = sc.symbol->GetLoadAddress(&process->GetTarget());
+ break;
}
}
}
}
- // This is the normal path where our symbol lookup was successful and we want
- // to send a packet with the new symbol value and see if another lookup needs to be
- // done.
-
- // Change "packet" to contain the requested symbol value and name
- packet.Clear();
- packet.PutCString("qSymbol:");
- if (symbol_load_addr != LLDB_INVALID_ADDRESS)
- packet.Printf("%" PRIx64, symbol_load_addr);
- packet.PutCString(":");
- packet.PutBytesAsRawHex8(symbol_name.data(), symbol_name.size());
- continue; // go back to the while loop and send "packet" and wait for another response
}
+ // This is the normal path where our symbol lookup was successful and we want
+ // to send a packet with the new symbol value and see if another lookup needs to be
+ // done.
+
+ // Change "packet" to contain the requested symbol value and name
+ packet.Clear();
+ packet.PutCString("qSymbol:");
+ if (symbol_load_addr != LLDB_INVALID_ADDRESS)
+ packet.Printf("%" PRIx64, symbol_load_addr);
+ packet.PutCString(":");
+ packet.PutBytesAsRawHex8(symbol_name.data(), symbol_name.size());
+ continue; // go back to the while loop and send "packet" and wait for another response
}
}
}
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
index b08ff0647797..d2df214d0dba 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
@@ -12,6 +12,8 @@
// C Includes
// C++ Includes
+#include <map>
+#include <string>
#include <vector>
// Other libraries and framework includes
@@ -28,12 +30,9 @@ namespace process_gdb_remote {
class GDBRemoteCommunicationClient : public GDBRemoteCommunication
{
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
GDBRemoteCommunicationClient();
- ~GDBRemoteCommunicationClient();
+ ~GDBRemoteCommunicationClient() override;
//------------------------------------------------------------------
// After connecting, send the handshake to the server to make sure
@@ -79,6 +78,7 @@ public:
const char *packet_payload,
size_t packet_length,
StringExtractorGDBRemote &response);
+
bool
SendvContPacket (ProcessGDBRemote *process,
const char *payload,
@@ -114,9 +114,15 @@ public:
bool
GetLaunchSuccess (std::string &error_str);
- uint16_t
- LaunchGDBserverAndGetPort (lldb::pid_t &pid, const char *remote_accept_hostname);
-
+ bool
+ LaunchGDBServer (const char *remote_accept_hostname,
+ lldb::pid_t &pid,
+ uint16_t &port,
+ std::string &socket_name);
+
+ size_t
+ QueryGDBServer (std::vector<std::pair<uint16_t, std::string>>& connection_urls);
+
bool
KillSpawnedProcess (lldb::pid_t pid);
@@ -161,7 +167,7 @@ public:
SendLaunchArchPacket (const char *arch);
int
- SendLaunchEventDataPacket (const char *data, bool *was_supported = NULL);
+ SendLaunchEventDataPacket(const char *data, bool *was_supported = nullptr);
//------------------------------------------------------------------
/// Sends a "vAttach:PID" where PID is in hex.
@@ -182,7 +188,6 @@ public:
SendAttach (lldb::pid_t pid,
StringExtractorGDBRemote& response);
-
//------------------------------------------------------------------
/// Sends a GDB remote protocol 'I' packet that delivers stdin
/// data to the remote process.
@@ -396,6 +401,7 @@ public:
default: return false;
}
}
+
uint8_t
SendGDBStoppointTypePacket (GDBStoppointType type, // Type of breakpoint or watchpoint
bool insert, // Insert or remove?
@@ -505,11 +511,11 @@ public:
GetFileExists (const FileSpec& file_spec);
Error
- RunShellCommand(const char *command, // Shouldn't be NULL
+ RunShellCommand(const char *command, // Shouldn't be nullptr
const FileSpec &working_dir, // Pass empty FileSpec to use the current working directory
- int *status_ptr, // Pass 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
+ int *status_ptr, // Pass nullptr if you don't want the process exit status
+ int *signo_ptr, // Pass nullptr if you don't want the signal that caused the process to exit
+ std::string *command_output, // Pass nullptr if you don't want the command output
uint32_t timeout_sec); // Timeout in seconds to wait for shell program to finish
bool
@@ -567,26 +573,6 @@ public:
ServeSymbolLookups(lldb_private::Process *process);
protected:
-
- PacketResult
- SendPacketAndWaitForResponseNoLock (const char *payload,
- size_t payload_length,
- StringExtractorGDBRemote &response);
-
- bool
- GetCurrentProcessInfo (bool allow_lazy_pid = true);
-
- bool
- GetGDBServerVersion();
-
- // Given the list of compression types that the remote debug stub can support,
- // possibly enable compression if we find an encoding we can handle.
- void
- MaybeEnableCompression (std::vector<std::string> supported_compressions);
-
- //------------------------------------------------------------------
- // Classes that inherit from GDBRemoteCommunicationClient can see and modify these
- //------------------------------------------------------------------
LazyBool m_supports_not_sending_acks;
LazyBool m_supports_thread_suffix;
LazyBool m_supports_threads_in_stop_reply;
@@ -639,7 +625,6 @@ protected:
lldb::tid_t m_curr_tid; // Current gdb remote protocol thread index for all other operations
lldb::tid_t m_curr_tid_run; // Current gdb remote protocol thread index for continue, step, etc
-
uint32_t m_num_supported_hardware_watchpoints;
// If we need to send a packet while the target is running, the m_async_XXX
@@ -667,18 +652,31 @@ protected:
uint32_t m_default_packet_timeout;
uint64_t m_max_packet_size; // as returned by qSupported
-
+ PacketResult
+ SendPacketAndWaitForResponseNoLock (const char *payload,
+ size_t payload_length,
+ StringExtractorGDBRemote &response);
+
+ bool
+ GetCurrentProcessInfo (bool allow_lazy_pid = true);
+
+ bool
+ GetGDBServerVersion();
+
+ // Given the list of compression types that the remote debug stub can support,
+ // possibly enable compression if we find an encoding we can handle.
+ void
+ MaybeEnableCompression (std::vector<std::string> supported_compressions);
+
bool
DecodeProcessInfoResponse (StringExtractorGDBRemote &response,
ProcessInstanceInfo &process_info);
+
private:
- //------------------------------------------------------------------
- // For GDBRemoteCommunicationClient only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationClient);
};
} // namespace process_gdb_remote
} // namespace lldb_private
-#endif // liblldb_GDBRemoteCommunicationClient_h_
+#endif // liblldb_GDBRemoteCommunicationClient_h_
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
index 44c0f6a32f5b..1d512bf1de59 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
@@ -39,8 +39,7 @@ public:
GDBRemoteCommunicationServer(const char *comm_name,
const char *listener_name);
- virtual
- ~GDBRemoteCommunicationServer();
+ ~GDBRemoteCommunicationServer() override;
void RegisterPacketHandler(StringExtractorGDBRemote::ServerPacketType packet_type,
PacketHandler handler);
@@ -73,13 +72,10 @@ protected:
SendOKResponse ();
private:
- //------------------------------------------------------------------
- // For GDBRemoteCommunicationServer only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationServer);
};
} // namespace process_gdb_remote
} // namespace lldb_private
-#endif // liblldb_GDBRemoteCommunicationServer_h_
+#endif // liblldb_GDBRemoteCommunicationServer_h_
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
index 698854e5dfbd..7f876fb393d9 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -58,8 +58,6 @@ using namespace lldb_private::process_gdb_remote;
//----------------------------------------------------------------------
GDBRemoteCommunicationServerCommon::GDBRemoteCommunicationServerCommon(const char *comm_name, const char *listener_name) :
GDBRemoteCommunicationServer (comm_name, listener_name),
- m_spawned_pids (),
- m_spawned_pids_mutex (Mutex::eMutexTypeRecursive),
m_process_launch_info (),
m_process_launch_error (),
m_proc_infos (),
@@ -79,8 +77,6 @@ GDBRemoteCommunicationServerCommon::GDBRemoteCommunicationServerCommon(const cha
&GDBRemoteCommunicationServerCommon::Handle_qGroupName);
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_qHostInfo,
&GDBRemoteCommunicationServerCommon::Handle_qHostInfo);
- RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_qKillSpawnedProcess,
- &GDBRemoteCommunicationServerCommon::Handle_qKillSpawnedProcess);
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_QLaunchArch,
&GDBRemoteCommunicationServerCommon::Handle_QLaunchArch);
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_qLaunchSuccess,
@@ -185,14 +181,20 @@ GDBRemoteCommunicationServerCommon::Handle_qHostInfo (StringExtractorGDBRemote &
else
response.Printf("watchpoint_exceptions_received:after;");
#else
- if (host_arch.GetMachine() == llvm::Triple::mips64 ||
- host_arch.GetMachine() == llvm::Triple::mips64el)
+ 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)
response.Printf("watchpoint_exceptions_received:before;");
else
response.Printf("watchpoint_exceptions_received:after;");
#endif
- switch (lldb::endian::InlHostByteOrder())
+ switch (endian::InlHostByteOrder())
{
case eByteOrderBig: response.PutCString ("endian:big;"); break;
case eByteOrderLittle: response.PutCString ("endian:little;"); break;
@@ -485,94 +487,6 @@ GDBRemoteCommunicationServerCommon::Handle_qSpeedTest (StringExtractorGDBRemote
}
GDBRemoteCommunication::PacketResult
-GDBRemoteCommunicationServerCommon::Handle_qKillSpawnedProcess (StringExtractorGDBRemote &packet)
-{
- packet.SetFilePos(::strlen ("qKillSpawnedProcess:"));
-
- lldb::pid_t pid = packet.GetU64(LLDB_INVALID_PROCESS_ID);
-
- // verify that we know anything about this pid.
- // Scope for locker
- {
- Mutex::Locker locker (m_spawned_pids_mutex);
- if (m_spawned_pids.find(pid) == m_spawned_pids.end())
- {
- // not a pid we know about
- return SendErrorResponse (10);
- }
- }
-
- // go ahead and attempt to kill the spawned process
- if (KillSpawnedProcess (pid))
- return SendOKResponse ();
- else
- return SendErrorResponse (11);
-}
-
-bool
-GDBRemoteCommunicationServerCommon::KillSpawnedProcess (lldb::pid_t pid)
-{
- // make sure we know about this process
- {
- Mutex::Locker locker (m_spawned_pids_mutex);
- if (m_spawned_pids.find(pid) == m_spawned_pids.end())
- return false;
- }
-
- // first try a SIGTERM (standard kill)
- Host::Kill (pid, SIGTERM);
-
- // check if that worked
- for (size_t i=0; i<10; ++i)
- {
- {
- Mutex::Locker locker (m_spawned_pids_mutex);
- if (m_spawned_pids.find(pid) == m_spawned_pids.end())
- {
- // it is now killed
- return true;
- }
- }
- usleep (10000);
- }
-
- // check one more time after the final usleep
- {
- Mutex::Locker locker (m_spawned_pids_mutex);
- if (m_spawned_pids.find(pid) == m_spawned_pids.end())
- return true;
- }
-
- // the launched process still lives. Now try killing it again,
- // this time with an unblockable signal.
- Host::Kill (pid, SIGKILL);
-
- for (size_t i=0; i<10; ++i)
- {
- {
- Mutex::Locker locker (m_spawned_pids_mutex);
- if (m_spawned_pids.find(pid) == m_spawned_pids.end())
- {
- // it is now killed
- return true;
- }
- }
- usleep (10000);
- }
-
- // check one more time after the final usleep
- // Scope for locker
- {
- Mutex::Locker locker (m_spawned_pids_mutex);
- if (m_spawned_pids.find(pid) == m_spawned_pids.end())
- return true;
- }
-
- // no luck - the process still lives
- return false;
-}
-
-GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_vFile_Open (StringExtractorGDBRemote &packet)
{
packet.SetFilePos(::strlen("vFile:open:"));
@@ -1299,6 +1213,7 @@ GDBRemoteCommunicationServerCommon::CreateProcessInfoResponse_DebugServerStyle (
switch (proc_triple.getArch ())
{
case llvm::Triple::arm:
+ case llvm::Triple::thumb:
case llvm::Triple::aarch64:
ostype = "ios";
break;
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
index 62b129bb18b9..f55b2eb3f4dc 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
@@ -12,14 +12,14 @@
// C Includes
// C++ Includes
-#include <set>
+#include <string>
// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private-forward.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Target/Process.h"
-// Project includes
#include "GDBRemoteCommunicationServer.h"
#include "GDBRemoteCommunicationServerCommon.h"
@@ -36,12 +36,9 @@ class GDBRemoteCommunicationServerCommon :
public:
GDBRemoteCommunicationServerCommon(const char *comm_name, const char *listener_name);
- virtual
- ~GDBRemoteCommunicationServerCommon();
+ ~GDBRemoteCommunicationServerCommon() override;
protected:
- std::set<lldb::pid_t> m_spawned_pids;
- Mutex m_spawned_pids_mutex;
ProcessLaunchInfo m_process_launch_info;
Error m_process_launch_error;
ProcessInstanceInfoList m_proc_infos;
@@ -74,9 +71,6 @@ protected:
Handle_qSpeedTest (StringExtractorGDBRemote &packet);
PacketResult
- Handle_qKillSpawnedProcess (StringExtractorGDBRemote &packet);
-
- PacketResult
Handle_vFile_Open (StringExtractorGDBRemote &packet);
PacketResult
@@ -160,9 +154,6 @@ protected:
PacketResult
Handle_QLaunchArch (StringExtractorGDBRemote &packet);
- bool
- KillSpawnedProcess (lldb::pid_t pid);
-
static void
CreateProcessInfoResponse (const ProcessInstanceInfo &proc_info,
StreamString &response);
@@ -213,4 +204,4 @@ protected:
} // namespace process_gdb_remote
} // namespace lldb_private
-#endif // liblldb_GDBRemoteCommunicationServerCommon_h_
+#endif // liblldb_GDBRemoteCommunicationServerCommon_h_
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index c4523252f190..921369c7ef21 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -43,6 +43,8 @@
#include "lldb/Host/common/NativeRegisterContext.h"
#include "lldb/Host/common/NativeProcessProtocol.h"
#include "lldb/Host/common/NativeThreadProtocol.h"
+#include "lldb/Utility/JSON.h"
+#include "lldb/Utility/LLDBAssert.h"
// Project includes
#include "Utility/StringExtractorGDBRemote.h"
@@ -96,20 +98,6 @@ GDBRemoteCommunicationServerLLGS::GDBRemoteCommunicationServerLLGS(
RegisterPacketHandlers();
}
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-GDBRemoteCommunicationServerLLGS::~GDBRemoteCommunicationServerLLGS()
-{
- Mutex::Locker locker (m_debugged_process_mutex);
-
- if (m_debugged_process_sp)
- {
- m_debugged_process_sp->Terminate ();
- m_debugged_process_sp.reset ();
- }
-}
-
void
GDBRemoteCommunicationServerLLGS::RegisterPacketHandlers()
{
@@ -126,7 +114,7 @@ GDBRemoteCommunicationServerLLGS::RegisterPacketHandlers()
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_interrupt,
&GDBRemoteCommunicationServerLLGS::Handle_interrupt);
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_m,
- &GDBRemoteCommunicationServerLLGS::Handle_m);
+ &GDBRemoteCommunicationServerLLGS::Handle_memory_read);
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_M,
&GDBRemoteCommunicationServerLLGS::Handle_M);
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_p,
@@ -161,6 +149,8 @@ GDBRemoteCommunicationServerLLGS::RegisterPacketHandlers()
&GDBRemoteCommunicationServerLLGS::Handle_qsThreadInfo);
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_qThreadStopInfo,
&GDBRemoteCommunicationServerLLGS::Handle_qThreadStopInfo);
+ RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_jThreadsInfo,
+ &GDBRemoteCommunicationServerLLGS::Handle_jThreadsInfo);
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_qWatchpointSupportInfo,
&GDBRemoteCommunicationServerLLGS::Handle_qWatchpointSupportInfo);
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_qXfer_auxv_read,
@@ -175,6 +165,8 @@ GDBRemoteCommunicationServerLLGS::RegisterPacketHandlers()
&GDBRemoteCommunicationServerLLGS::Handle_vCont);
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_vCont_actions,
&GDBRemoteCommunicationServerLLGS::Handle_vCont_actions);
+ RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_x,
+ &GDBRemoteCommunicationServerLLGS::Handle_memory_read);
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_Z,
&GDBRemoteCommunicationServerLLGS::Handle_Z);
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_z,
@@ -223,6 +215,7 @@ GDBRemoteCommunicationServerLLGS::LaunchProcess ()
error = NativeProcessProtocol::Launch(
m_process_launch_info,
*this,
+ m_mainloop,
m_debugged_process_sp);
}
@@ -274,17 +267,6 @@ GDBRemoteCommunicationServerLLGS::LaunchProcess ()
printf ("Launched '%s' as process %" PRIu64 "...\n", m_process_launch_info.GetArguments ().GetArgumentAtIndex (0), m_process_launch_info.GetProcessID ());
- // Add to list of spawned processes.
- lldb::pid_t pid;
- if ((pid = m_process_launch_info.GetProcessID ()) != LLDB_INVALID_PROCESS_ID)
- {
- // add to spawned pids
- Mutex::Locker locker (m_spawned_pids_mutex);
- // On an lldb-gdbserver, we would expect there to be only one.
- assert (m_spawned_pids.empty () && "lldb-gdbserver adding tracked process but one already existed");
- m_spawned_pids.insert (pid);
- }
-
return error;
}
@@ -297,48 +279,37 @@ GDBRemoteCommunicationServerLLGS::AttachToProcess (lldb::pid_t pid)
if (log)
log->Printf ("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64, __FUNCTION__, pid);
- // Scope for mutex locker.
+ // Before we try to attach, make sure we aren't already monitoring something else.
+ if (m_debugged_process_sp && m_debugged_process_sp->GetID() != LLDB_INVALID_PROCESS_ID)
+ return Error("cannot attach to a process %" PRIu64 " when another process with pid %" PRIu64 " is being debugged.", pid, m_debugged_process_sp->GetID());
+
+ // Try to attach.
+ error = NativeProcessProtocol::Attach(pid, *this, m_mainloop, m_debugged_process_sp);
+ if (!error.Success ())
{
- // Before we try to attach, make sure we aren't already monitoring something else.
- Mutex::Locker locker (m_spawned_pids_mutex);
- if (!m_spawned_pids.empty ())
- {
- error.SetErrorStringWithFormat ("cannot attach to a process %" PRIu64 " when another process with pid %" PRIu64 " is being debugged.", pid, *m_spawned_pids.begin());
- return error;
- }
+ fprintf (stderr, "%s: failed to attach to process %" PRIu64 ": %s", __FUNCTION__, pid, error.AsCString ());
+ return error;
+ }
- // Try to attach.
- error = NativeProcessProtocol::Attach(pid, *this, m_debugged_process_sp);
- if (!error.Success ())
- {
- fprintf (stderr, "%s: failed to attach to process %" PRIu64 ": %s", __FUNCTION__, pid, error.AsCString ());
+ // Setup stdout/stderr mapping from inferior.
+ auto terminal_fd = m_debugged_process_sp->GetTerminalFileDescriptor ();
+ if (terminal_fd >= 0)
+ {
+ if (log)
+ log->Printf ("ProcessGDBRemoteCommunicationServerLLGS::%s setting inferior STDIO fd to %d", __FUNCTION__, terminal_fd);
+ error = SetSTDIOFileDescriptor (terminal_fd);
+ if (error.Fail ())
return error;
- }
-
- // Setup stdout/stderr mapping from inferior.
- auto terminal_fd = m_debugged_process_sp->GetTerminalFileDescriptor ();
- if (terminal_fd >= 0)
- {
- if (log)
- log->Printf ("ProcessGDBRemoteCommunicationServerLLGS::%s setting inferior STDIO fd to %d", __FUNCTION__, terminal_fd);
- error = SetSTDIOFileDescriptor (terminal_fd);
- if (error.Fail ())
- return error;
- }
- else
- {
- if (log)
- log->Printf ("ProcessGDBRemoteCommunicationServerLLGS::%s ignoring inferior STDIO since terminal fd reported as %d", __FUNCTION__, terminal_fd);
- }
-
- printf ("Attached to process %" PRIu64 "...\n", pid);
+ }
+ else
+ {
+ if (log)
+ log->Printf ("ProcessGDBRemoteCommunicationServerLLGS::%s ignoring inferior STDIO since terminal fd reported as %d", __FUNCTION__, terminal_fd);
+ }
- // Add to list of spawned processes.
- assert (m_spawned_pids.empty () && "lldb-gdbserver adding tracked process but one already existed");
- m_spawned_pids.insert (pid);
+ printf ("Attached to process %" PRIu64 "...\n", pid);
- return error;
- }
+ return error;
}
void
@@ -455,6 +426,178 @@ WriteRegisterValueInHexFixedWidth (StreamString &response,
}
}
+static JSONObject::SP
+GetRegistersAsJSON(NativeThreadProtocol &thread, bool abridged)
+{
+ Log *log (GetLogIfAnyCategoriesSet (LIBLLDB_LOG_THREAD));
+
+ NativeRegisterContextSP reg_ctx_sp = thread.GetRegisterContext ();
+ if (! reg_ctx_sp)
+ return nullptr;
+
+ JSONObject::SP register_object_sp = std::make_shared<JSONObject>();
+
+#ifdef LLDB_JTHREADSINFO_FULL_REGISTER_SET
+ // Expedite all registers in the first register set (i.e. should be GPRs) that are not contained in other registers.
+ const RegisterSet *reg_set_p = reg_ctx_sp->GetRegisterSet(0);
+ if (! reg_set_p)
+ return nullptr;
+ for (const uint32_t *reg_num_p = reg_set_p->registers; *reg_num_p != LLDB_INVALID_REGNUM; ++reg_num_p)
+ {
+ uint32_t reg_num = *reg_num_p;
+#else
+ // Expedite only a couple of registers until we figure out why sending registers is
+ // expensive.
+ static const uint32_t k_expedited_registers[] = {
+ LLDB_REGNUM_GENERIC_PC, LLDB_REGNUM_GENERIC_SP, LLDB_REGNUM_GENERIC_FP, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM
+ };
+ static const uint32_t k_abridged_expedited_registers[] = {
+ LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM
+ };
+
+ for (const uint32_t *generic_reg_p = abridged ? k_abridged_expedited_registers : k_expedited_registers;
+ *generic_reg_p != LLDB_INVALID_REGNUM;
+ ++generic_reg_p)
+ {
+ uint32_t reg_num = reg_ctx_sp->ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, *generic_reg_p);
+ if (reg_num == LLDB_INVALID_REGNUM)
+ continue; // Target does not support the given register.
+#endif
+
+ const RegisterInfo *const reg_info_p = reg_ctx_sp->GetRegisterInfoAtIndex(reg_num);
+ if (reg_info_p == nullptr)
+ {
+ if (log)
+ log->Printf("%s failed to get register info for register index %" PRIu32,
+ __FUNCTION__, reg_num);
+ continue;
+ }
+
+ if (reg_info_p->value_regs != nullptr)
+ continue; // Only expedite registers that are not contained in other registers.
+
+ RegisterValue reg_value;
+ Error error = reg_ctx_sp->ReadRegister(reg_info_p, reg_value);
+ if (error.Fail())
+ {
+ if (log)
+ log->Printf("%s failed to read register '%s' index %" PRIu32 ": %s", __FUNCTION__,
+ reg_info_p->name ? reg_info_p->name : "<unnamed-register>", reg_num,
+ error.AsCString ());
+ continue;
+ }
+
+ StreamString stream;
+ WriteRegisterValueInHexFixedWidth(stream, reg_ctx_sp, *reg_info_p, &reg_value);
+
+ register_object_sp->SetObject(std::to_string(reg_num),
+ std::make_shared<JSONString>(stream.GetString()));
+ }
+
+ return register_object_sp;
+}
+
+static const char *
+GetStopReasonString(StopReason stop_reason)
+{
+ switch (stop_reason)
+ {
+ case eStopReasonTrace:
+ return "trace";
+ case eStopReasonBreakpoint:
+ return "breakpoint";
+ case eStopReasonWatchpoint:
+ return "watchpoint";
+ case eStopReasonSignal:
+ return "signal";
+ case eStopReasonException:
+ return "exception";
+ case eStopReasonExec:
+ return "exec";
+ case eStopReasonInstrumentation:
+ case eStopReasonInvalid:
+ case eStopReasonPlanComplete:
+ case eStopReasonThreadExiting:
+ case eStopReasonNone:
+ break; // ignored
+ }
+ return nullptr;
+}
+
+static JSONArray::SP
+GetJSONThreadsInfo(NativeProcessProtocol &process, bool abridged)
+{
+ Log *log (GetLogIfAnyCategoriesSet (LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD));
+
+ JSONArray::SP threads_array_sp = std::make_shared<JSONArray>();
+
+ // Ensure we can get info on the given thread.
+ uint32_t thread_idx = 0;
+ for ( NativeThreadProtocolSP thread_sp;
+ (thread_sp = process.GetThreadAtIndex(thread_idx)) != nullptr;
+ ++thread_idx)
+ {
+
+ lldb::tid_t tid = thread_sp->GetID();
+
+ // Grab the reason this thread stopped.
+ struct ThreadStopInfo tid_stop_info;
+ std::string description;
+ if (!thread_sp->GetStopReason (tid_stop_info, description))
+ return nullptr;
+
+ const int signum = tid_stop_info.details.signal.signo;
+ if (log)
+ {
+ log->Printf ("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64 " tid %" PRIu64 " got signal signo = %d, reason = %d, exc_type = %" PRIu64,
+ __FUNCTION__,
+ process.GetID (),
+ tid,
+ signum,
+ tid_stop_info.reason,
+ tid_stop_info.details.exception.type);
+ }
+
+ JSONObject::SP thread_obj_sp = std::make_shared<JSONObject>();
+ threads_array_sp->AppendObject(thread_obj_sp);
+
+ if (JSONObject::SP registers_sp = GetRegistersAsJSON(*thread_sp, abridged))
+ thread_obj_sp->SetObject("registers", registers_sp);
+
+ thread_obj_sp->SetObject("tid", std::make_shared<JSONNumber>(tid));
+ if (signum != 0)
+ thread_obj_sp->SetObject("signal", std::make_shared<JSONNumber>(signum));
+
+ const std::string thread_name = thread_sp->GetName ();
+ if (! thread_name.empty())
+ thread_obj_sp->SetObject("name", std::make_shared<JSONString>(thread_name));
+
+ if (const char *stop_reason_str = GetStopReasonString(tid_stop_info.reason))
+ thread_obj_sp->SetObject("reason", std::make_shared<JSONString>(stop_reason_str));
+
+ if (! description.empty())
+ thread_obj_sp->SetObject("description", std::make_shared<JSONString>(description));
+
+ if ((tid_stop_info.reason == eStopReasonException) && tid_stop_info.details.exception.type)
+ {
+ thread_obj_sp->SetObject("metype",
+ std::make_shared<JSONNumber>(tid_stop_info.details.exception.type));
+
+ JSONArray::SP medata_array_sp = std::make_shared<JSONArray>();
+ for (uint32_t i = 0; i < tid_stop_info.details.exception.data_count; ++i)
+ {
+ medata_array_sp->AppendObject(std::make_shared<JSONNumber>(
+ tid_stop_info.details.exception.data[i]));
+ }
+ thread_obj_sp->SetObject("medata", medata_array_sp);
+ }
+
+ // TODO: Expedite interesting regions of inferior memory
+ }
+
+ return threads_array_sp;
+}
+
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread (lldb::tid_t tid)
{
@@ -548,6 +691,31 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread (lldb::tid_t tid)
response.Printf ("%" PRIx64, listed_thread_sp->GetID ());
}
response.PutChar (';');
+
+ // Include JSON info that describes the stop reason for any threads
+ // that actually have stop reasons. We use the new "jstopinfo" key
+ // whose values is hex ascii JSON that contains the thread IDs
+ // thread stop info only for threads that have stop reasons. Only send
+ // this if we have more than one thread otherwise this packet has all
+ // the info it needs.
+ if (thread_index > 0)
+ {
+ const bool threads_with_valid_stop_info_only = true;
+ JSONArray::SP threads_info_sp = GetJSONThreadsInfo(*m_debugged_process_sp,
+ threads_with_valid_stop_info_only);
+ if (threads_info_sp)
+ {
+ response.PutCString("jstopinfo:");
+ StreamString unescaped_response;
+ threads_info_sp->Write(unescaped_response);
+ response.PutCStringAsRawHex8(unescaped_response.GetData());
+ response.PutChar(';');
+ }
+ else if (log)
+ log->Printf ("GDBRemoteCommunicationServerLLGS::%s failed to prepare a jstopinfo field for pid %" PRIu64,
+ __FUNCTION__, m_debugged_process_sp->GetID());
+
+ }
}
//
@@ -595,34 +763,7 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread (lldb::tid_t tid)
}
}
- const char* reason_str = nullptr;
- switch (tid_stop_info.reason)
- {
- case eStopReasonTrace:
- reason_str = "trace";
- break;
- case eStopReasonBreakpoint:
- reason_str = "breakpoint";
- break;
- case eStopReasonWatchpoint:
- reason_str = "watchpoint";
- break;
- case eStopReasonSignal:
- reason_str = "signal";
- break;
- case eStopReasonException:
- reason_str = "exception";
- break;
- case eStopReasonExec:
- reason_str = "exec";
- break;
- case eStopReasonInstrumentation:
- case eStopReasonInvalid:
- case eStopReasonPlanComplete:
- case eStopReasonThreadExiting:
- case eStopReasonNone:
- break;
- }
+ const char* reason_str = GetStopReasonString(tid_stop_info.reason);
if (reason_str != nullptr)
{
response.Printf ("reason:%s;", reason_str);
@@ -663,43 +804,15 @@ GDBRemoteCommunicationServerLLGS::HandleInferiorState_Exited (NativeProcessProto
if (log)
log->Printf ("GDBRemoteCommunicationServerLLGS::%s called", __FUNCTION__);
- // Send the exit result, and don't flush output.
- // Note: flushing output here would join the inferior stdio reflection thread, which
- // would gunk up the waitpid monitor thread that is calling this.
- PacketResult result = SendStopReasonForState (StateType::eStateExited, false);
+ PacketResult result = SendStopReasonForState(StateType::eStateExited);
if (result != PacketResult::Success)
{
if (log)
log->Printf ("GDBRemoteCommunicationServerLLGS::%s failed to send stop notification for PID %" PRIu64 ", state: eStateExited", __FUNCTION__, process->GetID ());
}
- // Remove the process from the list of spawned pids.
- {
- Mutex::Locker locker (m_spawned_pids_mutex);
- if (m_spawned_pids.erase (process->GetID ()) < 1)
- {
- if (log)
- log->Printf ("GDBRemoteCommunicationServerLLGS::%s failed to remove PID %" PRIu64 " from the spawned pids list", __FUNCTION__, process->GetID ());
-
- }
- }
-
- // FIXME can't do this yet - since process state propagation is currently
- // synchronous, it is running off the NativeProcessProtocol's innards and
- // will tear down the NPP while it still has code to execute.
-#if 0
- // Clear the NativeProcessProtocol pointer.
- {
- Mutex::Locker locker (m_debugged_process_mutex);
- m_debugged_process_sp.reset();
- }
-#endif
-
// Close the pipe to the inferior terminal i/o if we launched it
- // and set one up. Otherwise, 'k' and its flush of stdio could
- // end up waiting on a thread join that will never end. Consider
- // adding a timeout to the connection thread join call so we
- // can avoid that scenario altogether.
+ // and set one up.
MaybeCloseInferiorTerminalConnection ();
// We are ready to exit the debug monitor.
@@ -725,7 +838,7 @@ GDBRemoteCommunicationServerLLGS::HandleInferiorState_Stopped (NativeProcessProt
break;
default:
// In all other cases, send the stop reason.
- PacketResult result = SendStopReasonForState (StateType::eStateStopped, false);
+ PacketResult result = SendStopReasonForState(StateType::eStateStopped);
if (result != PacketResult::Success)
{
if (log)
@@ -748,21 +861,30 @@ GDBRemoteCommunicationServerLLGS::ProcessStateChanged (NativeProcessProtocol *pr
StateAsCString (state));
}
- // Make sure we get all of the pending stdout/stderr from the inferior
- // and send it to the lldb host before we send the state change
- // notification
- m_stdio_communication.SynchronizeWithReadThread();
-
switch (state)
{
- case StateType::eStateExited:
- HandleInferiorState_Exited (process);
+ case StateType::eStateRunning:
+ StartSTDIOForwarding();
break;
case StateType::eStateStopped:
+ // Make sure we get all of the pending stdout/stderr from the inferior
+ // and send it to the lldb host before we send the state change
+ // notification
+ SendProcessOutput();
+ // Then stop the forwarding, so that any late output (see llvm.org/pr25652) does not
+ // interfere with our protocol.
+ StopSTDIOForwarding();
HandleInferiorState_Stopped (process);
break;
+ case StateType::eStateExited:
+ // Same as above
+ SendProcessOutput();
+ StopSTDIOForwarding();
+ HandleInferiorState_Exited (process);
+ break;
+
default:
if (log)
{
@@ -796,7 +918,6 @@ GDBRemoteCommunicationServerLLGS::DataAvailableCallback ()
if(log)
log->Printf("GDBRemoteCommunicationServerLLGS::%s handshake with client failed, exiting",
__FUNCTION__);
- m_read_handle_up.reset();
m_mainloop.RequestTermination();
return;
}
@@ -817,7 +938,6 @@ GDBRemoteCommunicationServerLLGS::DataAvailableCallback ()
if(log)
log->Printf("GDBRemoteCommunicationServerLLGS::%s processing a packet failed: %s",
__FUNCTION__, error.AsCString());
- m_read_handle_up.reset();
m_mainloop.RequestTermination();
break;
}
@@ -831,7 +951,7 @@ GDBRemoteCommunicationServerLLGS::InitializeConnection (std::unique_ptr<Connecti
GDBRemoteCommunicationServer::SetConnection(connection.release());
Error error;
- m_read_handle_up = m_mainloop.RegisterReadObject(read_object_sp,
+ m_network_handle_up = m_mainloop.RegisterReadObject(read_object_sp,
[this] (MainLoopBase &) { DataAvailableCallback(); }, error);
return error;
}
@@ -857,7 +977,7 @@ GDBRemoteCommunicationServerLLGS::SetSTDIOFileDescriptor (int fd)
{
Error error;
- // Set up the Read Thread for reading/handling process I/O
+ // Set up the reading/handling of process I/O
std::unique_ptr<ConnectionFileDescriptor> conn_up (new ConnectionFileDescriptor (fd, true));
if (!conn_up)
{
@@ -873,29 +993,73 @@ GDBRemoteCommunicationServerLLGS::SetSTDIOFileDescriptor (int fd)
return error;
}
+ return Error();
+}
+
+void
+GDBRemoteCommunicationServerLLGS::StartSTDIOForwarding()
+{
+ // Don't forward if not connected (e.g. when attaching).
+ if (! m_stdio_communication.IsConnected())
+ return;
+
// llgs local-process debugging may specify PTY paths, which will make these
// file actions non-null
// process launch -e/o will also make these file actions non-null
// nullptr means that the traffic is expected to flow over gdb-remote protocol
- if (
- m_process_launch_info.GetFileActionForFD(STDOUT_FILENO) == nullptr ||
- m_process_launch_info.GetFileActionForFD(STDERR_FILENO) == nullptr
- )
+ if ( m_process_launch_info.GetFileActionForFD(STDOUT_FILENO) &&
+ m_process_launch_info.GetFileActionForFD(STDERR_FILENO))
+ return;
+
+ Error error;
+ lldbassert(! m_stdio_handle_up);
+ m_stdio_handle_up = m_mainloop.RegisterReadObject(
+ m_stdio_communication.GetConnection()->GetReadObject(),
+ [this] (MainLoopBase &) { SendProcessOutput(); }, error);
+
+ if (! m_stdio_handle_up)
{
- // output from the process must be forwarded over gdb-remote
- // create a thread to read the handle and send the data
- m_stdio_communication.SetReadThreadBytesReceivedCallback (STDIOReadThreadBytesReceived, this);
- m_stdio_communication.StartReadThread();
+ // Not much we can do about the failure. Log it and continue without forwarding.
+ if (Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS))
+ log->Printf("GDBRemoteCommunicationServerLLGS::%s Failed to set up stdio forwarding: %s",
+ __FUNCTION__, error.AsCString());
}
+}
- return error;
+void
+GDBRemoteCommunicationServerLLGS::StopSTDIOForwarding()
+{
+ m_stdio_handle_up.reset();
}
void
-GDBRemoteCommunicationServerLLGS::STDIOReadThreadBytesReceived (void *baton, const void *src, size_t src_len)
+GDBRemoteCommunicationServerLLGS::SendProcessOutput()
{
- GDBRemoteCommunicationServerLLGS *server = reinterpret_cast<GDBRemoteCommunicationServerLLGS*> (baton);
- static_cast<void> (server->SendONotification (static_cast<const char *>(src), src_len));
+ char buffer[1024];
+ ConnectionStatus status;
+ Error error;
+ while (true)
+ {
+ size_t bytes_read = m_stdio_communication.Read(buffer, sizeof buffer, 0, status, &error);
+ switch (status)
+ {
+ case eConnectionStatusSuccess:
+ SendONotification(buffer, bytes_read);
+ break;
+ case eConnectionStatusLostConnection:
+ case eConnectionStatusEndOfFile:
+ case eConnectionStatusError:
+ case eConnectionStatusNoConnection:
+ if (Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS))
+ log->Printf("GDBRemoteCommunicationServerLLGS::%s Stopping stdio forwarding as communication returned status %d (error: %s)", __FUNCTION__, status, error.AsCString());
+ m_stdio_handle_up.reset();
+ return;
+
+ case eConnectionStatusInterrupted:
+ case eConnectionStatusTimedOut:
+ return;
+ }
+ }
}
GDBRemoteCommunication::PacketResult
@@ -941,49 +1105,24 @@ GDBRemoteCommunicationServerLLGS::Handle_qC (StringExtractorGDBRemote &packet)
return SendPacketNoLock (response.GetData(), response.GetSize());
}
-bool
-GDBRemoteCommunicationServerLLGS::DebuggedProcessReaped (lldb::pid_t pid)
-{
- // reap a process that we were debugging (but not debugserver)
- Mutex::Locker locker (m_spawned_pids_mutex);
- return m_spawned_pids.erase(pid) > 0;
-}
-
-bool
-GDBRemoteCommunicationServerLLGS::ReapDebuggedProcess (void *callback_baton,
- lldb::pid_t pid,
- bool exited,
- int signal, // Zero for no signal
- int status) // Exit value of process if signal is zero
-{
- GDBRemoteCommunicationServerLLGS *server = (GDBRemoteCommunicationServerLLGS *)callback_baton;
- server->DebuggedProcessReaped (pid);
- return true;
-}
-
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerLLGS::Handle_k (StringExtractorGDBRemote &packet)
{
- // shutdown all spawned processes
- std::set<lldb::pid_t> spawned_pids_copy;
+ Log *log (GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
- // copy pids
- {
- Mutex::Locker locker (m_spawned_pids_mutex);
- spawned_pids_copy.insert (m_spawned_pids.begin (), m_spawned_pids.end ());
- }
+ StopSTDIOForwarding();
- // nuke the spawned processes
- for (auto it = spawned_pids_copy.begin (); it != spawned_pids_copy.end (); ++it)
+ if (! m_debugged_process_sp)
{
- lldb::pid_t spawned_pid = *it;
- if (!KillSpawnedProcess (spawned_pid))
- {
- fprintf (stderr, "%s: failed to kill spawned pid %" PRIu64 ", ignoring.\n", __FUNCTION__, spawned_pid);
- }
+ if (log)
+ log->Printf("GDBRemoteCommunicationServerLLGS::%s No debugged process found.", __FUNCTION__);
+ return PacketResult::Success;
}
- FlushInferiorOutput ();
+ Error error = m_debugged_process_sp->Kill();
+ if (error.Fail() && log)
+ log->Printf("GDBRemoteCommunicationServerLLGS::%s Failed to kill debugged process %" PRIu64 ": %s",
+ __FUNCTION__, m_debugged_process_sp->GetID(), error.AsCString());
// No OK response for kill packet.
// return SendOKResponse ();
@@ -1316,11 +1455,11 @@ GDBRemoteCommunicationServerLLGS::Handle_stop_reason (StringExtractorGDBRemote &
if (!m_debugged_process_sp)
return SendErrorResponse (02);
- return SendStopReasonForState (m_debugged_process_sp->GetState (), true);
+ return SendStopReasonForState (m_debugged_process_sp->GetState());
}
GDBRemoteCommunication::PacketResult
-GDBRemoteCommunicationServerLLGS::SendStopReasonForState (lldb::StateType process_state, bool flush_on_exit)
+GDBRemoteCommunicationServerLLGS::SendStopReasonForState (lldb::StateType process_state)
{
Log *log (GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
@@ -1349,8 +1488,6 @@ GDBRemoteCommunicationServerLLGS::SendStopReasonForState (lldb::StateType proces
case eStateInvalid:
case eStateUnloaded:
case eStateExited:
- if (flush_on_exit)
- FlushInferiorOutput ();
return SendWResponse(m_debugged_process_sp.get());
default:
@@ -1448,8 +1585,8 @@ GDBRemoteCommunicationServerLLGS::Handle_qRegisterInfo (StringExtractorGDBRemote
response.PutChar (';');
}
- if (reg_info->kinds[RegisterKind::eRegisterKindGCC] != LLDB_INVALID_REGNUM)
- response.Printf ("gcc:%" PRIu32 ";", reg_info->kinds[RegisterKind::eRegisterKindGCC]);
+ if (reg_info->kinds[RegisterKind::eRegisterKindEHFrame] != LLDB_INVALID_REGNUM)
+ response.Printf ("ehframe:%" PRIu32 ";", reg_info->kinds[RegisterKind::eRegisterKindEHFrame]);
if (reg_info->kinds[RegisterKind::eRegisterKindDWARF] != LLDB_INVALID_REGNUM)
response.Printf ("dwarf:%" PRIu32 ";", reg_info->kinds[RegisterKind::eRegisterKindDWARF]);
@@ -1856,7 +1993,7 @@ GDBRemoteCommunicationServerLLGS::Handle_interrupt (StringExtractorGDBRemote &pa
}
GDBRemoteCommunication::PacketResult
-GDBRemoteCommunicationServerLLGS::Handle_m (StringExtractorGDBRemote &packet)
+GDBRemoteCommunicationServerLLGS::Handle_memory_read(StringExtractorGDBRemote &packet)
{
Log *log (GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
@@ -1889,7 +2026,7 @@ GDBRemoteCommunicationServerLLGS::Handle_m (StringExtractorGDBRemote &packet)
{
if (log)
log->Printf ("GDBRemoteCommunicationServerLLGS::%s nothing to read: zero-length packet", __FUNCTION__);
- return PacketResult::Success;
+ return SendOKResponse();
}
// Allocate the response buffer.
@@ -1916,8 +2053,16 @@ GDBRemoteCommunicationServerLLGS::Handle_m (StringExtractorGDBRemote &packet)
}
StreamGDBRemote response;
- for (size_t i = 0; i < bytes_read; ++i)
- response.PutHex8(buf[i]);
+ packet.SetFilePos(0);
+ char kind = packet.GetChar('?');
+ if (kind == 'x')
+ response.PutEscapedBytes(buf.data(), byte_count);
+ else
+ {
+ assert(kind == 'm');
+ for (size_t i = 0; i < bytes_read; ++i)
+ response.PutHex8(buf[i]);
+ }
return SendPacketNoLock(response.GetData(), response.GetSize());
}
@@ -2108,6 +2253,7 @@ GDBRemoteCommunicationServerLLGS::Handle_Z (StringExtractorGDBRemote &packet)
bool want_breakpoint = true;
bool want_hardware = false;
+ uint32_t watch_flags = 0;
const GDBStoppointType stoppoint_type =
GDBStoppointType(packet.GetS32 (eStoppointInvalid));
@@ -2118,10 +2264,13 @@ GDBRemoteCommunicationServerLLGS::Handle_Z (StringExtractorGDBRemote &packet)
case eBreakpointHardware:
want_hardware = true; want_breakpoint = true; break;
case eWatchpointWrite:
+ watch_flags = 1;
want_hardware = true; want_breakpoint = false; break;
case eWatchpointRead:
+ watch_flags = 2;
want_hardware = true; want_breakpoint = false; break;
case eWatchpointReadWrite:
+ watch_flags = 3;
want_hardware = true; want_breakpoint = false; break;
case eStoppointInvalid:
return SendIllFormedResponse(packet, "Z packet had invalid software/hardware specifier");
@@ -2161,11 +2310,6 @@ GDBRemoteCommunicationServerLLGS::Handle_Z (StringExtractorGDBRemote &packet)
}
else
{
- uint32_t watch_flags =
- stoppoint_type == eWatchpointWrite
- ? 0x1 // Write
- : 0x3; // ReadWrite
-
// Try to set the watchpoint.
const Error error = m_debugged_process_sp->SetWatchpoint (
addr, size, watch_flags, want_hardware);
@@ -2555,7 +2699,7 @@ GDBRemoteCommunicationServerLLGS::Handle_vAttach (StringExtractorGDBRemote &pack
}
// Notify we attached by sending a stop packet.
- return SendStopReasonForState (m_debugged_process_sp->GetState (), true);
+ return SendStopReasonForState (m_debugged_process_sp->GetState ());
}
GDBRemoteCommunication::PacketResult
@@ -2563,8 +2707,7 @@ GDBRemoteCommunicationServerLLGS::Handle_D (StringExtractorGDBRemote &packet)
{
Log *log (GetLogIfAnyCategoriesSet (LIBLLDB_LOG_PROCESS));
- // Scope for mutex locker.
- Mutex::Locker locker (m_spawned_pids_mutex);
+ StopSTDIOForwarding();
// Fail if we don't have a current process.
if (!m_debugged_process_sp || (m_debugged_process_sp->GetID () == LLDB_INVALID_PROCESS_ID))
@@ -2574,14 +2717,6 @@ GDBRemoteCommunicationServerLLGS::Handle_D (StringExtractorGDBRemote &packet)
return SendErrorResponse (0x15);
}
- if (m_spawned_pids.find(m_debugged_process_sp->GetID ()) == m_spawned_pids.end())
- {
- if (log)
- log->Printf ("GDBRemoteCommunicationServerLLGS::%s failed to find PID %" PRIu64 " in spawned pids list",
- __FUNCTION__, m_debugged_process_sp->GetID ());
- return SendErrorResponse (0x1);
- }
-
lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
// Consume the ';' after D.
@@ -2603,11 +2738,6 @@ GDBRemoteCommunicationServerLLGS::Handle_D (StringExtractorGDBRemote &packet)
return SendIllFormedResponse (packet, "Invalid pid");
}
- if (m_stdio_communication.IsConnected ())
- {
- m_stdio_communication.StopReadThread ();
- }
-
const Error error = m_debugged_process_sp->Detach ();
if (error.Fail ())
{
@@ -2617,7 +2747,6 @@ GDBRemoteCommunicationServerLLGS::Handle_D (StringExtractorGDBRemote &packet)
return SendErrorResponse (0x01);
}
- m_spawned_pids.erase (m_debugged_process_sp->GetID ());
return SendOKResponse ();
}
@@ -2638,6 +2767,38 @@ GDBRemoteCommunicationServerLLGS::Handle_qThreadStopInfo (StringExtractorGDBRemo
}
GDBRemoteCommunication::PacketResult
+GDBRemoteCommunicationServerLLGS::Handle_jThreadsInfo (StringExtractorGDBRemote &)
+{
+ Log *log (GetLogIfAnyCategoriesSet (LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD));
+
+ // Ensure we have a debugged process.
+ if (!m_debugged_process_sp || (m_debugged_process_sp->GetID () == LLDB_INVALID_PROCESS_ID))
+ return SendErrorResponse (50);
+
+ if (log)
+ log->Printf ("GDBRemoteCommunicationServerLLGS::%s preparing packet for pid %" PRIu64,
+ __FUNCTION__, m_debugged_process_sp->GetID());
+
+
+ StreamString response;
+ const bool threads_with_valid_stop_info_only = false;
+ JSONArray::SP threads_array_sp = GetJSONThreadsInfo(*m_debugged_process_sp,
+ threads_with_valid_stop_info_only);
+ if (! threads_array_sp)
+ {
+ if (log)
+ log->Printf ("GDBRemoteCommunicationServerLLGS::%s failed to prepare a packet for pid %" PRIu64,
+ __FUNCTION__, m_debugged_process_sp->GetID());
+ return SendErrorResponse(52);
+ }
+
+ threads_array_sp->Write(response);
+ StreamGDBRemote escaped_response;
+ escaped_response.PutEscapedBytes(response.GetData(), response.GetSize());
+ return SendPacketNoLock (escaped_response.GetData(), escaped_response.GetSize());
+}
+
+GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerLLGS::Handle_qWatchpointSupportInfo (StringExtractorGDBRemote &packet)
{
// Fail if we don't have a current process.
@@ -2686,21 +2847,6 @@ GDBRemoteCommunicationServerLLGS::Handle_qFileLoadAddress (StringExtractorGDBRem
}
void
-GDBRemoteCommunicationServerLLGS::FlushInferiorOutput ()
-{
- // If we're not monitoring an inferior's terminal, ignore this.
- if (!m_stdio_communication.IsConnected())
- return;
-
- Log *log (GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD));
- if (log)
- log->Printf ("GDBRemoteCommunicationServerLLGS::%s() called", __FUNCTION__);
-
- // FIXME implement a timeout on the join.
- m_stdio_communication.JoinReadThread();
-}
-
-void
GDBRemoteCommunicationServerLLGS::MaybeCloseInferiorTerminalConnection ()
{
Log *log (GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
index 29f3fdebcfb0..f16057781ddc 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
@@ -42,9 +42,6 @@ public:
//------------------------------------------------------------------
GDBRemoteCommunicationServerLLGS(const lldb::PlatformSP& platform_sp, MainLoop &mainloop);
- virtual
- ~GDBRemoteCommunicationServerLLGS();
-
//------------------------------------------------------------------
/// Specify the program to launch and its arguments.
///
@@ -119,12 +116,15 @@ public:
protected:
lldb::PlatformSP m_platform_sp;
MainLoop &m_mainloop;
- MainLoop::ReadHandleUP m_read_handle_up;
+ MainLoop::ReadHandleUP m_network_handle_up;
lldb::tid_t m_current_tid;
lldb::tid_t m_continue_tid;
Mutex m_debugged_process_mutex;
NativeProcessProtocolSP m_debugged_process_sp;
+
Communication m_stdio_communication;
+ MainLoop::ReadHandleUP m_stdio_handle_up;
+
lldb::StateType m_inferior_prev_state;
lldb::DataBufferSP m_active_auxv_buffer_sp;
Mutex m_saved_registers_mutex;
@@ -142,7 +142,7 @@ protected:
SendStopReplyPacketForThread (lldb::tid_t tid);
PacketResult
- SendStopReasonForState (lldb::StateType process_state, bool flush_on_exit);
+ SendStopReasonForState (lldb::StateType process_state);
PacketResult
Handle_k (StringExtractorGDBRemote &packet);
@@ -201,8 +201,9 @@ protected:
PacketResult
Handle_interrupt (StringExtractorGDBRemote &packet);
+ // Handles $m and $x packets.
PacketResult
- Handle_m (StringExtractorGDBRemote &packet);
+ Handle_memory_read (StringExtractorGDBRemote &packet);
PacketResult
Handle_M (StringExtractorGDBRemote &packet);
@@ -241,6 +242,9 @@ protected:
Handle_qThreadStopInfo (StringExtractorGDBRemote &packet);
PacketResult
+ Handle_jThreadsInfo (StringExtractorGDBRemote &packet);
+
+ PacketResult
Handle_qWatchpointSupportInfo (StringExtractorGDBRemote &packet);
PacketResult
@@ -261,32 +265,16 @@ protected:
Error
SetSTDIOFileDescriptor (int fd);
- static void
- STDIOReadThreadBytesReceived (void *baton, const void *src, size_t src_len);
-
FileSpec
FindModuleFile (const std::string& module_path, const ArchSpec& arch) override;
private:
- bool
- DebuggedProcessReaped (lldb::pid_t pid);
-
- static bool
- ReapDebuggedProcess (void *callback_baton,
- lldb::pid_t pid,
- bool exited,
- int signal,
- int status);
-
void
HandleInferiorState_Exited (NativeProcessProtocol *process);
void
HandleInferiorState_Stopped (NativeProcessProtocol *process);
- void
- FlushInferiorOutput ();
-
NativeThreadProtocolSP
GetThreadFromSuffix (StringExtractorGDBRemote &packet);
@@ -305,6 +293,15 @@ private:
void
DataAvailableCallback ();
+ void
+ SendProcessOutput ();
+
+ void
+ StartSTDIOForwarding();
+
+ void
+ StopSTDIOForwarding();
+
//------------------------------------------------------------------
// For GDBRemoteCommunicationServerLLGS only
//------------------------------------------------------------------
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
index 1205049db3fb..f88ac1247526 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
@@ -15,19 +15,26 @@
// C++ Includes
#include <cstring>
#include <chrono>
+#include <mutex>
+#include <sstream>
// Other libraries and framework includes
+#include "llvm/Support/FileSystem.h"
+
#include "lldb/Core/Log.h"
+#include "lldb/Core/StreamGDBRemote.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Host/Config.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/Host.h"
+#include "lldb/Host/HostInfo.h"
#include "lldb/Host/StringConvert.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"
// Project includes
#include "Utility/StringExtractorGDBRemote.h"
@@ -40,18 +47,29 @@ using namespace lldb_private::process_gdb_remote;
//----------------------------------------------------------------------
// GDBRemoteCommunicationServerPlatform constructor
//----------------------------------------------------------------------
-GDBRemoteCommunicationServerPlatform::GDBRemoteCommunicationServerPlatform() :
+GDBRemoteCommunicationServerPlatform::GDBRemoteCommunicationServerPlatform(const Socket::SocketProtocol socket_protocol,
+ const char* socket_scheme) :
GDBRemoteCommunicationServerCommon ("gdb-remote.server", "gdb-remote.server.rx_packet"),
+ m_socket_protocol(socket_protocol),
+ m_socket_scheme(socket_scheme),
+ m_spawned_pids_mutex (Mutex::eMutexTypeRecursive),
m_platform_sp (Platform::GetHostPlatform ()),
m_port_map (),
m_port_offset(0)
{
+ m_pending_gdb_server.pid = LLDB_INVALID_PROCESS_ID;
+ m_pending_gdb_server.port = 0;
+
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_qC,
&GDBRemoteCommunicationServerPlatform::Handle_qC);
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_qGetWorkingDir,
&GDBRemoteCommunicationServerPlatform::Handle_qGetWorkingDir);
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_qLaunchGDBServer,
&GDBRemoteCommunicationServerPlatform::Handle_qLaunchGDBServer);
+ RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_qQueryGDBServer,
+ &GDBRemoteCommunicationServerPlatform::Handle_qQueryGDBServer);
+ RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_qKillSpawnedProcess,
+ &GDBRemoteCommunicationServerPlatform::Handle_qKillSpawnedProcess);
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_qProcessInfo,
&GDBRemoteCommunicationServerPlatform::Handle_qProcessInfo);
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_QSetWorkingDir,
@@ -78,38 +96,16 @@ GDBRemoteCommunicationServerPlatform::~GDBRemoteCommunicationServerPlatform()
{
}
-GDBRemoteCommunication::PacketResult
-GDBRemoteCommunicationServerPlatform::Handle_qLaunchGDBServer (StringExtractorGDBRemote &packet)
+Error
+GDBRemoteCommunicationServerPlatform::LaunchGDBServer(const lldb_private::Args& args,
+ std::string hostname,
+ lldb::pid_t& pid,
+ uint16_t& port,
+ std::string& socket_name)
{
-#ifdef _WIN32
- return SendErrorResponse(9);
-#else
- // Spawn a local debugserver as a platform so we can then attach or launch
- // a process...
-
- Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
- if (log)
- log->Printf ("GDBRemoteCommunicationServerPlatform::%s() called", __FUNCTION__);
-
- // Sleep and wait a bit for debugserver to start to listen...
- ConnectionFileDescriptor file_conn;
- std::string hostname;
- // TODO: /tmp/ should not be hardcoded. User might want to override /tmp
- // with the TMPDIR environment variable
- packet.SetFilePos(::strlen ("qLaunchGDBServer;"));
- std::string name;
- std::string value;
- uint16_t port = UINT16_MAX;
- while (packet.GetNameColonValue(name, value))
- {
- if (name.compare ("host") == 0)
- hostname.swap(value);
- else if (name.compare ("port") == 0)
- port = StringConvert::ToUInt32(value.c_str(), 0, 0);
- }
if (port == UINT16_MAX)
port = GetNextAvailablePort();
-
+
// Spawn a new thread to accept the port that gets bound after
// binding to port 0 (zero).
@@ -120,6 +116,8 @@ GDBRemoteCommunicationServerPlatform::Handle_qLaunchGDBServer (StringExtractorGD
ProcessLaunchInfo debugserver_launch_info;
if (hostname.empty())
hostname = "127.0.0.1";
+
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
if (log)
log->Printf("Launching debugserver with: %s:%u...", hostname.c_str(), port);
@@ -133,53 +131,210 @@ GDBRemoteCommunicationServerPlatform::Handle_qLaunchGDBServer (StringExtractorGD
int platform_port;
std::string platform_path;
bool ok = UriParser::Parse(GetConnection()->GetURI().c_str(), platform_scheme, platform_ip, platform_port, platform_path);
+ UNUSED_IF_ASSERT_DISABLED(ok);
assert(ok);
- Error error = StartDebugserverProcess (
- platform_ip.c_str(),
- port,
- debugserver_launch_info,
- port);
- lldb::pid_t debugserver_pid = debugserver_launch_info.GetProcessID();
+ std::ostringstream url;
+ uint16_t* port_ptr = &port;
+ if (m_socket_protocol == Socket::ProtocolTcp)
+ url << platform_ip << ":" << port;
+ else
+ {
+ socket_name = GetDomainSocketPath("gdbserver").GetPath();
+ url << socket_name;
+ port_ptr = nullptr;
+ }
+ Error error = StartDebugserverProcess (url.str().c_str(),
+ nullptr,
+ debugserver_launch_info,
+ port_ptr,
+ args);
- if (debugserver_pid != LLDB_INVALID_PROCESS_ID)
+ pid = debugserver_launch_info.GetProcessID();
+ if (pid != LLDB_INVALID_PROCESS_ID)
{
Mutex::Locker locker (m_spawned_pids_mutex);
- m_spawned_pids.insert(debugserver_pid);
+ m_spawned_pids.insert(pid);
if (port > 0)
- AssociatePortWithProcess(port, debugserver_pid);
+ AssociatePortWithProcess(port, pid);
}
else
{
if (port > 0)
- FreePort (port);
+ FreePort(port);
+ }
+ return error;
+}
+
+GDBRemoteCommunication::PacketResult
+GDBRemoteCommunicationServerPlatform::Handle_qLaunchGDBServer (StringExtractorGDBRemote &packet)
+{
+#ifdef _WIN32
+ return SendErrorResponse(9);
+#else
+ // Spawn a local debugserver as a platform so we can then attach or launch
+ // a process...
+
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ if (log)
+ log->Printf ("GDBRemoteCommunicationServerPlatform::%s() called", __FUNCTION__);
+
+ ConnectionFileDescriptor file_conn;
+ std::string hostname;
+ packet.SetFilePos(::strlen ("qLaunchGDBServer;"));
+ std::string name;
+ std::string value;
+ uint16_t port = UINT16_MAX;
+ while (packet.GetNameColonValue(name, value))
+ {
+ if (name.compare ("host") == 0)
+ hostname.swap(value);
+ else if (name.compare ("port") == 0)
+ port = StringConvert::ToUInt32(value.c_str(), 0, 0);
}
- if (error.Success())
+ lldb::pid_t debugserver_pid = LLDB_INVALID_PROCESS_ID;
+ std::string socket_name;
+ Error error = LaunchGDBServer(Args(), hostname, debugserver_pid, port, socket_name);
+ if (error.Fail())
{
if (log)
- log->Printf ("GDBRemoteCommunicationServerPlatform::%s() debugserver launched successfully as pid %" PRIu64, __FUNCTION__, debugserver_pid);
+ log->Printf("GDBRemoteCommunicationServerPlatform::%s() debugserver launch failed: %s", __FUNCTION__, error.AsCString ());
+ return SendErrorResponse(9);
+ }
- char response[256];
- const int response_len = ::snprintf (response, sizeof(response), "pid:%" PRIu64 ";port:%u;", debugserver_pid, port + m_port_offset);
- assert (response_len < (int)sizeof(response));
- PacketResult packet_result = SendPacketNoLock (response, response_len);
+ if (log)
+ log->Printf ("GDBRemoteCommunicationServerPlatform::%s() debugserver launched successfully as pid %" PRIu64, __FUNCTION__, debugserver_pid);
- if (packet_result != PacketResult::Success)
+ StreamGDBRemote response;
+ response.Printf("pid:%" PRIu64 ";port:%u;", debugserver_pid, port + m_port_offset);
+ if (!socket_name.empty())
+ {
+ response.PutCString("socket_name:");
+ response.PutCStringAsRawHex8(socket_name.c_str());
+ response.PutChar(';');
+ }
+
+ PacketResult packet_result = SendPacketNoLock(response.GetData(), response.GetSize());
+ if (packet_result != PacketResult::Success)
+ {
+ if (debugserver_pid != LLDB_INVALID_PROCESS_ID)
+ ::kill (debugserver_pid, SIGINT);
+ }
+ return packet_result;
+#endif
+}
+
+GDBRemoteCommunication::PacketResult
+GDBRemoteCommunicationServerPlatform::Handle_qQueryGDBServer (StringExtractorGDBRemote &packet)
+{
+ if (m_pending_gdb_server.pid == LLDB_INVALID_PROCESS_ID)
+ return SendErrorResponse(4);
+
+ JSONObject::SP server_sp = std::make_shared<JSONObject>();
+ server_sp->SetObject("port", std::make_shared<JSONNumber>(m_pending_gdb_server.port));
+ if (!m_pending_gdb_server.socket_name.empty())
+ server_sp->SetObject("socket_name",
+ std::make_shared<JSONString>(m_pending_gdb_server.socket_name.c_str()));
+
+ JSONArray server_list;
+ server_list.AppendObject(server_sp);
+
+ StreamGDBRemote response;
+ server_list.Write(response);
+
+ StreamGDBRemote escaped_response;
+ escaped_response.PutEscapedBytes(response.GetData(), response.GetSize());
+ return SendPacketNoLock(escaped_response.GetData(), escaped_response.GetSize());
+}
+
+GDBRemoteCommunication::PacketResult
+GDBRemoteCommunicationServerPlatform::Handle_qKillSpawnedProcess (StringExtractorGDBRemote &packet)
+{
+ packet.SetFilePos(::strlen ("qKillSpawnedProcess:"));
+
+ lldb::pid_t pid = packet.GetU64(LLDB_INVALID_PROCESS_ID);
+
+ // verify that we know anything about this pid.
+ // Scope for locker
+ {
+ Mutex::Locker locker (m_spawned_pids_mutex);
+ if (m_spawned_pids.find(pid) == m_spawned_pids.end())
{
- if (debugserver_pid != LLDB_INVALID_PROCESS_ID)
- ::kill (debugserver_pid, SIGINT);
+ // not a pid we know about
+ return SendErrorResponse (10);
}
- return packet_result;
}
+
+ // go ahead and attempt to kill the spawned process
+ if (KillSpawnedProcess (pid))
+ return SendOKResponse ();
else
+ return SendErrorResponse (11);
+}
+
+bool
+GDBRemoteCommunicationServerPlatform::KillSpawnedProcess (lldb::pid_t pid)
+{
+ // make sure we know about this process
{
- if (log)
- log->Printf ("GDBRemoteCommunicationServerPlatform::%s() debugserver launch failed: %s", __FUNCTION__, error.AsCString ());
+ Mutex::Locker locker (m_spawned_pids_mutex);
+ if (m_spawned_pids.find(pid) == m_spawned_pids.end())
+ return false;
}
- return SendErrorResponse (9);
-#endif
+
+ // first try a SIGTERM (standard kill)
+ Host::Kill (pid, SIGTERM);
+
+ // check if that worked
+ for (size_t i=0; i<10; ++i)
+ {
+ {
+ Mutex::Locker locker (m_spawned_pids_mutex);
+ if (m_spawned_pids.find(pid) == m_spawned_pids.end())
+ {
+ // it is now killed
+ return true;
+ }
+ }
+ usleep (10000);
+ }
+
+ // check one more time after the final usleep
+ {
+ Mutex::Locker locker (m_spawned_pids_mutex);
+ if (m_spawned_pids.find(pid) == m_spawned_pids.end())
+ return true;
+ }
+
+ // the launched process still lives. Now try killing it again,
+ // this time with an unblockable signal.
+ Host::Kill (pid, SIGKILL);
+
+ for (size_t i=0; i<10; ++i)
+ {
+ {
+ Mutex::Locker locker (m_spawned_pids_mutex);
+ if (m_spawned_pids.find(pid) == m_spawned_pids.end())
+ {
+ // it is now killed
+ return true;
+ }
+ }
+ usleep (10000);
+ }
+
+ // check one more time after the final usleep
+ // Scope for locker
+ {
+ Mutex::Locker locker (m_spawned_pids_mutex);
+ if (m_spawned_pids.find(pid) == m_spawned_pids.end())
+ return true;
+ }
+
+ // no luck - the process still lives
+ return false;
}
GDBRemoteCommunication::PacketResult
@@ -402,8 +557,48 @@ GDBRemoteCommunicationServerPlatform::FreePortForProcess (lldb::pid_t pid)
return false;
}
+const FileSpec&
+GDBRemoteCommunicationServerPlatform::GetDomainSocketDir()
+{
+ static FileSpec g_domainsocket_dir;
+ static std::once_flag g_once_flag;
+
+ std::call_once(g_once_flag, []() {
+ const char* domainsocket_dir_env = ::getenv("LLDB_DEBUGSERVER_DOMAINSOCKET_DIR");
+ if (domainsocket_dir_env != nullptr)
+ g_domainsocket_dir = FileSpec(domainsocket_dir_env, false);
+ else
+ HostInfo::GetLLDBPath(ePathTypeLLDBTempSystemDir, g_domainsocket_dir);
+ });
+
+ return g_domainsocket_dir;
+}
+
+FileSpec
+GDBRemoteCommunicationServerPlatform::GetDomainSocketPath(const char* prefix)
+{
+ llvm::SmallString<PATH_MAX> socket_path;
+ llvm::SmallString<PATH_MAX> socket_name((llvm::StringRef(prefix) + ".%%%%%%").str());
+
+ FileSpec socket_path_spec(GetDomainSocketDir());
+ socket_path_spec.AppendPathComponent(socket_name.c_str());
+
+ llvm::sys::fs::createUniqueFile(socket_path_spec.GetCString(), socket_path);
+ return FileSpec(socket_path.c_str(), false);
+}
+
void
-GDBRemoteCommunicationServerPlatform::SetPortOffset (uint16_t port_offset)
+GDBRemoteCommunicationServerPlatform::SetPortOffset(uint16_t port_offset)
{
m_port_offset = port_offset;
}
+
+void
+GDBRemoteCommunicationServerPlatform::SetPendingGdbServer(lldb::pid_t pid,
+ uint16_t port,
+ const std::string& socket_name)
+{
+ m_pending_gdb_server.pid = pid;
+ m_pending_gdb_server.port = port;
+ m_pending_gdb_server.socket_name = socket_name;
+}
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h
index 5c011371a3eb..1fe7207d2bc2 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h
@@ -10,7 +10,15 @@
#ifndef liblldb_GDBRemoteCommunicationServerPlatform_h_
#define liblldb_GDBRemoteCommunicationServerPlatform_h_
+// C Includes
+// C++ Includes
+#include <map>
+#include <set>
+
+// Other libraries and framework includes
+// Project includes
#include "GDBRemoteCommunicationServerCommon.h"
+#include "lldb/Host/Socket.h"
namespace lldb_private {
namespace process_gdb_remote {
@@ -21,10 +29,10 @@ class GDBRemoteCommunicationServerPlatform :
public:
typedef std::map<uint16_t, lldb::pid_t> PortMap;
- GDBRemoteCommunicationServerPlatform();
+ GDBRemoteCommunicationServerPlatform(const Socket::SocketProtocol socket_protocol,
+ const char* socket_scheme);
- virtual
- ~GDBRemoteCommunicationServerPlatform();
+ ~GDBRemoteCommunicationServerPlatform() override;
Error
LaunchProcess () override;
@@ -58,16 +66,40 @@ public:
void
SetPortOffset (uint16_t port_offset);
+ void
+ SetInferiorArguments (const lldb_private::Args& args);
+
+ Error
+ LaunchGDBServer(const lldb_private::Args& args,
+ std::string hostname,
+ lldb::pid_t& pid,
+ uint16_t& port,
+ std::string& socket_name);
+
+ void
+ SetPendingGdbServer(lldb::pid_t pid, uint16_t port, const std::string& socket_name);
+
protected:
+ const Socket::SocketProtocol m_socket_protocol;
+ const std::string m_socket_scheme;
+ Mutex m_spawned_pids_mutex;
+ std::set<lldb::pid_t> m_spawned_pids;
lldb::PlatformSP m_platform_sp;
PortMap m_port_map;
uint16_t m_port_offset;
+ struct { lldb::pid_t pid; uint16_t port; std::string socket_name; } m_pending_gdb_server;
PacketResult
Handle_qLaunchGDBServer (StringExtractorGDBRemote &packet);
PacketResult
+ Handle_qQueryGDBServer (StringExtractorGDBRemote &packet);
+
+ PacketResult
+ Handle_qKillSpawnedProcess (StringExtractorGDBRemote &packet);
+
+ PacketResult
Handle_qProcessInfo (StringExtractorGDBRemote &packet);
PacketResult
@@ -84,6 +116,9 @@ protected:
private:
bool
+ KillSpawnedProcess (lldb::pid_t pid);
+
+ bool
DebugserverProcessReaped (lldb::pid_t pid);
static bool
@@ -93,13 +128,16 @@ private:
int signal,
int status);
- //------------------------------------------------------------------
- // For GDBRemoteCommunicationServerPlatform only
- //------------------------------------------------------------------
+ static const FileSpec&
+ GetDomainSocketDir();
+
+ static FileSpec
+ GetDomainSocketPath(const char* prefix);
+
DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationServerPlatform);
};
} // namespace process_gdb_remote
} // namespace lldb_private
-#endif // liblldb_GDBRemoteCommunicationServerPlatform_h_
+#endif // liblldb_GDBRemoteCommunicationServerPlatform_h_
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index f5f134e80d6a..b0a1eaaeb79c 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -17,9 +17,6 @@
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Core/StreamString.h"
-#ifndef LLDB_DISABLE_PYTHON
-#include "lldb/Interpreter/PythonDataObjects.h"
-#endif
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/Utils.h"
@@ -28,8 +25,8 @@
#include "ProcessGDBRemote.h"
#include "ProcessGDBRemoteLog.h"
#include "ThreadGDBRemote.h"
-#include "Utility/ARM_GCC_Registers.h"
#include "Utility/ARM_DWARF_Registers.h"
+#include "Utility/ARM_ehframe_Registers.h"
using namespace lldb;
using namespace lldb_private;
@@ -150,6 +147,52 @@ GDBRemoteRegisterContext::PrivateSetRegisterValue (uint32_t reg, StringExtractor
return success;
}
+bool
+GDBRemoteRegisterContext::PrivateSetRegisterValue (uint32_t reg, uint64_t new_reg_val)
+{
+ const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg);
+ if (reg_info == NULL)
+ return false;
+
+ // Early in process startup, we can get a thread that has an invalid byte order
+ // because the process hasn't been completely set up yet (see the ctor where the
+ // byte order is setfrom the process). If that's the case, we can't set the
+ // value here.
+ if (m_reg_data.GetByteOrder() == eByteOrderInvalid)
+ {
+ return false;
+ }
+
+ // Invalidate if needed
+ InvalidateIfNeeded (false);
+
+ DataBufferSP buffer_sp (new DataBufferHeap (&new_reg_val, sizeof (new_reg_val)));
+ DataExtractor data (buffer_sp, endian::InlHostByteOrder(), sizeof (void*));
+
+ // If our register context and our register info disagree, which should never happen, don't
+ // overwrite past the end of the buffer.
+ if (m_reg_data.GetByteSize() < reg_info->byte_offset + reg_info->byte_size)
+ return false;
+
+ // Grab a pointer to where we are going to put this register
+ uint8_t *dst = const_cast<uint8_t*>(m_reg_data.PeekData(reg_info->byte_offset, reg_info->byte_size));
+
+ if (dst == NULL)
+ return false;
+
+
+ if (data.CopyByteOrderedData (0, // src offset
+ reg_info->byte_size, // src length
+ dst, // dst
+ reg_info->byte_size, // dst length
+ m_reg_data.GetByteOrder())) // dst byte order
+ {
+ SetRegisterIsValid (reg, true);
+ return true;
+ }
+ return false;
+}
+
// Helper function for GDBRemoteRegisterContext::ReadRegisterBytes().
bool
GDBRemoteRegisterContext::GetPrimordialRegister(const RegisterInfo *reg_info,
@@ -186,7 +229,8 @@ GDBRemoteRegisterContext::ReadRegisterBytes (const RegisterInfo *reg_info, DataE
if (!gdb_comm.ReadAllRegisters(m_thread.GetProtocolID(), response))
return false;
if (response.IsNormalResponse())
- if (response.GetHexBytes ((void *)m_reg_data.GetDataStart(), m_reg_data.GetByteSize(), '\xcc') == m_reg_data.GetByteSize())
+ if (response.GetHexBytes(const_cast<void *>(reinterpret_cast<const void *>(m_reg_data.GetDataStart())),
+ m_reg_data.GetByteSize(), '\xcc') == m_reg_data.GetByteSize())
SetAllRegisterValid (true);
}
else if (reg_info->value_regs)
@@ -275,8 +319,8 @@ GDBRemoteRegisterContext::SetPrimordialRegister(const RegisterInfo *reg_info,
packet.Printf ("P%x=", reg);
packet.PutBytesAsRawHex8 (m_reg_data.PeekData(reg_info->byte_offset, reg_info->byte_size),
reg_info->byte_size,
- lldb::endian::InlHostByteOrder(),
- lldb::endian::InlHostByteOrder());
+ endian::InlHostByteOrder(),
+ endian::InlHostByteOrder());
if (gdb_comm.GetThreadSuffixSupported())
packet.Printf (";thread:%4.4" PRIx64 ";", m_thread.GetProtocolID());
@@ -372,8 +416,8 @@ GDBRemoteRegisterContext::WriteRegisterBytes (const RegisterInfo *reg_info, Data
packet.PutChar ('G');
packet.PutBytesAsRawHex8 (m_reg_data.GetDataStart(),
m_reg_data.GetByteSize(),
- lldb::endian::InlHostByteOrder(),
- lldb::endian::InlHostByteOrder());
+ endian::InlHostByteOrder(),
+ endian::InlHostByteOrder());
if (thread_suffix_supported)
packet.Printf (";thread:%4.4" PRIx64 ";", m_thread.GetProtocolID());
@@ -772,8 +816,8 @@ GDBRemoteRegisterContext::WriteAllRegisterValues (const lldb::DataBufferSP &data
packet.Printf ("P%x=", reg);
packet.PutBytesAsRawHex8 (restore_src,
reg_byte_size,
- lldb::endian::InlHostByteOrder(),
- lldb::endian::InlHostByteOrder());
+ endian::InlHostByteOrder(),
+ endian::InlHostByteOrder());
if (thread_suffix_supported)
packet.Printf (";thread:%4.4" PRIx64 ";", m_thread.GetProtocolID());
@@ -795,8 +839,8 @@ GDBRemoteRegisterContext::WriteAllRegisterValues (const lldb::DataBufferSP &data
packet.Printf ("P%x=", reg);
packet.PutBytesAsRawHex8 (restore_src,
reg_byte_size,
- lldb::endian::InlHostByteOrder(),
- lldb::endian::InlHostByteOrder());
+ endian::InlHostByteOrder(),
+ endian::InlHostByteOrder());
if (thread_suffix_supported)
packet.Printf (";thread:%4.4" PRIx64 ";", m_thread.GetProtocolID());
@@ -851,7 +895,7 @@ GDBRemoteRegisterContext::WriteAllRegisterValues (const lldb::DataBufferSP &data
}
StreamString packet;
packet.Printf ("P%x=", reg_info->kinds[eRegisterKindLLDB]);
- packet.PutBytesAsRawHex8 (data_sp->GetBytes() + reg_info->byte_offset, reg_info->byte_size, lldb::endian::InlHostByteOrder(), lldb::endian::InlHostByteOrder());
+ packet.PutBytesAsRawHex8 (data_sp->GetBytes() + reg_info->byte_offset, reg_info->byte_size, endian::InlHostByteOrder(), endian::InlHostByteOrder());
if (thread_suffix_supported)
packet.Printf (";thread:%4.4" PRIx64 ";", m_thread.GetProtocolID());
@@ -941,115 +985,115 @@ GDBRemoteDynamicRegisterInfo::HardcodeARMRegisters(bool from_scratch)
};
static RegisterInfo g_register_infos[] = {
-// NAME ALT SZ OFF ENCODING FORMAT COMPILER DWARF GENERIC GDB LLDB VALUE REGS INVALIDATE REGS
-// ====== ====== === === ============= ============ =================== =================== ====================== === ==== ========== ===============
- { "r0", "arg1", 4, 0, eEncodingUint, eFormatHex, { gcc_r0, dwarf_r0, LLDB_REGNUM_GENERIC_ARG1,0, 0 }, NULL, NULL},
- { "r1", "arg2", 4, 0, eEncodingUint, eFormatHex, { gcc_r1, dwarf_r1, LLDB_REGNUM_GENERIC_ARG2,1, 1 }, NULL, NULL},
- { "r2", "arg3", 4, 0, eEncodingUint, eFormatHex, { gcc_r2, dwarf_r2, LLDB_REGNUM_GENERIC_ARG3,2, 2 }, NULL, NULL},
- { "r3", "arg4", 4, 0, eEncodingUint, eFormatHex, { gcc_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG4,3, 3 }, NULL, NULL},
- { "r4", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r4, dwarf_r4, LLDB_INVALID_REGNUM, 4, 4 }, NULL, NULL},
- { "r5", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r5, dwarf_r5, LLDB_INVALID_REGNUM, 5, 5 }, NULL, NULL},
- { "r6", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r6, dwarf_r6, LLDB_INVALID_REGNUM, 6, 6 }, NULL, NULL},
- { "r7", "fp", 4, 0, eEncodingUint, eFormatHex, { gcc_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP, 7, 7 }, NULL, NULL},
- { "r8", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r8, dwarf_r8, LLDB_INVALID_REGNUM, 8, 8 }, NULL, NULL},
- { "r9", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r9, dwarf_r9, LLDB_INVALID_REGNUM, 9, 9 }, NULL, NULL},
- { "r10", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r10, dwarf_r10, LLDB_INVALID_REGNUM, 10, 10 }, NULL, NULL},
- { "r11", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r11, dwarf_r11, LLDB_INVALID_REGNUM, 11, 11 }, NULL, NULL},
- { "r12", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r12, dwarf_r12, LLDB_INVALID_REGNUM, 12, 12 }, NULL, NULL},
- { "sp", "r13", 4, 0, eEncodingUint, eFormatHex, { gcc_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, 13, 13 }, NULL, NULL},
- { "lr", "r14", 4, 0, eEncodingUint, eFormatHex, { gcc_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, 14, 14 }, NULL, NULL},
- { "pc", "r15", 4, 0, eEncodingUint, eFormatHex, { gcc_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, 15, 15 }, NULL, NULL},
- { "f0", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 16, 16 }, NULL, NULL},
- { "f1", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 17, 17 }, NULL, NULL},
- { "f2", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 18, 18 }, NULL, NULL},
- { "f3", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 19, 19 }, NULL, NULL},
- { "f4", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 20, 20 }, NULL, NULL},
- { "f5", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 21, 21 }, NULL, NULL},
- { "f6", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 22, 22 }, NULL, NULL},
- { "f7", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 23, 23 }, NULL, NULL},
- { "fps", NULL, 4, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 24, 24 }, NULL, NULL},
- { "cpsr","flags", 4, 0, eEncodingUint, eFormatHex, { gcc_cpsr, dwarf_cpsr, LLDB_INVALID_REGNUM, 25, 25 }, NULL, NULL},
- { "s0", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, 26, 26 }, NULL, NULL},
- { "s1", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, 27, 27 }, NULL, NULL},
- { "s2", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, 28, 28 }, NULL, NULL},
- { "s3", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, 29, 29 }, NULL, NULL},
- { "s4", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, 30, 30 }, NULL, NULL},
- { "s5", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, 31, 31 }, NULL, NULL},
- { "s6", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, 32, 32 }, NULL, NULL},
- { "s7", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, 33, 33 }, NULL, NULL},
- { "s8", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, 34, 34 }, NULL, NULL},
- { "s9", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, 35, 35 }, NULL, NULL},
- { "s10", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, 36, 36 }, NULL, NULL},
- { "s11", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, 37, 37 }, NULL, NULL},
- { "s12", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, 38, 38 }, NULL, NULL},
- { "s13", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, 39, 39 }, NULL, NULL},
- { "s14", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, 40, 40 }, NULL, NULL},
- { "s15", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, 41, 41 }, NULL, NULL},
- { "s16", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, 42, 42 }, NULL, NULL},
- { "s17", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, 43, 43 }, NULL, NULL},
- { "s18", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, 44, 44 }, NULL, NULL},
- { "s19", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, 45, 45 }, NULL, NULL},
- { "s20", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, 46, 46 }, NULL, NULL},
- { "s21", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, 47, 47 }, NULL, NULL},
- { "s22", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, 48, 48 }, NULL, NULL},
- { "s23", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, 49, 49 }, NULL, NULL},
- { "s24", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, 50, 50 }, NULL, NULL},
- { "s25", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, 51, 51 }, NULL, NULL},
- { "s26", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, 52, 52 }, NULL, NULL},
- { "s27", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, 53, 53 }, NULL, NULL},
- { "s28", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, 54, 54 }, NULL, NULL},
- { "s29", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, 55, 55 }, NULL, NULL},
- { "s30", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, 56, 56 }, NULL, NULL},
- { "s31", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, 57, 57 }, NULL, NULL},
- { "fpscr",NULL, 4, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 58, 58 }, NULL, NULL},
- { "d16", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d16, LLDB_INVALID_REGNUM, 59, 59 }, NULL, NULL},
- { "d17", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d17, LLDB_INVALID_REGNUM, 60, 60 }, NULL, NULL},
- { "d18", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d18, LLDB_INVALID_REGNUM, 61, 61 }, NULL, NULL},
- { "d19", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d19, LLDB_INVALID_REGNUM, 62, 62 }, NULL, NULL},
- { "d20", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d20, LLDB_INVALID_REGNUM, 63, 63 }, NULL, NULL},
- { "d21", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d21, LLDB_INVALID_REGNUM, 64, 64 }, NULL, NULL},
- { "d22", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d22, LLDB_INVALID_REGNUM, 65, 65 }, NULL, NULL},
- { "d23", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d23, LLDB_INVALID_REGNUM, 66, 66 }, NULL, NULL},
- { "d24", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d24, LLDB_INVALID_REGNUM, 67, 67 }, NULL, NULL},
- { "d25", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d25, LLDB_INVALID_REGNUM, 68, 68 }, NULL, NULL},
- { "d26", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d26, LLDB_INVALID_REGNUM, 69, 69 }, NULL, NULL},
- { "d27", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d27, LLDB_INVALID_REGNUM, 70, 70 }, NULL, NULL},
- { "d28", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d28, LLDB_INVALID_REGNUM, 71, 71 }, NULL, NULL},
- { "d29", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d29, LLDB_INVALID_REGNUM, 72, 72 }, NULL, NULL},
- { "d30", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d30, LLDB_INVALID_REGNUM, 73, 73 }, NULL, NULL},
- { "d31", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d31, LLDB_INVALID_REGNUM, 74, 74 }, NULL, NULL},
- { "d0", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d0, LLDB_INVALID_REGNUM, 75, 75 }, g_d0_regs, NULL},
- { "d1", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d1, LLDB_INVALID_REGNUM, 76, 76 }, g_d1_regs, NULL},
- { "d2", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d2, LLDB_INVALID_REGNUM, 77, 77 }, g_d2_regs, NULL},
- { "d3", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d3, LLDB_INVALID_REGNUM, 78, 78 }, g_d3_regs, NULL},
- { "d4", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d4, LLDB_INVALID_REGNUM, 79, 79 }, g_d4_regs, NULL},
- { "d5", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d5, LLDB_INVALID_REGNUM, 80, 80 }, g_d5_regs, NULL},
- { "d6", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d6, LLDB_INVALID_REGNUM, 81, 81 }, g_d6_regs, NULL},
- { "d7", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d7, LLDB_INVALID_REGNUM, 82, 82 }, g_d7_regs, NULL},
- { "d8", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d8, LLDB_INVALID_REGNUM, 83, 83 }, g_d8_regs, NULL},
- { "d9", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d9, LLDB_INVALID_REGNUM, 84, 84 }, g_d9_regs, NULL},
- { "d10", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d10, LLDB_INVALID_REGNUM, 85, 85 }, g_d10_regs, NULL},
- { "d11", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d11, LLDB_INVALID_REGNUM, 86, 86 }, g_d11_regs, NULL},
- { "d12", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d12, LLDB_INVALID_REGNUM, 87, 87 }, g_d12_regs, NULL},
- { "d13", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d13, LLDB_INVALID_REGNUM, 88, 88 }, g_d13_regs, NULL},
- { "d14", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d14, LLDB_INVALID_REGNUM, 89, 89 }, g_d14_regs, NULL},
- { "d15", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d15, LLDB_INVALID_REGNUM, 90, 90 }, g_d15_regs, NULL},
- { "q0", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q0, LLDB_INVALID_REGNUM, 91, 91 }, g_q0_regs, NULL},
- { "q1", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q1, LLDB_INVALID_REGNUM, 92, 92 }, g_q1_regs, NULL},
- { "q2", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q2, LLDB_INVALID_REGNUM, 93, 93 }, g_q2_regs, NULL},
- { "q3", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q3, LLDB_INVALID_REGNUM, 94, 94 }, g_q3_regs, NULL},
- { "q4", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q4, LLDB_INVALID_REGNUM, 95, 95 }, g_q4_regs, NULL},
- { "q5", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q5, LLDB_INVALID_REGNUM, 96, 96 }, g_q5_regs, NULL},
- { "q6", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q6, LLDB_INVALID_REGNUM, 97, 97 }, g_q6_regs, NULL},
- { "q7", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q7, LLDB_INVALID_REGNUM, 98, 98 }, g_q7_regs, NULL},
- { "q8", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q8, LLDB_INVALID_REGNUM, 99, 99 }, g_q8_regs, NULL},
- { "q9", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q9, LLDB_INVALID_REGNUM, 100, 100 }, g_q9_regs, NULL},
- { "q10", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q10, LLDB_INVALID_REGNUM, 101, 101 }, g_q10_regs, NULL},
- { "q11", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q11, LLDB_INVALID_REGNUM, 102, 102 }, g_q11_regs, NULL},
- { "q12", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q12, LLDB_INVALID_REGNUM, 103, 103 }, g_q12_regs, NULL},
- { "q13", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q13, LLDB_INVALID_REGNUM, 104, 104 }, g_q13_regs, NULL},
- { "q14", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q14, LLDB_INVALID_REGNUM, 105, 105 }, g_q14_regs, NULL},
- { "q15", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q15, LLDB_INVALID_REGNUM, 106, 106 }, g_q15_regs, NULL}
+// NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB VALUE REGS INVALIDATE REGS
+// ====== ====== === === ============= ============ =================== =================== ====================== ============= ==== ========== ===============
+ { "r0", "arg1", 4, 0, eEncodingUint, eFormatHex, { ehframe_r0, dwarf_r0, LLDB_REGNUM_GENERIC_ARG1,0, 0 }, NULL, NULL},
+ { "r1", "arg2", 4, 0, eEncodingUint, eFormatHex, { ehframe_r1, dwarf_r1, LLDB_REGNUM_GENERIC_ARG2,1, 1 }, NULL, NULL},
+ { "r2", "arg3", 4, 0, eEncodingUint, eFormatHex, { ehframe_r2, dwarf_r2, LLDB_REGNUM_GENERIC_ARG3,2, 2 }, NULL, NULL},
+ { "r3", "arg4", 4, 0, eEncodingUint, eFormatHex, { ehframe_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG4,3, 3 }, NULL, NULL},
+ { "r4", NULL, 4, 0, eEncodingUint, eFormatHex, { ehframe_r4, dwarf_r4, LLDB_INVALID_REGNUM, 4, 4 }, NULL, NULL},
+ { "r5", NULL, 4, 0, eEncodingUint, eFormatHex, { ehframe_r5, dwarf_r5, LLDB_INVALID_REGNUM, 5, 5 }, NULL, NULL},
+ { "r6", NULL, 4, 0, eEncodingUint, eFormatHex, { ehframe_r6, dwarf_r6, LLDB_INVALID_REGNUM, 6, 6 }, NULL, NULL},
+ { "r7", "fp", 4, 0, eEncodingUint, eFormatHex, { ehframe_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP, 7, 7 }, NULL, NULL},
+ { "r8", NULL, 4, 0, eEncodingUint, eFormatHex, { ehframe_r8, dwarf_r8, LLDB_INVALID_REGNUM, 8, 8 }, NULL, NULL},
+ { "r9", NULL, 4, 0, eEncodingUint, eFormatHex, { ehframe_r9, dwarf_r9, LLDB_INVALID_REGNUM, 9, 9 }, NULL, NULL},
+ { "r10", NULL, 4, 0, eEncodingUint, eFormatHex, { ehframe_r10, dwarf_r10, LLDB_INVALID_REGNUM, 10, 10 }, NULL, NULL},
+ { "r11", NULL, 4, 0, eEncodingUint, eFormatHex, { ehframe_r11, dwarf_r11, LLDB_INVALID_REGNUM, 11, 11 }, NULL, NULL},
+ { "r12", NULL, 4, 0, eEncodingUint, eFormatHex, { ehframe_r12, dwarf_r12, LLDB_INVALID_REGNUM, 12, 12 }, NULL, NULL},
+ { "sp", "r13", 4, 0, eEncodingUint, eFormatHex, { ehframe_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, 13, 13 }, NULL, NULL},
+ { "lr", "r14", 4, 0, eEncodingUint, eFormatHex, { ehframe_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, 14, 14 }, NULL, NULL},
+ { "pc", "r15", 4, 0, eEncodingUint, eFormatHex, { ehframe_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, 15, 15 }, NULL, NULL},
+ { "f0", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 16, 16 }, NULL, NULL},
+ { "f1", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 17, 17 }, NULL, NULL},
+ { "f2", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 18, 18 }, NULL, NULL},
+ { "f3", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 19, 19 }, NULL, NULL},
+ { "f4", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 20, 20 }, NULL, NULL},
+ { "f5", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 21, 21 }, NULL, NULL},
+ { "f6", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 22, 22 }, NULL, NULL},
+ { "f7", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 23, 23 }, NULL, NULL},
+ { "fps", NULL, 4, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 24, 24 }, NULL, NULL},
+ { "cpsr","flags", 4, 0, eEncodingUint, eFormatHex, { ehframe_cpsr, dwarf_cpsr, LLDB_INVALID_REGNUM, 25, 25 }, NULL, NULL},
+ { "s0", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, 26, 26 }, NULL, NULL},
+ { "s1", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, 27, 27 }, NULL, NULL},
+ { "s2", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, 28, 28 }, NULL, NULL},
+ { "s3", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, 29, 29 }, NULL, NULL},
+ { "s4", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, 30, 30 }, NULL, NULL},
+ { "s5", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, 31, 31 }, NULL, NULL},
+ { "s6", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, 32, 32 }, NULL, NULL},
+ { "s7", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, 33, 33 }, NULL, NULL},
+ { "s8", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, 34, 34 }, NULL, NULL},
+ { "s9", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, 35, 35 }, NULL, NULL},
+ { "s10", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, 36, 36 }, NULL, NULL},
+ { "s11", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, 37, 37 }, NULL, NULL},
+ { "s12", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, 38, 38 }, NULL, NULL},
+ { "s13", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, 39, 39 }, NULL, NULL},
+ { "s14", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, 40, 40 }, NULL, NULL},
+ { "s15", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, 41, 41 }, NULL, NULL},
+ { "s16", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, 42, 42 }, NULL, NULL},
+ { "s17", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, 43, 43 }, NULL, NULL},
+ { "s18", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, 44, 44 }, NULL, NULL},
+ { "s19", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, 45, 45 }, NULL, NULL},
+ { "s20", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, 46, 46 }, NULL, NULL},
+ { "s21", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, 47, 47 }, NULL, NULL},
+ { "s22", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, 48, 48 }, NULL, NULL},
+ { "s23", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, 49, 49 }, NULL, NULL},
+ { "s24", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, 50, 50 }, NULL, NULL},
+ { "s25", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, 51, 51 }, NULL, NULL},
+ { "s26", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, 52, 52 }, NULL, NULL},
+ { "s27", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, 53, 53 }, NULL, NULL},
+ { "s28", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, 54, 54 }, NULL, NULL},
+ { "s29", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, 55, 55 }, NULL, NULL},
+ { "s30", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, 56, 56 }, NULL, NULL},
+ { "s31", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, 57, 57 }, NULL, NULL},
+ { "fpscr",NULL, 4, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 58, 58 }, NULL, NULL},
+ { "d16", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d16, LLDB_INVALID_REGNUM, 59, 59 }, NULL, NULL},
+ { "d17", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d17, LLDB_INVALID_REGNUM, 60, 60 }, NULL, NULL},
+ { "d18", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d18, LLDB_INVALID_REGNUM, 61, 61 }, NULL, NULL},
+ { "d19", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d19, LLDB_INVALID_REGNUM, 62, 62 }, NULL, NULL},
+ { "d20", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d20, LLDB_INVALID_REGNUM, 63, 63 }, NULL, NULL},
+ { "d21", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d21, LLDB_INVALID_REGNUM, 64, 64 }, NULL, NULL},
+ { "d22", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d22, LLDB_INVALID_REGNUM, 65, 65 }, NULL, NULL},
+ { "d23", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d23, LLDB_INVALID_REGNUM, 66, 66 }, NULL, NULL},
+ { "d24", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d24, LLDB_INVALID_REGNUM, 67, 67 }, NULL, NULL},
+ { "d25", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d25, LLDB_INVALID_REGNUM, 68, 68 }, NULL, NULL},
+ { "d26", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d26, LLDB_INVALID_REGNUM, 69, 69 }, NULL, NULL},
+ { "d27", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d27, LLDB_INVALID_REGNUM, 70, 70 }, NULL, NULL},
+ { "d28", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d28, LLDB_INVALID_REGNUM, 71, 71 }, NULL, NULL},
+ { "d29", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d29, LLDB_INVALID_REGNUM, 72, 72 }, NULL, NULL},
+ { "d30", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d30, LLDB_INVALID_REGNUM, 73, 73 }, NULL, NULL},
+ { "d31", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d31, LLDB_INVALID_REGNUM, 74, 74 }, NULL, NULL},
+ { "d0", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d0, LLDB_INVALID_REGNUM, 75, 75 }, g_d0_regs, NULL},
+ { "d1", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d1, LLDB_INVALID_REGNUM, 76, 76 }, g_d1_regs, NULL},
+ { "d2", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d2, LLDB_INVALID_REGNUM, 77, 77 }, g_d2_regs, NULL},
+ { "d3", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d3, LLDB_INVALID_REGNUM, 78, 78 }, g_d3_regs, NULL},
+ { "d4", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d4, LLDB_INVALID_REGNUM, 79, 79 }, g_d4_regs, NULL},
+ { "d5", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d5, LLDB_INVALID_REGNUM, 80, 80 }, g_d5_regs, NULL},
+ { "d6", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d6, LLDB_INVALID_REGNUM, 81, 81 }, g_d6_regs, NULL},
+ { "d7", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d7, LLDB_INVALID_REGNUM, 82, 82 }, g_d7_regs, NULL},
+ { "d8", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d8, LLDB_INVALID_REGNUM, 83, 83 }, g_d8_regs, NULL},
+ { "d9", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d9, LLDB_INVALID_REGNUM, 84, 84 }, g_d9_regs, NULL},
+ { "d10", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d10, LLDB_INVALID_REGNUM, 85, 85 }, g_d10_regs, NULL},
+ { "d11", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d11, LLDB_INVALID_REGNUM, 86, 86 }, g_d11_regs, NULL},
+ { "d12", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d12, LLDB_INVALID_REGNUM, 87, 87 }, g_d12_regs, NULL},
+ { "d13", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d13, LLDB_INVALID_REGNUM, 88, 88 }, g_d13_regs, NULL},
+ { "d14", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d14, LLDB_INVALID_REGNUM, 89, 89 }, g_d14_regs, NULL},
+ { "d15", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d15, LLDB_INVALID_REGNUM, 90, 90 }, g_d15_regs, NULL},
+ { "q0", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q0, LLDB_INVALID_REGNUM, 91, 91 }, g_q0_regs, NULL},
+ { "q1", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q1, LLDB_INVALID_REGNUM, 92, 92 }, g_q1_regs, NULL},
+ { "q2", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q2, LLDB_INVALID_REGNUM, 93, 93 }, g_q2_regs, NULL},
+ { "q3", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q3, LLDB_INVALID_REGNUM, 94, 94 }, g_q3_regs, NULL},
+ { "q4", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q4, LLDB_INVALID_REGNUM, 95, 95 }, g_q4_regs, NULL},
+ { "q5", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q5, LLDB_INVALID_REGNUM, 96, 96 }, g_q5_regs, NULL},
+ { "q6", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q6, LLDB_INVALID_REGNUM, 97, 97 }, g_q6_regs, NULL},
+ { "q7", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q7, LLDB_INVALID_REGNUM, 98, 98 }, g_q7_regs, NULL},
+ { "q8", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q8, LLDB_INVALID_REGNUM, 99, 99 }, g_q8_regs, NULL},
+ { "q9", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q9, LLDB_INVALID_REGNUM, 100, 100 }, g_q9_regs, NULL},
+ { "q10", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q10, LLDB_INVALID_REGNUM, 101, 101 }, g_q10_regs, NULL},
+ { "q11", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q11, LLDB_INVALID_REGNUM, 102, 102 }, g_q11_regs, NULL},
+ { "q12", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q12, LLDB_INVALID_REGNUM, 103, 103 }, g_q12_regs, NULL},
+ { "q13", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q13, LLDB_INVALID_REGNUM, 104, 104 }, g_q13_regs, NULL},
+ { "q14", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q14, LLDB_INVALID_REGNUM, 105, 105 }, g_q14_regs, NULL},
+ { "q15", NULL, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q15, LLDB_INVALID_REGNUM, 106, 106 }, g_q15_regs, NULL}
};
static const uint32_t num_registers = llvm::array_lengthof(g_register_infos);
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
index 117d280cc547..0e26c69eb2a9 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
@@ -42,32 +42,22 @@ public:
{
}
- ~GDBRemoteDynamicRegisterInfo ()
- {
- }
+ ~GDBRemoteDynamicRegisterInfo() override = default;
void
HardcodeARMRegisters(bool from_scratch);
-
};
class GDBRemoteRegisterContext : public RegisterContext
{
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
GDBRemoteRegisterContext (ThreadGDBRemote &thread,
uint32_t concrete_frame_idx,
GDBRemoteDynamicRegisterInfo &reg_info,
bool read_all_at_once);
- virtual
- ~GDBRemoteRegisterContext ();
+ ~GDBRemoteRegisterContext() override;
- //------------------------------------------------------------------
- // Subclasses must override these functions
- //------------------------------------------------------------------
void
InvalidateAllRegisters () override;
@@ -119,6 +109,9 @@ protected:
bool
PrivateSetRegisterValue (uint32_t reg, StringExtractor &response);
+ bool
+ PrivateSetRegisterValue (uint32_t reg, uint64_t val);
+
void
SetAllRegisterValid (bool b);
@@ -166,13 +159,10 @@ private:
bool SetPrimordialRegister(const RegisterInfo *reg_info,
GDBRemoteCommunicationClient &gdb_comm);
- //------------------------------------------------------------------
- // For GDBRemoteRegisterContext only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (GDBRemoteRegisterContext);
};
} // namespace process_gdb_remote
} // namespace lldb_private
-#endif // lldb_GDBRemoteRegisterContext_h_
+#endif // lldb_GDBRemoteRegisterContext_h_
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 1e150b1dda9f..2e7a5b5384f4 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -40,6 +40,7 @@
#include "lldb/Core/Timer.h"
#include "lldb/Core/Value.h"
#include "lldb/DataFormatters/FormatManager.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Host/Symbols.h"
@@ -56,6 +57,7 @@
#include "lldb/Interpreter/OptionGroupUInt64.h"
#include "lldb/Interpreter/Property.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Target/ABI.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/TargetList.h"
@@ -192,7 +194,7 @@ public:
{
for (uint32_t i = 0; i < e_num; ++i)
m_has[i] = false;
- };
+ }
void set_name (const std::string & name)
{
@@ -216,6 +218,16 @@ public:
return m_has[e_has_base];
}
+ void set_base_is_offset (bool is_offset)
+ {
+ m_base_is_offset = is_offset;
+ }
+ bool get_base_is_offset(bool & out) const
+ {
+ out = m_base_is_offset;
+ return m_has[e_has_base];
+ }
+
void set_link_map (const lldb::addr_t addr)
{
m_link_map = addr;
@@ -250,6 +262,7 @@ public:
std::string m_name;
lldb::addr_t m_link_map;
lldb::addr_t m_base;
+ bool m_base_is_offset;
lldb::addr_t m_dynamic;
};
@@ -322,22 +335,22 @@ ProcessGDBRemote::Terminate()
lldb::ProcessSP
-ProcessGDBRemote::CreateInstance (Target &target, Listener &listener, const FileSpec *crash_file_path)
+ProcessGDBRemote::CreateInstance (lldb::TargetSP target_sp, Listener &listener, const FileSpec *crash_file_path)
{
lldb::ProcessSP process_sp;
if (crash_file_path == NULL)
- process_sp.reset (new ProcessGDBRemote (target, listener));
+ process_sp.reset (new ProcessGDBRemote (target_sp, listener));
return process_sp;
}
bool
-ProcessGDBRemote::CanDebug (Target &target, bool plugin_specified_by_name)
+ProcessGDBRemote::CanDebug (lldb::TargetSP target_sp, bool plugin_specified_by_name)
{
if (plugin_specified_by_name)
return true;
// For now we are just making sure the file exists for a given module
- Module *exe_module = target.GetExecutableModulePointer();
+ Module *exe_module = target_sp->GetExecutableModulePointer();
if (exe_module)
{
ObjectFile *exe_objfile = exe_module->GetObjectFile();
@@ -366,17 +379,20 @@ ProcessGDBRemote::CanDebug (Target &target, bool plugin_specified_by_name)
//----------------------------------------------------------------------
// ProcessGDBRemote constructor
//----------------------------------------------------------------------
-ProcessGDBRemote::ProcessGDBRemote(Target& target, Listener &listener) :
- Process (target, listener),
+ProcessGDBRemote::ProcessGDBRemote(lldb::TargetSP target_sp, Listener &listener) :
+ Process (target_sp, listener),
m_flags (0),
m_gdb_comm (),
m_debugserver_pid (LLDB_INVALID_PROCESS_ID),
m_last_stop_packet_mutex (Mutex::eMutexTypeRecursive),
m_register_info (),
m_async_broadcaster (NULL, "lldb.process.gdb-remote.async-broadcaster"),
+ m_async_listener("lldb.process.gdb-remote.async-listener"),
m_async_thread_state_mutex(Mutex::eMutexTypeRecursive),
m_thread_ids (),
- m_threads_info_sp (),
+ m_thread_pcs (),
+ m_jstopinfo_sp (),
+ m_jthreadsinfo_sp (),
m_continue_c_tids (),
m_continue_C_tids (),
m_continue_s_tids (),
@@ -394,6 +410,25 @@ ProcessGDBRemote::ProcessGDBRemote(Target& target, Listener &listener) :
m_async_broadcaster.SetEventName (eBroadcastBitAsyncThreadShouldExit, "async thread should exit");
m_async_broadcaster.SetEventName (eBroadcastBitAsyncContinue, "async thread continue");
m_async_broadcaster.SetEventName (eBroadcastBitAsyncThreadDidExit, "async thread did exit");
+
+ Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_ASYNC));
+
+ const uint32_t async_event_mask = eBroadcastBitAsyncContinue | eBroadcastBitAsyncThreadShouldExit;
+
+ if (m_async_listener.StartListeningForEvents(&m_async_broadcaster, async_event_mask) != async_event_mask)
+ {
+ if (log)
+ log->Printf("ProcessGDBRemote::%s failed to listen for m_async_broadcaster events", __FUNCTION__);
+ }
+
+ const uint32_t gdb_event_mask = Communication::eBroadcastBitReadThreadDidExit |
+ GDBRemoteCommunication::eBroadcastBitGdbReadThreadGotNotify;
+ if (m_async_listener.StartListeningForEvents(&m_gdb_comm, gdb_event_mask) != gdb_event_mask)
+ {
+ if (log)
+ log->Printf("ProcessGDBRemote::%s failed to listen for m_gdb_comm events", __FUNCTION__);
+ }
+
const uint64_t timeout_seconds = GetGlobalPluginProperties()->GetPacketTimeout();
if (timeout_seconds > 0)
m_gdb_comm.SetPacketTimeout(timeout_seconds);
@@ -481,6 +516,40 @@ ProcessGDBRemote::ParsePythonTargetDefinition(const FileSpec &target_definition_
return false;
}
+// If the remote stub didn't give us eh_frame or DWARF register numbers for a register,
+// see if the ABI can provide them.
+// DWARF and eh_frame register numbers are defined as a part of the ABI.
+static void
+AugmentRegisterInfoViaABI (RegisterInfo &reg_info, ConstString reg_name, ABISP abi_sp)
+{
+ if (reg_info.kinds[eRegisterKindEHFrame] == LLDB_INVALID_REGNUM
+ || reg_info.kinds[eRegisterKindDWARF] == LLDB_INVALID_REGNUM)
+ {
+ if (abi_sp)
+ {
+ RegisterInfo abi_reg_info;
+ if (abi_sp->GetRegisterInfoByName (reg_name, abi_reg_info))
+ {
+ if (reg_info.kinds[eRegisterKindEHFrame] == LLDB_INVALID_REGNUM &&
+ abi_reg_info.kinds[eRegisterKindEHFrame] != LLDB_INVALID_REGNUM)
+ {
+ reg_info.kinds[eRegisterKindEHFrame] = abi_reg_info.kinds[eRegisterKindEHFrame];
+ }
+ if (reg_info.kinds[eRegisterKindDWARF] == LLDB_INVALID_REGNUM &&
+ abi_reg_info.kinds[eRegisterKindDWARF] != LLDB_INVALID_REGNUM)
+ {
+ reg_info.kinds[eRegisterKindDWARF] = abi_reg_info.kinds[eRegisterKindDWARF];
+ }
+ if (reg_info.kinds[eRegisterKindGeneric] == LLDB_INVALID_REGNUM &&
+ abi_reg_info.kinds[eRegisterKindGeneric] != LLDB_INVALID_REGNUM)
+ {
+ reg_info.kinds[eRegisterKindGeneric] = abi_reg_info.kinds[eRegisterKindGeneric];
+ }
+ }
+ }
+ }
+}
+
static size_t
SplitCommaSeparatedRegisterNumberString(const llvm::StringRef &comma_separated_regiter_numbers, std::vector<uint32_t> &regnums, int base)
{
@@ -524,11 +593,23 @@ ProcessGDBRemote::BuildDynamicRegisterInfo (bool force)
// 3 - Fall back on the qRegisterInfo packets.
FileSpec target_definition_fspec = GetGlobalPluginProperties()->GetTargetDefinitionFile ();
+ if (!target_definition_fspec.Exists())
+ {
+ // If the filename doesn't exist, it may be a ~ not having been expanded - try to resolve it.
+ target_definition_fspec.ResolvePath();
+ }
if (target_definition_fspec)
{
// See if we can get register definitions from a python file
if (ParsePythonTargetDefinition (target_definition_fspec))
+ {
return;
+ }
+ else
+ {
+ StreamSP stream_sp = GetTarget().GetDebugger().GetAsyncOutputStream();
+ stream_sp->Printf ("ERROR: target description file %s failed to parse.\n", target_definition_fspec.GetPath().c_str());
+ }
}
if (GetGDBServerRegisterInfo ())
@@ -561,12 +642,12 @@ ProcessGDBRemote::BuildDynamicRegisterInfo (bool force)
0, // byte size
reg_offset, // offset
eEncodingUint, // encoding
- eFormatHex, // formate
+ eFormatHex, // format
{
- LLDB_INVALID_REGNUM, // GCC reg num
+ LLDB_INVALID_REGNUM, // eh_frame reg num
LLDB_INVALID_REGNUM, // DWARF reg num
LLDB_INVALID_REGNUM, // generic reg num
- reg_num, // GDB reg num
+ reg_num, // process plugin reg num
reg_num // native register number
},
NULL,
@@ -635,9 +716,9 @@ ProcessGDBRemote::BuildDynamicRegisterInfo (bool force)
{
set_name.SetCString(value.c_str());
}
- else if (name.compare("gcc") == 0)
+ else if (name.compare("gcc") == 0 || name.compare("ehframe") == 0)
{
- reg_info.kinds[eRegisterKindGCC] = StringConvert::ToUInt32(value.c_str(), LLDB_INVALID_REGNUM, 0);
+ reg_info.kinds[eRegisterKindEHFrame] = StringConvert::ToUInt32(value.c_str(), LLDB_INVALID_REGNUM, 0);
}
else if (name.compare("dwarf") == 0)
{
@@ -671,6 +752,8 @@ ProcessGDBRemote::BuildDynamicRegisterInfo (bool force)
reg_info.invalidate_regs = invalidate_regs.data();
}
+ AugmentRegisterInfoViaABI (reg_info, reg_name, GetABI ());
+
m_register_info.AddRegister(reg_info, reg_name, alt_name, set_name);
}
else
@@ -711,11 +794,12 @@ ProcessGDBRemote::BuildDynamicRegisterInfo (bool force)
if (!target_arch.IsValid())
{
if (remote_arch.IsValid()
- && remote_arch.GetMachine() == llvm::Triple::arm
+ && (remote_arch.GetMachine() == llvm::Triple::arm || remote_arch.GetMachine() == llvm::Triple::thumb)
&& remote_arch.GetTriple().getVendor() == llvm::Triple::Apple)
m_register_info.HardcodeARMRegisters(from_scratch);
}
- else if (target_arch.GetMachine() == llvm::Triple::arm)
+ else if (target_arch.GetMachine() == llvm::Triple::arm
+ || target_arch.GetMachine() == llvm::Triple::thumb)
{
m_register_info.HardcodeARMRegisters(from_scratch);
}
@@ -779,20 +863,21 @@ ProcessGDBRemote::DoConnectRemote (Stream *strm, const char *remote_url)
if (GetTarget().GetNonStopModeEnabled())
HandleStopReplySequence();
- if (!m_target.GetArchitecture().IsValid())
+ Target &target = GetTarget();
+ if (!target.GetArchitecture().IsValid())
{
if (m_gdb_comm.GetProcessArchitecture().IsValid())
{
- m_target.SetArchitecture(m_gdb_comm.GetProcessArchitecture());
+ target.SetArchitecture(m_gdb_comm.GetProcessArchitecture());
}
else
{
- m_target.SetArchitecture(m_gdb_comm.GetHostArchitecture());
+ target.SetArchitecture(m_gdb_comm.GetHostArchitecture());
}
}
const StateType state = SetThreadStopInfo (response);
- if (state == eStateStopped)
+ if (state != eStateInvalid)
{
SetPrivateState (state);
}
@@ -910,27 +995,22 @@ ProcessGDBRemote::DoLaunch (Module *exe_module, ProcessLaunchInfo &launch_info)
ObjectFile * object_file = exe_module->GetObjectFile();
if (object_file)
{
- // Make sure we aren't already connected?
- if (!m_gdb_comm.IsConnected())
- {
- error = LaunchAndConnectToDebugserver (launch_info);
- }
-
+ error = EstablishConnectionIfNeeded (launch_info);
if (error.Success())
{
lldb_utility::PseudoTerminal pty;
const bool disable_stdio = (launch_flags & eLaunchFlagDisableSTDIO) != 0;
- PlatformSP platform_sp (m_target.GetPlatform());
+ PlatformSP platform_sp (GetTarget().GetPlatform());
if (disable_stdio)
{
// set to /dev/null unless redirected to a file above
if (!stdin_file_spec)
- stdin_file_spec.SetFile("/dev/null", false);
+ stdin_file_spec.SetFile(FileSystem::DEV_NULL, false);
if (!stdout_file_spec)
- stdout_file_spec.SetFile("/dev/null", false);
+ stdout_file_spec.SetFile(FileSystem::DEV_NULL, false);
if (!stderr_file_spec)
- stderr_file_spec.SetFile("/dev/null", false);
+ stderr_file_spec.SetFile(FileSystem::DEV_NULL, false);
}
else if (platform_sp && platform_sp->IsHost())
{
@@ -977,7 +1057,7 @@ ProcessGDBRemote::DoLaunch (Module *exe_module, ProcessLaunchInfo &launch_info)
m_gdb_comm.SetDisableASLR (launch_flags & eLaunchFlagDisableASLR);
m_gdb_comm.SetDetachOnError (launch_flags & eLaunchFlagDetachOnError);
- m_gdb_comm.SendLaunchArchPacket (m_target.GetArchitecture().GetArchitectureName());
+ m_gdb_comm.SendLaunchArchPacket (GetTarget().GetArchitecture().GetArchitectureName());
const char * launch_event_data = launch_info.GetLaunchEventData();
if (launch_event_data != NULL && *launch_event_data != '\0')
@@ -1044,13 +1124,13 @@ ProcessGDBRemote::DoLaunch (Module *exe_module, ProcessLaunchInfo &launch_info)
if (process_arch.IsValid())
{
- m_target.MergeArchitecture(process_arch);
+ GetTarget().MergeArchitecture(process_arch);
}
else
{
const ArchSpec &host_arch = m_gdb_comm.GetHostArchitecture();
if (host_arch.IsValid())
- m_target.MergeArchitecture(host_arch);
+ GetTarget().MergeArchitecture(host_arch);
}
SetPrivateState (SetThreadStopInfo (response));
@@ -1226,8 +1306,8 @@ ProcessGDBRemote::DidLaunchOrAttach (ArchSpec& process_arch)
// it has, so we really need to take the remote host architecture as our
// defacto architecture in this case.
- if (process_arch.GetMachine() == llvm::Triple::arm &&
- process_arch.GetTriple().getVendor() == llvm::Triple::Apple)
+ if ((process_arch.GetMachine() == llvm::Triple::arm || process_arch.GetMachine() == llvm::Triple::thumb)
+ && process_arch.GetTriple().getVendor() == llvm::Triple::Apple)
{
GetTarget().SetArchitecture (process_arch);
if (log)
@@ -1295,21 +1375,7 @@ ProcessGDBRemote::DoAttachToProcessWithID (lldb::pid_t attach_pid, const Process
Clear();
if (attach_pid != LLDB_INVALID_PROCESS_ID)
{
- // Make sure we aren't already connected?
- if (!m_gdb_comm.IsConnected())
- {
- error = LaunchAndConnectToDebugserver (attach_info);
-
- if (error.Fail())
- {
- const char *error_string = error.AsCString();
- if (error_string == NULL)
- error_string = "unable to launch " DEBUGSERVER_BASENAME;
-
- SetExitStatus (-1, error_string);
- }
- }
-
+ error = EstablishConnectionIfNeeded (attach_info);
if (error.Success())
{
m_gdb_comm.SetDetachOnError(attach_info.GetDetachOnError());
@@ -1319,6 +1385,8 @@ ProcessGDBRemote::DoAttachToProcessWithID (lldb::pid_t attach_pid, const Process
SetID (attach_pid);
m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncContinue, new EventDataBytes (packet, packet_len));
}
+ else
+ SetExitStatus (-1, error.AsCString());
}
return error;
@@ -1333,21 +1401,7 @@ ProcessGDBRemote::DoAttachToProcessWithName (const char *process_name, const Pro
if (process_name && process_name[0])
{
- // Make sure we aren't already connected?
- if (!m_gdb_comm.IsConnected())
- {
- error = LaunchAndConnectToDebugserver (attach_info);
-
- if (error.Fail())
- {
- const char *error_string = error.AsCString();
- if (error_string == NULL)
- error_string = "unable to launch " DEBUGSERVER_BASENAME;
-
- SetExitStatus (-1, error_string);
- }
- }
-
+ error = EstablishConnectionIfNeeded (attach_info);
if (error.Success())
{
StreamString packet;
@@ -1371,11 +1425,13 @@ ProcessGDBRemote::DoAttachToProcessWithName (const char *process_name, const Pro
else
packet.PutCString("vAttachName");
packet.PutChar(';');
- packet.PutBytesAsRawHex8(process_name, strlen(process_name), lldb::endian::InlHostByteOrder(), lldb::endian::InlHostByteOrder());
+ packet.PutBytesAsRawHex8(process_name, strlen(process_name), endian::InlHostByteOrder(), endian::InlHostByteOrder());
m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncContinue, new EventDataBytes (packet.GetData(), packet.GetSize()));
}
+ else
+ SetExitStatus (-1, error.AsCString());
}
return error;
}
@@ -1403,6 +1459,8 @@ ProcessGDBRemote::WillResume ()
m_continue_C_tids.clear();
m_continue_s_tids.clear();
m_continue_S_tids.clear();
+ m_jstopinfo_sp.reset();
+ m_jthreadsinfo_sp.reset();
return Error();
}
@@ -1694,12 +1752,14 @@ ProcessGDBRemote::ClearThreadIDList ()
{
Mutex::Locker locker(m_thread_list_real.GetMutex());
m_thread_ids.clear();
+ m_thread_pcs.clear();
}
size_t
ProcessGDBRemote::UpdateThreadIDsFromStopReplyThreadsValue (std::string &value)
{
m_thread_ids.clear();
+ m_thread_pcs.clear();
size_t comma_pos;
lldb::tid_t tid;
while ((comma_pos = value.find(',')) != std::string::npos)
@@ -1717,18 +1777,39 @@ ProcessGDBRemote::UpdateThreadIDsFromStopReplyThreadsValue (std::string &value)
return m_thread_ids.size();
}
+size_t
+ProcessGDBRemote::UpdateThreadPCsFromStopReplyThreadsValue (std::string &value)
+{
+ m_thread_pcs.clear();
+ size_t comma_pos;
+ lldb::addr_t pc;
+ while ((comma_pos = value.find(',')) != std::string::npos)
+ {
+ value[comma_pos] = '\0';
+ pc = StringConvert::ToUInt64 (value.c_str(), LLDB_INVALID_ADDRESS, 16);
+ if (pc != LLDB_INVALID_ADDRESS)
+ m_thread_pcs.push_back (pc);
+ value.erase(0, comma_pos + 1);
+ }
+ pc = StringConvert::ToUInt64 (value.c_str(), LLDB_INVALID_ADDRESS, 16);
+ if (pc != LLDB_INVALID_THREAD_ID)
+ m_thread_pcs.push_back (pc);
+ return m_thread_pcs.size();
+}
+
bool
ProcessGDBRemote::UpdateThreadIDList ()
{
Mutex::Locker locker(m_thread_list_real.GetMutex());
- if (m_threads_info_sp)
+ if (m_jthreadsinfo_sp)
{
// If we have the JSON threads info, we can get the thread list from that
- StructuredData::Array *thread_infos = m_threads_info_sp->GetAsArray();
+ StructuredData::Array *thread_infos = m_jthreadsinfo_sp->GetAsArray();
if (thread_infos && thread_infos->GetSize() > 0)
{
m_thread_ids.clear();
+ m_thread_pcs.clear();
thread_infos->ForEach([this](StructuredData::Object* object) -> bool {
StructuredData::Dictionary *thread_dict = object->GetAsDictionary();
if (thread_dict)
@@ -1751,25 +1832,43 @@ ProcessGDBRemote::UpdateThreadIDList ()
// that might contain a "threads" key/value pair
// Lock the thread stack while we access it
- Mutex::Locker stop_stack_lock(m_last_stop_packet_mutex);
- // Get the number of stop packets on the stack
- int nItems = m_stop_packet_stack.size();
- // Iterate over them
- for (int i = 0; i < nItems; i++)
+ //Mutex::Locker stop_stack_lock(m_last_stop_packet_mutex);
+ Mutex::Locker stop_stack_lock;
+ if (stop_stack_lock.TryLock(m_last_stop_packet_mutex))
{
- // Get the thread stop info
- StringExtractorGDBRemote &stop_info = m_stop_packet_stack[i];
- const std::string &stop_info_str = stop_info.GetStringRef();
- const size_t threads_pos = stop_info_str.find(";threads:");
- if (threads_pos != std::string::npos)
+ // Get the number of stop packets on the stack
+ int nItems = m_stop_packet_stack.size();
+ // Iterate over them
+ for (int i = 0; i < nItems; i++)
{
- const size_t start = threads_pos + strlen(";threads:");
- const size_t end = stop_info_str.find(';', start);
- if (end != std::string::npos)
+ // Get the thread stop info
+ StringExtractorGDBRemote &stop_info = m_stop_packet_stack[i];
+ const std::string &stop_info_str = stop_info.GetStringRef();
+
+ m_thread_pcs.clear();
+ const size_t thread_pcs_pos = stop_info_str.find(";thread-pcs:");
+ if (thread_pcs_pos != std::string::npos)
+ {
+ const size_t start = thread_pcs_pos + strlen(";thread-pcs:");
+ const size_t end = stop_info_str.find(';', start);
+ if (end != std::string::npos)
+ {
+ std::string value = stop_info_str.substr(start, end - start);
+ UpdateThreadPCsFromStopReplyThreadsValue(value);
+ }
+ }
+
+ const size_t threads_pos = stop_info_str.find(";threads:");
+ if (threads_pos != std::string::npos)
{
- std::string value = stop_info_str.substr(start, end - start);
- if (UpdateThreadIDsFromStopReplyThreadsValue(value))
- return true;
+ const size_t start = threads_pos + strlen(";threads:");
+ const size_t end = stop_info_str.find(';', start);
+ if (end != std::string::npos)
+ {
+ std::string value = stop_info_str.substr(start, end - start);
+ if (UpdateThreadIDsFromStopReplyThreadsValue(value))
+ return true;
+ }
}
}
}
@@ -1826,6 +1925,25 @@ ProcessGDBRemote::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new
__FUNCTION__, static_cast<void*>(thread_sp.get()),
thread_sp->GetID());
}
+ // The m_thread_pcs vector has pc values in big-endian order, not target-endian, unlike most
+ // of the register read/write packets in gdb-remote protocol.
+ // Early in the process startup, we may not yet have set the process ByteOrder so we ignore these;
+ // they are a performance improvement over fetching thread register values individually, the
+ // method we will fall back to if needed.
+ if (m_thread_ids.size() == m_thread_pcs.size() && thread_sp.get() && GetByteOrder() != eByteOrderInvalid)
+ {
+ ThreadGDBRemote *gdb_thread = static_cast<ThreadGDBRemote *> (thread_sp.get());
+ RegisterContextSP reg_ctx_sp (thread_sp->GetRegisterContext());
+ if (reg_ctx_sp)
+ {
+ uint32_t pc_regnum = reg_ctx_sp->ConvertRegisterKindToRegisterNumber
+ (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
+ if (pc_regnum != LLDB_INVALID_REGNUM)
+ {
+ gdb_thread->PrivateSetRegisterValue (pc_regnum, m_thread_pcs[i]);
+ }
+ }
+ }
new_thread_list.AddThread(thread_sp);
}
}
@@ -1846,13 +1964,14 @@ ProcessGDBRemote::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new
return true;
}
+
bool
-ProcessGDBRemote::CalculateThreadStopInfo (ThreadGDBRemote *thread)
+ProcessGDBRemote::GetThreadStopInfoFromJSON (ThreadGDBRemote *thread, const StructuredData::ObjectSP &thread_infos_sp)
{
// See if we got thread stop infos for all threads via the "jThreadsInfo" packet
- if (m_threads_info_sp)
+ if (thread_infos_sp)
{
- StructuredData::Array *thread_infos = m_threads_info_sp->GetAsArray();
+ StructuredData::Array *thread_infos = thread_infos_sp->GetAsArray();
if (thread_infos)
{
lldb::tid_t tid;
@@ -1865,12 +1984,36 @@ ProcessGDBRemote::CalculateThreadStopInfo (ThreadGDBRemote *thread)
if (thread_dict->GetValueForKeyAsInteger<lldb::tid_t>("tid", tid, LLDB_INVALID_THREAD_ID))
{
if (tid == thread->GetID())
- return SetThreadStopInfo(thread_dict);
+ return (bool)SetThreadStopInfo(thread_dict);
}
}
}
}
}
+ return false;
+}
+
+bool
+ProcessGDBRemote::CalculateThreadStopInfo (ThreadGDBRemote *thread)
+{
+ // See if we got thread stop infos for all threads via the "jThreadsInfo" packet
+ if (GetThreadStopInfoFromJSON (thread, m_jthreadsinfo_sp))
+ return true;
+
+ // See if we got thread stop info for any threads valid stop info reasons threads
+ // via the "jstopinfo" packet stop reply packet key/value pair?
+ if (m_jstopinfo_sp)
+ {
+ // If we have "jstopinfo" then we have stop descriptions for all threads
+ // that have stop reasons, and if there is no entry for a thread, then
+ // it has no stop reason.
+ thread->GetRegisterContext()->InvalidateIfNeeded(true);
+ if (!GetThreadStopInfoFromJSON (thread, m_jstopinfo_sp))
+ {
+ thread->SetStopInfo (StopInfoSP());
+ }
+ return true;
+ }
// Fall back to using the qThreadStopInfo packet
StringExtractorGDBRemote stop_packet;
@@ -1926,8 +2069,6 @@ ProcessGDBRemote::SetThreadStopInfo (lldb::tid_t tid,
gdb_thread->PrivateSetRegisterValue (pair.first, reg_value_extractor);
}
- // Clear the stop info just in case we don't set it to anything
- thread_sp->SetStopInfo (StopInfoSP());
thread_sp->SetName (thread_name.empty() ? NULL : thread_name.c_str());
gdb_thread->SetThreadDispatchQAddr (thread_dispatch_qaddr);
@@ -1937,145 +2078,159 @@ ProcessGDBRemote::SetThreadStopInfo (lldb::tid_t tid,
else
gdb_thread->ClearQueueInfo();
-
- if (exc_type != 0)
- {
- const size_t exc_data_size = exc_data.size();
-
- thread_sp->SetStopInfo (StopInfoMachException::CreateStopReasonWithMachException (*thread_sp,
- exc_type,
- exc_data_size,
- exc_data_size >= 1 ? exc_data[0] : 0,
- exc_data_size >= 2 ? exc_data[1] : 0,
- exc_data_size >= 3 ? exc_data[2] : 0));
- }
- else
+ // Make sure we update our thread stop reason just once
+ if (!thread_sp->StopInfoIsUpToDate())
{
- bool handled = false;
- bool did_exec = false;
- if (!reason.empty())
+ thread_sp->SetStopInfo (StopInfoSP());
+ // If there's a memory thread backed by this thread, we need to use it to calcualte StopInfo.
+ ThreadSP memory_thread_sp = m_thread_list.FindThreadByProtocolID(thread_sp->GetProtocolID());
+ if (memory_thread_sp)
+ thread_sp = memory_thread_sp;
+
+ if (exc_type != 0)
{
- if (reason.compare("trace") == 0)
- {
- thread_sp->SetStopInfo (StopInfo::CreateStopReasonToTrace (*thread_sp));
- handled = true;
- }
- else if (reason.compare("breakpoint") == 0)
+ const size_t exc_data_size = exc_data.size();
+
+ thread_sp->SetStopInfo (StopInfoMachException::CreateStopReasonWithMachException (*thread_sp,
+ exc_type,
+ exc_data_size,
+ exc_data_size >= 1 ? exc_data[0] : 0,
+ exc_data_size >= 2 ? exc_data[1] : 0,
+ exc_data_size >= 3 ? exc_data[2] : 0));
+ }
+ else
+ {
+ bool handled = false;
+ bool did_exec = false;
+ if (!reason.empty())
{
- addr_t pc = thread_sp->GetRegisterContext()->GetPC();
- lldb::BreakpointSiteSP bp_site_sp = thread_sp->GetProcess()->GetBreakpointSiteList().FindByAddress(pc);
- if (bp_site_sp)
+ if (reason.compare("trace") == 0)
{
- // If the breakpoint is for this thread, then we'll report the hit, but if it is for another thread,
- // we can just report no reason. We don't need to worry about stepping over the breakpoint here, that
- // will be taken care of when the thread resumes and notices that there's a breakpoint under the pc.
+ thread_sp->SetStopInfo (StopInfo::CreateStopReasonToTrace (*thread_sp));
handled = true;
- if (bp_site_sp->ValidForThisThread (thread_sp.get()))
- {
- thread_sp->SetStopInfo (StopInfo::CreateStopReasonWithBreakpointSiteID (*thread_sp, bp_site_sp->GetID()));
- }
- else
+ }
+ else if (reason.compare("breakpoint") == 0)
+ {
+ addr_t pc = thread_sp->GetRegisterContext()->GetPC();
+ lldb::BreakpointSiteSP bp_site_sp = thread_sp->GetProcess()->GetBreakpointSiteList().FindByAddress(pc);
+ if (bp_site_sp)
{
- StopInfoSP invalid_stop_info_sp;
- thread_sp->SetStopInfo (invalid_stop_info_sp);
+ // If the breakpoint is for this thread, then we'll report the hit, but if it is for another thread,
+ // we can just report no reason. We don't need to worry about stepping over the breakpoint here, that
+ // will be taken care of when the thread resumes and notices that there's a breakpoint under the pc.
+ handled = true;
+ if (bp_site_sp->ValidForThisThread (thread_sp.get()))
+ {
+ thread_sp->SetStopInfo (StopInfo::CreateStopReasonWithBreakpointSiteID (*thread_sp, bp_site_sp->GetID()));
+ }
+ else
+ {
+ StopInfoSP invalid_stop_info_sp;
+ thread_sp->SetStopInfo (invalid_stop_info_sp);
+ }
}
}
- }
- else if (reason.compare("trap") == 0)
- {
- // Let the trap just use the standard signal stop reason below...
- }
- else if (reason.compare("watchpoint") == 0)
- {
- StringExtractor desc_extractor(description.c_str());
- addr_t wp_addr = desc_extractor.GetU64(LLDB_INVALID_ADDRESS);
- uint32_t wp_index = desc_extractor.GetU32(LLDB_INVALID_INDEX32);
- addr_t wp_hit_addr = desc_extractor.GetU64(LLDB_INVALID_ADDRESS);
- watch_id_t watch_id = LLDB_INVALID_WATCH_ID;
- if (wp_addr != LLDB_INVALID_ADDRESS)
+ else if (reason.compare("trap") == 0)
{
- WatchpointSP wp_sp = GetTarget().GetWatchpointList().FindByAddress(wp_addr);
- if (wp_sp)
+ // Let the trap just use the standard signal stop reason below...
+ }
+ else if (reason.compare("watchpoint") == 0)
+ {
+ StringExtractor desc_extractor(description.c_str());
+ addr_t wp_addr = desc_extractor.GetU64(LLDB_INVALID_ADDRESS);
+ uint32_t wp_index = desc_extractor.GetU32(LLDB_INVALID_INDEX32);
+ addr_t wp_hit_addr = desc_extractor.GetU64(LLDB_INVALID_ADDRESS);
+ watch_id_t watch_id = LLDB_INVALID_WATCH_ID;
+ if (wp_addr != LLDB_INVALID_ADDRESS)
+ {
+ WatchpointSP wp_sp;
+ ArchSpec::Core core = GetTarget().GetArchitecture().GetCore();
+ if (core >= ArchSpec::kCore_mips_first && core <= ArchSpec::kCore_mips_last)
+ wp_sp = GetTarget().GetWatchpointList().FindByAddress(wp_hit_addr);
+ if (!wp_sp)
+ wp_sp = GetTarget().GetWatchpointList().FindByAddress(wp_addr);
+ if (wp_sp)
+ {
+ wp_sp->SetHardwareIndex(wp_index);
+ watch_id = wp_sp->GetID();
+ }
+ }
+ if (watch_id == LLDB_INVALID_WATCH_ID)
{
- wp_sp->SetHardwareIndex(wp_index);
- watch_id = wp_sp->GetID();
+ Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_WATCHPOINTS));
+ if (log) log->Printf ("failed to find watchpoint");
}
+ thread_sp->SetStopInfo (StopInfo::CreateStopReasonWithWatchpointID (*thread_sp, watch_id, wp_hit_addr));
+ handled = true;
}
- if (watch_id == LLDB_INVALID_WATCH_ID)
+ else if (reason.compare("exception") == 0)
{
- Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_WATCHPOINTS));
- if (log) log->Printf ("failed to find watchpoint");
+ thread_sp->SetStopInfo (StopInfo::CreateStopReasonWithException(*thread_sp, description.c_str()));
+ handled = true;
+ }
+ else if (reason.compare("exec") == 0)
+ {
+ did_exec = true;
+ thread_sp->SetStopInfo (StopInfo::CreateStopReasonWithExec(*thread_sp));
+ handled = true;
}
- thread_sp->SetStopInfo (StopInfo::CreateStopReasonWithWatchpointID (*thread_sp, watch_id, wp_hit_addr));
- handled = true;
- }
- else if (reason.compare("exception") == 0)
- {
- thread_sp->SetStopInfo (StopInfo::CreateStopReasonWithException(*thread_sp, description.c_str()));
- handled = true;
- }
- else if (reason.compare("exec") == 0)
- {
- did_exec = true;
- thread_sp->SetStopInfo (StopInfo::CreateStopReasonWithExec(*thread_sp));
- handled = true;
}
- }
- if (!handled && signo && did_exec == false)
- {
- if (signo == SIGTRAP)
+ if (!handled && signo && did_exec == false)
{
- // Currently we are going to assume SIGTRAP means we are either
- // hitting a breakpoint or hardware single stepping.
- handled = true;
- addr_t pc = thread_sp->GetRegisterContext()->GetPC() + m_breakpoint_pc_offset;
- lldb::BreakpointSiteSP bp_site_sp = thread_sp->GetProcess()->GetBreakpointSiteList().FindByAddress(pc);
-
- if (bp_site_sp)
+ if (signo == SIGTRAP)
{
- // If the breakpoint is for this thread, then we'll report the hit, but if it is for another thread,
- // we can just report no reason. We don't need to worry about stepping over the breakpoint here, that
- // will be taken care of when the thread resumes and notices that there's a breakpoint under the pc.
- if (bp_site_sp->ValidForThisThread (thread_sp.get()))
+ // Currently we are going to assume SIGTRAP means we are either
+ // hitting a breakpoint or hardware single stepping.
+ handled = true;
+ addr_t pc = thread_sp->GetRegisterContext()->GetPC() + m_breakpoint_pc_offset;
+ lldb::BreakpointSiteSP bp_site_sp = thread_sp->GetProcess()->GetBreakpointSiteList().FindByAddress(pc);
+
+ if (bp_site_sp)
{
- if(m_breakpoint_pc_offset != 0)
- thread_sp->GetRegisterContext()->SetPC(pc);
- thread_sp->SetStopInfo (StopInfo::CreateStopReasonWithBreakpointSiteID (*thread_sp, bp_site_sp->GetID()));
+ // If the breakpoint is for this thread, then we'll report the hit, but if it is for another thread,
+ // we can just report no reason. We don't need to worry about stepping over the breakpoint here, that
+ // will be taken care of when the thread resumes and notices that there's a breakpoint under the pc.
+ if (bp_site_sp->ValidForThisThread (thread_sp.get()))
+ {
+ if(m_breakpoint_pc_offset != 0)
+ thread_sp->GetRegisterContext()->SetPC(pc);
+ thread_sp->SetStopInfo (StopInfo::CreateStopReasonWithBreakpointSiteID (*thread_sp, bp_site_sp->GetID()));
+ }
+ else
+ {
+ StopInfoSP invalid_stop_info_sp;
+ thread_sp->SetStopInfo (invalid_stop_info_sp);
+ }
}
else
{
- StopInfoSP invalid_stop_info_sp;
- thread_sp->SetStopInfo (invalid_stop_info_sp);
+ // If we were stepping then assume the stop was the result of the trace. If we were
+ // not stepping then report the SIGTRAP.
+ // FIXME: We are still missing the case where we single step over a trap instruction.
+ if (thread_sp->GetTemporaryResumeState() == eStateStepping)
+ thread_sp->SetStopInfo (StopInfo::CreateStopReasonToTrace (*thread_sp));
+ else
+ thread_sp->SetStopInfo (StopInfo::CreateStopReasonWithSignal(*thread_sp, signo, description.c_str()));
}
}
- else
- {
- // If we were stepping then assume the stop was the result of the trace. If we were
- // not stepping then report the SIGTRAP.
- // FIXME: We are still missing the case where we single step over a trap instruction.
- if (thread_sp->GetTemporaryResumeState() == eStateStepping)
- thread_sp->SetStopInfo (StopInfo::CreateStopReasonToTrace (*thread_sp));
- else
- thread_sp->SetStopInfo (StopInfo::CreateStopReasonWithSignal(*thread_sp, signo, description.c_str()));
- }
+ if (!handled)
+ thread_sp->SetStopInfo (StopInfo::CreateStopReasonWithSignal (*thread_sp, signo, description.c_str()));
}
- if (!handled)
- thread_sp->SetStopInfo (StopInfo::CreateStopReasonWithSignal (*thread_sp, signo, description.c_str()));
- }
- if (!description.empty())
- {
- lldb::StopInfoSP stop_info_sp (thread_sp->GetStopInfo ());
- if (stop_info_sp)
- {
- const char *stop_info_desc = stop_info_sp->GetDescription();
- if (!stop_info_desc || !stop_info_desc[0])
- stop_info_sp->SetDescription (description.c_str());
- }
- else
+ if (!description.empty())
{
- thread_sp->SetStopInfo (StopInfo::CreateStopReasonWithException (*thread_sp, description.c_str()));
+ lldb::StopInfoSP stop_info_sp (thread_sp->GetStopInfo ());
+ if (stop_info_sp)
+ {
+ const char *stop_info_desc = stop_info_sp->GetDescription();
+ if (!stop_info_desc || !stop_info_desc[0])
+ stop_info_sp->SetDescription (description.c_str());
+ }
+ else
+ {
+ thread_sp->SetStopInfo (StopInfo::CreateStopReasonWithException (*thread_sp, description.c_str()));
+ }
}
}
}
@@ -2084,7 +2239,7 @@ ProcessGDBRemote::SetThreadStopInfo (lldb::tid_t tid,
return thread_sp;
}
-StateType
+lldb::ThreadSP
ProcessGDBRemote::SetThreadStopInfo (StructuredData::Dictionary *thread_dict)
{
static ConstString g_key_tid("tid");
@@ -2101,6 +2256,7 @@ ProcessGDBRemote::SetThreadStopInfo (StructuredData::Dictionary *thread_dict)
static ConstString g_key_address("address");
static ConstString g_key_bytes("bytes");
static ConstString g_key_description("description");
+ static ConstString g_key_signal("signal");
// Stop with signal and thread info
lldb::tid_t tid = LLDB_INVALID_THREAD_ID;
@@ -2159,7 +2315,7 @@ ProcessGDBRemote::SetThreadStopInfo (StructuredData::Dictionary *thread_dict)
}
else if (key == g_key_name)
{
- thread_name = std::move(object->GetStringValue());
+ thread_name = object->GetStringValue();
}
else if (key == g_key_qaddr)
{
@@ -2168,7 +2324,7 @@ ProcessGDBRemote::SetThreadStopInfo (StructuredData::Dictionary *thread_dict)
else if (key == g_key_queue_name)
{
queue_vars_valid = true;
- queue_name = std::move(object->GetStringValue());
+ queue_name = object->GetStringValue();
}
else if (key == g_key_queue_kind)
{
@@ -2192,11 +2348,11 @@ ProcessGDBRemote::SetThreadStopInfo (StructuredData::Dictionary *thread_dict)
}
else if (key == g_key_reason)
{
- reason = std::move(object->GetStringValue());
+ reason = object->GetStringValue();
}
else if (key == g_key_description)
{
- description = std::move(object->GetStringValue());
+ description = object->GetStringValue();
}
else if (key == g_key_registers)
{
@@ -2207,7 +2363,7 @@ ProcessGDBRemote::SetThreadStopInfo (StructuredData::Dictionary *thread_dict)
registers_dict->ForEach([&expedited_register_map](ConstString key, StructuredData::Object* object) -> bool {
const uint32_t reg = StringConvert::ToUInt32 (key.GetCString(), UINT32_MAX, 10);
if (reg != UINT32_MAX)
- expedited_register_map[reg] = std::move(object->GetStringValue());
+ expedited_register_map[reg] = object->GetStringValue();
return true; // Keep iterating through all array items
});
}
@@ -2245,24 +2401,24 @@ ProcessGDBRemote::SetThreadStopInfo (StructuredData::Dictionary *thread_dict)
}
}
+ else if (key == g_key_signal)
+ signo = object->GetIntegerValue(LLDB_INVALID_SIGNAL_NUMBER);
return true; // Keep iterating through all dictionary key/value pairs
});
- SetThreadStopInfo (tid,
- expedited_register_map,
- signo,
- thread_name,
- reason,
- description,
- exc_type,
- exc_data,
- thread_dispatch_qaddr,
- queue_vars_valid,
- queue_name,
- queue_kind,
- queue_serial);
-
- return eStateExited;
+ return SetThreadStopInfo (tid,
+ expedited_register_map,
+ signo,
+ thread_name,
+ reason,
+ description,
+ exc_type,
+ exc_data,
+ thread_dispatch_qaddr,
+ queue_vars_valid,
+ queue_name,
+ queue_kind,
+ queue_serial);
}
StateType
@@ -2348,6 +2504,39 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
if (tid != LLDB_INVALID_THREAD_ID)
m_thread_ids.push_back (tid);
}
+ else if (key.compare("thread-pcs") == 0)
+ {
+ m_thread_pcs.clear();
+ // A comma separated list of all threads in the current
+ // process that includes the thread for this stop reply
+ // packet
+ size_t comma_pos;
+ lldb::addr_t pc;
+ while ((comma_pos = value.find(',')) != std::string::npos)
+ {
+ value[comma_pos] = '\0';
+ // thread in big endian hex
+ pc = StringConvert::ToUInt64 (value.c_str(), LLDB_INVALID_ADDRESS, 16);
+ if (pc != LLDB_INVALID_ADDRESS)
+ m_thread_pcs.push_back (pc);
+ value.erase(0, comma_pos + 1);
+ }
+ pc = StringConvert::ToUInt64 (value.c_str(), LLDB_INVALID_ADDRESS, 16);
+ if (pc != LLDB_INVALID_ADDRESS)
+ m_thread_pcs.push_back (pc);
+ }
+ else if (key.compare("jstopinfo") == 0)
+ {
+ StringExtractor json_extractor;
+ // Swap "value" over into "name_extractor"
+ json_extractor.GetStringRef().swap(value);
+ // Now convert the HEX bytes into a string value
+ json_extractor.GetHexByteString (value);
+
+ // This JSON contains thread IDs and thread stop info for all threads.
+ // It doesn't contain expedited registers, memory or queue info.
+ m_jstopinfo_sp = StructuredData::ParseJSON (value);
+ }
else if (key.compare("hexname") == 0)
{
StringExtractor name_extractor;
@@ -2431,7 +2620,7 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
if (mem_cache_addr != LLDB_INVALID_ADDRESS)
{
StringExtractor bytes;
- bytes.GetStringRef() = std::move(pair.second.str());
+ bytes.GetStringRef() = pair.second.str();
const size_t byte_size = bytes.GetStringRef().size()/2;
DataBufferSP data_buffer_sp(new DataBufferHeap(byte_size, 0));
const size_t bytes_copied = bytes.GetHexBytes (data_buffer_sp->GetBytes(), byte_size, 0);
@@ -2455,6 +2644,10 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
ostr.Printf("%" PRIu64 " %" PRIu32, wp_addr, wp_index);
description = ostr.GetString().c_str();
}
+ else if (key.compare("library") == 0)
+ {
+ LoadModules();
+ }
else if (key.size() == 2 && ::isxdigit(key[0]) && ::isxdigit(key[1]))
{
uint32_t reg = StringConvert::ToUInt32 (key.c_str(), UINT32_MAX, 16);
@@ -2509,6 +2702,7 @@ ProcessGDBRemote::RefreshStateAfterStop ()
{
Mutex::Locker locker(m_thread_list_real.GetMutex());
m_thread_ids.clear();
+ m_thread_pcs.clear();
// Set the thread stop info. It might have a "threads" key whose value is
// a list of all thread IDs in the current process, so m_thread_ids might
// get set.
@@ -2545,11 +2739,6 @@ ProcessGDBRemote::RefreshStateAfterStop ()
m_initial_tid = LLDB_INVALID_THREAD_ID;
}
- // Fetch the threads via an efficient packet that gets stop infos for all threads
- // only if we have more than one thread
- if (m_thread_ids.size() > 1)
- m_threads_info_sp = m_gdb_comm.GetThreadsInfo();
-
// Let all threads recover from stopping and do any clean up based
// on the previous thread state (if any).
m_thread_list_real.RefreshStateAfterStop();
@@ -2824,6 +3013,12 @@ ProcessGDBRemote::SetLastStopPacket (const StringExtractorGDBRemote &response)
{
// Lock the thread stack while we access it
Mutex::Locker stop_stack_lock(m_last_stop_packet_mutex);
+
+ // We are are not using non-stop mode, there can only be one last stop
+ // reply packet, so clear the list.
+ if (GetTarget().GetNonStopModeEnabled() == false)
+ m_stop_packet_stack.clear();
+
// Add this stop packet to the stop packet stack
// This stack will get popped and examined when we switch to the
// Stopped state
@@ -2831,6 +3026,11 @@ ProcessGDBRemote::SetLastStopPacket (const StringExtractorGDBRemote &response)
}
}
+void
+ProcessGDBRemote::SetUnixSignals(const UnixSignalsSP &signals_sp)
+{
+ Process::SetUnixSignals(std::make_shared<GDBRemoteSignals>(signals_sp));
+}
//------------------------------------------------------------------
// Process Queries
@@ -2839,7 +3039,7 @@ ProcessGDBRemote::SetLastStopPacket (const StringExtractorGDBRemote &response)
bool
ProcessGDBRemote::IsAlive ()
{
- return m_gdb_comm.IsConnected() && m_private_state.GetValue() != eStateExited;
+ return m_gdb_comm.IsConnected() && Process::IsAlive();
}
addr_t
@@ -2859,6 +3059,35 @@ ProcessGDBRemote::GetImageInfoAddress()
return addr;
}
+void
+ProcessGDBRemote::WillPublicStop ()
+{
+ // See if the GDB remote client supports the JSON threads info.
+ // If so, we gather stop info for all threads, expedited registers,
+ // expedited memory, runtime queue information (iOS and MacOSX only),
+ // and more. Expediting memory will help stack backtracing be much
+ // faster. Expediting registers will make sure we don't have to read
+ // the thread registers for GPRs.
+ m_jthreadsinfo_sp = m_gdb_comm.GetThreadsInfo();
+
+ if (m_jthreadsinfo_sp)
+ {
+ // Now set the stop info for each thread and also expedite any registers
+ // and memory that was in the jThreadsInfo response.
+ StructuredData::Array *thread_infos = m_jthreadsinfo_sp->GetAsArray();
+ if (thread_infos)
+ {
+ const size_t n = thread_infos->GetSize();
+ for (size_t i=0; i<n; ++i)
+ {
+ StructuredData::Dictionary *thread_dict = thread_infos->GetItemAtIndex(i)->GetAsDictionary();
+ if (thread_dict)
+ SetThreadStopInfo(thread_dict);
+ }
+ }
+ }
+}
+
//------------------------------------------------------------------
// Process Memory
//------------------------------------------------------------------
@@ -2877,14 +3106,8 @@ ProcessGDBRemote::DoReadMemory (addr_t addr, void *buf, size_t size, Error &erro
char packet[64];
int packet_len;
bool binary_memory_read = m_gdb_comm.GetxPacketSupported();
- if (binary_memory_read)
- {
- packet_len = ::snprintf (packet, sizeof(packet), "x0x%" PRIx64 ",0x%" PRIx64, (uint64_t)addr, (uint64_t)size);
- }
- else
- {
- packet_len = ::snprintf (packet, sizeof(packet), "m%" PRIx64 ",%" PRIx64, (uint64_t)addr, (uint64_t)size);
- }
+ packet_len = ::snprintf(packet, sizeof(packet), "%c%" PRIx64 ",%" PRIx64,
+ binary_memory_read ? 'x' : 'm', (uint64_t)addr, (uint64_t)size);
assert (packet_len + 1 < (int)sizeof(packet));
StringExtractorGDBRemote response;
if (m_gdb_comm.SendPacketAndWaitForResponse(packet, packet_len, response, true) == GDBRemoteCommunication::PacketResult::Success)
@@ -2940,7 +3163,7 @@ ProcessGDBRemote::DoWriteMemory (addr_t addr, const void *buf, size_t size, Erro
StreamString packet;
packet.Printf("M%" PRIx64 ",%" PRIx64 ":", addr, (uint64_t)size);
- packet.PutBytesAsRawHex8(buf, size, lldb::endian::InlHostByteOrder(), lldb::endian::InlHostByteOrder());
+ packet.PutBytesAsRawHex8(buf, size, endian::InlHostByteOrder(), endian::InlHostByteOrder());
StringExtractorGDBRemote response;
if (m_gdb_comm.SendPacketAndWaitForResponse(packet.GetData(), packet.GetSize(), response, true) == GDBRemoteCommunication::PacketResult::Success)
{
@@ -3377,6 +3600,27 @@ ProcessGDBRemote::DoSignal (int signo)
}
Error
+ProcessGDBRemote::EstablishConnectionIfNeeded (const ProcessInfo &process_info)
+{
+ // Make sure we aren't already connected?
+ if (m_gdb_comm.IsConnected())
+ return Error();
+
+ PlatformSP platform_sp (GetTarget ().GetPlatform ());
+ if (platform_sp && !platform_sp->IsHost ())
+ return Error("Lost debug server connection");
+
+ auto error = LaunchAndConnectToDebugserver (process_info);
+ if (error.Fail())
+ {
+ const char *error_string = error.AsCString();
+ if (error_string == nullptr)
+ error_string = "unable to launch " DEBUGSERVER_BASENAME;
+ }
+ return error;
+}
+
+Error
ProcessGDBRemote::LaunchAndConnectToDebugserver (const ProcessInfo &process_info)
{
Error error;
@@ -3401,14 +3645,22 @@ ProcessGDBRemote::LaunchAndConnectToDebugserver (const ProcessInfo &process_info
// Set hostname being NULL to do the reverse connect where debugserver
// will bind to port zero and it will communicate back to us the port
// that we will connect to
- const char *hostname = NULL;
+ const char *hostname = nullptr;
uint16_t port = 0;
#endif
- error = m_gdb_comm.StartDebugserverProcess (hostname,
- port,
+ StreamString url_str;
+ const char* url = nullptr;
+ if (hostname != nullptr)
+ {
+ url_str.Printf("%s:%u", hostname, port);
+ url = url_str.GetData();
+ }
+
+ error = m_gdb_comm.StartDebugserverProcess (url,
+ GetTarget().GetPlatform().get(),
debugserver_launch_info,
- port);
+ &port);
if (error.Success ())
m_debugserver_pid = debugserver_launch_info.GetProcessID();
@@ -3653,164 +3905,174 @@ ProcessGDBRemote::AsyncThread (void *arg)
if (log)
log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64 ") thread starting...", __FUNCTION__, arg, process->GetID());
- Listener listener ("ProcessGDBRemote::AsyncThread");
EventSP event_sp;
- const uint32_t desired_event_mask = eBroadcastBitAsyncContinue |
- eBroadcastBitAsyncThreadShouldExit;
-
- if (listener.StartListeningForEvents (&process->m_async_broadcaster, desired_event_mask) == desired_event_mask)
+ bool done = false;
+ while (!done)
{
- listener.StartListeningForEvents (&process->m_gdb_comm, Communication::eBroadcastBitReadThreadDidExit |
- GDBRemoteCommunication::eBroadcastBitGdbReadThreadGotNotify);
-
- bool done = false;
- while (!done)
+ if (log)
+ log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64 ") listener.WaitForEvent (NULL, event_sp)...", __FUNCTION__, arg, process->GetID());
+ if (process->m_async_listener.WaitForEvent (NULL, event_sp))
{
- if (log)
- log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64 ") listener.WaitForEvent (NULL, event_sp)...", __FUNCTION__, arg, process->GetID());
- if (listener.WaitForEvent (NULL, event_sp))
+ const uint32_t event_type = event_sp->GetType();
+ if (event_sp->BroadcasterIs (&process->m_async_broadcaster))
{
- const uint32_t event_type = event_sp->GetType();
- if (event_sp->BroadcasterIs (&process->m_async_broadcaster))
+ if (log)
+ log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64 ") Got an event of type: %d...", __FUNCTION__, arg, process->GetID(), event_type);
+
+ switch (event_type)
{
- if (log)
- log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64 ") Got an event of type: %d...", __FUNCTION__, arg, process->GetID(), event_type);
+ case eBroadcastBitAsyncContinue:
+ {
+ const EventDataBytes *continue_packet = EventDataBytes::GetEventDataFromEvent(event_sp.get());
- switch (event_type)
- {
- case eBroadcastBitAsyncContinue:
+ if (continue_packet)
{
- const EventDataBytes *continue_packet = EventDataBytes::GetEventDataFromEvent(event_sp.get());
+ const char *continue_cstr = (const char *)continue_packet->GetBytes ();
+ const size_t continue_cstr_len = continue_packet->GetByteSize ();
+ if (log)
+ log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64 ") got eBroadcastBitAsyncContinue: %s", __FUNCTION__, arg, process->GetID(), continue_cstr);
- if (continue_packet)
+ if (::strstr (continue_cstr, "vAttach") == NULL)
+ process->SetPrivateState(eStateRunning);
+ StringExtractorGDBRemote response;
+
+ // If in Non-Stop-Mode
+ if (process->GetTarget().GetNonStopModeEnabled())
{
- const char *continue_cstr = (const char *)continue_packet->GetBytes ();
- const size_t continue_cstr_len = continue_packet->GetByteSize ();
- if (log)
- log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64 ") got eBroadcastBitAsyncContinue: %s", __FUNCTION__, arg, process->GetID(), continue_cstr);
-
- if (::strstr (continue_cstr, "vAttach") == NULL)
- process->SetPrivateState(eStateRunning);
- StringExtractorGDBRemote response;
-
- // If in Non-Stop-Mode
- if (process->GetTarget().GetNonStopModeEnabled())
+ // send the vCont packet
+ if (!process->GetGDBRemote().SendvContPacket(process, continue_cstr, continue_cstr_len, response))
{
- // send the vCont packet
- if (!process->GetGDBRemote().SendvContPacket(process, continue_cstr, continue_cstr_len, response))
- {
- // Something went wrong
- done = true;
- break;
- }
+ // Something went wrong
+ done = true;
+ break;
}
- // If in All-Stop-Mode
- else
- {
- StateType stop_state = process->GetGDBRemote().SendContinuePacketAndWaitForResponse (process, continue_cstr, continue_cstr_len, response);
-
- // We need to immediately clear the thread ID list so we are sure to get a valid list of threads.
- // The thread ID list might be contained within the "response", or the stop reply packet that
- // caused the stop. So clear it now before we give the stop reply packet to the process
- // using the process->SetLastStopPacket()...
- process->ClearThreadIDList ();
+ }
+ // If in All-Stop-Mode
+ else
+ {
+ StateType stop_state = process->GetGDBRemote().SendContinuePacketAndWaitForResponse (process, continue_cstr, continue_cstr_len, response);
- switch (stop_state)
- {
- case eStateStopped:
- case eStateCrashed:
- case eStateSuspended:
- process->SetLastStopPacket (response);
- process->SetPrivateState (stop_state);
- break;
+ // We need to immediately clear the thread ID list so we are sure to get a valid list of threads.
+ // The thread ID list might be contained within the "response", or the stop reply packet that
+ // caused the stop. So clear it now before we give the stop reply packet to the process
+ // using the process->SetLastStopPacket()...
+ process->ClearThreadIDList ();
- case eStateExited:
+ switch (stop_state)
+ {
+ case eStateStopped:
+ case eStateCrashed:
+ case eStateSuspended:
+ process->SetLastStopPacket (response);
+ process->SetPrivateState (stop_state);
+ break;
+
+ case eStateExited:
+ {
+ process->SetLastStopPacket (response);
+ process->ClearThreadIDList();
+ response.SetFilePos(1);
+
+ int exit_status = response.GetHexU8();
+ const char *desc_cstr = NULL;
+ StringExtractor extractor;
+ std::string desc_string;
+ if (response.GetBytesLeft() > 0 && response.GetChar('-') == ';')
{
- process->SetLastStopPacket (response);
- process->ClearThreadIDList();
- response.SetFilePos(1);
-
- int exit_status = response.GetHexU8();
- const char *desc_cstr = NULL;
- StringExtractor extractor;
- std::string desc_string;
- if (response.GetBytesLeft() > 0 && response.GetChar('-') == ';')
+ std::string desc_token;
+ while (response.GetNameColonValue (desc_token, desc_string))
{
- std::string desc_token;
- while (response.GetNameColonValue (desc_token, desc_string))
+ if (desc_token == "description")
{
- if (desc_token == "description")
- {
- extractor.GetStringRef().swap(desc_string);
- extractor.SetFilePos(0);
- extractor.GetHexByteString (desc_string);
- desc_cstr = desc_string.c_str();
- }
+ extractor.GetStringRef().swap(desc_string);
+ extractor.SetFilePos(0);
+ extractor.GetHexByteString (desc_string);
+ desc_cstr = desc_string.c_str();
}
}
- process->SetExitStatus(exit_status, desc_cstr);
- done = true;
- break;
}
- case eStateInvalid:
+ process->SetExitStatus(exit_status, desc_cstr);
+ done = true;
+ break;
+ }
+ case eStateInvalid:
+ {
+ // Check to see if we were trying to attach and if we got back
+ // 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
+ && response.GetError() == 0x87)
+ {
+ process->SetExitStatus(-1, "cannot attach to process due to System Integrity Protection");
+ }
+ // E01 code from vAttach means that the attach failed
+ if (::strstr (continue_cstr, "vAttach") != NULL
+ && response.GetError() == 0x1)
+ {
+ process->SetExitStatus(-1, "unable to attach");
+ }
+ else
+ {
process->SetExitStatus(-1, "lost connection");
+ }
break;
+ }
- default:
- process->SetPrivateState (stop_state);
- break;
- } // switch(stop_state)
- } // else // if in All-stop-mode
- } // if (continue_packet)
- } // case eBroadcastBitAysncContinue
- break;
+ default:
+ process->SetPrivateState (stop_state);
+ break;
+ } // switch(stop_state)
+ } // else // if in All-stop-mode
+ } // if (continue_packet)
+ } // case eBroadcastBitAysncContinue
+ break;
- case eBroadcastBitAsyncThreadShouldExit:
- if (log)
- log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64 ") got eBroadcastBitAsyncThreadShouldExit...", __FUNCTION__, arg, process->GetID());
- done = true;
- break;
+ case eBroadcastBitAsyncThreadShouldExit:
+ if (log)
+ log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64 ") got eBroadcastBitAsyncThreadShouldExit...", __FUNCTION__, arg, process->GetID());
+ done = true;
+ break;
- default:
- if (log)
- log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64 ") got unknown event 0x%8.8x", __FUNCTION__, arg, process->GetID(), event_type);
- done = true;
- break;
- }
+ default:
+ if (log)
+ log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64 ") got unknown event 0x%8.8x", __FUNCTION__, arg, process->GetID(), event_type);
+ done = true;
+ break;
}
- else if (event_sp->BroadcasterIs (&process->m_gdb_comm))
+ }
+ else if (event_sp->BroadcasterIs (&process->m_gdb_comm))
+ {
+ switch (event_type)
{
- switch (event_type)
- {
- case Communication::eBroadcastBitReadThreadDidExit:
- process->SetExitStatus (-1, "lost connection");
- done = true;
- break;
-
- case GDBRemoteCommunication::eBroadcastBitGdbReadThreadGotNotify:
- {
- lldb_private::Event *event = event_sp.get();
- const EventDataBytes *continue_packet = EventDataBytes::GetEventDataFromEvent(event);
- StringExtractorGDBRemote notify((const char*)continue_packet->GetBytes());
- // Hand this over to the process to handle
- process->HandleNotifyPacket(notify);
- break;
- }
+ case Communication::eBroadcastBitReadThreadDidExit:
+ process->SetExitStatus (-1, "lost connection");
+ done = true;
+ break;
- default:
- if (log)
- log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64 ") got unknown event 0x%8.8x", __FUNCTION__, arg, process->GetID(), event_type);
- done = true;
- break;
+ case GDBRemoteCommunication::eBroadcastBitGdbReadThreadGotNotify:
+ {
+ lldb_private::Event *event = event_sp.get();
+ const EventDataBytes *continue_packet = EventDataBytes::GetEventDataFromEvent(event);
+ StringExtractorGDBRemote notify((const char*)continue_packet->GetBytes());
+ // Hand this over to the process to handle
+ process->HandleNotifyPacket(notify);
+ break;
}
+
+ default:
+ if (log)
+ log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64 ") got unknown event 0x%8.8x", __FUNCTION__, arg, process->GetID(), event_type);
+ done = true;
+ break;
}
}
- else
- {
- if (log)
- log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64 ") listener.WaitForEvent (NULL, event_sp) => false", __FUNCTION__, arg, process->GetID());
- done = true;
- }
+ }
+ else
+ {
+ if (log)
+ log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64 ") listener.WaitForEvent (NULL, event_sp) => false", __FUNCTION__, arg, process->GetID());
+ done = true;
}
}
@@ -3864,10 +4126,10 @@ ProcessGDBRemote::StartNoticingNewThreads()
}
else
{
- PlatformSP platform_sp (m_target.GetPlatform());
+ PlatformSP platform_sp (GetTarget().GetPlatform());
if (platform_sp)
{
- m_thread_create_bp_sp = platform_sp->SetThreadCreationBreakpoint(m_target);
+ m_thread_create_bp_sp = platform_sp->SetThreadCreationBreakpoint(GetTarget());
if (m_thread_create_bp_sp)
{
if (log && log->GetVerbose())
@@ -3986,6 +4248,9 @@ ProcessGDBRemote::GetLoadedDynamicLibrariesInfos (lldb::addr_t image_list_addres
if (m_gdb_comm.GetLoadedDynamicLibrariesInfosSupported())
{
+ // Scope for the scoped timeout object
+ GDBRemoteCommunication::ScopedTimeout timeout (m_gdb_comm, 10);
+
StructuredData::ObjectSP args_dict(new StructuredData::Dictionary());
args_dict->GetAsDictionary()->AddIntegerItem ("image_list_address", image_list_address);
args_dict->GetAsDictionary()->AddIntegerItem ("image_count", image_count);
@@ -4009,8 +4274,6 @@ ProcessGDBRemote::GetLoadedDynamicLibrariesInfos (lldb::addr_t image_list_addres
{
if (!response.Empty())
{
- // The packet has already had the 0x7d xor quoting stripped out at the
- // GDBRemoteCommunication packet receive level.
object_sp = StructuredData::ParseJSON (response.GetStringRef());
}
}
@@ -4019,7 +4282,6 @@ ProcessGDBRemote::GetLoadedDynamicLibrariesInfos (lldb::addr_t image_list_addres
return object_sp;
}
-
// Establish the largest memory read/write payloads we should use.
// If the remote stub has a max packet size, stay under that size.
//
@@ -4113,6 +4375,18 @@ ProcessGDBRemote::GetModuleSpec(const FileSpec& module_file_spec,
return true;
}
+bool
+ProcessGDBRemote::GetHostOSVersion(uint32_t &major,
+ uint32_t &minor,
+ uint32_t &update)
+{
+ if (m_gdb_comm.GetOSVersion(major, minor, update))
+ return true;
+ // We failed to get the host OS version, defer to the base
+ // implementation to correctly invalidate the arguments.
+ return Process::GetHostOSVersion(major, minor, update);
+}
+
namespace {
typedef std::vector<std::string> stringVec;
@@ -4135,15 +4409,15 @@ struct GdbServerTargetInfo
};
bool
-ParseRegisters (XMLNode feature_node, GdbServerTargetInfo &target_info, GDBRemoteDynamicRegisterInfo &dyn_reg_info)
+ParseRegisters (XMLNode feature_node, GdbServerTargetInfo &target_info, GDBRemoteDynamicRegisterInfo &dyn_reg_info, ABISP abi_sp)
{
if (!feature_node)
return false;
- uint32_t prev_reg_num = 0;
+ uint32_t cur_reg_num = 0;
uint32_t reg_offset = 0;
- feature_node.ForEachChildElementWithName("reg", [&target_info, &dyn_reg_info, &prev_reg_num, &reg_offset](const XMLNode &reg_node) -> bool {
+ feature_node.ForEachChildElementWithName("reg", [&target_info, &dyn_reg_info, &cur_reg_num, &reg_offset, &abi_sp](const XMLNode &reg_node) -> bool {
std::string gdb_group;
std::string gdb_type;
ConstString reg_name;
@@ -4158,19 +4432,19 @@ ParseRegisters (XMLNode feature_node, GdbServerTargetInfo &target_info, GDBRemot
0, // byte size
reg_offset, // offset
eEncodingUint, // encoding
- eFormatHex, // formate
+ eFormatHex, // format
{
- LLDB_INVALID_REGNUM, // GCC reg num
+ LLDB_INVALID_REGNUM, // eh_frame reg num
LLDB_INVALID_REGNUM, // DWARF reg num
LLDB_INVALID_REGNUM, // generic reg num
- prev_reg_num, // GDB reg num
- prev_reg_num // native register number
+ cur_reg_num, // process plugin reg num
+ cur_reg_num // native register number
},
NULL,
NULL
};
- reg_node.ForEachAttribute([&target_info, &gdb_group, &gdb_type, &reg_name, &alt_name, &set_name, &value_regs, &invalidate_regs, &encoding_set, &format_set, &reg_info, &prev_reg_num, &reg_offset](const llvm::StringRef &name, const llvm::StringRef &value) -> bool {
+ reg_node.ForEachAttribute([&target_info, &gdb_group, &gdb_type, &reg_name, &alt_name, &set_name, &value_regs, &invalidate_regs, &encoding_set, &format_set, &reg_info, &cur_reg_num, &reg_offset](const llvm::StringRef &name, const llvm::StringRef &value) -> bool {
if (name == "name")
{
reg_name.SetString(value);
@@ -4192,9 +4466,7 @@ ParseRegisters (XMLNode feature_node, GdbServerTargetInfo &target_info, GDBRemot
const uint32_t regnum = StringConvert::ToUInt32(value.data(), LLDB_INVALID_REGNUM, 0);
if (regnum != LLDB_INVALID_REGNUM)
{
- reg_info.kinds[eRegisterKindGDB] = regnum;
- reg_info.kinds[eRegisterKindLLDB] = regnum;
- prev_reg_num = regnum;
+ reg_info.kinds[eRegisterKindProcessPlugin] = regnum;
}
}
else if (name == "offset")
@@ -4240,9 +4512,9 @@ ParseRegisters (XMLNode feature_node, GdbServerTargetInfo &target_info, GDBRemot
if (pos != target_info.reg_set_map.end())
set_name = pos->second.name;
}
- else if (name == "gcc_regnum")
+ else if (name == "gcc_regnum" || name == "ehframe_regnum")
{
- reg_info.kinds[eRegisterKindGCC] = StringConvert::ToUInt32(value.data(), LLDB_INVALID_REGNUM, 0);
+ reg_info.kinds[eRegisterKindEHFrame] = StringConvert::ToUInt32(value.data(), LLDB_INVALID_REGNUM, 0);
}
else if (name == "dwarf_regnum")
{
@@ -4305,7 +4577,8 @@ ParseRegisters (XMLNode feature_node, GdbServerTargetInfo &target_info, GDBRemot
reg_info.invalidate_regs = invalidate_regs.data();
}
- ++prev_reg_num;
+ ++cur_reg_num;
+ AugmentRegisterInfoViaABI (reg_info, reg_name, abi_sp);
dyn_reg_info.AddRegister(reg_info, reg_name, alt_name, set_name);
return true; // Keep iterating through all "reg" elements
@@ -4401,7 +4674,7 @@ ProcessGDBRemote::GetGDBServerRegisterInfo ()
if (feature_node)
{
- ParseRegisters(feature_node, target_info, this->m_register_info);
+ ParseRegisters(feature_node, target_info, this->m_register_info, GetABI());
}
for (const auto &include : target_info.includes)
@@ -4419,7 +4692,7 @@ ProcessGDBRemote::GetGDBServerRegisterInfo ()
XMLNode include_feature_node = include_xml_document.GetRootElement("feature");
if (include_feature_node)
{
- ParseRegisters(include_feature_node, target_info, this->m_register_info);
+ ParseRegisters(include_feature_node, target_info, this->m_register_info, GetABI());
}
}
this->m_register_info.Finalize(GetTarget().GetArchitecture());
@@ -4489,7 +4762,8 @@ ProcessGDBRemote::GetLoadedModuleList (GDBLoadedModuleInfoList & list)
{
// the displacement as read from the field 'l_addr' of the link_map struct.
module.set_base(StringConvert::ToUInt64(value.data(), LLDB_INVALID_ADDRESS, 0));
-
+ // base address is always a displacement, not an absolute value.
+ module.set_base_is_offset(true);
}
else if (name == "l_ld")
{
@@ -4504,13 +4778,15 @@ ProcessGDBRemote::GetLoadedModuleList (GDBLoadedModuleInfoList & list)
{
std::string name;
lldb::addr_t lm=0, base=0, ld=0;
+ bool base_is_offset;
module.get_name (name);
module.get_link_map (lm);
module.get_base (base);
+ module.get_base_is_offset (base_is_offset);
module.get_dynamic (ld);
- log->Printf ("found (link_map:0x08%" PRIx64 ", base:0x08%" PRIx64 ", ld:0x08%" PRIx64 ", name:'%s')", lm, base, ld, name.c_str());
+ log->Printf ("found (link_map:0x%08" PRIx64 ", base:0x%08" PRIx64 "[%s], ld:0x%08" PRIx64 ", name:'%s')", lm, base, (base_is_offset ? "offset" : "absolute"), ld, name.c_str());
}
list.add (module);
@@ -4552,15 +4828,19 @@ ProcessGDBRemote::GetLoadedModuleList (GDBLoadedModuleInfoList & list)
const XMLNode &section = library.FindFirstChildElementWithName("section");
llvm::StringRef address = section.GetAttributeValue("address");
module.set_base(StringConvert::ToUInt64(address.data(), LLDB_INVALID_ADDRESS, 0));
+ // These addresses are absolute values.
+ module.set_base_is_offset(false);
if (log)
{
std::string name;
lldb::addr_t base = 0;
+ bool base_is_offset;
module.get_name (name);
module.get_base (base);
+ module.get_base_is_offset (base_is_offset);
- log->Printf ("found (base:0x%" PRIx64 ", name:'%s')", base, name.c_str());
+ log->Printf ("found (base:0x%08" PRIx64 "[%s], name:'%s')", base, (base_is_offset ? "offset" : "absolute"), name.c_str());
}
list.add (module);
@@ -4577,7 +4857,7 @@ ProcessGDBRemote::GetLoadedModuleList (GDBLoadedModuleInfoList & list)
}
lldb::ModuleSP
-ProcessGDBRemote::LoadModuleAtAddress (const FileSpec &file, lldb::addr_t base_addr)
+ProcessGDBRemote::LoadModuleAtAddress (const FileSpec &file, lldb::addr_t base_addr, bool value_is_offset)
{
Target &target = m_process->GetTarget();
ModuleList &modules = target.GetImages();
@@ -4588,11 +4868,11 @@ ProcessGDBRemote::LoadModuleAtAddress (const FileSpec &file, lldb::addr_t base_a
ModuleSpec module_spec (file, target.GetArchitecture());
if ((module_sp = modules.FindFirstModule (module_spec)))
{
- module_sp->SetLoadAddress (target, base_addr, true, changed);
+ module_sp->SetLoadAddress (target, base_addr, value_is_offset, changed);
}
else if ((module_sp = target.GetSharedModule (module_spec)))
{
- module_sp->SetLoadAddress (target, base_addr, true, changed);
+ module_sp->SetLoadAddress (target, base_addr, value_is_offset, changed);
}
return module_sp;
@@ -4615,10 +4895,12 @@ ProcessGDBRemote::LoadModules ()
{
std::string mod_name;
lldb::addr_t mod_base;
+ bool mod_base_is_offset;
bool valid = true;
valid &= modInfo.get_name (mod_name);
valid &= modInfo.get_base (mod_base);
+ valid &= modInfo.get_base_is_offset (mod_base_is_offset);
if (!valid)
continue;
@@ -4630,7 +4912,7 @@ ProcessGDBRemote::LoadModules ()
marker += 1;
FileSpec file (mod_name.c_str()+marker, true);
- lldb::ModuleSP module_sp = LoadModuleAtAddress (file, mod_base);
+ lldb::ModuleSP module_sp = LoadModuleAtAddress (file, mod_base, mod_base_is_offset);
if (module_sp.get())
new_modules.Append (module_sp);
@@ -4638,7 +4920,7 @@ ProcessGDBRemote::LoadModules ()
if (new_modules.GetSize() > 0)
{
- Target & target = m_target;
+ Target &target = GetTarget();
new_modules.ForEach ([&target](const lldb::ModuleSP module_sp) -> bool
{
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index 45c74ea64ee5..54749827d6ac 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -11,12 +11,14 @@
#define liblldb_ProcessGDBRemote_h_
// C Includes
-
// C++ Includes
-#include <list>
+#include <atomic>
+#include <map>
+#include <string>
#include <vector>
// Other libraries and framework includes
+// Project includes
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/ConstString.h"
@@ -42,11 +44,12 @@ class ThreadGDBRemote;
class ProcessGDBRemote : public Process
{
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
+ ProcessGDBRemote(lldb::TargetSP target_sp, Listener &listener);
+
+ ~ProcessGDBRemote() override;
+
static lldb::ProcessSP
- CreateInstance (Target& target,
+ CreateInstance (lldb::TargetSP target_sp,
Listener &listener,
const FileSpec *crash_file_path);
@@ -66,18 +69,10 @@ public:
GetPluginDescriptionStatic();
//------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- ProcessGDBRemote(Target& target, Listener &listener);
-
- virtual
- ~ProcessGDBRemote();
-
- //------------------------------------------------------------------
// Check if a given Process
//------------------------------------------------------------------
bool
- CanDebug (Target &target, bool plugin_specified_by_name) override;
+ CanDebug (lldb::TargetSP target_sp, bool plugin_specified_by_name) override;
CommandObject *
GetPluginCommandObject() override;
@@ -152,6 +147,9 @@ public:
void
RefreshStateAfterStop() override;
+ void
+ SetUnixSignals(const lldb::UnixSignalsSP &signals_sp);
+
//------------------------------------------------------------------
// Process Queries
//------------------------------------------------------------------
@@ -161,6 +159,9 @@ public:
lldb::addr_t
GetImageInfoAddress() override;
+ void
+ WillPublicStop () override;
+
//------------------------------------------------------------------
// Process Memory
//------------------------------------------------------------------
@@ -238,6 +239,11 @@ public:
const ArchSpec& arch,
ModuleSpec &module_spec) override;
+ bool
+ GetHostOSVersion(uint32_t &major,
+ uint32_t &minor,
+ uint32_t &update) override;
+
size_t
LoadModules() override;
@@ -257,20 +263,63 @@ protected:
class GDBLoadedModuleInfoList;
+ //------------------------------------------------------------------
+ /// Broadcaster event bits definitions.
+ //------------------------------------------------------------------
+ enum
+ {
+ eBroadcastBitAsyncContinue = (1 << 0),
+ eBroadcastBitAsyncThreadShouldExit = (1 << 1),
+ eBroadcastBitAsyncThreadDidExit = (1 << 2)
+ };
+
+ Flags m_flags; // Process specific flags (see eFlags enums)
+ GDBRemoteCommunicationClient m_gdb_comm;
+ std::atomic<lldb::pid_t> m_debugserver_pid;
+ std::vector<StringExtractorGDBRemote> m_stop_packet_stack; // The stop packet stack replaces the last stop packet variable
+ Mutex m_last_stop_packet_mutex;
+ GDBRemoteDynamicRegisterInfo m_register_info;
+ Broadcaster m_async_broadcaster;
+ Listener m_async_listener;
+ HostThread m_async_thread;
+ Mutex m_async_thread_state_mutex;
+ typedef std::vector<lldb::tid_t> tid_collection;
+ typedef std::vector< std::pair<lldb::tid_t,int> > tid_sig_collection;
+ typedef std::map<lldb::addr_t, lldb::addr_t> MMapMap;
+ typedef std::map<uint32_t, std::string> ExpeditedRegisterMap;
+ tid_collection m_thread_ids; // Thread IDs for all threads. This list gets updated after stopping
+ std::vector<lldb::addr_t> m_thread_pcs; // PC values for all the threads.
+ StructuredData::ObjectSP m_jstopinfo_sp; // Stop info only for any threads that have valid stop infos
+ StructuredData::ObjectSP m_jthreadsinfo_sp; // Full stop info, expedited registers and memory for all threads if "jThreadsInfo" packet is supported
+ tid_collection m_continue_c_tids; // 'c' for continue
+ tid_sig_collection m_continue_C_tids; // 'C' for continue with signal
+ tid_collection m_continue_s_tids; // 's' for step
+ tid_sig_collection m_continue_S_tids; // 'S' for step with signal
+ uint64_t m_max_memory_size; // The maximum number of bytes to read/write when reading and writing memory
+ uint64_t m_remote_stub_max_memory_size; // The maximum memory size the remote gdb stub can handle
+ MMapMap m_addr_to_mmap_size;
+ lldb::BreakpointSP m_thread_create_bp_sp;
+ bool m_waiting_for_attach;
+ bool m_destroy_tried_resuming;
+ lldb::CommandObjectSP m_command_sp;
+ int64_t m_breakpoint_pc_offset;
+ lldb::tid_t m_initial_tid; // The initial thread ID, given by stub on attach
+
//----------------------------------------------------------------------
// Accessors
//----------------------------------------------------------------------
bool
IsRunning ( lldb::StateType state )
{
- return state == lldb::eStateRunning || IsStepping(state);
+ return state == lldb::eStateRunning || IsStepping(state);
}
bool
IsStepping ( lldb::StateType state)
{
- return state == lldb::eStateStepping;
+ return state == lldb::eStateStepping;
}
+
bool
CanResume ( lldb::StateType state)
{
@@ -306,6 +355,9 @@ protected:
ThreadList &new_thread_list) override;
Error
+ EstablishConnectionIfNeeded (const ProcessInfo &process_info);
+
+ Error
LaunchAndConnectToDebugserver (const ProcessInfo &process_info);
void
@@ -333,46 +385,10 @@ protected:
CalculateThreadStopInfo (ThreadGDBRemote *thread);
size_t
- UpdateThreadIDsFromStopReplyThreadsValue (std::string &value);
+ UpdateThreadPCsFromStopReplyThreadsValue (std::string &value);
- //------------------------------------------------------------------
- /// Broadcaster event bits definitions.
- //------------------------------------------------------------------
- enum
- {
- eBroadcastBitAsyncContinue = (1 << 0),
- eBroadcastBitAsyncThreadShouldExit = (1 << 1),
- eBroadcastBitAsyncThreadDidExit = (1 << 2)
- };
-
- Flags m_flags; // Process specific flags (see eFlags enums)
- GDBRemoteCommunicationClient m_gdb_comm;
- std::atomic<lldb::pid_t> m_debugserver_pid;
- std::vector<StringExtractorGDBRemote> m_stop_packet_stack; // The stop packet stack replaces the last stop packet variable
- Mutex m_last_stop_packet_mutex;
- GDBRemoteDynamicRegisterInfo m_register_info;
- Broadcaster m_async_broadcaster;
- HostThread m_async_thread;
- Mutex m_async_thread_state_mutex;
- typedef std::vector<lldb::tid_t> tid_collection;
- typedef std::vector< std::pair<lldb::tid_t,int> > tid_sig_collection;
- typedef std::map<lldb::addr_t, lldb::addr_t> MMapMap;
- typedef std::map<uint32_t, std::string> ExpeditedRegisterMap;
- tid_collection m_thread_ids; // Thread IDs for all threads. This list gets updated after stopping
- StructuredData::ObjectSP m_threads_info_sp; // Stop info for all threads if "jThreadsInfo" packet is supported
- tid_collection m_continue_c_tids; // 'c' for continue
- tid_sig_collection m_continue_C_tids; // 'C' for continue with signal
- tid_collection m_continue_s_tids; // 's' for step
- tid_sig_collection m_continue_S_tids; // 'S' for step with signal
- uint64_t m_max_memory_size; // The maximum number of bytes to read/write when reading and writing memory
- uint64_t m_remote_stub_max_memory_size; // The maximum memory size the remote gdb stub can handle
- MMapMap m_addr_to_mmap_size;
- lldb::BreakpointSP m_thread_create_bp_sp;
- bool m_waiting_for_attach;
- bool m_destroy_tried_resuming;
- lldb::CommandObjectSP m_command_sp;
- int64_t m_breakpoint_pc_offset;
- lldb::tid_t m_initial_tid; // The inital thread ID, given by stub on attach
+ size_t
+ UpdateThreadIDsFromStopReplyThreadsValue (std::string &value);
bool
HandleNotifyPacket(StringExtractorGDBRemote &packet);
@@ -396,7 +412,10 @@ protected:
lldb::StateType
SetThreadStopInfo (StringExtractor& stop_packet);
- lldb::StateType
+ bool
+ GetThreadStopInfoFromJSON (ThreadGDBRemote *thread, const StructuredData::ObjectSP &thread_infos_sp);
+
+ lldb::ThreadSP
SetThreadStopInfo (StructuredData::Dictionary *thread_dict);
lldb::ThreadSP
@@ -445,7 +464,7 @@ protected:
GetLoadedModuleList (GDBLoadedModuleInfoList &);
lldb::ModuleSP
- LoadModuleAtAddress (const FileSpec &file, lldb::addr_t base_addr);
+ LoadModuleAtAddress (const FileSpec &file, lldb::addr_t base_addr, bool value_is_offset);
private:
//------------------------------------------------------------------
@@ -458,10 +477,9 @@ private:
lldb::user_id_t break_loc_id);
DISALLOW_COPY_AND_ASSIGN (ProcessGDBRemote);
-
};
} // namespace process_gdb_remote
} // namespace lldb_private
-#endif // liblldb_ProcessGDBRemote_h_
+#endif // liblldb_ProcessGDBRemote_h_
diff --git a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
index d2a6503caf8e..9b410d8b5b8c 100644
--- a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
@@ -313,6 +313,14 @@ ThreadGDBRemote::PrivateSetRegisterValue (uint32_t reg, StringExtractor &respons
}
bool
+ThreadGDBRemote::PrivateSetRegisterValue (uint32_t reg, uint64_t regval)
+{
+ GDBRemoteRegisterContext *gdb_reg_ctx = static_cast<GDBRemoteRegisterContext *>(GetRegisterContext ().get());
+ assert (gdb_reg_ctx);
+ return gdb_reg_ctx->PrivateSetRegisterValue (reg, regval);
+}
+
+bool
ThreadGDBRemote::CalculateStopInfo ()
{
ProcessSP process_sp (GetProcess());
diff --git a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
index 175433a3e20c..24693ba891cc 100644
--- a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
+++ b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
@@ -10,8 +10,12 @@
#ifndef liblldb_ThreadGDBRemote_h_
#define liblldb_ThreadGDBRemote_h_
+// C Includes
+// C++ Includes
#include <string>
+// Other libraries and framework includes
+// Project includes
#include "lldb/Core/StructuredData.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Thread.h"
@@ -28,8 +32,7 @@ class ThreadGDBRemote : public Thread
public:
ThreadGDBRemote (Process &process, lldb::tid_t tid);
- virtual
- ~ThreadGDBRemote ();
+ ~ThreadGDBRemote() override;
void
WillResume (lldb::StateType resume_state) override;
@@ -101,30 +104,27 @@ public:
FetchThreadExtendedInfo () override;
protected:
-
friend class ProcessGDBRemote;
+ std::string m_thread_name;
+ std::string m_dispatch_queue_name;
+ lldb::addr_t m_thread_dispatch_qaddr;
+ lldb::QueueKind m_queue_kind; // Queue info from stop reply/stop info for thread
+ uint64_t m_queue_serial; // Queue info from stop reply/stop info for thread
+
bool
PrivateSetRegisterValue (uint32_t reg,
StringExtractor &response);
bool
+ PrivateSetRegisterValue (uint32_t reg,
+ uint64_t regval);
+
+ bool
CachedQueueInfoIsValid() const
{
return m_queue_kind != lldb::eQueueKindUnknown;
}
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- std::string m_thread_name;
- std::string m_dispatch_queue_name;
- lldb::addr_t m_thread_dispatch_qaddr;
- lldb::QueueKind m_queue_kind; // Queue info from stop reply/stop info for thread
- uint64_t m_queue_serial; // Queue info from stop reply/stop info for thread
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
-
void
SetStopInfoFromPacket (StringExtractor &stop_packet, uint32_t stop_id);
@@ -135,4 +135,4 @@ protected:
} // namespace process_gdb_remote
} // namespace lldb_private
-#endif // liblldb_ThreadGDBRemote_h_
+#endif // liblldb_ThreadGDBRemote_h_
diff --git a/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp b/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
new file mode 100644
index 000000000000..1a352fa1987f
--- /dev/null
+++ b/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
@@ -0,0 +1,93 @@
+//===-- ScriptInterpreterNone.cpp -------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "ScriptInterpreterNone.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/StreamFile.h"
+#include "lldb/Core/StringList.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+
+#include <mutex>
+
+using namespace lldb;
+using namespace lldb_private;
+
+ScriptInterpreterNone::ScriptInterpreterNone(CommandInterpreter &interpreter)
+ : ScriptInterpreter(interpreter, eScriptLanguageNone)
+{
+}
+
+ScriptInterpreterNone::~ScriptInterpreterNone()
+{
+}
+
+bool
+ScriptInterpreterNone::ExecuteOneLine(const char *command, CommandReturnObject *, const ExecuteScriptOptions &)
+{
+ m_interpreter.GetDebugger().GetErrorFile()->PutCString(
+ "error: there is no embedded script interpreter in this mode.\n");
+ return false;
+}
+
+void
+ScriptInterpreterNone::ExecuteInterpreterLoop()
+{
+ m_interpreter.GetDebugger().GetErrorFile()->PutCString(
+ "error: there is no embedded script interpreter in this mode.\n");
+}
+
+void
+ScriptInterpreterNone::Initialize()
+{
+ static std::once_flag g_once_flag;
+
+ std::call_once(g_once_flag, []()
+ {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(), GetPluginDescriptionStatic(),
+ lldb::eScriptLanguageNone, CreateInstance);
+ });
+}
+
+void
+ScriptInterpreterNone::Terminate()
+{
+}
+
+lldb::ScriptInterpreterSP
+ScriptInterpreterNone::CreateInstance(CommandInterpreter &interpreter)
+{
+ return std::make_shared<ScriptInterpreterNone>(interpreter);
+}
+
+lldb_private::ConstString
+ScriptInterpreterNone::GetPluginNameStatic()
+{
+ static ConstString g_name("script-none");
+ return g_name;
+}
+
+const char *
+ScriptInterpreterNone::GetPluginDescriptionStatic()
+{
+ return "Null script interpreter";
+}
+
+lldb_private::ConstString
+ScriptInterpreterNone::GetPluginName()
+{
+ return GetPluginNameStatic();
+}
+
+uint32_t
+ScriptInterpreterNone::GetPluginVersion()
+{
+ return 1;
+}
diff --git a/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h b/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h
new file mode 100644
index 000000000000..49fd4fabfbc5
--- /dev/null
+++ b/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h
@@ -0,0 +1,66 @@
+//===-- ScriptInterpreterNone.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_ScriptInterpreterNone_h_
+#define liblldb_ScriptInterpreterNone_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Interpreter/ScriptInterpreter.h"
+
+namespace lldb_private
+{
+
+class ScriptInterpreterNone : public ScriptInterpreter
+{
+ public:
+ ScriptInterpreterNone(CommandInterpreter &interpreter);
+
+ ~ScriptInterpreterNone() override;
+
+ bool
+ ExecuteOneLine(const char *command, CommandReturnObject *result,
+ const ExecuteScriptOptions &options = ExecuteScriptOptions()) override;
+
+ void
+ ExecuteInterpreterLoop() override;
+
+ //------------------------------------------------------------------
+ // Static Functions
+ //------------------------------------------------------------------
+ static void
+ Initialize();
+
+ static void
+ Terminate();
+
+ static lldb::ScriptInterpreterSP
+ CreateInstance(CommandInterpreter &interpreter);
+
+ static lldb_private::ConstString
+ GetPluginNameStatic();
+
+ static const char *
+ GetPluginDescriptionStatic();
+
+ //------------------------------------------------------------------
+ // PluginInterface protocol
+ //------------------------------------------------------------------
+ lldb_private::ConstString
+ GetPluginName() override;
+
+ uint32_t
+ GetPluginVersion() override;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_ScriptInterpreterNone_h_
diff --git a/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
new file mode 100644
index 000000000000..3107677ee948
--- /dev/null
+++ b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -0,0 +1,1069 @@
+//===-- PythonDataObjects.cpp ------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifdef LLDB_DISABLE_PYTHON
+
+// Python is disabled in this build
+
+#else
+
+#include "lldb-python.h"
+#include "PythonDataObjects.h"
+#include "ScriptInterpreterPython.h"
+
+#include "lldb/Core/Stream.h"
+#include "lldb/Host/File.h"
+#include "lldb/Interpreter/ScriptInterpreter.h"
+
+#include <stdio.h>
+
+using namespace lldb_private;
+using namespace lldb;
+
+void
+StructuredPythonObject::Dump(Stream &s) const
+{
+ s << "Python Obj: 0x" << GetValue();
+}
+
+//----------------------------------------------------------------------
+// PythonObject
+//----------------------------------------------------------------------
+
+void
+PythonObject::Dump(Stream &strm) const
+{
+ if (m_py_obj)
+ {
+ FILE *file = ::tmpfile();
+ if (file)
+ {
+ ::PyObject_Print (m_py_obj, file, 0);
+ const long length = ftell (file);
+ if (length)
+ {
+ ::rewind(file);
+ std::vector<char> file_contents (length,'\0');
+ const size_t length_read = ::fread (file_contents.data(), 1, file_contents.size(), file);
+ if (length_read > 0)
+ strm.Write (file_contents.data(), length_read);
+ }
+ ::fclose (file);
+ }
+ }
+ else
+ strm.PutCString ("NULL");
+}
+
+PyObjectType
+PythonObject::GetObjectType() const
+{
+ if (!IsAllocated())
+ return PyObjectType::None;
+
+ if (PythonModule::Check(m_py_obj))
+ return PyObjectType::Module;
+ if (PythonList::Check(m_py_obj))
+ return PyObjectType::List;
+ if (PythonTuple::Check(m_py_obj))
+ return PyObjectType::Tuple;
+ if (PythonDictionary::Check(m_py_obj))
+ return PyObjectType::Dictionary;
+ if (PythonString::Check(m_py_obj))
+ return PyObjectType::String;
+ if (PythonInteger::Check(m_py_obj))
+ return PyObjectType::Integer;
+ if (PythonFile::Check(m_py_obj))
+ return PyObjectType::File;
+ if (PythonCallable::Check(m_py_obj))
+ return PyObjectType::Callable;
+ return PyObjectType::Unknown;
+}
+
+PythonString
+PythonObject::Repr() const
+{
+ if (!m_py_obj)
+ return PythonString();
+ PyObject *repr = PyObject_Repr(m_py_obj);
+ if (!repr)
+ return PythonString();
+ return PythonString(PyRefType::Owned, repr);
+}
+
+PythonString
+PythonObject::Str() const
+{
+ if (!m_py_obj)
+ return PythonString();
+ PyObject *str = PyObject_Str(m_py_obj);
+ if (!str)
+ return PythonString();
+ return PythonString(PyRefType::Owned, str);
+}
+
+PythonObject
+PythonObject::ResolveNameWithDictionary(llvm::StringRef name, const PythonDictionary &dict)
+{
+ size_t dot_pos = name.find_first_of('.');
+ llvm::StringRef piece = name.substr(0, dot_pos);
+ PythonObject result = dict.GetItemForKey(PythonString(piece));
+ if (dot_pos == llvm::StringRef::npos)
+ {
+ // There was no dot, we're done.
+ return result;
+ }
+
+ // There was a dot. The remaining portion of the name should be looked up in
+ // the context of the object that was found in the dictionary.
+ return result.ResolveName(name.substr(dot_pos + 1));
+}
+
+PythonObject
+PythonObject::ResolveName(llvm::StringRef name) const
+{
+ // Resolve the name in the context of the specified object. If,
+ // for example, `this` refers to a PyModule, then this will look for
+ // `name` in this module. If `this` refers to a PyType, then it will
+ // resolve `name` as an attribute of that type. If `this` refers to
+ // an instance of an object, then it will resolve `name` as the value
+ // of the specified field.
+ //
+ // This function handles dotted names so that, for example, if `m_py_obj`
+ // 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('.');
+ 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`.
+ return GetAttributeValue(name);
+ }
+
+ // Look up the first piece of the name, and resolve the rest as a child of that.
+ PythonObject parent = ResolveName(name.substr(0, dot_pos));
+ if (!parent.IsAllocated())
+ return PythonObject();
+
+ // Tail recursion.. should be optimized by the compiler
+ return parent.ResolveName(name.substr(dot_pos + 1));
+}
+
+bool
+PythonObject::HasAttribute(llvm::StringRef attr) const
+{
+ if (!IsValid())
+ return false;
+ PythonString py_attr(attr);
+ return !!PyObject_HasAttr(m_py_obj, py_attr.get());
+}
+
+PythonObject
+PythonObject::GetAttributeValue(llvm::StringRef attr) const
+{
+ if (!IsValid())
+ return PythonObject();
+
+ PythonString py_attr(attr);
+ if (!PyObject_HasAttr(m_py_obj, py_attr.get()))
+ return PythonObject();
+
+ return PythonObject(PyRefType::Owned,
+ PyObject_GetAttr(m_py_obj, py_attr.get()));
+}
+
+bool
+PythonObject::IsNone() const
+{
+ return m_py_obj == Py_None;
+}
+
+bool
+PythonObject::IsValid() const
+{
+ return m_py_obj != nullptr;
+}
+
+bool
+PythonObject::IsAllocated() const
+{
+ return IsValid() && !IsNone();
+}
+
+StructuredData::ObjectSP
+PythonObject::CreateStructuredObject() const
+{
+ switch (GetObjectType())
+ {
+ case PyObjectType::Dictionary:
+ return PythonDictionary(PyRefType::Borrowed, m_py_obj).CreateStructuredDictionary();
+ case PyObjectType::Integer:
+ return PythonInteger(PyRefType::Borrowed, m_py_obj).CreateStructuredInteger();
+ case PyObjectType::List:
+ return PythonList(PyRefType::Borrowed, m_py_obj).CreateStructuredArray();
+ case PyObjectType::String:
+ return PythonString(PyRefType::Borrowed, m_py_obj).CreateStructuredString();
+ case PyObjectType::None:
+ return StructuredData::ObjectSP();
+ default:
+ return StructuredData::ObjectSP(new StructuredPythonObject(m_py_obj));
+ }
+}
+
+//----------------------------------------------------------------------
+// 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);
+}
+
+PythonString::PythonString(const char *string)
+ : PythonObject()
+{
+ SetString(llvm::StringRef(string));
+}
+
+PythonString::PythonString()
+ : PythonObject()
+{
+}
+
+PythonString::~PythonString ()
+{
+}
+
+bool
+PythonString::Check(PyObject *py_obj)
+{
+ if (!py_obj)
+ return false;
+
+ if (PyUnicode_Check(py_obj))
+ return true;
+#if PY_MAJOR_VERSION < 3
+ if (PyString_Check(py_obj))
+ return true;
+#endif
+ return false;
+}
+
+void
+PythonString::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 (!PythonString::Check(py_obj))
+ {
+ PythonObject::Reset();
+ return;
+ }
+#if PY_MAJOR_VERSION < 3
+ // In Python 2, Don't store PyUnicode objects directly, because we need
+ // access to their underlying character buffers which Python 2 doesn't
+ // provide.
+ if (PyUnicode_Check(py_obj))
+ result.Reset(PyRefType::Owned, PyUnicode_AsUTF8String(result.get()));
+#endif
+ // Calling PythonObject::Reset(const PythonObject&) will lead to stack overflow since it calls
+ // back into the virtual implementation.
+ PythonObject::Reset(PyRefType::Borrowed, result.get());
+}
+
+llvm::StringRef
+PythonString::GetString() const
+{
+ if (!IsValid())
+ return llvm::StringRef();
+
+ Py_ssize_t size;
+ char *c;
+
+#if PY_MAJOR_VERSION >= 3
+ c = PyUnicode_AsUTF8AndSize(m_py_obj, &size);
+#else
+ PyString_AsStringAndSize(m_py_obj, &c, &size);
+#endif
+ return llvm::StringRef(c, size);
+}
+
+size_t
+PythonString::GetSize() const
+{
+ if (IsValid())
+ {
+#if PY_MAJOR_VERSION >= 3
+ return PyUnicode_GetSize(m_py_obj);
+#else
+ return PyString_Size(m_py_obj);
+#endif
+ }
+ return 0;
+}
+
+void
+PythonString::SetString (llvm::StringRef string)
+{
+#if PY_MAJOR_VERSION >= 3
+ PyObject *unicode = PyUnicode_FromStringAndSize(string.data(), string.size());
+ PythonObject::Reset(PyRefType::Owned, unicode);
+#else
+ PyObject *str = PyString_FromStringAndSize(string.data(), string.size());
+ PythonObject::Reset(PyRefType::Owned, str);
+#endif
+}
+
+StructuredData::StringSP
+PythonString::CreateStructuredString() const
+{
+ StructuredData::StringSP result(new StructuredData::String);
+ result->SetValue(GetString());
+ return result;
+}
+
+//----------------------------------------------------------------------
+// PythonInteger
+//----------------------------------------------------------------------
+
+PythonInteger::PythonInteger()
+ : PythonObject()
+{
+
+}
+
+PythonInteger::PythonInteger(PyRefType type, PyObject *py_obj)
+ : PythonObject()
+{
+ 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);
+}
+
+
+PythonInteger::~PythonInteger ()
+{
+}
+
+bool
+PythonInteger::Check(PyObject *py_obj)
+{
+ if (!py_obj)
+ return false;
+
+#if PY_MAJOR_VERSION >= 3
+ // Python 3 does not have PyInt_Check. There is only one type of
+ // integral value, long.
+ return PyLong_Check(py_obj);
+#else
+ return PyLong_Check(py_obj) || PyInt_Check(py_obj);
+#endif
+}
+
+void
+PythonInteger::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 (!PythonInteger::Check(py_obj))
+ {
+ PythonObject::Reset();
+ return;
+ }
+
+#if PY_MAJOR_VERSION < 3
+ // Always store this as a PyLong, which makes interoperability between
+ // Python 2.x and Python 3.x easier. This is only necessary in 2.x,
+ // since 3.x doesn't even have a PyInt.
+ if (PyInt_Check(py_obj))
+ {
+ // Since we converted the original object to a different type, the new
+ // object is an owned object regardless of the ownership semantics requested
+ // by the user.
+ result.Reset(PyRefType::Owned, PyLong_FromLongLong(PyInt_AsLong(py_obj)));
+ }
+#endif
+
+ assert(PyLong_Check(result.get()) && "Couldn't get a PyLong from this PyObject");
+
+ // Calling PythonObject::Reset(const PythonObject&) will lead to stack overflow since it calls
+ // back into the virtual implementation.
+ PythonObject::Reset(PyRefType::Borrowed, result.get());
+}
+
+int64_t
+PythonInteger::GetInteger() const
+{
+ if (m_py_obj)
+ {
+ assert(PyLong_Check(m_py_obj) && "PythonInteger::GetInteger has a PyObject that isn't a PyLong");
+
+ return PyLong_AsLongLong(m_py_obj);
+ }
+ return UINT64_MAX;
+}
+
+void
+PythonInteger::SetInteger(int64_t value)
+{
+ PythonObject::Reset(PyRefType::Owned, PyLong_FromLongLong(value));
+}
+
+StructuredData::IntegerSP
+PythonInteger::CreateStructuredInteger() const
+{
+ StructuredData::IntegerSP result(new StructuredData::Integer);
+ result->SetValue(GetInteger());
+ return result;
+}
+
+//----------------------------------------------------------------------
+// PythonList
+//----------------------------------------------------------------------
+
+PythonList::PythonList(PyInitialValue value)
+ : PythonObject()
+{
+ if (value == PyInitialValue::Empty)
+ Reset(PyRefType::Owned, PyList_New(0));
+}
+
+PythonList::PythonList(int list_size)
+ : PythonObject()
+{
+ Reset(PyRefType::Owned, PyList_New(list_size));
+}
+
+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)
+{
+ if (!py_obj)
+ return false;
+ return PyList_Check(py_obj);
+}
+
+void
+PythonList::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 (!PythonList::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());
+}
+
+uint32_t
+PythonList::GetSize() const
+{
+ if (IsValid())
+ return PyList_GET_SIZE(m_py_obj);
+ return 0;
+}
+
+PythonObject
+PythonList::GetItemAtIndex(uint32_t index) const
+{
+ if (IsValid())
+ return PythonObject(PyRefType::Borrowed, PyList_GetItem(m_py_obj, index));
+ return PythonObject();
+}
+
+void
+PythonList::SetItemAtIndex(uint32_t index, const PythonObject &object)
+{
+ if (IsAllocated() && object.IsValid())
+ {
+ // PyList_SetItem is documented to "steal" a reference, so we need to
+ // convert it to an owned reference by incrementing it.
+ Py_INCREF(object.get());
+ PyList_SetItem(m_py_obj, index, object.get());
+ }
+}
+
+void
+PythonList::AppendItem(const PythonObject &object)
+{
+ if (IsAllocated() && object.IsValid())
+ {
+ // `PyList_Append` does *not* steal a reference, so do not call `Py_INCREF`
+ // here like we do with `PyList_SetItem`.
+ PyList_Append(m_py_obj, object.get());
+ }
+}
+
+StructuredData::ArraySP
+PythonList::CreateStructuredArray() const
+{
+ StructuredData::ArraySP result(new StructuredData::Array);
+ uint32_t count = GetSize();
+ for (uint32_t i = 0; i < count; ++i)
+ {
+ PythonObject obj = GetItemAtIndex(i);
+ result->AddItem(obj.CreateStructuredObject());
+ }
+ return result;
+}
+
+//----------------------------------------------------------------------
+// PythonTuple
+//----------------------------------------------------------------------
+
+PythonTuple::PythonTuple(PyInitialValue value)
+ : PythonObject()
+{
+ if (value == PyInitialValue::Empty)
+ Reset(PyRefType::Owned, PyTuple_New(0));
+}
+
+PythonTuple::PythonTuple(int tuple_size)
+ : PythonObject()
+{
+ Reset(PyRefType::Owned, PyTuple_New(tuple_size));
+}
+
+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());
+
+ uint32_t idx = 0;
+ for (auto object : objects)
+ {
+ if (object.IsValid())
+ SetItemAtIndex(idx, object);
+ idx++;
+ }
+}
+
+PythonTuple::PythonTuple(std::initializer_list<PyObject*> objects)
+{
+ m_py_obj = PyTuple_New(objects.size());
+
+ uint32_t idx = 0;
+ for (auto py_object : objects)
+ {
+ PythonObject object(PyRefType::Borrowed, py_object);
+ if (object.IsValid())
+ SetItemAtIndex(idx, object);
+ idx++;
+ }
+}
+
+PythonTuple::~PythonTuple()
+{
+}
+
+bool
+PythonTuple::Check(PyObject *py_obj)
+{
+ if (!py_obj)
+ return false;
+ return PyTuple_Check(py_obj);
+}
+
+void
+PythonTuple::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 (!PythonTuple::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());
+}
+
+uint32_t
+PythonTuple::GetSize() const
+{
+ if (IsValid())
+ return PyTuple_GET_SIZE(m_py_obj);
+ return 0;
+}
+
+PythonObject
+PythonTuple::GetItemAtIndex(uint32_t index) const
+{
+ if (IsValid())
+ return PythonObject(PyRefType::Borrowed, PyTuple_GetItem(m_py_obj, index));
+ return PythonObject();
+}
+
+void
+PythonTuple::SetItemAtIndex(uint32_t index, const PythonObject &object)
+{
+ if (IsAllocated() && object.IsValid())
+ {
+ // PyTuple_SetItem is documented to "steal" a reference, so we need to
+ // convert it to an owned reference by incrementing it.
+ Py_INCREF(object.get());
+ PyTuple_SetItem(m_py_obj, index, object.get());
+ }
+}
+
+StructuredData::ArraySP
+PythonTuple::CreateStructuredArray() const
+{
+ StructuredData::ArraySP result(new StructuredData::Array);
+ uint32_t count = GetSize();
+ for (uint32_t i = 0; i < count; ++i)
+ {
+ PythonObject obj = GetItemAtIndex(i);
+ result->AddItem(obj.CreateStructuredObject());
+ }
+ return result;
+}
+
+//----------------------------------------------------------------------
+// PythonDictionary
+//----------------------------------------------------------------------
+
+PythonDictionary::PythonDictionary(PyInitialValue value)
+ : PythonObject()
+{
+ if (value == PyInitialValue::Empty)
+ Reset(PyRefType::Owned, PyDict_New());
+}
+
+PythonDictionary::PythonDictionary(PyRefType type, PyObject *py_obj)
+ : PythonObject()
+{
+ 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)
+{
+ if (!py_obj)
+ return false;
+
+ return PyDict_Check(py_obj);
+}
+
+void
+PythonDictionary::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 (!PythonDictionary::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());
+}
+
+uint32_t
+PythonDictionary::GetSize() const
+{
+ if (IsValid())
+ return PyDict_Size(m_py_obj);
+ return 0;
+}
+
+PythonList
+PythonDictionary::GetKeys() const
+{
+ if (IsValid())
+ return PythonList(PyRefType::Owned, PyDict_Keys(m_py_obj));
+ return PythonList(PyInitialValue::Invalid);
+}
+
+PythonObject
+PythonDictionary::GetItemForKey(const PythonObject &key) const
+{
+ if (IsAllocated() && key.IsValid())
+ return PythonObject(PyRefType::Borrowed, PyDict_GetItem(m_py_obj, key.get()));
+ return PythonObject();
+}
+
+void
+PythonDictionary::SetItemForKey(const PythonObject &key, const PythonObject &value)
+{
+ if (IsAllocated() && key.IsValid() && value.IsValid())
+ PyDict_SetItem(m_py_obj, key.get(), value.get());
+}
+
+StructuredData::DictionarySP
+PythonDictionary::CreateStructuredDictionary() const
+{
+ StructuredData::DictionarySP result(new StructuredData::Dictionary);
+ PythonList keys(GetKeys());
+ uint32_t num_keys = keys.GetSize();
+ for (uint32_t i = 0; i < num_keys; ++i)
+ {
+ PythonObject key = keys.GetItemAtIndex(i);
+ PythonObject value = GetItemForKey(key);
+ StructuredData::ObjectSP structured_value = value.CreateStructuredObject();
+ result->AddItem(key.Str().GetString(), structured_value);
+ }
+ return result;
+}
+
+PythonModule::PythonModule() : PythonObject()
+{
+}
+
+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()
+{
+#if PY_MAJOR_VERSION >= 3
+ return AddModule("builtins");
+#else
+ return AddModule("__builtin__");
+#endif
+}
+
+PythonModule
+PythonModule::MainModule()
+{
+ return AddModule("__main__");
+}
+
+PythonModule
+PythonModule::AddModule(llvm::StringRef module)
+{
+ std::string str = module.str();
+ return PythonModule(PyRefType::Borrowed, PyImport_AddModule(str.c_str()));
+}
+
+
+PythonModule
+PythonModule::ImportModule(llvm::StringRef module)
+{
+ std::string str = module.str();
+ return PythonModule(PyRefType::Owned, PyImport_ImportModule(str.c_str()));
+}
+
+bool
+PythonModule::Check(PyObject *py_obj)
+{
+ if (!py_obj)
+ return false;
+
+ return PyModule_Check(py_obj);
+}
+
+void
+PythonModule::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 (!PythonModule::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());
+}
+
+PythonDictionary
+PythonModule::GetDictionary() const
+{
+ return PythonDictionary(PyRefType::Borrowed, PyModule_GetDict(m_py_obj));
+}
+
+PythonCallable::PythonCallable() : PythonObject()
+{
+}
+
+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)
+{
+ if (!py_obj)
+ return false;
+
+ return PyCallable_Check(py_obj);
+}
+
+void
+PythonCallable::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 (!PythonCallable::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());
+}
+
+
+PythonCallable::ArgInfo
+PythonCallable::GetNumArguments() const
+{
+ ArgInfo result = { 0, false, false };
+ if (!IsValid())
+ return result;
+
+ PyObject *py_func_obj = m_py_obj;
+ if (PyMethod_Check(py_func_obj))
+ py_func_obj = PyMethod_GET_FUNCTION(py_func_obj);
+
+ if (!py_func_obj)
+ return result;
+
+ PyCodeObject* code = (PyCodeObject*)PyFunction_GET_CODE(py_func_obj);
+ if (!code)
+ return result;
+
+ result.count = code->co_argcount;
+ result.has_varargs = !!(code->co_flags & CO_VARARGS);
+ result.has_kwargs = !!(code->co_flags & CO_VARKEYWORDS);
+ return result;
+}
+
+PythonObject
+PythonCallable::operator ()()
+{
+ return PythonObject(PyRefType::Owned,
+ PyObject_CallObject(m_py_obj, nullptr));
+}
+
+PythonObject
+PythonCallable::operator ()(std::initializer_list<PyObject*> args)
+{
+ PythonTuple arg_tuple(args);
+ return PythonObject(PyRefType::Owned,
+ PyObject_CallObject(m_py_obj, arg_tuple.get()));
+}
+
+PythonObject
+PythonCallable::operator ()(std::initializer_list<PythonObject> args)
+{
+ PythonTuple arg_tuple(args);
+ return PythonObject(PyRefType::Owned,
+ PyObject_CallObject(m_py_obj, arg_tuple.get()));
+}
+
+PythonFile::PythonFile()
+ : PythonObject()
+{
+}
+
+PythonFile::PythonFile(File &file, const char *mode)
+{
+ Reset(file, mode);
+}
+
+PythonFile::PythonFile(const char *path, const char *mode)
+{
+ FILE *fp = nullptr;
+ fp = fopen(path, mode);
+ lldb_private::File file(fp, true);
+ Reset(file, mode);
+}
+
+PythonFile::PythonFile(PyRefType type, PyObject *o)
+{
+ Reset(type, o);
+}
+
+PythonFile::~PythonFile()
+{
+}
+
+bool
+PythonFile::Check(PyObject *py_obj)
+{
+#if PY_MAJOR_VERSION < 3
+ return PyFile_Check(py_obj);
+#else
+ // In Python 3, there is no `PyFile_Check`, and in fact PyFile is not even a
+ // first-class object type anymore. `PyFile_FromFd` is just a thin wrapper
+ // over `io.open()`, which returns some object derived from `io.IOBase`.
+ // As a result, the only way to detect a file in Python 3 is to check whether
+ // it inherits from `io.IOBase`. Since it is possible for non-files to also
+ // inherit from `io.IOBase`, we additionally verify that it has the `fileno`
+ // attribute, which should guarantee that it is backed by the file system.
+ PythonObject io_module(PyRefType::Owned, PyImport_ImportModule("io"));
+ PythonDictionary io_dict(PyRefType::Borrowed, PyModule_GetDict(io_module.get()));
+ PythonObject io_base_class = io_dict.GetItemForKey(PythonString("IOBase"));
+
+ PythonObject object_type(PyRefType::Owned, PyObject_Type(py_obj));
+
+ if (1 != PyObject_IsSubclass(object_type.get(), io_base_class.get()))
+ return false;
+ if (!object_type.HasAttribute("fileno"))
+ return false;
+
+ return true;
+#endif
+}
+
+void
+PythonFile::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 (!PythonFile::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());
+}
+
+void
+PythonFile::Reset(File &file, const char *mode)
+{
+ if (!file.IsValid())
+ {
+ Reset();
+ return;
+ }
+
+ char *cmode = const_cast<char *>(mode);
+#if PY_MAJOR_VERSION >= 3
+ Reset(PyRefType::Owned,
+ PyFile_FromFd(file.GetDescriptor(), nullptr, cmode, -1, nullptr, "ignore", nullptr, 0));
+#else
+ // Read through the Python source, doesn't seem to modify these strings
+ Reset(PyRefType::Owned,
+ PyFile_FromFile(file.GetStream(), const_cast<char *>(""), cmode, nullptr));
+#endif
+}
+
+bool
+PythonFile::GetUnderlyingFile(File &file) const
+{
+ if (!IsValid())
+ return false;
+
+ file.Close();
+ // We don't own the file descriptor returned by this function, make sure the
+ // File object knows about that.
+ file.SetDescriptor(PyObject_AsFileDescriptor(m_py_obj), false);
+ return file.IsValid();
+}
+
+
+#endif
diff --git a/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
new file mode 100644
index 000000000000..c9d17c0f0fad
--- /dev/null
+++ b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
@@ -0,0 +1,498 @@
+//===-- PythonDataObjects.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_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONDATAOBJECTS_H
+#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONDATAOBJECTS_H
+
+#ifndef LLDB_DISABLE_PYTHON
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-defines.h"
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/StructuredData.h"
+#include "lldb/Core/Flags.h"
+#include "lldb/Host/File.h"
+#include "lldb/Interpreter/OptionValue.h"
+
+namespace lldb_private {
+
+class PythonString;
+class PythonList;
+class PythonDictionary;
+class PythonInteger;
+
+class StructuredPythonObject : public StructuredData::Generic
+{
+public:
+ StructuredPythonObject()
+ : StructuredData::Generic()
+ {
+ }
+
+ StructuredPythonObject(void *obj)
+ : StructuredData::Generic(obj)
+ {
+ Py_XINCREF(GetValue());
+ }
+
+ ~StructuredPythonObject() override
+ {
+ if (Py_IsInitialized())
+ Py_XDECREF(GetValue());
+ SetValue(nullptr);
+ }
+
+ bool
+ IsValid() const override
+ {
+ return GetValue() && GetValue() != Py_None;
+ }
+
+ void Dump(Stream &s) const override;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(StructuredPythonObject);
+};
+
+enum class PyObjectType
+{
+ Unknown,
+ None,
+ Integer,
+ Dictionary,
+ List,
+ String,
+ Module,
+ Callable,
+ Tuple,
+ File
+};
+
+enum class PyRefType
+{
+ Borrowed, // We are not given ownership of the incoming PyObject.
+ // We cannot safely hold it without calling Py_INCREF.
+ Owned // We have ownership of the incoming PyObject. We should
+ // not call Py_INCREF.
+};
+
+enum class PyInitialValue
+{
+ Invalid,
+ Empty
+};
+
+class PythonObject
+{
+public:
+ PythonObject()
+ : m_py_obj(nullptr)
+ {
+ }
+
+ PythonObject(PyRefType type, PyObject *py_obj)
+ : m_py_obj(nullptr)
+ {
+ Reset(type, py_obj);
+ }
+
+ PythonObject(const PythonObject &rhs)
+ : m_py_obj(nullptr)
+ {
+ Reset(rhs);
+ }
+
+ virtual ~PythonObject()
+ {
+ Reset();
+ }
+
+ void
+ Reset()
+ {
+ // Avoid calling the virtual method since it's not necessary
+ // to actually validate the type of the PyObject if we're
+ // just setting to null.
+ if (Py_IsInitialized())
+ Py_XDECREF(m_py_obj);
+ m_py_obj = nullptr;
+ }
+
+ void
+ Reset(const PythonObject &rhs)
+ {
+ // Avoid calling the virtual method if it's not necessary
+ // to actually validate the type of the PyObject.
+ if (!rhs.IsValid())
+ Reset();
+ else
+ Reset(PyRefType::Borrowed, rhs.m_py_obj);
+ }
+
+ // PythonObject is implicitly convertible to PyObject *, which will call the
+ // wrong overload. We want to explicitly disallow this, since a PyObject
+ // *always* owns its reference. Therefore the overload which takes a
+ // PyRefType doesn't make sense, and the copy constructor should be used.
+ void
+ Reset(PyRefType type, const PythonObject &ref) = delete;
+
+ virtual void
+ Reset(PyRefType type, PyObject *py_obj)
+ {
+ if (py_obj == m_py_obj)
+ return;
+
+ if (Py_IsInitialized())
+ Py_XDECREF(m_py_obj);
+
+ m_py_obj = py_obj;
+
+ // If this is a borrowed reference, we need to convert it to
+ // an owned reference by incrementing it. If it is an owned
+ // reference (for example the caller allocated it with PyDict_New()
+ // then we must *not* increment it.
+ if (Py_IsInitialized() && type == PyRefType::Borrowed)
+ Py_XINCREF(m_py_obj);
+ }
+
+ void
+ Dump () const
+ {
+ if (m_py_obj)
+ _PyObject_Dump (m_py_obj);
+ else
+ puts ("NULL");
+ }
+
+ void
+ Dump (Stream &strm) const;
+
+ PyObject*
+ get() const
+ {
+ return m_py_obj;
+ }
+
+ PyObject*
+ release()
+ {
+ PyObject *result = m_py_obj;
+ m_py_obj = nullptr;
+ return result;
+ }
+
+ PythonObject &
+ operator=(const PythonObject &other)
+ {
+ Reset(PyRefType::Borrowed, other.get());
+ return *this;
+ }
+
+ PyObjectType
+ GetObjectType() const;
+
+ PythonString
+ Repr() const;
+
+ PythonString
+ Str() const;
+
+ static PythonObject
+ ResolveNameWithDictionary(llvm::StringRef name, const PythonDictionary &dict);
+
+ template<typename T>
+ static T
+ ResolveNameWithDictionary(llvm::StringRef name, const PythonDictionary &dict)
+ {
+ return ResolveNameWithDictionary(name, dict).AsType<T>();
+ }
+
+ PythonObject
+ ResolveName(llvm::StringRef name) const;
+
+ template<typename T>
+ T
+ ResolveName(llvm::StringRef name) const
+ {
+ return ResolveName(name).AsType<T>();
+ }
+
+ bool
+ HasAttribute(llvm::StringRef attribute) const;
+
+ PythonObject
+ GetAttributeValue(llvm::StringRef attribute) const;
+
+ bool
+ IsValid() const;
+
+ bool
+ IsAllocated() const;
+
+ bool
+ IsNone() const;
+
+ template<typename T>
+ T AsType() const
+ {
+ if (!T::Check(m_py_obj))
+ return T();
+ return T(PyRefType::Borrowed, m_py_obj);
+ }
+
+ StructuredData::ObjectSP
+ CreateStructuredObject() const;
+
+protected:
+ PyObject* m_py_obj;
+};
+
+class PythonString : public PythonObject
+{
+public:
+ PythonString();
+ explicit PythonString(llvm::StringRef string);
+ explicit PythonString(const char *string);
+ PythonString(PyRefType type, PyObject *o);
+ PythonString(const PythonString &object);
+
+ ~PythonString() override;
+
+ 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;
+
+ llvm::StringRef
+ GetString() const;
+
+ size_t
+ GetSize() const;
+
+ void SetString(llvm::StringRef string);
+
+ StructuredData::StringSP CreateStructuredString() const;
+};
+
+class PythonInteger : public PythonObject
+{
+public:
+ PythonInteger();
+ explicit PythonInteger(int64_t value);
+ PythonInteger(PyRefType type, PyObject *o);
+ PythonInteger(const PythonInteger &object);
+
+ ~PythonInteger() override;
+
+ 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;
+
+ int64_t GetInteger() const;
+
+ void
+ SetInteger (int64_t value);
+
+ StructuredData::IntegerSP CreateStructuredInteger() 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;
+
+ 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;
+
+ uint32_t GetSize() const;
+
+ PythonObject GetItemAtIndex(uint32_t index) const;
+
+ void SetItemAtIndex(uint32_t index, const PythonObject &object);
+
+ void AppendItem(const PythonObject &object);
+
+ StructuredData::ArraySP CreateStructuredArray() const;
+};
+
+class PythonTuple : public PythonObject
+{
+public:
+ PythonTuple() {}
+ 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);
+
+ ~PythonTuple() override;
+
+ 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;
+
+ uint32_t GetSize() const;
+
+ PythonObject GetItemAtIndex(uint32_t index) const;
+
+ void SetItemAtIndex(uint32_t index, const PythonObject &object);
+
+ StructuredData::ArraySP CreateStructuredArray() const;
+};
+
+class PythonDictionary : public PythonObject
+{
+public:
+ PythonDictionary() {}
+ explicit PythonDictionary(PyInitialValue value);
+ PythonDictionary(PyRefType type, PyObject *o);
+ PythonDictionary(const PythonDictionary &dict);
+
+ ~PythonDictionary() override;
+
+ 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;
+
+ uint32_t GetSize() const;
+
+ PythonList GetKeys() const;
+
+ PythonObject GetItemForKey(const PythonObject &key) const;
+ void SetItemForKey(const PythonObject &key, const PythonObject &value);
+
+ StructuredData::DictionarySP CreateStructuredDictionary() const;
+};
+
+class PythonModule : public PythonObject
+{
+ public:
+ PythonModule();
+ PythonModule(PyRefType type, PyObject *o);
+ PythonModule(const PythonModule &dict);
+
+ ~PythonModule() override;
+
+ static bool Check(PyObject *py_obj);
+
+ static PythonModule
+ BuiltinsModule();
+
+ static PythonModule
+ MainModule();
+
+ static PythonModule
+ AddModule(llvm::StringRef module);
+
+ static PythonModule
+ ImportModule(llvm::StringRef module);
+
+ // Bring in the no-argument base class version
+ using PythonObject::Reset;
+
+ void Reset(PyRefType type, PyObject *py_obj) override;
+
+ PythonDictionary GetDictionary() const;
+};
+
+class PythonCallable : public PythonObject
+{
+public:
+ struct ArgInfo {
+ size_t count;
+ bool has_varargs : 1;
+ bool has_kwargs : 1;
+ };
+
+ PythonCallable();
+ PythonCallable(PyRefType type, PyObject *o);
+ PythonCallable(const PythonCallable &dict);
+
+ ~PythonCallable() override;
+
+ 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;
+
+ ArgInfo
+ GetNumArguments() const;
+
+ PythonObject
+ operator ()();
+
+ PythonObject
+ operator ()(std::initializer_list<PyObject*> args);
+
+ PythonObject
+ operator ()(std::initializer_list<PythonObject> args);
+
+ template<typename Arg, typename... Args>
+ PythonObject
+ operator ()(const Arg &arg, Args... args)
+ {
+ return operator()({ arg, args... });
+ }
+};
+
+
+class PythonFile : public PythonObject
+{
+ public:
+ PythonFile();
+ PythonFile(File &file, const char *mode);
+ PythonFile(const char *path, const char *mode);
+ PythonFile(PyRefType type, PyObject *o);
+
+ ~PythonFile() override;
+
+ static bool Check(PyObject *py_obj);
+
+ using PythonObject::Reset;
+
+ void Reset(PyRefType type, PyObject *py_obj) override;
+ void Reset(File &file, const char *mode);
+
+ bool GetUnderlyingFile(File &file) const;
+};
+
+} // namespace lldb_private
+
+#endif
+
+#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONDATAOBJECTS_H
diff --git a/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp b/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp
new file mode 100644
index 000000000000..2cbd85bfa11e
--- /dev/null
+++ b/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp
@@ -0,0 +1,201 @@
+//===-- PythonExceptionState.cpp --------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_DISABLE_PYTHON
+
+#include "lldb-python.h"
+#include "PythonExceptionState.h"
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace lldb_private;
+
+PythonExceptionState::PythonExceptionState(bool restore_on_exit)
+ : m_restore_on_exit(restore_on_exit)
+{
+ Acquire(restore_on_exit);
+}
+
+PythonExceptionState::~PythonExceptionState()
+{
+ if (m_restore_on_exit)
+ Restore();
+}
+
+void
+PythonExceptionState::Acquire(bool restore_on_exit)
+{
+ // If a state is already acquired, the user needs to decide whether they
+ // want to discard or restore it. Don't allow the potential silent
+ // loss of a valid state.
+ assert(!IsError());
+
+ if (!HasErrorOccurred())
+ return;
+
+ PyObject *py_type = nullptr;
+ PyObject *py_value = nullptr;
+ PyObject *py_traceback = nullptr;
+ PyErr_Fetch(&py_type, &py_value, &py_traceback);
+ // PyErr_Fetch clears the error flag.
+ assert(!HasErrorOccurred());
+
+ // Ownership of the objects returned by `PyErr_Fetch` is transferred
+ // to us.
+ m_type.Reset(PyRefType::Owned, py_type);
+ m_value.Reset(PyRefType::Owned, py_value);
+ m_traceback.Reset(PyRefType::Owned, py_traceback);
+ m_restore_on_exit = restore_on_exit;
+}
+
+void
+PythonExceptionState::Restore()
+{
+ if (m_type.IsValid())
+ {
+ // The documentation for PyErr_Restore says "Do not pass a null type and
+ // non-null value or traceback. So only restore if type was non-null
+ // to begin with. In this case we're passing ownership back to Python
+ // so release them all.
+ PyErr_Restore(m_type.release(), m_value.release(), m_traceback.release());
+ }
+
+ // After we restore, we should not hold onto the exception state. Demand that
+ // it be re-acquired.
+ Discard();
+}
+
+void
+PythonExceptionState::Discard()
+{
+ m_type.Reset();
+ m_value.Reset();
+ m_traceback.Reset();
+}
+
+void
+PythonExceptionState::Reset()
+{
+ if (m_restore_on_exit)
+ Restore();
+ else
+ Discard();
+}
+
+bool
+PythonExceptionState::HasErrorOccurred()
+{
+ return PyErr_Occurred();
+}
+
+bool
+PythonExceptionState::IsError() const
+{
+ return m_type.IsValid() || m_value.IsValid() || m_traceback.IsValid();
+}
+
+PythonObject
+PythonExceptionState::GetType() const
+{
+ return m_type;
+}
+
+PythonObject
+PythonExceptionState::GetValue() const
+{
+ return m_value;
+}
+
+PythonObject
+PythonExceptionState::GetTraceback() const
+{
+ return m_traceback;
+}
+
+std::string
+PythonExceptionState::Format() const
+{
+ // Don't allow this function to modify the error state.
+ PythonExceptionState state(true);
+
+ std::string backtrace = ReadBacktrace();
+ if (!IsError())
+ return std::string();
+
+ // It's possible that ReadPythonBacktrace generated another exception.
+ // If this happens we have to clear the exception, because otherwise
+ // PyObject_Str() will assert below. That's why we needed to do the
+ // save / restore at the beginning of this function.
+ PythonExceptionState bt_error_state(false);
+
+ std::string error_string;
+ llvm::raw_string_ostream error_stream(error_string);
+ error_stream << m_value.Str().GetString() << "\n";
+
+ if (!bt_error_state.IsError())
+ {
+ // If we were able to read the backtrace, just append it.
+ error_stream << backtrace << "\n";
+ }
+ else
+ {
+ // Otherwise, append some information about why we were unable to
+ // obtain the backtrace.
+ PythonString bt_error = bt_error_state.GetValue().Str();
+ error_stream << "An error occurred while retrieving the backtrace: " << bt_error.GetString() << "\n";
+ }
+ return error_stream.str();
+}
+
+std::string
+PythonExceptionState::ReadBacktrace() const
+{
+ std::string retval("backtrace unavailable");
+
+ auto traceback_module = PythonModule::ImportModule("traceback");
+#if PY_MAJOR_VERSION >= 3
+ auto stringIO_module = PythonModule::ImportModule("io");
+#else
+ auto stringIO_module = PythonModule::ImportModule("StringIO");
+#endif
+ if (!m_traceback.IsAllocated())
+ return retval;
+
+ if (!traceback_module.IsAllocated() || !stringIO_module.IsAllocated())
+ return retval;
+
+ auto stringIO_builder = stringIO_module.ResolveName<PythonCallable>("StringIO");
+ if (!stringIO_builder.IsAllocated())
+ return retval;
+
+ auto stringIO_buffer = stringIO_builder();
+ if (!stringIO_buffer.IsAllocated())
+ return retval;
+
+ auto printTB = traceback_module.ResolveName<PythonCallable>("print_tb");
+ if (!printTB.IsAllocated())
+ return retval;
+
+ auto printTB_result = printTB(m_traceback.get(), Py_None, stringIO_buffer.get());
+ auto stringIO_getvalue = stringIO_buffer.ResolveName<PythonCallable>("getvalue");
+ if (!stringIO_getvalue.IsAllocated())
+ return retval;
+
+ auto printTB_string = stringIO_getvalue().AsType<PythonString>();
+ if (!printTB_string.IsAllocated())
+ return retval;
+
+ llvm::StringRef string_data(printTB_string.GetString());
+ retval.assign(string_data.data(), string_data.size());
+
+ return retval;
+}
+
+#endif
diff --git a/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.h b/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.h
new file mode 100644
index 000000000000..c74e52b9ef56
--- /dev/null
+++ b/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.h
@@ -0,0 +1,70 @@
+//===-- PythonExceptionState.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_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONEXCEPTIONSTATE_H
+#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONEXCEPTIONSTATE_H
+
+#ifndef LLDB_DISABLE_PYTHON
+
+#include "PythonDataObjects.h"
+
+namespace lldb_private
+{
+
+class PythonExceptionState
+{
+ public:
+ explicit PythonExceptionState(bool restore_on_exit);
+ ~PythonExceptionState();
+
+ void
+ Acquire(bool restore_on_exit);
+
+ void
+ Restore();
+
+ void
+ Discard();
+
+ void
+ Reset();
+
+ static bool
+ HasErrorOccurred();
+
+ bool
+ IsError() const;
+
+ PythonObject
+ GetType() const;
+
+ PythonObject
+ GetValue() const;
+
+ PythonObject
+ GetTraceback() const;
+
+ std::string
+ Format() const;
+
+ private:
+ std::string
+ ReadBacktrace() const;
+
+ bool m_restore_on_exit;
+
+ PythonObject m_type;
+ PythonObject m_value;
+ PythonObject m_traceback;
+};
+}
+
+#endif
+
+#endif
diff --git a/source/Interpreter/ScriptInterpreterPython.cpp b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index 8f60793550c3..b1dd34b46f69 100644
--- a/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -7,20 +7,21 @@
//
//===----------------------------------------------------------------------===//
-// In order to guarantee correct working with Python, Python.h *MUST* be
-// the *FIRST* header file included here.
#ifdef LLDB_DISABLE_PYTHON
// Python is disabled in this build
#else
-#include "lldb/lldb-python.h"
-#include "lldb/Interpreter/ScriptInterpreterPython.h"
+#include "lldb-python.h"
+#include "ScriptInterpreterPython.h"
+#include "PythonDataObjects.h"
+#include "PythonExceptionState.h"
#include <stdlib.h>
#include <stdio.h>
+#include <mutex>
#include <string>
#include "lldb/API/SBValue.h"
@@ -29,15 +30,16 @@
#include "lldb/Breakpoint/WatchpointOptions.h"
#include "lldb/Core/Communication.h"
#include "lldb/Core/Debugger.h"
+#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Timer.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/Pipe.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Interpreter/PythonDataObjects.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
@@ -46,6 +48,7 @@
#endif
#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/STLExtras.h"
using namespace lldb;
using namespace lldb_private;
@@ -79,8 +82,102 @@ static ScriptInterpreterPython::SWIGPythonCallThreadPlan g_swig_call_thread_plan
static bool g_initialized = false;
-static std::string
-ReadPythonBacktrace (PyObject* py_backtrace);
+namespace
+{
+
+// Initializing Python is not a straightforward process. We cannot control what
+// external code may have done before getting to this point in LLDB, including
+// potentially having already initialized Python, so we need to do a lot of work
+// to ensure that the existing state of the system is maintained across our
+// initialization. We do this by using an RAII pattern where we save off initial
+// state at the beginning, and restore it at the end
+struct InitializePythonRAII
+{
+public:
+ InitializePythonRAII() :
+ m_gil_state(PyGILState_UNLOCKED),
+ m_was_already_initialized(false)
+ {
+ // Python will muck with STDIN terminal state, so save off any current TTY
+ // settings so we can restore them.
+ m_stdin_tty_state.Save(STDIN_FILENO, false);
+
+ InitializePythonHome();
+
+ // Python < 3.2 and Python >= 3.2 reversed the ordering requirements for
+ // calling `Py_Initialize` and `PyEval_InitThreads`. < 3.2 requires that you
+ // call `PyEval_InitThreads` first, and >= 3.2 requires that you call it last.
+#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 2) || (PY_MAJOR_VERSION > 3)
+ Py_InitializeEx(0);
+ InitializeThreadsPrivate();
+#else
+ InitializeThreadsPrivate();
+ Py_InitializeEx(0);
+#endif
+ }
+
+ ~InitializePythonRAII()
+ {
+ if (m_was_already_initialized)
+ {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT | LIBLLDB_LOG_VERBOSE));
+
+ if (log)
+ {
+ log->Printf("Releasing PyGILState. Returning to state = %slocked\n",
+ m_was_already_initialized == PyGILState_UNLOCKED ? "un" : "");
+ }
+ PyGILState_Release(m_gil_state);
+ }
+ else
+ {
+ // We initialized the threads in this function, just unlock the GIL.
+ PyEval_SaveThread();
+ }
+
+ m_stdin_tty_state.Restore();
+ }
+
+private:
+ void InitializePythonHome()
+ {
+#if defined(LLDB_PYTHON_HOME)
+#if PY_MAJOR_VERSION >= 3
+ size_t size = 0;
+ static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+#else
+ static char *g_python_home = LLDB_PYTHON_HOME;
+#endif
+ Py_SetPythonHome(g_python_home);
+#endif
+ }
+
+ void InitializeThreadsPrivate()
+ {
+ if (PyEval_ThreadsInitialized())
+ {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT | LIBLLDB_LOG_VERBOSE));
+
+ m_was_already_initialized = true;
+ m_gil_state = PyGILState_Ensure();
+ if (log)
+ {
+ log->Printf("Ensured PyGILState. Previous state = %slocked\n",
+ m_gil_state == PyGILState_UNLOCKED ? "un" : "");
+ }
+ return;
+ }
+
+ // InitThreads acquires the GIL if it hasn't been called before.
+ PyEval_InitThreads();
+ }
+
+ TerminalState m_stdin_tty_state;
+ PyGILState_STATE m_gil_state;
+ bool m_was_already_initialized;
+};
+
+}
ScriptInterpreterPython::Locker::Locker (ScriptInterpreterPython *py_interpreter,
uint16_t on_entry,
@@ -116,7 +213,7 @@ ScriptInterpreterPython::Locker::DoAcquireLock()
// place outside of Python (e.g. printing to screen, waiting for the network, ...)
// in that case, _PyThreadState_Current will be NULL - and we would be unable
// to set the asynchronous exception - not a desirable situation
- m_python_interpreter->SetThreadState (_PyThreadState_Current);
+ m_python_interpreter->SetThreadState(PyThreadState_Get());
m_python_interpreter->IncrementLockCount();
return true;
}
@@ -156,29 +253,28 @@ ScriptInterpreterPython::Locker::~Locker()
DoFreeLock();
}
-
-ScriptInterpreterPython::ScriptInterpreterPython (CommandInterpreter &interpreter) :
- ScriptInterpreter (interpreter, eScriptLanguagePython),
+ScriptInterpreterPython::ScriptInterpreterPython(CommandInterpreter &interpreter) :
+ ScriptInterpreter(interpreter, eScriptLanguagePython),
IOHandlerDelegateMultiline("DONE"),
- m_saved_stdin (),
- m_saved_stdout (),
- m_saved_stderr (),
- m_main_module (),
- m_lldb_module (),
- m_session_dict (false), // Don't create an empty dictionary, leave it invalid
- m_sys_module_dict (false), // Don't create an empty dictionary, leave it invalid
- m_run_one_line_function (),
- m_run_one_line_str_global (),
- m_dictionary_name (interpreter.GetDebugger().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)
-{
- assert(g_initialized && "ScriptInterpreterPython created but initialize has not been called!");
+ m_saved_stdin(),
+ m_saved_stdout(),
+ m_saved_stderr(),
+ m_main_module(),
+ m_lldb_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_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)
+{
+ assert(g_initialized && "ScriptInterpreterPython created but InitializePrivate has not been called!");
m_dictionary_name.append("_dict");
StreamString run_string;
@@ -190,10 +286,15 @@ ScriptInterpreterPython::ScriptInterpreterPython (CommandInterpreter &interprete
PyRun_SimpleString (run_string.GetData());
run_string.Clear();
-
run_string.Printf ("run_one_line (%s, 'import copy, keyword, os, re, sys, uuid, lldb')", m_dictionary_name.c_str());
PyRun_SimpleString (run_string.GetData());
+ // Reloading modules requires a different syntax in Python 2 and Python 3. This provides
+ // a consistent syntax no matter what version of Python.
+ run_string.Clear();
+ run_string.Printf("run_one_line (%s, 'from six.moves import reload_module')", m_dictionary_name.c_str());
+ PyRun_SimpleString(run_string.GetData());
+
// WARNING: temporary code that loads Cocoa formatters - this should be done on a per-platform basis rather than loading the whole set
// and letting the individual formatter classes exploit APIs to check whether they can/cannot do their task
run_string.Clear();
@@ -212,6 +313,67 @@ ScriptInterpreterPython::ScriptInterpreterPython (CommandInterpreter &interprete
ScriptInterpreterPython::~ScriptInterpreterPython ()
{
+ // 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 thread state, nuke the session dictionary
+ // and then release it for others to use and proceed with the rest of the shutdown
+ auto gil_state = PyGILState_Ensure();
+ m_session_dict.Reset();
+ PyGILState_Release(gil_state);
+}
+
+void
+ScriptInterpreterPython::Initialize()
+{
+ static std::once_flag g_once_flag;
+
+ std::call_once(g_once_flag, []()
+ {
+ InitializePrivate();
+
+ 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";
+}
+
+lldb_private::ConstString
+ScriptInterpreterPython::GetPluginName()
+{
+ return GetPluginNameStatic();
+}
+
+uint32_t
+ScriptInterpreterPython::GetPluginVersion()
+{
+ return 1;
}
void
@@ -361,21 +523,21 @@ ScriptInterpreterPython::LeaveSession ()
if (PyThreadState_GetDict())
{
PythonDictionary &sys_module_dict = GetSysModuleDictionary ();
- if (sys_module_dict)
+ if (sys_module_dict.IsValid())
{
- if (m_saved_stdin)
+ if (m_saved_stdin.IsValid())
{
- sys_module_dict.SetItemForKey("stdin", m_saved_stdin);
+ sys_module_dict.SetItemForKey(PythonString("stdin"), m_saved_stdin);
m_saved_stdin.Reset ();
}
- if (m_saved_stdout)
+ if (m_saved_stdout.IsValid())
{
- sys_module_dict.SetItemForKey("stdout", m_saved_stdout);
+ sys_module_dict.SetItemForKey(PythonString("stdout"), m_saved_stdout);
m_saved_stdout.Reset ();
}
- if (m_saved_stderr)
+ if (m_saved_stderr.IsValid())
{
- sys_module_dict.SetItemForKey("stderr", m_saved_stderr);
+ sys_module_dict.SetItemForKey(PythonString("stderr"), m_saved_stderr);
m_saved_stderr.Reset ();
}
}
@@ -384,13 +546,6 @@ ScriptInterpreterPython::LeaveSession ()
m_session_is_active = false;
}
-static PyObject *
-PyFile_FromFile_Const(FILE *fp, const char *name, const char *mode, int (*close)(FILE *))
-{
- // Read through the Python source, doesn't seem to modify these strings
- return PyFile_FromFile(fp, const_cast<char*>(name), const_cast<char*>(mode), close);
-}
-
bool
ScriptInterpreterPython::EnterSession (uint16_t on_entry_flags,
FILE *in,
@@ -437,12 +592,16 @@ ScriptInterpreterPython::EnterSession (uint16_t on_entry_flags,
run_string.Clear();
PythonDictionary &sys_module_dict = GetSysModuleDictionary ();
- if (sys_module_dict)
+ if (sys_module_dict.IsValid())
{
+ File in_file(in, false);
+ File out_file(out, false);
+ File err_file(err, false);
+
lldb::StreamFileSP in_sp;
lldb::StreamFileSP out_sp;
lldb::StreamFileSP err_sp;
- if (in == nullptr || out == nullptr || err == nullptr)
+ if (!in_file.IsValid() || !out_file.IsValid() || !err_file.IsValid())
m_interpreter.GetDebugger().AdoptTopIOHandlerFilesIfInvalid (in_sp, out_sp, err_sp);
m_saved_stdin.Reset();
@@ -450,40 +609,46 @@ ScriptInterpreterPython::EnterSession (uint16_t on_entry_flags,
if ((on_entry_flags & Locker::NoSTDIN) == 0)
{
// STDIN is enabled
- if (in == nullptr && in_sp)
- in = in_sp->GetFile().GetStream();
- if (in)
+ if (!in_file.IsValid() && in_sp)
+ in_file = in_sp->GetFile();
+ if (in_file.IsValid())
{
- m_saved_stdin.Reset(sys_module_dict.GetItemForKey("stdin"));
+ // Flush the file before giving it to python to avoid interleaved output.
+ in_file.Flush();
+
+ m_saved_stdin = sys_module_dict.GetItemForKey(PythonString("stdin")).AsType<PythonFile>();
// This call can deadlock your process if the file is locked
- PyObject *new_file = PyFile_FromFile_Const (in, "", "r", nullptr);
- sys_module_dict.SetItemForKey ("stdin", new_file);
- Py_DECREF (new_file);
+ PythonFile new_file(in_file, "r");
+ sys_module_dict.SetItemForKey (PythonString("stdin"), new_file);
}
}
- if (out == nullptr && out_sp)
- out = out_sp->GetFile().GetStream();
- if (out)
+ if (!out_file.IsValid() && out_sp)
+ out_file = out_sp->GetFile();
+ if (out_file.IsValid())
{
- m_saved_stdout.Reset(sys_module_dict.GetItemForKey("stdout"));
+ // Flush the file before giving it to python to avoid interleaved output.
+ out_file.Flush();
+
+ m_saved_stdout = sys_module_dict.GetItemForKey(PythonString("stdout")).AsType<PythonFile>();
- PyObject *new_file = PyFile_FromFile_Const (out, "", "w", nullptr);
- sys_module_dict.SetItemForKey ("stdout", new_file);
- Py_DECREF (new_file);
+ PythonFile new_file(out_file, "w");
+ sys_module_dict.SetItemForKey (PythonString("stdout"), new_file);
}
else
m_saved_stdout.Reset();
- if (err == nullptr && err_sp)
- err = err_sp->GetFile().GetStream();
- if (err)
+ if (!err_file.IsValid() && err_sp)
+ err_file = err_sp->GetFile();
+ if (err_file.IsValid())
{
- m_saved_stderr.Reset(sys_module_dict.GetItemForKey("stderr"));
+ // Flush the file before giving it to python to avoid interleaved output.
+ err_file.Flush();
- PyObject *new_file = PyFile_FromFile_Const (err, "", "w", nullptr);
- sys_module_dict.SetItemForKey ("stderr", new_file);
- Py_DECREF (new_file);
+ m_saved_stderr = sys_module_dict.GetItemForKey(PythonString("stderr")).AsType<PythonFile>();
+
+ PythonFile new_file(err_file, "w");
+ sys_module_dict.SetItemForKey (PythonString("stderr"), new_file);
}
else
m_saved_stderr.Reset();
@@ -496,40 +661,41 @@ ScriptInterpreterPython::EnterSession (uint16_t on_entry_flags,
}
PythonObject &
-ScriptInterpreterPython::GetMainModule ()
+ScriptInterpreterPython::GetMainModule()
{
- if (!m_main_module)
- m_main_module.Reset(PyImport_AddModule ("__main__"));
+ if (!m_main_module.IsValid())
+ m_main_module.Reset(PyRefType::Borrowed, PyImport_AddModule("__main__"));
return m_main_module;
}
PythonDictionary &
ScriptInterpreterPython::GetSessionDictionary ()
{
- if (!m_session_dict)
- {
- PythonObject &main_module = GetMainModule ();
- if (main_module)
- {
- PythonDictionary main_dict(PyModule_GetDict (main_module.get()));
- if (main_dict)
- {
- m_session_dict = main_dict.GetItemForKey(m_dictionary_name.c_str());
- }
- }
- }
+ if (m_session_dict.IsValid())
+ return m_session_dict;
+
+ PythonObject &main_module = GetMainModule();
+ if (!main_module.IsValid())
+ return m_session_dict;
+
+ PythonDictionary main_dict(PyRefType::Borrowed, PyModule_GetDict(main_module.get()));
+ if (!main_dict.IsValid())
+ return m_session_dict;
+
+ PythonObject item = main_dict.GetItemForKey(PythonString(m_dictionary_name));
+ m_session_dict.Reset(PyRefType::Borrowed, item.get());
return m_session_dict;
}
PythonDictionary &
ScriptInterpreterPython::GetSysModuleDictionary ()
{
- if (!m_sys_module_dict)
- {
- PyObject *sys_module = PyImport_AddModule ("sys");
- if (sys_module)
- m_sys_module_dict.Reset(PyModule_GetDict (sys_module));
- }
+ if (m_sys_module_dict.IsValid())
+ return m_sys_module_dict;
+
+ PythonObject sys_module(PyRefType::Borrowed, PyImport_AddModule("sys"));
+ if (sys_module.IsValid())
+ m_sys_module_dict.Reset(PyRefType::Borrowed, PyModule_GetDict(sys_module.get()));
return m_sys_module_dict;
}
@@ -554,20 +720,20 @@ GenerateUniqueName (const char* base_name_wanted,
bool
ScriptInterpreterPython::GetEmbeddedInterpreterModuleObjects ()
{
- if (!m_run_one_line_function)
- {
- PyObject *module = PyImport_AddModule ("lldb.embedded_interpreter");
- if (module != nullptr)
- {
- PythonDictionary module_dict (PyModule_GetDict (module));
- if (module_dict)
- {
- m_run_one_line_function = module_dict.GetItemForKey("run_one_line");
- m_run_one_line_str_global = module_dict.GetItemForKey("g_run_one_line_str");
- }
- }
- }
- return (bool)m_run_one_line_function;
+ if (m_run_one_line_function.IsValid())
+ return true;
+
+ PythonObject module(PyRefType::Borrowed, PyImport_AddModule ("lldb.embedded_interpreter"));
+ if (!module.IsValid())
+ return false;
+
+ PythonDictionary module_dict(PyRefType::Borrowed, PyModule_GetDict(module.get()));
+ if (!module_dict.IsValid())
+ return false;
+
+ m_run_one_line_function = module_dict.GetItemForKey(PythonString("run_one_line"));
+ m_run_one_line_str_global = module_dict.GetItemForKey(PythonString("g_run_one_line_str"));
+ return m_run_one_line_function.IsValid();
}
static void
@@ -641,58 +807,64 @@ ScriptInterpreterPython::ExecuteOneLine (const char *command, CommandReturnObjec
else
{
input_file_sp.reset (new StreamFile ());
- input_file_sp->GetFile().Open("/dev/null", File::eOpenOptionRead);
+ input_file_sp->GetFile().Open(FileSystem::DEV_NULL, File::eOpenOptionRead);
output_file_sp.reset (new StreamFile ());
- output_file_sp->GetFile().Open("/dev/null", File::eOpenOptionWrite);
+ output_file_sp->GetFile().Open(FileSystem::DEV_NULL, File::eOpenOptionWrite);
error_file_sp = output_file_sp;
}
FILE *in_file = input_file_sp->GetFile().GetStream();
FILE *out_file = output_file_sp->GetFile().GetStream();
FILE *err_file = error_file_sp->GetFile().GetStream();
- Locker locker(this,
- ScriptInterpreterPython::Locker::AcquireLock |
- ScriptInterpreterPython::Locker::InitSession |
- (options.GetSetLLDBGlobals() ? ScriptInterpreterPython::Locker::InitGlobals : 0) |
- ((result && result->GetInteractive()) ? 0: Locker::NoSTDIN),
- ScriptInterpreterPython::Locker::FreeAcquiredLock |
- ScriptInterpreterPython::Locker::TearDownSession,
- in_file,
- out_file,
- err_file);
-
bool success = false;
-
- // Find the correct script interpreter dictionary in the main module.
- PythonDictionary &session_dict = GetSessionDictionary ();
- if (session_dict)
{
- if (GetEmbeddedInterpreterModuleObjects ())
+ // WARNING! It's imperative that this RAII scope be as tight as possible. In particular, the
+ // scope must end *before* we try to join the read thread. The reason for this is that a
+ // pre-requisite for joining the read thread is that we close the write handle (to break the
+ // pipe and cause it to wake up and exit). But acquiring the GIL as below will redirect Python's
+ // stdio to use this same handle. If we close the handle while Python is still using it, bad
+ // things will happen.
+ Locker locker(this,
+ ScriptInterpreterPython::Locker::AcquireLock |
+ ScriptInterpreterPython::Locker::InitSession |
+ (options.GetSetLLDBGlobals() ? ScriptInterpreterPython::Locker::InitGlobals : 0) |
+ ((result && result->GetInteractive()) ? 0: Locker::NoSTDIN),
+ ScriptInterpreterPython::Locker::FreeAcquiredLock |
+ ScriptInterpreterPython::Locker::TearDownSession,
+ in_file,
+ out_file,
+ err_file);
+
+ // Find the correct script interpreter dictionary in the main module.
+ PythonDictionary &session_dict = GetSessionDictionary ();
+ if (session_dict.IsValid())
{
- PyObject *pfunc = m_run_one_line_function.get();
-
- if (pfunc && PyCallable_Check (pfunc))
+ if (GetEmbeddedInterpreterModuleObjects ())
{
- PythonObject pargs (Py_BuildValue("(Os)", session_dict.get(), command));
- if (pargs)
+ if (PyCallable_Check(m_run_one_line_function.get()))
{
- PythonObject return_value(PyObject_CallObject (pfunc, pargs.get()));
- if (return_value)
- success = true;
- else if (options.GetMaskoutErrors() && PyErr_Occurred ())
+ PythonObject pargs(PyRefType::Owned, Py_BuildValue("(Os)", session_dict.get(), command));
+ if (pargs.IsValid())
{
- PyErr_Print();
- PyErr_Clear();
+ PythonObject return_value(PyRefType::Owned,
+ PyObject_CallObject(m_run_one_line_function.get(), pargs.get()));
+ if (return_value.IsValid())
+ success = true;
+ else if (options.GetMaskoutErrors() && PyErr_Occurred ())
+ {
+ PyErr_Print();
+ PyErr_Clear();
+ }
}
}
}
}
- }
- // Flush our output and error file handles
- ::fflush (out_file);
- if (out_file != err_file)
- ::fflush (err_file);
+ // Flush our output and error file handles
+ ::fflush (out_file);
+ if (out_file != err_file)
+ ::fflush (err_file);
+ }
if (join_read_thread)
{
@@ -847,13 +1019,13 @@ ScriptInterpreterPython::Interrupt()
if (IsExecutingPython())
{
- PyThreadState* state = _PyThreadState_Current;
+ PyThreadState *state = PyThreadState_Get();
if (!state)
state = GetThreadState();
if (state)
{
long tid = state->thread_id;
- _PyThreadState_Current = state;
+ PyThreadState_Swap(state);
int num_threads = PyThreadState_SetAsyncExc(tid, PyExc_KeyboardInterrupt);
if (log)
log->Printf("ScriptInterpreterPython::Interrupt() sending PyExc_KeyboardInterrupt (tid = %li, num_threads = %i)...", tid, num_threads);
@@ -876,139 +1048,140 @@ ScriptInterpreterPython::ExecuteOneLineWithReturn (const char *in_string,
ScriptInterpreterPython::Locker::AcquireLock | ScriptInterpreterPython::Locker::InitSession | (options.GetSetLLDBGlobals() ? ScriptInterpreterPython::Locker::InitGlobals : 0) | Locker::NoSTDIN,
ScriptInterpreterPython::Locker::FreeAcquiredLock | ScriptInterpreterPython::Locker::TearDownSession);
- PyObject *py_return = nullptr;
- PythonObject &main_module = GetMainModule ();
- PythonDictionary globals (PyModule_GetDict(main_module.get()));
- PyObject *py_error = nullptr;
+ PythonObject py_return;
+ PythonObject &main_module = GetMainModule();
+ PythonDictionary globals(PyRefType::Borrowed, PyModule_GetDict(main_module.get()));
+ PythonObject py_error;
bool ret_success = false;
int success;
PythonDictionary locals = GetSessionDictionary ();
- if (!locals)
+ if (!locals.IsValid())
{
- locals = PyObject_GetAttrString (globals.get(), m_dictionary_name.c_str());
+ locals.Reset(PyRefType::Owned, PyObject_GetAttrString(globals.get(), m_dictionary_name.c_str()));
}
- if (!locals)
+ if (!locals.IsValid())
locals = globals;
- py_error = PyErr_Occurred();
- if (py_error != nullptr)
+ py_error.Reset(PyRefType::Borrowed, PyErr_Occurred());
+ if (py_error.IsValid())
PyErr_Clear();
if (in_string != nullptr)
{
{ // scope for PythonInputReaderManager
//PythonInputReaderManager py_input(options.GetEnableIO() ? this : NULL);
- py_return = PyRun_String (in_string, Py_eval_input, globals.get(), locals.get());
- if (py_return == nullptr)
- {
- py_error = PyErr_Occurred ();
- if (py_error != nullptr)
- PyErr_Clear ();
-
- py_return = PyRun_String (in_string, Py_single_input, globals.get(), locals.get());
+ py_return.Reset(PyRefType::Owned, PyRun_String(in_string, Py_eval_input, globals.get(), locals.get()));
+ if (!py_return.IsValid())
+ {
+ py_error.Reset(PyRefType::Borrowed, PyErr_Occurred());
+ if (py_error.IsValid())
+ PyErr_Clear();
+
+ py_return.Reset(PyRefType::Owned, PyRun_String(in_string, Py_single_input, globals.get(), locals.get()));
}
}
- if (py_return != nullptr)
+ if (py_return.IsValid())
{
switch (return_type)
{
case eScriptReturnTypeCharPtr: // "char *"
{
const char format[3] = "s#";
- success = PyArg_Parse (py_return, format, (char **) ret_value);
+ success = PyArg_Parse (py_return.get(), format, (char **) ret_value);
break;
}
case eScriptReturnTypeCharStrOrNone: // char* or NULL if py_return == Py_None
{
const char format[3] = "z";
- success = PyArg_Parse (py_return, format, (char **) ret_value);
+ success = PyArg_Parse (py_return.get(), format, (char **) ret_value);
break;
}
case eScriptReturnTypeBool:
{
const char format[2] = "b";
- success = PyArg_Parse (py_return, format, (bool *) ret_value);
+ success = PyArg_Parse (py_return.get(), format, (bool *) ret_value);
break;
}
case eScriptReturnTypeShortInt:
{
const char format[2] = "h";
- success = PyArg_Parse (py_return, format, (short *) ret_value);
+ success = PyArg_Parse (py_return.get(), format, (short *) ret_value);
break;
}
case eScriptReturnTypeShortIntUnsigned:
{
const char format[2] = "H";
- success = PyArg_Parse (py_return, format, (unsigned short *) ret_value);
+ success = PyArg_Parse (py_return.get(), format, (unsigned short *) ret_value);
break;
}
case eScriptReturnTypeInt:
{
const char format[2] = "i";
- success = PyArg_Parse (py_return, format, (int *) ret_value);
+ success = PyArg_Parse (py_return.get(), format, (int *) ret_value);
break;
}
case eScriptReturnTypeIntUnsigned:
{
const char format[2] = "I";
- success = PyArg_Parse (py_return, format, (unsigned int *) ret_value);
+ success = PyArg_Parse (py_return.get(), format, (unsigned int *) ret_value);
break;
}
case eScriptReturnTypeLongInt:
{
const char format[2] = "l";
- success = PyArg_Parse (py_return, format, (long *) ret_value);
+ success = PyArg_Parse (py_return.get(), format, (long *) ret_value);
break;
}
case eScriptReturnTypeLongIntUnsigned:
{
const char format[2] = "k";
- success = PyArg_Parse (py_return, format, (unsigned long *) ret_value);
+ success = PyArg_Parse (py_return.get(), format, (unsigned long *) ret_value);
break;
}
case eScriptReturnTypeLongLong:
{
const char format[2] = "L";
- success = PyArg_Parse (py_return, format, (long long *) ret_value);
+ success = PyArg_Parse (py_return.get(), format, (long long *) ret_value);
break;
}
case eScriptReturnTypeLongLongUnsigned:
{
const char format[2] = "K";
- success = PyArg_Parse (py_return, format, (unsigned long long *) ret_value);
+ success = PyArg_Parse (py_return.get(), format, (unsigned long long *) ret_value);
break;
}
case eScriptReturnTypeFloat:
{
const char format[2] = "f";
- success = PyArg_Parse (py_return, format, (float *) ret_value);
+ success = PyArg_Parse (py_return.get(), format, (float *) ret_value);
break;
}
case eScriptReturnTypeDouble:
{
const char format[2] = "d";
- success = PyArg_Parse (py_return, format, (double *) ret_value);
+ success = PyArg_Parse (py_return.get(), format, (double *) ret_value);
break;
}
case eScriptReturnTypeChar:
{
const char format[2] = "c";
- success = PyArg_Parse (py_return, format, (char *) ret_value);
+ success = PyArg_Parse (py_return.get(), format, (char *) ret_value);
break;
}
case eScriptReturnTypeOpaqueObject:
{
success = true;
- Py_XINCREF(py_return);
- *((PyObject**)ret_value) = py_return;
+ PyObject *saved_value = py_return.get();
+ Py_XINCREF(saved_value);
+ *((PyObject **)ret_value) = saved_value;
break;
}
}
- Py_XDECREF (py_return);
+
if (success)
ret_success = true;
else
@@ -1016,13 +1189,13 @@ ScriptInterpreterPython::ExecuteOneLineWithReturn (const char *in_string,
}
}
- py_error = PyErr_Occurred();
- if (py_error != nullptr)
+ py_error.Reset(PyRefType::Borrowed, PyErr_Occurred());
+ if (py_error.IsValid())
{
ret_success = false;
if (options.GetMaskoutErrors())
{
- if (PyErr_GivenExceptionMatches (py_error, PyExc_SyntaxError))
+ if (PyErr_GivenExceptionMatches (py_error.get(), PyExc_SyntaxError))
PyErr_Print ();
PyErr_Clear();
}
@@ -1041,68 +1214,45 @@ ScriptInterpreterPython::ExecuteMultipleLines (const char *in_string, const Exec
ScriptInterpreterPython::Locker::FreeAcquiredLock | ScriptInterpreterPython::Locker::TearDownSession);
PythonObject return_value;
- PythonObject &main_module = GetMainModule ();
- PythonDictionary globals (PyModule_GetDict(main_module.get()));
- PyObject *py_error = nullptr;
+ PythonObject &main_module = GetMainModule();
+ PythonDictionary globals(PyRefType::Borrowed, PyModule_GetDict(main_module.get()));
+ PythonObject py_error;
- PythonDictionary locals = GetSessionDictionary ();
-
- if (!locals)
- {
- locals = PyObject_GetAttrString (globals.get(), m_dictionary_name.c_str());
- }
+ PythonDictionary locals = GetSessionDictionary();
- if (!locals)
- {
+ if (!locals.IsValid())
+ locals.Reset(PyRefType::Owned, PyObject_GetAttrString(globals.get(), m_dictionary_name.c_str()));
+
+ if (!locals.IsValid())
locals = globals;
- }
- py_error = PyErr_Occurred();
- if (py_error != nullptr)
+ py_error.Reset(PyRefType::Borrowed, PyErr_Occurred());
+ if (py_error.IsValid())
PyErr_Clear();
if (in_string != nullptr)
{
- struct _node *compiled_node = PyParser_SimpleParseString (in_string, Py_file_input);
- if (compiled_node)
- {
- PyCodeObject *compiled_code = PyNode_Compile (compiled_node, "temp.py");
- if (compiled_code)
- {
- return_value.Reset(PyEval_EvalCode (compiled_code, globals.get(), locals.get()));
- }
- }
- }
+ PythonObject code_object;
+ code_object.Reset(PyRefType::Owned, Py_CompileString(in_string, "temp.py", Py_file_input));
- py_error = PyErr_Occurred ();
- if (py_error != nullptr)
- {
-// puts(in_string);
-// _PyObject_Dump (py_error);
-// PyErr_Print();
-// success = false;
-
- PyObject *type = nullptr;
- PyObject *value = nullptr;
- PyObject *traceback = nullptr;
- PyErr_Fetch (&type,&value,&traceback);
-
- // get the backtrace
- std::string bt = ReadPythonBacktrace(traceback);
-
- if (value && value != Py_None)
- error.SetErrorStringWithFormat("%s\n%s", PyString_AsString(PyObject_Str(value)),bt.c_str());
- else
- error.SetErrorStringWithFormat("%s",bt.c_str());
- Py_XDECREF(type);
- Py_XDECREF(value);
- Py_XDECREF(traceback);
- if (options.GetMaskoutErrors())
+ if (code_object.IsValid())
{
- PyErr_Clear();
+ // In Python 2.x, PyEval_EvalCode takes a PyCodeObject, but in Python 3.x, it takes
+ // a PyObject. They are convertible (hence the function PyCode_Check(PyObject*), so
+ // we have to do the cast for Python 2.x
+#if PY_MAJOR_VERSION >= 3
+ PyObject *py_code_obj = code_object.get();
+#else
+ PyCodeObject *py_code_obj = reinterpret_cast<PyCodeObject *>(code_object.get());
+#endif
+ return_value.Reset(PyRefType::Owned, PyEval_EvalCode(py_code_obj, globals.get(), locals.get()));
}
}
+ PythonExceptionState exception_state(!options.GetMaskoutErrors());
+ if (exception_state.IsError())
+ error.SetErrorString(exception_state.Format().c_str());
+
return error;
}
@@ -1372,53 +1522,42 @@ ScriptInterpreterPython::OSPlugin_RegisterInfo(StructuredData::ObjectSP os_plugi
if (!generic)
return nullptr;
- PyObject *implementor = (PyObject *)generic->GetValue();
+ PythonObject implementor(PyRefType::Borrowed, (PyObject *)generic->GetValue());
- if (implementor == nullptr || implementor == Py_None)
+ if (!implementor.IsAllocated())
return StructuredData::DictionarySP();
- PyObject* pmeth = PyObject_GetAttrString(implementor, callee_name);
-
+ PythonObject pmeth(PyRefType::Owned, PyObject_GetAttrString(implementor.get(), callee_name));
+
if (PyErr_Occurred())
- {
PyErr_Clear();
- }
-
- if (pmeth == nullptr || pmeth == Py_None)
- {
- Py_XDECREF(pmeth);
+
+ if (!pmeth.IsAllocated())
return StructuredData::DictionarySP();
- }
- if (PyCallable_Check(pmeth) == 0)
+ if (PyCallable_Check(pmeth.get()) == 0)
{
if (PyErr_Occurred())
- {
PyErr_Clear();
- }
- Py_XDECREF(pmeth);
return StructuredData::DictionarySP();
}
if (PyErr_Occurred())
- {
PyErr_Clear();
- }
-
- Py_XDECREF(pmeth);
// right now we know this function exists and is callable..
- PyObject* py_return = PyObject_CallMethod(implementor, callee_name, nullptr);
-
+ PythonObject py_return(PyRefType::Owned, PyObject_CallMethod(implementor.get(), callee_name, nullptr));
+
// if it fails, print the error but otherwise go on
if (PyErr_Occurred())
{
PyErr_Print();
PyErr_Clear();
}
+ assert(PythonDictionary::Check(py_return.get()) && "get_register_info returned unknown object type!");
- PythonDictionary result_dict(py_return);
+ PythonDictionary result_dict(PyRefType::Borrowed, py_return.get());
return result_dict.CreateStructuredDictionary();
}
@@ -1437,45 +1576,34 @@ ScriptInterpreterPython::OSPlugin_ThreadsInfo(StructuredData::ObjectSP os_plugin
StructuredData::Generic *generic = os_plugin_object_sp->GetAsGeneric();
if (!generic)
return nullptr;
- PyObject *implementor = (PyObject *)generic->GetValue();
- if (implementor == nullptr || implementor == Py_None)
+ PythonObject implementor(PyRefType::Borrowed, (PyObject *)generic->GetValue());
+
+ if (!implementor.IsAllocated())
return StructuredData::ArraySP();
- PyObject* pmeth = PyObject_GetAttrString(implementor, callee_name);
-
+ PythonObject pmeth(PyRefType::Owned, PyObject_GetAttrString(implementor.get(), callee_name));
+
if (PyErr_Occurred())
- {
PyErr_Clear();
- }
-
- if (pmeth == nullptr || pmeth == Py_None)
- {
- Py_XDECREF(pmeth);
+
+ if (!pmeth.IsAllocated())
return StructuredData::ArraySP();
- }
- if (PyCallable_Check(pmeth) == 0)
+ if (PyCallable_Check(pmeth.get()) == 0)
{
if (PyErr_Occurred())
- {
PyErr_Clear();
- }
- Py_XDECREF(pmeth);
return StructuredData::ArraySP();
}
if (PyErr_Occurred())
- {
PyErr_Clear();
- }
-
- Py_XDECREF(pmeth);
// right now we know this function exists and is callable..
- PyObject* py_return = PyObject_CallMethod(implementor, callee_name, nullptr);
-
+ PythonObject py_return(PyRefType::Owned, PyObject_CallMethod(implementor.get(), callee_name, nullptr));
+
// if it fails, print the error but otherwise go on
if (PyErr_Occurred())
{
@@ -1483,8 +1611,10 @@ ScriptInterpreterPython::OSPlugin_ThreadsInfo(StructuredData::ObjectSP os_plugin
PyErr_Clear();
}
- PythonList ResultList(py_return);
- return ResultList.CreateStructuredArray();
+ assert(PythonList::Check(py_return.get()) && "get_thread_info returned unknown object type!");
+
+ PythonList result_list(PyRefType::Borrowed, py_return.get());
+ return result_list.CreateStructuredArray();
}
// GetPythonValueFormatString provides a system independent type safe way to
@@ -1529,44 +1659,31 @@ ScriptInterpreterPython::OSPlugin_RegisterContextData(StructuredData::ObjectSP o
StructuredData::Generic *generic = os_plugin_object_sp->GetAsGeneric();
if (!generic)
return nullptr;
- PyObject *implementor = (PyObject *)generic->GetValue();
+ PythonObject implementor(PyRefType::Borrowed, (PyObject *)generic->GetValue());
- if (implementor == nullptr || implementor == Py_None)
+ if (!implementor.IsAllocated())
return StructuredData::StringSP();
- PyObject* pmeth = PyObject_GetAttrString(implementor, callee_name);
-
+ PythonObject pmeth(PyRefType::Owned, PyObject_GetAttrString(implementor.get(), callee_name));
+
if (PyErr_Occurred())
- {
PyErr_Clear();
- }
-
- if (pmeth == nullptr || pmeth == Py_None)
- {
- Py_XDECREF(pmeth);
+
+ if (!pmeth.IsAllocated())
return StructuredData::StringSP();
- }
- if (PyCallable_Check(pmeth) == 0)
+ if (PyCallable_Check(pmeth.get()) == 0)
{
if (PyErr_Occurred())
- {
PyErr_Clear();
- }
-
- Py_XDECREF(pmeth);
return StructuredData::StringSP();
}
if (PyErr_Occurred())
- {
PyErr_Clear();
- }
-
- Py_XDECREF(pmeth);
// right now we know this function exists and is callable..
- PyObject* py_return = PyObject_CallMethod(implementor, callee_name, param_format, tid);
+ PythonObject py_return(PyRefType::Owned, PyObject_CallMethod(implementor.get(), callee_name, param_format, tid));
// if it fails, print the error but otherwise go on
if (PyErr_Occurred())
@@ -1574,7 +1691,10 @@ ScriptInterpreterPython::OSPlugin_RegisterContextData(StructuredData::ObjectSP o
PyErr_Print();
PyErr_Clear();
}
- PythonString result_string(py_return);
+
+ assert(PythonString::Check(py_return.get()) && "get_register_data returned unknown object type!");
+
+ PythonString result_string(PyRefType::Borrowed, py_return.get());
return result_string.CreateStructuredString();
}
@@ -1596,45 +1716,33 @@ ScriptInterpreterPython::OSPlugin_CreateThread(StructuredData::ObjectSP os_plugi
StructuredData::Generic *generic = os_plugin_object_sp->GetAsGeneric();
if (!generic)
return nullptr;
- PyObject *implementor = (PyObject *)generic->GetValue();
- if (implementor == nullptr || implementor == Py_None)
+ PythonObject implementor(PyRefType::Borrowed, (PyObject *)generic->GetValue());
+
+ if (!implementor.IsAllocated())
return StructuredData::DictionarySP();
- PyObject* pmeth = PyObject_GetAttrString(implementor, callee_name);
-
+ PythonObject pmeth(PyRefType::Owned, PyObject_GetAttrString(implementor.get(), callee_name));
+
if (PyErr_Occurred())
- {
PyErr_Clear();
- }
-
- if (pmeth == nullptr || pmeth == Py_None)
- {
- Py_XDECREF(pmeth);
+
+ if (!pmeth.IsAllocated())
return StructuredData::DictionarySP();
- }
- if (PyCallable_Check(pmeth) == 0)
+ if (PyCallable_Check(pmeth.get()) == 0)
{
if (PyErr_Occurred())
- {
PyErr_Clear();
- }
-
- Py_XDECREF(pmeth);
return StructuredData::DictionarySP();
}
if (PyErr_Occurred())
- {
PyErr_Clear();
- }
-
- Py_XDECREF(pmeth);
// right now we know this function exists and is callable..
- PyObject* py_return = PyObject_CallMethod(implementor, callee_name, &param_format[0], tid, context);
-
+ PythonObject py_return(PyRefType::Owned, PyObject_CallMethod(implementor.get(), callee_name, &param_format[0], tid, context));
+
// if it fails, print the error but otherwise go on
if (PyErr_Occurred())
{
@@ -1642,7 +1750,9 @@ ScriptInterpreterPython::OSPlugin_CreateThread(StructuredData::ObjectSP os_plugi
PyErr_Clear();
}
- PythonDictionary result_dict(py_return);
+ assert(PythonDictionary::Check(py_return.get()) && "create_thread returned unknown object type!");
+
+ PythonDictionary result_dict(PyRefType::Borrowed, py_return.get());
return result_dict.CreateStructuredDictionary();
}
@@ -1756,16 +1866,15 @@ ScriptInterpreterPython::GetDynamicSettings(StructuredData::ObjectSP plugin_modu
if (!generic)
return StructuredData::DictionarySP();
- PyObject *reply_pyobj = nullptr;
-
+ PythonObject reply_pyobj;
{
Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
TargetSP target_sp(target->shared_from_this());
- reply_pyobj = (PyObject *)g_swig_plugin_get(generic->GetValue(), setting_name, target_sp);
+ reply_pyobj.Reset(PyRefType::Owned,
+ (PyObject *)g_swig_plugin_get(generic->GetValue(), setting_name, target_sp));
}
- PythonDictionary py_dict(reply_pyobj);
-
+ PythonDictionary py_dict(PyRefType::Borrowed, reply_pyobj.get());
return py_dict.CreateStructuredDictionary();
}
@@ -2066,7 +2175,7 @@ ScriptInterpreterPython::WatchpointCallbackFunction
}
size_t
-ScriptInterpreterPython::CalculateNumChildren(const StructuredData::ObjectSP &implementor_sp)
+ScriptInterpreterPython::CalculateNumChildren(const StructuredData::ObjectSP &implementor_sp, uint32_t max)
{
if (!implementor_sp)
return 0;
@@ -2084,7 +2193,7 @@ ScriptInterpreterPython::CalculateNumChildren(const StructuredData::ObjectSP &im
{
Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_calc_children (implementor);
+ ret_val = g_swig_calc_children (implementor, max);
}
return ret_val;
@@ -2244,63 +2353,6 @@ ScriptInterpreterPython::GetSyntheticValue(const StructuredData::ObjectSP &imple
return ret_val;
}
-static std::string
-ReadPythonBacktrace (PyObject* py_backtrace)
-{
- PyObject* traceback_module = nullptr,
- *stringIO_module = nullptr,
- *stringIO_builder = nullptr,
- *stringIO_buffer = nullptr,
- *printTB = nullptr,
- *printTB_args = nullptr,
- *printTB_result = nullptr,
- *stringIO_getvalue = nullptr,
- *printTB_string = nullptr;
-
- std::string retval("backtrace unavailable");
-
- if (py_backtrace && py_backtrace != Py_None)
- {
- traceback_module = PyImport_ImportModule("traceback");
- stringIO_module = PyImport_ImportModule("StringIO");
-
- if (traceback_module && traceback_module != Py_None && stringIO_module && stringIO_module != Py_None)
- {
- stringIO_builder = PyObject_GetAttrString(stringIO_module, "StringIO");
- if (stringIO_builder && stringIO_builder != Py_None)
- {
- stringIO_buffer = PyObject_CallObject(stringIO_builder, nullptr);
- if (stringIO_buffer && stringIO_buffer != Py_None)
- {
- printTB = PyObject_GetAttrString(traceback_module, "print_tb");
- if (printTB && printTB != Py_None)
- {
- printTB_args = Py_BuildValue("OOO",py_backtrace,Py_None,stringIO_buffer);
- printTB_result = PyObject_CallObject(printTB, printTB_args);
- stringIO_getvalue = PyObject_GetAttrString(stringIO_buffer, "getvalue");
- if (stringIO_getvalue && stringIO_getvalue != Py_None)
- {
- printTB_string = PyObject_CallObject (stringIO_getvalue,nullptr);
- if (printTB_string && printTB_string != Py_None && PyString_Check(printTB_string))
- retval.assign(PyString_AsString(printTB_string));
- }
- }
- }
- }
- }
- }
- Py_XDECREF(traceback_module);
- Py_XDECREF(stringIO_module);
- Py_XDECREF(stringIO_builder);
- Py_XDECREF(stringIO_buffer);
- Py_XDECREF(printTB);
- Py_XDECREF(printTB_args);
- Py_XDECREF(printTB_result);
- Py_XDECREF(stringIO_getvalue);
- Py_XDECREF(printTB_string);
- return retval;
-}
-
bool
ScriptInterpreterPython::RunScriptFormatKeyword (const char* impl_function,
Process* process,
@@ -2563,7 +2615,7 @@ ScriptInterpreterPython::LoadScriptingModule(const char *pathname, bool can_relo
// this call will fail if the module was not imported in this Debugger before
command_stream.Clear();
command_stream.Printf("sys.getrefcount(%s)",basename.c_str());
- bool was_imported_locally = !(GetSessionDictionary().GetItemForKey(basename.c_str()).IsNULLOrNone());
+ bool was_imported_locally = GetSessionDictionary().GetItemForKey(PythonString(basename)).IsAllocated();
bool was_imported = (was_imported_globally || was_imported_locally);
@@ -2579,9 +2631,9 @@ ScriptInterpreterPython::LoadScriptingModule(const char *pathname, bool can_relo
if (was_imported)
{
if (!was_imported_locally)
- command_stream.Printf("import %s ; reload(%s)",basename.c_str(),basename.c_str());
+ command_stream.Printf("import %s ; reload_module(%s)",basename.c_str(),basename.c_str());
else
- command_stream.Printf("reload(%s)",basename.c_str());
+ command_stream.Printf("reload_module(%s)",basename.c_str());
}
else
command_stream.Printf("import %s",basename.c_str());
@@ -2817,63 +2869,47 @@ ScriptInterpreterPython::GetShortHelpForCommandObject (StructuredData::GenericSP
if (!cmd_obj_sp)
return false;
-
- PyObject* implementor = (PyObject*)cmd_obj_sp->GetValue();
-
- if (implementor == nullptr || implementor == Py_None)
+
+ PythonObject implementor(PyRefType::Borrowed, (PyObject *)cmd_obj_sp->GetValue());
+
+ if (!implementor.IsAllocated())
return false;
-
- PyObject* pmeth = PyObject_GetAttrString(implementor, callee_name);
-
+
+ PythonObject pmeth(PyRefType::Owned, PyObject_GetAttrString(implementor.get(), callee_name));
+
if (PyErr_Occurred())
- {
PyErr_Clear();
- }
-
- if (pmeth == nullptr || pmeth == Py_None)
- {
- Py_XDECREF(pmeth);
+
+ if (!pmeth.IsAllocated())
return false;
- }
- if (PyCallable_Check(pmeth) == 0)
+ if (PyCallable_Check(pmeth.get()) == 0)
{
if (PyErr_Occurred())
- {
PyErr_Clear();
- }
-
- Py_XDECREF(pmeth);
return false;
}
if (PyErr_Occurred())
- {
PyErr_Clear();
- }
-
- Py_XDECREF(pmeth);
// right now we know this function exists and is callable..
- PyObject* py_return = PyObject_CallMethod(implementor, callee_name, nullptr);
-
+ PythonObject py_return(PyRefType::Owned, PyObject_CallMethod(implementor.get(), callee_name, nullptr));
+
// if it fails, print the error but otherwise go on
if (PyErr_Occurred())
{
PyErr_Print();
PyErr_Clear();
}
-
- if (py_return != nullptr && py_return != Py_None)
+
+ if (py_return.IsAllocated() && PythonString::Check(py_return.get()))
{
- if (PyString_Check(py_return))
- {
- dest.assign(PyString_AsString(py_return));
- got_string = true;
- }
+ PythonString py_string(PyRefType::Borrowed, py_return.get());
+ llvm::StringRef return_data(py_string.GetString());
+ dest.assign(return_data.data(), return_data.size());
+ got_string = true;
}
- Py_XDECREF(py_return);
-
return got_string;
}
@@ -2890,61 +2926,45 @@ ScriptInterpreterPython::GetFlagsForCommandObject (StructuredData::GenericSP cmd
if (!cmd_obj_sp)
return result;
-
- PyObject* implementor = (PyObject*)cmd_obj_sp->GetValue();
-
- if (implementor == nullptr || implementor == Py_None)
+
+ PythonObject implementor(PyRefType::Borrowed, (PyObject *)cmd_obj_sp->GetValue());
+
+ if (!implementor.IsAllocated())
return result;
-
- PyObject* pmeth = PyObject_GetAttrString(implementor, callee_name);
-
+
+ PythonObject pmeth(PyRefType::Owned, PyObject_GetAttrString(implementor.get(), callee_name));
+
if (PyErr_Occurred())
- {
PyErr_Clear();
- }
-
- if (pmeth == nullptr || pmeth == Py_None)
- {
- Py_XDECREF(pmeth);
+
+ if (!pmeth.IsAllocated())
return result;
- }
- if (PyCallable_Check(pmeth) == 0)
+ if (PyCallable_Check(pmeth.get()) == 0)
{
if (PyErr_Occurred())
- {
PyErr_Clear();
- }
-
- Py_XDECREF(pmeth);
return result;
}
if (PyErr_Occurred())
- {
PyErr_Clear();
- }
-
- Py_XDECREF(pmeth);
// right now we know this function exists and is callable..
- PyObject* py_return = PyObject_CallMethod(implementor, callee_name, nullptr);
-
+ PythonObject py_return(PyRefType::Owned, PyObject_CallMethod(implementor.get(), callee_name, nullptr));
+
// if it fails, print the error but otherwise go on
if (PyErr_Occurred())
{
PyErr_Print();
PyErr_Clear();
}
-
- if (py_return != nullptr && py_return != Py_None)
+
+ if (py_return.IsAllocated() && PythonInteger::Check(py_return.get()))
{
- if (PyInt_Check(py_return))
- result = (uint32_t)PyInt_AsLong(py_return);
- else if (PyLong_Check(py_return))
- result = (uint32_t)PyLong_AsLong(py_return);
+ PythonInteger int_value(PyRefType::Borrowed, py_return.get());
+ result = int_value.GetInteger();
}
- Py_XDECREF(py_return);
return result;
}
@@ -2964,62 +2984,48 @@ ScriptInterpreterPython::GetLongHelpForCommandObject (StructuredData::GenericSP
if (!cmd_obj_sp)
return false;
-
- PyObject* implementor = (PyObject*)cmd_obj_sp->GetValue();
-
- if (implementor == nullptr || implementor == Py_None)
+
+ PythonObject implementor(PyRefType::Borrowed, (PyObject *)cmd_obj_sp->GetValue());
+
+ if (!implementor.IsAllocated())
return false;
-
- PyObject* pmeth = PyObject_GetAttrString(implementor, callee_name);
-
+
+ PythonObject pmeth(PyRefType::Owned, PyObject_GetAttrString(implementor.get(), callee_name));
+
if (PyErr_Occurred())
- {
PyErr_Clear();
- }
-
- if (pmeth == nullptr || pmeth == Py_None)
- {
- Py_XDECREF(pmeth);
+
+ if (!pmeth.IsAllocated())
return false;
- }
- if (PyCallable_Check(pmeth) == 0)
+ if (PyCallable_Check(pmeth.get()) == 0)
{
if (PyErr_Occurred())
- {
PyErr_Clear();
- }
- Py_XDECREF(pmeth);
return false;
}
if (PyErr_Occurred())
- {
PyErr_Clear();
- }
-
- Py_XDECREF(pmeth);
// right now we know this function exists and is callable..
- PyObject* py_return = PyObject_CallMethod(implementor, callee_name, nullptr);
-
+ PythonObject py_return(PyRefType::Owned, PyObject_CallMethod(implementor.get(), callee_name, nullptr));
+
// if it fails, print the error but otherwise go on
if (PyErr_Occurred())
{
PyErr_Print();
PyErr_Clear();
}
-
- if (py_return != nullptr && py_return != Py_None)
+
+ if (py_return.IsAllocated() && PythonString::Check(py_return.get()))
{
- if (PyString_Check(py_return))
- {
- dest.assign(PyString_AsString(py_return));
- got_string = true;
- }
+ PythonString str(PyRefType::Borrowed, py_return.get());
+ llvm::StringRef str_data(str.GetString());
+ dest.assign(str_data.data(), str_data.size());
+ got_string = true;
}
- Py_XDECREF(py_return);
return got_string;
}
@@ -3097,27 +3103,10 @@ ScriptInterpreterPython::InitializePrivate ()
Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
- // Python will muck with STDIN terminal state, so save off any current TTY
- // settings so we can restore them.
- TerminalState stdin_tty_state;
- stdin_tty_state.Save(STDIN_FILENO, false);
-
-#if defined(LLDB_PYTHON_HOME)
- Py_SetPythonHome(LLDB_PYTHON_HOME);
-#endif
- PyGILState_STATE gstate;
- Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SCRIPT | LIBLLDB_LOG_VERBOSE));
- bool threads_already_initialized = false;
- if (PyEval_ThreadsInitialized ()) {
- gstate = PyGILState_Ensure ();
- if (log)
- log->Printf("Ensured PyGILState. Previous state = %slocked\n", gstate == PyGILState_UNLOCKED ? "un" : "");
- threads_already_initialized = true;
- } else {
- // InitThreads acquires the GIL if it hasn't been called before.
- PyEval_InitThreads ();
- }
- Py_InitializeEx (0);
+ // RAII-based initialization which correctly handles multiple-initialization, version-
+ // specific differences among Python 2 and Python 3, and saving and restoring various
+ // other pieces of state that can get mucked with during initialization.
+ InitializePythonRAII initialize_guard;
if (g_swig_init_callback)
g_swig_init_callback ();
@@ -3138,17 +3127,6 @@ ScriptInterpreterPython::InitializePrivate ()
AddToSysPath(AddLocation::Beginning, file_spec.GetPath(false));
PyRun_SimpleString ("sys.dont_write_bytecode = 1; import lldb.embedded_interpreter; from lldb.embedded_interpreter import run_python_interpreter; from lldb.embedded_interpreter import run_one_line");
-
- if (threads_already_initialized) {
- if (log)
- log->Printf("Releasing PyGILState. Returning to state = %slocked\n", gstate == PyGILState_UNLOCKED ? "un" : "");
- PyGILState_Release (gstate);
- } else {
- // We initialized the threads in this function, just unlock the GIL.
- PyEval_SaveThread();
- }
-
- stdin_tty_state.Restore();
}
void
diff --git a/include/lldb/Interpreter/ScriptInterpreterPython.h b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
index 058058ecccb5..4c6eb3949898 100644
--- a/include/lldb/Interpreter/ScriptInterpreterPython.h
+++ b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
@@ -7,9 +7,8 @@
//
//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_ScriptInterpreterPython_h_
-#define liblldb_ScriptInterpreterPython_h_
+#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H
+#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H
#ifdef LLDB_DISABLE_PYTHON
@@ -17,11 +16,18 @@
#else
-#include "lldb/lldb-python.h"
+// C Includes
+// C++ Includes
+#include <memory>
+#include <string>
+#include <vector>
+
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
+#include "PythonDataObjects.h"
#include "lldb/Core/IOHandler.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
-#include "lldb/Interpreter/PythonDataObjects.h"
#include "lldb/Host/Terminal.h"
class IOHandlerPythonInterpreter;
@@ -33,7 +39,11 @@ class ScriptInterpreterPython :
public IOHandlerDelegateMultiline
{
public:
- typedef void (*SWIGInitCallback) (void);
+#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,
@@ -70,13 +80,20 @@ public:
const char *session_dictionary_name,
const lldb::ProcessSP& process_sp);
- typedef size_t (*SWIGPythonCalculateNumChildren) (void *implementor);
+ 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,
@@ -92,7 +109,6 @@ public:
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);
@@ -101,6 +117,7 @@ public:
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,
@@ -129,7 +146,7 @@ public:
ScriptInterpreterPython (CommandInterpreter &interpreter);
- ~ScriptInterpreterPython ();
+ ~ScriptInterpreterPython() override;
bool
Interrupt() override;
@@ -156,17 +173,17 @@ public:
ExportFunctionDefinitionToInterpreter (StringList &function_def) override;
bool
- GenerateTypeScriptFunction (StringList &input, std::string& output, const void* name_token = NULL) override;
+ GenerateTypeScriptFunction(StringList &input, std::string& output, const void* name_token = nullptr) override;
bool
- GenerateTypeSynthClass (StringList &input, std::string& output, const void* name_token = NULL) override;
+ GenerateTypeSynthClass(StringList &input, std::string& output, const void* name_token = nullptr) override;
bool
- GenerateTypeSynthClass (const char* oneliner, std::string& output, const void* name_token = NULL) override;
+ 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 = NULL) override;
+ GenerateTypeScriptFunction(const char* oneliner, std::string& output, const void* name_token = nullptr) override;
bool
GenerateScriptAliasFunction (StringList &input, std::string& output) override;
@@ -178,7 +195,9 @@ public:
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;
+
lldb::StateType ScriptedThreadPlanGetRunState(StructuredData::ObjectSP implementor_sp, bool &script_error) override;
StructuredData::GenericSP OSPlugin_CreatePluginObject(const char *class_name, lldb::ProcessSP process_sp) override;
@@ -197,7 +216,7 @@ public:
StructuredData::DictionarySP GetDynamicSettings(StructuredData::ObjectSP plugin_module_sp, Target *target, const char *setting_name,
lldb_private::Error &error) override;
- size_t CalculateNumChildren(const StructuredData::ObjectSP &implementor) override;
+ size_t CalculateNumChildren(const StructuredData::ObjectSP &implementor, uint32_t max) override;
lldb::ValueObjectSP GetChildAtIndex(const StructuredData::ObjectSP &implementor, uint32_t idx) override;
@@ -389,7 +408,6 @@ public:
return m_dictionary_name.c_str();
}
-
PyThreadState *
GetThreadState()
{
@@ -412,40 +430,36 @@ public:
void
IOHandlerInputComplete (IOHandler &io_handler, std::string &data) override;
-protected:
-
- bool
- EnterSession (uint16_t on_entry_flags,
- FILE *in,
- FILE *out,
- FILE *err);
+ //------------------------------------------------------------------
+ // Static Functions
+ //------------------------------------------------------------------
+ static void
+ Initialize();
- void
- LeaveSession ();
+ static void
+ Terminate();
- void
- SaveTerminalState (int fd);
-
- void
- RestoreTerminalState ();
+ static lldb::ScriptInterpreterSP
+ CreateInstance(CommandInterpreter &interpreter);
- class SynchronicityHandler
+ static lldb_private::ConstString
+ GetPluginNameStatic();
+
+ static const char *
+ GetPluginDescriptionStatic();
+
+ //------------------------------------------------------------------
+ // PluginInterface protocol
+ //------------------------------------------------------------------
+ lldb_private::ConstString
+ GetPluginName() override;
+
+ uint32_t
+ GetPluginVersion() override;
+
+ class Locker : public ScriptInterpreterLocker
{
- private:
- lldb::DebuggerSP m_debugger_sp;
- ScriptedCommandSynchronicity m_synch_wanted;
- bool m_old_asynch;
public:
- SynchronicityHandler(lldb::DebuggerSP,
- ScriptedCommandSynchronicity);
- ~SynchronicityHandler();
- };
-
-public:
- class Locker : public ScriptInterpreterLocker
- {
- public:
-
enum OnEntry
{
AcquireLock = 0x0001,
@@ -461,17 +475,16 @@ public:
TearDownSession = 0x0004
};
- Locker (ScriptInterpreterPython *py_interpreter = NULL,
- uint16_t on_entry = AcquireLock | InitSession,
- uint16_t on_leave = FreeLock | TearDownSession,
- FILE *in = NULL,
- FILE *out = NULL,
- FILE *err = NULL);
+ 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 ();
+ ~Locker () override;
- private:
-
+ private:
bool
DoAcquireLock ();
@@ -491,8 +504,23 @@ public:
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,
@@ -501,6 +529,21 @@ protected:
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
{
@@ -526,9 +569,9 @@ protected:
eIOHandlerBreakpoint,
eIOHandlerWatchpoint
};
- PythonObject &
- GetMainModule ();
-
+
+ PythonObject &GetMainModule();
+
PythonDictionary &
GetSessionDictionary ();
@@ -537,10 +580,10 @@ protected:
bool
GetEmbeddedInterpreterModuleObjects ();
-
- PythonObject m_saved_stdin;
- PythonObject m_saved_stdout;
- PythonObject m_saved_stderr;
+
+ PythonFile m_saved_stdin;
+ PythonFile m_saved_stdout;
+ PythonFile m_saved_stderr;
PythonObject m_main_module;
PythonObject m_lldb_module;
PythonDictionary m_session_dict;
@@ -556,8 +599,9 @@ protected:
uint32_t m_lock_count;
PyThreadState *m_command_thread_state;
};
+
} // namespace lldb_private
-#endif // #ifdef LLDB_DISABLE_PYTHON
+#endif // LLDB_DISABLE_PYTHON
-#endif // #ifndef liblldb_ScriptInterpreterPython_h_
+#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H
diff --git a/source/Plugins/ScriptInterpreter/Python/lldb-python.h b/source/Plugins/ScriptInterpreter/Python/lldb-python.h
new file mode 100644
index 000000000000..013492c39bf8
--- /dev/null
+++ b/source/Plugins/ScriptInterpreter/Python/lldb-python.h
@@ -0,0 +1,31 @@
+//===-- 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.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H
+#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H
+
+// Python.h needs to be included before any system headers in order to avoid redefinition of macros
+
+#ifdef LLDB_DISABLE_PYTHON
+// Python is disabled in this build
+#else
+#if defined(__linux__)
+// features.h will define _POSIX_C_SOURCE if _GNU_SOURCE is defined. This value
+// may be different from the value that Python defines it to be which results
+// in a warning. Undefine _POSIX_C_SOURCE before including Python.h The same
+// holds for _XOPEN_SOURCE.
+#undef _POSIX_C_SOURCE
+#undef _XOPEN_SOURCE
+#endif
+
+// Include python for non windows machines
+#include <Python.h>
+#endif // LLDB_DISABLE_PYTHON
+
+#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H
diff --git a/source/Plugins/SymbolFile/DWARF/DIERef.cpp b/source/Plugins/SymbolFile/DWARF/DIERef.cpp
new file mode 100644
index 000000000000..c0754a1fdd54
--- /dev/null
+++ b/source/Plugins/SymbolFile/DWARF/DIERef.cpp
@@ -0,0 +1,56 @@
+//===-- DIERef.cpp ----------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "DIERef.h"
+#include "DWARFCompileUnit.h"
+#include "DWARFFormValue.h"
+
+DIERef::DIERef() :
+ cu_offset(DW_INVALID_OFFSET),
+ die_offset(DW_INVALID_OFFSET)
+{}
+
+DIERef::DIERef(dw_offset_t d) :
+ cu_offset(DW_INVALID_OFFSET),
+ die_offset(d)
+{}
+
+DIERef::DIERef(dw_offset_t c, dw_offset_t d) :
+ cu_offset(c),
+ die_offset(d)
+{}
+
+DIERef::DIERef(lldb::user_id_t uid) :
+ cu_offset(uid>>32),
+ die_offset(uid&0xffffffff)
+{}
+
+DIERef::DIERef(const DWARFFormValue& form_value) :
+ cu_offset(DW_INVALID_OFFSET),
+ die_offset(DW_INVALID_OFFSET)
+{
+ if (form_value.IsValid())
+ {
+ const DWARFCompileUnit* 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();
+ }
+}
+
+lldb::user_id_t
+DIERef::GetUID() const
+{
+ return ((lldb::user_id_t)cu_offset) << 32 | die_offset;
+}
diff --git a/source/Plugins/SymbolFile/DWARF/DIERef.h b/source/Plugins/SymbolFile/DWARF/DIERef.h
new file mode 100644
index 000000000000..a5484db6bd6c
--- /dev/null
+++ b/source/Plugins/SymbolFile/DWARF/DIERef.h
@@ -0,0 +1,42 @@
+//===-- DIERef.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_DIERef_h_
+#define SymbolFileDWARF_DIERef_h_
+
+#include "lldb/Core/dwarf.h"
+#include "lldb/lldb-defines.h"
+
+class DWARFFormValue;
+
+struct DIERef
+{
+ DIERef();
+
+ explicit
+ DIERef(dw_offset_t d);
+
+ DIERef(dw_offset_t c, dw_offset_t d);
+
+ explicit
+ DIERef(lldb::user_id_t uid);
+
+ explicit
+ DIERef(const DWARFFormValue& form_value);
+
+ lldb::user_id_t
+ GetUID() const;
+
+ dw_offset_t cu_offset;
+ dw_offset_t die_offset;
+};
+
+typedef std::vector<DIERef> DIEArray;
+
+#endif // SymbolFileDWARF_DIERef_h_
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h b/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
new file mode 100644
index 000000000000..ab20844bfcfd
--- /dev/null
+++ b/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
@@ -0,0 +1,65 @@
+//===-- DWARFASTParser.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_DWARFASTParser_h_
+#define SymbolFileDWARF_DWARFASTParser_h_
+
+#include "DWARFDefines.h"
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Symbol/CompilerDecl.h"
+#include "lldb/Symbol/CompilerDeclContext.h"
+
+class DWARFDIE;
+
+class DWARFASTParser
+{
+public:
+ virtual ~DWARFASTParser() {}
+
+ virtual lldb::TypeSP
+ ParseTypeFromDWARF (const lldb_private::SymbolContext& sc,
+ const DWARFDIE &die,
+ lldb_private::Log *log,
+ bool *type_is_new_ptr) = 0;
+
+ virtual lldb_private::Function *
+ ParseFunctionFromDWARF (const lldb_private::SymbolContext& sc,
+ const DWARFDIE &die) = 0;
+
+ virtual bool
+ CanCompleteType (const lldb_private::CompilerType &compiler_type)
+ {
+ return false;
+ }
+
+ virtual bool
+ CompleteType (const lldb_private::CompilerType &compiler_type)
+ {
+ return false;
+ }
+
+ virtual bool
+ CompleteTypeFromDWARF (const DWARFDIE &die,
+ lldb_private::Type *type,
+ lldb_private::CompilerType &compiler_type) = 0;
+
+ virtual lldb_private::CompilerDecl
+ GetDeclForUIDFromDWARF (const DWARFDIE &die) = 0;
+
+ virtual lldb_private::CompilerDeclContext
+ GetDeclContextForUIDFromDWARF (const DWARFDIE &die) = 0;
+
+ virtual lldb_private::CompilerDeclContext
+ GetDeclContextContainingUIDFromDWARF (const DWARFDIE &die) = 0;
+
+ virtual std::vector<DWARFDIE>
+ GetDIEForDeclContext (lldb_private::CompilerDeclContext decl_context) = 0;
+};
+
+#endif // SymbolFileDWARF_DWARFASTParser_h_
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
new file mode 100644
index 000000000000..68a0285b69df
--- /dev/null
+++ b/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -0,0 +1,4034 @@
+//===-- DWARFASTParserClang.cpp ---------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "DWARFASTParserClang.h"
+#include "DWARFCompileUnit.h"
+#include "DWARFDebugInfo.h"
+#include "DWARFDeclContext.h"
+#include "DWARFDefines.h"
+#include "DWARFDIE.h"
+#include "DWARFDIECollection.h"
+#include "SymbolFileDWARF.h"
+#include "SymbolFileDWARFDebugMap.h"
+#include "UniqueDWARFASTType.h"
+
+#include "lldb/Interpreter/Args.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Core/Value.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Symbol/ClangASTImporter.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"
+#include "lldb/Symbol/TypeList.h"
+#include "lldb/Symbol/TypeMap.h"
+#include "lldb/Target/Language.h"
+#include "Plugins/Language/ObjC/ObjCLanguage.h"
+
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclObjC.h"
+
+#include <map>
+#include <vector>
+
+//#define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN
+
+#ifdef ENABLE_DEBUG_PRINTF
+#include <stdio.h>
+#define DEBUG_PRINTF(fmt, ...) printf(fmt, __VA_ARGS__)
+#else
+#define DEBUG_PRINTF(fmt, ...)
+#endif
+
+
+using namespace lldb;
+using namespace lldb_private;
+DWARFASTParserClang::DWARFASTParserClang (ClangASTContext &ast) :
+ m_ast (ast),
+ m_die_to_decl_ctx (),
+ m_decl_ctx_to_die ()
+{
+}
+
+DWARFASTParserClang::~DWARFASTParserClang ()
+{
+}
+
+
+static AccessType
+DW_ACCESS_to_AccessType (uint32_t dwarf_accessibility)
+{
+ switch (dwarf_accessibility)
+ {
+ case DW_ACCESS_public: return eAccessPublic;
+ case DW_ACCESS_private: return eAccessPrivate;
+ case DW_ACCESS_protected: return eAccessProtected;
+ default: break;
+ }
+ return eAccessNone;
+}
+
+static bool
+DeclKindIsCXXClass (clang::Decl::Kind decl_kind)
+{
+ switch (decl_kind)
+ {
+ case clang::Decl::CXXRecord:
+ case clang::Decl::ClassTemplateSpecialization:
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
+struct BitfieldInfo
+{
+ uint64_t bit_size;
+ uint64_t bit_offset;
+
+ BitfieldInfo () :
+ bit_size (LLDB_INVALID_ADDRESS),
+ bit_offset (LLDB_INVALID_ADDRESS)
+ {
+ }
+
+ void
+ Clear()
+ {
+ bit_size = LLDB_INVALID_ADDRESS;
+ bit_offset = LLDB_INVALID_ADDRESS;
+ }
+
+ bool IsValid ()
+ {
+ return (bit_size != LLDB_INVALID_ADDRESS) &&
+ (bit_offset != LLDB_INVALID_ADDRESS);
+ }
+};
+
+
+ClangASTImporter &
+DWARFASTParserClang::GetClangASTImporter()
+{
+ if (!m_clang_ast_importer_ap)
+ {
+ m_clang_ast_importer_ap.reset (new ClangASTImporter);
+ }
+ return *m_clang_ast_importer_ap;
+}
+
+
+TypeSP
+DWARFASTParserClang::ParseTypeFromDWO (const DWARFDIE &die, Log *log)
+{
+ ModuleSP dwo_module_sp = die.GetContainingDWOModule();
+ if (dwo_module_sp)
+ {
+ // This type comes from an external DWO module
+ std::vector<CompilerContext> dwo_context;
+ die.GetDWOContext(dwo_context);
+ TypeMap dwo_types;
+ if (dwo_module_sp->GetSymbolVendor()->FindTypes(dwo_context, true, dwo_types))
+ {
+ const size_t num_dwo_types = dwo_types.GetSize();
+ if (num_dwo_types == 1)
+ {
+ // 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
+ TypeSP dwo_type_sp = dwo_types.GetTypeAtIndex(0);
+ if (dwo_type_sp)
+ {
+ lldb_private::CompilerType dwo_type = dwo_type_sp->GetForwardCompilerType();
+
+ lldb_private::CompilerType type = GetClangASTImporter().CopyType (m_ast, dwo_type);
+
+ //printf ("copied_qual_type: ast = %p, clang_type = %p, name = '%s'\n", m_ast, copied_qual_type.getAsOpaquePtr(), external_type->GetName().GetCString());
+ if (type)
+ {
+ 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,
+ &dwo_type_sp->GetDeclaration(),
+ type,
+ Type::eResolveStateForward));
+
+ dwarf->GetTypeList()->Insert(type_sp);
+ dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
+ clang::TagDecl *tag_decl = ClangASTContext::GetAsTagDecl(type);
+ if (tag_decl)
+ LinkDeclContextToDIE(tag_decl, die);
+ else
+ {
+ clang::DeclContext *defn_decl_ctx = GetCachedClangDeclContextForDIE(die);
+ if (defn_decl_ctx)
+ LinkDeclContextToDIE(defn_decl_ctx, die);
+ }
+ return type_sp;
+ }
+ }
+ }
+ }
+ }
+ return TypeSP();
+}
+
+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());
+
+ }
+ //
+ // Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
+ // if (log && dwarf_cu)
+ // {
+ // StreamString s;
+ // die->DumpLocation (this, dwarf_cu, s);
+ // dwarf->GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDwarf::%s %s", __FUNCTION__, s.GetData());
+ //
+ // }
+
+ 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;
+
+ const dw_tag_t tag = die.Tag();
+
+ bool is_forward_declaration = false;
+ DWARFAttributes attributes;
+ const char *type_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;
+
+ dw_attr_t attr;
+
+ switch (tag)
+ {
+ case DW_TAG_base_type:
+ case DW_TAG_pointer_type:
+ case DW_TAG_reference_type:
+ case DW_TAG_rvalue_reference_type:
+ case DW_TAG_typedef:
+ 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;
+ lldb::user_id_t encoding_uid = LLDB_INVALID_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();
+ // Work around a bug in llvm-gcc where they give a name to a reference type which doesn't
+ // include the "&"...
+ if (tag == DW_TAG_reference_type)
+ {
+ if (strchr (type_name_cstr, '&') == NULL)
+ type_name_cstr = NULL;
+ }
+ 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 = DIERef(form_value).GetUID(); break;
+ default:
+ case DW_AT_sibling:
+ 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);
+
+ switch (tag)
+ {
+ default:
+ break;
+
+ 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...
+
+ case DW_TAG_base_type:
+ resolve_state = Type::eResolveStateFull;
+ clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize (type_name_cstr,
+ encoding,
+ byte_size * 8);
+ 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;
+ }
+
+ if (!clang_type && (encoding_data_type == Type::eEncodingIsPointerUID || encoding_data_type == Type::eEncodingIsTypedefUID) && sc.comp_unit != NULL)
+ {
+ bool translation_unit_is_objc = (sc.comp_unit->GetLanguage() == eLanguageTypeObjC || sc.comp_unit->GetLanguage() == eLanguageTypeObjC_plus_plus);
+
+ 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 (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 = LLDB_INVALID_UID;
+ resolve_state = Type::eResolveStateFull;
+
+ }
+ 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 = LLDB_INVALID_UID;
+ resolve_state = Type::eResolveStateFull;
+ }
+ else if (type_name_const_str == 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;
+ encoding_uid = LLDB_INVALID_UID;
+ resolve_state = Type::eResolveStateFull;
+ }
+ }
+ else if (encoding_data_type == Type::eEncodingIsPointerUID && encoding_uid != LLDB_INVALID_UID)
+ {
+ // Clang sometimes erroneously emits id as objc_object*. In that case we fix up the type to "id".
+
+ const DWARFDIE encoding_die = die.GetDIE(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 = LLDB_INVALID_UID;
+ resolve_state = Type::eResolveStateFull;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ type_sp.reset( new Type (die.GetID(),
+ dwarf,
+ type_name_const_str,
+ byte_size,
+ NULL,
+ encoding_uid,
+ encoding_data_type,
+ &decl,
+ clang_type,
+ resolve_state));
+
+ dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
+
+ // Type* encoding_type = GetUniquedTypeForDIEOffset(encoding_uid, type_sp, NULL, 0, 0, false);
+ // if (encoding_type != NULL)
+ // {
+ // if (encoding_type != DIE_IS_BEING_PARSED)
+ // type_sp->SetEncodingType(encoding_type);
+ // else
+ // m_indirect_fixups.push_back(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;
+
+ LanguageType class_language = eLanguageTypeUnknown;
+ bool is_complete_objc_class = false;
+ //bool struct_is_class = 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:
+ if (die.GetCU()->DW_AT_decl_file_attributes_are_invalid())
+ {
+ // llvm-gcc outputs invalid DW_AT_decl_file attributes that always
+ // point to the compile unit file, so we clear this invalid value
+ // so that we can still unique types efficiently.
+ decl.SetFile(FileSpec ("<invalid>", false));
+ }
+ else
+ 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_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;
+ }
+ }
+ }
+ }
+
+ // 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());
+
+ if (type_name_const_str)
+ {
+ LanguageType die_language = die.GetLanguage();
+ bool handled = false;
+ if (Language::LanguageIsCPlusPlus(die_language))
+ {
+ std::string qualified_name;
+ if (die.GetQualifiedName(qualified_name))
+ {
+ handled = true;
+ ConstString const_qualified_name(qualified_name);
+ if (dwarf->GetUniqueDWARFASTTypeMap().Find(const_qualified_name, die, Declaration(),
+ 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 (!handled)
+ {
+ if (dwarf->GetUniqueDWARFASTTypeMap().Find(type_name_const_str, die, 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;
+ }
+ }
+ }
+ }
+
+ 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 (byte_size_valid && byte_size == 0 && type_name_cstr &&
+ die.HasChildren() == false &&
+ 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;
+ }
+
+ 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 (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());
+ }
+
+ // 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 (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);
+ }
+
+ // 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 (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());
+ }
+
+ // 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())));
+ 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 (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;
+ }
+
+ 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);
+
+ 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);
+ }
+ }
+
+ 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 = decl;
+ unique_ast_entry_ap->m_byte_size = byte_size;
+ dwarf->GetUniqueDWARFASTTypeMap().Insert (type_name_const_str,
+ *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;
+ }
+ }
+ }
+
+ 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() == false)
+ {
+ // No children for this struct/union/class, lets finish it
+ ClangASTContext::StartTagDeclarationDefinition (clang_type);
+ ClangASTContext::CompleteTagDeclarationDefinition (clang_type);
+
+ if (tag == DW_TAG_structure_type) // this only applies in C
+ {
+ clang::RecordDecl *record_decl = ClangASTContext::GetAsRecordDecl(clang_type);
+
+ if (record_decl)
+ m_record_decl_to_layout_map.insert(std::make_pair(record_decl, 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(ClangASTContext::RemoveFastQualifiers(clang_type).GetOpaqueQualType()) &&
+ "Type already in the forward declaration map!");
+ assert(((SymbolFileDWARF*)m_ast.GetSymbolFile())->UserIDMatches(die.GetDIERef().GetUID()) &&
+ "Adding incorrect type to forward declaration map");
+ dwarf->GetForwardDeclDieToClangType()[die.GetDIE()] = clang_type.GetOpaqueQualType();
+ dwarf->GetForwardDeclClangTypeToDie()[ClangASTContext::RemoveFastQualifiers(clang_type).GetOpaqueQualType()] = die.GetDIERef();
+ m_ast.SetHasExternalStorage (clang_type.GetOpaqueQualType(), true);
+ }
+ }
+ }
+ break;
+
+ 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;
+
+ DWARFFormValue encoding_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_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_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;
+ }
+ }
+ }
+
+ 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);
+ }
+ }
+
+ 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());
+ }
+
+ // 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())));
+ 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).GetUID());
+ if (enumerator_type)
+ enumerator_clang_type = enumerator_type->GetFullCompilerType ();
+ }
+
+ if (!enumerator_clang_type)
+ enumerator_clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize (NULL,
+ DW_ATE_signed,
+ byte_size * 8);
+
+ clang_type = m_ast.CreateEnumerationType (type_name_cstr,
+ GetClangDeclContextContainingDIE (die, nullptr),
+ decl,
+ enumerator_clang_type);
+ }
+ else
+ {
+ enumerator_clang_type = m_ast.GetEnumerationIntegerType (clang_type.GetOpaqueQualType());
+ }
+
+ 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(),
+ Type::eEncodingIsUID,
+ &decl,
+ clang_type,
+ Type::eResolveStateForward));
+
+ 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);
+ }
+ }
+ 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;
+
+ 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;
+ DWARFFormValue specification_die_form;
+ DWARFFormValue abstract_origin_die_form;
+ dw_offset_t object_pointer_die_offset = DW_INVALID_OFFSET;
+
+ 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: break; // mangled = form_value.AsCString(&dwarf->get_debug_str_data()); 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;
+ }
+ }
+ }
+ }
+
+ 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;
+ }
+ }
+
+ DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr);
+
+ CompilerType return_clang_type;
+ Type *func_type = NULL;
+
+ if (type_die_form.IsValid())
+ func_type = dwarf->ResolveTypeUID(DIERef(type_die_form).GetUID());
+
+ if (func_type)
+ return_clang_type = func_type->GetForwardCompilerType ();
+ else
+ return_clang_type = m_ast.GetBasicType(eBasicTypeVoid);
+
+
+ std::vector<CompilerType> function_param_types;
+ std::vector<clang::ParmVarDecl*> function_param_decls;
+
+ // Parse the function children for the parameters
+
+ 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();
+
+ const 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;
+
+ if (die.HasChildren())
+ {
+ bool skip_artificial = true;
+ ParseChildParameters (sc,
+ containing_decl_ctx,
+ die,
+ skip_artificial,
+ is_static,
+ is_variadic,
+ function_param_types,
+ function_param_decls,
+ type_quals);
+ }
+
+ // 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);
+
+ bool ignore_containing_context = false;
+
+ 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 (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);
+ 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"...
+ 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()));
+ }
+ else
+ {
+ class_symfile = dwarf;
+ class_type_die = dwarf->DebugInfo()->GetDIE (DIERef(class_type->GetID()));
+ }
+ 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.
+ 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);
+ }
+ 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() == ClangASTContext::GetQualType(clang_type))
+ {
+ add_method = false;
+ LinkDeclContextToDIE(ClangASTContext::GetAsDeclContext(method_decl), die);
+ type_handled = true;
+
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (add_method)
+ {
+ // REMOVE THE CRASH DESCRIPTION BELOW
+ Host::SetCrashDescriptionWithFormat ("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;
+ cxx_method_decl = m_ast.AddMethodToCXXRecordType (class_opaque_type.GetOpaqueQualType(),
+ type_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);
+
+ Host::SetCrashDescription (NULL);
+
+ 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)
+ {
+ // We just have a function that isn't part of a class
+ clang::FunctionDecl *function_decl = m_ast.CreateFunctionDeclaration (ignore_containing_context ? m_ast.GetTranslationUnitDecl() : containing_decl_ctx,
+ type_name_cstr,
+ clang_type,
+ storage,
+ is_inline);
+
+ // if (template_param_infos.GetSize() > 0)
+ // {
+ // clang::FunctionTemplateDecl *func_template_decl = CreateFunctionTemplateDecl (containing_decl_ctx,
+ // function_decl,
+ // type_name_cstr,
+ // template_param_infos);
+ //
+ // CreateFunctionTemplateSpecializationInfo (function_decl,
+ // func_template_decl,
+ // template_param_infos);
+ // }
+ // Add the decl to our DIE to decl context map
+ assert (function_decl);
+ LinkDeclContextToDIE(function_decl, die);
+ if (!function_param_decls.empty())
+ m_ast.SetFunctionParameters (function_decl,
+ &function_param_decls.front(),
+ function_param_decls.size());
+
+ 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 function object %p.",
+ object_pointer_name.c_str(),
+ static_cast<void*>(function_decl));
+ }
+ m_ast.SetMetadata (function_decl, metadata);
+ }
+ }
+ 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);
+
+ Type *element_type = dwarf->ResolveTypeUID(DIERef(type_die_form).GetUID());
+
+ if (element_type)
+ {
+ std::vector<uint64_t> element_orders;
+ ParseChildArrayInfo(sc, die, first_index, element_orders, byte_stride, bit_stride);
+ if (byte_stride == 0 && bit_stride == 0)
+ byte_stride = element_type->GetByteSize();
+ CompilerType array_element_type = element_type->GetForwardCompilerType ();
+ uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride;
+ if (element_orders.size() > 0)
+ {
+ uint64_t num_elements = 0;
+ std::vector<uint64_t>::const_reverse_iterator pos;
+ std::vector<uint64_t>::const_reverse_iterator end = element_orders.rend();
+ for (pos = 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);
+ }
+ ConstString empty_name;
+ type_sp.reset( new Type (die.GetID(),
+ dwarf,
+ empty_name,
+ array_element_bit_stride / 8,
+ NULL,
+ DIERef(type_die_form).GetUID(),
+ Type::eEncodingIsUID,
+ &decl,
+ clang_type,
+ Type::eResolveStateFull));
+ type_sp->SetEncodingType (element_type);
+ }
+ }
+ }
+ 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).GetUID());
+ Type *class_type = dwarf->ResolveTypeUID(DIERef(containing_type_die_form).GetUID());
+
+ CompilerType pointee_clang_type = pointee_type->GetForwardCompilerType ();
+ CompilerType class_clang_type = class_type->GetLayoutCompilerType ();
+
+ clang_type = ClangASTContext::CreateMemberPointerType(class_clang_type, pointee_clang_type);
+
+ byte_size = clang_type.GetByteSize(nullptr);
+
+ 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));
+ }
+
+ 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)
+ {
+ 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;
+ }
+
+ 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();
+ }
+ }
+ else if (type_ptr != DIE_IS_BEING_PARSED)
+ {
+ type_sp = type_ptr->shared_from_this();
+ }
+ }
+ return type_sp;
+}
+
+// DWARF parsing functions
+
+class DWARFASTParserClang::DelayedAddObjCClassProperty
+{
+public:
+ DelayedAddObjCClassProperty(const CompilerType &class_opaque_type,
+ const char *property_name,
+ const CompilerType &property_opaque_type, // The property type is only required if you don't have an ivar decl
+ clang::ObjCIvarDecl *ivar_decl,
+ const char *property_setter_name,
+ const char *property_getter_name,
+ uint32_t property_attributes,
+ const ClangASTMetadata *metadata) :
+ m_class_opaque_type (class_opaque_type),
+ m_property_name (property_name),
+ m_property_opaque_type (property_opaque_type),
+ m_ivar_decl (ivar_decl),
+ 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;
+ }
+ }
+
+ DelayedAddObjCClassProperty (const DelayedAddObjCClassProperty &rhs)
+ {
+ *this = rhs;
+ }
+
+ DelayedAddObjCClassProperty& operator= (const DelayedAddObjCClassProperty &rhs)
+ {
+ m_class_opaque_type = rhs.m_class_opaque_type;
+ m_property_name = rhs.m_property_name;
+ m_property_opaque_type = rhs.m_property_opaque_type;
+ m_ivar_decl = rhs.m_ivar_decl;
+ m_property_setter_name = rhs.m_property_setter_name;
+ 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;
+ }
+ return *this;
+ }
+
+ bool
+ Finalize()
+ {
+ 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());
+ }
+
+private:
+ CompilerType m_class_opaque_type;
+ const char *m_property_name;
+ CompilerType m_property_opaque_type;
+ clang::ObjCIvarDecl *m_ivar_decl;
+ const char *m_property_setter_name;
+ const char *m_property_getter_name;
+ uint32_t m_property_attributes;
+ std::unique_ptr<ClangASTMetadata> m_metadata_ap;
+};
+
+bool
+DWARFASTParserClang::ParseTemplateDIE (const DWARFDIE &die,
+ ClangASTContext::TemplateParameterInfos &template_param_infos)
+{
+ const dw_tag_t tag = die.Tag();
+
+ switch (tag)
+ {
+ case DW_TAG_template_type_parameter:
+ case DW_TAG_template_value_parameter:
+ {
+ DWARFAttributes attributes;
+ const size_t num_attributes = die.GetAttributes (attributes);
+ const char *name = NULL;
+ Type *lldb_type = NULL;
+ CompilerType clang_type;
+ uint64_t uval64 = 0;
+ bool uval64_valid = false;
+ if (num_attributes > 0)
+ {
+ DWARFFormValue form_value;
+ for (size_t i=0; i<num_attributes; ++i)
+ {
+ const dw_attr_t attr = attributes.AttributeAtIndex(i);
+
+ switch (attr)
+ {
+ case DW_AT_name:
+ if (attributes.ExtractFormValueAtIndex(i, form_value))
+ name = form_value.AsCString();
+ break;
+
+ case DW_AT_type:
+ if (attributes.ExtractFormValueAtIndex(i, form_value))
+ {
+ lldb_type = die.ResolveTypeUID(DIERef(form_value).GetUID());
+ if (lldb_type)
+ clang_type = lldb_type->GetForwardCompilerType ();
+ }
+ break;
+
+ case DW_AT_const_value:
+ if (attributes.ExtractFormValueAtIndex(i, form_value))
+ {
+ uval64_valid = true;
+ uval64 = form_value.Unsigned();
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ clang::ASTContext *ast = m_ast.getASTContext();
+ if (!clang_type)
+ clang_type = m_ast.GetBasicType(eBasicTypeVoid);
+
+ if (clang_type)
+ {
+ bool is_signed = false;
+ if (name && name[0])
+ template_param_infos.names.push_back(name);
+ else
+ template_param_infos.names.push_back(NULL);
+
+ if (tag == DW_TAG_template_value_parameter &&
+ lldb_type != NULL &&
+ clang_type.IsIntegerType (is_signed) &&
+ uval64_valid)
+ {
+ llvm::APInt apint (lldb_type->GetByteSize() * 8, uval64, is_signed);
+ template_param_infos.args.push_back (clang::TemplateArgument (*ast,
+ llvm::APSInt(apint),
+ ClangASTContext::GetQualType(clang_type)));
+ }
+ else
+ {
+ template_param_infos.args.push_back (clang::TemplateArgument (ClangASTContext::GetQualType(clang_type)));
+ }
+ }
+ else
+ {
+ return false;
+ }
+
+ }
+ }
+ return true;
+
+ default:
+ break;
+ }
+ return false;
+}
+
+bool
+DWARFASTParserClang::ParseTemplateParameterInfos (const DWARFDIE &parent_die,
+ ClangASTContext::TemplateParameterInfos &template_param_infos)
+{
+
+ if (!parent_die)
+ return false;
+
+ Args template_parameter_names;
+ for (DWARFDIE die = parent_die.GetFirstChild();
+ die.IsValid();
+ die = die.GetSibling())
+ {
+ const dw_tag_t tag = die.Tag();
+
+ switch (tag)
+ {
+ case DW_TAG_template_type_parameter:
+ case DW_TAG_template_value_parameter:
+ ParseTemplateDIE (die, template_param_infos);
+ break;
+
+ default:
+ break;
+ }
+ }
+ if (template_param_infos.args.empty())
+ return false;
+ return template_param_infos.args.size() == template_param_infos.names.size();
+}
+
+bool
+DWARFASTParserClang::CanCompleteType (const lldb_private::CompilerType &compiler_type)
+{
+ if (m_clang_ast_importer_ap)
+ return ClangASTContext::CanImport(compiler_type, GetClangASTImporter());
+ else
+ return false;
+}
+
+bool
+DWARFASTParserClang::CompleteType (const lldb_private::CompilerType &compiler_type)
+{
+ if (CanCompleteType(compiler_type))
+ {
+ if (ClangASTContext::Import(compiler_type, GetClangASTImporter()))
+ {
+ ClangASTContext::CompleteTagDeclarationDefinition(compiler_type);
+ return true;
+ }
+ else
+ {
+ ClangASTContext::SetHasExternalStorage (compiler_type.GetOpaqueQualType(), false);
+ }
+ }
+ return false;
+}
+
+bool
+DWARFASTParserClang::CompleteTypeFromDWARF (const DWARFDIE &die,
+ lldb_private::Type *type,
+ CompilerType &clang_type)
+{
+ // Disable external storage for this type so we don't get anymore
+ // clang::ExternalASTSource queries for this type.
+ m_ast.SetHasExternalStorage (clang_type.GetOpaqueQualType(), false);
+
+ if (!die)
+ return false;
+
+ const dw_tag_t tag = die.Tag();
+
+ SymbolFileDWARF *dwarf = die.GetDWARF();
+
+ Log *log = nullptr; // (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO|DWARF_LOG_TYPE_COMPLETION));
+ if (log)
+ dwarf->GetObjectFile()->GetModule()->LogMessageVerboseBacktrace (log,
+ "0x%8.8" PRIx64 ": %s '%s' resolving forward declaration...",
+ die.GetID(),
+ die.GetTagAsCString(),
+ type->GetName().AsCString());
+ assert (clang_type);
+ DWARFAttributes attributes;
+ switch (tag)
+ {
+ case DW_TAG_structure_type:
+ case DW_TAG_union_type:
+ case DW_TAG_class_type:
+ {
+ LayoutInfo layout_info;
+
+ {
+ if (die.HasChildren())
+ {
+ LanguageType class_language = eLanguageTypeUnknown;
+ if (ClangASTContext::IsObjCObjectOrInterfaceType(clang_type))
+ {
+ class_language = eLanguageTypeObjC;
+ // For objective C we don't start the definition when
+ // the class is created.
+ ClangASTContext::StartTagDeclarationDefinition (clang_type);
+ }
+
+ 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;
+ }
+
+ SymbolContext sc(die.GetLLDBCompileUnit());
+ std::vector<clang::CXXBaseSpecifier *> base_classes;
+ std::vector<int> member_accessibilities;
+ bool is_a_class = false;
+ // Parse members and base classes first
+ DWARFDIECollection member_function_dies;
+
+ DelayedPropertyList delayed_properties;
+ ParseChildMembers (sc,
+ die,
+ clang_type,
+ class_language,
+ base_classes,
+ 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));
+ }
+ }
+
+ if (class_language == eLanguageTypeObjC)
+ {
+ ConstString class_name (clang_type.GetTypeName());
+ if (class_name)
+ {
+ DIEArray method_die_offsets;
+ dwarf->GetObjCMethodDIEOffsets(class_name, method_die_offsets);
+
+ if (!method_die_offsets.empty())
+ {
+ DWARFDebugInfo* debug_info = dwarf->DebugInfo();
+
+ const size_t num_matches = method_die_offsets.size();
+ for (size_t i=0; i<num_matches; ++i)
+ {
+ const DIERef& die_ref = method_die_offsets[i];
+ DWARFDIE method_die = debug_info->GetDIE (die_ref);
+
+ if (method_die)
+ method_die.ResolveType ();
+ }
+ }
+
+ for (DelayedPropertyList::iterator pi = delayed_properties.begin(), pe = delayed_properties.end();
+ pi != pe;
+ ++pi)
+ pi->Finalize();
+ }
+ }
+
+ // If we have a DW_TAG_structure_type instead of a DW_TAG_class_type we
+ // need to tell the clang type it is actually a class.
+ if (class_language != eLanguageTypeObjC)
+ {
+ if (is_a_class && tag_decl_kind != clang::TTK_Class)
+ m_ast.SetTagTypeKind (ClangASTContext::GetQualType(clang_type), clang::TTK_Class);
+ }
+
+ // Since DW_TAG_structure_type gets used for both classes
+ // and structures, we may need to set any DW_TAG_member
+ // fields to have a "private" access if none was specified.
+ // When we parsed the child members we tracked that actual
+ // accessibility value for each DW_TAG_member in the
+ // "member_accessibilities" array. If the value for the
+ // member is zero, then it was set to the "default_accessibility"
+ // which for structs was "public". Below we correct this
+ // by setting any fields to "private" that weren't correctly
+ // set.
+ if (is_a_class && !member_accessibilities.empty())
+ {
+ // This is a class and all members that didn't have
+ // their access specified are private.
+ m_ast.SetDefaultAccessForRecordFields (m_ast.GetAsRecordDecl(clang_type),
+ eAccessPrivate,
+ &member_accessibilities.front(),
+ member_accessibilities.size());
+ }
+
+ if (!base_classes.empty())
+ {
+ // Make sure all base classes refer to complete types and not
+ // forward declarations. If we don't do this, clang will crash
+ // with an assertion in the call to clang_type.SetBaseClassesForClassType()
+ for (auto &base_class : base_classes)
+ {
+ clang::TypeSourceInfo *type_source_info = base_class->getTypeSourceInfo();
+ if (type_source_info)
+ {
+ CompilerType base_class_type (&m_ast, type_source_info->getType().getAsOpaquePtr());
+ if (base_class_type.GetCompleteType() == false)
+ {
+ auto module = dwarf->GetObjectFile()->GetModule();
+ module->ReportError (
+ ":: Class '%s' has a base class '%s' which does not have a complete definition.",
+ die.GetName(),
+ base_class_type.GetTypeName().GetCString());
+ if (die.GetCU()->GetProducer() == DWARFCompileUnit::eProducerClang)
+ module->ReportError (":: Try compiling the source file with -fno-limit-debug-info.");
+
+ // We have no choice other than to pretend that the base class
+ // is complete. If we don't do this, clang will crash when we
+ // call setBases() inside of "clang_type.SetBaseClassesForClassType()"
+ // below. 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.
+ ClangASTContext::StartTagDeclarationDefinition (base_class_type);
+ ClangASTContext::CompleteTagDeclarationDefinition (base_class_type);
+ }
+ }
+ }
+ m_ast.SetBaseClassesForClassType (clang_type.GetOpaqueQualType(),
+ &base_classes.front(),
+ base_classes.size());
+
+ // Clang will copy each CXXBaseSpecifier in "base_classes"
+ // so we have to free them all.
+ ClangASTContext::DeleteBaseClassSpecifiers (&base_classes.front(),
+ base_classes.size());
+ }
+ }
+ }
+
+ ClangASTContext::BuildIndirectFields (clang_type);
+ ClangASTContext::CompleteTagDeclarationDefinition (clang_type);
+
+ if (!layout_info.field_offsets.empty() ||
+ !layout_info.base_offsets.empty() ||
+ !layout_info.vbase_offsets.empty() )
+ {
+ if (type)
+ layout_info.bit_size = type->GetByteSize() * 8;
+ if (layout_info.bit_size == 0)
+ layout_info.bit_size = die.GetAttributeValueAsUnsigned(DW_AT_byte_size, 0) * 8;
+
+ clang::CXXRecordDecl *record_decl = m_ast.GetAsCXXRecordDecl(clang_type.GetOpaqueQualType());
+ if (record_decl)
+ {
+ if (log)
+ {
+ ModuleSP module_sp = dwarf->GetObjectFile()->GetModule();
+
+ if (module_sp)
+ {
+ module_sp->LogMessage (log,
+ "ClangASTContext::CompleteTypeFromDWARF (clang_type = %p) caching layout info for record_decl = %p, bit_size = %" PRIu64 ", alignment = %" PRIu64 ", field_offsets[%u], base_offsets[%u], vbase_offsets[%u])",
+ static_cast<void*>(clang_type.GetOpaqueQualType()),
+ static_cast<void*>(record_decl),
+ layout_info.bit_size,
+ layout_info.alignment,
+ static_cast<uint32_t>(layout_info.field_offsets.size()),
+ static_cast<uint32_t>(layout_info.base_offsets.size()),
+ static_cast<uint32_t>(layout_info.vbase_offsets.size()));
+
+ uint32_t idx;
+ {
+ llvm::DenseMap<const clang::FieldDecl *, uint64_t>::const_iterator pos,
+ end = layout_info.field_offsets.end();
+ for (idx = 0, pos = layout_info.field_offsets.begin(); pos != end; ++pos, ++idx)
+ {
+ module_sp->LogMessage(log,
+ "ClangASTContext::CompleteTypeFromDWARF (clang_type = %p) field[%u] = { bit_offset=%u, name='%s' }",
+ static_cast<void *>(clang_type.GetOpaqueQualType()),
+ idx,
+ static_cast<uint32_t>(pos->second),
+ pos->first->getNameAsString().c_str());
+ }
+ }
+
+ {
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>::const_iterator base_pos,
+ base_end = layout_info.base_offsets.end();
+ for (idx = 0, base_pos = layout_info.base_offsets.begin(); base_pos != base_end; ++base_pos, ++idx)
+ {
+ module_sp->LogMessage(log,
+ "ClangASTContext::CompleteTypeFromDWARF (clang_type = %p) base[%u] = { byte_offset=%u, name='%s' }",
+ clang_type.GetOpaqueQualType(), idx, (uint32_t)base_pos->second.getQuantity(),
+ base_pos->first->getNameAsString().c_str());
+ }
+ }
+ {
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>::const_iterator vbase_pos,
+ vbase_end = layout_info.vbase_offsets.end();
+ for (idx = 0, vbase_pos = layout_info.vbase_offsets.begin(); vbase_pos != vbase_end; ++vbase_pos, ++idx)
+ {
+ module_sp->LogMessage(log,
+ "ClangASTContext::CompleteTypeFromDWARF (clang_type = %p) vbase[%u] = { byte_offset=%u, name='%s' }",
+ static_cast<void *>(clang_type.GetOpaqueQualType()), idx,
+ static_cast<uint32_t>(vbase_pos->second.getQuantity()),
+ vbase_pos->first->getNameAsString().c_str());
+ }
+ }
+
+ }
+ }
+ m_record_decl_to_layout_map.insert(std::make_pair(record_decl, layout_info));
+ }
+ }
+ }
+
+ return (bool)clang_type;
+
+ case DW_TAG_enumeration_type:
+ 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);
+ }
+ ClangASTContext::CompleteTagDeclarationDefinition (clang_type);
+ return (bool)clang_type;
+
+ default:
+ assert(false && "not a forward clang type decl!");
+ break;
+ }
+
+ return false;
+}
+
+std::vector<DWARFDIE>
+DWARFASTParserClang::GetDIEForDeclContext(lldb_private::CompilerDeclContext decl_context)
+{
+ std::vector<DWARFDIE> result;
+ for (auto it = m_decl_ctx_to_die.find((clang::DeclContext *)decl_context.GetOpaqueDeclContext()); it != m_decl_ctx_to_die.end(); it++)
+ result.push_back(it->second);
+ return result;
+}
+
+CompilerDecl
+DWARFASTParserClang::GetDeclForUIDFromDWARF (const DWARFDIE &die)
+{
+ clang::Decl *clang_decl = GetClangDeclForDIE(die);
+ if (clang_decl != nullptr)
+ return CompilerDecl(&m_ast, clang_decl);
+ return CompilerDecl();
+}
+
+CompilerDeclContext
+DWARFASTParserClang::GetDeclContextForUIDFromDWARF (const DWARFDIE &die)
+{
+ clang::DeclContext *clang_decl_ctx = GetClangDeclContextForDIE (die);
+ if (clang_decl_ctx)
+ return CompilerDeclContext(&m_ast, clang_decl_ctx);
+ return CompilerDeclContext();
+}
+
+CompilerDeclContext
+DWARFASTParserClang::GetDeclContextContainingUIDFromDWARF (const DWARFDIE &die)
+{
+ clang::DeclContext *clang_decl_ctx = GetClangDeclContextContainingDIE (die, nullptr);
+ if (clang_decl_ctx)
+ return CompilerDeclContext(&m_ast, clang_decl_ctx);
+ return CompilerDeclContext();
+}
+
+size_t
+DWARFASTParserClang::ParseChildEnumerators (const SymbolContext& sc,
+ lldb_private::CompilerType &clang_type,
+ bool is_signed,
+ uint32_t enumerator_byte_size,
+ const DWARFDIE &parent_die)
+{
+ if (!parent_die)
+ return 0;
+
+ size_t enumerators_added = 0;
+
+ for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid(); die = die.GetSibling())
+ {
+ const dw_tag_t tag = die.Tag();
+ if (tag == DW_TAG_enumerator)
+ {
+ DWARFAttributes attributes;
+ const size_t num_child_attributes = die.GetAttributes(attributes);
+ if (num_child_attributes > 0)
+ {
+ const char *name = NULL;
+ bool got_value = false;
+ int64_t enum_value = 0;
+ Declaration decl;
+
+ uint32_t i;
+ for (i=0; i<num_child_attributes; ++i)
+ {
+ const dw_attr_t attr = attributes.AttributeAtIndex(i);
+ DWARFFormValue form_value;
+ if (attributes.ExtractFormValueAtIndex(i, form_value))
+ {
+ switch (attr)
+ {
+ case DW_AT_const_value:
+ got_value = true;
+ if (is_signed)
+ enum_value = form_value.Signed();
+ else
+ enum_value = form_value.Unsigned();
+ break;
+
+ case DW_AT_name:
+ name = form_value.AsCString();
+ break;
+
+ case DW_AT_description:
+ default:
+ 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_sibling:
+ break;
+ }
+ }
+ }
+
+ if (name && name[0] && got_value)
+ {
+ m_ast.AddEnumerationValueToEnumerationType (clang_type.GetOpaqueQualType(),
+ m_ast.GetEnumerationIntegerType(clang_type.GetOpaqueQualType()),
+ decl,
+ name,
+ enum_value,
+ enumerator_byte_size * 8);
+ ++enumerators_added;
+ }
+ }
+ }
+ }
+ return enumerators_added;
+}
+
+#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE)
+
+class DIEStack
+{
+public:
+
+ void Push (const DWARFDIE &die)
+ {
+ m_dies.push_back (die);
+ }
+
+
+ void LogDIEs (Log *log)
+ {
+ StreamString log_strm;
+ const size_t n = m_dies.size();
+ log_strm.Printf("DIEStack[%" PRIu64 "]:\n", (uint64_t)n);
+ for (size_t i=0; i<n; i++)
+ {
+ std::string qualified_name;
+ const DWARFDIE &die = m_dies[i];
+ die.GetQualifiedName(qualified_name);
+ log_strm.Printf ("[%" PRIu64 "] 0x%8.8x: %s name='%s'\n",
+ (uint64_t)i,
+ die.GetOffset(),
+ die.GetTagAsCString(),
+ qualified_name.c_str());
+ }
+ log->PutCString(log_strm.GetData());
+ }
+ void Pop ()
+ {
+ m_dies.pop_back();
+ }
+
+ class ScopedPopper
+ {
+ public:
+ ScopedPopper (DIEStack &die_stack) :
+ m_die_stack (die_stack),
+ m_valid (false)
+ {
+ }
+
+ void
+ Push (const DWARFDIE &die)
+ {
+ m_valid = true;
+ m_die_stack.Push (die);
+ }
+
+ ~ScopedPopper ()
+ {
+ if (m_valid)
+ m_die_stack.Pop();
+ }
+
+
+
+ protected:
+ DIEStack &m_die_stack;
+ bool m_valid;
+ };
+
+protected:
+ typedef std::vector<DWARFDIE> Stack;
+ Stack m_dies;
+};
+#endif
+
+Function *
+DWARFASTParserClang::ParseFunctionFromDWARF (const SymbolContext& sc,
+ const DWARFDIE &die)
+{
+ DWARFRangeList func_ranges;
+ const char *name = NULL;
+ const char *mangled = NULL;
+ 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());
+
+ const dw_tag_t tag = die.Tag();
+
+ if (tag != DW_TAG_subprogram)
+ return NULL;
+
+ if (die.GetDIENamesAndRanges (name,
+ mangled,
+ func_ranges,
+ decl_file,
+ decl_line,
+ decl_column,
+ call_file,
+ call_line,
+ call_column,
+ &frame_base))
+ {
+
+ // Union of all ranges in the function DIE (if the function is discontiguous)
+ AddressRange func_range;
+ lldb::addr_t lowest_func_addr = func_ranges.GetMinRangeBase (0);
+ lldb::addr_t highest_func_addr = func_ranges.GetMaxRangeEnd (0);
+ if (lowest_func_addr != LLDB_INVALID_ADDRESS && lowest_func_addr <= highest_func_addr)
+ {
+ ModuleSP module_sp (die.GetModule());
+ func_range.GetBaseAddress().ResolveAddressUsingFileSections (lowest_func_addr, module_sp->GetSectionList());
+ if (func_range.GetBaseAddress().IsValid())
+ func_range.SetByteSize(highest_func_addr - lowest_func_addr);
+ }
+
+ if (func_range.GetBaseAddress().IsValid())
+ {
+ Mangled func_name;
+ if (mangled)
+ func_name.SetValue(ConstString(mangled), true);
+ else if (die.GetParent().Tag() == DW_TAG_compile_unit &&
+ Language::LanguageIsCPlusPlus(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 "main" as its name is
+ // never mangled.
+ bool is_static = false;
+ bool is_variadic = false;
+ unsigned type_quals = 0;
+ std::vector<CompilerType> param_types;
+ std::vector<clang::ParmVarDecl*> param_decls;
+ DWARFDeclContext decl_ctx;
+ StreamString sstr;
+
+ die.GetDWARFDeclContext(decl_ctx);
+ sstr << decl_ctx.GetQualifiedName();
+
+ clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE(die, nullptr);
+ ParseChildParameters(sc,
+ containing_decl_ctx,
+ die,
+ true,
+ is_static,
+ is_variadic,
+ param_types,
+ param_decls,
+ type_quals);
+ sstr << "(";
+ for (size_t i = 0; i < param_types.size(); i++)
+ {
+ if (i > 0)
+ sstr << ", ";
+ sstr << param_types[i].GetTypeName();
+ }
+ if (is_variadic)
+ sstr << ", ...";
+ sstr << ")";
+ if (type_quals & clang::Qualifiers::Const)
+ sstr << " const";
+
+ func_name.SetValue(ConstString(sstr.GetData()), false);
+ }
+ else
+ func_name.SetValue(ConstString(name), false);
+
+ FunctionSP func_sp;
+ std::unique_ptr<Declaration> decl_ap;
+ if (decl_file != 0 || decl_line != 0 || decl_column != 0)
+ decl_ap.reset(new Declaration (sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(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);
+
+ if (dwarf->FixupAddress (func_range.GetBaseAddress()))
+ {
+ const user_id_t func_user_id = die.GetID();
+ func_sp.reset(new Function (sc.comp_unit,
+ func_user_id, // UserID is the DIE offset
+ func_user_id,
+ func_name,
+ func_type,
+ func_range)); // first address range
+
+ if (func_sp.get() != NULL)
+ {
+ if (frame_base.IsValid())
+ func_sp->GetFrameBaseExpression() = frame_base;
+ sc.comp_unit->AddFunction(func_sp);
+ return func_sp.get();
+ }
+ }
+ }
+ }
+ return NULL;
+}
+
+
+bool
+DWARFASTParserClang::ParseChildMembers (const SymbolContext& sc,
+ const DWARFDIE &parent_die,
+ CompilerType &class_clang_type,
+ const LanguageType class_language,
+ std::vector<clang::CXXBaseSpecifier *>& base_classes,
+ std::vector<int>& member_accessibilities,
+ DWARFDIECollection& member_function_dies,
+ DelayedPropertyList& delayed_properties,
+ AccessType& default_accessibility,
+ bool &is_a_class,
+ LayoutInfo &layout_info)
+{
+ if (!parent_die)
+ return 0;
+
+ uint32_t member_idx = 0;
+ BitfieldInfo last_field_info;
+
+ ModuleSP module_sp = parent_die.GetDWARF()->GetObjectFile()->GetModule();
+ ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(class_clang_type.GetTypeSystem());
+ if (ast == nullptr)
+ return 0;
+
+ for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid(); die = die.GetSibling())
+ {
+ dw_tag_t tag = die.Tag();
+
+ switch (tag)
+ {
+ case DW_TAG_member:
+ case DW_TAG_APPLE_property:
+ {
+ 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;
+ uint32_t prop_attributes = 0;
+
+
+ bool is_artificial = false;
+ DWARFFormValue encoding_form;
+ AccessType accessibility = eAccessNone;
+ uint32_t member_byte_offset = UINT32_MAX;
+ size_t byte_size = 0;
+ size_t bit_offset = 0;
+ size_t bit_size = 0;
+ bool is_external = false; // On DW_TAG_members, this means the member is static
+ uint32_t i;
+ for (i=0; i<num_attributes && !is_artificial; ++i)
+ {
+ const dw_attr_t attr = attributes.AttributeAtIndex(i);
+ 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;
+ case DW_AT_type: encoding_form = form_value; break;
+ case DW_AT_bit_offset: bit_offset = form_value.Unsigned(); break;
+ case DW_AT_bit_size: bit_size = form_value.Unsigned(); break;
+ case DW_AT_byte_size: byte_size = form_value.Unsigned(); break;
+ case DW_AT_data_member_location:
+ if (form_value.BlockData())
+ {
+ Value initialValue(0);
+ Value memberOffset(0);
+ const DWARFDataExtractor& debug_info_data = die.GetDWARF()->get_debug_info_data();
+ uint32_t block_length = form_value.Unsigned();
+ uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart();
+ if (DWARFExpression::Evaluate(NULL, // ExecutionContext *
+ NULL, // ClangExpressionVariableList *
+ NULL, // ClangExpressionDeclMap *
+ NULL, // RegisterContext *
+ module_sp,
+ debug_info_data,
+ die.GetCU(),
+ block_offset,
+ block_length,
+ eRegisterKindDWARF,
+ &initialValue,
+ memberOffset,
+ NULL))
+ {
+ member_byte_offset = memberOffset.ResolveValue(NULL).UInt();
+ }
+ }
+ else
+ {
+ // With DWARF 3 and later, if the value is an integer constant,
+ // this form value is the offset in bytes from the beginning
+ // of the containing entity.
+ member_byte_offset = form_value.Unsigned();
+ }
+ 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_APPLE_property_name: prop_name = form_value.AsCString();
+ break;
+ case DW_AT_APPLE_property_getter: prop_getter_name = form_value.AsCString();
+ break;
+ case DW_AT_APPLE_property_setter: prop_setter_name = form_value.AsCString();
+ break;
+ case DW_AT_APPLE_property_attribute: prop_attributes = form_value.Unsigned(); break;
+ case DW_AT_external: is_external = form_value.Boolean(); break;
+
+ default:
+ case DW_AT_declaration:
+ case DW_AT_description:
+ case DW_AT_mutable:
+ case DW_AT_visibility:
+ case DW_AT_sibling:
+ break;
+ }
+ }
+ }
+
+ if (prop_name)
+ {
+ ConstString fixed_getter;
+ ConstString fixed_setter;
+
+ // Check if the property getter/setter were provided as full
+ // names. We want basenames, so we extract them.
+
+ if (prop_getter_name && prop_getter_name[0] == '-')
+ {
+ ObjCLanguage::MethodName prop_getter_method(prop_getter_name, true);
+ prop_getter_name = prop_getter_method.GetSelector().GetCString();
+ }
+
+ if (prop_setter_name && prop_setter_name[0] == '-')
+ {
+ ObjCLanguage::MethodName prop_setter_method(prop_setter_name, true);
+ prop_setter_name = prop_setter_method.GetSelector().GetCString();
+ }
+
+ // If the names haven't been provided, they need to be
+ // filled in.
+
+ if (!prop_getter_name)
+ {
+ prop_getter_name = prop_name;
+ }
+ if (!prop_setter_name && prop_name[0] && !(prop_attributes & DW_APPLE_PROPERTY_readonly))
+ {
+ StreamString ss;
+
+ ss.Printf("set%c%s:",
+ toupper(prop_name[0]),
+ &prop_name[1]);
+
+ fixed_setter.SetCString(ss.GetData());
+ prop_setter_name = fixed_setter.GetCString();
+ }
+ }
+
+ // Clang has a DWARF generation bug where sometimes it
+ // represents fields that are references with bad byte size
+ // and bit size/offset information such as:
+ //
+ // DW_AT_byte_size( 0x00 )
+ // DW_AT_bit_size( 0x40 )
+ // DW_AT_bit_offset( 0xffffffffffffffc0 )
+ //
+ // So check the bit offset to make sure it is sane, and if
+ // the values are not sane, remove them. If we don't do this
+ // then we will end up with a crash if we try to use this
+ // type in an expression when clang becomes unhappy with its
+ // recycled debug info.
+
+ if (bit_offset > 128)
+ {
+ bit_size = 0;
+ bit_offset = 0;
+ }
+
+ // FIXME: Make Clang ignore Objective-C accessibility for expressions
+ if (class_language == eLanguageTypeObjC ||
+ class_language == eLanguageTypeObjC_plus_plus)
+ accessibility = eAccessNone;
+
+ if (member_idx == 0 && !is_artificial && name && (strstr (name, "_vptr$") == name))
+ {
+ // Not all compilers will mark the vtable pointer
+ // member as artificial (llvm-gcc). We can't have
+ // the virtual members in our classes otherwise it
+ // throws off all child offsets since we end up
+ // having and extra pointer sized member in our
+ // class layouts.
+ is_artificial = true;
+ }
+
+ // Handle static members
+ if (is_external && member_byte_offset == UINT32_MAX)
+ {
+ Type *var_type = die.ResolveTypeUID(DIERef(encoding_form).GetUID());
+
+ if (var_type)
+ {
+ if (accessibility == eAccessNone)
+ accessibility = eAccessPublic;
+ ClangASTContext::AddVariableToRecordType (class_clang_type,
+ name,
+ var_type->GetLayoutCompilerType (),
+ accessibility);
+ }
+ break;
+ }
+
+ if (is_artificial == false)
+ {
+ Type *member_type = die.ResolveTypeUID(DIERef(encoding_form).GetUID());
+
+ clang::FieldDecl *field_decl = NULL;
+ if (tag == DW_TAG_member)
+ {
+ if (member_type)
+ {
+ if (accessibility == eAccessNone)
+ accessibility = default_accessibility;
+ member_accessibilities.push_back(accessibility);
+
+ uint64_t field_bit_offset = (member_byte_offset == UINT32_MAX ? 0 : (member_byte_offset * 8));
+ if (bit_size > 0)
+ {
+
+ BitfieldInfo this_field_info;
+ this_field_info.bit_offset = field_bit_offset;
+ this_field_info.bit_size = bit_size;
+
+ /////////////////////////////////////////////////////////////
+ // How to locate a field given the DWARF debug information
+ //
+ // AT_byte_size indicates the size of the word in which the
+ // bit offset must be interpreted.
+ //
+ // AT_data_member_location indicates the byte offset of the
+ // word from the base address of the structure.
+ //
+ // AT_bit_offset indicates how many bits into the word
+ // (according to the host endianness) the low-order bit of
+ // the field starts. AT_bit_offset can be negative.
+ //
+ // AT_bit_size indicates the size of the field in bits.
+ /////////////////////////////////////////////////////////////
+
+ if (byte_size == 0)
+ byte_size = member_type->GetByteSize();
+
+ if (die.GetDWARF()->GetObjectFile()->GetByteOrder() == eByteOrderLittle)
+ {
+ this_field_info.bit_offset += byte_size * 8;
+ this_field_info.bit_offset -= (bit_offset + bit_size);
+ }
+ else
+ {
+ this_field_info.bit_offset += bit_offset;
+ }
+
+ // Update the field bit offset we will report for layout
+ field_bit_offset = this_field_info.bit_offset;
+
+ // If the member to be emitted did not start on a character boundary and there is
+ // empty space between the last field and this one, then we need to emit an
+ // anonymous member filling up the space up to its start. There are three cases
+ // here:
+ //
+ // 1 If the previous member ended on a character boundary, then we can emit an
+ // anonymous member starting at the most recent character boundary.
+ //
+ // 2 If the previous member did not end on a character boundary and the distance
+ // from the end of the previous member to the current member is less than a
+ // word width, then we can emit an anonymous member starting right after the
+ // previous member and right before this member.
+ //
+ // 3 If the previous member did not end on a character boundary and the distance
+ // from the end of the previous member to the current member is greater than
+ // or equal a word width, then we act as in Case 1.
+
+ const uint64_t character_width = 8;
+ const uint64_t word_width = 32;
+
+ // Objective-C has invalid DW_AT_bit_offset values in older versions
+ // of clang, so we have to be careful and only insert unnamed bitfields
+ // if we have a new enough clang.
+ bool detect_unnamed_bitfields = true;
+
+ if (class_language == eLanguageTypeObjC || class_language == eLanguageTypeObjC_plus_plus)
+ detect_unnamed_bitfields = die.GetCU()->Supports_unnamed_objc_bitfields ();
+
+ if (detect_unnamed_bitfields)
+ {
+ BitfieldInfo anon_field_info;
+
+ if ((this_field_info.bit_offset % character_width) != 0) // not char aligned
+ {
+ uint64_t last_field_end = 0;
+
+ if (last_field_info.IsValid())
+ last_field_end = last_field_info.bit_offset + last_field_info.bit_size;
+
+ if (this_field_info.bit_offset != last_field_end)
+ {
+ if (((last_field_end % character_width) == 0) || // case 1
+ (this_field_info.bit_offset - last_field_end >= word_width)) // case 3
+ {
+ anon_field_info.bit_size = this_field_info.bit_offset % character_width;
+ anon_field_info.bit_offset = this_field_info.bit_offset - anon_field_info.bit_size;
+ }
+ else // case 2
+ {
+ anon_field_info.bit_size = this_field_info.bit_offset - last_field_end;
+ anon_field_info.bit_offset = last_field_end;
+ }
+ }
+ }
+
+ if (anon_field_info.IsValid())
+ {
+ clang::FieldDecl *unnamed_bitfield_decl =
+ ClangASTContext::AddFieldToRecordType (class_clang_type,
+ NULL,
+ m_ast.GetBuiltinTypeForEncodingAndBitSize(eEncodingSint, word_width),
+ accessibility,
+ anon_field_info.bit_size);
+
+ layout_info.field_offsets.insert(
+ std::make_pair(unnamed_bitfield_decl, anon_field_info.bit_offset));
+ }
+ }
+ last_field_info = this_field_info;
+ }
+ else
+ {
+ last_field_info.Clear();
+ }
+
+ CompilerType member_clang_type = member_type->GetLayoutCompilerType ();
+ if (!member_clang_type.IsCompleteType())
+ member_clang_type.GetCompleteType();
+
+ {
+ // Older versions of clang emit array[0] and array[1] in the same way (<rdar://problem/12566646>).
+ // If the current field is at the end of the structure, then there is definitely no room for extra
+ // elements and we override the type to array[0].
+
+ CompilerType member_array_element_type;
+ uint64_t member_array_size;
+ bool member_array_is_incomplete;
+
+ if (member_clang_type.IsArrayType(&member_array_element_type,
+ &member_array_size,
+ &member_array_is_incomplete) &&
+ !member_array_is_incomplete)
+ {
+ uint64_t parent_byte_size = parent_die.GetAttributeValueAsUnsigned(DW_AT_byte_size, UINT64_MAX);
+
+ if (member_byte_offset >= parent_byte_size)
+ {
+ if (member_array_size != 1)
+ {
+ module_sp->ReportError ("0x%8.8" PRIx64 ": DW_TAG_member '%s' refers to type 0x%8.8" PRIx64 " which extends beyond the bounds of 0x%8.8" PRIx64,
+ die.GetID(),
+ name,
+ encoding_form.Reference(),
+ parent_die.GetID());
+ }
+
+ member_clang_type = m_ast.CreateArrayType(member_array_element_type, 0, false);
+ }
+ }
+ }
+
+ if (ClangASTContext::IsCXXClassType(member_clang_type) && member_clang_type.GetCompleteType() == false)
+ {
+ if (die.GetCU()->GetProducer() == DWARFCompileUnit::eProducerClang)
+ module_sp->ReportError ("DWARF DIE at 0x%8.8x (class %s) has a member variable 0x%8.8x (%s) whose type is a forward declaration, not a complete definition.\nTry compiling the source file with -fno-limit-debug-info",
+ parent_die.GetOffset(),
+ parent_die.GetName(),
+ die.GetOffset(),
+ name);
+ else
+ module_sp->ReportError ("DWARF DIE at 0x%8.8x (class %s) has a member variable 0x%8.8x (%s) whose type is a forward declaration, not a 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");
+ // 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 assistance, all
+ // ivars in this class and other classes will be fine, this is
+ // the best we can do short of crashing.
+ ClangASTContext::StartTagDeclarationDefinition(member_clang_type);
+ ClangASTContext::CompleteTagDeclarationDefinition(member_clang_type);
+ }
+
+ field_decl = ClangASTContext::AddFieldToRecordType (class_clang_type,
+ name,
+ member_clang_type,
+ accessibility,
+ bit_size);
+
+ m_ast.SetMetadataAsUserID (field_decl, die.GetID());
+
+ layout_info.field_offsets.insert(std::make_pair(field_decl, field_bit_offset));
+ }
+ else
+ {
+ if (name)
+ module_sp->ReportError ("0x%8.8" PRIx64 ": DW_TAG_member '%s' refers to type 0x%8.8" PRIx64 " which was unable to be parsed",
+ die.GetID(),
+ name,
+ encoding_form.Reference());
+ else
+ module_sp->ReportError ("0x%8.8" PRIx64 ": DW_TAG_member refers to type 0x%8.8" PRIx64 " which was unable to be parsed",
+ die.GetID(),
+ encoding_form.Reference());
+ }
+ }
+
+ if (prop_name != NULL && member_type)
+ {
+ clang::ObjCIvarDecl *ivar_decl = NULL;
+
+ if (field_decl)
+ {
+ ivar_decl = clang::dyn_cast<clang::ObjCIvarDecl>(field_decl);
+ assert (ivar_decl != NULL);
+ }
+
+ ClangASTMetadata metadata;
+ metadata.SetUserID (die.GetID());
+ delayed_properties.push_back(DelayedAddObjCClassProperty(class_clang_type,
+ prop_name,
+ member_type->GetLayoutCompilerType (),
+ ivar_decl,
+ prop_setter_name,
+ prop_getter_name,
+ prop_attributes,
+ &metadata));
+
+ if (ivar_decl)
+ m_ast.SetMetadataAsUserID (ivar_decl, die.GetID());
+ }
+ }
+ }
+ ++member_idx;
+ }
+ break;
+
+ case DW_TAG_subprogram:
+ // Let the type parsing code handle this one for us.
+ member_function_dies.Append (die);
+ break;
+
+ case DW_TAG_inheritance:
+ {
+ is_a_class = true;
+ if (default_accessibility == eAccessNone)
+ default_accessibility = eAccessPrivate;
+ // TODO: implement DW_TAG_inheritance type parsing
+ 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;
+ bool is_base_of_class = true;
+ off_t member_byte_offset = 0;
+ uint32_t i;
+ for (i=0; i<num_attributes; ++i)
+ {
+ const dw_attr_t attr = attributes.AttributeAtIndex(i);
+ 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;
+ case DW_AT_data_member_location:
+ if (form_value.BlockData())
+ {
+ Value initialValue(0);
+ Value memberOffset(0);
+ const DWARFDataExtractor& debug_info_data = die.GetDWARF()->get_debug_info_data();
+ uint32_t block_length = form_value.Unsigned();
+ uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart();
+ if (DWARFExpression::Evaluate (NULL,
+ NULL,
+ NULL,
+ NULL,
+ module_sp,
+ debug_info_data,
+ die.GetCU(),
+ block_offset,
+ block_length,
+ eRegisterKindDWARF,
+ &initialValue,
+ memberOffset,
+ NULL))
+ {
+ member_byte_offset = memberOffset.ResolveValue(NULL).UInt();
+ }
+ }
+ else
+ {
+ // With DWARF 3 and later, if the value is an integer constant,
+ // this form value is the offset in bytes from the beginning
+ // of the containing entity.
+ member_byte_offset = form_value.Unsigned();
+ }
+ break;
+
+ case DW_AT_accessibility:
+ accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned());
+ break;
+
+ case DW_AT_virtuality:
+ is_virtual = form_value.Boolean();
+ break;
+
+ case DW_AT_sibling:
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ Type *base_class_type = die.ResolveTypeUID(DIERef(encoding_form).GetUID());
+ if (base_class_type == NULL)
+ {
+ module_sp->ReportError("0x%8.8x: DW_TAG_inheritance failed to resolve the base class at 0x%8.8" PRIx64 " 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(),
+ parent_die.GetOffset());
+ break;
+ }
+
+ CompilerType base_class_clang_type = base_class_type->GetFullCompilerType ();
+ assert (base_class_clang_type);
+ if (class_language == eLanguageTypeObjC)
+ {
+ ast->SetObjCSuperClass(class_clang_type, base_class_clang_type);
+ }
+ else
+ {
+ base_classes.push_back (ast->CreateBaseClassSpecifier (base_class_clang_type.GetOpaqueQualType(),
+ accessibility,
+ is_virtual,
+ is_base_of_class));
+
+ if (is_virtual)
+ {
+ // Do not specify any offset for virtual inheritance. The DWARF produced by clang doesn't
+ // give us a constant offset, but gives us a DWARF expressions that requires an actual object
+ // in memory. the DW_AT_data_member_location for a virtual base class looks like:
+ // DW_AT_data_member_location( DW_OP_dup, DW_OP_deref, DW_OP_constu(0x00000018), DW_OP_minus, DW_OP_deref, DW_OP_plus )
+ // Given this, there is really no valid response we can give to clang for virtual base
+ // class offsets, and this should eventually be removed from LayoutRecordType() in the external
+ // AST source in clang.
+ }
+ else
+ {
+ layout_info.base_offsets.insert(
+ std::make_pair(ast->GetAsCXXRecordDecl(base_class_clang_type.GetOpaqueQualType()),
+ clang::CharUnits::fromQuantity(member_byte_offset)));
+ }
+ }
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return true;
+}
+
+
+size_t
+DWARFASTParserClang::ParseChildParameters (const SymbolContext& sc,
+ clang::DeclContext *containing_decl_ctx,
+ const DWARFDIE &parent_die,
+ bool skip_artificial,
+ bool &is_static,
+ bool &is_variadic,
+ std::vector<CompilerType>& function_param_types,
+ std::vector<clang::ParmVarDecl*>& function_param_decls,
+ unsigned &type_quals)
+{
+ if (!parent_die)
+ return 0;
+
+ size_t arg_idx = 0;
+ for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid(); die = die.GetSibling())
+ {
+ const dw_tag_t tag = die.Tag();
+ switch (tag)
+ {
+ case DW_TAG_formal_parameter:
+ {
+ DWARFAttributes attributes;
+ const size_t num_attributes = die.GetAttributes(attributes);
+ if (num_attributes > 0)
+ {
+ const char *name = NULL;
+ Declaration decl;
+ DWARFFormValue param_type_die_form;
+ bool is_artificial = false;
+ // one of None, Auto, Register, Extern, Static, PrivateExtern
+
+ clang::StorageClass storage = clang::SC_None;
+ uint32_t i;
+ for (i=0; i<num_attributes; ++i)
+ {
+ const dw_attr_t attr = attributes.AttributeAtIndex(i);
+ 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;
+ case DW_AT_type: param_type_die_form = form_value; break;
+ case DW_AT_artificial: is_artificial = form_value.Boolean(); break;
+ case DW_AT_location:
+ // if (form_value.BlockData())
+ // {
+ // const DWARFDataExtractor& debug_info_data = debug_info();
+ // uint32_t block_length = form_value.Unsigned();
+ // DWARFDataExtractor location(debug_info_data, form_value.BlockData() - debug_info_data.GetDataStart(), block_length);
+ // }
+ // else
+ // {
+ // }
+ // break;
+ case DW_AT_const_value:
+ case DW_AT_default_value:
+ case DW_AT_description:
+ case DW_AT_endianity:
+ case DW_AT_is_optional:
+ case DW_AT_segment:
+ case DW_AT_variable_parameter:
+ default:
+ case DW_AT_abstract_origin:
+ case DW_AT_sibling:
+ break;
+ }
+ }
+ }
+
+ bool skip = false;
+ if (skip_artificial)
+ {
+ if (is_artificial)
+ {
+ // In order to determine if a C++ member function is
+ // "const" we have to look at the const-ness of "this"...
+ // Ugly, but that
+ if (arg_idx == 0)
+ {
+ if (DeclKindIsCXXClass(containing_decl_ctx->getDeclKind()))
+ {
+ // 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...
+ if (name == NULL || ::strcmp(name, "this")==0)
+ {
+ Type *this_type = die.ResolveTypeUID (DIERef(param_type_die_form).GetUID());
+ if (this_type)
+ {
+ uint32_t encoding_mask = this_type->GetEncodingMask();
+ if (encoding_mask & Type::eEncodingIsPointerUID)
+ {
+ is_static = false;
+
+ if (encoding_mask & (1u << Type::eEncodingIsConstUID))
+ type_quals |= clang::Qualifiers::Const;
+ if (encoding_mask & (1u << Type::eEncodingIsVolatileUID))
+ type_quals |= clang::Qualifiers::Volatile;
+ }
+ }
+ }
+ }
+ }
+ skip = true;
+ }
+ else
+ {
+
+ // HACK: Objective C formal parameters "self" and "_cmd"
+ // are not marked as artificial in the DWARF...
+ CompileUnit *comp_unit = die.GetLLDBCompileUnit();
+ if (comp_unit)
+ {
+ switch (comp_unit->GetLanguage())
+ {
+ case eLanguageTypeObjC:
+ case eLanguageTypeObjC_plus_plus:
+ if (name && name[0] && (strcmp (name, "self") == 0 || strcmp (name, "_cmd") == 0))
+ skip = true;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ if (!skip)
+ {
+ Type *type = die.ResolveTypeUID(DIERef(param_type_die_form).GetUID());
+ if (type)
+ {
+ function_param_types.push_back (type->GetForwardCompilerType ());
+
+ clang::ParmVarDecl *param_var_decl = m_ast.CreateParameterDeclaration (name,
+ type->GetForwardCompilerType (),
+ storage);
+ assert(param_var_decl);
+ function_param_decls.push_back(param_var_decl);
+
+ m_ast.SetMetadataAsUserID (param_var_decl, die.GetID());
+ }
+ }
+ }
+ arg_idx++;
+ }
+ break;
+
+ case DW_TAG_unspecified_parameters:
+ is_variadic = true;
+ break;
+
+ case DW_TAG_template_type_parameter:
+ case DW_TAG_template_value_parameter:
+ // The one caller of this was never using the template_param_infos,
+ // and the local variable was taking up a large amount of stack space
+ // in SymbolFileDWARF::ParseType() so this was removed. If we ever need
+ // the template params back, we can add them back.
+ // ParseTemplateDIE (dwarf_cu, die, template_param_infos);
+ break;
+
+ default:
+ break;
+ }
+ }
+ return arg_idx;
+}
+
+void
+DWARFASTParserClang::ParseChildArrayInfo (const SymbolContext& sc,
+ const DWARFDIE &parent_die,
+ int64_t& first_index,
+ std::vector<uint64_t>& element_orders,
+ uint32_t& byte_stride,
+ uint32_t& bit_stride)
+{
+ if (!parent_die)
+ return;
+
+ for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid(); die = die.GetSibling())
+ {
+ const dw_tag_t tag = die.Tag();
+ switch (tag)
+ {
+ case DW_TAG_subrange_type:
+ {
+ DWARFAttributes attributes;
+ const size_t num_child_attributes = die.GetAttributes(attributes);
+ if (num_child_attributes > 0)
+ {
+ uint64_t num_elements = 0;
+ uint64_t lower_bound = 0;
+ uint64_t upper_bound = 0;
+ bool upper_bound_valid = false;
+ uint32_t i;
+ for (i=0; i<num_child_attributes; ++i)
+ {
+ const dw_attr_t attr = attributes.AttributeAtIndex(i);
+ DWARFFormValue form_value;
+ if (attributes.ExtractFormValueAtIndex(i, form_value))
+ {
+ switch (attr)
+ {
+ case DW_AT_name:
+ break;
+
+ case DW_AT_count:
+ num_elements = form_value.Unsigned();
+ break;
+
+ case DW_AT_bit_stride:
+ bit_stride = form_value.Unsigned();
+ break;
+
+ case DW_AT_byte_stride:
+ byte_stride = form_value.Unsigned();
+ break;
+
+ case DW_AT_lower_bound:
+ lower_bound = form_value.Unsigned();
+ break;
+
+ case DW_AT_upper_bound:
+ upper_bound_valid = true;
+ upper_bound = form_value.Unsigned();
+ break;
+
+ default:
+ case DW_AT_abstract_origin:
+ case DW_AT_accessibility:
+ case DW_AT_allocated:
+ case DW_AT_associated:
+ case DW_AT_data_location:
+ case DW_AT_declaration:
+ case DW_AT_description:
+ case DW_AT_sibling:
+ case DW_AT_threads_scaled:
+ case DW_AT_type:
+ case DW_AT_visibility:
+ break;
+ }
+ }
+ }
+
+ if (num_elements == 0)
+ {
+ if (upper_bound_valid && upper_bound >= lower_bound)
+ num_elements = upper_bound - lower_bound + 1;
+ }
+
+ element_orders.push_back (num_elements);
+ }
+ }
+ break;
+ }
+ }
+}
+
+Type *
+DWARFASTParserClang::GetTypeForDIE (const DWARFDIE &die)
+{
+ if (die)
+ {
+ SymbolFileDWARF *dwarf = die.GetDWARF();
+ DWARFAttributes attributes;
+ const size_t num_attributes = die.GetAttributes(attributes);
+ if (num_attributes > 0)
+ {
+ DWARFFormValue type_die_form;
+ for (size_t i = 0; i < num_attributes; ++i)
+ {
+ dw_attr_t attr = attributes.AttributeAtIndex(i);
+ DWARFFormValue form_value;
+
+ if (attr == DW_AT_type && attributes.ExtractFormValueAtIndex(i, form_value))
+ return dwarf->ResolveTypeUID(DIERef(form_value).GetUID());
+ }
+ }
+ }
+
+ return nullptr;
+}
+
+clang::Decl *
+DWARFASTParserClang::GetClangDeclForDIE (const DWARFDIE &die)
+{
+ if (!die)
+ return nullptr;
+
+ switch (die.Tag())
+ {
+ case DW_TAG_variable:
+ case DW_TAG_constant:
+ case DW_TAG_formal_parameter:
+ case DW_TAG_imported_declaration:
+ case DW_TAG_imported_module:
+ break;
+ default:
+ return nullptr;
+ }
+
+ DIEToDeclMap::iterator cache_pos = m_die_to_decl.find(die.GetDIE());
+ if (cache_pos != m_die_to_decl.end())
+ return cache_pos->second;
+
+ if (DWARFDIE spec_die = die.GetReferencedDIE(DW_AT_specification))
+ {
+ clang::Decl *decl = GetClangDeclForDIE(spec_die);
+ m_die_to_decl[die.GetDIE()] = decl;
+ m_decl_to_die[decl].insert(die.GetDIE());
+ return decl;
+ }
+
+ clang::Decl *decl = nullptr;
+ switch (die.Tag())
+ {
+ case DW_TAG_variable:
+ case DW_TAG_constant:
+ case DW_TAG_formal_parameter:
+ {
+ SymbolFileDWARF *dwarf = die.GetDWARF();
+ Type *type = GetTypeForDIE(die);
+ const char *name = die.GetName();
+ clang::DeclContext *decl_context = ClangASTContext::DeclContextGetAsDeclContext(dwarf->GetDeclContextContainingUID(die.GetID()));
+ decl = m_ast.CreateVariableDeclaration(
+ decl_context,
+ name,
+ ClangASTContext::GetQualType(type->GetForwardCompilerType()));
+ break;
+ }
+ case DW_TAG_imported_declaration:
+ {
+ SymbolFileDWARF *dwarf = die.GetDWARF();
+ lldb::user_id_t imported_uid = die.GetAttributeValueAsReference(DW_AT_import, DW_INVALID_OFFSET);
+
+ if (dwarf->UserIDMatches(imported_uid))
+ {
+ CompilerDecl imported_decl = dwarf->GetDeclForUID(imported_uid);
+ if (imported_decl)
+ {
+ clang::DeclContext *decl_context = ClangASTContext::DeclContextGetAsDeclContext(dwarf->GetDeclContextContainingUID(die.GetID()));
+ if (clang::NamedDecl *clang_imported_decl = llvm::dyn_cast<clang::NamedDecl>((clang::Decl *)imported_decl.GetOpaqueDecl()))
+ decl = m_ast.CreateUsingDeclaration(decl_context, clang_imported_decl);
+ }
+ }
+ break;
+ }
+ case DW_TAG_imported_module:
+ {
+ SymbolFileDWARF *dwarf = die.GetDWARF();
+ lldb::user_id_t imported_uid = die.GetAttributeValueAsReference(DW_AT_import, DW_INVALID_OFFSET);
+
+ if (dwarf->UserIDMatches(imported_uid))
+ {
+ CompilerDeclContext imported_decl = dwarf->GetDeclContextForUID(imported_uid);
+ if (imported_decl)
+ {
+ clang::DeclContext *decl_context = ClangASTContext::DeclContextGetAsDeclContext(dwarf->GetDeclContextContainingUID(die.GetID()));
+ if (clang::NamespaceDecl *ns_decl = ClangASTContext::DeclContextGetAsNamespaceDecl(imported_decl))
+ decl = m_ast.CreateUsingDirectiveDeclaration(decl_context, ns_decl);
+ }
+ }
+ break;
+ }
+ default:
+ break;
+ }
+
+ m_die_to_decl[die.GetDIE()] = decl;
+ m_decl_to_die[decl].insert(die.GetDIE());
+
+ return decl;
+}
+
+clang::DeclContext *
+DWARFASTParserClang::GetClangDeclContextForDIE (const DWARFDIE &die)
+{
+ if (die)
+ {
+ clang::DeclContext *decl_ctx = GetCachedClangDeclContextForDIE (die);
+ if (decl_ctx)
+ return decl_ctx;
+
+ bool try_parsing_type = true;
+ switch (die.Tag())
+ {
+ case DW_TAG_compile_unit:
+ decl_ctx = m_ast.GetTranslationUnitDecl();
+ try_parsing_type = false;
+ break;
+
+ case DW_TAG_namespace:
+ decl_ctx = ResolveNamespaceDIE (die);
+ try_parsing_type = false;
+ break;
+
+ case DW_TAG_lexical_block:
+ decl_ctx = (clang::DeclContext *)ResolveBlockDIE(die);
+ try_parsing_type = false;
+ break;
+
+ default:
+ break;
+ }
+
+ if (decl_ctx == nullptr && try_parsing_type)
+ {
+ Type* type = die.GetDWARF()->ResolveType (die);
+ if (type)
+ decl_ctx = GetCachedClangDeclContextForDIE (die);
+ }
+
+ if (decl_ctx)
+ {
+ LinkDeclContextToDIE (decl_ctx, die);
+ return decl_ctx;
+ }
+ }
+ return nullptr;
+}
+
+clang::BlockDecl *
+DWARFASTParserClang::ResolveBlockDIE (const DWARFDIE &die)
+{
+ if (die && die.Tag() == DW_TAG_lexical_block)
+ {
+ clang::BlockDecl *decl = llvm::cast_or_null<clang::BlockDecl>(m_die_to_decl_ctx[die.GetDIE()]);
+
+ if (!decl)
+ {
+ DWARFDIE decl_context_die;
+ clang::DeclContext *decl_context = GetClangDeclContextContainingDIE(die, &decl_context_die);
+ decl = m_ast.CreateBlockDeclaration(decl_context);
+
+ if (decl)
+ LinkDeclContextToDIE((clang::DeclContext *)decl, die);
+ }
+
+ return decl;
+ }
+ return nullptr;
+}
+
+clang::NamespaceDecl *
+DWARFASTParserClang::ResolveNamespaceDIE (const DWARFDIE &die)
+{
+ if (die && die.Tag() == DW_TAG_namespace)
+ {
+ // See if we already parsed this namespace DIE and associated it with a
+ // uniqued namespace declaration
+ clang::NamespaceDecl *namespace_decl = static_cast<clang::NamespaceDecl *>(m_die_to_decl_ctx[die.GetDIE()]);
+ if (namespace_decl)
+ return namespace_decl;
+ else
+ {
+ const char *namespace_name = die.GetName();
+ clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (die, nullptr);
+ namespace_decl = m_ast.GetUniqueNamespaceDeclaration (namespace_name, containing_decl_ctx);
+ Log *log = nullptr;// (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
+ if (log)
+ {
+ SymbolFileDWARF *dwarf = die.GetDWARF();
+ if (namespace_name)
+ {
+ dwarf->GetObjectFile()->GetModule()->LogMessage (log,
+ "ASTContext => %p: 0x%8.8" PRIx64 ": DW_TAG_namespace with DW_AT_name(\"%s\") => clang::NamespaceDecl *%p (original = %p)",
+ static_cast<void*>(m_ast.getASTContext()),
+ die.GetID(),
+ namespace_name,
+ static_cast<void*>(namespace_decl),
+ static_cast<void*>(namespace_decl->getOriginalNamespace()));
+ }
+ else
+ {
+ dwarf->GetObjectFile()->GetModule()->LogMessage (log,
+ "ASTContext => %p: 0x%8.8" PRIx64 ": DW_TAG_namespace (anonymous) => clang::NamespaceDecl *%p (original = %p)",
+ static_cast<void*>(m_ast.getASTContext()),
+ die.GetID(),
+ static_cast<void*>(namespace_decl),
+ static_cast<void*>(namespace_decl->getOriginalNamespace()));
+ }
+ }
+
+ if (namespace_decl)
+ LinkDeclContextToDIE((clang::DeclContext*)namespace_decl, die);
+ return namespace_decl;
+ }
+ }
+ return nullptr;
+}
+
+clang::DeclContext *
+DWARFASTParserClang::GetClangDeclContextContainingDIE (const DWARFDIE &die,
+ DWARFDIE *decl_ctx_die_copy)
+{
+ SymbolFileDWARF *dwarf = die.GetDWARF();
+
+ DWARFDIE decl_ctx_die = dwarf->GetDeclContextDIEContainingDIE (die);
+
+ if (decl_ctx_die_copy)
+ *decl_ctx_die_copy = decl_ctx_die;
+
+ if (decl_ctx_die)
+ {
+ clang::DeclContext *clang_decl_ctx = GetClangDeclContextForDIE (decl_ctx_die);
+ if (clang_decl_ctx)
+ return clang_decl_ctx;
+ }
+ return m_ast.GetTranslationUnitDecl();
+}
+
+clang::DeclContext *
+DWARFASTParserClang::GetCachedClangDeclContextForDIE (const DWARFDIE &die)
+{
+ if (die)
+ {
+ DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find(die.GetDIE());
+ if (pos != m_die_to_decl_ctx.end())
+ return pos->second;
+ }
+ return nullptr;
+}
+
+void
+DWARFASTParserClang::LinkDeclContextToDIE (clang::DeclContext *decl_ctx, const DWARFDIE &die)
+{
+ m_die_to_decl_ctx[die.GetDIE()] = decl_ctx;
+ // There can be many DIEs for a single decl context
+ //m_decl_ctx_to_die[decl_ctx].insert(die.GetDIE());
+ m_decl_ctx_to_die.insert(std::make_pair(decl_ctx, die));
+}
+
+bool
+DWARFASTParserClang::CopyUniqueClassMethodTypes (const DWARFDIE &src_class_die,
+ const DWARFDIE &dst_class_die,
+ lldb_private::Type *class_type,
+ DWARFDIECollection &failures)
+{
+ if (!class_type || !src_class_die || !dst_class_die)
+ return false;
+ if (src_class_die.Tag() != dst_class_die.Tag())
+ return false;
+
+ // We need to complete the class type so we can get all of the method types
+ // parsed so we can then unique those types to their equivalent counterparts
+ // in "dst_cu" and "dst_class_die"
+ class_type->GetFullCompilerType ();
+
+ DWARFDIE src_die;
+ DWARFDIE dst_die;
+ UniqueCStringMap<DWARFDIE> src_name_to_die;
+ UniqueCStringMap<DWARFDIE> dst_name_to_die;
+ UniqueCStringMap<DWARFDIE> src_name_to_die_artificial;
+ UniqueCStringMap<DWARFDIE> dst_name_to_die_artificial;
+ for (src_die = src_class_die.GetFirstChild(); src_die.IsValid(); src_die = src_die.GetSibling())
+ {
+ if (src_die.Tag() == DW_TAG_subprogram)
+ {
+ // Make sure this is a declaration and not a concrete instance by looking
+ // for DW_AT_declaration set to 1. Sometimes concrete function instances
+ // are placed inside the class definitions and shouldn't be included in
+ // the list of things are are tracking here.
+ if (src_die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) == 1)
+ {
+ const char *src_name = src_die.GetMangledName ();
+ if (src_name)
+ {
+ ConstString src_const_name(src_name);
+ if (src_die.GetAttributeValueAsUnsigned(DW_AT_artificial, 0))
+ src_name_to_die_artificial.Append(src_const_name.GetCString(), src_die);
+ else
+ src_name_to_die.Append(src_const_name.GetCString(), src_die);
+ }
+ }
+ }
+ }
+ for (dst_die = dst_class_die.GetFirstChild(); dst_die.IsValid(); dst_die = dst_die.GetSibling())
+ {
+ if (dst_die.Tag() == DW_TAG_subprogram)
+ {
+ // Make sure this is a declaration and not a concrete instance by looking
+ // for DW_AT_declaration set to 1. Sometimes concrete function instances
+ // are placed inside the class definitions and shouldn't be included in
+ // the list of things are are tracking here.
+ if (dst_die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) == 1)
+ {
+ const char *dst_name = dst_die.GetMangledName ();
+ if (dst_name)
+ {
+ ConstString dst_const_name(dst_name);
+ if ( dst_die.GetAttributeValueAsUnsigned(DW_AT_artificial, 0))
+ dst_name_to_die_artificial.Append(dst_const_name.GetCString(), dst_die);
+ else
+ dst_name_to_die.Append(dst_const_name.GetCString(), dst_die);
+ }
+ }
+ }
+ }
+ const uint32_t src_size = src_name_to_die.GetSize ();
+ const uint32_t dst_size = dst_name_to_die.GetSize ();
+ Log *log = nullptr; // (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO | DWARF_LOG_TYPE_COMPLETION));
+
+ // Is everything kosher so we can go through the members at top speed?
+ bool fast_path = true;
+
+ if (src_size != dst_size)
+ {
+ if (src_size != 0 && dst_size != 0)
+ {
+ if (log)
+ log->Printf("warning: trying to unique class DIE 0x%8.8x to 0x%8.8x, but they didn't have the same size (src=%d, dst=%d)",
+ src_class_die.GetOffset(),
+ dst_class_die.GetOffset(),
+ src_size,
+ dst_size);
+ }
+
+ fast_path = false;
+ }
+
+ uint32_t idx;
+
+ if (fast_path)
+ {
+ for (idx = 0; idx < src_size; ++idx)
+ {
+ src_die = src_name_to_die.GetValueAtIndexUnchecked (idx);
+ dst_die = dst_name_to_die.GetValueAtIndexUnchecked (idx);
+
+ if (src_die.Tag() != dst_die.Tag())
+ {
+ if (log)
+ log->Printf("warning: tried to unique class DIE 0x%8.8x to 0x%8.8x, but 0x%8.8x (%s) tags didn't match 0x%8.8x (%s)",
+ src_class_die.GetOffset(),
+ dst_class_die.GetOffset(),
+ src_die.GetOffset(),
+ src_die.GetTagAsCString(),
+ dst_die.GetOffset(),
+ dst_die.GetTagAsCString());
+ fast_path = false;
+ }
+
+ const char *src_name = src_die.GetMangledName ();
+ const char *dst_name = dst_die.GetMangledName ();
+
+ // Make sure the names match
+ if (src_name == dst_name || (strcmp (src_name, dst_name) == 0))
+ continue;
+
+ if (log)
+ log->Printf("warning: tried to unique class DIE 0x%8.8x to 0x%8.8x, but 0x%8.8x (%s) names didn't match 0x%8.8x (%s)",
+ src_class_die.GetOffset(),
+ dst_class_die.GetOffset(),
+ src_die.GetOffset(),
+ src_name,
+ dst_die.GetOffset(),
+ dst_name);
+
+ fast_path = false;
+ }
+ }
+
+ DWARFASTParserClang *src_dwarf_ast_parser = (DWARFASTParserClang *)src_die.GetDWARFParser();
+ DWARFASTParserClang *dst_dwarf_ast_parser = (DWARFASTParserClang *)dst_die.GetDWARFParser();
+
+ // Now do the work of linking the DeclContexts and Types.
+ if (fast_path)
+ {
+ // We can do this quickly. Just run across the tables index-for-index since
+ // we know each node has matching names and tags.
+ for (idx = 0; idx < src_size; ++idx)
+ {
+ src_die = src_name_to_die.GetValueAtIndexUnchecked (idx);
+ dst_die = dst_name_to_die.GetValueAtIndexUnchecked (idx);
+
+ clang::DeclContext *src_decl_ctx = src_dwarf_ast_parser->m_die_to_decl_ctx[src_die.GetDIE()];
+ if (src_decl_ctx)
+ {
+ if (log)
+ log->Printf ("uniquing decl context %p from 0x%8.8x for 0x%8.8x",
+ static_cast<void*>(src_decl_ctx),
+ src_die.GetOffset(), dst_die.GetOffset());
+ dst_dwarf_ast_parser->LinkDeclContextToDIE (src_decl_ctx, dst_die);
+ }
+ else
+ {
+ if (log)
+ log->Printf ("warning: tried to unique decl context from 0x%8.8x for 0x%8.8x, but none was found",
+ src_die.GetOffset(), dst_die.GetOffset());
+ }
+
+ Type *src_child_type = dst_die.GetDWARF()->GetDIEToType()[src_die.GetDIE()];
+ if (src_child_type)
+ {
+ if (log)
+ log->Printf ("uniquing type %p (uid=0x%" PRIx64 ") from 0x%8.8x for 0x%8.8x",
+ static_cast<void*>(src_child_type),
+ src_child_type->GetID(),
+ src_die.GetOffset(), dst_die.GetOffset());
+ dst_die.GetDWARF()->GetDIEToType()[dst_die.GetDIE()] = src_child_type;
+ }
+ else
+ {
+ if (log)
+ log->Printf ("warning: tried to unique lldb_private::Type from 0x%8.8x for 0x%8.8x, but none was found", src_die.GetOffset(), dst_die.GetOffset());
+ }
+ }
+ }
+ else
+ {
+ // We must do this slowly. For each member of the destination, look
+ // up a member in the source with the same name, check its tag, and
+ // unique them if everything matches up. Report failures.
+
+ if (!src_name_to_die.IsEmpty() && !dst_name_to_die.IsEmpty())
+ {
+ src_name_to_die.Sort();
+
+ for (idx = 0; idx < dst_size; ++idx)
+ {
+ const char *dst_name = dst_name_to_die.GetCStringAtIndex(idx);
+ dst_die = dst_name_to_die.GetValueAtIndexUnchecked(idx);
+ src_die = src_name_to_die.Find(dst_name, DWARFDIE());
+
+ if (src_die && (src_die.Tag() == dst_die.Tag()))
+ {
+ clang::DeclContext *src_decl_ctx = src_dwarf_ast_parser->m_die_to_decl_ctx[src_die.GetDIE()];
+ if (src_decl_ctx)
+ {
+ if (log)
+ log->Printf ("uniquing decl context %p from 0x%8.8x for 0x%8.8x",
+ static_cast<void*>(src_decl_ctx),
+ src_die.GetOffset(),
+ dst_die.GetOffset());
+ dst_dwarf_ast_parser->LinkDeclContextToDIE (src_decl_ctx, dst_die);
+ }
+ else
+ {
+ if (log)
+ log->Printf ("warning: tried to unique decl context from 0x%8.8x for 0x%8.8x, but none was found", src_die.GetOffset(), dst_die.GetOffset());
+ }
+
+ Type *src_child_type = dst_die.GetDWARF()->GetDIEToType()[src_die.GetDIE()];
+ if (src_child_type)
+ {
+ if (log)
+ log->Printf ("uniquing type %p (uid=0x%" PRIx64 ") from 0x%8.8x for 0x%8.8x",
+ static_cast<void*>(src_child_type),
+ src_child_type->GetID(),
+ src_die.GetOffset(),
+ dst_die.GetOffset());
+ dst_die.GetDWARF()->GetDIEToType()[dst_die.GetDIE()] = src_child_type;
+ }
+ else
+ {
+ if (log)
+ log->Printf ("warning: tried to unique lldb_private::Type from 0x%8.8x for 0x%8.8x, but none was found", src_die.GetOffset(), dst_die.GetOffset());
+ }
+ }
+ else
+ {
+ if (log)
+ log->Printf ("warning: couldn't find a match for 0x%8.8x", dst_die.GetOffset());
+
+ failures.Append(dst_die);
+ }
+ }
+ }
+ }
+
+ const uint32_t src_size_artificial = src_name_to_die_artificial.GetSize ();
+ const uint32_t dst_size_artificial = dst_name_to_die_artificial.GetSize ();
+
+ if (src_size_artificial && dst_size_artificial)
+ {
+ dst_name_to_die_artificial.Sort();
+
+ for (idx = 0; idx < src_size_artificial; ++idx)
+ {
+ const char *src_name_artificial = src_name_to_die_artificial.GetCStringAtIndex(idx);
+ src_die = src_name_to_die_artificial.GetValueAtIndexUnchecked (idx);
+ dst_die = dst_name_to_die_artificial.Find(src_name_artificial, DWARFDIE());
+
+ if (dst_die)
+ {
+ // Both classes have the artificial types, link them
+ clang::DeclContext *src_decl_ctx = src_dwarf_ast_parser->m_die_to_decl_ctx[src_die.GetDIE()];
+ if (src_decl_ctx)
+ {
+ if (log)
+ log->Printf ("uniquing decl context %p from 0x%8.8x for 0x%8.8x",
+ static_cast<void*>(src_decl_ctx),
+ src_die.GetOffset(), dst_die.GetOffset());
+ dst_dwarf_ast_parser->LinkDeclContextToDIE (src_decl_ctx, dst_die);
+ }
+ else
+ {
+ if (log)
+ log->Printf ("warning: tried to unique decl context from 0x%8.8x for 0x%8.8x, but none was found", src_die.GetOffset(), dst_die.GetOffset());
+ }
+
+ Type *src_child_type = dst_die.GetDWARF()->GetDIEToType()[src_die.GetDIE()];
+ if (src_child_type)
+ {
+ if (log)
+ log->Printf ("uniquing type %p (uid=0x%" PRIx64 ") from 0x%8.8x for 0x%8.8x",
+ static_cast<void*>(src_child_type),
+ src_child_type->GetID(),
+ src_die.GetOffset(), dst_die.GetOffset());
+ dst_die.GetDWARF()->GetDIEToType()[dst_die.GetDIE()] = src_child_type;
+ }
+ else
+ {
+ if (log)
+ log->Printf ("warning: tried to unique lldb_private::Type from 0x%8.8x for 0x%8.8x, but none was found", src_die.GetOffset(), dst_die.GetOffset());
+ }
+ }
+ }
+ }
+
+ if (dst_size_artificial)
+ {
+ for (idx = 0; idx < dst_size_artificial; ++idx)
+ {
+ const char *dst_name_artificial = dst_name_to_die_artificial.GetCStringAtIndex(idx);
+ dst_die = dst_name_to_die_artificial.GetValueAtIndexUnchecked (idx);
+ if (log)
+ log->Printf ("warning: need to create artificial method for 0x%8.8x for method '%s'", dst_die.GetOffset(), dst_name_artificial);
+
+ failures.Append(dst_die);
+ }
+ }
+
+ return (failures.Size() != 0);
+}
+
+
+bool
+DWARFASTParserClang::LayoutRecordType(const clang::RecordDecl *record_decl,
+ uint64_t &bit_size,
+ uint64_t &alignment,
+ llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets)
+{
+ RecordDeclToLayoutMap::iterator pos = m_record_decl_to_layout_map.find (record_decl);
+ bool success = false;
+ base_offsets.clear();
+ vbase_offsets.clear();
+ if (pos != m_record_decl_to_layout_map.end())
+ {
+ bit_size = pos->second.bit_size;
+ alignment = pos->second.alignment;
+ field_offsets.swap(pos->second.field_offsets);
+ base_offsets.swap (pos->second.base_offsets);
+ vbase_offsets.swap (pos->second.vbase_offsets);
+ m_record_decl_to_layout_map.erase(pos);
+ success = true;
+ }
+ else
+ {
+ bit_size = 0;
+ alignment = 0;
+ field_offsets.clear();
+ }
+ return success;
+}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h b/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
new file mode 100644
index 000000000000..3814758fdd2c
--- /dev/null
+++ b/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -0,0 +1,213 @@
+//===-- DWARFASTParserClang.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_DWARFASTParserClang_h_
+#define SymbolFileDWARF_DWARFASTParserClang_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
+#include "clang/AST/CharUnits.h"
+
+// Project includes
+#include "lldb/Core/ClangForward.h"
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "DWARFDefines.h"
+#include "DWARFASTParser.h"
+
+class DWARFDebugInfoEntry;
+class DWARFDIECollection;
+
+class DWARFASTParserClang : public DWARFASTParser
+{
+public:
+ DWARFASTParserClang (lldb_private::ClangASTContext &ast);
+
+ ~DWARFASTParserClang() override;
+
+ lldb::TypeSP
+ ParseTypeFromDWARF (const lldb_private::SymbolContext& sc,
+ const DWARFDIE &die,
+ lldb_private::Log *log,
+ bool *type_is_new_ptr) override;
+
+
+ lldb_private::Function *
+ ParseFunctionFromDWARF (const lldb_private::SymbolContext& sc,
+ const DWARFDIE &die) override;
+
+ bool
+ CanCompleteType (const lldb_private::CompilerType &compiler_type) override;
+
+ bool
+ CompleteType (const lldb_private::CompilerType &compiler_type) override;
+
+ bool
+ CompleteTypeFromDWARF (const DWARFDIE &die,
+ lldb_private::Type *type,
+ lldb_private::CompilerType &compiler_type) override;
+
+ lldb_private::CompilerDecl
+ GetDeclForUIDFromDWARF (const DWARFDIE &die) override;
+
+ std::vector<DWARFDIE>
+ GetDIEForDeclContext (lldb_private::CompilerDeclContext decl_context) override;
+
+ lldb_private::CompilerDeclContext
+ GetDeclContextForUIDFromDWARF (const DWARFDIE &die) override;
+
+ lldb_private::CompilerDeclContext
+ GetDeclContextContainingUIDFromDWARF (const DWARFDIE &die) override;
+
+ bool
+ LayoutRecordType(const clang::RecordDecl *record_decl,
+ uint64_t &bit_size,
+ uint64_t &alignment,
+ llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets);
+
+protected:
+ class DelayedAddObjCClassProperty;
+ typedef std::vector <DelayedAddObjCClassProperty> DelayedPropertyList;
+
+ struct LayoutInfo
+ {
+ LayoutInfo () :
+ bit_size(0),
+ alignment(0),
+ field_offsets(),
+ base_offsets(),
+ vbase_offsets()
+ {
+ }
+ uint64_t bit_size;
+ uint64_t alignment;
+ llvm::DenseMap<const clang::FieldDecl *, uint64_t> field_offsets;
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> base_offsets;
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> vbase_offsets;
+ };
+
+ clang::BlockDecl *
+ ResolveBlockDIE (const DWARFDIE &die);
+
+ clang::NamespaceDecl *
+ ResolveNamespaceDIE (const DWARFDIE &die);
+
+ typedef llvm::DenseMap<const clang::RecordDecl *, LayoutInfo> RecordDeclToLayoutMap;
+
+ bool
+ ParseTemplateDIE (const DWARFDIE &die,
+ lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos);
+ bool
+ ParseTemplateParameterInfos (const DWARFDIE &parent_die,
+ lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos);
+
+ bool
+ ParseChildMembers (const lldb_private::SymbolContext& sc,
+ const DWARFDIE &die,
+ lldb_private::CompilerType &class_compiler_type,
+ const lldb::LanguageType class_language,
+ std::vector<clang::CXXBaseSpecifier *>& base_classes,
+ std::vector<int>& member_accessibilities,
+ DWARFDIECollection& member_function_dies,
+ DelayedPropertyList& delayed_properties,
+ lldb::AccessType &default_accessibility,
+ bool &is_a_class,
+ LayoutInfo &layout_info);
+
+ size_t
+ ParseChildParameters (const lldb_private::SymbolContext& sc,
+ clang::DeclContext *containing_decl_ctx,
+ const DWARFDIE &parent_die,
+ bool skip_artificial,
+ bool &is_static,
+ bool &is_variadic,
+ std::vector<lldb_private::CompilerType>& function_args,
+ std::vector<clang::ParmVarDecl*>& function_param_decls,
+ unsigned &type_quals);
+
+ void
+ ParseChildArrayInfo (const lldb_private::SymbolContext& sc,
+ const DWARFDIE &parent_die,
+ int64_t& first_index,
+ std::vector<uint64_t>& element_orders,
+ uint32_t& byte_stride,
+ uint32_t& bit_stride);
+
+ size_t
+ ParseChildEnumerators (const lldb_private::SymbolContext& sc,
+ lldb_private::CompilerType &compiler_type,
+ bool is_signed,
+ uint32_t enumerator_byte_size,
+ const DWARFDIE &parent_die);
+
+ lldb_private::Type *
+ GetTypeForDIE (const DWARFDIE &die);
+
+ clang::Decl *
+ GetClangDeclForDIE (const DWARFDIE &die);
+
+ clang::DeclContext *
+ GetClangDeclContextForDIE (const DWARFDIE &die);
+
+ clang::DeclContext *
+ GetClangDeclContextContainingDIE (const DWARFDIE &die,
+ DWARFDIE *decl_ctx_die);
+
+ bool
+ CopyUniqueClassMethodTypes (const DWARFDIE &src_class_die,
+ const DWARFDIE &dst_class_die,
+ lldb_private::Type *class_type,
+ DWARFDIECollection &failures);
+
+ clang::DeclContext *
+ GetCachedClangDeclContextForDIE (const DWARFDIE &die);
+
+ void
+ LinkDeclContextToDIE (clang::DeclContext *decl_ctx,
+ const DWARFDIE &die);
+
+ void
+ LinkDeclToDIE (clang::Decl *decl, const DWARFDIE &die);
+
+ lldb_private::ClangASTImporter &
+ GetClangASTImporter();
+
+ 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;
+ typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *> DIEToDeclContextMap;
+ //typedef llvm::DenseMap<const clang::DeclContext *, DIEPointerSet> DeclContextToDIEMap;
+ typedef std::multimap<const clang::DeclContext *, const DWARFDIE> DeclContextToDIEMap;
+ typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::Decl *> DIEToDeclMap;
+ typedef llvm::DenseMap<const clang::Decl *, DIEPointerSet> DeclToDIEMap;
+
+ lldb_private::ClangASTContext &m_ast;
+ DIEToDeclMap m_die_to_decl;
+ DeclToDIEMap m_decl_to_die;
+ DIEToDeclContextMap m_die_to_decl_ctx;
+ DeclContextToDIEMap m_decl_ctx_to_die;
+ RecordDeclToLayoutMap m_record_decl_to_layout_map;
+ std::unique_ptr<lldb_private::ClangASTImporter> m_clang_ast_importer_ap;
+};
+
+#endif // SymbolFileDWARF_DWARFASTParserClang_h_
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp b/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp
new file mode 100644
index 000000000000..bde2694461e2
--- /dev/null
+++ b/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp
@@ -0,0 +1,828 @@
+//===-- DWARFASTParserGo.cpp ---------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "DWARFASTParserGo.h"
+
+#include "DWARFASTParserGo.h"
+#include "DWARFCompileUnit.h"
+#include "DWARFDebugInfo.h"
+#include "DWARFDeclContext.h"
+#include "DWARFDefines.h"
+#include "DWARFDIE.h"
+#include "DWARFDIECollection.h"
+#include "SymbolFileDWARF.h"
+#include "SymbolFileDWARFDebugMap.h"
+#include "UniqueDWARFASTType.h"
+
+#include "clang/Basic/Specifiers.h"
+
+#include "lldb/Core/Module.h"
+#include "lldb/Core/Value.h"
+#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/TypeList.h"
+
+//#define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN
+
+#ifdef ENABLE_DEBUG_PRINTF
+#include <stdio.h>
+#define DEBUG_PRINTF(fmt, ...) printf(fmt, __VA_ARGS__)
+#else
+#define DEBUG_PRINTF(fmt, ...)
+#endif
+
+#define DW_AT_go_kind 0x2900
+#define DW_AT_go_key 0x2901
+#define DW_AT_go_elem 0x2902
+
+using namespace lldb;
+using namespace lldb_private;
+DWARFASTParserGo::DWARFASTParserGo(GoASTContext &ast)
+ : m_ast(ast)
+{
+}
+
+DWARFASTParserGo::~DWARFASTParserGo()
+{
+}
+
+TypeSP
+DWARFASTParserGo::ParseTypeFromDWARF(const lldb_private::SymbolContext &sc, const DWARFDIE &die, lldb_private::Log *log,
+ bool *type_is_new_ptr)
+{
+ TypeSP type_sp;
+
+ if (type_is_new_ptr)
+ *type_is_new_ptr = false;
+
+ if (die)
+ {
+ SymbolFileDWARF *dwarf = die.GetDWARF();
+ if (log)
+ {
+ dwarf->GetObjectFile()->GetModule()->LogMessage(
+ log, "DWARFASTParserGo::ParseTypeFromDWARF (die = 0x%8.8x) %s name = '%s')", die.GetOffset(),
+ DW_TAG_value_to_name(die.Tag()), die.GetName());
+ }
+
+ Type *type_ptr = dwarf->m_die_to_type.lookup(die.GetDIE());
+ TypeList *type_list = dwarf->GetTypeList();
+ if (type_ptr == NULL)
+ {
+ if (type_is_new_ptr)
+ *type_is_new_ptr = true;
+
+ const dw_tag_t tag = die.Tag();
+
+ bool is_forward_declaration = false;
+ DWARFAttributes attributes;
+ const char *type_name_cstr = NULL;
+ ConstString type_name_const_str;
+ Type::ResolveState resolve_state = Type::eResolveStateUnresolved;
+ uint64_t byte_size = 0;
+ uint64_t go_kind = 0;
+ Declaration decl;
+
+ Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID;
+ CompilerType compiler_type;
+ DWARFFormValue form_value;
+
+ dw_attr_t attr;
+
+ switch (tag)
+ {
+ case DW_TAG_base_type:
+ case DW_TAG_pointer_type:
+ case DW_TAG_typedef:
+ case DW_TAG_unspecified_type:
+ {
+ // Set a bit that lets us know that we are currently parsing this
+ dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
+
+ const size_t num_attributes = die.GetAttributes(attributes);
+ lldb::user_id_t encoding_uid = LLDB_INVALID_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_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:
+ // = form_value.Unsigned();
+ break;
+ case DW_AT_type:
+ encoding_uid = form_value.Reference();
+ break;
+ case DW_AT_go_kind:
+ go_kind = form_value.Unsigned();
+ break;
+ default:
+ // Do we care about DW_AT_go_key or DW_AT_go_elem?
+ break;
+ }
+ }
+ }
+ }
+
+ DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\") type => 0x%8.8lx\n", dwarf->MakeUserID(die.GetOffset()),
+ DW_TAG_value_to_name(tag), type_name_cstr, encoding_uid);
+
+ switch (tag)
+ {
+ default:
+ break;
+
+ case DW_TAG_unspecified_type:
+ resolve_state = Type::eResolveStateFull;
+ compiler_type = m_ast.CreateVoidType(type_name_const_str);
+ break;
+
+ case DW_TAG_base_type:
+ resolve_state = Type::eResolveStateFull;
+ compiler_type = m_ast.CreateBaseType(go_kind, type_name_const_str, byte_size);
+ break;
+
+ case DW_TAG_pointer_type:
+ encoding_data_type = Type::eEncodingIsPointerUID;
+ break;
+ case DW_TAG_typedef:
+ encoding_data_type = Type::eEncodingIsTypedefUID;
+ CompilerType impl;
+ Type *type = dwarf->ResolveTypeUID(encoding_uid);
+ if (type)
+ {
+ if (go_kind == 0 && type->GetName() == type_name_const_str)
+ {
+ // Go emits extra typedefs as a forward declaration. Ignore these.
+ dwarf->m_die_to_type[die.GetDIE()] = type;
+ return type->shared_from_this();
+ }
+ impl = type->GetForwardCompilerType();
+ compiler_type = m_ast.CreateTypedefType (go_kind, type_name_const_str, impl);
+ }
+ break;
+ }
+
+ type_sp.reset(new Type(dwarf->MakeUserID(die.GetOffset()), dwarf, type_name_const_str, byte_size,
+ NULL, encoding_uid, encoding_data_type, &decl, compiler_type, resolve_state));
+
+ dwarf->m_die_to_type[die.GetDIE()] = type_sp.get();
+ }
+ break;
+
+ case DW_TAG_structure_type:
+ {
+ // Set a bit that lets us know that we are currently parsing this
+ dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
+ bool byte_size_valid = 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_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_go_kind:
+ go_kind = form_value.Unsigned();
+ break;
+
+ // TODO: Should we use SLICETYPE's DW_AT_go_elem?
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ // TODO(ribrdb): Do we need this?
+
+ // 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());
+
+ // Only try and unique the type if it has a name.
+ if (type_name_const_str &&
+ dwarf->GetUniqueDWARFASTTypeMap().Find(type_name_const_str, die, decl,
+ byte_size_valid ? byte_size : -1, *unique_ast_entry_ap))
+ {
+ // We have already parsed this type or from another
+ // compile unit. GCC loves to use the "one definition
+ // rule" which can result in multiple definitions
+ // of the same class over and over in each compile
+ // unit.
+ type_sp = unique_ast_entry_ap->m_type_sp;
+ if (type_sp)
+ {
+ dwarf->m_die_to_type[die.GetDIE()] = type_sp.get();
+ return type_sp;
+ }
+ }
+
+ DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", dwarf->MakeUserID(die.GetOffset()),
+ DW_TAG_value_to_name(tag), type_name_cstr);
+
+ bool compiler_type_was_created = false;
+ compiler_type.SetCompilerType(&m_ast, dwarf->m_forward_decl_die_to_clang_type.lookup(die.GetDIE()));
+ if (!compiler_type)
+ {
+ compiler_type_was_created = true;
+ compiler_type = m_ast.CreateStructType(go_kind, type_name_const_str, byte_size);
+ }
+
+ type_sp.reset(new Type(dwarf->MakeUserID(die.GetOffset()), dwarf, type_name_const_str, byte_size,
+ NULL, LLDB_INVALID_UID, Type::eEncodingIsUID, &decl, compiler_type,
+ Type::eResolveStateForward));
+
+ // 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 = decl;
+ unique_ast_entry_ap->m_byte_size = byte_size;
+ dwarf->GetUniqueDWARFASTTypeMap().Insert(type_name_const_str, *unique_ast_entry_ap);
+
+ 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() == false)
+ {
+ // No children for this struct/union/class, lets finish it
+ m_ast.CompleteStructType(compiler_type);
+ }
+ else if (compiler_type_was_created)
+ {
+ // 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.
+ dwarf->m_forward_decl_die_to_clang_type[die.GetDIE()] = compiler_type.GetOpaqueQualType();
+ dwarf->m_forward_decl_clang_type_to_die[compiler_type.GetOpaqueQualType()] = die.GetDIERef();
+ // SetHasExternalStorage (compiler_type.GetOpaqueQualType(), true);
+ }
+ }
+ }
+ break;
+
+ case DW_TAG_subprogram:
+ case DW_TAG_subroutine_type:
+ {
+ // Set a bit that lets us know that we are currently parsing this
+ dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
+
+ bool is_variadic = false;
+ 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_name:
+ type_name_cstr = form_value.AsCString();
+ type_name_const_str.SetCString(type_name_cstr);
+ 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_high_pc:
+ case DW_AT_low_pc:
+ break;
+ }
+ }
+ }
+ }
+
+ DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", dwarf->MakeUserID(die.GetOffset()),
+ DW_TAG_value_to_name(tag), type_name_cstr);
+
+ std::vector<CompilerType> function_param_types;
+
+ // Parse the function children for the parameters
+
+ if (die.HasChildren())
+ {
+ ParseChildParameters(sc, die, is_variadic, function_param_types);
+ }
+
+ // compiler_type will get the function prototype clang type after this call
+ compiler_type = m_ast.CreateFunctionType(type_name_const_str, function_param_types.data(),
+ function_param_types.size(), is_variadic);
+
+ type_sp.reset(new Type(dwarf->MakeUserID(die.GetOffset()), dwarf, type_name_const_str, 0, NULL,
+ LLDB_INVALID_UID, Type::eEncodingIsUID, &decl, compiler_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->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
+
+ lldb::user_id_t type_die_offset = DW_INVALID_OFFSET;
+ int64_t first_index = 0;
+ uint32_t byte_stride = 0;
+ uint32_t bit_stride = 0;
+ 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_name:
+ type_name_cstr = form_value.AsCString();
+ type_name_const_str.SetCString(type_name_cstr);
+ break;
+
+ case DW_AT_type:
+ type_die_offset = form_value.Reference();
+ break;
+ case DW_AT_byte_size:
+ break; // byte_size = form_value.Unsigned(); break;
+ case DW_AT_go_kind:
+ go_kind = form_value.Unsigned();
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", dwarf->MakeUserID(die.GetOffset()),
+ DW_TAG_value_to_name(tag), type_name_cstr);
+
+ Type *element_type = dwarf->ResolveTypeUID(type_die_offset);
+
+ if (element_type)
+ {
+ std::vector<uint64_t> element_orders;
+ ParseChildArrayInfo(sc, die, first_index, element_orders, byte_stride, bit_stride);
+ if (byte_stride == 0)
+ byte_stride = element_type->GetByteSize();
+ CompilerType array_element_type = element_type->GetForwardCompilerType();
+ if (element_orders.size() > 0)
+ {
+ if (element_orders.size() > 1)
+ printf("golang: unsupported multi-dimensional array %s\n", type_name_cstr);
+ compiler_type =
+ m_ast.CreateArrayType(type_name_const_str, array_element_type, element_orders[0]);
+ }
+ else
+ {
+ compiler_type = m_ast.CreateArrayType(type_name_const_str, array_element_type, 0);
+ }
+ type_sp.reset(new Type(dwarf->MakeUserID(die.GetOffset()), dwarf, type_name_const_str,
+ byte_stride, NULL, type_die_offset, Type::eEncodingIsUID, &decl,
+ compiler_type, Type::eResolveStateFull));
+ type_sp->SetEncodingType(element_type);
+ }
+ }
+ }
+ 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)
+ {
+ symbol_context_scope = sc.comp_unit;
+ }
+ else if (sc.function != NULL && sc_parent_die)
+ {
+ symbol_context_scope =
+ sc.function->GetBlock(true).FindBlockByID(dwarf->MakeUserID(sc_parent_die.GetOffset()));
+ if (symbol_context_scope == NULL)
+ symbol_context_scope = sc.function;
+ }
+
+ 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->m_die_to_type[die.GetDIE()] = type_sp.get();
+ }
+ }
+ else if (type_ptr != DIE_IS_BEING_PARSED)
+ {
+ type_sp = type_ptr->shared_from_this();
+ }
+ }
+ return type_sp;
+}
+
+size_t
+DWARFASTParserGo::ParseChildParameters(const SymbolContext &sc,
+
+ const DWARFDIE &parent_die, bool &is_variadic,
+ std::vector<CompilerType> &function_param_types)
+{
+ if (!parent_die)
+ return 0;
+
+ size_t arg_idx = 0;
+ for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid(); die = die.GetSibling())
+ {
+
+ dw_tag_t tag = die.Tag();
+ switch (tag)
+ {
+ case DW_TAG_formal_parameter:
+ {
+ DWARFAttributes attributes;
+ const size_t num_attributes = die.GetAttributes(attributes);
+ if (num_attributes > 0)
+ {
+ Declaration decl;
+ dw_offset_t param_type_die_offset = DW_INVALID_OFFSET;
+
+ uint32_t i;
+ for (i = 0; i < num_attributes; ++i)
+ {
+ const dw_attr_t attr = attributes.AttributeAtIndex(i);
+ DWARFFormValue form_value;
+ if (attributes.ExtractFormValueAtIndex(i, form_value))
+ {
+ switch (attr)
+ {
+ case DW_AT_name:
+ // = form_value.AsCString();
+ break;
+ case DW_AT_type:
+ param_type_die_offset = form_value.Reference();
+ break;
+ case DW_AT_location:
+ // if (form_value.BlockData())
+ // {
+ // const DWARFDataExtractor& debug_info_data =
+ // debug_info();
+ // uint32_t block_length = form_value.Unsigned();
+ // DWARFDataExtractor location(debug_info_data,
+ // form_value.BlockData() - debug_info_data.GetDataStart(),
+ // block_length);
+ // }
+ // else
+ // {
+ // }
+ // break;
+ default:
+ break;
+ }
+ }
+ }
+
+ Type *type = parent_die.ResolveTypeUID(param_type_die_offset);
+ if (type)
+ {
+ function_param_types.push_back(type->GetForwardCompilerType());
+ }
+ }
+ arg_idx++;
+ }
+ break;
+
+ case DW_TAG_unspecified_parameters:
+ is_variadic = true;
+ break;
+
+ default:
+ break;
+ }
+ }
+ return arg_idx;
+}
+
+void
+DWARFASTParserGo::ParseChildArrayInfo(const SymbolContext &sc, const DWARFDIE &parent_die, int64_t &first_index,
+ std::vector<uint64_t> &element_orders, uint32_t &byte_stride,
+ uint32_t &bit_stride)
+{
+ if (!parent_die)
+ return;
+
+ for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid(); die = die.GetSibling())
+ {
+ const dw_tag_t tag = die.Tag();
+ switch (tag)
+ {
+ case DW_TAG_subrange_type:
+ {
+ DWARFAttributes attributes;
+ const size_t num_child_attributes = die.GetAttributes(attributes);
+ if (num_child_attributes > 0)
+ {
+ uint64_t num_elements = 0;
+ uint32_t i;
+ for (i = 0; i < num_child_attributes; ++i)
+ {
+ const dw_attr_t attr = attributes.AttributeAtIndex(i);
+ DWARFFormValue form_value;
+ if (attributes.ExtractFormValueAtIndex(i, form_value))
+ {
+ switch (attr)
+ {
+ case DW_AT_count:
+ num_elements = form_value.Unsigned();
+ break;
+
+ default:
+ case DW_AT_type:
+ break;
+ }
+ }
+ }
+
+ element_orders.push_back(num_elements);
+ }
+ }
+ break;
+ }
+ }
+}
+
+bool
+DWARFASTParserGo::CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type, CompilerType &compiler_type)
+{
+ if (!die)
+ return false;
+
+ const dw_tag_t tag = die.Tag();
+
+ SymbolFileDWARF *dwarf = die.GetDWARF();
+ Log *log = nullptr; // (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO|DWARF_LOG_TYPE_COMPLETION));
+ if (log)
+ dwarf->GetObjectFile()->GetModule()->LogMessageVerboseBacktrace(
+ log, "0x%8.8" PRIx64 ": %s '%s' resolving forward declaration...", dwarf->MakeUserID(die.GetOffset()),
+ DW_TAG_value_to_name(tag), type->GetName().AsCString());
+ assert(compiler_type);
+ DWARFAttributes attributes;
+
+ switch (tag)
+ {
+ case DW_TAG_structure_type:
+ {
+ {
+ if (die.HasChildren())
+ {
+ SymbolContext sc(die.GetLLDBCompileUnit());
+
+ ParseChildMembers(sc, die, compiler_type);
+ }
+ }
+ m_ast.CompleteStructType(compiler_type);
+ return (bool)compiler_type;
+ }
+
+ default:
+ assert(false && "not a forward go type decl!");
+ break;
+ }
+
+ return false;
+}
+
+size_t
+DWARFASTParserGo::ParseChildMembers(const SymbolContext &sc, const DWARFDIE &parent_die, CompilerType &class_compiler_type)
+{
+ size_t count = 0;
+ uint32_t member_idx = 0;
+
+ ModuleSP module_sp = parent_die.GetDWARF()->GetObjectFile()->GetModule();
+ GoASTContext *ast = llvm::dyn_cast_or_null<GoASTContext>(class_compiler_type.GetTypeSystem());
+ if (ast == nullptr)
+ return 0;
+
+ for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid(); die = die.GetSibling())
+ {
+ dw_tag_t tag = die.Tag();
+
+ switch (tag)
+ {
+ case DW_TAG_member:
+ {
+ DWARFAttributes attributes;
+ const size_t num_attributes = die.GetAttributes(attributes);
+ if (num_attributes > 0)
+ {
+ Declaration decl;
+ const char *name = NULL;
+
+ lldb::user_id_t encoding_uid = LLDB_INVALID_UID;
+ uint32_t member_byte_offset = UINT32_MAX;
+ uint32_t i;
+ for (i = 0; i < num_attributes; ++i)
+ {
+ const dw_attr_t attr = attributes.AttributeAtIndex(i);
+ DWARFFormValue form_value;
+ if (attributes.ExtractFormValueAtIndex(i, form_value))
+ {
+ switch (attr)
+ {
+ case DW_AT_name:
+ name = form_value.AsCString();
+ break;
+ case DW_AT_type:
+ encoding_uid = form_value.Reference();
+ break;
+ case DW_AT_data_member_location:
+ if (form_value.BlockData())
+ {
+ Value initialValue(0);
+ Value memberOffset(0);
+ const DWARFDataExtractor &debug_info_data =
+ die.GetDWARF()->get_debug_info_data();
+ uint32_t block_length = form_value.Unsigned();
+ uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart();
+ if (DWARFExpression::Evaluate(NULL, // ExecutionContext *
+ NULL, // ClangExpressionVariableList *
+ NULL, // ClangExpressionDeclMap *
+ NULL, // RegisterContext *
+ module_sp, debug_info_data, die.GetCU(),
+ block_offset, block_length, eRegisterKindDWARF,
+ &initialValue, memberOffset, NULL))
+ {
+ member_byte_offset = memberOffset.ResolveValue(NULL).UInt();
+ }
+ }
+ else
+ {
+ // With DWARF 3 and later, if the value is an integer constant,
+ // this form value is the offset in bytes from the beginning
+ // of the containing entity.
+ member_byte_offset = form_value.Unsigned();
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ Type *member_type = die.ResolveTypeUID(encoding_uid);
+ if (member_type)
+ {
+ CompilerType member_go_type = member_type->GetFullCompilerType();
+ ConstString name_const_str(name);
+ m_ast.AddFieldToStruct(class_compiler_type, name_const_str, member_go_type, member_byte_offset);
+ }
+ }
+ ++member_idx;
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return count;
+}
+
+Function *
+DWARFASTParserGo::ParseFunctionFromDWARF(const SymbolContext &sc, const DWARFDIE &die)
+{
+ DWARFRangeList func_ranges;
+ const char *name = NULL;
+ const char *mangled = NULL;
+ 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());
+
+ assert(die.Tag() == DW_TAG_subprogram);
+
+ if (die.Tag() != DW_TAG_subprogram)
+ return NULL;
+
+ if (die.GetDIENamesAndRanges(name, mangled, func_ranges, decl_file, decl_line, decl_column, call_file, call_line,
+ call_column, &frame_base))
+ {
+ // Union of all ranges in the function DIE (if the function is discontiguous)
+ AddressRange func_range;
+ lldb::addr_t lowest_func_addr = func_ranges.GetMinRangeBase(0);
+ lldb::addr_t highest_func_addr = func_ranges.GetMaxRangeEnd(0);
+ if (lowest_func_addr != LLDB_INVALID_ADDRESS && lowest_func_addr <= highest_func_addr)
+ {
+ ModuleSP module_sp(die.GetModule());
+ func_range.GetBaseAddress().ResolveAddressUsingFileSections(lowest_func_addr, module_sp->GetSectionList());
+ if (func_range.GetBaseAddress().IsValid())
+ func_range.SetByteSize(highest_func_addr - lowest_func_addr);
+ }
+
+ if (func_range.GetBaseAddress().IsValid())
+ {
+ Mangled func_name;
+ func_name.SetValue(ConstString(name), false);
+
+ FunctionSP func_sp;
+ std::unique_ptr<Declaration> decl_ap;
+ if (decl_file != 0 || decl_line != 0 || decl_column != 0)
+ decl_ap.reset(new Declaration(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file), decl_line,
+ decl_column));
+
+ SymbolFileDWARF *dwarf = die.GetDWARF();
+ // Supply the type _only_ if it has already been parsed
+ Type *func_type = dwarf->m_die_to_type.lookup(die.GetDIE());
+
+ assert(func_type == NULL || func_type != DIE_IS_BEING_PARSED);
+
+ if (dwarf->FixupAddress(func_range.GetBaseAddress()))
+ {
+ const user_id_t func_user_id = dwarf->MakeUserID(die.GetOffset());
+ func_sp.reset(new Function(sc.comp_unit,
+ dwarf->MakeUserID(func_user_id), // UserID is the DIE offset
+ dwarf->MakeUserID(func_user_id), func_name, func_type,
+ func_range)); // first address range
+
+ if (func_sp.get() != NULL)
+ {
+ if (frame_base.IsValid())
+ func_sp->GetFrameBaseExpression() = frame_base;
+ sc.comp_unit->AddFunction(func_sp);
+ return func_sp.get();
+ }
+ }
+ }
+ }
+ return NULL;
+}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.h b/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.h
new file mode 100644
index 000000000000..5039fc7f7672
--- /dev/null
+++ b/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.h
@@ -0,0 +1,84 @@
+//===-- DWARFASTParserGo.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_DWARFASTParserGo_h_
+#define SymbolFileDWARF_DWARFASTParserGo_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
+
+// Project includes
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Symbol/GoASTContext.h"
+#include "DWARFDefines.h"
+#include "DWARFASTParser.h"
+#include "DWARFDIE.h"
+
+class DWARFDebugInfoEntry;
+class DWARFDIECollection;
+
+class DWARFASTParserGo : public DWARFASTParser
+{
+public:
+ DWARFASTParserGo(lldb_private::GoASTContext &ast);
+
+ ~DWARFASTParserGo() override;
+
+ lldb::TypeSP ParseTypeFromDWARF(const lldb_private::SymbolContext &sc, const DWARFDIE &die, lldb_private::Log *log,
+ bool *type_is_new_ptr) override;
+
+ lldb_private::Function *
+ ParseFunctionFromDWARF(const lldb_private::SymbolContext &sc,
+ const DWARFDIE &die) override;
+
+ bool
+ CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type,
+ lldb_private::CompilerType &go_type) override;
+
+ lldb_private::CompilerDeclContext
+ GetDeclContextForUIDFromDWARF(const DWARFDIE &die) override
+ {
+ return lldb_private::CompilerDeclContext();
+ }
+
+ lldb_private::CompilerDeclContext
+ GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die) override
+ {
+ return lldb_private::CompilerDeclContext();
+ }
+
+ lldb_private::CompilerDecl
+ GetDeclForUIDFromDWARF (const DWARFDIE &die) override
+ {
+ return lldb_private::CompilerDecl();
+ }
+
+ std::vector<DWARFDIE>
+ GetDIEForDeclContext (lldb_private::CompilerDeclContext decl_context) override
+ {
+ return std::vector<DWARFDIE>();
+ }
+
+private:
+ size_t ParseChildParameters(const lldb_private::SymbolContext &sc, const DWARFDIE &parent_die, bool &is_variadic,
+ std::vector<lldb_private::CompilerType> &function_param_types);
+ void ParseChildArrayInfo(const lldb_private::SymbolContext &sc, const DWARFDIE &parent_die, int64_t &first_index,
+ std::vector<uint64_t> &element_orders, uint32_t &byte_stride, uint32_t &bit_stride);
+
+ size_t ParseChildMembers(const lldb_private::SymbolContext &sc, const DWARFDIE &die,
+ lldb_private::CompilerType &class_compiler_type);
+
+ lldb_private::GoASTContext &m_ast;
+};
+
+#endif // SymbolFileDWARF_DWARFASTParserGo_h_
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp b/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
new file mode 100644
index 000000000000..a522bcb35288
--- /dev/null
+++ b/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
@@ -0,0 +1,90 @@
+//===-- DWARFAttribute.cpp --------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "DWARFAttribute.h"
+#include "DWARFDebugInfo.h"
+#include "DWARFCompileUnit.h"
+
+DWARFAttributes::DWARFAttributes() :
+ m_infos()
+{
+}
+
+DWARFAttributes::~DWARFAttributes()
+{
+}
+
+
+uint32_t
+DWARFAttributes::FindAttributeIndex(dw_attr_t attr) const
+{
+ collection::const_iterator end = m_infos.end();
+ collection::const_iterator beg = m_infos.begin();
+ collection::const_iterator pos;
+ for (pos = beg; pos != end; ++pos)
+ {
+ if (pos->attr.get_attr() == attr)
+ return std::distance(beg, pos);
+ }
+ return UINT32_MAX;
+}
+
+void
+DWARFAttributes::Append(const DWARFCompileUnit *cu, dw_offset_t attr_die_offset, dw_attr_t attr, dw_form_t form)
+{
+ AttributeValue attr_value = { cu, attr_die_offset, { attr, form } };
+ 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 DWARFCompileUnit *cu = CompileUnitAtIndex(i);
+ form_value.SetCompileUnit(cu);
+ form_value.SetForm(FormAtIndex(i));
+ lldb::offset_t offset = DIEOffsetAtIndex(i);
+ return form_value.ExtractValue(cu->GetSymbolFileDWARF()->get_debug_info_data(), &offset);
+}
+
+uint64_t
+DWARFAttributes::FormValueAsUnsigned (dw_attr_t attr, uint64_t fail_value) const
+{
+ const uint32_t attr_idx = FindAttributeIndex (attr);
+ if (attr_idx != UINT32_MAX)
+ return FormValueAsUnsignedAtIndex (attr_idx, fail_value);
+ return fail_value;
+}
+
+uint64_t
+DWARFAttributes::FormValueAsUnsignedAtIndex(uint32_t i, uint64_t fail_value) const
+{
+ DWARFFormValue form_value;
+ if (ExtractFormValueAtIndex(i, form_value))
+ return form_value.Reference();
+ return fail_value;
+}
+
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h b/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
index 40c8af3d6e8e..f5ca9cce525e 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
@@ -10,36 +10,72 @@
#ifndef SymbolFileDWARF_DWARFAttribute_h_
#define SymbolFileDWARF_DWARFAttribute_h_
+#include "llvm/ADT/SmallVector.h"
#include "DWARFDefines.h"
#include <vector>
+class DWARFCompileUnit;
+class DWARFFormValue;
+
class DWARFAttribute
{
public:
DWARFAttribute(dw_attr_t attr, dw_form_t form) :
- m_attr_form ( attr << 16 | form )
+ m_attr (attr),
+ m_form (form)
{
}
- void set(dw_attr_t attr, dw_form_t form) { m_attr_form = (attr << 16) | form; }
- void set_attr(dw_attr_t attr) { m_attr_form = (m_attr_form & 0x0000ffffu) | (attr << 16); }
- void set_form(dw_form_t form) { m_attr_form = (m_attr_form & 0xffff0000u) | form; }
- dw_attr_t get_attr() const { return m_attr_form >> 16; }
- dw_form_t get_form() const { return (dw_form_t)m_attr_form; }
- void get(dw_attr_t& attr, dw_form_t& form) const
+ void set (dw_attr_t attr, dw_form_t form) { 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) const
{
- uint32_t attr_form = m_attr_form;
- attr = attr_form >> 16;
- form = (dw_form_t)attr_form;
+ attr = m_attr;
+ form = m_form;
}
- bool operator == (const DWARFAttribute& rhs) const { return m_attr_form == rhs.m_attr_form; }
+ bool operator == (const DWARFAttribute& rhs) const { return m_attr == rhs.m_attr && m_form == rhs.m_form; }
typedef std::vector<DWARFAttribute> collection;
typedef collection::iterator iterator;
typedef collection::const_iterator const_iterator;
protected:
- uint32_t m_attr_form; // Upper 16 bits is attribute, lower 16 bits is form
+ dw_attr_t m_attr;
+ dw_form_t m_form;
};
+class DWARFAttributes
+{
+public:
+ DWARFAttributes();
+ ~DWARFAttributes();
+
+ void Append(const DWARFCompileUnit *cu, dw_offset_t attr_die_offset, dw_attr_t attr, dw_form_t form);
+ const DWARFCompileUnit * CompileUnitAtIndex(uint32_t i) const { return m_infos[i].cu; }
+ dw_offset_t DIEOffsetAtIndex(uint32_t i) const { return m_infos[i].die_offset; }
+ dw_attr_t AttributeAtIndex(uint32_t i) const { return m_infos[i].attr.get_attr(); }
+ 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;
+ 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(); }
+
+protected:
+ struct AttributeValue
+ {
+ const DWARFCompileUnit *cu; // Keep the compile unit with each attribute in case we have DW_FORM_ref_addr values
+ dw_offset_t die_offset;
+ DWARFAttribute attr;
+ };
+ typedef llvm::SmallVector<AttributeValue, 8> collection;
+ collection m_infos;
+};
+
#endif // SymbolFileDWARF_DWARFAttribute_h_
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
index 60933108c97a..e7cb2b413ad7 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -12,12 +12,13 @@
#include "lldb/Core/Mangled.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Stream.h"
+#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "Plugins/Language/ObjC/ObjCLanguage.h"
#include "DWARFDebugAbbrev.h"
#include "DWARFDebugAranges.h"
@@ -27,6 +28,7 @@
#include "LogChannelDWARF.h"
#include "NameToDIE.h"
#include "SymbolFileDWARF.h"
+#include "SymbolFileDWARFDwo.h"
#include "SymbolFileDWARFDebugMap.h"
using namespace lldb;
@@ -52,10 +54,16 @@ DWARFCompileUnit::DWARFCompileUnit(SymbolFileDWARF* dwarf2Data) :
m_producer_version_minor (0),
m_producer_version_update (0),
m_language_type (eLanguageTypeUnknown),
- m_is_dwarf64 (false)
+ m_is_dwarf64 (false),
+ m_is_optimized (eLazyBoolCalculate),
+ m_addr_base (0),
+ m_base_obj_offset (DW_INVALID_OFFSET)
{
}
+DWARFCompileUnit::~DWARFCompileUnit()
+{}
+
void
DWARFCompileUnit::Clear()
{
@@ -71,6 +79,9 @@ DWARFCompileUnit::Clear()
m_producer = eProducerInvalid;
m_language_type = eLanguageTypeUnknown;
m_is_dwarf64 = false;
+ m_is_optimized = eLazyBoolCalculate;
+ m_addr_base = 0;
+ m_base_obj_offset = DW_INVALID_OFFSET;
}
bool
@@ -128,6 +139,9 @@ DWARFCompileUnit::ClearDIEs(bool keep_compile_unit_die)
if (keep_compile_unit_die)
m_die_array.push_back(tmp_array.front());
}
+
+ if (m_dwo_symbol_file)
+ m_dwo_symbol_file->GetCompileUnit()->ClearDIEs(keep_compile_unit_die);
}
//----------------------------------------------------------------------
@@ -174,7 +188,8 @@ DWARFCompileUnit::ExtractDIEsIfNeeded (bool cu_die_only)
die_index_stack.reserve(32);
die_index_stack.push_back(0);
bool prev_die_had_children = false;
- const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize(), m_is_dwarf64);
+ DWARFFormValue::FixedFormSizes fixed_form_sizes =
+ DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize(), m_is_dwarf64);
while (offset < next_cu_offset &&
die.FastExtract (debug_info_data, this, fixed_form_sizes, &offset))
{
@@ -188,12 +203,12 @@ DWARFCompileUnit::ExtractDIEsIfNeeded (bool cu_die_only)
const bool null_die = die.IsNULL();
if (depth == 0)
{
- uint64_t base_addr = die.GetAttributeValueAsUnsigned(m_dwarf2Data, this, DW_AT_low_pc, LLDB_INVALID_ADDRESS);
+ if (initial_die_array_size == 0)
+ AddCompileUnitDIE(die);
+ uint64_t base_addr = die.GetAttributeValueAsAddress(m_dwarf2Data, this, DW_AT_low_pc, LLDB_INVALID_ADDRESS);
if (base_addr == LLDB_INVALID_ADDRESS)
- base_addr = die.GetAttributeValueAsUnsigned(m_dwarf2Data, this, DW_AT_entry_pc, 0);
+ base_addr = die.GetAttributeValueAsAddress(m_dwarf2Data, this, DW_AT_entry_pc, 0);
SetBaseAddress (base_addr);
- if (initial_die_array_size == 0)
- AddDIE (die);
if (cu_die_only)
return 1;
}
@@ -283,9 +298,83 @@ DWARFCompileUnit::ExtractDIEsIfNeeded (bool cu_die_only)
verbose_log->PutCString (strm.GetString().c_str());
}
- return m_die_array.size();
+ if (!m_dwo_symbol_file)
+ return m_die_array.size();
+
+ DWARFCompileUnit* dwo_cu = m_dwo_symbol_file->GetCompileUnit();
+ size_t dwo_die_count = dwo_cu->ExtractDIEsIfNeeded(cu_die_only);
+ return m_die_array.size() + dwo_die_count - 1; // We have 2 CU die, but we waht to count it only as one
}
+void
+DWARFCompileUnit::AddCompileUnitDIE(DWARFDebugInfoEntry& die)
+{
+ assert (m_die_array.empty() && "Compile unit DIE already added");
+ AddDIE(die);
+
+ DWARFDebugInfoEntry& cu_die = m_die_array.front();
+
+ const char* dwo_name = cu_die.GetAttributeValueAsString(m_dwarf2Data,
+ this,
+ DW_AT_GNU_dwo_name,
+ nullptr);
+ if (!dwo_name)
+ return;
+
+ FileSpec dwo_file(dwo_name, true);
+ if (dwo_file.IsRelative())
+ {
+ const char* comp_dir = cu_die.GetAttributeValueAsString(m_dwarf2Data,
+ this,
+ DW_AT_comp_dir,
+ nullptr);
+ if (!comp_dir)
+ return;
+
+ dwo_file.SetFile(comp_dir, true);
+ dwo_file.AppendPathComponent(dwo_name);
+ }
+
+ if (!dwo_file.Exists())
+ return;
+
+ DataBufferSP dwo_file_data_sp;
+ lldb::offset_t dwo_file_data_offset = 0;
+ ObjectFileSP dwo_obj_file = ObjectFile::FindPlugin(m_dwarf2Data->GetObjectFile()->GetModule(),
+ &dwo_file,
+ 0 /* file_offset */,
+ dwo_file.GetByteSize(),
+ dwo_file_data_sp,
+ dwo_file_data_offset);
+ if (dwo_obj_file == nullptr)
+ return;
+
+ std::unique_ptr<SymbolFileDWARFDwo> dwo_symbol_file(new SymbolFileDWARFDwo(dwo_obj_file, this));
+
+ DWARFCompileUnit* dwo_cu = dwo_symbol_file->GetCompileUnit();
+ if (!dwo_cu)
+ return; // Can't fetch the compile unit from the dwo file.
+
+ DWARFDIE dwo_cu_die = dwo_cu->GetCompileUnitDIEOnly();
+ if (!dwo_cu_die.IsValid())
+ return; // Can't fetch the compile unit DIE from the dwo file.
+
+ uint64_t main_dwo_id = cu_die.GetAttributeValueAsUnsigned(m_dwarf2Data,
+ 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)
+ return; // The 2 dwo ID isn't match. Don't use the dwo file as it belongs to a differectn compilation.
+
+ m_dwo_symbol_file = std::move(dwo_symbol_file);
+
+ dw_addr_t addr_base = cu_die.GetAttributeValueAsUnsigned(m_dwarf2Data,
+ this,
+ DW_AT_GNU_addr_base,
+ 0);
+ dwo_cu->SetAddrBase(addr_base, m_offset);
+}
dw_offset_t
DWARFCompileUnit::GetAbbrevOffset() const
@@ -373,6 +462,16 @@ DWARFCompileUnit::SetDefaultAddressSize(uint8_t addr_size)
g_default_addr_size = addr_size;
}
+lldb::user_id_t
+DWARFCompileUnit::GetID () const
+{
+ dw_offset_t local_id = m_base_obj_offset != DW_INVALID_OFFSET ? m_base_obj_offset : m_offset;
+ if (m_dwarf2Data)
+ return m_dwarf2Data->MakeUserID(local_id);
+ else
+ return local_id;
+}
+
void
DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
DWARFDebugAranges* debug_aranges)
@@ -381,13 +480,15 @@ DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
// 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 = GetCompileUnitDIEOnly();
+ const DWARFDebugInfoEntry* die = GetCompileUnitDIEPtrOnly();
const dw_offset_t cu_offset = GetOffset();
if (die)
{
- DWARFDebugRanges::RangeList ranges;
+ DWARFRangeList ranges;
const size_t num_ranges = die->GetAttributeAddressRanges(dwarf2Data, this, ranges, false);
if (num_ranges > 0)
{
@@ -397,7 +498,7 @@ DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
// this with recent GCC builds.
for (size_t i=0; i<num_ranges; ++i)
{
- const DWARFDebugRanges::RangeList::Entry &range = ranges.GetEntryRef(i);
+ const DWARFRangeList::Entry &range = ranges.GetEntryRef(i);
debug_aranges->AppendRange(cu_offset, range.GetRangeBase(), range.GetRangeEnd());
}
@@ -411,11 +512,11 @@ DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
// and then throwing them all away to keep memory usage down.
const bool clear_dies = ExtractDIEsIfNeeded (false) > 1;
- die = DIE();
+ die = DIEPtr();
if (die)
die->BuildAddressRangeTable(dwarf2Data, this, debug_aranges);
- if (debug_aranges->IsEmpty())
+ 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.
@@ -437,7 +538,6 @@ DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
{
const LineTable::FileAddressRanges::Entry &range = file_ranges.GetEntryRef(idx);
debug_aranges->AppendRange(cu_offset, range.GetRangeBase(), range.GetRangeEnd());
- printf ("0x%8.8x: [0x%16.16" PRIx64 " - 0x%16.16" PRIx64 ")\n", GetOffset(), range.GetRangeBase(), range.GetRangeEnd());
}
}
}
@@ -446,7 +546,7 @@ DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
}
}
- if (debug_aranges->IsEmpty())
+ 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.
@@ -465,7 +565,6 @@ DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
{
const LineTable::FileAddressRanges::Entry &range = file_ranges.GetEntryRef(idx);
debug_aranges->AppendRange(GetOffset(), range.GetRangeBase(), range.GetRangeEnd());
- printf ("0x%8.8x: [0x%16.16" PRIx64 " - 0x%16.16" PRIx64 ")\n", GetOffset(), range.GetRangeBase(), range.GetRangeEnd());
}
}
}
@@ -493,119 +592,85 @@ DWARFCompileUnit::GetFunctionAranges ()
"DWARFCompileUnit::GetFunctionAranges() for compile unit at .debug_info[0x%8.8x]",
GetOffset());
}
- const DWARFDebugInfoEntry* die = DIE();
+ const DWARFDebugInfoEntry* die = DIEPtr();
if (die)
die->BuildFunctionAddressRangeTable (m_dwarf2Data, this, m_func_aranges_ap.get());
+
+ if (m_dwo_symbol_file)
+ {
+ DWARFCompileUnit* 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());
+ }
+
const bool minimize = false;
m_func_aranges_ap->Sort(minimize);
}
return *m_func_aranges_ap.get();
}
-bool
-DWARFCompileUnit::LookupAddress
-(
- const dw_addr_t address,
- DWARFDebugInfoEntry** function_die_handle,
- DWARFDebugInfoEntry** block_die_handle
-)
+DWARFDIE
+DWARFCompileUnit::LookupAddress (const dw_addr_t address)
{
- bool success = false;
-
- if (function_die_handle != NULL && DIE())
+ if (DIE())
{
-
const DWARFDebugAranges &func_aranges = GetFunctionAranges ();
// Re-check the aranges auto pointer contents in case it was created above
if (!func_aranges.IsEmpty())
- {
- *function_die_handle = GetDIEPtr(func_aranges.FindAddress(address));
- if (*function_die_handle != NULL)
- {
- success = true;
- if (block_die_handle != NULL)
- {
- DWARFDebugInfoEntry* child = (*function_die_handle)->GetFirstChild();
- while (child)
- {
- if (child->LookupAddress(address, m_dwarf2Data, this, NULL, block_die_handle))
- break;
- child = child->GetSibling();
- }
- }
- }
- }
+ return GetDIE(func_aranges.FindAddress(address));
}
- return success;
+ return DWARFDIE();
}
//----------------------------------------------------------------------
// Compare function DWARFDebugAranges::Range structures
//----------------------------------------------------------------------
-static bool CompareDIEOffset (const DWARFDebugInfoEntry& die1, const DWARFDebugInfoEntry& die2)
+static bool CompareDIEOffset (const DWARFDebugInfoEntry& die, const dw_offset_t die_offset)
{
- return die1.GetOffset() < die2.GetOffset();
+ return die.GetOffset() < die_offset;
}
//----------------------------------------------------------------------
-// GetDIEPtr()
+// GetDIE()
//
-// Get the DIE (Debug Information Entry) with the specified offset.
+// 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.
//----------------------------------------------------------------------
-DWARFDebugInfoEntry*
-DWARFCompileUnit::GetDIEPtr(dw_offset_t die_offset)
+DWARFDIE
+DWARFCompileUnit::GetDIE (dw_offset_t die_offset)
{
if (die_offset != DW_INVALID_OFFSET)
{
- ExtractDIEsIfNeeded (false);
- DWARFDebugInfoEntry compare_die;
- compare_die.SetOffset(die_offset);
- DWARFDebugInfoEntry::iterator end = m_die_array.end();
- DWARFDebugInfoEntry::iterator pos = lower_bound(m_die_array.begin(), end, compare_die, CompareDIEOffset);
- if (pos != end)
- {
- if (die_offset == (*pos).GetOffset())
- return &(*pos);
- }
- }
- return NULL; // Not found in any compile units
-}
+ if (m_dwo_symbol_file)
+ return m_dwo_symbol_file->GetCompileUnit()->GetDIE(die_offset);
-//----------------------------------------------------------------------
-// GetDIEPtrContainingOffset()
-//
-// Get the DIE (Debug Information Entry) that contains the specified
-// .debug_info offset.
-//----------------------------------------------------------------------
-const DWARFDebugInfoEntry*
-DWARFCompileUnit::GetDIEPtrContainingOffset(dw_offset_t die_offset)
-{
- if (die_offset != DW_INVALID_OFFSET)
- {
- ExtractDIEsIfNeeded (false);
- DWARFDebugInfoEntry compare_die;
- compare_die.SetOffset(die_offset);
- DWARFDebugInfoEntry::iterator end = m_die_array.end();
- DWARFDebugInfoEntry::iterator pos = lower_bound(m_die_array.begin(), end, compare_die, CompareDIEOffset);
- if (pos != end)
+ if (ContainsDIEOffset(die_offset))
{
- if (die_offset >= (*pos).GetOffset())
+ ExtractDIEsIfNeeded (false);
+ DWARFDebugInfoEntry::iterator end = m_die_array.end();
+ DWARFDebugInfoEntry::iterator pos = lower_bound(m_die_array.begin(), end, die_offset, CompareDIEOffset);
+ if (pos != end)
{
- DWARFDebugInfoEntry::iterator next = pos + 1;
- if (next != end)
- {
- if (die_offset < (*next).GetOffset())
- return &(*pos);
- }
+ 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_dwarf2Data->DebugInfo()->GetDIE (DIERef(die_offset));
+ }
}
- return NULL; // Not found in any compile units
+ return DWARFDIE(); // Not found
}
-
-
size_t
DWARFCompileUnit::AppendDIEsWithTag (const dw_tag_t tag, DWARFDIECollection& dies, uint32_t depth) const
{
@@ -615,7 +680,7 @@ DWARFCompileUnit::AppendDIEsWithTag (const dw_tag_t tag, DWARFDIECollection& die
for (pos = m_die_array.begin(); pos != end; ++pos)
{
if (pos->Tag() == tag)
- dies.Append (&(*pos));
+ dies.Append (DWARFDIE(this, &(*pos)));
}
// Return the number of DIEs added to the collection
@@ -646,8 +711,7 @@ DWARFCompileUnit::AppendDIEsWithTag (const dw_tag_t tag, DWARFDIECollection& die
void
-DWARFCompileUnit::Index (const uint32_t cu_idx,
- NameToDIE& func_basenames,
+DWARFCompileUnit::Index (NameToDIE& func_basenames,
NameToDIE& func_fullnames,
NameToDIE& func_methods,
NameToDIE& func_selectors,
@@ -656,10 +720,6 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
NameToDIE& types,
NameToDIE& namespaces)
{
- const DWARFDataExtractor* debug_str = &m_dwarf2Data->get_debug_str_data();
-
- const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize(), m_is_dwarf64);
-
Log *log (LogChannelDWARF::GetLogIfAll (DWARF_LOG_LOOKUPS));
if (log)
@@ -670,9 +730,57 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
}
const LanguageType cu_language = GetLanguageType();
+ DWARFFormValue::FixedFormSizes fixed_form_sizes =
+ DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize(), m_is_dwarf64);
+
+ IndexPrivate(this,
+ cu_language,
+ fixed_form_sizes,
+ GetOffset(),
+ func_basenames,
+ func_fullnames,
+ func_methods,
+ func_selectors,
+ objc_class_selectors,
+ globals,
+ types,
+ namespaces);
+
+ SymbolFileDWARFDwo* dwo_symbol_file = GetDwoSymbolFile();
+ if (dwo_symbol_file)
+ {
+ IndexPrivate(dwo_symbol_file->GetCompileUnit(),
+ cu_language,
+ fixed_form_sizes,
+ GetOffset(),
+ func_basenames,
+ func_fullnames,
+ func_methods,
+ func_selectors,
+ objc_class_selectors,
+ globals,
+ types,
+ namespaces);
+ }
+}
+
+void
+DWARFCompileUnit::IndexPrivate (DWARFCompileUnit* dwarf_cu,
+ const LanguageType cu_language,
+ const DWARFFormValue::FixedFormSizes& fixed_form_sizes,
+ const dw_offset_t cu_offset,
+ NameToDIE& func_basenames,
+ NameToDIE& func_fullnames,
+ NameToDIE& func_methods,
+ NameToDIE& func_selectors,
+ NameToDIE& objc_class_selectors,
+ NameToDIE& globals,
+ NameToDIE& types,
+ NameToDIE& namespaces)
+{
DWARFDebugInfoEntry::const_iterator pos;
- DWARFDebugInfoEntry::const_iterator begin = m_die_array.begin();
- DWARFDebugInfoEntry::const_iterator end = m_die_array.end();
+ DWARFDebugInfoEntry::const_iterator begin = dwarf_cu->m_die_array.begin();
+ DWARFDebugInfoEntry::const_iterator end = dwarf_cu->m_die_array.end();
for (pos = begin; pos != end; ++pos)
{
const DWARFDebugInfoEntry &die = *pos;
@@ -701,17 +809,17 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
continue;
}
- DWARFDebugInfoEntry::Attributes attributes;
+ DWARFAttributes attributes;
const char *name = NULL;
const char *mangled_cstr = NULL;
bool is_declaration = false;
//bool is_artificial = false;
bool has_address = false;
- bool has_location = false;
+ bool has_location_or_const_value = false;
bool is_global_or_static_variable = false;
- dw_offset_t specification_die_offset = DW_INVALID_OFFSET;
- const size_t num_attributes = die.GetAttributes(m_dwarf2Data, this, fixed_form_sizes, attributes);
+ DWARFFormValue specification_die_form;
+ const size_t num_attributes = die.GetAttributes(dwarf_cu, fixed_form_sizes, attributes);
if (num_attributes > 0)
{
for (uint32_t i=0; i<num_attributes; ++i)
@@ -721,24 +829,24 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
switch (attr)
{
case DW_AT_name:
- if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
- name = form_value.AsCString(debug_str);
+ if (attributes.ExtractFormValueAtIndex(i, form_value))
+ name = form_value.AsCString();
break;
case DW_AT_declaration:
- if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
+ if (attributes.ExtractFormValueAtIndex(i, form_value))
is_declaration = form_value.Unsigned() != 0;
break;
// case DW_AT_artificial:
-// if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
+// if (attributes.ExtractFormValueAtIndex(i, form_value))
// is_artificial = form_value.Unsigned() != 0;
// break;
case DW_AT_MIPS_linkage_name:
case DW_AT_linkage_name:
- if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
- mangled_cstr = form_value.AsCString(debug_str);
+ if (attributes.ExtractFormValueAtIndex(i, form_value))
+ mangled_cstr = form_value.AsCString();
break;
case DW_AT_low_pc:
@@ -752,7 +860,8 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
break;
case DW_AT_location:
- has_location = true;
+ case DW_AT_const_value:
+ has_location_or_const_value = true;
if (tag == DW_TAG_variable)
{
const DWARFDebugInfoEntry* parent_die = die.GetParent();
@@ -800,8 +909,8 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
break;
case DW_AT_specification:
- if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
- specification_die_offset = form_value.Reference();
+ if (attributes.ExtractFormValueAtIndex(i, form_value))
+ specification_die_form = form_value;
break;
}
}
@@ -814,24 +923,22 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
{
if (name)
{
- // Note, this check is also done in ParseMethodName, but since this is a hot loop, we do the
- // simple inlined check outside the call.
- ObjCLanguageRuntime::MethodName objc_method(name, true);
+ 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());
- func_fullnames.Insert (ConstString(name), die.GetOffset());
+ func_fullnames.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset()));
if (objc_class_name_with_category)
- objc_class_selectors.Insert(objc_class_name_with_category, die.GetOffset());
+ 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)
- objc_class_selectors.Insert(objc_class_name_no_category, die.GetOffset());
+ objc_class_selectors.Insert(objc_class_name_no_category, DIERef(cu_offset, die.GetOffset()));
if (objc_selector_name)
- func_selectors.Insert (objc_selector_name, die.GetOffset());
+ func_selectors.Insert (objc_selector_name, DIERef(cu_offset, die.GetOffset()));
if (objc_fullname_no_category_name)
- func_fullnames.Insert (objc_fullname_no_category_name, die.GetOffset());
+ func_fullnames.Insert (objc_fullname_no_category_name, DIERef(cu_offset, die.GetOffset()));
}
// If we have a mangled name, then the DW_AT_name attribute
// is usually the method name without the class or any parameters
@@ -846,32 +953,23 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
}
else
{
- if (specification_die_offset != DW_INVALID_OFFSET)
+ if (specification_die_form.IsValid())
{
- const DWARFDebugInfoEntry *specification_die = m_dwarf2Data->DebugInfo()->GetDIEPtr (specification_die_offset, NULL);
- if (specification_die)
- {
- parent = specification_die->GetParent();
- if (parent)
- {
- parent_tag = parent->Tag();
-
- if (parent_tag == DW_TAG_class_type || parent_tag == DW_TAG_structure_type)
- is_method = true;
- }
- }
+ DWARFDIE specification_die = dwarf_cu->GetSymbolFileDWARF()->DebugInfo()->GetDIE (DIERef(specification_die_form));
+ if (specification_die.GetParent().IsStructOrClass())
+ is_method = true;
}
}
}
if (is_method)
- func_methods.Insert (ConstString(name), die.GetOffset());
+ func_methods.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset()));
else
- func_basenames.Insert (ConstString(name), die.GetOffset());
+ func_basenames.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset()));
if (!is_method && !mangled_cstr && !objc_method.IsValid(true))
- func_fullnames.Insert (ConstString(name), die.GetOffset());
+ func_fullnames.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset()));
}
if (mangled_cstr)
{
@@ -882,10 +980,10 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
if (name != mangled_cstr && ((mangled_cstr[0] == '_') || (name && ::strcmp(name, mangled_cstr) != 0)))
{
Mangled mangled (ConstString(mangled_cstr), true);
- func_fullnames.Insert (mangled.GetMangledName(), die.GetOffset());
+ func_fullnames.Insert (mangled.GetMangledName(), DIERef(cu_offset, die.GetOffset()));
ConstString demangled = mangled.GetDemangledName(cu_language);
if (demangled)
- func_fullnames.Insert (demangled, die.GetOffset());
+ func_fullnames.Insert (demangled, DIERef(cu_offset, die.GetOffset()));
}
}
}
@@ -895,7 +993,7 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
if (has_address)
{
if (name)
- func_basenames.Insert (ConstString(name), die.GetOffset());
+ func_basenames.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset()));
if (mangled_cstr)
{
// Make sure our mangled name isn't the same string table entry
@@ -905,14 +1003,14 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
if (name != mangled_cstr && ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0)))
{
Mangled mangled (ConstString(mangled_cstr), true);
- func_fullnames.Insert (mangled.GetMangledName(), die.GetOffset());
+ func_fullnames.Insert (mangled.GetMangledName(), DIERef(cu_offset, die.GetOffset()));
ConstString demangled = mangled.GetDemangledName(cu_language);
if (demangled)
- func_fullnames.Insert (demangled, die.GetOffset());
+ func_fullnames.Insert (demangled, DIERef(cu_offset, die.GetOffset()));
}
}
else
- func_fullnames.Insert (ConstString(name), die.GetOffset());
+ func_fullnames.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset()));
}
break;
@@ -928,19 +1026,19 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
case DW_TAG_unspecified_type:
if (name && is_declaration == false)
{
- types.Insert (ConstString(name), die.GetOffset());
+ types.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset()));
}
break;
case DW_TAG_namespace:
if (name)
- namespaces.Insert (ConstString(name), die.GetOffset());
+ namespaces.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset()));
break;
case DW_TAG_variable:
- if (name && has_location && is_global_or_static_variable)
+ if (name && has_location_or_const_value && is_global_or_static_variable)
{
- globals.Insert (ConstString(name), die.GetOffset());
+ globals.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset()));
// 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
@@ -953,10 +1051,10 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
if (mangled_cstr && name != mangled_cstr && ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0)))
{
Mangled mangled (ConstString(mangled_cstr), true);
- globals.Insert (mangled.GetMangledName(), die.GetOffset());
+ globals.Insert (mangled.GetMangledName(), DIERef(cu_offset, die.GetOffset()));
ConstString demangled = mangled.GetDemangledName(cu_language);
if (demangled)
- globals.Insert (demangled, die.GetOffset());
+ globals.Insert (demangled, DIERef(cu_offset, die.GetOffset()));
}
}
break;
@@ -1004,7 +1102,7 @@ DWARFCompileUnit::ParseProducerInfo ()
m_producer_version_minor = UINT32_MAX;
m_producer_version_update = UINT32_MAX;
- const DWARFDebugInfoEntry *die = GetCompileUnitDIEOnly();
+ const DWARFDebugInfoEntry *die = GetCompileUnitDIEPtrOnly();
if (die)
{
@@ -1095,10 +1193,9 @@ DWARFCompileUnit::GetLanguageType()
if (m_language_type != eLanguageTypeUnknown)
return m_language_type;
- const DWARFDebugInfoEntry *die = GetCompileUnitDIEOnly();
+ const DWARFDebugInfoEntry *die = GetCompileUnitDIEPtrOnly();
if (die)
- m_language_type = LanguageTypeFromDWARF(
- die->GetAttributeValueAsUnsigned(m_dwarf2Data, this, DW_AT_language, 0));
+ m_language_type = LanguageTypeFromDWARF(die->GetAttributeValueAsUnsigned(m_dwarf2Data, this, DW_AT_language, 0));
return m_language_type;
}
@@ -1108,3 +1205,57 @@ DWARFCompileUnit::IsDWARF64() const
return m_is_dwarf64;
}
+bool
+DWARFCompileUnit::GetIsOptimized ()
+{
+ if (m_is_optimized == eLazyBoolCalculate)
+ {
+ const DWARFDebugInfoEntry *die = GetCompileUnitDIEPtrOnly();
+ if (die)
+ {
+ m_is_optimized = eLazyBoolNo;
+ if (die->GetAttributeValueAsUnsigned (m_dwarf2Data, this, DW_AT_APPLE_optimized, 0) == 1)
+ {
+ m_is_optimized = eLazyBoolYes;
+ }
+ }
+ }
+ if (m_is_optimized == eLazyBoolYes)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+DWARFFormValue::FixedFormSizes
+DWARFCompileUnit::GetFixedFormSizes ()
+{
+ return DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize(), IsDWARF64());
+}
+
+TypeSystem *
+DWARFCompileUnit::GetTypeSystem ()
+{
+ if (m_dwarf2Data)
+ return m_dwarf2Data->GetTypeSystemForLanguage(GetLanguageType());
+ else
+ return nullptr;
+}
+
+void
+DWARFCompileUnit::SetUserData(void *d)
+{
+ m_user_data = d;
+ if (m_dwo_symbol_file)
+ m_dwo_symbol_file->GetCompileUnit()->SetUserData(d);
+}
+
+void
+DWARFCompileUnit::SetAddrBase(dw_addr_t addr_base, dw_offset_t base_obj_offset)
+{
+ m_addr_base = addr_base;
+ m_base_obj_offset = base_obj_offset;
+}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
index 93c8df822dcc..0fcaaca09ed8 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
@@ -12,9 +12,11 @@
#include "lldb/lldb-enumerations.h"
#include "DWARFDebugInfoEntry.h"
-#include "SymbolFileDWARF.h"
+#include "DWARFDIE.h"
class NameToDIE;
+class SymbolFileDWARF;
+class SymbolFileDWARFDwo;
class DWARFCompileUnit
{
@@ -29,19 +31,17 @@ public:
};
DWARFCompileUnit(SymbolFileDWARF* dwarf2Data);
+ ~DWARFCompileUnit();
bool Extract(const lldb_private::DWARFDataExtractor &debug_info, lldb::offset_t *offset_ptr);
size_t ExtractDIEsIfNeeded (bool cu_die_only);
- bool LookupAddress(
- const dw_addr_t address,
- DWARFDebugInfoEntry** function_die,
- DWARFDebugInfoEntry** block_die);
-
+ DWARFDIE LookupAddress(const dw_addr_t address);
size_t AppendDIEsWithTag (const dw_tag_t tag, DWARFDIECollection& matching_dies, uint32_t depth = UINT32_MAX) const;
void Clear();
bool Verify(lldb_private::Stream *s) const;
void Dump(lldb_private::Stream *s) const;
dw_offset_t GetOffset() const { return m_offset; }
+ lldb::user_id_t GetID () const;
uint32_t Size() const { return m_is_dwarf64 ? 23 : 11; /* Size in bytes of the compile unit header */ }
bool ContainsDIEOffset(dw_offset_t die_offset) const { return die_offset >= GetFirstDIEOffset() && die_offset < GetNextCompileUnitOffset(); }
dw_offset_t GetFirstDIEOffset() const { return m_offset + Size(); }
@@ -53,32 +53,35 @@ public:
dw_offset_t GetAbbrevOffset() const;
uint8_t GetAddressByteSize() const { return m_addr_size; }
dw_addr_t GetBaseAddress() const { return m_base_addr; }
+ dw_addr_t GetAddrBase() const { return m_addr_base; }
+ void SetAddrBase(dw_addr_t addr_base, dw_offset_t base_obj_offset);
void ClearDIEs(bool keep_compile_unit_die);
void BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
DWARFDebugAranges* debug_aranges);
+
+ lldb_private::TypeSystem *
+ GetTypeSystem();
+
+ DWARFFormValue::FixedFormSizes
+ GetFixedFormSizes ();
+
void
SetBaseAddress(dw_addr_t base_addr)
{
m_base_addr = base_addr;
}
- const DWARFDebugInfoEntry*
+ DWARFDIE
GetCompileUnitDIEOnly()
{
- ExtractDIEsIfNeeded (true);
- if (m_die_array.empty())
- return NULL;
- return &m_die_array[0];
+ return DWARFDIE(this, GetCompileUnitDIEPtrOnly());
}
- const DWARFDebugInfoEntry*
- DIE()
+ DWARFDIE
+ DIE ()
{
- ExtractDIEsIfNeeded (false);
- if (m_die_array.empty())
- return NULL;
- return &m_die_array[0];
+ return DWARFDIE(this, DIEPtr());
}
void
@@ -97,6 +100,9 @@ public:
m_die_array.reserve(GetDebugInfoSize() / 24);
m_die_array.push_back(die);
}
+
+ void
+ AddCompileUnitDIE (DWARFDebugInfoEntry& die);
bool
HasDIEsParsed () const
@@ -104,17 +110,8 @@ public:
return m_die_array.size() > 1;
}
- DWARFDebugInfoEntry*
- GetDIEAtIndexUnchecked (uint32_t idx)
- {
- return &m_die_array[idx];
- }
-
- DWARFDebugInfoEntry*
- GetDIEPtr (dw_offset_t die_offset);
-
- const DWARFDebugInfoEntry*
- GetDIEPtrContainingOffset (dw_offset_t die_offset);
+ DWARFDIE
+ GetDIE (dw_offset_t die_offset);
static uint8_t
GetAddressByteSize(const DWARFCompileUnit* cu);
@@ -135,10 +132,7 @@ public:
}
void
- SetUserData(void *d)
- {
- m_user_data = d;
- }
+ SetUserData(void *d);
bool
Supports_DW_AT_APPLE_objc_complete_type ();
@@ -149,15 +143,8 @@ public:
bool
Supports_unnamed_objc_bitfields ();
-// void
-// AddGlobalDIEByIndex (uint32_t die_idx);
-//
-// void
-// AddGlobal (const DWARFDebugInfoEntry* die);
-//
void
- Index (const uint32_t cu_idx,
- NameToDIE& func_basenames,
+ Index (NameToDIE& func_basenames,
NameToDIE& func_fullnames,
NameToDIE& func_methods,
NameToDIE& func_selectors,
@@ -196,8 +183,24 @@ public:
bool
IsDWARF64() const;
+ bool
+ GetIsOptimized ();
+
+ SymbolFileDWARFDwo*
+ GetDwoSymbolFile() const
+ {
+ return m_dwo_symbol_file.get();
+ }
+
+ dw_offset_t
+ GetBaseObjOffset() const
+ {
+ return m_base_obj_offset;
+ }
+
protected:
SymbolFileDWARF* m_dwarf2Data;
+ std::unique_ptr<SymbolFileDWARFDwo> m_dwo_symbol_file;
const DWARFAbbreviationDeclarationSet *m_abbrevs;
void * m_user_data;
DWARFDebugInfoEntry::collection m_die_array; // The compile unit debug information entry item
@@ -213,10 +216,49 @@ protected:
uint32_t m_producer_version_update;
lldb::LanguageType m_language_type;
bool m_is_dwarf64;
-
+ lldb_private::LazyBool m_is_optimized;
+ dw_addr_t m_addr_base; // Value of DW_AT_addr_base
+ dw_offset_t m_base_obj_offset; // If this is a dwo compile unit this is the offset of
+ // the base compile unit in the main object file
+
void
ParseProducerInfo ();
+
+ static void
+ IndexPrivate (DWARFCompileUnit* dwarf_cu,
+ const lldb::LanguageType cu_language,
+ const DWARFFormValue::FixedFormSizes& fixed_form_sizes,
+ const dw_offset_t cu_offset,
+ NameToDIE& func_basenames,
+ NameToDIE& func_fullnames,
+ NameToDIE& func_methods,
+ NameToDIE& func_selectors,
+ NameToDIE& objc_class_selectors,
+ NameToDIE& globals,
+ NameToDIE& types,
+ NameToDIE& namespaces);
+
private:
+
+ const DWARFDebugInfoEntry*
+ GetCompileUnitDIEPtrOnly()
+ {
+ ExtractDIEsIfNeeded (true);
+ if (m_die_array.empty())
+ return NULL;
+ return &m_die_array[0];
+ }
+
+ const DWARFDebugInfoEntry*
+ DIEPtr()
+ {
+ ExtractDIEsIfNeeded (false);
+ if (m_die_array.empty())
+ return NULL;
+ return &m_die_array[0];
+ }
+
+
DISALLOW_COPY_AND_ASSIGN (DWARFCompileUnit);
};
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
new file mode 100644
index 000000000000..0564de9e5dd1
--- /dev/null
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -0,0 +1,543 @@
+//===-- DWARFDIE.cpp --------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "DWARFDIE.h"
+
+#include "DWARFCompileUnit.h"
+#include "DWARFDebugAbbrev.h"
+#include "DWARFDebugAranges.h"
+#include "DWARFDebugInfo.h"
+#include "DWARFDebugInfoEntry.h"
+#include "DWARFDebugRanges.h"
+#include "DWARFDeclContext.h"
+#include "DWARFDIECollection.h"
+#include "DWARFFormValue.h"
+#include "SymbolFileDWARF.h"
+
+#include "lldb/Core/Module.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/TypeSystem.h"
+
+using namespace lldb_private;
+
+DIERef
+DWARFDIE::GetDIERef() const
+{
+ if (!IsValid())
+ return DIERef();
+
+ 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());
+}
+
+dw_tag_t
+DWARFDIE::Tag() const
+{
+ if (m_die)
+ return m_die->Tag();
+ else
+ return 0;
+}
+
+const char *
+DWARFDIE::GetTagAsCString () const
+{
+ return lldb_private::DW_TAG_value_to_name (Tag());
+}
+
+DWARFDIE
+DWARFDIE::GetParent () const
+{
+ if (IsValid())
+ return DWARFDIE(m_cu, m_die->GetParent());
+ else
+ return DWARFDIE();
+}
+
+DWARFDIE
+DWARFDIE::GetFirstChild () const
+{
+ if (IsValid())
+ return DWARFDIE(m_cu, m_die->GetFirstChild());
+ else
+ return DWARFDIE();
+}
+
+DWARFDIE
+DWARFDIE::GetSibling () const
+{
+ if (IsValid())
+ return DWARFDIE(m_cu, m_die->GetSibling());
+ else
+ return DWARFDIE();
+}
+
+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);
+ else
+ return DWARFDIE();
+}
+
+DWARFDIE
+DWARFDIE::GetDIE (dw_offset_t die_offset) const
+{
+ if (IsValid())
+ return m_cu->GetDIE(die_offset);
+ else
+ return DWARFDIE();
+}
+
+const char *
+DWARFDIE::GetAttributeValueAsString (const dw_attr_t attr, const char *fail_value) const
+{
+ if (IsValid())
+ return m_die->GetAttributeValueAsString(GetDWARF(), GetCU(), attr, fail_value);
+ else
+ return fail_value;
+}
+
+uint64_t
+DWARFDIE::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
+DWARFDIE::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
+DWARFDIE::GetAttributeValueAsReference (const dw_attr_t attr, uint64_t fail_value) const
+{
+ if (IsValid())
+ return m_die->GetAttributeValueAsReference(GetDWARF(), GetCU(), attr, fail_value);
+ else
+ return fail_value;
+}
+
+uint64_t
+DWARFDIE::GetAttributeValueAsAddress (const dw_attr_t attr, uint64_t fail_value) const
+{
+ if (IsValid())
+ return m_die->GetAttributeValueAsAddress(GetDWARF(), GetCU(), attr, fail_value);
+ else
+ return fail_value;
+}
+
+
+DWARFDIE
+DWARFDIE::LookupDeepestBlock (lldb::addr_t file_addr) const
+{
+ if (IsValid())
+ {
+ SymbolFileDWARF *dwarf= GetDWARF();
+ DWARFCompileUnit *cu = GetCU();
+ DWARFDebugInfoEntry* function_die = nullptr;
+ DWARFDebugInfoEntry* block_die = nullptr;
+ if (m_die->LookupAddress (file_addr,
+ dwarf,
+ 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()->GetCompileUnitContainingDIE(DIERef(cu->GetOffset(), block_die->GetOffset())), block_die);
+ }
+ }
+ }
+ return DWARFDIE();
+}
+
+lldb::user_id_t
+DWARFDIE::GetID () const
+{
+ const dw_offset_t die_offset = GetOffset();
+ if (die_offset != DW_INVALID_OFFSET)
+ {
+ lldb::user_id_t id = 0;
+ SymbolFileDWARF *dwarf = GetDWARF();
+ if (dwarf)
+ id = dwarf->MakeUserID(die_offset);
+ else
+ id = die_offset;
+
+ if (m_cu)
+ {
+ lldb::user_id_t cu_id = m_cu->GetID()&0xffffffff00000000ull;
+ assert ((id&0xffffffff00000000ull) == 0 ||
+ (cu_id&0xffffffff00000000ll) == 0 ||
+ (id&0xffffffff00000000ull) == (cu_id&0xffffffff00000000ll));
+ id |= cu_id;
+ }
+ return id;
+ }
+ return LLDB_INVALID_UID;
+}
+
+const char *
+DWARFDIE::GetName () const
+{
+ if (IsValid())
+ return m_die->GetName (GetDWARF(), m_cu);
+ else
+ return nullptr;
+}
+
+const char *
+DWARFDIE::GetMangledName () const
+{
+ if (IsValid())
+ return m_die->GetMangledName (GetDWARF(), m_cu);
+ else
+ return nullptr;
+}
+
+const char *
+DWARFDIE::GetPubname () const
+{
+ if (IsValid())
+ return m_die->GetPubname (GetDWARF(), m_cu);
+ else
+ return nullptr;
+}
+
+const char *
+DWARFDIE::GetQualifiedName (std::string &storage) const
+{
+ if (IsValid())
+ return m_die->GetQualifiedName (GetDWARF(), m_cu, storage);
+ else
+ return nullptr;
+}
+
+lldb::LanguageType
+DWARFDIE::GetLanguage () const
+{
+ if (IsValid())
+ return m_cu->GetLanguageType();
+ else
+ return lldb::eLanguageTypeUnknown;
+}
+
+
+lldb::ModuleSP
+DWARFDIE::GetModule () const
+{
+ SymbolFileDWARF *dwarf = GetDWARF();
+ if (dwarf)
+ return dwarf->GetObjectFile()->GetModule();
+ else
+ return lldb::ModuleSP();
+}
+
+lldb_private::CompileUnit *
+DWARFDIE::GetLLDBCompileUnit () const
+{
+ if (IsValid())
+ return GetDWARF()->GetCompUnitForDWARFCompUnit(GetCU());
+ else
+ return nullptr;
+}
+
+lldb_private::Type *
+DWARFDIE::ResolveType () const
+{
+ if (IsValid())
+ return GetDWARF()->ResolveType(*this, true);
+ else
+ return nullptr;
+}
+
+lldb_private::Type *
+DWARFDIE::ResolveTypeUID (lldb::user_id_t uid) const
+{
+ SymbolFileDWARF *dwarf = GetDWARF();
+ if (dwarf)
+ return dwarf->ResolveTypeUID(uid);
+ else
+ 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);
+ }
+ }
+}
+
+void
+DWARFDIE::GetDWARFDeclContext (DWARFDeclContext &dwarf_decl_ctx) const
+{
+ if (IsValid())
+ {
+ m_die->GetDWARFDeclContext (GetDWARF(), GetCU(), dwarf_decl_ctx);
+ }
+ else
+ {
+ dwarf_decl_ctx.Clear();
+ }
+}
+
+void
+DWARFDIE::GetDWOContext (std::vector<CompilerContext> &context) const
+{
+ const dw_tag_t tag = Tag();
+ if (tag == DW_TAG_compile_unit)
+ return;
+ DWARFDIE parent = GetParent();
+ if (parent)
+ parent.GetDWOContext(context);
+ switch (tag)
+ {
+ case DW_TAG_module:
+ context.push_back(CompilerContext(CompilerContextKind::Module, ConstString(GetName())));
+ break;
+ case DW_TAG_namespace:
+ context.push_back(CompilerContext(CompilerContextKind::Namespace, ConstString(GetName())));
+ break;
+ case DW_TAG_structure_type:
+ context.push_back(CompilerContext(CompilerContextKind::Structure, ConstString(GetName())));
+ break;
+ case DW_TAG_union_type:
+ context.push_back(CompilerContext(CompilerContextKind::Union, ConstString(GetName())));
+ break;
+ case DW_TAG_class_type:
+ context.push_back(CompilerContext(CompilerContextKind::Class, ConstString(GetName())));
+ break;
+ case DW_TAG_enumeration_type:
+ context.push_back(CompilerContext(CompilerContextKind::Enumeration, ConstString(GetName())));
+ break;
+ case DW_TAG_subprogram:
+ context.push_back(CompilerContext(CompilerContextKind::Function, ConstString(GetPubname())));
+ break;
+ case DW_TAG_variable:
+ context.push_back(CompilerContext(CompilerContextKind::Variable, ConstString(GetPubname())));
+ break;
+ case DW_TAG_typedef:
+ context.push_back(CompilerContext(CompilerContextKind::Typedef, ConstString(GetName())));
+ break;
+ default:
+ break;
+ }
+}
+
+
+
+DWARFDIE
+DWARFDIE::GetParentDeclContextDIE () const
+{
+ if (IsValid())
+ return m_die->GetParentDeclContextDIE(GetDWARF(), m_cu);
+ else
+ return DWARFDIE();
+}
+
+
+dw_offset_t
+DWARFDIE::GetOffset () const
+{
+ if (IsValid())
+ return m_die->GetOffset();
+ else
+ return DW_INVALID_OFFSET;
+}
+
+dw_offset_t
+DWARFDIE::GetCompileUnitRelativeOffset () const
+{
+ if (IsValid())
+ return m_die->GetOffset() - m_cu->GetOffset();
+ else
+ return DW_INVALID_OFFSET;
+}
+
+SymbolFileDWARF *
+DWARFDIE::GetDWARF () const
+{
+ if (m_cu)
+ return m_cu->GetSymbolFileDWARF();
+ else
+ return nullptr;
+}
+
+lldb_private::TypeSystem *
+DWARFDIE::GetTypeSystem () const
+{
+ if (m_cu)
+ return m_cu->GetTypeSystem();
+ else
+ return nullptr;
+}
+
+DWARFASTParser *
+DWARFDIE::GetDWARFParser () const
+{
+ lldb_private::TypeSystem *type_system = GetTypeSystem ();
+ if (type_system)
+ return type_system->GetDWARFParser();
+ else
+ return nullptr;
+}
+
+bool
+DWARFDIE::IsStructOrClass () const
+{
+ const dw_tag_t tag = Tag();
+ return tag == DW_TAG_class_type || tag == DW_TAG_structure_type;
+}
+
+
+DWARFDIE
+DWARFDIE::GetContainingDWOModuleDIE () const
+{
+ if (IsValid())
+ {
+ DWARFDIE top_module_die;
+ // Now make sure this DIE is scoped in a DW_TAG_module tag and return true if so
+ for (DWARFDIE parent = GetParent(); parent.IsValid(); parent = parent.GetParent())
+ {
+ const dw_tag_t tag = parent.Tag();
+ if (tag == DW_TAG_module)
+ top_module_die = parent;
+ else if (tag == DW_TAG_compile_unit)
+ break;
+ }
+
+ return top_module_die;
+ }
+ return DWARFDIE();
+}
+
+lldb::ModuleSP
+DWARFDIE::GetContainingDWOModule () const
+{
+ if (IsValid())
+ {
+ DWARFDIE dwo_module_die = GetContainingDWOModuleDIE();
+
+ if (dwo_module_die)
+ {
+ const char *module_name = dwo_module_die.GetName();
+ if (module_name)
+ return GetDWARF()->GetDWOModule (lldb_private::ConstString(module_name));
+ }
+ }
+ return lldb::ModuleSP();
+}
+
+bool
+DWARFDIE::HasChildren () const
+{
+ if (m_die)
+ return m_die->HasChildren();
+ else
+ return false;
+}
+
+bool
+DWARFDIE::Supports_DW_AT_APPLE_objc_complete_type () const
+{
+ if (IsValid())
+ return GetDWARF()->Supports_DW_AT_APPLE_objc_complete_type(m_cu);
+ else
+ return false;
+}
+
+size_t
+DWARFDIE::GetAttributes (DWARFAttributes &attributes, uint32_t depth) const
+{
+ if (IsValid())
+ {
+ return m_die->GetAttributes (m_cu,
+ m_cu->GetFixedFormSizes(),
+ attributes,
+ depth);
+ }
+ if (depth == 0)
+ attributes.Clear();
+ return 0;
+}
+
+
+bool
+DWARFDIE::GetDIENamesAndRanges (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,
+ 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);
+ }
+ else
+ return false;
+}
+
+void
+DWARFDIE::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 DWARFDIE &lhs, const DWARFDIE &rhs)
+{
+ return lhs.GetDIE() == rhs.GetDIE() && lhs.GetCU() == rhs.GetCU();
+}
+
+bool operator != (const DWARFDIE &lhs, const DWARFDIE &rhs)
+{
+ return lhs.GetDIE() != rhs.GetDIE() || lhs.GetCU() != rhs.GetCU();
+}
+
+
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDIE.h b/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
new file mode 100644
index 000000000000..db37a45ad01a
--- /dev/null
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
@@ -0,0 +1,281 @@
+//===-- DWARFDIE.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_DWARFDIE_h_
+#define SymbolFileDWARF_DWARFDIE_h_
+
+#include "lldb/lldb-types.h"
+#include "lldb/Core/dwarf.h"
+
+struct DIERef;
+class DWARFASTParser;
+class DWARFAttributes;
+class DWARFCompileUnit;
+class DWARFDebugInfoEntry;
+class DWARFDeclContext;
+class DWARFDIECollection;
+class SymbolFileDWARF;
+
+class DWARFDIE
+{
+public:
+ DWARFDIE () :
+ m_cu (nullptr),
+ m_die (nullptr)
+ {
+ }
+
+ DWARFDIE (DWARFCompileUnit *cu, DWARFDebugInfoEntry *die) :
+ m_cu (cu),
+ m_die (die)
+ {
+ }
+
+ DWARFDIE (const DWARFCompileUnit *cu, DWARFDebugInfoEntry *die) :
+ m_cu (const_cast<DWARFCompileUnit *>(cu)),
+ m_die (die)
+ {
+ }
+
+ DWARFDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die) :
+ m_cu (cu),
+ m_die (const_cast<DWARFDebugInfoEntry *>(die))
+ {
+ }
+
+ DWARFDIE (const DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die) :
+ m_cu (const_cast<DWARFCompileUnit *>(cu)),
+ m_die (const_cast<DWARFDebugInfoEntry *>(die))
+ {
+ }
+
+ //----------------------------------------------------------------------
+ // Tests
+ //----------------------------------------------------------------------
+ operator bool () const
+ {
+ return IsValid();
+ }
+
+ bool
+ IsValid() const
+ {
+ return m_cu && m_die;
+ }
+
+ bool
+ IsStructOrClass () const;
+
+ bool
+ HasChildren () const;
+
+ bool
+ Supports_DW_AT_APPLE_objc_complete_type () const;
+
+ //----------------------------------------------------------------------
+ // Accessors
+ //----------------------------------------------------------------------
+ SymbolFileDWARF *
+ GetDWARF () const;
+
+ DWARFCompileUnit *
+ GetCU() const
+ {
+ return m_cu;
+ }
+
+ DWARFDebugInfoEntry *
+ GetDIE() const
+ {
+ return m_die;
+ }
+
+ DIERef
+ GetDIERef() const;
+
+ lldb_private::TypeSystem *
+ GetTypeSystem () const;
+
+ DWARFASTParser *
+ GetDWARFParser () const;
+
+ void
+ Set (DWARFCompileUnit *cu, DWARFDebugInfoEntry *die)
+ {
+ if (cu && die)
+ {
+ m_cu = cu;
+ m_die = die;
+ }
+ else
+ {
+ Clear();
+ }
+ }
+
+ void
+ Clear ()
+ {
+ m_cu = nullptr;
+ m_die = nullptr;
+ }
+
+ lldb::ModuleSP
+ GetContainingDWOModule () const;
+
+ DWARFDIE
+ GetContainingDWOModuleDIE () 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;
+
+ const char *
+ GetMangledName () const;
+
+ const char *
+ GetPubname () const;
+
+ const char *
+ GetQualifiedName (std::string &storage) const;
+
+ lldb::LanguageType
+ GetLanguage () const;
+
+ lldb::ModuleSP
+ GetModule () const;
+
+ lldb_private::CompileUnit *
+ GetLLDBCompileUnit () const;
+
+ lldb_private::Type *
+ ResolveType () const;
+
+ // Resolve a type by UID using this DIE's DWARF file
+ lldb_private::Type *
+ ResolveTypeUID (lldb::user_id_t uid) const;
+
+ //----------------------------------------------------------------------
+ // Functions for obtaining DIE relations and references
+ //----------------------------------------------------------------------
+
+ DWARFDIE
+ GetParent () const;
+
+ DWARFDIE
+ GetFirstChild () const;
+
+ DWARFDIE
+ GetSibling () const;
+
+ 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;
+
+ DWARFDIE
+ LookupDeepestBlock (lldb::addr_t file_addr) const;
+
+ DWARFDIE
+ GetParentDeclContextDIE () const;
+
+ //----------------------------------------------------------------------
+ // DeclContext related functions
+ //----------------------------------------------------------------------
+ void
+ GetDeclContextDIEs (DWARFDIECollection &decl_context_dies) const;
+
+ void
+ GetDWARFDeclContext (DWARFDeclContext &dwarf_decl_ctx) const;
+
+ void
+ GetDWOContext (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
+ //----------------------------------------------------------------------
+ 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;
+
+ bool
+ GetDIENamesAndRanges (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,
+ lldb_private::DWARFExpression *frame_base) const;
+
+ //----------------------------------------------------------------------
+ // Pretty printing
+ //----------------------------------------------------------------------
+
+ void
+ Dump (lldb_private::Stream *s, const uint32_t recurse_depth) const;
+
+protected:
+ DWARFCompileUnit *m_cu;
+ DWARFDebugInfoEntry *m_die;
+};
+
+bool operator == (const DWARFDIE &lhs, const DWARFDIE &rhs);
+bool operator != (const DWARFDIE &lhs, const DWARFDIE &rhs);
+
+#endif // SymbolFileDWARF_DWARFDIE_h_
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp
index 1beb75d33642..9e021c7185bd 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp
@@ -13,13 +13,11 @@
#include "lldb/Core/Stream.h"
-#include "DWARFDebugInfoEntry.h"
-
using namespace lldb_private;
using namespace std;
bool
-DWARFDIECollection::Insert(const DWARFDebugInfoEntry *die)
+DWARFDIECollection::Insert(const DWARFDIE &die)
{
iterator end_pos = m_dies.end();
iterator insert_pos = upper_bound(m_dies.begin(), end_pos, die);
@@ -30,17 +28,17 @@ DWARFDIECollection::Insert(const DWARFDebugInfoEntry *die)
}
void
-DWARFDIECollection::Append (const DWARFDebugInfoEntry *die)
+DWARFDIECollection::Append (const DWARFDIE &die)
{
m_dies.push_back (die);
}
-const DWARFDebugInfoEntry *
-DWARFDIECollection::GetDIEPtrAtIndex(uint32_t idx) const
+DWARFDIE
+DWARFDIECollection::GetDIEAtIndex(uint32_t idx) const
{
if (idx < m_dies.size())
return m_dies[idx];
- return NULL;
+ return DWARFDIE();
}
@@ -55,8 +53,6 @@ DWARFDIECollection::Dump(Stream *s, const char* title) const
{
if (title && title[0] != '\0')
s->Printf( "%s\n", title);
- const_iterator end_pos = m_dies.end();
- const_iterator pos;
- for (pos = m_dies.begin(); pos != end_pos; ++pos)
- s->Printf( "0x%8.8x\n", (*pos)->GetOffset());
+ 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
index 173d0a5604d0..e39e1aa4ccda 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h
@@ -10,7 +10,7 @@
#ifndef SymbolFileDWARF_DWARFDIECollection_h_
#define SymbolFileDWARF_DWARFDIECollection_h_
-#include "SymbolFileDWARF.h"
+#include "DWARFDIE.h"
#include <vector>
class DWARFDIECollection
@@ -25,22 +25,22 @@ public:
}
void
- Append (const DWARFDebugInfoEntry *die);
+ Append (const DWARFDIE &die);
void
Dump(lldb_private::Stream *s, const char* title) const;
- const DWARFDebugInfoEntry*
- GetDIEPtrAtIndex(uint32_t idx) const;
+ DWARFDIE
+ GetDIEAtIndex (uint32_t idx) const;
bool
- Insert(const DWARFDebugInfoEntry *die);
+ Insert(const DWARFDIE &die);
size_t
Size() const;
protected:
- typedef std::vector<const DWARFDebugInfoEntry *> collection;
+ typedef std::vector<DWARFDIE> collection;
typedef collection::iterator iterator;
typedef collection::const_iterator const_iterator;
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h b/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
index ba2e8ad08acc..0281b5ad5c89 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
@@ -19,10 +19,10 @@ namespace lldb_private {
class DWARFDataExtractor : public lldb_private::DataExtractor
{
public:
- DWARFDataExtractor() : DataExtractor(), m_is_dwarf64(false) { };
+ DWARFDataExtractor() : DataExtractor(), m_is_dwarf64(false) { }
DWARFDataExtractor (const DWARFDataExtractor& data, lldb::offset_t offset, lldb::offset_t length) :
- DataExtractor(data, offset, length), m_is_dwarf64(false) { };
+ DataExtractor(data, offset, length), m_is_dwarf64(false) { }
uint64_t
GetDWARFInitialLength(lldb::offset_t *offset_ptr) const;
@@ -43,4 +43,3 @@ protected:
}
#endif // liblldb_DWARFDataExtractor_h_
-
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
index 393434800c01..a1b00d1892e9 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -103,57 +103,6 @@ DWARFDebugInfo::GetCompileUnitAranges ()
return *m_cu_aranges_ap.get();
}
-
-//----------------------------------------------------------------------
-// LookupAddress
-//----------------------------------------------------------------------
-bool
-DWARFDebugInfo::LookupAddress
-(
- const dw_addr_t address,
- const dw_offset_t hint_die_offset,
- DWARFCompileUnitSP& cu_sp,
- DWARFDebugInfoEntry** function_die,
- DWARFDebugInfoEntry** block_die
-)
-{
-
- if (hint_die_offset != DW_INVALID_OFFSET)
- cu_sp = GetCompileUnit(hint_die_offset);
- else
- {
- DWARFDebugAranges &cu_aranges = GetCompileUnitAranges ();
- const dw_offset_t cu_offset = cu_aranges.FindAddress (address);
- cu_sp = GetCompileUnit(cu_offset);
- }
-
- if (cu_sp.get())
- {
- if (cu_sp->LookupAddress(address, function_die, block_die))
- return true;
- cu_sp.reset();
- }
- else
- {
- // The hint_die_offset may have been a pointer to the actual item that
- // we are looking for
- DWARFDebugInfoEntry* die_ptr = GetDIEPtr(hint_die_offset, &cu_sp);
- if (die_ptr)
- {
- if (cu_sp.get())
- {
- if (function_die || block_die)
- return die_ptr->LookupAddress(address, m_dwarf2Data, cu_sp.get(), function_die, block_die);
-
- // We only wanted the compile unit that contained this address
- return true;
- }
- }
- }
- return false;
-}
-
-
void
DWARFDebugInfo::ParseCompileUnitHeadersIfNeeded()
{
@@ -213,19 +162,13 @@ DWARFDebugInfo::ContainsCompileUnit (const DWARFCompileUnit *cu) const
return false;
}
-static int
-CompareDWARFCompileUnitSPOffset (const void *key, const void *arrmem)
+bool
+DWARFDebugInfo::OffsetLessThanCompileUnitOffset (dw_offset_t offset, const DWARFCompileUnitSP& cu_sp)
{
- const dw_offset_t key_cu_offset = *(dw_offset_t*) key;
- const dw_offset_t cu_offset = ((DWARFCompileUnitSP *)arrmem)->get()->GetOffset();
- if (key_cu_offset < cu_offset)
- return -1;
- if (key_cu_offset > cu_offset)
- return 1;
- return 0;
+ return offset < cu_sp->GetOffset();
}
-DWARFCompileUnitSP
+DWARFCompileUnit *
DWARFDebugInfo::GetCompileUnit(dw_offset_t cu_offset, uint32_t* idx_ptr)
{
DWARFCompileUnitSP cu_sp;
@@ -234,41 +177,80 @@ DWARFDebugInfo::GetCompileUnit(dw_offset_t cu_offset, uint32_t* idx_ptr)
{
ParseCompileUnitHeadersIfNeeded();
- DWARFCompileUnitSP* match = (DWARFCompileUnitSP*)bsearch(&cu_offset, &m_compile_units[0], m_compile_units.size(), sizeof(DWARFCompileUnitSP), CompareDWARFCompileUnitSPOffset);
- if (match)
+ // 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)
{
- cu_sp = *match;
- cu_idx = match - &m_compile_units[0];
+ 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);
+ }
+ }
}
}
if (idx_ptr)
*idx_ptr = cu_idx;
- return cu_sp;
+ return cu_sp.get();
}
-DWARFCompileUnitSP
-DWARFDebugInfo::GetCompileUnitContainingDIE(dw_offset_t die_offset)
+DWARFCompileUnit *
+DWARFDebugInfo::GetCompileUnitContainingDIE (const DIERef& die_ref)
{
+ dw_offset_t search_offset = die_ref.die_offset;
+ bool is_cu_offset = false;
+ if (m_dwarf2Data->GetID() == 0 && die_ref.cu_offset != DW_INVALID_OFFSET)
+ {
+ is_cu_offset = true;
+ search_offset = die_ref.cu_offset;
+ }
+
DWARFCompileUnitSP cu_sp;
- if (die_offset != DW_INVALID_OFFSET)
+ if (search_offset != DW_INVALID_OFFSET)
{
ParseCompileUnitHeadersIfNeeded();
- CompileUnitColl::const_iterator end_pos = m_compile_units.end();
- CompileUnitColl::const_iterator pos;
-
- for (pos = m_compile_units.begin(); pos != end_pos; ++pos)
+ // 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)
{
- dw_offset_t cu_start_offset = (*pos)->GetOffset();
- dw_offset_t cu_end_offset = (*pos)->GetNextCompileUnitOffset();
- if (cu_start_offset <= die_offset && die_offset < cu_end_offset)
+ if ((is_cu_offset && m_compile_units[0]->GetOffset() == search_offset) ||
+ (!is_cu_offset && m_compile_units[0]->ContainsDIEOffset(search_offset)))
{
- cu_sp = *pos;
- break;
+ cu_sp = m_compile_units[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, search_offset, OffsetLessThanCompileUnitOffset);
+ if (pos != begin_pos)
+ {
+ --pos;
+ if ((is_cu_offset && (*pos)->GetOffset() == search_offset) ||
+ (!is_cu_offset && (*pos)->ContainsDIEOffset(search_offset)))
+ {
+ cu_sp = *pos;
+ }
}
}
}
- return cu_sp;
+ return cu_sp.get();
}
//----------------------------------------------------------------------
@@ -276,73 +258,15 @@ DWARFDebugInfo::GetCompileUnitContainingDIE(dw_offset_t die_offset)
//
// Get the DIE (Debug Information Entry) with the specified offset.
//----------------------------------------------------------------------
-DWARFDebugInfoEntry*
-DWARFDebugInfo::GetDIEPtr(dw_offset_t die_offset, DWARFCompileUnitSP* cu_sp_ptr)
-{
- DWARFCompileUnitSP cu_sp(GetCompileUnitContainingDIE(die_offset));
- if (cu_sp_ptr)
- *cu_sp_ptr = cu_sp;
- if (cu_sp.get())
- return cu_sp->GetDIEPtr(die_offset);
- return NULL; // Not found in any compile units
-}
-
-DWARFDebugInfoEntry*
-DWARFDebugInfo::GetDIEPtrWithCompileUnitHint (dw_offset_t die_offset, DWARFCompileUnit**cu_handle)
-{
- assert (cu_handle);
- DWARFDebugInfoEntry* die = NULL;
- if (*cu_handle)
- die = (*cu_handle)->GetDIEPtr(die_offset);
-
- if (die == NULL)
- {
- DWARFCompileUnitSP cu_sp (GetCompileUnitContainingDIE(die_offset));
- if (cu_sp.get())
- {
- *cu_handle = cu_sp.get();
- die = cu_sp->GetDIEPtr(die_offset);
- }
- }
- if (die == NULL)
- *cu_handle = NULL;
- return die;
-}
-
-
-const DWARFDebugInfoEntry*
-DWARFDebugInfo::GetDIEPtrContainingOffset(dw_offset_t die_offset, DWARFCompileUnitSP* cu_sp_ptr)
-{
- DWARFCompileUnitSP cu_sp(GetCompileUnitContainingDIE(die_offset));
- if (cu_sp_ptr)
- *cu_sp_ptr = cu_sp;
- if (cu_sp.get())
- return cu_sp->GetDIEPtrContainingOffset(die_offset);
-
- return NULL; // Not found in any compile units
-
-}
-
-//----------------------------------------------------------------------
-// AddCompileUnit
-//----------------------------------------------------------------------
-void
-DWARFDebugInfo::AddCompileUnit(DWARFCompileUnitSP& cu)
+DWARFDIE
+DWARFDebugInfo::GetDIE(const DIERef& die_ref)
{
- m_compile_units.push_back(cu);
+ DWARFCompileUnit *cu = GetCompileUnitContainingDIE(die_ref);
+ if (cu)
+ return cu->GetDIE (die_ref.die_offset);
+ return DWARFDIE(); // Not found
}
-/*
-void
-DWARFDebugInfo::AddDIE(DWARFDebugInfoEntry& die)
-{
- m_die_array.push_back(die);
-}
-*/
-
-
-
-
//----------------------------------------------------------------------
// Parse
//
@@ -372,7 +296,7 @@ DWARFDebugInfo::Parse(SymbolFileDWARF* dwarf2Data, Callback callback, void* user
depth = 0;
// Call the callback function with no DIE pointer for the compile unit
// and get the offset that we are to continue to parse from
- offset = callback(dwarf2Data, cu, NULL, offset, depth, userData);
+ offset = callback(dwarf2Data, cu.get(), NULL, offset, depth, userData);
// Make sure we are within our compile unit
if (offset < next_cu_offset)
@@ -383,7 +307,7 @@ DWARFDebugInfo::Parse(SymbolFileDWARF* dwarf2Data, Callback callback, void* user
while (!done && die.Extract(dwarf2Data, cu.get(), &offset))
{
// Call the callback function with DIE pointer that falls within the compile unit
- offset = callback(dwarf2Data, cu, &die, offset, depth, userData);
+ offset = callback(dwarf2Data, cu.get(), &die, offset, depth, userData);
if (die.IsNULL())
{
@@ -450,7 +374,7 @@ typedef struct DumpInfo
static dw_offset_t DumpCallback
(
SymbolFileDWARF* dwarf2Data,
- DWARFCompileUnitSP& cu_sp,
+ DWARFCompileUnit* cu,
DWARFDebugInfoEntry* die,
const dw_offset_t next_offset,
const uint32_t curr_depth,
@@ -458,9 +382,6 @@ static dw_offset_t DumpCallback
)
{
DumpInfo* dumpInfo = (DumpInfo*)userData;
-
- const DWARFCompileUnit* cu = cu_sp.get();
-
Stream *s = dumpInfo->strm;
bool show_parents = s->GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowAncestors);
@@ -676,12 +597,12 @@ DWARFDebugInfo::Dump (Stream *s, const uint32_t die_offset, const uint32_t recur
ParseCompileUnitHeadersIfNeeded();
for (pos = m_compile_units.begin(); pos != m_compile_units.end(); ++pos)
{
- const DWARFCompileUnitSP& cu_sp = *pos;
- DumpCallback(m_dwarf2Data, (DWARFCompileUnitSP&)cu_sp, NULL, 0, curr_depth, &dumpInfo);
+ DWARFCompileUnit *cu = pos->get();
+ DumpCallback(m_dwarf2Data, cu, NULL, 0, curr_depth, &dumpInfo);
- const DWARFDebugInfoEntry* die = cu_sp->DIE();
+ const DWARFDIE die = cu->DIE();
if (die)
- die->Dump(m_dwarf2Data, cu_sp.get(), *s, recurse_depth);
+ die.Dump(s, recurse_depth);
}
}
@@ -707,7 +628,7 @@ typedef struct FindCallbackStringInfoTag
static dw_offset_t FindCallbackString
(
SymbolFileDWARF* dwarf2Data,
- DWARFCompileUnitSP& cu_sp,
+ DWARFCompileUnit* cu,
DWARFDebugInfoEntry* die,
const dw_offset_t next_offset,
const uint32_t curr_depth,
@@ -715,7 +636,6 @@ static dw_offset_t FindCallbackString
)
{
FindCallbackStringInfo* info = (FindCallbackStringInfo*)userData;
- const DWARFCompileUnit* cu = cu_sp.get();
if (die)
{
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
index 50a7ae76921f..ea2e204db702 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
@@ -16,19 +16,18 @@
#include "lldb/lldb-private.h"
#include "lldb/lldb-private.h"
#include "SymbolFileDWARF.h"
+#include "DWARFDIE.h"
typedef std::multimap<const char*, dw_offset_t, CStringCompareFunctionObject> CStringToDIEMap;
typedef CStringToDIEMap::iterator CStringToDIEMapIter;
typedef CStringToDIEMap::const_iterator CStringToDIEMapConstIter;
-typedef std::shared_ptr<DWARFCompileUnit> DWARFCompileUnitSP;
-
class DWARFDebugInfo
{
public:
typedef dw_offset_t (*Callback)(
SymbolFileDWARF* dwarf2Data,
- DWARFCompileUnitSP& cu_shared_ptr,
+ DWARFCompileUnit* cu,
DWARFDebugInfoEntry* die,
const dw_offset_t next_offset,
const uint32_t depth,
@@ -37,24 +36,13 @@ public:
DWARFDebugInfo();
void SetDwarfData(SymbolFileDWARF* dwarf2Data);
- bool LookupAddress(
- const dw_addr_t address,
- const dw_offset_t cu_offset, // Can be valid (find in .debug_aranges), or DW_INVALID_OFFSET if we need to search manually
- DWARFCompileUnitSP& cu_shared_ptr,
- DWARFDebugInfoEntry** function_die,
- DWARFDebugInfoEntry** block_die);
-
- void AddCompileUnit(DWARFCompileUnitSP& cu);
size_t GetNumCompileUnits();
bool ContainsCompileUnit (const DWARFCompileUnit *cu) const;
- DWARFCompileUnit* GetCompileUnitAtIndex(uint32_t idx);
- DWARFCompileUnitSP GetCompileUnit(dw_offset_t cu_offset, uint32_t* idx_ptr = NULL);
- DWARFCompileUnitSP GetCompileUnitContainingDIE(dw_offset_t die_offset);
+ DWARFCompileUnit* GetCompileUnitAtIndex (uint32_t idx);
+ DWARFCompileUnit* GetCompileUnit (dw_offset_t cu_offset, uint32_t* idx_ptr = NULL);
+ DWARFCompileUnit* GetCompileUnitContainingDIE (const DIERef& die_ref);
- DWARFDebugInfoEntry* GetDIEPtr(dw_offset_t die_offset, DWARFCompileUnitSP* cu_sp_ptr);
- DWARFDebugInfoEntry* GetDIEPtrWithCompileUnitHint (dw_offset_t die_offset, DWARFCompileUnit**cu_handle);
-
- const DWARFDebugInfoEntry* GetDIEPtrContainingOffset(dw_offset_t die_offset, DWARFCompileUnitSP* cu_sp_ptr);
+ DWARFDIE GetDIE (const DIERef& die_ref);
void Dump(lldb_private::Stream *s, const uint32_t die_offset, const uint32_t recurse_depth);
static void Parse(SymbolFileDWARF* parser, Callback callback, void* userData);
@@ -74,8 +62,17 @@ public:
GetCompileUnitAranges ();
protected:
- SymbolFileDWARF* m_dwarf2Data;
+ typedef std::shared_ptr<DWARFCompileUnit> DWARFCompileUnitSP;
+
+ static bool
+ OffsetLessThanCompileUnitOffset (dw_offset_t offset, const DWARFCompileUnitSP& cu_sp);
+
typedef std::vector<DWARFCompileUnitSP> CompileUnitColl;
+
+ //----------------------------------------------------------------------
+ // Member variables
+ //----------------------------------------------------------------------
+ SymbolFileDWARF* m_dwarf2Data;
CompileUnitColl m_compile_units;
std::unique_ptr<DWARFDebugAranges> m_cu_aranges_ap; // A quick address to compile unit table
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 0ad1f1a3a95a..b9d825489aef 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -19,107 +19,26 @@
#include "lldb/Symbol/ObjectFile.h"
#include "DWARFCompileUnit.h"
-#include "SymbolFileDWARF.h"
#include "DWARFDebugAbbrev.h"
#include "DWARFDebugAranges.h"
#include "DWARFDebugInfo.h"
#include "DWARFDeclContext.h"
#include "DWARFDIECollection.h"
#include "DWARFFormValue.h"
-#include "DWARFLocationDescription.h"
-#include "DWARFLocationList.h"
#include "DWARFDebugRanges.h"
+#include "SymbolFileDWARF.h"
+#include "SymbolFileDWARFDwo.h"
using namespace lldb_private;
using namespace std;
extern int g_verbose;
-
-
-DWARFDebugInfoEntry::Attributes::Attributes() :
- m_infos()
-{
-}
-
-DWARFDebugInfoEntry::Attributes::~Attributes()
-{
-}
-
-
-uint32_t
-DWARFDebugInfoEntry::Attributes::FindAttributeIndex(dw_attr_t attr) const
-{
- collection::const_iterator end = m_infos.end();
- collection::const_iterator beg = m_infos.begin();
- collection::const_iterator pos;
- for (pos = beg; pos != end; ++pos)
- {
- if (pos->attr == attr)
- return std::distance(beg, pos);
- }
- return UINT32_MAX;
-}
-
-void
-DWARFDebugInfoEntry::Attributes::Append(const DWARFCompileUnit *cu, dw_offset_t attr_die_offset, dw_attr_t attr, dw_form_t form)
-{
- Info info = { cu, attr_die_offset, attr, form };
- m_infos.push_back(info);
-}
-
-bool
-DWARFDebugInfoEntry::Attributes::ContainsAttribute(dw_attr_t attr) const
-{
- return FindAttributeIndex(attr) != UINT32_MAX;
-}
-
-bool
-DWARFDebugInfoEntry::Attributes::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
-DWARFDebugInfoEntry::Attributes::ExtractFormValueAtIndex (SymbolFileDWARF* dwarf2Data, uint32_t i, DWARFFormValue &form_value) const
-{
- form_value.SetCompileUnit(CompileUnitAtIndex(i));
- form_value.SetForm(FormAtIndex(i));
- lldb::offset_t offset = DIEOffsetAtIndex(i);
- return form_value.ExtractValue(dwarf2Data->get_debug_info_data(), &offset);
-}
-
-uint64_t
-DWARFDebugInfoEntry::Attributes::FormValueAsUnsigned (SymbolFileDWARF* dwarf2Data, dw_attr_t attr, uint64_t fail_value) const
-{
- const uint32_t attr_idx = FindAttributeIndex (attr);
- if (attr_idx != UINT32_MAX)
- return FormValueAsUnsignedAtIndex (dwarf2Data, attr_idx, fail_value);
- return fail_value;
-}
-
-uint64_t
-DWARFDebugInfoEntry::Attributes::FormValueAsUnsignedAtIndex(SymbolFileDWARF* dwarf2Data, uint32_t i, uint64_t fail_value) const
-{
- DWARFFormValue form_value;
- if (ExtractFormValueAtIndex(dwarf2Data, i, form_value))
- return form_value.Reference();
- return fail_value;
-}
-
-
-
bool
DWARFDebugInfoEntry::FastExtract
(
const DWARFDataExtractor& debug_info_data,
const DWARFCompileUnit* cu,
- const uint8_t *fixed_form_sizes,
+ const DWARFFormValue::FixedFormSizes& fixed_form_sizes,
lldb::offset_t *offset_ptr
)
{
@@ -158,7 +77,7 @@ DWARFDebugInfoEntry::FastExtract
{
form = abbrevDecl->GetFormByIndexUnchecked(i);
- const uint8_t fixed_skip_size = fixed_form_sizes [form];
+ const uint8_t fixed_skip_size = fixed_form_sizes.GetSize(form);
if (fixed_skip_size)
offset += fixed_skip_size;
else
@@ -226,9 +145,11 @@ DWARFDebugInfoEntry::FastExtract
break;
// signed or unsigned LEB 128 values
- case DW_FORM_sdata :
- case DW_FORM_udata :
- case DW_FORM_ref_udata :
+ 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;
@@ -306,7 +227,7 @@ DWARFDebugInfoEntry::Extract
bool isCompileUnitTag = m_tag == DW_TAG_compile_unit;
if (cu && isCompileUnitTag)
- ((DWARFCompileUnit*)cu)->SetBaseAddress(0);
+ const_cast<DWARFCompileUnit *>(cu)->SetBaseAddress(0);
// Skip all data in the .debug_info for the attributes
const uint32_t numAttributes = abbrevDecl->NumAttributes();
@@ -323,7 +244,7 @@ DWARFDebugInfoEntry::Extract
if (form_value.ExtractValue(debug_info_data, &offset))
{
if (attr == DW_AT_low_pc || attr == DW_AT_entry_pc)
- ((DWARFCompileUnit*)cu)->SetBaseAddress(form_value.Unsigned());
+ const_cast<DWARFCompileUnit*>(cu)->SetBaseAddress(form_value.Address());
}
}
else
@@ -389,9 +310,11 @@ DWARFDebugInfoEntry::Extract
break;
// signed or unsigned LEB 128 values
- case DW_FORM_sdata :
- case DW_FORM_udata :
- case DW_FORM_ref_udata :
+ 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;
@@ -456,276 +379,6 @@ DWARFDebugInfoEntry::DumpAncestry
}
//----------------------------------------------------------------------
-// Compare two DIE by comparing all their attributes values, and
-// following all DW_FORM_ref attributes and comparing their contents as
-// well (except for DW_AT_sibling attributes.
-//
-// DWARFDebugInfoEntry::CompareState compare_state;
-// int result = DWARFDebugInfoEntry::Compare(this, 0x00017ccb, 0x0001eb2b, compare_state, false, true);
-//----------------------------------------------------------------------
-//int
-//DWARFDebugInfoEntry::Compare
-//(
-// SymbolFileDWARF* dwarf2Data,
-// dw_offset_t a_die_offset,
-// dw_offset_t b_die_offset,
-// CompareState &compare_state,
-// bool compare_siblings,
-// bool compare_children
-//)
-//{
-// if (a_die_offset == b_die_offset)
-// return 0;
-//
-// DWARFCompileUnitSP a_cu_sp;
-// DWARFCompileUnitSP b_cu_sp;
-// const DWARFDebugInfoEntry* a_die = dwarf2Data->DebugInfo()->GetDIEPtr(a_die_offset, &a_cu_sp);
-// const DWARFDebugInfoEntry* b_die = dwarf2Data->DebugInfo()->GetDIEPtr(b_die_offset, &b_cu_sp);
-//
-// return Compare(dwarf2Data, a_cu_sp.get(), a_die, b_cu_sp.get(), b_die, compare_state, compare_siblings, compare_children);
-//}
-//
-//int
-//DWARFDebugInfoEntry::Compare
-//(
-// SymbolFileDWARF* dwarf2Data,
-// DWARFCompileUnit* a_cu, const DWARFDebugInfoEntry* a_die,
-// DWARFCompileUnit* b_cu, const DWARFDebugInfoEntry* b_die,
-// CompareState &compare_state,
-// bool compare_siblings,
-// bool compare_children
-//)
-//{
-// if (a_die == b_die)
-// return 0;
-//
-// if (!compare_state.AddTypePair(a_die->GetOffset(), b_die->GetOffset()))
-// {
-// // We are already comparing both of these types, so let
-// // compares complete for the real result
-// return 0;
-// }
-//
-// //printf("DWARFDebugInfoEntry::Compare(0x%8.8x, 0x%8.8x)\n", a_die->GetOffset(), b_die->GetOffset());
-//
-// // Do we have two valid DIEs?
-// if (a_die && b_die)
-// {
-// // Both DIE are valid
-// int result = 0;
-//
-// const dw_tag_t a_tag = a_die->Tag();
-// const dw_tag_t b_tag = b_die->Tag();
-// if (a_tag == 0 && b_tag == 0)
-// return 0;
-//
-// //printf(" comparing tags: %s and %s\n", DW_TAG_value_to_name(a_tag), DW_TAG_value_to_name(b_tag));
-//
-// if (a_tag < b_tag)
-// return -1;
-// else if (a_tag > b_tag)
-// return 1;
-//
-// DWARFDebugInfoEntry::Attributes a_attrs;
-// DWARFDebugInfoEntry::Attributes b_attrs;
-// size_t a_attr_count = a_die->GetAttributes(dwarf2Data, a_cu, a_attrs);
-// size_t b_attr_count = b_die->GetAttributes(dwarf2Data, b_cu, b_attrs);
-// if (a_attr_count != b_attr_count)
-// {
-// a_attrs.RemoveAttribute(DW_AT_sibling);
-// b_attrs.RemoveAttribute(DW_AT_sibling);
-// }
-//
-// a_attr_count = a_attrs.Size();
-// b_attr_count = b_attrs.Size();
-//
-// DWARFFormValue a_form_value;
-// DWARFFormValue b_form_value;
-//
-// if (a_attr_count != b_attr_count)
-// {
-// uint32_t is_decl_index = a_attrs.FindAttributeIndex(DW_AT_declaration);
-// uint32_t a_name_index = UINT32_MAX;
-// uint32_t b_name_index = UINT32_MAX;
-// if (is_decl_index != UINT32_MAX)
-// {
-// if (a_attr_count == 2)
-// {
-// a_name_index = a_attrs.FindAttributeIndex(DW_AT_name);
-// b_name_index = b_attrs.FindAttributeIndex(DW_AT_name);
-// }
-// }
-// else
-// {
-// is_decl_index = b_attrs.FindAttributeIndex(DW_AT_declaration);
-// if (is_decl_index != UINT32_MAX && a_attr_count == 2)
-// {
-// a_name_index = a_attrs.FindAttributeIndex(DW_AT_name);
-// b_name_index = b_attrs.FindAttributeIndex(DW_AT_name);
-// }
-// }
-// if (a_name_index != UINT32_MAX && b_name_index != UINT32_MAX)
-// {
-// if (a_attrs.ExtractFormValueAtIndex(dwarf2Data, a_name_index, a_form_value) &&
-// b_attrs.ExtractFormValueAtIndex(dwarf2Data, b_name_index, b_form_value))
-// {
-// result = DWARFFormValue::Compare (a_form_value, b_form_value, a_cu, b_cu, &dwarf2Data->get_debug_str_data());
-// if (result == 0)
-// {
-// a_attr_count = b_attr_count = 0;
-// compare_children = false;
-// }
-// }
-// }
-// }
-//
-// if (a_attr_count < b_attr_count)
-// return -1;
-// if (a_attr_count > b_attr_count)
-// return 1;
-//
-//
-// // The number of attributes are the same...
-// if (a_attr_count > 0)
-// {
-// const DWARFDataExtractor* debug_str_data_ptr = &dwarf2Data->get_debug_str_data();
-//
-// uint32_t i;
-// for (i=0; i<a_attr_count; ++i)
-// {
-// const dw_attr_t a_attr = a_attrs.AttributeAtIndex(i);
-// const dw_attr_t b_attr = b_attrs.AttributeAtIndex(i);
-// //printf(" comparing attributes\n\t\t0x%8.8x: %s %s\t\t0x%8.8x: %s %s\n",
-// // a_attrs.DIEOffsetAtIndex(i), DW_FORM_value_to_name(a_attrs.FormAtIndex(i)), DW_AT_value_to_name(a_attr),
-// // b_attrs.DIEOffsetAtIndex(i), DW_FORM_value_to_name(b_attrs.FormAtIndex(i)), DW_AT_value_to_name(b_attr));
-//
-// if (a_attr < b_attr)
-// return -1;
-// else if (a_attr > b_attr)
-// return 1;
-//
-// switch (a_attr)
-// {
-// // Since we call a form of GetAttributes which inlines the
-// // attributes from DW_AT_abstract_origin and DW_AT_specification
-// // we don't care if their values mismatch...
-// case DW_AT_abstract_origin:
-// case DW_AT_specification:
-// case DW_AT_sibling:
-// case DW_AT_containing_type:
-// //printf(" action = IGNORE\n");
-// result = 0;
-// break; // ignore
-//
-// default:
-// if (a_attrs.ExtractFormValueAtIndex(dwarf2Data, i, a_form_value) &&
-// b_attrs.ExtractFormValueAtIndex(dwarf2Data, i, b_form_value))
-// result = DWARFFormValue::Compare (a_form_value, b_form_value, a_cu, b_cu, debug_str_data_ptr);
-// break;
-// }
-//
-// //printf("\t result = %i\n", result);
-//
-// if (result != 0)
-// {
-// // Attributes weren't equal, lets see if we care?
-// switch (a_attr)
-// {
-// case DW_AT_decl_file:
-// // TODO: add the ability to compare files in two different compile units
-// if (a_cu == b_cu)
-// {
-// //printf(" action = RETURN RESULT\n");
-// return result; // Only return the compare results when the compile units are the same and the decl_file attributes can be compared
-// }
-// else
-// {
-// result = 0;
-// //printf(" action = IGNORE\n");
-// }
-// break;
-//
-// default:
-// switch (a_attrs.FormAtIndex(i))
-// {
-// case DW_FORM_ref1:
-// case DW_FORM_ref2:
-// case DW_FORM_ref4:
-// case DW_FORM_ref8:
-// case DW_FORM_ref_udata:
-// case DW_FORM_ref_addr:
-// //printf(" action = COMPARE DIEs 0x%8.8x 0x%8.8x\n", (dw_offset_t)a_form_value.Reference(a_cu), (dw_offset_t)b_form_value.Reference(b_cu));
-// // These attribute values refer to other DIEs, so lets compare those instead of their DIE offsets...
-// result = Compare(dwarf2Data, a_form_value.Reference(a_cu), b_form_value.Reference(b_cu), compare_state, false, true);
-// if (result != 0)
-// return result;
-// break;
-//
-// default:
-// // We do care that they were different, return this result...
-// //printf(" action = RETURN RESULT\n");
-// return result;
-// }
-// }
-// }
-// }
-// }
-// //printf(" SUCCESS\n\t\t0x%8.8x: %s\n\t\t0x%8.8x: %s\n", a_die->GetOffset(), DW_TAG_value_to_name(a_tag), b_die->GetOffset(), DW_TAG_value_to_name(b_tag));
-//
-// if (compare_children)
-// {
-// bool a_has_children = a_die->HasChildren();
-// bool b_has_children = b_die->HasChildren();
-// if (a_has_children == b_has_children)
-// {
-// // Both either have kids or don't
-// if (a_has_children)
-// result = Compare( dwarf2Data,
-// a_cu, a_die->GetFirstChild(),
-// b_cu, b_die->GetFirstChild(),
-// compare_state, true, compare_children);
-// else
-// result = 0;
-// }
-// else if (!a_has_children)
-// result = -1; // A doesn't have kids, but B does
-// else
-// result = 1; // A has kids, but B doesn't
-// }
-//
-// if (compare_siblings)
-// {
-// result = Compare( dwarf2Data,
-// a_cu, a_die->GetSibling(),
-// b_cu, b_die->GetSibling(),
-// compare_state, true, compare_children);
-// }
-//
-// return result;
-// }
-//
-// if (a_die == NULL)
-// return -1; // a_die is NULL, yet b_die is non-NULL
-// else
-// return 1; // a_die is non-NULL, yet b_die is NULL
-//
-//}
-//
-//
-//int
-//DWARFDebugInfoEntry::Compare
-//(
-// SymbolFileDWARF* dwarf2Data,
-// const DWARFCompileUnit* cu_a,
-// const DWARFDebugInfoEntry* die_a,
-// const DWARFCompileUnit* cu_a,
-// const DWARFDebugInfoEntry* die_b,
-// CompareState &compare_state
-//)
-//{
-//}
-
-//----------------------------------------------------------------------
// GetDIENamesAndRanges
//
// Gets the valid address ranges for a given DIE by looking for a
@@ -739,7 +392,7 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges
const DWARFCompileUnit* cu,
const char * &name,
const char * &mangled,
- DWARFDebugRanges::RangeList& ranges,
+ DWARFRangeList& ranges,
int& decl_file,
int& decl_line,
int& decl_column,
@@ -749,12 +402,27 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges
DWARFExpression *frame_base
) const
{
- if (dwarf2Data == NULL)
+ 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);
+
dw_addr_t lo_pc = LLDB_INVALID_ADDRESS;
dw_addr_t hi_pc = LLDB_INVALID_ADDRESS;
- std::vector<dw_offset_t> die_offsets;
+ std::vector<DIERef> die_refs;
bool set_frame_base_loclist_addr = false;
lldb::offset_t offset;
@@ -784,7 +452,7 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges
switch (attr)
{
case DW_AT_low_pc:
- lo_pc = form_value.Unsigned();
+ lo_pc = form_value.Address();
if (do_offset)
hi_pc += lo_pc;
@@ -792,13 +460,18 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges
break;
case DW_AT_entry_pc:
- lo_pc = form_value.Unsigned();
+ lo_pc = form_value.Address();
break;
case DW_AT_high_pc:
- hi_pc = form_value.Unsigned();
- if (form_value.Form() != DW_FORM_addr)
+ if (form_value.Form() == DW_FORM_addr ||
+ form_value.Form() == DW_FORM_GNU_addr_index)
{
+ hi_pc = form_value.Address();
+ }
+ else
+ {
+ hi_pc = form_value.Unsigned();
if (lo_pc == LLDB_INVALID_ADDRESS)
do_offset = hi_pc != LLDB_INVALID_ADDRESS;
else
@@ -819,21 +492,21 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges
case DW_AT_name:
if (name == NULL)
- name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
+ name = form_value.AsCString();
break;
case DW_AT_MIPS_linkage_name:
case DW_AT_linkage_name:
if (mangled == NULL)
- mangled = form_value.AsCString(&dwarf2Data->get_debug_str_data());
+ mangled = form_value.AsCString();
break;
case DW_AT_abstract_origin:
- die_offsets.push_back(form_value.Reference());
+ die_refs.emplace_back(form_value);
break;
case DW_AT_specification:
- die_offsets.push_back(form_value.Reference());
+ die_refs.emplace_back(form_value);
break;
case DW_AT_decl_file:
@@ -880,7 +553,7 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges
const DWARFDataExtractor &debug_loc_data = dwarf2Data->get_debug_loc_data();
const dw_offset_t debug_loc_offset = form_value.Unsigned();
- size_t loc_list_length = DWARFLocationList::Size(debug_loc_data, debug_loc_offset);
+ 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);
@@ -910,9 +583,9 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges
if (lo_pc != LLDB_INVALID_ADDRESS)
{
if (hi_pc != LLDB_INVALID_ADDRESS && hi_pc > lo_pc)
- ranges.Append(DWARFDebugRanges::Range (lo_pc, hi_pc - lo_pc));
+ ranges.Append(DWARFRangeList::Entry (lo_pc, hi_pc - lo_pc));
else
- ranges.Append(DWARFDebugRanges::Range (lo_pc, 0));
+ ranges.Append(DWARFRangeList::Entry (lo_pc, 0));
}
}
@@ -925,18 +598,13 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges
if (ranges.IsEmpty() || name == NULL || mangled == NULL)
{
- std::vector<dw_offset_t>::const_iterator pos;
- std::vector<dw_offset_t>::const_iterator end = die_offsets.end();
- for (pos = die_offsets.begin(); pos != end; ++pos)
+ for (const DIERef& die_ref : die_refs)
{
- DWARFCompileUnitSP cu_sp_ptr;
- const DWARFDebugInfoEntry* die = NULL;
- dw_offset_t die_offset = *pos;
- if (die_offset != DW_INVALID_OFFSET)
+ if (die_ref.die_offset != DW_INVALID_OFFSET)
{
- die = dwarf2Data->DebugInfo()->GetDIEPtr(die_offset, &cu_sp_ptr);
+ DWARFDIE die = dwarf2Data->DebugInfo()->GetDIE(die_ref);
if (die)
- die->GetDIENamesAndRanges(dwarf2Data, cu_sp_ptr.get(), name, mangled, ranges, decl_file, decl_line, decl_column, call_file, call_line, call_column);
+ die.GetDIE()->GetDIENamesAndRanges(die.GetDWARF(), die.GetCU(), name, mangled, ranges, decl_file, decl_line, decl_column, call_file, call_line, call_column);
}
}
}
@@ -1023,10 +691,10 @@ DWARFDebugInfoEntry::DumpLocation
Stream &s
) const
{
- const DWARFDebugInfoEntry *cu_die = cu->GetCompileUnitDIEOnly();
+ const DWARFDIE cu_die = cu->GetCompileUnitDIEOnly();
const char *cu_name = NULL;
- if (cu_die != NULL)
- cu_name = cu_die->GetName (dwarf2Data, cu);
+ if (cu_die)
+ cu_name = cu_die.GetName ();
const char *obj_file_name = NULL;
ObjectFile *obj_file = dwarf2Data->GetObjectFile();
if (obj_file)
@@ -1062,7 +730,6 @@ DWARFDebugInfoEntry::DumpAttribute
bool verbose = s.GetVerbose();
bool show_form = s.GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowForm);
- const DWARFDataExtractor* debug_str_data = dwarf2Data ? &dwarf2Data->get_debug_str_data() : NULL;
if (verbose)
s.Offset (*offset_ptr);
else
@@ -1094,7 +761,7 @@ DWARFDebugInfoEntry::DumpAttribute
// Always dump form value if verbose is enabled
if (verbose)
{
- form_value.Dump(s, debug_str_data);
+ form_value.Dump(s);
}
@@ -1127,12 +794,16 @@ DWARFDebugInfoEntry::DumpAttribute
if (blockData)
{
if (!verbose)
- form_value.Dump(s, debug_str_data);
+ form_value.Dump(s);
// Location description is inlined in data in the form value
DWARFDataExtractor locationData(debug_info_data, (*offset_ptr) - form_value.Unsigned(), form_value.Unsigned());
if ( verbose ) s.PutCString(" ( ");
- print_dwarf_expression (s, locationData, DWARFCompileUnit::GetAddressByteSize(cu), 4, false);
+ DWARFExpression::PrintDWARFExpression(s,
+ locationData,
+ DWARFCompileUnit::GetAddressByteSize(cu),
+ 4,
+ false);
if ( verbose ) s.PutCString(" )");
}
else
@@ -1144,13 +815,16 @@ DWARFDebugInfoEntry::DumpAttribute
if (dwarf2Data)
{
if ( !verbose )
- form_value.Dump(s, debug_str_data);
- DWARFLocationList::Dump(s, cu, dwarf2Data->get_debug_loc_data(), debug_loc_offset);
+ form_value.Dump(s);
+ DWARFExpression::PrintDWARFLocationList(s,
+ cu,
+ dwarf2Data->get_debug_loc_data(),
+ debug_loc_offset);
}
else
{
if ( !verbose )
- form_value.Dump(s, NULL);
+ form_value.Dump(s);
}
}
}
@@ -1160,7 +834,7 @@ DWARFDebugInfoEntry::DumpAttribute
case DW_AT_specification:
{
uint64_t abstract_die_offset = form_value.Reference();
- form_value.Dump(s, debug_str_data);
+ form_value.Dump(s);
// *ostrm_ptr << HEX32 << abstract_die_offset << " ( ";
if ( verbose ) s.PutCString(" ( ");
GetName(dwarf2Data, cu, abstract_die_offset, s);
@@ -1172,7 +846,7 @@ DWARFDebugInfoEntry::DumpAttribute
{
uint64_t type_die_offset = form_value.Reference();
if (!verbose)
- form_value.Dump(s, debug_str_data);
+ form_value.Dump(s);
s.PutCString(" ( ");
AppendTypeName(dwarf2Data, cu, type_die_offset, s);
s.PutCString(" )");
@@ -1182,7 +856,7 @@ DWARFDebugInfoEntry::DumpAttribute
case DW_AT_ranges:
{
if ( !verbose )
- form_value.Dump(s, debug_str_data);
+ form_value.Dump(s);
lldb::offset_t ranges_offset = form_value.Unsigned();
dw_addr_t base_addr = cu ? cu->GetBaseAddress() : 0;
if (dwarf2Data)
@@ -1192,7 +866,7 @@ DWARFDebugInfoEntry::DumpAttribute
default:
if ( !verbose )
- form_value.Dump(s, debug_str_data);
+ form_value.Dump(s);
break;
}
@@ -1206,24 +880,37 @@ DWARFDebugInfoEntry::DumpAttribute
// take precedence (this can happen for declaration attributes).
//----------------------------------------------------------------------
size_t
-DWARFDebugInfoEntry::GetAttributes
-(
- SymbolFileDWARF* dwarf2Data,
- const DWARFCompileUnit* cu,
- const uint8_t *fixed_form_sizes,
- DWARFDebugInfoEntry::Attributes& attributes,
- uint32_t curr_depth
-) const
+DWARFDebugInfoEntry::GetAttributes (const DWARFCompileUnit* cu,
+ DWARFFormValue::FixedFormSizes fixed_form_sizes,
+ DWARFAttributes& attributes,
+ uint32_t curr_depth) const
{
- lldb::offset_t offset;
- const DWARFAbbreviationDeclaration* abbrevDecl = GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset);
+ SymbolFileDWARF* dwarf2Data = nullptr;
+ const DWARFAbbreviationDeclaration* abbrevDecl = nullptr;
+ lldb::offset_t offset = 0;
+ if (cu)
+ {
+ if (m_tag != DW_TAG_compile_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);
+ }
if (abbrevDecl)
{
const DWARFDataExtractor& debug_info_data = dwarf2Data->get_debug_info_data();
- if (fixed_form_sizes == NULL)
- fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize(cu->GetAddressByteSize(), cu->IsDWARF64());
+ if (fixed_form_sizes.Empty())
+ fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize(
+ cu->GetAddressByteSize(), cu->IsDWARF64());
const uint32_t num_attributes = abbrevDecl->NumAttributes();
uint32_t i;
@@ -1258,26 +945,15 @@ DWARFDebugInfoEntry::GetAttributes
DWARFFormValue form_value (cu, form);
if (form_value.ExtractValue(debug_info_data, &offset))
{
- const DWARFDebugInfoEntry* die = NULL;
dw_offset_t die_offset = form_value.Reference();
- if (cu->ContainsDIEOffset(die_offset))
- {
- die = const_cast<DWARFCompileUnit*>(cu)->GetDIEPtr(die_offset);
- if (die)
- die->GetAttributes(dwarf2Data, cu, fixed_form_sizes, attributes, curr_depth + 1);
- }
- else
- {
- DWARFCompileUnitSP cu_sp_ptr;
- die = const_cast<SymbolFileDWARF*>(dwarf2Data)->DebugInfo()->GetDIEPtr(die_offset, &cu_sp_ptr);
- if (die)
- die->GetAttributes(dwarf2Data, cu_sp_ptr.get(), fixed_form_sizes, attributes, curr_depth + 1);
- }
+ DWARFDIE spec_die = const_cast<DWARFCompileUnit*>(cu)->GetDIE(die_offset);
+ if (spec_die)
+ spec_die.GetAttributes(attributes, curr_depth + 1);
}
}
else
{
- const uint8_t fixed_skip_size = fixed_form_sizes [form];
+ const uint8_t fixed_skip_size = fixed_form_sizes.GetSize(form);
if (fixed_skip_size)
offset += fixed_skip_size;
else
@@ -1308,9 +984,19 @@ DWARFDebugInfoEntry::GetAttributeValue
const DWARFCompileUnit* cu,
const dw_attr_t attr,
DWARFFormValue& form_value,
- dw_offset_t* end_attr_offset_ptr
+ 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)
+ 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);
@@ -1338,7 +1024,58 @@ DWARFDebugInfoEntry::GetAttributeValue
}
}
- return 0;
+ if (check_specification_or_abstract_origin)
+ {
+ if (GetAttributeValue(dwarf2Data, cu, DW_AT_specification, form_value))
+ {
+ DWARFDIE die = const_cast<DWARFCompileUnit*>(cu)->GetDIE(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);
+ if (die_offset)
+ return die_offset;
+ }
+ }
+
+ if (GetAttributeValue(dwarf2Data, cu, DW_AT_abstract_origin, form_value))
+ {
+ DWARFDIE die = const_cast<DWARFCompileUnit*>(cu)->GetDIE(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);
+ if (die_offset)
+ return die_offset;
+ }
+ }
+ }
+
+ if (!dwo_symbol_file)
+ return 0;
+
+ DWARFCompileUnit* dwo_cu = dwo_symbol_file->GetCompileUnit();
+ if (!dwo_cu)
+ return 0;
+
+ DWARFDIE dwo_cu_die = dwo_cu->GetCompileUnitDIEOnly();
+ if (!dwo_cu_die.IsValid())
+ return 0;
+
+ return dwo_cu_die.GetDIE()->GetAttributeValue(dwo_symbol_file,
+ dwo_cu,
+ attr,
+ form_value,
+ end_attr_offset_ptr,
+ check_specification_or_abstract_origin);
}
//----------------------------------------------------------------------
@@ -1355,11 +1092,12 @@ DWARFDebugInfoEntry::GetAttributeValueAsString
SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
const dw_attr_t attr,
- const char* fail_value) const
+ const char* fail_value,
+ bool check_specification_or_abstract_origin) const
{
DWARFFormValue form_value;
- if (GetAttributeValue(dwarf2Data, cu, attr, form_value))
- return form_value.AsCString(&dwarf2Data->get_debug_str_data());
+ if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr, check_specification_or_abstract_origin))
+ return form_value.AsCString();
return fail_value;
}
@@ -1374,11 +1112,12 @@ DWARFDebugInfoEntry::GetAttributeValueAsUnsigned
SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
const dw_attr_t attr,
- uint64_t fail_value
+ uint64_t fail_value,
+ bool check_specification_or_abstract_origin
) const
{
DWARFFormValue form_value;
- if (GetAttributeValue(dwarf2Data, cu, attr, form_value))
+ if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr, check_specification_or_abstract_origin))
return form_value.Unsigned();
return fail_value;
}
@@ -1394,11 +1133,12 @@ DWARFDebugInfoEntry::GetAttributeValueAsSigned
SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
const dw_attr_t attr,
- int64_t fail_value
+ int64_t fail_value,
+ bool check_specification_or_abstract_origin
) const
{
DWARFFormValue form_value;
- if (GetAttributeValue(dwarf2Data, cu, attr, form_value))
+ if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr, check_specification_or_abstract_origin))
return form_value.Signed();
return fail_value;
}
@@ -1415,15 +1155,32 @@ DWARFDebugInfoEntry::GetAttributeValueAsReference
SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
const dw_attr_t attr,
- uint64_t fail_value
+ uint64_t fail_value,
+ bool check_specification_or_abstract_origin
) const
{
DWARFFormValue form_value;
- if (GetAttributeValue(dwarf2Data, cu, attr, form_value))
+ if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr, check_specification_or_abstract_origin))
return form_value.Reference();
return fail_value;
}
+uint64_t
+DWARFDebugInfoEntry::GetAttributeValueAsAddress
+(
+ SymbolFileDWARF* dwarf2Data,
+ const DWARFCompileUnit* 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, check_specification_or_abstract_origin))
+ return form_value.Address();
+ return fail_value;
+}
+
//----------------------------------------------------------------------
// GetAttributeHighPC
//
@@ -1438,17 +1195,19 @@ DWARFDebugInfoEntry::GetAttributeHighPC
SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
dw_addr_t lo_pc,
- uint64_t fail_value
+ uint64_t fail_value,
+ bool check_specification_or_abstract_origin
) const
{
DWARFFormValue form_value;
-
- if (GetAttributeValue(dwarf2Data, cu, DW_AT_high_pc, form_value))
+ if (GetAttributeValue(dwarf2Data, cu, DW_AT_high_pc, form_value, nullptr, check_specification_or_abstract_origin))
{
- dw_addr_t hi_pc = form_value.Unsigned();
- if (form_value.Form() != DW_FORM_addr)
- hi_pc += lo_pc; // DWARF4 can specify the hi_pc as an <offset-from-lowpc>
- return hi_pc;
+ dw_form_t form = form_value.Form();
+ if (form == DW_FORM_addr || form == DW_FORM_GNU_addr_index)
+ return form_value.Address();
+
+ // DWARF4 can specify the hi_pc as an <offset-from-lowpc>
+ return lo_pc + form_value.Unsigned();
}
return fail_value;
}
@@ -1468,13 +1227,14 @@ DWARFDebugInfoEntry::GetAttributeAddressRange
const DWARFCompileUnit* cu,
dw_addr_t& lo_pc,
dw_addr_t& hi_pc,
- uint64_t fail_value
+ uint64_t fail_value,
+ bool check_specification_or_abstract_origin
) const
{
- lo_pc = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_low_pc, fail_value);
+ lo_pc = GetAttributeValueAsAddress(dwarf2Data, 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(dwarf2Data, cu, lo_pc, fail_value, check_specification_or_abstract_origin);
if (hi_pc != fail_value)
return true;
}
@@ -1484,89 +1244,40 @@ DWARFDebugInfoEntry::GetAttributeAddressRange
}
size_t
-DWARFDebugInfoEntry::GetAttributeAddressRanges(SymbolFileDWARF* dwarf2Data,
- const DWARFCompileUnit* cu,
- DWARFDebugRanges::RangeList &ranges,
- bool check_hi_lo_pc) const
+DWARFDebugInfoEntry::GetAttributeAddressRanges (SymbolFileDWARF* dwarf2Data,
+ const DWARFCompileUnit* cu,
+ DWARFRangeList &ranges,
+ bool check_hi_lo_pc,
+ bool check_specification_or_abstract_origin) const
{
ranges.Clear();
- dw_offset_t ranges_offset = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_ranges, DW_INVALID_OFFSET);
- if (ranges_offset != DW_INVALID_OFFSET)
+ dw_offset_t debug_ranges_offset = GetAttributeValueAsUnsigned(dwarf2Data,
+ cu,
+ DW_AT_ranges,
+ DW_INVALID_OFFSET,
+ check_specification_or_abstract_origin);
+ if (debug_ranges_offset != DW_INVALID_OFFSET)
{
- dw_offset_t debug_ranges_offset = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_ranges, DW_INVALID_OFFSET);
- if (debug_ranges_offset != DW_INVALID_OFFSET)
- {
- DWARFDebugRanges* debug_ranges = dwarf2Data->DebugRanges();
-
- debug_ranges->FindRanges(debug_ranges_offset, ranges);
- ranges.Slide (cu->GetBaseAddress());
- }
+ DWARFDebugRanges* debug_ranges = dwarf2Data->DebugRanges();
+
+ debug_ranges->FindRanges(debug_ranges_offset, ranges);
+ ranges.Slide (cu->GetBaseAddress());
}
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 (dwarf2Data, cu, lo_pc, hi_pc, LLDB_INVALID_ADDRESS, check_specification_or_abstract_origin))
{
if (lo_pc < hi_pc)
- ranges.Append(DWARFDebugRanges::RangeList::Entry(lo_pc, hi_pc - lo_pc));
+ ranges.Append(DWARFRangeList::Entry(lo_pc, hi_pc - lo_pc));
}
}
return ranges.GetSize();
}
//----------------------------------------------------------------------
-// GetAttributeValueAsLocation
-//
-// Get the value of an attribute as reference and fix up and compile
-// unit relative offsets as needed.
-//----------------------------------------------------------------------
-dw_offset_t
-DWARFDebugInfoEntry::GetAttributeValueAsLocation
-(
- SymbolFileDWARF* dwarf2Data,
- const DWARFCompileUnit* cu,
- const dw_attr_t attr,
- DWARFDataExtractor& location_data,
- uint32_t &block_size
-) const
-{
- block_size = 0;
- DWARFFormValue form_value;
-
- // Empty out data in case we don't find anything
- location_data.Clear();
- dw_offset_t end_addr_offset = DW_INVALID_OFFSET;
- const dw_offset_t attr_offset = GetAttributeValue(dwarf2Data, cu, attr, form_value, &end_addr_offset);
- if (attr_offset)
- {
- const uint8_t* blockData = form_value.BlockData();
- if (blockData)
- {
- // We have an inlined location list in the .debug_info section
- const DWARFDataExtractor& debug_info = dwarf2Data->get_debug_info_data();
- dw_offset_t block_offset = blockData - debug_info.GetDataStart();
- block_size = (end_addr_offset - attr_offset) - form_value.Unsigned();
- location_data.SetData(debug_info, block_offset, block_size);
- }
- else
- {
- // 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
- lldb::offset_t debug_loc_offset = form_value.Unsigned();
- if (dwarf2Data)
- {
- assert(dwarf2Data->get_debug_loc_data().GetAddressByteSize() == cu->GetAddressByteSize());
- return DWARFLocationList::Extract(dwarf2Data->get_debug_loc_data(), &debug_loc_offset, location_data);
- }
- }
- }
- return attr_offset;
-}
-
-//----------------------------------------------------------------------
// GetName
//
// Get value of the DW_AT_name attribute and return it if one exists,
@@ -1579,27 +1290,9 @@ DWARFDebugInfoEntry::GetName
const DWARFCompileUnit* cu
) const
{
- DWARFFormValue form_value;
- if (GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value))
- return form_value.AsCString(&dwarf2Data->get_debug_str_data());
- else if (GetAttributeValue(dwarf2Data, cu, DW_AT_specification, form_value))
- {
- DWARFCompileUnitSP cu_sp_ptr;
- const DWARFDebugInfoEntry* die = const_cast<SymbolFileDWARF*>(dwarf2Data)->DebugInfo()->GetDIEPtr(form_value.Reference(), &cu_sp_ptr);
- if (die)
- return die->GetName(dwarf2Data, cu_sp_ptr.get());
- }
- else if (GetAttributeValue(dwarf2Data, cu, DW_AT_abstract_origin, form_value))
- {
- DWARFCompileUnitSP cu_sp_ptr;
- const DWARFDebugInfoEntry* die = const_cast<SymbolFileDWARF*>(dwarf2Data)->DebugInfo()->GetDIEPtr(form_value.Reference(), &cu_sp_ptr);
- if (die)
- return die->GetName(dwarf2Data, cu_sp_ptr.get());
- }
- return nullptr;
+ return GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, nullptr, true);
}
-
//----------------------------------------------------------------------
// GetMangledName
//
@@ -1614,20 +1307,20 @@ DWARFDebugInfoEntry::GetMangledName
bool substitute_name_allowed
) const
{
- const char* name = NULL;
- DWARFFormValue form_value;
+ const char* name = nullptr;
- if (GetAttributeValue(dwarf2Data, cu, DW_AT_MIPS_linkage_name, form_value))
- name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
+ name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_MIPS_linkage_name, nullptr, true);
+ if (name)
+ return name;
- if (GetAttributeValue(dwarf2Data, cu, DW_AT_linkage_name, form_value))
- name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
+ name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_linkage_name, nullptr, true);
+ if (name)
+ return name;
- if (substitute_name_allowed && name == NULL)
- {
- if (GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value))
- name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
- }
+ if (!substitute_name_allowed)
+ return nullptr;
+
+ name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, nullptr, true);
return name;
}
@@ -1645,27 +1338,19 @@ DWARFDebugInfoEntry::GetPubname
const DWARFCompileUnit* cu
) const
{
- const char* name = NULL;
+ const char* name = nullptr;
if (!dwarf2Data)
return name;
-
- DWARFFormValue form_value;
- if (GetAttributeValue(dwarf2Data, cu, DW_AT_MIPS_linkage_name, form_value))
- name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
- else if (GetAttributeValue(dwarf2Data, cu, DW_AT_linkage_name, form_value))
- name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
- else if (GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value))
- name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
- else if (GetAttributeValue(dwarf2Data, cu, DW_AT_specification, form_value))
- {
- // The specification DIE may be in another compile unit so we need
- // to get a die and its compile unit.
- DWARFCompileUnitSP cu_sp_ptr;
- const DWARFDebugInfoEntry* die = const_cast<SymbolFileDWARF*>(dwarf2Data)->DebugInfo()->GetDIEPtr(form_value.Reference(), &cu_sp_ptr);
- if (die)
- return die->GetPubname(dwarf2Data, cu_sp_ptr.get());
- }
+ name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_MIPS_linkage_name, nullptr, true);
+ if (name)
+ return name;
+
+ name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_linkage_name, nullptr, true);
+ if (name)
+ return name;
+
+ name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, nullptr, true);
return name;
}
@@ -1705,15 +1390,11 @@ DWARFDebugInfoEntry::GetName
}
else
{
- DWARFFormValue form_value;
- if (die.GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value))
+ const char* name = die.GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, nullptr, true);
+ if (name)
{
- const char* name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
- if (name)
- {
- s.PutCString(name);
- return true;
- }
+ s.PutCString(name);
+ return true;
}
}
}
@@ -1755,8 +1436,6 @@ DWARFDebugInfoEntry::AppendTypeName
else
{
const char* name = die.GetPubname(dwarf2Data, cu);
- // if (die.GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value))
- // name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
if (name)
s.PutCString(name);
else
@@ -1909,16 +1588,12 @@ DWARFDebugInfoEntry::BuildFunctionAddressRangeTable
}
void
-DWARFDebugInfoEntry::GetDeclContextDIEs (SymbolFileDWARF* dwarf2Data,
- DWARFCompileUnit* cu,
+DWARFDebugInfoEntry::GetDeclContextDIEs (DWARFCompileUnit* cu,
DWARFDIECollection &decl_context_dies) const
{
- const DWARFDebugInfoEntry *parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu);
- if (parent_decl_ctx_die && parent_decl_ctx_die != this)
- {
- decl_context_dies.Append(parent_decl_ctx_die);
- parent_decl_ctx_die->GetDeclContextDIEs (dwarf2Data, cu, decl_context_dies);
- }
+
+ DWARFDIE die (cu, const_cast<DWARFDebugInfoEntry *>(this));
+ die.GetDeclContextDIEs(decl_context_dies);
}
void
@@ -1930,11 +1605,11 @@ DWARFDebugInfoEntry::GetDWARFDeclContext (SymbolFileDWARF* dwarf2Data,
if (tag != DW_TAG_compile_unit)
{
dwarf_decl_ctx.AppendDeclContext(tag, GetName(dwarf2Data, cu));
- const DWARFDebugInfoEntry *parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu);
- if (parent_decl_ctx_die && parent_decl_ctx_die != this)
+ DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, 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->GetDWARFDeclContext (dwarf2Data, cu, dwarf_decl_ctx);
+ if (parent_decl_ctx_die.Tag() != DW_TAG_compile_unit)
+ parent_decl_ctx_die.GetDIE()->GetDWARFDeclContext (parent_decl_ctx_die.GetDWARF(), parent_decl_ctx_die.GetCU(), dwarf_decl_ctx);
}
}
}
@@ -1951,30 +1626,30 @@ DWARFDebugInfoEntry::MatchesDWARFDeclContext (SymbolFileDWARF* dwarf2Data,
return this_dwarf_decl_ctx == dwarf_decl_ctx;
}
-const DWARFDebugInfoEntry *
+DWARFDIE
DWARFDebugInfoEntry::GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data,
DWARFCompileUnit* cu) const
{
- DWARFDebugInfoEntry::Attributes attributes;
- GetAttributes(dwarf2Data, cu, NULL, attributes);
+ DWARFAttributes attributes;
+ GetAttributes(cu, DWARFFormValue::FixedFormSizes(), attributes);
return GetParentDeclContextDIE (dwarf2Data, cu, attributes);
}
-const DWARFDebugInfoEntry *
+DWARFDIE
DWARFDebugInfoEntry::GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data,
DWARFCompileUnit* cu,
- const DWARFDebugInfoEntry::Attributes& attributes) const
+ const DWARFAttributes& attributes) const
{
- const DWARFDebugInfoEntry * die = this;
-
- while (die != NULL)
+ DWARFDIE die (cu, const_cast<DWARFDebugInfoEntry *>(this));
+
+ while (die)
{
// If this is the original DIE that we are searching for a declaration
// for, then don't look in the cache as we don't want our own decl
// context to be our decl context...
- if (die != this)
+ if (die.GetDIE() != this)
{
- switch (die->Tag())
+ switch (die.Tag())
{
case DW_TAG_compile_unit:
case DW_TAG_namespace:
@@ -1990,33 +1665,33 @@ DWARFDebugInfoEntry::GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data,
dw_offset_t die_offset;
- die_offset = attributes.FormValueAsUnsigned(dwarf2Data, DW_AT_specification, DW_INVALID_OFFSET);
+ die_offset = attributes.FormValueAsUnsigned(DW_AT_specification, DW_INVALID_OFFSET);
if (die_offset != DW_INVALID_OFFSET)
{
- const DWARFDebugInfoEntry *spec_die = cu->GetDIEPtr (die_offset);
+ DWARFDIE spec_die = cu->GetDIE (die_offset);
if (spec_die)
- {
- const DWARFDebugInfoEntry *spec_die_decl_ctx_die = spec_die->GetParentDeclContextDIE (dwarf2Data, cu);
- if (spec_die_decl_ctx_die)
- return spec_die_decl_ctx_die;
- }
+ {
+ DWARFDIE decl_ctx_die = spec_die.GetParentDeclContextDIE();
+ if (decl_ctx_die)
+ return decl_ctx_die;
+ }
}
- die_offset = attributes.FormValueAsUnsigned(dwarf2Data, DW_AT_abstract_origin, DW_INVALID_OFFSET);
+ die_offset = attributes.FormValueAsUnsigned(DW_AT_abstract_origin, DW_INVALID_OFFSET);
if (die_offset != DW_INVALID_OFFSET)
{
- const DWARFDebugInfoEntry *abs_die = cu->GetDIEPtr (die_offset);
+ DWARFDIE abs_die = cu->GetDIE (die_offset);
if (abs_die)
{
- const DWARFDebugInfoEntry *abs_die_decl_ctx_die = abs_die->GetParentDeclContextDIE (dwarf2Data, cu);
- if (abs_die_decl_ctx_die)
- return abs_die_decl_ctx_die;
+ DWARFDIE decl_ctx_die = abs_die.GetParentDeclContextDIE();
+ if (decl_ctx_die)
+ return decl_ctx_die;
}
}
- die = die->GetParent();
+ die = die.GetParent();
}
- return NULL;
+ return DWARFDIE();
}
@@ -2025,15 +1700,15 @@ DWARFDebugInfoEntry::GetQualifiedName (SymbolFileDWARF* dwarf2Data,
DWARFCompileUnit* cu,
std::string &storage) const
{
- DWARFDebugInfoEntry::Attributes attributes;
- GetAttributes(dwarf2Data, cu, NULL, attributes);
+ DWARFAttributes attributes;
+ GetAttributes(cu, DWARFFormValue::FixedFormSizes(), attributes);
return GetQualifiedName (dwarf2Data, cu, attributes, storage);
}
const char*
DWARFDebugInfoEntry::GetQualifiedName (SymbolFileDWARF* dwarf2Data,
DWARFCompileUnit* cu,
- const DWARFDebugInfoEntry::Attributes& attributes,
+ const DWARFAttributes& attributes,
std::string &storage) const
{
@@ -2041,47 +1716,47 @@ DWARFDebugInfoEntry::GetQualifiedName (SymbolFileDWARF* dwarf2Data,
if (name)
{
- const DWARFDebugInfoEntry *parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu);
+ DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu);
storage.clear();
// TODO: change this to get the correct decl context parent....
while (parent_decl_ctx_die)
{
- const dw_tag_t parent_tag = parent_decl_ctx_die->Tag();
+ const dw_tag_t parent_tag = parent_decl_ctx_die.Tag();
switch (parent_tag)
{
case DW_TAG_namespace:
- {
- const char *namespace_name = parent_decl_ctx_die->GetName (dwarf2Data, cu);
- if (namespace_name)
- {
- storage.insert (0, "::");
- storage.insert (0, namespace_name);
- }
- else
- {
- storage.insert (0, "(anonymous namespace)::");
- }
- parent_decl_ctx_die = parent_decl_ctx_die->GetParentDeclContextDIE(dwarf2Data, cu);
- }
+ {
+ const char *namespace_name = parent_decl_ctx_die.GetName ();
+ if (namespace_name)
+ {
+ storage.insert (0, "::");
+ storage.insert (0, namespace_name);
+ }
+ else
+ {
+ storage.insert (0, "(anonymous namespace)::");
+ }
+ parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
+ }
break;
case DW_TAG_class_type:
case DW_TAG_structure_type:
case DW_TAG_union_type:
- {
- const char *class_union_struct_name = parent_decl_ctx_die->GetName (dwarf2Data, cu);
-
- if (class_union_struct_name)
- {
- storage.insert (0, "::");
- storage.insert (0, class_union_struct_name);
- }
- parent_decl_ctx_die = parent_decl_ctx_die->GetParentDeclContextDIE(dwarf2Data, cu);
- }
+ {
+ const char *class_union_struct_name = parent_decl_ctx_die.GetName ();
+
+ if (class_union_struct_name)
+ {
+ storage.insert (0, "::");
+ storage.insert (0, class_union_struct_name);
+ }
+ parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
+ }
break;
default:
- parent_decl_ctx_die = NULL;
+ parent_decl_ctx_die.Clear();
break;
}
}
@@ -2179,7 +1854,7 @@ DWARFDebugInfoEntry::LookupAddress
if (match_addr_range)
{
- dw_addr_t lo_pc = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_low_pc, LLDB_INVALID_ADDRESS);
+ dw_addr_t lo_pc = GetAttributeValueAsAddress(dwarf2Data, 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);
@@ -2229,7 +1904,7 @@ DWARFDebugInfoEntry::LookupAddress
dw_offset_t debug_ranges_offset = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_ranges, DW_INVALID_OFFSET);
if (debug_ranges_offset != DW_INVALID_OFFSET)
{
- DWARFDebugRanges::RangeList ranges;
+ DWARFRangeList ranges;
DWARFDebugRanges* debug_ranges = dwarf2Data->DebugRanges();
debug_ranges->FindRanges(debug_ranges_offset, ranges);
// All DW_AT_ranges are relative to the base address of the
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
index 3949ad339dd8..02bbff8defc0 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -57,56 +57,6 @@ public:
typedef offset_collection::iterator offset_collection_iterator;
typedef offset_collection::const_iterator offset_collection_const_iterator;
- class Attributes
- {
- public:
- Attributes();
- ~Attributes();
-
- void Append(const DWARFCompileUnit *cu, dw_offset_t attr_die_offset, dw_attr_t attr, dw_form_t form);
- const DWARFCompileUnit * CompileUnitAtIndex(uint32_t i) const { return m_infos[i].cu; }
- dw_offset_t DIEOffsetAtIndex(uint32_t i) const { return m_infos[i].die_offset; }
- dw_attr_t AttributeAtIndex(uint32_t i) const { return m_infos[i].attr; }
- dw_attr_t FormAtIndex(uint32_t i) const { return m_infos[i].form; }
- bool ExtractFormValueAtIndex (SymbolFileDWARF* dwarf2Data, uint32_t i, DWARFFormValue &form_value) const;
- uint64_t FormValueAsUnsignedAtIndex (SymbolFileDWARF* dwarf2Data, uint32_t i, uint64_t fail_value) const;
- uint64_t FormValueAsUnsigned (SymbolFileDWARF* dwarf2Data, dw_attr_t attr, uint64_t fail_value) 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(); }
-
- protected:
- struct Info
- {
- const DWARFCompileUnit *cu; // Keep the compile unit with each attribute in case we have DW_FORM_ref_addr values
- dw_offset_t die_offset;
- dw_attr_t attr;
- dw_form_t form;
- };
-
- typedef llvm::SmallVector<Info, 8> collection;
- collection m_infos;
- };
-
- struct CompareState
- {
- CompareState() :
- die_offset_pairs()
- {
- assert(sizeof(dw_offset_t)*2 == sizeof(uint64_t));
- }
-
- bool AddTypePair(dw_offset_t a, dw_offset_t b)
- {
- uint64_t a_b_offsets = (uint64_t)a << 32 | (uint64_t)b;
- // Return true if this type was inserted, false otherwise
- return die_offset_pairs.insert(a_b_offsets).second;
- }
- std::set< uint64_t > die_offset_pairs;
- };
-
DWARFDebugInfoEntry():
m_offset (DW_INVALID_OFFSET),
m_parent_idx (0),
@@ -144,7 +94,7 @@ public:
bool FastExtract(
const lldb_private::DWARFDataExtractor& debug_info_data,
const DWARFCompileUnit* cu,
- const uint8_t *fixed_form_sizes,
+ const DWARFFormValue::FixedFormSizes& fixed_form_sizes,
lldb::offset_t* offset_ptr);
bool Extract(
@@ -160,68 +110,67 @@ public:
DWARFDebugInfoEntry** block_die);
size_t GetAttributes(
- SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
- const uint8_t *fixed_form_sizes,
- DWARFDebugInfoEntry::Attributes& attrs,
+ 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 DWARFCompileUnit* cu,
- const dw_attr_t attr,
- DWARFFormValue& formValue,
- dw_offset_t* end_attr_offset_ptr = NULL) const;
-
const char* GetAttributeValueAsString(
SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
const dw_attr_t attr,
- const char* fail_value) const;
+ const char* fail_value,
+ bool check_specification_or_abstract_origin = false) const;
uint64_t GetAttributeValueAsUnsigned(
SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
const dw_attr_t attr,
- uint64_t fail_value) const;
+ uint64_t fail_value,
+ bool check_specification_or_abstract_origin = false) const;
uint64_t GetAttributeValueAsReference(
SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
const dw_attr_t attr,
- uint64_t fail_value) const;
+ uint64_t fail_value,
+ bool check_specification_or_abstract_origin = false) const;
int64_t GetAttributeValueAsSigned(
SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
const dw_attr_t attr,
- int64_t fail_value) const;
+ int64_t fail_value,
+ bool check_specification_or_abstract_origin = false) const;
+
+ uint64_t GetAttributeValueAsAddress(
+ SymbolFileDWARF* dwarf2Data,
+ const DWARFCompileUnit* 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 DWARFCompileUnit* cu,
dw_addr_t lo_pc,
- uint64_t fail_value) const;
+ uint64_t fail_value,
+ bool check_specification_or_abstract_origin = false) const;
bool GetAttributeAddressRange(
SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
dw_addr_t& lo_pc,
dw_addr_t& hi_pc,
- uint64_t fail_value) const;
+ uint64_t fail_value,
+ bool check_specification_or_abstract_origin = false) const;
size_t GetAttributeAddressRanges (
SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
- DWARFDebugRanges::RangeList &ranges,
- bool check_hi_lo_pc) const;
-
- dw_offset_t GetAttributeValueAsLocation(
- SymbolFileDWARF* dwarf2Data,
- const DWARFCompileUnit* cu,
- const dw_attr_t attr,
- lldb_private::DWARFDataExtractor& data,
- uint32_t &block_size) const;
+ DWARFRangeList &ranges,
+ bool check_hi_lo_pc,
+ bool check_specification_or_abstract_origin = false) const;
const char* GetName(
SymbolFileDWARF* dwarf2Data,
@@ -256,25 +205,9 @@ public:
const char * GetQualifiedName (
SymbolFileDWARF* dwarf2Data,
DWARFCompileUnit* cu,
- const DWARFDebugInfoEntry::Attributes& attributes,
+ const DWARFAttributes& attributes,
std::string &storage) const;
-// static int Compare(
-// SymbolFileDWARF* dwarf2Data,
-// dw_offset_t a_die_offset,
-// dw_offset_t b_die_offset,
-// CompareState &compare_state,
-// bool compare_siblings,
-// bool compare_children);
-//
-// static int Compare(
-// SymbolFileDWARF* dwarf2Data,
-// DWARFCompileUnit* a_cu, const DWARFDebugInfoEntry* a_die,
-// DWARFCompileUnit* b_cu, const DWARFDebugInfoEntry* b_die,
-// CompareState &compare_state,
-// bool compare_siblings,
-// bool compare_children);
-
static bool OffsetLessThan (
const DWARFDebugInfoEntry& a,
const DWARFDebugInfoEntry& b);
@@ -311,7 +244,7 @@ public:
const DWARFCompileUnit* cu,
const char * &name,
const char * &mangled,
- DWARFDebugRanges::RangeList& rangeList,
+ DWARFRangeList& rangeList,
int& decl_file,
int& decl_line,
int& decl_column,
@@ -376,8 +309,7 @@ public:
const DWARFDebugInfoEntry* GetFirstChild() const { return (HasChildren() && !m_empty_children) ? this + 1 : NULL; }
- void GetDeclContextDIEs (SymbolFileDWARF* dwarf2Data,
- DWARFCompileUnit* cu,
+ void GetDeclContextDIEs (DWARFCompileUnit* cu,
DWARFDIECollection &decl_context_dies) const;
void GetDWARFDeclContext (SymbolFileDWARF* dwarf2Data,
@@ -389,11 +321,11 @@ public:
DWARFCompileUnit* cu,
const DWARFDeclContext &dwarf_decl_ctx) const;
- const DWARFDebugInfoEntry* GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data,
+ DWARFDIE GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data,
DWARFCompileUnit* cu) const;
- const DWARFDebugInfoEntry* GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data,
+ DWARFDIE GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data,
DWARFCompileUnit* cu,
- const DWARFDebugInfoEntry::Attributes& attributes) const;
+ const DWARFAttributes& attributes) const;
void
SetParent (DWARFDebugInfoEntry* parent)
@@ -450,6 +382,13 @@ public:
DWARFDebugInfoEntry::collection &die_collection);
protected:
+ dw_offset_t GetAttributeValue(SymbolFileDWARF* dwarf2Data,
+ const DWARFCompileUnit* cu,
+ const dw_attr_t attr,
+ DWARFFormValue& formValue,
+ dw_offset_t* end_attr_offset_ptr = nullptr,
+ bool check_specification_or_abstract_origin = false) const;
+
dw_offset_t m_offset; // Offset within the .debug_info of the start of this entry
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.
@@ -457,7 +396,6 @@ protected:
uint32_t m_abbr_idx:DIE_ABBR_IDX_BITSIZE,
m_has_children:1, // Set to 1 if this DIE has children
m_tag:16; // A copy of the DW_TAG value so we don't have to go through the compile unit abbrev table
-
};
#endif // SymbolFileDWARF_DWARFDebugInfoEntry_h_
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
index 48e11bd80089..84c2142e8419 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
@@ -249,7 +249,7 @@ DWARFDebugLine::DumpStatementOpcodes(Log *log, const DWARFDataExtractor& debug_l
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.c_str(),
+ fileEntry.name,
fileEntry.dir_idx,
fileEntry.mod_time,
fileEntry.length);
@@ -486,65 +486,25 @@ DWARFDebugLine::ParseSupportFiles (const lldb::ModuleSP &module_sp,
FileSpecList &support_files)
{
lldb::offset_t offset = stmt_list;
- // Skip the total length
- (void)debug_line_data.GetDWARFInitialLength(&offset);
- uint32_t version = debug_line_data.GetU16(&offset);
- if (version < 2 || version > 4)
- return false;
- const dw_offset_t end_prologue_offset = debug_line_data.GetDWARFOffset(&offset) + offset;
- // Skip instruction length, default is stmt, line base, line range
- offset += 4;
- // For DWARF4, skip maximum operations per instruction
- if (version >= 4)
- offset += 1;
- // Skip opcode base, and all opcode lengths
- const uint8_t opcode_base = debug_line_data.GetU8(&offset);
- offset += opcode_base - 1;
- std::vector<FileSpec> include_directories{{}}; // Directory at index zero doesn't exist
- while (offset < end_prologue_offset)
+ Prologue prologue;
+ if (!ParsePrologue(debug_line_data, &offset, &prologue))
{
- FileSpec dir{debug_line_data.GetCStr(&offset), false};
- if (dir)
- include_directories.emplace_back(std::move(dir));
- else
- break;
+ Host::SystemLog (Host::eSystemLogError, "error: parsing line table prologue at 0x%8.8x (parsing ended around 0x%8.8" PRIx64 "\n", stmt_list, offset);
+ return false;
}
- while (offset < end_prologue_offset)
- {
- FileSpec file_spec{debug_line_data.GetCStr(&offset), false};
- if (file_spec)
- {
- uint32_t dir_idx = debug_line_data.GetULEB128(&offset);
- debug_line_data.Skip_LEB128(&offset); // Skip mod_time
- debug_line_data.Skip_LEB128(&offset); // Skip length
- if (file_spec.IsRelative())
- {
- if (0 < dir_idx && dir_idx < include_directories.size())
- {
- const FileSpec &dir = include_directories[dir_idx];
- file_spec.PrependPathComponent(dir);
- }
- if (file_spec.IsRelative())
- file_spec.PrependPathComponent(cu_comp_dir);
- }
- std::string remapped_file;
- if (module_sp->RemapSourceFile(file_spec.GetCString(), remapped_file))
- file_spec.SetFile(remapped_file, false);
- support_files.Append(file_spec);
- }
- }
+ FileSpec file_spec;
+ std::string remapped_file;
- if (offset != end_prologue_offset)
+ for (uint32_t file_idx = 1; prologue.GetFile(file_idx, cu_comp_dir, file_spec); ++file_idx)
{
- Host::SystemLog (Host::eSystemLogError,
- "warning: parsing line table prologue at 0x%8.8x should have ended at 0x%8.8x but it ended at 0x%8.8" PRIx64 "\n",
- stmt_list,
- end_prologue_offset,
- offset);
+ if (module_sp->RemapSourceFile(file_spec.GetCString(), remapped_file))
+ file_spec.SetFile(remapped_file, false);
+ support_files.Append(file_spec);
+
}
- return end_prologue_offset;
+ return true;
}
//----------------------------------------------------------------------
@@ -900,7 +860,7 @@ DWARFDebugLine::Prologue::Dump(Log *log)
{
for (i=0; i<include_directories.size(); ++i)
{
- log->Printf( "include_directories[%3u] = '%s'", i+1, include_directories[i].c_str());
+ log->Printf( "include_directories[%3u] = '%s'", i+1, include_directories[i]);
}
}
@@ -916,7 +876,7 @@ DWARFDebugLine::Prologue::Dump(Log *log)
fileEntry.dir_idx,
fileEntry.mod_time,
fileEntry.length,
- fileEntry.name.c_str());
+ fileEntry.name);
}
}
}
@@ -959,17 +919,28 @@ DWARFDebugLine::Prologue::Dump(Log *log)
//}
-bool DWARFDebugLine::Prologue::GetFile(uint32_t file_idx, std::string& path, std::string& directory) const
+bool DWARFDebugLine::Prologue::GetFile(uint32_t file_idx, const char *comp_dir, FileSpec &file) const
{
uint32_t idx = file_idx - 1; // File indexes are 1 based...
if (idx < file_names.size())
{
- path = file_names[idx].name;
- uint32_t dir_idx = file_names[idx].dir_idx - 1;
- if (dir_idx < include_directories.size())
- directory = include_directories[dir_idx];
- else
- directory.clear();
+ file.SetFile(file_names[idx].name, false);
+ if (file.IsRelative())
+ {
+ if (file_names[idx].dir_idx > 0)
+ {
+ const uint32_t dir_idx = file_names[idx].dir_idx - 1;
+ if (dir_idx < include_directories.size())
+ {
+ file.PrependPathComponent(include_directories[dir_idx]);
+ if (!file.IsRelative())
+ return true;
+ }
+ }
+
+ if (comp_dir && comp_dir[0])
+ file.PrependPathComponent(comp_dir);
+ }
return true;
}
return false;
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h
index 7da0e76a22be..9f2219b01812 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h
@@ -20,7 +20,6 @@
#include "DWARFDefines.h"
class SymbolFileDWARF;
-class DWARFDebugInfoEntry;
//----------------------------------------------------------------------
// DWARFDebugLine
@@ -34,14 +33,14 @@ public:
struct FileNameEntry
{
FileNameEntry() :
- name(),
+ name(nullptr),
dir_idx(0),
mod_time(0),
length(0)
{
}
- std::string name;
+ const char* name;
dw_sleb128_t dir_idx;
dw_sleb128_t mod_time;
dw_sleb128_t length;
@@ -81,7 +80,7 @@ public:
uint8_t line_range; // This parameter affects the meaning of the special opcodes. See below.
uint8_t opcode_base; // The number assigned to the first special opcode.
std::vector<uint8_t> standard_opcode_lengths;
- std::vector<std::string> include_directories;
+ std::vector<const char *> include_directories;
std::vector<FileNameEntry> file_names;
int32_t MaxLineIncrementForSpecialOpcode() const { return line_base + (int8_t)line_range - 1; }
@@ -96,7 +95,7 @@ public:
include_directories.clear();
file_names.clear();
}
- bool GetFile(uint32_t file_idx, std::string& file, std::string& dir) const;
+ bool GetFile(uint32_t file_idx, const char *comp_dir, lldb_private::FileSpec &file) const;
};
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp
new file mode 100644
index 000000000000..75c812e6e79d
--- /dev/null
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp
@@ -0,0 +1,128 @@
+//===-- DWARFDebugMacro.cpp -------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "DWARFDebugMacro.h"
+#include "SymbolFileDWARF.h"
+
+#include "lldb/Symbol/DebugMacros.h"
+
+#include "DWARFDataExtractor.h"
+
+using namespace lldb_private;
+
+DWARFDebugMacroHeader
+DWARFDebugMacroHeader::ParseHeader(const DWARFDataExtractor &debug_macro_data, lldb::offset_t *offset)
+{
+ DWARFDebugMacroHeader header;
+
+ // Skip over the version field in header.
+ header.m_version = debug_macro_data.GetU16(offset);
+
+ uint8_t flags = debug_macro_data.GetU8(offset);
+ header.m_offset_is_64_bit = flags & OFFSET_SIZE_MASK ? true : false;
+
+ if (flags & DEBUG_LINE_OFFSET_MASK)
+ {
+ if (header.m_offset_is_64_bit)
+ header.m_debug_line_offset = debug_macro_data.GetU64(offset);
+ else
+ header.m_debug_line_offset = debug_macro_data.GetU32(offset);
+ }
+
+ // Skip over the operands table if it is present.
+ if (flags & OPCODE_OPERANDS_TABLE_MASK)
+ SkipOperandTable(debug_macro_data, offset);
+
+ return header;
+}
+
+void
+DWARFDebugMacroHeader::SkipOperandTable(const DWARFDataExtractor &debug_macro_data, lldb::offset_t *offset)
+{
+ uint8_t entry_count = debug_macro_data.GetU8(offset);
+ for (uint8_t i = 0; i < entry_count; i++)
+ {
+ // Skip over the opcode number.
+ debug_macro_data.GetU8(offset);
+
+ uint64_t operand_count = debug_macro_data.GetULEB128(offset);
+
+ for (uint64_t j = 0; j < operand_count; j++)
+ {
+ // Skip over the operand form
+ debug_macro_data.GetU8(offset);
+ }
+ }
+}
+
+void
+DWARFDebugMacroEntry::ReadMacroEntries(const DWARFDataExtractor &debug_macro_data,
+ const DWARFDataExtractor &debug_str_data,
+ const bool offset_is_64_bit,
+ lldb::offset_t *offset,
+ SymbolFileDWARF *sym_file_dwarf,
+ DebugMacrosSP &debug_macros_sp)
+{
+ llvm::dwarf::MacroEntryType type = static_cast<llvm::dwarf::MacroEntryType>(debug_macro_data.GetU8(offset));
+ while (type != 0)
+ {
+ lldb::offset_t new_offset = 0, str_offset = 0;
+ uint32_t line = 0;
+ const char *macro_str = nullptr;
+ uint32_t debug_line_file_idx = 0;
+
+ switch (type)
+ {
+ case DW_MACRO_define:
+ case DW_MACRO_undef:
+ line = debug_macro_data.GetULEB128(offset);
+ macro_str = debug_macro_data.GetCStr(offset);
+ if (type == DW_MACRO_define)
+ debug_macros_sp->AddMacroEntry(DebugMacroEntry::CreateDefineEntry(line, macro_str));
+ else
+ debug_macros_sp->AddMacroEntry(DebugMacroEntry::CreateUndefEntry(line, macro_str));
+ break;
+ case DW_MACRO_define_indirect:
+ case DW_MACRO_undef_indirect:
+ line = debug_macro_data.GetULEB128(offset);
+ if (offset_is_64_bit)
+ str_offset = debug_macro_data.GetU64(offset);
+ else
+ str_offset = debug_macro_data.GetU32(offset);
+ macro_str = debug_str_data.GetCStr(&str_offset);
+ if (type == DW_MACRO_define_indirect)
+ debug_macros_sp->AddMacroEntry(DebugMacroEntry::CreateDefineEntry(line, macro_str));
+ else
+ debug_macros_sp->AddMacroEntry(DebugMacroEntry::CreateUndefEntry(line, macro_str));
+ break;
+ case DW_MACRO_start_file:
+ line = debug_macro_data.GetULEB128(offset);
+ debug_line_file_idx = debug_macro_data.GetULEB128(offset);
+ debug_macros_sp->AddMacroEntry(DebugMacroEntry::CreateStartFileEntry(line, debug_line_file_idx));
+ break;
+ case DW_MACRO_end_file:
+ // This operation has no operands.
+ debug_macros_sp->AddMacroEntry(DebugMacroEntry::CreateEndFileEntry());
+ break;
+ case DW_MACRO_transparent_include:
+ if (offset_is_64_bit)
+ new_offset = debug_macro_data.GetU64(offset);
+ else
+ new_offset = debug_macro_data.GetU32(offset);
+ debug_macros_sp->AddMacroEntry(
+ DebugMacroEntry::CreateIndirectEntry(sym_file_dwarf->ParseDebugMacros(&new_offset)));
+ break;
+ default:
+ // TODO: Add support for other standard operations.
+ // TODO: Provide mechanism to hook handling of non-standard/extension operands.
+ return;
+ }
+ type = static_cast<llvm::dwarf::MacroEntryType>(debug_macro_data.GetU8(offset));
+ }
+}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h
new file mode 100644
index 000000000000..c60b9749b005
--- /dev/null
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h
@@ -0,0 +1,68 @@
+//===-- DWARFDebugMacro.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_DWARFDebugMacro_h_
+#define SymbolFileDWARF_DWARFDebugMacro_h_
+
+#include <map>
+
+#include "lldb/lldb-types.h"
+#include "lldb/Core/dwarf.h"
+#include "lldb/Symbol/DebugMacros.h"
+
+namespace lldb_private
+{
+
+class DWARFDataExtractor;
+
+} // namespace lldb_private
+
+class SymbolFileDWARF;
+
+class DWARFDebugMacroHeader
+{
+public:
+ enum HeaderFlagMask
+ {
+ OFFSET_SIZE_MASK = 0x1,
+ DEBUG_LINE_OFFSET_MASK = 0x2,
+ OPCODE_OPERANDS_TABLE_MASK = 0x4
+ };
+
+ static DWARFDebugMacroHeader
+ ParseHeader(const lldb_private::DWARFDataExtractor &debug_macro_data, lldb::offset_t *offset);
+
+ bool
+ OffsetIs64Bit() const
+ {
+ return m_offset_is_64_bit;
+ }
+
+private:
+ static void
+ SkipOperandTable(const lldb_private::DWARFDataExtractor &debug_macro_data, lldb::offset_t *offset);
+
+ uint16_t m_version;
+ bool m_offset_is_64_bit;
+ uint64_t m_debug_line_offset;
+};
+
+class DWARFDebugMacroEntry
+{
+public:
+ static void
+ ReadMacroEntries(const lldb_private::DWARFDataExtractor &debug_macro_data,
+ const lldb_private::DWARFDataExtractor &debug_str_data,
+ const bool offset_is_64_bit,
+ lldb::offset_t *sect_offset,
+ SymbolFileDWARF *sym_file_dwarf,
+ lldb_private::DebugMacrosSP &debug_macros_sp);
+};
+
+#endif // SymbolFileDWARF_DWARFDebugMacro_h_
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp
index 8469b78d0dd5..547bd0cd1a5a 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp
@@ -77,9 +77,6 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data)
DWARFDebugInfo* debug_info = dwarf2Data->DebugInfo();
if (debug_info)
{
-
- const DWARFDataExtractor* debug_str = &dwarf2Data->get_debug_str_data();
-
uint32_t cu_idx = 0;
const uint32_t num_compile_units = dwarf2Data->GetNumCompileUnits();
for (cu_idx = 0; cu_idx < num_compile_units; ++cu_idx)
@@ -87,7 +84,9 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data)
DWARFCompileUnit* cu = debug_info->GetCompileUnitAtIndex(cu_idx);
- const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (cu->GetAddressByteSize(), cu->IsDWARF64());
+ DWARFFormValue::FixedFormSizes fixed_form_sizes =
+ DWARFFormValue::GetFixedFormSizesForAddressSize (cu->GetAddressByteSize(),
+ cu->IsDWARF64());
bool clear_dies = cu->ExtractDIEsIfNeeded (false) > 1;
@@ -101,17 +100,17 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data)
size_t die_idx;
for (die_idx = 0; die_idx < die_count; ++die_idx)
{
- const DWARFDebugInfoEntry *die = dies.GetDIEPtrAtIndex(die_idx);
- DWARFDebugInfoEntry::Attributes attributes;
+ DWARFDIE die = dies.GetDIEAtIndex(die_idx);
+ DWARFAttributes attributes;
const char *name = NULL;
const char *mangled = NULL;
bool add_die = false;
- const size_t num_attributes = die->GetAttributes(dwarf2Data, cu, fixed_form_sizes, attributes);
+ const size_t num_attributes = die.GetDIE()->GetAttributes(die.GetCU(), fixed_form_sizes, attributes);
if (num_attributes > 0)
{
uint32_t i;
- dw_tag_t tag = die->Tag();
+ dw_tag_t tag = die.Tag();
for (i=0; i<num_attributes; ++i)
{
@@ -120,14 +119,14 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data)
switch (attr)
{
case DW_AT_name:
- if (attributes.ExtractFormValueAtIndex(dwarf2Data, i, form_value))
- name = form_value.AsCString(debug_str);
+ if (attributes.ExtractFormValueAtIndex(i, form_value))
+ name = form_value.AsCString();
break;
case DW_AT_MIPS_linkage_name:
case DW_AT_linkage_name:
- if (attributes.ExtractFormValueAtIndex(dwarf2Data, i, form_value))
- mangled = form_value.AsCString(debug_str);
+ if (attributes.ExtractFormValueAtIndex(i, form_value))
+ mangled = form_value.AsCString();
break;
case DW_AT_low_pc:
@@ -140,10 +139,10 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data)
case DW_AT_location:
if (tag == DW_TAG_variable)
{
- const DWARFDebugInfoEntry* parent_die = die->GetParent();
- while ( parent_die != NULL )
+ DWARFDIE parent_die = die.GetParent();
+ while ( parent_die )
{
- switch (parent_die->Tag())
+ switch (parent_die.Tag())
{
case DW_TAG_subprogram:
case DW_TAG_lexical_block:
@@ -153,31 +152,16 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data)
// if the location describes a hard coded address, but we don't want the performance
// penalty of that right now.
add_die = false;
-// if (attributes.ExtractFormValueAtIndex(dwarf2Data, i, form_value))
-// {
-// // If we have valid block data, then we have location expression bytes
-// // that are fixed (not a location list).
-// const uint8_t *block_data = form_value.BlockData();
-// if (block_data)
-// {
-// uint32_t block_length = form_value.Unsigned();
-// if (block_length == 1 + attributes.CompileUnitAtIndex(i)->GetAddressByteSize())
-// {
-// if (block_data[0] == DW_OP_addr)
-// add_die = true;
-// }
-// }
-// }
- parent_die = NULL; // Terminate the while loop.
+ parent_die.Clear(); // Terminate the while loop.
break;
case DW_TAG_compile_unit:
add_die = true;
- parent_die = NULL; // Terminate the while loop.
+ parent_die.Clear(); // Terminate the while loop.
break;
default:
- parent_die = parent_die->GetParent(); // Keep going in the while loop.
+ parent_die = parent_die.GetParent(); // Keep going in the while loop.
break;
}
}
@@ -189,7 +173,7 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data)
if (add_die && (name || mangled))
{
- pubnames_set.AddDescriptor(die->GetOffset() - cu_offset, mangled ? mangled : name);
+ pubnames_set.AddDescriptor(die.GetCompileUnitRelativeOffset(), mangled ? mangled : name);
}
}
@@ -231,13 +215,11 @@ DWARFDebugPubnames::GeneratePubBaseTypes(SymbolFileDWARF* dwarf2Data)
size_t die_idx;
for (die_idx = 0; die_idx < die_count; ++die_idx)
{
- const DWARFDebugInfoEntry *die = dies.GetDIEPtrAtIndex(die_idx);
- const char *name = die->GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, NULL);
+ DWARFDIE die = dies.GetDIEAtIndex (die_idx);
+ const char *name = die.GetName();
if (name)
- {
- pubnames_set.AddDescriptor(die->GetOffset() - cu_offset, name);
- }
+ pubnames_set.AddDescriptor(die.GetCompileUnitRelativeOffset(), name);
}
if (pubnames_set.NumDescriptors() > 0)
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
index 0953554ffd7d..fc2831f22438 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
@@ -27,7 +27,7 @@ DWARFDebugRanges::~DWARFDebugRanges()
void
DWARFDebugRanges::Extract(SymbolFileDWARF* dwarf2Data)
{
- RangeList range_list;
+ DWARFRangeList range_list;
lldb::offset_t offset = 0;
dw_offset_t debug_ranges_offset = offset;
while (Extract(dwarf2Data, &offset, range_list))
@@ -38,52 +38,8 @@ DWARFDebugRanges::Extract(SymbolFileDWARF* dwarf2Data)
}
}
-//void
-//DWARFDebugRanges::RangeList::AddOffset(dw_addr_t offset)
-//{
-// if (!ranges.empty())
-// {
-// Range::iterator pos = ranges.begin();
-// Range::iterator end_pos = ranges.end();
-// for (pos = ranges.begin(); pos != end_pos; ++pos)
-// {
-// // assert for unsigned overflows
-// assert (~pos->begin_offset >= offset);
-// assert (~pos->end_offset >= offset);
-// pos->begin_offset += offset;
-// pos->end_offset += offset;
-// }
-// }
-//}
-//
-//void
-//DWARFDebugRanges::RangeList::SubtractOffset(dw_addr_t offset)
-//{
-// if (!ranges.empty())
-// {
-// Range::iterator pos = ranges.begin();
-// Range::iterator end_pos = ranges.end();
-// for (pos = ranges.begin(); pos != end_pos; ++pos)
-// {
-// assert (pos->begin_offset >= offset);
-// assert (pos->end_offset >= offset);
-// pos->begin_offset -= offset;
-// pos->end_offset -= offset;
-// }
-// }
-//}
-//
-//
-//const DWARFDebugRanges::Range*
-//DWARFDebugRanges::RangeList::RangeAtIndex(size_t i) const
-//{
-// if (i < ranges.size())
-// return &ranges[i];
-// return NULL;
-//}
-
bool
-DWARFDebugRanges::Extract(SymbolFileDWARF* dwarf2Data, lldb::offset_t *offset_ptr, RangeList &range_list)
+DWARFDebugRanges::Extract(SymbolFileDWARF* dwarf2Data, lldb::offset_t *offset_ptr, DWARFRangeList &range_list)
{
range_list.Clear();
@@ -118,13 +74,13 @@ DWARFDebugRanges::Extract(SymbolFileDWARF* dwarf2Data, lldb::offset_t *offset_pt
break;
default:
- assert(!"DWARFDebugRanges::RangeList::Extract() unsupported address size.");
+ assert(!"DWARFRangeList::Extract() unsupported address size.");
break;
}
// Filter out empty ranges
if (begin < end)
- range_list.Append(Range(begin, end - begin));
+ range_list.Append(DWARFRangeList::Entry(begin, end - begin));
}
// Make sure we consumed at least something
@@ -178,7 +134,7 @@ DWARFDebugRanges::Dump(Stream &s, const DWARFDataExtractor& debug_ranges_data, l
}
bool
-DWARFDebugRanges::FindRanges(dw_offset_t debug_ranges_offset, RangeList& range_list) const
+DWARFDebugRanges::FindRanges(dw_offset_t debug_ranges_offset, DWARFRangeList& range_list) const
{
range_map_const_iterator pos = m_range_map.find(debug_ranges_offset);
if (pos != m_range_map.end())
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
index 50af91d41009..3ff4ea3502c9 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
@@ -11,34 +11,30 @@
#define SymbolFileDWARF_DWARFDebugRanges_h_
#include "SymbolFileDWARF.h"
+#include "DWARFDIE.h"
#include <map>
-#include <vector>
-
-#include "lldb/Core/RangeMap.h"
class DWARFDebugRanges
{
public:
- typedef lldb_private::RangeArray<dw_addr_t, dw_addr_t, 2> RangeList;
- typedef RangeList::Entry Range;
DWARFDebugRanges();
~DWARFDebugRanges();
void Extract(SymbolFileDWARF* dwarf2Data);
static void Dump(lldb_private::Stream &s, const lldb_private::DWARFDataExtractor& debug_ranges_data, lldb::offset_t *offset_ptr, dw_addr_t cu_base_addr);
- bool FindRanges(dw_offset_t debug_ranges_offset, DWARFDebugRanges::RangeList& range_list) const;
+ bool FindRanges(dw_offset_t debug_ranges_offset, DWARFRangeList& range_list) const;
protected:
bool
Extract (SymbolFileDWARF* dwarf2Data,
lldb::offset_t *offset_ptr,
- RangeList &range_list);
+ DWARFRangeList &range_list);
- typedef std::map<dw_offset_t, RangeList> range_map;
- typedef range_map::iterator range_map_iterator;
- typedef range_map::const_iterator range_map_const_iterator;
+ typedef std::map<dw_offset_t, DWARFRangeList> range_map;
+ typedef range_map::iterator range_map_iterator;
+ typedef range_map::const_iterator range_map_const_iterator;
range_map m_range_map;
};
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h b/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
index 3a99d2b33878..4c29447b47bb 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
@@ -108,6 +108,13 @@ public:
return lldb_private::ConstString (GetQualifiedName ());
}
+ void
+ Clear()
+ {
+ m_entries.clear();
+ m_qualified_name.clear();
+ }
+
protected:
typedef std::vector<Entry> collection;
collection m_entries;
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
index c733832e4f4d..a0ed9731a565 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -136,21 +136,21 @@ g_form_sizes_addr8_dwarf64[] =
8, // 0x20 DW_FORM_ref_sig8
};
-const uint8_t *
+DWARFFormValue::FixedFormSizes
DWARFFormValue::GetFixedFormSizesForAddressSize (uint8_t addr_size, bool is_dwarf64)
{
if (!is_dwarf64) {
switch (addr_size)
{
- case 4: return g_form_sizes_addr4;
- case 8: return g_form_sizes_addr8;
+ 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 g_form_sizes_addr8_dwarf64;
+ return FixedFormSizes(g_form_sizes_addr8_dwarf64, sizeof(g_form_sizes_addr8_dwarf64));
// is_dwarf64 && addr_size == 4 : no provider does this.
}
- return NULL;
+ return FixedFormSizes();
}
DWARFFormValue::DWARFFormValue() :
@@ -187,11 +187,7 @@ DWARFFormValue::ExtractValue(const DWARFDataExtractor& data, lldb::offset_t* off
case DW_FORM_data2: m_value.value.uval = data.GetU16(offset_ptr); break;
case DW_FORM_data4: m_value.value.uval = data.GetU32(offset_ptr); break;
case DW_FORM_data8: m_value.value.uval = data.GetU64(offset_ptr); break;
- case DW_FORM_string: m_value.value.cstr = data.GetCStr(offset_ptr);
- // Set the string value to also be the data for inlined cstr form values only
- // so we can tell the difference between DW_FORM_string and DW_FORM_strp form
- // values;
- m_value.data = (const uint8_t*)m_value.value.cstr; break;
+ case DW_FORM_string: m_value.value.cstr = data.GetCStr(offset_ptr); break;
case DW_FORM_exprloc:
case DW_FORM_block: m_value.value.uval = data.GetULEB128(offset_ptr); is_block = true; break;
case DW_FORM_block1: m_value.value.uval = data.GetU8(offset_ptr); is_block = true; break;
@@ -219,10 +215,12 @@ DWARFFormValue::ExtractValue(const DWARFDataExtractor& data, lldb::offset_t* off
indirect = true;
break;
- case DW_FORM_sec_offset: assert(m_cu);
- m_value.value.uval = data.GetMaxU64(offset_ptr, DWARFCompileUnit::IsDWARF64(m_cu) ? 8 : 4); break;
- case DW_FORM_flag_present: m_value.value.uval = 1; break;
- case DW_FORM_ref_sig8: m_value.value.uval = data.GetU64(offset_ptr); break;
+ case DW_FORM_sec_offset: assert(m_cu);
+ m_value.value.uval = data.GetMaxU64(offset_ptr, DWARFCompileUnit::IsDWARF64(m_cu) ? 8 : 4); break;
+ case DW_FORM_flag_present: m_value.value.uval = 1; break;
+ case DW_FORM_ref_sig8: m_value.value.uval = data.GetU64(offset_ptr); break;
+ case DW_FORM_GNU_str_index: m_value.value.uval = data.GetULEB128(offset_ptr); break;
+ case DW_FORM_GNU_addr_index: m_value.value.uval = data.GetULEB128(offset_ptr); break;
default:
return false;
break;
@@ -322,6 +320,8 @@ DWARFFormValue::SkipValue(dw_form_t form, const DWARFDataExtractor& debug_info_d
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_ptr);
return true;
@@ -342,7 +342,7 @@ DWARFFormValue::SkipValue(dw_form_t form, const DWARFDataExtractor& debug_info_d
void
-DWARFFormValue::Dump(Stream &s, const DWARFDataExtractor* debug_str_data) const
+DWARFFormValue::Dump(Stream &s) const
{
uint64_t uvalue = Unsigned();
bool cu_relative_offset = false;
@@ -353,13 +353,13 @@ DWARFFormValue::Dump(Stream &s, const DWARFDataExtractor* debug_str_data) const
{
case DW_FORM_addr: s.Address(uvalue, sizeof (uint64_t)); break;
case DW_FORM_flag:
- case DW_FORM_data1: s.PutHex8(uvalue); break;
+ case DW_FORM_data1: s.PutHex8(uvalue); break;
case DW_FORM_data2: s.PutHex16(uvalue); break;
case DW_FORM_sec_offset:
case DW_FORM_data4: s.PutHex32(uvalue); break;
case DW_FORM_ref_sig8:
case DW_FORM_data8: s.PutHex64(uvalue); break;
- case DW_FORM_string: s.QuotedCString(AsCString(NULL)); break;
+ case DW_FORM_string: s.QuotedCString(AsCString()); break;
case DW_FORM_exprloc:
case DW_FORM_block:
case DW_FORM_block1:
@@ -395,18 +395,18 @@ DWARFFormValue::Dump(Stream &s, const DWARFDataExtractor* debug_str_data) const
case DW_FORM_sdata: s.PutSLEB128(uvalue); break;
case DW_FORM_udata: s.PutULEB128(uvalue); break;
case DW_FORM_strp:
- if (debug_str_data)
{
- if (verbose)
- s.Printf(" .debug_str[0x%8.8x] = ", (uint32_t)uvalue);
-
- const char* dbg_str = AsCString(debug_str_data);
+ const char* dbg_str = AsCString();
if (dbg_str)
+ {
+ if (verbose)
+ s.Printf(" .debug_str[0x%8.8x] = ", (uint32_t)uvalue);
s.QuotedCString(dbg_str);
- }
- else
- {
- s.PutHex32(uvalue);
+ }
+ else
+ {
+ s.PutHex32(uvalue);
+ }
}
break;
@@ -444,13 +444,52 @@ DWARFFormValue::Dump(Stream &s, const DWARFDataExtractor* debug_str_data) const
}
const char*
-DWARFFormValue::AsCString(const DWARFDataExtractor* debug_str_data_ptr) const
+DWARFFormValue::AsCString() const
{
- if (IsInlinedCStr())
+ SymbolFileDWARF* symbol_file = m_cu->GetSymbolFileDWARF();
+
+ if (m_form == DW_FORM_string)
+ {
return m_value.value.cstr;
- else if (debug_str_data_ptr)
- return debug_str_data_ptr->PeekCStr(m_value.value.uval);
- return NULL;
+ }
+ else if (m_form == DW_FORM_strp)
+ {
+ if (!symbol_file)
+ return nullptr;
+
+ return symbol_file->get_debug_str_data().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;
+ 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);
+ }
+ return nullptr;
+}
+
+dw_addr_t
+DWARFFormValue::Address() const
+{
+ SymbolFileDWARF* symbol_file = m_cu->GetSymbolFileDWARF();
+
+ if (m_form == DW_FORM_addr)
+ return Unsigned();
+
+ assert(m_cu);
+ assert(m_form == DW_FORM_GNU_addr_index);
+
+ if (!symbol_file)
+ return 0;
+
+ uint32_t index_size = m_cu->GetAddressByteSize();
+ dw_offset_t addr_base = m_cu->GetAddrBase();
+ lldb::offset_t offset = addr_base + m_value.value.uval * index_size;
+ return symbol_file->get_debug_addr_data().GetMaxU64(&offset, index_size);
}
uint64_t
@@ -500,9 +539,7 @@ DWARFFormValue::Reference (dw_offset_t base_offset) const
const uint8_t*
DWARFFormValue::BlockData() const
{
- if (!IsInlinedCStr())
- return m_value.data;
- return NULL;
+ return m_value.data;
}
@@ -537,7 +574,8 @@ DWARFFormValue::IsDataForm(const dw_form_t form)
}
int
-DWARFFormValue::Compare (const DWARFFormValue& a_value, const DWARFFormValue& b_value, const DWARFDataExtractor* debug_str_data_ptr)
+DWARFFormValue::Compare (const DWARFFormValue& a_value,
+ const DWARFFormValue& b_value)
{
dw_form_t a_form = a_value.Form();
dw_form_t b_form = b_value.Form();
@@ -558,6 +596,7 @@ DWARFFormValue::Compare (const DWARFFormValue& a_value, const DWARFFormValue& b_
case DW_FORM_sec_offset:
case DW_FORM_flag_present:
case DW_FORM_ref_sig8:
+ case DW_FORM_GNU_addr_index:
{
uint64_t a = a_value.Unsigned();
uint64_t b = b_value.Unsigned();
@@ -581,9 +620,10 @@ DWARFFormValue::Compare (const DWARFFormValue& a_value, const DWARFFormValue& b_
case DW_FORM_string:
case DW_FORM_strp:
+ case DW_FORM_GNU_str_index:
{
- const char *a_string = a_value.AsCString(debug_str_data_ptr);
- const char *b_string = b_value.AsCString(debug_str_data_ptr);
+ const char *a_string = a_value.AsCString();
+ const char *b_string = b_value.AsCString();
if (a_string == b_string)
return 0;
else if (a_string && b_string)
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h b/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
index 392df26a088e..b10f4d3a0ac9 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
@@ -35,6 +35,34 @@ public:
} value;
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
{
@@ -52,10 +80,9 @@ public:
dw_form_t Form() const { return m_form; }
void SetForm(dw_form_t form) { m_form = form; }
const ValueType& Value() const { return m_value; }
- void Dump(lldb_private::Stream &s, const lldb_private::DWARFDataExtractor* debug_str_data) const;
+ void Dump(lldb_private::Stream &s) const;
bool ExtractValue(const lldb_private::DWARFDataExtractor& data,
lldb::offset_t* offset_ptr);
- bool IsInlinedCStr() const { return (m_value.data != NULL) && m_value.data == (const uint8_t*)m_value.value.cstr; }
const uint8_t* BlockData() const;
uint64_t Reference() const;
uint64_t Reference (dw_offset_t offset) const;
@@ -64,13 +91,16 @@ public:
void SetUnsigned(uint64_t uval) { m_value.value.uval = uval; }
int64_t Signed() const { return m_value.value.sval; }
void SetSigned(int64_t sval) { m_value.value.sval = sval; }
- const char* AsCString(const lldb_private::DWARFDataExtractor* debug_str_data_ptr) const;
+ const char* AsCString() const;
+ dw_addr_t Address() const;
+ bool IsValid() const { return m_form != 0; }
bool SkipValue(const lldb_private::DWARFDataExtractor& debug_info_data, 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 DWARFCompileUnit* cu);
static bool IsBlockForm(const dw_form_t form);
static bool IsDataForm(const dw_form_t form);
- static const uint8_t * GetFixedFormSizesForAddressSize (uint8_t addr_size, bool is_dwarf64);
- static int Compare (const DWARFFormValue& a, const DWARFFormValue& b, const lldb_private::DWARFDataExtractor* debug_str_data_ptr);
+ static FixedFormSizes GetFixedFormSizesForAddressSize (uint8_t addr_size, bool is_dwarf64);
+ static int Compare (const DWARFFormValue& a,
+ const DWARFFormValue& b);
protected:
const DWARFCompileUnit* m_cu; // Compile unit for this form
dw_form_t m_form; // Form for this value
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp b/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp
deleted file mode 100644
index d79ae79822b0..000000000000
--- a/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
-//===-- DWARFLocationDescription.cpp ----------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "DWARFLocationDescription.h"
-#include "DWARFDefines.h"
-#include "lldb/lldb-private.h"
-#include "lldb/Core/Stream.h"
-
-
-using namespace lldb_private;
-
-static int print_dwarf_exp_op (Stream &s, const DWARFDataExtractor& data, lldb::offset_t *offset_ptr, int address_size, int dwarf_ref_size);
-
-int
-print_dwarf_expression (Stream &s,
- const DWARFDataExtractor& data,
- int address_size,
- int dwarf_ref_size,
- bool location_expression)
-{
- int op_count = 0;
- lldb::offset_t offset = 0;
- while (data.ValidOffset(offset))
- {
- if (location_expression && op_count > 0)
- {
- // err (baton, "Dwarf location expressions may only have one operand!");
- return 1;
- }
- if (op_count > 0)
- {
- s.PutCString(", ");
- }
- if (print_dwarf_exp_op (s, data, &offset, address_size, dwarf_ref_size) == 1)
- return 1;
- op_count++;
- }
-
- return 0;
-}
-
-static int
-print_dwarf_exp_op (Stream &s,
- const DWARFDataExtractor& data,
- lldb::offset_t *offset_ptr,
- int address_size,
- int dwarf_ref_size)
-{
- uint8_t opcode = data.GetU8(offset_ptr);
- DRC_class opcode_class;
- uint64_t uint;
- int64_t sint;
-
- int size;
-
- opcode_class = DW_OP_value_to_class (opcode) & (~DRC_DWARFv3);
-
- s.Printf("%s ", DW_OP_value_to_name (opcode));
-
- /* Does this take zero parameters? If so we can shortcut this function. */
- if (opcode_class == DRC_ZEROOPERANDS)
- return 0;
-
- if (opcode_class == DRC_TWOOPERANDS && opcode == DW_OP_bregx)
- {
- uint = data.GetULEB128(offset_ptr);
- sint = data.GetSLEB128(offset_ptr);
- s.Printf("%" PRIu64 " %" PRIi64, uint, sint);
- return 0;
- }
- if (opcode_class != DRC_ONEOPERAND)
- {
- s.Printf("UNKNOWN OP %u", opcode);
- return 1;
- }
-
- switch (opcode)
- {
- case DW_OP_addr: size = address_size; break;
- case DW_OP_const1u: size = 1; break;
- case DW_OP_const1s: size = -1; break;
- case DW_OP_const2u: size = 2; break;
- case DW_OP_const2s: size = -2; break;
- case DW_OP_const4u: size = 4; break;
- case DW_OP_const4s: size = -4; break;
- case DW_OP_const8u: size = 8; break;
- case DW_OP_const8s: size = -8; break;
- case DW_OP_constu: size = 128; break;
- case DW_OP_consts: size = -128; break;
- case DW_OP_fbreg: size = -128; break;
- case DW_OP_breg0:
- case DW_OP_breg1:
- case DW_OP_breg2:
- case DW_OP_breg3:
- case DW_OP_breg4:
- case DW_OP_breg5:
- case DW_OP_breg6:
- case DW_OP_breg7:
- case DW_OP_breg8:
- case DW_OP_breg9:
- case DW_OP_breg10:
- case DW_OP_breg11:
- case DW_OP_breg12:
- case DW_OP_breg13:
- case DW_OP_breg14:
- case DW_OP_breg15:
- case DW_OP_breg16:
- case DW_OP_breg17:
- case DW_OP_breg18:
- case DW_OP_breg19:
- case DW_OP_breg20:
- case DW_OP_breg21:
- case DW_OP_breg22:
- case DW_OP_breg23:
- case DW_OP_breg24:
- case DW_OP_breg25:
- case DW_OP_breg26:
- case DW_OP_breg27:
- case DW_OP_breg28:
- case DW_OP_breg29:
- case DW_OP_breg30:
- case DW_OP_breg31:
- size = -128; break;
- case DW_OP_pick:
- size = 1; break;
- case DW_OP_deref_size:
- size = 1; break;
- case DW_OP_xderef_size:
- size = 1; break;
- case DW_OP_plus_uconst:
- size = 128; break;
- case DW_OP_skip:
- size = -2; break;
- case DW_OP_bra:
- size = -2; break;
- case DW_OP_call2:
- size = 2; break;
- case DW_OP_call4:
- size = 4; break;
- case DW_OP_call_ref:
- size = dwarf_ref_size; break;
- case DW_OP_piece:
- size = 128; break;
- case DW_OP_regx:
- size = 128; break;
- default:
- s.Printf("UNKNOWN ONE-OPERAND OPCODE, #%u", opcode);
- return 1;
- }
-
- switch (size)
- {
- case -1: sint = (int8_t) data.GetU8(offset_ptr); s.Printf("%+" PRIi64, sint); break;
- case -2: sint = (int16_t) data.GetU16(offset_ptr); s.Printf("%+" PRIi64, sint); break;
- case -4: sint = (int32_t) data.GetU32(offset_ptr); s.Printf("%+" PRIi64, sint); break;
- case -8: sint = (int64_t) data.GetU64(offset_ptr); s.Printf("%+" PRIi64, sint); break;
- case -128: sint = data.GetSLEB128(offset_ptr); s.Printf("%+" PRIi64, sint); break;
- case 1: uint = data.GetU8(offset_ptr); s.Printf("0x%2.2" PRIx64, uint); break;
- case 2: uint = data.GetU16(offset_ptr); s.Printf("0x%4.4" PRIx64, uint); break;
- case 4: uint = data.GetU32(offset_ptr); s.Printf("0x%8.8" PRIx64, uint); break;
- case 8: uint = data.GetU64(offset_ptr); s.Printf("0x%16.16" PRIx64, uint); break;
- case 128: uint = data.GetULEB128(offset_ptr); s.Printf("0x%" PRIx64, uint); break;
- }
-
- return 0;
-}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.h b/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.h
deleted file mode 100644
index 69cc0c15969c..000000000000
--- a/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.h
+++ /dev/null
@@ -1,24 +0,0 @@
-//===-- DWARFLocationDescription.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_DWARFLocationDescription_h_
-#define SymbolFileDWARF_DWARFLocationDescription_h_
-
-#include "SymbolFileDWARF.h"
-
-int
-print_dwarf_expression (lldb_private::Stream &s,
- const lldb_private::DWARFDataExtractor& data,
- int address_size,
- int dwarf_ref_size,
- bool location_expression);
-
-
-
-#endif // SymbolFileDWARF_DWARFLocationDescription_h_
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp b/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp
deleted file mode 100644
index 26768f060ef1..000000000000
--- a/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-//===-- DWARFLocationList.cpp -----------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "DWARFLocationList.h"
-
-#include "lldb/Core/Stream.h"
-
-#include "DWARFCompileUnit.h"
-#include "DWARFDebugInfo.h"
-#include "DWARFLocationDescription.h"
-
-using namespace lldb_private;
-
-dw_offset_t
-DWARFLocationList::Dump(Stream &s, const DWARFCompileUnit* cu, const DWARFDataExtractor& debug_loc_data, lldb::offset_t offset)
-{
- uint64_t start_addr, end_addr;
- uint32_t addr_size = DWARFCompileUnit::GetAddressByteSize(cu);
- s.SetAddressByteSize(DWARFCompileUnit::GetAddressByteSize(cu));
- dw_addr_t base_addr = cu ? cu->GetBaseAddress() : 0;
- while (debug_loc_data.ValidOffset(offset))
- {
- start_addr = debug_loc_data.GetMaxU64(&offset,addr_size);
- end_addr = debug_loc_data.GetMaxU64(&offset,addr_size);
-
- if (start_addr == 0 && end_addr == 0)
- break;
-
- s.PutCString("\n ");
- s.Indent();
- if (cu)
- s.AddressRange (start_addr + base_addr,
- end_addr + base_addr,
- cu->GetAddressByteSize(),
- NULL,
- ": ");
- uint32_t loc_length = debug_loc_data.GetU16(&offset);
-
- DWARFDataExtractor locationData(debug_loc_data, offset, loc_length);
- // if ( dump_flags & DWARFDebugInfo::eDumpFlag_Verbose ) *ostrm_ptr << " ( ";
- print_dwarf_expression (s, locationData, addr_size, 4, false);
- offset += loc_length;
- }
-
- return offset;
-}
-
-bool
-DWARFLocationList::Extract(const DWARFDataExtractor& debug_loc_data, lldb::offset_t* offset_ptr, DWARFDataExtractor& location_list_data)
-{
- // Initialize with no data just in case we don't find anything
- location_list_data.Clear();
-
- size_t loc_list_length = Size(debug_loc_data, *offset_ptr);
- if (loc_list_length > 0)
- {
- location_list_data.SetData(debug_loc_data, *offset_ptr, loc_list_length);
- *offset_ptr += loc_list_length;
- return true;
- }
-
- return false;
-}
-
-size_t
-DWARFLocationList::Size(const DWARFDataExtractor& debug_loc_data, lldb::offset_t offset)
-{
- const dw_offset_t debug_loc_offset = offset;
-
- while (debug_loc_data.ValidOffset(offset))
- {
- dw_addr_t start_addr = debug_loc_data.GetAddress(&offset);
- dw_addr_t end_addr = debug_loc_data.GetAddress(&offset);
-
- if (start_addr == 0 && end_addr == 0)
- break;
-
- uint16_t loc_length = debug_loc_data.GetU16(&offset);
- offset += loc_length;
- }
-
- if (offset > debug_loc_offset)
- return offset - debug_loc_offset;
- return 0;
-}
-
-
-
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFLocationList.h b/source/Plugins/SymbolFile/DWARF/DWARFLocationList.h
deleted file mode 100644
index 6dcc0d74e441..000000000000
--- a/source/Plugins/SymbolFile/DWARF/DWARFLocationList.h
+++ /dev/null
@@ -1,34 +0,0 @@
-//===-- DWARFLocationList.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_DWARFLocationList_h_
-#define SymbolFileDWARF_DWARFLocationList_h_
-
-#include "SymbolFileDWARF.h"
-
-class DWARFLocationList
-{
-public:
- static dw_offset_t
- Dump (lldb_private::Stream &s,
- const DWARFCompileUnit* cu,
- const lldb_private::DWARFDataExtractor& debug_loc_data,
- lldb::offset_t offset);
-
- static bool
- Extract (const lldb_private::DWARFDataExtractor& debug_loc_data,
- lldb::offset_t* offset_ptr,
- lldb_private::DWARFDataExtractor& location_list_data);
-
- static size_t
- Size (const lldb_private::DWARFDataExtractor& debug_loc_data,
- lldb::offset_t offset);
-
-};
-#endif // SymbolFileDWARF_DWARFLocationList_h_
diff --git a/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp b/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
new file mode 100644
index 000000000000..0db416054ae8
--- /dev/null
+++ b/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
@@ -0,0 +1,747 @@
+//===-- HashedNameToDIE.cpp -------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "HashedNameToDIE.h"
+
+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);
+}
+
+void
+DWARFMappedHash::ExtractDIEArray (const DIEInfoArray &die_info_array,
+ const dw_tag_t tag,
+ DIEArray &die_offsets)
+{
+ if (tag == 0)
+ {
+ ExtractDIEArray (die_info_array, die_offsets);
+ }
+ else
+ {
+ const size_t count = die_info_array.size();
+ for (size_t i=0; i<count; ++i)
+ {
+ const dw_tag_t die_tag = die_info_array[i].tag;
+ bool tag_matches = die_tag == 0 || tag == die_tag;
+ if (!tag_matches)
+ {
+ if (die_tag == DW_TAG_class_type || die_tag == DW_TAG_structure_type)
+ tag_matches = 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);
+ }
+ }
+}
+
+void
+DWARFMappedHash::ExtractDIEArray (const DIEInfoArray &die_info_array,
+ const dw_tag_t tag,
+ const uint32_t qualified_name_hash,
+ DIEArray &die_offsets)
+{
+ if (tag == 0)
+ {
+ ExtractDIEArray (die_info_array, die_offsets);
+ }
+ else
+ {
+ const size_t count = die_info_array.size();
+ for (size_t i=0; i<count; ++i)
+ {
+ if (qualified_name_hash != die_info_array[i].qualified_name_hash)
+ continue;
+ const dw_tag_t die_tag = die_info_array[i].tag;
+ bool tag_matches = die_tag == 0 || tag == die_tag;
+ if (!tag_matches)
+ {
+ if (die_tag == DW_TAG_class_type || die_tag == DW_TAG_structure_type)
+ tag_matches = 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);
+ }
+ }
+}
+
+void
+DWARFMappedHash::ExtractClassOrStructDIEArray (const DIEInfoArray &die_info_array,
+ bool return_implementation_only_if_available,
+ DIEArray &die_offsets)
+{
+ const size_t count = die_info_array.size();
+ for (size_t i=0; i<count; ++i)
+ {
+ const dw_tag_t die_tag = die_info_array[i].tag;
+ if (die_tag == 0 || die_tag == DW_TAG_class_type || die_tag == DW_TAG_structure_type)
+ {
+ if (die_info_array[i].type_flags & eTypeFlagClassIsImplementation)
+ {
+ if (return_implementation_only_if_available)
+ {
+ // 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);
+ 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);
+ }
+ }
+ else
+ {
+ die_offsets.emplace_back(die_info_array[i].cu_offset, die_info_array[i].offset);
+ }
+ }
+ }
+}
+
+void
+DWARFMappedHash::ExtractTypesFromDIEArray (const DIEInfoArray &die_info_array,
+ uint32_t type_flag_mask,
+ uint32_t type_flag_value,
+ DIEArray &die_offsets)
+{
+ 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);
+ }
+}
+
+const char *
+DWARFMappedHash::GetAtomTypeName (uint16_t atom)
+{
+ switch (atom)
+ {
+ case eAtomTypeNULL: return "NULL";
+ case eAtomTypeDIEOffset: return "die-offset";
+ case eAtomTypeCUOffset: return "cu-offset";
+ case eAtomTypeTag: return "die-tag";
+ case eAtomTypeNameFlags: return "name-flags";
+ case eAtomTypeTypeFlags: return "type-flags";
+ case eAtomTypeQualNameHash: return "qualified-name-hash";
+ }
+ 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::Prologue::Prologue (dw_offset_t _die_base_offset) :
+ die_base_offset (_die_base_offset),
+ atoms(),
+ atom_mask (0),
+ min_hash_data_byte_size(0),
+ hash_data_has_fixed_byte_size(true)
+{
+ // Define an array of DIE offsets by first defining an array,
+ // and then define the atom type for the array, in this case
+ // we have an array of DIE offsets
+ AppendAtom (eAtomTypeDIEOffset, DW_FORM_data4);
+}
+
+void
+DWARFMappedHash::Prologue::ClearAtoms ()
+{
+ hash_data_has_fixed_byte_size = true;
+ min_hash_data_byte_size = 0;
+ atom_mask = 0;
+ atoms.clear();
+}
+
+bool
+DWARFMappedHash::Prologue::ContainsAtom (AtomType atom_type) const
+{
+ return (atom_mask & (1u << atom_type)) != 0;
+}
+
+void
+DWARFMappedHash::Prologue::Clear ()
+{
+ die_base_offset = 0;
+ ClearAtoms ();
+}
+
+void
+DWARFMappedHash::Prologue::AppendAtom (AtomType type, dw_form_t form)
+{
+ atoms.push_back ({type, form});
+ atom_mask |= 1u << type;
+ switch (form)
+ {
+ case DW_FORM_indirect:
+ case DW_FORM_exprloc:
+ case DW_FORM_flag_present:
+ case DW_FORM_ref_sig8:
+ assert (!"Unhandled atom form");
+ break;
+
+ case DW_FORM_string:
+ case DW_FORM_block:
+ case DW_FORM_block1:
+ 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:
+ hash_data_has_fixed_byte_size = false;
+ // Fall through to the cases below...
+ case DW_FORM_flag:
+ case DW_FORM_data1:
+ case DW_FORM_ref1:
+ case DW_FORM_sec_offset:
+ min_hash_data_byte_size += 1;
+ break;
+
+ case DW_FORM_block2:
+ hash_data_has_fixed_byte_size = false;
+ // Fall through to the cases below...
+ case DW_FORM_data2:
+ case DW_FORM_ref2:
+ min_hash_data_byte_size += 2;
+ break;
+
+ case DW_FORM_block4:
+ hash_data_has_fixed_byte_size = false;
+ // Fall through to the cases below...
+ case DW_FORM_data4:
+ case DW_FORM_ref4:
+ case DW_FORM_addr:
+ case DW_FORM_ref_addr:
+ case DW_FORM_strp:
+ min_hash_data_byte_size += 4;
+ break;
+
+ case DW_FORM_data8:
+ case DW_FORM_ref8:
+ min_hash_data_byte_size += 8;
+ break;
+
+ }
+}
+
+lldb::offset_t
+DWARFMappedHash::Prologue::Read (const lldb_private::DataExtractor &data,
+ lldb::offset_t offset)
+{
+ ClearAtoms ();
+
+ die_base_offset = data.GetU32 (&offset);
+
+ const uint32_t atom_count = data.GetU32 (&offset);
+ if (atom_count == 0x00060003u)
+ {
+ // Old format, deal with contents of old pre-release format
+ while (data.GetU32(&offset))
+ /* do nothing */;
+
+ // Hardcode to the only known value for now.
+ AppendAtom (eAtomTypeDIEOffset, DW_FORM_data4);
+ }
+ else
+ {
+ for (uint32_t i=0; i<atom_count; ++i)
+ {
+ AtomType type = (AtomType)data.GetU16 (&offset);
+ dw_form_t form = (dw_form_t)data.GetU16 (&offset);
+ AppendAtom (type, form);
+ }
+ }
+ return offset;
+}
+
+size_t
+DWARFMappedHash::Prologue::GetByteSize () const
+{
+ // Add an extra count to the atoms size for the zero termination Atom that gets
+ // written to disk
+ return sizeof(die_base_offset) + sizeof(uint32_t) + atoms.size() * sizeof(Atom);
+}
+
+size_t
+DWARFMappedHash::Prologue::GetMinimumHashDataByteSize () const
+{
+ return min_hash_data_byte_size;
+}
+
+bool
+DWARFMappedHash::Prologue::HashDataHasFixedByteSize() const
+{
+ return hash_data_has_fixed_byte_size;
+}
+
+size_t
+DWARFMappedHash::Header::GetByteSize (const HeaderData &header_data)
+{
+ return header_data.GetByteSize();
+}
+
+lldb::offset_t
+DWARFMappedHash::Header::Read (lldb_private::DataExtractor &data, lldb::offset_t offset)
+{
+ offset = MappedHash::Header<Prologue>::Read (data, offset);
+ if (offset != UINT32_MAX)
+ {
+ offset = header_data.Read (data, offset);
+ }
+ return offset;
+}
+
+bool
+DWARFMappedHash::Header::Read (const lldb_private::DWARFDataExtractor &data,
+ lldb::offset_t *offset_ptr,
+ DIEInfo &hash_data) const
+{
+ const size_t num_atoms = header_data.atoms.size();
+ if (num_atoms == 0)
+ return false;
+
+ for (size_t i=0; i<num_atoms; ++i)
+ {
+ DWARFFormValue form_value (NULL, 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 = (dw_offset_t)form_value.Reference (header_data.die_base_offset);
+ break;
+
+ case eAtomTypeTag: // DW_TAG value for the DIE
+ hash_data.tag = (dw_tag_t)form_value.Unsigned ();
+
+ case eAtomTypeTypeFlags: // Flags from enum TypeFlags
+ hash_data.type_flags = (uint32_t)form_value.Unsigned ();
+ break;
+
+ case eAtomTypeQualNameHash: // Flags from enum TypeFlags
+ hash_data.qualified_name_hash = form_value.Unsigned ();
+ break;
+
+ default:
+ // We can always skip atoms we don't know about
+ 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;
+ }
+ }
+}
+
+DWARFMappedHash::MemoryTable::MemoryTable (lldb_private::DWARFDataExtractor &table_data,
+ const lldb_private::DWARFDataExtractor &string_table,
+ const char *name) :
+ MappedHash::MemoryTable<uint32_t, Header, DIEInfoArray> (table_data),
+ m_data (table_data),
+ m_string_table (string_table),
+ m_name (name)
+{
+}
+
+const char *
+DWARFMappedHash::MemoryTable::GetStringForKeyType (KeyType key) const
+{
+ // The key in the DWARF table is the .debug_str offset for the string
+ return m_string_table.PeekCStr (key);
+}
+
+bool
+DWARFMappedHash::MemoryTable::ReadHashData (uint32_t hash_data_offset, HashData &hash_data) const
+{
+ lldb::offset_t offset = hash_data_offset;
+ offset += 4; // Skip string table offset that contains offset of hash name in .debug_str
+ const uint32_t count = m_data.GetU32 (&offset);
+ if (count > 0)
+ {
+ hash_data.resize(count);
+ for (uint32_t i=0; i<count; ++i)
+ {
+ if (!m_header.Read(m_data, &offset, hash_data[i]))
+ return false;
+ }
+ }
+ else
+ hash_data.clear();
+ return true;
+}
+
+DWARFMappedHash::MemoryTable::Result
+DWARFMappedHash::MemoryTable::GetHashDataForName (const char *name,
+ lldb::offset_t* hash_data_offset_ptr,
+ Pair &pair) const
+{
+ pair.key = m_data.GetU32 (hash_data_offset_ptr);
+ pair.value.clear();
+
+ // If the key is zero, this terminates our chain of HashData objects
+ // for this hash value.
+ if (pair.key == 0)
+ return eResultEndOfHashData;
+
+ // 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)
+ {
+ *hash_data_offset_ptr = UINT32_MAX;
+ return eResultError;
+ }
+
+ const uint32_t count = m_data.GetU32 (hash_data_offset_ptr);
+ const size_t min_total_hash_data_size = count * m_header.header_data.GetMinimumHashDataByteSize();
+ if (count > 0 && m_data.ValidOffsetForDataOfSize (*hash_data_offset_ptr, min_total_hash_data_size))
+ {
+ // We have at least one HashData entry, and we have enough
+ // data to parse at least "count" HashData entries.
+
+ // First make sure the entire C string matches...
+ const bool match = strcmp (name, strp_cstr) == 0;
+
+ if (!match && m_header.header_data.HashDataHasFixedByteSize())
+ {
+ // If the string doesn't match and we have fixed size data,
+ // we can just add the total byte size of all HashData objects
+ // to the hash data offset and be done...
+ *hash_data_offset_ptr += min_total_hash_data_size;
+ }
+ else
+ {
+ // If the string does match, or we don't have fixed size data
+ // then we need to read the hash data as a stream. If the
+ // string matches we also append all HashData objects to the
+ // value array.
+ for (uint32_t i=0; i<count; ++i)
+ {
+ DIEInfo die_info;
+ if (m_header.Read(m_data, hash_data_offset_ptr, die_info))
+ {
+ // Only happened if the HashData of the string matched...
+ if (match)
+ pair.value.push_back (die_info);
+ }
+ else
+ {
+ // Something went wrong while reading the data
+ *hash_data_offset_ptr = UINT32_MAX;
+ return eResultError;
+ }
+ }
+ }
+ // Return the correct response depending on if the string matched
+ // or not...
+ if (match)
+ return eResultKeyMatch; // The key (cstring) matches and we have lookup results!
+ else
+ return eResultKeyMismatch; // The key doesn't match, this function will get called
+ // again for the next key/value or the key terminator
+ // which in our case is a zero .debug_str offset.
+ }
+ else
+ {
+ *hash_data_offset_ptr = UINT32_MAX;
+ return eResultError;
+ }
+}
+
+DWARFMappedHash::MemoryTable::Result
+DWARFMappedHash::MemoryTable::AppendHashDataForRegularExpression (
+ const lldb_private::RegularExpression& regex,
+ lldb::offset_t* hash_data_offset_ptr,
+ Pair &pair) const
+{
+ pair.key = m_data.GetU32 (hash_data_offset_ptr);
+ // If the key is zero, this terminates our chain of HashData objects
+ // for this hash value.
+ if (pair.key == 0)
+ return eResultEndOfHashData;
+
+ // 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)
+ return eResultError;
+
+ const uint32_t count = m_data.GetU32 (hash_data_offset_ptr);
+ const size_t min_total_hash_data_size = count * m_header.header_data.GetMinimumHashDataByteSize();
+ if (count > 0 && m_data.ValidOffsetForDataOfSize (*hash_data_offset_ptr, min_total_hash_data_size))
+ {
+ const bool match = regex.Execute(strp_cstr);
+
+ if (!match && m_header.header_data.HashDataHasFixedByteSize())
+ {
+ // If the regex doesn't match and we have fixed size data,
+ // we can just add the total byte size of all HashData objects
+ // to the hash data offset and be done...
+ *hash_data_offset_ptr += min_total_hash_data_size;
+ }
+ else
+ {
+ // If the string does match, or we don't have fixed size data
+ // then we need to read the hash data as a stream. If the
+ // string matches we also append all HashData objects to the
+ // value array.
+ for (uint32_t i=0; i<count; ++i)
+ {
+ DIEInfo die_info;
+ if (m_header.Read(m_data, hash_data_offset_ptr, die_info))
+ {
+ // Only happened if the HashData of the string matched...
+ if (match)
+ pair.value.push_back (die_info);
+ }
+ else
+ {
+ // Something went wrong while reading the data
+ *hash_data_offset_ptr = UINT32_MAX;
+ return eResultError;
+ }
+ }
+ }
+ // Return the correct response depending on if the string matched
+ // or not...
+ if (match)
+ return eResultKeyMatch; // The key (cstring) matches and we have lookup results!
+ else
+ return eResultKeyMismatch; // The key doesn't match, this function will get called
+ // again for the next key/value or the key terminator
+ // which in our case is a zero .debug_str offset.
+ }
+ else
+ {
+ *hash_data_offset_ptr = UINT32_MAX;
+ return eResultError;
+ }
+}
+
+size_t
+DWARFMappedHash::MemoryTable::AppendAllDIEsThatMatchingRegex (
+ const lldb_private::RegularExpression& regex,
+ DIEInfoArray &die_info_array) const
+{
+ const uint32_t hash_count = m_header.hashes_count;
+ Pair pair;
+ for (uint32_t offset_idx=0; offset_idx<hash_count; ++offset_idx)
+ {
+ lldb::offset_t hash_data_offset = GetHashDataOffset (offset_idx);
+ while (hash_data_offset != UINT32_MAX)
+ {
+ const lldb::offset_t prev_hash_data_offset = hash_data_offset;
+ Result hash_result = AppendHashDataForRegularExpression (regex, &hash_data_offset, pair);
+ if (prev_hash_data_offset == hash_data_offset)
+ break;
+
+ // Check the result of getting our hash data
+ switch (hash_result)
+ {
+ case eResultKeyMatch:
+ case eResultKeyMismatch:
+ // Whether we matches or not, it doesn't matter, we
+ // keep looking.
+ break;
+
+ case eResultEndOfHashData:
+ case eResultError:
+ hash_data_offset = UINT32_MAX;
+ break;
+ }
+ }
+ }
+ die_info_array.swap (pair.value);
+ return die_info_array.size();
+}
+
+size_t
+DWARFMappedHash::MemoryTable::AppendAllDIEsInRange (const uint32_t die_offset_start,
+ const uint32_t die_offset_end,
+ DIEInfoArray &die_info_array) const
+{
+ const uint32_t hash_count = m_header.hashes_count;
+ for (uint32_t offset_idx=0; offset_idx<hash_count; ++offset_idx)
+ {
+ bool done = false;
+ lldb::offset_t hash_data_offset = GetHashDataOffset (offset_idx);
+ while (!done && hash_data_offset != UINT32_MAX)
+ {
+ KeyType key = m_data.GetU32 (&hash_data_offset);
+ // If the key is zero, this terminates our chain of HashData objects
+ // for this hash value.
+ if (key == 0)
+ break;
+
+ const uint32_t count = m_data.GetU32 (&hash_data_offset);
+ 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)
+ done = true;
+ if (die_offset_start <= die_info.offset && die_info.offset < die_offset_end)
+ die_info_array.push_back(die_info);
+ }
+ }
+ }
+ }
+ return die_info_array.size();
+}
+
+size_t
+DWARFMappedHash::MemoryTable::FindByName (const char *name, DIEArray &die_offsets)
+{
+ DIEInfoArray die_info_array;
+ if (FindByName(name, die_info_array))
+ DWARFMappedHash::ExtractDIEArray (die_info_array, die_offsets);
+ return die_info_array.size();
+}
+
+size_t
+DWARFMappedHash::MemoryTable::FindByNameAndTag (const char *name,
+ const dw_tag_t tag,
+ DIEArray &die_offsets)
+{
+ DIEInfoArray die_info_array;
+ if (FindByName(name, die_info_array))
+ DWARFMappedHash::ExtractDIEArray (die_info_array, tag, die_offsets);
+ return die_info_array.size();
+}
+
+size_t
+DWARFMappedHash::MemoryTable::FindByNameAndTagAndQualifiedNameHash (const char *name,
+ const dw_tag_t tag,
+ const uint32_t qualified_name_hash,
+ DIEArray &die_offsets)
+{
+ DIEInfoArray die_info_array;
+ if (FindByName(name, die_info_array))
+ DWARFMappedHash::ExtractDIEArray (die_info_array, tag, qualified_name_hash, die_offsets);
+ return die_info_array.size();
+}
+
+size_t
+DWARFMappedHash::MemoryTable::FindCompleteObjCClassByName (const char *name,
+ DIEArray &die_offsets,
+ bool must_be_implementation)
+{
+ DIEInfoArray die_info_array;
+ if (FindByName(name, die_info_array))
+ {
+ if (must_be_implementation && GetHeader().header_data.ContainsAtom (eAtomTypeTypeFlags))
+ {
+ // If we have two atoms, then we have the DIE offset and
+ // the type flags so we can find the objective C class
+ // efficiently.
+ DWARFMappedHash::ExtractTypesFromDIEArray (die_info_array,
+ UINT32_MAX,
+ eTypeFlagClassIsImplementation,
+ die_offsets);
+ }
+ else
+ {
+ // We don't only want the one true definition, so try and see
+ // what we can find, and only return class or struct DIEs.
+ // If we do have the full implementation, then return it alone,
+ // else return all possible matches.
+ const bool return_implementation_only_if_available = true;
+ DWARFMappedHash::ExtractClassOrStructDIEArray (die_info_array,
+ return_implementation_only_if_available,
+ die_offsets);
+ }
+ }
+ return die_offsets.size();
+}
+
+size_t
+DWARFMappedHash::MemoryTable::FindByName (const char *name, DIEInfoArray &die_info_array)
+{
+ Pair kv_pair;
+ size_t old_size = die_info_array.size();
+ if (Find (name, kv_pair))
+ {
+ die_info_array.swap(kv_pair.value);
+ return die_info_array.size() - old_size;
+ }
+ return 0;
+}
diff --git a/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h b/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
index f8a8cc60467d..bcde558ae449 100644
--- a/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
+++ b/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
@@ -12,139 +12,36 @@
#include <vector>
-#include "DWARFDefines.h"
-#include "DWARFFormValue.h"
-
#include "lldb/lldb-defines.h"
#include "lldb/Core/dwarf.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/MappedHash.h"
+#include "DWARFDefines.h"
+#include "DWARFFormValue.h"
+#include "NameToDIE.h"
class SymbolFileDWARF;
class DWARFCompileUnit;
class DWARFDebugInfoEntry;
-struct DWARFMappedHash
+class DWARFMappedHash
{
- struct DIEInfo
- {
- 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 () :
- offset (DW_INVALID_OFFSET),
- tag (0),
- type_flags (0),
- qualified_name_hash (0)
- {
- }
-
- DIEInfo (dw_offset_t o, dw_tag_t t, uint32_t f, uint32_t h) :
- offset(o),
- tag (t),
- type_flags (f),
- qualified_name_hash (h)
- {
- }
-
- void
- Clear()
- {
- offset = DW_INVALID_OFFSET;
- tag = 0;
- type_flags = 0;
- qualified_name_hash = 0;
- }
- };
-
- typedef std::vector<DIEInfo> DIEInfoArray;
- typedef std::vector<uint32_t> DIEArray;
-
- static void
- 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.push_back (die_info_array[i].offset);
- }
- }
-
- static void
- ExtractDIEArray (const DIEInfoArray &die_info_array,
- const dw_tag_t tag,
- DIEArray &die_offsets)
- {
- if (tag == 0)
- {
- ExtractDIEArray (die_info_array, die_offsets);
- }
- else
- {
- const size_t count = die_info_array.size();
- for (size_t i=0; i<count; ++i)
- {
- const dw_tag_t die_tag = die_info_array[i].tag;
- bool tag_matches = die_tag == 0 || tag == die_tag;
- if (!tag_matches)
- {
- if (die_tag == DW_TAG_class_type || die_tag == DW_TAG_structure_type)
- tag_matches = tag == DW_TAG_structure_type || tag == DW_TAG_class_type;
- }
- if (tag_matches)
- die_offsets.push_back (die_info_array[i].offset);
- }
- }
- }
-
- static void
- ExtractDIEArray (const DIEInfoArray &die_info_array,
- const dw_tag_t tag,
- const uint32_t qualified_name_hash,
- DIEArray &die_offsets)
- {
- if (tag == 0)
- {
- ExtractDIEArray (die_info_array, die_offsets);
- }
- else
- {
- const size_t count = die_info_array.size();
- for (size_t i=0; i<count; ++i)
- {
- if (qualified_name_hash != die_info_array[i].qualified_name_hash)
- continue;
- const dw_tag_t die_tag = die_info_array[i].tag;
- bool tag_matches = die_tag == 0 || tag == die_tag;
- if (!tag_matches)
- {
- if (die_tag == DW_TAG_class_type || die_tag == DW_TAG_structure_type)
- tag_matches = tag == DW_TAG_structure_type || tag == DW_TAG_class_type;
- }
- if (tag_matches)
- die_offsets.push_back (die_info_array[i].offset);
- }
- }
- }
-
- enum AtomType
+public:
+ enum AtomType : uint16_t
{
- eAtomTypeNULL = 0u,
- eAtomTypeDIEOffset = 1u, // DIE offset, check form for encoding
- eAtomTypeCUOffset = 2u, // DIE offset of the compiler unit header that contains the item in question
- eAtomTypeTag = 3u, // DW_TAG_xxx value, should be encoded as DW_FORM_data1 (if no tags exceed 255) or DW_FORM_data2
- eAtomTypeNameFlags = 4u, // Flags from enum NameFlags
- eAtomTypeTypeFlags = 5u, // Flags from enum TypeFlags,
+ eAtomTypeNULL = 0u,
+ eAtomTypeDIEOffset = 1u, // DIE offset, check form for encoding
+ eAtomTypeCUOffset = 2u, // DIE offset of the compiler unit header that contains the item in question
+ eAtomTypeTag = 3u, // DW_TAG_xxx value, should be encoded as DW_FORM_data1 (if no tags exceed 255) or DW_FORM_data2
+ eAtomTypeNameFlags = 4u, // Flags from enum NameFlags
+ eAtomTypeTypeFlags = 5u, // Flags from enum TypeFlags,
eAtomTypeQualNameHash = 6u // A 32 bit hash of the full qualified name (since all hash entries are basename only)
// For example a type like "std::vector<int>::iterator" would have a name of "iterator"
// and a 32 bit hash for "std::vector<int>::iterator" to allow us to not have to pull
// in debug info for a type when we know the fully qualified name.
};
-
+
// Bit definitions for the eAtomTypeTypeFlags flags
enum TypeFlags
{
@@ -152,782 +49,171 @@ struct DWARFMappedHash
// @implementation for class
eTypeFlagClassIsImplementation = ( 1u << 1 )
};
-
- static void
- ExtractClassOrStructDIEArray (const DIEInfoArray &die_info_array,
- bool return_implementation_only_if_available,
- DIEArray &die_offsets)
+ struct DIEInfo
{
- const size_t count = die_info_array.size();
- for (size_t i=0; i<count; ++i)
- {
- const dw_tag_t die_tag = die_info_array[i].tag;
- if (die_tag == 0 || die_tag == DW_TAG_class_type || die_tag == DW_TAG_structure_type)
- {
- if (die_info_array[i].type_flags & eTypeFlagClassIsImplementation)
- {
- if (return_implementation_only_if_available)
- {
- // We found the one true definition for this class, so
- // only return that
- die_offsets.clear();
- die_offsets.push_back (die_info_array[i].offset);
- return;
- }
- else
- {
- // Put the one true definition as the first entry so it
- // matches first
- die_offsets.insert (die_offsets.begin(), die_info_array[i].offset);
- }
- }
- else
- {
- die_offsets.push_back (die_info_array[i].offset);
- }
- }
- }
- }
+ 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
- static void
- ExtractTypesFromDIEArray (const DIEInfoArray &die_info_array,
- uint32_t type_flag_mask,
- uint32_t type_flag_value,
- DIEArray &die_offsets)
- {
- 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.push_back (die_info_array[i].offset);
- }
- }
+ DIEInfo ();
+ DIEInfo (dw_offset_t c, dw_offset_t o, dw_tag_t t, uint32_t f, uint32_t h);
+ };
struct Atom
{
- uint16_t type;
+ AtomType type;
dw_form_t form;
-
- Atom (uint16_t t = eAtomTypeNULL, dw_form_t f = 0) :
- type (t),
- form (f)
- {
- }
};
-
+
+ typedef std::vector<DIEInfo> DIEInfoArray;
typedef std::vector<Atom> AtomArray;
-
- static uint32_t
- GetTypeFlags (SymbolFileDWARF *dwarf2Data,
- const DWARFCompileUnit* cu,
- const DWARFDebugInfoEntry* die);
-
- static const char *
- GetAtomTypeName (uint16_t atom)
- {
- switch (atom)
- {
- case eAtomTypeNULL: return "NULL";
- case eAtomTypeDIEOffset: return "die-offset";
- case eAtomTypeCUOffset: return "cu-offset";
- case eAtomTypeTag: return "die-tag";
- case eAtomTypeNameFlags: return "name-flags";
- case eAtomTypeTypeFlags: return "type-flags";
- case eAtomTypeQualNameHash: return "qualified-name-hash";
- }
- return "<invalid>";
- }
- struct Prologue
+ class Prologue
{
- // DIE offset base so die offsets in hash_data can be CU relative
- dw_offset_t die_base_offset;
- AtomArray atoms;
- uint32_t atom_mask;
- size_t min_hash_data_byte_size;
- bool hash_data_has_fixed_byte_size;
-
- Prologue (dw_offset_t _die_base_offset = 0) :
- die_base_offset (_die_base_offset),
- atoms(),
- atom_mask (0),
- min_hash_data_byte_size(0),
- hash_data_has_fixed_byte_size(true)
- {
- // Define an array of DIE offsets by first defining an array,
- // and then define the atom type for the array, in this case
- // we have an array of DIE offsets
- AppendAtom (eAtomTypeDIEOffset, DW_FORM_data4);
- }
-
- virtual ~Prologue()
- {
- }
+ public:
+ Prologue (dw_offset_t _die_base_offset = 0);
void
- ClearAtoms ()
- {
- hash_data_has_fixed_byte_size = true;
- min_hash_data_byte_size = 0;
- atom_mask = 0;
- atoms.clear();
- }
+ ClearAtoms ();
bool
- ContainsAtom (AtomType atom_type) const
- {
- return (atom_mask & (1u << atom_type)) != 0;
- }
-
- virtual void
- Clear ()
- {
- die_base_offset = 0;
- ClearAtoms ();
- }
-
+ ContainsAtom (AtomType atom_type) const;
+
void
- AppendAtom (AtomType type, dw_form_t form)
- {
- atoms.push_back (Atom(type, form));
- atom_mask |= 1u << type;
- switch (form)
- {
- case DW_FORM_indirect:
- case DW_FORM_exprloc:
- case DW_FORM_flag_present:
- case DW_FORM_ref_sig8:
- assert (!"Unhandled atom form");
- break;
-
- case DW_FORM_string:
- case DW_FORM_block:
- case DW_FORM_block1:
- case DW_FORM_sdata:
- case DW_FORM_udata:
- case DW_FORM_ref_udata:
- hash_data_has_fixed_byte_size = false;
- // Fall through to the cases below...
- case DW_FORM_flag:
- case DW_FORM_data1:
- case DW_FORM_ref1:
- case DW_FORM_sec_offset:
- min_hash_data_byte_size += 1;
- break;
-
- case DW_FORM_block2:
- hash_data_has_fixed_byte_size = false;
- // Fall through to the cases below...
- case DW_FORM_data2:
- case DW_FORM_ref2:
- min_hash_data_byte_size += 2;
- break;
-
- case DW_FORM_block4:
- hash_data_has_fixed_byte_size = false;
- // Fall through to the cases below...
- case DW_FORM_data4:
- case DW_FORM_ref4:
- case DW_FORM_addr:
- case DW_FORM_ref_addr:
- case DW_FORM_strp:
- min_hash_data_byte_size += 4;
- break;
-
- case DW_FORM_data8:
- case DW_FORM_ref8:
- min_hash_data_byte_size += 8;
- break;
-
- }
- }
-
-// void
-// Dump (std::ostream* ostrm_ptr);
-
+ Clear ();
+
+ void
+ AppendAtom (AtomType type, dw_form_t form);
+
lldb::offset_t
- Read (const lldb_private::DataExtractor &data,
- lldb::offset_t offset)
- {
- ClearAtoms ();
-
- die_base_offset = data.GetU32 (&offset);
-
- const uint32_t atom_count = data.GetU32 (&offset);
- if (atom_count == 0x00060003u)
- {
- // Old format, deal with contents of old pre-release format
- while (data.GetU32(&offset))
- /* do nothing */;
-
- // Hardcode to the only known value for now.
- AppendAtom (eAtomTypeDIEOffset, DW_FORM_data4);
- }
- else
- {
- for (uint32_t i=0; i<atom_count; ++i)
- {
- AtomType type = (AtomType)data.GetU16 (&offset);
- dw_form_t form = (dw_form_t)data.GetU16 (&offset);
- AppendAtom (type, form);
- }
- }
- return offset;
- }
-
-// virtual void
-// Write (BinaryStreamBuf &s);
-
+ Read (const lldb_private::DataExtractor &data, lldb::offset_t offset);
+
size_t
- GetByteSize () const
- {
- // Add an extra count to the atoms size for the zero termination Atom that gets
- // written to disk
- return sizeof(die_base_offset) + sizeof(uint32_t) + atoms.size() * sizeof(Atom);
- }
-
+ GetByteSize () const;
+
size_t
- GetMinimumHashDataByteSize () const
- {
- return min_hash_data_byte_size;
- }
+ GetMinimumHashDataByteSize () const;
bool
- HashDataHasFixedByteSize() const
- {
- return hash_data_has_fixed_byte_size;
- }
+ HashDataHasFixedByteSize() const;
+
+ // DIE offset base so die offsets in hash_data can be CU relative
+ dw_offset_t die_base_offset;
+ AtomArray atoms;
+ uint32_t atom_mask;
+ size_t min_hash_data_byte_size;
+ bool hash_data_has_fixed_byte_size;
};
- struct Header : public MappedHash::Header<Prologue>
+ class Header : public MappedHash::Header<Prologue>
{
- Header (dw_offset_t _die_base_offset = 0)
- {
- }
-
- virtual
- ~Header()
- {
- }
-
- virtual size_t
- GetByteSize (const HeaderData &header_data)
- {
- return header_data.GetByteSize();
- }
-
- // virtual void
- // Dump (std::ostream* ostrm_ptr);
- //
- virtual lldb::offset_t
- Read (lldb_private::DataExtractor &data, lldb::offset_t offset)
- {
- offset = MappedHash::Header<Prologue>::Read (data, offset);
- if (offset != UINT32_MAX)
- {
- offset = header_data.Read (data, offset);
- }
- return offset;
- }
-
+ public:
+ size_t
+ GetByteSize (const HeaderData &header_data) override;
+
+ lldb::offset_t
+ Read (lldb_private::DataExtractor &data, lldb::offset_t offset) override;
+
bool
Read (const lldb_private::DWARFDataExtractor &data,
lldb::offset_t *offset_ptr,
- DIEInfo &hash_data) const
- {
- const size_t num_atoms = header_data.atoms.size();
- if (num_atoms == 0)
- return false;
-
- for (size_t i=0; i<num_atoms; ++i)
- {
- DWARFFormValue form_value (NULL, 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 = (dw_offset_t)form_value.Reference (header_data.die_base_offset);
- break;
-
- case eAtomTypeTag: // DW_TAG value for the DIE
- hash_data.tag = (dw_tag_t)form_value.Unsigned ();
-
- case eAtomTypeTypeFlags: // Flags from enum TypeFlags
- hash_data.type_flags = (uint32_t)form_value.Unsigned ();
- break;
-
- case eAtomTypeQualNameHash: // Flags from enum TypeFlags
- hash_data.qualified_name_hash = form_value.Unsigned ();
- break;
-
- default:
- // We can always skip atoms we don't know about
- break;
- }
- }
- return true;
- }
-
+ DIEInfo &hash_data) const;
+
void
- 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;
- }
- }
- }
+ Dump (lldb_private::Stream& strm, const DIEInfo &hash_data) const;
};
-
-// class ExportTable
-// {
-// public:
-// ExportTable ();
-//
-// void
-// AppendNames (DWARFDebugPubnamesSet &pubnames_set,
-// StringTable &string_table);
-//
-// void
-// AppendNamesEntry (SymbolFileDWARF *dwarf2Data,
-// const DWARFCompileUnit* cu,
-// const DWARFDebugInfoEntry* die,
-// StringTable &string_table);
-//
-// void
-// AppendTypesEntry (DWARFData *dwarf2Data,
-// const DWARFCompileUnit* cu,
-// const DWARFDebugInfoEntry* die,
-// StringTable &string_table);
-//
-// size_t
-// Save (BinaryStreamBuf &names_data, const StringTable &string_table);
-//
-// void
-// AppendName (const char *name,
-// uint32_t die_offset,
-// StringTable &string_table,
-// dw_offset_t name_debug_str_offset = DW_INVALID_OFFSET); // If "name" has already been looked up, then it can be supplied
-// void
-// AppendType (const char *name,
-// uint32_t die_offset,
-// StringTable &string_table);
-//
-//
-// protected:
-// struct Entry
-// {
-// uint32_t hash;
-// uint32_t str_offset;
-// uint32_t die_offset;
-// };
-//
-// // Map uniqued .debug_str offset to the corresponding DIE offsets
-// typedef std::map<uint32_t, DIEInfoArray> NameInfo;
-// // Map a name hash to one or more name infos
-// typedef std::map<uint32_t, NameInfo> BucketEntry;
-//
-// static uint32_t
-// GetByteSize (const NameInfo &name_info);
-//
-// typedef std::vector<BucketEntry> BucketEntryColl;
-// typedef std::vector<Entry> EntryColl;
-// EntryColl m_entries;
-//
-// };
-
-
+
// A class for reading and using a saved hash table from a block of data
// in memory
class MemoryTable : public MappedHash::MemoryTable<uint32_t, DWARFMappedHash::Header, DIEInfoArray>
{
public:
-
MemoryTable (lldb_private::DWARFDataExtractor &table_data,
const lldb_private::DWARFDataExtractor &string_table,
- const char *name) :
- MappedHash::MemoryTable<uint32_t, Header, DIEInfoArray> (table_data),
- m_data (table_data),
- m_string_table (string_table),
- m_name (name)
- {
- }
-
- virtual
- ~MemoryTable ()
- {
- }
-
- virtual const char *
- GetStringForKeyType (KeyType key) const
- {
- // The key in the DWARF table is the .debug_str offset for the string
- return m_string_table.PeekCStr (key);
- }
+ const char *name);
+
+ const char *
+ GetStringForKeyType (KeyType key) const override;
- virtual bool
- ReadHashData (uint32_t hash_data_offset,
- HashData &hash_data) const
- {
- lldb::offset_t offset = hash_data_offset;
- offset += 4; // Skip string table offset that contains offset of hash name in .debug_str
- const uint32_t count = m_data.GetU32 (&offset);
- if (count > 0)
- {
- hash_data.resize(count);
- for (uint32_t i=0; i<count; ++i)
- {
- if (!m_header.Read(m_data, &offset, hash_data[i]))
- return false;
- }
- }
- else
- hash_data.clear();
- return true;
- }
-
- virtual Result
- GetHashDataForName (const char *name,
- lldb::offset_t* hash_data_offset_ptr,
- Pair &pair) const
- {
- pair.key = m_data.GetU32 (hash_data_offset_ptr);
- pair.value.clear();
-
- // If the key is zero, this terminates our chain of HashData objects
- // for this hash value.
- if (pair.key == 0)
- return eResultEndOfHashData;
-
- // 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)
- {
- *hash_data_offset_ptr = UINT32_MAX;
- return eResultError;
- }
-
- const uint32_t count = m_data.GetU32 (hash_data_offset_ptr);
- const size_t min_total_hash_data_size = count * m_header.header_data.GetMinimumHashDataByteSize();
- if (count > 0 && m_data.ValidOffsetForDataOfSize (*hash_data_offset_ptr, min_total_hash_data_size))
- {
- // We have at least one HashData entry, and we have enough
- // data to parse at least "count" HashData entries.
-
- // First make sure the entire C string matches...
- const bool match = strcmp (name, strp_cstr) == 0;
-
- if (!match && m_header.header_data.HashDataHasFixedByteSize())
- {
- // If the string doesn't match and we have fixed size data,
- // we can just add the total byte size of all HashData objects
- // to the hash data offset and be done...
- *hash_data_offset_ptr += min_total_hash_data_size;
- }
- else
- {
- // If the string does match, or we don't have fixed size data
- // then we need to read the hash data as a stream. If the
- // string matches we also append all HashData objects to the
- // value array.
- for (uint32_t i=0; i<count; ++i)
- {
- DIEInfo die_info;
- if (m_header.Read(m_data, hash_data_offset_ptr, die_info))
- {
- // Only happened if the HashData of the string matched...
- if (match)
- pair.value.push_back (die_info);
- }
- else
- {
- // Something went wrong while reading the data
- *hash_data_offset_ptr = UINT32_MAX;
- return eResultError;
- }
- }
- }
- // Return the correct response depending on if the string matched
- // or not...
- if (match)
- return eResultKeyMatch; // The key (cstring) matches and we have lookup results!
- else
- return eResultKeyMismatch; // The key doesn't match, this function will get called
- // again for the next key/value or the key terminator
- // which in our case is a zero .debug_str offset.
- }
- else
- {
- *hash_data_offset_ptr = UINT32_MAX;
- return eResultError;
- }
- }
-
- virtual Result
- AppendHashDataForRegularExpression (const lldb_private::RegularExpression& regex,
- lldb::offset_t* hash_data_offset_ptr,
- Pair &pair) const
- {
- pair.key = m_data.GetU32 (hash_data_offset_ptr);
- // If the key is zero, this terminates our chain of HashData objects
- // for this hash value.
- if (pair.key == 0)
- return eResultEndOfHashData;
-
- // 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)
- return eResultError;
-
- const uint32_t count = m_data.GetU32 (hash_data_offset_ptr);
- const size_t min_total_hash_data_size = count * m_header.header_data.GetMinimumHashDataByteSize();
- if (count > 0 && m_data.ValidOffsetForDataOfSize (*hash_data_offset_ptr, min_total_hash_data_size))
- {
- const bool match = regex.Execute(strp_cstr);
-
- if (!match && m_header.header_data.HashDataHasFixedByteSize())
- {
- // If the regex doesn't match and we have fixed size data,
- // we can just add the total byte size of all HashData objects
- // to the hash data offset and be done...
- *hash_data_offset_ptr += min_total_hash_data_size;
- }
- else
- {
- // If the string does match, or we don't have fixed size data
- // then we need to read the hash data as a stream. If the
- // string matches we also append all HashData objects to the
- // value array.
- for (uint32_t i=0; i<count; ++i)
- {
- DIEInfo die_info;
- if (m_header.Read(m_data, hash_data_offset_ptr, die_info))
- {
- // Only happened if the HashData of the string matched...
- if (match)
- pair.value.push_back (die_info);
- }
- else
- {
- // Something went wrong while reading the data
- *hash_data_offset_ptr = UINT32_MAX;
- return eResultError;
- }
- }
- }
- // Return the correct response depending on if the string matched
- // or not...
- if (match)
- return eResultKeyMatch; // The key (cstring) matches and we have lookup results!
- else
- return eResultKeyMismatch; // The key doesn't match, this function will get called
- // again for the next key/value or the key terminator
- // which in our case is a zero .debug_str offset.
- }
- else
- {
- *hash_data_offset_ptr = UINT32_MAX;
- return eResultError;
- }
- }
+ bool
+ ReadHashData (uint32_t hash_data_offset, HashData &hash_data) const override;
size_t
AppendAllDIEsThatMatchingRegex (const lldb_private::RegularExpression& regex,
- DIEInfoArray &die_info_array) const
- {
- const uint32_t hash_count = m_header.hashes_count;
- Pair pair;
- for (uint32_t offset_idx=0; offset_idx<hash_count; ++offset_idx)
- {
- lldb::offset_t hash_data_offset = GetHashDataOffset (offset_idx);
- while (hash_data_offset != UINT32_MAX)
- {
- const lldb::offset_t prev_hash_data_offset = hash_data_offset;
- Result hash_result = AppendHashDataForRegularExpression (regex, &hash_data_offset, pair);
- if (prev_hash_data_offset == hash_data_offset)
- break;
-
- // Check the result of getting our hash data
- switch (hash_result)
- {
- case eResultKeyMatch:
- case eResultKeyMismatch:
- // Whether we matches or not, it doesn't matter, we
- // keep looking.
- break;
-
- case eResultEndOfHashData:
- case eResultError:
- hash_data_offset = UINT32_MAX;
- break;
- }
- }
- }
- die_info_array.swap (pair.value);
- return die_info_array.size();
- }
-
+ DIEInfoArray &die_info_array) const;
+
size_t
AppendAllDIEsInRange (const uint32_t die_offset_start,
const uint32_t die_offset_end,
- DIEInfoArray &die_info_array) const
- {
- const uint32_t hash_count = m_header.hashes_count;
- for (uint32_t offset_idx=0; offset_idx<hash_count; ++offset_idx)
- {
- bool done = false;
- lldb::offset_t hash_data_offset = GetHashDataOffset (offset_idx);
- while (!done && hash_data_offset != UINT32_MAX)
- {
- KeyType key = m_data.GetU32 (&hash_data_offset);
- // If the key is zero, this terminates our chain of HashData objects
- // for this hash value.
- if (key == 0)
- break;
-
- const uint32_t count = m_data.GetU32 (&hash_data_offset);
- 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)
- done = true;
- if (die_offset_start <= die_info.offset && die_info.offset < die_offset_end)
- die_info_array.push_back(die_info);
- }
- }
- }
- }
- return die_info_array.size();
- }
+ DIEInfoArray &die_info_array) const;
size_t
- FindByName (const char *name, DIEArray &die_offsets)
- {
- DIEInfoArray die_info_array;
- if (FindByName(name, die_info_array))
- DWARFMappedHash::ExtractDIEArray (die_info_array, die_offsets);
- return die_info_array.size();
- }
+ FindByName (const char *name, DIEArray &die_offsets);
size_t
- FindByNameAndTag (const char *name,
- const dw_tag_t tag,
- DIEArray &die_offsets)
- {
- DIEInfoArray die_info_array;
- if (FindByName(name, die_info_array))
- DWARFMappedHash::ExtractDIEArray (die_info_array, tag, die_offsets);
- return die_info_array.size();
- }
+ FindByNameAndTag (const char *name, const dw_tag_t tag, DIEArray &die_offsets);
size_t
FindByNameAndTagAndQualifiedNameHash (const char *name,
const dw_tag_t tag,
const uint32_t qualified_name_hash,
- DIEArray &die_offsets)
- {
- DIEInfoArray die_info_array;
- if (FindByName(name, die_info_array))
- DWARFMappedHash::ExtractDIEArray (die_info_array, tag, qualified_name_hash, die_offsets);
- return die_info_array.size();
- }
+ DIEArray &die_offsets);
size_t
- FindCompleteObjCClassByName (const char *name, DIEArray &die_offsets, bool must_be_implementation)
- {
- DIEInfoArray die_info_array;
- if (FindByName(name, die_info_array))
- {
- if (must_be_implementation && GetHeader().header_data.ContainsAtom (eAtomTypeTypeFlags))
- {
- // If we have two atoms, then we have the DIE offset and
- // the type flags so we can find the objective C class
- // efficiently.
- DWARFMappedHash::ExtractTypesFromDIEArray (die_info_array,
- UINT32_MAX,
- eTypeFlagClassIsImplementation,
- die_offsets);
- }
- else
- {
- // We don't only want the one true definition, so try and see
- // what we can find, and only return class or struct DIEs.
- // If we do have the full implementation, then return it alone,
- // else return all possible matches.
- const bool return_implementation_only_if_available = true;
- DWARFMappedHash::ExtractClassOrStructDIEArray (die_info_array,
- return_implementation_only_if_available,
- die_offsets);
- }
- }
- return die_offsets.size();
- }
+ FindCompleteObjCClassByName (const char *name,
+ DIEArray &die_offsets,
+ bool must_be_implementation);
- size_t
- FindByName (const char *name, DIEInfoArray &die_info_array)
- {
- Pair kv_pair;
- size_t old_size = die_info_array.size();
- if (Find (name, kv_pair))
- {
- die_info_array.swap(kv_pair.value);
- return die_info_array.size() - old_size;
- }
- return 0;
- }
-
protected:
+ Result
+ AppendHashDataForRegularExpression (const lldb_private::RegularExpression& regex,
+ lldb::offset_t* hash_data_offset_ptr,
+ Pair &pair) const;
+
+ size_t
+ FindByName (const char *name, DIEInfoArray &die_info_array);
+
+ Result
+ GetHashDataForName (const char *name,
+ lldb::offset_t* hash_data_offset_ptr,
+ Pair &pair) const override;
+
const lldb_private::DWARFDataExtractor &m_data;
const lldb_private::DWARFDataExtractor &m_string_table;
std::string m_name;
};
-};
+ static void
+ ExtractDIEArray (const DIEInfoArray &die_info_array, DIEArray &die_offsets);
+
+protected:
+ static void
+ ExtractDIEArray (const DIEInfoArray &die_info_array,
+ const dw_tag_t tag,
+ DIEArray &die_offsets);
+
+ static void
+ ExtractDIEArray (const DIEInfoArray &die_info_array,
+ const dw_tag_t tag,
+ const uint32_t qualified_name_hash,
+ DIEArray &die_offsets);
+
+ static void
+ ExtractClassOrStructDIEArray (const DIEInfoArray &die_info_array,
+ bool return_implementation_only_if_available,
+ DIEArray &die_offsets);
+
+ static void
+ ExtractTypesFromDIEArray (const DIEInfoArray &die_info_array,
+ uint32_t type_flag_mask,
+ uint32_t type_flag_value,
+ DIEArray &die_offsets);
+
+ static const char *
+ GetAtomTypeName (uint16_t atom);
+};
#endif // SymbolFileDWARF_HashedNameToDIE_h_
diff --git a/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h b/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h
index 2091a8414f58..24fa7d148cd3 100644
--- a/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h
+++ b/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h
@@ -1,4 +1,4 @@
-//===-- LogChannelDWARF.h --------------------------------------*- C++ -*-===//
+//===-- LogChannelDWARF.h ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -13,7 +13,6 @@
// C Includes
// C++ Includes
// Other libraries and framework includes
-
// Project includes
#include "lldb/Core/Log.h"
@@ -34,8 +33,7 @@ class LogChannelDWARF : public lldb_private::LogChannel
public:
LogChannelDWARF ();
- virtual
- ~LogChannelDWARF ();
+ ~LogChannelDWARF() override;
static void
Initialize();
@@ -52,26 +50,26 @@ public:
static lldb_private::LogChannel *
CreateInstance ();
- virtual lldb_private::ConstString
- GetPluginName();
+ lldb_private::ConstString
+ GetPluginName() override;
- virtual uint32_t
- GetPluginVersion();
+ uint32_t
+ GetPluginVersion() override;
- virtual void
- Disable (const char** categories, lldb_private::Stream *feedback_strm);
+ void
+ Disable(const char** categories, lldb_private::Stream *feedback_strm) override;
void
Delete ();
- virtual bool
- Enable (lldb::StreamSP &log_stream_sp,
- uint32_t log_options,
- lldb_private::Stream *feedback_strm, // Feedback stream for argument errors etc
- const char **categories); // The categories to enable within this logging stream, if empty, enable default set
+ bool
+ Enable(lldb::StreamSP &log_stream_sp,
+ uint32_t log_options,
+ lldb_private::Stream *feedback_strm, // Feedback stream for argument errors etc
+ const char **categories) override; // The categories to enable within this logging stream, if empty, enable default set
- virtual void
- ListCategories (lldb_private::Stream *strm);
+ void
+ ListCategories(lldb_private::Stream *strm) override;
static lldb_private::Log *
GetLog ();
@@ -86,4 +84,4 @@ public:
LogIf (uint32_t mask, const char *format, ...);
};
-#endif // SymbolFileDWARF_LogChannelDWARF_h_
+#endif // SymbolFileDWARF_LogChannelDWARF_h_
diff --git a/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp b/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
index c49237b8fbbc..775bb6718b8a 100644
--- a/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
+++ b/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
@@ -18,6 +18,7 @@
#include "DWARFDebugInfo.h"
#include "DWARFDebugInfoEntry.h"
#include "SymbolFileDWARF.h"
+
using namespace lldb;
using namespace lldb_private;
@@ -29,9 +30,9 @@ NameToDIE::Finalize()
}
void
-NameToDIE::Insert (const ConstString& name, uint32_t die_offset)
+NameToDIE::Insert (const ConstString& name, const DIERef& die_ref)
{
- m_map.Append(name.GetCString(), die_offset);
+ m_map.Append(name.GetCString(), die_ref);
}
size_t
@@ -47,17 +48,15 @@ NameToDIE::Find (const RegularExpression& regex, DIEArray &info_array) const
}
size_t
-NameToDIE::FindAllEntriesForCompileUnit (uint32_t cu_offset,
- uint32_t cu_end_offset,
- DIEArray &info_array) const
+NameToDIE::FindAllEntriesForCompileUnit (dw_offset_t cu_offset, 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 uint32_t die_offset = m_map.GetValueAtIndexUnchecked(i);
- if (cu_offset < die_offset && die_offset < cu_end_offset)
- info_array.push_back (die_offset);
+ const DIERef& die_ref = m_map.GetValueAtIndexUnchecked(i);
+ if (cu_offset == die_ref.cu_offset)
+ info_array.push_back (die_ref);
}
return info_array.size() - initial_size;
}
@@ -69,18 +68,29 @@ NameToDIE::Dump (Stream *s)
for (uint32_t i=0; i<size; ++i)
{
const char *cstr = m_map.GetCStringAtIndex(i);
- s->Printf("%p: {0x%8.8x} \"%s\"\n", (const void *)cstr, m_map.GetValueAtIndexUnchecked(i), cstr);
+ const DIERef& die_ref = m_map.GetValueAtIndexUnchecked(i);
+ s->Printf("%p: {0x%8.8x/0x%8.8x} \"%s\"\n", cstr, die_ref.cu_offset, die_ref.die_offset, cstr);
}
}
void
-NameToDIE::ForEach (std::function <bool(const char *name, uint32_t die_offset)> const &callback) const
+NameToDIE::ForEach (std::function <bool(const char *name, const DIERef& die_ref)> const &callback) const
{
const uint32_t size = m_map.GetSize();
for (uint32_t i=0; i<size; ++i)
{
- if (!callback(m_map.GetCStringAtIndexUnchecked(i),
- m_map.GetValueAtIndexUnchecked (i)))
+ if (!callback(m_map.GetCStringAtIndexUnchecked(i), m_map.GetValueAtIndexUnchecked (i)))
break;
}
}
+
+void
+NameToDIE::Append (const NameToDIE& other)
+{
+ const uint32_t size = other.m_map.GetSize();
+ for (uint32_t i = 0; i < size; ++i)
+ {
+ m_map.Append(other.m_map.GetCStringAtIndexUnchecked (i),
+ other.m_map.GetValueAtIndexUnchecked (i));
+ }
+}
diff --git a/source/Plugins/SymbolFile/DWARF/NameToDIE.h b/source/Plugins/SymbolFile/DWARF/NameToDIE.h
index f9a12736bf9e..7fc66138f51e 100644
--- a/source/Plugins/SymbolFile/DWARF/NameToDIE.h
+++ b/source/Plugins/SymbolFile/DWARF/NameToDIE.h
@@ -10,56 +10,53 @@
#ifndef SymbolFileDWARF_NameToDIE_h_
#define SymbolFileDWARF_NameToDIE_h_
-#include "lldb/Core/UniqueCStringMap.h"
-
#include <functional>
+#include "lldb/Core/dwarf.h"
+#include "lldb/Core/UniqueCStringMap.h"
#include "lldb/lldb-defines.h"
+#include "DIERef.h"
class SymbolFileDWARF;
-typedef std::vector<uint32_t> DIEArray;
-
class NameToDIE
{
public:
- NameToDIE () :
+ NameToDIE () :
m_map()
{
}
-
+
~NameToDIE ()
{
}
-
+
void
Dump (lldb_private::Stream *s);
void
- Insert (const lldb_private::ConstString& name, uint32_t die_offset);
+ Insert (const lldb_private::ConstString& name, const DIERef& die_ref);
+
+ void
+ Append (const NameToDIE& other);
void
Finalize();
size_t
- Find (const lldb_private::ConstString &name,
- DIEArray &info_array) const;
+ Find (const lldb_private::ConstString &name, DIEArray &info_array) const;
size_t
- Find (const lldb_private::RegularExpression& regex,
- DIEArray &info_array) const;
+ Find (const lldb_private::RegularExpression& regex, DIEArray &info_array) const;
size_t
- FindAllEntriesForCompileUnit (uint32_t cu_offset,
- uint32_t cu_end_offset,
- DIEArray &info_array) const;
+ FindAllEntriesForCompileUnit (dw_offset_t cu_offset, DIEArray &info_array) const;
void
- ForEach (std::function <bool(const char *name, uint32_t die_offset)> const &callback) const;
+ ForEach (std::function <bool(const char *name, const DIERef& die_ref)> const &callback) const;
protected:
- lldb_private::UniqueCStringMap<uint32_t> m_map;
-
+ lldb_private::UniqueCStringMap<DIERef> m_map;
};
#endif // SymbolFileDWARF_NameToDIE_h_
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index ea8aedcc2be0..0ed4d05be5c2 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -10,20 +10,6 @@
#include "SymbolFileDWARF.h"
// Other libraries and framework includes
-#include "clang/AST/ASTConsumer.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/DeclGroup.h"
-#include "clang/AST/DeclObjC.h"
-#include "clang/AST/DeclTemplate.h"
-#include "clang/Basic/Builtins.h"
-#include "clang/Basic/IdentifierTable.h"
-#include "clang/Basic/LangOptions.h"
-#include "clang/Basic/SourceManager.h"
-#include "clang/Basic/TargetInfo.h"
-#include "clang/Basic/Specifiers.h"
-#include "clang/Sema/DeclSpec.h"
-
#include "llvm/Support/Casting.h"
#include "lldb/Core/ArchSpec.h"
@@ -39,34 +25,48 @@
#include "lldb/Core/Timer.h"
#include "lldb/Core/Value.h"
-#include "lldb/Expression/ClangModulesDeclVendor.h"
+#include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
+#include "lldb/Interpreter/OptionValueFileSpecList.h"
+#include "lldb/Interpreter/OptionValueProperties.h"
+
#include "lldb/Symbol/Block.h"
-#include "lldb/Symbol/ClangExternalASTSourceCallbacks.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/CompilerDecl.h"
+#include "lldb/Symbol/CompilerDeclContext.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/LineTable.h"
+#include "lldb/Symbol/DebugMacros.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Symbol/VariableList.h"
+#include "lldb/Symbol/TypeMap.h"
+
+#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
+#include "Plugins/Language/ObjC/ObjCLanguage.h"
+
+#include "lldb/Target/Language.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
-#include "lldb/Target/CPPLanguageRuntime.h"
+#include "lldb/Utility/TaskPool.h"
+#include "DWARFASTParser.h"
#include "DWARFCompileUnit.h"
#include "DWARFDebugAbbrev.h"
#include "DWARFDebugAranges.h"
#include "DWARFDebugInfo.h"
-#include "DWARFDebugInfoEntry.h"
#include "DWARFDebugLine.h"
+#include "DWARFDebugMacro.h"
#include "DWARFDebugPubnames.h"
#include "DWARFDebugRanges.h"
#include "DWARFDeclContext.h"
#include "DWARFDIECollection.h"
#include "DWARFFormValue.h"
-#include "DWARFLocationList.h"
#include "LogChannelDWARF.h"
+#include "SymbolFileDWARFDwo.h"
#include "SymbolFileDWARFDebugMap.h"
#include <map>
@@ -83,8 +83,6 @@
#define DEBUG_PRINTF(fmt, ...)
#endif
-#define DIE_IS_BEING_PARSED ((lldb_private::Type*)1)
-
using namespace lldb;
using namespace lldb_private;
@@ -105,18 +103,58 @@ using namespace lldb_private;
// return false;
//}
//
-static AccessType
-DW_ACCESS_to_AccessType (uint32_t dwarf_accessibility)
-{
- switch (dwarf_accessibility)
+
+namespace {
+
+ PropertyDefinition
+ g_properties[] =
+ {
+ { "comp-dir-symlink-paths" , OptionValue::eTypeFileSpecList, true, 0 , nullptr, nullptr, "If the DW_AT_comp_dir matches any of these paths the symbolic links will be resolved at DWARF parse time." },
+ { nullptr , OptionValue::eTypeInvalid , false, 0, nullptr, nullptr, nullptr }
+ };
+
+ enum
+ {
+ ePropertySymLinkPaths
+ };
+
+
+ class PluginProperties : public Properties
{
- case DW_ACCESS_public: return eAccessPublic;
- case DW_ACCESS_private: return eAccessPrivate;
- case DW_ACCESS_protected: return eAccessProtected;
- default: break;
+ public:
+ static ConstString
+ GetSettingName()
+ {
+ return SymbolFileDWARF::GetPluginNameStatic();
+ }
+
+ PluginProperties()
+ {
+ m_collection_sp.reset (new OptionValueProperties(GetSettingName()));
+ m_collection_sp->Initialize(g_properties);
+ }
+
+ FileSpecList&
+ GetSymLinkPaths()
+ {
+ OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr, true, ePropertySymLinkPaths);
+ assert(option_value);
+ return option_value->GetCurrentValue();
+ }
+
+ };
+
+ typedef std::shared_ptr<PluginProperties> SymbolFileDWARFPropertiesSP;
+
+ static const SymbolFileDWARFPropertiesSP&
+ GetGlobalPluginProperties()
+ {
+ static const auto g_settings_sp(std::make_shared<PluginProperties>());
+ return g_settings_sp;
}
- return eAccessNone;
-}
+
+} // anonymous namespace end
+
static const char*
removeHostnameFromPathname(const char* path_from_dwarf)
@@ -125,9 +163,15 @@ removeHostnameFromPathname(const char* path_from_dwarf)
{
return path_from_dwarf;
}
-
+
const char *colon_pos = strchr(path_from_dwarf, ':');
- if (!colon_pos)
+ 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;
}
@@ -142,89 +186,42 @@ removeHostnameFromPathname(const char* path_from_dwarf)
{
return path_from_dwarf;
}
-
+
return colon_pos + 1;
}
-#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE)
-
-class DIEStack
+static const char*
+resolveCompDir(const char* path_from_dwarf)
{
-public:
-
- void Push (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die)
- {
- m_dies.push_back (DIEInfo(cu, die));
- }
+ if (!path_from_dwarf)
+ return nullptr;
-
- void LogDIEs (Log *log, SymbolFileDWARF *dwarf)
- {
- StreamString log_strm;
- const size_t n = m_dies.size();
- log_strm.Printf("DIEStack[%" PRIu64 "]:\n", (uint64_t)n);
- for (size_t i=0; i<n; i++)
- {
- DWARFCompileUnit *cu = m_dies[i].cu;
- const DWARFDebugInfoEntry *die = m_dies[i].die;
- std::string qualified_name;
- die->GetQualifiedName(dwarf, cu, qualified_name);
- log_strm.Printf ("[%" PRIu64 "] 0x%8.8x: %s name='%s'\n",
- (uint64_t)i,
- die->GetOffset(),
- DW_TAG_value_to_name(die->Tag()),
- qualified_name.c_str());
- }
- log->PutCString(log_strm.GetData());
- }
- void Pop ()
- {
- m_dies.pop_back();
- }
-
- class ScopedPopper
- {
- public:
- ScopedPopper (DIEStack &die_stack) :
- m_die_stack (die_stack),
- m_valid (false)
- {
- }
-
- void
- Push (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die)
- {
- m_valid = true;
- m_die_stack.Push (cu, die);
- }
-
- ~ScopedPopper ()
- {
- if (m_valid)
- m_die_stack.Pop();
- }
-
-
-
- protected:
- DIEStack &m_die_stack;
- bool m_valid;
- };
+ // 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 nullptr;
+
+ bool is_symlink = false;
+ FileSpec local_path_spec(local_path, false);
+ 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_path_spec, true);
+
+ if (!is_symlink)
+ return local_path;
+
+ if (!local_path_spec.IsSymbolicLink())
+ return local_path;
+
+ FileSpec resolved_local_path_spec;
+ const auto error = FileSystem::Readlink(local_path_spec, resolved_local_path_spec);
+ if (error.Success())
+ return resolved_local_path_spec.GetCString();
+
+ return nullptr;
+}
-protected:
- struct DIEInfo {
- DIEInfo (DWARFCompileUnit *c, const DWARFDebugInfoEntry *d) :
- cu(c),
- die(d)
- {
- }
- DWARFCompileUnit *cu;
- const DWARFDebugInfoEntry *die;
- };
- typedef std::vector<DIEInfo> Stack;
- Stack m_dies;
-};
-#endif
void
SymbolFileDWARF::Initialize()
@@ -232,7 +229,21 @@ SymbolFileDWARF::Initialize()
LogChannelDWARF::Initialize();
PluginManager::RegisterPlugin (GetPluginNameStatic(),
GetPluginDescriptionStatic(),
- CreateInstance);
+ CreateInstance,
+ DebuggerInitialize);
+}
+
+void
+SymbolFileDWARF::DebuggerInitialize(Debugger &debugger)
+{
+ if (!PluginManager::GetSettingForSymbolFilePlugin(debugger, PluginProperties::GetSettingName()))
+ {
+ const bool is_global_setting = true;
+ PluginManager::CreateSettingForSymbolFilePlugin(debugger,
+ GetGlobalPluginProperties()->GetValueProperties(),
+ ConstString ("Properties for the dwarf symbol-file plug-in."),
+ is_global_setting);
+ }
}
void
@@ -272,65 +283,61 @@ SymbolFileDWARF::GetTypeList ()
}
void
-SymbolFileDWARF::GetTypes (DWARFCompileUnit* cu,
- const DWARFDebugInfoEntry *die,
+SymbolFileDWARF::GetTypes (const DWARFDIE &die,
dw_offset_t min_die_offset,
dw_offset_t max_die_offset,
uint32_t type_mask,
TypeSet &type_set)
{
- if (cu)
+ if (die)
{
- if (die)
+ const dw_offset_t die_offset = die.GetOffset();
+
+ if (die_offset >= max_die_offset)
+ return;
+
+ if (die_offset >= min_die_offset)
{
- const dw_offset_t die_offset = die->GetOffset();
-
- if (die_offset >= max_die_offset)
- return;
+ const dw_tag_t tag = die.Tag();
- if (die_offset >= min_die_offset)
- {
- const dw_tag_t tag = die->Tag();
-
- bool add_type = false;
+ bool add_type = false;
- switch (tag)
- {
- case DW_TAG_array_type: add_type = (type_mask & eTypeClassArray ) != 0; break;
- case DW_TAG_unspecified_type:
- case DW_TAG_base_type: add_type = (type_mask & eTypeClassBuiltin ) != 0; break;
- case DW_TAG_class_type: add_type = (type_mask & eTypeClassClass ) != 0; break;
- case DW_TAG_structure_type: add_type = (type_mask & eTypeClassStruct ) != 0; break;
- case DW_TAG_union_type: add_type = (type_mask & eTypeClassUnion ) != 0; break;
- case DW_TAG_enumeration_type: add_type = (type_mask & eTypeClassEnumeration ) != 0; break;
- case DW_TAG_subroutine_type:
- case DW_TAG_subprogram:
- case DW_TAG_inlined_subroutine: add_type = (type_mask & eTypeClassFunction ) != 0; break;
- case DW_TAG_pointer_type: add_type = (type_mask & eTypeClassPointer ) != 0; break;
- case DW_TAG_rvalue_reference_type:
- case DW_TAG_reference_type: add_type = (type_mask & eTypeClassReference ) != 0; break;
- case DW_TAG_typedef: add_type = (type_mask & eTypeClassTypedef ) != 0; break;
- case DW_TAG_ptr_to_member_type: add_type = (type_mask & eTypeClassMemberPointer ) != 0; break;
- }
+ switch (tag)
+ {
+ case DW_TAG_array_type: add_type = (type_mask & eTypeClassArray ) != 0; break;
+ case DW_TAG_unspecified_type:
+ case DW_TAG_base_type: add_type = (type_mask & eTypeClassBuiltin ) != 0; break;
+ case DW_TAG_class_type: add_type = (type_mask & eTypeClassClass ) != 0; break;
+ case DW_TAG_structure_type: add_type = (type_mask & eTypeClassStruct ) != 0; break;
+ case DW_TAG_union_type: add_type = (type_mask & eTypeClassUnion ) != 0; break;
+ case DW_TAG_enumeration_type: add_type = (type_mask & eTypeClassEnumeration ) != 0; break;
+ case DW_TAG_subroutine_type:
+ case DW_TAG_subprogram:
+ case DW_TAG_inlined_subroutine: add_type = (type_mask & eTypeClassFunction ) != 0; break;
+ case DW_TAG_pointer_type: add_type = (type_mask & eTypeClassPointer ) != 0; break;
+ case DW_TAG_rvalue_reference_type:
+ case DW_TAG_reference_type: add_type = (type_mask & eTypeClassReference ) != 0; break;
+ case DW_TAG_typedef: add_type = (type_mask & eTypeClassTypedef ) != 0; break;
+ case DW_TAG_ptr_to_member_type: add_type = (type_mask & eTypeClassMemberPointer ) != 0; break;
+ }
- if (add_type)
+ if (add_type)
+ {
+ const bool assert_not_being_parsed = true;
+ Type *type = ResolveTypeUID (die, assert_not_being_parsed);
+ if (type)
{
- const bool assert_not_being_parsed = true;
- Type *type = ResolveTypeUID (cu, die, assert_not_being_parsed);
- if (type)
- {
- if (type_set.find(type) == type_set.end())
- type_set.insert(type);
- }
+ if (type_set.find(type) == type_set.end())
+ type_set.insert(type);
}
}
-
- for (const DWARFDebugInfoEntry *child_die = die->GetFirstChild();
- child_die != NULL;
- child_die = child_die->GetSibling())
- {
- GetTypes (cu, child_die, min_die_offset, max_die_offset, type_mask, type_set);
- }
+ }
+
+ for (DWARFDIE child_die = die.GetFirstChild();
+ child_die.IsValid();
+ child_die = child_die.GetSibling())
+ {
+ GetTypes (child_die, min_die_offset, max_die_offset, type_mask, type_set);
}
}
}
@@ -353,8 +360,7 @@ SymbolFileDWARF::GetTypes (SymbolContextScope *sc_scope,
dwarf_cu = GetDWARFCompileUnit(comp_unit);
if (dwarf_cu == 0)
return 0;
- GetTypes (dwarf_cu,
- dwarf_cu->DIE(),
+ GetTypes (dwarf_cu->DIE(),
dwarf_cu->GetOffset(),
dwarf_cu->GetNextCompileUnitOffset(),
type_mask,
@@ -371,8 +377,7 @@ SymbolFileDWARF::GetTypes (SymbolContextScope *sc_scope,
dwarf_cu = info->GetCompileUnitAtIndex(cu_idx);
if (dwarf_cu)
{
- GetTypes (dwarf_cu,
- dwarf_cu->DIE(),
+ GetTypes (dwarf_cu->DIE(),
0,
UINT32_MAX,
type_mask,
@@ -381,76 +386,15 @@ SymbolFileDWARF::GetTypes (SymbolContextScope *sc_scope,
}
}
}
-// if (m_using_apple_tables)
-// {
-// DWARFMappedHash::MemoryTable *apple_types = m_apple_types_ap.get();
-// if (apple_types)
-// {
-// apple_types->ForEach([this, &type_set, apple_types, type_mask](const DWARFMappedHash::DIEInfoArray &die_info_array) -> bool {
-//
-// for (auto die_info: die_info_array)
-// {
-// bool add_type = TagMatchesTypeMask (type_mask, 0);
-// if (!add_type)
-// {
-// dw_tag_t tag = die_info.tag;
-// if (tag == 0)
-// {
-// const DWARFDebugInfoEntry *die = DebugInfo()->GetDIEPtr(die_info.offset, NULL);
-// tag = die->Tag();
-// }
-// add_type = TagMatchesTypeMask (type_mask, tag);
-// }
-// if (add_type)
-// {
-// Type *type = ResolveTypeUID(die_info.offset);
-//
-// if (type_set.find(type) == type_set.end())
-// type_set.insert(type);
-// }
-// }
-// return true; // Keep iterating
-// });
-// }
-// }
-// else
-// {
-// if (!m_indexed)
-// Index ();
-//
-// m_type_index.ForEach([this, &type_set, type_mask](const char *name, uint32_t die_offset) -> bool {
-//
-// bool add_type = TagMatchesTypeMask (type_mask, 0);
-//
-// if (!add_type)
-// {
-// const DWARFDebugInfoEntry *die = DebugInfo()->GetDIEPtr(die_offset, NULL);
-// if (die)
-// {
-// const dw_tag_t tag = die->Tag();
-// add_type = TagMatchesTypeMask (type_mask, tag);
-// }
-// }
-//
-// if (add_type)
-// {
-// Type *type = ResolveTypeUID(die_offset);
-//
-// if (type_set.find(type) == type_set.end())
-// type_set.insert(type);
-// }
-// return true; // Keep iterating
-// });
-// }
-
- std::set<ClangASTType> clang_type_set;
+
+ std::set<CompilerType> compiler_type_set;
size_t num_types_added = 0;
for (Type *type : type_set)
{
- ClangASTType clang_type = type->GetClangForwardType();
- if (clang_type_set.find(clang_type) == clang_type_set.end())
+ CompilerType compiler_type = type->GetForwardCompilerType ();
+ if (compiler_type_set.find(compiler_type) == compiler_type_set.end())
{
- clang_type_set.insert(clang_type);
+ compiler_type_set.insert(compiler_type);
type_list.Insert (type->shared_from_this());
++num_types_added;
}
@@ -463,13 +407,13 @@ SymbolFileDWARF::GetTypes (SymbolContextScope *sc_scope,
// Gets the first parent that is a lexical block, function or inlined
// subroutine, or compile unit.
//----------------------------------------------------------------------
-static const DWARFDebugInfoEntry *
-GetParentSymbolContextDIE(const DWARFDebugInfoEntry *child_die)
+DWARFDIE
+SymbolFileDWARF::GetParentSymbolContextDIE(const DWARFDIE &child_die)
{
- const DWARFDebugInfoEntry *die;
- for (die = child_die->GetParent(); die != NULL; die = die->GetParent())
+ DWARFDIE die;
+ for (die = child_die.GetParent(); die; die = die.GetParent())
{
- dw_tag_t tag = die->Tag();
+ dw_tag_t tag = die.Tag();
switch (tag)
{
@@ -480,7 +424,7 @@ GetParentSymbolContextDIE(const DWARFDebugInfoEntry *child_die)
return die;
}
}
- return NULL;
+ return DWARFDIE();
}
@@ -489,13 +433,12 @@ SymbolFileDWARF::SymbolFileDWARF(ObjectFile* objfile) :
UserID (0), // 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_clang_tu_decl (NULL),
- m_flags(),
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_str (),
@@ -518,7 +461,6 @@ SymbolFileDWARF::SymbolFileDWARF(ObjectFile* objfile) :
m_type_index(),
m_namespace_index(),
m_indexed (false),
- m_is_external_ast_source (false),
m_using_apple_tables (false),
m_fetched_external_modules (false),
m_supports_DW_AT_APPLE_objc_complete_type (eLazyBoolCalculate),
@@ -529,12 +471,6 @@ SymbolFileDWARF::SymbolFileDWARF(ObjectFile* objfile) :
SymbolFileDWARF::~SymbolFileDWARF()
{
- if (m_is_external_ast_source)
- {
- ModuleSP module_sp (m_obj_file->GetModule());
- if (module_sp)
- module_sp->GetClangASTContext().RemoveExternalSource ();
- }
}
static const ConstString &
@@ -552,36 +488,31 @@ SymbolFileDWARF::GetUniqueDWARFASTTypeMap ()
return m_unique_ast_type_map;
}
-ClangASTContext &
-SymbolFileDWARF::GetClangASTContext ()
+TypeSystem *
+SymbolFileDWARF::GetTypeSystemForLanguage (LanguageType language)
{
- if (GetDebugMapSymfile ())
- return m_debug_map_symfile->GetClangASTContext ();
-
- ClangASTContext &ast = m_obj_file->GetModule()->GetClangASTContext();
- if (!m_is_external_ast_source)
+ SymbolFileDWARFDebugMap * debug_map_symfile = GetDebugMapSymfile ();
+ TypeSystem *type_system;
+ if (debug_map_symfile)
{
- m_is_external_ast_source = true;
- llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> ast_source_ap (
- new ClangExternalASTSourceCallbacks (SymbolFileDWARF::CompleteTagDecl,
- SymbolFileDWARF::CompleteObjCInterfaceDecl,
- SymbolFileDWARF::FindExternalVisibleDeclsByName,
- SymbolFileDWARF::LayoutRecordType,
- this));
- ast.SetExternalSource (ast_source_ap);
+ type_system = debug_map_symfile->GetTypeSystemForLanguage(language);
}
- return ast;
+ else
+ {
+ type_system = m_obj_file->GetModule()->GetTypeSystemForLanguage(language);
+ if (type_system)
+ type_system->SetSymbolFile(this);
+ }
+ return type_system;
}
void
SymbolFileDWARF::InitializeObject()
{
- // Install our external AST source callbacks so we can complete Clang types.
ModuleSP module_sp (m_obj_file->GetModule());
if (module_sp)
{
const SectionList *section_list = module_sp->GetSectionList();
-
const Section* section = section_list->FindSectionByName(GetDWARFMachOSegmentName ()).get();
// Memory map the DWARF mach-o segment so we have everything mmap'ed
@@ -589,19 +520,24 @@ SymbolFileDWARF::InitializeObject()
if (section)
m_obj_file->MemoryMapSectionData(section, m_dwarf_data);
}
+
get_apple_names_data();
- if (m_data_apple_names.GetByteSize() > 0)
+ if (m_data_apple_names.m_data.GetByteSize() > 0)
{
- m_apple_names_ap.reset (new DWARFMappedHash::MemoryTable (m_data_apple_names, get_debug_str_data(), ".apple_names"));
+ m_apple_names_ap.reset (new DWARFMappedHash::MemoryTable (m_data_apple_names.m_data,
+ get_debug_str_data(),
+ ".apple_names"));
if (m_apple_names_ap->IsValid())
m_using_apple_tables = true;
else
m_apple_names_ap.reset();
}
get_apple_types_data();
- if (m_data_apple_types.GetByteSize() > 0)
+ if (m_data_apple_types.m_data.GetByteSize() > 0)
{
- m_apple_types_ap.reset (new DWARFMappedHash::MemoryTable (m_data_apple_types, get_debug_str_data(), ".apple_types"));
+ m_apple_types_ap.reset (new DWARFMappedHash::MemoryTable (m_data_apple_types.m_data,
+ get_debug_str_data(),
+ ".apple_types"));
if (m_apple_types_ap->IsValid())
m_using_apple_tables = true;
else
@@ -609,9 +545,11 @@ SymbolFileDWARF::InitializeObject()
}
get_apple_namespaces_data();
- if (m_data_apple_namespaces.GetByteSize() > 0)
+ if (m_data_apple_namespaces.m_data.GetByteSize() > 0)
{
- m_apple_namespaces_ap.reset (new DWARFMappedHash::MemoryTable (m_data_apple_namespaces, get_debug_str_data(), ".apple_namespaces"));
+ m_apple_namespaces_ap.reset (new DWARFMappedHash::MemoryTable (m_data_apple_namespaces.m_data,
+ get_debug_str_data(),
+ ".apple_namespaces"));
if (m_apple_namespaces_ap->IsValid())
m_using_apple_tables = true;
else
@@ -619,9 +557,11 @@ SymbolFileDWARF::InitializeObject()
}
get_apple_objc_data();
- if (m_data_apple_objc.GetByteSize() > 0)
+ if (m_data_apple_objc.m_data.GetByteSize() > 0)
{
- m_apple_objc_ap.reset (new DWARFMappedHash::MemoryTable (m_data_apple_objc, get_debug_str_data(), ".apple_objc"));
+ m_apple_objc_ap.reset (new DWARFMappedHash::MemoryTable (m_data_apple_objc.m_data,
+ get_debug_str_data(),
+ ".apple_objc"));
if (m_apple_objc_ap->IsValid())
m_using_apple_tables = true;
else
@@ -663,46 +603,10 @@ SymbolFileDWARF::CalculateAbilities ()
section = section_list->FindSectionByType (eSectionTypeDWARFDebugAbbrev, true).get();
if (section)
debug_abbrev_file_size = section->GetFileSize();
- else
- m_flags.Set (flagsGotDebugAbbrevData);
-
- section = section_list->FindSectionByType (eSectionTypeDWARFDebugAranges, true).get();
- if (!section)
- m_flags.Set (flagsGotDebugArangesData);
-
- section = section_list->FindSectionByType (eSectionTypeDWARFDebugFrame, true).get();
- if (!section)
- m_flags.Set (flagsGotDebugFrameData);
section = section_list->FindSectionByType (eSectionTypeDWARFDebugLine, true).get();
if (section)
debug_line_file_size = section->GetFileSize();
- else
- m_flags.Set (flagsGotDebugLineData);
-
- section = section_list->FindSectionByType (eSectionTypeDWARFDebugLoc, true).get();
- if (!section)
- m_flags.Set (flagsGotDebugLocData);
-
- section = section_list->FindSectionByType (eSectionTypeDWARFDebugMacInfo, true).get();
- if (!section)
- m_flags.Set (flagsGotDebugMacInfoData);
-
- section = section_list->FindSectionByType (eSectionTypeDWARFDebugPubNames, true).get();
- if (!section)
- m_flags.Set (flagsGotDebugPubNamesData);
-
- section = section_list->FindSectionByType (eSectionTypeDWARFDebugPubTypes, true).get();
- if (!section)
- m_flags.Set (flagsGotDebugPubTypesData);
-
- section = section_list->FindSectionByType (eSectionTypeDWARFDebugRanges, true).get();
- if (!section)
- m_flags.Set (flagsGotDebugRangesData);
-
- section = section_list->FindSectionByType (eSectionTypeDWARFDebugStr, true).get();
- if (!section)
- m_flags.Set (flagsGotDebugStrData);
}
else
{
@@ -737,104 +641,128 @@ SymbolFileDWARF::CalculateAbilities ()
}
const DWARFDataExtractor&
-SymbolFileDWARF::GetCachedSectionData (uint32_t got_flag, SectionType sect_type, DWARFDataExtractor &data)
+SymbolFileDWARF::GetCachedSectionData (lldb::SectionType sect_type, DWARFDataSegment& data_segment)
{
- if (m_flags.IsClear (got_flag))
+ std::call_once(data_segment.m_flag,
+ &SymbolFileDWARF::LoadSectionData,
+ this,
+ sect_type,
+ std::ref(data_segment.m_data));
+ return data_segment.m_data;
+}
+
+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)
{
- ModuleSP module_sp (m_obj_file->GetModule());
- m_flags.Set (got_flag);
- const SectionList *section_list = module_sp->GetSectionList();
- if (section_list)
+ SectionSP section_sp (section_list->FindSectionByType(sect_type, true));
+ if (section_sp)
{
- 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())
{
- // 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();
- }
+ data.SetData(m_dwarf_data, section_sp->GetOffset(), section_sp->GetFileSize());
+ }
+ else
+ {
+ if (m_obj_file->ReadSectionData(section_sp.get(), data) == 0)
+ data.Clear();
}
}
}
- return data;
}
const DWARFDataExtractor&
SymbolFileDWARF::get_debug_abbrev_data()
{
- return GetCachedSectionData (flagsGotDebugAbbrevData, eSectionTypeDWARFDebugAbbrev, m_data_debug_abbrev);
+ 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 (flagsGotDebugArangesData, eSectionTypeDWARFDebugAranges, m_data_debug_aranges);
+ return GetCachedSectionData (eSectionTypeDWARFDebugAranges, m_data_debug_aranges);
}
const DWARFDataExtractor&
SymbolFileDWARF::get_debug_frame_data()
{
- return GetCachedSectionData (flagsGotDebugFrameData, eSectionTypeDWARFDebugFrame, m_data_debug_frame);
+ return GetCachedSectionData (eSectionTypeDWARFDebugFrame, m_data_debug_frame);
}
const DWARFDataExtractor&
SymbolFileDWARF::get_debug_info_data()
{
- return GetCachedSectionData (flagsGotDebugInfoData, eSectionTypeDWARFDebugInfo, m_data_debug_info);
+ return GetCachedSectionData (eSectionTypeDWARFDebugInfo, m_data_debug_info);
}
const DWARFDataExtractor&
SymbolFileDWARF::get_debug_line_data()
{
- return GetCachedSectionData (flagsGotDebugLineData, eSectionTypeDWARFDebugLine, m_data_debug_line);
+ return GetCachedSectionData (eSectionTypeDWARFDebugLine, m_data_debug_line);
+}
+
+const DWARFDataExtractor&
+SymbolFileDWARF::get_debug_macro_data()
+{
+ return GetCachedSectionData (eSectionTypeDWARFDebugMacro, m_data_debug_macro);
}
const DWARFDataExtractor&
SymbolFileDWARF::get_debug_loc_data()
{
- return GetCachedSectionData (flagsGotDebugLocData, eSectionTypeDWARFDebugLoc, m_data_debug_loc);
+ return GetCachedSectionData (eSectionTypeDWARFDebugLoc, m_data_debug_loc);
}
const DWARFDataExtractor&
SymbolFileDWARF::get_debug_ranges_data()
{
- return GetCachedSectionData (flagsGotDebugRangesData, eSectionTypeDWARFDebugRanges, m_data_debug_ranges);
+ return GetCachedSectionData (eSectionTypeDWARFDebugRanges, m_data_debug_ranges);
}
const DWARFDataExtractor&
SymbolFileDWARF::get_debug_str_data()
{
- return GetCachedSectionData (flagsGotDebugStrData, eSectionTypeDWARFDebugStr, m_data_debug_str);
+ 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_apple_names_data()
{
- return GetCachedSectionData (flagsGotAppleNamesData, eSectionTypeDWARFAppleNames, m_data_apple_names);
+ return GetCachedSectionData (eSectionTypeDWARFAppleNames, m_data_apple_names);
}
const DWARFDataExtractor&
SymbolFileDWARF::get_apple_types_data()
{
- return GetCachedSectionData (flagsGotAppleTypesData, eSectionTypeDWARFAppleTypes, m_data_apple_types);
+ return GetCachedSectionData (eSectionTypeDWARFAppleTypes, m_data_apple_types);
}
const DWARFDataExtractor&
SymbolFileDWARF::get_apple_namespaces_data()
{
- return GetCachedSectionData (flagsGotAppleNamespacesData, eSectionTypeDWARFAppleNamespaces, m_data_apple_namespaces);
+ return GetCachedSectionData (eSectionTypeDWARFAppleNamespaces, m_data_apple_namespaces);
}
const DWARFDataExtractor&
SymbolFileDWARF::get_apple_objc_data()
{
- return GetCachedSectionData (flagsGotAppleObjCData, eSectionTypeDWARFAppleObjC, m_data_apple_objc);
+ return GetCachedSectionData (eSectionTypeDWARFAppleObjC, m_data_apple_objc);
}
@@ -889,6 +817,9 @@ SymbolFileDWARF::DebugInfo() const
DWARFCompileUnit*
SymbolFileDWARF::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit)
{
+ if (!comp_unit)
+ return nullptr;
+
DWARFDebugInfo* info = DebugInfo();
if (info)
{
@@ -900,7 +831,7 @@ SymbolFileDWARF::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit)
// TODO: modify to support LTO .o files where each .o file might
// have multiple DW_TAG_compile_unit tags.
- DWARFCompileUnit *dwarf_cu = info->GetCompileUnit(0).get();
+ DWARFCompileUnit *dwarf_cu = info->GetCompileUnit(0);
if (dwarf_cu && dwarf_cu->GetUserData() == NULL)
dwarf_cu->SetUserData(comp_unit);
return dwarf_cu;
@@ -910,7 +841,7 @@ SymbolFileDWARF::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit)
// Just a normal DWARF file whose user ID for the compile unit is
// the DWARF offset itself
- DWARFCompileUnit *dwarf_cu = info->GetCompileUnit((dw_offset_t)comp_unit->GetID()).get();
+ DWARFCompileUnit *dwarf_cu = info->GetCompileUnit((dw_offset_t)comp_unit->GetID());
if (dwarf_cu && dwarf_cu->GetUserData() == NULL)
dwarf_cu->SetUserData(comp_unit);
return dwarf_cu;
@@ -958,7 +889,11 @@ SymbolFileDWARF::ParseCompileUnit (DWARFCompileUnit* dwarf_cu, uint32_t cu_idx)
}
else
{
- if (GetDebugMapSymfile ())
+ if (dwarf_cu->GetSymbolFileDWARF() != this)
+ {
+ return dwarf_cu->GetSymbolFileDWARF()->ParseCompileUnit(dwarf_cu, cu_idx);
+ }
+ else if (GetDebugMapSymfile ())
{
// Let the debug map create the compile unit
cu_sp = m_debug_map_symfile->GetCompileUnit(this);
@@ -969,20 +904,18 @@ SymbolFileDWARF::ParseCompileUnit (DWARFCompileUnit* dwarf_cu, uint32_t cu_idx)
ModuleSP module_sp (m_obj_file->GetModule());
if (module_sp)
{
- const DWARFDebugInfoEntry * cu_die = dwarf_cu->GetCompileUnitDIEOnly ();
+ const DWARFDIE cu_die = dwarf_cu->GetCompileUnitDIEOnly ();
if (cu_die)
{
- FileSpec cu_file_spec{cu_die->GetName(this, dwarf_cu), false};
+ FileSpec cu_file_spec{cu_die.GetName(), false};
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())
{
- // DWARF2/3 suggests the form hostname:pathname for compilation directory.
- // Remove the host part if present.
- const char *cu_comp_dir{cu_die->GetAttributeValueAsString(this, dwarf_cu, DW_AT_comp_dir, nullptr)};
- cu_file_spec.PrependPathComponent(removeHostnameFromPathname(cu_comp_dir));
+ 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;
@@ -990,13 +923,15 @@ SymbolFileDWARF::ParseCompileUnit (DWARFCompileUnit* dwarf_cu, uint32_t cu_idx)
cu_file_spec.SetFile(remapped_file, false);
}
- LanguageType cu_language = DWARFCompileUnit::LanguageTypeFromDWARF(cu_die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_language, 0));
+ LanguageType cu_language = DWARFCompileUnit::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,
- MakeUserID(dwarf_cu->GetOffset()),
- cu_language));
+ dwarf_cu->GetID(),
+ cu_language,
+ is_optimized));
if (cu_sp)
{
// If we just created a compile unit with an invalid file spec, try and get the
@@ -1053,137 +988,20 @@ SymbolFileDWARF::ParseCompileUnitAtIndex(uint32_t cu_idx)
}
Function *
-SymbolFileDWARF::ParseCompileUnitFunction (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die)
+SymbolFileDWARF::ParseCompileUnitFunction (const SymbolContext& sc, const DWARFDIE &die)
{
- DWARFDebugRanges::RangeList func_ranges;
- const char *name = NULL;
- const char *mangled = NULL;
- 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;
-
- assert (die->Tag() == DW_TAG_subprogram);
-
- if (die->Tag() != DW_TAG_subprogram)
- return NULL;
-
- if (die->GetDIENamesAndRanges (this,
- dwarf_cu,
- name,
- mangled,
- func_ranges,
- decl_file,
- decl_line,
- decl_column,
- call_file,
- call_line,
- call_column,
- &frame_base))
+ if (die.IsValid())
{
- // Union of all ranges in the function DIE (if the function is discontiguous)
- AddressRange func_range;
- lldb::addr_t lowest_func_addr = func_ranges.GetMinRangeBase (0);
- lldb::addr_t highest_func_addr = func_ranges.GetMaxRangeEnd (0);
- if (lowest_func_addr != LLDB_INVALID_ADDRESS && lowest_func_addr <= highest_func_addr)
- {
- ModuleSP module_sp (m_obj_file->GetModule());
- func_range.GetBaseAddress().ResolveAddressUsingFileSections (lowest_func_addr, module_sp->GetSectionList());
- if (func_range.GetBaseAddress().IsValid())
- func_range.SetByteSize(highest_func_addr - lowest_func_addr);
- }
+ TypeSystem *type_system = GetTypeSystemForLanguage(die.GetCU()->GetLanguageType());
- if (func_range.GetBaseAddress().IsValid())
+ if (type_system)
{
- Mangled func_name;
- if (mangled)
- func_name.SetValue(ConstString(mangled), true);
- else if (die->GetParent()->Tag() == DW_TAG_compile_unit &&
- LanguageRuntime::LanguageIsCPlusPlus(dwarf_cu->GetLanguageType()) &&
- 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 "main" as its name is
- // never mangled.
- bool is_static = false;
- bool is_variadic = false;
- unsigned type_quals = 0;
- std::vector<ClangASTType> param_types;
- std::vector<clang::ParmVarDecl*> param_decls;
- const DWARFDebugInfoEntry *decl_ctx_die = NULL;
- DWARFDeclContext decl_ctx;
- StreamString sstr;
-
- die->GetDWARFDeclContext(this, dwarf_cu, decl_ctx);
- sstr << decl_ctx.GetQualifiedName();
-
- clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE(dwarf_cu,
- die,
- &decl_ctx_die);
- ParseChildParameters(sc,
- containing_decl_ctx,
- dwarf_cu,
- die,
- true,
- is_static,
- is_variadic,
- param_types,
- param_decls,
- type_quals);
- sstr << "(";
- for (size_t i = 0; i < param_types.size(); i++)
- {
- if (i > 0)
- sstr << ", ";
- sstr << param_types[i].GetTypeName();
- }
- if (is_variadic)
- sstr << ", ...";
- sstr << ")";
- if (type_quals & clang::Qualifiers::Const)
- sstr << " const";
-
- func_name.SetValue(ConstString(sstr.GetData()), false);
- }
- else
- func_name.SetValue(ConstString(name), false);
-
- FunctionSP func_sp;
- std::unique_ptr<Declaration> decl_ap;
- if (decl_file != 0 || decl_line != 0 || decl_column != 0)
- decl_ap.reset(new Declaration (sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file),
- decl_line,
- decl_column));
-
- // Supply the type _only_ if it has already been parsed
- Type *func_type = m_die_to_type.lookup (die);
-
- assert(func_type == NULL || func_type != DIE_IS_BEING_PARSED);
-
- if (FixupAddress (func_range.GetBaseAddress()))
- {
- const user_id_t func_user_id = MakeUserID(die->GetOffset());
- func_sp.reset(new Function (sc.comp_unit,
- MakeUserID(func_user_id), // UserID is the DIE offset
- MakeUserID(func_user_id),
- func_name,
- func_type,
- func_range)); // first address range
-
- if (func_sp.get() != NULL)
- {
- if (frame_base.IsValid())
- func_sp->GetFrameBaseExpression() = frame_base;
- sc.comp_unit->AddFunction(func_sp);
- return func_sp.get();
- }
- }
+ DWARFASTParser *dwarf_ast = type_system->GetDWARFParser();
+ if (dwarf_ast)
+ return dwarf_ast->ParseFunctionFromDWARF(sc, die);
}
}
- return NULL;
+ return nullptr;
}
bool
@@ -1203,12 +1021,9 @@ SymbolFileDWARF::ParseCompileUnitLanguage (const SymbolContext& sc)
assert (sc.comp_unit);
DWARFCompileUnit* dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
if (dwarf_cu)
- {
- const DWARFDebugInfoEntry *die = dwarf_cu->GetCompileUnitDIEOnly();
- if (die)
- return DWARFCompileUnit::LanguageTypeFromDWARF(die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_language, 0));
- }
- return eLanguageTypeUnknown;
+ return dwarf_cu->GetLanguageType();
+ else
+ return eLanguageTypeUnknown;
}
size_t
@@ -1224,10 +1039,10 @@ SymbolFileDWARF::ParseCompileUnitFunctions(const SymbolContext &sc)
size_t func_idx;
for (func_idx = 0; func_idx < num_functions; ++func_idx)
{
- const DWARFDebugInfoEntry *die = function_dies.GetDIEPtrAtIndex(func_idx);
- if (sc.comp_unit->FindFunctionByUID (MakeUserID(die->GetOffset())).get() == NULL)
+ DWARFDIE die = function_dies.GetDIEAtIndex(func_idx);
+ if (sc.comp_unit->FindFunctionByUID (die.GetID()).get() == NULL)
{
- if (ParseCompileUnitFunction(sc, dwarf_cu, die))
+ if (ParseCompileUnitFunction(sc, die))
++functions_added;
}
}
@@ -1243,17 +1058,13 @@ SymbolFileDWARF::ParseCompileUnitSupportFiles (const SymbolContext& sc, FileSpec
DWARFCompileUnit* dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
if (dwarf_cu)
{
- const DWARFDebugInfoEntry * cu_die = dwarf_cu->GetCompileUnitDIEOnly();
+ const DWARFDIE cu_die = dwarf_cu->GetCompileUnitDIEOnly();
if (cu_die)
{
- const char * cu_comp_dir = cu_die->GetAttributeValueAsString(this, dwarf_cu, DW_AT_comp_dir, NULL);
-
- // DWARF2/3 suggests the form hostname:pathname for compilation directory.
- // Remove the host part if present.
- cu_comp_dir = removeHostnameFromPathname(cu_comp_dir);
+ const char * cu_comp_dir = resolveCompDir(cu_die.GetAttributeValueAsString(DW_AT_comp_dir, nullptr));
- dw_offset_t stmt_list = cu_die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_stmt_list, DW_INVALID_OFFSET);
+ const dw_offset_t stmt_list = cu_die.GetAttributeValueAsUnsigned(DW_AT_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.
@@ -1275,9 +1086,9 @@ SymbolFileDWARF::ParseImportedModules (const lldb_private::SymbolContext &sc, st
if (ClangModulesDeclVendor::LanguageSupportsClangModules(sc.comp_unit->GetLanguage()))
{
UpdateExternalModuleListIfNeeded();
- for (const std::pair<uint64_t, const ClangModuleInfo> &external_type_module : m_external_type_modules)
+ for (const auto &pair : m_external_type_modules)
{
- imported_modules.push_back(external_type_module.second.m_name);
+ imported_modules.push_back(pair.first);
}
}
}
@@ -1288,6 +1099,7 @@ struct ParseDWARFLineTableCallbackInfo
{
LineTable* line_table;
std::unique_ptr<LineSequence> sequence_ap;
+ lldb::addr_t addr_mask;
};
//----------------------------------------------------------------------
@@ -1317,7 +1129,7 @@ ParseDWARFLineTableCallback(dw_offset_t offset, const DWARFDebugLine::State& sta
assert(info->sequence_ap.get());
}
line_table->AppendLineEntryToSequence (info->sequence_ap.get(),
- state.address,
+ state.address & info->addr_mask,
state.line,
state.column,
state.file,
@@ -1346,10 +1158,10 @@ SymbolFileDWARF::ParseCompileUnitLineTable (const SymbolContext &sc)
DWARFCompileUnit* dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
if (dwarf_cu)
{
- const DWARFDebugInfoEntry *dwarf_cu_die = dwarf_cu->GetCompileUnitDIEOnly();
+ const DWARFDIE dwarf_cu_die = dwarf_cu->GetCompileUnitDIEOnly();
if (dwarf_cu_die)
{
- const dw_offset_t cu_line_offset = dwarf_cu_die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_stmt_list, DW_INVALID_OFFSET);
+ const dw_offset_t cu_line_offset = 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(sc.comp_unit));
@@ -1357,6 +1169,28 @@ SymbolFileDWARF::ParseCompileUnitLineTable (const SymbolContext &sc)
{
ParseDWARFLineTableCallbackInfo info;
info.line_table = line_table_ap.get();
+
+ /*
+ * MIPS:
+ * The SymbolContext may not have a valid target, thus we may not be able
+ * to call Address::GetOpcodeLoadAddress() which would clear the bit #0
+ * for MIPS. Use ArchSpec to clear the bit #0.
+ */
+ ArchSpec arch;
+ GetObjectFile()->GetArchitecture(arch);
+ switch (arch.GetMachine())
+ {
+ case llvm::Triple::mips:
+ case llvm::Triple::mipsel:
+ case llvm::Triple::mips64:
+ case llvm::Triple::mips64el:
+ info.addr_mask = ~((lldb::addr_t)1);
+ break;
+ default:
+ info.addr_mask = ~((lldb::addr_t)0);
+ break;
+ }
+
lldb::offset_t offset = cu_line_offset;
DWARFDebugLine::ParseStatementTable(get_debug_line_data(), &offset, ParseDWARFLineTableCallback, &info);
if (m_debug_map_symfile)
@@ -1379,21 +1213,63 @@ SymbolFileDWARF::ParseCompileUnitLineTable (const SymbolContext &sc)
return false;
}
+lldb_private::DebugMacrosSP
+SymbolFileDWARF::ParseDebugMacros(lldb::offset_t *offset)
+{
+ auto iter = m_debug_macros_map.find(*offset);
+ if (iter != m_debug_macros_map.end())
+ return iter->second;
+
+ const DWARFDataExtractor &debug_macro_data = get_debug_macro_data();
+ if (debug_macro_data.GetByteSize() == 0)
+ return DebugMacrosSP();
+
+ lldb_private::DebugMacrosSP debug_macros_sp(new lldb_private::DebugMacros());
+ m_debug_macros_map[*offset] = debug_macros_sp;
+
+ 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);
+
+ return debug_macros_sp;
+}
+
+bool
+SymbolFileDWARF::ParseCompileUnitDebugMacros(const SymbolContext& sc)
+{
+ assert (sc.comp_unit);
+
+ DWARFCompileUnit* dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
+ if (dwarf_cu == nullptr)
+ return false;
+
+ const DWARFDIE dwarf_cu_die = dwarf_cu->GetCompileUnitDIEOnly();
+ if (!dwarf_cu_die)
+ return false;
+
+ lldb::offset_t sect_offset = dwarf_cu_die.GetAttributeValueAsUnsigned(DW_AT_macros, DW_INVALID_OFFSET);
+ if (sect_offset == DW_INVALID_OFFSET)
+ sect_offset = dwarf_cu_die.GetAttributeValueAsUnsigned(DW_AT_GNU_macros, DW_INVALID_OFFSET);
+ if (sect_offset == DW_INVALID_OFFSET)
+ return false;
+
+ sc.comp_unit->SetDebugMacros(ParseDebugMacros(&sect_offset));
+
+ return true;
+}
+
size_t
-SymbolFileDWARF::ParseFunctionBlocks
-(
- const SymbolContext& sc,
- Block *parent_block,
- DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *die,
- addr_t subprogram_low_pc,
- uint32_t depth
-)
+SymbolFileDWARF::ParseFunctionBlocks (const SymbolContext& sc,
+ Block *parent_block,
+ const DWARFDIE &orig_die,
+ addr_t subprogram_low_pc,
+ uint32_t depth)
{
size_t blocks_added = 0;
- while (die != NULL)
+ DWARFDIE die = orig_die;
+ while (die)
{
- dw_tag_t tag = die->Tag();
+ dw_tag_t tag = die.Tag();
switch (tag)
{
@@ -1415,11 +1291,11 @@ SymbolFileDWARF::ParseFunctionBlocks
}
else
{
- BlockSP block_sp(new Block (MakeUserID(die->GetOffset())));
+ BlockSP block_sp(new Block (die.GetID()));
parent_block->AddChild(block_sp);
block = block_sp.get();
}
- DWARFDebugRanges::RangeList ranges;
+ DWARFRangeList ranges;
const char *name = NULL;
const char *mangled_name = NULL;
@@ -1429,13 +1305,11 @@ SymbolFileDWARF::ParseFunctionBlocks
int call_file = 0;
int call_line = 0;
int call_column = 0;
- if (die->GetDIENamesAndRanges (this,
- dwarf_cu,
- name,
- mangled_name,
- ranges,
- decl_file, decl_line, decl_column,
- call_file, call_line, call_column))
+ if (die.GetDIENamesAndRanges (name,
+ mangled_name,
+ ranges,
+ decl_file, decl_line, decl_column,
+ call_file, call_line, call_column, nullptr))
{
if (tag == DW_TAG_subprogram)
{
@@ -1461,7 +1335,7 @@ SymbolFileDWARF::ParseFunctionBlocks
const size_t num_ranges = ranges.GetSize();
for (size_t i = 0; i<num_ranges; ++i)
{
- const DWARFDebugRanges::Range &range = ranges.GetEntryRef (i);
+ const DWARFRangeList::Entry &range = ranges.GetEntryRef (i);
const addr_t range_base = range.GetRangeBase();
if (range_base >= subprogram_low_pc)
block->AddRange(Block::Range (range_base - subprogram_low_pc, range.GetByteSize()));
@@ -1493,12 +1367,11 @@ SymbolFileDWARF::ParseFunctionBlocks
++blocks_added;
- if (die->HasChildren())
+ if (die.HasChildren())
{
blocks_added += ParseFunctionBlocks (sc,
block,
- dwarf_cu,
- die->GetFirstChild(),
+ die.GetFirstChild(),
subprogram_low_pc,
depth + 1);
}
@@ -1514,278 +1387,21 @@ SymbolFileDWARF::ParseFunctionBlocks
// DW_TAG_subprogram DIE
if (depth == 0)
- die = NULL;
+ die.Clear();
else
- die = die->GetSibling();
+ die = die.GetSibling();
}
return blocks_added;
}
bool
-SymbolFileDWARF::ParseTemplateDIE (DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *die,
- ClangASTContext::TemplateParameterInfos &template_param_infos)
-{
- const dw_tag_t tag = die->Tag();
-
- switch (tag)
- {
- case DW_TAG_template_type_parameter:
- case DW_TAG_template_value_parameter:
- {
- const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize(), dwarf_cu->IsDWARF64());
-
- DWARFDebugInfoEntry::Attributes attributes;
- const size_t num_attributes = die->GetAttributes (this,
- dwarf_cu,
- fixed_form_sizes,
- attributes);
- const char *name = NULL;
- Type *lldb_type = NULL;
- ClangASTType clang_type;
- uint64_t uval64 = 0;
- bool uval64_valid = false;
- if (num_attributes > 0)
- {
- DWARFFormValue form_value;
- for (size_t i=0; i<num_attributes; ++i)
- {
- const dw_attr_t attr = attributes.AttributeAtIndex(i);
-
- switch (attr)
- {
- case DW_AT_name:
- if (attributes.ExtractFormValueAtIndex(this, i, form_value))
- name = form_value.AsCString(&get_debug_str_data());
- break;
-
- case DW_AT_type:
- if (attributes.ExtractFormValueAtIndex(this, i, form_value))
- {
- const dw_offset_t type_die_offset = form_value.Reference();
- lldb_type = ResolveTypeUID(type_die_offset);
- if (lldb_type)
- clang_type = lldb_type->GetClangForwardType();
- }
- break;
-
- case DW_AT_const_value:
- if (attributes.ExtractFormValueAtIndex(this, i, form_value))
- {
- uval64_valid = true;
- uval64 = form_value.Unsigned();
- }
- break;
- default:
- break;
- }
- }
-
- clang::ASTContext *ast = GetClangASTContext().getASTContext();
- if (!clang_type)
- clang_type = GetClangASTContext().GetBasicType(eBasicTypeVoid);
-
- if (clang_type)
- {
- bool is_signed = false;
- if (name && name[0])
- template_param_infos.names.push_back(name);
- else
- template_param_infos.names.push_back(NULL);
-
- if (tag == DW_TAG_template_value_parameter &&
- lldb_type != NULL &&
- clang_type.IsIntegerType (is_signed) &&
- uval64_valid)
- {
- llvm::APInt apint (lldb_type->GetByteSize() * 8, uval64, is_signed);
- template_param_infos.args.push_back (clang::TemplateArgument (*ast,
- llvm::APSInt(apint),
- clang_type.GetQualType()));
- }
- else
- {
- template_param_infos.args.push_back (clang::TemplateArgument (clang_type.GetQualType()));
- }
- }
- else
- {
- return false;
- }
-
- }
- }
- return true;
-
- default:
- break;
- }
- return false;
-}
-
-bool
-SymbolFileDWARF::ParseTemplateParameterInfos (DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *parent_die,
- ClangASTContext::TemplateParameterInfos &template_param_infos)
-{
-
- if (parent_die == NULL)
- return false;
-
- Args template_parameter_names;
- for (const DWARFDebugInfoEntry *die = parent_die->GetFirstChild();
- die != NULL;
- die = die->GetSibling())
- {
- const dw_tag_t tag = die->Tag();
-
- switch (tag)
- {
- case DW_TAG_template_type_parameter:
- case DW_TAG_template_value_parameter:
- ParseTemplateDIE (dwarf_cu, die, template_param_infos);
- break;
-
- default:
- break;
- }
- }
- if (template_param_infos.args.empty())
- return false;
- return template_param_infos.args.size() == template_param_infos.names.size();
-}
-
-clang::ClassTemplateDecl *
-SymbolFileDWARF::ParseClassTemplateDecl (clang::DeclContext *decl_ctx,
- lldb::AccessType access_type,
- const char *parent_name,
- int tag_decl_kind,
- const ClangASTContext::TemplateParameterInfos &template_param_infos)
-{
- if (template_param_infos.IsValid())
- {
- std::string template_basename(parent_name);
- template_basename.erase (template_basename.find('<'));
- ClangASTContext &ast = GetClangASTContext();
-
- return ast.CreateClassTemplateDecl (decl_ctx,
- access_type,
- template_basename.c_str(),
- tag_decl_kind,
- template_param_infos);
- }
- return NULL;
-}
-
-class SymbolFileDWARF::DelayedAddObjCClassProperty
-{
-public:
- DelayedAddObjCClassProperty
- (
- const ClangASTType &class_opaque_type,
- const char *property_name,
- const ClangASTType &property_opaque_type, // The property type is only required if you don't have an ivar decl
- clang::ObjCIvarDecl *ivar_decl,
- const char *property_setter_name,
- const char *property_getter_name,
- uint32_t property_attributes,
- const ClangASTMetadata *metadata
- ) :
- m_class_opaque_type (class_opaque_type),
- m_property_name (property_name),
- m_property_opaque_type (property_opaque_type),
- m_ivar_decl (ivar_decl),
- 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;
- }
- }
-
- DelayedAddObjCClassProperty (const DelayedAddObjCClassProperty &rhs)
- {
- *this = rhs;
- }
-
- DelayedAddObjCClassProperty& operator= (const DelayedAddObjCClassProperty &rhs)
- {
- m_class_opaque_type = rhs.m_class_opaque_type;
- m_property_name = rhs.m_property_name;
- m_property_opaque_type = rhs.m_property_opaque_type;
- m_ivar_decl = rhs.m_ivar_decl;
- m_property_setter_name = rhs.m_property_setter_name;
- 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;
- }
- return *this;
- }
-
- bool
- Finalize()
- {
- return m_class_opaque_type.AddObjCClassProperty (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());
- }
-private:
- ClangASTType m_class_opaque_type;
- const char *m_property_name;
- ClangASTType m_property_opaque_type;
- clang::ObjCIvarDecl *m_ivar_decl;
- const char *m_property_setter_name;
- const char *m_property_getter_name;
- uint32_t m_property_attributes;
- std::unique_ptr<ClangASTMetadata> m_metadata_ap;
-};
-
-struct BitfieldInfo
-{
- uint64_t bit_size;
- uint64_t bit_offset;
-
- BitfieldInfo () :
- bit_size (LLDB_INVALID_ADDRESS),
- bit_offset (LLDB_INVALID_ADDRESS)
- {
- }
-
- void
- Clear()
- {
- bit_size = LLDB_INVALID_ADDRESS;
- bit_offset = LLDB_INVALID_ADDRESS;
- }
-
- bool IsValid ()
- {
- return (bit_size != LLDB_INVALID_ADDRESS) &&
- (bit_offset != LLDB_INVALID_ADDRESS);
- }
-};
-
-
-bool
-SymbolFileDWARF::ClassOrStructIsVirtual (DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *parent_die)
+SymbolFileDWARF::ClassOrStructIsVirtual (const DWARFDIE &parent_die)
{
if (parent_die)
{
- for (const DWARFDebugInfoEntry *die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling())
+ for (DWARFDIE die = parent_die.GetFirstChild(); die; die = die.GetSibling())
{
- dw_tag_t tag = die->Tag();
+ dw_tag_t tag = die.Tag();
bool check_virtuality = false;
switch (tag)
{
@@ -1798,7 +1414,7 @@ SymbolFileDWARF::ClassOrStructIsVirtual (DWARFCompileUnit* dwarf_cu,
}
if (check_virtuality)
{
- if (die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_virtuality, 0) != 0)
+ if (die.GetAttributeValueAsUnsigned(DW_AT_virtuality, 0) != 0)
return true;
}
}
@@ -1806,602 +1422,79 @@ SymbolFileDWARF::ClassOrStructIsVirtual (DWARFCompileUnit* dwarf_cu,
return false;
}
-size_t
-SymbolFileDWARF::ParseChildMembers
-(
- const SymbolContext& sc,
- DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *parent_die,
- ClangASTType &class_clang_type,
- const LanguageType class_language,
- std::vector<clang::CXXBaseSpecifier *>& base_classes,
- std::vector<int>& member_accessibilities,
- DWARFDIECollection& member_function_dies,
- DelayedPropertyList& delayed_properties,
- AccessType& default_accessibility,
- bool &is_a_class,
- LayoutInfo &layout_info
-)
+void
+SymbolFileDWARF::ParseDeclsForContext (CompilerDeclContext decl_ctx)
{
- if (parent_die == NULL)
- return 0;
+ TypeSystem *type_system = decl_ctx.GetTypeSystem();
+ DWARFASTParser *ast_parser = type_system->GetDWARFParser();
+ std::vector<DWARFDIE> decl_ctx_die_list = ast_parser->GetDIEForDeclContext(decl_ctx);
- size_t count = 0;
- const DWARFDebugInfoEntry *die;
- const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize(), dwarf_cu->IsDWARF64());
- uint32_t member_idx = 0;
- BitfieldInfo last_field_info;
- ModuleSP module = GetObjectFile()->GetModule();
+ for (DWARFDIE decl_ctx_die : decl_ctx_die_list)
+ for (DWARFDIE decl = decl_ctx_die.GetFirstChild(); decl; decl = decl.GetSibling())
+ ast_parser->GetDeclForUIDFromDWARF(decl);
+}
- for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling())
+CompilerDecl
+SymbolFileDWARF::GetDeclForUID (lldb::user_id_t type_uid)
+{
+ if (UserIDMatches(type_uid))
{
- dw_tag_t tag = die->Tag();
-
- switch (tag)
+ DWARFDebugInfo* debug_info = DebugInfo();
+ if (debug_info)
{
- case DW_TAG_member:
- case DW_TAG_APPLE_property:
- {
- DWARFDebugInfoEntry::Attributes attributes;
- const size_t num_attributes = die->GetAttributes (this,
- dwarf_cu,
- fixed_form_sizes,
- 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;
- uint32_t prop_attributes = 0;
-
-
- bool is_artificial = false;
- lldb::user_id_t encoding_uid = LLDB_INVALID_UID;
- AccessType accessibility = eAccessNone;
- uint32_t member_byte_offset = UINT32_MAX;
- size_t byte_size = 0;
- size_t bit_offset = 0;
- size_t bit_size = 0;
- bool is_external = false; // On DW_TAG_members, this means the member is static
- uint32_t i;
- for (i=0; i<num_attributes && !is_artificial; ++i)
- {
- const dw_attr_t attr = attributes.AttributeAtIndex(i);
- DWARFFormValue form_value;
- if (attributes.ExtractFormValueAtIndex(this, 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(&get_debug_str_data()); break;
- case DW_AT_type: encoding_uid = form_value.Reference(); break;
- case DW_AT_bit_offset: bit_offset = form_value.Unsigned(); break;
- case DW_AT_bit_size: bit_size = form_value.Unsigned(); break;
- case DW_AT_byte_size: byte_size = form_value.Unsigned(); break;
- case DW_AT_data_member_location:
- if (form_value.BlockData())
- {
- Value initialValue(0);
- Value memberOffset(0);
- const DWARFDataExtractor& debug_info_data = get_debug_info_data();
- uint32_t block_length = form_value.Unsigned();
- uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart();
- if (DWARFExpression::Evaluate(NULL, // ExecutionContext *
- NULL, // ClangExpressionVariableList *
- NULL, // ClangExpressionDeclMap *
- NULL, // RegisterContext *
- module,
- debug_info_data,
- block_offset,
- block_length,
- eRegisterKindDWARF,
- &initialValue,
- memberOffset,
- NULL))
- {
- member_byte_offset = memberOffset.ResolveValue(NULL).UInt();
- }
- }
- else
- {
- // With DWARF 3 and later, if the value is an integer constant,
- // this form value is the offset in bytes from the beginning
- // of the containing entity.
- member_byte_offset = form_value.Unsigned();
- }
- 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_APPLE_property_name: prop_name = form_value.AsCString(&get_debug_str_data()); break;
- case DW_AT_APPLE_property_getter: prop_getter_name = form_value.AsCString(&get_debug_str_data()); break;
- case DW_AT_APPLE_property_setter: prop_setter_name = form_value.AsCString(&get_debug_str_data()); break;
- case DW_AT_APPLE_property_attribute: prop_attributes = form_value.Unsigned(); break;
- case DW_AT_external: is_external = form_value.Boolean(); break;
-
- default:
- case DW_AT_declaration:
- case DW_AT_description:
- case DW_AT_mutable:
- case DW_AT_visibility:
- case DW_AT_sibling:
- break;
- }
- }
- }
-
- if (prop_name)
- {
- ConstString fixed_getter;
- ConstString fixed_setter;
-
- // Check if the property getter/setter were provided as full
- // names. We want basenames, so we extract them.
-
- if (prop_getter_name && prop_getter_name[0] == '-')
- {
- ObjCLanguageRuntime::MethodName prop_getter_method(prop_getter_name, true);
- prop_getter_name = prop_getter_method.GetSelector().GetCString();
- }
-
- if (prop_setter_name && prop_setter_name[0] == '-')
- {
- ObjCLanguageRuntime::MethodName prop_setter_method(prop_setter_name, true);
- prop_setter_name = prop_setter_method.GetSelector().GetCString();
- }
-
- // If the names haven't been provided, they need to be
- // filled in.
-
- if (!prop_getter_name)
- {
- prop_getter_name = prop_name;
- }
- if (!prop_setter_name && prop_name[0] && !(prop_attributes & DW_APPLE_PROPERTY_readonly))
- {
- StreamString ss;
-
- ss.Printf("set%c%s:",
- toupper(prop_name[0]),
- &prop_name[1]);
-
- fixed_setter.SetCString(ss.GetData());
- prop_setter_name = fixed_setter.GetCString();
- }
- }
-
- // Clang has a DWARF generation bug where sometimes it
- // represents fields that are references with bad byte size
- // and bit size/offset information such as:
- //
- // DW_AT_byte_size( 0x00 )
- // DW_AT_bit_size( 0x40 )
- // DW_AT_bit_offset( 0xffffffffffffffc0 )
- //
- // So check the bit offset to make sure it is sane, and if
- // the values are not sane, remove them. If we don't do this
- // then we will end up with a crash if we try to use this
- // type in an expression when clang becomes unhappy with its
- // recycled debug info.
-
- if (bit_offset > 128)
- {
- bit_size = 0;
- bit_offset = 0;
- }
-
- // FIXME: Make Clang ignore Objective-C accessibility for expressions
- if (class_language == eLanguageTypeObjC ||
- class_language == eLanguageTypeObjC_plus_plus)
- accessibility = eAccessNone;
-
- if (member_idx == 0 && !is_artificial && name && (strstr (name, "_vptr$") == name))
- {
- // Not all compilers will mark the vtable pointer
- // member as artificial (llvm-gcc). We can't have
- // the virtual members in our classes otherwise it
- // throws off all child offsets since we end up
- // having and extra pointer sized member in our
- // class layouts.
- is_artificial = true;
- }
-
- // Handle static members
- if (is_external && member_byte_offset == UINT32_MAX)
- {
- Type *var_type = ResolveTypeUID(encoding_uid);
-
- if (var_type)
- {
- if (accessibility == eAccessNone)
- accessibility = eAccessPublic;
- class_clang_type.AddVariableToRecordType (name,
- var_type->GetClangLayoutType(),
- accessibility);
- }
- break;
- }
-
- if (is_artificial == false)
- {
- Type *member_type = ResolveTypeUID(encoding_uid);
-
- clang::FieldDecl *field_decl = NULL;
- if (tag == DW_TAG_member)
- {
- if (member_type)
- {
- if (accessibility == eAccessNone)
- accessibility = default_accessibility;
- member_accessibilities.push_back(accessibility);
-
- uint64_t field_bit_offset = (member_byte_offset == UINT32_MAX ? 0 : (member_byte_offset * 8));
- if (bit_size > 0)
- {
-
- BitfieldInfo this_field_info;
- this_field_info.bit_offset = field_bit_offset;
- this_field_info.bit_size = bit_size;
-
- /////////////////////////////////////////////////////////////
- // How to locate a field given the DWARF debug information
- //
- // AT_byte_size indicates the size of the word in which the
- // bit offset must be interpreted.
- //
- // AT_data_member_location indicates the byte offset of the
- // word from the base address of the structure.
- //
- // AT_bit_offset indicates how many bits into the word
- // (according to the host endianness) the low-order bit of
- // the field starts. AT_bit_offset can be negative.
- //
- // AT_bit_size indicates the size of the field in bits.
- /////////////////////////////////////////////////////////////
-
- if (byte_size == 0)
- byte_size = member_type->GetByteSize();
-
- if (GetObjectFile()->GetByteOrder() == eByteOrderLittle)
- {
- this_field_info.bit_offset += byte_size * 8;
- this_field_info.bit_offset -= (bit_offset + bit_size);
- }
- else
- {
- this_field_info.bit_offset += bit_offset;
- }
-
- // Update the field bit offset we will report for layout
- field_bit_offset = this_field_info.bit_offset;
-
- // If the member to be emitted did not start on a character boundary and there is
- // empty space between the last field and this one, then we need to emit an
- // anonymous member filling up the space up to its start. There are three cases
- // here:
- //
- // 1 If the previous member ended on a character boundary, then we can emit an
- // anonymous member starting at the most recent character boundary.
- //
- // 2 If the previous member did not end on a character boundary and the distance
- // from the end of the previous member to the current member is less than a
- // word width, then we can emit an anonymous member starting right after the
- // previous member and right before this member.
- //
- // 3 If the previous member did not end on a character boundary and the distance
- // from the end of the previous member to the current member is greater than
- // or equal a word width, then we act as in Case 1.
-
- const uint64_t character_width = 8;
- const uint64_t word_width = 32;
-
- // Objective-C has invalid DW_AT_bit_offset values in older versions
- // of clang, so we have to be careful and only insert unnamed bitfields
- // if we have a new enough clang.
- bool detect_unnamed_bitfields = true;
-
- if (class_language == eLanguageTypeObjC || class_language == eLanguageTypeObjC_plus_plus)
- detect_unnamed_bitfields = dwarf_cu->Supports_unnamed_objc_bitfields ();
-
- if (detect_unnamed_bitfields)
- {
- BitfieldInfo anon_field_info;
-
- if ((this_field_info.bit_offset % character_width) != 0) // not char aligned
- {
- uint64_t last_field_end = 0;
-
- if (last_field_info.IsValid())
- last_field_end = last_field_info.bit_offset + last_field_info.bit_size;
-
- if (this_field_info.bit_offset != last_field_end)
- {
- if (((last_field_end % character_width) == 0) || // case 1
- (this_field_info.bit_offset - last_field_end >= word_width)) // case 3
- {
- anon_field_info.bit_size = this_field_info.bit_offset % character_width;
- anon_field_info.bit_offset = this_field_info.bit_offset - anon_field_info.bit_size;
- }
- else // case 2
- {
- anon_field_info.bit_size = this_field_info.bit_offset - last_field_end;
- anon_field_info.bit_offset = last_field_end;
- }
- }
- }
-
- if (anon_field_info.IsValid())
- {
- clang::FieldDecl *unnamed_bitfield_decl = class_clang_type.AddFieldToRecordType (NULL,
- GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize(eEncodingSint, word_width),
- accessibility,
- anon_field_info.bit_size);
-
- layout_info.field_offsets.insert(
- std::make_pair(unnamed_bitfield_decl, anon_field_info.bit_offset));
- }
- }
- last_field_info = this_field_info;
- }
- else
- {
- last_field_info.Clear();
- }
-
- ClangASTType member_clang_type = member_type->GetClangLayoutType();
-
- {
- // Older versions of clang emit array[0] and array[1] in the same way (<rdar://problem/12566646>).
- // If the current field is at the end of the structure, then there is definitely no room for extra
- // elements and we override the type to array[0].
-
- ClangASTType member_array_element_type;
- uint64_t member_array_size;
- bool member_array_is_incomplete;
-
- if (member_clang_type.IsArrayType(&member_array_element_type,
- &member_array_size,
- &member_array_is_incomplete) &&
- !member_array_is_incomplete)
- {
- uint64_t parent_byte_size = parent_die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_byte_size, UINT64_MAX);
-
- if (member_byte_offset >= parent_byte_size)
- {
- if (member_array_size != 1)
- {
- GetObjectFile()->GetModule()->ReportError ("0x%8.8" PRIx64 ": DW_TAG_member '%s' refers to type 0x%8.8" PRIx64 " which extends beyond the bounds of 0x%8.8" PRIx64,
- MakeUserID(die->GetOffset()),
- name,
- encoding_uid,
- MakeUserID(parent_die->GetOffset()));
- }
-
- member_clang_type = GetClangASTContext().CreateArrayType(member_array_element_type, 0, false);
- }
- }
- }
-
- field_decl = class_clang_type.AddFieldToRecordType (name,
- member_clang_type,
- accessibility,
- bit_size);
-
- GetClangASTContext().SetMetadataAsUserID (field_decl, MakeUserID(die->GetOffset()));
-
- layout_info.field_offsets.insert(std::make_pair(field_decl, field_bit_offset));
- }
- else
- {
- if (name)
- GetObjectFile()->GetModule()->ReportError ("0x%8.8" PRIx64 ": DW_TAG_member '%s' refers to type 0x%8.8" PRIx64 " which was unable to be parsed",
- MakeUserID(die->GetOffset()),
- name,
- encoding_uid);
- else
- GetObjectFile()->GetModule()->ReportError ("0x%8.8" PRIx64 ": DW_TAG_member refers to type 0x%8.8" PRIx64 " which was unable to be parsed",
- MakeUserID(die->GetOffset()),
- encoding_uid);
- }
- }
-
- if (prop_name != NULL && member_type)
- {
- clang::ObjCIvarDecl *ivar_decl = NULL;
-
- if (field_decl)
- {
- ivar_decl = clang::dyn_cast<clang::ObjCIvarDecl>(field_decl);
- assert (ivar_decl != NULL);
- }
-
- ClangASTMetadata metadata;
- metadata.SetUserID (MakeUserID(die->GetOffset()));
- delayed_properties.push_back(DelayedAddObjCClassProperty(class_clang_type,
- prop_name,
- member_type->GetClangLayoutType(),
- ivar_decl,
- prop_setter_name,
- prop_getter_name,
- prop_attributes,
- &metadata));
-
- if (ivar_decl)
- GetClangASTContext().SetMetadataAsUserID (ivar_decl, MakeUserID(die->GetOffset()));
- }
- }
- }
- ++member_idx;
- }
- break;
-
- case DW_TAG_subprogram:
- // Let the type parsing code handle this one for us.
- member_function_dies.Append (die);
- break;
-
- case DW_TAG_inheritance:
+ DWARFDIE die = debug_info->GetDIE(DIERef(type_uid));
+ if (die)
{
- is_a_class = true;
- if (default_accessibility == eAccessNone)
- default_accessibility = eAccessPrivate;
- // TODO: implement DW_TAG_inheritance type parsing
- DWARFDebugInfoEntry::Attributes attributes;
- const size_t num_attributes = die->GetAttributes (this,
- dwarf_cu,
- fixed_form_sizes,
- attributes);
- if (num_attributes > 0)
- {
- Declaration decl;
- DWARFExpression location;
- lldb::user_id_t encoding_uid = LLDB_INVALID_UID;
- AccessType accessibility = default_accessibility;
- bool is_virtual = false;
- bool is_base_of_class = true;
- off_t member_byte_offset = 0;
- uint32_t i;
- for (i=0; i<num_attributes; ++i)
- {
- const dw_attr_t attr = attributes.AttributeAtIndex(i);
- DWARFFormValue form_value;
- if (attributes.ExtractFormValueAtIndex(this, 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_uid = form_value.Reference(); break;
- case DW_AT_data_member_location:
- if (form_value.BlockData())
- {
- Value initialValue(0);
- Value memberOffset(0);
- const DWARFDataExtractor& debug_info_data = get_debug_info_data();
- uint32_t block_length = form_value.Unsigned();
- uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart();
- if (DWARFExpression::Evaluate (NULL,
- NULL,
- NULL,
- NULL,
- module,
- debug_info_data,
- block_offset,
- block_length,
- eRegisterKindDWARF,
- &initialValue,
- memberOffset,
- NULL))
- {
- member_byte_offset = memberOffset.ResolveValue(NULL).UInt();
- }
- }
- else
- {
- // With DWARF 3 and later, if the value is an integer constant,
- // this form value is the offset in bytes from the beginning
- // of the containing entity.
- member_byte_offset = form_value.Unsigned();
- }
- break;
-
- case DW_AT_accessibility:
- accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned());
- break;
-
- case DW_AT_virtuality:
- is_virtual = form_value.Boolean();
- break;
-
- case DW_AT_sibling:
- break;
-
- default:
- break;
- }
- }
- }
-
- Type *base_class_type = ResolveTypeUID(encoding_uid);
- if (base_class_type == NULL)
- {
- GetObjectFile()->GetModule()->ReportError("0x%8.8x: DW_TAG_inheritance failed to resolve the base class at 0x%8.8" PRIx64 " from enclosing type 0x%8.8x. \nPlease file a bug and attach the file at the start of this error message",
- die->GetOffset(),
- encoding_uid,
- parent_die->GetOffset());
- break;
- }
-
- ClangASTType base_class_clang_type = base_class_type->GetClangFullType();
- assert (base_class_clang_type);
- if (class_language == eLanguageTypeObjC)
- {
- class_clang_type.SetObjCSuperClass(base_class_clang_type);
- }
- else
- {
- base_classes.push_back (base_class_clang_type.CreateBaseClassSpecifier (accessibility,
- is_virtual,
- is_base_of_class));
-
- if (is_virtual)
- {
- // Do not specify any offset for virtual inheritance. The DWARF produced by clang doesn't
- // give us a constant offset, but gives us a DWARF expressions that requires an actual object
- // in memory. the DW_AT_data_member_location for a virtual base class looks like:
- // DW_AT_data_member_location( DW_OP_dup, DW_OP_deref, DW_OP_constu(0x00000018), DW_OP_minus, DW_OP_deref, DW_OP_plus )
- // Given this, there is really no valid response we can give to clang for virtual base
- // class offsets, and this should eventually be removed from LayoutRecordType() in the external
- // AST source in clang.
- }
- else
- {
- layout_info.base_offsets.insert(
- std::make_pair(base_class_clang_type.GetAsCXXRecordDecl(),
- clang::CharUnits::fromQuantity(member_byte_offset)));
- }
- }
- }
+ DWARFASTParser *dwarf_ast = die.GetDWARFParser();
+ if (dwarf_ast)
+ return dwarf_ast->GetDeclForUIDFromDWARF(die);
}
- break;
-
- default:
- break;
}
}
-
- return count;
+ return CompilerDecl();
}
-
-clang::DeclContext*
-SymbolFileDWARF::GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid)
+CompilerDeclContext
+SymbolFileDWARF::GetDeclContextForUID (lldb::user_id_t type_uid)
{
- DWARFDebugInfo* debug_info = DebugInfo();
- if (debug_info && UserIDMatches(type_uid))
+ if (UserIDMatches(type_uid))
{
- DWARFCompileUnitSP cu_sp;
- const DWARFDebugInfoEntry* die = debug_info->GetDIEPtr(type_uid, &cu_sp);
- if (die)
- return GetClangDeclContextContainingDIE (cu_sp.get(), die, NULL);
+ DWARFDebugInfo* debug_info = DebugInfo();
+ if (debug_info)
+ {
+ DWARFDIE die = debug_info->GetDIE(DIERef(type_uid));
+ if (die)
+ {
+ DWARFASTParser *dwarf_ast = die.GetDWARFParser();
+ if (dwarf_ast)
+ return dwarf_ast->GetDeclContextForUIDFromDWARF(die);
+ }
+ }
}
- return NULL;
+ return CompilerDeclContext();
}
-clang::DeclContext*
-SymbolFileDWARF::GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid)
+CompilerDeclContext
+SymbolFileDWARF::GetDeclContextContainingUID (lldb::user_id_t type_uid)
{
if (UserIDMatches(type_uid))
- return GetClangDeclContextForDIEOffset (sc, type_uid);
- return NULL;
+ {
+ DWARFDebugInfo* debug_info = DebugInfo();
+ if (debug_info)
+ {
+ DWARFDIE die = debug_info->GetDIE(DIERef(type_uid));
+ if (die)
+ {
+ DWARFASTParser *dwarf_ast = die.GetDWARFParser();
+ if (dwarf_ast)
+ return dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
+ }
+ }
+ }
+ return CompilerDeclContext();
}
+
Type*
SymbolFileDWARF::ResolveTypeUID (lldb::user_id_t type_uid)
{
@@ -2410,418 +1503,143 @@ SymbolFileDWARF::ResolveTypeUID (lldb::user_id_t type_uid)
DWARFDebugInfo* debug_info = DebugInfo();
if (debug_info)
{
- DWARFCompileUnitSP cu_sp;
- const DWARFDebugInfoEntry* type_die = debug_info->GetDIEPtr(type_uid, &cu_sp);
- const bool assert_not_being_parsed = true;
- return ResolveTypeUID (cu_sp.get(), type_die, assert_not_being_parsed);
+ DWARFDIE type_die = debug_info->GetDIE (DIERef(type_uid));
+ if (type_die)
+ {
+ const bool assert_not_being_parsed = true;
+ return ResolveTypeUID (type_die, assert_not_being_parsed);
+ }
}
}
return NULL;
}
Type*
-SymbolFileDWARF::ResolveTypeUID (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* die, bool assert_not_being_parsed)
+SymbolFileDWARF::ResolveTypeUID (const DWARFDIE &die, bool assert_not_being_parsed)
{
- if (die != NULL)
+ if (die)
{
Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
if (log)
GetObjectFile()->GetModule()->LogMessage (log,
"SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s'",
- die->GetOffset(),
- DW_TAG_value_to_name(die->Tag()),
- die->GetName(this, cu));
+ die.GetOffset(),
+ die.GetTagAsCString(),
+ die.GetName());
// We might be coming in in the middle of a type tree (a class
// withing a class, an enum within a class), so parse any needed
// parent DIEs before we get to this one...
- const DWARFDebugInfoEntry *decl_ctx_die = GetDeclContextDIEContainingDIE (cu, die);
- switch (decl_ctx_die->Tag())
+ DWARFDIE decl_ctx_die = GetDeclContextDIEContainingDIE (die);
+ if (decl_ctx_die)
{
- case DW_TAG_structure_type:
- case DW_TAG_union_type:
- case DW_TAG_class_type:
+ if (log)
{
- // Get the type, which could be a forward declaration
- if (log)
- GetObjectFile()->GetModule()->LogMessage (log,
- "SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s' resolve parent forward type for 0x%8.8x",
- die->GetOffset(),
- DW_TAG_value_to_name(die->Tag()),
- die->GetName(this, cu),
- decl_ctx_die->GetOffset());
-//
-// Type *parent_type = ResolveTypeUID (cu, decl_ctx_die, assert_not_being_parsed);
-// if (child_requires_parent_class_union_or_struct_to_be_completed(die->Tag()))
-// {
-// if (log)
-// GetObjectFile()->GetModule()->LogMessage (log,
-// "SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s' resolve parent full type for 0x%8.8x since die is a function",
-// die->GetOffset(),
-// DW_TAG_value_to_name(die->Tag()),
-// die->GetName(this, cu),
-// decl_ctx_die->GetOffset());
-// // Ask the type to complete itself if it already hasn't since if we
-// // want a function (method or static) from a class, the class must
-// // create itself and add it's own methods and class functions.
-// if (parent_type)
-// parent_type->GetClangFullType();
-// }
- }
- break;
+ switch (decl_ctx_die.Tag())
+ {
+ case DW_TAG_structure_type:
+ case DW_TAG_union_type:
+ case DW_TAG_class_type:
+ {
+ // Get the type, which could be a forward declaration
+ if (log)
+ GetObjectFile()->GetModule()->LogMessage (log,
+ "SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s' resolve parent forward type for 0x%8.8x",
+ die.GetOffset(),
+ die.GetTagAsCString(),
+ die.GetName(),
+ decl_ctx_die.GetOffset());
+ }
+ break;
- default:
- break;
+ default:
+ break;
+ }
+ }
}
- return ResolveType (cu, die);
+ return ResolveType (die);
}
return NULL;
}
// This function is used when SymbolFileDWARFDebugMap owns a bunch of
// SymbolFileDWARF objects to detect if this DWARF file is the one that
-// can resolve a clang_type.
+// can resolve a compiler_type.
bool
-SymbolFileDWARF::HasForwardDeclForClangType (const ClangASTType &clang_type)
+SymbolFileDWARF::HasForwardDeclForClangType (const CompilerType &compiler_type)
{
- ClangASTType clang_type_no_qualifiers = clang_type.RemoveFastQualifiers();
- const DWARFDebugInfoEntry* die = m_forward_decl_clang_type_to_die.lookup (clang_type_no_qualifiers.GetOpaqueQualType());
- return die != NULL;
+ CompilerType compiler_type_no_qualifiers = ClangASTContext::RemoveFastQualifiers(compiler_type);
+ if (GetForwardDeclClangTypeToDie().count (compiler_type_no_qualifiers.GetOpaqueQualType()))
+ {
+ return true;
+ }
+ TypeSystem *type_system = compiler_type.GetTypeSystem();
+ if (type_system)
+ {
+ DWARFASTParser *dwarf_ast = type_system->GetDWARFParser();
+ if (dwarf_ast)
+ return dwarf_ast->CanCompleteType(compiler_type);
+ }
+ return false;
}
bool
-SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type)
+SymbolFileDWARF::CompleteType (CompilerType &compiler_type)
{
+ TypeSystem *type_system = compiler_type.GetTypeSystem();
+ if (type_system)
+ {
+ DWARFASTParser *dwarf_ast = type_system->GetDWARFParser();
+ if (dwarf_ast && dwarf_ast->CanCompleteType(compiler_type))
+ return dwarf_ast->CompleteType(compiler_type);
+ }
+
// We have a struct/union/class/enum that needs to be fully resolved.
- ClangASTType clang_type_no_qualifiers = clang_type.RemoveFastQualifiers();
- const DWARFDebugInfoEntry* die = m_forward_decl_clang_type_to_die.lookup (clang_type_no_qualifiers.GetOpaqueQualType());
- if (die == NULL)
+ CompilerType compiler_type_no_qualifiers = ClangASTContext::RemoveFastQualifiers(compiler_type);
+ auto die_it = GetForwardDeclClangTypeToDie().find (compiler_type_no_qualifiers.GetOpaqueQualType());
+ if (die_it == GetForwardDeclClangTypeToDie().end())
{
// We have already resolved this type...
return true;
}
+
+ DWARFDebugInfo* debug_info = DebugInfo();
+ DWARFDIE dwarf_die = debug_info->GetDIE(die_it->getSecond());
+
+ assert(UserIDMatches(die_it->getSecond().GetUID()) && "CompleteType called on the wrong SymbolFile");
+
// Once we start resolving this type, remove it from the forward declaration
// map in case anyone child members or other types require this type to get resolved.
// The type will get resolved when all of the calls to SymbolFileDWARF::ResolveClangOpaqueTypeDefinition
// are done.
- m_forward_decl_clang_type_to_die.erase (clang_type_no_qualifiers.GetOpaqueQualType());
-
- // Disable external storage for this type so we don't get anymore
- // clang::ExternalASTSource queries for this type.
- clang_type.SetHasExternalStorage (false);
-
- DWARFDebugInfo* debug_info = DebugInfo();
+ GetForwardDeclClangTypeToDie().erase (die_it);
- DWARFCompileUnit *dwarf_cu = debug_info->GetCompileUnitContainingDIE (die->GetOffset()).get();
- Type *type = m_die_to_type.lookup (die);
-
- const dw_tag_t tag = die->Tag();
+ Type *type = GetDIEToType().lookup (dwarf_die.GetDIE());
Log *log (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO|DWARF_LOG_TYPE_COMPLETION));
if (log)
GetObjectFile()->GetModule()->LogMessageVerboseBacktrace (log,
"0x%8.8" PRIx64 ": %s '%s' resolving forward declaration...",
- MakeUserID(die->GetOffset()),
- DW_TAG_value_to_name(tag),
+ dwarf_die.GetID(),
+ dwarf_die.GetTagAsCString(),
type->GetName().AsCString());
- assert (clang_type);
- DWARFDebugInfoEntry::Attributes attributes;
-
- switch (tag)
- {
- case DW_TAG_structure_type:
- case DW_TAG_union_type:
- case DW_TAG_class_type:
- {
- LayoutInfo layout_info;
-
- {
- if (die->HasChildren())
- {
- LanguageType class_language = eLanguageTypeUnknown;
- if (clang_type.IsObjCObjectOrInterfaceType())
- {
- class_language = eLanguageTypeObjC;
- // For objective C we don't start the definition when
- // the class is created.
- clang_type.StartTagDeclarationDefinition ();
- }
-
- 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;
- }
-
- SymbolContext sc(GetCompUnitForDWARFCompUnit(dwarf_cu));
- std::vector<clang::CXXBaseSpecifier *> base_classes;
- std::vector<int> member_accessibilities;
- bool is_a_class = false;
- // Parse members and base classes first
- DWARFDIECollection member_function_dies;
-
- DelayedPropertyList delayed_properties;
- ParseChildMembers (sc,
- dwarf_cu,
- die,
- clang_type,
- class_language,
- base_classes,
- 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)
- {
- ResolveType(dwarf_cu, member_function_dies.GetDIEPtrAtIndex(i));
- }
- }
-
- if (class_language == eLanguageTypeObjC)
- {
- ConstString class_name (clang_type.GetTypeName());
- if (class_name)
- {
- DIEArray method_die_offsets;
- if (m_using_apple_tables)
- {
- if (m_apple_objc_ap.get())
- m_apple_objc_ap->FindByName(class_name.GetCString(), method_die_offsets);
- }
- else
- {
- if (!m_indexed)
- Index ();
-
- m_objc_class_selectors_index.Find (class_name, method_die_offsets);
- }
-
- if (!method_die_offsets.empty())
- {
- DWARFDebugInfo* debug_info = DebugInfo();
-
- DWARFCompileUnit* method_cu = NULL;
- const size_t num_matches = method_die_offsets.size();
- for (size_t i=0; i<num_matches; ++i)
- {
- const dw_offset_t die_offset = method_die_offsets[i];
- DWARFDebugInfoEntry *method_die = debug_info->GetDIEPtrWithCompileUnitHint (die_offset, &method_cu);
-
- if (method_die)
- ResolveType (method_cu, method_die);
- else
- {
- if (m_using_apple_tables)
- {
- GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_objc accelerator table had bad die 0x%8.8x for '%s')\n",
- die_offset, class_name.GetCString());
- }
- }
- }
- }
-
- for (DelayedPropertyList::iterator pi = delayed_properties.begin(), pe = delayed_properties.end();
- pi != pe;
- ++pi)
- pi->Finalize();
- }
- }
-
- // If we have a DW_TAG_structure_type instead of a DW_TAG_class_type we
- // need to tell the clang type it is actually a class.
- if (class_language != eLanguageTypeObjC)
- {
- if (is_a_class && tag_decl_kind != clang::TTK_Class)
- clang_type.SetTagTypeKind (clang::TTK_Class);
- }
-
- // Since DW_TAG_structure_type gets used for both classes
- // and structures, we may need to set any DW_TAG_member
- // fields to have a "private" access if none was specified.
- // When we parsed the child members we tracked that actual
- // accessibility value for each DW_TAG_member in the
- // "member_accessibilities" array. If the value for the
- // member is zero, then it was set to the "default_accessibility"
- // which for structs was "public". Below we correct this
- // by setting any fields to "private" that weren't correctly
- // set.
- if (is_a_class && !member_accessibilities.empty())
- {
- // This is a class and all members that didn't have
- // their access specified are private.
- clang_type.SetDefaultAccessForRecordFields (eAccessPrivate,
- &member_accessibilities.front(),
- member_accessibilities.size());
- }
-
- if (!base_classes.empty())
- {
- // Make sure all base classes refer to complete types and not
- // forward declarations. If we don't do this, clang will crash
- // with an assertion in the call to clang_type.SetBaseClassesForClassType()
- bool base_class_error = false;
- for (auto &base_class : base_classes)
- {
- clang::TypeSourceInfo *type_source_info = base_class->getTypeSourceInfo();
- if (type_source_info)
- {
- ClangASTType base_class_type (GetClangASTContext().getASTContext(), type_source_info->getType());
- if (base_class_type.GetCompleteType() == false)
- {
- if (!base_class_error)
- {
- GetObjectFile()->GetModule()->ReportError ("DWARF DIE at 0x%8.8x for class '%s' has a base class '%s' 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(),
- die->GetName(this, dwarf_cu),
- base_class_type.GetTypeName().GetCString(),
- sc.comp_unit ? sc.comp_unit->GetPath().c_str() : "the source file");
- }
- // We have no choice other than to pretend that the base class
- // is complete. If we don't do this, clang will crash when we
- // call setBases() inside of "clang_type.SetBaseClassesForClassType()"
- // below. 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.
- base_class_type.StartTagDeclarationDefinition ();
- base_class_type.CompleteTagDeclarationDefinition ();
- }
- }
- }
- clang_type.SetBaseClassesForClassType (&base_classes.front(),
- base_classes.size());
-
- // Clang will copy each CXXBaseSpecifier in "base_classes"
- // so we have to free them all.
- ClangASTType::DeleteBaseClassSpecifiers (&base_classes.front(),
- base_classes.size());
- }
- }
- }
-
- clang_type.BuildIndirectFields ();
- clang_type.CompleteTagDeclarationDefinition ();
-
- if (!layout_info.field_offsets.empty() ||
- !layout_info.base_offsets.empty() ||
- !layout_info.vbase_offsets.empty() )
- {
- if (type)
- layout_info.bit_size = type->GetByteSize() * 8;
- if (layout_info.bit_size == 0)
- layout_info.bit_size = die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_byte_size, 0) * 8;
-
- clang::CXXRecordDecl *record_decl = clang_type.GetAsCXXRecordDecl();
- if (record_decl)
- {
- if (log)
- {
- GetObjectFile()->GetModule()->LogMessage (log,
- "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) caching layout info for record_decl = %p, bit_size = %" PRIu64 ", alignment = %" PRIu64 ", field_offsets[%u], base_offsets[%u], vbase_offsets[%u])",
- static_cast<void*>(clang_type.GetOpaqueQualType()),
- static_cast<void*>(record_decl),
- layout_info.bit_size,
- layout_info.alignment,
- static_cast<uint32_t>(layout_info.field_offsets.size()),
- static_cast<uint32_t>(layout_info.base_offsets.size()),
- static_cast<uint32_t>(layout_info.vbase_offsets.size()));
-
- uint32_t idx;
- {
- llvm::DenseMap<const clang::FieldDecl *, uint64_t>::const_iterator pos,
- end = layout_info.field_offsets.end();
- for (idx = 0, pos = layout_info.field_offsets.begin(); pos != end; ++pos, ++idx)
- {
- GetObjectFile()->GetModule()->LogMessage(
- log, "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) field[%u] = "
- "{ bit_offset=%u, name='%s' }",
- static_cast<void *>(clang_type.GetOpaqueQualType()), idx,
- static_cast<uint32_t>(pos->second), pos->first->getNameAsString().c_str());
- }
- }
-
- {
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>::const_iterator base_pos,
- base_end = layout_info.base_offsets.end();
- for (idx = 0, base_pos = layout_info.base_offsets.begin(); base_pos != base_end;
- ++base_pos, ++idx)
- {
- GetObjectFile()->GetModule()->LogMessage(
- log, "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) base[%u] "
- "= { byte_offset=%u, name='%s' }",
- clang_type.GetOpaqueQualType(), idx, (uint32_t)base_pos->second.getQuantity(),
- base_pos->first->getNameAsString().c_str());
- }
- }
- {
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>::const_iterator vbase_pos,
- vbase_end = layout_info.vbase_offsets.end();
- for (idx = 0, vbase_pos = layout_info.vbase_offsets.begin(); vbase_pos != vbase_end;
- ++vbase_pos, ++idx)
- {
- GetObjectFile()->GetModule()->LogMessage(
- log, "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) "
- "vbase[%u] = { byte_offset=%u, name='%s' }",
- static_cast<void *>(clang_type.GetOpaqueQualType()), idx,
- static_cast<uint32_t>(vbase_pos->second.getQuantity()),
- vbase_pos->first->getNameAsString().c_str());
- }
- }
- }
- m_record_decl_to_layout_map.insert(std::make_pair(record_decl, layout_info));
- }
- }
- }
-
- return (bool)clang_type;
-
- case DW_TAG_enumeration_type:
- clang_type.StartTagDeclarationDefinition ();
- if (die->HasChildren())
- {
- SymbolContext sc(GetCompUnitForDWARFCompUnit(dwarf_cu));
- bool is_signed = false;
- clang_type.IsIntegerType(is_signed);
- ParseChildEnumerators(sc, clang_type, is_signed, type->GetByteSize(), dwarf_cu, die);
- }
- clang_type.CompleteTagDeclarationDefinition ();
- return (bool)clang_type;
-
- default:
- assert(false && "not a forward clang type decl!");
- break;
- }
+ assert (compiler_type);
+ DWARFASTParser *dwarf_ast = dwarf_die.GetDWARFParser();
+ if (dwarf_ast)
+ return dwarf_ast->CompleteTypeFromDWARF (dwarf_die, type, compiler_type);
return false;
}
Type*
-SymbolFileDWARF::ResolveType (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* type_die, bool assert_not_being_parsed)
+SymbolFileDWARF::ResolveType (const DWARFDIE &die, bool assert_not_being_parsed, bool resolve_function_context)
{
- if (type_die != NULL)
+ if (die)
{
- Type *type = m_die_to_type.lookup (type_die);
+ Type *type = GetDIEToType().lookup (die.GetDIE());
if (type == NULL)
- type = GetTypeForDIE (dwarf_cu, type_die).get();
+ type = GetTypeForDIE (die, resolve_function_context).get();
if (assert_not_being_parsed)
{
@@ -2829,15 +1647,15 @@ SymbolFileDWARF::ResolveType (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEn
return type;
GetObjectFile()->GetModule()->ReportError ("Parsing a die that is being parsed die: 0x%8.8x: %s %s",
- type_die->GetOffset(),
- DW_TAG_value_to_name(type_die->Tag()),
- type_die->GetName(this, dwarf_cu));
+ die.GetOffset(),
+ die.GetTagAsCString(),
+ die.GetName());
}
else
return type;
}
- return NULL;
+ return nullptr;
}
CompileUnit*
@@ -2853,26 +1671,60 @@ SymbolFileDWARF::GetCompUnitForDWARFCompUnit (DWARFCompileUnit* dwarf_cu, uint32
return (CompileUnit*)dwarf_cu->GetUserData();
}
+size_t
+SymbolFileDWARF::GetObjCMethodDIEOffsets (ConstString class_name, DIEArray &method_die_offsets)
+{
+ method_die_offsets.clear();
+ if (m_using_apple_tables)
+ {
+ if (m_apple_objc_ap.get())
+ m_apple_objc_ap->FindByName(class_name.GetCString(), method_die_offsets);
+ }
+ else
+ {
+ if (!m_indexed)
+ Index ();
+
+ m_objc_class_selectors_index.Find (class_name, method_die_offsets);
+ }
+ return method_die_offsets.size();
+}
+
bool
-SymbolFileDWARF::GetFunction (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* func_die, SymbolContext& sc)
+SymbolFileDWARF::GetFunction (const DWARFDIE &die, SymbolContext& sc)
{
sc.Clear(false);
- // Check if the symbol vendor already knows about this compile unit?
- sc.comp_unit = GetCompUnitForDWARFCompUnit(dwarf_cu, UINT32_MAX);
- sc.function = sc.comp_unit->FindFunctionByUID (MakeUserID(func_die->GetOffset())).get();
- if (sc.function == NULL)
- sc.function = ParseCompileUnitFunction(sc, dwarf_cu, func_die);
-
- if (sc.function)
- {
- sc.module_sp = sc.function->CalculateSymbolContextModule();
- return true;
+ if (die)
+ {
+ // Check if the symbol vendor already knows about this compile unit?
+ sc.comp_unit = GetCompUnitForDWARFCompUnit(die.GetCU(), UINT32_MAX);
+
+ sc.function = sc.comp_unit->FindFunctionByUID (die.GetID()).get();
+ if (sc.function == NULL)
+ sc.function = ParseCompileUnitFunction(sc, die);
+
+ if (sc.function)
+ {
+ sc.module_sp = sc.function->CalculateSymbolContextModule();
+ return true;
+ }
}
return false;
}
+lldb::ModuleSP
+SymbolFileDWARF::GetDWOModule (ConstString name)
+{
+ UpdateExternalModuleListIfNeeded();
+ const auto &pos = m_external_type_modules.find(name);
+ if (pos != m_external_type_modules.end())
+ return pos->second;
+ else
+ return lldb::ModuleSP();
+}
+
void
SymbolFileDWARF::UpdateExternalModuleListIfNeeded()
{
@@ -2881,47 +1733,33 @@ SymbolFileDWARF::UpdateExternalModuleListIfNeeded()
m_fetched_external_modules = true;
DWARFDebugInfo * debug_info = DebugInfo();
- debug_info->GetNumCompileUnits();
-
+
const uint32_t num_compile_units = GetNumCompileUnits();
for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx)
{
DWARFCompileUnit* dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
- const DWARFDebugInfoEntry *die = dwarf_cu->GetCompileUnitDIEOnly();
- if (die && die->HasChildren() == false)
+ const DWARFDIE die = dwarf_cu->GetCompileUnitDIEOnly();
+ if (die && die.HasChildren() == false)
{
- const uint64_t name_strp = die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_name, UINT64_MAX);
- const uint64_t dwo_path_strp = die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_GNU_dwo_name, UINT64_MAX);
-
- if (name_strp != UINT64_MAX)
+ const char *name = die.GetAttributeValueAsString(DW_AT_name, nullptr);
+
+ if (name)
{
- if (m_external_type_modules.find(dwo_path_strp) == m_external_type_modules.end())
+ ConstString const_name(name);
+ if (m_external_type_modules.find(const_name) == m_external_type_modules.end())
{
- const char *name = get_debug_str_data().PeekCStr(name_strp);
- const char *dwo_path = get_debug_str_data().PeekCStr(dwo_path_strp);
- if (name || dwo_path)
+ ModuleSP module_sp;
+ const char *dwo_path = die.GetAttributeValueAsString(DW_AT_GNU_dwo_name, nullptr);
+ if (dwo_path)
{
- ModuleSP module_sp;
- if (dwo_path)
- {
- ModuleSpec dwo_module_spec;
- dwo_module_spec.GetFileSpec().SetFile(dwo_path, false);
- dwo_module_spec.GetArchitecture() = m_obj_file->GetModule()->GetArchitecture();
- //printf ("Loading dwo = '%s'\n", dwo_path);
- Error error = ModuleList::GetSharedModule (dwo_module_spec, module_sp, NULL, NULL, NULL);
- }
-
- if (dwo_path_strp != LLDB_INVALID_UID)
- {
- m_external_type_modules[dwo_path_strp] = ClangModuleInfo { ConstString(name), module_sp };
- }
- else
- {
- // This hack should be removed promptly once clang emits both.
- m_external_type_modules[name_strp] = ClangModuleInfo { ConstString(name), module_sp };
- }
+ ModuleSpec dwo_module_spec;
+ dwo_module_spec.GetFileSpec().SetFile(dwo_path, false);
+ dwo_module_spec.GetArchitecture() = m_obj_file->GetModule()->GetArchitecture();
+ //printf ("Loading dwo = '%s'\n", dwo_path);
+ Error error = ModuleList::GetSharedModule (dwo_module_spec, module_sp, NULL, NULL, NULL);
}
+ m_external_type_modules[const_name] = module_sp;
}
}
}
@@ -3025,7 +1863,7 @@ SymbolFileDWARF::ResolveSymbolContext (const Address& so_addr, uint32_t resolve_
else
{
uint32_t cu_idx = DW_INVALID_INDEX;
- DWARFCompileUnit* dwarf_cu = debug_info->GetCompileUnit(cu_offset, &cu_idx).get();
+ DWARFCompileUnit* dwarf_cu = debug_info->GetCompileUnit(cu_offset, &cu_idx);
if (dwarf_cu)
{
sc.comp_unit = GetCompUnitForDWARFCompUnit(dwarf_cu, cu_idx);
@@ -3036,22 +1874,16 @@ SymbolFileDWARF::ResolveSymbolContext (const Address& so_addr, uint32_t resolve_
bool force_check_line_table = false;
if (resolve_scope & (eSymbolContextFunction | eSymbolContextBlock))
{
- DWARFDebugInfoEntry *function_die = NULL;
- DWARFDebugInfoEntry *block_die = NULL;
- if (resolve_scope & eSymbolContextBlock)
- {
- dwarf_cu->LookupAddress(file_vm_addr, &function_die, &block_die);
- }
- else
- {
- dwarf_cu->LookupAddress(file_vm_addr, &function_die, NULL);
- }
-
- if (function_die != NULL)
+ DWARFDIE function_die = dwarf_cu->LookupAddress(file_vm_addr);
+ DWARFDIE block_die;
+ if (function_die)
{
- sc.function = sc.comp_unit->FindFunctionByUID (MakeUserID(function_die->GetOffset())).get();
+ sc.function = sc.comp_unit->FindFunctionByUID (function_die.GetID()).get();
if (sc.function == NULL)
- sc.function = ParseCompileUnitFunction(sc, dwarf_cu, function_die);
+ sc.function = ParseCompileUnitFunction(sc, function_die);
+
+ if (sc.function && (resolve_scope & eSymbolContextBlock))
+ block_die = function_die.LookupDeepestBlock(file_vm_addr);
}
else
{
@@ -3072,10 +1904,10 @@ SymbolFileDWARF::ResolveSymbolContext (const Address& so_addr, uint32_t resolve_
{
Block& block = sc.function->GetBlock (true);
- if (block_die != NULL)
- sc.block = block.FindBlockByID (MakeUserID(block_die->GetOffset()));
+ if (block_die)
+ sc.block = block.FindBlockByID (block_die.GetID());
else
- sc.block = block.FindBlockByID (MakeUserID(function_die->GetOffset()));
+ sc.block = block.FindBlockByID (function_die.GetID());
if (sc.block)
resolved |= eSymbolContextBlock;
}
@@ -3190,25 +2022,26 @@ SymbolFileDWARF::ResolveSymbolContext(const FileSpec& file_spec, uint32_t line,
const lldb::addr_t file_vm_addr = sc.line_entry.range.GetBaseAddress().GetFileAddress();
if (file_vm_addr != LLDB_INVALID_ADDRESS)
{
- DWARFDebugInfoEntry *function_die = NULL;
- DWARFDebugInfoEntry *block_die = NULL;
- dwarf_cu->LookupAddress(file_vm_addr, &function_die, resolve_scope & eSymbolContextBlock ? &block_die : NULL);
-
- if (function_die != NULL)
+ DWARFDIE function_die = dwarf_cu->LookupAddress(file_vm_addr);
+ DWARFDIE block_die;
+ if (function_die)
{
- sc.function = sc.comp_unit->FindFunctionByUID (MakeUserID(function_die->GetOffset())).get();
+ sc.function = sc.comp_unit->FindFunctionByUID (function_die.GetID()).get();
if (sc.function == NULL)
- sc.function = ParseCompileUnitFunction(sc, dwarf_cu, function_die);
+ sc.function = ParseCompileUnitFunction(sc, 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 (block_die != NULL)
- sc.block = block.FindBlockByID (MakeUserID(block_die->GetOffset()));
- else if (function_die != NULL)
- sc.block = block.FindBlockByID (MakeUserID(function_die->GetOffset()));
+ if (block_die)
+ sc.block = block.FindBlockByID (block_die.GetID());
+ else if (function_die)
+ sc.block = block.FindBlockByID (function_die.GetID());
}
}
}
@@ -3255,38 +2088,77 @@ SymbolFileDWARF::Index ()
DWARFDebugInfo* debug_info = DebugInfo();
if (debug_info)
{
- uint32_t cu_idx = 0;
const uint32_t num_compile_units = GetNumCompileUnits();
- for (cu_idx = 0; cu_idx < num_compile_units; ++cu_idx)
+ std::vector<NameToDIE> function_basename_index(num_compile_units);
+ std::vector<NameToDIE> function_fullname_index(num_compile_units);
+ std::vector<NameToDIE> function_method_index(num_compile_units);
+ std::vector<NameToDIE> function_selector_index(num_compile_units);
+ std::vector<NameToDIE> objc_class_selectors_index(num_compile_units);
+ std::vector<NameToDIE> global_index(num_compile_units);
+ std::vector<NameToDIE> type_index(num_compile_units);
+ std::vector<NameToDIE> namespace_index(num_compile_units);
+
+ auto parser_fn = [this,
+ debug_info,
+ &function_basename_index,
+ &function_fullname_index,
+ &function_method_index,
+ &function_selector_index,
+ &objc_class_selectors_index,
+ &global_index,
+ &type_index,
+ &namespace_index](uint32_t cu_idx)
{
DWARFCompileUnit* dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
+ bool clear_dies = dwarf_cu->ExtractDIEsIfNeeded(false) > 1;
+
+ dwarf_cu->Index(function_basename_index[cu_idx],
+ function_fullname_index[cu_idx],
+ function_method_index[cu_idx],
+ function_selector_index[cu_idx],
+ objc_class_selectors_index[cu_idx],
+ global_index[cu_idx],
+ type_index[cu_idx],
+ namespace_index[cu_idx]);
- bool clear_dies = dwarf_cu->ExtractDIEsIfNeeded (false) > 1;
-
- dwarf_cu->Index (cu_idx,
- m_function_basename_index,
- m_function_fullname_index,
- m_function_method_index,
- m_function_selector_index,
- m_objc_class_selectors_index,
- m_global_index,
- m_type_index,
- m_namespace_index);
-
// Keep memory down by clearing DIEs if this generate function
// caused them to be parsed
if (clear_dies)
- dwarf_cu->ClearDIEs (true);
+ dwarf_cu->ClearDIEs(true);
+
+ return cu_idx;
+ };
+
+ TaskRunner<uint32_t> task_runner;
+ for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx)
+ task_runner.AddTask(parser_fn, cu_idx);
+
+ while (true)
+ {
+ std::future<uint32_t> f = task_runner.WaitForNextCompletedTask();
+ if (!f.valid())
+ break;
+ uint32_t cu_idx = f.get();
+
+ m_function_basename_index.Append(function_basename_index[cu_idx]);
+ m_function_fullname_index.Append(function_fullname_index[cu_idx]);
+ m_function_method_index.Append(function_method_index[cu_idx]);
+ m_function_selector_index.Append(function_selector_index[cu_idx]);
+ m_objc_class_selectors_index.Append(objc_class_selectors_index[cu_idx]);
+ m_global_index.Append(global_index[cu_idx]);
+ m_type_index.Append(type_index[cu_idx]);
+ m_namespace_index.Append(namespace_index[cu_idx]);
}
-
- m_function_basename_index.Finalize();
- m_function_fullname_index.Finalize();
- m_function_method_index.Finalize();
- m_function_selector_index.Finalize();
- m_objc_class_selectors_index.Finalize();
- m_global_index.Finalize();
- m_type_index.Finalize();
- m_namespace_index.Finalize();
+
+ TaskPool::RunTasks(
+ [&]() { m_function_basename_index.Finalize(); },
+ [&]() { m_function_fullname_index.Finalize(); },
+ [&]() { m_function_method_index.Finalize(); },
+ [&]() { m_function_selector_index.Finalize(); },
+ [&]() { m_objc_class_selectors_index.Finalize(); },
+ [&]() { m_global_index.Finalize(); },
+ [&]() { m_type_index.Finalize(); },
+ [&]() { m_namespace_index.Finalize(); });
#if defined (ENABLE_DEBUG_PRINTF)
StreamFile s(stdout, false);
@@ -3299,30 +2171,26 @@ SymbolFileDWARF::Index ()
s.Printf("\nObjective C class selectors:\n"); m_objc_class_selectors_index.Dump (&s);
s.Printf("\nGlobals and statics:\n"); m_global_index.Dump (&s);
s.Printf("\nTypes:\n"); m_type_index.Dump (&s);
- s.Printf("\nNamepaces:\n"); m_namespace_index.Dump (&s);
+ s.Printf("\nNamespaces:\n") m_namespace_index.Dump (&s);
#endif
}
}
bool
-SymbolFileDWARF::NamespaceDeclMatchesThisSymbolFile (const ClangNamespaceDecl *namespace_decl)
+SymbolFileDWARF::DeclContextMatchesThisSymbolFile (const lldb_private::CompilerDeclContext *decl_ctx)
{
- if (namespace_decl == NULL)
+ if (decl_ctx == nullptr || !decl_ctx->IsValid())
{
// Invalid namespace decl which means we aren't matching only things
// in this symbol file, so return true to indicate it matches this
// symbol file.
return true;
}
-
- clang::ASTContext *namespace_ast = namespace_decl->GetASTContext();
-
- if (namespace_ast == NULL)
- return true; // No AST in the "namespace_decl", return true since it
- // could then match any symbol file, including this one
- if (namespace_ast == GetClangASTContext().getASTContext())
- return true; // The ASTs match, return true
+ TypeSystem *decl_ctx_type_system = decl_ctx->GetTypeSystem();
+ TypeSystem *type_system = GetTypeSystemForLanguage(decl_ctx_type_system->GetMinimumLanguage(nullptr));
+ if (decl_ctx_type_system == type_system)
+ return true; // The type systems match, return true
// The namespace AST was valid, and it does not match...
Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
@@ -3333,66 +2201,19 @@ SymbolFileDWARF::NamespaceDeclMatchesThisSymbolFile (const ClangNamespaceDecl *n
return false;
}
-bool
-SymbolFileDWARF::DIEIsInNamespace (const ClangNamespaceDecl *namespace_decl,
- DWARFCompileUnit* cu,
- const DWARFDebugInfoEntry* die)
-{
- // No namespace specified, so the answer is
- if (namespace_decl == NULL)
- return true;
-
- Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
-
- const DWARFDebugInfoEntry *decl_ctx_die = NULL;
- clang::DeclContext *die_clang_decl_ctx = GetClangDeclContextContainingDIE (cu, die, &decl_ctx_die);
- if (decl_ctx_die)
- {
- clang::NamespaceDecl *clang_namespace_decl = namespace_decl->GetNamespaceDecl();
-
- if (clang_namespace_decl)
- {
- if (decl_ctx_die->Tag() != DW_TAG_namespace)
- {
- if (log)
- GetObjectFile()->GetModule()->LogMessage(log, "Found a match, but its parent is not a namespace");
- return false;
- }
-
- if (clang_namespace_decl == die_clang_decl_ctx)
- return true;
- else
- return false;
- }
- else
- {
- // We have a namespace_decl that was not NULL but it contained
- // a NULL "clang::NamespaceDecl", so this means the global namespace
- // So as long the contained decl context DIE isn't a namespace
- // we should be ok.
- if (decl_ctx_die->Tag() != DW_TAG_namespace)
- return true;
- }
- }
-
- if (log)
- GetObjectFile()->GetModule()->LogMessage(log, "Found a match, but its parent doesn't exist");
-
- return false;
-}
uint32_t
-SymbolFileDWARF::FindGlobalVariables (const ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, VariableList& variables)
+SymbolFileDWARF::FindGlobalVariables (const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, VariableList& variables)
{
Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
if (log)
GetObjectFile()->GetModule()->LogMessage (log,
- "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", namespace_decl=%p, append=%u, max_matches=%u, variables)",
+ "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", parent_decl_ctx=%p, append=%u, max_matches=%u, variables)",
name.GetCString(),
- static_cast<const void*>(namespace_decl),
+ static_cast<const void*>(parent_decl_ctx),
append, max_matches);
- if (!NamespaceDeclMatchesThisSymbolFile(namespace_decl))
+ if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
return 0;
DWARFDebugInfo* info = DebugInfo();
@@ -3417,7 +2238,7 @@ SymbolFileDWARF::FindGlobalVariables (const ConstString &name, const lldb_privat
llvm::StringRef basename;
llvm::StringRef context;
- if (!CPPLanguageRuntime::ExtractContextAndIdentifier(name_cstr, context, basename))
+ if (!CPlusPlusLanguage::ExtractContextAndIdentifier(name_cstr, context, basename))
basename = name_cstr;
m_apple_names_ap->FindByName (basename.data(), die_offsets);
@@ -3440,17 +2261,15 @@ SymbolFileDWARF::FindGlobalVariables (const ConstString &name, const lldb_privat
assert (sc.module_sp);
DWARFDebugInfo* debug_info = DebugInfo();
- DWARFCompileUnit* dwarf_cu = NULL;
- const DWARFDebugInfoEntry* die = NULL;
bool done = false;
for (size_t i=0; i<num_die_matches && !done; ++i)
{
- const dw_offset_t die_offset = die_offsets[i];
- die = debug_info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu);
+ const DIERef& die_ref = die_offsets[i];
+ DWARFDIE die = debug_info->GetDIE (die_ref);
if (die)
{
- switch (die->Tag())
+ switch (die.Tag())
{
default:
case DW_TAG_subprogram:
@@ -3461,12 +2280,20 @@ SymbolFileDWARF::FindGlobalVariables (const ConstString &name, const lldb_privat
case DW_TAG_variable:
{
- sc.comp_unit = GetCompUnitForDWARFCompUnit(dwarf_cu, UINT32_MAX);
+ sc.comp_unit = GetCompUnitForDWARFCompUnit(die.GetCU(), UINT32_MAX);
- if (namespace_decl && !DIEIsInNamespace (namespace_decl, dwarf_cu, die))
- continue;
+ if (parent_decl_ctx)
+ {
+ DWARFASTParser *dwarf_ast = die.GetDWARFParser();
+ if (dwarf_ast)
+ {
+ CompilerDeclContext actual_parent_decl_ctx = dwarf_ast->GetDeclContextContainingUIDFromDWARF (die);
+ if (!actual_parent_decl_ctx || actual_parent_decl_ctx != *parent_decl_ctx)
+ continue;
+ }
+ }
- ParseVariables(sc, dwarf_cu, LLDB_INVALID_ADDRESS, die, false, false, &variables);
+ ParseVariables(sc, die, LLDB_INVALID_ADDRESS, false, false, &variables);
if (variables.GetSize() - original_size >= max_matches)
done = true;
@@ -3479,7 +2306,7 @@ SymbolFileDWARF::FindGlobalVariables (const ConstString &name, const lldb_privat
if (m_using_apple_tables)
{
GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_names accelerator table had bad die 0x%8.8x for '%s')\n",
- die_offset, name.GetCString());
+ die_ref.die_offset, name.GetCString());
}
}
}
@@ -3490,9 +2317,9 @@ SymbolFileDWARF::FindGlobalVariables (const ConstString &name, const lldb_privat
if (log && num_matches > 0)
{
GetObjectFile()->GetModule()->LogMessage (log,
- "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", namespace_decl=%p, append=%u, max_matches=%u, variables) => %u",
+ "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", parent_decl_ctx=%p, append=%u, max_matches=%u, variables) => %u",
name.GetCString(),
- static_cast<const void*>(namespace_decl),
+ static_cast<const void*>(parent_decl_ctx),
append, max_matches,
num_matches);
}
@@ -3525,7 +2352,7 @@ SymbolFileDWARF::FindGlobalVariables(const RegularExpression& regex, bool append
const uint32_t original_size = variables.GetSize();
DIEArray die_offsets;
-
+
if (m_using_apple_tables)
{
if (m_apple_names_ap.get())
@@ -3548,22 +2375,20 @@ SymbolFileDWARF::FindGlobalVariables(const RegularExpression& regex, bool append
sc.module_sp = m_obj_file->GetModule();
assert (sc.module_sp);
- DWARFCompileUnit* dwarf_cu = NULL;
- const DWARFDebugInfoEntry* die = NULL;
const size_t num_matches = die_offsets.size();
if (num_matches)
{
DWARFDebugInfo* debug_info = DebugInfo();
for (size_t i=0; i<num_matches; ++i)
{
- const dw_offset_t die_offset = die_offsets[i];
- die = debug_info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu);
+ const DIERef& die_ref = die_offsets[i];
+ DWARFDIE die = debug_info->GetDIE (die_ref);
if (die)
{
- sc.comp_unit = GetCompUnitForDWARFCompUnit(dwarf_cu, UINT32_MAX);
+ sc.comp_unit = GetCompUnitForDWARFCompUnit(die.GetCU(), UINT32_MAX);
- ParseVariables(sc, dwarf_cu, LLDB_INVALID_ADDRESS, die, false, false, &variables);
+ ParseVariables(sc, die, LLDB_INVALID_ADDRESS, false, false, &variables);
if (variables.GetSize() - original_size >= max_matches)
break;
@@ -3573,7 +2398,7 @@ SymbolFileDWARF::FindGlobalVariables(const RegularExpression& regex, bool append
if (m_using_apple_tables)
{
GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_names accelerator table had bad die 0x%8.8x for regex '%s')\n",
- die_offset, regex.GetText());
+ die_ref.die_offset, regex.GetText());
}
}
}
@@ -3585,53 +2410,59 @@ SymbolFileDWARF::FindGlobalVariables(const RegularExpression& regex, bool append
bool
-SymbolFileDWARF::ResolveFunction (dw_offset_t die_offset,
- DWARFCompileUnit *&dwarf_cu,
+SymbolFileDWARF::ResolveFunction (const DIERef& die_ref,
bool include_inlines,
SymbolContextList& sc_list)
{
- const DWARFDebugInfoEntry *die = DebugInfo()->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu);
- return ResolveFunction (dwarf_cu, die, include_inlines, sc_list);
+ DWARFDIE die = DebugInfo()->GetDIE (die_ref);
+ return ResolveFunction (die, include_inlines, sc_list);
}
bool
-SymbolFileDWARF::ResolveFunction (DWARFCompileUnit *cu,
- const DWARFDebugInfoEntry *die,
+SymbolFileDWARF::ResolveFunction (const DWARFDIE &orig_die,
bool include_inlines,
SymbolContextList& sc_list)
{
SymbolContext sc;
- if (die == NULL)
+ if (!orig_die)
return false;
// If we were passed a die that is not a function, just return false...
- if (! (die->Tag() == DW_TAG_subprogram || (include_inlines && die->Tag() == DW_TAG_inlined_subroutine)))
+ if (!(orig_die.Tag() == DW_TAG_subprogram || (include_inlines && orig_die.Tag() == DW_TAG_inlined_subroutine)))
return false;
-
- const DWARFDebugInfoEntry* inlined_die = NULL;
- if (die->Tag() == DW_TAG_inlined_subroutine)
+
+ DWARFDIE die = orig_die;
+ DWARFDIE inlined_die;
+ if (die.Tag() == DW_TAG_inlined_subroutine)
{
inlined_die = die;
- while ((die = die->GetParent()) != NULL)
+ while (1)
{
- if (die->Tag() == DW_TAG_subprogram)
+ die = die.GetParent();
+
+ if (die)
+ {
+ if (die.Tag() == DW_TAG_subprogram)
+ break;
+ }
+ else
break;
}
}
- assert (die && die->Tag() == DW_TAG_subprogram);
- if (GetFunction (cu, die, sc))
+ assert (die && die.Tag() == DW_TAG_subprogram);
+ if (GetFunction (die, sc))
{
Address addr;
// Parse all blocks if needed
if (inlined_die)
{
Block &function_block = sc.function->GetBlock (true);
- sc.block = function_block.FindBlockByID (MakeUserID(inlined_die->GetOffset()));
+ sc.block = function_block.FindBlockByID (inlined_die.GetID());
if (sc.block == NULL)
- sc.block = function_block.FindBlockByID (inlined_die->GetOffset());
+ sc.block = function_block.FindBlockByID (inlined_die.GetOffset());
if (sc.block == NULL || sc.block->GetStartAddress (addr) == false)
addr.Clear();
}
@@ -3702,131 +2533,37 @@ SymbolFileDWARF::ParseFunctions (const DIEArray &die_offsets,
const size_t num_matches = die_offsets.size();
if (num_matches)
{
- DWARFCompileUnit* dwarf_cu = NULL;
for (size_t i=0; i<num_matches; ++i)
- {
- const dw_offset_t die_offset = die_offsets[i];
- ResolveFunction (die_offset, dwarf_cu, include_inlines, sc_list);
- }
+ ResolveFunction (die_offsets[i], include_inlines, sc_list);
}
}
bool
-SymbolFileDWARF::FunctionDieMatchesPartialName (const DWARFDebugInfoEntry* die,
- const DWARFCompileUnit *dwarf_cu,
- uint32_t name_type_mask,
- const char *partial_name,
- const char *base_name_start,
- const char *base_name_end)
+SymbolFileDWARF::DIEInDeclContext (const CompilerDeclContext *decl_ctx,
+ const DWARFDIE &die)
{
- // If we are looking only for methods, throw away all the ones that are or aren't in C++ classes:
- if (name_type_mask == eFunctionNameTypeMethod || name_type_mask == eFunctionNameTypeBase)
- {
- clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIEOffset(die->GetOffset());
- if (!containing_decl_ctx)
- return false;
-
- bool is_cxx_method = DeclKindIsCXXClass(containing_decl_ctx->getDeclKind());
-
- if (name_type_mask == eFunctionNameTypeMethod)
- {
- if (is_cxx_method == false)
- return false;
- }
-
- if (name_type_mask == eFunctionNameTypeBase)
- {
- if (is_cxx_method == true)
- return false;
- }
- }
+ // If we have no parent decl context to match this DIE matches, and if the parent
+ // decl context isn't valid, we aren't trying to look for any particular decl
+ // context so any die matches.
+ if (decl_ctx == nullptr || !decl_ctx->IsValid())
+ return true;
- // Now we need to check whether the name we got back for this type matches the extra specifications
- // that were in the name we're looking up:
- if (base_name_start != partial_name || *base_name_end != '\0')
+ if (die)
{
- // First see if the stuff to the left matches the full name. To do that let's see if
- // we can pull out the mips linkage name attribute:
-
- Mangled best_name;
- DWARFDebugInfoEntry::Attributes attributes;
- DWARFFormValue form_value;
- die->GetAttributes(this, dwarf_cu, NULL, attributes);
- uint32_t idx = attributes.FindAttributeIndex(DW_AT_MIPS_linkage_name);
- if (idx == UINT32_MAX)
- idx = attributes.FindAttributeIndex(DW_AT_linkage_name);
- if (idx != UINT32_MAX)
+ DWARFASTParser *dwarf_ast = die.GetDWARFParser();
+ if (dwarf_ast)
{
- if (attributes.ExtractFormValueAtIndex(this, idx, form_value))
- {
- const char *mangled_name = form_value.AsCString(&get_debug_str_data());
- if (mangled_name)
- best_name.SetValue (ConstString(mangled_name), true);
- }
- }
-
- if (!best_name)
- {
- idx = attributes.FindAttributeIndex(DW_AT_name);
- if (idx != UINT32_MAX && attributes.ExtractFormValueAtIndex(this, idx, form_value))
- {
- const char *name = form_value.AsCString(&get_debug_str_data());
- best_name.SetValue (ConstString(name), false);
- }
- }
-
- const LanguageType cu_language = const_cast<DWARFCompileUnit *>(dwarf_cu)->GetLanguageType();
- if (best_name.GetDemangledName(cu_language))
- {
- const char *demangled = best_name.GetDemangledName(cu_language).GetCString();
- if (demangled)
- {
- std::string name_no_parens(partial_name, base_name_end - partial_name);
- const char *partial_in_demangled = strstr (demangled, name_no_parens.c_str());
- if (partial_in_demangled == NULL)
- return false;
- else
- {
- // Sort out the case where our name is something like "Process::Destroy" and the match is
- // "SBProcess::Destroy" - that shouldn't be a match. We should really always match on
- // namespace boundaries...
-
- if (partial_name[0] == ':' && partial_name[1] == ':')
- {
- // The partial name was already on a namespace boundary so all matches are good.
- return true;
- }
- else if (partial_in_demangled == demangled)
- {
- // They both start the same, so this is an good match.
- return true;
- }
- else
- {
- if (partial_in_demangled - demangled == 1)
- {
- // Only one character difference, can't be a namespace boundary...
- return false;
- }
- else if (*(partial_in_demangled - 1) == ':' && *(partial_in_demangled - 2) == ':')
- {
- // We are on a namespace boundary, so this is also good.
- return true;
- }
- else
- return false;
- }
- }
- }
+ CompilerDeclContext actual_decl_ctx = dwarf_ast->GetDeclContextContainingUIDFromDWARF (die);
+ if (actual_decl_ctx)
+ return actual_decl_ctx == *decl_ctx;
}
}
-
- return true;
+ return false;
}
uint32_t
-SymbolFileDWARF::FindFunctions (const ConstString &name,
- const lldb_private::ClangNamespaceDecl *namespace_decl,
+SymbolFileDWARF::FindFunctions (const ConstString &name,
+ const CompilerDeclContext *parent_decl_ctx,
uint32_t name_type_mask,
bool include_inlines,
bool append,
@@ -3854,7 +2591,7 @@ SymbolFileDWARF::FindFunctions (const ConstString &name,
if (!append)
sc_list.Clear();
- if (!NamespaceDeclMatchesThisSymbolFile(namespace_decl))
+ if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
return 0;
// If name is empty then we won't find anything.
@@ -3872,7 +2609,6 @@ SymbolFileDWARF::FindFunctions (const ConstString &name,
if (info == NULL)
return 0;
- DWARFCompileUnit *dwarf_cu = NULL;
std::set<const DWARFDebugInfoEntry *> resolved_dies;
if (m_using_apple_tables)
{
@@ -3891,30 +2627,30 @@ SymbolFileDWARF::FindFunctions (const ConstString &name,
num_matches = m_apple_names_ap->FindByName (name_cstr, die_offsets);
for (uint32_t i = 0; i < num_matches; i++)
{
- const dw_offset_t die_offset = die_offsets[i];
- const DWARFDebugInfoEntry *die = info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu);
+ const DIERef& die_ref = die_offsets[i];
+ DWARFDIE die = info->GetDIE (die_ref);
if (die)
{
- if (namespace_decl && !DIEIsInNamespace (namespace_decl, dwarf_cu, die))
- continue;
-
- if (resolved_dies.find(die) == resolved_dies.end())
+ if (!DIEInDeclContext(parent_decl_ctx, die))
+ continue; // The containing decl contexts don't match
+
+ if (resolved_dies.find(die.GetDIE()) == resolved_dies.end())
{
- if (ResolveFunction (dwarf_cu, die, include_inlines, sc_list))
- resolved_dies.insert(die);
+ if (ResolveFunction (die, include_inlines, sc_list))
+ resolved_dies.insert(die.GetDIE());
}
}
else
{
GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_names accelerator table had bad die 0x%8.8x for '%s')",
- die_offset, name_cstr);
+ die_ref.die_offset, name_cstr);
}
}
}
if (name_type_mask & eFunctionNameTypeSelector)
{
- if (namespace_decl && *namespace_decl)
+ if (parent_decl_ctx && parent_decl_ctx->IsValid())
return 0; // no selectors in namespaces
num_matches = m_apple_names_ap->FindByName (name_cstr, die_offsets);
@@ -3923,30 +2659,30 @@ SymbolFileDWARF::FindFunctions (const ConstString &name,
for (uint32_t i = 0; i < num_matches; i++)
{
- const dw_offset_t die_offset = die_offsets[i];
- const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu);
+ const DIERef& die_ref = die_offsets[i];
+ DWARFDIE die = info->GetDIE (die_ref);
if (die)
{
- const char *die_name = die->GetName(this, dwarf_cu);
- if (ObjCLanguageRuntime::IsPossibleObjCMethodName(die_name))
+ const char *die_name = die.GetName();
+ if (ObjCLanguage::IsPossibleObjCMethodName(die_name))
{
- if (resolved_dies.find(die) == resolved_dies.end())
+ if (resolved_dies.find(die.GetDIE()) == resolved_dies.end())
{
- if (ResolveFunction (dwarf_cu, die, include_inlines, sc_list))
- resolved_dies.insert(die);
+ if (ResolveFunction (die, include_inlines, sc_list))
+ resolved_dies.insert(die.GetDIE());
}
}
}
else
{
GetObjectFile()->GetModule()->ReportError ("the DWARF debug information has been modified (.apple_names accelerator table had bad die 0x%8.8x for '%s')",
- die_offset, name_cstr);
+ die_ref.die_offset, name_cstr);
}
}
die_offsets.clear();
}
- if (((name_type_mask & eFunctionNameTypeMethod) && !namespace_decl) || name_type_mask & eFunctionNameTypeBase)
+ if (((name_type_mask & eFunctionNameTypeMethod) && !parent_decl_ctx) || name_type_mask & eFunctionNameTypeBase)
{
// The apple_names table stores just the "base name" of C++ methods in the table. So we have to
// extract the base name, look that up, and if there is any other information in the name we were
@@ -3957,16 +2693,16 @@ SymbolFileDWARF::FindFunctions (const ConstString &name,
for (uint32_t i = 0; i < num_matches; i++)
{
- const dw_offset_t die_offset = die_offsets[i];
- const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu);
+ const DIERef& die_ref = die_offsets[i];
+ DWARFDIE die = info->GetDIE (die_ref);
if (die)
{
- if (namespace_decl && !DIEIsInNamespace (namespace_decl, dwarf_cu, die))
- continue;
+ if (!DIEInDeclContext(parent_decl_ctx, die))
+ continue; // The containing decl contexts don't match
+
// If we get to here, the die is good, and we should add it:
- if (resolved_dies.find(die) == resolved_dies.end())
- if (ResolveFunction (dwarf_cu, die, include_inlines, sc_list))
+ if (resolved_dies.find(die.GetDIE()) == resolved_dies.end() && ResolveFunction (die, include_inlines, sc_list))
{
bool keep_die = true;
if ((name_type_mask & (eFunctionNameTypeBase|eFunctionNameTypeMethod)) != (eFunctionNameTypeBase|eFunctionNameTypeMethod))
@@ -3986,8 +2722,8 @@ SymbolFileDWARF::FindFunctions (const ConstString &name,
if (type)
{
- clang::DeclContext* decl_ctx = GetClangDeclContextContainingTypeUID (type->GetID());
- if (decl_ctx->isRecord())
+ CompilerDeclContext decl_ctx = GetDeclContextContainingUID (type->GetID());
+ if (decl_ctx.IsStructUnionOrClass())
{
if (name_type_mask & eFunctionNameTypeBase)
{
@@ -4007,19 +2743,19 @@ SymbolFileDWARF::FindFunctions (const ConstString &name,
else
{
GetObjectFile()->GetModule()->ReportWarning ("function at die offset 0x%8.8x had no function type",
- die_offset);
+ die_ref.die_offset);
}
}
}
}
if (keep_die)
- resolved_dies.insert(die);
+ resolved_dies.insert(die.GetDIE());
}
}
else
{
GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_names accelerator table had bad die 0x%8.8x for '%s')",
- die_offset, name_cstr);
+ die_ref.die_offset, name_cstr);
}
}
die_offsets.clear();
@@ -4046,10 +2782,10 @@ SymbolFileDWARF::FindFunctions (const ConstString &name,
// TODO: The arch in the object file isn't correct for MSVC
// binaries on windows, we should find a way to make it
// correct and handle those symbols as well.
- if (sc_list.GetSize() == 0)
+ if (sc_list.GetSize() == original_size)
{
ArchSpec arch;
- if (!namespace_decl &&
+ if (!parent_decl_ctx &&
GetObjectFile()->GetArchitecture(arch) &&
(arch.GetTriple().isOSFreeBSD() || arch.GetTriple().isOSLinux() ||
arch.GetMachine() == llvm::Triple::hexagon))
@@ -4076,24 +2812,22 @@ SymbolFileDWARF::FindFunctions (const ConstString &name,
}
}
DIEArray die_offsets;
- DWARFCompileUnit *dwarf_cu = NULL;
-
if (name_type_mask & eFunctionNameTypeBase)
{
uint32_t num_base = m_function_basename_index.Find(name, die_offsets);
for (uint32_t i = 0; i < num_base; i++)
{
- const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offsets[i], &dwarf_cu);
+ DWARFDIE die = info->GetDIE (die_offsets[i]);
if (die)
{
- if (namespace_decl && !DIEIsInNamespace (namespace_decl, dwarf_cu, die))
- continue;
-
+ if (!DIEInDeclContext(parent_decl_ctx, die))
+ continue; // The containing decl contexts don't match
+
// If we get to here, the die is good, and we should add it:
- if (resolved_dies.find(die) == resolved_dies.end())
+ if (resolved_dies.find(die.GetDIE()) == resolved_dies.end())
{
- if (ResolveFunction (dwarf_cu, die, include_inlines, sc_list))
- resolved_dies.insert(die);
+ if (ResolveFunction (die, include_inlines, sc_list))
+ resolved_dies.insert(die.GetDIE());
}
}
}
@@ -4102,21 +2836,21 @@ SymbolFileDWARF::FindFunctions (const ConstString &name,
if (name_type_mask & eFunctionNameTypeMethod)
{
- if (namespace_decl && *namespace_decl)
+ if (parent_decl_ctx && parent_decl_ctx->IsValid())
return 0; // no methods in namespaces
uint32_t num_base = m_function_method_index.Find(name, die_offsets);
{
for (uint32_t i = 0; i < num_base; i++)
{
- const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offsets[i], &dwarf_cu);
+ DWARFDIE die = info->GetDIE (die_offsets[i]);
if (die)
{
// If we get to here, the die is good, and we should add it:
- if (resolved_dies.find(die) == resolved_dies.end())
+ if (resolved_dies.find(die.GetDIE()) == resolved_dies.end())
{
- if (ResolveFunction (dwarf_cu, die, include_inlines, sc_list))
- resolved_dies.insert(die);
+ if (ResolveFunction (die, include_inlines, sc_list))
+ resolved_dies.insert(die.GetDIE());
}
}
}
@@ -4124,7 +2858,7 @@ SymbolFileDWARF::FindFunctions (const ConstString &name,
die_offsets.clear();
}
- if ((name_type_mask & eFunctionNameTypeSelector) && (!namespace_decl || !*namespace_decl))
+ if ((name_type_mask & eFunctionNameTypeSelector) && (!parent_decl_ctx || !parent_decl_ctx->IsValid()))
{
FindFunctions (name, m_function_selector_index, include_inlines, sc_list);
}
@@ -4196,10 +2930,10 @@ SymbolFileDWARF::FindFunctions(const RegularExpression& regex, bool include_inli
uint32_t
SymbolFileDWARF::FindTypes (const SymbolContext& sc,
const ConstString &name,
- const lldb_private::ClangNamespaceDecl *namespace_decl,
+ const CompilerDeclContext *parent_decl_ctx,
bool append,
uint32_t max_matches,
- TypeList& types)
+ TypeMap& types)
{
DWARFDebugInfo* info = DebugInfo();
if (info == NULL)
@@ -4209,16 +2943,16 @@ SymbolFileDWARF::FindTypes (const SymbolContext& sc,
if (log)
{
- if (namespace_decl)
+ if (parent_decl_ctx)
GetObjectFile()->GetModule()->LogMessage (log,
- "SymbolFileDWARF::FindTypes (sc, name=\"%s\", clang::NamespaceDecl(%p) \"%s\", append=%u, max_matches=%u, type_list)",
+ "SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx = %p (\"%s\"), append=%u, max_matches=%u, type_list)",
name.GetCString(),
- static_cast<void*>(namespace_decl->GetNamespaceDecl()),
- namespace_decl->GetQualifiedName().c_str(),
+ static_cast<const void*>(parent_decl_ctx),
+ parent_decl_ctx->GetName().AsCString("<NULL>"),
append, max_matches);
else
GetObjectFile()->GetModule()->LogMessage (log,
- "SymbolFileDWARF::FindTypes (sc, name=\"%s\", clang::NamespaceDecl(NULL), append=%u, max_matches=%u, type_list)",
+ "SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx = NULL, append=%u, max_matches=%u, type_list)",
name.GetCString(), append,
max_matches);
}
@@ -4227,7 +2961,7 @@ SymbolFileDWARF::FindTypes (const SymbolContext& sc,
if (!append)
types.Clear();
- if (!NamespaceDeclMatchesThisSymbolFile(namespace_decl))
+ if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
return 0;
DIEArray die_offsets;
@@ -4253,20 +2987,18 @@ SymbolFileDWARF::FindTypes (const SymbolContext& sc,
if (num_die_matches)
{
const uint32_t initial_types_size = types.GetSize();
- DWARFCompileUnit* dwarf_cu = NULL;
- const DWARFDebugInfoEntry* die = NULL;
DWARFDebugInfo* debug_info = DebugInfo();
for (size_t i=0; i<num_die_matches; ++i)
{
- const dw_offset_t die_offset = die_offsets[i];
- die = debug_info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu);
+ const DIERef& die_ref = die_offsets[i];
+ DWARFDIE die = debug_info->GetDIE (die_ref);
if (die)
{
- if (namespace_decl && !DIEIsInNamespace (namespace_decl, dwarf_cu, die))
- continue;
+ if (!DIEInDeclContext(parent_decl_ctx, die))
+ continue; // The containing decl contexts don't match
- Type *matching_type = ResolveType (dwarf_cu, die);
+ Type *matching_type = ResolveType (die, true, true);
if (matching_type)
{
// We found a type pointer, now find the shared pointer form our type list
@@ -4280,7 +3012,7 @@ SymbolFileDWARF::FindTypes (const SymbolContext& sc,
if (m_using_apple_tables)
{
GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_types accelerator table had bad die 0x%8.8x for '%s')\n",
- die_offset, name.GetCString());
+ die_ref.die_offset, name.GetCString());
}
}
@@ -4288,20 +3020,20 @@ SymbolFileDWARF::FindTypes (const SymbolContext& sc,
const uint32_t num_matches = types.GetSize() - initial_types_size;
if (log && num_matches)
{
- if (namespace_decl)
+ if (parent_decl_ctx)
{
GetObjectFile()->GetModule()->LogMessage (log,
- "SymbolFileDWARF::FindTypes (sc, name=\"%s\", clang::NamespaceDecl(%p) \"%s\", append=%u, max_matches=%u, type_list) => %u",
+ "SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx = %p (\"%s\"), append=%u, max_matches=%u, type_list) => %u",
name.GetCString(),
- static_cast<void*>(namespace_decl->GetNamespaceDecl()),
- namespace_decl->GetQualifiedName().c_str(),
+ static_cast<const void*>(parent_decl_ctx),
+ parent_decl_ctx->GetName().AsCString("<NULL>"),
append, max_matches,
num_matches);
}
else
{
GetObjectFile()->GetModule()->LogMessage (log,
- "SymbolFileDWARF::FindTypes (sc, name=\"%s\", clang::NamespaceDecl(NULL), append=%u, max_matches=%u, type_list) => %u",
+ "SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx = NULL, append=%u, max_matches=%u, type_list) => %u",
name.GetCString(),
append, max_matches,
num_matches);
@@ -4309,14 +3041,112 @@ SymbolFileDWARF::FindTypes (const SymbolContext& sc,
}
return num_matches;
}
+ else
+ {
+ UpdateExternalModuleListIfNeeded();
+
+ for (const auto &pair : m_external_type_modules)
+ {
+ ModuleSP external_module_sp = pair.second;
+ if (external_module_sp)
+ {
+ SymbolVendor *sym_vendor = external_module_sp->GetSymbolVendor();
+ if (sym_vendor)
+ {
+ const uint32_t num_external_matches = sym_vendor->FindTypes (sc,
+ name,
+ parent_decl_ctx,
+ append,
+ max_matches,
+ types);
+ if (num_external_matches)
+ return num_external_matches;
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+
+size_t
+SymbolFileDWARF::FindTypes (const std::vector<CompilerContext> &context,
+ bool append,
+ TypeMap& types)
+{
+ if (!append)
+ types.Clear();
+
+ if (context.empty())
+ return 0;
+
+ DIEArray die_offsets;
+
+ ConstString name = context.back().name;
+
+ if (m_using_apple_tables)
+ {
+ if (m_apple_types_ap.get())
+ {
+ const char *name_cstr = name.GetCString();
+ m_apple_types_ap->FindByName (name_cstr, die_offsets);
+ }
+ }
+ else
+ {
+ if (!m_indexed)
+ Index ();
+
+ m_type_index.Find (name, die_offsets);
+ }
+
+ const size_t num_die_matches = die_offsets.size();
+
+ if (num_die_matches)
+ {
+ size_t num_matches = 0;
+ DWARFDebugInfo* debug_info = DebugInfo();
+ for (size_t i=0; i<num_die_matches; ++i)
+ {
+ const DIERef& die_ref = die_offsets[i];
+ DWARFDIE die = debug_info->GetDIE (die_ref);
+
+ if (die)
+ {
+ std::vector<CompilerContext> die_context;
+ die.GetDWOContext(die_context);
+ if (die_context != context)
+ continue;
+
+ Type *matching_type = ResolveType (die, true, true);
+ if (matching_type)
+ {
+ // We found a type pointer, now find the shared pointer form our type list
+ types.InsertUnique (matching_type->shared_from_this());
+ ++num_matches;
+ }
+ }
+ else
+ {
+ if (m_using_apple_tables)
+ {
+ GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_types accelerator table had bad die 0x%8.8x for '%s')\n",
+ die_ref.die_offset, name.GetCString());
+ }
+ }
+
+ }
+ return num_matches;
+ }
return 0;
}
-ClangNamespaceDecl
+CompilerDeclContext
SymbolFileDWARF::FindNamespace (const SymbolContext& sc,
const ConstString &name,
- const lldb_private::ClangNamespaceDecl *parent_namespace_decl)
+ const CompilerDeclContext *parent_decl_ctx)
{
Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
@@ -4326,11 +3156,13 @@ SymbolFileDWARF::FindNamespace (const SymbolContext& sc,
"SymbolFileDWARF::FindNamespace (sc, name=\"%s\")",
name.GetCString());
}
-
- if (!NamespaceDeclMatchesThisSymbolFile(parent_namespace_decl))
- return ClangNamespaceDecl();
- ClangNamespaceDecl namespace_decl;
+ CompilerDeclContext namespace_decl_ctx;
+
+ if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
+ return namespace_decl_ctx;
+
+
DWARFDebugInfo* info = DebugInfo();
if (info)
{
@@ -4354,28 +3186,26 @@ SymbolFileDWARF::FindNamespace (const SymbolContext& sc,
m_namespace_index.Find (name, die_offsets);
}
- DWARFCompileUnit* dwarf_cu = NULL;
- const DWARFDebugInfoEntry* die = NULL;
const size_t num_matches = die_offsets.size();
if (num_matches)
{
DWARFDebugInfo* debug_info = DebugInfo();
for (size_t i=0; i<num_matches; ++i)
{
- const dw_offset_t die_offset = die_offsets[i];
- die = debug_info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu);
-
+ const DIERef& die_ref = die_offsets[i];
+ DWARFDIE die = debug_info->GetDIE (die_ref);
+
if (die)
{
- if (parent_namespace_decl && !DIEIsInNamespace (parent_namespace_decl, dwarf_cu, die))
- continue;
+ if (!DIEInDeclContext (parent_decl_ctx, die))
+ continue; // The containing decl contexts don't match
- clang::NamespaceDecl *clang_namespace_decl = ResolveNamespaceDIE (dwarf_cu, die);
- if (clang_namespace_decl)
+ DWARFASTParser *dwarf_ast = die.GetDWARFParser();
+ if (dwarf_ast)
{
- namespace_decl.SetASTContext (GetClangASTContext().getASTContext());
- namespace_decl.SetNamespaceDecl (clang_namespace_decl);
- break;
+ namespace_decl_ctx = dwarf_ast->GetDeclContextForUIDFromDWARF (die);
+ if (namespace_decl_ctx)
+ break;
}
}
else
@@ -4383,421 +3213,50 @@ SymbolFileDWARF::FindNamespace (const SymbolContext& sc,
if (m_using_apple_tables)
{
GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_namespaces accelerator table had bad die 0x%8.8x for '%s')\n",
- die_offset, name.GetCString());
+ die_ref.die_offset, name.GetCString());
}
}
}
}
}
- if (log && namespace_decl.GetNamespaceDecl())
+ if (log && namespace_decl_ctx)
{
GetObjectFile()->GetModule()->LogMessage (log,
- "SymbolFileDWARF::FindNamespace (sc, name=\"%s\") => clang::NamespaceDecl(%p) \"%s\"",
+ "SymbolFileDWARF::FindNamespace (sc, name=\"%s\") => CompilerDeclContext(%p/%p) \"%s\"",
name.GetCString(),
- static_cast<const void*>(namespace_decl.GetNamespaceDecl()),
- namespace_decl.GetQualifiedName().c_str());
- }
-
- return namespace_decl;
-}
-
-uint32_t
-SymbolFileDWARF::FindTypes(std::vector<dw_offset_t> die_offsets, uint32_t max_matches, TypeList& types)
-{
- // Remember how many sc_list are in the list before we search in case
- // we are appending the results to a variable list.
- uint32_t original_size = types.GetSize();
-
- const uint32_t num_die_offsets = die_offsets.size();
- // Parse all of the types we found from the pubtypes matches
- uint32_t i;
- uint32_t num_matches = 0;
- for (i = 0; i < num_die_offsets; ++i)
- {
- Type *matching_type = ResolveTypeUID (die_offsets[i]);
- if (matching_type)
- {
- // We found a type pointer, now find the shared pointer form our type list
- types.InsertUnique (matching_type->shared_from_this());
- ++num_matches;
- if (num_matches >= max_matches)
- break;
- }
- }
-
- // Return the number of variable that were appended to the list
- return types.GetSize() - original_size;
-}
-
-
-size_t
-SymbolFileDWARF::ParseChildParameters (const SymbolContext& sc,
- clang::DeclContext *containing_decl_ctx,
- DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *parent_die,
- bool skip_artificial,
- bool &is_static,
- bool &is_variadic,
- std::vector<ClangASTType>& function_param_types,
- std::vector<clang::ParmVarDecl*>& function_param_decls,
- unsigned &type_quals) // ,
- // ClangASTContext::TemplateParameterInfos &template_param_infos))
-{
- if (parent_die == NULL)
- return 0;
-
- const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize(), dwarf_cu->IsDWARF64());
-
- size_t arg_idx = 0;
- const DWARFDebugInfoEntry *die;
- for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling())
- {
- dw_tag_t tag = die->Tag();
- switch (tag)
- {
- case DW_TAG_formal_parameter:
- {
- DWARFDebugInfoEntry::Attributes attributes;
- const size_t num_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes);
- if (num_attributes > 0)
- {
- const char *name = NULL;
- Declaration decl;
- dw_offset_t param_type_die_offset = DW_INVALID_OFFSET;
- bool is_artificial = false;
- // one of None, Auto, Register, Extern, Static, PrivateExtern
-
- clang::StorageClass storage = clang::SC_None;
- uint32_t i;
- for (i=0; i<num_attributes; ++i)
- {
- const dw_attr_t attr = attributes.AttributeAtIndex(i);
- DWARFFormValue form_value;
- if (attributes.ExtractFormValueAtIndex(this, 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(&get_debug_str_data()); break;
- case DW_AT_type: param_type_die_offset = form_value.Reference(); break;
- case DW_AT_artificial: is_artificial = form_value.Boolean(); break;
- case DW_AT_location:
- // if (form_value.BlockData())
- // {
- // const DWARFDataExtractor& debug_info_data = debug_info();
- // uint32_t block_length = form_value.Unsigned();
- // DWARFDataExtractor location(debug_info_data, form_value.BlockData() - debug_info_data.GetDataStart(), block_length);
- // }
- // else
- // {
- // }
- // break;
- case DW_AT_const_value:
- case DW_AT_default_value:
- case DW_AT_description:
- case DW_AT_endianity:
- case DW_AT_is_optional:
- case DW_AT_segment:
- case DW_AT_variable_parameter:
- default:
- case DW_AT_abstract_origin:
- case DW_AT_sibling:
- break;
- }
- }
- }
-
- bool skip = false;
- if (skip_artificial)
- {
- if (is_artificial)
- {
- // In order to determine if a C++ member function is
- // "const" we have to look at the const-ness of "this"...
- // Ugly, but that
- if (arg_idx == 0)
- {
- if (DeclKindIsCXXClass(containing_decl_ctx->getDeclKind()))
- {
- // 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...
- if (name == NULL || ::strcmp(name, "this")==0)
- {
- Type *this_type = ResolveTypeUID (param_type_die_offset);
- if (this_type)
- {
- uint32_t encoding_mask = this_type->GetEncodingMask();
- if (encoding_mask & Type::eEncodingIsPointerUID)
- {
- is_static = false;
-
- if (encoding_mask & (1u << Type::eEncodingIsConstUID))
- type_quals |= clang::Qualifiers::Const;
- if (encoding_mask & (1u << Type::eEncodingIsVolatileUID))
- type_quals |= clang::Qualifiers::Volatile;
- }
- }
- }
- }
- }
- skip = true;
- }
- else
- {
-
- // HACK: Objective C formal parameters "self" and "_cmd"
- // are not marked as artificial in the DWARF...
- CompileUnit *comp_unit = GetCompUnitForDWARFCompUnit(dwarf_cu, UINT32_MAX);
- if (comp_unit)
- {
- switch (comp_unit->GetLanguage())
- {
- case eLanguageTypeObjC:
- case eLanguageTypeObjC_plus_plus:
- if (name && name[0] && (strcmp (name, "self") == 0 || strcmp (name, "_cmd") == 0))
- skip = true;
- break;
- default:
- break;
- }
- }
- }
- }
-
- if (!skip)
- {
- Type *type = ResolveTypeUID(param_type_die_offset);
- if (type)
- {
- function_param_types.push_back (type->GetClangForwardType());
-
- clang::ParmVarDecl *param_var_decl = GetClangASTContext().CreateParameterDeclaration (name,
- type->GetClangForwardType(),
- storage);
- assert(param_var_decl);
- function_param_decls.push_back(param_var_decl);
-
- GetClangASTContext().SetMetadataAsUserID (param_var_decl, MakeUserID(die->GetOffset()));
- }
- }
- }
- arg_idx++;
- }
- break;
-
- case DW_TAG_unspecified_parameters:
- is_variadic = true;
- break;
-
- case DW_TAG_template_type_parameter:
- case DW_TAG_template_value_parameter:
- // The one caller of this was never using the template_param_infos,
- // and the local variable was taking up a large amount of stack space
- // in SymbolFileDWARF::ParseType() so this was removed. If we ever need
- // the template params back, we can add them back.
- // ParseTemplateDIE (dwarf_cu, die, template_param_infos);
- break;
-
- default:
- break;
- }
- }
- return arg_idx;
-}
-
-size_t
-SymbolFileDWARF::ParseChildEnumerators
-(
- const SymbolContext& sc,
- lldb_private::ClangASTType &clang_type,
- bool is_signed,
- uint32_t enumerator_byte_size,
- DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *parent_die
-)
-{
- if (parent_die == NULL)
- return 0;
-
- size_t enumerators_added = 0;
- const DWARFDebugInfoEntry *die;
- const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize(), dwarf_cu->IsDWARF64());
-
- for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling())
- {
- const dw_tag_t tag = die->Tag();
- if (tag == DW_TAG_enumerator)
- {
- DWARFDebugInfoEntry::Attributes attributes;
- const size_t num_child_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes);
- if (num_child_attributes > 0)
- {
- const char *name = NULL;
- bool got_value = false;
- int64_t enum_value = 0;
- Declaration decl;
-
- uint32_t i;
- for (i=0; i<num_child_attributes; ++i)
- {
- const dw_attr_t attr = attributes.AttributeAtIndex(i);
- DWARFFormValue form_value;
- if (attributes.ExtractFormValueAtIndex(this, i, form_value))
- {
- switch (attr)
- {
- case DW_AT_const_value:
- got_value = true;
- if (is_signed)
- enum_value = form_value.Signed();
- else
- enum_value = form_value.Unsigned();
- break;
-
- case DW_AT_name:
- name = form_value.AsCString(&get_debug_str_data());
- break;
-
- case DW_AT_description:
- default:
- 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_sibling:
- break;
- }
- }
- }
-
- if (name && name[0] && got_value)
- {
- clang_type.AddEnumerationValueToEnumerationType (clang_type.GetEnumerationIntegerType(),
- decl,
- name,
- enum_value,
- enumerator_byte_size * 8);
- ++enumerators_added;
- }
- }
- }
+ static_cast<const void*>(namespace_decl_ctx.GetTypeSystem()),
+ static_cast<const void*>(namespace_decl_ctx.GetOpaqueDeclContext()),
+ namespace_decl_ctx.GetName().AsCString("<NULL>"));
}
- return enumerators_added;
-}
-
-void
-SymbolFileDWARF::ParseChildArrayInfo
-(
- const SymbolContext& sc,
- DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *parent_die,
- int64_t& first_index,
- std::vector<uint64_t>& element_orders,
- uint32_t& byte_stride,
- uint32_t& bit_stride
-)
-{
- if (parent_die == NULL)
- return;
-
- const DWARFDebugInfoEntry *die;
- const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize(), dwarf_cu->IsDWARF64());
- for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling())
- {
- const dw_tag_t tag = die->Tag();
- switch (tag)
- {
- case DW_TAG_subrange_type:
- {
- DWARFDebugInfoEntry::Attributes attributes;
- const size_t num_child_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes);
- if (num_child_attributes > 0)
- {
- uint64_t num_elements = 0;
- uint64_t lower_bound = 0;
- uint64_t upper_bound = 0;
- bool upper_bound_valid = false;
- uint32_t i;
- for (i=0; i<num_child_attributes; ++i)
- {
- const dw_attr_t attr = attributes.AttributeAtIndex(i);
- DWARFFormValue form_value;
- if (attributes.ExtractFormValueAtIndex(this, i, form_value))
- {
- switch (attr)
- {
- case DW_AT_name:
- break;
-
- case DW_AT_count:
- num_elements = form_value.Unsigned();
- break;
-
- case DW_AT_bit_stride:
- bit_stride = form_value.Unsigned();
- break;
-
- case DW_AT_byte_stride:
- byte_stride = form_value.Unsigned();
- break;
-
- case DW_AT_lower_bound:
- lower_bound = form_value.Unsigned();
- break;
-
- case DW_AT_upper_bound:
- upper_bound_valid = true;
- upper_bound = form_value.Unsigned();
- break;
-
- default:
- case DW_AT_abstract_origin:
- case DW_AT_accessibility:
- case DW_AT_allocated:
- case DW_AT_associated:
- case DW_AT_data_location:
- case DW_AT_declaration:
- case DW_AT_description:
- case DW_AT_sibling:
- case DW_AT_threads_scaled:
- case DW_AT_type:
- case DW_AT_visibility:
- break;
- }
- }
- }
- if (num_elements == 0)
- {
- if (upper_bound_valid && upper_bound >= lower_bound)
- num_elements = upper_bound - lower_bound + 1;
- }
-
- element_orders.push_back (num_elements);
- }
- }
- break;
- }
- }
+ return namespace_decl_ctx;
}
TypeSP
-SymbolFileDWARF::GetTypeForDIE (DWARFCompileUnit *dwarf_cu, const DWARFDebugInfoEntry* die)
+SymbolFileDWARF::GetTypeForDIE (const DWARFDIE &die, bool resolve_function_context)
{
TypeSP type_sp;
- if (die != NULL)
+ if (die)
{
- assert(dwarf_cu != NULL);
- Type *type_ptr = m_die_to_type.lookup (die);
+ Type *type_ptr = GetDIEToType().lookup (die.GetDIE());
if (type_ptr == NULL)
{
- CompileUnit* lldb_cu = GetCompUnitForDWARFCompUnit(dwarf_cu);
+ CompileUnit* lldb_cu = GetCompUnitForDWARFCompUnit(die.GetCU());
assert (lldb_cu);
SymbolContext sc(lldb_cu);
- type_sp = ParseType(sc, dwarf_cu, die, NULL);
+ const DWARFDebugInfoEntry* parent_die = die.GetParent().GetDIE();
+ while (parent_die != nullptr)
+ {
+ if (parent_die->Tag() == DW_TAG_subprogram)
+ break;
+ parent_die = parent_die->GetParent();
+ }
+ SymbolContext sc_backup = sc;
+ if (resolve_function_context && parent_die != nullptr && !GetFunction(DWARFDIE(die.GetCU(),parent_die), sc))
+ sc = sc_backup;
+
+ type_sp = ParseType(sc, die, NULL);
}
else if (type_ptr != DIE_IS_BEING_PARSED)
{
@@ -4809,215 +3268,57 @@ SymbolFileDWARF::GetTypeForDIE (DWARFCompileUnit *dwarf_cu, const DWARFDebugInfo
return type_sp;
}
-clang::DeclContext *
-SymbolFileDWARF::GetClangDeclContextContainingDIEOffset (dw_offset_t die_offset)
-{
- if (die_offset != DW_INVALID_OFFSET)
- {
- DWARFCompileUnitSP cu_sp;
- const DWARFDebugInfoEntry* die = DebugInfo()->GetDIEPtr(die_offset, &cu_sp);
- return GetClangDeclContextContainingDIE (cu_sp.get(), die, NULL);
- }
- return NULL;
-}
-
-clang::DeclContext *
-SymbolFileDWARF::GetClangDeclContextForDIEOffset (const SymbolContext &sc, dw_offset_t die_offset)
-{
- if (die_offset != DW_INVALID_OFFSET)
- {
- DWARFDebugInfo* debug_info = DebugInfo();
- if (debug_info)
- {
- DWARFCompileUnitSP cu_sp;
- const DWARFDebugInfoEntry* die = debug_info->GetDIEPtr(die_offset, &cu_sp);
- if (die)
- return GetClangDeclContextForDIE (sc, cu_sp.get(), die);
- }
- }
- return NULL;
-}
-
-clang::NamespaceDecl *
-SymbolFileDWARF::ResolveNamespaceDIE (DWARFCompileUnit *dwarf_cu, const DWARFDebugInfoEntry *die)
-{
- if (die && die->Tag() == DW_TAG_namespace)
- {
- // See if we already parsed this namespace DIE and associated it with a
- // uniqued namespace declaration
- clang::NamespaceDecl *namespace_decl = static_cast<clang::NamespaceDecl *>(m_die_to_decl_ctx[die]);
- if (namespace_decl)
- return namespace_decl;
- else
- {
- const char *namespace_name = die->GetAttributeValueAsString(this, dwarf_cu, DW_AT_name, NULL);
- clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (dwarf_cu, die, NULL);
- namespace_decl = GetClangASTContext().GetUniqueNamespaceDeclaration (namespace_name, containing_decl_ctx);
- Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
- if (log)
- {
- if (namespace_name)
- {
- GetObjectFile()->GetModule()->LogMessage (log,
- "ASTContext => %p: 0x%8.8" PRIx64 ": DW_TAG_namespace with DW_AT_name(\"%s\") => clang::NamespaceDecl *%p (original = %p)",
- static_cast<void*>(GetClangASTContext().getASTContext()),
- MakeUserID(die->GetOffset()),
- namespace_name,
- static_cast<void*>(namespace_decl),
- static_cast<void*>(namespace_decl->getOriginalNamespace()));
- }
- else
- {
- GetObjectFile()->GetModule()->LogMessage (log,
- "ASTContext => %p: 0x%8.8" PRIx64 ": DW_TAG_namespace (anonymous) => clang::NamespaceDecl *%p (original = %p)",
- static_cast<void*>(GetClangASTContext().getASTContext()),
- MakeUserID(die->GetOffset()),
- static_cast<void*>(namespace_decl),
- static_cast<void*>(namespace_decl->getOriginalNamespace()));
- }
- }
-
- if (namespace_decl)
- LinkDeclContextToDIE((clang::DeclContext*)namespace_decl, die);
- return namespace_decl;
- }
- }
- return NULL;
-}
-
-clang::DeclContext *
-SymbolFileDWARF::GetClangDeclContextForDIE (const SymbolContext &sc, DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die)
-{
- clang::DeclContext *clang_decl_ctx = GetCachedClangDeclContextForDIE (die);
- if (clang_decl_ctx)
- return clang_decl_ctx;
- // If this DIE has a specification, or an abstract origin, then trace to those.
-
- dw_offset_t die_offset = die->GetAttributeValueAsReference(this, cu, DW_AT_specification, DW_INVALID_OFFSET);
- if (die_offset != DW_INVALID_OFFSET)
- return GetClangDeclContextForDIEOffset (sc, die_offset);
-
- die_offset = die->GetAttributeValueAsReference(this, cu, DW_AT_abstract_origin, DW_INVALID_OFFSET);
- if (die_offset != DW_INVALID_OFFSET)
- return GetClangDeclContextForDIEOffset (sc, die_offset);
-
- Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
- if (log)
- GetObjectFile()->GetModule()->LogMessage(log, "SymbolFileDWARF::GetClangDeclContextForDIE (die = 0x%8.8x) %s '%s'", die->GetOffset(), DW_TAG_value_to_name(die->Tag()), die->GetName(this, cu));
- // This is the DIE we want. Parse it, then query our map.
- bool assert_not_being_parsed = true;
- ResolveTypeUID (cu, die, assert_not_being_parsed);
-
- clang_decl_ctx = GetCachedClangDeclContextForDIE (die);
-
- return clang_decl_ctx;
-}
-
-clang::DeclContext *
-SymbolFileDWARF::GetClangDeclContextContainingDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die, const DWARFDebugInfoEntry **decl_ctx_die_copy)
-{
- if (m_clang_tu_decl == NULL)
- m_clang_tu_decl = GetClangASTContext().getASTContext()->getTranslationUnitDecl();
-
- const DWARFDebugInfoEntry *decl_ctx_die = GetDeclContextDIEContainingDIE (cu, die);
-
- if (decl_ctx_die_copy)
- *decl_ctx_die_copy = decl_ctx_die;
-
- if (decl_ctx_die)
- {
-
- DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find (decl_ctx_die);
- if (pos != m_die_to_decl_ctx.end())
- return pos->second;
-
- switch (decl_ctx_die->Tag())
- {
- case DW_TAG_compile_unit:
- return m_clang_tu_decl;
-
- case DW_TAG_namespace:
- return ResolveNamespaceDIE (cu, decl_ctx_die);
- break;
-
- case DW_TAG_structure_type:
- case DW_TAG_union_type:
- case DW_TAG_class_type:
- {
- Type* type = ResolveType (cu, decl_ctx_die);
- if (type)
- {
- clang::DeclContext *decl_ctx = type->GetClangForwardType().GetDeclContextForType ();
- if (decl_ctx)
- {
- LinkDeclContextToDIE (decl_ctx, decl_ctx_die);
- if (decl_ctx)
- return decl_ctx;
- }
- }
- }
- break;
-
- default:
- break;
- }
- }
- return m_clang_tu_decl;
-}
-
-const DWARFDebugInfoEntry *
-SymbolFileDWARF::GetDeclContextDIEContainingDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die)
+DWARFDIE
+SymbolFileDWARF::GetDeclContextDIEContainingDIE (const DWARFDIE &orig_die)
{
- if (cu && die)
+ if (orig_die)
{
- const DWARFDebugInfoEntry * const decl_die = die;
+ DWARFDIE die = orig_die;
- while (die != NULL)
+ while (die)
{
// If this is the original DIE that we are searching for a declaration
// for, then don't look in the cache as we don't want our own decl
// context to be our decl context...
- if (decl_die != die)
+ if (orig_die != die)
{
- switch (die->Tag())
+ switch (die.Tag())
{
case DW_TAG_compile_unit:
case DW_TAG_namespace:
case DW_TAG_structure_type:
case DW_TAG_union_type:
case DW_TAG_class_type:
+ case DW_TAG_lexical_block:
+ case DW_TAG_subprogram:
return die;
default:
break;
}
}
-
- dw_offset_t die_offset = die->GetAttributeValueAsReference(this, cu, DW_AT_specification, DW_INVALID_OFFSET);
- if (die_offset != DW_INVALID_OFFSET)
+
+ DWARFDIE spec_die = die.GetReferencedDIE(DW_AT_specification);
+ if (spec_die)
{
- DWARFCompileUnit *spec_cu = cu;
- const DWARFDebugInfoEntry *spec_die = DebugInfo()->GetDIEPtrWithCompileUnitHint (die_offset, &spec_cu);
- const DWARFDebugInfoEntry *spec_die_decl_ctx_die = GetDeclContextDIEContainingDIE (spec_cu, spec_die);
- if (spec_die_decl_ctx_die)
- return spec_die_decl_ctx_die;
+ DWARFDIE decl_ctx_die = GetDeclContextDIEContainingDIE(spec_die);
+ if (decl_ctx_die)
+ return decl_ctx_die;
}
-
- die_offset = die->GetAttributeValueAsReference(this, cu, DW_AT_abstract_origin, DW_INVALID_OFFSET);
- if (die_offset != DW_INVALID_OFFSET)
+
+ DWARFDIE abs_die = die.GetReferencedDIE(DW_AT_abstract_origin);
+ if (abs_die)
{
- DWARFCompileUnit *abs_cu = cu;
- const DWARFDebugInfoEntry *abs_die = DebugInfo()->GetDIEPtrWithCompileUnitHint (die_offset, &abs_cu);
- const DWARFDebugInfoEntry *abs_die_decl_ctx_die = GetDeclContextDIEContainingDIE (abs_cu, abs_die);
- if (abs_die_decl_ctx_die)
- return abs_die_decl_ctx_die;
+ DWARFDIE decl_ctx_die = GetDeclContextDIEContainingDIE(abs_die);
+ if (decl_ctx_die)
+ return decl_ctx_die;
}
-
- die = die->GetParent();
+
+ die = die.GetParent();
}
}
- return NULL;
+ return DWARFDIE();
}
@@ -5075,7 +3376,7 @@ SymbolFileDWARF::Supports_DW_AT_APPLE_objc_complete_type (DWARFCompileUnit *cu)
// 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 DWARFDebugInfoEntry *die,
+SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE (const DWARFDIE &die,
const ConstString &type_name,
bool must_be_implementation)
{
@@ -5105,15 +3406,13 @@ SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry
const size_t num_matches = die_offsets.size();
- DWARFCompileUnit* type_cu = NULL;
- const DWARFDebugInfoEntry* type_die = NULL;
if (num_matches)
{
DWARFDebugInfo* debug_info = DebugInfo();
for (size_t i=0; i<num_matches; ++i)
{
- const dw_offset_t die_offset = die_offsets[i];
- type_die = debug_info->GetDIEPtrWithCompileUnitHint (die_offset, &type_cu);
+ const DIERef& die_ref = die_offsets[i];
+ DWARFDIE type_die = debug_info->GetDIE (die_ref);
if (type_die)
{
@@ -5122,7 +3421,7 @@ SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry
// Don't try and resolve the DIE we are looking for with the DIE itself!
if (type_die != die)
{
- switch (type_die->Tag())
+ switch (type_die.Tag())
{
case DW_TAG_class_type:
case DW_TAG_structure_type:
@@ -5135,22 +3434,22 @@ SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry
if (try_resolving_type)
{
- if (must_be_implementation && type_cu->Supports_DW_AT_APPLE_objc_complete_type())
- try_resolving_type = type_die->GetAttributeValueAsUnsigned (this, type_cu, DW_AT_APPLE_objc_complete_type, 0);
+ if (must_be_implementation && type_die.Supports_DW_AT_APPLE_objc_complete_type())
+ try_resolving_type = type_die.GetAttributeValueAsUnsigned (DW_AT_APPLE_objc_complete_type, 0);
if (try_resolving_type)
{
- Type *resolved_type = ResolveType (type_cu, type_die, false);
+ Type *resolved_type = ResolveType (type_die, false, true);
if (resolved_type && resolved_type != DIE_IS_BEING_PARSED)
{
DEBUG_PRINTF ("resolved 0x%8.8" PRIx64 " from %s to 0x%8.8" PRIx64 " (cu 0x%8.8" PRIx64 ")\n",
- MakeUserID(die->GetOffset()),
+ die.GetID(),
m_obj_file->GetFileSpec().GetFilename().AsCString("<Unknown>"),
- MakeUserID(type_die->GetOffset()),
- MakeUserID(type_cu->GetOffset()));
+ type_die.GetID(),
+ type_cu->GetID());
if (die)
- m_die_to_type[die] = resolved_type;
+ GetDIEToType()[die.GetDIE()] = resolved_type;
type_sp = resolved_type->shared_from_this();
break;
}
@@ -5162,7 +3461,7 @@ SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry
if (m_using_apple_tables)
{
GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_types accelerator table had bad die 0x%8.8x for '%s')\n",
- die_offset, type_name.GetCString());
+ die_ref.die_offset, type_name.GetCString());
}
}
@@ -5185,19 +3484,12 @@ SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry
// when they don't.
//----------------------------------------------------------------------
bool
-SymbolFileDWARF::DIEDeclContextsMatch (DWARFCompileUnit* cu1, const DWARFDebugInfoEntry *die1,
- DWARFCompileUnit* cu2, const DWARFDebugInfoEntry *die2)
+SymbolFileDWARF::DIEDeclContextsMatch (const DWARFDIE &die1,
+ const DWARFDIE &die2)
{
if (die1 == die2)
return true;
-#if defined (LLDB_CONFIGURATION_DEBUG)
- // You can't and shouldn't call this function with a compile unit from
- // two different SymbolFileDWARF instances.
- assert (DebugInfo()->ContainsCompileUnit (cu1));
- assert (DebugInfo()->ContainsCompileUnit (cu2));
-#endif
-
DWARFDIECollection decl_ctx_1;
DWARFDIECollection decl_ctx_2;
//The declaration DIE stack is a stack of the declaration context
@@ -5215,8 +3507,8 @@ SymbolFileDWARF::DIEDeclContextsMatch (DWARFCompileUnit* cu1, const DWARFDebugIn
// all the way back to the compiler unit.
// First lets grab the decl contexts for both DIEs
- die1->GetDeclContextDIEs (this, cu1, decl_ctx_1);
- die2->GetDeclContextDIEs (this, cu2, decl_ctx_2);
+ die1.GetDeclContextDIEs (decl_ctx_1);
+ die2.GetDeclContextDIEs (decl_ctx_2);
// Make sure the context arrays have the same size, otherwise
// we are done
const size_t count1 = decl_ctx_1.Size();
@@ -5226,32 +3518,32 @@ SymbolFileDWARF::DIEDeclContextsMatch (DWARFCompileUnit* cu1, const DWARFDebugIn
// Make sure the DW_TAG values match all the way back up the
// compile unit. If they don't, then we are done.
- const DWARFDebugInfoEntry *decl_ctx_die1;
- const DWARFDebugInfoEntry *decl_ctx_die2;
+ DWARFDIE decl_ctx_die1;
+ DWARFDIE decl_ctx_die2;
size_t i;
for (i=0; i<count1; i++)
{
- decl_ctx_die1 = decl_ctx_1.GetDIEPtrAtIndex (i);
- decl_ctx_die2 = decl_ctx_2.GetDIEPtrAtIndex (i);
- if (decl_ctx_die1->Tag() != decl_ctx_die2->Tag())
+ decl_ctx_die1 = decl_ctx_1.GetDIEAtIndex (i);
+ decl_ctx_die2 = decl_ctx_2.GetDIEAtIndex (i);
+ if (decl_ctx_die1.Tag() != decl_ctx_die2.Tag())
return false;
}
#if defined LLDB_CONFIGURATION_DEBUG
// Make sure the top item in the decl context die array is always
// DW_TAG_compile_unit. If it isn't then something went wrong in
- // the DWARFDebugInfoEntry::GetDeclContextDIEs() function...
- assert (decl_ctx_1.GetDIEPtrAtIndex (count1 - 1)->Tag() == DW_TAG_compile_unit);
+ // the DWARFDIE::GetDeclContextDIEs() function...
+ assert (decl_ctx_1.GetDIEAtIndex (count1 - 1).Tag() == DW_TAG_compile_unit);
#endif
// 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.GetDIEPtrAtIndex (i);
- decl_ctx_die2 = decl_ctx_2.GetDIEPtrAtIndex (i);
- const char *name1 = decl_ctx_die1->GetName(this, cu1);
- const char *name2 = decl_ctx_die2->GetName(this, cu2);
+ decl_ctx_die1 = decl_ctx_1.GetDIEAtIndex (i);
+ decl_ctx_die2 = decl_ctx_2.GetDIEAtIndex (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 the same!
if (name1 == name2)
@@ -5338,22 +3630,20 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext &
const size_t num_matches = die_offsets.size();
- DWARFCompileUnit* type_cu = NULL;
- const DWARFDebugInfoEntry* type_die = NULL;
if (num_matches)
{
DWARFDebugInfo* debug_info = DebugInfo();
for (size_t i=0; i<num_matches; ++i)
{
- const dw_offset_t die_offset = die_offsets[i];
- type_die = debug_info->GetDIEPtrWithCompileUnitHint (die_offset, &type_cu);
+ const DIERef& die_ref = die_offsets[i];
+ DWARFDIE type_die = debug_info->GetDIE (die_ref);
if (type_die)
{
bool try_resolving_type = false;
// Don't try and resolve the DIE we are looking for with the DIE itself!
- const dw_tag_t type_tag = type_die->Tag();
+ const dw_tag_t type_tag = type_die.Tag();
// Make sure the tags match
if (type_tag == tag)
{
@@ -5386,7 +3676,7 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext &
if (try_resolving_type)
{
DWARFDeclContext type_dwarf_decl_ctx;
- type_die->GetDWARFDeclContext (this, type_cu, type_dwarf_decl_ctx);
+ type_die.GetDWARFDeclContext (type_dwarf_decl_ctx);
if (log)
{
@@ -5394,14 +3684,14 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext &
"SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(tag=%s, qualified-name='%s') trying die=0x%8.8x (%s)",
DW_TAG_value_to_name(dwarf_decl_ctx[0].tag),
dwarf_decl_ctx.GetQualifiedName(),
- type_die->GetOffset(),
+ type_die.GetOffset(),
type_dwarf_decl_ctx.GetQualifiedName());
}
// Make sure the decl contexts match all the way up
if (dwarf_decl_ctx == type_dwarf_decl_ctx)
{
- Type *resolved_type = ResolveType (type_cu, type_die, false);
+ Type *resolved_type = ResolveType (type_die, false);
if (resolved_type && resolved_type != DIE_IS_BEING_PARSED)
{
type_sp = resolved_type->shared_from_this();
@@ -5414,12 +3704,12 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext &
if (log)
{
std::string qualified_name;
- type_die->GetQualifiedName(this, type_cu, qualified_name);
+ type_die.GetQualifiedName(qualified_name);
GetObjectFile()->GetModule()->LogMessage (log,
"SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(tag=%s, qualified-name='%s') ignoring die=0x%8.8x (%s)",
DW_TAG_value_to_name(dwarf_decl_ctx[0].tag),
dwarf_decl_ctx.GetQualifiedName(),
- type_die->GetOffset(),
+ type_die.GetOffset(),
qualified_name.c_str());
}
}
@@ -5429,7 +3719,7 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext &
if (m_using_apple_tables)
{
GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_types accelerator table had bad die 0x%8.8x for '%s')\n",
- die_offset, type_name.GetCString());
+ die_ref.die_offset, type_name.GetCString());
}
}
@@ -5440,1744 +3730,32 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext &
return type_sp;
}
-bool
-SymbolFileDWARF::CopyUniqueClassMethodTypes (SymbolFileDWARF *src_symfile,
- Type *class_type,
- DWARFCompileUnit* src_cu,
- const DWARFDebugInfoEntry *src_class_die,
- DWARFCompileUnit* dst_cu,
- const DWARFDebugInfoEntry *dst_class_die,
- DWARFDIECollection &failures)
-{
- if (!class_type || !src_cu || !src_class_die || !dst_cu || !dst_class_die)
- return false;
- if (src_class_die->Tag() != dst_class_die->Tag())
- return false;
-
- // We need to complete the class type so we can get all of the method types
- // parsed so we can then unique those types to their equivalent counterparts
- // in "dst_cu" and "dst_class_die"
- class_type->GetClangFullType();
-
- const DWARFDebugInfoEntry *src_die;
- const DWARFDebugInfoEntry *dst_die;
- UniqueCStringMap<const DWARFDebugInfoEntry *> src_name_to_die;
- UniqueCStringMap<const DWARFDebugInfoEntry *> dst_name_to_die;
- UniqueCStringMap<const DWARFDebugInfoEntry *> src_name_to_die_artificial;
- UniqueCStringMap<const DWARFDebugInfoEntry *> dst_name_to_die_artificial;
- for (src_die = src_class_die->GetFirstChild(); src_die != NULL; src_die = src_die->GetSibling())
- {
- if (src_die->Tag() == DW_TAG_subprogram)
- {
- // Make sure this is a declaration and not a concrete instance by looking
- // for DW_AT_declaration set to 1. Sometimes concrete function instances
- // are placed inside the class definitions and shouldn't be included in
- // the list of things are are tracking here.
- if (src_die->GetAttributeValueAsUnsigned(src_symfile, src_cu, DW_AT_declaration, 0) == 1)
- {
- const char *src_name = src_die->GetMangledName (src_symfile, src_cu);
- if (src_name)
- {
- ConstString src_const_name(src_name);
- if (src_die->GetAttributeValueAsUnsigned(src_symfile, src_cu, DW_AT_artificial, 0))
- src_name_to_die_artificial.Append(src_const_name.GetCString(), src_die);
- else
- src_name_to_die.Append(src_const_name.GetCString(), src_die);
- }
- }
- }
- }
- for (dst_die = dst_class_die->GetFirstChild(); dst_die != NULL; dst_die = dst_die->GetSibling())
- {
- if (dst_die->Tag() == DW_TAG_subprogram)
- {
- // Make sure this is a declaration and not a concrete instance by looking
- // for DW_AT_declaration set to 1. Sometimes concrete function instances
- // are placed inside the class definitions and shouldn't be included in
- // the list of things are are tracking here.
- if (dst_die->GetAttributeValueAsUnsigned(this, dst_cu, DW_AT_declaration, 0) == 1)
- {
- const char *dst_name = dst_die->GetMangledName (this, dst_cu);
- if (dst_name)
- {
- ConstString dst_const_name(dst_name);
- if (dst_die->GetAttributeValueAsUnsigned(this, dst_cu, DW_AT_artificial, 0))
- dst_name_to_die_artificial.Append(dst_const_name.GetCString(), dst_die);
- else
- dst_name_to_die.Append(dst_const_name.GetCString(), dst_die);
- }
- }
- }
- }
- const uint32_t src_size = src_name_to_die.GetSize ();
- const uint32_t dst_size = dst_name_to_die.GetSize ();
- Log *log (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO | DWARF_LOG_TYPE_COMPLETION));
-
- // Is everything kosher so we can go through the members at top speed?
- bool fast_path = true;
-
- if (src_size != dst_size)
- {
- if (src_size != 0 && dst_size != 0)
- {
- if (log)
- log->Printf("warning: trying to unique class DIE 0x%8.8x to 0x%8.8x, but they didn't have the same size (src=%d, dst=%d)",
- src_class_die->GetOffset(),
- dst_class_die->GetOffset(),
- src_size,
- dst_size);
- }
-
- fast_path = false;
- }
-
- uint32_t idx;
-
- if (fast_path)
- {
- for (idx = 0; idx < src_size; ++idx)
- {
- src_die = src_name_to_die.GetValueAtIndexUnchecked (idx);
- dst_die = dst_name_to_die.GetValueAtIndexUnchecked (idx);
-
- if (src_die->Tag() != dst_die->Tag())
- {
- if (log)
- log->Printf("warning: tried to unique class DIE 0x%8.8x to 0x%8.8x, but 0x%8.8x (%s) tags didn't match 0x%8.8x (%s)",
- src_class_die->GetOffset(),
- dst_class_die->GetOffset(),
- src_die->GetOffset(),
- DW_TAG_value_to_name(src_die->Tag()),
- dst_die->GetOffset(),
- DW_TAG_value_to_name(src_die->Tag()));
- fast_path = false;
- }
-
- const char *src_name = src_die->GetMangledName (src_symfile, src_cu);
- const char *dst_name = dst_die->GetMangledName (this, dst_cu);
-
- // Make sure the names match
- if (src_name == dst_name || (strcmp (src_name, dst_name) == 0))
- continue;
-
- if (log)
- log->Printf("warning: tried to unique class DIE 0x%8.8x to 0x%8.8x, but 0x%8.8x (%s) names didn't match 0x%8.8x (%s)",
- src_class_die->GetOffset(),
- dst_class_die->GetOffset(),
- src_die->GetOffset(),
- src_name,
- dst_die->GetOffset(),
- dst_name);
-
- fast_path = false;
- }
- }
-
- // Now do the work of linking the DeclContexts and Types.
- if (fast_path)
- {
- // We can do this quickly. Just run across the tables index-for-index since
- // we know each node has matching names and tags.
- for (idx = 0; idx < src_size; ++idx)
- {
- src_die = src_name_to_die.GetValueAtIndexUnchecked (idx);
- dst_die = dst_name_to_die.GetValueAtIndexUnchecked (idx);
-
- clang::DeclContext *src_decl_ctx = src_symfile->m_die_to_decl_ctx[src_die];
- if (src_decl_ctx)
- {
- if (log)
- log->Printf ("uniquing decl context %p from 0x%8.8x for 0x%8.8x",
- static_cast<void*>(src_decl_ctx),
- src_die->GetOffset(), dst_die->GetOffset());
- LinkDeclContextToDIE (src_decl_ctx, dst_die);
- }
- else
- {
- if (log)
- log->Printf ("warning: tried to unique decl context from 0x%8.8x for 0x%8.8x, but none was found",
- src_die->GetOffset(), dst_die->GetOffset());
- }
-
- Type *src_child_type = m_die_to_type[src_die];
- if (src_child_type)
- {
- if (log)
- log->Printf ("uniquing type %p (uid=0x%" PRIx64 ") from 0x%8.8x for 0x%8.8x",
- static_cast<void*>(src_child_type),
- src_child_type->GetID(),
- src_die->GetOffset(), dst_die->GetOffset());
- m_die_to_type[dst_die] = src_child_type;
- }
- else
- {
- if (log)
- log->Printf ("warning: tried to unique lldb_private::Type from 0x%8.8x for 0x%8.8x, but none was found", src_die->GetOffset(), dst_die->GetOffset());
- }
- }
- }
- else
- {
- // We must do this slowly. For each member of the destination, look
- // up a member in the source with the same name, check its tag, and
- // unique them if everything matches up. Report failures.
-
- if (!src_name_to_die.IsEmpty() && !dst_name_to_die.IsEmpty())
- {
- src_name_to_die.Sort();
-
- for (idx = 0; idx < dst_size; ++idx)
- {
- const char *dst_name = dst_name_to_die.GetCStringAtIndex(idx);
- dst_die = dst_name_to_die.GetValueAtIndexUnchecked(idx);
- src_die = src_name_to_die.Find(dst_name, NULL);
-
- if (src_die && (src_die->Tag() == dst_die->Tag()))
- {
- clang::DeclContext *src_decl_ctx = src_symfile->m_die_to_decl_ctx[src_die];
- if (src_decl_ctx)
- {
- if (log)
- log->Printf ("uniquing decl context %p from 0x%8.8x for 0x%8.8x",
- static_cast<void*>(src_decl_ctx),
- src_die->GetOffset(),
- dst_die->GetOffset());
- LinkDeclContextToDIE (src_decl_ctx, dst_die);
- }
- else
- {
- if (log)
- log->Printf ("warning: tried to unique decl context from 0x%8.8x for 0x%8.8x, but none was found", src_die->GetOffset(), dst_die->GetOffset());
- }
-
- Type *src_child_type = m_die_to_type[src_die];
- if (src_child_type)
- {
- if (log)
- log->Printf ("uniquing type %p (uid=0x%" PRIx64 ") from 0x%8.8x for 0x%8.8x",
- static_cast<void*>(src_child_type),
- src_child_type->GetID(),
- src_die->GetOffset(),
- dst_die->GetOffset());
- m_die_to_type[dst_die] = src_child_type;
- }
- else
- {
- if (log)
- log->Printf ("warning: tried to unique lldb_private::Type from 0x%8.8x for 0x%8.8x, but none was found", src_die->GetOffset(), dst_die->GetOffset());
- }
- }
- else
- {
- if (log)
- log->Printf ("warning: couldn't find a match for 0x%8.8x", dst_die->GetOffset());
-
- failures.Append(dst_die);
- }
- }
- }
- }
-
- const uint32_t src_size_artificial = src_name_to_die_artificial.GetSize ();
- const uint32_t dst_size_artificial = dst_name_to_die_artificial.GetSize ();
-
- UniqueCStringMap<const DWARFDebugInfoEntry *> name_to_die_artificial_not_in_src;
-
- if (src_size_artificial && dst_size_artificial)
- {
- dst_name_to_die_artificial.Sort();
-
- for (idx = 0; idx < src_size_artificial; ++idx)
- {
- const char *src_name_artificial = src_name_to_die_artificial.GetCStringAtIndex(idx);
- src_die = src_name_to_die_artificial.GetValueAtIndexUnchecked (idx);
- dst_die = dst_name_to_die_artificial.Find(src_name_artificial, NULL);
-
- if (dst_die)
- {
- // Both classes have the artificial types, link them
- clang::DeclContext *src_decl_ctx = m_die_to_decl_ctx[src_die];
- if (src_decl_ctx)
- {
- if (log)
- log->Printf ("uniquing decl context %p from 0x%8.8x for 0x%8.8x",
- static_cast<void*>(src_decl_ctx),
- src_die->GetOffset(), dst_die->GetOffset());
- LinkDeclContextToDIE (src_decl_ctx, dst_die);
- }
- else
- {
- if (log)
- log->Printf ("warning: tried to unique decl context from 0x%8.8x for 0x%8.8x, but none was found", src_die->GetOffset(), dst_die->GetOffset());
- }
-
- Type *src_child_type = m_die_to_type[src_die];
- if (src_child_type)
- {
- if (log)
- log->Printf ("uniquing type %p (uid=0x%" PRIx64 ") from 0x%8.8x for 0x%8.8x",
- static_cast<void*>(src_child_type),
- src_child_type->GetID(),
- src_die->GetOffset(), dst_die->GetOffset());
- m_die_to_type[dst_die] = src_child_type;
- }
- else
- {
- if (log)
- log->Printf ("warning: tried to unique lldb_private::Type from 0x%8.8x for 0x%8.8x, but none was found", src_die->GetOffset(), dst_die->GetOffset());
- }
- }
- }
- }
-
- if (dst_size_artificial)
- {
- for (idx = 0; idx < dst_size_artificial; ++idx)
- {
- const char *dst_name_artificial = dst_name_to_die_artificial.GetCStringAtIndex(idx);
- dst_die = dst_name_to_die_artificial.GetValueAtIndexUnchecked (idx);
- if (log)
- log->Printf ("warning: need to create artificial method for 0x%8.8x for method '%s'", dst_die->GetOffset(), dst_name_artificial);
-
- failures.Append(dst_die);
- }
- }
-
- return (failures.Size() != 0);
-}
-
TypeSP
-SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool *type_is_new_ptr)
+SymbolFileDWARF::ParseType (const SymbolContext& sc, const DWARFDIE &die, bool *type_is_new_ptr)
{
TypeSP type_sp;
- if (type_is_new_ptr)
- *type_is_new_ptr = false;
-
-#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE)
- static DIEStack g_die_stack;
- DIEStack::ScopedPopper scoped_die_logger(g_die_stack);
-#endif
-
- AccessType accessibility = eAccessNone;
- if (die != NULL)
+ if (die)
{
- Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
- if (log)
- {
- const DWARFDebugInfoEntry *context_die;
- clang::DeclContext *context = GetClangDeclContextContainingDIE (dwarf_cu, die, &context_die);
-
- 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(),
- DW_TAG_value_to_name(die->Tag()),
- die->GetName(this, dwarf_cu));
-
-#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE)
- scoped_die_logger.Push (dwarf_cu, die);
- g_die_stack.LogDIEs(log, this);
-#endif
- }
-//
-// Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
-// if (log && dwarf_cu)
-// {
-// StreamString s;
-// die->DumpLocation (this, dwarf_cu, s);
-// GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDwarf::%s %s", __FUNCTION__, s.GetData());
-//
-// }
-
- Type *type_ptr = m_die_to_type.lookup (die);
- TypeList* type_list = GetTypeList();
- if (type_ptr == NULL)
- {
- ClangASTContext &ast = GetClangASTContext();
- if (type_is_new_ptr)
- *type_is_new_ptr = true;
-
- const dw_tag_t tag = die->Tag();
-
- bool is_forward_declaration = false;
- DWARFDebugInfoEntry::Attributes attributes;
- const char *type_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;
- ClangASTType clang_type;
- DWARFFormValue form_value;
-
- dw_attr_t attr;
-
- switch (tag)
- {
- case DW_TAG_base_type:
- case DW_TAG_pointer_type:
- case DW_TAG_reference_type:
- case DW_TAG_rvalue_reference_type:
- case DW_TAG_typedef:
- 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
- m_die_to_type[die] = DIE_IS_BEING_PARSED;
-
- const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes);
- uint32_t encoding = 0;
- lldb::user_id_t encoding_uid = LLDB_INVALID_UID;
-
- if (num_attributes > 0)
- {
- uint32_t i;
- for (i=0; i<num_attributes; ++i)
- {
- attr = attributes.AttributeAtIndex(i);
- if (attributes.ExtractFormValueAtIndex(this, 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(&get_debug_str_data());
- // Work around a bug in llvm-gcc where they give a name to a reference type which doesn't
- // include the "&"...
- if (tag == DW_TAG_reference_type)
- {
- if (strchr (type_name_cstr, '&') == NULL)
- type_name_cstr = NULL;
- }
- 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.Reference(); break;
- default:
- case DW_AT_sibling:
- break;
- }
- }
- }
- }
-
- DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\") type => 0x%8.8lx\n", MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type_name_cstr, encoding_uid);
-
- switch (tag)
- {
- default:
- break;
-
- 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 = ast.GetBasicType(eBasicTypeNullPtr);
- break;
- }
- // Fall through to base type below in case we can handle the type there...
-
- case DW_TAG_base_type:
- resolve_state = Type::eResolveStateFull;
- clang_type = ast.GetBuiltinTypeForDWARFEncodingAndBitSize (type_name_cstr,
- encoding,
- byte_size * 8);
- 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;
- }
-
- if (!clang_type && (encoding_data_type == Type::eEncodingIsPointerUID || encoding_data_type == Type::eEncodingIsTypedefUID) && sc.comp_unit != NULL)
- {
- bool translation_unit_is_objc = (sc.comp_unit->GetLanguage() == eLanguageTypeObjC || sc.comp_unit->GetLanguage() == eLanguageTypeObjC_plus_plus);
-
- 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 (type_name_const_str == g_objc_type_name_id)
- {
- if (log)
- GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is Objective C 'id' built-in type.",
- die->GetOffset(),
- DW_TAG_value_to_name(die->Tag()),
- die->GetName(this, dwarf_cu));
- clang_type = ast.GetBasicType(eBasicTypeObjCID);
- encoding_data_type = Type::eEncodingIsUID;
- encoding_uid = LLDB_INVALID_UID;
- resolve_state = Type::eResolveStateFull;
-
- }
- else if (type_name_const_str == g_objc_type_name_Class)
- {
- if (log)
- GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is Objective C 'Class' built-in type.",
- die->GetOffset(),
- DW_TAG_value_to_name(die->Tag()),
- die->GetName(this, dwarf_cu));
- clang_type = ast.GetBasicType(eBasicTypeObjCClass);
- encoding_data_type = Type::eEncodingIsUID;
- encoding_uid = LLDB_INVALID_UID;
- resolve_state = Type::eResolveStateFull;
- }
- else if (type_name_const_str == g_objc_type_name_selector)
- {
- if (log)
- GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is Objective C 'selector' built-in type.",
- die->GetOffset(),
- DW_TAG_value_to_name(die->Tag()),
- die->GetName(this, dwarf_cu));
- clang_type = ast.GetBasicType(eBasicTypeObjCSel);
- encoding_data_type = Type::eEncodingIsUID;
- encoding_uid = LLDB_INVALID_UID;
- resolve_state = Type::eResolveStateFull;
- }
- }
- else if (encoding_data_type == Type::eEncodingIsPointerUID && encoding_uid != LLDB_INVALID_UID)
- {
- // Clang sometimes erroneously emits id as objc_object*. In that case we fix up the type to "id".
-
- DWARFDebugInfoEntry* encoding_die = dwarf_cu->GetDIEPtr(encoding_uid);
-
- if (encoding_die && encoding_die->Tag() == DW_TAG_structure_type)
- {
- if (const char *struct_name = encoding_die->GetAttributeValueAsString(this, dwarf_cu, DW_AT_name, NULL))
- {
- if (!strcmp(struct_name, "objc_object"))
- {
- if (log)
- GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is 'objc_object*', which we overrode to 'id'.",
- die->GetOffset(),
- DW_TAG_value_to_name(die->Tag()),
- die->GetName(this, dwarf_cu));
- clang_type = ast.GetBasicType(eBasicTypeObjCID);
- encoding_data_type = Type::eEncodingIsUID;
- encoding_uid = LLDB_INVALID_UID;
- resolve_state = Type::eResolveStateFull;
- }
- }
- }
- }
- }
- }
-
- type_sp.reset( new Type (MakeUserID(die->GetOffset()),
- this,
- type_name_const_str,
- byte_size,
- NULL,
- encoding_uid,
- encoding_data_type,
- &decl,
- clang_type,
- resolve_state));
-
- m_die_to_type[die] = type_sp.get();
-
-// Type* encoding_type = GetUniquedTypeForDIEOffset(encoding_uid, type_sp, NULL, 0, 0, false);
-// if (encoding_type != NULL)
-// {
-// if (encoding_type != DIE_IS_BEING_PARSED)
-// type_sp->SetEncodingType(encoding_type);
-// else
-// m_indirect_fixups.push_back(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
- m_die_to_type[die] = DIE_IS_BEING_PARSED;
- bool byte_size_valid = false;
-
- LanguageType class_language = eLanguageTypeUnknown;
- bool is_complete_objc_class = false;
- //bool struct_is_class = false;
- const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes);
- if (num_attributes > 0)
- {
- uint32_t i;
- for (i=0; i<num_attributes; ++i)
- {
- attr = attributes.AttributeAtIndex(i);
- if (attributes.ExtractFormValueAtIndex(this, i, form_value))
- {
- switch (attr)
- {
- case DW_AT_decl_file:
- if (dwarf_cu->DW_AT_decl_file_attributes_are_invalid())
- {
- // llvm-gcc outputs invalid DW_AT_decl_file attributes that always
- // point to the compile unit file, so we clear this invalid value
- // so that we can still unique types efficiently.
- decl.SetFile(FileSpec ("<invalid>", false));
- }
- else
- 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(&get_debug_str_data());
- 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_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;
- }
- }
- }
- }
-
- // 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());
-
- // Only try and unique the type if it has a name.
- if (type_name_const_str &&
- GetUniqueDWARFASTTypeMap().Find (type_name_const_str,
- this,
- dwarf_cu,
- die,
- decl,
- byte_size_valid ? byte_size : -1,
- *unique_ast_entry_ap))
- {
- // We have already parsed this type or from another
- // compile unit. GCC loves to use the "one definition
- // rule" which can result in multiple definitions
- // of the same class over and over in each compile
- // unit.
- type_sp = unique_ast_entry_ap->m_type_sp;
- if (type_sp)
- {
- m_die_to_type[die] = type_sp.get();
- return type_sp;
- }
- }
-
- DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", MakeUserID(die->GetOffset()), 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 (byte_size_valid && byte_size == 0 && type_name_cstr &&
- die->HasChildren() == false &&
- 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;
- }
-
- if (class_language == eLanguageTypeObjC ||
- class_language == eLanguageTypeObjC_plus_plus)
- {
- if (!is_complete_objc_class && Supports_DW_AT_APPLE_objc_complete_type(dwarf_cu))
- {
- // 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 = FindCompleteObjCDefinitionTypeForDIE (die, type_name_const_str, true);
-
- if (!type_sp && GetDebugMapSymfile ())
- {
- // We weren't able to find a full declaration in
- // this DWARF, see if we have a declaration anywhere
- // else...
- type_sp = m_debug_map_symfile->FindCompleteObjCDefinitionTypeForDIE (die, type_name_const_str, true);
- }
-
- if (type_sp)
- {
- if (log)
- {
- 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());
- }
-
- // 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
- m_die_to_type[die] = type_sp.get();
- return type_sp;
- }
- }
- }
-
-
- 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)
- {
- 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);
- }
-
- DWARFDeclContext die_decl_ctx;
- die->GetDWARFDeclContext(this, dwarf_cu, die_decl_ctx);
-
- //type_sp = FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str);
- type_sp = FindDefinitionTypeForDWARFDeclContext (die_decl_ctx);
-
- if (!type_sp && GetDebugMapSymfile ())
- {
- // We weren't able to find a full declaration in
- // this DWARF, see if we have a declaration anywhere
- // else...
- type_sp = m_debug_map_symfile->FindDefinitionTypeForDWARFDeclContext (die_decl_ctx);
- }
-
- if (type_sp)
- {
- if (log)
- {
- 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());
- }
-
- // 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
- m_die_to_type[die] = type_sp.get();
- return type_sp;
- }
- }
- assert (tag_decl_kind != -1);
- bool clang_type_was_created = false;
- clang_type.SetClangType(ast.getASTContext(), m_forward_decl_die_to_clang_type.lookup (die));
- if (!clang_type)
- {
- const DWARFDebugInfoEntry *decl_ctx_die;
-
- clang::DeclContext *decl_ctx = GetClangDeclContextContainingDIE (dwarf_cu, die, &decl_ctx_die);
- 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;
- }
-
- ClangASTMetadata metadata;
- metadata.SetUserID(MakeUserID(die->GetOffset()));
- metadata.SetIsDynamicCXXType(ClassOrStructIsVirtual (dwarf_cu, die));
-
- if (type_name_cstr && strchr (type_name_cstr, '<'))
- {
- ClangASTContext::TemplateParameterInfos template_param_infos;
- if (ParseTemplateParameterInfos (dwarf_cu, die, template_param_infos))
- {
- clang::ClassTemplateDecl *class_template_decl = ParseClassTemplateDecl (decl_ctx,
- accessibility,
- type_name_cstr,
- tag_decl_kind,
- template_param_infos);
-
- clang::ClassTemplateSpecializationDecl *class_specialization_decl = ast.CreateClassTemplateSpecializationDecl (decl_ctx,
- class_template_decl,
- tag_decl_kind,
- template_param_infos);
- clang_type = ast.CreateClassTemplateSpecializationType (class_specialization_decl);
- clang_type_was_created = true;
-
- GetClangASTContext().SetMetadata (class_template_decl, metadata);
- GetClangASTContext().SetMetadata (class_specialization_decl, metadata);
- }
- }
-
- if (!clang_type_was_created)
- {
- clang_type_was_created = true;
- clang_type = 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(clang_type.GetDeclContextForType(), die);
- type_sp.reset (new Type (MakeUserID(die->GetOffset()),
- this,
- 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_symfile = this;
- unique_ast_entry_ap->m_cu = dwarf_cu;
- unique_ast_entry_ap->m_die = die;
- unique_ast_entry_ap->m_declaration = decl;
- unique_ast_entry_ap->m_byte_size = byte_size;
- GetUniqueDWARFASTTypeMap().Insert (type_name_const_str,
- *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
- const DWARFDebugInfoEntry *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 = NULL;
- is_forward_declaration = false;
- break;
- default:
- child_die = child_die->GetSibling();
- break;
- }
- }
- }
-
- 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() == false)
- {
- // No children for this struct/union/class, lets finish it
- clang_type.StartTagDeclarationDefinition ();
- clang_type.CompleteTagDeclarationDefinition ();
-
- if (tag == DW_TAG_structure_type) // this only applies in C
- {
- clang::RecordDecl *record_decl = clang_type.GetAsRecordDecl();
-
- if (record_decl)
- m_record_decl_to_layout_map.insert(std::make_pair(record_decl, 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)
- clang_type.StartTagDeclarationDefinition ();
-
- // 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::ResolveClangOpaqueTypeDefinition(Type *)"
- // When the definition needs to be defined.
- m_forward_decl_die_to_clang_type[die] = clang_type.GetOpaqueQualType();
- m_forward_decl_clang_type_to_die[clang_type.RemoveFastQualifiers().GetOpaqueQualType()] = die;
- clang_type.SetHasExternalStorage (true);
- }
- }
-
- }
- break;
-
- case DW_TAG_enumeration_type:
- {
- // Set a bit that lets us know that we are currently parsing this
- m_die_to_type[die] = DIE_IS_BEING_PARSED;
-
- lldb::user_id_t encoding_uid = DW_INVALID_OFFSET;
-
- const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes);
- if (num_attributes > 0)
- {
- uint32_t i;
-
- for (i=0; i<num_attributes; ++i)
- {
- attr = attributes.AttributeAtIndex(i);
- if (attributes.ExtractFormValueAtIndex(this, 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(&get_debug_str_data());
- type_name_const_str.SetCString(type_name_cstr);
- break;
- case DW_AT_type: encoding_uid = form_value.Reference(); 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: break; //is_forward_declaration = 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;
- }
- }
- }
-
- DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type_name_cstr);
-
- ClangASTType enumerator_clang_type;
- clang_type.SetClangType (ast.getASTContext(), m_forward_decl_die_to_clang_type.lookup (die));
- if (!clang_type)
- {
- if (encoding_uid != DW_INVALID_OFFSET)
- {
- Type *enumerator_type = ResolveTypeUID(encoding_uid);
- if (enumerator_type)
- enumerator_clang_type = enumerator_type->GetClangFullType();
- }
-
- if (!enumerator_clang_type)
- enumerator_clang_type = ast.GetBuiltinTypeForDWARFEncodingAndBitSize (NULL,
- DW_ATE_signed,
- byte_size * 8);
-
- clang_type = ast.CreateEnumerationType (type_name_cstr,
- GetClangDeclContextContainingDIE (dwarf_cu, die, NULL),
- decl,
- enumerator_clang_type);
- }
- else
- {
- enumerator_clang_type = clang_type.GetEnumerationIntegerType ();
- }
-
- LinkDeclContextToDIE(clang_type.GetDeclContextForType(), die);
-
- type_sp.reset( new Type (MakeUserID(die->GetOffset()),
- this,
- type_name_const_str,
- byte_size,
- NULL,
- encoding_uid,
- Type::eEncodingIsUID,
- &decl,
- clang_type,
- Type::eResolveStateForward));
-
- clang_type.StartTagDeclarationDefinition ();
- if (die->HasChildren())
- {
- SymbolContext cu_sc(GetCompUnitForDWARFCompUnit(dwarf_cu));
- bool is_signed = false;
- enumerator_clang_type.IsIntegerType(is_signed);
- ParseChildEnumerators(cu_sc, clang_type, is_signed, type_sp->GetByteSize(), dwarf_cu, die);
- }
- clang_type.CompleteTagDeclarationDefinition ();
- }
- }
- 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
- m_die_to_type[die] = DIE_IS_BEING_PARSED;
-
- //const char *mangled = NULL;
- dw_offset_t type_die_offset = DW_INVALID_OFFSET;
- bool is_variadic = false;
- bool is_inline = false;
- bool is_static = false;
- bool is_virtual = false;
- bool is_explicit = false;
- bool is_artificial = false;
- dw_offset_t specification_die_offset = DW_INVALID_OFFSET;
- dw_offset_t abstract_origin_die_offset = DW_INVALID_OFFSET;
- dw_offset_t object_pointer_die_offset = DW_INVALID_OFFSET;
-
- unsigned type_quals = 0;
- clang::StorageClass storage = clang::SC_None;//, Extern, Static, PrivateExtern
-
-
- const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes);
- if (num_attributes > 0)
- {
- uint32_t i;
- for (i=0; i<num_attributes; ++i)
- {
- attr = attributes.AttributeAtIndex(i);
- if (attributes.ExtractFormValueAtIndex(this, 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(&get_debug_str_data());
- type_name_const_str.SetCString(type_name_cstr);
- break;
-
- case DW_AT_linkage_name:
- case DW_AT_MIPS_linkage_name: break; // mangled = form_value.AsCString(&get_debug_str_data()); break;
- case DW_AT_type: type_die_offset = form_value.Reference(); 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_offset = form_value.Reference();
- break;
-
- case DW_AT_abstract_origin:
- abstract_origin_die_offset = form_value.Reference();
- 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;
- }
- }
- }
- }
-
- std::string object_pointer_name;
- if (object_pointer_die_offset != DW_INVALID_OFFSET)
- {
- // Get the name from the object pointer die
- StreamString s;
- if (DWARFDebugInfoEntry::GetName (this, dwarf_cu, object_pointer_die_offset, s))
- {
- object_pointer_name.assign(s.GetData());
- }
- }
-
- DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type_name_cstr);
-
- ClangASTType return_clang_type;
- Type *func_type = NULL;
-
- if (type_die_offset != DW_INVALID_OFFSET)
- func_type = ResolveTypeUID(type_die_offset);
-
- if (func_type)
- return_clang_type = func_type->GetClangForwardType();
- else
- return_clang_type = ast.GetBasicType(eBasicTypeVoid);
-
-
- std::vector<ClangASTType> function_param_types;
- std::vector<clang::ParmVarDecl*> function_param_decls;
-
- // Parse the function children for the parameters
-
- const DWARFDebugInfoEntry *decl_ctx_die = NULL;
- clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (dwarf_cu, die, &decl_ctx_die);
- const clang::Decl::Kind containing_decl_kind = containing_decl_ctx->getDeclKind();
-
- const 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;
-
- if (die->HasChildren())
- {
- bool skip_artificial = true;
- ParseChildParameters (sc,
- containing_decl_ctx,
- dwarf_cu,
- die,
- skip_artificial,
- is_static,
- is_variadic,
- function_param_types,
- function_param_decls,
- type_quals);
- }
-
- // clang_type will get the function prototype clang type after this call
- clang_type = ast.CreateFunctionType (return_clang_type,
- function_param_types.data(),
- function_param_types.size(),
- is_variadic,
- type_quals);
-
- bool ignore_containing_context = false;
-
- if (type_name_cstr)
- {
- bool type_handled = false;
- if (tag == DW_TAG_subprogram)
- {
- ObjCLanguageRuntime::MethodName objc_method (type_name_cstr, true);
- if (objc_method.IsValid(true))
- {
- ClangASTType class_opaque_type;
- ConstString class_name(objc_method.GetClassName());
- if (class_name)
- {
- TypeSP complete_objc_class_type_sp (FindCompleteObjCDefinitionTypeForDIE (NULL, class_name, false));
-
- if (complete_objc_class_type_sp)
- {
- ClangASTType type_clang_forward_type = complete_objc_class_type_sp->GetClangForwardType();
- if (type_clang_forward_type.IsObjCObjectOrInterfaceType ())
- class_opaque_type = type_clang_forward_type;
- }
- }
-
- 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 = class_opaque_type.AddMethodToObjCObjectType (type_name_cstr,
- clang_type,
- accessibility,
- is_artificial);
- type_handled = objc_method_decl != NULL;
- if (type_handled)
- {
- LinkDeclContextToDIE(ClangASTContext::GetAsDeclContext(objc_method_decl), die);
- GetClangASTContext().SetMetadataAsUserID (objc_method_decl, MakeUserID(die->GetOffset()));
- }
- else
- {
- 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 = ResolveType (dwarf_cu, decl_ctx_die);
- if (class_type)
- {
- if (class_type->GetID() != MakeUserID(decl_ctx_die->GetOffset()))
- {
- // 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;
- DWARFCompileUnitSP class_type_cu_sp;
- const DWARFDebugInfoEntry *class_type_die = NULL;
-
- SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile();
- if (debug_map_symfile)
- {
- class_symfile = debug_map_symfile->GetSymbolFileByOSOIndex(SymbolFileDWARFDebugMap::GetOSOIndexFromUserID(class_type->GetID()));
- class_type_die = class_symfile->DebugInfo()->GetDIEPtr(class_type->GetID(), &class_type_cu_sp);
- }
- else
- {
- class_symfile = this;
- class_type_die = DebugInfo()->GetDIEPtr(class_type->GetID(), &class_type_cu_sp);
- }
- if (class_type_die)
- {
- DWARFDIECollection failures;
-
- CopyUniqueClassMethodTypes (class_symfile,
- class_type,
- class_type_cu_sp.get(),
- class_type_die,
- dwarf_cu,
- decl_ctx_die,
- 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 = m_die_to_type[die];
- if (type_ptr && type_ptr != DIE_IS_BEING_PARSED)
- {
- type_sp = type_ptr->shared_from_this();
- break;
- }
- }
- }
-
- if (specification_die_offset != DW_INVALID_OFFSET)
- {
- // 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->GetClangForwardType();
- // If we have a specification, then the function type should have been
- // made with the specification and not with this die.
- DWARFCompileUnitSP spec_cu_sp;
- const DWARFDebugInfoEntry* spec_die = DebugInfo()->GetDIEPtr(specification_die_offset, &spec_cu_sp);
- clang::DeclContext *spec_clang_decl_ctx = GetClangDeclContextForDIE (sc, dwarf_cu, spec_die);
- if (spec_clang_decl_ctx)
- {
- LinkDeclContextToDIE(spec_clang_decl_ctx, die);
- }
- else
- {
- GetObjectFile()->GetModule()->ReportWarning ("0x%8.8" PRIx64 ": DW_AT_specification(0x%8.8x) has no decl\n",
- MakeUserID(die->GetOffset()),
- specification_die_offset);
- }
- type_handled = true;
- }
- else if (abstract_origin_die_offset != DW_INVALID_OFFSET)
- {
- // 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->GetClangForwardType();
-
- DWARFCompileUnitSP abs_cu_sp;
- const DWARFDebugInfoEntry* abs_die = DebugInfo()->GetDIEPtr(abstract_origin_die_offset, &abs_cu_sp);
- clang::DeclContext *abs_clang_decl_ctx = GetClangDeclContextForDIE (sc, dwarf_cu, abs_die);
- if (abs_clang_decl_ctx)
- {
- LinkDeclContextToDIE (abs_clang_decl_ctx, die);
- }
- else
- {
- GetObjectFile()->GetModule()->ReportWarning ("0x%8.8" PRIx64 ": DW_AT_abstract_origin(0x%8.8x) has no decl\n",
- MakeUserID(die->GetOffset()),
- abstract_origin_die_offset);
- }
- type_handled = true;
- }
- else
- {
- ClangASTType class_opaque_type = class_type->GetClangForwardType();
- if (class_opaque_type.IsCXXClassType ())
- {
- if (class_opaque_type.IsBeingDefined ())
- {
- // 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;
-
- 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
- {
- clang::CXXMethodDecl *cxx_method_decl;
- // REMOVE THE CRASH DESCRIPTION BELOW
- Host::SetCrashDescriptionWithFormat ("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(),
- MakeUserID(die->GetOffset()),
- m_obj_file->GetFileSpec().GetPath().c_str());
-
- const bool is_attr_used = false;
-
- cxx_method_decl = class_opaque_type.AddMethodToCXXRecordType (type_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);
-
- Host::SetCrashDescription (NULL);
-
-
- ClangASTMetadata metadata;
- metadata.SetUserID(MakeUserID(die->GetOffset()));
-
- 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));
- }
- GetClangASTContext().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 m_die_to_type map. First
- // we need to modify the m_die_to_type so it doesn't think we are
- // trying to parse this DIE anymore...
- m_die_to_type[die] = 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->GetClangFullType();
-
- // The type for this DIE should have been filled in the function call above
- type_ptr = m_die_to_type[die];
- 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)
- {
- // We just have a function that isn't part of a class
- clang::FunctionDecl *function_decl = ast.CreateFunctionDeclaration (ignore_containing_context ? GetClangASTContext().GetTranslationUnitDecl() : containing_decl_ctx,
- type_name_cstr,
- clang_type,
- storage,
- is_inline);
-
-// if (template_param_infos.GetSize() > 0)
-// {
-// clang::FunctionTemplateDecl *func_template_decl = ast.CreateFunctionTemplateDecl (containing_decl_ctx,
-// function_decl,
-// type_name_cstr,
-// template_param_infos);
-//
-// ast.CreateFunctionTemplateSpecializationInfo (function_decl,
-// func_template_decl,
-// template_param_infos);
-// }
- // Add the decl to our DIE to decl context map
- assert (function_decl);
- LinkDeclContextToDIE(function_decl, die);
- if (!function_param_decls.empty())
- ast.SetFunctionParameters (function_decl,
- &function_param_decls.front(),
- function_param_decls.size());
-
- ClangASTMetadata metadata;
- metadata.SetUserID(MakeUserID(die->GetOffset()));
-
- 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));
- }
- GetClangASTContext().SetMetadata (function_decl, metadata);
- }
- }
- type_sp.reset( new Type (MakeUserID(die->GetOffset()),
- this,
- 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
- m_die_to_type[die] = DIE_IS_BEING_PARSED;
-
- lldb::user_id_t type_die_offset = DW_INVALID_OFFSET;
- 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(this, dwarf_cu, NULL, attributes);
-
- if (num_attributes > 0)
- {
- uint32_t i;
- for (i=0; i<num_attributes; ++i)
- {
- attr = attributes.AttributeAtIndex(i);
- if (attributes.ExtractFormValueAtIndex(this, 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(&get_debug_str_data());
- type_name_const_str.SetCString(type_name_cstr);
- break;
-
- case DW_AT_type: type_die_offset = form_value.Reference(); 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", MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type_name_cstr);
-
- Type *element_type = ResolveTypeUID(type_die_offset);
-
- if (element_type)
- {
- std::vector<uint64_t> element_orders;
- ParseChildArrayInfo(sc, dwarf_cu, die, first_index, element_orders, byte_stride, bit_stride);
- if (byte_stride == 0 && bit_stride == 0)
- byte_stride = element_type->GetByteSize();
- ClangASTType array_element_type = element_type->GetClangForwardType();
- uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride;
- if (element_orders.size() > 0)
- {
- uint64_t num_elements = 0;
- std::vector<uint64_t>::const_reverse_iterator pos;
- std::vector<uint64_t>::const_reverse_iterator end = element_orders.rend();
- for (pos = element_orders.rbegin(); pos != end; ++pos)
- {
- num_elements = *pos;
- clang_type = 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 = ast.CreateArrayType (array_element_type, 0, is_vector);
- }
- ConstString empty_name;
- type_sp.reset( new Type (MakeUserID(die->GetOffset()),
- this,
- empty_name,
- array_element_bit_stride / 8,
- NULL,
- type_die_offset,
- Type::eEncodingIsUID,
- &decl,
- clang_type,
- Type::eResolveStateFull));
- type_sp->SetEncodingType (element_type);
- }
- }
- }
- break;
+ TypeSystem *type_system = GetTypeSystemForLanguage(die.GetCU()->GetLanguageType());
- case DW_TAG_ptr_to_member_type:
- {
- dw_offset_t type_die_offset = DW_INVALID_OFFSET;
- dw_offset_t containing_type_die_offset = DW_INVALID_OFFSET;
-
- const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes);
-
- if (num_attributes > 0) {
- uint32_t i;
- for (i=0; i<num_attributes; ++i)
- {
- attr = attributes.AttributeAtIndex(i);
- if (attributes.ExtractFormValueAtIndex(this, i, form_value))
- {
- switch (attr)
- {
- case DW_AT_type:
- type_die_offset = form_value.Reference(); break;
- case DW_AT_containing_type:
- containing_type_die_offset = form_value.Reference(); break;
- }
- }
- }
-
- Type *pointee_type = ResolveTypeUID(type_die_offset);
- Type *class_type = ResolveTypeUID(containing_type_die_offset);
-
- ClangASTType pointee_clang_type = pointee_type->GetClangForwardType();
- ClangASTType class_clang_type = class_type->GetClangLayoutType();
-
- clang_type = pointee_clang_type.CreateMemberPointerType(class_clang_type);
-
- byte_size = clang_type.GetByteSize(nullptr);
-
- type_sp.reset( new Type (MakeUserID(die->GetOffset()),
- this,
- type_name_const_str,
- byte_size,
- NULL,
- LLDB_INVALID_UID,
- Type::eEncodingIsUID,
- NULL,
- clang_type,
- Type::eResolveStateForward));
- }
-
- break;
- }
- default:
- 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())
+ if (type_system)
+ {
+ DWARFASTParser *dwarf_ast = type_system->GetDWARFParser();
+ if (dwarf_ast)
{
- const DWARFDebugInfoEntry *sc_parent_die = GetParentSymbolContextDIE(die);
- dw_tag_t sc_parent_tag = sc_parent_die ? sc_parent_die->Tag() : 0;
-
- SymbolContextScope * symbol_context_scope = NULL;
- if (sc_parent_tag == DW_TAG_compile_unit)
+ Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
+ type_sp = dwarf_ast->ParseTypeFromDWARF (sc, die, log, type_is_new_ptr);
+ if (type_sp)
{
- symbol_context_scope = sc.comp_unit;
+ TypeList* type_list = GetTypeList();
+ if (type_list)
+ type_list->Insert(type_sp);
}
- else if (sc.function != NULL && sc_parent_die)
- {
- symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(MakeUserID(sc_parent_die->GetOffset()));
- if (symbol_context_scope == NULL)
- symbol_context_scope = sc.function;
- }
-
- 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);
-
- m_die_to_type[die] = type_sp.get();
}
}
- else if (type_ptr != DIE_IS_BEING_PARSED)
- {
- type_sp = type_ptr->shared_from_this();
- }
}
+
return type_sp;
}
@@ -7185,38 +3763,38 @@ size_t
SymbolFileDWARF::ParseTypes
(
const SymbolContext& sc,
- DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *die,
+ const DWARFDIE &orig_die,
bool parse_siblings,
bool parse_children
)
{
size_t types_added = 0;
- while (die != NULL)
+ DWARFDIE die = orig_die;
+ while (die)
{
bool type_is_new = false;
- if (ParseType(sc, dwarf_cu, die, &type_is_new).get())
+ if (ParseType(sc, die, &type_is_new).get())
{
if (type_is_new)
++types_added;
}
- if (parse_children && die->HasChildren())
+ if (parse_children && die.HasChildren())
{
- if (die->Tag() == DW_TAG_subprogram)
+ if (die.Tag() == DW_TAG_subprogram)
{
SymbolContext child_sc(sc);
- child_sc.function = sc.comp_unit->FindFunctionByUID(MakeUserID(die->GetOffset())).get();
- types_added += ParseTypes(child_sc, dwarf_cu, die->GetFirstChild(), true, true);
+ child_sc.function = sc.comp_unit->FindFunctionByUID(die.GetID()).get();
+ types_added += ParseTypes(child_sc, die.GetFirstChild(), true, true);
}
else
- types_added += ParseTypes(sc, dwarf_cu, die->GetFirstChild(), true, true);
+ types_added += ParseTypes(sc, die.GetFirstChild(), true, true);
}
if (parse_siblings)
- die = die->GetSibling();
+ die = die.GetSibling();
else
- die = NULL;
+ die.Clear();
}
return types_added;
}
@@ -7230,11 +3808,11 @@ SymbolFileDWARF::ParseFunctionBlocks (const SymbolContext &sc)
DWARFCompileUnit* dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
if (dwarf_cu)
{
- dw_offset_t function_die_offset = sc.function->GetID();
- const DWARFDebugInfoEntry *function_die = dwarf_cu->GetDIEPtr(function_die_offset);
+ const dw_offset_t function_die_offset = sc.function->GetID();
+ DWARFDIE function_die = dwarf_cu->GetDIE (function_die_offset);
if (function_die)
{
- ParseFunctionBlocks(sc, &sc.function->GetBlock (false), dwarf_cu, function_die, LLDB_INVALID_ADDRESS, 0);
+ ParseFunctionBlocks(sc, &sc.function->GetBlock (false), function_die, LLDB_INVALID_ADDRESS, 0);
}
}
@@ -7254,18 +3832,18 @@ SymbolFileDWARF::ParseTypes (const SymbolContext &sc)
if (sc.function)
{
dw_offset_t function_die_offset = sc.function->GetID();
- const DWARFDebugInfoEntry *func_die = dwarf_cu->GetDIEPtr(function_die_offset);
- if (func_die && func_die->HasChildren())
+ DWARFDIE func_die = dwarf_cu->GetDIE(function_die_offset);
+ if (func_die && func_die.HasChildren())
{
- types_added = ParseTypes(sc, dwarf_cu, func_die->GetFirstChild(), true, true);
+ types_added = ParseTypes(sc, func_die.GetFirstChild(), true, true);
}
}
else
{
- const DWARFDebugInfoEntry *dwarf_cu_die = dwarf_cu->DIE();
- if (dwarf_cu_die && dwarf_cu_die->HasChildren())
+ DWARFDIE dwarf_cu_die = dwarf_cu->DIE();
+ if (dwarf_cu_die && dwarf_cu_die.HasChildren())
{
- types_added = ParseTypes(sc, dwarf_cu, dwarf_cu_die->GetFirstChild(), true, true);
+ types_added = ParseTypes(sc, dwarf_cu_die.GetFirstChild(), true, true);
}
}
}
@@ -7284,17 +3862,12 @@ SymbolFileDWARF::ParseVariablesForContext (const SymbolContext& sc)
if (sc.function)
{
- DWARFCompileUnit* dwarf_cu = info->GetCompileUnitContainingDIE(sc.function->GetID()).get();
+ DWARFDIE function_die = info->GetDIE(DIERef(sc.function->GetID()));
- if (dwarf_cu == NULL)
- return 0;
-
- const DWARFDebugInfoEntry *function_die = dwarf_cu->GetDIEPtr(sc.function->GetID());
-
- dw_addr_t func_lo_pc = function_die->GetAttributeValueAsUnsigned (this, dwarf_cu, DW_AT_low_pc, LLDB_INVALID_ADDRESS);
+ const dw_addr_t func_lo_pc = function_die.GetAttributeValueAsAddress (DW_AT_low_pc, LLDB_INVALID_ADDRESS);
if (func_lo_pc != LLDB_INVALID_ADDRESS)
{
- const size_t num_variables = ParseVariables(sc, dwarf_cu, func_lo_pc, function_die->GetFirstChild(), true, true);
+ const size_t num_variables = ParseVariables(sc, function_die.GetFirstChild(), func_lo_pc, true, true);
// Let all blocks know they have parse all their variables
sc.function->GetBlock (false).SetDidParseVariables (true, true);
@@ -7303,7 +3876,7 @@ SymbolFileDWARF::ParseVariablesForContext (const SymbolContext& sc)
}
else if (sc.comp_unit)
{
- DWARFCompileUnit* dwarf_cu = info->GetCompileUnit(sc.comp_unit->GetID()).get();
+ DWARFCompileUnit* dwarf_cu = info->GetCompileUnit(sc.comp_unit->GetID());
if (dwarf_cu == NULL)
return 0;
@@ -7316,8 +3889,6 @@ SymbolFileDWARF::ParseVariablesForContext (const SymbolContext& sc)
variables.reset(new VariableList());
sc.comp_unit->SetVariableList(variables);
- DWARFCompileUnit* match_dwarf_cu = NULL;
- const DWARFDebugInfoEntry* die = NULL;
DIEArray die_offsets;
if (m_using_apple_tables)
{
@@ -7340,7 +3911,6 @@ SymbolFileDWARF::ParseVariablesForContext (const SymbolContext& sc)
Index ();
m_global_index.FindAllEntriesForCompileUnit (dwarf_cu->GetOffset(),
- dwarf_cu->GetNextCompileUnitOffset(),
die_offsets);
}
@@ -7350,11 +3920,11 @@ SymbolFileDWARF::ParseVariablesForContext (const SymbolContext& sc)
DWARFDebugInfo* debug_info = DebugInfo();
for (size_t i=0; i<num_matches; ++i)
{
- const dw_offset_t die_offset = die_offsets[i];
- die = debug_info->GetDIEPtrWithCompileUnitHint (die_offset, &match_dwarf_cu);
+ const DIERef& die_ref = die_offsets[i];
+ DWARFDIE die = debug_info->GetDIE (die_ref);
if (die)
{
- VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, die, LLDB_INVALID_ADDRESS));
+ VariableSP var_sp (ParseVariableDIE(sc, die, LLDB_INVALID_ADDRESS));
if (var_sp)
{
variables->AddVariableIfUnique (var_sp);
@@ -7365,7 +3935,7 @@ SymbolFileDWARF::ParseVariablesForContext (const SymbolContext& sc)
{
if (m_using_apple_tables)
{
- GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_names accelerator table had bad die 0x%8.8x)\n", die_offset);
+ GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_names accelerator table had bad die 0x%8.8x)\n", die_ref.die_offset);
}
}
@@ -7378,37 +3948,43 @@ SymbolFileDWARF::ParseVariablesForContext (const SymbolContext& sc)
return 0;
}
-
VariableSP
SymbolFileDWARF::ParseVariableDIE
(
const SymbolContext& sc,
- DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *die,
+ const DWARFDIE &die,
const lldb::addr_t func_low_pc
)
{
- VariableSP var_sp (m_die_to_variable_sp[die]);
+ if (die.GetDWARF() != this)
+ return die.GetDWARF()->ParseVariableDIE(sc, die, func_low_pc);
+
+ VariableSP var_sp;
+ if (!die)
+ return var_sp;
+
+ var_sp = GetDIEToVariable()[die.GetDIE()];
if (var_sp)
return var_sp; // Already been parsed!
- const dw_tag_t tag = die->Tag();
+ const dw_tag_t tag = die.Tag();
ModuleSP module = GetObjectFile()->GetModule();
if ((tag == DW_TAG_variable) ||
(tag == DW_TAG_constant) ||
(tag == DW_TAG_formal_parameter && sc.function))
{
- DWARFDebugInfoEntry::Attributes attributes;
- const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes);
+ DWARFAttributes attributes;
+ const size_t num_attributes = die.GetAttributes(attributes);
+ DWARFDIE spec_die;
if (num_attributes > 0)
{
const char *name = NULL;
const char *mangled = NULL;
Declaration decl;
uint32_t i;
- lldb::user_id_t type_uid = LLDB_INVALID_UID;
- DWARFExpression location;
+ DWARFFormValue type_die_form;
+ DWARFExpression location(die.GetCU());
bool is_external = false;
bool is_artificial = false;
bool location_is_const_value_data = false;
@@ -7421,17 +3997,17 @@ SymbolFileDWARF::ParseVariableDIE
dw_attr_t attr = attributes.AttributeAtIndex(i);
DWARFFormValue form_value;
- if (attributes.ExtractFormValueAtIndex(this, i, 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(&get_debug_str_data()); break;
+ case DW_AT_name: name = form_value.AsCString(); break;
case DW_AT_linkage_name:
- case DW_AT_MIPS_linkage_name: mangled = form_value.AsCString(&get_debug_str_data()); break;
- case DW_AT_type: type_uid = form_value.Reference(); break;
+ case DW_AT_MIPS_linkage_name: mangled = form_value.AsCString(); break;
+ case DW_AT_type: type_die_form = form_value; break;
case DW_AT_external: is_external = form_value.Boolean(); break;
case DW_AT_const_value:
// If we have already found a DW_AT_location attribute, ignore this attribute.
@@ -7450,9 +4026,12 @@ SymbolFileDWARF::ParseVariableDIE
else if (DWARFFormValue::IsDataForm(form_value.Form()))
{
// Retrieve the value as a data expression.
- const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (attributes.CompileUnitAtIndex(i)->GetAddressByteSize(), attributes.CompileUnitAtIndex(i)->IsDWARF64());
+ 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[form_value.Form()];
+ uint32_t data_length = fixed_form_sizes.GetSize(form_value.Form());
if (data_length == 0)
{
const uint8_t *data_pointer = form_value.BlockData();
@@ -7474,14 +4053,17 @@ SymbolFileDWARF::ParseVariableDIE
// Retrieve the value as a string expression.
if (form_value.Form() == DW_FORM_strp)
{
- const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (attributes.CompileUnitAtIndex(i)->GetAddressByteSize(), attributes.CompileUnitAtIndex(i)->IsDWARF64());
+ 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[form_value.Form()];
+ uint32_t data_length = fixed_form_sizes.GetSize(form_value.Form());
location.CopyOpcodeData(module, debug_info_data, data_offset, data_length);
}
else
{
- const char *str = form_value.AsCString(&debug_info_data);
+ 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);
@@ -7503,10 +4085,10 @@ SymbolFileDWARF::ParseVariableDIE
}
else
{
- const DWARFDataExtractor& debug_loc_data = get_debug_loc_data();
+ const DWARFDataExtractor& debug_loc_data = get_debug_loc_data();
const dw_offset_t debug_loc_offset = form_value.Unsigned();
- size_t loc_list_length = DWARFLocationList::Size(debug_loc_data, debug_loc_offset);
+ 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);
@@ -7516,7 +4098,13 @@ SymbolFileDWARF::ParseVariableDIE
}
}
break;
-
+ case DW_AT_specification:
+ {
+ DWARFDebugInfo* debug_info = DebugInfo();
+ if (debug_info)
+ spec_die = debug_info->GetDIE(DIERef(form_value));
+ break;
+ }
case DW_AT_artificial: is_artificial = form_value.Boolean(); break;
case DW_AT_accessibility: break; //accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break;
case DW_AT_declaration:
@@ -7528,16 +4116,18 @@ SymbolFileDWARF::ParseVariableDIE
default:
case DW_AT_abstract_origin:
case DW_AT_sibling:
- case DW_AT_specification:
break;
}
}
}
+ const DWARFDIE parent_context_die = GetDeclContextDIEContainingDIE(die);
+ const dw_tag_t parent_tag = die.GetParent().Tag();
+ bool is_static_member = parent_tag == DW_TAG_compile_unit && (parent_context_die.Tag() == DW_TAG_class_type || parent_context_die.Tag() == DW_TAG_structure_type);
+
ValueType scope = eValueTypeInvalid;
- const DWARFDebugInfoEntry *sc_parent_die = GetParentSymbolContextDIE(die);
- dw_tag_t parent_tag = sc_parent_die ? sc_parent_die->Tag() : 0;
+ const DWARFDIE sc_parent_die = GetParentSymbolContextDIE(die);
SymbolContextScope * symbol_context_scope = NULL;
if (!mangled)
@@ -7548,12 +4138,12 @@ SymbolFileDWARF::ParseVariableDIE
// B which in turn is contained in a namespace A, the command "frame var j" returns
// "(int) A::B::j = 4". If the compiler does not emit a linkage name, we should be able
// to generate a fully qualified name from the declaration context.
- if (die->GetParent()->Tag() == DW_TAG_compile_unit &&
- LanguageRuntime::LanguageIsCPlusPlus(dwarf_cu->GetLanguageType()))
+ if (parent_tag == DW_TAG_compile_unit &&
+ Language::LanguageIsCPlusPlus(die.GetLanguage()))
{
DWARFDeclContext decl_ctx;
- die->GetDWARFDeclContext(this, dwarf_cu, decl_ctx);
+ die.GetDWARFDeclContext(decl_ctx);
mangled = decl_ctx.GetQualifiedNameAsConstString().GetCString();
}
}
@@ -7582,7 +4172,7 @@ SymbolFileDWARF::ParseVariableDIE
{
StreamString strm;
location.DumpLocationForAddress (&strm, eDescriptionLevelFull, 0, 0, NULL);
- GetObjectFile()->GetModule()->ReportError ("0x%8.8x: %s has an invalid location: %s", die->GetOffset(), DW_TAG_value_to_name(die->Tag()), strm.GetString().c_str());
+ GetObjectFile()->GetModule()->ReportError ("0x%8.8x: %s has an invalid location: %s", die.GetOffset(), die.GetTagAsCString(), strm.GetString().c_str());
}
}
@@ -7670,7 +4260,10 @@ SymbolFileDWARF::ParseVariableDIE
}
else
{
- scope = eValueTypeVariableLocal;
+ if (location_is_const_value_data)
+ scope = eValueTypeVariableStatic;
+ else
+ scope = eValueTypeVariableLocal;
}
}
@@ -7683,7 +4276,7 @@ SymbolFileDWARF::ParseVariableDIE
case DW_TAG_lexical_block:
if (sc.function)
{
- symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(MakeUserID(sc_parent_die->GetOffset()));
+ symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID());
if (symbol_context_scope == NULL)
symbol_context_scope = sc.function;
}
@@ -7697,12 +4290,12 @@ SymbolFileDWARF::ParseVariableDIE
if (symbol_context_scope)
{
- SymbolFileTypeSP type_sp(new SymbolFileType(*this, type_uid));
+ SymbolFileTypeSP type_sp(new SymbolFileType(*this, DIERef(type_die_form).GetUID()));
if (const_value.Form() && type_sp && type_sp->GetType())
- location.CopyOpcodeData(const_value.Unsigned(), type_sp->GetType()->GetByteSize(), dwarf_cu->GetAddressByteSize());
+ location.CopyOpcodeData(const_value.Unsigned(), type_sp->GetType()->GetByteSize(), die.GetCU()->GetAddressByteSize());
- var_sp.reset (new Variable (MakeUserID(die->GetOffset()),
+ var_sp.reset (new Variable (die.GetID(),
name,
mangled,
type_sp,
@@ -7711,7 +4304,8 @@ SymbolFileDWARF::ParseVariableDIE
&decl,
location,
is_external,
- is_artificial));
+ is_artificial,
+ is_static_member));
var_sp->SetLocationIsConstantValueData (location_is_const_value_data);
}
@@ -7727,57 +4321,42 @@ SymbolFileDWARF::ParseVariableDIE
// was missing vital information to be able to be displayed in the debugger
// (missing location due to optimization, etc)) so we don't re-parse
// this DIE over and over later...
- m_die_to_variable_sp[die] = var_sp;
+ GetDIEToVariable()[die.GetDIE()] = var_sp;
+ if (spec_die)
+ GetDIEToVariable()[spec_die.GetDIE()] = var_sp;
}
return var_sp;
}
-const DWARFDebugInfoEntry *
-SymbolFileDWARF::FindBlockContainingSpecification (dw_offset_t func_die_offset,
- dw_offset_t spec_block_die_offset,
- DWARFCompileUnit **result_die_cu_handle)
+DWARFDIE
+SymbolFileDWARF::FindBlockContainingSpecification (const DIERef& func_die_ref,
+ dw_offset_t spec_block_die_offset)
{
// Give the concrete function die specified by "func_die_offset", find the
// concrete block whose DW_AT_specification or DW_AT_abstract_origin points
// to "spec_block_die_offset"
- DWARFDebugInfo* info = DebugInfo();
-
- const DWARFDebugInfoEntry *die = info->GetDIEPtrWithCompileUnitHint(func_die_offset, result_die_cu_handle);
- if (die)
- {
- assert (*result_die_cu_handle);
- return FindBlockContainingSpecification (*result_die_cu_handle, die, spec_block_die_offset, result_die_cu_handle);
- }
- return NULL;
+ return FindBlockContainingSpecification (DebugInfo()->GetDIE (func_die_ref), spec_block_die_offset);
}
-const DWARFDebugInfoEntry *
-SymbolFileDWARF::FindBlockContainingSpecification(DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *die,
- dw_offset_t spec_block_die_offset,
- DWARFCompileUnit **result_die_cu_handle)
+DWARFDIE
+SymbolFileDWARF::FindBlockContainingSpecification(const DWARFDIE &die,
+ dw_offset_t spec_block_die_offset)
{
if (die)
{
- switch (die->Tag())
+ switch (die.Tag())
{
case DW_TAG_subprogram:
case DW_TAG_inlined_subroutine:
case DW_TAG_lexical_block:
{
- if (die->GetAttributeValueAsReference (this, dwarf_cu, DW_AT_specification, DW_INVALID_OFFSET) == spec_block_die_offset)
- {
- *result_die_cu_handle = dwarf_cu;
+ if (die.GetAttributeValueAsReference (DW_AT_specification, DW_INVALID_OFFSET) == spec_block_die_offset)
return die;
- }
- if (die->GetAttributeValueAsReference (this, dwarf_cu, DW_AT_abstract_origin, DW_INVALID_OFFSET) == spec_block_die_offset)
- {
- *result_die_cu_handle = dwarf_cu;
+ if (die.GetAttributeValueAsReference (DW_AT_abstract_origin, DW_INVALID_OFFSET) == spec_block_die_offset)
return die;
- }
}
break;
}
@@ -7785,49 +4364,42 @@ SymbolFileDWARF::FindBlockContainingSpecification(DWARFCompileUnit* dwarf_cu,
// Give the concrete function die specified by "func_die_offset", find the
// concrete block whose DW_AT_specification or DW_AT_abstract_origin points
// to "spec_block_die_offset"
- for (const DWARFDebugInfoEntry *child_die = die->GetFirstChild(); child_die != NULL; child_die = child_die->GetSibling())
+ for (DWARFDIE child_die = die.GetFirstChild(); child_die; child_die = child_die.GetSibling())
{
- const DWARFDebugInfoEntry *result_die = FindBlockContainingSpecification (dwarf_cu,
- child_die,
- spec_block_die_offset,
- result_die_cu_handle);
+ DWARFDIE result_die = FindBlockContainingSpecification (child_die, spec_block_die_offset);
if (result_die)
return result_die;
}
}
- *result_die_cu_handle = NULL;
- return NULL;
+ return DWARFDIE();
}
size_t
-SymbolFileDWARF::ParseVariables
-(
- const SymbolContext& sc,
- DWARFCompileUnit* dwarf_cu,
- const lldb::addr_t func_low_pc,
- const DWARFDebugInfoEntry *orig_die,
- bool parse_siblings,
- bool parse_children,
- VariableList* cc_variable_list
-)
+SymbolFileDWARF::ParseVariables (const SymbolContext& sc,
+ const DWARFDIE &orig_die,
+ const lldb::addr_t func_low_pc,
+ bool parse_siblings,
+ bool parse_children,
+ VariableList* cc_variable_list)
{
- if (orig_die == NULL)
+ if (!orig_die)
return 0;
VariableListSP variable_list_sp;
size_t vars_added = 0;
- const DWARFDebugInfoEntry *die = orig_die;
- while (die != NULL)
+ DWARFDIE die = orig_die;
+ while (die)
{
- dw_tag_t tag = die->Tag();
+ dw_tag_t tag = die.Tag();
// Check to see if we have already parsed this variable or constant?
- if (m_die_to_variable_sp[die])
+ VariableSP var_sp = GetDIEToVariable()[die.GetDIE()];
+ if (var_sp)
{
if (cc_variable_list)
- cc_variable_list->AddVariableIfUnique (m_die_to_variable_sp[die]);
+ cc_variable_list->AddVariableIfUnique (var_sp);
}
else
{
@@ -7838,8 +4410,8 @@ SymbolFileDWARF::ParseVariables
{
if (variable_list_sp.get() == NULL)
{
- const DWARFDebugInfoEntry *sc_parent_die = GetParentSymbolContextDIE(orig_die);
- dw_tag_t parent_tag = sc_parent_die ? sc_parent_die->Tag() : 0;
+ DWARFDIE sc_parent_die = GetParentSymbolContextDIE(orig_die);
+ dw_tag_t parent_tag = sc_parent_die.Tag();
switch (parent_tag)
{
case DW_TAG_compile_unit:
@@ -7855,10 +4427,10 @@ SymbolFileDWARF::ParseVariables
else
{
GetObjectFile()->GetModule()->ReportError ("parent 0x%8.8" PRIx64 " %s with no valid compile unit in symbol context for 0x%8.8" PRIx64 " %s.\n",
- MakeUserID(sc_parent_die->GetOffset()),
- DW_TAG_value_to_name (parent_tag),
- MakeUserID(orig_die->GetOffset()),
- DW_TAG_value_to_name (orig_die->Tag()));
+ sc_parent_die.GetID(),
+ sc_parent_die.GetTagAsCString(),
+ orig_die.GetID(),
+ orig_die.GetTagAsCString());
}
break;
@@ -7869,19 +4441,17 @@ SymbolFileDWARF::ParseVariables
{
// Check to see if we already have parsed the variables for the given scope
- Block *block = sc.function->GetBlock(true).FindBlockByID(MakeUserID(sc_parent_die->GetOffset()));
+ Block *block = sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID());
if (block == NULL)
{
// 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
- DWARFCompileUnit *concrete_block_die_cu = dwarf_cu;
- const DWARFDebugInfoEntry *concrete_block_die = FindBlockContainingSpecification (sc.function->GetID(),
- sc_parent_die->GetOffset(),
- &concrete_block_die_cu);
+ const DWARFDIE concrete_block_die = FindBlockContainingSpecification (DIERef(sc.function->GetID()),
+ sc_parent_die.GetOffset());
if (concrete_block_die)
- block = sc.function->GetBlock(true).FindBlockByID(MakeUserID(concrete_block_die->GetOffset()));
+ block = sc.function->GetBlock(true).FindBlockByID(concrete_block_die.GetID());
}
if (block != NULL)
@@ -7899,15 +4469,15 @@ SymbolFileDWARF::ParseVariables
default:
GetObjectFile()->GetModule()->ReportError ("didn't find appropriate parent DIE for variable list for 0x%8.8" PRIx64 " %s.\n",
- MakeUserID(orig_die->GetOffset()),
- DW_TAG_value_to_name (orig_die->Tag()));
+ orig_die.GetID(),
+ orig_die.GetTagAsCString());
break;
}
}
if (variable_list_sp)
{
- VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, die, func_low_pc));
+ VariableSP var_sp (ParseVariableDIE(sc, die, func_low_pc));
if (var_sp)
{
variable_list_sp->AddVariableIfUnique (var_sp);
@@ -7921,15 +4491,15 @@ SymbolFileDWARF::ParseVariables
bool skip_children = (sc.function == NULL && tag == DW_TAG_subprogram);
- if (!skip_children && parse_children && die->HasChildren())
+ if (!skip_children && parse_children && die.HasChildren())
{
- vars_added += ParseVariables(sc, dwarf_cu, func_low_pc, die->GetFirstChild(), true, true, cc_variable_list);
+ vars_added += ParseVariables(sc, die.GetFirstChild(), func_low_pc, true, true, cc_variable_list);
}
if (parse_siblings)
- die = die->GetSibling();
+ die = die.GetSibling();
else
- die = NULL;
+ die.Clear();
}
return vars_added;
}
@@ -7950,24 +4520,6 @@ SymbolFileDWARF::GetPluginVersion()
}
void
-SymbolFileDWARF::CompleteTagDecl (void *baton, clang::TagDecl *decl)
-{
- SymbolFileDWARF *symbol_file_dwarf = (SymbolFileDWARF *)baton;
- ClangASTType clang_type = symbol_file_dwarf->GetClangASTContext().GetTypeForDecl (decl);
- if (clang_type)
- symbol_file_dwarf->ResolveClangOpaqueTypeDefinition (clang_type);
-}
-
-void
-SymbolFileDWARF::CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *decl)
-{
- SymbolFileDWARF *symbol_file_dwarf = (SymbolFileDWARF *)baton;
- ClangASTType clang_type = symbol_file_dwarf->GetClangASTContext().GetTypeForDecl (decl);
- if (clang_type)
- symbol_file_dwarf->ResolveClangOpaqueTypeDefinition (clang_type);
-}
-
-void
SymbolFileDWARF::DumpIndexes ()
{
StreamFile s(stdout, false);
@@ -7982,147 +4534,7 @@ SymbolFileDWARF::DumpIndexes ()
s.Printf("\nObjective C class selectors:\n"); m_objc_class_selectors_index.Dump (&s);
s.Printf("\nGlobals and statics:\n"); m_global_index.Dump (&s);
s.Printf("\nTypes:\n"); m_type_index.Dump (&s);
- s.Printf("\nNamepaces:\n"); m_namespace_index.Dump (&s);
-}
-
-void
-SymbolFileDWARF::SearchDeclContext (const clang::DeclContext *decl_context,
- const char *name,
- llvm::SmallVectorImpl <clang::NamedDecl *> *results)
-{
- DeclContextToDIEMap::iterator iter = m_decl_ctx_to_die.find(decl_context);
-
- if (iter == m_decl_ctx_to_die.end())
- return;
-
- for (DIEPointerSet::iterator pos = iter->second.begin(), end = iter->second.end(); pos != end; ++pos)
- {
- const DWARFDebugInfoEntry *context_die = *pos;
-
- if (!results)
- return;
-
- DWARFDebugInfo* info = DebugInfo();
-
- DIEArray die_offsets;
-
- DWARFCompileUnit* dwarf_cu = NULL;
- const DWARFDebugInfoEntry* die = NULL;
-
- if (m_using_apple_tables)
- {
- if (m_apple_types_ap.get())
- m_apple_types_ap->FindByName (name, die_offsets);
- }
- else
- {
- if (!m_indexed)
- Index ();
-
- m_type_index.Find (ConstString(name), die_offsets);
- }
-
- const size_t num_matches = die_offsets.size();
-
- if (num_matches)
- {
- for (size_t i = 0; i < num_matches; ++i)
- {
- const dw_offset_t die_offset = die_offsets[i];
- die = info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu);
-
- if (die->GetParent() != context_die)
- continue;
-
- Type *matching_type = ResolveType (dwarf_cu, die);
-
- clang::QualType qual_type = matching_type->GetClangForwardType().GetQualType();
-
- if (const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr()))
- {
- clang::TagDecl *tag_decl = tag_type->getDecl();
- results->push_back(tag_decl);
- }
- else if (const clang::TypedefType *typedef_type = llvm::dyn_cast<clang::TypedefType>(qual_type.getTypePtr()))
- {
- clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
- results->push_back(typedef_decl);
- }
- }
- }
- }
-}
-
-void
-SymbolFileDWARF::FindExternalVisibleDeclsByName (void *baton,
- const clang::DeclContext *decl_context,
- clang::DeclarationName decl_name,
- llvm::SmallVectorImpl <clang::NamedDecl *> *results)
-{
-
- switch (decl_context->getDeclKind())
- {
- case clang::Decl::Namespace:
- case clang::Decl::TranslationUnit:
- {
- SymbolFileDWARF *symbol_file_dwarf = (SymbolFileDWARF *)baton;
- symbol_file_dwarf->SearchDeclContext (decl_context, decl_name.getAsString().c_str(), results);
- }
- break;
- default:
- break;
- }
-}
-
-bool
-SymbolFileDWARF::LayoutRecordType(void *baton, const clang::RecordDecl *record_decl, uint64_t &size,
- uint64_t &alignment,
- llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets)
-{
- SymbolFileDWARF *symbol_file_dwarf = (SymbolFileDWARF *)baton;
- return symbol_file_dwarf->LayoutRecordType (record_decl, size, alignment, field_offsets, base_offsets, vbase_offsets);
-}
-
-bool
-SymbolFileDWARF::LayoutRecordType(const clang::RecordDecl *record_decl, uint64_t &bit_size, uint64_t &alignment,
- llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets)
-{
- Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
- RecordDeclToLayoutMap::iterator pos = m_record_decl_to_layout_map.find (record_decl);
- bool success = false;
- base_offsets.clear();
- vbase_offsets.clear();
- if (pos != m_record_decl_to_layout_map.end())
- {
- bit_size = pos->second.bit_size;
- alignment = pos->second.alignment;
- field_offsets.swap(pos->second.field_offsets);
- base_offsets.swap (pos->second.base_offsets);
- vbase_offsets.swap (pos->second.vbase_offsets);
- m_record_decl_to_layout_map.erase(pos);
- success = true;
- }
- else
- {
- bit_size = 0;
- alignment = 0;
- field_offsets.clear();
- }
-
- if (log)
- GetObjectFile()->GetModule()->LogMessage (log,
- "SymbolFileDWARF::LayoutRecordType (record_decl = %p, bit_size = %" PRIu64 ", alignment = %" PRIu64 ", field_offsets[%u],base_offsets[%u], vbase_offsets[%u]) success = %i",
- static_cast<const void*>(record_decl),
- bit_size, alignment,
- static_cast<uint32_t>(field_offsets.size()),
- static_cast<uint32_t>(base_offsets.size()),
- static_cast<uint32_t>(vbase_offsets.size()),
- success);
- return success;
+ s.Printf("\nNamespaces:\n"); m_namespace_index.Dump (&s);
}
@@ -8142,4 +4554,8 @@ SymbolFileDWARF::GetDebugMapSymfile ()
return m_debug_map_symfile;
}
-
+DWARFExpression::LocationListFormat
+SymbolFileDWARF::GetLocationListFormat() const
+{
+ return DWARFExpression::RegularLocationList;
+}
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 2f0b3f05b153..c2e78a417b7a 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -14,24 +14,22 @@
// C++ Includes
#include <list>
#include <map>
+#include <mutex>
#include <set>
+#include <unordered_map>
#include <vector>
// Other libraries and framework includes
-#include "clang/AST/CharUnits.h"
-#include "clang/AST/ExternalASTSource.h"
#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/SmallPtrSet.h"
-#include "llvm/ADT/SmallVector.h"
#include "lldb/lldb-private.h"
-#include "lldb/Core/ClangForward.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/dwarf.h"
#include "lldb/Core/Flags.h"
#include "lldb/Core/RangeMap.h"
#include "lldb/Core/UniqueCStringMap.h"
-#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Expression/DWARFExpression.h"
+#include "lldb/Symbol/DebugMacros.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/SymbolContext.h"
@@ -61,12 +59,18 @@ class DWARFDIECollection;
class DWARFFormValue;
class SymbolFileDWARFDebugMap;
+#define DIE_IS_BEING_PARSED ((lldb_private::Type*)1)
+
class SymbolFileDWARF : public lldb_private::SymbolFile, public lldb_private::UserID
{
public:
friend class SymbolFileDWARFDebugMap;
+ friend class SymbolFileDWARFDwo;
friend class DebugMapModule;
friend class DWARFCompileUnit;
+ friend class DWARFASTParserClang;
+ friend class DWARFASTParserGo;
+
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
@@ -76,6 +80,9 @@ public:
static void
Terminate();
+ static void
+ DebuggerInitialize(lldb_private::Debugger &debugger);
+
static lldb_private::ConstString
GetPluginNameStatic();
@@ -84,481 +91,419 @@ public:
static lldb_private::SymbolFile*
CreateInstance (lldb_private::ObjectFile* obj_file);
+
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
- SymbolFileDWARF(lldb_private::ObjectFile* ofile);
- virtual ~SymbolFileDWARF();
- virtual uint32_t CalculateAbilities ();
- virtual void InitializeObject();
+ SymbolFileDWARF(lldb_private::ObjectFile* ofile);
+
+ ~SymbolFileDWARF() override;
+
+ uint32_t
+ CalculateAbilities () override;
+
+ void
+ InitializeObject() override;
//------------------------------------------------------------------
// Compile Unit function calls
//------------------------------------------------------------------
- virtual uint32_t GetNumCompileUnits();
- virtual lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index);
-
- virtual lldb::LanguageType ParseCompileUnitLanguage (const lldb_private::SymbolContext& sc);
- virtual size_t ParseCompileUnitFunctions (const lldb_private::SymbolContext& sc);
- virtual bool ParseCompileUnitLineTable (const lldb_private::SymbolContext& sc);
- virtual bool ParseCompileUnitSupportFiles (const lldb_private::SymbolContext& sc, lldb_private::FileSpecList& support_files);
- virtual bool ParseImportedModules (const lldb_private::SymbolContext &sc, std::vector<lldb_private::ConstString> &imported_modules);
- virtual size_t ParseFunctionBlocks (const lldb_private::SymbolContext& sc);
- virtual size_t ParseTypes (const lldb_private::SymbolContext& sc);
- virtual size_t ParseVariablesForContext (const lldb_private::SymbolContext& sc);
-
- virtual lldb_private::Type* ResolveTypeUID(lldb::user_id_t type_uid);
- virtual bool ResolveClangOpaqueTypeDefinition (lldb_private::ClangASTType& clang_type);
-
- virtual lldb_private::Type* ResolveType (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* type_die, bool assert_not_being_parsed = true);
- virtual clang::DeclContext* GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid);
- virtual clang::DeclContext* GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid);
-
- virtual uint32_t ResolveSymbolContext (const lldb_private::Address& so_addr, uint32_t resolve_scope, lldb_private::SymbolContext& sc);
- virtual uint32_t ResolveSymbolContext (const lldb_private::FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, lldb_private::SymbolContextList& sc_list);
- virtual uint32_t FindGlobalVariables(const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::VariableList& variables);
- virtual uint32_t FindGlobalVariables(const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb_private::VariableList& variables);
- virtual uint32_t FindFunctions(const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, uint32_t name_type_mask, bool include_inlines, bool append, lldb_private::SymbolContextList& sc_list);
- virtual uint32_t FindFunctions(const lldb_private::RegularExpression& regex, bool include_inlines, bool append, lldb_private::SymbolContextList& sc_list);
- virtual uint32_t FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::TypeList& types);
- virtual lldb_private::TypeList *
- GetTypeList ();
- virtual size_t GetTypes (lldb_private::SymbolContextScope *sc_scope,
- uint32_t type_mask,
- lldb_private::TypeList &type_list);
-
- virtual lldb_private::ClangASTContext &
- GetClangASTContext ();
-
- virtual lldb_private::ClangNamespaceDecl
- FindNamespace (const lldb_private::SymbolContext& sc,
- const lldb_private::ConstString &name,
- const lldb_private::ClangNamespaceDecl *parent_namespace_decl);
+ uint32_t
+ GetNumCompileUnits() override;
- //------------------------------------------------------------------
- // ClangASTContext callbacks for external source lookups.
- //------------------------------------------------------------------
- static void
- CompleteTagDecl (void *baton, clang::TagDecl *);
-
- static void
- CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *);
+ lldb::CompUnitSP
+ ParseCompileUnitAtIndex(uint32_t index) override;
+
+ lldb::LanguageType
+ ParseCompileUnitLanguage (const lldb_private::SymbolContext& sc) override;
+
+ size_t
+ ParseCompileUnitFunctions (const lldb_private::SymbolContext& sc) override;
+
+ bool
+ ParseCompileUnitLineTable (const lldb_private::SymbolContext& sc) override;
+
+ bool
+ ParseCompileUnitDebugMacros (const lldb_private::SymbolContext& sc) override;
+
+ bool
+ ParseCompileUnitSupportFiles (const lldb_private::SymbolContext& sc,
+ lldb_private::FileSpecList& support_files) override;
+
+ bool
+ ParseImportedModules (const lldb_private::SymbolContext &sc,
+ std::vector<lldb_private::ConstString> &imported_modules) override;
+
+ size_t
+ ParseFunctionBlocks (const lldb_private::SymbolContext& sc) override;
+
+ size_t
+ ParseTypes (const lldb_private::SymbolContext& sc) override;
+
+ size_t
+ ParseVariablesForContext (const lldb_private::SymbolContext& sc) override;
+
+ lldb_private::Type *
+ ResolveTypeUID(lldb::user_id_t type_uid) override;
+
+ bool
+ CompleteType (lldb_private::CompilerType& compiler_type) override;
+
+ lldb_private::Type *
+ ResolveType (const DWARFDIE &die,
+ bool assert_not_being_parsed = true,
+ bool resolve_function_context = false);
+
+ lldb_private::CompilerDecl
+ GetDeclForUID (lldb::user_id_t uid) override;
+
+ lldb_private::CompilerDeclContext
+ GetDeclContextForUID (lldb::user_id_t uid) override;
+
+ lldb_private::CompilerDeclContext
+ GetDeclContextContainingUID (lldb::user_id_t uid) override;
+
+ void
+ ParseDeclsForContext (lldb_private::CompilerDeclContext decl_ctx) override;
- static void
- FindExternalVisibleDeclsByName (void *baton,
- const clang::DeclContext *DC,
- clang::DeclarationName Name,
- llvm::SmallVectorImpl <clang::NamedDecl *> *results);
-
- static bool LayoutRecordType(void *baton, const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment,
- llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets);
-
- bool LayoutRecordType(const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment,
- llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets);
-
- struct LayoutInfo
- {
- LayoutInfo () :
- bit_size(0),
- alignment(0),
- field_offsets(),
- base_offsets(),
- vbase_offsets()
- {
- }
- uint64_t bit_size;
- uint64_t alignment;
- llvm::DenseMap<const clang::FieldDecl *, uint64_t> field_offsets;
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> base_offsets;
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> vbase_offsets;
- };
+
+ uint32_t
+ ResolveSymbolContext (const lldb_private::Address& so_addr,
+ uint32_t resolve_scope,
+ lldb_private::SymbolContext& sc) override;
+
+ uint32_t
+ ResolveSymbolContext (const lldb_private::FileSpec& file_spec,
+ uint32_t line,
+ bool check_inlines,
+ uint32_t resolve_scope,
+ lldb_private::SymbolContextList& sc_list) override;
+
+ uint32_t
+ FindGlobalVariables (const lldb_private::ConstString &name,
+ const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ bool append,
+ uint32_t max_matches,
+ lldb_private::VariableList& variables) override;
+
+ uint32_t
+ FindGlobalVariables (const lldb_private::RegularExpression& regex,
+ bool append,
+ uint32_t max_matches,
+ lldb_private::VariableList& variables) override;
+
+ uint32_t
+ FindFunctions (const lldb_private::ConstString &name,
+ const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ uint32_t name_type_mask,
+ bool include_inlines,
+ bool append,
+ lldb_private::SymbolContextList& sc_list) override;
+
+ uint32_t
+ FindFunctions (const lldb_private::RegularExpression& regex,
+ bool include_inlines,
+ bool append,
+ lldb_private::SymbolContextList& sc_list) override;
+
+ uint32_t
+ FindTypes (const lldb_private::SymbolContext& sc,
+ const lldb_private::ConstString &name,
+ const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ bool append,
+ uint32_t max_matches,
+ lldb_private::TypeMap& types) override;
+
+ size_t
+ FindTypes (const std::vector<lldb_private::CompilerContext> &context,
+ bool append,
+ lldb_private::TypeMap& types) override;
+
+ lldb_private::TypeList *
+ GetTypeList () override;
+
+ size_t
+ GetTypes (lldb_private::SymbolContextScope *sc_scope,
+ uint32_t type_mask,
+ lldb_private::TypeList &type_list) override;
+
+ lldb_private::TypeSystem *
+ GetTypeSystemForLanguage (lldb::LanguageType language) override;
+
+ lldb_private::CompilerDeclContext
+ FindNamespace (const lldb_private::SymbolContext& sc,
+ const lldb_private::ConstString &name,
+ const lldb_private::CompilerDeclContext *parent_decl_ctx) override;
+
+
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
- virtual lldb_private::ConstString
- GetPluginName();
-
- virtual uint32_t
- GetPluginVersion();
+ lldb_private::ConstString
+ GetPluginName() override;
- // Approach 2 - count + accessor
- // Index compile units would scan the initial compile units and register
- // them with the module. This would only be done on demand if and only if
- // the compile units were needed.
- //virtual size_t GetCompUnitCount() = 0;
- //virtual CompUnitSP GetCompUnitAtIndex(size_t cu_idx) = 0;
+ uint32_t
+ GetPluginVersion() override;
const lldb_private::DWARFDataExtractor& get_debug_abbrev_data ();
+ const lldb_private::DWARFDataExtractor& get_debug_addr_data ();
const lldb_private::DWARFDataExtractor& get_debug_aranges_data ();
const lldb_private::DWARFDataExtractor& get_debug_frame_data ();
const lldb_private::DWARFDataExtractor& get_debug_info_data ();
const lldb_private::DWARFDataExtractor& get_debug_line_data ();
+ const lldb_private::DWARFDataExtractor& get_debug_macro_data ();
const lldb_private::DWARFDataExtractor& get_debug_loc_data ();
const lldb_private::DWARFDataExtractor& get_debug_ranges_data ();
const lldb_private::DWARFDataExtractor& get_debug_str_data ();
+ const lldb_private::DWARFDataExtractor& get_debug_str_offsets_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 ();
- DWARFDebugAbbrev* DebugAbbrev();
- const DWARFDebugAbbrev* DebugAbbrev() const;
+ DWARFDebugAbbrev*
+ DebugAbbrev();
- DWARFDebugInfo* DebugInfo();
- const DWARFDebugInfo* DebugInfo() const;
+ const DWARFDebugAbbrev*
+ DebugAbbrev() const;
- DWARFDebugRanges* DebugRanges();
- const DWARFDebugRanges* DebugRanges() const;
+ DWARFDebugInfo*
+ DebugInfo();
- const lldb_private::DWARFDataExtractor&
- GetCachedSectionData (uint32_t got_flag,
- lldb::SectionType sect_type,
- lldb_private::DWARFDataExtractor &data);
+ const DWARFDebugInfo*
+ DebugInfo() const;
+
+ DWARFDebugRanges*
+ DebugRanges();
+
+ const DWARFDebugRanges*
+ DebugRanges() const;
static bool
SupportedVersion(uint16_t version);
- clang::DeclContext *
- GetCachedClangDeclContextForDIE (const DWARFDebugInfoEntry *die)
- {
- DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find(die);
- if (pos != m_die_to_decl_ctx.end())
- return pos->second;
- else
- return NULL;
- }
+ DWARFDIE
+ GetDeclContextDIEContainingDIE (const DWARFDIE &die);
- clang::DeclContext *
- GetClangDeclContextForDIE (const lldb_private::SymbolContext &sc, DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die);
-
- clang::DeclContext *
- GetClangDeclContextForDIEOffset (const lldb_private::SymbolContext &sc, dw_offset_t die_offset);
-
- clang::DeclContext *
- GetClangDeclContextContainingDIE (DWARFCompileUnit *cu,
- const DWARFDebugInfoEntry *die,
- const DWARFDebugInfoEntry **decl_ctx_die);
-
- clang::DeclContext *
- GetClangDeclContextContainingDIEOffset (dw_offset_t die_offset);
+ bool
+ HasForwardDeclForClangType (const lldb_private::CompilerType &compiler_type);
- const DWARFDebugInfoEntry *
- GetDeclContextDIEContainingDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die);
+ lldb_private::CompileUnit*
+ GetCompUnitForDWARFCompUnit(DWARFCompileUnit* dwarf_cu,
+ uint32_t cu_idx = UINT32_MAX);
- void
- SearchDeclContext (const clang::DeclContext *decl_context,
- const char *name,
- llvm::SmallVectorImpl <clang::NamedDecl *> *results);
-
- lldb_private::Flags&
- GetFlags ()
+ lldb::user_id_t
+ MakeUserID (dw_offset_t die_offset) const
{
- return m_flags;
+ return GetID() | die_offset;
}
- const lldb_private::Flags&
- GetFlags () const
- {
- return m_flags;
- }
+ size_t
+ GetObjCMethodDIEOffsets (lldb_private::ConstString class_name,
+ DIEArray &method_die_offsets);
bool
- HasForwardDeclForClangType (const lldb_private::ClangASTType &clang_type);
+ Supports_DW_AT_APPLE_objc_complete_type (DWARFCompileUnit *cu);
+
+ lldb_private::DebugMacrosSP
+ ParseDebugMacros(lldb::offset_t *offset);
+
+ static DWARFDIE
+ GetParentSymbolContextDIE(const DWARFDIE &die);
+
+ virtual lldb::CompUnitSP
+ ParseCompileUnit (DWARFCompileUnit* dwarf_cu, uint32_t cu_idx);
+
+ virtual lldb_private::DWARFExpression::LocationListFormat
+ GetLocationListFormat() const;
+
+ lldb::ModuleSP
+ GetDWOModule (lldb_private::ConstString name);
protected:
+ typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *> DIEToTypePtr;
+ typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::VariableSP> DIEToVariableSP;
+ typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::opaque_compiler_type_t> DIEToClangType;
+ typedef llvm::DenseMap<lldb::opaque_compiler_type_t, DIERef> ClangTypeToDIE;
- enum
+ struct DWARFDataSegment
{
- flagsGotDebugAbbrevData = (1 << 0),
- flagsGotDebugArangesData = (1 << 1),
- flagsGotDebugFrameData = (1 << 2),
- flagsGotDebugInfoData = (1 << 3),
- flagsGotDebugLineData = (1 << 4),
- flagsGotDebugLocData = (1 << 5),
- flagsGotDebugMacInfoData = (1 << 6),
- flagsGotDebugPubNamesData = (1 << 7),
- flagsGotDebugPubTypesData = (1 << 8),
- flagsGotDebugRangesData = (1 << 9),
- flagsGotDebugStrData = (1 << 10),
- flagsGotAppleNamesData = (1 << 11),
- flagsGotAppleTypesData = (1 << 12),
- flagsGotAppleNamespacesData = (1 << 13),
- flagsGotAppleObjCData = (1 << 14)
+ std::once_flag m_flag;
+ lldb_private::DWARFDataExtractor m_data;
};
-
- bool NamespaceDeclMatchesThisSymbolFile (const lldb_private::ClangNamespaceDecl *namespace_decl);
-
- bool DIEIsInNamespace (const lldb_private::ClangNamespaceDecl *namespace_decl,
- DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry* die);
DISALLOW_COPY_AND_ASSIGN (SymbolFileDWARF);
- lldb::CompUnitSP ParseCompileUnit (DWARFCompileUnit* dwarf_cu, uint32_t cu_idx);
- DWARFCompileUnit* GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit);
- DWARFCompileUnit* GetNextUnparsedDWARFCompileUnit(DWARFCompileUnit* prev_cu);
- lldb_private::CompileUnit* GetCompUnitForDWARFCompUnit(DWARFCompileUnit* dwarf_cu, uint32_t cu_idx = UINT32_MAX);
- bool GetFunction (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* func_die, lldb_private::SymbolContext& sc);
- lldb_private::Function * ParseCompileUnitFunction (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die);
- size_t ParseFunctionBlocks (const lldb_private::SymbolContext& sc,
- lldb_private::Block *parent_block,
- DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *die,
- lldb::addr_t subprogram_low_pc,
- uint32_t depth);
- size_t ParseTypes (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool parse_siblings, bool parse_children);
- lldb::TypeSP ParseType (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool *type_is_new);
- lldb_private::Type* ResolveTypeUID (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* die, bool assert_not_being_parsed);
-
- lldb::VariableSP ParseVariableDIE(
- const lldb_private::SymbolContext& sc,
- DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *die,
- const lldb::addr_t func_low_pc);
-
- size_t ParseVariables(
- const lldb_private::SymbolContext& sc,
- DWARFCompileUnit* dwarf_cu,
- const lldb::addr_t func_low_pc,
- const DWARFDebugInfoEntry *die,
- bool parse_siblings,
- bool parse_children,
- lldb_private::VariableList* cc_variable_list = NULL);
-
- class DelayedAddObjCClassProperty;
- typedef std::vector <DelayedAddObjCClassProperty> DelayedPropertyList;
-
- bool ClassOrStructIsVirtual (
- DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *parent_die);
-
- size_t ParseChildMembers(
- const lldb_private::SymbolContext& sc,
- DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *die,
- lldb_private::ClangASTType &class_clang_type,
- const lldb::LanguageType class_language,
- std::vector<clang::CXXBaseSpecifier *>& base_classes,
- std::vector<int>& member_accessibilities,
- DWARFDIECollection& member_function_dies,
- DelayedPropertyList& delayed_properties,
- lldb::AccessType &default_accessibility,
- bool &is_a_class,
- LayoutInfo &layout_info);
-
- size_t ParseChildParameters(
- const lldb_private::SymbolContext& sc,
- clang::DeclContext *containing_decl_ctx,
- DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *parent_die,
- bool skip_artificial,
- bool &is_static,
- bool &is_variadic,
- std::vector<lldb_private::ClangASTType>& function_args,
- std::vector<clang::ParmVarDecl*>& function_param_decls,
- unsigned &type_quals);
- // lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos); // not currently needed
-
-
- size_t ParseChildEnumerators(
- const lldb_private::SymbolContext& sc,
- lldb_private::ClangASTType &clang_type,
- bool is_signed,
- uint32_t enumerator_byte_size,
- DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *enum_die);
-
- void ParseChildArrayInfo(
- const lldb_private::SymbolContext& sc,
- DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *parent_die,
- int64_t& first_index,
- std::vector<uint64_t>& element_orders,
- uint32_t& byte_stride,
- uint32_t& bit_stride);
-
- // Given a die_offset, figure out the symbol context representing that die.
- bool ResolveFunction (dw_offset_t offset,
- DWARFCompileUnit *&dwarf_cu,
- bool include_inlines,
- lldb_private::SymbolContextList& sc_list);
-
- bool ResolveFunction (DWARFCompileUnit *cu,
- const DWARFDebugInfoEntry *die,
- bool include_inlines,
- lldb_private::SymbolContextList& sc_list);
-
- bool FunctionDieMatchesPartialName (
- const DWARFDebugInfoEntry* die,
- const DWARFCompileUnit *dwarf_cu,
- uint32_t name_type_mask,
- const char *partial_name,
- const char *base_name_start,
- const char *base_name_end);
-
- void FindFunctions(
- const lldb_private::ConstString &name,
- const NameToDIE &name_to_die,
- bool include_inlines,
- lldb_private::SymbolContextList& sc_list);
-
- void FindFunctions (
- const lldb_private::RegularExpression &regex,
- const NameToDIE &name_to_die,
- bool include_inlines,
- lldb_private::SymbolContextList& sc_list);
-
- void FindFunctions (
- const lldb_private::RegularExpression &regex,
- const DWARFMappedHash::MemoryTable &memory_table,
- bool include_inlines,
- lldb_private::SymbolContextList& sc_list);
-
- lldb::TypeSP FindDefinitionTypeForDWARFDeclContext (
- const DWARFDeclContext &die_decl_ctx);
-
- lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE (
- const DWARFDebugInfoEntry *die,
- const lldb_private::ConstString &type_name,
- bool must_be_implementation);
-
- bool Supports_DW_AT_APPLE_objc_complete_type (DWARFCompileUnit *cu);
-
- lldb::TypeSP FindCompleteObjCDefinitionType (const lldb_private::ConstString &type_name,
- bool header_definition_ok);
-
- lldb_private::Symbol * GetObjCClassSymbol (const lldb_private::ConstString &objc_class_name);
-
- void ParseFunctions (const DIEArray &die_offsets,
- bool include_inlines,
- lldb_private::SymbolContextList& sc_list);
- lldb::TypeSP GetTypeForDIE (DWARFCompileUnit *cu,
- const DWARFDebugInfoEntry* die);
-
- uint32_t FindTypes(std::vector<dw_offset_t> die_offsets, uint32_t max_matches, lldb_private::TypeList& types);
-
- void Index();
-
- void DumpIndexes();
- void SetDebugMapModule (const lldb::ModuleSP &module_sp)
- {
- m_debug_map_module_wp = module_sp;
- }
+ const lldb_private::DWARFDataExtractor&
+ GetCachedSectionData (lldb::SectionType sect_type, DWARFDataSegment& data_segment);
+
+ virtual void
+ LoadSectionData (lldb::SectionType sect_type, lldb_private::DWARFDataExtractor& data);
+
+ bool
+ DeclContextMatchesThisSymbolFile (const lldb_private::CompilerDeclContext *decl_ctx);
+
+ bool
+ DIEInDeclContext (const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ const DWARFDIE &die);
+
+ virtual DWARFCompileUnit*
+ GetDWARFCompileUnit (lldb_private::CompileUnit *comp_unit);
+
+ DWARFCompileUnit*
+ GetNextUnparsedDWARFCompileUnit (DWARFCompileUnit* prev_cu);
+
+ bool
+ GetFunction (const DWARFDIE &die,
+ lldb_private::SymbolContext& sc);
+
+ lldb_private::Function *
+ ParseCompileUnitFunction (const lldb_private::SymbolContext& sc,
+ const DWARFDIE &die);
+
+ size_t
+ ParseFunctionBlocks (const lldb_private::SymbolContext& sc,
+ lldb_private::Block *parent_block,
+ const DWARFDIE &die,
+ lldb::addr_t subprogram_low_pc,
+ uint32_t depth);
+
+ size_t
+ ParseTypes (const lldb_private::SymbolContext& sc,
+ const DWARFDIE &die,
+ bool parse_siblings,
+ bool parse_children);
+
+ lldb::TypeSP
+ ParseType (const lldb_private::SymbolContext& sc,
+ const DWARFDIE &die,
+ bool *type_is_new);
+
+ lldb_private::Type *
+ ResolveTypeUID (const DWARFDIE &die,
+ bool assert_not_being_parsed);
+
+ lldb::VariableSP
+ ParseVariableDIE(const lldb_private::SymbolContext& sc,
+ const DWARFDIE &die,
+ const lldb::addr_t func_low_pc);
+
+ size_t
+ ParseVariables (const lldb_private::SymbolContext& sc,
+ const DWARFDIE &orig_die,
+ const lldb::addr_t func_low_pc,
+ bool parse_siblings,
+ bool parse_children,
+ lldb_private::VariableList* cc_variable_list = NULL);
+
+ bool
+ ClassOrStructIsVirtual (const DWARFDIE &die);
+
+ // Given a die_offset, figure out the symbol context representing that die.
+ bool
+ ResolveFunction (const DIERef& die_ref,
+ bool include_inlines,
+ lldb_private::SymbolContextList& sc_list);
+
+ bool
+ ResolveFunction (const DWARFDIE &die,
+ bool include_inlines,
+ lldb_private::SymbolContextList& sc_list);
+
+ void
+ FindFunctions(const lldb_private::ConstString &name,
+ const NameToDIE &name_to_die,
+ bool include_inlines,
+ lldb_private::SymbolContextList& sc_list);
+
+ void
+ FindFunctions (const lldb_private::RegularExpression &regex,
+ const NameToDIE &name_to_die,
+ bool include_inlines,
+ lldb_private::SymbolContextList& sc_list);
+
+ void
+ FindFunctions (const lldb_private::RegularExpression &regex,
+ const DWARFMappedHash::MemoryTable &memory_table,
+ bool include_inlines,
+ lldb_private::SymbolContextList& sc_list);
+
+ virtual lldb::TypeSP
+ FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext &die_decl_ctx);
+
+ lldb::TypeSP
+ FindCompleteObjCDefinitionTypeForDIE (const DWARFDIE &die,
+ const lldb_private::ConstString &type_name,
+ bool must_be_implementation);
+
+ lldb::TypeSP
+ FindCompleteObjCDefinitionType (const lldb_private::ConstString &type_name,
+ bool header_definition_ok);
+
+ lldb_private::Symbol *
+ GetObjCClassSymbol (const lldb_private::ConstString &objc_class_name);
+
+ void
+ ParseFunctions (const DIEArray &die_offsets,
+ bool include_inlines,
+ lldb_private::SymbolContextList& sc_list);
+
+ lldb::TypeSP
+ GetTypeForDIE (const DWARFDIE &die, bool resolve_function_context = false);
+
+ void
+ Index();
- SymbolFileDWARFDebugMap *
- GetDebugMapSymfile ();
+ void
+ DumpIndexes();
- const DWARFDebugInfoEntry *
- FindBlockContainingSpecification (dw_offset_t func_die_offset,
- dw_offset_t spec_block_die_offset,
- DWARFCompileUnit **dwarf_cu_handle);
+ void
+ SetDebugMapModule (const lldb::ModuleSP &module_sp)
+ {
+ m_debug_map_module_wp = module_sp;
+ }
+
+ SymbolFileDWARFDebugMap *
+ GetDebugMapSymfile ();
- const DWARFDebugInfoEntry *
- FindBlockContainingSpecification (DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *die,
- dw_offset_t spec_block_die_offset,
- DWARFCompileUnit **dwarf_cu_handle);
+ DWARFDIE
+ FindBlockContainingSpecification (const DIERef& func_die_ref, dw_offset_t spec_block_die_offset);
- clang::NamespaceDecl *
- ResolveNamespaceDIE (DWARFCompileUnit *curr_cu, const DWARFDebugInfoEntry *die);
+ DWARFDIE
+ FindBlockContainingSpecification (const DWARFDIE &die, dw_offset_t spec_block_die_offset);
- UniqueDWARFASTTypeMap &
+ virtual UniqueDWARFASTTypeMap &
GetUniqueDWARFASTTypeMap ();
-
- void LinkDeclContextToDIE (clang::DeclContext *decl_ctx,
- const DWARFDebugInfoEntry *die)
- {
- m_die_to_decl_ctx[die] = decl_ctx;
- // There can be many DIEs for a single decl context
- m_decl_ctx_to_die[decl_ctx].insert(die);
- }
bool
UserIDMatches (lldb::user_id_t uid) const
{
const lldb::user_id_t high_uid = uid & 0xffffffff00000000ull;
- if (high_uid)
+ if (high_uid != 0 && GetID() != 0)
return high_uid == GetID();
return true;
}
- lldb::user_id_t
- MakeUserID (dw_offset_t die_offset) const
- {
- return GetID() | die_offset;
- }
-
- static bool
- DeclKindIsCXXClass (clang::Decl::Kind decl_kind)
- {
- switch (decl_kind)
- {
- case clang::Decl::CXXRecord:
- case clang::Decl::ClassTemplateSpecialization:
- return true;
- default:
- break;
- }
- return false;
- }
-
- bool
- ParseTemplateParameterInfos (DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *parent_die,
- lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos);
-
bool
- ParseTemplateDIE (DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *die,
- lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos);
-
- clang::ClassTemplateDecl *
- ParseClassTemplateDecl (clang::DeclContext *decl_ctx,
- lldb::AccessType access_type,
- const char *parent_name,
- int tag_decl_kind,
- const lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos);
-
- bool
- DIEDeclContextsMatch (DWARFCompileUnit* cu1, const DWARFDebugInfoEntry *die1,
- DWARFCompileUnit* cu2, const DWARFDebugInfoEntry *die2);
+ DIEDeclContextsMatch (const DWARFDIE &die1,
+ const DWARFDIE &die2);
bool
- ClassContainsSelector (DWARFCompileUnit *dwarf_cu,
- const DWARFDebugInfoEntry *class_die,
+ ClassContainsSelector (const DWARFDIE &class_die,
const lldb_private::ConstString &selector);
bool
- CopyUniqueClassMethodTypes (SymbolFileDWARF *class_symfile,
- lldb_private::Type *class_type,
- DWARFCompileUnit* src_cu,
- const DWARFDebugInfoEntry *src_class_die,
- DWARFCompileUnit* dst_cu,
- const DWARFDebugInfoEntry *dst_class_die,
- DWARFDIECollection &failures);
-
- bool
FixupAddress (lldb_private::Address &addr);
typedef std::set<lldb_private::Type *> TypeSet;
- typedef struct {
- lldb_private::ConstString m_name;
- lldb::ModuleSP m_module_sp;
- } ClangModuleInfo;
-
- typedef std::map<uint64_t, ClangModuleInfo> ExternalTypeModuleMap;
+ typedef std::map<lldb_private::ConstString, lldb::ModuleSP> ExternalTypeModuleMap;
void
- GetTypes (DWARFCompileUnit* dwarf_cu,
- const DWARFDebugInfoEntry *die,
+ GetTypes (const DWARFDIE &die,
dw_offset_t min_die_offset,
dw_offset_t max_die_offset,
uint32_t type_mask,
@@ -572,23 +517,37 @@ protected:
void
UpdateExternalModuleListIfNeeded();
+ virtual DIEToTypePtr&
+ GetDIEToType() { return m_die_to_type; }
+
+ virtual DIEToVariableSP&
+ GetDIEToVariable() { return m_die_to_variable_sp; }
+
+ virtual DIEToClangType&
+ GetForwardDeclDieToClangType() { return m_forward_decl_die_to_clang_type; }
+
+ virtual ClangTypeToDIE&
+ GetForwardDeclClangTypeToDie() { return m_forward_decl_clang_type_to_die; }
+
lldb::ModuleWP m_debug_map_module_wp;
SymbolFileDWARFDebugMap * m_debug_map_symfile;
- clang::TranslationUnitDecl * m_clang_tu_decl;
- lldb_private::Flags m_flags;
- lldb_private::DWARFDataExtractor m_dwarf_data;
- lldb_private::DWARFDataExtractor m_data_debug_abbrev;
- lldb_private::DWARFDataExtractor m_data_debug_aranges;
- lldb_private::DWARFDataExtractor m_data_debug_frame;
- lldb_private::DWARFDataExtractor m_data_debug_info;
- lldb_private::DWARFDataExtractor m_data_debug_line;
- lldb_private::DWARFDataExtractor m_data_debug_loc;
- lldb_private::DWARFDataExtractor m_data_debug_ranges;
- lldb_private::DWARFDataExtractor m_data_debug_str;
- lldb_private::DWARFDataExtractor m_data_apple_names;
- lldb_private::DWARFDataExtractor m_data_apple_types;
- lldb_private::DWARFDataExtractor m_data_apple_namespaces;
- lldb_private::DWARFDataExtractor m_data_apple_objc;
+ lldb_private::DWARFDataExtractor m_dwarf_data;
+
+ 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_macro;
+ DWARFDataSegment m_data_debug_loc;
+ DWARFDataSegment m_data_debug_ranges;
+ DWARFDataSegment m_data_debug_str;
+ DWARFDataSegment m_data_debug_str_offsets;
+ DWARFDataSegment m_data_apple_names;
+ DWARFDataSegment m_data_apple_types;
+ DWARFDataSegment m_data_apple_namespaces;
+ DWARFDataSegment m_data_apple_objc;
// The unique pointer items below are generated on demand if and when someone accesses
// them through a non const version of this class.
@@ -600,6 +559,10 @@ protected:
std::unique_ptr<DWARFMappedHash::MemoryTable> m_apple_namespaces_ap;
std::unique_ptr<DWARFMappedHash::MemoryTable> m_apple_objc_ap;
std::unique_ptr<GlobalVariableMap> m_global_aranges_ap;
+
+ typedef std::unordered_map<lldb::offset_t, lldb_private::DebugMacrosSP> DebugMacrosMap;
+ DebugMacrosMap m_debug_macros_map;
+
ExternalTypeModuleMap m_external_type_modules;
NameToDIE m_function_basename_index; // All concrete functions
NameToDIE m_function_fullname_index; // All concrete functions
@@ -610,28 +573,16 @@ protected:
NameToDIE m_type_index; // All type DIE offsets
NameToDIE m_namespace_index; // All type DIE offsets
bool m_indexed:1,
- m_is_external_ast_source:1,
m_using_apple_tables:1,
m_fetched_external_modules:1;
lldb_private::LazyBool m_supports_DW_AT_APPLE_objc_complete_type;
std::unique_ptr<DWARFDebugRanges> m_ranges;
UniqueDWARFASTTypeMap m_unique_ast_type_map;
- typedef llvm::SmallPtrSet<const DWARFDebugInfoEntry *, 4> DIEPointerSet;
- typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *> DIEToDeclContextMap;
- typedef llvm::DenseMap<const clang::DeclContext *, DIEPointerSet> DeclContextToDIEMap;
- typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *> DIEToTypePtr;
- typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::VariableSP> DIEToVariableSP;
- typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::clang_type_t> DIEToClangType;
- typedef llvm::DenseMap<lldb::clang_type_t, const DWARFDebugInfoEntry *> ClangTypeToDIE;
- typedef llvm::DenseMap<const clang::RecordDecl *, LayoutInfo> RecordDeclToLayoutMap;
- DIEToDeclContextMap m_die_to_decl_ctx;
- DeclContextToDIEMap m_decl_ctx_to_die;
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;
- RecordDeclToLayoutMap m_record_decl_to_layout_map;
};
#endif // SymbolFileDWARF_SymbolFileDWARF_h_
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index de972acd7ed7..be25dfc99dee 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -1,4 +1,4 @@
-//===-- SymbolFileDWARFDebugMap.cpp ----------------------------*- C++ -*-===//
+//===-- SymbolFileDWARFDebugMap.cpp -----------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "SymbolFileDWARFDebugMap.h"
#include "DWARFDebugAranges.h"
@@ -24,11 +28,11 @@
#endif
#include "lldb/Core/Timer.h"
-#include "lldb/Symbol/ClangExternalASTSourceCallbacks.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Symbol/TypeMap.h"
#include "lldb/Symbol/VariableList.h"
#include "LogChannelDWARF.h"
@@ -41,9 +45,6 @@ using namespace lldb_private;
// (so we can fixup the object file sections) and also for "Module::GetSymbolVendor()"
// (so we can fixup the symbol file id.
-
-
-
const SymbolFileDWARFDebugMap::FileRangeMap &
SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap(SymbolFileDWARFDebugMap *exe_symfile)
{
@@ -173,7 +174,6 @@ SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap(SymbolFileDWARFDebugMa
return file_range_map;
}
-
class DebugMapModule : public Module
{
public:
@@ -190,14 +190,10 @@ public:
{
}
- virtual
- ~DebugMapModule ()
- {
- }
+ ~DebugMapModule() override = default;
-
- virtual SymbolVendor*
- GetSymbolVendor(bool can_create = true, lldb_private::Stream *feedback_strm = NULL)
+ SymbolVendor*
+ GetSymbolVendor(bool can_create = true, lldb_private::Stream *feedback_strm = NULL) override
{
// Scope for locker
if (m_symfile_ap.get() || can_create == false)
@@ -259,7 +255,6 @@ SymbolFileDWARFDebugMap::Terminate()
PluginManager::UnregisterPlugin (CreateInstance);
}
-
lldb_private::ConstString
SymbolFileDWARFDebugMap::GetPluginNameStatic()
{
@@ -279,7 +274,6 @@ SymbolFileDWARFDebugMap::CreateInstance (ObjectFile* obj_file)
return new SymbolFileDWARFDebugMap (obj_file);
}
-
SymbolFileDWARFDebugMap::SymbolFileDWARFDebugMap (ObjectFile* ofile) :
SymbolFile(ofile),
m_flags(),
@@ -290,7 +284,6 @@ SymbolFileDWARFDebugMap::SymbolFileDWARFDebugMap (ObjectFile* ofile) :
{
}
-
SymbolFileDWARFDebugMap::~SymbolFileDWARFDebugMap()
{
}
@@ -298,15 +291,6 @@ SymbolFileDWARFDebugMap::~SymbolFileDWARFDebugMap()
void
SymbolFileDWARFDebugMap::InitializeObject()
{
- // Install our external AST source callbacks so we can complete Clang types.
- llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> ast_source_ap (
- new ClangExternalASTSourceCallbacks (SymbolFileDWARFDebugMap::CompleteTagDecl,
- SymbolFileDWARFDebugMap::CompleteObjCInterfaceDecl,
- NULL,
- SymbolFileDWARFDebugMap::LayoutRecordType,
- this));
-
- GetClangASTContext().SetExternalSource (ast_source_ap);
}
void
@@ -517,7 +501,6 @@ SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo (CompileUnitInfo *comp_unit_inf
return NULL;
}
-
bool
SymbolFileDWARFDebugMap::GetFileSpecForSO (uint32_t oso_idx, FileSpec &file_spec)
{
@@ -532,8 +515,6 @@ SymbolFileDWARFDebugMap::GetFileSpecForSO (uint32_t oso_idx, FileSpec &file_spec
return false;
}
-
-
ObjectFile *
SymbolFileDWARFDebugMap::GetObjectFileByOSOIndex (uint32_t oso_idx)
{
@@ -561,7 +542,6 @@ SymbolFileDWARFDebugMap::GetObjectFileByCompUnitInfo (CompileUnitInfo *comp_unit
return NULL;
}
-
uint32_t
SymbolFileDWARFDebugMap::GetCompUnitInfoIndex (const CompileUnitInfo *comp_unit_info)
{
@@ -637,7 +617,6 @@ SymbolFileDWARFDebugMap::GetNumCompileUnits()
return m_compile_unit_infos.size();
}
-
CompUnitSP
SymbolFileDWARFDebugMap::ParseCompileUnitAtIndex(uint32_t cu_idx)
{
@@ -660,7 +639,8 @@ SymbolFileDWARFDebugMap::ParseCompileUnitAtIndex(uint32_t cu_idx)
NULL,
so_file_spec,
cu_id,
- eLanguageTypeUnknown));
+ eLanguageTypeUnknown,
+ false));
if (m_compile_unit_infos[cu_idx].compile_unit_sp)
{
@@ -687,7 +667,6 @@ SymbolFileDWARFDebugMap::GetCompUnitInfo (const SymbolContext& sc)
return NULL;
}
-
size_t
SymbolFileDWARFDebugMap::GetCompUnitInfosForModule (const lldb_private::Module *module, std::vector<CompileUnitInfo *>& cu_infos)
{
@@ -728,6 +707,15 @@ SymbolFileDWARFDebugMap::ParseCompileUnitLineTable (const SymbolContext& sc)
}
bool
+SymbolFileDWARFDebugMap::ParseCompileUnitDebugMacros (const SymbolContext& sc)
+{
+ SymbolFileDWARF *oso_dwarf = GetSymbolFile (sc);
+ if (oso_dwarf)
+ return oso_dwarf->ParseCompileUnitDebugMacros (sc);
+ return false;
+}
+
+bool
SymbolFileDWARFDebugMap::ParseCompileUnitSupportFiles (const SymbolContext& sc, FileSpecList &support_files)
{
SymbolFileDWARF *oso_dwarf = GetSymbolFile (sc);
@@ -754,7 +742,6 @@ SymbolFileDWARFDebugMap::ParseFunctionBlocks (const SymbolContext& sc)
return 0;
}
-
size_t
SymbolFileDWARFDebugMap::ParseTypes (const SymbolContext& sc)
{
@@ -764,7 +751,6 @@ SymbolFileDWARFDebugMap::ParseTypes (const SymbolContext& sc)
return 0;
}
-
size_t
SymbolFileDWARFDebugMap::ParseVariablesForContext (const SymbolContext& sc)
{
@@ -774,8 +760,6 @@ SymbolFileDWARFDebugMap::ParseVariablesForContext (const SymbolContext& sc)
return 0;
}
-
-
Type*
SymbolFileDWARFDebugMap::ResolveTypeUID(lldb::user_id_t type_uid)
{
@@ -787,10 +771,22 @@ SymbolFileDWARFDebugMap::ResolveTypeUID(lldb::user_id_t type_uid)
}
bool
-SymbolFileDWARFDebugMap::ResolveClangOpaqueTypeDefinition (ClangASTType& clang_type)
+SymbolFileDWARFDebugMap::CompleteType (CompilerType& compiler_type)
{
- // We have a struct/union/class/enum that needs to be fully resolved.
- return false;
+ bool success = false;
+ if (compiler_type)
+ {
+ ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
+ if (oso_dwarf->HasForwardDeclForClangType (compiler_type))
+ {
+ oso_dwarf->CompleteType (compiler_type);
+ success = true;
+ return true;
+ }
+ return false;
+ });
+ }
+ return success;
}
uint32_t
@@ -834,7 +830,6 @@ SymbolFileDWARFDebugMap::ResolveSymbolContext (const Address& exe_so_addr, uint3
return resolved_flags;
}
-
uint32_t
SymbolFileDWARFDebugMap::ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list)
{
@@ -871,7 +866,7 @@ uint32_t
SymbolFileDWARFDebugMap::PrivateFindGlobalVariables
(
const ConstString &name,
- const ClangNamespaceDecl *namespace_decl,
+ 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
@@ -888,7 +883,7 @@ SymbolFileDWARFDebugMap::PrivateFindGlobalVariables
SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx);
if (oso_dwarf)
{
- if (oso_dwarf->FindGlobalVariables(name, namespace_decl, true, max_matches, variables))
+ if (oso_dwarf->FindGlobalVariables(name, parent_decl_ctx, true, max_matches, variables))
if (variables.GetSize() > max_matches)
break;
}
@@ -898,7 +893,11 @@ SymbolFileDWARFDebugMap::PrivateFindGlobalVariables
}
uint32_t
-SymbolFileDWARFDebugMap::FindGlobalVariables (const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, VariableList& variables)
+SymbolFileDWARFDebugMap::FindGlobalVariables (const ConstString &name,
+ const CompilerDeclContext *parent_decl_ctx,
+ bool append,
+ uint32_t max_matches,
+ VariableList& variables)
{
// If we aren't appending the results to this list, then clear the list
@@ -913,7 +912,7 @@ SymbolFileDWARFDebugMap::FindGlobalVariables (const ConstString &name, const Cla
ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
const uint32_t oso_matches = oso_dwarf->FindGlobalVariables (name,
- namespace_decl,
+ parent_decl_ctx,
true,
max_matches,
variables);
@@ -941,7 +940,6 @@ SymbolFileDWARFDebugMap::FindGlobalVariables (const ConstString &name, const Cla
return variables.GetSize() - original_size;
}
-
uint32_t
SymbolFileDWARFDebugMap::FindGlobalVariables (const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables)
{
@@ -983,7 +981,6 @@ SymbolFileDWARFDebugMap::FindGlobalVariables (const RegularExpression& regex, bo
return variables.GetSize() - original_size;
}
-
int
SymbolFileDWARFDebugMap::SymbolContainsSymbolWithIndex (uint32_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info)
{
@@ -998,7 +995,6 @@ SymbolFileDWARFDebugMap::SymbolContainsSymbolWithIndex (uint32_t *symbol_idx_ptr
return 1;
}
-
int
SymbolFileDWARFDebugMap::SymbolContainsSymbolWithID (user_id_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info)
{
@@ -1013,7 +1009,6 @@ SymbolFileDWARFDebugMap::SymbolContainsSymbolWithID (user_id_t *symbol_idx_ptr,
return 1;
}
-
SymbolFileDWARFDebugMap::CompileUnitInfo*
SymbolFileDWARFDebugMap::GetCompileUnitInfoForSymbolWithIndex (uint32_t symbol_idx, uint32_t *oso_idx_ptr)
{
@@ -1062,7 +1057,6 @@ SymbolFileDWARFDebugMap::GetCompileUnitInfoForSymbolWithID (user_id_t symbol_id,
return comp_unit_info;
}
-
static void
RemoveFunctionsWithModuleNotEqualTo (const ModuleSP &module_sp, SymbolContextList &sc_list, uint32_t start_idx)
{
@@ -1091,7 +1085,12 @@ RemoveFunctionsWithModuleNotEqualTo (const ModuleSP &module_sp, SymbolContextLis
}
uint32_t
-SymbolFileDWARFDebugMap::FindFunctions(const ConstString &name, const ClangNamespaceDecl *namespace_decl, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list)
+SymbolFileDWARFDebugMap::FindFunctions(const ConstString &name,
+ const CompilerDeclContext *parent_decl_ctx,
+ uint32_t name_type_mask,
+ bool include_inlines,
+ bool append,
+ SymbolContextList& sc_list)
{
Timer scoped_timer (__PRETTY_FUNCTION__,
"SymbolFileDWARFDebugMap::FindFunctions (name = %s)",
@@ -1105,7 +1104,7 @@ SymbolFileDWARFDebugMap::FindFunctions(const ConstString &name, const ClangNames
ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
uint32_t sc_idx = sc_list.GetSize();
- if (oso_dwarf->FindFunctions(name, namespace_decl, name_type_mask, include_inlines, true, sc_list))
+ if (oso_dwarf->FindFunctions(name, parent_decl_ctx, name_type_mask, include_inlines, true, sc_list))
{
RemoveFunctionsWithModuleNotEqualTo (m_obj_file->GetModule(), sc_list, sc_idx);
}
@@ -1115,7 +1114,6 @@ SymbolFileDWARFDebugMap::FindFunctions(const ConstString &name, const ClangNames
return sc_list.GetSize() - initial_size;
}
-
uint32_t
SymbolFileDWARFDebugMap::FindFunctions (const RegularExpression& regex, bool include_inlines, bool append, SymbolContextList& sc_list)
{
@@ -1150,8 +1148,7 @@ SymbolFileDWARFDebugMap::GetTypes (SymbolContextScope *sc_scope,
Timer scoped_timer (__PRETTY_FUNCTION__,
"SymbolFileDWARFDebugMap::GetTypes (type_mask = 0x%8.8x)",
type_mask);
-
-
+
uint32_t initial_size = type_list.GetSize();
SymbolFileDWARF *oso_dwarf = NULL;
if (sc_scope)
@@ -1177,7 +1174,6 @@ SymbolFileDWARFDebugMap::GetTypes (SymbolContextScope *sc_scope,
return type_list.GetSize() - initial_size;
}
-
TypeSP
SymbolFileDWARFDebugMap::FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext &die_decl_ctx)
{
@@ -1189,8 +1185,6 @@ SymbolFileDWARFDebugMap::FindDefinitionTypeForDWARFDeclContext (const DWARFDeclC
return type_sp;
}
-
-
bool
SymbolFileDWARFDebugMap::Supports_DW_AT_APPLE_objc_complete_type (SymbolFileDWARF *skip_dwarf_oso)
{
@@ -1210,7 +1204,7 @@ SymbolFileDWARFDebugMap::Supports_DW_AT_APPLE_objc_complete_type (SymbolFileDWAR
}
TypeSP
-SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry *die,
+SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE (const DWARFDIE &die,
const ConstString &type_name,
bool must_be_implementation)
{
@@ -1280,10 +1274,10 @@ SymbolFileDWARFDebugMap::FindTypes
(
const SymbolContext& sc,
const ConstString &name,
- const ClangNamespaceDecl *namespace_decl,
- bool append,
+ const CompilerDeclContext *parent_decl_ctx,
+ bool append,
uint32_t max_matches,
- TypeList& types
+ TypeMap& types
)
{
if (!append)
@@ -1296,12 +1290,12 @@ SymbolFileDWARFDebugMap::FindTypes
{
oso_dwarf = GetSymbolFile (sc);
if (oso_dwarf)
- return oso_dwarf->FindTypes (sc, name, namespace_decl, append, max_matches, types);
+ return oso_dwarf->FindTypes (sc, name, parent_decl_ctx, append, max_matches, types);
}
else
{
ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
- oso_dwarf->FindTypes (sc, name, namespace_decl, append, max_matches, types);
+ oso_dwarf->FindTypes (sc, name, parent_decl_ctx, append, max_matches, types);
return false;
});
}
@@ -1320,24 +1314,24 @@ SymbolFileDWARFDebugMap::FindTypes
//}
-ClangNamespaceDecl
+CompilerDeclContext
SymbolFileDWARFDebugMap::FindNamespace (const lldb_private::SymbolContext& sc,
const lldb_private::ConstString &name,
- const ClangNamespaceDecl *parent_namespace_decl)
+ const CompilerDeclContext *parent_decl_ctx)
{
- ClangNamespaceDecl matching_namespace;
+ CompilerDeclContext matching_namespace;
SymbolFileDWARF *oso_dwarf;
if (sc.comp_unit)
{
oso_dwarf = GetSymbolFile (sc);
if (oso_dwarf)
- matching_namespace = oso_dwarf->FindNamespace (sc, name, parent_namespace_decl);
+ matching_namespace = oso_dwarf->FindNamespace (sc, name, parent_decl_ctx);
}
else
{
ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
- matching_namespace = oso_dwarf->FindNamespace (sc, name, parent_namespace_decl);
+ matching_namespace = oso_dwarf->FindNamespace (sc, name, parent_decl_ctx);
return (bool)matching_namespace;
});
@@ -1401,7 +1395,6 @@ SymbolFileDWARFDebugMap::GetCompileUnitInfo (SymbolFileDWARF *oso_dwarf)
return NULL;
}
-
void
SymbolFileDWARFDebugMap::SetCompileUnit (SymbolFileDWARF *oso_dwarf, const CompUnitSP &cu_sp)
{
@@ -1427,78 +1420,33 @@ SymbolFileDWARFDebugMap::SetCompileUnit (SymbolFileDWARF *oso_dwarf, const CompU
}
}
-
-void
-SymbolFileDWARFDebugMap::CompleteTagDecl (void *baton, clang::TagDecl *decl)
-{
- SymbolFileDWARFDebugMap *symbol_file_dwarf = (SymbolFileDWARFDebugMap *)baton;
- ClangASTType clang_type = symbol_file_dwarf->GetClangASTContext().GetTypeForDecl (decl);
- if (clang_type)
- {
- symbol_file_dwarf->ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
- if (oso_dwarf->HasForwardDeclForClangType (clang_type))
- {
- oso_dwarf->ResolveClangOpaqueTypeDefinition (clang_type);
- return true;
- }
- return false;
- });
- }
-}
-
-void
-SymbolFileDWARFDebugMap::CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *decl)
-{
- SymbolFileDWARFDebugMap *symbol_file_dwarf = (SymbolFileDWARFDebugMap *)baton;
- ClangASTType clang_type = symbol_file_dwarf->GetClangASTContext().GetTypeForDecl (decl);
- if (clang_type)
- {
- symbol_file_dwarf->ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
- if (oso_dwarf->HasForwardDeclForClangType (clang_type))
- {
- oso_dwarf->ResolveClangOpaqueTypeDefinition (clang_type);
- return true;
- }
- return false;
- });
- }
-}
-
-bool
-SymbolFileDWARFDebugMap::LayoutRecordType(void *baton, const clang::RecordDecl *record_decl, uint64_t &size,
- uint64_t &alignment,
- llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets)
-{
- SymbolFileDWARFDebugMap *symbol_file_dwarf = (SymbolFileDWARFDebugMap *)baton;
- bool laid_out = false;
- symbol_file_dwarf->ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
- return (laid_out = oso_dwarf->LayoutRecordType (record_decl, size, alignment, field_offsets, base_offsets, vbase_offsets));
- });
- return laid_out;
-}
-
-
-
-clang::DeclContext*
-SymbolFileDWARFDebugMap::GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid)
+CompilerDeclContext
+SymbolFileDWARFDebugMap::GetDeclContextForUID (lldb::user_id_t type_uid)
{
const uint64_t oso_idx = GetOSOIndexFromUserID (type_uid);
SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx);
if (oso_dwarf)
- return oso_dwarf->GetClangDeclContextContainingTypeUID (type_uid);
- return NULL;
+ return oso_dwarf->GetDeclContextForUID (type_uid);
+ return CompilerDeclContext();
}
-clang::DeclContext*
-SymbolFileDWARFDebugMap::GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid)
+CompilerDeclContext
+SymbolFileDWARFDebugMap::GetDeclContextContainingUID (lldb::user_id_t type_uid)
{
const uint64_t oso_idx = GetOSOIndexFromUserID (type_uid);
SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx);
if (oso_dwarf)
- return oso_dwarf->GetClangDeclContextForTypeUID (sc, type_uid);
- return NULL;
+ return oso_dwarf->GetDeclContextContainingUID (type_uid);
+ return CompilerDeclContext();
+}
+
+void
+SymbolFileDWARFDebugMap::ParseDeclsForContext (lldb_private::CompilerDeclContext decl_ctx)
+{
+ ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
+ oso_dwarf->ParseDeclsForContext (decl_ctx);
+ return true; // Keep iterating
+ });
}
bool
@@ -1613,7 +1561,6 @@ SymbolFileDWARFDebugMap::AddOSOARanges (SymbolFileDWARF* dwarf2Data, DWARFDebugA
const FileRangeMap::Entry* entry = file_range_map.GetEntryAtIndex(idx);
if (entry)
{
- printf ("[0x%16.16" PRIx64 " - 0x%16.16" PRIx64 ")\n", entry->GetRangeBase(), entry->GetRangeEnd());
debug_aranges->AppendRange(dwarf2Data->GetID(), entry->GetRangeBase(), entry->GetRangeEnd());
num_line_entries_added++;
}
@@ -1622,4 +1569,3 @@ SymbolFileDWARFDebugMap::AddOSOARanges (SymbolFileDWARF* dwarf2Data, DWARFDebugA
}
return num_line_entries_added;
}
-
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
index ce0cfd744f0b..1eb33c927bdf 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -14,19 +14,14 @@
#include <vector>
#include <bitset>
-#include "clang/AST/CharUnits.h"
-
#include "lldb/Core/RangeMap.h"
#include "lldb/Symbol/SymbolFile.h"
#include "UniqueDWARFASTType.h"
class SymbolFileDWARF;
-class DWARFCompileUnit;
class DWARFDebugAranges;
-class DWARFDebugInfoEntry;
class DWARFDeclContext;
-class DebugMapModule;
class SymbolFileDWARFDebugMap : public lldb_private::SymbolFile
{
@@ -57,7 +52,6 @@ public:
~SymbolFileDWARFDebugMap () override;
uint32_t CalculateAbilities () override;
-
void InitializeObject() override;
//------------------------------------------------------------------
@@ -69,6 +63,7 @@ public:
lldb::LanguageType ParseCompileUnitLanguage (const lldb_private::SymbolContext& sc) override;
size_t ParseCompileUnitFunctions (const lldb_private::SymbolContext& sc) override;
bool ParseCompileUnitLineTable (const lldb_private::SymbolContext& sc) override;
+ bool ParseCompileUnitDebugMacros (const lldb_private::SymbolContext& sc) override;
bool ParseCompileUnitSupportFiles (const lldb_private::SymbolContext& sc, lldb_private::FileSpecList &support_files) override;
bool ParseImportedModules (const lldb_private::SymbolContext &sc, std::vector<lldb_private::ConstString> &imported_modules) override;
size_t ParseFunctionBlocks (const lldb_private::SymbolContext& sc) override;
@@ -76,39 +71,26 @@ public:
size_t ParseVariablesForContext (const lldb_private::SymbolContext& sc) override;
lldb_private::Type* ResolveTypeUID (lldb::user_id_t type_uid) override;
- clang::DeclContext* GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid) override;
- clang::DeclContext* GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid) override;
- bool ResolveClangOpaqueTypeDefinition (lldb_private::ClangASTType& clang_type) override;
+ lldb_private::CompilerDeclContext GetDeclContextForUID (lldb::user_id_t uid) override;
+ lldb_private::CompilerDeclContext GetDeclContextContainingUID (lldb::user_id_t uid) override;
+ void ParseDeclsForContext (lldb_private::CompilerDeclContext decl_ctx) override;
+
+ bool CompleteType (lldb_private::CompilerType& compiler_type) override;
uint32_t ResolveSymbolContext (const lldb_private::Address& so_addr, uint32_t resolve_scope, lldb_private::SymbolContext& sc) override;
uint32_t ResolveSymbolContext (const lldb_private::FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, lldb_private::SymbolContextList& sc_list) override;
- uint32_t FindGlobalVariables (const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::VariableList& variables) override;
+ uint32_t FindGlobalVariables (const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, lldb_private::VariableList& variables) override;
uint32_t FindGlobalVariables (const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb_private::VariableList& variables) override;
- uint32_t FindFunctions (const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, uint32_t name_type_mask, bool include_inlines, bool append, lldb_private::SymbolContextList& sc_list) override;
+ uint32_t FindFunctions (const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool include_inlines, bool append, lldb_private::SymbolContextList& sc_list) override;
uint32_t FindFunctions (const lldb_private::RegularExpression& regex, bool include_inlines, bool append, lldb_private::SymbolContextList& sc_list) override;
- uint32_t FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::TypeList& types) override;
- lldb_private::ClangNamespaceDecl
+ uint32_t FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, lldb_private::TypeMap& types) override;
+ lldb_private::CompilerDeclContext
FindNamespace (const lldb_private::SymbolContext& sc,
const lldb_private::ConstString &name,
- const lldb_private::ClangNamespaceDecl *parent_namespace_decl) override;
+ const lldb_private::CompilerDeclContext *parent_decl_ctx) override;
size_t GetTypes (lldb_private::SymbolContextScope *sc_scope,
uint32_t type_mask,
lldb_private::TypeList &type_list) override;
-
- //------------------------------------------------------------------
- // ClangASTContext callbacks for external source lookups.
- //------------------------------------------------------------------
- static void
- CompleteTagDecl (void *baton, clang::TagDecl *);
-
- static void
- CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *);
-
- static bool LayoutRecordType(void *baton, const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment,
- llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets);
-
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
@@ -128,6 +110,7 @@ protected:
friend class DWARFCompileUnit;
friend class SymbolFileDWARF;
friend class DebugMapModule;
+ friend class DWARFASTParserClang;
struct OSOInfo
{
lldb::ModuleSP module_sp;
@@ -259,7 +242,7 @@ protected:
uint32_t
PrivateFindGlobalVariables (const lldb_private::ConstString &name,
- const lldb_private::ClangNamespaceDecl *namespace_decl,
+ const lldb_private::CompilerDeclContext *parent_decl_ctx,
const std::vector<uint32_t> &name_symbol_indexes,
uint32_t max_matches,
lldb_private::VariableList& variables);
@@ -281,7 +264,7 @@ protected:
Supports_DW_AT_APPLE_objc_complete_type (SymbolFileDWARF *skip_dwarf_oso);
lldb::TypeSP
- FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry *die,
+ FindCompleteObjCDefinitionTypeForDIE (const DWARFDIE &die,
const lldb_private::ConstString &type_name,
bool must_be_implementation);
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
new file mode 100644
index 000000000000..326c397c83d5
--- /dev/null
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -0,0 +1,131 @@
+//===-- SymbolFileDWARFDwo.cpp ----------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "SymbolFileDWARFDwo.h"
+
+#include "lldb/Core/Section.h"
+#include "lldb/Expression/DWARFExpression.h"
+#include "lldb/Symbol/ObjectFile.h"
+
+#include "DWARFCompileUnit.h"
+#include "DWARFDebugInfo.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+SymbolFileDWARFDwo::SymbolFileDWARFDwo(ObjectFileSP objfile, DWARFCompileUnit* 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);
+}
+
+void
+SymbolFileDWARFDwo::LoadSectionData (lldb::SectionType sect_type, DWARFDataExtractor& data)
+{
+ const SectionList* section_list = m_obj_file->GetSectionList(false /* update_module_section_list */);
+ 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;
+
+ data.Clear();
+ }
+ }
+
+ SymbolFileDWARF::LoadSectionData(sect_type, data);
+}
+
+lldb::CompUnitSP
+SymbolFileDWARFDwo::ParseCompileUnit(DWARFCompileUnit* 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);
+}
+
+DWARFCompileUnit*
+SymbolFileDWARFDwo::GetCompileUnit()
+{
+ // Only dwo files with 1 compile unit is supported
+ if (GetNumCompileUnits() == 1)
+ return DebugInfo()->GetCompileUnitAtIndex(0);
+ else
+ return nullptr;
+}
+
+DWARFCompileUnit*
+SymbolFileDWARFDwo::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit)
+{
+ return GetCompileUnit();
+}
+
+SymbolFileDWARF::DIEToTypePtr&
+SymbolFileDWARFDwo::GetDIEToType()
+{
+ return GetBaseSymbolFile()->GetDIEToType();
+}
+
+SymbolFileDWARF::DIEToVariableSP&
+SymbolFileDWARFDwo::GetDIEToVariable()
+{
+ return GetBaseSymbolFile()->GetDIEToVariable();
+}
+
+SymbolFileDWARF::DIEToClangType&
+SymbolFileDWARFDwo::GetForwardDeclDieToClangType()
+{
+ return GetBaseSymbolFile()->GetForwardDeclDieToClangType();
+}
+
+SymbolFileDWARF::ClangTypeToDIE&
+SymbolFileDWARFDwo::GetForwardDeclClangTypeToDie()
+{
+ return GetBaseSymbolFile()->GetForwardDeclClangTypeToDie();
+}
+
+UniqueDWARFASTTypeMap&
+SymbolFileDWARFDwo::GetUniqueDWARFASTTypeMap()
+{
+ return GetBaseSymbolFile()->GetUniqueDWARFASTTypeMap();
+}
+
+lldb::TypeSP
+SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext &die_decl_ctx)
+{
+ return GetBaseSymbolFile()->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
+}
+
+SymbolFileDWARF*
+SymbolFileDWARFDwo::GetBaseSymbolFile()
+{
+ return m_base_dwarf_cu->GetSymbolFileDWARF();
+}
+
+DWARFExpression::LocationListFormat
+SymbolFileDWARFDwo::GetLocationListFormat() const
+{
+ return DWARFExpression::SplitDwarfLocationList;
+}
+
+TypeSystem*
+SymbolFileDWARFDwo::GetTypeSystemForLanguage(LanguageType language)
+{
+ return GetBaseSymbolFile()->GetTypeSystemForLanguage(language);
+}
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
new file mode 100644
index 000000000000..39ed6502229b
--- /dev/null
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -0,0 +1,70 @@
+//===-- SymbolFileDWARFDwo.h ------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SymbolFileDWARFDwo_SymbolFileDWARFDwo_h_
+#define SymbolFileDWARFDwo_SymbolFileDWARFDwo_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "SymbolFileDWARF.h"
+
+class SymbolFileDWARFDwo : public SymbolFileDWARF
+{
+public:
+ SymbolFileDWARFDwo(lldb::ObjectFileSP objfile, DWARFCompileUnit* dwarf_cu);
+
+ ~SymbolFileDWARFDwo() override = default;
+
+ lldb::CompUnitSP
+ ParseCompileUnit(DWARFCompileUnit* dwarf_cu, uint32_t cu_idx) override;
+
+ DWARFCompileUnit*
+ GetCompileUnit();
+
+ DWARFCompileUnit*
+ GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) override;
+
+ lldb_private::DWARFExpression::LocationListFormat
+ GetLocationListFormat() const override;
+
+ lldb_private::TypeSystem*
+ GetTypeSystemForLanguage(lldb::LanguageType language) override;
+
+protected:
+ void
+ LoadSectionData (lldb::SectionType sect_type, lldb_private::DWARFDataExtractor& data) override;
+
+ DIEToTypePtr&
+ GetDIEToType() override;
+
+ DIEToVariableSP&
+ GetDIEToVariable() override;
+
+ DIEToClangType&
+ GetForwardDeclDieToClangType() override;
+
+ ClangTypeToDIE&
+ GetForwardDeclClangTypeToDie() override;
+
+ UniqueDWARFASTTypeMap&
+ GetUniqueDWARFASTTypeMap() override;
+
+ lldb::TypeSP
+ FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext &die_decl_ctx) override;
+
+ SymbolFileDWARF*
+ GetBaseSymbolFile();
+
+ lldb::ObjectFileSP m_obj_file_sp;
+ DWARFCompileUnit* m_base_dwarf_cu;
+};
+
+#endif // SymbolFileDWARFDwo_SymbolFileDWARFDwo_h_
diff --git a/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp b/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
index 94044c0feb30..2ca407b9e48a 100644
--- a/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
+++ b/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
@@ -15,58 +15,51 @@
// Project includes
#include "lldb/Symbol/Declaration.h"
-#include "DWARFDebugInfoEntry.h"
-
bool
-UniqueDWARFASTTypeList::Find
-(
- SymbolFileDWARF *symfile,
- const DWARFCompileUnit *cu,
- const DWARFDebugInfoEntry *die,
- const lldb_private::Declaration &decl,
- const int32_t byte_size,
- UniqueDWARFASTType &entry
-) const
+UniqueDWARFASTTypeList::Find (const DWARFDIE &die,
+ const lldb_private::Declaration &decl,
+ const int32_t byte_size,
+ UniqueDWARFASTType &entry) const
{
- collection::const_iterator pos, end = m_collection.end();
- for (pos = m_collection.begin(); pos != end; ++pos)
+ for (const UniqueDWARFASTType &udt : m_collection)
{
// Make sure the tags match
- if (pos->m_die->Tag() == die->Tag())
+ if (udt.m_die.Tag() == die.Tag())
{
// Validate byte sizes of both types only if both are valid.
- if (pos->m_byte_size < 0 || byte_size < 0 || pos->m_byte_size == byte_size)
+ if (udt.m_byte_size < 0 || byte_size < 0 || udt.m_byte_size == byte_size)
{
// Make sure the file and line match
- if (pos->m_declaration == decl)
+ if (udt.m_declaration == decl)
{
// The type has the same name, and was defined on the same
// file and line. Now verify all of the parent DIEs match.
- const DWARFDebugInfoEntry *parent_arg_die = die->GetParent();
- const DWARFDebugInfoEntry *parend_pos_die = pos->m_die->GetParent();
+ DWARFDIE parent_arg_die = die.GetParent();
+ DWARFDIE parent_pos_die = udt.m_die.GetParent();
bool match = true;
bool done = false;
- while (!done && match && parent_arg_die && parend_pos_die)
+ while (!done && match && parent_arg_die && parent_pos_die)
{
- if (parent_arg_die->Tag() == parend_pos_die->Tag())
+ const dw_tag_t parent_arg_tag = parent_arg_die.Tag();
+ const dw_tag_t parent_pos_tag = parent_pos_die.Tag();
+ if (parent_arg_tag == parent_pos_tag)
{
- const dw_tag_t tag = parent_arg_die->Tag();
- switch (tag)
+ switch (parent_arg_tag)
{
case DW_TAG_class_type:
case DW_TAG_structure_type:
case DW_TAG_union_type:
case DW_TAG_namespace:
{
- const char *parent_arg_die_name = parent_arg_die->GetName(symfile, cu);
+ const char *parent_arg_die_name = parent_arg_die.GetName();
if (parent_arg_die_name == NULL) // Anonymous (i.e. no-name) struct
{
match = false;
}
else
{
- const char *parent_pos_die_name = parend_pos_die->GetName(pos->m_symfile, pos->m_cu);
- if (parent_pos_die_name == NULL || strcmp (parent_arg_die_name, parent_pos_die_name))
+ const char *parent_pos_die_name = parent_pos_die.GetName();
+ if (parent_pos_die_name == NULL || ((parent_arg_die_name != parent_pos_die_name) && strcmp (parent_arg_die_name, parent_pos_die_name)))
match = false;
}
}
@@ -77,13 +70,13 @@ UniqueDWARFASTTypeList::Find
break;
}
}
- parent_arg_die = parent_arg_die->GetParent();
- parend_pos_die = parend_pos_die->GetParent();
+ parent_arg_die = parent_arg_die.GetParent();
+ parent_pos_die = parent_pos_die.GetParent();
}
if (match)
{
- entry = *pos;
+ entry = udt;
return true;
}
}
diff --git a/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h b/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h
index c85e175235ca..b7b18efd8769 100644
--- a/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h
+++ b/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h
@@ -19,10 +19,7 @@
// Project includes
#include "lldb/Symbol/Declaration.h"
-
-class DWARFCompileUnit;
-class DWARFDebugInfoEntry;
-class SymbolFileDWARF;
+#include "DWARFDIE.h"
class UniqueDWARFASTType
{
@@ -32,23 +29,17 @@ public:
//------------------------------------------------------------------
UniqueDWARFASTType () :
m_type_sp (),
- m_symfile (NULL),
- m_cu (NULL),
- m_die (NULL),
+ m_die (),
m_declaration (),
m_byte_size (-1) // Set to negative value to make sure we have a valid value
{
}
UniqueDWARFASTType (lldb::TypeSP &type_sp,
- SymbolFileDWARF *symfile,
- DWARFCompileUnit *cu,
- DWARFDebugInfoEntry *die,
+ const DWARFDIE &die,
const lldb_private::Declaration &decl,
int32_t byte_size) :
m_type_sp (type_sp),
- m_symfile (symfile),
- m_cu (cu),
m_die (die),
m_declaration (decl),
m_byte_size (byte_size)
@@ -57,8 +48,6 @@ public:
UniqueDWARFASTType (const UniqueDWARFASTType &rhs) :
m_type_sp (rhs.m_type_sp),
- m_symfile (rhs.m_symfile),
- m_cu (rhs.m_cu),
m_die (rhs.m_die),
m_declaration (rhs.m_declaration),
m_byte_size (rhs.m_byte_size)
@@ -75,8 +64,6 @@ public:
if (this != &rhs)
{
m_type_sp = rhs.m_type_sp;
- m_symfile = rhs.m_symfile;
- m_cu = rhs.m_cu;
m_die = rhs.m_die;
m_declaration = rhs.m_declaration;
m_byte_size = rhs.m_byte_size;
@@ -85,9 +72,7 @@ public:
}
lldb::TypeSP m_type_sp;
- SymbolFileDWARF *m_symfile;
- const DWARFCompileUnit *m_cu;
- const DWARFDebugInfoEntry *m_die;
+ DWARFDIE m_die;
lldb_private::Declaration m_declaration;
int32_t m_byte_size;
};
@@ -117,9 +102,7 @@ public:
}
bool
- Find (SymbolFileDWARF *symfile,
- const DWARFCompileUnit *cu,
- const DWARFDebugInfoEntry *die,
+ Find (const DWARFDIE &die,
const lldb_private::Declaration &decl,
const int32_t byte_size,
UniqueDWARFASTType &entry) const;
@@ -149,10 +132,8 @@ public:
}
bool
- Find (const lldb_private::ConstString &name,
- SymbolFileDWARF *symfile,
- const DWARFCompileUnit *cu,
- const DWARFDebugInfoEntry *die,
+ Find (const lldb_private::ConstString &name,
+ const DWARFDIE &die,
const lldb_private::Declaration &decl,
const int32_t byte_size,
UniqueDWARFASTType &entry) const
@@ -161,7 +142,7 @@ public:
collection::const_iterator pos = m_collection.find (unique_name_cstr);
if (pos != m_collection.end())
{
- return pos->second.Find (symfile, cu, die, decl, byte_size, entry);
+ return pos->second.Find (die, decl, byte_size, entry);
}
return false;
}
diff --git a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
index 09b919782608..d3dd1ae923e0 100644
--- a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
+++ b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
@@ -12,7 +12,6 @@
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/Timer.h"
-#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -79,14 +78,6 @@ SymbolFileSymtab::~SymbolFileSymtab()
{
}
-ClangASTContext &
-SymbolFileSymtab::GetClangASTContext ()
-{
- ClangASTContext &ast = m_obj_file->GetModule()->GetClangASTContext();
-
- return ast;
-}
-
uint32_t
SymbolFileSymtab::CalculateAbilities ()
{
@@ -115,6 +106,7 @@ SymbolFileSymtab::CalculateAbilities ()
if (symtab->AppendSymbolIndexesWithType(eSymbolTypeCode, Symtab::eDebugNo, Symtab::eVisibilityAny, m_code_indexes))
{
symtab->SortSymbolIndexesByValue(m_code_indexes, true);
+ abilities |= Functions;
}
if (symtab->AppendSymbolIndexesWithType(eSymbolTypeData, m_data_indexes))
@@ -161,7 +153,7 @@ 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_symbol->GetName().AsCString(), 0, eLanguageTypeUnknown));
+ cu_sp.reset(new CompileUnit (m_obj_file->GetModule(), NULL, cu_symbol->GetName().AsCString(), 0, eLanguageTypeUnknown, false));
}
return cu_sp;
}
@@ -261,6 +253,12 @@ SymbolFileSymtab::ParseCompileUnitLineTable (const SymbolContext &sc)
}
bool
+SymbolFileSymtab::ParseCompileUnitDebugMacros (const SymbolContext &sc)
+{
+ return false;
+}
+
+bool
SymbolFileSymtab::ParseCompileUnitSupportFiles (const SymbolContext& sc, FileSpecList &support_files)
{
return false;
@@ -299,17 +297,11 @@ SymbolFileSymtab::ResolveTypeUID(lldb::user_id_t type_uid)
}
bool
-SymbolFileSymtab::ResolveClangOpaqueTypeDefinition (lldb_private::ClangASTType& clang_opaque_type)
+SymbolFileSymtab::CompleteType (lldb_private::CompilerType& compiler_type)
{
return false;
}
-ClangNamespaceDecl
-SymbolFileSymtab::FindNamespace (const SymbolContext& sc, const ConstString &name, const ClangNamespaceDecl *namespace_decl)
-{
- return ClangNamespaceDecl();
-}
-
uint32_t
SymbolFileSymtab::ResolveSymbolContext (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc)
{
@@ -326,63 +318,6 @@ SymbolFileSymtab::ResolveSymbolContext (const Address& so_addr, uint32_t resolve
return resolved_flags;
}
-uint32_t
-SymbolFileSymtab::ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list)
-{
- return 0;
-}
-
-uint32_t
-SymbolFileSymtab::FindGlobalVariables(const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, VariableList& variables)
-{
- return 0;
-}
-
-uint32_t
-SymbolFileSymtab::FindGlobalVariables(const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables)
-{
- return 0;
-}
-
-uint32_t
-SymbolFileSymtab::FindFunctions(const ConstString &name, const ClangNamespaceDecl *namespace_decl, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list)
-{
- Timer scoped_timer (__PRETTY_FUNCTION__,
- "SymbolFileSymtab::FindFunctions (name = '%s')",
- name.GetCString());
- // If we ever support finding STABS or COFF debug info symbols,
- // we will need to add support here. We are not trying to find symbols
- // here, just "lldb_private::Function" objects that come from complete
- // debug information. Any symbol queries should go through the symbol
- // table itself in the module's object file.
- return 0;
-}
-
-uint32_t
-SymbolFileSymtab::FindFunctions(const RegularExpression& regex, bool include_inlines, bool append, SymbolContextList& sc_list)
-{
- Timer scoped_timer (__PRETTY_FUNCTION__,
- "SymbolFileSymtab::FindFunctions (regex = '%s')",
- regex.GetText());
- // If we ever support finding STABS or COFF debug info symbols,
- // we will need to add support here. We are not trying to find symbols
- // here, just "lldb_private::Function" objects that come from complete
- // debug information. Any symbol queries should go through the symbol
- // table itself in the module's object file.
- return 0;
-}
-
-uint32_t
-SymbolFileSymtab::FindTypes (const lldb_private::SymbolContext& sc,
- const lldb_private::ConstString &name,
- const ClangNamespaceDecl *namespace_decl,
- bool append,
- uint32_t max_matches,
- lldb_private::TypeList& types)
-{
- return 0;
-}
-
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
diff --git a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
index d606419a0d94..4648da49cb9f 100644
--- a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
+++ b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
@@ -10,14 +10,26 @@
#ifndef liblldb_SymbolFileSymtab_h_
#define liblldb_SymbolFileSymtab_h_
+// C Includes
+// C++ Includes
+#include <vector>
+
+// Other libraries and framework includes
+// Project includes
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/Symtab.h"
-#include <vector>
class SymbolFileSymtab : public lldb_private::SymbolFile
{
public:
//------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ SymbolFileSymtab(lldb_private::ObjectFile* obj_file);
+
+ ~SymbolFileSymtab() override;
+
+ //------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
static void
@@ -35,94 +47,71 @@ public:
static lldb_private::SymbolFile*
CreateInstance (lldb_private::ObjectFile* obj_file);
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- SymbolFileSymtab(lldb_private::ObjectFile* obj_file);
-
- virtual
- ~SymbolFileSymtab();
-
- virtual uint32_t CalculateAbilities ();
+ uint32_t
+ CalculateAbilities() override;
//------------------------------------------------------------------
// Compile Unit function calls
//------------------------------------------------------------------
- virtual uint32_t
- GetNumCompileUnits();
-
- virtual lldb::CompUnitSP
- ParseCompileUnitAtIndex(uint32_t index);
-
- virtual lldb::LanguageType
- ParseCompileUnitLanguage (const lldb_private::SymbolContext& sc);
-
- virtual size_t
- ParseCompileUnitFunctions (const lldb_private::SymbolContext& sc);
-
- virtual bool
- ParseCompileUnitLineTable (const lldb_private::SymbolContext& sc);
+ uint32_t
+ GetNumCompileUnits() override;
- virtual bool
- ParseCompileUnitSupportFiles (const lldb_private::SymbolContext& sc, lldb_private::FileSpecList &support_files);
-
- virtual bool
- ParseImportedModules (const lldb_private::SymbolContext &sc, std::vector<lldb_private::ConstString> &imported_modules);
-
- virtual size_t
- ParseFunctionBlocks (const lldb_private::SymbolContext& sc);
-
- virtual size_t
- ParseTypes (const lldb_private::SymbolContext& sc);
+ lldb::CompUnitSP
+ ParseCompileUnitAtIndex(uint32_t index) override;
- virtual size_t
- ParseVariablesForContext (const lldb_private::SymbolContext& sc);
+ lldb::LanguageType
+ ParseCompileUnitLanguage(const lldb_private::SymbolContext& sc) override;
- virtual lldb_private::Type*
- ResolveTypeUID(lldb::user_id_t type_uid);
+ size_t
+ ParseCompileUnitFunctions(const lldb_private::SymbolContext& sc) override;
- virtual bool
- ResolveClangOpaqueTypeDefinition (lldb_private::ClangASTType& clang_type);
+ bool
+ ParseCompileUnitLineTable(const lldb_private::SymbolContext& sc) override;
- virtual uint32_t
- ResolveSymbolContext (const lldb_private::Address& so_addr, uint32_t resolve_scope, lldb_private::SymbolContext& sc);
+ bool
+ ParseCompileUnitDebugMacros(const lldb_private::SymbolContext& sc) override;
- virtual uint32_t
- ResolveSymbolContext (const lldb_private::FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, lldb_private::SymbolContextList& sc_list);
+ bool
+ ParseCompileUnitSupportFiles(const lldb_private::SymbolContext& sc,
+ lldb_private::FileSpecList &support_files) override;
+
+ bool
+ ParseImportedModules(const lldb_private::SymbolContext &sc,
+ std::vector<lldb_private::ConstString> &imported_modules) override;
- virtual uint32_t
- FindGlobalVariables(const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::VariableList& variables);
+ size_t
+ ParseFunctionBlocks(const lldb_private::SymbolContext& sc) override;
- virtual uint32_t
- FindGlobalVariables(const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb_private::VariableList& variables);
+ size_t
+ ParseTypes(const lldb_private::SymbolContext& sc) override;
- virtual uint32_t
- FindFunctions(const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, uint32_t name_type_mask, bool include_inlines, bool append, lldb_private::SymbolContextList& sc_list);
+ size_t
+ ParseVariablesForContext(const lldb_private::SymbolContext& sc) override;
- virtual uint32_t
- FindFunctions(const lldb_private::RegularExpression& regex, bool include_inlines, bool append, lldb_private::SymbolContextList& sc_list);
+ lldb_private::Type*
+ ResolveTypeUID(lldb::user_id_t type_uid) override;
- virtual uint32_t
- FindTypes (const lldb_private::SymbolContext& sc,const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::TypeList& types);
+ bool
+ CompleteType(lldb_private::CompilerType& compiler_type) override;
- virtual size_t
- GetTypes (lldb_private::SymbolContextScope *sc_scope,
- uint32_t type_mask,
- lldb_private::TypeList &type_list);
+ uint32_t
+ ResolveSymbolContext(const lldb_private::Address& so_addr,
+ uint32_t resolve_scope,
+ lldb_private::SymbolContext& sc) override;
- virtual lldb_private::ClangNamespaceDecl
- FindNamespace (const lldb_private::SymbolContext& sc,
- const lldb_private::ConstString &name,
- const lldb_private::ClangNamespaceDecl *parent_namespace_decl);
+ size_t
+ GetTypes(lldb_private::SymbolContextScope *sc_scope,
+ uint32_t type_mask,
+ lldb_private::TypeList &type_list) override;
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
- virtual lldb_private::ConstString
- GetPluginName();
+ lldb_private::ConstString
+ GetPluginName() override;
- virtual uint32_t
- GetPluginVersion();
+ uint32_t
+ GetPluginVersion() override;
protected:
typedef std::map<lldb_private::ConstString, lldb::TypeSP> TypeMap;
@@ -133,13 +122,9 @@ protected:
lldb_private::Symtab::IndexCollection m_data_indexes;
lldb_private::Symtab::NameToIndexMap m_objc_class_name_to_index;
TypeMap m_objc_class_types;
-
- lldb_private::ClangASTContext &
- GetClangASTContext ();
private:
DISALLOW_COPY_AND_ASSIGN (SymbolFileSymtab);
};
-
-#endif // liblldb_SymbolFileSymtab_h_
+#endif // liblldb_SymbolFileSymtab_h_
diff --git a/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp b/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
index a9f8f36e610e..3cd1b68d7b0f 100644
--- a/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
+++ b/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
@@ -142,17 +142,19 @@ SymbolVendorELF::CreateInstance (const lldb::ModuleSP &module_sp, lldb_private::
static const SectionType g_sections[] =
{
- eSectionTypeDWARFDebugAranges,
- eSectionTypeDWARFDebugInfo,
eSectionTypeDWARFDebugAbbrev,
+ eSectionTypeDWARFDebugAddr,
+ eSectionTypeDWARFDebugAranges,
eSectionTypeDWARFDebugFrame,
+ eSectionTypeDWARFDebugInfo,
eSectionTypeDWARFDebugLine,
- eSectionTypeDWARFDebugStr,
eSectionTypeDWARFDebugLoc,
eSectionTypeDWARFDebugMacInfo,
eSectionTypeDWARFDebugPubNames,
eSectionTypeDWARFDebugPubTypes,
eSectionTypeDWARFDebugRanges,
+ eSectionTypeDWARFDebugStr,
+ eSectionTypeDWARFDebugStrOffsets,
eSectionTypeELFSymbolTable,
};
for (size_t idx = 0; idx < sizeof(g_sections) / sizeof(g_sections[0]); ++idx)
diff --git a/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h b/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h
index acd62b6cc3ab..425ff9efc59c 100644
--- a/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h
+++ b/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h
@@ -1,4 +1,4 @@
-//===-- SymbolVendorELF.h ------------------------------------*- C++ -*-===//
+//===-- SymbolVendorELF.h ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,6 +10,10 @@
#ifndef liblldb_SymbolVendorELF_h_
#define liblldb_SymbolVendorELF_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Symbol/SymbolVendor.h"
@@ -17,6 +21,13 @@ class SymbolVendorELF : public lldb_private::SymbolVendor
{
public:
//------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ SymbolVendorELF (const lldb::ModuleSP &module_sp);
+
+ ~SymbolVendorELF() override;
+
+ //------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
static void
@@ -35,24 +46,16 @@ public:
CreateInstance (const lldb::ModuleSP &module_sp, lldb_private::Stream *feedback_strm);
//------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- SymbolVendorELF (const lldb::ModuleSP &module_sp);
-
- virtual
- ~SymbolVendorELF();
-
- //------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
- virtual lldb_private::ConstString
- GetPluginName();
+ lldb_private::ConstString
+ GetPluginName() override;
- virtual uint32_t
- GetPluginVersion();
+ uint32_t
+ GetPluginVersion() override;
private:
DISALLOW_COPY_AND_ASSIGN (SymbolVendorELF);
};
-#endif // liblldb_SymbolVendorELF_h_
+#endif // liblldb_SymbolVendorELF_h_
diff --git a/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
index 8f5d92697501..eb5fec34fc20 100644
--- a/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
+++ b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
@@ -117,21 +117,13 @@ UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly (AddressRange&
// cache the pc register number (in whatever register numbering this UnwindPlan uses) for
// quick reference during instruction parsing.
- uint32_t pc_reg_num = LLDB_INVALID_REGNUM;
RegisterInfo pc_reg_info;
- if (m_inst_emulator_ap->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, pc_reg_info))
- pc_reg_num = pc_reg_info.kinds[unwind_plan.GetRegisterKind()];
- else
- pc_reg_num = LLDB_INVALID_REGNUM;
+ m_inst_emulator_ap->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.
- uint32_t ra_reg_num = LLDB_INVALID_REGNUM;
RegisterInfo ra_reg_info;
- if (m_inst_emulator_ap->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA, ra_reg_info))
- ra_reg_num = ra_reg_info.kinds[unwind_plan.GetRegisterKind()];
- else
- ra_reg_num = LLDB_INVALID_REGNUM;
+ m_inst_emulator_ap->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA, ra_reg_info);
for (size_t idx=0; idx<num_instructions; ++idx)
{
@@ -511,7 +503,8 @@ UnwindAssemblyInstEmulation::WriteRegister (EmulateInstruction *instruction,
log->PutCString(strm.GetData());
}
- SetRegisterValue (*reg_info, reg_value);
+ if (!instruction->IsInstructionConditional())
+ SetRegisterValue (*reg_info, reg_value);
switch (context.type)
{
@@ -573,18 +566,45 @@ UnwindAssemblyInstEmulation::WriteRegister (EmulateInstruction *instruction,
case EmulateInstruction::eContextPopRegisterOffStack:
{
- const uint32_t reg_num = reg_info->kinds[m_unwind_plan_ptr->GetRegisterKind()];
- const uint32_t generic_regnum = reg_info->kinds[eRegisterKindGeneric];
- if (reg_num != LLDB_INVALID_REGNUM && generic_regnum != LLDB_REGNUM_GENERIC_SP)
+ if (!instruction->IsInstructionConditional())
{
- m_curr_row->SetRegisterLocationToSame (reg_num, /*must_replace*/ false);
- m_curr_row_modified = true;
+ const uint32_t reg_num = reg_info->kinds[m_unwind_plan_ptr->GetRegisterKind()];
+ const uint32_t generic_regnum = reg_info->kinds[eRegisterKindGeneric];
+ if (reg_num != LLDB_INVALID_REGNUM && generic_regnum != LLDB_REGNUM_GENERIC_SP)
+ {
+ switch (context.info_type)
+ {
+ case EmulateInstruction::eInfoTypeAddress:
+ if (m_pushed_regs.find(reg_num) != m_pushed_regs.end() &&
+ context.info.address == m_pushed_regs[reg_num])
+ {
+ m_curr_row->SetRegisterLocationToSame(reg_num,
+ false /*must_replace*/);
+ m_curr_row_modified = true;
+ }
+ break;
+ case EmulateInstruction::eInfoTypeISA:
+ assert((generic_regnum == LLDB_REGNUM_GENERIC_PC ||
+ generic_regnum == LLDB_REGNUM_GENERIC_FLAGS) &&
+ "eInfoTypeISA used for poping a register other the the PC/FLAGS");
+ if (generic_regnum != LLDB_REGNUM_GENERIC_FLAGS)
+ {
+ m_curr_row->SetRegisterLocationToSame(reg_num,
+ false /*must_replace*/);
+ m_curr_row_modified = true;
+ }
+ break;
+ default:
+ assert(false && "unhandled case, add code to handle this!");
+ break;
+ }
+ }
}
}
break;
case EmulateInstruction::eContextSetFramePointer:
- if (!m_fp_is_cfa)
+ if (!m_fp_is_cfa && !instruction->IsInstructionConditional())
{
m_fp_is_cfa = true;
m_cfa_reg_info = *reg_info;
@@ -599,7 +619,7 @@ UnwindAssemblyInstEmulation::WriteRegister (EmulateInstruction *instruction,
case EmulateInstruction::eContextAdjustStackPointer:
// If we have created a frame using the frame pointer, don't follow
// subsequent adjustments to the stack pointer.
- if (!m_fp_is_cfa)
+ if (!m_fp_is_cfa && !instruction->IsInstructionConditional())
{
m_curr_row->GetCFAValue().SetIsRegisterPlusOffset(
m_curr_row->GetCFAValue().GetRegisterNumber(),
diff --git a/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
index bf6d017370cc..61d3ece3f6c3 100644
--- a/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
+++ b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
@@ -1,4 +1,4 @@
-//===-- UnwindAssemblyInstEmulation.h ----------------------------*- C++ -*-===//
+//===-- UnwindAssemblyInstEmulation.h ---------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,6 +10,10 @@
#ifndef liblldb_UnwindAssemblyInstEmulation_h_
#define liblldb_UnwindAssemblyInstEmulation_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/EmulateInstruction.h"
#include "lldb/Core/RegisterValue.h"
@@ -19,32 +23,28 @@
class UnwindAssemblyInstEmulation : public lldb_private::UnwindAssembly
{
public:
+ ~UnwindAssemblyInstEmulation() override = default;
- virtual
- ~UnwindAssemblyInstEmulation ()
- {
- }
-
- virtual bool
- GetNonCallSiteUnwindPlanFromAssembly (lldb_private::AddressRange& func,
- lldb_private::Thread& thread,
- lldb_private::UnwindPlan& unwind_plan);
+ bool
+ GetNonCallSiteUnwindPlanFromAssembly(lldb_private::AddressRange& func,
+ lldb_private::Thread& thread,
+ lldb_private::UnwindPlan& unwind_plan) override;
- virtual bool
- AugmentUnwindPlanFromCallSite (lldb_private::AddressRange& func,
- lldb_private::Thread& thread,
- lldb_private::UnwindPlan& unwind_plan);
+ bool
+ AugmentUnwindPlanFromCallSite(lldb_private::AddressRange& func,
+ lldb_private::Thread& thread,
+ lldb_private::UnwindPlan& unwind_plan) override;
- virtual bool
- GetFastUnwindPlan (lldb_private::AddressRange& func,
- lldb_private::Thread& thread,
- lldb_private::UnwindPlan &unwind_plan);
+ bool
+ GetFastUnwindPlan(lldb_private::AddressRange& func,
+ lldb_private::Thread& thread,
+ lldb_private::UnwindPlan &unwind_plan) override;
// thread may be NULL in which case we only use the Target (e.g. if this is called pre-process-launch).
- virtual bool
- FirstNonPrologueInsn (lldb_private::AddressRange& func,
- const lldb_private::ExecutionContext &exe_ctx,
- lldb_private::Address& first_non_prologue_insn);
+ bool
+ FirstNonPrologueInsn(lldb_private::AddressRange& func,
+ const lldb_private::ExecutionContext &exe_ctx,
+ lldb_private::Address& first_non_prologue_insn) override;
static lldb_private::UnwindAssembly *
CreateInstance (const lldb_private::ArchSpec &arch);
@@ -64,14 +64,36 @@ public:
static const char *
GetPluginDescriptionStatic();
- virtual lldb_private::ConstString
- GetPluginName();
+ lldb_private::ConstString
+ GetPluginName() override;
- virtual uint32_t
- GetPluginVersion();
+ uint32_t
+ GetPluginVersion() override;
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_thread_ptr (NULL),
+ m_unwind_plan_ptr (NULL),
+ 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, WriteRegister);
+ }
+ }
+
static size_t
ReadMemory (lldb_private::EmulateInstruction *instruction,
void *baton,
@@ -101,7 +123,6 @@ private:
const lldb_private::RegisterInfo *reg_info,
const lldb_private::RegisterValue &reg_value);
-
// size_t
// ReadMemory (lldb_private::EmulateInstruction *instruction,
// const lldb_private::EmulateInstruction::Context &context,
@@ -127,29 +148,6 @@ private:
const lldb_private::RegisterInfo *reg_info,
const lldb_private::RegisterValue &reg_value);
- // 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_thread_ptr (NULL),
- m_unwind_plan_ptr (NULL),
- 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, WriteRegister);
- }
- }
-
static uint64_t
MakeRegisterKindValuePair (const lldb_private::RegisterInfo &reg_info);
diff --git a/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h b/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h
index 8a4fe7c09800..4d43a6e02b73 100644
--- a/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h
+++ b/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h
@@ -1,4 +1,4 @@
-//===-- UnwindAssembly-x86.h -------------------------------------*- C++ -*-===//
+//===-- UnwindAssembly-x86.h ------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,42 +10,44 @@
#ifndef liblldb_UnwindAssembly_x86_h_
#define liblldb_UnwindAssembly_x86_h_
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
#include "llvm-c/Disassembler.h"
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Target/UnwindAssembly.h"
class UnwindAssembly_x86 : public lldb_private::UnwindAssembly
{
public:
+ ~UnwindAssembly_x86() override;
- ~UnwindAssembly_x86 ();
+ bool
+ GetNonCallSiteUnwindPlanFromAssembly(lldb_private::AddressRange& func,
+ lldb_private::Thread& thread,
+ lldb_private::UnwindPlan& unwind_plan) override;
- virtual bool
- GetNonCallSiteUnwindPlanFromAssembly (lldb_private::AddressRange& func,
- lldb_private::Thread& thread,
- lldb_private::UnwindPlan& unwind_plan);
+ bool
+ AugmentUnwindPlanFromCallSite(lldb_private::AddressRange& func,
+ lldb_private::Thread& thread,
+ lldb_private::UnwindPlan& unwind_plan) override;
- virtual bool
- AugmentUnwindPlanFromCallSite (lldb_private::AddressRange& func,
- lldb_private::Thread& thread,
- lldb_private::UnwindPlan& unwind_plan);
-
- virtual bool
- GetFastUnwindPlan (lldb_private::AddressRange& func,
- lldb_private::Thread& thread,
- lldb_private::UnwindPlan &unwind_plan);
+ bool
+ GetFastUnwindPlan(lldb_private::AddressRange& func,
+ lldb_private::Thread& thread,
+ lldb_private::UnwindPlan &unwind_plan) override;
// thread may be NULL in which case we only use the Target (e.g. if this is called pre-process-launch).
- virtual bool
- FirstNonPrologueInsn (lldb_private::AddressRange& func,
- const lldb_private::ExecutionContext &exe_ctx,
- lldb_private::Address& first_non_prologue_insn);
+ bool
+ FirstNonPrologueInsn(lldb_private::AddressRange& func,
+ const lldb_private::ExecutionContext &exe_ctx,
+ lldb_private::Address& first_non_prologue_insn) override;
static lldb_private::UnwindAssembly *
CreateInstance (const lldb_private::ArchSpec &arch);
-
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
@@ -61,11 +63,11 @@ public:
static const char *
GetPluginDescriptionStatic();
- virtual lldb_private::ConstString
- GetPluginName();
+ lldb_private::ConstString
+ GetPluginName() override;
- virtual uint32_t
- GetPluginVersion();
+ uint32_t
+ GetPluginVersion() override;
private:
UnwindAssembly_x86 (const lldb_private::ArchSpec &arch, int cpu);
@@ -74,5 +76,4 @@ private:
lldb_private::ArchSpec m_arch;
};
-
#endif // liblldb_UnwindAssembly_x86_h_
diff --git a/source/Symbol/ArmUnwindInfo.cpp b/source/Symbol/ArmUnwindInfo.cpp
new file mode 100644
index 000000000000..0d3e974bebbe
--- /dev/null
+++ b/source/Symbol/ArmUnwindInfo.cpp
@@ -0,0 +1,445 @@
+//===-- ArmUnwindInfo.cpp ---------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <vector>
+
+#include "lldb/Core/Module.h"
+#include "lldb/Core/Section.h"
+#include "lldb/Host/Endian.h"
+#include "lldb/Symbol/ArmUnwindInfo.h"
+#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Symbol/UnwindPlan.h"
+#include "Utility/ARM_DWARF_Registers.h"
+
+/*
+ * Unwind information reader and parser for the ARM exception handling ABI
+ *
+ * Implemented based on:
+ * Exception Handling ABI for the ARM Architecture
+ * Document number: ARM IHI 0038A (current through ABI r2.09)
+ * Date of Issue: 25th January 2007, reissued 30th November 2012
+ * http://infocenter.arm.com/help/topic/com.arm.doc.ihi0038a/IHI0038A_ehabi.pdf
+ */
+
+using namespace lldb;
+using namespace lldb_private;
+
+// Converts a prel31 avlue to lldb::addr_t with sign extension
+static addr_t
+Prel31ToAddr(uint32_t prel31)
+{
+ addr_t res = prel31;
+ if (prel31 & (1<<30))
+ res |= 0xffffffff80000000ULL;
+ return res;
+}
+
+ArmUnwindInfo::ArmExidxEntry::ArmExidxEntry(uint32_t f, lldb::addr_t a, uint32_t d) :
+ file_address(f), address(a), data(d)
+{
+}
+
+bool
+ArmUnwindInfo::ArmExidxEntry::operator<(const ArmExidxEntry& other) const
+{
+ return address < other.address;
+}
+
+ArmUnwindInfo::ArmUnwindInfo(const ObjectFile& objfile,
+ SectionSP& arm_exidx,
+ SectionSP& arm_extab) :
+ m_byte_order(objfile.GetByteOrder()),
+ m_arm_exidx_sp(arm_exidx),
+ m_arm_extab_sp(arm_extab)
+{
+ objfile.ReadSectionData(arm_exidx.get(), m_arm_exidx_data);
+ objfile.ReadSectionData(arm_extab.get(), m_arm_extab_data);
+
+ addr_t exidx_base_addr = m_arm_exidx_sp->GetFileAddress();
+
+ offset_t offset = 0;
+ while (m_arm_exidx_data.ValidOffset(offset))
+ {
+ lldb::addr_t file_addr = exidx_base_addr + offset;
+ lldb::addr_t addr = exidx_base_addr +
+ (addr_t)offset +
+ Prel31ToAddr(m_arm_exidx_data.GetU32(&offset));
+ uint32_t data = m_arm_exidx_data.GetU32(&offset);
+ m_exidx_entries.emplace_back(file_addr, addr, data);
+ }
+
+ // Sort the entries in the exidx section. The entries should be sorted inside the section but
+ // some old compiler isn't sorted them.
+ std::sort(m_exidx_entries.begin(), m_exidx_entries.end());
+}
+
+ArmUnwindInfo::~ArmUnwindInfo()
+{
+}
+
+// Read a byte from the unwind instruction stream with the given offset.
+// Custom function is required because have to red in order of significance within their containing
+// word (most significant byte first) and in increasing word address order.
+uint8_t
+ArmUnwindInfo::GetByteAtOffset(const uint32_t* data, uint16_t offset) const
+{
+ uint32_t value = data[offset / 4];
+ if (m_byte_order != endian::InlHostByteOrder())
+ value = llvm::ByteSwap_32(value);
+ return (value >> ((3 - (offset % 4)) * 8)) & 0xff;
+}
+
+uint64_t
+ArmUnwindInfo::GetULEB128(const uint32_t* data, uint16_t& offset, uint16_t max_offset) const
+{
+ uint64_t result = 0;
+ uint8_t shift = 0;
+ while (offset < max_offset)
+ {
+ uint8_t byte = GetByteAtOffset(data, offset++);
+ result |= (byte & 0x7f) << shift;
+ if ((byte & 0x80) == 0)
+ break;
+ shift += 7;
+ }
+ return result;
+}
+
+bool
+ArmUnwindInfo::GetUnwindPlan(Target &target, const Address& addr, UnwindPlan& unwind_plan)
+{
+ const uint32_t* data = (const uint32_t*)GetExceptionHandlingTableEntry(addr);
+ if (data == nullptr)
+ return false; // No unwind information for the function
+
+ if (data[0] == 0x1)
+ return false; // EXIDX_CANTUNWIND
+
+ uint16_t byte_count = 0;
+ uint16_t byte_offset = 0;
+ if (data[0] & 0x80000000)
+ {
+ switch ((data[0] >> 24) & 0x0f)
+ {
+ case 0:
+ byte_count = 4;
+ byte_offset = 1;
+ break;
+ case 1:
+ case 2:
+ byte_count = 4 * ((data[0] >> 16) & 0xff) + 4;
+ byte_offset = 2;
+ break;
+ default:
+ // Unhandled personality routine index
+ return false;
+ }
+ }
+ else
+ {
+ byte_count = 4 * ((data[1] >> 24) & 0xff) + 8;
+ byte_offset = 5;
+ }
+
+ uint8_t vsp_reg = dwarf_sp;
+ int32_t vsp = 0;
+ std::vector<std::pair<uint32_t, int32_t>> register_offsets; // register -> (offset from vsp_reg)
+
+ while (byte_offset < byte_count)
+ {
+ uint8_t byte1 = GetByteAtOffset(data, byte_offset++);
+ if ((byte1&0xc0) == 0x00)
+ {
+ // 00xxxxxx
+ // vsp = vsp + (xxxxxx << 2) + 4. Covers range 0x04-0x100 inclusive
+ vsp += ((byte1 & 0x3f) << 2) + 4;
+ }
+ else if ((byte1&0xc0) == 0x40)
+ {
+ // 01xxxxxx
+ // vsp = vsp – (xxxxxx << 2) - 4. Covers range 0x04-0x100 inclusive
+ vsp -= ((byte1 & 0x3f) << 2) + 4;
+ }
+ else if ((byte1&0xf0) == 0x80)
+ {
+ if (byte_offset >= byte_count)
+ return false;
+
+ uint8_t byte2 = GetByteAtOffset(data, byte_offset++);
+ if (byte1 == 0x80 && byte2 == 0)
+ {
+ // 10000000 00000000
+ // Refuse to unwind (for example, out of a cleanup) (see remark a)
+ return false;
+ }
+ else
+ {
+ // 1000iiii iiiiiiii (i not all 0)
+ // Pop up to 12 integer registers under masks {r15-r12}, {r11-r4} (see remark b)
+ uint16_t regs = ((byte1&0x0f) << 8) | byte2;
+ for (uint8_t i = 0; i < 12; ++i)
+ {
+ if (regs & (1<<i))
+ {
+ register_offsets.emplace_back(dwarf_r4 + i, vsp);
+ vsp += 4;
+ }
+ }
+ }
+ }
+ else if ((byte1&0xff) == 0x9d)
+ {
+ // 10011101
+ // Reserved as prefix for ARM register to register moves
+ return false;
+ }
+ else if ((byte1&0xff) == 0x9f)
+ {
+ // 10011111
+ // Reserved as prefix for Intel Wireless MMX register to register moves
+ return false;
+ }
+ else if ((byte1&0xf0) == 0x90)
+ {
+ // 1001nnnn (nnnn != 13,15)
+ // Set vsp = r[nnnn]
+ vsp_reg = dwarf_r0 + (byte1&0x0f);
+ }
+ else if ((byte1&0xf8) == 0xa0)
+ {
+ // 10100nnn
+ // Pop r4-r[4+nnn]
+ uint8_t n = byte1&0x7;
+ for (uint8_t i = 0; i <= n; ++i)
+ {
+ register_offsets.emplace_back(dwarf_r4 + i, vsp);
+ vsp += 4;
+ }
+ }
+ else if ((byte1&0xf8) == 0xa8)
+ {
+ // 10101nnn
+ // Pop r4-r[4+nnn], r14
+ uint8_t n = byte1&0x7;
+ for (uint8_t i = 0; i <= n; ++i)
+ {
+ register_offsets.emplace_back(dwarf_r4 + i, vsp);
+ vsp += 4;
+ }
+
+ register_offsets.emplace_back(dwarf_lr, vsp);
+ vsp += 4;
+ }
+ else if ((byte1&0xff) == 0xb0)
+ {
+ // 10110000
+ // Finish (see remark c)
+ break;
+ }
+ else if ((byte1&0xff) == 0xb1)
+ {
+ if (byte_offset >= byte_count)
+ return false;
+
+ uint8_t byte2 = GetByteAtOffset(data, byte_offset++);
+ if ((byte2&0xff) == 0x00)
+ {
+ // 10110001 00000000
+ // Spare (see remark f)
+ return false;
+ }
+ else if ((byte2&0xf0) == 0x00)
+ {
+ // 10110001 0000iiii (i not all 0)
+ // Pop integer registers under mask {r3, r2, r1, r0}
+ for (uint8_t i = 0; i < 4; ++i)
+ {
+ if (byte2 & (1<<i))
+ {
+ register_offsets.emplace_back(dwarf_r0 + i, vsp);
+ vsp += 4;
+ }
+ }
+ }
+ else
+ {
+ // 10110001 xxxxyyyy
+ // Spare (xxxx != 0000)
+ return false;
+ }
+ }
+ else if ((byte1&0xff) == 0xb2)
+ {
+ // 10110010 uleb128
+ // vsp = vsp + 0x204+ (uleb128 << 2)
+ uint64_t uleb128 = GetULEB128(data, byte_offset, byte_count);
+ vsp += 0x204 + (uleb128 << 2);
+ }
+ else if ((byte1&0xff) == 0xb3)
+ {
+ // 10110011 sssscccc
+ // Pop VFP double-precision registers D[ssss]-D[ssss+cccc] saved (as if) by FSTMFDX (see remark d)
+ if (byte_offset >= byte_count)
+ return false;
+
+ uint8_t byte2 = GetByteAtOffset(data, byte_offset++);
+ uint8_t s = (byte2&0xf0) >> 4;
+ uint8_t c = (byte2&0x0f) >> 0;
+ for (uint8_t i = 0; i <= c; ++i)
+ {
+ register_offsets.emplace_back(dwarf_d0 + s + i, vsp);
+ vsp += 8;
+ }
+ vsp += 4;
+ }
+ else if ((byte1&0xfc) == 0xb4)
+ {
+ // 101101nn
+ // Spare (was Pop FPA)
+ return false;
+ }
+ else if ((byte1&0xf8) == 0xb8)
+ {
+ // 10111nnn
+ // Pop VFP double-precision registers D[8]-D[8+nnn] saved (as if) by FSTMFDX (see remark d)
+ uint8_t n = byte1&0x07;
+ for (uint8_t i = 0; i <= n; ++i)
+ {
+ register_offsets.emplace_back(dwarf_d8 + i, vsp);
+ vsp += 8;
+ }
+ vsp += 4;
+ }
+ else if ((byte1&0xf8) == 0xc0)
+ {
+ // 11000nnn (nnn != 6,7)
+ // Intel Wireless MMX pop wR[10]-wR[10+nnn]
+
+ // 11000110 sssscccc
+ // Intel Wireless MMX pop wR[ssss]-wR[ssss+cccc] (see remark e)
+
+ // 11000111 00000000
+ // Spare
+
+ // 11000111 0000iiii
+ // Intel Wireless MMX pop wCGR registers under mask {wCGR3,2,1,0}
+
+ // 11000111 xxxxyyyy
+ // Spare (xxxx != 0000)
+
+ return false;
+ }
+ else if ((byte1&0xff) == 0xc8)
+ {
+ // 11001000 sssscccc
+ // Pop VFP double precision registers D[16+ssss]-D[16+ssss+cccc] saved (as if) by FSTMFDD (see remarks d,e)
+ if (byte_offset >= byte_count)
+ return false;
+
+ uint8_t byte2 = GetByteAtOffset(data, byte_offset++);
+ uint8_t s = (byte2&0xf0) >> 4;
+ uint8_t c = (byte2&0x0f) >> 0;
+ for (uint8_t i = 0; i <= c; ++i)
+ {
+ register_offsets.emplace_back(dwarf_d16 + s + i, vsp);
+ vsp += 8;
+ }
+ }
+ else if ((byte1&0xff) == 0xc9)
+ {
+ // 11001001 sssscccc
+ // Pop VFP double precision registers D[ssss]-D[ssss+cccc] saved (as if) by FSTMFDD (see remark d)
+ if (byte_offset >= byte_count)
+ return false;
+
+ uint8_t byte2 = GetByteAtOffset(data, byte_offset++);
+ uint8_t s = (byte2&0xf0) >> 4;
+ uint8_t c = (byte2&0x0f) >> 0;
+ for (uint8_t i = 0; i <= c; ++i)
+ {
+ register_offsets.emplace_back(dwarf_d0 + s + i, vsp);
+ vsp += 8;
+ }
+ }
+ else if ((byte1&0xf8) == 0xc8)
+ {
+ // 11001yyy
+ // Spare (yyy != 000, 001)
+ return false;
+ }
+ else if ((byte1&0xf8) == 0xc0)
+ {
+ // 11010nnn
+ // Pop VFP double-precision registers D[8]-D[8+nnn] saved (as if) by FSTMFDD (see remark d)
+ uint8_t n = byte1&0x07;
+ for (uint8_t i = 0; i <= n; ++i)
+ {
+ register_offsets.emplace_back(dwarf_d8 + i, vsp);
+ vsp += 8;
+ }
+ }
+ else if ((byte1&0xc0) == 0xc0)
+ {
+ // 11xxxyyy Spare (xxx != 000, 001, 010)
+ return false;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ UnwindPlan::RowSP row = std::make_shared<UnwindPlan::Row>();
+ row->SetOffset(0);
+ row->GetCFAValue().SetIsRegisterPlusOffset(vsp_reg, vsp);
+
+ bool have_location_for_pc = false;
+ for (const auto& offset : register_offsets)
+ {
+ have_location_for_pc |= offset.first == dwarf_pc;
+ row->SetRegisterLocationToAtCFAPlusOffset(offset.first, offset.second - vsp, true);
+ }
+
+ if (!have_location_for_pc)
+ {
+ UnwindPlan::Row::RegisterLocation lr_location;
+ if (row->GetRegisterInfo(dwarf_lr, lr_location))
+ row->SetRegisterInfo(dwarf_pc, lr_location);
+ else
+ row->SetRegisterLocationToRegister(dwarf_pc, dwarf_lr, false);
+ }
+
+ unwind_plan.AppendRow(row);
+ unwind_plan.SetSourceName ("ARM.exidx unwind info");
+ unwind_plan.SetSourcedFromCompiler (eLazyBoolYes);
+ unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolNo);
+ unwind_plan.SetRegisterKind (eRegisterKindDWARF);
+
+ return true;
+}
+
+const uint8_t*
+ArmUnwindInfo::GetExceptionHandlingTableEntry(const Address& addr)
+{
+ auto it = std::upper_bound(m_exidx_entries.begin(),
+ m_exidx_entries.end(),
+ ArmExidxEntry{0, addr.GetFileAddress(), 0});
+ if (it == m_exidx_entries.begin())
+ return nullptr;
+ --it;
+
+ if (it->data == 0x1)
+ return nullptr; // EXIDX_CANTUNWIND
+
+ if (it->data & 0x80000000)
+ return (const uint8_t*)&it->data;
+
+ addr_t data_file_addr = it->file_address + 4 + Prel31ToAddr(it->data);
+ return m_arm_extab_data.GetDataStart() + (data_file_addr - m_arm_extab_sp->GetFileAddress());
+}
diff --git a/source/Symbol/Block.cpp b/source/Symbol/Block.cpp
index 94fa166bb265..dfe9217362bd 100644
--- a/source/Symbol/Block.cpp
+++ b/source/Symbol/Block.cpp
@@ -546,27 +546,24 @@ Block::AppendVariables
return num_variables_added;
}
-clang::DeclContext *
-Block::GetClangDeclContext()
+CompilerDeclContext
+Block::GetDeclContext()
{
- SymbolContext sc;
-
- CalculateSymbolContext (&sc);
-
- if (!sc.module_sp)
- return nullptr;
-
- SymbolVendor *sym_vendor = sc.module_sp->GetSymbolVendor();
-
- if (!sym_vendor)
- return nullptr;
-
- SymbolFile *sym_file = sym_vendor->GetSymbolFile();
+ ModuleSP module_sp = CalculateSymbolContextModule ();
+
+ if (module_sp)
+ {
+ SymbolVendor *sym_vendor = module_sp->GetSymbolVendor();
- if (!sym_file)
- return nullptr;
+ if (sym_vendor)
+ {
+ SymbolFile *sym_file = sym_vendor->GetSymbolFile();
- return sym_file->GetClangDeclContextForTypeUID (sc, m_uid);
+ if (sym_file)
+ return sym_file->GetDeclContextForUID (GetID());
+ }
+ }
+ return CompilerDeclContext();
}
void
diff --git a/source/Symbol/ClangASTContext.cpp b/source/Symbol/ClangASTContext.cpp
index 68bcde8a47c1..8b11c239aabf 100644
--- a/source/Symbol/ClangASTContext.cpp
+++ b/source/Symbol/ClangASTContext.cpp
@@ -13,6 +13,7 @@
// C++ Includes
#include <mutex> // std::once
#include <string>
+#include <vector>
// Other libraries and framework includes
@@ -39,8 +40,10 @@
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclTemplate.h"
+#include "clang/AST/Mangle.h"
#include "clang/AST/RecordLayout.h"
#include "clang/AST/Type.h"
+#include "clang/AST/VTableBuilder.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/FileManager.h"
@@ -58,19 +61,33 @@
#include <assert.h>
#endif
+#include "llvm/Support/Signals.h"
+
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/dwarf.h"
#include "lldb/Core/Flags.h"
#include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegularExpression.h"
+#include "lldb/Core/StreamFile.h"
#include "lldb/Core/ThreadSafeDenseMap.h"
#include "lldb/Core/UniqueCStringMap.h"
-#include "lldb/Expression/ASTDumper.h"
+#include "Plugins/ExpressionParser/Clang/ClangUserExpression.h"
+#include "Plugins/ExpressionParser/Clang/ClangFunctionCaller.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtilityFunction.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/ClangExternalASTSourceCallbacks.h"
#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/VerifyDecl.h"
#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/Process.h"
+#include "lldb/Target/Language.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+
+#include "Plugins/SymbolFile/DWARF/DWARFASTParserClang.h"
#include <stdio.h>
@@ -81,6 +98,17 @@ using namespace lldb_private;
using namespace llvm;
using namespace clang;
+namespace
+{
+ static inline bool ClangASTContextSupportsLanguage (lldb::LanguageType language)
+ {
+ return language == eLanguageTypeUnknown || // Clang is the default type system
+ Language::LanguageIsC (language) ||
+ Language::LanguageIsCPlusPlus (language) ||
+ Language::LanguageIsObjC (language);
+ }
+}
+
typedef lldb_private::ThreadSafeDenseMap<clang::ASTContext *, ClangASTContext*> ClangASTMap;
static ClangASTMap &
@@ -277,22 +305,23 @@ ParseLangArgs (LangOptions &Opts, InputKind IK, const char* triple)
}
-ClangASTContext::ClangASTContext (const char *target_triple) :
- 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(),
+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),
m_callback_objc_decl (nullptr),
m_callback_baton (nullptr),
- m_pointer_byte_size (0)
-
+ m_pointer_byte_size (0),
+ m_ast_owned (false)
{
if (target_triple && target_triple[0])
SetTargetTriple (target_triple);
@@ -306,6 +335,8 @@ ClangASTContext::~ClangASTContext()
if (m_ast_ap.get())
{
GetASTMap().Erase(m_ast_ap.get());
+ if (!m_ast_owned)
+ m_ast_ap.release();
}
m_builtins_ap.reset();
@@ -319,6 +350,127 @@ ClangASTContext::~ClangASTContext()
m_ast_ap.reset();
}
+ConstString
+ClangASTContext::GetPluginNameStatic()
+{
+ return ConstString("clang");
+}
+
+ConstString
+ClangASTContext::GetPluginName()
+{
+ return ClangASTContext::GetPluginNameStatic();
+}
+
+uint32_t
+ClangASTContext::GetPluginVersion()
+{
+ return 1;
+}
+
+lldb::TypeSystemSP
+ClangASTContext::CreateInstance (lldb::LanguageType language,
+ lldb_private::Module *module,
+ Target *target)
+{
+ if (ClangASTContextSupportsLanguage(language))
+ {
+ ArchSpec arch;
+ if (module)
+ arch = module->GetArchitecture();
+ else if (target)
+ arch = target->GetArchitecture();
+
+ if (arch.IsValid())
+ {
+ ArchSpec fixed_arch = arch;
+ // LLVM wants this to be set to iOS or MacOSX; if we're working on
+ // a bare-boards type image, change the triple for llvm's benefit.
+ if (fixed_arch.GetTriple().getVendor() == llvm::Triple::Apple &&
+ fixed_arch.GetTriple().getOS() == llvm::Triple::UnknownOS)
+ {
+ if (fixed_arch.GetTriple().getArch() == llvm::Triple::arm ||
+ fixed_arch.GetTriple().getArch() == llvm::Triple::aarch64 ||
+ fixed_arch.GetTriple().getArch() == llvm::Triple::thumb)
+ {
+ fixed_arch.GetTriple().setOS(llvm::Triple::IOS);
+ }
+ else
+ {
+ fixed_arch.GetTriple().setOS(llvm::Triple::MacOSX);
+ }
+ }
+
+ if (module)
+ {
+ std::shared_ptr<ClangASTContext> ast_sp(new ClangASTContext);
+ if (ast_sp)
+ {
+ ast_sp->SetArchitecture (fixed_arch);
+ }
+ return ast_sp;
+ }
+ else if (target && target->IsValid())
+ {
+ std::shared_ptr<ClangASTContextForExpressions> ast_sp(new ClangASTContextForExpressions(*target));
+ if (ast_sp)
+ {
+ ast_sp->SetArchitecture(fixed_arch);
+ ast_sp->m_scratch_ast_source_ap.reset (new ClangASTSource(target->shared_from_this()));
+ ast_sp->m_scratch_ast_source_ap->InstallASTContext(ast_sp->getASTContext());
+ llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source(ast_sp->m_scratch_ast_source_ap->CreateProxy());
+ ast_sp->SetExternalSource(proxy_ast_source);
+ return ast_sp;
+ }
+ }
+ }
+ }
+ return lldb::TypeSystemSP();
+}
+
+void
+ClangASTContext::EnumerateSupportedLanguages(std::set<lldb::LanguageType> &languages_for_types, std::set<lldb::LanguageType> &languages_for_expressions)
+{
+ static std::vector<lldb::LanguageType> s_supported_languages_for_types({
+ lldb::eLanguageTypeC89,
+ lldb::eLanguageTypeC,
+ lldb::eLanguageTypeC11,
+ lldb::eLanguageTypeC_plus_plus,
+ lldb::eLanguageTypeC99,
+ lldb::eLanguageTypeObjC,
+ lldb::eLanguageTypeObjC_plus_plus,
+ lldb::eLanguageTypeC_plus_plus_03,
+ lldb::eLanguageTypeC_plus_plus_11,
+ lldb::eLanguageTypeC11,
+ lldb::eLanguageTypeC_plus_plus_14});
+
+ static std::vector<lldb::LanguageType> s_supported_languages_for_expressions({
+ lldb::eLanguageTypeC_plus_plus,
+ lldb::eLanguageTypeObjC_plus_plus,
+ lldb::eLanguageTypeC_plus_plus_03,
+ lldb::eLanguageTypeC_plus_plus_11,
+ lldb::eLanguageTypeC_plus_plus_14});
+
+ languages_for_types.insert(s_supported_languages_for_types.begin(), s_supported_languages_for_types.end());
+ languages_for_expressions.insert(s_supported_languages_for_expressions.begin(), s_supported_languages_for_expressions.end());
+}
+
+
+void
+ClangASTContext::Initialize()
+{
+ PluginManager::RegisterPlugin (GetPluginNameStatic(),
+ "clang base AST context plug-in",
+ CreateInstance,
+ EnumerateSupportedLanguages);
+}
+
+void
+ClangASTContext::Terminate()
+{
+ PluginManager::UnregisterPlugin (CreateInstance);
+}
+
void
ClangASTContext::Clear()
@@ -389,13 +541,23 @@ ClangASTContext::RemoveExternalSource ()
}
}
-
+void
+ClangASTContext::setASTContext(clang::ASTContext *ast_ctx)
+{
+ if (!m_ast_owned) {
+ m_ast_ap.release();
+ }
+ m_ast_owned = false;
+ m_ast_ap.reset(ast_ctx);
+ GetASTMap().Insert(ast_ctx, this);
+}
ASTContext *
ClangASTContext::getASTContext()
{
if (m_ast_ap.get() == nullptr)
{
+ m_ast_owned = true;
m_ast_ap.reset(new ASTContext (*getLanguageOptions(),
*getSourceManager(),
*getIdentifierTable(),
@@ -417,6 +579,13 @@ ClangASTContext::getASTContext()
}
GetASTMap().Insert(m_ast_ap.get(), this);
+
+ llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> ast_source_ap (new ClangExternalASTSourceCallbacks (ClangASTContext::CompleteTagDecl,
+ ClangASTContext::CompleteObjCInterfaceDecl,
+ nullptr,
+ ClangASTContext::LayoutRecordType,
+ this));
+ SetExternalSource (ast_source_ap);
}
return m_ast_ap.get();
}
@@ -494,6 +663,14 @@ ClangASTContext::getDiagnosticsEngine()
return m_diagnostics_engine_ap.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();
+}
+
class NullDiagnosticConsumer : public DiagnosticConsumer
{
public:
@@ -561,72 +738,74 @@ QualTypeMatchesBitSize(const uint64_t bit_size, ASTContext *ast, QualType qual_t
return true;
return false;
}
-ClangASTType
-ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (Encoding encoding, uint32_t bit_size)
+
+CompilerType
+ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (Encoding encoding, size_t bit_size)
{
return ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (getASTContext(), encoding, bit_size);
}
-ClangASTType
+CompilerType
ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (ASTContext *ast, Encoding encoding, uint32_t bit_size)
{
if (!ast)
- return ClangASTType();
-
+ return CompilerType();
switch (encoding)
{
case eEncodingInvalid:
if (QualTypeMatchesBitSize (bit_size, ast, ast->VoidPtrTy))
- return ClangASTType (ast, ast->VoidPtrTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->VoidPtrTy);
break;
case eEncodingUint:
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedCharTy))
- return ClangASTType (ast, ast->UnsignedCharTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedCharTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedShortTy))
- return ClangASTType (ast, ast->UnsignedShortTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedShortTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedIntTy))
- return ClangASTType (ast, ast->UnsignedIntTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedIntTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedLongTy))
- return ClangASTType (ast, ast->UnsignedLongTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedLongTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedLongLongTy))
- return ClangASTType (ast, ast->UnsignedLongLongTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedLongLongTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedInt128Ty))
- return ClangASTType (ast, ast->UnsignedInt128Ty.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedInt128Ty);
break;
case eEncodingSint:
if (QualTypeMatchesBitSize (bit_size, ast, ast->CharTy))
- return ClangASTType (ast, ast->CharTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->CharTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->ShortTy))
- return ClangASTType (ast, ast->ShortTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->ShortTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->IntTy))
- return ClangASTType (ast, ast->IntTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->IntTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->LongTy))
- return ClangASTType (ast, ast->LongTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->LongTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->LongLongTy))
- return ClangASTType (ast, ast->LongLongTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->LongLongTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->Int128Ty))
- return ClangASTType (ast, ast->Int128Ty.getAsOpaquePtr());
+ return CompilerType (ast, ast->Int128Ty);
break;
case eEncodingIEEE754:
if (QualTypeMatchesBitSize (bit_size, ast, ast->FloatTy))
- return ClangASTType (ast, ast->FloatTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->FloatTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->DoubleTy))
- return ClangASTType (ast, ast->DoubleTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->DoubleTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->LongDoubleTy))
- return ClangASTType (ast, ast->LongDoubleTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->LongDoubleTy);
+ if (QualTypeMatchesBitSize (bit_size, ast, ast->HalfTy))
+ return CompilerType (ast, ast->HalfTy);
break;
case eEncodingVector:
// Sanity check that bit_size is a multiple of 8's.
if (bit_size && !(bit_size & 0x7u))
- return ClangASTType (ast, ast->getExtVectorType (ast->UnsignedCharTy, bit_size/8).getAsOpaquePtr());
+ return CompilerType (ast, ast->getExtVectorType (ast->UnsignedCharTy, bit_size/8));
break;
}
- return ClangASTType();
+ return CompilerType();
}
@@ -694,7 +873,7 @@ ClangASTContext::GetBasicTypeEnumeration (const ConstString &name)
return eBasicTypeInvalid;
}
-ClangASTType
+CompilerType
ClangASTContext::GetBasicType (ASTContext *ast, const ConstString &name)
{
if (ast)
@@ -702,7 +881,7 @@ ClangASTContext::GetBasicType (ASTContext *ast, const ConstString &name)
lldb::BasicType basic_type = ClangASTContext::GetBasicTypeEnumeration (name);
return ClangASTContext::GetBasicType (ast, basic_type);
}
- return ClangASTType();
+ return CompilerType();
}
uint32_t
@@ -713,18 +892,18 @@ ClangASTContext::GetPointerByteSize ()
return m_pointer_byte_size;
}
-ClangASTType
+CompilerType
ClangASTContext::GetBasicType (lldb::BasicType basic_type)
{
return GetBasicType (getASTContext(), basic_type);
}
-ClangASTType
+CompilerType
ClangASTContext::GetBasicType (ASTContext *ast, lldb::BasicType basic_type)
{
if (ast)
{
- clang_type_t clang_type = nullptr;
+ lldb::opaque_compiler_type_t clang_type = nullptr;
switch (basic_type)
{
@@ -827,13 +1006,13 @@ ClangASTContext::GetBasicType (ASTContext *ast, lldb::BasicType basic_type)
}
if (clang_type)
- return ClangASTType (ast, clang_type);
+ return CompilerType (GetASTContext(ast), clang_type);
}
- return ClangASTType();
+ return CompilerType();
}
-ClangASTType
+CompilerType
ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name, uint32_t dw_ate, uint32_t bit_size)
{
ASTContext *ast = getASTContext();
@@ -849,18 +1028,18 @@ ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name
case DW_ATE_address:
if (QualTypeMatchesBitSize (bit_size, ast, ast->VoidPtrTy))
- return ClangASTType (ast, ast->VoidPtrTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->VoidPtrTy);
break;
case DW_ATE_boolean:
if (QualTypeMatchesBitSize (bit_size, ast, ast->BoolTy))
- return ClangASTType (ast, ast->BoolTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->BoolTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedCharTy))
- return ClangASTType (ast, ast->UnsignedCharTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedCharTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedShortTy))
- return ClangASTType (ast, ast->UnsignedShortTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedShortTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedIntTy))
- return ClangASTType (ast, ast->UnsignedIntTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedIntTy);
break;
case DW_ATE_lo_user:
@@ -869,40 +1048,42 @@ ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name
{
if (::strstr(type_name, "complex"))
{
- ClangASTType complex_int_clang_type = GetBuiltinTypeForDWARFEncodingAndBitSize ("int", DW_ATE_signed, bit_size/2);
- return ClangASTType (ast, ast->getComplexType (complex_int_clang_type.GetQualType()).getAsOpaquePtr());
+ CompilerType complex_int_clang_type = GetBuiltinTypeForDWARFEncodingAndBitSize ("int", DW_ATE_signed, bit_size/2);
+ return CompilerType (ast, ast->getComplexType (GetQualType(complex_int_clang_type)));
}
}
break;
case DW_ATE_complex_float:
if (QualTypeMatchesBitSize (bit_size, ast, ast->FloatComplexTy))
- return ClangASTType (ast, ast->FloatComplexTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->FloatComplexTy);
else if (QualTypeMatchesBitSize (bit_size, ast, ast->DoubleComplexTy))
- return ClangASTType (ast, ast->DoubleComplexTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->DoubleComplexTy);
else if (QualTypeMatchesBitSize (bit_size, ast, ast->LongDoubleComplexTy))
- return ClangASTType (ast, ast->LongDoubleComplexTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->LongDoubleComplexTy);
else
{
- ClangASTType complex_float_clang_type = GetBuiltinTypeForDWARFEncodingAndBitSize ("float", DW_ATE_float, bit_size/2);
- return ClangASTType (ast, ast->getComplexType (complex_float_clang_type.GetQualType()).getAsOpaquePtr());
+ CompilerType complex_float_clang_type = GetBuiltinTypeForDWARFEncodingAndBitSize ("float", DW_ATE_float, bit_size/2);
+ return CompilerType (ast, ast->getComplexType (GetQualType(complex_float_clang_type)));
}
break;
case DW_ATE_float:
if (streq(type_name, "float") && QualTypeMatchesBitSize (bit_size, ast, ast->FloatTy))
- return ClangASTType (ast, ast->FloatTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->FloatTy);
if (streq(type_name, "double") && QualTypeMatchesBitSize (bit_size, ast, ast->DoubleTy))
- return ClangASTType (ast, ast->DoubleTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->DoubleTy);
if (streq(type_name, "long double") && QualTypeMatchesBitSize (bit_size, ast, ast->LongDoubleTy))
- return ClangASTType (ast, ast->LongDoubleTy.getAsOpaquePtr());
- // Fall back to not requring a name match
+ return CompilerType (ast, ast->LongDoubleTy);
+ // Fall back to not requiring a name match
if (QualTypeMatchesBitSize (bit_size, ast, ast->FloatTy))
- return ClangASTType (ast, ast->FloatTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->FloatTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->DoubleTy))
- return ClangASTType (ast, ast->DoubleTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->DoubleTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->LongDoubleTy))
- return ClangASTType (ast, ast->LongDoubleTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->LongDoubleTy);
+ if (QualTypeMatchesBitSize (bit_size, ast, ast->HalfTy))
+ return CompilerType (ast, ast->HalfTy);
break;
case DW_ATE_signed:
@@ -911,57 +1092,57 @@ ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name
if (streq(type_name, "wchar_t") &&
QualTypeMatchesBitSize (bit_size, ast, ast->WCharTy) &&
(getTargetInfo() && TargetInfo::isTypeSigned (getTargetInfo()->getWCharType())))
- return ClangASTType (ast, ast->WCharTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->WCharTy);
if (streq(type_name, "void") &&
QualTypeMatchesBitSize (bit_size, ast, ast->VoidTy))
- return ClangASTType (ast, ast->VoidTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->VoidTy);
if (strstr(type_name, "long long") &&
QualTypeMatchesBitSize (bit_size, ast, ast->LongLongTy))
- return ClangASTType (ast, ast->LongLongTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->LongLongTy);
if (strstr(type_name, "long") &&
QualTypeMatchesBitSize (bit_size, ast, ast->LongTy))
- return ClangASTType (ast, ast->LongTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->LongTy);
if (strstr(type_name, "short") &&
QualTypeMatchesBitSize (bit_size, ast, ast->ShortTy))
- return ClangASTType (ast, ast->ShortTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->ShortTy);
if (strstr(type_name, "char"))
{
if (QualTypeMatchesBitSize (bit_size, ast, ast->CharTy))
- return ClangASTType (ast, ast->CharTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->CharTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->SignedCharTy))
- return ClangASTType (ast, ast->SignedCharTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->SignedCharTy);
}
if (strstr(type_name, "int"))
{
if (QualTypeMatchesBitSize (bit_size, ast, ast->IntTy))
- return ClangASTType (ast, ast->IntTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->IntTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->Int128Ty))
- return ClangASTType (ast, ast->Int128Ty.getAsOpaquePtr());
+ return CompilerType (ast, ast->Int128Ty);
}
}
// We weren't able to match up a type name, just search by size
if (QualTypeMatchesBitSize (bit_size, ast, ast->CharTy))
- return ClangASTType (ast, ast->CharTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->CharTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->ShortTy))
- return ClangASTType (ast, ast->ShortTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->ShortTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->IntTy))
- return ClangASTType (ast, ast->IntTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->IntTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->LongTy))
- return ClangASTType (ast, ast->LongTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->LongTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->LongLongTy))
- return ClangASTType (ast, ast->LongLongTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->LongLongTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->Int128Ty))
- return ClangASTType (ast, ast->Int128Ty.getAsOpaquePtr());
+ return CompilerType (ast, ast->Int128Ty);
break;
case DW_ATE_signed_char:
if (ast->getLangOpts().CharIsSigned && type_name && streq(type_name, "char"))
{
if (QualTypeMatchesBitSize (bit_size, ast, ast->CharTy))
- return ClangASTType (ast, ast->CharTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->CharTy);
}
if (QualTypeMatchesBitSize (bit_size, ast, ast->SignedCharTy))
- return ClangASTType (ast, ast->SignedCharTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->SignedCharTy);
break;
case DW_ATE_unsigned:
@@ -972,62 +1153,62 @@ ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name
if (QualTypeMatchesBitSize (bit_size, ast, ast->WCharTy))
{
if (!(getTargetInfo() && TargetInfo::isTypeSigned (getTargetInfo()->getWCharType())))
- return ClangASTType (ast, ast->WCharTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->WCharTy);
}
}
if (strstr(type_name, "long long"))
{
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedLongLongTy))
- return ClangASTType (ast, ast->UnsignedLongLongTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedLongLongTy);
}
else if (strstr(type_name, "long"))
{
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedLongTy))
- return ClangASTType (ast, ast->UnsignedLongTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedLongTy);
}
else if (strstr(type_name, "short"))
{
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedShortTy))
- return ClangASTType (ast, ast->UnsignedShortTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedShortTy);
}
else if (strstr(type_name, "char"))
{
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedCharTy))
- return ClangASTType (ast, ast->UnsignedCharTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedCharTy);
}
else if (strstr(type_name, "int"))
{
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedIntTy))
- return ClangASTType (ast, ast->UnsignedIntTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedIntTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedInt128Ty))
- return ClangASTType (ast, ast->UnsignedInt128Ty.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedInt128Ty);
}
}
// We weren't able to match up a type name, just search by size
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedCharTy))
- return ClangASTType (ast, ast->UnsignedCharTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedCharTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedShortTy))
- return ClangASTType (ast, ast->UnsignedShortTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedShortTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedIntTy))
- return ClangASTType (ast, ast->UnsignedIntTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedIntTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedLongTy))
- return ClangASTType (ast, ast->UnsignedLongTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedLongTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedLongLongTy))
- return ClangASTType (ast, ast->UnsignedLongLongTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedLongLongTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedInt128Ty))
- return ClangASTType (ast, ast->UnsignedInt128Ty.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedInt128Ty);
break;
case DW_ATE_unsigned_char:
if (!ast->getLangOpts().CharIsSigned && type_name && streq(type_name, "char"))
{
if (QualTypeMatchesBitSize (bit_size, ast, ast->CharTy))
- return ClangASTType (ast, ast->CharTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->CharTy);
}
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedCharTy))
- return ClangASTType (ast, ast->UnsignedCharTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedCharTy);
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedShortTy))
- return ClangASTType (ast, ast->UnsignedShortTy.getAsOpaquePtr());
+ return CompilerType (ast, ast->UnsignedShortTy);
break;
case DW_ATE_imaginary_float:
@@ -1038,11 +1219,11 @@ ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name
{
if (streq(type_name, "char16_t"))
{
- return ClangASTType (ast, ast->Char16Ty.getAsOpaquePtr());
+ return CompilerType (ast, ast->Char16Ty);
}
else if (streq(type_name, "char32_t"))
{
- return ClangASTType (ast, ast->Char32Ty.getAsOpaquePtr());
+ return CompilerType (ast, ast->Char32Ty);
}
}
break;
@@ -1058,18 +1239,18 @@ ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name
{
Host::SystemLog (Host::eSystemLogError, "error: need to add support for DW_TAG_base_type encoded with DW_ATE = 0x%x, bit_size = %u\n", dw_ate, bit_size);
}
- return ClangASTType ();
+ return CompilerType ();
}
-ClangASTType
+CompilerType
ClangASTContext::GetUnknownAnyType(clang::ASTContext *ast)
{
if (ast)
- return ClangASTType (ast, ast->UnknownAnyTy.getAsOpaquePtr());
- return ClangASTType();
+ return CompilerType (ast, ast->UnknownAnyTy);
+ return CompilerType();
}
-ClangASTType
+CompilerType
ClangASTContext::GetCStringType (bool is_const)
{
ASTContext *ast = getASTContext();
@@ -1078,7 +1259,7 @@ ClangASTContext::GetCStringType (bool is_const)
if (is_const)
char_type.addConst();
- return ClangASTType (ast, ast->getPointerType(char_type).getAsOpaquePtr());
+ return CompilerType (ast, ast->getPointerType(char_type));
}
clang::DeclContext *
@@ -1087,23 +1268,6 @@ ClangASTContext::GetTranslationUnitDecl (clang::ASTContext *ast)
return ast->getTranslationUnitDecl();
}
-ClangASTType
-ClangASTContext::CopyType (ASTContext *dst_ast,
- ClangASTType src)
-{
- FileSystemOptions file_system_options;
- ASTContext *src_ast = src.GetASTContext();
- FileManager file_manager (file_system_options);
- ASTImporter importer(*dst_ast, file_manager,
- *src_ast, file_manager,
- false);
-
- QualType dst (importer.Import(src.GetQualType()));
-
- return ClangASTType (dst_ast, dst.getAsOpaquePtr());
-}
-
-
clang::Decl *
ClangASTContext::CopyDecl (ASTContext *dst_ast,
ASTContext *src_ast,
@@ -1119,19 +1283,19 @@ ClangASTContext::CopyDecl (ASTContext *dst_ast,
}
bool
-ClangASTContext::AreTypesSame (ClangASTType type1,
- ClangASTType type2,
+ClangASTContext::AreTypesSame (CompilerType type1,
+ CompilerType type2,
bool ignore_qualifiers)
{
- ASTContext *ast = type1.GetASTContext();
- if (ast != type2.GetASTContext())
+ ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(type1.GetTypeSystem());
+ if (!ast || ast != type2.GetTypeSystem())
return false;
if (type1.GetOpaqueQualType() == type2.GetOpaqueQualType())
return true;
- QualType type1_qual = type1.GetQualType();
- QualType type2_qual = type2.GetQualType();
+ QualType type1_qual = GetQualType(type1);
+ QualType type2_qual = GetQualType(type2);
if (ignore_qualifiers)
{
@@ -1139,21 +1303,21 @@ ClangASTContext::AreTypesSame (ClangASTType type1,
type2_qual = type2_qual.getUnqualifiedType();
}
- return ast->hasSameType (type1_qual, type2_qual);
+ return ast->getASTContext()->hasSameType (type1_qual, type2_qual);
}
-ClangASTType
+CompilerType
ClangASTContext::GetTypeForDecl (clang::NamedDecl *decl)
{
if (clang::ObjCInterfaceDecl *interface_decl = llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl))
return GetTypeForDecl(interface_decl);
if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl))
return GetTypeForDecl(tag_decl);
- return ClangASTType();
+ return CompilerType();
}
-ClangASTType
+CompilerType
ClangASTContext::GetTypeForDecl (TagDecl *decl)
{
// No need to call the getASTContext() accessor (which can create the AST
@@ -1161,11 +1325,11 @@ ClangASTContext::GetTypeForDecl (TagDecl *decl)
// AST if our AST didn't already exist...
ASTContext *ast = &decl->getASTContext();
if (ast)
- return ClangASTType (ast, ast->getTagDeclType(decl).getAsOpaquePtr());
- return ClangASTType();
+ return CompilerType (ast, ast->getTagDeclType(decl));
+ return CompilerType();
}
-ClangASTType
+CompilerType
ClangASTContext::GetTypeForDecl (ObjCInterfaceDecl *decl)
{
// No need to call the getASTContext() accessor (which can create the AST
@@ -1173,13 +1337,13 @@ ClangASTContext::GetTypeForDecl (ObjCInterfaceDecl *decl)
// AST if our AST didn't already exist...
ASTContext *ast = &decl->getASTContext();
if (ast)
- return ClangASTType (ast, ast->getObjCInterfaceType(decl).getAsOpaquePtr());
- return ClangASTType();
+ return CompilerType (ast, ast->getObjCInterfaceType(decl));
+ return CompilerType();
}
#pragma mark Structure, Unions, Classes
-ClangASTType
+CompilerType
ClangASTContext::CreateRecordType (DeclContext *decl_ctx,
AccessType access_type,
const char *name,
@@ -1230,9 +1394,9 @@ ClangASTContext::CreateRecordType (DeclContext *decl_ctx,
if (decl_ctx)
decl_ctx->addDecl (decl);
- return ClangASTType(ast, ast->getTagDeclType(decl).getAsOpaquePtr());
+ return CompilerType(ast, ast->getTagDeclType(decl));
}
- return ClangASTType();
+ return CompilerType();
}
static TemplateParameterList *
@@ -1282,8 +1446,7 @@ CreateTemplateParameterList (ASTContext *ast,
TemplateParameterList *template_param_list = TemplateParameterList::Create (*ast,
SourceLocation(),
SourceLocation(),
- &template_param_decls.front(),
- template_param_decls.size(),
+ template_param_decls,
SourceLocation());
return template_param_list;
}
@@ -1434,16 +1597,16 @@ ClangASTContext::CreateClassTemplateSpecializationDecl (DeclContext *decl_ctx,
return class_template_specialization_decl;
}
-ClangASTType
+CompilerType
ClangASTContext::CreateClassTemplateSpecializationType (ClassTemplateSpecializationDecl *class_template_specialization_decl)
{
if (class_template_specialization_decl)
{
ASTContext *ast = getASTContext();
if (ast)
- return ClangASTType(ast, ast->getTagDeclType(class_template_specialization_decl).getAsOpaquePtr());
+ return CompilerType(ast, ast->getTagDeclType(class_template_specialization_decl));
}
- return ClangASTType();
+ return CompilerType();
}
static inline bool
@@ -1571,7 +1734,7 @@ ClangASTContext::RecordHasFields (const RecordDecl *record_decl)
#pragma mark Objective C Classes
-ClangASTType
+CompilerType
ClangASTContext::CreateObjCClass
(
const char *name,
@@ -1600,7 +1763,7 @@ ClangASTContext::CreateObjCClass
if (decl && metadata)
SetMetadata(ast, decl, *metadata);
- return ClangASTType (ast, ast->getObjCInterfaceType(decl));
+ return CompilerType (ast, ast->getObjCInterfaceType(decl));
}
static inline bool
@@ -1714,24 +1877,6 @@ ClangASTContext::GetUniqueNamespaceDeclaration (const char *name, DeclContext *d
// BAD!!!
}
}
-
-
- if (namespace_decl)
- {
- // If we make it here, we are creating the anonymous namespace decl
- // for the first time, so we need to do the using directive magic
- // like SEMA does
- UsingDirectiveDecl* using_directive_decl = UsingDirectiveDecl::Create (*ast,
- decl_ctx,
- SourceLocation(),
- SourceLocation(),
- NestedNameSpecifierLoc(),
- SourceLocation(),
- namespace_decl,
- decl_ctx);
- using_directive_decl->setImplicit();
- decl_ctx->addDecl(using_directive_decl);
- }
}
#ifdef LLDB_CONFIGURATION_DEBUG
VerifyDecl(namespace_decl);
@@ -1740,12 +1885,104 @@ ClangASTContext::GetUniqueNamespaceDeclaration (const char *name, DeclContext *d
}
+clang::BlockDecl *
+ClangASTContext::CreateBlockDeclaration (clang::DeclContext *ctx)
+{
+ if (ctx != nullptr)
+ {
+ clang::BlockDecl *decl = clang::BlockDecl::Create(*getASTContext(), ctx, clang::SourceLocation());
+ ctx->addDecl(decl);
+ return decl;
+ }
+ return nullptr;
+}
+
+clang::DeclContext *
+FindLCABetweenDecls(clang::DeclContext *left, clang::DeclContext *right, clang::DeclContext *root)
+{
+ if (root == nullptr)
+ return nullptr;
+
+ std::set<clang::DeclContext *> path_left;
+ for (clang::DeclContext *d = left; d != nullptr; d = d->getParent())
+ path_left.insert(d);
+
+ for (clang::DeclContext *d = right; d != nullptr; d = d->getParent())
+ if (path_left.find(d) != path_left.end())
+ return d;
+
+ return nullptr;
+}
+
+clang::UsingDirectiveDecl *
+ClangASTContext::CreateUsingDirectiveDeclaration (clang::DeclContext *decl_ctx, clang::NamespaceDecl *ns_decl)
+{
+ if (decl_ctx != nullptr && ns_decl != nullptr)
+ {
+ clang::TranslationUnitDecl *translation_unit = (clang::TranslationUnitDecl *)GetTranslationUnitDecl(getASTContext());
+ clang::UsingDirectiveDecl *using_decl = clang::UsingDirectiveDecl::Create(*getASTContext(),
+ decl_ctx,
+ clang::SourceLocation(),
+ clang::SourceLocation(),
+ clang::NestedNameSpecifierLoc(),
+ clang::SourceLocation(),
+ ns_decl,
+ FindLCABetweenDecls(decl_ctx, ns_decl, translation_unit));
+ decl_ctx->addDecl(using_decl);
+ return using_decl;
+ }
+ return nullptr;
+}
+
+clang::UsingDecl *
+ClangASTContext::CreateUsingDeclaration (clang::DeclContext *current_decl_ctx, clang::NamedDecl *target)
+{
+ if (current_decl_ctx != nullptr && target != nullptr)
+ {
+ clang::UsingDecl *using_decl = clang::UsingDecl::Create(*getASTContext(),
+ current_decl_ctx,
+ clang::SourceLocation(),
+ clang::NestedNameSpecifierLoc(),
+ clang::DeclarationNameInfo(),
+ false);
+ clang::UsingShadowDecl *shadow_decl = clang::UsingShadowDecl::Create(*getASTContext(),
+ current_decl_ctx,
+ clang::SourceLocation(),
+ using_decl,
+ target);
+ using_decl->addShadowDecl(shadow_decl);
+ current_decl_ctx->addDecl(using_decl);
+ return using_decl;
+ }
+ return nullptr;
+}
+
+clang::VarDecl *
+ClangASTContext::CreateVariableDeclaration (clang::DeclContext *decl_context, const char *name, clang::QualType type)
+{
+ if (decl_context != nullptr)
+ {
+ clang::VarDecl *var_decl = clang::VarDecl::Create(*getASTContext(),
+ decl_context,
+ clang::SourceLocation(),
+ clang::SourceLocation(),
+ name && name[0] ? &getASTContext()->Idents.getOwn(name) : nullptr,
+ type,
+ nullptr,
+ clang::SC_None);
+ var_decl->setAccess(clang::AS_public);
+ decl_context->addDecl(var_decl);
+ return var_decl;
+ }
+ return nullptr;
+}
+
#pragma mark Function Types
FunctionDecl *
ClangASTContext::CreateFunctionDeclaration (DeclContext *decl_ctx,
const char *name,
- const ClangASTType &function_clang_type,
+ const CompilerType &function_clang_type,
int storage,
bool is_inline)
{
@@ -1765,7 +2002,7 @@ ClangASTContext::CreateFunctionDeclaration (DeclContext *decl_ctx,
SourceLocation(),
SourceLocation(),
DeclarationName (&ast->Idents.get(name)),
- function_clang_type.GetQualType(),
+ GetQualType(function_clang_type),
nullptr,
(clang::StorageClass)storage,
is_inline,
@@ -1779,7 +2016,7 @@ ClangASTContext::CreateFunctionDeclaration (DeclContext *decl_ctx,
SourceLocation(),
SourceLocation(),
DeclarationName (),
- function_clang_type.GetQualType(),
+ GetQualType(function_clang_type),
nullptr,
(clang::StorageClass)storage,
is_inline,
@@ -1796,10 +2033,10 @@ ClangASTContext::CreateFunctionDeclaration (DeclContext *decl_ctx,
return func_decl;
}
-ClangASTType
+CompilerType
ClangASTContext::CreateFunctionType (ASTContext *ast,
- const ClangASTType& result_type,
- const ClangASTType *args,
+ const CompilerType& result_type,
+ const CompilerType *args,
unsigned num_args,
bool is_variadic,
unsigned type_quals)
@@ -1807,7 +2044,7 @@ ClangASTContext::CreateFunctionType (ASTContext *ast,
assert (ast != nullptr);
std::vector<QualType> qual_type_args;
for (unsigned i=0; i<num_args; ++i)
- qual_type_args.push_back (args[i].GetQualType());
+ qual_type_args.push_back (GetQualType(args[i]));
// TODO: Detect calling convention in DWARF?
FunctionProtoType::ExtProtoInfo proto_info;
@@ -1816,13 +2053,13 @@ ClangASTContext::CreateFunctionType (ASTContext *ast,
proto_info.TypeQuals = type_quals;
proto_info.RefQualifier = RQ_None;
- return ClangASTType (ast, ast->getFunctionType (result_type.GetQualType(),
+ return CompilerType (ast, ast->getFunctionType (GetQualType(result_type),
qual_type_args,
- proto_info).getAsOpaquePtr());
+ proto_info));
}
ParmVarDecl *
-ClangASTContext::CreateParameterDeclaration (const char *name, const ClangASTType &param_type, int storage)
+ClangASTContext::CreateParameterDeclaration (const char *name, const CompilerType &param_type, int storage)
{
ASTContext *ast = getASTContext();
assert (ast != nullptr);
@@ -1831,7 +2068,7 @@ ClangASTContext::CreateParameterDeclaration (const char *name, const ClangASTTyp
SourceLocation(),
SourceLocation(),
name && name[0] ? &ast->Idents.get(name) : nullptr,
- param_type.GetQualType(),
+ GetQualType(param_type),
nullptr,
(clang::StorageClass)storage,
nullptr);
@@ -1847,8 +2084,8 @@ ClangASTContext::SetFunctionParameters (FunctionDecl *function_decl, ParmVarDecl
#pragma mark Array Types
-ClangASTType
-ClangASTContext::CreateArrayType (const ClangASTType &element_type,
+CompilerType
+ClangASTContext::CreateArrayType (const CompilerType &element_type,
size_t element_count,
bool is_vector)
{
@@ -1859,7 +2096,7 @@ ClangASTContext::CreateArrayType (const ClangASTType &element_type,
if (is_vector)
{
- return ClangASTType (ast, ast->getExtVectorType(element_type.GetQualType(), element_count).getAsOpaquePtr());
+ return CompilerType (ast, ast->getExtVectorType(GetQualType(element_type), element_count));
}
else
{
@@ -1867,59 +2104,59 @@ ClangASTContext::CreateArrayType (const ClangASTType &element_type,
llvm::APInt ap_element_count (64, element_count);
if (element_count == 0)
{
- return ClangASTType (ast, ast->getIncompleteArrayType (element_type.GetQualType(),
+ return CompilerType (ast, ast->getIncompleteArrayType (GetQualType(element_type),
ArrayType::Normal,
- 0).getAsOpaquePtr());
+ 0));
}
else
{
- return ClangASTType (ast, ast->getConstantArrayType (element_type.GetQualType(),
+ return CompilerType (ast, ast->getConstantArrayType (GetQualType(element_type),
ap_element_count,
ArrayType::Normal,
- 0).getAsOpaquePtr());
+ 0));
}
}
}
- return ClangASTType();
+ return CompilerType();
}
-ClangASTType
+CompilerType
ClangASTContext::GetOrCreateStructForIdentifier (const ConstString &type_name,
- const std::initializer_list< std::pair < const char *, ClangASTType > >& type_fields,
+ const std::initializer_list< std::pair < const char *, CompilerType > >& type_fields,
bool packed)
{
- ClangASTType type;
+ CompilerType type;
if ((type = GetTypeForIdentifier<clang::CXXRecordDecl>(type_name)).IsValid())
return type;
type = CreateRecordType(nullptr, lldb::eAccessPublic, type_name.GetCString(), clang::TTK_Struct, lldb::eLanguageTypeC);
- type.StartTagDeclarationDefinition();
+ StartTagDeclarationDefinition(type);
for (const auto& field : type_fields)
- type.AddFieldToRecordType(field.first, field.second, lldb::eAccessPublic, 0);
+ AddFieldToRecordType(type, field.first, field.second, lldb::eAccessPublic, 0);
if (packed)
- type.SetIsPacked();
- type.CompleteTagDeclarationDefinition();
+ SetIsPacked(type);
+ CompleteTagDeclarationDefinition(type);
return type;
}
#pragma mark Enumeration Types
-ClangASTType
-ClangASTContext::CreateEnumerationType
+CompilerType
+ClangASTContext::CreateEnumerationType
(
- const char *name,
- DeclContext *decl_ctx,
- const Declaration &decl,
- const ClangASTType &integer_clang_type
-)
+ const char *name,
+ DeclContext *decl_ctx,
+ const Declaration &decl,
+ const CompilerType &integer_clang_type
+ )
{
// TODO: Do something intelligent with the Declaration object passed in
// like maybe filling in the SourceLocation with it...
ASTContext *ast = getASTContext();
-
+
// TODO: ask about these...
-// const bool IsScoped = false;
-// const bool IsFixed = false;
-
+ // const bool IsScoped = false;
+ // const bool IsFixed = false;
+
EnumDecl *enum_decl = EnumDecl::Create (*ast,
decl_ctx,
SourceLocation(),
@@ -1934,13 +2171,13 @@ ClangASTContext::CreateEnumerationType
if (enum_decl)
{
// TODO: check if we should be setting the promotion type too?
- enum_decl->setIntegerType(integer_clang_type.GetQualType());
+ enum_decl->setIntegerType(GetQualType(integer_clang_type));
enum_decl->setAccess(AS_public); // TODO respect what's in the debug info
- return ClangASTType (ast, ast->getTagDeclType(enum_decl).getAsOpaquePtr());
+ return CompilerType (ast, ast->getTagDeclType(enum_decl));
}
- return ClangASTType();
+ return CompilerType();
}
// Disable this for now since I can't seem to get a nicely formatted float
@@ -1950,7 +2187,7 @@ ClangASTContext::CreateEnumerationType
// so we can support remote targets. The code below also requires a patch to
// llvm::APInt.
//bool
-//ClangASTContext::ConvertFloatValueToString (ASTContext *ast, clang_type_t clang_type, const uint8_t* bytes, size_t byte_size, int apint_byte_order, std::string &float_str)
+//ClangASTContext::ConvertFloatValueToString (ASTContext *ast, lldb::opaque_compiler_type_t clang_type, const uint8_t* bytes, size_t byte_size, int apint_byte_order, std::string &float_str)
//{
// uint32_t count = 0;
// bool is_complex = false;
@@ -1984,7 +2221,7 @@ ClangASTContext::CreateEnumerationType
// return false;
//}
-ClangASTType
+CompilerType
ClangASTContext::GetIntTypeFromBitSize (clang::ASTContext *ast,
size_t bit_size, bool is_signed)
{
@@ -1993,74 +2230,207 @@ ClangASTContext::GetIntTypeFromBitSize (clang::ASTContext *ast,
if (is_signed)
{
if (bit_size == ast->getTypeSize(ast->SignedCharTy))
- return ClangASTType(ast, ast->SignedCharTy.getAsOpaquePtr());
+ return CompilerType(ast, ast->SignedCharTy);
if (bit_size == ast->getTypeSize(ast->ShortTy))
- return ClangASTType(ast, ast->ShortTy.getAsOpaquePtr());
+ return CompilerType(ast, ast->ShortTy);
if (bit_size == ast->getTypeSize(ast->IntTy))
- return ClangASTType(ast, ast->IntTy.getAsOpaquePtr());
+ return CompilerType(ast, ast->IntTy);
if (bit_size == ast->getTypeSize(ast->LongTy))
- return ClangASTType(ast, ast->LongTy.getAsOpaquePtr());
+ return CompilerType(ast, ast->LongTy);
if (bit_size == ast->getTypeSize(ast->LongLongTy))
- return ClangASTType(ast, ast->LongLongTy.getAsOpaquePtr());
+ return CompilerType(ast, ast->LongLongTy);
if (bit_size == ast->getTypeSize(ast->Int128Ty))
- return ClangASTType(ast, ast->Int128Ty.getAsOpaquePtr());
+ return CompilerType(ast, ast->Int128Ty);
}
else
{
if (bit_size == ast->getTypeSize(ast->UnsignedCharTy))
- return ClangASTType(ast, ast->UnsignedCharTy.getAsOpaquePtr());
+ return CompilerType(ast, ast->UnsignedCharTy);
if (bit_size == ast->getTypeSize(ast->UnsignedShortTy))
- return ClangASTType(ast, ast->UnsignedShortTy.getAsOpaquePtr());
+ return CompilerType(ast, ast->UnsignedShortTy);
if (bit_size == ast->getTypeSize(ast->UnsignedIntTy))
- return ClangASTType(ast, ast->UnsignedIntTy.getAsOpaquePtr());
+ return CompilerType(ast, ast->UnsignedIntTy);
if (bit_size == ast->getTypeSize(ast->UnsignedLongTy))
- return ClangASTType(ast, ast->UnsignedLongTy.getAsOpaquePtr());
+ return CompilerType(ast, ast->UnsignedLongTy);
if (bit_size == ast->getTypeSize(ast->UnsignedLongLongTy))
- return ClangASTType(ast, ast->UnsignedLongLongTy.getAsOpaquePtr());
+ return CompilerType(ast, ast->UnsignedLongLongTy);
if (bit_size == ast->getTypeSize(ast->UnsignedInt128Ty))
- return ClangASTType(ast, ast->UnsignedInt128Ty.getAsOpaquePtr());
+ return CompilerType(ast, ast->UnsignedInt128Ty);
}
}
- return ClangASTType();
+ return CompilerType();
}
-ClangASTType
+CompilerType
ClangASTContext::GetPointerSizedIntType (clang::ASTContext *ast, bool is_signed)
{
if (ast)
return GetIntTypeFromBitSize(ast, ast->getTypeSize(ast->VoidPtrTy), is_signed);
- return ClangASTType();
+ return CompilerType();
}
-ClangASTType
-ClangASTContext::GetFloatTypeFromBitSize (clang::ASTContext *ast,
- size_t bit_size)
+void
+ClangASTContext::DumpDeclContextHiearchy (clang::DeclContext *decl_ctx)
{
- if (ast)
+ if (decl_ctx)
+ {
+ DumpDeclContextHiearchy (decl_ctx->getParent());
+
+ clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl_ctx);
+ if (named_decl)
+ {
+ printf ("%20s: %s\n", decl_ctx->getDeclKindName(), named_decl->getDeclName().getAsString().c_str());
+ }
+ else
+ {
+ printf ("%20s\n", decl_ctx->getDeclKindName());
+ }
+ }
+}
+
+void
+ClangASTContext::DumpDeclHiearchy (clang::Decl *decl)
+{
+ if (decl == nullptr)
+ return;
+ DumpDeclContextHiearchy(decl->getDeclContext());
+
+ clang::RecordDecl *record_decl = llvm::dyn_cast<clang::RecordDecl>(decl);
+ if (record_decl)
{
- if (bit_size == ast->getTypeSize(ast->FloatTy))
- return ClangASTType(ast, ast->FloatTy.getAsOpaquePtr());
- else if (bit_size == ast->getTypeSize(ast->DoubleTy))
- return ClangASTType(ast, ast->DoubleTy.getAsOpaquePtr());
- else if (bit_size == ast->getTypeSize(ast->LongDoubleTy))
- return ClangASTType(ast, ast->LongDoubleTy.getAsOpaquePtr());
- else if (bit_size == ast->getTypeSize(ast->HalfTy))
- return ClangASTType(ast, ast->HalfTy.getAsOpaquePtr());
+ printf ("%20s: %s%s\n", decl->getDeclKindName(), record_decl->getDeclName().getAsString().c_str(), record_decl->isInjectedClassName() ? " (injected class name)" : "");
+
+ }
+ else
+ {
+ clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl);
+ if (named_decl)
+ {
+ printf ("%20s: %s\n", decl->getDeclKindName(), named_decl->getDeclName().getAsString().c_str());
+ }
+ else
+ {
+ printf ("%20s\n", decl->getDeclKindName());
+ }
}
- return ClangASTType();
}
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)
+ {
+ if (lhs_decl_ctx && rhs_decl_ctx)
+ {
+ const clang::Decl::Kind lhs_decl_ctx_kind = lhs_decl_ctx->getDeclKind();
+ const clang::Decl::Kind rhs_decl_ctx_kind = rhs_decl_ctx->getDeclKind();
+ if (lhs_decl_ctx_kind == rhs_decl_ctx_kind)
+ {
+ lhs_decl_ctx = lhs_decl_ctx->getParent();
+ rhs_decl_ctx = rhs_decl_ctx->getParent();
+
+ if (lhs_decl_ctx == nullptr && rhs_decl_ctx == nullptr)
+ break;
+ }
+ else
+ return false;
+ }
+ else
+ 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 = llvm::dyn_cast<clang::NamedDecl>(rhs_decl);
+ if (lhs_named_decl && rhs_named_decl)
+ {
+ clang::DeclarationName lhs_decl_name = lhs_named_decl->getDeclName();
+ clang::DeclarationName rhs_decl_name = rhs_named_decl->getDeclName();
+ if (lhs_decl_name.getNameKind() == rhs_decl_name.getNameKind())
+ {
+ if (lhs_decl_name.getAsString() != rhs_decl_name.getAsString())
+ return false;
+ }
+ else
+ return false;
+ }
+ 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)
+ {
+ switch (lhs_decl_ctx->getDeclKind())
+ {
+ case clang::Decl::TranslationUnit:
+ // We don't care about the translation unit names
+ return true;
+ default:
+ {
+ clang::NamedDecl *lhs_named_decl = llvm::dyn_cast<clang::NamedDecl>(lhs_decl_ctx);
+ clang::NamedDecl *rhs_named_decl = llvm::dyn_cast<clang::NamedDecl>(rhs_decl_ctx);
+ if (lhs_named_decl && rhs_named_decl)
+ {
+ clang::DeclarationName lhs_decl_name = lhs_named_decl->getDeclName();
+ clang::DeclarationName rhs_decl_name = rhs_named_decl->getDeclName();
+ if (lhs_decl_name.getNameKind() == rhs_decl_name.getNameKind())
+ {
+ if (lhs_decl_name.getAsString() != rhs_decl_name.getAsString())
+ return false;
+ }
+ else
+ return false;
+ }
+ else
+ return false;
+ }
+ break;
+
+ }
+ lhs_decl_ctx = lhs_decl_ctx->getParent();
+ rhs_decl_ctx = rhs_decl_ctx->getParent();
+ }
+ }
+ }
+ }
+ return false;
+}
+bool
ClangASTContext::GetCompleteDecl (clang::ASTContext *ast,
clang::Decl *decl)
{
@@ -2148,46 +2518,7484 @@ ClangASTContext::GetAsDeclContext (clang::ObjCMethodDecl *objc_method_decl)
return llvm::dyn_cast<clang::DeclContext>(objc_method_decl);
}
+bool
+ClangASTContext::SetTagTypeKind (clang::QualType tag_qual_type, int kind) const
+{
+ const clang::Type *clang_type = tag_qual_type.getTypePtr();
+ if (clang_type)
+ {
+ const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(clang_type);
+ if (tag_type)
+ {
+ clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(tag_type->getDecl());
+ if (tag_decl)
+ {
+ tag_decl->setTagKind ((clang::TagDecl::TagKind)kind);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
bool
-ClangASTContext::GetClassMethodInfoForDeclContext (clang::DeclContext *decl_ctx,
- lldb::LanguageType &language,
- bool &is_instance_method,
- ConstString &language_object_name)
+ClangASTContext::SetDefaultAccessForRecordFields (clang::RecordDecl* record_decl,
+ int default_accessibility,
+ int *assigned_accessibilities,
+ size_t num_assigned_accessibilities)
{
- language_object_name.Clear();
- language = eLanguageTypeUnknown;
- is_instance_method = false;
+ if (record_decl)
+ {
+ uint32_t field_idx;
+ clang::RecordDecl::field_iterator field, field_end;
+ for (field = record_decl->field_begin(), field_end = record_decl->field_end(), field_idx = 0;
+ field != field_end;
+ ++field, ++field_idx)
+ {
+ // If no accessibility was assigned, assign the correct one
+ if (field_idx < num_assigned_accessibilities && assigned_accessibilities[field_idx] == clang::AS_none)
+ field->setAccess ((clang::AccessSpecifier)default_accessibility);
+ }
+ return true;
+ }
+ return false;
+}
- if (decl_ctx)
+clang::DeclContext *
+ClangASTContext::GetDeclContextForType (const CompilerType& type)
+{
+ return GetDeclContextForType(GetQualType(type));
+}
+
+clang::DeclContext *
+ClangASTContext::GetDeclContextForType (clang::QualType type)
+{
+ if (type.isNull())
+ return nullptr;
+
+ clang::QualType qual_type = type.getCanonicalType();
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::ObjCInterface: return llvm::cast<clang::ObjCObjectType>(qual_type.getTypePtr())->getInterface();
+ case clang::Type::ObjCObjectPointer: return GetDeclContextForType (llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())->getPointeeType());
+ case clang::Type::Record: return llvm::cast<clang::RecordType>(qual_type)->getDecl();
+ case clang::Type::Enum: return llvm::cast<clang::EnumType>(qual_type)->getDecl();
+ case clang::Type::Typedef: return GetDeclContextForType (llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType());
+ case clang::Type::Auto: return GetDeclContextForType (llvm::cast<clang::AutoType>(qual_type)->getDeducedType());
+ case clang::Type::Elaborated: return GetDeclContextForType (llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType());
+ case clang::Type::Paren: return GetDeclContextForType (llvm::cast<clang::ParenType>(qual_type)->desugar());
+ default:
+ break;
+ }
+ // No DeclContext in this type...
+ return nullptr;
+}
+
+static bool
+GetCompleteQualType (clang::ASTContext *ast, clang::QualType qual_type, bool allow_completion = true)
+{
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::ConstantArray:
+ case clang::Type::IncompleteArray:
+ case clang::Type::VariableArray:
+ {
+ const clang::ArrayType *array_type = llvm::dyn_cast<clang::ArrayType>(qual_type.getTypePtr());
+
+ if (array_type)
+ return GetCompleteQualType (ast, array_type->getElementType(), allow_completion);
+ }
+ break;
+ case clang::Type::Record:
+ {
+ clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+ if (cxx_record_decl)
+ {
+ if (cxx_record_decl->hasExternalLexicalStorage())
+ {
+ const bool is_complete = cxx_record_decl->isCompleteDefinition();
+ const bool fields_loaded = cxx_record_decl->hasLoadedFieldsFromExternalStorage();
+ if (is_complete && fields_loaded)
+ return true;
+
+ if (!allow_completion)
+ return false;
+
+ // Call the field_begin() accessor to for it to use the external source
+ // to load the fields...
+ clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
+ if (external_ast_source)
+ {
+ external_ast_source->CompleteType(cxx_record_decl);
+ if (cxx_record_decl->isCompleteDefinition())
+ {
+ cxx_record_decl->setHasLoadedFieldsFromExternalStorage (true);
+ cxx_record_decl->field_begin();
+ }
+ }
+ }
+ }
+ const clang::TagType *tag_type = llvm::cast<clang::TagType>(qual_type.getTypePtr());
+ return !tag_type->isIncompleteType();
+ }
+ break;
+
+ case clang::Type::Enum:
+ {
+ const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
+ if (tag_type)
+ {
+ clang::TagDecl *tag_decl = tag_type->getDecl();
+ if (tag_decl)
+ {
+ if (tag_decl->getDefinition())
+ return true;
+
+ if (!allow_completion)
+ return false;
+
+ if (tag_decl->hasExternalLexicalStorage())
+ {
+ if (ast)
+ {
+ clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
+ if (external_ast_source)
+ {
+ external_ast_source->CompleteType(tag_decl);
+ return !tag_type->isIncompleteType();
+ }
+ }
+ }
+ return false;
+ }
+ }
+
+ }
+ break;
+ case clang::Type::ObjCObject:
+ case clang::Type::ObjCInterface:
+ {
+ const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
+ if (objc_class_type)
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+ // 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 (class_interface_decl->getDefinition())
+ return true;
+
+ if (!allow_completion)
+ return false;
+
+ if (class_interface_decl->hasExternalLexicalStorage())
+ {
+ if (ast)
+ {
+ clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
+ if (external_ast_source)
+ {
+ external_ast_source->CompleteType (class_interface_decl);
+ return !objc_class_type->isIncompleteType();
+ }
+ }
+ }
+ return false;
+ }
+ }
+ }
+ break;
+
+ case clang::Type::Typedef:
+ return GetCompleteQualType (ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType(), allow_completion);
+
+ case clang::Type::Auto:
+ return GetCompleteQualType (ast, llvm::cast<clang::AutoType>(qual_type)->getDeducedType(), allow_completion);
+
+ case clang::Type::Elaborated:
+ return GetCompleteQualType (ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType(), allow_completion);
+
+ case clang::Type::Paren:
+ return GetCompleteQualType (ast, llvm::cast<clang::ParenType>(qual_type)->desugar(), allow_completion);
+
+ case clang::Type::Attributed:
+ return GetCompleteQualType (ast, llvm::cast<clang::AttributedType>(qual_type)->getModifiedType(), allow_completion);
+
+ default:
+ break;
+ }
+
+ return true;
+}
+
+static clang::ObjCIvarDecl::AccessControl
+ConvertAccessTypeToObjCIvarAccessControl (AccessType access)
+{
+ switch (access)
+ {
+ case eAccessNone: return clang::ObjCIvarDecl::None;
+ case eAccessPublic: return clang::ObjCIvarDecl::Public;
+ case eAccessPrivate: return clang::ObjCIvarDecl::Private;
+ case eAccessProtected: return clang::ObjCIvarDecl::Protected;
+ case eAccessPackage: return clang::ObjCIvarDecl::Package;
+ }
+ return clang::ObjCIvarDecl::None;
+}
+
+
+//----------------------------------------------------------------------
+// Tests
+//----------------------------------------------------------------------
+
+bool
+ClangASTContext::IsAggregateType (lldb::opaque_compiler_type_t type)
+{
+ clang::QualType qual_type (GetCanonicalQualType(type));
+
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::IncompleteArray:
+ case clang::Type::VariableArray:
+ case clang::Type::ConstantArray:
+ case clang::Type::ExtVector:
+ case clang::Type::Vector:
+ case clang::Type::Record:
+ case clang::Type::ObjCObject:
+ case clang::Type::ObjCInterface:
+ return true;
+ case clang::Type::Auto:
+ return IsAggregateType(llvm::cast<clang::AutoType>(qual_type)->getDeducedType().getAsOpaquePtr());
+ case clang::Type::Elaborated:
+ return IsAggregateType(llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr());
+ case clang::Type::Typedef:
+ return IsAggregateType(llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
+ case clang::Type::Paren:
+ return IsAggregateType(llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr());
+ default:
+ break;
+ }
+ // The clang type does have a value
+ return false;
+}
+
+bool
+ClangASTContext::IsAnonymousType (lldb::opaque_compiler_type_t type)
+{
+ clang::QualType qual_type (GetCanonicalQualType(type));
+
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Record:
+ {
+ if (const clang::RecordType *record_type = llvm::dyn_cast_or_null<clang::RecordType>(qual_type.getTypePtrOrNull()))
+ {
+ if (const clang::RecordDecl *record_decl = record_type->getDecl())
+ {
+ return record_decl->isAnonymousStructOrUnion();
+ }
+ }
+ break;
+ }
+ case clang::Type::Auto:
+ return IsAnonymousType(llvm::cast<clang::AutoType>(qual_type)->getDeducedType().getAsOpaquePtr());
+ case clang::Type::Elaborated:
+ return IsAnonymousType(llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr());
+ case clang::Type::Typedef:
+ return IsAnonymousType(llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
+ case clang::Type::Paren:
+ return IsAnonymousType(llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr());
+ default:
+ break;
+ }
+ // The clang type does have a value
+ return false;
+}
+
+bool
+ClangASTContext::IsArrayType (lldb::opaque_compiler_type_t type,
+ CompilerType *element_type_ptr,
+ uint64_t *size,
+ bool *is_incomplete)
+{
+ clang::QualType qual_type (GetCanonicalQualType(type));
+
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ default:
+ break;
+
+ case clang::Type::ConstantArray:
+ if (element_type_ptr)
+ element_type_ptr->SetCompilerType (getASTContext(), llvm::cast<clang::ConstantArrayType>(qual_type)->getElementType());
+ if (size)
+ *size = llvm::cast<clang::ConstantArrayType>(qual_type)->getSize().getLimitedValue(ULLONG_MAX);
+ if (is_incomplete)
+ *is_incomplete = false;
+ return true;
+
+ case clang::Type::IncompleteArray:
+ if (element_type_ptr)
+ element_type_ptr->SetCompilerType (getASTContext(), llvm::cast<clang::IncompleteArrayType>(qual_type)->getElementType());
+ if (size)
+ *size = 0;
+ if (is_incomplete)
+ *is_incomplete = true;
+ return true;
+
+ case clang::Type::VariableArray:
+ if (element_type_ptr)
+ element_type_ptr->SetCompilerType (getASTContext(), llvm::cast<clang::VariableArrayType>(qual_type)->getElementType());
+ if (size)
+ *size = 0;
+ if (is_incomplete)
+ *is_incomplete = false;
+ return true;
+
+ case clang::Type::DependentSizedArray:
+ if (element_type_ptr)
+ element_type_ptr->SetCompilerType (getASTContext(), llvm::cast<clang::DependentSizedArrayType>(qual_type)->getElementType());
+ if (size)
+ *size = 0;
+ if (is_incomplete)
+ *is_incomplete = false;
+ return true;
+
+ case clang::Type::Typedef:
+ return IsArrayType(llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(),
+ element_type_ptr,
+ size,
+ is_incomplete);
+ case clang::Type::Auto:
+ return IsArrayType(llvm::cast<clang::AutoType>(qual_type)->getDeducedType().getAsOpaquePtr(),
+ element_type_ptr,
+ size,
+ is_incomplete);
+ case clang::Type::Elaborated:
+ return IsArrayType(llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(),
+ element_type_ptr,
+ size,
+ is_incomplete);
+ case clang::Type::Paren:
+ return IsArrayType(llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(),
+ element_type_ptr,
+ size,
+ is_incomplete);
+ }
+ if (element_type_ptr)
+ element_type_ptr->Clear();
+ if (size)
+ *size = 0;
+ if (is_incomplete)
+ *is_incomplete = false;
+ return false;
+}
+
+bool
+ClangASTContext::IsVectorType (lldb::opaque_compiler_type_t type,
+ CompilerType *element_type,
+ uint64_t *size)
+{
+ clang::QualType qual_type (GetCanonicalQualType(type));
+
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Vector:
+ {
+ const clang::VectorType *vector_type = qual_type->getAs<clang::VectorType>();
+ if (vector_type)
+ {
+ if (size)
+ *size = vector_type->getNumElements();
+ if (element_type)
+ *element_type = CompilerType(getASTContext(), vector_type->getElementType());
+ }
+ return true;
+ }
+ break;
+ case clang::Type::ExtVector:
+ {
+ const clang::ExtVectorType *ext_vector_type = qual_type->getAs<clang::ExtVectorType>();
+ if (ext_vector_type)
+ {
+ if (size)
+ *size = ext_vector_type->getNumElements();
+ if (element_type)
+ *element_type = CompilerType(getASTContext(), ext_vector_type->getElementType());
+ }
+ return true;
+ }
+ default:
+ break;
+ }
+ return false;
+}
+
+bool
+ClangASTContext::IsRuntimeGeneratedType (lldb::opaque_compiler_type_t type)
+{
+ clang::DeclContext* decl_ctx = ClangASTContext::GetASTContext(getASTContext())->GetDeclContextForType(GetQualType(type));
+ if (!decl_ctx)
+ return false;
+
+ if (!llvm::isa<clang::ObjCInterfaceDecl>(decl_ctx))
+ return false;
+
+ clang::ObjCInterfaceDecl *result_iface_decl = llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl_ctx);
+
+ ClangASTMetadata* ast_metadata = ClangASTContext::GetMetadata(getASTContext(), result_iface_decl);
+ if (!ast_metadata)
+ return false;
+ return (ast_metadata->GetISAPtr() != 0);
+}
+
+bool
+ClangASTContext::IsCharType (lldb::opaque_compiler_type_t type)
+{
+ return GetQualType(type).getUnqualifiedType()->isCharType();
+}
+
+
+bool
+ClangASTContext::IsCompleteType (lldb::opaque_compiler_type_t type)
+{
+ const bool allow_completion = false;
+ return GetCompleteQualType (getASTContext(), GetQualType(type), allow_completion);
+}
+
+bool
+ClangASTContext::IsConst(lldb::opaque_compiler_type_t type)
+{
+ return GetQualType(type).isConstQualified();
+}
+
+bool
+ClangASTContext::IsCStringType (lldb::opaque_compiler_type_t type, uint32_t &length)
+{
+ CompilerType pointee_or_element_clang_type;
+ length = 0;
+ Flags type_flags (GetTypeInfo (type, &pointee_or_element_clang_type));
+
+ if (!pointee_or_element_clang_type.IsValid())
+ return false;
+
+ if (type_flags.AnySet (eTypeIsArray | eTypeIsPointer))
+ {
+ if (pointee_or_element_clang_type.IsCharType())
+ {
+ if (type_flags.Test (eTypeIsArray))
+ {
+ // We know the size of the array and it could be a C string
+ // since it is an array of characters
+ length = llvm::cast<clang::ConstantArrayType>(GetCanonicalQualType(type).getTypePtr())->getSize().getLimitedValue();
+ }
+ return true;
+
+ }
+ }
+ return false;
+}
+
+bool
+ClangASTContext::IsFunctionType (lldb::opaque_compiler_type_t type, bool *is_variadic_ptr)
+{
+ if (type)
+ {
+ clang::QualType qual_type (GetCanonicalQualType(type));
+
+ if (qual_type->isFunctionType())
+ {
+ if (is_variadic_ptr)
+ {
+ const clang::FunctionProtoType *function_proto_type = llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
+ if (function_proto_type)
+ *is_variadic_ptr = function_proto_type->isVariadic();
+ else
+ *is_variadic_ptr = false;
+ }
+ return true;
+ }
+
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ default:
+ break;
+ case clang::Type::Typedef:
+ return IsFunctionType(llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), nullptr);
+ case clang::Type::Auto:
+ return IsFunctionType(llvm::cast<clang::AutoType>(qual_type)->getDeducedType().getAsOpaquePtr(), nullptr);
+ case clang::Type::Elaborated:
+ return IsFunctionType(llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(), nullptr);
+ case clang::Type::Paren:
+ return IsFunctionType(llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(), nullptr);
+ case clang::Type::LValueReference:
+ case clang::Type::RValueReference:
+ {
+ const clang::ReferenceType *reference_type = llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
+ if (reference_type)
+ return IsFunctionType(reference_type->getPointeeType().getAsOpaquePtr(), nullptr);
+ }
+ break;
+ }
+ }
+ return false;
+}
+
+// Used to detect "Homogeneous Floating-point Aggregates"
+uint32_t
+ClangASTContext::IsHomogeneousAggregate (lldb::opaque_compiler_type_t type, CompilerType* base_type_ptr)
+{
+ if (!type)
+ return 0;
+
+ clang::QualType qual_type(GetCanonicalQualType(type));
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Record:
+ if (GetCompleteType (type))
+ {
+ const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+ if (cxx_record_decl)
+ {
+ if (cxx_record_decl->getNumBases() ||
+ cxx_record_decl->isDynamicClass())
+ return 0;
+ }
+ const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
+ if (record_type)
+ {
+ const clang::RecordDecl *record_decl = record_type->getDecl();
+ if (record_decl)
+ {
+ // We are looking for a structure that contains only floating point types
+ clang::RecordDecl::field_iterator field_pos, field_end = record_decl->field_end();
+ uint32_t num_fields = 0;
+ bool is_hva = false;
+ bool is_hfa = false;
+ clang::QualType base_qual_type;
+ for (field_pos = record_decl->field_begin(); field_pos != field_end; ++field_pos)
+ {
+ clang::QualType field_qual_type = field_pos->getType();
+ if (field_qual_type->isFloatingType())
+ {
+ if (field_qual_type->isComplexType())
+ return 0;
+ else
+ {
+ if (num_fields == 0)
+ base_qual_type = field_qual_type;
+ else
+ {
+ if (is_hva)
+ return 0;
+ is_hfa = true;
+ if (field_qual_type.getTypePtr() != base_qual_type.getTypePtr())
+ return 0;
+ }
+ }
+ }
+ else if (field_qual_type->isVectorType() || field_qual_type->isExtVectorType())
+ {
+ const clang::VectorType *array = field_qual_type.getTypePtr()->getAs<clang::VectorType>();
+ if (array && array->getNumElements() <= 4)
+ {
+ if (num_fields == 0)
+ base_qual_type = array->getElementType();
+ else
+ {
+ if (is_hfa)
+ return 0;
+ is_hva = true;
+ if (field_qual_type.getTypePtr() != base_qual_type.getTypePtr())
+ return 0;
+ }
+ }
+ else
+ return 0;
+ }
+ else
+ return 0;
+ ++num_fields;
+ }
+ if (base_type_ptr)
+ *base_type_ptr = CompilerType (getASTContext(), base_qual_type);
+ return num_fields;
+ }
+ }
+ }
+ break;
+
+ case clang::Type::Typedef:
+ return IsHomogeneousAggregate(llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), base_type_ptr);
+
+ case clang::Type::Auto:
+ return IsHomogeneousAggregate(llvm::cast<clang::AutoType>(qual_type)->getDeducedType().getAsOpaquePtr(), base_type_ptr);
+
+ case clang::Type::Elaborated:
+ return IsHomogeneousAggregate(llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(), base_type_ptr);
+ default:
+ break;
+ }
+ return 0;
+}
+
+size_t
+ClangASTContext::GetNumberOfFunctionArguments (lldb::opaque_compiler_type_t type)
+{
+ if (type)
+ {
+ clang::QualType qual_type (GetCanonicalQualType(type));
+ const clang::FunctionProtoType* func = llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
+ if (func)
+ return func->getNumParams();
+ }
+ return 0;
+}
+
+CompilerType
+ClangASTContext::GetFunctionArgumentAtIndex (lldb::opaque_compiler_type_t type, const size_t index)
+{
+ if (type)
+ {
+ clang::QualType qual_type (GetCanonicalQualType(type));
+ const clang::FunctionProtoType* func = llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
+ if (func)
+ {
+ if (index < func->getNumParams())
+ return CompilerType(getASTContext(), func->getParamType(index));
+ }
+ }
+ return CompilerType();
+}
+
+bool
+ClangASTContext::IsFunctionPointerType (lldb::opaque_compiler_type_t type)
+{
+ if (type)
+ {
+ clang::QualType qual_type (GetCanonicalQualType(type));
+
+ if (qual_type->isFunctionPointerType())
+ return true;
+
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ default:
+ break;
+ case clang::Type::Typedef:
+ return IsFunctionPointerType (llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
+ case clang::Type::Auto:
+ return IsFunctionPointerType (llvm::cast<clang::AutoType>(qual_type)->getDeducedType().getAsOpaquePtr());
+ case clang::Type::Elaborated:
+ return IsFunctionPointerType (llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr());
+ case clang::Type::Paren:
+ return IsFunctionPointerType (llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr());
+
+ case clang::Type::LValueReference:
+ case clang::Type::RValueReference:
+ {
+ const clang::ReferenceType *reference_type = llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
+ if (reference_type)
+ return IsFunctionPointerType(reference_type->getPointeeType().getAsOpaquePtr());
+ }
+ break;
+ }
+ }
+ return false;
+
+}
+
+bool
+ClangASTContext::IsIntegerType (lldb::opaque_compiler_type_t type, bool &is_signed)
+{
+ if (!type)
+ return false;
+
+ clang::QualType qual_type (GetCanonicalQualType(type));
+ const clang::BuiltinType *builtin_type = llvm::dyn_cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal());
+
+ if (builtin_type)
+ {
+ if (builtin_type->isInteger())
+ {
+ is_signed = builtin_type->isSignedInteger();
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool
+ClangASTContext::IsPointerType (lldb::opaque_compiler_type_t type, CompilerType *pointee_type)
+{
+ if (type)
+ {
+ clang::QualType qual_type (GetCanonicalQualType(type));
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Builtin:
+ switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind())
+ {
+ default:
+ break;
+ case clang::BuiltinType::ObjCId:
+ case clang::BuiltinType::ObjCClass:
+ return true;
+ }
+ return false;
+ case clang::Type::ObjCObjectPointer:
+ if (pointee_type)
+ pointee_type->SetCompilerType (getASTContext(), llvm::cast<clang::ObjCObjectPointerType>(qual_type)->getPointeeType());
+ return true;
+ case clang::Type::BlockPointer:
+ if (pointee_type)
+ pointee_type->SetCompilerType (getASTContext(), llvm::cast<clang::BlockPointerType>(qual_type)->getPointeeType());
+ return true;
+ case clang::Type::Pointer:
+ if (pointee_type)
+ pointee_type->SetCompilerType (getASTContext(), llvm::cast<clang::PointerType>(qual_type)->getPointeeType());
+ return true;
+ case clang::Type::MemberPointer:
+ if (pointee_type)
+ pointee_type->SetCompilerType (getASTContext(), llvm::cast<clang::MemberPointerType>(qual_type)->getPointeeType());
+ return true;
+ case clang::Type::Typedef:
+ return IsPointerType (llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), pointee_type);
+ case clang::Type::Auto:
+ return IsPointerType (llvm::cast<clang::AutoType>(qual_type)->getDeducedType().getAsOpaquePtr(), pointee_type);
+ case clang::Type::Elaborated:
+ return IsPointerType (llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(), pointee_type);
+ case clang::Type::Paren:
+ return IsPointerType (llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(), pointee_type);
+ default:
+ break;
+ }
+ }
+ if (pointee_type)
+ pointee_type->Clear();
+ return false;
+}
+
+
+bool
+ClangASTContext::IsPointerOrReferenceType (lldb::opaque_compiler_type_t type, CompilerType *pointee_type)
+{
+ if (type)
+ {
+ clang::QualType qual_type (GetCanonicalQualType(type));
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Builtin:
+ switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind())
+ {
+ default:
+ break;
+ case clang::BuiltinType::ObjCId:
+ case clang::BuiltinType::ObjCClass:
+ return true;
+ }
+ return false;
+ case clang::Type::ObjCObjectPointer:
+ if (pointee_type)
+ pointee_type->SetCompilerType(getASTContext(), llvm::cast<clang::ObjCObjectPointerType>(qual_type)->getPointeeType());
+ return true;
+ case clang::Type::BlockPointer:
+ if (pointee_type)
+ pointee_type->SetCompilerType(getASTContext(), llvm::cast<clang::BlockPointerType>(qual_type)->getPointeeType());
+ return true;
+ case clang::Type::Pointer:
+ if (pointee_type)
+ pointee_type->SetCompilerType(getASTContext(), llvm::cast<clang::PointerType>(qual_type)->getPointeeType());
+ return true;
+ case clang::Type::MemberPointer:
+ if (pointee_type)
+ pointee_type->SetCompilerType(getASTContext(), llvm::cast<clang::MemberPointerType>(qual_type)->getPointeeType());
+ return true;
+ case clang::Type::LValueReference:
+ if (pointee_type)
+ pointee_type->SetCompilerType(getASTContext(), llvm::cast<clang::LValueReferenceType>(qual_type)->desugar());
+ return true;
+ case clang::Type::RValueReference:
+ if (pointee_type)
+ pointee_type->SetCompilerType(getASTContext(), llvm::cast<clang::RValueReferenceType>(qual_type)->desugar());
+ return true;
+ case clang::Type::Typedef:
+ return IsPointerOrReferenceType(llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), pointee_type);
+ case clang::Type::Auto:
+ return IsPointerOrReferenceType(llvm::cast<clang::AutoType>(qual_type)->getDeducedType().getAsOpaquePtr(), pointee_type);
+ case clang::Type::Elaborated:
+ return IsPointerOrReferenceType(llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(), pointee_type);
+ case clang::Type::Paren:
+ return IsPointerOrReferenceType(llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(), pointee_type);
+ default:
+ break;
+ }
+ }
+ if (pointee_type)
+ pointee_type->Clear();
+ return false;
+}
+
+
+bool
+ClangASTContext::IsReferenceType (lldb::opaque_compiler_type_t type, CompilerType *pointee_type, bool* is_rvalue)
+{
+ if (type)
+ {
+ clang::QualType qual_type (GetCanonicalQualType(type));
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+
+ switch (type_class)
+ {
+ case clang::Type::LValueReference:
+ if (pointee_type)
+ pointee_type->SetCompilerType(getASTContext(), llvm::cast<clang::LValueReferenceType>(qual_type)->desugar());
+ if (is_rvalue)
+ *is_rvalue = false;
+ return true;
+ case clang::Type::RValueReference:
+ if (pointee_type)
+ pointee_type->SetCompilerType(getASTContext(), llvm::cast<clang::RValueReferenceType>(qual_type)->desugar());
+ if (is_rvalue)
+ *is_rvalue = true;
+ return true;
+ case clang::Type::Typedef:
+ return IsReferenceType (llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), pointee_type, is_rvalue);
+ case clang::Type::Auto:
+ return IsReferenceType (llvm::cast<clang::AutoType>(qual_type)->getDeducedType().getAsOpaquePtr(), pointee_type, is_rvalue);
+ case clang::Type::Elaborated:
+ return IsReferenceType (llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(), pointee_type, is_rvalue);
+ case clang::Type::Paren:
+ return IsReferenceType (llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(), pointee_type, is_rvalue);
+
+ default:
+ break;
+ }
+ }
+ if (pointee_type)
+ pointee_type->Clear();
+ return false;
+}
+
+bool
+ClangASTContext::IsFloatingPointType (lldb::opaque_compiler_type_t type, uint32_t &count, bool &is_complex)
+{
+ if (type)
+ {
+ clang::QualType qual_type (GetCanonicalQualType(type));
+
+ if (const clang::BuiltinType *BT = llvm::dyn_cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal()))
+ {
+ clang::BuiltinType::Kind kind = BT->getKind();
+ if (kind >= clang::BuiltinType::Float && kind <= clang::BuiltinType::LongDouble)
+ {
+ count = 1;
+ is_complex = false;
+ return true;
+ }
+ }
+ else if (const clang::ComplexType *CT = llvm::dyn_cast<clang::ComplexType>(qual_type->getCanonicalTypeInternal()))
+ {
+ if (IsFloatingPointType (CT->getElementType().getAsOpaquePtr(), count, is_complex))
+ {
+ count = 2;
+ is_complex = true;
+ return true;
+ }
+ }
+ else if (const clang::VectorType *VT = llvm::dyn_cast<clang::VectorType>(qual_type->getCanonicalTypeInternal()))
+ {
+ if (IsFloatingPointType (VT->getElementType().getAsOpaquePtr(), count, is_complex))
+ {
+ count = VT->getNumElements();
+ is_complex = false;
+ return true;
+ }
+ }
+ }
+ count = 0;
+ is_complex = false;
+ return false;
+}
+
+
+bool
+ClangASTContext::IsDefined(lldb::opaque_compiler_type_t type)
+{
+ if (!type)
+ return false;
+
+ clang::QualType qual_type(GetQualType(type));
+ const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
+ if (tag_type)
+ {
+ clang::TagDecl *tag_decl = tag_type->getDecl();
+ if (tag_decl)
+ return tag_decl->isCompleteDefinition();
+ return false;
+ }
+ else
+ {
+ const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
+ if (objc_class_type)
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+ if (class_interface_decl)
+ return class_interface_decl->getDefinition() != nullptr;
+ return false;
+ }
+ }
+ return true;
+}
+
+bool
+ClangASTContext::IsObjCClassType (const CompilerType& type)
+{
+ if (type)
+ {
+ clang::QualType qual_type (GetCanonicalQualType(type));
+
+ const clang::ObjCObjectPointerType *obj_pointer_type = llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
+
+ if (obj_pointer_type)
+ return obj_pointer_type->isObjCClassType();
+ }
+ return false;
+}
+
+bool
+ClangASTContext::IsObjCObjectOrInterfaceType (const CompilerType& type)
+{
+ if (IsClangType(type))
+ return GetCanonicalQualType(type)->isObjCObjectOrInterfaceType();
+ return false;
+}
+
+bool
+ClangASTContext::IsPolymorphicClass (lldb::opaque_compiler_type_t type)
+{
+ if (type)
+ {
+ clang::QualType qual_type(GetCanonicalQualType(type));
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Record:
+ if (GetCompleteType(type))
+ {
+ const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
+ const clang::RecordDecl *record_decl = record_type->getDecl();
+ if (record_decl)
+ {
+ const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
+ if (cxx_record_decl)
+ return cxx_record_decl->isPolymorphic();
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ return false;
+}
+
+bool
+ClangASTContext::IsPossibleDynamicType (lldb::opaque_compiler_type_t type, CompilerType *dynamic_pointee_type,
+ bool check_cplusplus,
+ bool check_objc)
+{
+ clang::QualType pointee_qual_type;
+ if (type)
+ {
+ clang::QualType qual_type (GetCanonicalQualType(type));
+ bool success = false;
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Builtin:
+ if (check_objc && llvm::cast<clang::BuiltinType>(qual_type)->getKind() == clang::BuiltinType::ObjCId)
+ {
+ if (dynamic_pointee_type)
+ dynamic_pointee_type->SetCompilerType(this, type);
+ return true;
+ }
+ break;
+
+ case clang::Type::ObjCObjectPointer:
+ if (check_objc)
+ {
+ if (dynamic_pointee_type)
+ dynamic_pointee_type->SetCompilerType(getASTContext(), llvm::cast<clang::ObjCObjectPointerType>(qual_type)->getPointeeType());
+ return true;
+ }
+ break;
+
+ case clang::Type::Pointer:
+ pointee_qual_type = llvm::cast<clang::PointerType>(qual_type)->getPointeeType();
+ success = true;
+ break;
+
+ case clang::Type::LValueReference:
+ case clang::Type::RValueReference:
+ pointee_qual_type = llvm::cast<clang::ReferenceType>(qual_type)->getPointeeType();
+ success = true;
+ break;
+
+ case clang::Type::Typedef:
+ return IsPossibleDynamicType (llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(),
+ dynamic_pointee_type,
+ check_cplusplus,
+ check_objc);
+
+ case clang::Type::Auto:
+ return IsPossibleDynamicType (llvm::cast<clang::AutoType>(qual_type)->getDeducedType().getAsOpaquePtr(),
+ dynamic_pointee_type,
+ check_cplusplus,
+ check_objc);
+
+ case clang::Type::Elaborated:
+ return IsPossibleDynamicType (llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(),
+ dynamic_pointee_type,
+ check_cplusplus,
+ check_objc);
+
+ case clang::Type::Paren:
+ return IsPossibleDynamicType (llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(),
+ dynamic_pointee_type,
+ check_cplusplus,
+ check_objc);
+ default:
+ break;
+ }
+
+ if (success)
+ {
+ // Check to make sure what we are pointing too is a possible dynamic C++ type
+ // We currently accept any "void *" (in case we have a class that has been
+ // watered down to an opaque pointer) and virtual C++ classes.
+ const clang::Type::TypeClass pointee_type_class = pointee_qual_type.getCanonicalType()->getTypeClass();
+ switch (pointee_type_class)
+ {
+ case clang::Type::Builtin:
+ switch (llvm::cast<clang::BuiltinType>(pointee_qual_type)->getKind())
+ {
+ case clang::BuiltinType::UnknownAny:
+ case clang::BuiltinType::Void:
+ if (dynamic_pointee_type)
+ dynamic_pointee_type->SetCompilerType(getASTContext(), pointee_qual_type);
+ return true;
+ default:
+ break;
+ }
+ break;
+
+ case clang::Type::Record:
+ if (check_cplusplus)
+ {
+ clang::CXXRecordDecl *cxx_record_decl = pointee_qual_type->getAsCXXRecordDecl();
+ if (cxx_record_decl)
+ {
+ bool is_complete = cxx_record_decl->isCompleteDefinition();
+
+ if (is_complete)
+ success = cxx_record_decl->isDynamicClass();
+ else
+ {
+ ClangASTMetadata *metadata = ClangASTContext::GetMetadata (getASTContext(), cxx_record_decl);
+ if (metadata)
+ success = metadata->GetIsDynamicCXXType();
+ else
+ {
+ is_complete = CompilerType(getASTContext(), pointee_qual_type).GetCompleteType();
+ if (is_complete)
+ success = cxx_record_decl->isDynamicClass();
+ else
+ success = false;
+ }
+ }
+
+ if (success)
+ {
+ if (dynamic_pointee_type)
+ dynamic_pointee_type->SetCompilerType(getASTContext(), pointee_qual_type);
+ return true;
+ }
+ }
+ }
+ break;
+
+ case clang::Type::ObjCObject:
+ case clang::Type::ObjCInterface:
+ if (check_objc)
+ {
+ if (dynamic_pointee_type)
+ dynamic_pointee_type->SetCompilerType(getASTContext(), pointee_qual_type);
+ return true;
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+ if (dynamic_pointee_type)
+ dynamic_pointee_type->Clear();
+ return false;
+}
+
+
+bool
+ClangASTContext::IsScalarType (lldb::opaque_compiler_type_t type)
+{
+ if (!type)
+ return false;
+
+ return (GetTypeInfo (type, nullptr) & eTypeIsScalar) != 0;
+}
+
+bool
+ClangASTContext::IsTypedefType (lldb::opaque_compiler_type_t type)
+{
+ if (!type)
+ return false;
+ return GetQualType(type)->getTypeClass() == clang::Type::Typedef;
+}
+
+bool
+ClangASTContext::IsVoidType (lldb::opaque_compiler_type_t type)
+{
+ if (!type)
+ return false;
+ return GetCanonicalQualType(type)->isVoidType();
+}
+
+bool
+ClangASTContext::SupportsLanguage (lldb::LanguageType language)
+{
+ return ClangASTContextSupportsLanguage(language);
+}
+
+bool
+ClangASTContext::GetCXXClassName (const CompilerType& type, std::string &class_name)
+{
+ if (type)
+ {
+ clang::QualType qual_type (GetCanonicalQualType(type));
+ if (!qual_type.isNull())
+ {
+ clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+ if (cxx_record_decl)
+ {
+ class_name.assign(cxx_record_decl->getIdentifier()->getNameStart());
+ return true;
+ }
+ }
+ }
+ class_name.clear();
+ return false;
+}
+
+
+bool
+ClangASTContext::IsCXXClassType (const CompilerType& type)
+{
+ if (!type)
+ return false;
+
+ clang::QualType qual_type (GetCanonicalQualType(type));
+ if (!qual_type.isNull() && qual_type->getAsCXXRecordDecl() != nullptr)
+ return true;
+ return false;
+}
+
+bool
+ClangASTContext::IsBeingDefined (lldb::opaque_compiler_type_t type)
+{
+ if (!type)
+ return false;
+ clang::QualType qual_type (GetCanonicalQualType(type));
+ const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type);
+ if (tag_type)
+ return tag_type->isBeingDefined();
+ return false;
+}
+
+bool
+ClangASTContext::IsObjCObjectPointerType (const CompilerType& type, CompilerType *class_type_ptr)
+{
+ if (!type)
+ return false;
+
+ clang::QualType qual_type (GetCanonicalQualType(type));
+
+ if (!qual_type.isNull() && qual_type->isObjCObjectPointerType())
+ {
+ if (class_type_ptr)
+ {
+ if (!qual_type->isObjCClassType() &&
+ !qual_type->isObjCIdType())
+ {
+ const clang::ObjCObjectPointerType *obj_pointer_type = llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
+ if (obj_pointer_type == nullptr)
+ class_type_ptr->Clear();
+ else
+ class_type_ptr->SetCompilerType (type.GetTypeSystem(), clang::QualType(obj_pointer_type->getInterfaceType(), 0).getAsOpaquePtr());
+ }
+ }
+ return true;
+ }
+ if (class_type_ptr)
+ class_type_ptr->Clear();
+ return false;
+}
+
+bool
+ClangASTContext::GetObjCClassName (const CompilerType& type, std::string &class_name)
+{
+ if (!type)
+ return false;
+
+ clang::QualType qual_type (GetCanonicalQualType(type));
+
+ const clang::ObjCObjectType *object_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
+ if (object_type)
+ {
+ const clang::ObjCInterfaceDecl *interface = object_type->getInterface();
+ if (interface)
+ {
+ class_name = interface->getNameAsString();
+ return true;
+ }
+ }
+ return false;
+}
+
+
+//----------------------------------------------------------------------
+// Type Completion
+//----------------------------------------------------------------------
+
+bool
+ClangASTContext::GetCompleteType (lldb::opaque_compiler_type_t type)
+{
+ if (!type)
+ return false;
+ const bool allow_completion = true;
+ return GetCompleteQualType (getASTContext(), GetQualType(type), allow_completion);
+}
+
+ConstString
+ClangASTContext::GetTypeName (lldb::opaque_compiler_type_t type)
+{
+ std::string type_name;
+ if (type)
+ {
+ clang::PrintingPolicy printing_policy (getASTContext()->getPrintingPolicy());
+ clang::QualType qual_type(GetQualType(type));
+ printing_policy.SuppressTagKeyword = true;
+ printing_policy.LangOpts.WChar = true;
+ const clang::TypedefType *typedef_type = qual_type->getAs<clang::TypedefType>();
+ if (typedef_type)
+ {
+ const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
+ type_name = typedef_decl->getQualifiedNameAsString();
+ }
+ else
+ {
+ type_name = qual_type.getAsString(printing_policy);
+ }
+ }
+ return ConstString(type_name);
+}
+
+uint32_t
+ClangASTContext::GetTypeInfo (lldb::opaque_compiler_type_t type, CompilerType *pointee_or_element_clang_type)
+{
+ if (!type)
+ return 0;
+
+ if (pointee_or_element_clang_type)
+ pointee_or_element_clang_type->Clear();
+
+ clang::QualType qual_type (GetQualType(type));
+
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Builtin:
+ {
+ const clang::BuiltinType *builtin_type = llvm::dyn_cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal());
+
+ uint32_t builtin_type_flags = eTypeIsBuiltIn | eTypeHasValue;
+ switch (builtin_type->getKind())
+ {
+ case clang::BuiltinType::ObjCId:
+ case clang::BuiltinType::ObjCClass:
+ if (pointee_or_element_clang_type)
+ pointee_or_element_clang_type->SetCompilerType(getASTContext(), getASTContext()->ObjCBuiltinClassTy);
+ builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
+ break;
+
+ case clang::BuiltinType::ObjCSel:
+ if (pointee_or_element_clang_type)
+ pointee_or_element_clang_type->SetCompilerType(getASTContext(), getASTContext()->CharTy);
+ builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
+ break;
+
+ case clang::BuiltinType::Bool:
+ case clang::BuiltinType::Char_U:
+ case clang::BuiltinType::UChar:
+ case clang::BuiltinType::WChar_U:
+ case clang::BuiltinType::Char16:
+ case clang::BuiltinType::Char32:
+ case clang::BuiltinType::UShort:
+ case clang::BuiltinType::UInt:
+ case clang::BuiltinType::ULong:
+ case clang::BuiltinType::ULongLong:
+ case clang::BuiltinType::UInt128:
+ case clang::BuiltinType::Char_S:
+ case clang::BuiltinType::SChar:
+ case clang::BuiltinType::WChar_S:
+ case clang::BuiltinType::Short:
+ case clang::BuiltinType::Int:
+ case clang::BuiltinType::Long:
+ case clang::BuiltinType::LongLong:
+ case clang::BuiltinType::Int128:
+ case clang::BuiltinType::Float:
+ case clang::BuiltinType::Double:
+ case clang::BuiltinType::LongDouble:
+ builtin_type_flags |= eTypeIsScalar;
+ if (builtin_type->isInteger())
+ {
+ builtin_type_flags |= eTypeIsInteger;
+ if (builtin_type->isSignedInteger())
+ builtin_type_flags |= eTypeIsSigned;
+ }
+ else if (builtin_type->isFloatingPoint())
+ builtin_type_flags |= eTypeIsFloat;
+ break;
+ default:
+ break;
+ }
+ return builtin_type_flags;
+ }
+
+ case clang::Type::BlockPointer:
+ if (pointee_or_element_clang_type)
+ pointee_or_element_clang_type->SetCompilerType(getASTContext(), qual_type->getPointeeType());
+ return eTypeIsPointer | eTypeHasChildren | eTypeIsBlock;
+
+ case clang::Type::Complex:
+ {
+ uint32_t complex_type_flags = eTypeIsBuiltIn | eTypeHasValue | eTypeIsComplex;
+ const clang::ComplexType *complex_type = llvm::dyn_cast<clang::ComplexType>(qual_type->getCanonicalTypeInternal());
+ if (complex_type)
+ {
+ clang::QualType complex_element_type (complex_type->getElementType());
+ if (complex_element_type->isIntegerType())
+ complex_type_flags |= eTypeIsFloat;
+ else if (complex_element_type->isFloatingType())
+ complex_type_flags |= eTypeIsInteger;
+ }
+ return complex_type_flags;
+ }
+ break;
+
+ case clang::Type::ConstantArray:
+ case clang::Type::DependentSizedArray:
+ case clang::Type::IncompleteArray:
+ case clang::Type::VariableArray:
+ if (pointee_or_element_clang_type)
+ pointee_or_element_clang_type->SetCompilerType(getASTContext(), llvm::cast<clang::ArrayType>(qual_type.getTypePtr())->getElementType());
+ return eTypeHasChildren | eTypeIsArray;
+
+ case clang::Type::DependentName: return 0;
+ case clang::Type::DependentSizedExtVector: return eTypeHasChildren | eTypeIsVector;
+ case clang::Type::DependentTemplateSpecialization: return eTypeIsTemplate;
+ case clang::Type::Decltype: return 0;
+
+ case clang::Type::Enum:
+ if (pointee_or_element_clang_type)
+ pointee_or_element_clang_type->SetCompilerType(getASTContext(), llvm::cast<clang::EnumType>(qual_type)->getDecl()->getIntegerType());
+ return eTypeIsEnumeration | eTypeHasValue;
+
+ case clang::Type::Auto:
+ return CompilerType (getASTContext(), llvm::cast<clang::AutoType>(qual_type)->getDeducedType()).GetTypeInfo (pointee_or_element_clang_type);
+ case clang::Type::Elaborated:
+ return CompilerType (getASTContext(), llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetTypeInfo (pointee_or_element_clang_type);
+ case clang::Type::Paren:
+ return CompilerType (getASTContext(), llvm::cast<clang::ParenType>(qual_type)->desugar()).GetTypeInfo (pointee_or_element_clang_type);
+
+ case clang::Type::FunctionProto: return eTypeIsFuncPrototype | eTypeHasValue;
+ case clang::Type::FunctionNoProto: return eTypeIsFuncPrototype | eTypeHasValue;
+ case clang::Type::InjectedClassName: return 0;
+
+ case clang::Type::LValueReference:
+ case clang::Type::RValueReference:
+ if (pointee_or_element_clang_type)
+ pointee_or_element_clang_type->SetCompilerType(getASTContext(), llvm::cast<clang::ReferenceType>(qual_type.getTypePtr())->getPointeeType());
+ return eTypeHasChildren | eTypeIsReference | eTypeHasValue;
+
+ case clang::Type::MemberPointer: return eTypeIsPointer | eTypeIsMember | eTypeHasValue;
+
+ case clang::Type::ObjCObjectPointer:
+ if (pointee_or_element_clang_type)
+ pointee_or_element_clang_type->SetCompilerType(getASTContext(), qual_type->getPointeeType());
+ return eTypeHasChildren | eTypeIsObjC | eTypeIsClass | eTypeIsPointer | eTypeHasValue;
+
+ case clang::Type::ObjCObject: return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
+ case clang::Type::ObjCInterface: return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
+
+ case clang::Type::Pointer:
+ if (pointee_or_element_clang_type)
+ pointee_or_element_clang_type->SetCompilerType(getASTContext(), qual_type->getPointeeType());
+ return eTypeHasChildren | eTypeIsPointer | eTypeHasValue;
+
+ case clang::Type::Record:
+ if (qual_type->getAsCXXRecordDecl())
+ return eTypeHasChildren | eTypeIsClass | eTypeIsCPlusPlus;
+ else
+ return eTypeHasChildren | eTypeIsStructUnion;
+ break;
+ case clang::Type::SubstTemplateTypeParm: return eTypeIsTemplate;
+ case clang::Type::TemplateTypeParm: return eTypeIsTemplate;
+ case clang::Type::TemplateSpecialization: return eTypeIsTemplate;
+
+ case clang::Type::Typedef:
+ return eTypeIsTypedef | CompilerType (getASTContext(), llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetTypeInfo (pointee_or_element_clang_type);
+ case clang::Type::TypeOfExpr: return 0;
+ case clang::Type::TypeOf: return 0;
+ case clang::Type::UnresolvedUsing: return 0;
+
+ case clang::Type::ExtVector:
+ case clang::Type::Vector:
+ {
+ uint32_t vector_type_flags = eTypeHasChildren | eTypeIsVector;
+ const clang::VectorType *vector_type = llvm::dyn_cast<clang::VectorType>(qual_type->getCanonicalTypeInternal());
+ if (vector_type)
+ {
+ if (vector_type->isIntegerType())
+ vector_type_flags |= eTypeIsFloat;
+ else if (vector_type->isFloatingType())
+ vector_type_flags |= eTypeIsInteger;
+ }
+ return vector_type_flags;
+ }
+ default: return 0;
+ }
+ return 0;
+}
+
+
+
+lldb::LanguageType
+ClangASTContext::GetMinimumLanguage (lldb::opaque_compiler_type_t type)
+{
+ if (!type)
+ return lldb::eLanguageTypeC;
+
+ // If the type is a reference, then resolve it to what it refers to first:
+ clang::QualType qual_type (GetCanonicalQualType(type).getNonReferenceType());
+ if (qual_type->isAnyPointerType())
+ {
+ if (qual_type->isObjCObjectPointerType())
+ return lldb::eLanguageTypeObjC;
+
+ clang::QualType pointee_type (qual_type->getPointeeType());
+ if (pointee_type->getPointeeCXXRecordDecl() != nullptr)
+ return lldb::eLanguageTypeC_plus_plus;
+ if (pointee_type->isObjCObjectOrInterfaceType())
+ return lldb::eLanguageTypeObjC;
+ if (pointee_type->isObjCClassType())
+ return lldb::eLanguageTypeObjC;
+ if (pointee_type.getTypePtr() == getASTContext()->ObjCBuiltinIdTy.getTypePtr())
+ return lldb::eLanguageTypeObjC;
+ }
+ else
+ {
+ if (qual_type->isObjCObjectOrInterfaceType())
+ return lldb::eLanguageTypeObjC;
+ if (qual_type->getAsCXXRecordDecl())
+ return lldb::eLanguageTypeC_plus_plus;
+ switch (qual_type->getTypeClass())
+ {
+ default:
+ break;
+ case clang::Type::Builtin:
+ switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind())
+ {
+ default:
+ case clang::BuiltinType::Void:
+ case clang::BuiltinType::Bool:
+ case clang::BuiltinType::Char_U:
+ case clang::BuiltinType::UChar:
+ case clang::BuiltinType::WChar_U:
+ case clang::BuiltinType::Char16:
+ case clang::BuiltinType::Char32:
+ case clang::BuiltinType::UShort:
+ case clang::BuiltinType::UInt:
+ case clang::BuiltinType::ULong:
+ case clang::BuiltinType::ULongLong:
+ case clang::BuiltinType::UInt128:
+ case clang::BuiltinType::Char_S:
+ case clang::BuiltinType::SChar:
+ case clang::BuiltinType::WChar_S:
+ case clang::BuiltinType::Short:
+ case clang::BuiltinType::Int:
+ case clang::BuiltinType::Long:
+ case clang::BuiltinType::LongLong:
+ case clang::BuiltinType::Int128:
+ case clang::BuiltinType::Float:
+ case clang::BuiltinType::Double:
+ case clang::BuiltinType::LongDouble:
+ break;
+
+ case clang::BuiltinType::NullPtr:
+ return eLanguageTypeC_plus_plus;
+
+ case clang::BuiltinType::ObjCId:
+ case clang::BuiltinType::ObjCClass:
+ case clang::BuiltinType::ObjCSel:
+ return eLanguageTypeObjC;
+
+ case clang::BuiltinType::Dependent:
+ case clang::BuiltinType::Overload:
+ case clang::BuiltinType::BoundMember:
+ case clang::BuiltinType::UnknownAny:
+ break;
+ }
+ break;
+ case clang::Type::Typedef:
+ return CompilerType(getASTContext(), llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetMinimumLanguage();
+ }
+ }
+ return lldb::eLanguageTypeC;
+}
+
+lldb::TypeClass
+ClangASTContext::GetTypeClass (lldb::opaque_compiler_type_t type)
+{
+ if (!type)
+ return lldb::eTypeClassInvalid;
+
+ clang::QualType qual_type(GetQualType(type));
+
+ switch (qual_type->getTypeClass())
+ {
+ case clang::Type::UnaryTransform: break;
+ case clang::Type::FunctionNoProto: return lldb::eTypeClassFunction;
+ case clang::Type::FunctionProto: return lldb::eTypeClassFunction;
+ case clang::Type::IncompleteArray: return lldb::eTypeClassArray;
+ case clang::Type::VariableArray: return lldb::eTypeClassArray;
+ case clang::Type::ConstantArray: return lldb::eTypeClassArray;
+ case clang::Type::DependentSizedArray: return lldb::eTypeClassArray;
+ case clang::Type::DependentSizedExtVector: return lldb::eTypeClassVector;
+ case clang::Type::ExtVector: return lldb::eTypeClassVector;
+ case clang::Type::Vector: return lldb::eTypeClassVector;
+ case clang::Type::Builtin: return lldb::eTypeClassBuiltin;
+ case clang::Type::ObjCObjectPointer: return lldb::eTypeClassObjCObjectPointer;
+ case clang::Type::BlockPointer: return lldb::eTypeClassBlockPointer;
+ case clang::Type::Pointer: return lldb::eTypeClassPointer;
+ case clang::Type::LValueReference: return lldb::eTypeClassReference;
+ case clang::Type::RValueReference: return lldb::eTypeClassReference;
+ case clang::Type::MemberPointer: return lldb::eTypeClassMemberPointer;
+ case clang::Type::Complex:
+ if (qual_type->isComplexType())
+ return lldb::eTypeClassComplexFloat;
+ else
+ return lldb::eTypeClassComplexInteger;
+ case clang::Type::ObjCObject: return lldb::eTypeClassObjCObject;
+ case clang::Type::ObjCInterface: return lldb::eTypeClassObjCInterface;
+ case clang::Type::Record:
+ {
+ const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
+ const clang::RecordDecl *record_decl = record_type->getDecl();
+ if (record_decl->isUnion())
+ return lldb::eTypeClassUnion;
+ else if (record_decl->isStruct())
+ return lldb::eTypeClassStruct;
+ else
+ return lldb::eTypeClassClass;
+ }
+ break;
+ case clang::Type::Enum: return lldb::eTypeClassEnumeration;
+ case clang::Type::Typedef: return lldb::eTypeClassTypedef;
+ case clang::Type::UnresolvedUsing: break;
+ case clang::Type::Paren:
+ return CompilerType(getASTContext(), llvm::cast<clang::ParenType>(qual_type)->desugar()).GetTypeClass();
+ case clang::Type::Auto:
+ return CompilerType(getASTContext(), llvm::cast<clang::AutoType>(qual_type)->getDeducedType()).GetTypeClass();
+ case clang::Type::Elaborated:
+ return CompilerType(getASTContext(), llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetTypeClass();
+
+ case clang::Type::Attributed: break;
+ case clang::Type::TemplateTypeParm: break;
+ case clang::Type::SubstTemplateTypeParm: break;
+ case clang::Type::SubstTemplateTypeParmPack:break;
+ case clang::Type::InjectedClassName: break;
+ case clang::Type::DependentName: break;
+ case clang::Type::DependentTemplateSpecialization: break;
+ case clang::Type::PackExpansion: break;
+
+ case clang::Type::TypeOfExpr: break;
+ case clang::Type::TypeOf: break;
+ case clang::Type::Decltype: break;
+ case clang::Type::TemplateSpecialization: break;
+ case clang::Type::Atomic: break;
+
+ // pointer type decayed from an array or function type.
+ case clang::Type::Decayed: break;
+ case clang::Type::Adjusted: break;
+ }
+ // We don't know hot to display this type...
+ return lldb::eTypeClassOther;
+
+}
+
+unsigned
+ClangASTContext::GetTypeQualifiers(lldb::opaque_compiler_type_t type)
+{
+ if (type)
+ return GetQualType(type).getQualifiers().getCVRQualifiers();
+ return 0;
+}
+
+//----------------------------------------------------------------------
+// Creating related types
+//----------------------------------------------------------------------
+
+CompilerType
+ClangASTContext::GetArrayElementType (lldb::opaque_compiler_type_t type, uint64_t *stride)
+{
+ if (type)
+ {
+ clang::QualType qual_type(GetCanonicalQualType(type));
+
+ const clang::Type *array_eletype = qual_type.getTypePtr()->getArrayElementTypeNoTypeQual();
+
+ if (!array_eletype)
+ return CompilerType();
+
+ CompilerType element_type (getASTContext(), array_eletype->getCanonicalTypeUnqualified());
+
+ // TODO: the real stride will be >= this value.. find the real one!
+ if (stride)
+ *stride = element_type.GetByteSize(nullptr);
+
+ return element_type;
+
+ }
+ return CompilerType();
+}
+
+CompilerType
+ClangASTContext::GetCanonicalType (lldb::opaque_compiler_type_t type)
+{
+ if (type)
+ return CompilerType (getASTContext(), GetCanonicalQualType(type));
+ return CompilerType();
+}
+
+static clang::QualType
+GetFullyUnqualifiedType_Impl (clang::ASTContext *ast, clang::QualType qual_type)
+{
+ if (qual_type->isPointerType())
+ qual_type = ast->getPointerType(GetFullyUnqualifiedType_Impl(ast, qual_type->getPointeeType()));
+ else
+ qual_type = qual_type.getUnqualifiedType();
+ qual_type.removeLocalConst();
+ qual_type.removeLocalRestrict();
+ qual_type.removeLocalVolatile();
+ return qual_type;
+}
+
+CompilerType
+ClangASTContext::GetFullyUnqualifiedType (lldb::opaque_compiler_type_t type)
+{
+ if (type)
+ return CompilerType(getASTContext(), GetFullyUnqualifiedType_Impl(getASTContext(), GetQualType(type)));
+ return CompilerType();
+}
+
+
+int
+ClangASTContext::GetFunctionArgumentCount (lldb::opaque_compiler_type_t type)
+{
+ if (type)
+ {
+ const clang::FunctionProtoType* func = llvm::dyn_cast<clang::FunctionProtoType>(GetCanonicalQualType(type));
+ if (func)
+ return func->getNumParams();
+ }
+ return -1;
+}
+
+CompilerType
+ClangASTContext::GetFunctionArgumentTypeAtIndex (lldb::opaque_compiler_type_t type, size_t idx)
+{
+ if (type)
+ {
+ const clang::FunctionProtoType* func = llvm::dyn_cast<clang::FunctionProtoType>(GetQualType(type));
+ if (func)
+ {
+ const uint32_t num_args = func->getNumParams();
+ if (idx < num_args)
+ return CompilerType(getASTContext(), func->getParamType(idx));
+ }
+ }
+ return CompilerType();
+}
+
+CompilerType
+ClangASTContext::GetFunctionReturnType (lldb::opaque_compiler_type_t type)
+{
+ if (type)
+ {
+ clang::QualType qual_type(GetQualType(type));
+ const clang::FunctionProtoType* func = llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
+ if (func)
+ return CompilerType(getASTContext(), func->getReturnType());
+ }
+ return CompilerType();
+}
+
+size_t
+ClangASTContext::GetNumMemberFunctions (lldb::opaque_compiler_type_t type)
+{
+ size_t num_functions = 0;
+ if (type)
+ {
+ clang::QualType qual_type(GetCanonicalQualType(type));
+ switch (qual_type->getTypeClass()) {
+ case clang::Type::Record:
+ if (GetCompleteQualType (getASTContext(), qual_type))
+ {
+ const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
+ const clang::RecordDecl *record_decl = record_type->getDecl();
+ assert(record_decl);
+ const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
+ if (cxx_record_decl)
+ num_functions = std::distance(cxx_record_decl->method_begin(), cxx_record_decl->method_end());
+ }
+ break;
+
+ case clang::Type::ObjCObjectPointer:
+ if (GetCompleteType(type))
+ {
+ const clang::ObjCObjectPointerType *objc_class_type = qual_type->getAsObjCInterfacePointerType();
+ if (objc_class_type)
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterfaceDecl();
+ if (class_interface_decl)
+ num_functions = std::distance(class_interface_decl->meth_begin(), class_interface_decl->meth_end());
+ }
+ }
+ break;
+
+ case clang::Type::ObjCObject:
+ case clang::Type::ObjCInterface:
+ if (GetCompleteType(type))
+ {
+ const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
+ if (objc_class_type)
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+ if (class_interface_decl)
+ num_functions = std::distance(class_interface_decl->meth_begin(), class_interface_decl->meth_end());
+ }
+ }
+ break;
+
+
+ case clang::Type::Typedef:
+ return CompilerType (getASTContext(), llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumMemberFunctions();
+
+ case clang::Type::Auto:
+ return CompilerType (getASTContext(), llvm::cast<clang::AutoType>(qual_type)->getDeducedType()).GetNumMemberFunctions();
+
+ case clang::Type::Elaborated:
+ return CompilerType (getASTContext(), llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetNumMemberFunctions();
+
+ case clang::Type::Paren:
+ return CompilerType (getASTContext(), llvm::cast<clang::ParenType>(qual_type)->desugar()).GetNumMemberFunctions();
+
+ default:
+ break;
+ }
+ }
+ return num_functions;
+}
+
+TypeMemberFunctionImpl
+ClangASTContext::GetMemberFunctionAtIndex (lldb::opaque_compiler_type_t type, size_t idx)
+{
+ std::string name;
+ MemberFunctionKind kind(MemberFunctionKind::eMemberFunctionKindUnknown);
+ CompilerType clang_type;
+ CompilerDecl clang_decl;
+ if (type)
+ {
+ clang::QualType qual_type(GetCanonicalQualType(type));
+ switch (qual_type->getTypeClass()) {
+ case clang::Type::Record:
+ if (GetCompleteQualType (getASTContext(), qual_type))
+ {
+ const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
+ const clang::RecordDecl *record_decl = record_type->getDecl();
+ assert(record_decl);
+ const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
+ if (cxx_record_decl)
+ {
+ auto method_iter = cxx_record_decl->method_begin();
+ auto method_end = cxx_record_decl->method_end();
+ if (idx < static_cast<size_t>(std::distance(method_iter, method_end)))
+ {
+ std::advance(method_iter, idx);
+ clang::CXXMethodDecl *cxx_method_decl = method_iter->getCanonicalDecl();
+ if (cxx_method_decl)
+ {
+ name = cxx_method_decl->getDeclName().getAsString();
+ if (cxx_method_decl->isStatic())
+ kind = lldb::eMemberFunctionKindStaticMethod;
+ else if (llvm::isa<clang::CXXConstructorDecl>(cxx_method_decl))
+ kind = lldb::eMemberFunctionKindConstructor;
+ else if (llvm::isa<clang::CXXDestructorDecl>(cxx_method_decl))
+ kind = lldb::eMemberFunctionKindDestructor;
+ else
+ kind = lldb::eMemberFunctionKindInstanceMethod;
+ clang_type = CompilerType(this, cxx_method_decl->getType().getAsOpaquePtr());
+ clang_decl = CompilerDecl(this, cxx_method_decl);
+ }
+ }
+ }
+ }
+ break;
+
+ case clang::Type::ObjCObjectPointer:
+ if (GetCompleteType(type))
+ {
+ const clang::ObjCObjectPointerType *objc_class_type = qual_type->getAsObjCInterfacePointerType();
+ if (objc_class_type)
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterfaceDecl();
+ if (class_interface_decl)
+ {
+ auto method_iter = class_interface_decl->meth_begin();
+ auto method_end = class_interface_decl->meth_end();
+ if (idx < static_cast<size_t>(std::distance(method_iter, method_end)))
+ {
+ std::advance(method_iter, idx);
+ clang::ObjCMethodDecl *objc_method_decl = method_iter->getCanonicalDecl();
+ if (objc_method_decl)
+ {
+ clang_decl = CompilerDecl(this, objc_method_decl);
+ name = objc_method_decl->getSelector().getAsString();
+ if (objc_method_decl->isClassMethod())
+ kind = lldb::eMemberFunctionKindStaticMethod;
+ else
+ kind = lldb::eMemberFunctionKindInstanceMethod;
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case clang::Type::ObjCObject:
+ case clang::Type::ObjCInterface:
+ if (GetCompleteType(type))
+ {
+ const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
+ if (objc_class_type)
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+ if (class_interface_decl)
+ {
+ auto method_iter = class_interface_decl->meth_begin();
+ auto method_end = class_interface_decl->meth_end();
+ if (idx < static_cast<size_t>(std::distance(method_iter, method_end)))
+ {
+ std::advance(method_iter, idx);
+ clang::ObjCMethodDecl *objc_method_decl = method_iter->getCanonicalDecl();
+ if (objc_method_decl)
+ {
+ clang_decl = CompilerDecl(this, objc_method_decl);
+ name = objc_method_decl->getSelector().getAsString();
+ if (objc_method_decl->isClassMethod())
+ kind = lldb::eMemberFunctionKindStaticMethod;
+ else
+ kind = lldb::eMemberFunctionKindInstanceMethod;
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case clang::Type::Typedef:
+ return GetMemberFunctionAtIndex(llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), idx);
+
+ case clang::Type::Auto:
+ return GetMemberFunctionAtIndex(llvm::cast<clang::AutoType>(qual_type)->getDeducedType().getAsOpaquePtr(), idx);
+
+ case clang::Type::Elaborated:
+ return GetMemberFunctionAtIndex(llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(), idx);
+
+ case clang::Type::Paren:
+ return GetMemberFunctionAtIndex(llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(), idx);
+
+ default:
+ break;
+ }
+ }
+
+ if (kind == eMemberFunctionKindUnknown)
+ return TypeMemberFunctionImpl();
+ else
+ return TypeMemberFunctionImpl(clang_type, clang_decl, name, kind);
+}
+
+CompilerType
+ClangASTContext::GetNonReferenceType (lldb::opaque_compiler_type_t type)
+{
+ if (type)
+ return CompilerType(getASTContext(), GetQualType(type).getNonReferenceType());
+ return CompilerType();
+}
+
+CompilerType
+ClangASTContext::CreateTypedefType (const CompilerType& type,
+ const char *typedef_name,
+ const CompilerDeclContext &compiler_decl_ctx)
+{
+ if (type && typedef_name && typedef_name[0])
+ {
+ ClangASTContext *ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
+ if (!ast)
+ return CompilerType();
+ clang::ASTContext* clang_ast = ast->getASTContext();
+ clang::QualType qual_type (GetQualType(type));
+
+ clang::DeclContext *decl_ctx = ClangASTContext::DeclContextGetAsDeclContext(compiler_decl_ctx);
+ if (decl_ctx == nullptr)
+ decl_ctx = ast->getASTContext()->getTranslationUnitDecl();
+
+ clang::TypedefDecl *decl = clang::TypedefDecl::Create (*clang_ast,
+ decl_ctx,
+ clang::SourceLocation(),
+ clang::SourceLocation(),
+ &clang_ast->Idents.get(typedef_name),
+ clang_ast->getTrivialTypeSourceInfo(qual_type));
+
+ decl->setAccess(clang::AS_public); // TODO respect proper access specifier
+
+ // Get a uniqued clang::QualType for the typedef decl type
+ return CompilerType (clang_ast, clang_ast->getTypedefType (decl));
+ }
+ return CompilerType();
+
+}
+
+CompilerType
+ClangASTContext::GetPointeeType (lldb::opaque_compiler_type_t type)
+{
+ if (type)
+ {
+ clang::QualType qual_type(GetQualType(type));
+ return CompilerType (getASTContext(), qual_type.getTypePtr()->getPointeeType());
+ }
+ return CompilerType();
+}
+
+CompilerType
+ClangASTContext::GetPointerType (lldb::opaque_compiler_type_t type)
+{
+ if (type)
+ {
+ clang::QualType qual_type (GetQualType(type));
+
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::ObjCObject:
+ case clang::Type::ObjCInterface:
+ return CompilerType(getASTContext(), getASTContext()->getObjCObjectPointerType(qual_type));
+
+ default:
+ return CompilerType(getASTContext(), getASTContext()->getPointerType(qual_type));
+ }
+ }
+ return CompilerType();
+}
+
+
+CompilerType
+ClangASTContext::GetLValueReferenceType (lldb::opaque_compiler_type_t type)
+{
+ if (type)
+ return CompilerType(this, getASTContext()->getLValueReferenceType(GetQualType(type)).getAsOpaquePtr());
+ else
+ return CompilerType();
+}
+
+CompilerType
+ClangASTContext::GetRValueReferenceType (lldb::opaque_compiler_type_t type)
+{
+ if (type)
+ return CompilerType(this, getASTContext()->getRValueReferenceType(GetQualType(type)).getAsOpaquePtr());
+ else
+ return CompilerType();
+}
+
+CompilerType
+ClangASTContext::AddConstModifier (lldb::opaque_compiler_type_t type)
+{
+ if (type)
+ {
+ clang::QualType result(GetQualType(type));
+ result.addConst();
+ return CompilerType (this, result.getAsOpaquePtr());
+ }
+ return CompilerType();
+}
+
+CompilerType
+ClangASTContext::AddVolatileModifier (lldb::opaque_compiler_type_t type)
+{
+ if (type)
+ {
+ clang::QualType result(GetQualType(type));
+ result.addVolatile();
+ return CompilerType (this, result.getAsOpaquePtr());
+ }
+ return CompilerType();
+
+}
+
+CompilerType
+ClangASTContext::AddRestrictModifier (lldb::opaque_compiler_type_t type)
+{
+ if (type)
+ {
+ clang::QualType result(GetQualType(type));
+ result.addRestrict();
+ return CompilerType (this, result.getAsOpaquePtr());
+ }
+ return CompilerType();
+
+}
+
+CompilerType
+ClangASTContext::CreateTypedef (lldb::opaque_compiler_type_t type, const char *typedef_name, const CompilerDeclContext &compiler_decl_ctx)
+{
+ if (type)
+ {
+ clang::ASTContext* clang_ast = getASTContext();
+ clang::QualType qual_type (GetQualType(type));
+
+ clang::DeclContext *decl_ctx = ClangASTContext::DeclContextGetAsDeclContext(compiler_decl_ctx);
+ if (decl_ctx == nullptr)
+ decl_ctx = getASTContext()->getTranslationUnitDecl();
+
+ clang::TypedefDecl *decl = clang::TypedefDecl::Create (*clang_ast,
+ decl_ctx,
+ clang::SourceLocation(),
+ clang::SourceLocation(),
+ &clang_ast->Idents.get(typedef_name),
+ clang_ast->getTrivialTypeSourceInfo(qual_type));
+
+ decl->setAccess(clang::AS_public); // TODO respect proper access specifier
+
+ // Get a uniqued clang::QualType for the typedef decl type
+ return CompilerType (this, clang_ast->getTypedefType (decl).getAsOpaquePtr());
+
+ }
+ return CompilerType();
+
+}
+
+CompilerType
+ClangASTContext::GetTypedefedType (lldb::opaque_compiler_type_t type)
+{
+ if (type)
+ {
+ const clang::TypedefType *typedef_type = llvm::dyn_cast<clang::TypedefType>(GetQualType(type));
+ if (typedef_type)
+ return CompilerType (getASTContext(), typedef_type->getDecl()->getUnderlyingType());
+ }
+ return CompilerType();
+}
+
+CompilerType
+ClangASTContext::RemoveFastQualifiers (const CompilerType& type)
+{
+ if (IsClangType(type))
+ {
+ clang::QualType qual_type(GetQualType(type));
+ qual_type.getQualifiers().removeFastQualifiers();
+ return CompilerType (type.GetTypeSystem(), qual_type.getAsOpaquePtr());
+ }
+ return type;
+}
+
+
+//----------------------------------------------------------------------
+// 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)
+{
+ if (GetCompleteType (type))
+ {
+ clang::QualType qual_type(GetCanonicalQualType(type));
+ switch (qual_type->getTypeClass())
+ {
+ case clang::Type::ObjCInterface:
+ case clang::Type::ObjCObject:
+ {
+ ExecutionContext exe_ctx (exe_scope);
+ Process *process = exe_ctx.GetProcessPtr();
+ if (process)
+ {
+ ObjCLanguageRuntime *objc_runtime = process->GetObjCLanguageRuntime();
+ if (objc_runtime)
+ {
+ uint64_t bit_size = 0;
+ if (objc_runtime->GetTypeBitSize(CompilerType(getASTContext(), qual_type), bit_size))
+ return bit_size;
+ }
+ }
+ else
+ {
+ static bool g_printed = false;
+ if (!g_printed)
+ {
+ StreamString s;
+ DumpTypeDescription(type, &s);
+
+ llvm::outs() << "warning: trying to determine the size of type ";
+ llvm::outs() << s.GetString() << "\n";
+ llvm::outs() << "without a valid ExecutionContext. this is not reliable. please file a bug against LLDB.\n";
+ llvm::outs() << "backtrace:\n";
+ llvm::sys::PrintStackTrace(llvm::outs());
+ llvm::outs() << "\n";
+ g_printed = true;
+ }
+ }
+ }
+ // fallthrough
+ default:
+ const uint32_t bit_size = getASTContext()->getTypeSize (qual_type);
+ if (bit_size == 0)
+ {
+ if (qual_type->isIncompleteArrayType())
+ return getASTContext()->getTypeSize (qual_type->getArrayElementTypeNoTypeQual()->getCanonicalTypeUnqualified());
+ }
+ if (qual_type->isObjCObjectOrInterfaceType())
+ return bit_size + getASTContext()->getTypeSize(getASTContext()->ObjCBuiltinClassTy);
+ return bit_size;
+ }
+ }
+ return 0;
+}
+
+size_t
+ClangASTContext::GetTypeBitAlign (lldb::opaque_compiler_type_t type)
+{
+ if (GetCompleteType(type))
+ return getASTContext()->getTypeAlign(GetQualType(type));
+ return 0;
+}
+
+
+lldb::Encoding
+ClangASTContext::GetEncoding (lldb::opaque_compiler_type_t type, uint64_t &count)
+{
+ if (!type)
+ return lldb::eEncodingInvalid;
+
+ count = 1;
+ clang::QualType qual_type(GetCanonicalQualType(type));
+
+ switch (qual_type->getTypeClass())
+ {
+ case clang::Type::UnaryTransform:
+ break;
+
+ case clang::Type::FunctionNoProto:
+ case clang::Type::FunctionProto:
+ break;
+
+ case clang::Type::IncompleteArray:
+ case clang::Type::VariableArray:
+ break;
+
+ case clang::Type::ConstantArray:
+ break;
+
+ case clang::Type::ExtVector:
+ case clang::Type::Vector:
+ // TODO: Set this to more than one???
+ break;
+
+ case clang::Type::Builtin:
+ switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind())
+ {
+ case clang::BuiltinType::Void:
+ break;
+
+ case clang::BuiltinType::Bool:
+ case clang::BuiltinType::Char_S:
+ case clang::BuiltinType::SChar:
+ case clang::BuiltinType::WChar_S:
+ case clang::BuiltinType::Char16:
+ case clang::BuiltinType::Char32:
+ case clang::BuiltinType::Short:
+ case clang::BuiltinType::Int:
+ case clang::BuiltinType::Long:
+ case clang::BuiltinType::LongLong:
+ case clang::BuiltinType::Int128: return lldb::eEncodingSint;
+
+ case clang::BuiltinType::Char_U:
+ case clang::BuiltinType::UChar:
+ case clang::BuiltinType::WChar_U:
+ case clang::BuiltinType::UShort:
+ case clang::BuiltinType::UInt:
+ case clang::BuiltinType::ULong:
+ case clang::BuiltinType::ULongLong:
+ case clang::BuiltinType::UInt128: return lldb::eEncodingUint;
+
+ case clang::BuiltinType::Half:
+ case clang::BuiltinType::Float:
+ case clang::BuiltinType::Double:
+ case clang::BuiltinType::LongDouble: return lldb::eEncodingIEEE754;
+
+ case clang::BuiltinType::ObjCClass:
+ case clang::BuiltinType::ObjCId:
+ case clang::BuiltinType::ObjCSel: return lldb::eEncodingUint;
+
+ case clang::BuiltinType::NullPtr: return lldb::eEncodingUint;
+
+ case clang::BuiltinType::Kind::ARCUnbridgedCast:
+ case clang::BuiltinType::Kind::BoundMember:
+ case clang::BuiltinType::Kind::BuiltinFn:
+ case clang::BuiltinType::Kind::Dependent:
+ case clang::BuiltinType::Kind::OCLClkEvent:
+ case clang::BuiltinType::Kind::OCLEvent:
+ case clang::BuiltinType::Kind::OCLImage1d:
+ case clang::BuiltinType::Kind::OCLImage1dArray:
+ case clang::BuiltinType::Kind::OCLImage1dBuffer:
+ case clang::BuiltinType::Kind::OCLImage2d:
+ case clang::BuiltinType::Kind::OCLImage2dArray:
+ case clang::BuiltinType::Kind::OCLImage2dArrayDepth:
+ case clang::BuiltinType::Kind::OCLImage2dArrayMSAA:
+ case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepth:
+ case clang::BuiltinType::Kind::OCLImage2dDepth:
+ case clang::BuiltinType::Kind::OCLImage2dMSAA:
+ case clang::BuiltinType::Kind::OCLImage2dMSAADepth:
+ case clang::BuiltinType::Kind::OCLImage3d:
+ case clang::BuiltinType::Kind::OCLQueue:
+ case clang::BuiltinType::Kind::OCLNDRange:
+ case clang::BuiltinType::Kind::OCLReserveID:
+ case clang::BuiltinType::Kind::OCLSampler:
+ case clang::BuiltinType::Kind::OMPArraySection:
+ case clang::BuiltinType::Kind::Overload:
+ case clang::BuiltinType::Kind::PseudoObject:
+ case clang::BuiltinType::Kind::UnknownAny:
+ break;
+ }
+ break;
+ // All pointer types are represented as unsigned integer encodings.
+ // We may nee to add a eEncodingPointer if we ever need to know the
+ // difference
+ case clang::Type::ObjCObjectPointer:
+ case clang::Type::BlockPointer:
+ case clang::Type::Pointer:
+ case clang::Type::LValueReference:
+ case clang::Type::RValueReference:
+ case clang::Type::MemberPointer: return lldb::eEncodingUint;
+ case clang::Type::Complex:
+ {
+ lldb::Encoding encoding = lldb::eEncodingIEEE754;
+ if (qual_type->isComplexType())
+ encoding = lldb::eEncodingIEEE754;
+ else
+ {
+ const clang::ComplexType *complex_type = qual_type->getAsComplexIntegerType();
+ if (complex_type)
+ encoding = CompilerType(getASTContext(), complex_type->getElementType()).GetEncoding(count);
+ else
+ encoding = lldb::eEncodingSint;
+ }
+ count = 2;
+ return encoding;
+ }
+
+ case clang::Type::ObjCInterface: break;
+ case clang::Type::Record: break;
+ case clang::Type::Enum: return lldb::eEncodingSint;
+ case clang::Type::Typedef:
+ return CompilerType(getASTContext(), llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetEncoding(count);
+
+ case clang::Type::Auto:
+ return CompilerType(getASTContext(), llvm::cast<clang::AutoType>(qual_type)->getDeducedType()).GetEncoding(count);
+
+ case clang::Type::Elaborated:
+ return CompilerType(getASTContext(), llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetEncoding(count);
+
+ case clang::Type::Paren:
+ return CompilerType(getASTContext(), llvm::cast<clang::ParenType>(qual_type)->desugar()).GetEncoding(count);
+
+ case clang::Type::DependentSizedArray:
+ case clang::Type::DependentSizedExtVector:
+ case clang::Type::UnresolvedUsing:
+ case clang::Type::Attributed:
+ case clang::Type::TemplateTypeParm:
+ case clang::Type::SubstTemplateTypeParm:
+ case clang::Type::SubstTemplateTypeParmPack:
+ case clang::Type::InjectedClassName:
+ case clang::Type::DependentName:
+ case clang::Type::DependentTemplateSpecialization:
+ case clang::Type::PackExpansion:
+ case clang::Type::ObjCObject:
+
+ case clang::Type::TypeOfExpr:
+ case clang::Type::TypeOf:
+ case clang::Type::Decltype:
+ case clang::Type::TemplateSpecialization:
+ case clang::Type::Atomic:
+ case clang::Type::Adjusted:
+ break;
+
+ // pointer type decayed from an array or function type.
+ case clang::Type::Decayed:
+ break;
+ }
+ count = 0;
+ return lldb::eEncodingInvalid;
+}
+
+lldb::Format
+ClangASTContext::GetFormat (lldb::opaque_compiler_type_t type)
+{
+ if (!type)
+ return lldb::eFormatDefault;
+
+ clang::QualType qual_type(GetCanonicalQualType(type));
+
+ switch (qual_type->getTypeClass())
+ {
+ case clang::Type::UnaryTransform:
+ break;
+
+ case clang::Type::FunctionNoProto:
+ case clang::Type::FunctionProto:
+ break;
+
+ case clang::Type::IncompleteArray:
+ case clang::Type::VariableArray:
+ break;
+
+ case clang::Type::ConstantArray:
+ return lldb::eFormatVoid; // no value
+
+ case clang::Type::ExtVector:
+ case clang::Type::Vector:
+ break;
+
+ case clang::Type::Builtin:
+ switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind())
+ {
+ //default: assert(0 && "Unknown builtin type!");
+ case clang::BuiltinType::UnknownAny:
+ case clang::BuiltinType::Void:
+ case clang::BuiltinType::BoundMember:
+ break;
+
+ case clang::BuiltinType::Bool: return lldb::eFormatBoolean;
+ case clang::BuiltinType::Char_S:
+ case clang::BuiltinType::SChar:
+ case clang::BuiltinType::WChar_S:
+ case clang::BuiltinType::Char_U:
+ case clang::BuiltinType::UChar:
+ case clang::BuiltinType::WChar_U: return lldb::eFormatChar;
+ case clang::BuiltinType::Char16: return lldb::eFormatUnicode16;
+ case clang::BuiltinType::Char32: return lldb::eFormatUnicode32;
+ case clang::BuiltinType::UShort: return lldb::eFormatUnsigned;
+ case clang::BuiltinType::Short: return lldb::eFormatDecimal;
+ case clang::BuiltinType::UInt: return lldb::eFormatUnsigned;
+ case clang::BuiltinType::Int: return lldb::eFormatDecimal;
+ case clang::BuiltinType::ULong: return lldb::eFormatUnsigned;
+ case clang::BuiltinType::Long: return lldb::eFormatDecimal;
+ case clang::BuiltinType::ULongLong: return lldb::eFormatUnsigned;
+ case clang::BuiltinType::LongLong: return lldb::eFormatDecimal;
+ case clang::BuiltinType::UInt128: return lldb::eFormatUnsigned;
+ case clang::BuiltinType::Int128: return lldb::eFormatDecimal;
+ case clang::BuiltinType::Half:
+ case clang::BuiltinType::Float:
+ case clang::BuiltinType::Double:
+ case clang::BuiltinType::LongDouble: return lldb::eFormatFloat;
+ default:
+ return lldb::eFormatHex;
+ }
+ break;
+ case clang::Type::ObjCObjectPointer: return lldb::eFormatHex;
+ case clang::Type::BlockPointer: return lldb::eFormatHex;
+ case clang::Type::Pointer: return lldb::eFormatHex;
+ case clang::Type::LValueReference:
+ case clang::Type::RValueReference: return lldb::eFormatHex;
+ case clang::Type::MemberPointer: break;
+ case clang::Type::Complex:
+ {
+ if (qual_type->isComplexType())
+ return lldb::eFormatComplex;
+ else
+ return lldb::eFormatComplexInteger;
+ }
+ case clang::Type::ObjCInterface: break;
+ case clang::Type::Record: break;
+ case clang::Type::Enum: return lldb::eFormatEnum;
+ case clang::Type::Typedef:
+ return CompilerType (getASTContext(), llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetFormat();
+ case clang::Type::Auto:
+ return CompilerType (getASTContext(), llvm::cast<clang::AutoType>(qual_type)->desugar()).GetFormat();
+ case clang::Type::Paren:
+ return CompilerType (getASTContext(), llvm::cast<clang::ParenType>(qual_type)->desugar()).GetFormat();
+ case clang::Type::Elaborated:
+ return CompilerType (getASTContext(), llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetFormat();
+ case clang::Type::DependentSizedArray:
+ case clang::Type::DependentSizedExtVector:
+ case clang::Type::UnresolvedUsing:
+ case clang::Type::Attributed:
+ case clang::Type::TemplateTypeParm:
+ case clang::Type::SubstTemplateTypeParm:
+ case clang::Type::SubstTemplateTypeParmPack:
+ case clang::Type::InjectedClassName:
+ case clang::Type::DependentName:
+ case clang::Type::DependentTemplateSpecialization:
+ case clang::Type::PackExpansion:
+ case clang::Type::ObjCObject:
+
+ case clang::Type::TypeOfExpr:
+ case clang::Type::TypeOf:
+ case clang::Type::Decltype:
+ case clang::Type::TemplateSpecialization:
+ case clang::Type::Atomic:
+ case clang::Type::Adjusted:
+ break;
+
+ // pointer type decayed from an array or function type.
+ case clang::Type::Decayed:
+ break;
+ }
+ // We don't know hot to display this type...
+ return lldb::eFormatBytes;
+}
+
+static bool
+ObjCDeclHasIVars (clang::ObjCInterfaceDecl *class_interface_decl, bool check_superclass)
+{
+ while (class_interface_decl)
+ {
+ if (class_interface_decl->ivar_size() > 0)
+ return true;
+
+ if (check_superclass)
+ class_interface_decl = class_interface_decl->getSuperClass();
+ else
+ break;
+ }
+ return false;
+}
+
+uint32_t
+ClangASTContext::GetNumChildren (lldb::opaque_compiler_type_t type, bool omit_empty_base_classes)
+{
+ if (!type)
+ return 0;
+
+ uint32_t num_children = 0;
+ clang::QualType qual_type(GetQualType(type));
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Builtin:
+ switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind())
+ {
+ case clang::BuiltinType::ObjCId: // child is Class
+ case clang::BuiltinType::ObjCClass: // child is Class
+ num_children = 1;
+ break;
+
+ default:
+ break;
+ }
+ break;
+
+ case clang::Type::Complex: return 0;
+
+ case clang::Type::Record:
+ if (GetCompleteQualType (getASTContext(), qual_type))
+ {
+ const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
+ const clang::RecordDecl *record_decl = record_type->getDecl();
+ assert(record_decl);
+ const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
+ if (cxx_record_decl)
+ {
+ if (omit_empty_base_classes)
+ {
+ // Check each base classes to see if it or any of its
+ // base classes contain any fields. This can help
+ // limit the noise in variable views by not having to
+ // show base classes that contain no members.
+ clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
+ for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
+ base_class != base_class_end;
+ ++base_class)
+ {
+ const clang::CXXRecordDecl *base_class_decl = llvm::cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl());
+
+ // Skip empty base classes
+ if (ClangASTContext::RecordHasFields(base_class_decl) == false)
+ continue;
+
+ num_children++;
+ }
+ }
+ else
+ {
+ // Include all base classes
+ num_children += cxx_record_decl->getNumBases();
+ }
+
+ }
+ clang::RecordDecl::field_iterator field, field_end;
+ for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field)
+ ++num_children;
+ }
+ break;
+
+ case clang::Type::ObjCObject:
+ case clang::Type::ObjCInterface:
+ if (GetCompleteQualType (getASTContext(), qual_type))
+ {
+ const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
+ assert (objc_class_type);
+ if (objc_class_type)
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+
+ if (class_interface_decl)
+ {
+
+ clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass();
+ if (superclass_interface_decl)
+ {
+ if (omit_empty_base_classes)
+ {
+ if (ObjCDeclHasIVars (superclass_interface_decl, true))
+ ++num_children;
+ }
+ else
+ ++num_children;
+ }
+
+ num_children += class_interface_decl->ivar_size();
+ }
+ }
+ }
+ break;
+
+ case clang::Type::ObjCObjectPointer:
+ {
+ const clang::ObjCObjectPointerType *pointer_type = llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr());
+ clang::QualType pointee_type = pointer_type->getPointeeType();
+ uint32_t num_pointee_children = CompilerType (getASTContext(),pointee_type).GetNumChildren (omit_empty_base_classes);
+ // If this type points to a simple type, then it has 1 child
+ if (num_pointee_children == 0)
+ num_children = 1;
+ else
+ num_children = num_pointee_children;
+ }
+ break;
+
+ case clang::Type::Vector:
+ case clang::Type::ExtVector:
+ num_children = llvm::cast<clang::VectorType>(qual_type.getTypePtr())->getNumElements();
+ break;
+
+ case clang::Type::ConstantArray:
+ num_children = llvm::cast<clang::ConstantArrayType>(qual_type.getTypePtr())->getSize().getLimitedValue();
+ break;
+
+ case clang::Type::Pointer:
+ {
+ const clang::PointerType *pointer_type = llvm::cast<clang::PointerType>(qual_type.getTypePtr());
+ clang::QualType pointee_type (pointer_type->getPointeeType());
+ uint32_t num_pointee_children = CompilerType (getASTContext(),pointee_type).GetNumChildren (omit_empty_base_classes);
+ if (num_pointee_children == 0)
+ {
+ // We have a pointer to a pointee type that claims it has no children.
+ // We will want to look at
+ num_children = GetNumPointeeChildren (pointee_type);
+ }
+ else
+ num_children = num_pointee_children;
+ }
+ break;
+
+ case clang::Type::LValueReference:
+ case clang::Type::RValueReference:
+ {
+ const clang::ReferenceType *reference_type = llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
+ clang::QualType pointee_type = reference_type->getPointeeType();
+ uint32_t num_pointee_children = CompilerType (getASTContext(), pointee_type).GetNumChildren (omit_empty_base_classes);
+ // If this type points to a simple type, then it has 1 child
+ if (num_pointee_children == 0)
+ num_children = 1;
+ else
+ num_children = num_pointee_children;
+ }
+ break;
+
+
+ case clang::Type::Typedef:
+ num_children = CompilerType (getASTContext(), llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumChildren (omit_empty_base_classes);
+ break;
+
+ case clang::Type::Auto:
+ num_children = CompilerType (getASTContext(), llvm::cast<clang::AutoType>(qual_type)->getDeducedType()).GetNumChildren (omit_empty_base_classes);
+ break;
+
+ case clang::Type::Elaborated:
+ num_children = CompilerType (getASTContext(), llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetNumChildren (omit_empty_base_classes);
+ break;
+
+ case clang::Type::Paren:
+ num_children = CompilerType (getASTContext(), llvm::cast<clang::ParenType>(qual_type)->desugar()).GetNumChildren (omit_empty_base_classes);
+ break;
+ default:
+ break;
+ }
+ return num_children;
+}
+
+CompilerType
+ClangASTContext::GetBuiltinTypeByName (const ConstString &name)
+{
+ return GetBasicType (GetBasicTypeEnumeration (name));
+}
+
+lldb::BasicType
+ClangASTContext::GetBasicTypeEnumeration (lldb::opaque_compiler_type_t type)
+{
+ if (type)
+ {
+ clang::QualType qual_type(GetQualType(type));
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ if (type_class == clang::Type::Builtin)
+ {
+ switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind())
+ {
+ case clang::BuiltinType::Void: return eBasicTypeVoid;
+ case clang::BuiltinType::Bool: return eBasicTypeBool;
+ case clang::BuiltinType::Char_S: return eBasicTypeSignedChar;
+ case clang::BuiltinType::Char_U: return eBasicTypeUnsignedChar;
+ case clang::BuiltinType::Char16: return eBasicTypeChar16;
+ case clang::BuiltinType::Char32: return eBasicTypeChar32;
+ case clang::BuiltinType::UChar: return eBasicTypeUnsignedChar;
+ case clang::BuiltinType::SChar: return eBasicTypeSignedChar;
+ case clang::BuiltinType::WChar_S: return eBasicTypeSignedWChar;
+ case clang::BuiltinType::WChar_U: return eBasicTypeUnsignedWChar;
+ case clang::BuiltinType::Short: return eBasicTypeShort;
+ case clang::BuiltinType::UShort: return eBasicTypeUnsignedShort;
+ case clang::BuiltinType::Int: return eBasicTypeInt;
+ case clang::BuiltinType::UInt: return eBasicTypeUnsignedInt;
+ case clang::BuiltinType::Long: return eBasicTypeLong;
+ case clang::BuiltinType::ULong: return eBasicTypeUnsignedLong;
+ case clang::BuiltinType::LongLong: return eBasicTypeLongLong;
+ case clang::BuiltinType::ULongLong: return eBasicTypeUnsignedLongLong;
+ case clang::BuiltinType::Int128: return eBasicTypeInt128;
+ case clang::BuiltinType::UInt128: return eBasicTypeUnsignedInt128;
+
+ case clang::BuiltinType::Half: return eBasicTypeHalf;
+ case clang::BuiltinType::Float: return eBasicTypeFloat;
+ case clang::BuiltinType::Double: return eBasicTypeDouble;
+ case clang::BuiltinType::LongDouble:return eBasicTypeLongDouble;
+
+ case clang::BuiltinType::NullPtr: return eBasicTypeNullPtr;
+ case clang::BuiltinType::ObjCId: return eBasicTypeObjCID;
+ case clang::BuiltinType::ObjCClass: return eBasicTypeObjCClass;
+ case clang::BuiltinType::ObjCSel: return eBasicTypeObjCSel;
+ default:
+ return eBasicTypeOther;
+ }
+ }
+ }
+ return eBasicTypeInvalid;
+}
+
+void
+ClangASTContext::ForEachEnumerator (lldb::opaque_compiler_type_t type, std::function <bool (const CompilerType &integer_type, const ConstString &name, const llvm::APSInt &value)> const &callback)
+{
+ const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(GetCanonicalQualType(type));
+ if (enum_type)
+ {
+ const clang::EnumDecl *enum_decl = enum_type->getDecl();
+ if (enum_decl)
+ {
+ CompilerType integer_type(this, enum_decl->getIntegerType().getAsOpaquePtr());
+
+ clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
+ for (enum_pos = enum_decl->enumerator_begin(), enum_end_pos = enum_decl->enumerator_end(); enum_pos != enum_end_pos; ++enum_pos)
+ {
+ ConstString name(enum_pos->getNameAsString().c_str());
+ if (!callback (integer_type, name, enum_pos->getInitVal()))
+ break;
+ }
+ }
+ }
+}
+
+
+#pragma mark Aggregate Types
+
+uint32_t
+ClangASTContext::GetNumFields (lldb::opaque_compiler_type_t type)
+{
+ if (!type)
+ return 0;
+
+ uint32_t count = 0;
+ clang::QualType qual_type(GetCanonicalQualType(type));
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Record:
+ if (GetCompleteType(type))
+ {
+ const clang::RecordType *record_type = llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
+ if (record_type)
+ {
+ clang::RecordDecl *record_decl = record_type->getDecl();
+ if (record_decl)
+ {
+ uint32_t field_idx = 0;
+ clang::RecordDecl::field_iterator field, field_end;
+ for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field)
+ ++field_idx;
+ count = field_idx;
+ }
+ }
+ }
+ break;
+
+ case clang::Type::Typedef:
+ count = CompilerType (getASTContext(), llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumFields();
+ break;
+
+ case clang::Type::Auto:
+ count = CompilerType (getASTContext(), llvm::cast<clang::AutoType>(qual_type)->getDeducedType()).GetNumFields();
+ break;
+
+ case clang::Type::Elaborated:
+ count = CompilerType (getASTContext(), llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetNumFields();
+ break;
+
+ case clang::Type::Paren:
+ count = CompilerType (getASTContext(), llvm::cast<clang::ParenType>(qual_type)->desugar()).GetNumFields();
+ break;
+
+ case clang::Type::ObjCObjectPointer:
+ if (GetCompleteType(type))
+ {
+ const clang::ObjCObjectPointerType *objc_class_type = qual_type->getAsObjCInterfacePointerType();
+ if (objc_class_type)
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterfaceDecl();
+
+ if (class_interface_decl)
+ count = class_interface_decl->ivar_size();
+ }
+ }
+ break;
+
+ case clang::Type::ObjCObject:
+ case clang::Type::ObjCInterface:
+ if (GetCompleteType(type))
+ {
+ const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
+ if (objc_class_type)
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+
+ if (class_interface_decl)
+ count = class_interface_decl->ivar_size();
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ return count;
+}
+
+static lldb::opaque_compiler_type_t
+GetObjCFieldAtIndex (clang::ASTContext *ast,
+ clang::ObjCInterfaceDecl *class_interface_decl,
+ size_t idx,
+ std::string& name,
+ uint64_t *bit_offset_ptr,
+ uint32_t *bitfield_bit_size_ptr,
+ bool *is_bitfield_ptr)
+{
+ if (class_interface_decl)
+ {
+ if (idx < (class_interface_decl->ivar_size()))
+ {
+ clang::ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end();
+ uint32_t ivar_idx = 0;
+
+ for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end; ++ivar_pos, ++ivar_idx)
+ {
+ if (ivar_idx == idx)
+ {
+ const clang::ObjCIvarDecl* ivar_decl = *ivar_pos;
+
+ clang::QualType ivar_qual_type(ivar_decl->getType());
+
+ name.assign(ivar_decl->getNameAsString());
+
+ if (bit_offset_ptr)
+ {
+ const clang::ASTRecordLayout &interface_layout = ast->getASTObjCInterfaceLayout(class_interface_decl);
+ *bit_offset_ptr = interface_layout.getFieldOffset (ivar_idx);
+ }
+
+ const bool is_bitfield = ivar_pos->isBitField();
+
+ if (bitfield_bit_size_ptr)
+ {
+ *bitfield_bit_size_ptr = 0;
+
+ if (is_bitfield && ast)
+ {
+ clang::Expr *bitfield_bit_size_expr = ivar_pos->getBitWidth();
+ llvm::APSInt bitfield_apsint;
+ if (bitfield_bit_size_expr && bitfield_bit_size_expr->EvaluateAsInt(bitfield_apsint, *ast))
+ {
+ *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
+ }
+ }
+ }
+ if (is_bitfield_ptr)
+ *is_bitfield_ptr = is_bitfield;
+
+ return ivar_qual_type.getAsOpaquePtr();
+ }
+ }
+ }
+ }
+ return nullptr;
+}
+
+CompilerType
+ClangASTContext::GetFieldAtIndex (lldb::opaque_compiler_type_t type, size_t idx,
+ std::string& name,
+ uint64_t *bit_offset_ptr,
+ uint32_t *bitfield_bit_size_ptr,
+ bool *is_bitfield_ptr)
+{
+ if (!type)
+ return CompilerType();
+
+ clang::QualType qual_type(GetCanonicalQualType(type));
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Record:
+ if (GetCompleteType(type))
+ {
+ const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
+ const clang::RecordDecl *record_decl = record_type->getDecl();
+ uint32_t field_idx = 0;
+ clang::RecordDecl::field_iterator field, field_end;
+ for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++field_idx)
+ {
+ if (idx == field_idx)
+ {
+ // Print the member type if requested
+ // Print the member name and equal sign
+ name.assign(field->getNameAsString());
+
+ // Figure out the type byte size (field_type_info.first) and
+ // alignment (field_type_info.second) from the AST context.
+ if (bit_offset_ptr)
+ {
+ const clang::ASTRecordLayout &record_layout = getASTContext()->getASTRecordLayout(record_decl);
+ *bit_offset_ptr = record_layout.getFieldOffset (field_idx);
+ }
+
+ const bool is_bitfield = field->isBitField();
+
+ if (bitfield_bit_size_ptr)
+ {
+ *bitfield_bit_size_ptr = 0;
+
+ if (is_bitfield)
+ {
+ clang::Expr *bitfield_bit_size_expr = field->getBitWidth();
+ llvm::APSInt bitfield_apsint;
+ if (bitfield_bit_size_expr && bitfield_bit_size_expr->EvaluateAsInt(bitfield_apsint, *getASTContext()))
+ {
+ *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
+ }
+ }
+ }
+ if (is_bitfield_ptr)
+ *is_bitfield_ptr = is_bitfield;
+
+ return CompilerType (getASTContext(), field->getType());
+ }
+ }
+ }
+ break;
+
+ case clang::Type::ObjCObjectPointer:
+ if (GetCompleteType(type))
+ {
+ const clang::ObjCObjectPointerType *objc_class_type = qual_type->getAsObjCInterfacePointerType();
+ if (objc_class_type)
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterfaceDecl();
+ return CompilerType (this, GetObjCFieldAtIndex(getASTContext(), class_interface_decl, idx, name, bit_offset_ptr, bitfield_bit_size_ptr, is_bitfield_ptr));
+ }
+ }
+ break;
+
+ case clang::Type::ObjCObject:
+ case clang::Type::ObjCInterface:
+ if (GetCompleteType(type))
+ {
+ const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
+ assert (objc_class_type);
+ if (objc_class_type)
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+ return CompilerType (this, GetObjCFieldAtIndex(getASTContext(), class_interface_decl, idx, name, bit_offset_ptr, bitfield_bit_size_ptr, is_bitfield_ptr));
+ }
+ }
+ break;
+
+
+ case clang::Type::Typedef:
+ return CompilerType (getASTContext(), llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).
+ GetFieldAtIndex (idx,
+ name,
+ bit_offset_ptr,
+ bitfield_bit_size_ptr,
+ is_bitfield_ptr);
+
+ case clang::Type::Auto:
+ return CompilerType (getASTContext(), llvm::cast<clang::AutoType>(qual_type)->getDeducedType()).
+ GetFieldAtIndex (idx,
+ name,
+ bit_offset_ptr,
+ bitfield_bit_size_ptr,
+ is_bitfield_ptr);
+
+ case clang::Type::Elaborated:
+ return CompilerType (getASTContext(), llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).
+ GetFieldAtIndex (idx,
+ name,
+ bit_offset_ptr,
+ bitfield_bit_size_ptr,
+ is_bitfield_ptr);
+
+ case clang::Type::Paren:
+ return CompilerType (getASTContext(), llvm::cast<clang::ParenType>(qual_type)->desugar()).
+ GetFieldAtIndex (idx,
+ name,
+ bit_offset_ptr,
+ bitfield_bit_size_ptr,
+ is_bitfield_ptr);
+
+ default:
+ break;
+ }
+ return CompilerType();
+}
+
+uint32_t
+ClangASTContext::GetNumDirectBaseClasses (lldb::opaque_compiler_type_t type)
+{
+ uint32_t count = 0;
+ clang::QualType qual_type(GetCanonicalQualType(type));
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Record:
+ if (GetCompleteType(type))
+ {
+ const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+ if (cxx_record_decl)
+ count = cxx_record_decl->getNumBases();
+ }
+ break;
+
+ case clang::Type::ObjCObjectPointer:
+ count = GetPointeeType(type).GetNumDirectBaseClasses();
+ break;
+
+ case clang::Type::ObjCObject:
+ if (GetCompleteType(type))
+ {
+ const clang::ObjCObjectType *objc_class_type = qual_type->getAsObjCQualifiedInterfaceType();
+ if (objc_class_type)
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+
+ if (class_interface_decl && class_interface_decl->getSuperClass())
+ count = 1;
+ }
+ }
+ break;
+ case clang::Type::ObjCInterface:
+ if (GetCompleteType(type))
+ {
+ const clang::ObjCInterfaceType *objc_interface_type = qual_type->getAs<clang::ObjCInterfaceType>();
+ if (objc_interface_type)
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_interface_type->getInterface();
+
+ if (class_interface_decl && class_interface_decl->getSuperClass())
+ count = 1;
+ }
+ }
+ break;
+
+
+ case clang::Type::Typedef:
+ count = GetNumDirectBaseClasses(llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
+ break;
+
+ case clang::Type::Auto:
+ count = GetNumDirectBaseClasses(llvm::cast<clang::AutoType>(qual_type)->getDeducedType().getAsOpaquePtr());
+ break;
+
+ case clang::Type::Elaborated:
+ count = GetNumDirectBaseClasses(llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr());
+ break;
+
+ case clang::Type::Paren:
+ return GetNumDirectBaseClasses(llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr());
+
+ default:
+ break;
+ }
+ return count;
+
+}
+
+uint32_t
+ClangASTContext::GetNumVirtualBaseClasses (lldb::opaque_compiler_type_t type)
+{
+ uint32_t count = 0;
+ clang::QualType qual_type(GetCanonicalQualType(type));
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Record:
+ if (GetCompleteType(type))
+ {
+ const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+ if (cxx_record_decl)
+ count = cxx_record_decl->getNumVBases();
+ }
+ break;
+
+ case clang::Type::Typedef:
+ count = GetNumVirtualBaseClasses(llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
+ break;
+
+ case clang::Type::Auto:
+ count = GetNumVirtualBaseClasses(llvm::cast<clang::AutoType>(qual_type)->getDeducedType().getAsOpaquePtr());
+ break;
+
+ case clang::Type::Elaborated:
+ count = GetNumVirtualBaseClasses(llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr());
+ break;
+
+ case clang::Type::Paren:
+ count = GetNumVirtualBaseClasses(llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr());
+ break;
+
+ default:
+ break;
+ }
+ return count;
+
+}
+
+CompilerType
+ClangASTContext::GetDirectBaseClassAtIndex (lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr)
+{
+ clang::QualType qual_type(GetCanonicalQualType(type));
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Record:
+ if (GetCompleteType(type))
+ {
+ const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+ if (cxx_record_decl)
+ {
+ uint32_t curr_idx = 0;
+ clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
+ for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
+ base_class != base_class_end;
+ ++base_class, ++curr_idx)
+ {
+ if (curr_idx == idx)
+ {
+ if (bit_offset_ptr)
+ {
+ const clang::ASTRecordLayout &record_layout = getASTContext()->getASTRecordLayout(cxx_record_decl);
+ const clang::CXXRecordDecl *base_class_decl = llvm::cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl());
+ if (base_class->isVirtual())
+ *bit_offset_ptr = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8;
+ else
+ *bit_offset_ptr = record_layout.getBaseClassOffset(base_class_decl).getQuantity() * 8;
+ }
+ return CompilerType (this, base_class->getType().getAsOpaquePtr());
+ }
+ }
+ }
+ }
+ break;
+
+ case clang::Type::ObjCObjectPointer:
+ return GetPointeeType(type).GetDirectBaseClassAtIndex(idx, bit_offset_ptr);
+
+ case clang::Type::ObjCObject:
+ if (idx == 0 && GetCompleteType(type))
+ {
+ const clang::ObjCObjectType *objc_class_type = qual_type->getAsObjCQualifiedInterfaceType();
+ if (objc_class_type)
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+
+ if (class_interface_decl)
+ {
+ clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass();
+ if (superclass_interface_decl)
+ {
+ if (bit_offset_ptr)
+ *bit_offset_ptr = 0;
+ return CompilerType (getASTContext(), getASTContext()->getObjCInterfaceType(superclass_interface_decl));
+ }
+ }
+ }
+ }
+ break;
+ case clang::Type::ObjCInterface:
+ if (idx == 0 && GetCompleteType(type))
+ {
+ const clang::ObjCObjectType *objc_interface_type = qual_type->getAs<clang::ObjCInterfaceType>();
+ if (objc_interface_type)
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_interface_type->getInterface();
+
+ if (class_interface_decl)
+ {
+ clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass();
+ if (superclass_interface_decl)
+ {
+ if (bit_offset_ptr)
+ *bit_offset_ptr = 0;
+ return CompilerType (getASTContext(), getASTContext()->getObjCInterfaceType(superclass_interface_decl));
+ }
+ }
+ }
+ }
+ break;
+
+
+ case clang::Type::Typedef:
+ return GetDirectBaseClassAtIndex (llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), idx, bit_offset_ptr);
+
+ case clang::Type::Auto:
+ return GetDirectBaseClassAtIndex (llvm::cast<clang::AutoType>(qual_type)->getDeducedType().getAsOpaquePtr(), idx, bit_offset_ptr);
+
+ case clang::Type::Elaborated:
+ return GetDirectBaseClassAtIndex (llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(), idx, bit_offset_ptr);
+
+ case clang::Type::Paren:
+ return GetDirectBaseClassAtIndex (llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(), idx, bit_offset_ptr);
+
+ default:
+ break;
+ }
+ return CompilerType();
+}
+
+CompilerType
+ClangASTContext::GetVirtualBaseClassAtIndex (lldb::opaque_compiler_type_t type,
+ size_t idx,
+ uint32_t *bit_offset_ptr)
+{
+ clang::QualType qual_type(GetCanonicalQualType(type));
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
{
- if (clang::CXXMethodDecl *method_decl = llvm::dyn_cast<clang::CXXMethodDecl>(decl_ctx))
+ case clang::Type::Record:
+ if (GetCompleteType(type))
+ {
+ const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+ if (cxx_record_decl)
+ {
+ uint32_t curr_idx = 0;
+ clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
+ for (base_class = cxx_record_decl->vbases_begin(), base_class_end = cxx_record_decl->vbases_end();
+ base_class != base_class_end;
+ ++base_class, ++curr_idx)
+ {
+ if (curr_idx == idx)
+ {
+ if (bit_offset_ptr)
+ {
+ const clang::ASTRecordLayout &record_layout = getASTContext()->getASTRecordLayout(cxx_record_decl);
+ const clang::CXXRecordDecl *base_class_decl = llvm::cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl());
+ *bit_offset_ptr = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8;
+
+ }
+ return CompilerType (this, base_class->getType().getAsOpaquePtr());
+ }
+ }
+ }
+ }
+ break;
+
+ case clang::Type::Typedef:
+ return GetVirtualBaseClassAtIndex (llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), idx, bit_offset_ptr);
+
+ case clang::Type::Auto:
+ return GetVirtualBaseClassAtIndex (llvm::cast<clang::AutoType>(qual_type)->getDeducedType().getAsOpaquePtr(), idx, bit_offset_ptr);
+
+ case clang::Type::Elaborated:
+ return GetVirtualBaseClassAtIndex (llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(), idx, bit_offset_ptr);
+
+ case clang::Type::Paren:
+ return GetVirtualBaseClassAtIndex (llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(), idx, bit_offset_ptr);
+
+ default:
+ break;
+ }
+ return CompilerType();
+
+}
+
+// If a pointer to a pointee type (the clang_type arg) says that it has no
+// children, then we either need to trust it, or override it and return a
+// different result. For example, an "int *" has one child that is an integer,
+// but a function pointer doesn't have any children. Likewise if a Record type
+// claims it has no children, then there really is nothing to show.
+uint32_t
+ClangASTContext::GetNumPointeeChildren (clang::QualType type)
+{
+ if (type.isNull())
+ return 0;
+
+ clang::QualType qual_type(type.getCanonicalType());
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Builtin:
+ switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind())
+ {
+ case clang::BuiltinType::UnknownAny:
+ case clang::BuiltinType::Void:
+ case clang::BuiltinType::NullPtr:
+ case clang::BuiltinType::OCLEvent:
+ case clang::BuiltinType::OCLImage1d:
+ case clang::BuiltinType::OCLImage1dArray:
+ case clang::BuiltinType::OCLImage1dBuffer:
+ case clang::BuiltinType::OCLImage2d:
+ case clang::BuiltinType::OCLImage2dArray:
+ case clang::BuiltinType::OCLImage3d:
+ case clang::BuiltinType::OCLSampler:
+ return 0;
+ case clang::BuiltinType::Bool:
+ case clang::BuiltinType::Char_U:
+ case clang::BuiltinType::UChar:
+ case clang::BuiltinType::WChar_U:
+ case clang::BuiltinType::Char16:
+ case clang::BuiltinType::Char32:
+ case clang::BuiltinType::UShort:
+ case clang::BuiltinType::UInt:
+ case clang::BuiltinType::ULong:
+ case clang::BuiltinType::ULongLong:
+ case clang::BuiltinType::UInt128:
+ case clang::BuiltinType::Char_S:
+ case clang::BuiltinType::SChar:
+ case clang::BuiltinType::WChar_S:
+ case clang::BuiltinType::Short:
+ case clang::BuiltinType::Int:
+ case clang::BuiltinType::Long:
+ case clang::BuiltinType::LongLong:
+ case clang::BuiltinType::Int128:
+ case clang::BuiltinType::Float:
+ case clang::BuiltinType::Double:
+ case clang::BuiltinType::LongDouble:
+ case clang::BuiltinType::Dependent:
+ case clang::BuiltinType::Overload:
+ case clang::BuiltinType::ObjCId:
+ case clang::BuiltinType::ObjCClass:
+ case clang::BuiltinType::ObjCSel:
+ case clang::BuiltinType::BoundMember:
+ case clang::BuiltinType::Half:
+ case clang::BuiltinType::ARCUnbridgedCast:
+ case clang::BuiltinType::PseudoObject:
+ case clang::BuiltinType::BuiltinFn:
+ case clang::BuiltinType::OMPArraySection:
+ return 1;
+ default:
+ return 0;
+ }
+ break;
+
+ case clang::Type::Complex: return 1;
+ case clang::Type::Pointer: return 1;
+ case clang::Type::BlockPointer: return 0; // If block pointers don't have debug info, then no children for them
+ case clang::Type::LValueReference: return 1;
+ case clang::Type::RValueReference: return 1;
+ case clang::Type::MemberPointer: return 0;
+ case clang::Type::ConstantArray: return 0;
+ case clang::Type::IncompleteArray: return 0;
+ case clang::Type::VariableArray: return 0;
+ case clang::Type::DependentSizedArray: return 0;
+ case clang::Type::DependentSizedExtVector: return 0;
+ case clang::Type::Vector: return 0;
+ case clang::Type::ExtVector: return 0;
+ case clang::Type::FunctionProto: return 0; // When we function pointers, they have no children...
+ case clang::Type::FunctionNoProto: return 0; // When we function pointers, they have no children...
+ case clang::Type::UnresolvedUsing: return 0;
+ case clang::Type::Paren: return GetNumPointeeChildren (llvm::cast<clang::ParenType>(qual_type)->desugar());
+ case clang::Type::Typedef: return GetNumPointeeChildren (llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType());
+ case clang::Type::Auto: return GetNumPointeeChildren (llvm::cast<clang::AutoType>(qual_type)->getDeducedType());
+ case clang::Type::Elaborated: return GetNumPointeeChildren (llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType());
+ case clang::Type::TypeOfExpr: return 0;
+ case clang::Type::TypeOf: return 0;
+ case clang::Type::Decltype: return 0;
+ case clang::Type::Record: return 0;
+ case clang::Type::Enum: return 1;
+ case clang::Type::TemplateTypeParm: return 1;
+ case clang::Type::SubstTemplateTypeParm: return 1;
+ case clang::Type::TemplateSpecialization: return 1;
+ case clang::Type::InjectedClassName: return 0;
+ case clang::Type::DependentName: return 1;
+ case clang::Type::DependentTemplateSpecialization: return 1;
+ case clang::Type::ObjCObject: return 0;
+ case clang::Type::ObjCInterface: return 0;
+ case clang::Type::ObjCObjectPointer: return 1;
+ default:
+ break;
+ }
+ return 0;
+}
+
+
+CompilerType
+ClangASTContext::GetChildCompilerTypeAtIndex (lldb::opaque_compiler_type_t type,
+ ExecutionContext *exe_ctx,
+ size_t idx,
+ bool transparent_pointers,
+ bool omit_empty_base_classes,
+ bool ignore_array_bounds,
+ std::string& child_name,
+ uint32_t &child_byte_size,
+ int32_t &child_byte_offset,
+ uint32_t &child_bitfield_bit_size,
+ uint32_t &child_bitfield_bit_offset,
+ bool &child_is_base_class,
+ bool &child_is_deref_of_parent,
+ ValueObject *valobj,
+ uint64_t &language_flags)
+{
+ if (!type)
+ return CompilerType();
+
+ clang::QualType parent_qual_type(GetCanonicalQualType(type));
+ const clang::Type::TypeClass parent_type_class = parent_qual_type->getTypeClass();
+ child_bitfield_bit_size = 0;
+ child_bitfield_bit_offset = 0;
+ child_is_base_class = false;
+ language_flags = 0;
+
+ const bool idx_is_valid = idx < GetNumChildren (type, omit_empty_base_classes);
+ uint32_t bit_offset;
+ switch (parent_type_class)
+ {
+ case clang::Type::Builtin:
+ if (idx_is_valid)
+ {
+ switch (llvm::cast<clang::BuiltinType>(parent_qual_type)->getKind())
+ {
+ case clang::BuiltinType::ObjCId:
+ case clang::BuiltinType::ObjCClass:
+ child_name = "isa";
+ child_byte_size = getASTContext()->getTypeSize(getASTContext()->ObjCBuiltinClassTy) / CHAR_BIT;
+ return CompilerType (getASTContext(), getASTContext()->ObjCBuiltinClassTy);
+
+ default:
+ break;
+ }
+ }
+ break;
+
+ case clang::Type::Record:
+ if (idx_is_valid && GetCompleteType(type))
+ {
+ const clang::RecordType *record_type = llvm::cast<clang::RecordType>(parent_qual_type.getTypePtr());
+ const clang::RecordDecl *record_decl = record_type->getDecl();
+ assert(record_decl);
+ const clang::ASTRecordLayout &record_layout = getASTContext()->getASTRecordLayout(record_decl);
+ uint32_t child_idx = 0;
+
+ const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
+ if (cxx_record_decl)
+ {
+ // We might have base classes to print out first
+ clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
+ for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
+ base_class != base_class_end;
+ ++base_class)
+ {
+ const clang::CXXRecordDecl *base_class_decl = nullptr;
+
+ // Skip empty base classes
+ if (omit_empty_base_classes)
+ {
+ base_class_decl = llvm::cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl());
+ if (ClangASTContext::RecordHasFields(base_class_decl) == false)
+ continue;
+ }
+
+ if (idx == child_idx)
+ {
+ if (base_class_decl == nullptr)
+ base_class_decl = llvm::cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl());
+
+
+ if (base_class->isVirtual())
+ {
+ bool handled = false;
+ if (valobj)
+ {
+ Error err;
+ AddressType addr_type = eAddressTypeInvalid;
+ lldb::addr_t vtable_ptr_addr = valobj->GetCPPVTableAddress(addr_type);
+
+ if (vtable_ptr_addr != LLDB_INVALID_ADDRESS && addr_type == eAddressTypeLoad)
+ {
+
+ ExecutionContext exe_ctx (valobj->GetExecutionContextRef());
+ Process *process = exe_ctx.GetProcessPtr();
+ if (process)
+ {
+ clang::VTableContextBase *vtable_ctx = getASTContext()->getVTableContext();
+ if (vtable_ctx)
+ {
+ if (vtable_ctx->isMicrosoft())
+ {
+ clang::MicrosoftVTableContext *msoft_vtable_ctx = static_cast<clang::MicrosoftVTableContext *>(vtable_ctx);
+
+ if (vtable_ptr_addr)
+ {
+ const lldb::addr_t vbtable_ptr_addr = vtable_ptr_addr + record_layout.getVBPtrOffset().getQuantity();
+
+ const lldb::addr_t vbtable_ptr = process->ReadPointerFromMemory(vbtable_ptr_addr, err);
+ if (vbtable_ptr != LLDB_INVALID_ADDRESS)
+ {
+ // Get the index into the virtual base table. The index is the index in uint32_t from vbtable_ptr
+ const unsigned vbtable_index = msoft_vtable_ctx->getVBTableIndex(cxx_record_decl, base_class_decl);
+ const lldb::addr_t base_offset_addr = vbtable_ptr + vbtable_index * 4;
+ const uint32_t base_offset = process->ReadUnsignedIntegerFromMemory(base_offset_addr, 4, UINT32_MAX, err);
+ if (base_offset != UINT32_MAX)
+ {
+ handled = true;
+ bit_offset = base_offset * 8;
+ }
+ }
+ }
+ }
+ else
+ {
+ clang::ItaniumVTableContext *itanium_vtable_ctx = static_cast<clang::ItaniumVTableContext *>(vtable_ctx);
+ if (vtable_ptr_addr)
+ {
+ const lldb::addr_t vtable_ptr = process->ReadPointerFromMemory(vtable_ptr_addr, err);
+ if (vtable_ptr != LLDB_INVALID_ADDRESS)
+ {
+ clang::CharUnits base_offset_offset = itanium_vtable_ctx->getVirtualBaseOffsetOffset(cxx_record_decl, base_class_decl);
+ const lldb::addr_t base_offset_addr = vtable_ptr + base_offset_offset.getQuantity();
+ const uint32_t base_offset = process->ReadUnsignedIntegerFromMemory(base_offset_addr, 4, UINT32_MAX, err);
+ if (base_offset != UINT32_MAX)
+ {
+ handled = true;
+ bit_offset = base_offset * 8;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ }
+ if (!handled)
+ bit_offset = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8;
+ }
+ else
+ bit_offset = record_layout.getBaseClassOffset(base_class_decl).getQuantity() * 8;
+
+ // Base classes should be a multiple of 8 bits in size
+ child_byte_offset = bit_offset/8;
+ CompilerType base_class_clang_type(getASTContext(), base_class->getType());
+ child_name = base_class_clang_type.GetTypeName().AsCString("");
+ uint64_t base_class_clang_type_bit_size = base_class_clang_type.GetBitSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
+
+ // Base classes bit sizes should be a multiple of 8 bits in size
+ assert (base_class_clang_type_bit_size % 8 == 0);
+ child_byte_size = base_class_clang_type_bit_size / 8;
+ child_is_base_class = true;
+ return base_class_clang_type;
+ }
+ // We don't increment the child index in the for loop since we might
+ // be skipping empty base classes
+ ++child_idx;
+ }
+ }
+ // Make sure index is in range...
+ uint32_t field_idx = 0;
+ clang::RecordDecl::field_iterator field, field_end;
+ for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++field_idx, ++child_idx)
+ {
+ if (idx == child_idx)
+ {
+ // Print the member type if requested
+ // Print the member name and equal sign
+ child_name.assign(field->getNameAsString().c_str());
+
+ // Figure out the type byte size (field_type_info.first) and
+ // alignment (field_type_info.second) from the AST context.
+ CompilerType field_clang_type (getASTContext(), field->getType());
+ assert(field_idx < record_layout.getFieldCount());
+ child_byte_size = field_clang_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
+
+ // Figure out the field offset within the current struct/union/class type
+ bit_offset = record_layout.getFieldOffset (field_idx);
+ child_byte_offset = bit_offset / 8;
+ if (ClangASTContext::FieldIsBitfield (getASTContext(), *field, child_bitfield_bit_size))
+ child_bitfield_bit_offset = bit_offset % 8;
+
+ return field_clang_type;
+ }
+ }
+ }
+ break;
+
+ case clang::Type::ObjCObject:
+ case clang::Type::ObjCInterface:
+ if (idx_is_valid && GetCompleteType(type))
+ {
+ const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(parent_qual_type.getTypePtr());
+ assert (objc_class_type);
+ if (objc_class_type)
+ {
+ uint32_t child_idx = 0;
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+
+ if (class_interface_decl)
+ {
+
+ const clang::ASTRecordLayout &interface_layout = getASTContext()->getASTObjCInterfaceLayout(class_interface_decl);
+ clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass();
+ if (superclass_interface_decl)
+ {
+ if (omit_empty_base_classes)
+ {
+ CompilerType base_class_clang_type (getASTContext(), getASTContext()->getObjCInterfaceType(superclass_interface_decl));
+ if (base_class_clang_type.GetNumChildren(omit_empty_base_classes) > 0)
+ {
+ if (idx == 0)
+ {
+ clang::QualType ivar_qual_type(getASTContext()->getObjCInterfaceType(superclass_interface_decl));
+
+
+ child_name.assign(superclass_interface_decl->getNameAsString().c_str());
+
+ clang::TypeInfo ivar_type_info = getASTContext()->getTypeInfo(ivar_qual_type.getTypePtr());
+
+ child_byte_size = ivar_type_info.Width / 8;
+ child_byte_offset = 0;
+ child_is_base_class = true;
+
+ return CompilerType (getASTContext(), ivar_qual_type);
+ }
+
+ ++child_idx;
+ }
+ }
+ else
+ ++child_idx;
+ }
+
+ const uint32_t superclass_idx = child_idx;
+
+ if (idx < (child_idx + class_interface_decl->ivar_size()))
+ {
+ clang::ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end();
+
+ for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end; ++ivar_pos)
+ {
+ if (child_idx == idx)
+ {
+ clang::ObjCIvarDecl* ivar_decl = *ivar_pos;
+
+ clang::QualType ivar_qual_type(ivar_decl->getType());
+
+ child_name.assign(ivar_decl->getNameAsString().c_str());
+
+ clang::TypeInfo ivar_type_info = getASTContext()->getTypeInfo(ivar_qual_type.getTypePtr());
+
+ child_byte_size = ivar_type_info.Width / 8;
+
+ // Figure out the field offset within the current struct/union/class type
+ // For ObjC objects, we can't trust the bit offset we get from the Clang AST, since
+ // that doesn't account for the space taken up by unbacked properties, or from
+ // the changing size of base classes that are newer than this class.
+ // So if we have a process around that we can ask about this object, do so.
+ child_byte_offset = LLDB_INVALID_IVAR_OFFSET;
+ Process *process = nullptr;
+ if (exe_ctx)
+ process = exe_ctx->GetProcessPtr();
+ if (process)
+ {
+ ObjCLanguageRuntime *objc_runtime = process->GetObjCLanguageRuntime();
+ if (objc_runtime != nullptr)
+ {
+ CompilerType parent_ast_type (getASTContext(), parent_qual_type);
+ child_byte_offset = objc_runtime->GetByteOffsetForIvar (parent_ast_type, ivar_decl->getNameAsString().c_str());
+ }
+ }
+
+ // Setting this to UINT32_MAX to make sure we don't compute it twice...
+ bit_offset = UINT32_MAX;
+
+ if (child_byte_offset == static_cast<int32_t>(LLDB_INVALID_IVAR_OFFSET))
+ {
+ bit_offset = interface_layout.getFieldOffset (child_idx - superclass_idx);
+ child_byte_offset = bit_offset / 8;
+ }
+
+ // Note, the ObjC Ivar Byte offset is just that, it doesn't account for the bit offset
+ // of a bitfield within its containing object. So regardless of where we get the byte
+ // offset from, we still need to get the bit offset for bitfields from the layout.
+
+ if (ClangASTContext::FieldIsBitfield (getASTContext(), ivar_decl, child_bitfield_bit_size))
+ {
+ if (bit_offset == UINT32_MAX)
+ bit_offset = interface_layout.getFieldOffset (child_idx - superclass_idx);
+
+ child_bitfield_bit_offset = bit_offset % 8;
+ }
+ return CompilerType (getASTContext(), ivar_qual_type);
+ }
+ ++child_idx;
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case clang::Type::ObjCObjectPointer:
+ if (idx_is_valid)
+ {
+ CompilerType pointee_clang_type (GetPointeeType(type));
+
+ if (transparent_pointers && pointee_clang_type.IsAggregateType())
+ {
+ child_is_deref_of_parent = false;
+ bool tmp_child_is_deref_of_parent = false;
+ return pointee_clang_type.GetChildCompilerTypeAtIndex (exe_ctx,
+ idx,
+ transparent_pointers,
+ omit_empty_base_classes,
+ ignore_array_bounds,
+ child_name,
+ child_byte_size,
+ child_byte_offset,
+ child_bitfield_bit_size,
+ child_bitfield_bit_offset,
+ child_is_base_class,
+ tmp_child_is_deref_of_parent,
+ valobj,
+ language_flags);
+ }
+ else
+ {
+ child_is_deref_of_parent = true;
+ const char *parent_name = valobj ? valobj->GetName().GetCString() : NULL;
+ if (parent_name)
+ {
+ child_name.assign(1, '*');
+ child_name += parent_name;
+ }
+
+ // We have a pointer to an simple type
+ if (idx == 0 && pointee_clang_type.GetCompleteType())
+ {
+ child_byte_size = pointee_clang_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
+ child_byte_offset = 0;
+ return pointee_clang_type;
+ }
+ }
+ }
+ break;
+
+ case clang::Type::Vector:
+ case clang::Type::ExtVector:
+ if (idx_is_valid)
+ {
+ const clang::VectorType *array = llvm::cast<clang::VectorType>(parent_qual_type.getTypePtr());
+ if (array)
+ {
+ CompilerType element_type (getASTContext(), array->getElementType());
+ if (element_type.GetCompleteType())
+ {
+ char element_name[64];
+ ::snprintf (element_name, sizeof (element_name), "[%" PRIu64 "]", static_cast<uint64_t>(idx));
+ child_name.assign(element_name);
+ child_byte_size = element_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
+ child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
+ return element_type;
+ }
+ }
+ }
+ break;
+
+ case clang::Type::ConstantArray:
+ case clang::Type::IncompleteArray:
+ if (ignore_array_bounds || idx_is_valid)
+ {
+ const clang::ArrayType *array = GetQualType(type)->getAsArrayTypeUnsafe();
+ if (array)
+ {
+ CompilerType element_type (getASTContext(), array->getElementType());
+ if (element_type.GetCompleteType())
+ {
+ char element_name[64];
+ ::snprintf (element_name, sizeof (element_name), "[%" PRIu64 "]", static_cast<uint64_t>(idx));
+ child_name.assign(element_name);
+ child_byte_size = element_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
+ child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
+ return element_type;
+ }
+ }
+ }
+ break;
+
+
+ case clang::Type::Pointer:
+ if (idx_is_valid)
+ {
+ CompilerType pointee_clang_type (GetPointeeType(type));
+
+ // Don't dereference "void *" pointers
+ if (pointee_clang_type.IsVoidType())
+ return CompilerType();
+
+ if (transparent_pointers && pointee_clang_type.IsAggregateType ())
+ {
+ child_is_deref_of_parent = false;
+ bool tmp_child_is_deref_of_parent = false;
+ return pointee_clang_type.GetChildCompilerTypeAtIndex (exe_ctx,
+ idx,
+ transparent_pointers,
+ omit_empty_base_classes,
+ ignore_array_bounds,
+ child_name,
+ child_byte_size,
+ child_byte_offset,
+ child_bitfield_bit_size,
+ child_bitfield_bit_offset,
+ child_is_base_class,
+ tmp_child_is_deref_of_parent,
+ valobj,
+ language_flags);
+ }
+ else
+ {
+ child_is_deref_of_parent = true;
+
+ const char *parent_name = valobj ? valobj->GetName().GetCString() : NULL;
+ if (parent_name)
+ {
+ child_name.assign(1, '*');
+ child_name += parent_name;
+ }
+
+ // We have a pointer to an simple type
+ if (idx == 0)
+ {
+ child_byte_size = pointee_clang_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
+ child_byte_offset = 0;
+ return pointee_clang_type;
+ }
+ }
+ }
+ break;
+
+ case clang::Type::LValueReference:
+ case clang::Type::RValueReference:
+ if (idx_is_valid)
+ {
+ const clang::ReferenceType *reference_type = llvm::cast<clang::ReferenceType>(parent_qual_type.getTypePtr());
+ CompilerType pointee_clang_type (getASTContext(), reference_type->getPointeeType());
+ if (transparent_pointers && pointee_clang_type.IsAggregateType ())
+ {
+ child_is_deref_of_parent = false;
+ bool tmp_child_is_deref_of_parent = false;
+ return pointee_clang_type.GetChildCompilerTypeAtIndex (exe_ctx,
+ idx,
+ transparent_pointers,
+ omit_empty_base_classes,
+ ignore_array_bounds,
+ child_name,
+ child_byte_size,
+ child_byte_offset,
+ child_bitfield_bit_size,
+ child_bitfield_bit_offset,
+ child_is_base_class,
+ tmp_child_is_deref_of_parent,
+ valobj,
+ language_flags);
+ }
+ else
+ {
+ const char *parent_name = valobj ? valobj->GetName().GetCString() : NULL;
+ if (parent_name)
+ {
+ child_name.assign(1, '&');
+ child_name += parent_name;
+ }
+
+ // We have a pointer to an simple type
+ if (idx == 0)
+ {
+ child_byte_size = pointee_clang_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
+ child_byte_offset = 0;
+ return pointee_clang_type;
+ }
+ }
+ }
+ break;
+
+ case clang::Type::Typedef:
+ {
+ CompilerType typedefed_clang_type (getASTContext(), llvm::cast<clang::TypedefType>(parent_qual_type)->getDecl()->getUnderlyingType());
+ return typedefed_clang_type.GetChildCompilerTypeAtIndex (exe_ctx,
+ idx,
+ transparent_pointers,
+ omit_empty_base_classes,
+ ignore_array_bounds,
+ child_name,
+ child_byte_size,
+ child_byte_offset,
+ child_bitfield_bit_size,
+ child_bitfield_bit_offset,
+ child_is_base_class,
+ child_is_deref_of_parent,
+ valobj,
+ language_flags);
+ }
+ break;
+
+ case clang::Type::Auto:
+ {
+ CompilerType elaborated_clang_type (getASTContext(), llvm::cast<clang::AutoType>(parent_qual_type)->getDeducedType());
+ return elaborated_clang_type.GetChildCompilerTypeAtIndex (exe_ctx,
+ idx,
+ transparent_pointers,
+ omit_empty_base_classes,
+ ignore_array_bounds,
+ child_name,
+ child_byte_size,
+ child_byte_offset,
+ child_bitfield_bit_size,
+ child_bitfield_bit_offset,
+ child_is_base_class,
+ child_is_deref_of_parent,
+ valobj,
+ language_flags);
+ }
+
+ case clang::Type::Elaborated:
{
- if (method_decl->isStatic())
+ CompilerType elaborated_clang_type (getASTContext(), llvm::cast<clang::ElaboratedType>(parent_qual_type)->getNamedType());
+ return elaborated_clang_type.GetChildCompilerTypeAtIndex (exe_ctx,
+ idx,
+ transparent_pointers,
+ omit_empty_base_classes,
+ ignore_array_bounds,
+ child_name,
+ child_byte_size,
+ child_byte_offset,
+ child_bitfield_bit_size,
+ child_bitfield_bit_offset,
+ child_is_base_class,
+ child_is_deref_of_parent,
+ valobj,
+ language_flags);
+ }
+
+ case clang::Type::Paren:
+ {
+ CompilerType paren_clang_type (getASTContext(), llvm::cast<clang::ParenType>(parent_qual_type)->desugar());
+ return paren_clang_type.GetChildCompilerTypeAtIndex (exe_ctx,
+ idx,
+ transparent_pointers,
+ omit_empty_base_classes,
+ ignore_array_bounds,
+ child_name,
+ child_byte_size,
+ child_byte_offset,
+ child_bitfield_bit_size,
+ child_bitfield_bit_offset,
+ child_is_base_class,
+ child_is_deref_of_parent,
+ valobj,
+ language_flags);
+ }
+
+
+ default:
+ break;
+ }
+ return CompilerType();
+}
+
+static uint32_t
+GetIndexForRecordBase
+(
+ const clang::RecordDecl *record_decl,
+ const clang::CXXBaseSpecifier *base_spec,
+ bool omit_empty_base_classes
+ )
+{
+ uint32_t child_idx = 0;
+
+ const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
+
+ // const char *super_name = record_decl->getNameAsCString();
+ // const char *base_name = base_spec->getType()->getAs<clang::RecordType>()->getDecl()->getNameAsCString();
+ // printf ("GetIndexForRecordChild (%s, %s)\n", super_name, base_name);
+ //
+ if (cxx_record_decl)
+ {
+ clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
+ for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
+ base_class != base_class_end;
+ ++base_class)
+ {
+ if (omit_empty_base_classes)
{
- is_instance_method = false;
+ if (BaseSpecifierIsEmpty (base_class))
+ continue;
}
+
+ // printf ("GetIndexForRecordChild (%s, %s) base[%u] = %s\n", super_name, base_name,
+ // child_idx,
+ // base_class->getType()->getAs<clang::RecordType>()->getDecl()->getNameAsCString());
+ //
+ //
+ if (base_class == base_spec)
+ return child_idx;
+ ++child_idx;
+ }
+ }
+
+ return UINT32_MAX;
+}
+
+
+static uint32_t
+GetIndexForRecordChild (const clang::RecordDecl *record_decl,
+ clang::NamedDecl *canonical_decl,
+ bool omit_empty_base_classes)
+{
+ uint32_t child_idx = ClangASTContext::GetNumBaseClasses (llvm::dyn_cast<clang::CXXRecordDecl>(record_decl),
+ omit_empty_base_classes);
+
+ clang::RecordDecl::field_iterator field, field_end;
+ for (field = record_decl->field_begin(), field_end = record_decl->field_end();
+ field != field_end;
+ ++field, ++child_idx)
+ {
+ if (field->getCanonicalDecl() == canonical_decl)
+ return child_idx;
+ }
+
+ return UINT32_MAX;
+}
+
+// Look for a child member (doesn't include base classes, but it does include
+// their members) in the type hierarchy. Returns an index path into "clang_type"
+// on how to reach the appropriate member.
+//
+// class A
+// {
+// public:
+// int m_a;
+// int m_b;
+// };
+//
+// class B
+// {
+// };
+//
+// class C :
+// public B,
+// public A
+// {
+// };
+//
+// If we have a clang type that describes "class C", and we wanted to looked
+// "m_b" in it:
+//
+// With omit_empty_base_classes == false we would get an integer array back with:
+// { 1, 1 }
+// The first index 1 is the child index for "class A" within class C
+// The second index 1 is the child index for "m_b" within class A
+//
+// With omit_empty_base_classes == true we would get an integer array back with:
+// { 0, 1 }
+// The first index 0 is the child index for "class A" within class C (since class B doesn't have any members it doesn't count)
+// The second index 1 is the child index for "m_b" within class A
+
+size_t
+ClangASTContext::GetIndexOfChildMemberWithName (lldb::opaque_compiler_type_t type, const char *name,
+ bool omit_empty_base_classes,
+ std::vector<uint32_t>& child_indexes)
+{
+ if (type && name && name[0])
+ {
+ clang::QualType qual_type(GetCanonicalQualType(type));
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Record:
+ if (GetCompleteType(type))
+ {
+ const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
+ const clang::RecordDecl *record_decl = record_type->getDecl();
+
+ assert(record_decl);
+ uint32_t child_idx = 0;
+
+ const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
+
+ // Try and find a field that matches NAME
+ clang::RecordDecl::field_iterator field, field_end;
+ llvm::StringRef name_sref(name);
+ for (field = record_decl->field_begin(), field_end = record_decl->field_end();
+ field != field_end;
+ ++field, ++child_idx)
+ {
+ llvm::StringRef field_name = field->getName();
+ if (field_name.empty())
+ {
+ CompilerType field_type(getASTContext(),field->getType());
+ child_indexes.push_back(child_idx);
+ if (field_type.GetIndexOfChildMemberWithName(name, omit_empty_base_classes, child_indexes))
+ return child_indexes.size();
+ child_indexes.pop_back();
+
+ }
+ else if (field_name.equals (name_sref))
+ {
+ // We have to add on the number of base classes to this index!
+ child_indexes.push_back (child_idx + ClangASTContext::GetNumBaseClasses (cxx_record_decl, omit_empty_base_classes));
+ return child_indexes.size();
+ }
+ }
+
+ if (cxx_record_decl)
+ {
+ const clang::RecordDecl *parent_record_decl = cxx_record_decl;
+
+ //printf ("parent = %s\n", parent_record_decl->getNameAsCString());
+
+ //const Decl *root_cdecl = cxx_record_decl->getCanonicalDecl();
+ // Didn't find things easily, lets let clang do its thang...
+ clang::IdentifierInfo & ident_ref = getASTContext()->Idents.get(name_sref);
+ clang::DeclarationName decl_name(&ident_ref);
+
+ clang::CXXBasePaths paths;
+ if (cxx_record_decl->lookupInBases([decl_name](const clang::CXXBaseSpecifier *specifier, clang::CXXBasePath &path) {
+ return clang::CXXRecordDecl::FindOrdinaryMember(specifier, path, decl_name);
+ },
+ paths))
+ {
+ clang::CXXBasePaths::const_paths_iterator path, path_end = paths.end();
+ for (path = paths.begin(); path != path_end; ++path)
+ {
+ const size_t num_path_elements = path->size();
+ for (size_t e=0; e<num_path_elements; ++e)
+ {
+ clang::CXXBasePathElement elem = (*path)[e];
+
+ child_idx = GetIndexForRecordBase (parent_record_decl, elem.Base, omit_empty_base_classes);
+ if (child_idx == UINT32_MAX)
+ {
+ child_indexes.clear();
+ return 0;
+ }
+ else
+ {
+ child_indexes.push_back (child_idx);
+ parent_record_decl = llvm::cast<clang::RecordDecl>(elem.Base->getType()->getAs<clang::RecordType>()->getDecl());
+ }
+ }
+ for (clang::NamedDecl *path_decl : path->Decls)
+ {
+ child_idx = GetIndexForRecordChild (parent_record_decl, path_decl, omit_empty_base_classes);
+ if (child_idx == UINT32_MAX)
+ {
+ child_indexes.clear();
+ return 0;
+ }
+ else
+ {
+ child_indexes.push_back (child_idx);
+ }
+ }
+ }
+ return child_indexes.size();
+ }
+ }
+
+ }
+ break;
+
+ case clang::Type::ObjCObject:
+ case clang::Type::ObjCInterface:
+ if (GetCompleteType(type))
+ {
+ llvm::StringRef name_sref(name);
+ const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
+ assert (objc_class_type);
+ if (objc_class_type)
+ {
+ uint32_t child_idx = 0;
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+
+ if (class_interface_decl)
+ {
+ clang::ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end();
+ clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass();
+
+ for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end; ++ivar_pos, ++child_idx)
+ {
+ const clang::ObjCIvarDecl* ivar_decl = *ivar_pos;
+
+ if (ivar_decl->getName().equals (name_sref))
+ {
+ if ((!omit_empty_base_classes && superclass_interface_decl) ||
+ ( omit_empty_base_classes && ObjCDeclHasIVars (superclass_interface_decl, true)))
+ ++child_idx;
+
+ child_indexes.push_back (child_idx);
+ return child_indexes.size();
+ }
+ }
+
+ if (superclass_interface_decl)
+ {
+ // The super class index is always zero for ObjC classes,
+ // so we push it onto the child indexes in case we find
+ // an ivar in our superclass...
+ child_indexes.push_back (0);
+
+ CompilerType superclass_clang_type (getASTContext(), getASTContext()->getObjCInterfaceType(superclass_interface_decl));
+ if (superclass_clang_type.GetIndexOfChildMemberWithName (name,
+ omit_empty_base_classes,
+ child_indexes))
+ {
+ // We did find an ivar in a superclass so just
+ // return the results!
+ return child_indexes.size();
+ }
+
+ // We didn't find an ivar matching "name" in our
+ // superclass, pop the superclass zero index that
+ // we pushed on above.
+ child_indexes.pop_back();
+ }
+ }
+ }
+ }
+ break;
+
+ case clang::Type::ObjCObjectPointer:
+ {
+ CompilerType objc_object_clang_type (getASTContext(), llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())->getPointeeType());
+ return objc_object_clang_type.GetIndexOfChildMemberWithName (name,
+ omit_empty_base_classes,
+ child_indexes);
+ }
+ break;
+
+
+ case clang::Type::ConstantArray:
+ {
+ // const clang::ConstantArrayType *array = llvm::cast<clang::ConstantArrayType>(parent_qual_type.getTypePtr());
+ // const uint64_t element_count = array->getSize().getLimitedValue();
+ //
+ // if (idx < element_count)
+ // {
+ // std::pair<uint64_t, unsigned> field_type_info = ast->getTypeInfo(array->getElementType());
+ //
+ // char element_name[32];
+ // ::snprintf (element_name, sizeof (element_name), "%s[%u]", parent_name ? parent_name : "", idx);
+ //
+ // child_name.assign(element_name);
+ // assert(field_type_info.first % 8 == 0);
+ // child_byte_size = field_type_info.first / 8;
+ // child_byte_offset = idx * child_byte_size;
+ // return array->getElementType().getAsOpaquePtr();
+ // }
+ }
+ break;
+
+ // case clang::Type::MemberPointerType:
+ // {
+ // MemberPointerType *mem_ptr_type = llvm::cast<MemberPointerType>(qual_type.getTypePtr());
+ // clang::QualType pointee_type = mem_ptr_type->getPointeeType();
+ //
+ // if (ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr()))
+ // {
+ // return GetIndexOfChildWithName (ast,
+ // mem_ptr_type->getPointeeType().getAsOpaquePtr(),
+ // name);
+ // }
+ // }
+ // break;
+ //
+ case clang::Type::LValueReference:
+ case clang::Type::RValueReference:
+ {
+ const clang::ReferenceType *reference_type = llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
+ clang::QualType pointee_type(reference_type->getPointeeType());
+ CompilerType pointee_clang_type (getASTContext(), pointee_type);
+
+ if (pointee_clang_type.IsAggregateType ())
+ {
+ return pointee_clang_type.GetIndexOfChildMemberWithName (name,
+ omit_empty_base_classes,
+ child_indexes);
+ }
+ }
+ break;
+
+ case clang::Type::Pointer:
+ {
+ CompilerType pointee_clang_type (GetPointeeType(type));
+
+ if (pointee_clang_type.IsAggregateType ())
+ {
+ return pointee_clang_type.GetIndexOfChildMemberWithName (name,
+ omit_empty_base_classes,
+ child_indexes);
+ }
+ }
+ break;
+
+ case clang::Type::Typedef:
+ return CompilerType (getASTContext(), llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetIndexOfChildMemberWithName (name,
+ omit_empty_base_classes,
+ child_indexes);
+
+ case clang::Type::Auto:
+ return CompilerType (getASTContext(), llvm::cast<clang::AutoType>(qual_type)->getDeducedType()).GetIndexOfChildMemberWithName (name,
+ omit_empty_base_classes,
+ child_indexes);
+
+ case clang::Type::Elaborated:
+ return CompilerType (getASTContext(), llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetIndexOfChildMemberWithName (name,
+ omit_empty_base_classes,
+ child_indexes);
+
+ case clang::Type::Paren:
+ return CompilerType (getASTContext(), llvm::cast<clang::ParenType>(qual_type)->desugar()).GetIndexOfChildMemberWithName (name,
+ omit_empty_base_classes,
+ child_indexes);
+
+ default:
+ break;
+ }
+ }
+ return 0;
+}
+
+
+// Get the index of the child of "clang_type" whose name matches. This function
+// doesn't descend into the children, but only looks one level deep and name
+// matches can include base class names.
+
+uint32_t
+ClangASTContext::GetIndexOfChildWithName (lldb::opaque_compiler_type_t type, const char *name, bool omit_empty_base_classes)
+{
+ if (type && name && name[0])
+ {
+ clang::QualType qual_type(GetCanonicalQualType(type));
+
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+
+ switch (type_class)
+ {
+ case clang::Type::Record:
+ if (GetCompleteType(type))
+ {
+ const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
+ const clang::RecordDecl *record_decl = record_type->getDecl();
+
+ assert(record_decl);
+ uint32_t child_idx = 0;
+
+ const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
+
+ if (cxx_record_decl)
+ {
+ clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
+ for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
+ base_class != base_class_end;
+ ++base_class)
+ {
+ // Skip empty base classes
+ clang::CXXRecordDecl *base_class_decl = llvm::cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl());
+ if (omit_empty_base_classes && ClangASTContext::RecordHasFields(base_class_decl) == false)
+ continue;
+
+ CompilerType base_class_clang_type (getASTContext(), base_class->getType());
+ std::string base_class_type_name (base_class_clang_type.GetTypeName().AsCString(""));
+ if (base_class_type_name.compare (name) == 0)
+ return child_idx;
+ ++child_idx;
+ }
+ }
+
+ // Try and find a field that matches NAME
+ clang::RecordDecl::field_iterator field, field_end;
+ llvm::StringRef name_sref(name);
+ for (field = record_decl->field_begin(), field_end = record_decl->field_end();
+ field != field_end;
+ ++field, ++child_idx)
+ {
+ if (field->getName().equals (name_sref))
+ return child_idx;
+ }
+
+ }
+ break;
+
+ case clang::Type::ObjCObject:
+ case clang::Type::ObjCInterface:
+ if (GetCompleteType(type))
+ {
+ llvm::StringRef name_sref(name);
+ const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
+ assert (objc_class_type);
+ if (objc_class_type)
+ {
+ uint32_t child_idx = 0;
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+
+ if (class_interface_decl)
+ {
+ clang::ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end();
+ clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass();
+
+ for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end; ++ivar_pos, ++child_idx)
+ {
+ const clang::ObjCIvarDecl* ivar_decl = *ivar_pos;
+
+ if (ivar_decl->getName().equals (name_sref))
+ {
+ if ((!omit_empty_base_classes && superclass_interface_decl) ||
+ ( omit_empty_base_classes && ObjCDeclHasIVars (superclass_interface_decl, true)))
+ ++child_idx;
+
+ return child_idx;
+ }
+ }
+
+ if (superclass_interface_decl)
+ {
+ if (superclass_interface_decl->getName().equals (name_sref))
+ return 0;
+ }
+ }
+ }
+ }
+ break;
+
+ case clang::Type::ObjCObjectPointer:
+ {
+ CompilerType pointee_clang_type (getASTContext(), llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())->getPointeeType());
+ return pointee_clang_type.GetIndexOfChildWithName (name, omit_empty_base_classes);
+ }
+ break;
+
+ case clang::Type::ConstantArray:
+ {
+ // const clang::ConstantArrayType *array = llvm::cast<clang::ConstantArrayType>(parent_qual_type.getTypePtr());
+ // const uint64_t element_count = array->getSize().getLimitedValue();
+ //
+ // if (idx < element_count)
+ // {
+ // std::pair<uint64_t, unsigned> field_type_info = ast->getTypeInfo(array->getElementType());
+ //
+ // char element_name[32];
+ // ::snprintf (element_name, sizeof (element_name), "%s[%u]", parent_name ? parent_name : "", idx);
+ //
+ // child_name.assign(element_name);
+ // assert(field_type_info.first % 8 == 0);
+ // child_byte_size = field_type_info.first / 8;
+ // child_byte_offset = idx * child_byte_size;
+ // return array->getElementType().getAsOpaquePtr();
+ // }
+ }
+ break;
+
+ // case clang::Type::MemberPointerType:
+ // {
+ // MemberPointerType *mem_ptr_type = llvm::cast<MemberPointerType>(qual_type.getTypePtr());
+ // clang::QualType pointee_type = mem_ptr_type->getPointeeType();
+ //
+ // if (ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr()))
+ // {
+ // return GetIndexOfChildWithName (ast,
+ // mem_ptr_type->getPointeeType().getAsOpaquePtr(),
+ // name);
+ // }
+ // }
+ // break;
+ //
+ case clang::Type::LValueReference:
+ case clang::Type::RValueReference:
+ {
+ const clang::ReferenceType *reference_type = llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
+ CompilerType pointee_type (getASTContext(), reference_type->getPointeeType());
+
+ if (pointee_type.IsAggregateType ())
+ {
+ return pointee_type.GetIndexOfChildWithName (name, omit_empty_base_classes);
+ }
+ }
+ break;
+
+ case clang::Type::Pointer:
+ {
+ const clang::PointerType *pointer_type = llvm::cast<clang::PointerType>(qual_type.getTypePtr());
+ CompilerType pointee_type (getASTContext(), pointer_type->getPointeeType());
+
+ if (pointee_type.IsAggregateType ())
+ {
+ return pointee_type.GetIndexOfChildWithName (name, omit_empty_base_classes);
+ }
+ else
+ {
+ // if (parent_name)
+ // {
+ // child_name.assign(1, '*');
+ // child_name += parent_name;
+ // }
+ //
+ // // We have a pointer to an simple type
+ // if (idx == 0)
+ // {
+ // std::pair<uint64_t, unsigned> clang_type_info = ast->getTypeInfo(pointee_type);
+ // assert(clang_type_info.first % 8 == 0);
+ // child_byte_size = clang_type_info.first / 8;
+ // child_byte_offset = 0;
+ // return pointee_type.getAsOpaquePtr();
+ // }
+ }
+ }
+ break;
+
+ case clang::Type::Auto:
+ return CompilerType (getASTContext(), llvm::cast<clang::AutoType>(qual_type)->getDeducedType()).GetIndexOfChildWithName (name, omit_empty_base_classes);
+
+ case clang::Type::Elaborated:
+ return CompilerType (getASTContext(), llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetIndexOfChildWithName (name, omit_empty_base_classes);
+
+ case clang::Type::Paren:
+ return CompilerType (getASTContext(), llvm::cast<clang::ParenType>(qual_type)->desugar()).GetIndexOfChildWithName (name, omit_empty_base_classes);
+
+ case clang::Type::Typedef:
+ return CompilerType (getASTContext(), llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetIndexOfChildWithName (name, omit_empty_base_classes);
+
+ default:
+ break;
+ }
+ }
+ return UINT32_MAX;
+}
+
+
+size_t
+ClangASTContext::GetNumTemplateArguments (lldb::opaque_compiler_type_t type)
+{
+ if (!type)
+ return 0;
+
+ clang::QualType qual_type (GetCanonicalQualType(type));
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Record:
+ if (GetCompleteType(type))
+ {
+ const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+ if (cxx_record_decl)
+ {
+ const clang::ClassTemplateSpecializationDecl *template_decl = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(cxx_record_decl);
+ if (template_decl)
+ return template_decl->getTemplateArgs().size();
+ }
+ }
+ break;
+
+ case clang::Type::Typedef:
+ return (CompilerType (getASTContext(), llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType())).GetNumTemplateArguments();
+
+ case clang::Type::Auto:
+ return (CompilerType (getASTContext(), llvm::cast<clang::AutoType>(qual_type)->getDeducedType())).GetNumTemplateArguments();
+
+ case clang::Type::Elaborated:
+ return (CompilerType (getASTContext(), llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())).GetNumTemplateArguments();
+
+ case clang::Type::Paren:
+ return (CompilerType (getASTContext(), llvm::cast<clang::ParenType>(qual_type)->desugar())).GetNumTemplateArguments();
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+CompilerType
+ClangASTContext::GetTemplateArgument (lldb::opaque_compiler_type_t type, size_t arg_idx, lldb::TemplateArgumentKind &kind)
+{
+ if (!type)
+ return CompilerType();
+
+ clang::QualType qual_type (GetCanonicalQualType(type));
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Record:
+ if (GetCompleteType(type))
+ {
+ const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+ if (cxx_record_decl)
+ {
+ const clang::ClassTemplateSpecializationDecl *template_decl = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(cxx_record_decl);
+ if (template_decl && arg_idx < template_decl->getTemplateArgs().size())
+ {
+ const clang::TemplateArgument &template_arg = template_decl->getTemplateArgs()[arg_idx];
+ switch (template_arg.getKind())
+ {
+ case clang::TemplateArgument::Null:
+ kind = eTemplateArgumentKindNull;
+ return CompilerType();
+
+ case clang::TemplateArgument::Type:
+ kind = eTemplateArgumentKindType;
+ return CompilerType(getASTContext(), template_arg.getAsType());
+
+ case clang::TemplateArgument::Declaration:
+ kind = eTemplateArgumentKindDeclaration;
+ return CompilerType();
+
+ case clang::TemplateArgument::Integral:
+ kind = eTemplateArgumentKindIntegral;
+ return CompilerType(getASTContext(), template_arg.getIntegralType());
+
+ case clang::TemplateArgument::Template:
+ kind = eTemplateArgumentKindTemplate;
+ return CompilerType();
+
+ case clang::TemplateArgument::TemplateExpansion:
+ kind = eTemplateArgumentKindTemplateExpansion;
+ return CompilerType();
+
+ case clang::TemplateArgument::Expression:
+ kind = eTemplateArgumentKindExpression;
+ return CompilerType();
+
+ case clang::TemplateArgument::Pack:
+ kind = eTemplateArgumentKindPack;
+ return CompilerType();
+
+ default:
+ assert (!"Unhandled clang::TemplateArgument::ArgKind");
+ break;
+ }
+ }
+ }
+ }
+ break;
+
+ case clang::Type::Typedef:
+ return (CompilerType (getASTContext(), llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType())).GetTemplateArgument(arg_idx, kind);
+
+ case clang::Type::Auto:
+ return (CompilerType (getASTContext(), llvm::cast<clang::AutoType>(qual_type)->getDeducedType())).GetTemplateArgument(arg_idx, kind);
+
+ case clang::Type::Elaborated:
+ return (CompilerType (getASTContext(), llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())).GetTemplateArgument(arg_idx, kind);
+
+ case clang::Type::Paren:
+ return (CompilerType (getASTContext(), llvm::cast<clang::ParenType>(qual_type)->desugar())).GetTemplateArgument(arg_idx, kind);
+
+ default:
+ break;
+ }
+ kind = eTemplateArgumentKindNull;
+ return CompilerType ();
+}
+
+CompilerType
+ClangASTContext::GetTypeForFormatters (void* type)
+{
+ if (type)
+ return RemoveFastQualifiers(CompilerType(this, type));
+ return CompilerType();
+}
+
+static bool
+IsOperator (const char *name, clang::OverloadedOperatorKind &op_kind)
+{
+ if (name == nullptr || name[0] == '\0')
+ return false;
+
+#define OPERATOR_PREFIX "operator"
+#define OPERATOR_PREFIX_LENGTH (sizeof (OPERATOR_PREFIX) - 1)
+
+ const char *post_op_name = nullptr;
+
+ bool no_space = true;
+
+ if (::strncmp(name, OPERATOR_PREFIX, OPERATOR_PREFIX_LENGTH))
+ return false;
+
+ post_op_name = name + OPERATOR_PREFIX_LENGTH;
+
+ if (post_op_name[0] == ' ')
+ {
+ post_op_name++;
+ no_space = false;
+ }
+
+#undef OPERATOR_PREFIX
+#undef OPERATOR_PREFIX_LENGTH
+
+ // This is an operator, set the overloaded operator kind to invalid
+ // in case this is a conversion operator...
+ op_kind = clang::NUM_OVERLOADED_OPERATORS;
+
+ switch (post_op_name[0])
+ {
+ default:
+ if (no_space)
+ return false;
+ break;
+ case 'n':
+ if (no_space)
+ return false;
+ if (strcmp (post_op_name, "new") == 0)
+ op_kind = clang::OO_New;
+ else if (strcmp (post_op_name, "new[]") == 0)
+ op_kind = clang::OO_Array_New;
+ break;
+
+ case 'd':
+ if (no_space)
+ return false;
+ if (strcmp (post_op_name, "delete") == 0)
+ op_kind = clang::OO_Delete;
+ else if (strcmp (post_op_name, "delete[]") == 0)
+ op_kind = clang::OO_Array_Delete;
+ break;
+
+ case '+':
+ if (post_op_name[1] == '\0')
+ op_kind = clang::OO_Plus;
+ else if (post_op_name[2] == '\0')
+ {
+ if (post_op_name[1] == '=')
+ op_kind = clang::OO_PlusEqual;
+ else if (post_op_name[1] == '+')
+ op_kind = clang::OO_PlusPlus;
+ }
+ break;
+
+ case '-':
+ if (post_op_name[1] == '\0')
+ op_kind = clang::OO_Minus;
+ else if (post_op_name[2] == '\0')
+ {
+ switch (post_op_name[1])
+ {
+ case '=': op_kind = clang::OO_MinusEqual; break;
+ case '-': op_kind = clang::OO_MinusMinus; break;
+ case '>': op_kind = clang::OO_Arrow; break;
+ }
+ }
+ else if (post_op_name[3] == '\0')
+ {
+ if (post_op_name[2] == '*')
+ op_kind = clang::OO_ArrowStar; break;
+ }
+ break;
+
+ case '*':
+ if (post_op_name[1] == '\0')
+ op_kind = clang::OO_Star;
+ else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
+ op_kind = clang::OO_StarEqual;
+ break;
+
+ case '/':
+ if (post_op_name[1] == '\0')
+ op_kind = clang::OO_Slash;
+ else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
+ op_kind = clang::OO_SlashEqual;
+ break;
+
+ case '%':
+ if (post_op_name[1] == '\0')
+ op_kind = clang::OO_Percent;
+ else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
+ op_kind = clang::OO_PercentEqual;
+ break;
+
+
+ case '^':
+ if (post_op_name[1] == '\0')
+ op_kind = clang::OO_Caret;
+ else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
+ op_kind = clang::OO_CaretEqual;
+ break;
+
+ case '&':
+ if (post_op_name[1] == '\0')
+ op_kind = clang::OO_Amp;
+ else if (post_op_name[2] == '\0')
+ {
+ switch (post_op_name[1])
+ {
+ case '=': op_kind = clang::OO_AmpEqual; break;
+ case '&': op_kind = clang::OO_AmpAmp; break;
+ }
+ }
+ break;
+
+ case '|':
+ if (post_op_name[1] == '\0')
+ op_kind = clang::OO_Pipe;
+ else if (post_op_name[2] == '\0')
+ {
+ switch (post_op_name[1])
+ {
+ case '=': op_kind = clang::OO_PipeEqual; break;
+ case '|': op_kind = clang::OO_PipePipe; break;
+ }
+ }
+ break;
+
+ case '~':
+ if (post_op_name[1] == '\0')
+ op_kind = clang::OO_Tilde;
+ break;
+
+ case '!':
+ if (post_op_name[1] == '\0')
+ op_kind = clang::OO_Exclaim;
+ else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
+ op_kind = clang::OO_ExclaimEqual;
+ break;
+
+ case '=':
+ if (post_op_name[1] == '\0')
+ op_kind = clang::OO_Equal;
+ else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
+ op_kind = clang::OO_EqualEqual;
+ break;
+
+ case '<':
+ if (post_op_name[1] == '\0')
+ op_kind = clang::OO_Less;
+ else if (post_op_name[2] == '\0')
+ {
+ switch (post_op_name[1])
+ {
+ case '<': op_kind = clang::OO_LessLess; break;
+ case '=': op_kind = clang::OO_LessEqual; break;
+ }
+ }
+ else if (post_op_name[3] == '\0')
+ {
+ if (post_op_name[2] == '=')
+ op_kind = clang::OO_LessLessEqual;
+ }
+ break;
+
+ case '>':
+ if (post_op_name[1] == '\0')
+ op_kind = clang::OO_Greater;
+ else if (post_op_name[2] == '\0')
+ {
+ switch (post_op_name[1])
+ {
+ case '>': op_kind = clang::OO_GreaterGreater; break;
+ case '=': op_kind = clang::OO_GreaterEqual; break;
+ }
+ }
+ else if (post_op_name[1] == '>' &&
+ post_op_name[2] == '=' &&
+ post_op_name[3] == '\0')
+ {
+ op_kind = clang::OO_GreaterGreaterEqual;
+ }
+ break;
+
+ case ',':
+ if (post_op_name[1] == '\0')
+ op_kind = clang::OO_Comma;
+ break;
+
+ case '(':
+ if (post_op_name[1] == ')' && post_op_name[2] == '\0')
+ op_kind = clang::OO_Call;
+ break;
+
+ case '[':
+ if (post_op_name[1] == ']' && post_op_name[2] == '\0')
+ op_kind = clang::OO_Subscript;
+ break;
+ }
+
+ return true;
+}
+
+clang::EnumDecl *
+ClangASTContext::GetAsEnumDecl (const CompilerType& type)
+{
+ const clang::EnumType *enutype = llvm::dyn_cast<clang::EnumType>(GetCanonicalQualType(type));
+ if (enutype)
+ return enutype->getDecl();
+ return NULL;
+}
+
+clang::RecordDecl *
+ClangASTContext::GetAsRecordDecl (const CompilerType& type)
+{
+ const clang::RecordType *record_type = llvm::dyn_cast<clang::RecordType>(GetCanonicalQualType(type));
+ if (record_type)
+ return record_type->getDecl();
+ return nullptr;
+}
+
+clang::TagDecl *
+ClangASTContext::GetAsTagDecl (const CompilerType& type)
+{
+ clang::QualType qual_type = GetCanonicalQualType(type);
+ if (qual_type.isNull())
+ return nullptr;
+ else
+ return qual_type->getAsTagDecl();
+}
+
+clang::CXXRecordDecl *
+ClangASTContext::GetAsCXXRecordDecl (lldb::opaque_compiler_type_t type)
+{
+ return GetCanonicalQualType(type)->getAsCXXRecordDecl();
+}
+
+clang::ObjCInterfaceDecl *
+ClangASTContext::GetAsObjCInterfaceDecl (const CompilerType& type)
+{
+ const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(GetCanonicalQualType(type));
+ if (objc_class_type)
+ return objc_class_type->getInterface();
+ return nullptr;
+}
+
+clang::FieldDecl *
+ClangASTContext::AddFieldToRecordType (const CompilerType& type, const char *name,
+ const CompilerType &field_clang_type,
+ AccessType access,
+ uint32_t bitfield_bit_size)
+{
+ if (!type.IsValid() || !field_clang_type.IsValid())
+ return nullptr;
+ ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(type.GetTypeSystem());
+ if (!ast)
+ return nullptr;
+ clang::ASTContext* clang_ast = ast->getASTContext();
+
+ clang::FieldDecl *field = nullptr;
+
+ clang::Expr *bit_width = nullptr;
+ if (bitfield_bit_size != 0)
+ {
+ llvm::APInt bitfield_bit_size_apint(clang_ast->getTypeSize(clang_ast->IntTy), bitfield_bit_size);
+ bit_width = new (*clang_ast)clang::IntegerLiteral (*clang_ast, bitfield_bit_size_apint, clang_ast->IntTy, clang::SourceLocation());
+ }
+
+ clang::RecordDecl *record_decl = ast->GetAsRecordDecl (type);
+ if (record_decl)
+ {
+ field = clang::FieldDecl::Create (*clang_ast,
+ record_decl,
+ clang::SourceLocation(),
+ clang::SourceLocation(),
+ name ? &clang_ast->Idents.get(name) : nullptr, // Identifier
+ GetQualType(field_clang_type), // Field type
+ nullptr, // TInfo *
+ bit_width, // BitWidth
+ false, // Mutable
+ clang::ICIS_NoInit); // HasInit
+
+ if (!name)
+ {
+ // Determine whether this field corresponds to an anonymous
+ // struct or union.
+ if (const clang::TagType *TagT = field->getType()->getAs<clang::TagType>()) {
+ if (clang::RecordDecl *Rec = llvm::dyn_cast<clang::RecordDecl>(TagT->getDecl()))
+ if (!Rec->getDeclName()) {
+ Rec->setAnonymousStructOrUnion(true);
+ field->setImplicit();
+
+ }
+ }
+ }
+
+ if (field)
+ {
+ field->setAccess (ClangASTContext::ConvertAccessTypeToAccessSpecifier (access));
+
+ record_decl->addDecl(field);
+
+#ifdef LLDB_CONFIGURATION_DEBUG
+ VerifyDecl(field);
+#endif
+ }
+ }
+ else
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = ast->GetAsObjCInterfaceDecl (type);
+
+ if (class_interface_decl)
+ {
+ const bool is_synthesized = false;
+
+ field_clang_type.GetCompleteType();
+
+ field = clang::ObjCIvarDecl::Create (*clang_ast,
+ class_interface_decl,
+ clang::SourceLocation(),
+ clang::SourceLocation(),
+ name ? &clang_ast->Idents.get(name) : nullptr, // Identifier
+ GetQualType(field_clang_type), // Field type
+ nullptr, // TypeSourceInfo *
+ ConvertAccessTypeToObjCIvarAccessControl (access),
+ bit_width,
+ is_synthesized);
+
+ if (field)
+ {
+ class_interface_decl->addDecl(field);
+
+#ifdef LLDB_CONFIGURATION_DEBUG
+ VerifyDecl(field);
+#endif
+ }
+ }
+ }
+ return field;
+}
+
+void
+ClangASTContext::BuildIndirectFields (const CompilerType& type)
+{
+ if (!type)
+ return;
+
+ ClangASTContext *ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
+ if (!ast)
+ return;
+
+ clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
+
+ if (!record_decl)
+ return;
+
+ typedef llvm::SmallVector <clang::IndirectFieldDecl *, 1> IndirectFieldVector;
+
+ IndirectFieldVector indirect_fields;
+ clang::RecordDecl::field_iterator field_pos;
+ clang::RecordDecl::field_iterator field_end_pos = record_decl->field_end();
+ clang::RecordDecl::field_iterator last_field_pos = field_end_pos;
+ for (field_pos = record_decl->field_begin(); field_pos != field_end_pos; last_field_pos = field_pos++)
+ {
+ if (field_pos->isAnonymousStructOrUnion())
+ {
+ clang::QualType field_qual_type = field_pos->getType();
+
+ const clang::RecordType *field_record_type = field_qual_type->getAs<clang::RecordType>();
+
+ if (!field_record_type)
+ continue;
+
+ clang::RecordDecl *field_record_decl = field_record_type->getDecl();
+
+ if (!field_record_decl)
+ continue;
+
+ for (clang::RecordDecl::decl_iterator di = field_record_decl->decls_begin(), de = field_record_decl->decls_end();
+ di != de;
+ ++di)
+ {
+ if (clang::FieldDecl *nested_field_decl = llvm::dyn_cast<clang::FieldDecl>(*di))
+ {
+ clang::NamedDecl **chain = new (*ast->getASTContext()) clang::NamedDecl*[2];
+ chain[0] = *field_pos;
+ chain[1] = nested_field_decl;
+ clang::IndirectFieldDecl *indirect_field = clang::IndirectFieldDecl::Create(*ast->getASTContext(),
+ record_decl,
+ clang::SourceLocation(),
+ nested_field_decl->getIdentifier(),
+ nested_field_decl->getType(),
+ chain,
+ 2);
+
+ indirect_field->setImplicit();
+
+ indirect_field->setAccess(ClangASTContext::UnifyAccessSpecifiers(field_pos->getAccess(),
+ nested_field_decl->getAccess()));
+
+ indirect_fields.push_back(indirect_field);
+ }
+ else if (clang::IndirectFieldDecl *nested_indirect_field_decl = llvm::dyn_cast<clang::IndirectFieldDecl>(*di))
+ {
+ int nested_chain_size = nested_indirect_field_decl->getChainingSize();
+ clang::NamedDecl **chain = new (*ast->getASTContext()) clang::NamedDecl*[nested_chain_size + 1];
+ chain[0] = *field_pos;
+
+ int chain_index = 1;
+ for (clang::IndirectFieldDecl::chain_iterator nci = nested_indirect_field_decl->chain_begin(),
+ nce = nested_indirect_field_decl->chain_end();
+ nci < nce;
+ ++nci)
+ {
+ chain[chain_index] = *nci;
+ chain_index++;
+ }
+
+ clang::IndirectFieldDecl *indirect_field = clang::IndirectFieldDecl::Create(*ast->getASTContext(),
+ record_decl,
+ clang::SourceLocation(),
+ nested_indirect_field_decl->getIdentifier(),
+ nested_indirect_field_decl->getType(),
+ chain,
+ nested_chain_size + 1);
+
+ indirect_field->setImplicit();
+
+ indirect_field->setAccess(ClangASTContext::UnifyAccessSpecifiers(field_pos->getAccess(),
+ nested_indirect_field_decl->getAccess()));
+
+ indirect_fields.push_back(indirect_field);
+ }
+ }
+ }
+ }
+
+ // Check the last field to see if it has an incomplete array type as its
+ // last member and if it does, the tell the record decl about it
+ if (last_field_pos != field_end_pos)
+ {
+ if (last_field_pos->getType()->isIncompleteArrayType())
+ record_decl->hasFlexibleArrayMember();
+ }
+
+ for (IndirectFieldVector::iterator ifi = indirect_fields.begin(), ife = indirect_fields.end();
+ ifi < ife;
+ ++ifi)
+ {
+ record_decl->addDecl(*ifi);
+ }
+}
+
+void
+ClangASTContext::SetIsPacked (const CompilerType& type)
+{
+ if (type)
+ {
+ ClangASTContext *ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
+ if (ast)
+ {
+ clang::RecordDecl *record_decl = GetAsRecordDecl(type);
+
+ if (!record_decl)
+ return;
+
+ record_decl->addAttr(clang::PackedAttr::CreateImplicit(*ast->getASTContext()));
+ }
+ }
+}
+
+clang::VarDecl *
+ClangASTContext::AddVariableToRecordType (const CompilerType& type, const char *name,
+ const CompilerType &var_type,
+ AccessType access)
+{
+ clang::VarDecl *var_decl = nullptr;
+
+ if (!type.IsValid() || !var_type.IsValid())
+ return nullptr;
+ ClangASTContext *ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
+ if (!ast)
+ return nullptr;
+
+ clang::RecordDecl *record_decl = ast->GetAsRecordDecl (type);
+ if (record_decl)
+ {
+ var_decl = clang::VarDecl::Create (*ast->getASTContext(), // ASTContext &
+ record_decl, // DeclContext *
+ clang::SourceLocation(), // clang::SourceLocation StartLoc
+ clang::SourceLocation(), // clang::SourceLocation IdLoc
+ name ? &ast->getASTContext()->Idents.get(name) : nullptr, // clang::IdentifierInfo *
+ GetQualType(var_type), // Variable clang::QualType
+ nullptr, // TypeSourceInfo *
+ clang::SC_Static); // StorageClass
+ if (var_decl)
+ {
+ var_decl->setAccess(ClangASTContext::ConvertAccessTypeToAccessSpecifier (access));
+ record_decl->addDecl(var_decl);
+
+#ifdef LLDB_CONFIGURATION_DEBUG
+ VerifyDecl(var_decl);
+#endif
+ }
+ }
+ return var_decl;
+}
+
+
+clang::CXXMethodDecl *
+ClangASTContext::AddMethodToCXXRecordType (lldb::opaque_compiler_type_t type, const char *name,
+ const CompilerType &method_clang_type,
+ lldb::AccessType access,
+ bool is_virtual,
+ bool is_static,
+ bool is_inline,
+ bool is_explicit,
+ bool is_attr_used,
+ bool is_artificial)
+{
+ if (!type || !method_clang_type.IsValid() || name == nullptr || name[0] == '\0')
+ return nullptr;
+
+ clang::QualType record_qual_type(GetCanonicalQualType(type));
+
+ clang::CXXRecordDecl *cxx_record_decl = record_qual_type->getAsCXXRecordDecl();
+
+ if (cxx_record_decl == nullptr)
+ return nullptr;
+
+ clang::QualType method_qual_type (GetQualType(method_clang_type));
+
+ clang::CXXMethodDecl *cxx_method_decl = nullptr;
+
+ clang::DeclarationName decl_name (&getASTContext()->Idents.get(name));
+
+ const clang::FunctionType *function_type = llvm::dyn_cast<clang::FunctionType>(method_qual_type.getTypePtr());
+
+ if (function_type == nullptr)
+ return nullptr;
+
+ const clang::FunctionProtoType *method_function_prototype (llvm::dyn_cast<clang::FunctionProtoType>(function_type));
+
+ if (!method_function_prototype)
+ return nullptr;
+
+ unsigned int num_params = method_function_prototype->getNumParams();
+
+ clang::CXXDestructorDecl *cxx_dtor_decl(nullptr);
+ clang::CXXConstructorDecl *cxx_ctor_decl(nullptr);
+
+ if (is_artificial)
+ return nullptr; // skip everything artificial
+
+ if (name[0] == '~')
+ {
+ cxx_dtor_decl = clang::CXXDestructorDecl::Create (*getASTContext(),
+ cxx_record_decl,
+ clang::SourceLocation(),
+ clang::DeclarationNameInfo (getASTContext()->DeclarationNames.getCXXDestructorName (getASTContext()->getCanonicalType (record_qual_type)), clang::SourceLocation()),
+ method_qual_type,
+ nullptr,
+ is_inline,
+ is_artificial);
+ cxx_method_decl = cxx_dtor_decl;
+ }
+ else if (decl_name == cxx_record_decl->getDeclName())
+ {
+ cxx_ctor_decl = clang::CXXConstructorDecl::Create (*getASTContext(),
+ cxx_record_decl,
+ clang::SourceLocation(),
+ clang::DeclarationNameInfo (getASTContext()->DeclarationNames.getCXXConstructorName (getASTContext()->getCanonicalType (record_qual_type)), clang::SourceLocation()),
+ method_qual_type,
+ nullptr, // TypeSourceInfo *
+ is_explicit,
+ is_inline,
+ is_artificial,
+ false /*is_constexpr*/);
+ cxx_method_decl = cxx_ctor_decl;
+ }
+ else
+ {
+ clang::StorageClass SC = is_static ? clang::SC_Static : clang::SC_None;
+ clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
+
+ if (IsOperator (name, op_kind))
+ {
+ if (op_kind != clang::NUM_OVERLOADED_OPERATORS)
+ {
+ // Check the number of operator parameters. Sometimes we have
+ // seen bad DWARF that doesn't correctly describe operators and
+ // if we try to create a method and add it to the class, clang
+ // will assert and crash, so we need to make sure things are
+ // acceptable.
+ if (!ClangASTContext::CheckOverloadedOperatorKindParameterCount (op_kind, num_params))
+ return nullptr;
+ cxx_method_decl = clang::CXXMethodDecl::Create (*getASTContext(),
+ cxx_record_decl,
+ clang::SourceLocation(),
+ clang::DeclarationNameInfo (getASTContext()->DeclarationNames.getCXXOperatorName (op_kind), clang::SourceLocation()),
+ method_qual_type,
+ nullptr, // TypeSourceInfo *
+ SC,
+ is_inline,
+ false /*is_constexpr*/,
+ clang::SourceLocation());
+ }
+ else if (num_params == 0)
+ {
+ // Conversion operators don't take params...
+ cxx_method_decl = clang::CXXConversionDecl::Create (*getASTContext(),
+ cxx_record_decl,
+ clang::SourceLocation(),
+ clang::DeclarationNameInfo (getASTContext()->DeclarationNames.getCXXConversionFunctionName (getASTContext()->getCanonicalType (function_type->getReturnType())), clang::SourceLocation()),
+ method_qual_type,
+ nullptr, // TypeSourceInfo *
+ is_inline,
+ is_explicit,
+ false /*is_constexpr*/,
+ clang::SourceLocation());
+ }
+ }
+
+ if (cxx_method_decl == nullptr)
+ {
+ cxx_method_decl = clang::CXXMethodDecl::Create (*getASTContext(),
+ cxx_record_decl,
+ clang::SourceLocation(),
+ clang::DeclarationNameInfo (decl_name, clang::SourceLocation()),
+ method_qual_type,
+ nullptr, // TypeSourceInfo *
+ SC,
+ is_inline,
+ false /*is_constexpr*/,
+ clang::SourceLocation());
+ }
+ }
+
+ clang::AccessSpecifier access_specifier = ClangASTContext::ConvertAccessTypeToAccessSpecifier (access);
+
+ cxx_method_decl->setAccess (access_specifier);
+ cxx_method_decl->setVirtualAsWritten (is_virtual);
+
+ if (is_attr_used)
+ cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(*getASTContext()));
+
+ // Populate the method decl with parameter decls
+
+ llvm::SmallVector<clang::ParmVarDecl *, 12> params;
+
+ for (unsigned param_index = 0;
+ param_index < num_params;
+ ++param_index)
+ {
+ params.push_back (clang::ParmVarDecl::Create (*getASTContext(),
+ cxx_method_decl,
+ clang::SourceLocation(),
+ clang::SourceLocation(),
+ nullptr, // anonymous
+ method_function_prototype->getParamType(param_index),
+ nullptr,
+ clang::SC_None,
+ nullptr));
+ }
+
+ cxx_method_decl->setParams (llvm::ArrayRef<clang::ParmVarDecl*>(params));
+
+ cxx_record_decl->addDecl (cxx_method_decl);
+
+ // Sometimes the debug info will mention a constructor (default/copy/move),
+ // destructor, or assignment operator (copy/move) but there won't be any
+ // version of this in the code. So we check if the function was artificially
+ // generated and if it is trivial and this lets the compiler/backend know
+ // that it can inline the IR for these when it needs to and we can avoid a
+ // "missing function" error when running expressions.
+
+ if (is_artificial)
+ {
+ if (cxx_ctor_decl &&
+ ((cxx_ctor_decl->isDefaultConstructor() && cxx_record_decl->hasTrivialDefaultConstructor ()) ||
+ (cxx_ctor_decl->isCopyConstructor() && cxx_record_decl->hasTrivialCopyConstructor ()) ||
+ (cxx_ctor_decl->isMoveConstructor() && cxx_record_decl->hasTrivialMoveConstructor ()) ))
+ {
+ cxx_ctor_decl->setDefaulted();
+ cxx_ctor_decl->setTrivial(true);
+ }
+ else if (cxx_dtor_decl)
+ {
+ if (cxx_record_decl->hasTrivialDestructor())
+ {
+ cxx_dtor_decl->setDefaulted();
+ cxx_dtor_decl->setTrivial(true);
+ }
+ }
+ else if ((cxx_method_decl->isCopyAssignmentOperator() && cxx_record_decl->hasTrivialCopyAssignment()) ||
+ (cxx_method_decl->isMoveAssignmentOperator() && cxx_record_decl->hasTrivialMoveAssignment()))
+ {
+ cxx_method_decl->setDefaulted();
+ cxx_method_decl->setTrivial(true);
+ }
+ }
+
+#ifdef LLDB_CONFIGURATION_DEBUG
+ VerifyDecl(cxx_method_decl);
+#endif
+
+ // printf ("decl->isPolymorphic() = %i\n", cxx_record_decl->isPolymorphic());
+ // printf ("decl->isAggregate() = %i\n", cxx_record_decl->isAggregate());
+ // printf ("decl->isPOD() = %i\n", cxx_record_decl->isPOD());
+ // printf ("decl->isEmpty() = %i\n", cxx_record_decl->isEmpty());
+ // printf ("decl->isAbstract() = %i\n", cxx_record_decl->isAbstract());
+ // printf ("decl->hasTrivialConstructor() = %i\n", cxx_record_decl->hasTrivialConstructor());
+ // printf ("decl->hasTrivialCopyConstructor() = %i\n", cxx_record_decl->hasTrivialCopyConstructor());
+ // printf ("decl->hasTrivialCopyAssignment() = %i\n", cxx_record_decl->hasTrivialCopyAssignment());
+ // printf ("decl->hasTrivialDestructor() = %i\n", cxx_record_decl->hasTrivialDestructor());
+ return cxx_method_decl;
+}
+
+
+#pragma mark C++ Base Classes
+
+clang::CXXBaseSpecifier *
+ClangASTContext::CreateBaseClassSpecifier (lldb::opaque_compiler_type_t type, AccessType access, bool is_virtual, bool base_of_class)
+{
+ if (type)
+ return new clang::CXXBaseSpecifier (clang::SourceRange(),
+ is_virtual,
+ base_of_class,
+ ClangASTContext::ConvertAccessTypeToAccessSpecifier (access),
+ getASTContext()->getTrivialTypeSourceInfo (GetQualType(type)),
+ clang::SourceLocation());
+ return nullptr;
+}
+
+void
+ClangASTContext::DeleteBaseClassSpecifiers (clang::CXXBaseSpecifier **base_classes, unsigned num_base_classes)
+{
+ for (unsigned i=0; i<num_base_classes; ++i)
+ {
+ delete base_classes[i];
+ base_classes[i] = nullptr;
+ }
+}
+
+bool
+ClangASTContext::SetBaseClassesForClassType (lldb::opaque_compiler_type_t type, clang::CXXBaseSpecifier const * const *base_classes,
+ unsigned num_base_classes)
+{
+ if (type)
+ {
+ clang::CXXRecordDecl *cxx_record_decl = GetAsCXXRecordDecl(type);
+ if (cxx_record_decl)
+ {
+ cxx_record_decl->setBases(base_classes, num_base_classes);
+ return true;
+ }
+ }
+ return false;
+}
+
+bool
+ClangASTContext::SetObjCSuperClass (const CompilerType& type, const CompilerType &superclass_clang_type)
+{
+ ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(type.GetTypeSystem());
+ if (!ast)
+ return false;
+ clang::ASTContext* clang_ast = ast->getASTContext();
+
+ if (type && superclass_clang_type.IsValid() && superclass_clang_type.GetTypeSystem() == type.GetTypeSystem())
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl (type);
+ clang::ObjCInterfaceDecl *super_interface_decl = GetAsObjCInterfaceDecl (superclass_clang_type);
+ if (class_interface_decl && super_interface_decl)
+ {
+ class_interface_decl->setSuperClass(clang_ast->getTrivialTypeSourceInfo(clang_ast->getObjCInterfaceType(super_interface_decl)));
+ return true;
+ }
+ }
+ return false;
+}
+
+bool
+ClangASTContext::AddObjCClassProperty (const CompilerType& type,
+ const char *property_name,
+ const CompilerType &property_clang_type,
+ clang::ObjCIvarDecl *ivar_decl,
+ const char *property_setter_name,
+ const char *property_getter_name,
+ uint32_t property_attributes,
+ ClangASTMetadata *metadata)
+{
+ if (!type || !property_clang_type.IsValid() || property_name == nullptr || property_name[0] == '\0')
+ return false;
+ ClangASTContext *ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
+ if (!ast)
+ return false;
+ clang::ASTContext* clang_ast = ast->getASTContext();
+
+ clang::ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl (type);
+
+ if (class_interface_decl)
+ {
+ CompilerType property_clang_type_to_access;
+
+ if (property_clang_type.IsValid())
+ property_clang_type_to_access = property_clang_type;
+ else if (ivar_decl)
+ property_clang_type_to_access = CompilerType (clang_ast, ivar_decl->getType());
+
+ if (class_interface_decl && property_clang_type_to_access.IsValid())
+ {
+ clang::TypeSourceInfo *prop_type_source;
+ if (ivar_decl)
+ prop_type_source = clang_ast->getTrivialTypeSourceInfo (ivar_decl->getType());
else
+ prop_type_source = clang_ast->getTrivialTypeSourceInfo (GetQualType(property_clang_type));
+
+ clang::ObjCPropertyDecl *property_decl = clang::ObjCPropertyDecl::Create (*clang_ast,
+ class_interface_decl,
+ clang::SourceLocation(), // Source Location
+ &clang_ast->Idents.get(property_name),
+ clang::SourceLocation(), //Source Location for AT
+ clang::SourceLocation(), //Source location for (
+ ivar_decl ? ivar_decl->getType() : ClangASTContext::GetQualType(property_clang_type),
+ prop_type_source);
+
+ if (property_decl)
{
- language_object_name.SetCString("this");
- is_instance_method = true;
+ if (metadata)
+ ClangASTContext::SetMetadata(clang_ast, property_decl, *metadata);
+
+ class_interface_decl->addDecl (property_decl);
+
+ clang::Selector setter_sel, getter_sel;
+
+ if (property_setter_name != nullptr)
+ {
+ std::string property_setter_no_colon(property_setter_name, strlen(property_setter_name) - 1);
+ clang::IdentifierInfo *setter_ident = &clang_ast->Idents.get(property_setter_no_colon.c_str());
+ setter_sel = clang_ast->Selectors.getSelector(1, &setter_ident);
+ }
+ else if (!(property_attributes & DW_APPLE_PROPERTY_readonly))
+ {
+ std::string setter_sel_string("set");
+ setter_sel_string.push_back(::toupper(property_name[0]));
+ setter_sel_string.append(&property_name[1]);
+ clang::IdentifierInfo *setter_ident = &clang_ast->Idents.get(setter_sel_string.c_str());
+ setter_sel = clang_ast->Selectors.getSelector(1, &setter_ident);
+ }
+ property_decl->setSetterName(setter_sel);
+ property_decl->setPropertyAttributes (clang::ObjCPropertyDecl::OBJC_PR_setter);
+
+ if (property_getter_name != nullptr)
+ {
+ clang::IdentifierInfo *getter_ident = &clang_ast->Idents.get(property_getter_name);
+ getter_sel = clang_ast->Selectors.getSelector(0, &getter_ident);
+ }
+ else
+ {
+ clang::IdentifierInfo *getter_ident = &clang_ast->Idents.get(property_name);
+ getter_sel = clang_ast->Selectors.getSelector(0, &getter_ident);
+ }
+ property_decl->setGetterName(getter_sel);
+ property_decl->setPropertyAttributes (clang::ObjCPropertyDecl::OBJC_PR_getter);
+
+ if (ivar_decl)
+ property_decl->setPropertyIvarDecl (ivar_decl);
+
+ if (property_attributes & DW_APPLE_PROPERTY_readonly)
+ property_decl->setPropertyAttributes (clang::ObjCPropertyDecl::OBJC_PR_readonly);
+ if (property_attributes & DW_APPLE_PROPERTY_readwrite)
+ property_decl->setPropertyAttributes (clang::ObjCPropertyDecl::OBJC_PR_readwrite);
+ if (property_attributes & DW_APPLE_PROPERTY_assign)
+ property_decl->setPropertyAttributes (clang::ObjCPropertyDecl::OBJC_PR_assign);
+ if (property_attributes & DW_APPLE_PROPERTY_retain)
+ property_decl->setPropertyAttributes (clang::ObjCPropertyDecl::OBJC_PR_retain);
+ if (property_attributes & DW_APPLE_PROPERTY_copy)
+ property_decl->setPropertyAttributes (clang::ObjCPropertyDecl::OBJC_PR_copy);
+ if (property_attributes & DW_APPLE_PROPERTY_nonatomic)
+ property_decl->setPropertyAttributes (clang::ObjCPropertyDecl::OBJC_PR_nonatomic);
+
+ if (!getter_sel.isNull() && !class_interface_decl->lookupInstanceMethod(getter_sel))
+ {
+ const bool isInstance = true;
+ const bool isVariadic = false;
+ const bool isSynthesized = false;
+ const bool isImplicitlyDeclared = true;
+ const bool isDefined = false;
+ const clang::ObjCMethodDecl::ImplementationControl impControl = clang::ObjCMethodDecl::None;
+ const bool HasRelatedResultType = false;
+
+ clang::ObjCMethodDecl *getter = clang::ObjCMethodDecl::Create (*clang_ast,
+ clang::SourceLocation(),
+ clang::SourceLocation(),
+ getter_sel,
+ GetQualType(property_clang_type_to_access),
+ nullptr,
+ class_interface_decl,
+ isInstance,
+ isVariadic,
+ isSynthesized,
+ isImplicitlyDeclared,
+ isDefined,
+ impControl,
+ HasRelatedResultType);
+
+ if (getter && metadata)
+ ClangASTContext::SetMetadata(clang_ast, getter, *metadata);
+
+ if (getter)
+ {
+ getter->setMethodParams(*clang_ast, llvm::ArrayRef<clang::ParmVarDecl*>(), llvm::ArrayRef<clang::SourceLocation>());
+
+ class_interface_decl->addDecl(getter);
+ }
+ }
+
+ if (!setter_sel.isNull() && !class_interface_decl->lookupInstanceMethod(setter_sel))
+ {
+ clang::QualType result_type = clang_ast->VoidTy;
+
+ const bool isInstance = true;
+ const bool isVariadic = false;
+ const bool isSynthesized = false;
+ const bool isImplicitlyDeclared = true;
+ const bool isDefined = false;
+ const clang::ObjCMethodDecl::ImplementationControl impControl = clang::ObjCMethodDecl::None;
+ const bool HasRelatedResultType = false;
+
+ clang::ObjCMethodDecl *setter = clang::ObjCMethodDecl::Create (*clang_ast,
+ clang::SourceLocation(),
+ clang::SourceLocation(),
+ setter_sel,
+ result_type,
+ nullptr,
+ class_interface_decl,
+ isInstance,
+ isVariadic,
+ isSynthesized,
+ isImplicitlyDeclared,
+ isDefined,
+ impControl,
+ HasRelatedResultType);
+
+ if (setter && metadata)
+ ClangASTContext::SetMetadata(clang_ast, setter, *metadata);
+
+ llvm::SmallVector<clang::ParmVarDecl *, 1> params;
+
+ params.push_back (clang::ParmVarDecl::Create (*clang_ast,
+ setter,
+ clang::SourceLocation(),
+ clang::SourceLocation(),
+ nullptr, // anonymous
+ GetQualType(property_clang_type_to_access),
+ nullptr,
+ clang::SC_Auto,
+ nullptr));
+
+ if (setter)
+ {
+ setter->setMethodParams(*clang_ast, llvm::ArrayRef<clang::ParmVarDecl*>(params), llvm::ArrayRef<clang::SourceLocation>());
+
+ class_interface_decl->addDecl(setter);
+ }
+ }
+
+ return true;
}
- language = eLanguageTypeC_plus_plus;
+ }
+ }
+ return false;
+}
+
+bool
+ClangASTContext::IsObjCClassTypeAndHasIVars (const CompilerType& type, bool check_superclass)
+{
+ clang::ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl (type);
+ if (class_interface_decl)
+ return ObjCDeclHasIVars (class_interface_decl, check_superclass);
+ return false;
+}
+
+
+clang::ObjCMethodDecl *
+ClangASTContext::AddMethodToObjCObjectType (const CompilerType& type,
+ const char *name, // the full symbol name as seen in the symbol table (lldb::opaque_compiler_type_t type, "-[NString stringWithCString:]")
+ const CompilerType &method_clang_type,
+ lldb::AccessType access,
+ bool is_artificial)
+{
+ if (!type || !method_clang_type.IsValid())
+ return nullptr;
+
+ clang::ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl(type);
+
+ if (class_interface_decl == nullptr)
+ return nullptr;
+ ClangASTContext *lldb_ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
+ if (lldb_ast == nullptr)
+ return nullptr;
+ clang::ASTContext *ast = lldb_ast->getASTContext();
+
+ const char *selector_start = ::strchr (name, ' ');
+ if (selector_start == nullptr)
+ return nullptr;
+
+ selector_start++;
+ llvm::SmallVector<clang::IdentifierInfo *, 12> selector_idents;
+
+ size_t len = 0;
+ const char *start;
+ //printf ("name = '%s'\n", name);
+
+ unsigned num_selectors_with_args = 0;
+ for (start = selector_start;
+ start && *start != '\0' && *start != ']';
+ start += len)
+ {
+ len = ::strcspn(start, ":]");
+ bool has_arg = (start[len] == ':');
+ if (has_arg)
+ ++num_selectors_with_args;
+ selector_idents.push_back (&ast->Idents.get (llvm::StringRef (start, len)));
+ if (has_arg)
+ len += 1;
+ }
+
+
+ if (selector_idents.size() == 0)
+ return nullptr;
+
+ clang::Selector method_selector = ast->Selectors.getSelector (num_selectors_with_args ? selector_idents.size() : 0,
+ selector_idents.data());
+
+ clang::QualType method_qual_type (GetQualType(method_clang_type));
+
+ // Populate the method decl with parameter decls
+ const clang::Type *method_type(method_qual_type.getTypePtr());
+
+ if (method_type == nullptr)
+ return nullptr;
+
+ const clang::FunctionProtoType *method_function_prototype (llvm::dyn_cast<clang::FunctionProtoType>(method_type));
+
+ if (!method_function_prototype)
+ return nullptr;
+
+
+ bool is_variadic = false;
+ bool is_synthesized = false;
+ bool is_defined = false;
+ clang::ObjCMethodDecl::ImplementationControl imp_control = clang::ObjCMethodDecl::None;
+
+ const unsigned num_args = method_function_prototype->getNumParams();
+
+ if (num_args != num_selectors_with_args)
+ return nullptr; // some debug information is corrupt. We are not going to deal with it.
+
+ clang::ObjCMethodDecl *objc_method_decl = clang::ObjCMethodDecl::Create (*ast,
+ clang::SourceLocation(), // beginLoc,
+ clang::SourceLocation(), // endLoc,
+ method_selector,
+ method_function_prototype->getReturnType(),
+ nullptr, // TypeSourceInfo *ResultTInfo,
+ ClangASTContext::GetASTContext(ast)->GetDeclContextForType(GetQualType(type)),
+ name[0] == '-',
+ is_variadic,
+ is_synthesized,
+ true, // is_implicitly_declared; we force this to true because we don't have source locations
+ is_defined,
+ imp_control,
+ false /*has_related_result_type*/);
+
+
+ if (objc_method_decl == nullptr)
+ return nullptr;
+
+ if (num_args > 0)
+ {
+ llvm::SmallVector<clang::ParmVarDecl *, 12> params;
+
+ for (unsigned param_index = 0; param_index < num_args; ++param_index)
+ {
+ params.push_back (clang::ParmVarDecl::Create (*ast,
+ objc_method_decl,
+ clang::SourceLocation(),
+ clang::SourceLocation(),
+ nullptr, // anonymous
+ method_function_prototype->getParamType(param_index),
+ nullptr,
+ clang::SC_Auto,
+ nullptr));
+ }
+
+ objc_method_decl->setMethodParams(*ast, llvm::ArrayRef<clang::ParmVarDecl*>(params), llvm::ArrayRef<clang::SourceLocation>());
+ }
+
+ class_interface_decl->addDecl (objc_method_decl);
+
+#ifdef LLDB_CONFIGURATION_DEBUG
+ VerifyDecl(objc_method_decl);
+#endif
+
+ return objc_method_decl;
+}
+
+bool
+ClangASTContext::GetHasExternalStorage (const CompilerType &type)
+{
+ if (IsClangType(type))
+ return false;
+
+ clang::QualType qual_type (GetCanonicalQualType(type));
+
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Record:
+ {
+ clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+ if (cxx_record_decl)
+ return cxx_record_decl->hasExternalLexicalStorage () || cxx_record_decl->hasExternalVisibleStorage();
+ }
+ break;
+
+ case clang::Type::Enum:
+ {
+ clang::EnumDecl *enum_decl = llvm::cast<clang::EnumType>(qual_type)->getDecl();
+ if (enum_decl)
+ return enum_decl->hasExternalLexicalStorage () || enum_decl->hasExternalVisibleStorage();
+ }
+ break;
+
+ case clang::Type::ObjCObject:
+ case clang::Type::ObjCInterface:
+ {
+ const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
+ assert (objc_class_type);
+ if (objc_class_type)
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+
+ if (class_interface_decl)
+ return class_interface_decl->hasExternalLexicalStorage () || class_interface_decl->hasExternalVisibleStorage ();
+ }
+ }
+ break;
+
+ case clang::Type::Typedef:
+ return GetHasExternalStorage (CompilerType(type.GetTypeSystem(), llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()));
+
+ case clang::Type::Auto:
+ return GetHasExternalStorage (CompilerType(type.GetTypeSystem(), llvm::cast<clang::AutoType>(qual_type)->getDeducedType().getAsOpaquePtr()));
+
+ case clang::Type::Elaborated:
+ return GetHasExternalStorage (CompilerType(type.GetTypeSystem(), llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr()));
+
+ case clang::Type::Paren:
+ return GetHasExternalStorage (CompilerType(type.GetTypeSystem(), llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
+
+ default:
+ break;
+ }
+ return false;
+}
+
+
+bool
+ClangASTContext::SetHasExternalStorage (lldb::opaque_compiler_type_t type, bool has_extern)
+{
+ if (!type)
+ return false;
+
+ clang::QualType qual_type (GetCanonicalQualType(type));
+
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Record:
+ {
+ clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+ if (cxx_record_decl)
+ {
+ cxx_record_decl->setHasExternalLexicalStorage (has_extern);
+ cxx_record_decl->setHasExternalVisibleStorage (has_extern);
+ return true;
+ }
+ }
+ break;
+
+ case clang::Type::Enum:
+ {
+ clang::EnumDecl *enum_decl = llvm::cast<clang::EnumType>(qual_type)->getDecl();
+ if (enum_decl)
+ {
+ enum_decl->setHasExternalLexicalStorage (has_extern);
+ enum_decl->setHasExternalVisibleStorage (has_extern);
+ return true;
+ }
+ }
+ break;
+
+ case clang::Type::ObjCObject:
+ case clang::Type::ObjCInterface:
+ {
+ const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
+ assert (objc_class_type);
+ if (objc_class_type)
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+
+ if (class_interface_decl)
+ {
+ class_interface_decl->setHasExternalLexicalStorage (has_extern);
+ class_interface_decl->setHasExternalVisibleStorage (has_extern);
+ return true;
+ }
+ }
+ }
+ break;
+
+ case clang::Type::Typedef:
+ return SetHasExternalStorage(llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), has_extern);
+
+ case clang::Type::Auto:
+ return SetHasExternalStorage (llvm::cast<clang::AutoType>(qual_type)->getDeducedType().getAsOpaquePtr(), has_extern);
+
+ case clang::Type::Elaborated:
+ return SetHasExternalStorage (llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(), has_extern);
+
+ case clang::Type::Paren:
+ return SetHasExternalStorage (llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(), has_extern);
+
+ default:
+ break;
+ }
+ return false;
+}
+
+
+bool
+ClangASTContext::CanImport (const CompilerType &type, lldb_private::ClangASTImporter &importer)
+{
+ if (IsClangType(type))
+ {
+ // TODO: remove external completion BOOL
+ // CompleteAndFetchChildren should get the Decl out and check for the
+
+ clang::QualType qual_type(GetCanonicalQualType(RemoveFastQualifiers(type)));
+
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Record:
+ {
+ const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+ if (cxx_record_decl)
+ {
+ if (importer.ResolveDeclOrigin (cxx_record_decl, NULL, NULL))
+ return true;
+ }
+ }
+ break;
+
+ case clang::Type::Enum:
+ {
+ clang::EnumDecl *enum_decl = llvm::cast<clang::EnumType>(qual_type)->getDecl();
+ if (enum_decl)
+ {
+ if (importer.ResolveDeclOrigin (enum_decl, NULL, NULL))
+ return true;
+ }
+ }
+ break;
+
+ case clang::Type::ObjCObject:
+ case clang::Type::ObjCInterface:
+ {
+ const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
+ if (objc_class_type)
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+ // 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 (importer.ResolveDeclOrigin (class_interface_decl, NULL, NULL))
+ return true;
+ }
+ }
+ }
+ break;
+
+
+ case clang::Type::Typedef:
+ return CanImport(CompilerType (type.GetTypeSystem(), llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()), importer);
+
+ case clang::Type::Auto:
+ return CanImport(CompilerType (type.GetTypeSystem(), llvm::cast<clang::AutoType>(qual_type)->getDeducedType().getAsOpaquePtr()), importer);
+
+ case clang::Type::Elaborated:
+ return CanImport(CompilerType (type.GetTypeSystem(), llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr()), importer);
+
+ case clang::Type::Paren:
+ return CanImport(CompilerType (type.GetTypeSystem(), llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()), importer);
+
+ default:
+ break;
+ }
+ }
+ return false;
+}
+bool
+ClangASTContext::Import (const CompilerType &type, lldb_private::ClangASTImporter &importer)
+{
+ if (IsClangType(type))
+ {
+ // TODO: remove external completion BOOL
+ // CompleteAndFetchChildren should get the Decl out and check for the
+
+ clang::QualType qual_type(GetCanonicalQualType(RemoveFastQualifiers(type)));
+
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Record:
+ {
+ const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+ if (cxx_record_decl)
+ {
+ if (importer.ResolveDeclOrigin (cxx_record_decl, NULL, NULL))
+ return importer.CompleteAndFetchChildren(qual_type);
+ }
+ }
+ break;
+
+ case clang::Type::Enum:
+ {
+ clang::EnumDecl *enum_decl = llvm::cast<clang::EnumType>(qual_type)->getDecl();
+ if (enum_decl)
+ {
+ if (importer.ResolveDeclOrigin (enum_decl, NULL, NULL))
+ return importer.CompleteAndFetchChildren(qual_type);
+ }
+ }
+ break;
+
+ case clang::Type::ObjCObject:
+ case clang::Type::ObjCInterface:
+ {
+ const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
+ if (objc_class_type)
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+ // 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 (importer.ResolveDeclOrigin (class_interface_decl, NULL, NULL))
+ return importer.CompleteAndFetchChildren(qual_type);
+ }
+ }
+ }
+ break;
+
+
+ case clang::Type::Typedef:
+ return Import (CompilerType(type.GetTypeSystem(), llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()), importer);
+
+ case clang::Type::Auto:
+ return Import (CompilerType(type.GetTypeSystem(),llvm::cast<clang::AutoType>(qual_type)->getDeducedType().getAsOpaquePtr()), importer);
+
+ case clang::Type::Elaborated:
+ return Import (CompilerType(type.GetTypeSystem(),llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr()), importer);
+
+ case clang::Type::Paren:
+ return Import (CompilerType(type.GetTypeSystem(),llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()), importer);
+
+ default:
+ break;
+ }
+ }
+ return false;
+}
+
+
+#pragma mark TagDecl
+
+bool
+ClangASTContext::StartTagDeclarationDefinition (const CompilerType &type)
+{
+ clang::QualType qual_type (ClangASTContext::GetQualType(type));
+ if (!qual_type.isNull())
+ {
+ const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
+ if (tag_type)
+ {
+ clang::TagDecl *tag_decl = tag_type->getDecl();
+ if (tag_decl)
+ {
+ tag_decl->startDefinition();
+ return true;
+ }
+ }
+
+ const clang::ObjCObjectType *object_type = qual_type->getAs<clang::ObjCObjectType>();
+ if (object_type)
+ {
+ clang::ObjCInterfaceDecl *interface_decl = object_type->getInterface();
+ if (interface_decl)
+ {
+ interface_decl->startDefinition();
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+bool
+ClangASTContext::CompleteTagDeclarationDefinition (const CompilerType& type)
+{
+ clang::QualType qual_type (ClangASTContext::GetQualType(type));
+ if (!qual_type.isNull())
+ {
+ clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+
+ if (cxx_record_decl)
+ {
+ if (!cxx_record_decl->isCompleteDefinition())
+ cxx_record_decl->completeDefinition();
+ cxx_record_decl->setHasLoadedFieldsFromExternalStorage(true);
+ cxx_record_decl->setHasExternalLexicalStorage (false);
+ cxx_record_decl->setHasExternalVisibleStorage (false);
return true;
}
- else if (clang::ObjCMethodDecl *method_decl = llvm::dyn_cast<clang::ObjCMethodDecl>(decl_ctx))
+
+ const clang::EnumType *enutype = qual_type->getAs<clang::EnumType>();
+
+ if (enutype)
{
- // Both static and instance methods have a "self" object in objective C
- language_object_name.SetCString("self");
- if (method_decl->isInstanceMethod())
+ clang::EnumDecl *enum_decl = enutype->getDecl();
+
+ if (enum_decl)
{
- is_instance_method = true;
+ if (!enum_decl->isCompleteDefinition())
+ {
+ ClangASTContext *lldb_ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
+ if (lldb_ast == nullptr)
+ return false;
+ clang::ASTContext *ast = lldb_ast->getASTContext();
+
+ /// TODO This really needs to be fixed.
+
+ unsigned NumPositiveBits = 1;
+ unsigned NumNegativeBits = 0;
+
+ clang::QualType promotion_qual_type;
+ // If the enum integer type is less than an integer in bit width,
+ // then we must promote it to an integer size.
+ if (ast->getTypeSize(enum_decl->getIntegerType()) < ast->getTypeSize(ast->IntTy))
+ {
+ if (enum_decl->getIntegerType()->isSignedIntegerType())
+ promotion_qual_type = ast->IntTy;
+ else
+ promotion_qual_type = ast->UnsignedIntTy;
+ }
+ else
+ promotion_qual_type = enum_decl->getIntegerType();
+
+ enum_decl->completeDefinition(enum_decl->getIntegerType(), promotion_qual_type, NumPositiveBits, NumNegativeBits);
+ }
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+bool
+ClangASTContext::AddEnumerationValueToEnumerationType (lldb::opaque_compiler_type_t type,
+ const CompilerType &enumerator_clang_type,
+ const Declaration &decl,
+ const char *name,
+ int64_t enum_value,
+ uint32_t enum_value_bit_size)
+{
+ if (type && enumerator_clang_type.IsValid() && name && name[0])
+ {
+ clang::QualType enum_qual_type (GetCanonicalQualType(type));
+
+ bool is_signed = false;
+ enumerator_clang_type.IsIntegerType (is_signed);
+ const clang::Type *clang_type = enum_qual_type.getTypePtr();
+ if (clang_type)
+ {
+ const clang::EnumType *enutype = llvm::dyn_cast<clang::EnumType>(clang_type);
+
+ if (enutype)
+ {
+ llvm::APSInt enum_llvm_apsint(enum_value_bit_size, is_signed);
+ enum_llvm_apsint = enum_value;
+ clang::EnumConstantDecl *enumerator_decl =
+ clang::EnumConstantDecl::Create (*getASTContext(),
+ enutype->getDecl(),
+ clang::SourceLocation(),
+ name ? &getASTContext()->Idents.get(name) : nullptr, // Identifier
+ GetQualType(enumerator_clang_type),
+ nullptr,
+ enum_llvm_apsint);
+
+ if (enumerator_decl)
+ {
+ enutype->getDecl()->addDecl(enumerator_decl);
+
+#ifdef LLDB_CONFIGURATION_DEBUG
+ VerifyDecl(enumerator_decl);
+#endif
+
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+CompilerType
+ClangASTContext::GetEnumerationIntegerType (lldb::opaque_compiler_type_t type)
+{
+ clang::QualType enum_qual_type (GetCanonicalQualType(type));
+ const clang::Type *clang_type = enum_qual_type.getTypePtr();
+ if (clang_type)
+ {
+ const clang::EnumType *enutype = llvm::dyn_cast<clang::EnumType>(clang_type);
+ if (enutype)
+ {
+ clang::EnumDecl *enum_decl = enutype->getDecl();
+ if (enum_decl)
+ return CompilerType (getASTContext(), enum_decl->getIntegerType());
+ }
+ }
+ return CompilerType();
+}
+
+CompilerType
+ClangASTContext::CreateMemberPointerType (const CompilerType& type, const CompilerType &pointee_type)
+{
+ if (type && pointee_type.IsValid() && type.GetTypeSystem() == pointee_type.GetTypeSystem())
+ {
+ ClangASTContext *ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
+ if (!ast)
+ return CompilerType();
+ return CompilerType (ast->getASTContext(),
+ ast->getASTContext()->getMemberPointerType (GetQualType(pointee_type),
+ GetQualType(type).getTypePtr()));
+ }
+ return CompilerType();
+}
+
+
+size_t
+ClangASTContext::ConvertStringToFloatValue (lldb::opaque_compiler_type_t type, const char *s, uint8_t *dst, size_t dst_size)
+{
+ if (type)
+ {
+ clang::QualType qual_type (GetCanonicalQualType(type));
+ uint32_t count = 0;
+ bool is_complex = false;
+ if (IsFloatingPointType (type, count, is_complex))
+ {
+ // TODO: handle complex and vector types
+ if (count != 1)
+ return false;
+
+ llvm::StringRef s_sref(s);
+ llvm::APFloat ap_float(getASTContext()->getFloatTypeSemantics(qual_type), s_sref);
+
+ const uint64_t bit_size = getASTContext()->getTypeSize (qual_type);
+ const uint64_t byte_size = bit_size / 8;
+ if (dst_size >= byte_size)
+ {
+ if (bit_size == sizeof(float)*8)
+ {
+ float float32 = ap_float.convertToFloat();
+ ::memcpy (dst, &float32, byte_size);
+ return byte_size;
+ }
+ else if (bit_size >= 64)
+ {
+ llvm::APInt ap_int(ap_float.bitcastToAPInt());
+ ::memcpy (dst, ap_int.getRawData(), byte_size);
+ return byte_size;
+ }
+ }
+ }
+ }
+ return 0;
+}
+
+
+
+//----------------------------------------------------------------------
+// Dumping types
+//----------------------------------------------------------------------
+#define DEPTH_INCREMENT 2
+
+void
+ClangASTContext::DumpValue (lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
+ Stream *s,
+ lldb::Format format,
+ const lldb_private::DataExtractor &data,
+ lldb::offset_t data_byte_offset,
+ size_t data_byte_size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset,
+ bool show_types,
+ bool show_summary,
+ bool verbose,
+ uint32_t depth)
+{
+ if (!type)
+ return;
+
+ clang::QualType qual_type(GetQualType(type));
+ switch (qual_type->getTypeClass())
+ {
+ case clang::Type::Record:
+ if (GetCompleteType(type))
+ {
+ const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
+ const clang::RecordDecl *record_decl = record_type->getDecl();
+ assert(record_decl);
+ uint32_t field_bit_offset = 0;
+ uint32_t field_byte_offset = 0;
+ const clang::ASTRecordLayout &record_layout = getASTContext()->getASTRecordLayout(record_decl);
+ uint32_t child_idx = 0;
+
+ const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
+ if (cxx_record_decl)
+ {
+ // We might have base classes to print out first
+ clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
+ for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
+ base_class != base_class_end;
+ ++base_class)
+ {
+ const clang::CXXRecordDecl *base_class_decl = llvm::cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl());
+
+ // Skip empty base classes
+ if (verbose == false && ClangASTContext::RecordHasFields(base_class_decl) == false)
+ continue;
+
+ if (base_class->isVirtual())
+ field_bit_offset = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8;
+ else
+ field_bit_offset = record_layout.getBaseClassOffset(base_class_decl).getQuantity() * 8;
+ field_byte_offset = field_bit_offset / 8;
+ assert (field_bit_offset % 8 == 0);
+ if (child_idx == 0)
+ s->PutChar('{');
+ else
+ s->PutChar(',');
+
+ clang::QualType base_class_qual_type = base_class->getType();
+ std::string base_class_type_name(base_class_qual_type.getAsString());
+
+ // Indent and print the base class type name
+ s->Printf("\n%*s%s ", depth + DEPTH_INCREMENT, "", base_class_type_name.c_str());
+
+ clang::TypeInfo base_class_type_info = getASTContext()->getTypeInfo(base_class_qual_type);
+
+ // Dump the value of the member
+ CompilerType base_clang_type(getASTContext(), base_class_qual_type);
+ base_clang_type.DumpValue (exe_ctx,
+ s, // Stream to dump to
+ base_clang_type.GetFormat(), // The format with which to display the member
+ data, // Data buffer containing all bytes for this type
+ data_byte_offset + field_byte_offset,// Offset into "data" where to grab value from
+ base_class_type_info.Width / 8, // Size of this type in bytes
+ 0, // Bitfield bit size
+ 0, // Bitfield bit offset
+ show_types, // Boolean indicating if we should show the variable types
+ show_summary, // Boolean indicating if we should show a summary for the current type
+ verbose, // Verbose output?
+ depth + DEPTH_INCREMENT); // Scope depth for any types that have children
+
+ ++child_idx;
+ }
+ }
+ uint32_t field_idx = 0;
+ clang::RecordDecl::field_iterator field, field_end;
+ for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++field_idx, ++child_idx)
+ {
+ // Print the starting squiggly bracket (if this is the
+ // first member) or comma (for member 2 and beyond) for
+ // the struct/union/class member.
+ if (child_idx == 0)
+ s->PutChar('{');
+ else
+ s->PutChar(',');
+
+ // Indent
+ s->Printf("\n%*s", depth + DEPTH_INCREMENT, "");
+
+ clang::QualType field_type = field->getType();
+ // Print the member type if requested
+ // Figure out the type byte size (field_type_info.first) and
+ // alignment (field_type_info.second) from the AST context.
+ clang::TypeInfo field_type_info = getASTContext()->getTypeInfo(field_type);
+ assert(field_idx < record_layout.getFieldCount());
+ // Figure out the field offset within the current struct/union/class type
+ field_bit_offset = record_layout.getFieldOffset (field_idx);
+ field_byte_offset = field_bit_offset / 8;
+ uint32_t field_bitfield_bit_size = 0;
+ uint32_t field_bitfield_bit_offset = 0;
+ if (ClangASTContext::FieldIsBitfield (getASTContext(), *field, field_bitfield_bit_size))
+ field_bitfield_bit_offset = field_bit_offset % 8;
+
+ if (show_types)
+ {
+ std::string field_type_name(field_type.getAsString());
+ if (field_bitfield_bit_size > 0)
+ s->Printf("(%s:%u) ", field_type_name.c_str(), field_bitfield_bit_size);
+ else
+ s->Printf("(%s) ", field_type_name.c_str());
+ }
+ // Print the member name and equal sign
+ s->Printf("%s = ", field->getNameAsString().c_str());
+
+
+ // Dump the value of the member
+ CompilerType field_clang_type (getASTContext(), field_type);
+ field_clang_type.DumpValue (exe_ctx,
+ s, // Stream to dump to
+ field_clang_type.GetFormat(), // The format with which to display the member
+ data, // Data buffer containing all bytes for this type
+ data_byte_offset + field_byte_offset,// Offset into "data" where to grab value from
+ field_type_info.Width / 8, // Size of this type in bytes
+ field_bitfield_bit_size, // Bitfield bit size
+ field_bitfield_bit_offset, // Bitfield bit offset
+ show_types, // Boolean indicating if we should show the variable types
+ show_summary, // Boolean indicating if we should show a summary for the current type
+ verbose, // Verbose output?
+ depth + DEPTH_INCREMENT); // Scope depth for any types that have children
+ }
+
+ // Indent the trailing squiggly bracket
+ if (child_idx > 0)
+ s->Printf("\n%*s}", depth, "");
+ }
+ return;
+
+ case clang::Type::Enum:
+ if (GetCompleteType(type))
+ {
+ const clang::EnumType *enutype = llvm::cast<clang::EnumType>(qual_type.getTypePtr());
+ const clang::EnumDecl *enum_decl = enutype->getDecl();
+ assert(enum_decl);
+ clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
+ lldb::offset_t offset = data_byte_offset;
+ const int64_t enum_value = data.GetMaxU64Bitfield(&offset, data_byte_size, bitfield_bit_size, bitfield_bit_offset);
+ for (enum_pos = enum_decl->enumerator_begin(), enum_end_pos = enum_decl->enumerator_end(); enum_pos != enum_end_pos; ++enum_pos)
+ {
+ if (enum_pos->getInitVal() == enum_value)
+ {
+ s->Printf("%s", enum_pos->getNameAsString().c_str());
+ return;
+ }
+ }
+ // If we have gotten here we didn't get find the enumerator in the
+ // enum decl, so just print the integer.
+ s->Printf("%" PRIi64, enum_value);
+ }
+ return;
+
+ case clang::Type::ConstantArray:
+ {
+ const clang::ConstantArrayType *array = llvm::cast<clang::ConstantArrayType>(qual_type.getTypePtr());
+ bool is_array_of_characters = false;
+ clang::QualType element_qual_type = array->getElementType();
+
+ const clang::Type *canonical_type = element_qual_type->getCanonicalTypeInternal().getTypePtr();
+ if (canonical_type)
+ is_array_of_characters = canonical_type->isCharType();
+
+ const uint64_t element_count = array->getSize().getLimitedValue();
+
+ clang::TypeInfo field_type_info = getASTContext()->getTypeInfo(element_qual_type);
+
+ uint32_t element_idx = 0;
+ uint32_t element_offset = 0;
+ uint64_t element_byte_size = field_type_info.Width / 8;
+ uint32_t element_stride = element_byte_size;
+
+ if (is_array_of_characters)
+ {
+ s->PutChar('"');
+ data.Dump(s, data_byte_offset, lldb::eFormatChar, element_byte_size, element_count, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0);
+ s->PutChar('"');
+ return;
}
else
{
- is_instance_method = false;
+ CompilerType element_clang_type(getASTContext(), element_qual_type);
+ lldb::Format element_format = element_clang_type.GetFormat();
+
+ for (element_idx = 0; element_idx < element_count; ++element_idx)
+ {
+ // Print the starting squiggly bracket (if this is the
+ // first member) or comman (for member 2 and beyong) for
+ // the struct/union/class member.
+ if (element_idx == 0)
+ s->PutChar('{');
+ else
+ s->PutChar(',');
+
+ // Indent and print the index
+ s->Printf("\n%*s[%u] ", depth + DEPTH_INCREMENT, "", element_idx);
+
+ // Figure out the field offset within the current struct/union/class type
+ element_offset = element_idx * element_stride;
+
+ // Dump the value of the member
+ element_clang_type.DumpValue (exe_ctx,
+ s, // Stream to dump to
+ element_format, // The format with which to display the element
+ data, // Data buffer containing all bytes for this type
+ data_byte_offset + element_offset,// Offset into "data" where to grab value from
+ element_byte_size, // Size of this type in bytes
+ 0, // Bitfield bit size
+ 0, // Bitfield bit offset
+ show_types, // Boolean indicating if we should show the variable types
+ show_summary, // Boolean indicating if we should show a summary for the current type
+ verbose, // Verbose output?
+ depth + DEPTH_INCREMENT); // Scope depth for any types that have children
+ }
+
+ // Indent the trailing squiggly bracket
+ if (element_idx > 0)
+ s->Printf("\n%*s}", depth, "");
+ }
+ }
+ return;
+
+ case clang::Type::Typedef:
+ {
+ clang::QualType typedef_qual_type = llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType();
+
+ CompilerType typedef_clang_type (getASTContext(), typedef_qual_type);
+ lldb::Format typedef_format = typedef_clang_type.GetFormat();
+ clang::TypeInfo typedef_type_info = getASTContext()->getTypeInfo(typedef_qual_type);
+ uint64_t typedef_byte_size = typedef_type_info.Width / 8;
+
+ return typedef_clang_type.DumpValue (exe_ctx,
+ s, // Stream to dump to
+ typedef_format, // The format with which to display the element
+ data, // Data buffer containing all bytes for this type
+ data_byte_offset, // Offset into "data" where to grab value from
+ typedef_byte_size, // Size of this type in bytes
+ bitfield_bit_size, // Bitfield bit size
+ bitfield_bit_offset,// Bitfield bit offset
+ show_types, // Boolean indicating if we should show the variable types
+ show_summary, // Boolean indicating if we should show a summary for the current type
+ verbose, // Verbose output?
+ depth); // Scope depth for any types that have children
+ }
+ break;
+
+ case clang::Type::Auto:
+ {
+ clang::QualType elaborated_qual_type = llvm::cast<clang::AutoType>(qual_type)->getDeducedType();
+ CompilerType elaborated_clang_type (getASTContext(), elaborated_qual_type);
+ lldb::Format elaborated_format = elaborated_clang_type.GetFormat();
+ clang::TypeInfo elaborated_type_info = getASTContext()->getTypeInfo(elaborated_qual_type);
+ uint64_t elaborated_byte_size = elaborated_type_info.Width / 8;
+
+ return elaborated_clang_type.DumpValue (exe_ctx,
+ s, // Stream to dump to
+ elaborated_format, // The format with which to display the element
+ data, // Data buffer containing all bytes for this type
+ data_byte_offset, // Offset into "data" where to grab value from
+ elaborated_byte_size, // Size of this type in bytes
+ bitfield_bit_size, // Bitfield bit size
+ bitfield_bit_offset,// Bitfield bit offset
+ show_types, // Boolean indicating if we should show the variable types
+ show_summary, // Boolean indicating if we should show a summary for the current type
+ verbose, // Verbose output?
+ depth); // Scope depth for any types that have children
+ }
+ break;
+
+ case clang::Type::Elaborated:
+ {
+ clang::QualType elaborated_qual_type = llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType();
+ CompilerType elaborated_clang_type (getASTContext(), elaborated_qual_type);
+ lldb::Format elaborated_format = elaborated_clang_type.GetFormat();
+ clang::TypeInfo elaborated_type_info = getASTContext()->getTypeInfo(elaborated_qual_type);
+ uint64_t elaborated_byte_size = elaborated_type_info.Width / 8;
+
+ return elaborated_clang_type.DumpValue (exe_ctx,
+ s, // Stream to dump to
+ elaborated_format, // The format with which to display the element
+ data, // Data buffer containing all bytes for this type
+ data_byte_offset, // Offset into "data" where to grab value from
+ elaborated_byte_size, // Size of this type in bytes
+ bitfield_bit_size, // Bitfield bit size
+ bitfield_bit_offset,// Bitfield bit offset
+ show_types, // Boolean indicating if we should show the variable types
+ show_summary, // Boolean indicating if we should show a summary for the current type
+ verbose, // Verbose output?
+ depth); // Scope depth for any types that have children
+ }
+ break;
+
+ case clang::Type::Paren:
+ {
+ clang::QualType desugar_qual_type = llvm::cast<clang::ParenType>(qual_type)->desugar();
+ CompilerType desugar_clang_type (getASTContext(), desugar_qual_type);
+
+ lldb::Format desugar_format = desugar_clang_type.GetFormat();
+ clang::TypeInfo desugar_type_info = getASTContext()->getTypeInfo(desugar_qual_type);
+ uint64_t desugar_byte_size = desugar_type_info.Width / 8;
+
+ return desugar_clang_type.DumpValue (exe_ctx,
+ s, // Stream to dump to
+ desugar_format, // The format with which to display the element
+ data, // Data buffer containing all bytes for this type
+ data_byte_offset, // Offset into "data" where to grab value from
+ desugar_byte_size, // Size of this type in bytes
+ bitfield_bit_size, // Bitfield bit size
+ bitfield_bit_offset,// Bitfield bit offset
+ show_types, // Boolean indicating if we should show the variable types
+ show_summary, // Boolean indicating if we should show a summary for the current type
+ verbose, // Verbose output?
+ depth); // Scope depth for any types that have children
+ }
+ break;
+
+ default:
+ // We are down to a scalar type that we just need to display.
+ data.Dump(s,
+ data_byte_offset,
+ format,
+ data_byte_size,
+ 1,
+ UINT32_MAX,
+ LLDB_INVALID_ADDRESS,
+ bitfield_bit_size,
+ bitfield_bit_offset);
+
+ if (show_summary)
+ DumpSummary (type, exe_ctx, s, data, data_byte_offset, data_byte_size);
+ break;
+ }
+}
+
+
+
+
+bool
+ClangASTContext::DumpTypeValue (lldb::opaque_compiler_type_t type, Stream *s,
+ lldb::Format format,
+ const lldb_private::DataExtractor &data,
+ lldb::offset_t byte_offset,
+ size_t byte_size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset,
+ ExecutionContextScope *exe_scope)
+{
+ if (!type)
+ return false;
+ if (IsAggregateType(type))
+ {
+ return false;
+ }
+ else
+ {
+ clang::QualType qual_type(GetQualType(type));
+
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Typedef:
+ {
+ clang::QualType typedef_qual_type = llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType();
+ CompilerType typedef_clang_type (getASTContext(), typedef_qual_type);
+ if (format == eFormatDefault)
+ format = typedef_clang_type.GetFormat();
+ clang::TypeInfo typedef_type_info = getASTContext()->getTypeInfo(typedef_qual_type);
+ uint64_t typedef_byte_size = typedef_type_info.Width / 8;
+
+ return typedef_clang_type.DumpTypeValue (s,
+ format, // The format with which to display the element
+ data, // Data buffer containing all bytes for this type
+ byte_offset, // Offset into "data" where to grab value from
+ typedef_byte_size, // Size of this type in bytes
+ bitfield_bit_size, // Size in bits of a bitfield value, if zero don't treat as a bitfield
+ bitfield_bit_offset, // Offset in bits of a bitfield value if bitfield_bit_size != 0
+ exe_scope);
+ }
+ break;
+
+ case clang::Type::Enum:
+ // If our format is enum or default, show the enumeration value as
+ // its enumeration string value, else just display it as requested.
+ if ((format == eFormatEnum || format == eFormatDefault) && GetCompleteType(type))
+ {
+ const clang::EnumType *enutype = llvm::cast<clang::EnumType>(qual_type.getTypePtr());
+ const clang::EnumDecl *enum_decl = enutype->getDecl();
+ assert(enum_decl);
+ clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
+ const bool is_signed = qual_type->isSignedIntegerOrEnumerationType();
+ lldb::offset_t offset = byte_offset;
+ if (is_signed)
+ {
+ const int64_t enum_svalue = data.GetMaxS64Bitfield (&offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
+ for (enum_pos = enum_decl->enumerator_begin(), enum_end_pos = enum_decl->enumerator_end(); enum_pos != enum_end_pos; ++enum_pos)
+ {
+ if (enum_pos->getInitVal().getSExtValue() == enum_svalue)
+ {
+ s->PutCString (enum_pos->getNameAsString().c_str());
+ return true;
+ }
+ }
+ // If we have gotten here we didn't get find the enumerator in the
+ // enum decl, so just print the integer.
+ s->Printf("%" PRIi64, enum_svalue);
+ }
+ else
+ {
+ const uint64_t enum_uvalue = data.GetMaxU64Bitfield (&offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
+ for (enum_pos = enum_decl->enumerator_begin(), enum_end_pos = enum_decl->enumerator_end(); enum_pos != enum_end_pos; ++enum_pos)
+ {
+ if (enum_pos->getInitVal().getZExtValue() == enum_uvalue)
+ {
+ s->PutCString (enum_pos->getNameAsString().c_str());
+ return true;
+ }
+ }
+ // If we have gotten here we didn't get find the enumerator in the
+ // enum decl, so just print the integer.
+ s->Printf("%" PRIu64, enum_uvalue);
+ }
+ return true;
+ }
+ // format was not enum, just fall through and dump the value as requested....
+
+ default:
+ // We are down to a scalar type that we just need to display.
+ {
+ uint32_t item_count = 1;
+ // A few formats, we might need to modify our size and count for depending
+ // on how we are trying to display the value...
+ switch (format)
+ {
+ default:
+ case eFormatBoolean:
+ case eFormatBinary:
+ case eFormatComplex:
+ case eFormatCString: // NULL terminated C strings
+ case eFormatDecimal:
+ case eFormatEnum:
+ case eFormatHex:
+ case eFormatHexUppercase:
+ case eFormatFloat:
+ case eFormatOctal:
+ case eFormatOSType:
+ case eFormatUnsigned:
+ case eFormatPointer:
+ case eFormatVectorOfChar:
+ case eFormatVectorOfSInt8:
+ case eFormatVectorOfUInt8:
+ case eFormatVectorOfSInt16:
+ case eFormatVectorOfUInt16:
+ case eFormatVectorOfSInt32:
+ case eFormatVectorOfUInt32:
+ case eFormatVectorOfSInt64:
+ case eFormatVectorOfUInt64:
+ case eFormatVectorOfFloat32:
+ case eFormatVectorOfFloat64:
+ case eFormatVectorOfUInt128:
+ break;
+
+ case eFormatChar:
+ case eFormatCharPrintable:
+ case eFormatCharArray:
+ case eFormatBytes:
+ case eFormatBytesWithASCII:
+ item_count = byte_size;
+ byte_size = 1;
+ break;
+
+ case eFormatUnicode16:
+ item_count = byte_size / 2;
+ byte_size = 2;
+ break;
+
+ case eFormatUnicode32:
+ item_count = byte_size / 4;
+ byte_size = 4;
+ break;
+ }
+ return data.Dump (s,
+ byte_offset,
+ format,
+ byte_size,
+ item_count,
+ UINT32_MAX,
+ LLDB_INVALID_ADDRESS,
+ bitfield_bit_size,
+ bitfield_bit_offset,
+ exe_scope);
+ }
+ break;
+ }
+ }
+ return 0;
+}
+
+
+
+void
+ClangASTContext::DumpSummary (lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
+ Stream *s,
+ const lldb_private::DataExtractor &data,
+ lldb::offset_t data_byte_offset,
+ size_t data_byte_size)
+{
+ uint32_t length = 0;
+ if (IsCStringType (type, length))
+ {
+ if (exe_ctx)
+ {
+ Process *process = exe_ctx->GetProcessPtr();
+ if (process)
+ {
+ lldb::offset_t offset = data_byte_offset;
+ lldb::addr_t pointer_address = data.GetMaxU64(&offset, data_byte_size);
+ std::vector<uint8_t> buf;
+ if (length > 0)
+ buf.resize (length);
+ else
+ buf.resize (256);
+
+ lldb_private::DataExtractor cstr_data(&buf.front(), buf.size(), process->GetByteOrder(), 4);
+ buf.back() = '\0';
+ size_t bytes_read;
+ size_t total_cstr_len = 0;
+ Error error;
+ while ((bytes_read = process->ReadMemory (pointer_address, &buf.front(), buf.size(), error)) > 0)
+ {
+ const size_t len = strlen((const char *)&buf.front());
+ if (len == 0)
+ break;
+ if (total_cstr_len == 0)
+ s->PutCString (" \"");
+ cstr_data.Dump(s, 0, lldb::eFormatChar, 1, len, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0);
+ total_cstr_len += len;
+ if (len < buf.size())
+ break;
+ pointer_address += total_cstr_len;
+ }
+ if (total_cstr_len > 0)
+ s->PutChar ('"');
+ }
+ }
+ }
+}
+
+void
+ClangASTContext::DumpTypeDescription (lldb::opaque_compiler_type_t type)
+{
+ StreamFile s (stdout, false);
+ DumpTypeDescription (type, &s);
+ ClangASTMetadata *metadata = ClangASTContext::GetMetadata (getASTContext(), type);
+ if (metadata)
+ {
+ metadata->Dump (&s);
+ }
+}
+
+void
+ClangASTContext::DumpTypeDescription (lldb::opaque_compiler_type_t type, Stream *s)
+{
+ if (type)
+ {
+ clang::QualType qual_type(GetQualType(type));
+
+ llvm::SmallVector<char, 1024> buf;
+ llvm::raw_svector_ostream llvm_ostrm (buf);
+
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::ObjCObject:
+ case clang::Type::ObjCInterface:
+ {
+ GetCompleteType(type);
+
+ const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
+ assert (objc_class_type);
+ if (objc_class_type)
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+ if (class_interface_decl)
+ {
+ clang::PrintingPolicy policy = getASTContext()->getPrintingPolicy();
+ class_interface_decl->print(llvm_ostrm, policy, s->GetIndentLevel());
+ }
+ }
+ }
+ break;
+
+ case clang::Type::Typedef:
+ {
+ const clang::TypedefType *typedef_type = qual_type->getAs<clang::TypedefType>();
+ if (typedef_type)
+ {
+ const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
+ std::string clang_typedef_name (typedef_decl->getQualifiedNameAsString());
+ if (!clang_typedef_name.empty())
+ {
+ s->PutCString ("typedef ");
+ s->PutCString (clang_typedef_name.c_str());
+ }
+ }
+ }
+ break;
+
+ case clang::Type::Auto:
+ CompilerType (getASTContext(), llvm::cast<clang::AutoType>(qual_type)->getDeducedType()).DumpTypeDescription(s);
+ return;
+
+ case clang::Type::Elaborated:
+ CompilerType (getASTContext(), llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).DumpTypeDescription(s);
+ return;
+
+ case clang::Type::Paren:
+ CompilerType (getASTContext(), llvm::cast<clang::ParenType>(qual_type)->desugar()).DumpTypeDescription(s);
+ return;
+
+ case clang::Type::Record:
+ {
+ GetCompleteType(type);
+
+ const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
+ const clang::RecordDecl *record_decl = record_type->getDecl();
+ const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
+
+ if (cxx_record_decl)
+ cxx_record_decl->print(llvm_ostrm, getASTContext()->getPrintingPolicy(), s->GetIndentLevel());
+ else
+ record_decl->print(llvm_ostrm, getASTContext()->getPrintingPolicy(), s->GetIndentLevel());
+ }
+ break;
+
+ default:
+ {
+ const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
+ if (tag_type)
+ {
+ clang::TagDecl *tag_decl = tag_type->getDecl();
+ if (tag_decl)
+ tag_decl->print(llvm_ostrm, 0);
+ }
+ else
+ {
+ std::string clang_type_name(qual_type.getAsString());
+ if (!clang_type_name.empty())
+ s->PutCString (clang_type_name.c_str());
+ }
+ }
+ }
+
+ if (buf.size() > 0)
+ {
+ s->Write (buf.data(), buf.size());
+ }
+ }
+}
+
+void
+ClangASTContext::DumpTypeName (const CompilerType &type)
+{
+ if (IsClangType(type))
+ {
+ clang::QualType qual_type(GetCanonicalQualType(RemoveFastQualifiers(type)));
+
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Record:
+ {
+ const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+ if (cxx_record_decl)
+ printf("class %s", cxx_record_decl->getName().str().c_str());
+ }
+ break;
+
+ case clang::Type::Enum:
+ {
+ clang::EnumDecl *enum_decl = llvm::cast<clang::EnumType>(qual_type)->getDecl();
+ if (enum_decl)
+ {
+ printf("enum %s", enum_decl->getName().str().c_str());
+ }
+ }
+ break;
+
+ case clang::Type::ObjCObject:
+ case clang::Type::ObjCInterface:
+ {
+ const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
+ if (objc_class_type)
+ {
+ clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+ // 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)
+ printf("@class %s", class_interface_decl->getName().str().c_str());
+ }
+ }
+ break;
+
+
+ case clang::Type::Typedef:
+ printf("typedef %s", llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getName().str().c_str());
+ break;
+
+ case clang::Type::Auto:
+ printf("auto ");
+ return DumpTypeName (CompilerType (type.GetTypeSystem(), llvm::cast<clang::AutoType>(qual_type)->getDeducedType().getAsOpaquePtr()));
+
+ case clang::Type::Elaborated:
+ printf("elaborated ");
+ return DumpTypeName (CompilerType (type.GetTypeSystem(), llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr()));
+
+ case clang::Type::Paren:
+ printf("paren ");
+ return DumpTypeName (CompilerType (type.GetTypeSystem(), llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
+
+ default:
+ printf("ClangASTContext::DumpTypeName() type_class = %u", type_class);
+ break;
+ }
+ }
+
+}
+
+
+
+clang::ClassTemplateDecl *
+ClangASTContext::ParseClassTemplateDecl (clang::DeclContext *decl_ctx,
+ lldb::AccessType access_type,
+ const char *parent_name,
+ int tag_decl_kind,
+ const ClangASTContext::TemplateParameterInfos &template_param_infos)
+{
+ if (template_param_infos.IsValid())
+ {
+ std::string template_basename(parent_name);
+ template_basename.erase (template_basename.find('<'));
+
+ return CreateClassTemplateDecl (decl_ctx,
+ access_type,
+ template_basename.c_str(),
+ tag_decl_kind,
+ template_param_infos);
+ }
+ return NULL;
+}
+
+void
+ClangASTContext::CompleteTagDecl (void *baton, clang::TagDecl *decl)
+{
+ ClangASTContext *ast = (ClangASTContext *)baton;
+ SymbolFile *sym_file = ast->GetSymbolFile();
+ if (sym_file)
+ {
+ CompilerType clang_type = GetTypeForDecl (decl);
+ if (clang_type)
+ sym_file->CompleteType (clang_type);
+ }
+}
+
+void
+ClangASTContext::CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *decl)
+{
+ ClangASTContext *ast = (ClangASTContext *)baton;
+ SymbolFile *sym_file = ast->GetSymbolFile();
+ if (sym_file)
+ {
+ CompilerType clang_type = GetTypeForDecl (decl);
+ if (clang_type)
+ sym_file->CompleteType (clang_type);
+ }
+}
+
+
+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();
+}
+
+
+bool
+ClangASTContext::LayoutRecordType(void *baton,
+ const clang::RecordDecl *record_decl,
+ uint64_t &bit_size,
+ uint64_t &alignment,
+ llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets)
+{
+ ClangASTContext *ast = (ClangASTContext *)baton;
+ DWARFASTParserClang *dwarf_ast_parser = (DWARFASTParserClang *)ast->GetDWARFParser();
+ return dwarf_ast_parser->LayoutRecordType(record_decl, bit_size, alignment, field_offsets, base_offsets, vbase_offsets);
+}
+
+//----------------------------------------------------------------------
+// CompilerDecl override functions
+//----------------------------------------------------------------------
+lldb::VariableSP
+ClangASTContext::DeclGetVariable (void *opaque_decl)
+{
+ if (llvm::dyn_cast<clang::VarDecl>((clang::Decl *)opaque_decl))
+ {
+ auto decl_search_it = m_decl_objects.find(opaque_decl);
+ if (decl_search_it != m_decl_objects.end())
+ return std::static_pointer_cast<Variable>(decl_search_it->second);
+ }
+ return VariableSP();
+}
+
+void
+ClangASTContext::DeclLinkToObject (void *opaque_decl, std::shared_ptr<void> object)
+{
+ if (m_decl_objects.find(opaque_decl) == m_decl_objects.end())
+ m_decl_objects.insert(std::make_pair(opaque_decl, object));
+}
+
+ConstString
+ClangASTContext::DeclGetName (void *opaque_decl)
+{
+ if (opaque_decl)
+ {
+ clang::NamedDecl *nd = llvm::dyn_cast<NamedDecl>((clang::Decl*)opaque_decl);
+ if (nd != nullptr)
+ return ConstString(nd->getDeclName().getAsString());
+ }
+ return ConstString();
+}
+
+ConstString
+ClangASTContext::DeclGetMangledName (void *opaque_decl)
+{
+ if (opaque_decl)
+ {
+ clang::NamedDecl *nd = llvm::dyn_cast<clang::NamedDecl>((clang::Decl*)opaque_decl);
+ if (nd != nullptr && !llvm::isa<clang::ObjCMethodDecl>(nd))
+ {
+ clang::MangleContext *mc = getMangleContext();
+ if (mc && mc->shouldMangleCXXName(nd))
+ {
+ llvm::SmallVector<char, 1024> buf;
+ llvm::raw_svector_ostream llvm_ostrm (buf);
+ if (llvm::isa<clang::CXXConstructorDecl>(nd))
+ {
+ mc->mangleCXXCtor(llvm::dyn_cast<clang::CXXConstructorDecl>(nd), Ctor_Complete, llvm_ostrm);
+ }
+ else if (llvm::isa<clang::CXXDestructorDecl>(nd))
+ {
+ mc->mangleCXXDtor(llvm::dyn_cast<clang::CXXDestructorDecl>(nd), Dtor_Complete, llvm_ostrm);
+ }
+ else
+ {
+ mc->mangleName(nd, llvm_ostrm);
+ }
+ if (buf.size() > 0)
+ return ConstString(buf.data(), buf.size());
+ }
+ }
+ }
+ return ConstString();
+}
+
+CompilerDeclContext
+ClangASTContext::DeclGetDeclContext (void *opaque_decl)
+{
+ if (opaque_decl)
+ return CompilerDeclContext(this, ((clang::Decl*)opaque_decl)->getDeclContext());
+ else
+ return CompilerDeclContext();
+}
+
+CompilerType
+ClangASTContext::DeclGetFunctionReturnType(void *opaque_decl)
+{
+ if (clang::FunctionDecl *func_decl = llvm::dyn_cast<clang::FunctionDecl>((clang::Decl*)opaque_decl))
+ return CompilerType(this, func_decl->getReturnType().getAsOpaquePtr());
+ if (clang::ObjCMethodDecl *objc_method = llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl*)opaque_decl))
+ return CompilerType(this, objc_method->getReturnType().getAsOpaquePtr());
+ else
+ return CompilerType();
+}
+
+size_t
+ClangASTContext::DeclGetFunctionNumArguments(void *opaque_decl)
+{
+ if (clang::FunctionDecl *func_decl = llvm::dyn_cast<clang::FunctionDecl>((clang::Decl*)opaque_decl))
+ return func_decl->param_size();
+ if (clang::ObjCMethodDecl *objc_method = llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl*)opaque_decl))
+ return objc_method->param_size();
+ else
+ return 0;
+}
+
+CompilerType
+ClangASTContext::DeclGetFunctionArgumentType (void *opaque_decl, size_t idx)
+{
+ if (clang::FunctionDecl *func_decl = llvm::dyn_cast<clang::FunctionDecl>((clang::Decl*)opaque_decl))
+ {
+ if (idx < func_decl->param_size())
+ {
+ ParmVarDecl *var_decl = func_decl->getParamDecl(idx);
+ if (var_decl)
+ return CompilerType(this, var_decl->getOriginalType().getAsOpaquePtr());
+ }
+ }
+ else if (clang::ObjCMethodDecl *objc_method = llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl*)opaque_decl))
+ {
+ if (idx < objc_method->param_size())
+ return CompilerType(this, objc_method->parameters()[idx]->getOriginalType().getAsOpaquePtr());
+ }
+ return CompilerType();
+}
+
+//----------------------------------------------------------------------
+// CompilerDeclContext functions
+//----------------------------------------------------------------------
+
+std::vector<CompilerDecl>
+ClangASTContext::DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name)
+{
+ std::vector<CompilerDecl> found_decls;
+ if (opaque_decl_ctx)
+ {
+ DeclContext *root_decl_ctx = (DeclContext *)opaque_decl_ctx;
+ std::set<DeclContext *> searched;
+ std::multimap<DeclContext *, DeclContext *> search_queue;
+ SymbolFile *symbol_file = GetSymbolFile();
+
+ for (clang::DeclContext *decl_context = root_decl_ctx; decl_context != nullptr && found_decls.empty(); decl_context = decl_context->getParent())
+ {
+ search_queue.insert(std::make_pair(decl_context, decl_context));
+
+ for (auto it = search_queue.find(decl_context); it != search_queue.end(); it++)
+ {
+ if (!searched.insert(it->second).second)
+ continue;
+ symbol_file->ParseDeclsForContext(CompilerDeclContext(this, it->second));
+
+ for (clang::Decl *child : it->second->decls())
+ {
+ if (clang::UsingDirectiveDecl *ud = llvm::dyn_cast<clang::UsingDirectiveDecl>(child))
+ {
+ clang::DeclContext *from = ud->getCommonAncestor();
+ if (searched.find(ud->getNominatedNamespace()) == searched.end())
+ search_queue.insert(std::make_pair(from, ud->getNominatedNamespace()));
+ }
+ else if (clang::UsingDecl *ud = llvm::dyn_cast<clang::UsingDecl>(child))
+ {
+ for (clang::UsingShadowDecl *usd : ud->shadows())
+ {
+ clang::Decl *target = usd->getTargetDecl();
+ if (clang::NamedDecl *nd = llvm::dyn_cast<clang::NamedDecl>(target))
+ {
+ IdentifierInfo *ii = nd->getIdentifier();
+ if (ii != nullptr && ii->getName().equals(name.AsCString(nullptr)))
+ found_decls.push_back(CompilerDecl(this, nd));
+ }
+ }
+ }
+ else if (clang::NamedDecl *nd = llvm::dyn_cast<clang::NamedDecl>(child))
+ {
+ IdentifierInfo *ii = nd->getIdentifier();
+ if (ii != nullptr && ii->getName().equals(name.AsCString(nullptr)))
+ found_decls.push_back(CompilerDecl(this, nd));
+ }
+ }
}
- language = eLanguageTypeObjC;
+ }
+ }
+ return found_decls;
+}
+
+// Look for child_decl_ctx's lookup scope in frame_decl_ctx and its parents,
+// and return the number of levels it took to find it, or LLDB_INVALID_DECL_LEVEL
+// if not found. If the decl was imported via a using declaration, its name and/or
+// type, if set, will be used to check that the decl found in the scope is a match.
+//
+// The optional name is required by languages (like C++) to handle using declarations
+// like:
+//
+// void poo();
+// namespace ns {
+// void foo();
+// void goo();
+// }
+// void bar() {
+// using ns::foo;
+// // CountDeclLevels returns 0 for 'foo', 1 for 'poo', and
+// // LLDB_INVALID_DECL_LEVEL for 'goo'.
+// }
+//
+// The optional type is useful in the case that there's a specific overload
+// that we're looking for that might otherwise be shadowed, like:
+//
+// void foo(int);
+// namespace ns {
+// void foo();
+// }
+// void bar() {
+// using ns::foo;
+// // CountDeclLevels returns 0 for { 'foo', void() },
+// // 1 for { 'foo', void(int) }, and
+// // LLDB_INVALID_DECL_LEVEL for { 'foo', void(int, int) }.
+// }
+//
+// NOTE: Because file statics are at the TranslationUnit along with globals, a
+// function at file scope will return the same level as a function at global scope.
+// Ideally we'd like to treat the file scope as an additional scope just below the
+// global scope. More work needs to be done to recognise that, if the decl we're
+// trying to look up is static, we should compare its source file with that of the
+// current scope and return a lower number for it.
+uint32_t
+ClangASTContext::CountDeclLevels (clang::DeclContext *frame_decl_ctx,
+ clang::DeclContext *child_decl_ctx,
+ ConstString *child_name,
+ CompilerType *child_type)
+{
+ if (frame_decl_ctx)
+ {
+ std::set<DeclContext *> searched;
+ std::multimap<DeclContext *, DeclContext *> search_queue;
+ SymbolFile *symbol_file = GetSymbolFile();
+
+ // Get the lookup scope for the decl we're trying to find.
+ clang::DeclContext *parent_decl_ctx = child_decl_ctx->getParent();
+
+ // Look for it in our scope's decl context and its parents.
+ uint32_t level = 0;
+ for (clang::DeclContext *decl_ctx = frame_decl_ctx; decl_ctx != nullptr; decl_ctx = decl_ctx->getParent())
+ {
+ if (!decl_ctx->isLookupContext())
+ continue;
+ if (decl_ctx == parent_decl_ctx)
+ // Found it!
+ return level;
+ search_queue.insert(std::make_pair(decl_ctx, decl_ctx));
+ for (auto it = search_queue.find(decl_ctx); it != search_queue.end(); it++)
+ {
+ if (searched.find(it->second) != searched.end())
+ continue;
+ searched.insert(it->second);
+ symbol_file->ParseDeclsForContext(CompilerDeclContext(this, it->second));
+
+ for (clang::Decl *child : it->second->decls())
+ {
+ if (clang::UsingDirectiveDecl *ud = llvm::dyn_cast<clang::UsingDirectiveDecl>(child))
+ {
+ clang::DeclContext *ns = ud->getNominatedNamespace();
+ if (ns == parent_decl_ctx)
+ // Found it!
+ return level;
+ clang::DeclContext *from = ud->getCommonAncestor();
+ if (searched.find(ns) == searched.end())
+ search_queue.insert(std::make_pair(from, ns));
+ }
+ else if (child_name)
+ {
+ if (clang::UsingDecl *ud = llvm::dyn_cast<clang::UsingDecl>(child))
+ {
+ for (clang::UsingShadowDecl *usd : ud->shadows())
+ {
+ clang::Decl *target = usd->getTargetDecl();
+ clang::NamedDecl *nd = llvm::dyn_cast<clang::NamedDecl>(target);
+ if (!nd)
+ continue;
+ // Check names.
+ IdentifierInfo *ii = nd->getIdentifier();
+ if (ii == nullptr || !ii->getName().equals(child_name->AsCString(nullptr)))
+ continue;
+ // Check types, if one was provided.
+ if (child_type)
+ {
+ CompilerType clang_type = ClangASTContext::GetTypeForDecl(nd);
+ if (!AreTypesSame(clang_type, *child_type, /*ignore_qualifiers=*/true))
+ continue;
+ }
+ // Found it!
+ return level;
+ }
+ }
+ }
+ }
+ }
+ ++level;
+ }
+ }
+ return LLDB_INVALID_DECL_LEVEL;
+}
+
+bool
+ClangASTContext::DeclContextIsStructUnionOrClass (void *opaque_decl_ctx)
+{
+ if (opaque_decl_ctx)
+ return ((clang::DeclContext *)opaque_decl_ctx)->isRecord();
+ else
+ return false;
+}
+
+ConstString
+ClangASTContext::DeclContextGetName (void *opaque_decl_ctx)
+{
+ if (opaque_decl_ctx)
+ {
+ clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
+ if (named_decl)
+ return ConstString(named_decl->getName());
+ }
+ return ConstString();
+}
+
+bool
+ClangASTContext::DeclContextIsClassMethod (void *opaque_decl_ctx,
+ lldb::LanguageType *language_ptr,
+ bool *is_instance_method_ptr,
+ ConstString *language_object_name_ptr)
+{
+ if (opaque_decl_ctx)
+ {
+ clang::DeclContext *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
+ if (ObjCMethodDecl *objc_method = llvm::dyn_cast<clang::ObjCMethodDecl>(decl_ctx))
+ {
+ if (is_instance_method_ptr)
+ *is_instance_method_ptr = objc_method->isInstanceMethod();
+ if (language_ptr)
+ *language_ptr = eLanguageTypeObjC;
+ if (language_object_name_ptr)
+ language_object_name_ptr->SetCString("self");
+ return true;
+ }
+ else if (CXXMethodDecl *cxx_method = llvm::dyn_cast<clang::CXXMethodDecl>(decl_ctx))
+ {
+ if (is_instance_method_ptr)
+ *is_instance_method_ptr = cxx_method->isInstance();
+ if (language_ptr)
+ *language_ptr = eLanguageTypeC_plus_plus;
+ if (language_object_name_ptr)
+ language_object_name_ptr->SetCString("this");
return true;
}
else if (clang::FunctionDecl *function_decl = llvm::dyn_cast<clang::FunctionDecl>(decl_ctx))
@@ -2195,13 +10003,129 @@ ClangASTContext::GetClassMethodInfoForDeclContext (clang::DeclContext *decl_ctx,
ClangASTMetadata *metadata = GetMetadata (&decl_ctx->getParentASTContext(), function_decl);
if (metadata && metadata->HasObjectPtr())
{
- language_object_name.SetCString (metadata->GetObjectPtrName());
- language = eLanguageTypeObjC;
- is_instance_method = true;
+ if (is_instance_method_ptr)
+ *is_instance_method_ptr = true;
+ if (language_ptr)
+ *language_ptr = eLanguageTypeObjC;
+ if (language_object_name_ptr)
+ language_object_name_ptr->SetCString (metadata->GetObjectPtrName());
+ return true;
}
- return true;
}
}
return false;
}
+clang::DeclContext *
+ClangASTContext::DeclContextGetAsDeclContext (const CompilerDeclContext &dc)
+{
+ if (dc.IsClang())
+ return (clang::DeclContext *)dc.GetOpaqueDeclContext();
+ return nullptr;
+}
+
+
+ObjCMethodDecl *
+ClangASTContext::DeclContextGetAsObjCMethodDecl (const CompilerDeclContext &dc)
+{
+ if (dc.IsClang())
+ return llvm::dyn_cast<clang::ObjCMethodDecl>((clang::DeclContext *)dc.GetOpaqueDeclContext());
+ return nullptr;
+}
+
+CXXMethodDecl *
+ClangASTContext::DeclContextGetAsCXXMethodDecl (const CompilerDeclContext &dc)
+{
+ if (dc.IsClang())
+ return llvm::dyn_cast<clang::CXXMethodDecl>((clang::DeclContext *)dc.GetOpaqueDeclContext());
+ return nullptr;
+}
+
+clang::FunctionDecl *
+ClangASTContext::DeclContextGetAsFunctionDecl (const CompilerDeclContext &dc)
+{
+ if (dc.IsClang())
+ return llvm::dyn_cast<clang::FunctionDecl>((clang::DeclContext *)dc.GetOpaqueDeclContext());
+ return nullptr;
+}
+
+clang::NamespaceDecl *
+ClangASTContext::DeclContextGetAsNamespaceDecl (const CompilerDeclContext &dc)
+{
+ if (dc.IsClang())
+ return llvm::dyn_cast<clang::NamespaceDecl>((clang::DeclContext *)dc.GetOpaqueDeclContext());
+ return nullptr;
+}
+
+ClangASTMetadata *
+ClangASTContext::DeclContextGetMetaData (const CompilerDeclContext &dc, const void *object)
+{
+ clang::ASTContext *ast = DeclContextGetClangASTContext (dc);
+ if (ast)
+ return ClangASTContext::GetMetadata (ast, object);
+ return nullptr;
+}
+
+clang::ASTContext *
+ClangASTContext::DeclContextGetClangASTContext (const CompilerDeclContext &dc)
+{
+ ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(dc.GetTypeSystem());
+ if (ast)
+ return ast->getASTContext();
+ return nullptr;
+}
+
+ClangASTContextForExpressions::ClangASTContextForExpressions (Target &target) :
+ ClangASTContext (target.GetArchitecture().GetTriple().getTriple().c_str()),
+ m_target_wp(target.shared_from_this()),
+ m_persistent_variables (new ClangPersistentVariables)
+{
+}
+
+UserExpression *
+ClangASTContextForExpressions::GetUserExpression (const char *expr,
+ const char *expr_prefix,
+ lldb::LanguageType language,
+ Expression::ResultType desired_type,
+ const EvaluateExpressionOptions &options)
+{
+ TargetSP target_sp = m_target_wp.lock();
+ if (!target_sp)
+ return nullptr;
+
+ return new ClangUserExpression(*target_sp.get(), expr, expr_prefix, language, desired_type, options);
+}
+
+FunctionCaller *
+ClangASTContextForExpressions::GetFunctionCaller (const CompilerType &return_type,
+ const Address& function_address,
+ const ValueList &arg_value_list,
+ const char *name)
+{
+ TargetSP target_sp = m_target_wp.lock();
+ if (!target_sp)
+ return nullptr;
+
+ Process *process = target_sp->GetProcessSP().get();
+ if (!process)
+ return nullptr;
+
+ return new ClangFunctionCaller (*process, return_type, function_address, arg_value_list, name);
+}
+
+UtilityFunction *
+ClangASTContextForExpressions::GetUtilityFunction (const char *text,
+ const char *name)
+{
+ TargetSP target_sp = m_target_wp.lock();
+ if (!target_sp)
+ return nullptr;
+
+ return new ClangUtilityFunction(*target_sp.get(), text, name);
+}
+
+PersistentExpressionState *
+ClangASTContextForExpressions::GetPersistentExpressionState ()
+{
+ return m_persistent_variables.get();
+}
diff --git a/source/Symbol/ClangASTImporter.cpp b/source/Symbol/ClangASTImporter.cpp
index dd73b35d86a9..141937072c73 100644
--- a/source/Symbol/ClangASTImporter.cpp
+++ b/source/Symbol/ClangASTImporter.cpp
@@ -16,7 +16,6 @@
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ClangASTImporter.h"
#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
-#include "lldb/Symbol/ClangNamespaceDecl.h"
#include "lldb/Utility/LLDBAssert.h"
using namespace lldb_private;
@@ -60,14 +59,39 @@ ClangASTImporter::CopyType (clang::ASTContext *dst_ast,
return QualType();
}
-lldb::clang_type_t
+lldb::opaque_compiler_type_t
ClangASTImporter::CopyType (clang::ASTContext *dst_ast,
clang::ASTContext *src_ast,
- lldb::clang_type_t type)
+ lldb::opaque_compiler_type_t type)
{
return CopyType (dst_ast, src_ast, QualType::getFromOpaquePtr(type)).getAsOpaquePtr();
}
+CompilerType
+ClangASTImporter::CopyType (ClangASTContext &dst_ast,
+ const CompilerType &src_type)
+{
+ clang::ASTContext *dst_clang_ast = dst_ast.getASTContext();
+ if (dst_clang_ast)
+ {
+ ClangASTContext *src_ast = llvm::dyn_cast_or_null<ClangASTContext>(src_type.GetTypeSystem());
+ if (src_ast)
+ {
+ clang::ASTContext *src_clang_ast = src_ast->getASTContext();
+ if (src_clang_ast)
+ {
+ lldb::opaque_compiler_type_t dst_clang_type = CopyType(dst_clang_ast,
+ src_clang_ast,
+ src_type.GetOpaqueQualType());
+
+ if (dst_clang_type)
+ return CompilerType(&dst_ast, dst_clang_type);
+ }
+ }
+ }
+ return CompilerType();
+}
+
clang::Decl *
ClangASTImporter::CopyDecl (clang::ASTContext *dst_ast,
clang::ASTContext *src_ast,
@@ -238,11 +262,19 @@ public:
}
};
-lldb::clang_type_t
+lldb::opaque_compiler_type_t
ClangASTImporter::DeportType (clang::ASTContext *dst_ctx,
clang::ASTContext *src_ctx,
- lldb::clang_type_t type)
-{
+ lldb::opaque_compiler_type_t type)
+{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+
+ if (log)
+ log->Printf(" [ClangASTImporter] DeportType called on (%sType*)0x%llx from (ASTContext*)%p to (ASTContext*)%p",
+ QualType::getFromOpaquePtr(type)->getTypeClassName(), (unsigned long long)type,
+ static_cast<void*>(src_ctx),
+ static_cast<void*>(dst_ctx));
+
MinionSP minion_sp (GetMinion (dst_ctx, src_ctx));
if (!minion_sp)
@@ -261,7 +293,7 @@ ClangASTImporter::DeportType (clang::ASTContext *dst_ctx,
minion_sp->InitDeportWorkQueues(&decls_to_deport,
&decls_already_deported);
- lldb::clang_type_t result = CopyType(dst_ctx, src_ctx, type);
+ lldb::opaque_compiler_type_t result = CopyType(dst_ctx, src_ctx, type);
minion_sp->ExecuteDeportWorkQueues();
@@ -280,7 +312,7 @@ ClangASTImporter::DeportDecl (clang::ASTContext *dst_ctx,
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
if (log)
- log->Printf(" [ClangASTImporter] DeportDecl called on (%sDecl*)%p from (ASTContext*)%p to (ASTContex*)%p",
+ log->Printf(" [ClangASTImporter] DeportDecl called on (%sDecl*)%p from (ASTContext*)%p to (ASTContext*)%p",
decl->getDeclKindName(), static_cast<void*>(decl),
static_cast<void*>(src_ctx),
static_cast<void*>(dst_ctx));
@@ -422,6 +454,68 @@ ClangASTImporter::CompleteObjCInterfaceDecl (clang::ObjCInterfaceDecl *interface
}
bool
+ClangASTImporter::CompleteAndFetchChildren (clang::QualType type)
+{
+ if (!RequireCompleteType(type))
+ return false;
+
+ if (const TagType *tag_type = type->getAs<TagType>())
+ {
+ TagDecl *tag_decl = tag_type->getDecl();
+
+ DeclOrigin decl_origin = GetDeclOrigin(tag_decl);
+
+ if (!decl_origin.Valid())
+ return false;
+
+ MinionSP minion_sp (GetMinion(&tag_decl->getASTContext(), decl_origin.ctx));
+
+ 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);
+ }
+
+ if (RecordDecl *record_decl = dyn_cast<RecordDecl>(origin_tag_decl))
+ {
+ record_decl->setHasLoadedFieldsFromExternalStorage(true);
+ }
+
+ return true;
+ }
+
+ if (const ObjCObjectType *objc_object_type = type->getAs<ObjCObjectType>())
+ {
+ if (ObjCInterfaceDecl *objc_interface_decl = objc_object_type->getInterface())
+ {
+ DeclOrigin decl_origin = GetDeclOrigin(objc_interface_decl);
+
+ if (!decl_origin.Valid())
+ return false;
+
+ MinionSP minion_sp (GetMinion(&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);
+ }
+
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+
+bool
ClangASTImporter::RequireCompleteType (clang::QualType type)
{
if (type.isNull())
@@ -600,7 +694,7 @@ void
ClangASTImporter::Minion::InitDeportWorkQueues (std::set<clang::NamedDecl *> *decls_to_deport,
std::set<clang::NamedDecl *> *decls_already_deported)
{
- assert(!m_decls_to_deport); // TODO make debug only
+ assert(!m_decls_to_deport);
assert(!m_decls_already_deported);
m_decls_to_deport = decls_to_deport;
@@ -610,7 +704,7 @@ ClangASTImporter::Minion::InitDeportWorkQueues (std::set<clang::NamedDecl *> *de
void
ClangASTImporter::Minion::ExecuteDeportWorkQueues ()
{
- assert(m_decls_to_deport); // TODO make debug only
+ assert(m_decls_to_deport);
assert(m_decls_already_deported);
ASTContextMetadataSP to_context_md = m_master.GetContextMetadata(&getToContext());
@@ -623,6 +717,7 @@ ClangASTImporter::Minion::ExecuteDeportWorkQueues ()
m_decls_to_deport->erase(decl);
DeclOrigin &origin = to_context_md->m_origins[decl];
+ UNUSED_IF_ASSERT_DISABLED(origin);
assert (origin.ctx == m_source_ctx); // otherwise we should never have added this
// because it doesn't need to be deported
@@ -763,7 +858,8 @@ ClangASTImporter::Minion::Imported (clang::Decl *from, clang::Decl *to)
if (to_context_md->m_origins.find(to) == to_context_md->m_origins.end() ||
user_id != LLDB_INVALID_UID)
{
- to_context_md->m_origins[to] = origin_iter->second;
+ if (origin_iter->second.ctx != &to->getASTContext())
+ to_context_md->m_origins[to] = origin_iter->second;
}
MinionSP direct_completer = m_master.GetMinion(&to->getASTContext(), origin_iter->second.ctx);
@@ -784,10 +880,14 @@ ClangASTImporter::Minion::Imported (clang::Decl *from, clang::Decl *to)
{
if (isa<TagDecl>(to) || isa<ObjCInterfaceDecl>(to))
{
- NamedDecl *to_named_decl = dyn_cast<NamedDecl>(to);
-
- if (!m_decls_already_deported->count(to_named_decl))
- m_decls_to_deport->insert(to_named_decl);
+ RecordDecl *from_record_decl = dyn_cast<RecordDecl>(from);
+ if (from_record_decl == nullptr || from_record_decl->isInjectedClassName() == false)
+ {
+ NamedDecl *to_named_decl = dyn_cast<NamedDecl>(to);
+
+ if (!m_decls_already_deported->count(to_named_decl))
+ m_decls_to_deport->insert(to_named_decl);
+ }
}
}
diff --git a/source/Symbol/ClangASTType.cpp b/source/Symbol/ClangASTType.cpp
deleted file mode 100644
index 6f1002fbd9fc..000000000000
--- a/source/Symbol/ClangASTType.cpp
+++ /dev/null
@@ -1,7057 +0,0 @@
-//===-- ClangASTType.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/Symbol/ClangASTType.h"
-
-#include "clang/AST/ASTConsumer.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/Attr.h"
-#include "clang/AST/CXXInheritance.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/DeclCXX.h"
-#include "clang/AST/DeclObjC.h"
-#include "clang/AST/DeclGroup.h"
-#include "clang/AST/DeclTemplate.h"
-#include "clang/AST/RecordLayout.h"
-#include "clang/AST/Type.h"
-#include "clang/AST/VTableBuilder.h"
-
-#include "clang/Basic/Builtins.h"
-#include "clang/Basic/IdentifierTable.h"
-#include "clang/Basic/LangOptions.h"
-#include "clang/Basic/SourceManager.h"
-#include "clang/Basic/TargetInfo.h"
-
-#include "llvm/Support/Format.h"
-#include "llvm/Support/Signals.h"
-#include "llvm/Support/FormattedStream.h"
-#include "llvm/Support/raw_ostream.h"
-
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Scalar.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
-#include "lldb/Symbol/Type.h"
-#include "lldb/Symbol/VerifyDecl.h"
-#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
-#include "lldb/Target/Process.h"
-
-#include <iterator>
-#include <mutex>
-
-using namespace lldb;
-using namespace lldb_private;
-
-static bool
-GetCompleteQualType (clang::ASTContext *ast, clang::QualType qual_type, bool allow_completion = true)
-{
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::ConstantArray:
- case clang::Type::IncompleteArray:
- case clang::Type::VariableArray:
- {
- const clang::ArrayType *array_type = llvm::dyn_cast<clang::ArrayType>(qual_type.getTypePtr());
-
- if (array_type)
- return GetCompleteQualType (ast, array_type->getElementType(), allow_completion);
- }
- break;
-
- case clang::Type::Record:
- case clang::Type::Enum:
- {
- const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
- if (tag_type)
- {
- clang::TagDecl *tag_decl = tag_type->getDecl();
- if (tag_decl)
- {
- if (tag_decl->isCompleteDefinition())
- return true;
-
- if (!allow_completion)
- return false;
-
- if (tag_decl->hasExternalLexicalStorage())
- {
- if (ast)
- {
- clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
- if (external_ast_source)
- {
- external_ast_source->CompleteType(tag_decl);
- return !tag_type->isIncompleteType();
- }
- }
- }
- return false;
- }
- }
-
- }
- break;
-
- case clang::Type::ObjCObject:
- case clang::Type::ObjCInterface:
- {
- const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
- if (objc_class_type)
- {
- clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
- // 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 (class_interface_decl->getDefinition())
- return true;
-
- if (!allow_completion)
- return false;
-
- if (class_interface_decl->hasExternalLexicalStorage())
- {
- if (ast)
- {
- clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
- if (external_ast_source)
- {
- external_ast_source->CompleteType (class_interface_decl);
- return !objc_class_type->isIncompleteType();
- }
- }
- }
- return false;
- }
- }
- }
- break;
-
- case clang::Type::Typedef:
- return GetCompleteQualType (ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType(), allow_completion);
-
- case clang::Type::Elaborated:
- return GetCompleteQualType (ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType(), allow_completion);
-
- case clang::Type::Paren:
- return GetCompleteQualType (ast, llvm::cast<clang::ParenType>(qual_type)->desugar(), allow_completion);
-
- default:
- break;
- }
-
- return true;
-}
-
-static clang::ObjCIvarDecl::AccessControl
-ConvertAccessTypeToObjCIvarAccessControl (AccessType access)
-{
- switch (access)
- {
- case eAccessNone: return clang::ObjCIvarDecl::None;
- case eAccessPublic: return clang::ObjCIvarDecl::Public;
- case eAccessPrivate: return clang::ObjCIvarDecl::Private;
- case eAccessProtected: return clang::ObjCIvarDecl::Protected;
- case eAccessPackage: return clang::ObjCIvarDecl::Package;
- }
- return clang::ObjCIvarDecl::None;
-}
-
-//----------------------------------------------------------------------
-// Tests
-//----------------------------------------------------------------------
-
-ClangASTType::ClangASTType (clang::ASTContext *ast,
- clang::QualType qual_type) :
- m_type (qual_type.getAsOpaquePtr()),
- m_ast (ast)
-{
-}
-
-ClangASTType::~ClangASTType()
-{
-}
-
-//----------------------------------------------------------------------
-// Tests
-//----------------------------------------------------------------------
-
-bool
-ClangASTType::IsAggregateType () const
-{
- if (!IsValid())
- return false;
-
- clang::QualType qual_type (GetCanonicalQualType());
-
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::IncompleteArray:
- case clang::Type::VariableArray:
- case clang::Type::ConstantArray:
- case clang::Type::ExtVector:
- case clang::Type::Vector:
- case clang::Type::Record:
- case clang::Type::ObjCObject:
- case clang::Type::ObjCInterface:
- return true;
- case clang::Type::Elaborated:
- return ClangASTType(m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).IsAggregateType();
- case clang::Type::Typedef:
- return ClangASTType(m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsAggregateType();
- case clang::Type::Paren:
- return ClangASTType(m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).IsAggregateType();
- default:
- break;
- }
- // The clang type does have a value
- return false;
-}
-
-bool
-ClangASTType::IsArrayType (ClangASTType *element_type_ptr,
- uint64_t *size,
- bool *is_incomplete) const
-{
- if (IsValid())
- {
- clang::QualType qual_type (GetCanonicalQualType());
-
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- default:
- break;
-
- case clang::Type::ConstantArray:
- if (element_type_ptr)
- element_type_ptr->SetClangType (m_ast, llvm::cast<clang::ConstantArrayType>(qual_type)->getElementType());
- if (size)
- *size = llvm::cast<clang::ConstantArrayType>(qual_type)->getSize().getLimitedValue(ULLONG_MAX);
- return true;
-
- case clang::Type::IncompleteArray:
- if (element_type_ptr)
- element_type_ptr->SetClangType (m_ast, llvm::cast<clang::IncompleteArrayType>(qual_type)->getElementType());
- if (size)
- *size = 0;
- if (is_incomplete)
- *is_incomplete = true;
- return true;
-
- case clang::Type::VariableArray:
- if (element_type_ptr)
- element_type_ptr->SetClangType (m_ast, llvm::cast<clang::VariableArrayType>(qual_type)->getElementType());
- if (size)
- *size = 0;
- return true;
-
- case clang::Type::DependentSizedArray:
- if (element_type_ptr)
- element_type_ptr->SetClangType (m_ast, llvm::cast<clang::DependentSizedArrayType>(qual_type)->getElementType());
- if (size)
- *size = 0;
- return true;
-
- case clang::Type::Typedef:
- return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsArrayType (element_type_ptr,
- size,
- is_incomplete);
- case clang::Type::Elaborated:
- return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).IsArrayType (element_type_ptr,
- size,
- is_incomplete);
- case clang::Type::Paren:
- return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).IsArrayType (element_type_ptr,
- size,
- is_incomplete);
- }
- }
- if (element_type_ptr)
- element_type_ptr->Clear();
- if (size)
- *size = 0;
- if (is_incomplete)
- *is_incomplete = false;
- return 0;
-}
-
-bool
-ClangASTType::IsVectorType (ClangASTType *element_type,
- uint64_t *size) const
-{
- if (IsValid())
- {
- clang::QualType qual_type (GetCanonicalQualType());
-
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::Vector:
- {
- const clang::VectorType *vector_type = qual_type->getAs<clang::VectorType>();
- if (vector_type)
- {
- if (size)
- *size = vector_type->getNumElements();
- if (element_type)
- *element_type = ClangASTType(m_ast, vector_type->getElementType().getAsOpaquePtr());
- }
- return true;
- }
- break;
- case clang::Type::ExtVector:
- {
- const clang::ExtVectorType *ext_vector_type = qual_type->getAs<clang::ExtVectorType>();
- if (ext_vector_type)
- {
- if (size)
- *size = ext_vector_type->getNumElements();
- if (element_type)
- *element_type = ClangASTType(m_ast, ext_vector_type->getElementType().getAsOpaquePtr());
- }
- return true;
- }
- default:
- break;
- }
- }
- return false;
-}
-
-bool
-ClangASTType::IsRuntimeGeneratedType () const
-{
- if (!IsValid())
- return false;
-
- clang::DeclContext* decl_ctx = GetDeclContextForType();
- if (!decl_ctx)
- return false;
-
- if (!llvm::isa<clang::ObjCInterfaceDecl>(decl_ctx))
- return false;
-
- clang::ObjCInterfaceDecl *result_iface_decl = llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl_ctx);
-
- ClangASTMetadata* ast_metadata = ClangASTContext::GetMetadata(m_ast, result_iface_decl);
- if (!ast_metadata)
- return false;
- return (ast_metadata->GetISAPtr() != 0);
-}
-
-bool
-ClangASTType::IsCharType () const
-{
- if (!IsValid())
- return false;
- return GetQualType().getUnqualifiedType()->isCharType();
-}
-
-
-bool
-ClangASTType::IsCompleteType () const
-{
- if (!IsValid())
- return false;
- const bool allow_completion = false;
- return GetCompleteQualType (m_ast, GetQualType(), allow_completion);
-}
-
-bool
-ClangASTType::IsConst() const
-{
- return GetQualType().isConstQualified();
-}
-
-bool
-ClangASTType::IsCStringType (uint32_t &length) const
-{
- ClangASTType pointee_or_element_clang_type;
- length = 0;
- Flags type_flags (GetTypeInfo (&pointee_or_element_clang_type));
-
- if (!pointee_or_element_clang_type.IsValid())
- return false;
-
- if (type_flags.AnySet (eTypeIsArray | eTypeIsPointer))
- {
- if (pointee_or_element_clang_type.IsCharType())
- {
- if (type_flags.Test (eTypeIsArray))
- {
- // We know the size of the array and it could be a C string
- // since it is an array of characters
- length = llvm::cast<clang::ConstantArrayType>(GetCanonicalQualType().getTypePtr())->getSize().getLimitedValue();
- }
- return true;
-
- }
- }
- return false;
-}
-
-bool
-ClangASTType::IsFunctionType (bool *is_variadic_ptr) const
-{
- if (IsValid())
- {
- clang::QualType qual_type (GetCanonicalQualType());
-
- if (qual_type->isFunctionType())
- {
- if (is_variadic_ptr)
- {
- const clang::FunctionProtoType *function_proto_type = llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
- if (function_proto_type)
- *is_variadic_ptr = function_proto_type->isVariadic();
- else
- *is_variadic_ptr = false;
- }
- return true;
- }
-
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- default:
- break;
- case clang::Type::Typedef:
- return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsFunctionType();
- case clang::Type::Elaborated:
- return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).IsFunctionType();
- case clang::Type::Paren:
- return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).IsFunctionType();
-
- case clang::Type::LValueReference:
- case clang::Type::RValueReference:
- {
- const clang::ReferenceType *reference_type = llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
- if (reference_type)
- return ClangASTType (m_ast, reference_type->getPointeeType()).IsFunctionType();
- }
- break;
- }
- }
- return false;
-}
-
-// Used to detect "Homogeneous Floating-point Aggregates"
-uint32_t
-ClangASTType::IsHomogeneousAggregate (ClangASTType* base_type_ptr) const
-{
- if (!IsValid())
- return 0;
-
- clang::QualType qual_type(GetCanonicalQualType());
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::Record:
- if (GetCompleteType ())
- {
- const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
- if (cxx_record_decl)
- {
- if (cxx_record_decl->getNumBases() ||
- cxx_record_decl->isDynamicClass())
- return 0;
- }
- const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- if (record_type)
- {
- const clang::RecordDecl *record_decl = record_type->getDecl();
- if (record_decl)
- {
- // We are looking for a structure that contains only floating point types
- clang::RecordDecl::field_iterator field_pos, field_end = record_decl->field_end();
- uint32_t num_fields = 0;
- bool is_hva = false;
- bool is_hfa = false;
- clang::QualType base_qual_type;
- for (field_pos = record_decl->field_begin(); field_pos != field_end; ++field_pos)
- {
- clang::QualType field_qual_type = field_pos->getType();
- if (field_qual_type->isFloatingType())
- {
- if (field_qual_type->isComplexType())
- return 0;
- else
- {
- if (num_fields == 0)
- base_qual_type = field_qual_type;
- else
- {
- if (is_hva)
- return 0;
- is_hfa = true;
- if (field_qual_type.getTypePtr() != base_qual_type.getTypePtr())
- return 0;
- }
- }
- }
- else if (field_qual_type->isVectorType() || field_qual_type->isExtVectorType())
- {
- const clang::VectorType *array = field_qual_type.getTypePtr()->getAs<clang::VectorType>();
- if (array && array->getNumElements() <= 4)
- {
- if (num_fields == 0)
- base_qual_type = array->getElementType();
- else
- {
- if (is_hfa)
- return 0;
- is_hva = true;
- if (field_qual_type.getTypePtr() != base_qual_type.getTypePtr())
- return 0;
- }
- }
- else
- return 0;
- }
- else
- return 0;
- ++num_fields;
- }
- if (base_type_ptr)
- *base_type_ptr = ClangASTType (m_ast, base_qual_type);
- return num_fields;
- }
- }
- }
- break;
-
- case clang::Type::Typedef:
- return ClangASTType(m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsHomogeneousAggregate (base_type_ptr);
-
- case clang::Type::Elaborated:
- return ClangASTType(m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).IsHomogeneousAggregate (base_type_ptr);
- default:
- break;
- }
- return 0;
-}
-
-size_t
-ClangASTType::GetNumberOfFunctionArguments () const
-{
- if (IsValid())
- {
- clang::QualType qual_type (GetCanonicalQualType());
- const clang::FunctionProtoType* func = llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
- if (func)
- return func->getNumParams();
- }
- return 0;
-}
-
-ClangASTType
-ClangASTType::GetFunctionArgumentAtIndex (const size_t index) const
-{
- if (IsValid())
- {
- clang::QualType qual_type (GetCanonicalQualType());
- const clang::FunctionProtoType* func = llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
- if (func)
- {
- if (index < func->getNumParams())
- return ClangASTType(m_ast, func->getParamType(index).getAsOpaquePtr());
- }
- }
- return ClangASTType();
-}
-
-bool
-ClangASTType::IsFunctionPointerType () const
-{
- if (IsValid())
- {
- clang::QualType qual_type (GetCanonicalQualType());
-
- if (qual_type->isFunctionPointerType())
- return true;
-
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- default:
- break;
- case clang::Type::Typedef:
- return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsFunctionPointerType();
- case clang::Type::Elaborated:
- return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).IsFunctionPointerType();
- case clang::Type::Paren:
- return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).IsFunctionPointerType();
-
- case clang::Type::LValueReference:
- case clang::Type::RValueReference:
- {
- const clang::ReferenceType *reference_type = llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
- if (reference_type)
- return ClangASTType (m_ast, reference_type->getPointeeType()).IsFunctionPointerType();
- }
- break;
- }
- }
- return false;
-
-}
-
-bool
-ClangASTType::IsIntegerType (bool &is_signed) const
-{
- if (!IsValid())
- return false;
-
- clang::QualType qual_type (GetCanonicalQualType());
- const clang::BuiltinType *builtin_type = llvm::dyn_cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal());
-
- if (builtin_type)
- {
- if (builtin_type->isInteger())
- {
- is_signed = builtin_type->isSignedInteger();
- return true;
- }
- }
-
- return false;
-}
-
-bool
-ClangASTType::IsPointerType (ClangASTType *pointee_type) const
-{
- if (IsValid())
- {
- clang::QualType qual_type (GetCanonicalQualType());
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::Builtin:
- switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind())
- {
- default:
- break;
- case clang::BuiltinType::ObjCId:
- case clang::BuiltinType::ObjCClass:
- return true;
- }
- return false;
- case clang::Type::ObjCObjectPointer:
- if (pointee_type)
- pointee_type->SetClangType (m_ast, llvm::cast<clang::ObjCObjectPointerType>(qual_type)->getPointeeType());
- return true;
- case clang::Type::BlockPointer:
- if (pointee_type)
- pointee_type->SetClangType (m_ast, llvm::cast<clang::BlockPointerType>(qual_type)->getPointeeType());
- return true;
- case clang::Type::Pointer:
- if (pointee_type)
- pointee_type->SetClangType (m_ast, llvm::cast<clang::PointerType>(qual_type)->getPointeeType());
- return true;
- case clang::Type::MemberPointer:
- if (pointee_type)
- pointee_type->SetClangType (m_ast, llvm::cast<clang::MemberPointerType>(qual_type)->getPointeeType());
- return true;
- case clang::Type::Typedef:
- return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsPointerType(pointee_type);
- case clang::Type::Elaborated:
- return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).IsPointerType(pointee_type);
- case clang::Type::Paren:
- return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).IsPointerType(pointee_type);
- default:
- break;
- }
- }
- if (pointee_type)
- pointee_type->Clear();
- return false;
-}
-
-
-bool
-ClangASTType::IsPointerOrReferenceType (ClangASTType *pointee_type) const
-{
- if (IsValid())
- {
- clang::QualType qual_type (GetCanonicalQualType());
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::Builtin:
- switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind())
- {
- default:
- break;
- case clang::BuiltinType::ObjCId:
- case clang::BuiltinType::ObjCClass:
- return true;
- }
- return false;
- case clang::Type::ObjCObjectPointer:
- if (pointee_type)
- pointee_type->SetClangType(m_ast, llvm::cast<clang::ObjCObjectPointerType>(qual_type)->getPointeeType());
- return true;
- case clang::Type::BlockPointer:
- if (pointee_type)
- pointee_type->SetClangType(m_ast, llvm::cast<clang::BlockPointerType>(qual_type)->getPointeeType());
- return true;
- case clang::Type::Pointer:
- if (pointee_type)
- pointee_type->SetClangType(m_ast, llvm::cast<clang::PointerType>(qual_type)->getPointeeType());
- return true;
- case clang::Type::MemberPointer:
- if (pointee_type)
- pointee_type->SetClangType(m_ast, llvm::cast<clang::MemberPointerType>(qual_type)->getPointeeType());
- return true;
- case clang::Type::LValueReference:
- if (pointee_type)
- pointee_type->SetClangType(m_ast, llvm::cast<clang::LValueReferenceType>(qual_type)->desugar());
- return true;
- case clang::Type::RValueReference:
- if (pointee_type)
- pointee_type->SetClangType(m_ast, llvm::cast<clang::RValueReferenceType>(qual_type)->desugar());
- return true;
- case clang::Type::Typedef:
- return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsPointerOrReferenceType(pointee_type);
- case clang::Type::Elaborated:
- return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).IsPointerOrReferenceType(pointee_type);
- case clang::Type::Paren:
- return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).IsPointerOrReferenceType(pointee_type);
- default:
- break;
- }
- }
- if (pointee_type)
- pointee_type->Clear();
- return false;
-}
-
-
-bool
-ClangASTType::IsReferenceType (ClangASTType *pointee_type, bool* is_rvalue) const
-{
- if (IsValid())
- {
- clang::QualType qual_type (GetCanonicalQualType());
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
-
- switch (type_class)
- {
- case clang::Type::LValueReference:
- if (pointee_type)
- pointee_type->SetClangType(m_ast, llvm::cast<clang::LValueReferenceType>(qual_type)->desugar());
- if (is_rvalue)
- *is_rvalue = false;
- return true;
- case clang::Type::RValueReference:
- if (pointee_type)
- pointee_type->SetClangType(m_ast, llvm::cast<clang::RValueReferenceType>(qual_type)->desugar());
- if (is_rvalue)
- *is_rvalue = true;
- return true;
- case clang::Type::Typedef:
- return ClangASTType(m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsReferenceType(pointee_type, is_rvalue);
- case clang::Type::Elaborated:
- return ClangASTType(m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).IsReferenceType(pointee_type, is_rvalue);
- case clang::Type::Paren:
- return ClangASTType(m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).IsReferenceType(pointee_type, is_rvalue);
-
- default:
- break;
- }
- }
- if (pointee_type)
- pointee_type->Clear();
- return false;
-}
-
-bool
-ClangASTType::IsFloatingPointType (uint32_t &count, bool &is_complex) const
-{
- if (IsValid())
- {
- clang::QualType qual_type (GetCanonicalQualType());
-
- if (const clang::BuiltinType *BT = llvm::dyn_cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal()))
- {
- clang::BuiltinType::Kind kind = BT->getKind();
- if (kind >= clang::BuiltinType::Float && kind <= clang::BuiltinType::LongDouble)
- {
- count = 1;
- is_complex = false;
- return true;
- }
- }
- else if (const clang::ComplexType *CT = llvm::dyn_cast<clang::ComplexType>(qual_type->getCanonicalTypeInternal()))
- {
- if (ClangASTType (m_ast, CT->getElementType()).IsFloatingPointType (count, is_complex))
- {
- count = 2;
- is_complex = true;
- return true;
- }
- }
- else if (const clang::VectorType *VT = llvm::dyn_cast<clang::VectorType>(qual_type->getCanonicalTypeInternal()))
- {
- if (ClangASTType (m_ast, VT->getElementType()).IsFloatingPointType (count, is_complex))
- {
- count = VT->getNumElements();
- is_complex = false;
- return true;
- }
- }
- }
- count = 0;
- is_complex = false;
- return false;
-}
-
-
-bool
-ClangASTType::IsDefined() const
-{
- if (!IsValid())
- return false;
-
- clang::QualType qual_type(GetQualType());
- const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
- if (tag_type)
- {
- clang::TagDecl *tag_decl = tag_type->getDecl();
- if (tag_decl)
- return tag_decl->isCompleteDefinition();
- return false;
- }
- else
- {
- const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
- if (objc_class_type)
- {
- clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
- if (class_interface_decl)
- return class_interface_decl->getDefinition() != nullptr;
- return false;
- }
- }
- return true;
-}
-
-bool
-ClangASTType::IsObjCClassType () const
-{
- if (IsValid())
- {
- clang::QualType qual_type (GetCanonicalQualType());
-
- const clang::ObjCObjectPointerType *obj_pointer_type = llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
-
- if (obj_pointer_type)
- return obj_pointer_type->isObjCClassType();
- }
- return false;
-}
-
-bool
-ClangASTType::IsObjCObjectOrInterfaceType () const
-{
- if (IsValid())
- return GetCanonicalQualType()->isObjCObjectOrInterfaceType();
- return false;
-}
-
-bool
-ClangASTType::IsPolymorphicClass () const
-{
- if (IsValid())
- {
- clang::QualType qual_type(GetCanonicalQualType());
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::Record:
- if (GetCompleteType())
- {
- const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
- if (record_decl)
- {
- const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
- if (cxx_record_decl)
- return cxx_record_decl->isPolymorphic();
- }
- }
- break;
-
- default:
- break;
- }
- }
- return false;
-}
-
-bool
-ClangASTType::IsPossibleDynamicType (ClangASTType *dynamic_pointee_type,
- bool check_cplusplus,
- bool check_objc) const
-{
- clang::QualType pointee_qual_type;
- if (m_type)
- {
- clang::QualType qual_type (GetCanonicalQualType());
- bool success = false;
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::Builtin:
- if (check_objc && llvm::cast<clang::BuiltinType>(qual_type)->getKind() == clang::BuiltinType::ObjCId)
- {
- if (dynamic_pointee_type)
- dynamic_pointee_type->SetClangType(m_ast, m_type);
- return true;
- }
- break;
-
- case clang::Type::ObjCObjectPointer:
- if (check_objc)
- {
- if (dynamic_pointee_type)
- dynamic_pointee_type->SetClangType(m_ast, llvm::cast<clang::ObjCObjectPointerType>(qual_type)->getPointeeType());
- return true;
- }
- break;
-
- case clang::Type::Pointer:
- pointee_qual_type = llvm::cast<clang::PointerType>(qual_type)->getPointeeType();
- success = true;
- break;
-
- case clang::Type::LValueReference:
- case clang::Type::RValueReference:
- pointee_qual_type = llvm::cast<clang::ReferenceType>(qual_type)->getPointeeType();
- success = true;
- break;
-
- case clang::Type::Typedef:
- return ClangASTType (m_ast,
- llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).IsPossibleDynamicType (dynamic_pointee_type,
- check_cplusplus,
- check_objc);
-
- case clang::Type::Elaborated:
- return ClangASTType (m_ast,
- llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).IsPossibleDynamicType (dynamic_pointee_type,
- check_cplusplus,
- check_objc);
-
- case clang::Type::Paren:
- return ClangASTType (m_ast,
- llvm::cast<clang::ParenType>(qual_type)->desugar()).IsPossibleDynamicType (dynamic_pointee_type,
- check_cplusplus,
- check_objc);
- default:
- break;
- }
-
- if (success)
- {
- // Check to make sure what we are pointing too is a possible dynamic C++ type
- // We currently accept any "void *" (in case we have a class that has been
- // watered down to an opaque pointer) and virtual C++ classes.
- const clang::Type::TypeClass pointee_type_class = pointee_qual_type.getCanonicalType()->getTypeClass();
- switch (pointee_type_class)
- {
- case clang::Type::Builtin:
- switch (llvm::cast<clang::BuiltinType>(pointee_qual_type)->getKind())
- {
- case clang::BuiltinType::UnknownAny:
- case clang::BuiltinType::Void:
- if (dynamic_pointee_type)
- dynamic_pointee_type->SetClangType(m_ast, pointee_qual_type);
- return true;
-
- case clang::BuiltinType::NullPtr:
- case clang::BuiltinType::Bool:
- case clang::BuiltinType::Char_U:
- case clang::BuiltinType::UChar:
- case clang::BuiltinType::WChar_U:
- case clang::BuiltinType::Char16:
- case clang::BuiltinType::Char32:
- case clang::BuiltinType::UShort:
- case clang::BuiltinType::UInt:
- case clang::BuiltinType::ULong:
- case clang::BuiltinType::ULongLong:
- case clang::BuiltinType::UInt128:
- case clang::BuiltinType::Char_S:
- case clang::BuiltinType::SChar:
- case clang::BuiltinType::WChar_S:
- case clang::BuiltinType::Short:
- case clang::BuiltinType::Int:
- case clang::BuiltinType::Long:
- case clang::BuiltinType::LongLong:
- case clang::BuiltinType::Int128:
- case clang::BuiltinType::Float:
- case clang::BuiltinType::Double:
- case clang::BuiltinType::LongDouble:
- case clang::BuiltinType::Dependent:
- case clang::BuiltinType::Overload:
- case clang::BuiltinType::ObjCId:
- case clang::BuiltinType::ObjCClass:
- case clang::BuiltinType::ObjCSel:
- case clang::BuiltinType::BoundMember:
- case clang::BuiltinType::Half:
- case clang::BuiltinType::ARCUnbridgedCast:
- case clang::BuiltinType::PseudoObject:
- case clang::BuiltinType::BuiltinFn:
- case clang::BuiltinType::OCLEvent:
- case clang::BuiltinType::OCLImage1d:
- case clang::BuiltinType::OCLImage1dArray:
- case clang::BuiltinType::OCLImage1dBuffer:
- case clang::BuiltinType::OCLImage2d:
- case clang::BuiltinType::OCLImage2dArray:
- case clang::BuiltinType::OCLImage3d:
- case clang::BuiltinType::OCLSampler:
- break;
- }
- break;
-
- case clang::Type::Record:
- if (check_cplusplus)
- {
- clang::CXXRecordDecl *cxx_record_decl = pointee_qual_type->getAsCXXRecordDecl();
- if (cxx_record_decl)
- {
- bool is_complete = cxx_record_decl->isCompleteDefinition();
-
- if (is_complete)
- success = cxx_record_decl->isDynamicClass();
- else
- {
- ClangASTMetadata *metadata = ClangASTContext::GetMetadata (m_ast, cxx_record_decl);
- if (metadata)
- success = metadata->GetIsDynamicCXXType();
- else
- {
- is_complete = ClangASTType(m_ast, pointee_qual_type).GetCompleteType();
- if (is_complete)
- success = cxx_record_decl->isDynamicClass();
- else
- success = false;
- }
- }
-
- if (success)
- {
- if (dynamic_pointee_type)
- dynamic_pointee_type->SetClangType(m_ast, pointee_qual_type);
- return true;
- }
- }
- }
- break;
-
- case clang::Type::ObjCObject:
- case clang::Type::ObjCInterface:
- if (check_objc)
- {
- if (dynamic_pointee_type)
- dynamic_pointee_type->SetClangType(m_ast, pointee_qual_type);
- return true;
- }
- break;
-
- default:
- break;
- }
- }
- }
- if (dynamic_pointee_type)
- dynamic_pointee_type->Clear();
- return false;
-}
-
-
-bool
-ClangASTType::IsScalarType () const
-{
- if (!IsValid())
- return false;
-
- return (GetTypeInfo (nullptr) & eTypeIsScalar) != 0;
-}
-
-bool
-ClangASTType::IsTypedefType () const
-{
- if (!IsValid())
- return false;
- return GetQualType()->getTypeClass() == clang::Type::Typedef;
-}
-
-bool
-ClangASTType::IsVoidType () const
-{
- if (!IsValid())
- return false;
- return GetCanonicalQualType()->isVoidType();
-}
-
-bool
-ClangASTType::IsPointerToScalarType () const
-{
- if (!IsValid())
- return false;
-
- return IsPointerType() && GetPointeeType().IsScalarType();
-}
-
-bool
-ClangASTType::IsArrayOfScalarType () const
-{
- ClangASTType element_type;
- if (IsArrayType(&element_type, nullptr, nullptr))
- return element_type.IsScalarType();
- return false;
-}
-
-
-bool
-ClangASTType::GetCXXClassName (std::string &class_name) const
-{
- if (IsValid())
- {
- clang::QualType qual_type (GetCanonicalQualType());
-
- clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
- if (cxx_record_decl)
- {
- class_name.assign (cxx_record_decl->getIdentifier()->getNameStart());
- return true;
- }
- }
- class_name.clear();
- return false;
-}
-
-
-bool
-ClangASTType::IsCXXClassType () const
-{
- if (!IsValid())
- return false;
-
- clang::QualType qual_type (GetCanonicalQualType());
- if (qual_type->getAsCXXRecordDecl() != nullptr)
- return true;
- return false;
-}
-
-bool
-ClangASTType::IsBeingDefined () const
-{
- if (!IsValid())
- return false;
- clang::QualType qual_type (GetCanonicalQualType());
- const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type);
- if (tag_type)
- return tag_type->isBeingDefined();
- return false;
-}
-
-bool
-ClangASTType::IsObjCObjectPointerType (ClangASTType *class_type_ptr)
-{
- if (!IsValid())
- return false;
-
- clang::QualType qual_type (GetCanonicalQualType());
-
- if (qual_type->isObjCObjectPointerType())
- {
- if (class_type_ptr)
- {
- if (!qual_type->isObjCClassType() &&
- !qual_type->isObjCIdType())
- {
- const clang::ObjCObjectPointerType *obj_pointer_type = llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
- if (obj_pointer_type == nullptr)
- class_type_ptr->Clear();
- else
- class_type_ptr->SetClangType (m_ast, clang::QualType(obj_pointer_type->getInterfaceType(), 0));
- }
- }
- return true;
- }
- if (class_type_ptr)
- class_type_ptr->Clear();
- return false;
-}
-
-bool
-ClangASTType::GetObjCClassName (std::string &class_name)
-{
- if (!IsValid())
- return false;
-
- clang::QualType qual_type (GetCanonicalQualType());
-
- const clang::ObjCObjectType *object_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
- if (object_type)
- {
- const clang::ObjCInterfaceDecl *interface = object_type->getInterface();
- if (interface)
- {
- class_name = interface->getNameAsString();
- return true;
- }
- }
- return false;
-}
-
-
-//----------------------------------------------------------------------
-// Type Completion
-//----------------------------------------------------------------------
-
-bool
-ClangASTType::GetCompleteType () const
-{
- if (!IsValid())
- return false;
- const bool allow_completion = true;
- return GetCompleteQualType (m_ast, GetQualType(), allow_completion);
-}
-
-//----------------------------------------------------------------------
-// AST related queries
-//----------------------------------------------------------------------
-size_t
-ClangASTType::GetPointerByteSize () const
-{
- if (m_ast)
- return m_ast->getTypeSize(m_ast->VoidPtrTy) / 8;
- return 0;
-}
-
-ConstString
-ClangASTType::GetConstQualifiedTypeName () const
-{
- return GetConstTypeName ();
-}
-
-ConstString
-ClangASTType::GetConstTypeName () const
-{
- if (IsValid())
- {
- ConstString type_name (GetTypeName());
- if (type_name)
- return type_name;
- }
- return ConstString("<invalid>");
-}
-
-ConstString
-ClangASTType::GetTypeName () const
-{
- std::string type_name;
- if (IsValid())
- {
- clang::PrintingPolicy printing_policy (m_ast->getPrintingPolicy());
- clang::QualType qual_type(GetQualType());
- printing_policy.SuppressTagKeyword = true;
- printing_policy.LangOpts.WChar = true;
- const clang::TypedefType *typedef_type = qual_type->getAs<clang::TypedefType>();
- if (typedef_type)
- {
- const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
- type_name = typedef_decl->getQualifiedNameAsString();
- }
- else
- {
- type_name = qual_type.getAsString(printing_policy);
- }
- }
- return ConstString(type_name);
-}
-
-ConstString
-ClangASTType::GetDisplayTypeName () const
-{
- return GetTypeName();
-}
-
-uint32_t
-ClangASTType::GetTypeInfo (ClangASTType *pointee_or_element_clang_type) const
-{
- if (!IsValid())
- return 0;
-
- if (pointee_or_element_clang_type)
- pointee_or_element_clang_type->Clear();
-
- clang::QualType qual_type (GetQualType());
-
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::Builtin:
- {
- const clang::BuiltinType *builtin_type = llvm::dyn_cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal());
-
- uint32_t builtin_type_flags = eTypeIsBuiltIn | eTypeHasValue;
- switch (builtin_type->getKind())
- {
- case clang::BuiltinType::ObjCId:
- case clang::BuiltinType::ObjCClass:
- if (pointee_or_element_clang_type)
- pointee_or_element_clang_type->SetClangType(m_ast, m_ast->ObjCBuiltinClassTy);
- builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
- break;
-
- case clang::BuiltinType::ObjCSel:
- if (pointee_or_element_clang_type)
- pointee_or_element_clang_type->SetClangType(m_ast, m_ast->CharTy);
- builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
- break;
-
- case clang::BuiltinType::Bool:
- case clang::BuiltinType::Char_U:
- case clang::BuiltinType::UChar:
- case clang::BuiltinType::WChar_U:
- case clang::BuiltinType::Char16:
- case clang::BuiltinType::Char32:
- case clang::BuiltinType::UShort:
- case clang::BuiltinType::UInt:
- case clang::BuiltinType::ULong:
- case clang::BuiltinType::ULongLong:
- case clang::BuiltinType::UInt128:
- case clang::BuiltinType::Char_S:
- case clang::BuiltinType::SChar:
- case clang::BuiltinType::WChar_S:
- case clang::BuiltinType::Short:
- case clang::BuiltinType::Int:
- case clang::BuiltinType::Long:
- case clang::BuiltinType::LongLong:
- case clang::BuiltinType::Int128:
- case clang::BuiltinType::Float:
- case clang::BuiltinType::Double:
- case clang::BuiltinType::LongDouble:
- builtin_type_flags |= eTypeIsScalar;
- if (builtin_type->isInteger())
- {
- builtin_type_flags |= eTypeIsInteger;
- if (builtin_type->isSignedInteger())
- builtin_type_flags |= eTypeIsSigned;
- }
- else if (builtin_type->isFloatingPoint())
- builtin_type_flags |= eTypeIsFloat;
- break;
- default:
- break;
- }
- return builtin_type_flags;
- }
-
- case clang::Type::BlockPointer:
- if (pointee_or_element_clang_type)
- pointee_or_element_clang_type->SetClangType(m_ast, qual_type->getPointeeType());
- return eTypeIsPointer | eTypeHasChildren | eTypeIsBlock;
-
- case clang::Type::Complex:
- {
- uint32_t complex_type_flags = eTypeIsBuiltIn | eTypeHasValue | eTypeIsComplex;
- const clang::ComplexType *complex_type = llvm::dyn_cast<clang::ComplexType>(qual_type->getCanonicalTypeInternal());
- if (complex_type)
- {
- clang::QualType complex_element_type (complex_type->getElementType());
- if (complex_element_type->isIntegerType())
- complex_type_flags |= eTypeIsFloat;
- else if (complex_element_type->isFloatingType())
- complex_type_flags |= eTypeIsInteger;
- }
- return complex_type_flags;
- }
- break;
-
- case clang::Type::ConstantArray:
- case clang::Type::DependentSizedArray:
- case clang::Type::IncompleteArray:
- case clang::Type::VariableArray:
- if (pointee_or_element_clang_type)
- pointee_or_element_clang_type->SetClangType(m_ast, llvm::cast<clang::ArrayType>(qual_type.getTypePtr())->getElementType());
- return eTypeHasChildren | eTypeIsArray;
-
- case clang::Type::DependentName: return 0;
- case clang::Type::DependentSizedExtVector: return eTypeHasChildren | eTypeIsVector;
- case clang::Type::DependentTemplateSpecialization: return eTypeIsTemplate;
- case clang::Type::Decltype: return 0;
-
- case clang::Type::Enum:
- if (pointee_or_element_clang_type)
- pointee_or_element_clang_type->SetClangType(m_ast, llvm::cast<clang::EnumType>(qual_type)->getDecl()->getIntegerType());
- return eTypeIsEnumeration | eTypeHasValue;
-
- case clang::Type::Elaborated:
- return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetTypeInfo (pointee_or_element_clang_type);
- case clang::Type::Paren:
- return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetTypeInfo (pointee_or_element_clang_type);
-
- case clang::Type::FunctionProto: return eTypeIsFuncPrototype | eTypeHasValue;
- case clang::Type::FunctionNoProto: return eTypeIsFuncPrototype | eTypeHasValue;
- case clang::Type::InjectedClassName: return 0;
-
- case clang::Type::LValueReference:
- case clang::Type::RValueReference:
- if (pointee_or_element_clang_type)
- pointee_or_element_clang_type->SetClangType(m_ast, llvm::cast<clang::ReferenceType>(qual_type.getTypePtr())->getPointeeType());
- return eTypeHasChildren | eTypeIsReference | eTypeHasValue;
-
- case clang::Type::MemberPointer: return eTypeIsPointer | eTypeIsMember | eTypeHasValue;
-
- case clang::Type::ObjCObjectPointer:
- if (pointee_or_element_clang_type)
- pointee_or_element_clang_type->SetClangType(m_ast, qual_type->getPointeeType());
- return eTypeHasChildren | eTypeIsObjC | eTypeIsClass | eTypeIsPointer | eTypeHasValue;
-
- case clang::Type::ObjCObject: return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
- case clang::Type::ObjCInterface: return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
-
- case clang::Type::Pointer:
- if (pointee_or_element_clang_type)
- pointee_or_element_clang_type->SetClangType(m_ast, qual_type->getPointeeType());
- return eTypeHasChildren | eTypeIsPointer | eTypeHasValue;
-
- case clang::Type::Record:
- if (qual_type->getAsCXXRecordDecl())
- return eTypeHasChildren | eTypeIsClass | eTypeIsCPlusPlus;
- else
- return eTypeHasChildren | eTypeIsStructUnion;
- break;
- case clang::Type::SubstTemplateTypeParm: return eTypeIsTemplate;
- case clang::Type::TemplateTypeParm: return eTypeIsTemplate;
- case clang::Type::TemplateSpecialization: return eTypeIsTemplate;
-
- case clang::Type::Typedef:
- return eTypeIsTypedef | ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetTypeInfo (pointee_or_element_clang_type);
- case clang::Type::TypeOfExpr: return 0;
- case clang::Type::TypeOf: return 0;
- case clang::Type::UnresolvedUsing: return 0;
-
- case clang::Type::ExtVector:
- case clang::Type::Vector:
- {
- uint32_t vector_type_flags = eTypeHasChildren | eTypeIsVector;
- const clang::VectorType *vector_type = llvm::dyn_cast<clang::VectorType>(qual_type->getCanonicalTypeInternal());
- if (vector_type)
- {
- if (vector_type->isIntegerType())
- vector_type_flags |= eTypeIsFloat;
- else if (vector_type->isFloatingType())
- vector_type_flags |= eTypeIsInteger;
- }
- return vector_type_flags;
- }
- default: return 0;
- }
- return 0;
-}
-
-
-
-lldb::LanguageType
-ClangASTType::GetMinimumLanguage ()
-{
- if (!IsValid())
- return lldb::eLanguageTypeC;
-
- // If the type is a reference, then resolve it to what it refers to first:
- clang::QualType qual_type (GetCanonicalQualType().getNonReferenceType());
- if (qual_type->isAnyPointerType())
- {
- if (qual_type->isObjCObjectPointerType())
- return lldb::eLanguageTypeObjC;
-
- clang::QualType pointee_type (qual_type->getPointeeType());
- if (pointee_type->getPointeeCXXRecordDecl() != nullptr)
- return lldb::eLanguageTypeC_plus_plus;
- if (pointee_type->isObjCObjectOrInterfaceType())
- return lldb::eLanguageTypeObjC;
- if (pointee_type->isObjCClassType())
- return lldb::eLanguageTypeObjC;
- if (pointee_type.getTypePtr() == m_ast->ObjCBuiltinIdTy.getTypePtr())
- return lldb::eLanguageTypeObjC;
- }
- else
- {
- if (qual_type->isObjCObjectOrInterfaceType())
- return lldb::eLanguageTypeObjC;
- if (qual_type->getAsCXXRecordDecl())
- return lldb::eLanguageTypeC_plus_plus;
- switch (qual_type->getTypeClass())
- {
- default:
- break;
- case clang::Type::Builtin:
- switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind())
- {
- default:
- case clang::BuiltinType::Void:
- case clang::BuiltinType::Bool:
- case clang::BuiltinType::Char_U:
- case clang::BuiltinType::UChar:
- case clang::BuiltinType::WChar_U:
- case clang::BuiltinType::Char16:
- case clang::BuiltinType::Char32:
- case clang::BuiltinType::UShort:
- case clang::BuiltinType::UInt:
- case clang::BuiltinType::ULong:
- case clang::BuiltinType::ULongLong:
- case clang::BuiltinType::UInt128:
- case clang::BuiltinType::Char_S:
- case clang::BuiltinType::SChar:
- case clang::BuiltinType::WChar_S:
- case clang::BuiltinType::Short:
- case clang::BuiltinType::Int:
- case clang::BuiltinType::Long:
- case clang::BuiltinType::LongLong:
- case clang::BuiltinType::Int128:
- case clang::BuiltinType::Float:
- case clang::BuiltinType::Double:
- case clang::BuiltinType::LongDouble:
- break;
-
- case clang::BuiltinType::NullPtr:
- return eLanguageTypeC_plus_plus;
-
- case clang::BuiltinType::ObjCId:
- case clang::BuiltinType::ObjCClass:
- case clang::BuiltinType::ObjCSel:
- return eLanguageTypeObjC;
-
- case clang::BuiltinType::Dependent:
- case clang::BuiltinType::Overload:
- case clang::BuiltinType::BoundMember:
- case clang::BuiltinType::UnknownAny:
- break;
- }
- break;
- case clang::Type::Typedef:
- return ClangASTType(m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetMinimumLanguage();
- }
- }
- return lldb::eLanguageTypeC;
-}
-
-lldb::TypeClass
-ClangASTType::GetTypeClass () const
-{
- if (!IsValid())
- return lldb::eTypeClassInvalid;
-
- clang::QualType qual_type(GetQualType());
-
- switch (qual_type->getTypeClass())
- {
- case clang::Type::UnaryTransform: break;
- case clang::Type::FunctionNoProto: return lldb::eTypeClassFunction;
- case clang::Type::FunctionProto: return lldb::eTypeClassFunction;
- case clang::Type::IncompleteArray: return lldb::eTypeClassArray;
- case clang::Type::VariableArray: return lldb::eTypeClassArray;
- case clang::Type::ConstantArray: return lldb::eTypeClassArray;
- case clang::Type::DependentSizedArray: return lldb::eTypeClassArray;
- case clang::Type::DependentSizedExtVector: return lldb::eTypeClassVector;
- case clang::Type::ExtVector: return lldb::eTypeClassVector;
- case clang::Type::Vector: return lldb::eTypeClassVector;
- case clang::Type::Builtin: return lldb::eTypeClassBuiltin;
- case clang::Type::ObjCObjectPointer: return lldb::eTypeClassObjCObjectPointer;
- case clang::Type::BlockPointer: return lldb::eTypeClassBlockPointer;
- case clang::Type::Pointer: return lldb::eTypeClassPointer;
- case clang::Type::LValueReference: return lldb::eTypeClassReference;
- case clang::Type::RValueReference: return lldb::eTypeClassReference;
- case clang::Type::MemberPointer: return lldb::eTypeClassMemberPointer;
- case clang::Type::Complex:
- if (qual_type->isComplexType())
- return lldb::eTypeClassComplexFloat;
- else
- return lldb::eTypeClassComplexInteger;
- case clang::Type::ObjCObject: return lldb::eTypeClassObjCObject;
- case clang::Type::ObjCInterface: return lldb::eTypeClassObjCInterface;
- case clang::Type::Record:
- {
- const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
- if (record_decl->isUnion())
- return lldb::eTypeClassUnion;
- else if (record_decl->isStruct())
- return lldb::eTypeClassStruct;
- else
- return lldb::eTypeClassClass;
- }
- break;
- case clang::Type::Enum: return lldb::eTypeClassEnumeration;
- case clang::Type::Typedef: return lldb::eTypeClassTypedef;
- case clang::Type::UnresolvedUsing: break;
- case clang::Type::Paren:
- return ClangASTType(m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetTypeClass();
- case clang::Type::Elaborated:
- return ClangASTType(m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetTypeClass();
-
- case clang::Type::Attributed: break;
- case clang::Type::TemplateTypeParm: break;
- case clang::Type::SubstTemplateTypeParm: break;
- case clang::Type::SubstTemplateTypeParmPack:break;
- case clang::Type::Auto: break;
- case clang::Type::InjectedClassName: break;
- case clang::Type::DependentName: break;
- case clang::Type::DependentTemplateSpecialization: break;
- case clang::Type::PackExpansion: break;
-
- case clang::Type::TypeOfExpr: break;
- case clang::Type::TypeOf: break;
- case clang::Type::Decltype: break;
- case clang::Type::TemplateSpecialization: break;
- case clang::Type::Atomic: break;
-
- // pointer type decayed from an array or function type.
- case clang::Type::Decayed: break;
- case clang::Type::Adjusted: break;
- }
- // We don't know hot to display this type...
- return lldb::eTypeClassOther;
-
-}
-
-void
-ClangASTType::SetClangType (clang::ASTContext *ast, clang::QualType qual_type)
-{
- m_ast = ast;
- m_type = qual_type.getAsOpaquePtr();
-}
-
-unsigned
-ClangASTType::GetTypeQualifiers() const
-{
- if (IsValid())
- return GetQualType().getQualifiers().getCVRQualifiers();
- return 0;
-}
-
-//----------------------------------------------------------------------
-// Creating related types
-//----------------------------------------------------------------------
-
-ClangASTType
-ClangASTType::AddConstModifier () const
-{
- if (m_type)
- {
- clang::QualType result(GetQualType());
- result.addConst();
- return ClangASTType (m_ast, result);
- }
- return ClangASTType();
-}
-
-ClangASTType
-ClangASTType::AddRestrictModifier () const
-{
- if (m_type)
- {
- clang::QualType result(GetQualType());
- result.getQualifiers().setRestrict (true);
- return ClangASTType (m_ast, result);
- }
- return ClangASTType();
-}
-
-ClangASTType
-ClangASTType::AddVolatileModifier () const
-{
- if (m_type)
- {
- clang::QualType result(GetQualType());
- result.getQualifiers().setVolatile (true);
- return ClangASTType (m_ast, result);
- }
- return ClangASTType();
-}
-
-ClangASTType
-ClangASTType::GetArrayElementType (uint64_t *stride) const
-{
- if (IsValid())
- {
- clang::QualType qual_type(GetCanonicalQualType());
-
- const clang::Type *array_elem_type = qual_type.getTypePtr()->getArrayElementTypeNoTypeQual();
-
- if (!array_elem_type)
- return ClangASTType();
-
- ClangASTType element_type (m_ast, array_elem_type->getCanonicalTypeUnqualified());
-
- // TODO: the real stride will be >= this value.. find the real one!
- if (stride)
- *stride = element_type.GetByteSize(nullptr);
-
- return element_type;
-
- }
- return ClangASTType();
-}
-
-ClangASTType
-ClangASTType::GetCanonicalType () const
-{
- if (IsValid())
- return ClangASTType (m_ast, GetCanonicalQualType());
- return ClangASTType();
-}
-
-static clang::QualType
-GetFullyUnqualifiedType_Impl (clang::ASTContext *ast, clang::QualType qual_type)
-{
- if (qual_type->isPointerType())
- qual_type = ast->getPointerType(GetFullyUnqualifiedType_Impl(ast, qual_type->getPointeeType()));
- else
- qual_type = qual_type.getUnqualifiedType();
- qual_type.removeLocalConst();
- qual_type.removeLocalRestrict();
- qual_type.removeLocalVolatile();
- return qual_type;
-}
-
-ClangASTType
-ClangASTType::GetFullyUnqualifiedType () const
-{
- if (IsValid())
- return ClangASTType(m_ast, GetFullyUnqualifiedType_Impl(m_ast, GetQualType()));
- return ClangASTType();
-}
-
-
-int
-ClangASTType::GetFunctionArgumentCount () const
-{
- if (IsValid())
- {
- const clang::FunctionProtoType* func = llvm::dyn_cast<clang::FunctionProtoType>(GetCanonicalQualType());
- if (func)
- return func->getNumParams();
- }
- return -1;
-}
-
-ClangASTType
-ClangASTType::GetFunctionArgumentTypeAtIndex (size_t idx) const
-{
- if (IsValid())
- {
- const clang::FunctionProtoType* func = llvm::dyn_cast<clang::FunctionProtoType>(GetCanonicalQualType());
- if (func)
- {
- const uint32_t num_args = func->getNumParams();
- if (idx < num_args)
- return ClangASTType(m_ast, func->getParamType(idx));
- }
- }
- return ClangASTType();
-}
-
-ClangASTType
-ClangASTType::GetFunctionReturnType () const
-{
- if (IsValid())
- {
- clang::QualType qual_type(GetCanonicalQualType());
- const clang::FunctionProtoType* func = llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
- if (func)
- return ClangASTType(m_ast, func->getReturnType());
- }
- return ClangASTType();
-}
-
-size_t
-ClangASTType::GetNumMemberFunctions () const
-{
- size_t num_functions = 0;
- if (IsValid())
- {
- clang::QualType qual_type(GetCanonicalQualType());
- switch (qual_type->getTypeClass()) {
- case clang::Type::Record:
- if (GetCompleteQualType (m_ast, qual_type))
- {
- const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
- assert(record_decl);
- const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
- if (cxx_record_decl)
- num_functions = std::distance(cxx_record_decl->method_begin(), cxx_record_decl->method_end());
- }
- break;
-
- case clang::Type::ObjCObjectPointer:
- if (GetCompleteType())
- {
- const clang::ObjCObjectPointerType *objc_class_type = qual_type->getAsObjCInterfacePointerType();
- if (objc_class_type)
- {
- clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterfaceDecl();
- if (class_interface_decl)
- num_functions = std::distance(class_interface_decl->meth_begin(), class_interface_decl->meth_end());
- }
- }
- break;
-
- case clang::Type::ObjCObject:
- case clang::Type::ObjCInterface:
- if (GetCompleteType())
- {
- const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
- if (objc_class_type)
- {
- clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
- if (class_interface_decl)
- num_functions = std::distance(class_interface_decl->meth_begin(), class_interface_decl->meth_end());
- }
- }
- break;
-
-
- case clang::Type::Typedef:
- return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumMemberFunctions();
-
- case clang::Type::Elaborated:
- return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetNumMemberFunctions();
-
- case clang::Type::Paren:
- return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetNumMemberFunctions();
-
- default:
- break;
- }
- }
- return num_functions;
-}
-
-TypeMemberFunctionImpl
-ClangASTType::GetMemberFunctionAtIndex (size_t idx)
-{
- std::string name("");
- MemberFunctionKind kind(MemberFunctionKind::eMemberFunctionKindUnknown);
- ClangASTType type{};
- clang::ObjCMethodDecl *method_decl(nullptr);
- if (IsValid())
- {
- clang::QualType qual_type(GetCanonicalQualType());
- switch (qual_type->getTypeClass()) {
- case clang::Type::Record:
- if (GetCompleteQualType (m_ast, qual_type))
- {
- const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
- assert(record_decl);
- const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
- if (cxx_record_decl)
- {
- auto method_iter = cxx_record_decl->method_begin();
- auto method_end = cxx_record_decl->method_end();
- if (idx < static_cast<size_t>(std::distance(method_iter, method_end)))
- {
- std::advance(method_iter, idx);
- auto method_decl = method_iter->getCanonicalDecl();
- if (method_decl)
- {
- if (!method_decl->getName().empty())
- name.assign(method_decl->getName().data());
- else
- name.clear();
- if (method_decl->isStatic())
- kind = lldb::eMemberFunctionKindStaticMethod;
- else if (llvm::isa<clang::CXXConstructorDecl>(method_decl))
- kind = lldb::eMemberFunctionKindConstructor;
- else if (llvm::isa<clang::CXXDestructorDecl>(method_decl))
- kind = lldb::eMemberFunctionKindDestructor;
- else
- kind = lldb::eMemberFunctionKindInstanceMethod;
- type = ClangASTType(m_ast,method_decl->getType().getAsOpaquePtr());
- }
- }
- }
- }
- break;
-
- case clang::Type::ObjCObjectPointer:
- if (GetCompleteType())
- {
- const clang::ObjCObjectPointerType *objc_class_type = qual_type->getAsObjCInterfacePointerType();
- if (objc_class_type)
- {
- clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterfaceDecl();
- if (class_interface_decl)
- {
- auto method_iter = class_interface_decl->meth_begin();
- auto method_end = class_interface_decl->meth_end();
- if (idx < static_cast<size_t>(std::distance(method_iter, method_end)))
- {
- std::advance(method_iter, idx);
- method_decl = method_iter->getCanonicalDecl();
- if (method_decl)
- {
- name = method_decl->getSelector().getAsString();
- if (method_decl->isClassMethod())
- kind = lldb::eMemberFunctionKindStaticMethod;
- else
- kind = lldb::eMemberFunctionKindInstanceMethod;
- }
- }
- }
- }
- }
- break;
-
- case clang::Type::ObjCObject:
- case clang::Type::ObjCInterface:
- if (GetCompleteType())
- {
- const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
- if (objc_class_type)
- {
- clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
- if (class_interface_decl)
- {
- auto method_iter = class_interface_decl->meth_begin();
- auto method_end = class_interface_decl->meth_end();
- if (idx < static_cast<size_t>(std::distance(method_iter, method_end)))
- {
- std::advance(method_iter, idx);
- method_decl = method_iter->getCanonicalDecl();
- if (method_decl)
- {
- name = method_decl->getSelector().getAsString();
- if (method_decl->isClassMethod())
- kind = lldb::eMemberFunctionKindStaticMethod;
- else
- kind = lldb::eMemberFunctionKindInstanceMethod;
- }
- }
- }
- }
- }
- break;
-
- case clang::Type::Typedef:
- return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetMemberFunctionAtIndex(idx);
-
- case clang::Type::Elaborated:
- return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetMemberFunctionAtIndex(idx);
-
- case clang::Type::Paren:
- return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetMemberFunctionAtIndex(idx);
-
- default:
- break;
- }
- }
-
- if (kind == eMemberFunctionKindUnknown)
- return TypeMemberFunctionImpl();
- if (method_decl)
- return TypeMemberFunctionImpl(method_decl, name, kind);
- if (type)
- return TypeMemberFunctionImpl(type, name, kind);
-
- return TypeMemberFunctionImpl();
-}
-
-ClangASTType
-ClangASTType::GetLValueReferenceType () const
-{
- if (IsValid())
- {
- return ClangASTType(m_ast, m_ast->getLValueReferenceType(GetQualType()));
- }
- return ClangASTType();
-}
-
-ClangASTType
-ClangASTType::GetRValueReferenceType () const
-{
- if (IsValid())
- {
- return ClangASTType(m_ast, m_ast->getRValueReferenceType(GetQualType()));
- }
- return ClangASTType();
-}
-
-ClangASTType
-ClangASTType::GetNonReferenceType () const
-{
- if (IsValid())
- return ClangASTType(m_ast, GetQualType().getNonReferenceType());
- return ClangASTType();
-}
-
-ClangASTType
-ClangASTType::CreateTypedefType (const char *typedef_name,
- clang::DeclContext *decl_ctx) const
-{
- if (IsValid() && typedef_name && typedef_name[0])
- {
- clang::QualType qual_type (GetQualType());
- if (decl_ctx == nullptr)
- decl_ctx = m_ast->getTranslationUnitDecl();
- clang::TypedefDecl *decl = clang::TypedefDecl::Create (*m_ast,
- decl_ctx,
- clang::SourceLocation(),
- clang::SourceLocation(),
- &m_ast->Idents.get(typedef_name),
- m_ast->getTrivialTypeSourceInfo(qual_type));
-
- decl->setAccess(clang::AS_public); // TODO respect proper access specifier
-
- // Get a uniqued clang::QualType for the typedef decl type
- return ClangASTType (m_ast, m_ast->getTypedefType (decl));
- }
- return ClangASTType();
-
-}
-
-ClangASTType
-ClangASTType::GetPointeeType () const
-{
- if (m_type)
- {
- clang::QualType qual_type(GetQualType());
- return ClangASTType (m_ast, qual_type.getTypePtr()->getPointeeType());
- }
- return ClangASTType();
-}
-
-ClangASTType
-ClangASTType::GetPointerType () const
-{
- if (IsValid())
- {
- clang::QualType qual_type (GetQualType());
-
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::ObjCObject:
- case clang::Type::ObjCInterface:
- return ClangASTType(m_ast, m_ast->getObjCObjectPointerType(qual_type).getAsOpaquePtr());
-
- default:
- return ClangASTType(m_ast, m_ast->getPointerType(qual_type).getAsOpaquePtr());
- }
- }
- return ClangASTType();
-}
-
-ClangASTType
-ClangASTType::GetTypedefedType () const
-{
- if (IsValid())
- {
- const clang::TypedefType *typedef_type = llvm::dyn_cast<clang::TypedefType>(GetQualType());
- if (typedef_type)
- return ClangASTType (m_ast, typedef_type->getDecl()->getUnderlyingType());
- }
- return ClangASTType();
-}
-
-ClangASTType
-ClangASTType::RemoveFastQualifiers () const
-{
- if (m_type)
- {
- clang::QualType qual_type(GetQualType());
- qual_type.getQualifiers().removeFastQualifiers();
- return ClangASTType (m_ast, qual_type);
- }
- return ClangASTType();
-}
-
-
-//----------------------------------------------------------------------
-// Create related types using the current type's AST
-//----------------------------------------------------------------------
-
-ClangASTType
-ClangASTType::GetBasicTypeFromAST (lldb::BasicType basic_type) const
-{
- if (IsValid())
- return ClangASTContext::GetBasicType(m_ast, basic_type);
- return ClangASTType();
-}
-//----------------------------------------------------------------------
-// Exploring the type
-//----------------------------------------------------------------------
-
-uint64_t
-ClangASTType::GetBitSize (ExecutionContextScope *exe_scope) const
-{
- if (GetCompleteType ())
- {
- clang::QualType qual_type(GetCanonicalQualType());
- switch (qual_type->getTypeClass())
- {
- case clang::Type::ObjCInterface:
- case clang::Type::ObjCObject:
- {
- ExecutionContext exe_ctx (exe_scope);
- Process *process = exe_ctx.GetProcessPtr();
- if (process)
- {
- ObjCLanguageRuntime *objc_runtime = process->GetObjCLanguageRuntime();
- if (objc_runtime)
- {
- uint64_t bit_size = 0;
- if (objc_runtime->GetTypeBitSize(*this, bit_size))
- return bit_size;
- }
- }
- else
- {
- static bool g_printed = false;
- if (!g_printed)
- {
- StreamString s;
- DumpTypeDescription(&s);
-
- llvm::outs() << "warning: trying to determine the size of type ";
- llvm::outs() << s.GetString() << "\n";
- llvm::outs() << "without a valid ExecutionContext. this is not reliable. please file a bug against LLDB.\n";
- llvm::outs() << "backtrace:\n";
- llvm::sys::PrintStackTrace(llvm::outs());
- llvm::outs() << "\n";
- g_printed = true;
- }
- }
- }
- // fallthrough
- default:
- const uint32_t bit_size = m_ast->getTypeSize (qual_type);
- if (bit_size == 0)
- {
- if (qual_type->isIncompleteArrayType())
- return m_ast->getTypeSize (qual_type->getArrayElementTypeNoTypeQual()->getCanonicalTypeUnqualified());
- }
- if (qual_type->isObjCObjectOrInterfaceType())
- return bit_size + m_ast->getTypeSize(m_ast->ObjCBuiltinClassTy);
- return bit_size;
- }
- }
- return 0;
-}
-
-uint64_t
-ClangASTType::GetByteSize (ExecutionContextScope *exe_scope) const
-{
- return (GetBitSize (exe_scope) + 7) / 8;
-}
-
-
-size_t
-ClangASTType::GetTypeBitAlign () const
-{
- if (GetCompleteType ())
- return m_ast->getTypeAlign(GetQualType());
- return 0;
-}
-
-
-lldb::Encoding
-ClangASTType::GetEncoding (uint64_t &count) const
-{
- if (!IsValid())
- return lldb::eEncodingInvalid;
-
- count = 1;
- clang::QualType qual_type(GetCanonicalQualType());
-
- switch (qual_type->getTypeClass())
- {
- case clang::Type::UnaryTransform:
- break;
-
- case clang::Type::FunctionNoProto:
- case clang::Type::FunctionProto:
- break;
-
- case clang::Type::IncompleteArray:
- case clang::Type::VariableArray:
- break;
-
- case clang::Type::ConstantArray:
- break;
-
- case clang::Type::ExtVector:
- case clang::Type::Vector:
- // TODO: Set this to more than one???
- break;
-
- case clang::Type::Builtin:
- switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind())
- {
- default: assert(0 && "Unknown builtin type!");
- case clang::BuiltinType::Void:
- break;
-
- case clang::BuiltinType::Bool:
- case clang::BuiltinType::Char_S:
- case clang::BuiltinType::SChar:
- case clang::BuiltinType::WChar_S:
- case clang::BuiltinType::Char16:
- case clang::BuiltinType::Char32:
- case clang::BuiltinType::Short:
- case clang::BuiltinType::Int:
- case clang::BuiltinType::Long:
- case clang::BuiltinType::LongLong:
- case clang::BuiltinType::Int128: return lldb::eEncodingSint;
-
- case clang::BuiltinType::Char_U:
- case clang::BuiltinType::UChar:
- case clang::BuiltinType::WChar_U:
- case clang::BuiltinType::UShort:
- case clang::BuiltinType::UInt:
- case clang::BuiltinType::ULong:
- case clang::BuiltinType::ULongLong:
- case clang::BuiltinType::UInt128: return lldb::eEncodingUint;
-
- case clang::BuiltinType::Float:
- case clang::BuiltinType::Double:
- case clang::BuiltinType::LongDouble: return lldb::eEncodingIEEE754;
-
- case clang::BuiltinType::ObjCClass:
- case clang::BuiltinType::ObjCId:
- case clang::BuiltinType::ObjCSel: return lldb::eEncodingUint;
-
- case clang::BuiltinType::NullPtr: return lldb::eEncodingUint;
-
- case clang::BuiltinType::Kind::ARCUnbridgedCast:
- case clang::BuiltinType::Kind::BoundMember:
- case clang::BuiltinType::Kind::BuiltinFn:
- case clang::BuiltinType::Kind::Dependent:
- case clang::BuiltinType::Kind::Half:
- case clang::BuiltinType::Kind::OCLEvent:
- case clang::BuiltinType::Kind::OCLImage1d:
- case clang::BuiltinType::Kind::OCLImage1dArray:
- case clang::BuiltinType::Kind::OCLImage1dBuffer:
- case clang::BuiltinType::Kind::OCLImage2d:
- case clang::BuiltinType::Kind::OCLImage2dArray:
- case clang::BuiltinType::Kind::OCLImage3d:
- case clang::BuiltinType::Kind::OCLSampler:
- case clang::BuiltinType::Kind::Overload:
- case clang::BuiltinType::Kind::PseudoObject:
- case clang::BuiltinType::Kind::UnknownAny:
- break;
- }
- break;
- // All pointer types are represented as unsigned integer encodings.
- // We may nee to add a eEncodingPointer if we ever need to know the
- // difference
- case clang::Type::ObjCObjectPointer:
- case clang::Type::BlockPointer:
- case clang::Type::Pointer:
- case clang::Type::LValueReference:
- case clang::Type::RValueReference:
- case clang::Type::MemberPointer: return lldb::eEncodingUint;
- case clang::Type::Complex:
- {
- lldb::Encoding encoding = lldb::eEncodingIEEE754;
- if (qual_type->isComplexType())
- encoding = lldb::eEncodingIEEE754;
- else
- {
- const clang::ComplexType *complex_type = qual_type->getAsComplexIntegerType();
- if (complex_type)
- encoding = ClangASTType(m_ast, complex_type->getElementType()).GetEncoding(count);
- else
- encoding = lldb::eEncodingSint;
- }
- count = 2;
- return encoding;
- }
-
- case clang::Type::ObjCInterface: break;
- case clang::Type::Record: break;
- case clang::Type::Enum: return lldb::eEncodingSint;
- case clang::Type::Typedef:
- return ClangASTType(m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetEncoding(count);
-
- case clang::Type::Elaborated:
- return ClangASTType(m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetEncoding(count);
-
- case clang::Type::Paren:
- return ClangASTType(m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetEncoding(count);
-
- case clang::Type::DependentSizedArray:
- case clang::Type::DependentSizedExtVector:
- case clang::Type::UnresolvedUsing:
- case clang::Type::Attributed:
- case clang::Type::TemplateTypeParm:
- case clang::Type::SubstTemplateTypeParm:
- case clang::Type::SubstTemplateTypeParmPack:
- case clang::Type::Auto:
- case clang::Type::InjectedClassName:
- case clang::Type::DependentName:
- case clang::Type::DependentTemplateSpecialization:
- case clang::Type::PackExpansion:
- case clang::Type::ObjCObject:
-
- case clang::Type::TypeOfExpr:
- case clang::Type::TypeOf:
- case clang::Type::Decltype:
- case clang::Type::TemplateSpecialization:
- case clang::Type::Atomic:
- case clang::Type::Adjusted:
- break;
-
- // pointer type decayed from an array or function type.
- case clang::Type::Decayed:
- break;
- }
- count = 0;
- return lldb::eEncodingInvalid;
-}
-
-lldb::Format
-ClangASTType::GetFormat () const
-{
- if (!IsValid())
- return lldb::eFormatDefault;
-
- clang::QualType qual_type(GetCanonicalQualType());
-
- switch (qual_type->getTypeClass())
- {
- case clang::Type::UnaryTransform:
- break;
-
- case clang::Type::FunctionNoProto:
- case clang::Type::FunctionProto:
- break;
-
- case clang::Type::IncompleteArray:
- case clang::Type::VariableArray:
- break;
-
- case clang::Type::ConstantArray:
- return lldb::eFormatVoid; // no value
-
- case clang::Type::ExtVector:
- case clang::Type::Vector:
- break;
-
- case clang::Type::Builtin:
- switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind())
- {
- //default: assert(0 && "Unknown builtin type!");
- case clang::BuiltinType::UnknownAny:
- case clang::BuiltinType::Void:
- case clang::BuiltinType::BoundMember:
- break;
-
- case clang::BuiltinType::Bool: return lldb::eFormatBoolean;
- case clang::BuiltinType::Char_S:
- case clang::BuiltinType::SChar:
- case clang::BuiltinType::WChar_S:
- case clang::BuiltinType::Char_U:
- case clang::BuiltinType::UChar:
- case clang::BuiltinType::WChar_U: return lldb::eFormatChar;
- case clang::BuiltinType::Char16: return lldb::eFormatUnicode16;
- case clang::BuiltinType::Char32: return lldb::eFormatUnicode32;
- case clang::BuiltinType::UShort: return lldb::eFormatUnsigned;
- case clang::BuiltinType::Short: return lldb::eFormatDecimal;
- case clang::BuiltinType::UInt: return lldb::eFormatUnsigned;
- case clang::BuiltinType::Int: return lldb::eFormatDecimal;
- case clang::BuiltinType::ULong: return lldb::eFormatUnsigned;
- case clang::BuiltinType::Long: return lldb::eFormatDecimal;
- case clang::BuiltinType::ULongLong: return lldb::eFormatUnsigned;
- case clang::BuiltinType::LongLong: return lldb::eFormatDecimal;
- case clang::BuiltinType::UInt128: return lldb::eFormatUnsigned;
- case clang::BuiltinType::Int128: return lldb::eFormatDecimal;
- case clang::BuiltinType::Float: return lldb::eFormatFloat;
- case clang::BuiltinType::Double: return lldb::eFormatFloat;
- case clang::BuiltinType::LongDouble: return lldb::eFormatFloat;
- case clang::BuiltinType::NullPtr:
- case clang::BuiltinType::Overload:
- case clang::BuiltinType::Dependent:
- case clang::BuiltinType::ObjCId:
- case clang::BuiltinType::ObjCClass:
- case clang::BuiltinType::ObjCSel:
- case clang::BuiltinType::Half:
- case clang::BuiltinType::ARCUnbridgedCast:
- case clang::BuiltinType::PseudoObject:
- case clang::BuiltinType::BuiltinFn:
- case clang::BuiltinType::OCLEvent:
- case clang::BuiltinType::OCLImage1d:
- case clang::BuiltinType::OCLImage1dArray:
- case clang::BuiltinType::OCLImage1dBuffer:
- case clang::BuiltinType::OCLImage2d:
- case clang::BuiltinType::OCLImage2dArray:
- case clang::BuiltinType::OCLImage3d:
- case clang::BuiltinType::OCLSampler:
- return lldb::eFormatHex;
- }
- break;
- case clang::Type::ObjCObjectPointer: return lldb::eFormatHex;
- case clang::Type::BlockPointer: return lldb::eFormatHex;
- case clang::Type::Pointer: return lldb::eFormatHex;
- case clang::Type::LValueReference:
- case clang::Type::RValueReference: return lldb::eFormatHex;
- case clang::Type::MemberPointer: break;
- case clang::Type::Complex:
- {
- if (qual_type->isComplexType())
- return lldb::eFormatComplex;
- else
- return lldb::eFormatComplexInteger;
- }
- case clang::Type::ObjCInterface: break;
- case clang::Type::Record: break;
- case clang::Type::Enum: return lldb::eFormatEnum;
- case clang::Type::Typedef:
- return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetFormat();
- case clang::Type::Auto:
- return ClangASTType (m_ast, llvm::cast<clang::AutoType>(qual_type)->desugar()).GetFormat();
- case clang::Type::Paren:
- return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetFormat();
- case clang::Type::Elaborated:
- return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetFormat();
- case clang::Type::DependentSizedArray:
- case clang::Type::DependentSizedExtVector:
- case clang::Type::UnresolvedUsing:
- case clang::Type::Attributed:
- case clang::Type::TemplateTypeParm:
- case clang::Type::SubstTemplateTypeParm:
- case clang::Type::SubstTemplateTypeParmPack:
- case clang::Type::InjectedClassName:
- case clang::Type::DependentName:
- case clang::Type::DependentTemplateSpecialization:
- case clang::Type::PackExpansion:
- case clang::Type::ObjCObject:
-
- case clang::Type::TypeOfExpr:
- case clang::Type::TypeOf:
- case clang::Type::Decltype:
- case clang::Type::TemplateSpecialization:
- case clang::Type::Atomic:
- case clang::Type::Adjusted:
- break;
-
- // pointer type decayed from an array or function type.
- case clang::Type::Decayed:
- break;
- }
- // We don't know hot to display this type...
- return lldb::eFormatBytes;
-}
-
-static bool
-ObjCDeclHasIVars (clang::ObjCInterfaceDecl *class_interface_decl, bool check_superclass)
-{
- while (class_interface_decl)
- {
- if (class_interface_decl->ivar_size() > 0)
- return true;
-
- if (check_superclass)
- class_interface_decl = class_interface_decl->getSuperClass();
- else
- break;
- }
- return false;
-}
-
-uint32_t
-ClangASTType::GetNumChildren (bool omit_empty_base_classes) const
-{
- if (!IsValid())
- return 0;
-
- uint32_t num_children = 0;
- clang::QualType qual_type(GetQualType());
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::Builtin:
- switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind())
- {
- case clang::BuiltinType::ObjCId: // child is Class
- case clang::BuiltinType::ObjCClass: // child is Class
- num_children = 1;
- break;
-
- default:
- break;
- }
- break;
-
- case clang::Type::Complex: return 0;
-
- case clang::Type::Record:
- if (GetCompleteQualType (m_ast, qual_type))
- {
- const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
- assert(record_decl);
- const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
- if (cxx_record_decl)
- {
- if (omit_empty_base_classes)
- {
- // Check each base classes to see if it or any of its
- // base classes contain any fields. This can help
- // limit the noise in variable views by not having to
- // show base classes that contain no members.
- clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
- for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
- base_class != base_class_end;
- ++base_class)
- {
- const clang::CXXRecordDecl *base_class_decl = llvm::cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl());
-
- // Skip empty base classes
- if (ClangASTContext::RecordHasFields(base_class_decl) == false)
- continue;
-
- num_children++;
- }
- }
- else
- {
- // Include all base classes
- num_children += cxx_record_decl->getNumBases();
- }
-
- }
- clang::RecordDecl::field_iterator field, field_end;
- for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field)
- ++num_children;
- }
- break;
-
- case clang::Type::ObjCObject:
- case clang::Type::ObjCInterface:
- if (GetCompleteQualType (m_ast, qual_type))
- {
- const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
- assert (objc_class_type);
- if (objc_class_type)
- {
- clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
-
- if (class_interface_decl)
- {
-
- clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass();
- if (superclass_interface_decl)
- {
- if (omit_empty_base_classes)
- {
- if (ObjCDeclHasIVars (superclass_interface_decl, true))
- ++num_children;
- }
- else
- ++num_children;
- }
-
- num_children += class_interface_decl->ivar_size();
- }
- }
- }
- break;
-
- case clang::Type::ObjCObjectPointer:
- {
- const clang::ObjCObjectPointerType *pointer_type = llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr());
- clang::QualType pointee_type = pointer_type->getPointeeType();
- uint32_t num_pointee_children = ClangASTType (m_ast,pointee_type).GetNumChildren (omit_empty_base_classes);
- // If this type points to a simple type, then it has 1 child
- if (num_pointee_children == 0)
- num_children = 1;
- else
- num_children = num_pointee_children;
- }
- break;
-
- case clang::Type::Vector:
- case clang::Type::ExtVector:
- num_children = llvm::cast<clang::VectorType>(qual_type.getTypePtr())->getNumElements();
- break;
-
- case clang::Type::ConstantArray:
- num_children = llvm::cast<clang::ConstantArrayType>(qual_type.getTypePtr())->getSize().getLimitedValue();
- break;
-
- case clang::Type::Pointer:
- {
- const clang::PointerType *pointer_type = llvm::cast<clang::PointerType>(qual_type.getTypePtr());
- clang::QualType pointee_type (pointer_type->getPointeeType());
- uint32_t num_pointee_children = ClangASTType (m_ast,pointee_type).GetNumChildren (omit_empty_base_classes);
- if (num_pointee_children == 0)
- {
- // We have a pointer to a pointee type that claims it has no children.
- // We will want to look at
- num_children = ClangASTType (m_ast, pointee_type).GetNumPointeeChildren();
- }
- else
- num_children = num_pointee_children;
- }
- break;
-
- case clang::Type::LValueReference:
- case clang::Type::RValueReference:
- {
- const clang::ReferenceType *reference_type = llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
- clang::QualType pointee_type = reference_type->getPointeeType();
- uint32_t num_pointee_children = ClangASTType (m_ast, pointee_type).GetNumChildren (omit_empty_base_classes);
- // If this type points to a simple type, then it has 1 child
- if (num_pointee_children == 0)
- num_children = 1;
- else
- num_children = num_pointee_children;
- }
- break;
-
-
- case clang::Type::Typedef:
- num_children = ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumChildren (omit_empty_base_classes);
- break;
-
- case clang::Type::Elaborated:
- num_children = ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetNumChildren (omit_empty_base_classes);
- break;
-
- case clang::Type::Paren:
- num_children = ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetNumChildren (omit_empty_base_classes);
- break;
- default:
- break;
- }
- return num_children;
-}
-
-lldb::BasicType
-ClangASTType::GetBasicTypeEnumeration () const
-{
- if (IsValid())
- {
- clang::QualType qual_type(GetQualType());
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- if (type_class == clang::Type::Builtin)
- {
- switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind())
- {
- case clang::BuiltinType::Void: return eBasicTypeVoid;
- case clang::BuiltinType::Bool: return eBasicTypeBool;
- case clang::BuiltinType::Char_S: return eBasicTypeSignedChar;
- case clang::BuiltinType::Char_U: return eBasicTypeUnsignedChar;
- case clang::BuiltinType::Char16: return eBasicTypeChar16;
- case clang::BuiltinType::Char32: return eBasicTypeChar32;
- case clang::BuiltinType::UChar: return eBasicTypeUnsignedChar;
- case clang::BuiltinType::SChar: return eBasicTypeSignedChar;
- case clang::BuiltinType::WChar_S: return eBasicTypeSignedWChar;
- case clang::BuiltinType::WChar_U: return eBasicTypeUnsignedWChar;
- case clang::BuiltinType::Short: return eBasicTypeShort;
- case clang::BuiltinType::UShort: return eBasicTypeUnsignedShort;
- case clang::BuiltinType::Int: return eBasicTypeInt;
- case clang::BuiltinType::UInt: return eBasicTypeUnsignedInt;
- case clang::BuiltinType::Long: return eBasicTypeLong;
- case clang::BuiltinType::ULong: return eBasicTypeUnsignedLong;
- case clang::BuiltinType::LongLong: return eBasicTypeLongLong;
- case clang::BuiltinType::ULongLong: return eBasicTypeUnsignedLongLong;
- case clang::BuiltinType::Int128: return eBasicTypeInt128;
- case clang::BuiltinType::UInt128: return eBasicTypeUnsignedInt128;
-
- case clang::BuiltinType::Half: return eBasicTypeHalf;
- case clang::BuiltinType::Float: return eBasicTypeFloat;
- case clang::BuiltinType::Double: return eBasicTypeDouble;
- case clang::BuiltinType::LongDouble:return eBasicTypeLongDouble;
-
- case clang::BuiltinType::NullPtr: return eBasicTypeNullPtr;
- case clang::BuiltinType::ObjCId: return eBasicTypeObjCID;
- case clang::BuiltinType::ObjCClass: return eBasicTypeObjCClass;
- case clang::BuiltinType::ObjCSel: return eBasicTypeObjCSel;
- case clang::BuiltinType::Dependent:
- case clang::BuiltinType::Overload:
- case clang::BuiltinType::BoundMember:
- case clang::BuiltinType::PseudoObject:
- case clang::BuiltinType::UnknownAny:
- case clang::BuiltinType::BuiltinFn:
- case clang::BuiltinType::ARCUnbridgedCast:
- case clang::BuiltinType::OCLEvent:
- case clang::BuiltinType::OCLImage1d:
- case clang::BuiltinType::OCLImage1dArray:
- case clang::BuiltinType::OCLImage1dBuffer:
- case clang::BuiltinType::OCLImage2d:
- case clang::BuiltinType::OCLImage2dArray:
- case clang::BuiltinType::OCLImage3d:
- case clang::BuiltinType::OCLSampler:
- return eBasicTypeOther;
- }
- }
- }
- return eBasicTypeInvalid;
-}
-
-
-#pragma mark Aggregate Types
-
-uint32_t
-ClangASTType::GetNumDirectBaseClasses () const
-{
- if (!IsValid())
- return 0;
-
- uint32_t count = 0;
- clang::QualType qual_type(GetCanonicalQualType());
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::Record:
- if (GetCompleteType())
- {
- const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
- if (cxx_record_decl)
- count = cxx_record_decl->getNumBases();
- }
- break;
-
- case clang::Type::ObjCObjectPointer:
- count = GetPointeeType().GetNumDirectBaseClasses();
- break;
-
- case clang::Type::ObjCObject:
- if (GetCompleteType())
- {
- const clang::ObjCObjectType *objc_class_type = qual_type->getAsObjCQualifiedInterfaceType();
- if (objc_class_type)
- {
- clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
-
- if (class_interface_decl && class_interface_decl->getSuperClass())
- count = 1;
- }
- }
- break;
- case clang::Type::ObjCInterface:
- if (GetCompleteType())
- {
- const clang::ObjCInterfaceType *objc_interface_type = qual_type->getAs<clang::ObjCInterfaceType>();
- if (objc_interface_type)
- {
- clang::ObjCInterfaceDecl *class_interface_decl = objc_interface_type->getInterface();
-
- if (class_interface_decl && class_interface_decl->getSuperClass())
- count = 1;
- }
- }
- break;
-
-
- case clang::Type::Typedef:
- count = ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumDirectBaseClasses ();
- break;
-
- case clang::Type::Elaborated:
- count = ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetNumDirectBaseClasses ();
- break;
-
- case clang::Type::Paren:
- return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetNumDirectBaseClasses ();
-
- default:
- break;
- }
- return count;
-}
-
-uint32_t
-ClangASTType::GetNumVirtualBaseClasses () const
-{
- if (!IsValid())
- return 0;
-
- uint32_t count = 0;
- clang::QualType qual_type(GetCanonicalQualType());
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::Record:
- if (GetCompleteType())
- {
- const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
- if (cxx_record_decl)
- count = cxx_record_decl->getNumVBases();
- }
- break;
-
- case clang::Type::Typedef:
- count = ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumVirtualBaseClasses();
- break;
-
- case clang::Type::Elaborated:
- count = ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetNumVirtualBaseClasses();
- break;
-
- case clang::Type::Paren:
- count = ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetNumVirtualBaseClasses();
- break;
-
- default:
- break;
- }
- return count;
-}
-
-uint32_t
-ClangASTType::GetNumFields () const
-{
- if (!IsValid())
- return 0;
-
- uint32_t count = 0;
- clang::QualType qual_type(GetCanonicalQualType());
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::Record:
- if (GetCompleteType())
- {
- const clang::RecordType *record_type = llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
- if (record_type)
- {
- clang::RecordDecl *record_decl = record_type->getDecl();
- if (record_decl)
- {
- uint32_t field_idx = 0;
- clang::RecordDecl::field_iterator field, field_end;
- for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field)
- ++field_idx;
- count = field_idx;
- }
- }
- }
- break;
-
- case clang::Type::Typedef:
- count = ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumFields();
- break;
-
- case clang::Type::Elaborated:
- count = ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetNumFields();
- break;
-
- case clang::Type::Paren:
- count = ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetNumFields();
- break;
-
- case clang::Type::ObjCObjectPointer:
- if (GetCompleteType())
- {
- const clang::ObjCObjectPointerType *objc_class_type = qual_type->getAsObjCInterfacePointerType();
- if (objc_class_type)
- {
- clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterfaceDecl();
-
- if (class_interface_decl)
- count = class_interface_decl->ivar_size();
- }
- }
- break;
-
- case clang::Type::ObjCObject:
- case clang::Type::ObjCInterface:
- if (GetCompleteType())
- {
- const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
- if (objc_class_type)
- {
- clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
-
- if (class_interface_decl)
- count = class_interface_decl->ivar_size();
- }
- }
- break;
-
- default:
- break;
- }
- return count;
-}
-
-ClangASTType
-ClangASTType::GetDirectBaseClassAtIndex (size_t idx, uint32_t *bit_offset_ptr) const
-{
- if (!IsValid())
- return ClangASTType();
-
- clang::QualType qual_type(GetCanonicalQualType());
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::Record:
- if (GetCompleteType())
- {
- const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
- if (cxx_record_decl)
- {
- uint32_t curr_idx = 0;
- clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
- for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
- base_class != base_class_end;
- ++base_class, ++curr_idx)
- {
- if (curr_idx == idx)
- {
- if (bit_offset_ptr)
- {
- const clang::ASTRecordLayout &record_layout = m_ast->getASTRecordLayout(cxx_record_decl);
- const clang::CXXRecordDecl *base_class_decl = llvm::cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl());
- if (base_class->isVirtual())
- *bit_offset_ptr = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8;
- else
- *bit_offset_ptr = record_layout.getBaseClassOffset(base_class_decl).getQuantity() * 8;
- }
- return ClangASTType (m_ast, base_class->getType());
- }
- }
- }
- }
- break;
-
- case clang::Type::ObjCObjectPointer:
- return GetPointeeType().GetDirectBaseClassAtIndex(idx,bit_offset_ptr);
-
- case clang::Type::ObjCObject:
- if (idx == 0 && GetCompleteType())
- {
- const clang::ObjCObjectType *objc_class_type = qual_type->getAsObjCQualifiedInterfaceType();
- if (objc_class_type)
- {
- clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
-
- if (class_interface_decl)
- {
- clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass();
- if (superclass_interface_decl)
- {
- if (bit_offset_ptr)
- *bit_offset_ptr = 0;
- return ClangASTType (m_ast, m_ast->getObjCInterfaceType(superclass_interface_decl));
- }
- }
- }
- }
- break;
- case clang::Type::ObjCInterface:
- if (idx == 0 && GetCompleteType())
- {
- const clang::ObjCObjectType *objc_interface_type = qual_type->getAs<clang::ObjCInterfaceType>();
- if (objc_interface_type)
- {
- clang::ObjCInterfaceDecl *class_interface_decl = objc_interface_type->getInterface();
-
- if (class_interface_decl)
- {
- clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass();
- if (superclass_interface_decl)
- {
- if (bit_offset_ptr)
- *bit_offset_ptr = 0;
- return ClangASTType (m_ast, m_ast->getObjCInterfaceType(superclass_interface_decl));
- }
- }
- }
- }
- break;
-
-
- case clang::Type::Typedef:
- return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetDirectBaseClassAtIndex (idx, bit_offset_ptr);
-
- case clang::Type::Elaborated:
- return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetDirectBaseClassAtIndex (idx, bit_offset_ptr);
-
- case clang::Type::Paren:
- return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetDirectBaseClassAtIndex (idx, bit_offset_ptr);
-
- default:
- break;
- }
- return ClangASTType();
-}
-
-ClangASTType
-ClangASTType::GetVirtualBaseClassAtIndex (size_t idx, uint32_t *bit_offset_ptr) const
-{
- if (!IsValid())
- return ClangASTType();
-
- clang::QualType qual_type(GetCanonicalQualType());
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::Record:
- if (GetCompleteType())
- {
- const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
- if (cxx_record_decl)
- {
- uint32_t curr_idx = 0;
- clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
- for (base_class = cxx_record_decl->vbases_begin(), base_class_end = cxx_record_decl->vbases_end();
- base_class != base_class_end;
- ++base_class, ++curr_idx)
- {
- if (curr_idx == idx)
- {
- if (bit_offset_ptr)
- {
- const clang::ASTRecordLayout &record_layout = m_ast->getASTRecordLayout(cxx_record_decl);
- const clang::CXXRecordDecl *base_class_decl = llvm::cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl());
- *bit_offset_ptr = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8;
-
- }
- return ClangASTType (m_ast, base_class->getType());
- }
- }
- }
- }
- break;
-
- case clang::Type::Typedef:
- return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetVirtualBaseClassAtIndex (idx, bit_offset_ptr);
-
- case clang::Type::Elaborated:
- return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetVirtualBaseClassAtIndex (idx, bit_offset_ptr);
-
- case clang::Type::Paren:
- return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetVirtualBaseClassAtIndex (idx, bit_offset_ptr);
-
- default:
- break;
- }
- return ClangASTType();
-}
-
-static clang_type_t
-GetObjCFieldAtIndex (clang::ASTContext *ast,
- clang::ObjCInterfaceDecl *class_interface_decl,
- size_t idx,
- std::string& name,
- uint64_t *bit_offset_ptr,
- uint32_t *bitfield_bit_size_ptr,
- bool *is_bitfield_ptr)
-{
- if (class_interface_decl)
- {
- if (idx < (class_interface_decl->ivar_size()))
- {
- clang::ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end();
- uint32_t ivar_idx = 0;
-
- for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end; ++ivar_pos, ++ivar_idx)
- {
- if (ivar_idx == idx)
- {
- const clang::ObjCIvarDecl* ivar_decl = *ivar_pos;
-
- clang::QualType ivar_qual_type(ivar_decl->getType());
-
- name.assign(ivar_decl->getNameAsString());
-
- if (bit_offset_ptr)
- {
- const clang::ASTRecordLayout &interface_layout = ast->getASTObjCInterfaceLayout(class_interface_decl);
- *bit_offset_ptr = interface_layout.getFieldOffset (ivar_idx);
- }
-
- const bool is_bitfield = ivar_pos->isBitField();
-
- if (bitfield_bit_size_ptr)
- {
- *bitfield_bit_size_ptr = 0;
-
- if (is_bitfield && ast)
- {
- clang::Expr *bitfield_bit_size_expr = ivar_pos->getBitWidth();
- llvm::APSInt bitfield_apsint;
- if (bitfield_bit_size_expr && bitfield_bit_size_expr->EvaluateAsInt(bitfield_apsint, *ast))
- {
- *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
- }
- }
- }
- if (is_bitfield_ptr)
- *is_bitfield_ptr = is_bitfield;
-
- return ivar_qual_type.getAsOpaquePtr();
- }
- }
- }
- }
- return nullptr;
-}
-
-ClangASTType
-ClangASTType::GetFieldAtIndex (size_t idx,
- std::string& name,
- uint64_t *bit_offset_ptr,
- uint32_t *bitfield_bit_size_ptr,
- bool *is_bitfield_ptr) const
-{
- if (!IsValid())
- return ClangASTType();
-
- clang::QualType qual_type(GetCanonicalQualType());
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::Record:
- if (GetCompleteType())
- {
- const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
- uint32_t field_idx = 0;
- clang::RecordDecl::field_iterator field, field_end;
- for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++field_idx)
- {
- if (idx == field_idx)
- {
- // Print the member type if requested
- // Print the member name and equal sign
- name.assign(field->getNameAsString());
-
- // Figure out the type byte size (field_type_info.first) and
- // alignment (field_type_info.second) from the AST context.
- if (bit_offset_ptr)
- {
- const clang::ASTRecordLayout &record_layout = m_ast->getASTRecordLayout(record_decl);
- *bit_offset_ptr = record_layout.getFieldOffset (field_idx);
- }
-
- const bool is_bitfield = field->isBitField();
-
- if (bitfield_bit_size_ptr)
- {
- *bitfield_bit_size_ptr = 0;
-
- if (is_bitfield)
- {
- clang::Expr *bitfield_bit_size_expr = field->getBitWidth();
- llvm::APSInt bitfield_apsint;
- if (bitfield_bit_size_expr && bitfield_bit_size_expr->EvaluateAsInt(bitfield_apsint, *m_ast))
- {
- *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
- }
- }
- }
- if (is_bitfield_ptr)
- *is_bitfield_ptr = is_bitfield;
-
- return ClangASTType (m_ast, field->getType());
- }
- }
- }
- break;
-
- case clang::Type::ObjCObjectPointer:
- if (GetCompleteType())
- {
- const clang::ObjCObjectPointerType *objc_class_type = qual_type->getAsObjCInterfacePointerType();
- if (objc_class_type)
- {
- clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterfaceDecl();
- return ClangASTType (m_ast, GetObjCFieldAtIndex(m_ast, class_interface_decl, idx, name, bit_offset_ptr, bitfield_bit_size_ptr, is_bitfield_ptr));
- }
- }
- break;
-
- case clang::Type::ObjCObject:
- case clang::Type::ObjCInterface:
- if (GetCompleteType())
- {
- const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
- assert (objc_class_type);
- if (objc_class_type)
- {
- clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
- return ClangASTType (m_ast, GetObjCFieldAtIndex(m_ast, class_interface_decl, idx, name, bit_offset_ptr, bitfield_bit_size_ptr, is_bitfield_ptr));
- }
- }
- break;
-
-
- case clang::Type::Typedef:
- return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).
- GetFieldAtIndex (idx,
- name,
- bit_offset_ptr,
- bitfield_bit_size_ptr,
- is_bitfield_ptr);
-
- case clang::Type::Elaborated:
- return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).
- GetFieldAtIndex (idx,
- name,
- bit_offset_ptr,
- bitfield_bit_size_ptr,
- is_bitfield_ptr);
-
- case clang::Type::Paren:
- return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).
- GetFieldAtIndex (idx,
- name,
- bit_offset_ptr,
- bitfield_bit_size_ptr,
- is_bitfield_ptr);
-
- default:
- break;
- }
- return ClangASTType();
-}
-
-uint32_t
-ClangASTType::GetIndexOfFieldWithName (const char* name,
- ClangASTType* field_clang_type_ptr,
- uint64_t *bit_offset_ptr,
- uint32_t *bitfield_bit_size_ptr,
- bool *is_bitfield_ptr) const
-{
- unsigned count = GetNumFields();
- std::string field_name;
- for (unsigned index = 0; index < count; index++)
- {
- ClangASTType field_clang_type (GetFieldAtIndex(index, field_name, bit_offset_ptr, bitfield_bit_size_ptr, is_bitfield_ptr));
- if (strcmp(field_name.c_str(), name) == 0)
- {
- if (field_clang_type_ptr)
- *field_clang_type_ptr = field_clang_type;
- return index;
- }
- }
- return UINT32_MAX;
-}
-
-// If a pointer to a pointee type (the clang_type arg) says that it has no
-// children, then we either need to trust it, or override it and return a
-// different result. For example, an "int *" has one child that is an integer,
-// but a function pointer doesn't have any children. Likewise if a Record type
-// claims it has no children, then there really is nothing to show.
-uint32_t
-ClangASTType::GetNumPointeeChildren () const
-{
- if (!IsValid())
- return 0;
-
- clang::QualType qual_type(GetCanonicalQualType());
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::Builtin:
- switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind())
- {
- case clang::BuiltinType::UnknownAny:
- case clang::BuiltinType::Void:
- case clang::BuiltinType::NullPtr:
- case clang::BuiltinType::OCLEvent:
- case clang::BuiltinType::OCLImage1d:
- case clang::BuiltinType::OCLImage1dArray:
- case clang::BuiltinType::OCLImage1dBuffer:
- case clang::BuiltinType::OCLImage2d:
- case clang::BuiltinType::OCLImage2dArray:
- case clang::BuiltinType::OCLImage3d:
- case clang::BuiltinType::OCLSampler:
- return 0;
- case clang::BuiltinType::Bool:
- case clang::BuiltinType::Char_U:
- case clang::BuiltinType::UChar:
- case clang::BuiltinType::WChar_U:
- case clang::BuiltinType::Char16:
- case clang::BuiltinType::Char32:
- case clang::BuiltinType::UShort:
- case clang::BuiltinType::UInt:
- case clang::BuiltinType::ULong:
- case clang::BuiltinType::ULongLong:
- case clang::BuiltinType::UInt128:
- case clang::BuiltinType::Char_S:
- case clang::BuiltinType::SChar:
- case clang::BuiltinType::WChar_S:
- case clang::BuiltinType::Short:
- case clang::BuiltinType::Int:
- case clang::BuiltinType::Long:
- case clang::BuiltinType::LongLong:
- case clang::BuiltinType::Int128:
- case clang::BuiltinType::Float:
- case clang::BuiltinType::Double:
- case clang::BuiltinType::LongDouble:
- case clang::BuiltinType::Dependent:
- case clang::BuiltinType::Overload:
- case clang::BuiltinType::ObjCId:
- case clang::BuiltinType::ObjCClass:
- case clang::BuiltinType::ObjCSel:
- case clang::BuiltinType::BoundMember:
- case clang::BuiltinType::Half:
- case clang::BuiltinType::ARCUnbridgedCast:
- case clang::BuiltinType::PseudoObject:
- case clang::BuiltinType::BuiltinFn:
- return 1;
- }
- break;
-
- case clang::Type::Complex: return 1;
- case clang::Type::Pointer: return 1;
- case clang::Type::BlockPointer: return 0; // If block pointers don't have debug info, then no children for them
- case clang::Type::LValueReference: return 1;
- case clang::Type::RValueReference: return 1;
- case clang::Type::MemberPointer: return 0;
- case clang::Type::ConstantArray: return 0;
- case clang::Type::IncompleteArray: return 0;
- case clang::Type::VariableArray: return 0;
- case clang::Type::DependentSizedArray: return 0;
- case clang::Type::DependentSizedExtVector: return 0;
- case clang::Type::Vector: return 0;
- case clang::Type::ExtVector: return 0;
- case clang::Type::FunctionProto: return 0; // When we function pointers, they have no children...
- case clang::Type::FunctionNoProto: return 0; // When we function pointers, they have no children...
- case clang::Type::UnresolvedUsing: return 0;
- case clang::Type::Paren: return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetNumPointeeChildren ();
- case clang::Type::Typedef: return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumPointeeChildren ();
- case clang::Type::Elaborated: return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetNumPointeeChildren ();
- case clang::Type::TypeOfExpr: return 0;
- case clang::Type::TypeOf: return 0;
- case clang::Type::Decltype: return 0;
- case clang::Type::Record: return 0;
- case clang::Type::Enum: return 1;
- case clang::Type::TemplateTypeParm: return 1;
- case clang::Type::SubstTemplateTypeParm: return 1;
- case clang::Type::TemplateSpecialization: return 1;
- case clang::Type::InjectedClassName: return 0;
- case clang::Type::DependentName: return 1;
- case clang::Type::DependentTemplateSpecialization: return 1;
- case clang::Type::ObjCObject: return 0;
- case clang::Type::ObjCInterface: return 0;
- case clang::Type::ObjCObjectPointer: return 1;
- default:
- break;
- }
- return 0;
-}
-
-
-ClangASTType
-ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx,
- size_t idx,
- bool transparent_pointers,
- bool omit_empty_base_classes,
- bool ignore_array_bounds,
- std::string& child_name,
- uint32_t &child_byte_size,
- int32_t &child_byte_offset,
- uint32_t &child_bitfield_bit_size,
- uint32_t &child_bitfield_bit_offset,
- bool &child_is_base_class,
- bool &child_is_deref_of_parent,
- ValueObject *valobj) const
-{
- if (!IsValid())
- return ClangASTType();
-
- clang::QualType parent_qual_type(GetCanonicalQualType());
- const clang::Type::TypeClass parent_type_class = parent_qual_type->getTypeClass();
- child_bitfield_bit_size = 0;
- child_bitfield_bit_offset = 0;
- child_is_base_class = false;
-
- const bool idx_is_valid = idx < GetNumChildren (omit_empty_base_classes);
- uint32_t bit_offset;
- switch (parent_type_class)
- {
- case clang::Type::Builtin:
- if (idx_is_valid)
- {
- switch (llvm::cast<clang::BuiltinType>(parent_qual_type)->getKind())
- {
- case clang::BuiltinType::ObjCId:
- case clang::BuiltinType::ObjCClass:
- child_name = "isa";
- child_byte_size = m_ast->getTypeSize(m_ast->ObjCBuiltinClassTy) / CHAR_BIT;
- return ClangASTType (m_ast, m_ast->ObjCBuiltinClassTy);
-
- default:
- break;
- }
- }
- break;
-
- case clang::Type::Record:
- if (idx_is_valid && GetCompleteType())
- {
- const clang::RecordType *record_type = llvm::cast<clang::RecordType>(parent_qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
- assert(record_decl);
- const clang::ASTRecordLayout &record_layout = m_ast->getASTRecordLayout(record_decl);
- uint32_t child_idx = 0;
-
- const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
- if (cxx_record_decl)
- {
- // We might have base classes to print out first
- clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
- for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
- base_class != base_class_end;
- ++base_class)
- {
- const clang::CXXRecordDecl *base_class_decl = nullptr;
-
- // Skip empty base classes
- if (omit_empty_base_classes)
- {
- base_class_decl = llvm::cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl());
- if (ClangASTContext::RecordHasFields(base_class_decl) == false)
- continue;
- }
-
- if (idx == child_idx)
- {
- if (base_class_decl == nullptr)
- base_class_decl = llvm::cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl());
-
-
- if (base_class->isVirtual())
- {
- bool handled = false;
- if (valobj)
- {
- Error err;
- AddressType addr_type = eAddressTypeInvalid;
- lldb::addr_t vtable_ptr_addr = valobj->GetCPPVTableAddress(addr_type);
-
- if (vtable_ptr_addr != LLDB_INVALID_ADDRESS && addr_type == eAddressTypeLoad)
- {
-
- ExecutionContext exe_ctx (valobj->GetExecutionContextRef());
- Process *process = exe_ctx.GetProcessPtr();
- if (process)
- {
- clang::VTableContextBase *vtable_ctx = m_ast->getVTableContext();
- if (vtable_ctx)
- {
- if (vtable_ctx->isMicrosoft())
- {
- clang::MicrosoftVTableContext *msoft_vtable_ctx = static_cast<clang::MicrosoftVTableContext *>(vtable_ctx);
-
- if (vtable_ptr_addr)
- {
- const lldb::addr_t vbtable_ptr_addr = vtable_ptr_addr + record_layout.getVBPtrOffset().getQuantity();
-
- const lldb::addr_t vbtable_ptr = process->ReadPointerFromMemory(vbtable_ptr_addr, err);
- if (vbtable_ptr != LLDB_INVALID_ADDRESS)
- {
- // Get the index into the virtual base table. The index is the index in uint32_t from vbtable_ptr
- const unsigned vbtable_index = msoft_vtable_ctx->getVBTableIndex(cxx_record_decl, base_class_decl);
- const lldb::addr_t base_offset_addr = vbtable_ptr + vbtable_index * 4;
- const uint32_t base_offset = process->ReadUnsignedIntegerFromMemory(base_offset_addr, 4, UINT32_MAX, err);
- if (base_offset != UINT32_MAX)
- {
- handled = true;
- bit_offset = base_offset * 8;
- }
- }
- }
- }
- else
- {
- clang::ItaniumVTableContext *itanium_vtable_ctx = static_cast<clang::ItaniumVTableContext *>(vtable_ctx);
- if (vtable_ptr_addr)
- {
- const lldb::addr_t vtable_ptr = process->ReadPointerFromMemory(vtable_ptr_addr, err);
- if (vtable_ptr != LLDB_INVALID_ADDRESS)
- {
- clang::CharUnits base_offset_offset = itanium_vtable_ctx->getVirtualBaseOffsetOffset(cxx_record_decl, base_class_decl);
- const lldb::addr_t base_offset_addr = vtable_ptr + base_offset_offset.getQuantity();
- const uint32_t base_offset = process->ReadUnsignedIntegerFromMemory(base_offset_addr, 4, UINT32_MAX, err);
- if (base_offset != UINT32_MAX)
- {
- handled = true;
- bit_offset = base_offset * 8;
- }
- }
- }
- }
- }
- }
- }
-
- }
- if (!handled)
- bit_offset = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8;
- }
- else
- bit_offset = record_layout.getBaseClassOffset(base_class_decl).getQuantity() * 8;
-
- // Base classes should be a multiple of 8 bits in size
- child_byte_offset = bit_offset/8;
- ClangASTType base_class_clang_type(m_ast, base_class->getType());
- child_name = base_class_clang_type.GetTypeName().AsCString("");
- uint64_t base_class_clang_type_bit_size = base_class_clang_type.GetBitSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
-
- // Base classes bit sizes should be a multiple of 8 bits in size
- assert (base_class_clang_type_bit_size % 8 == 0);
- child_byte_size = base_class_clang_type_bit_size / 8;
- child_is_base_class = true;
- return base_class_clang_type;
- }
- // We don't increment the child index in the for loop since we might
- // be skipping empty base classes
- ++child_idx;
- }
- }
- // Make sure index is in range...
- uint32_t field_idx = 0;
- clang::RecordDecl::field_iterator field, field_end;
- for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++field_idx, ++child_idx)
- {
- if (idx == child_idx)
- {
- // Print the member type if requested
- // Print the member name and equal sign
- child_name.assign(field->getNameAsString().c_str());
-
- // Figure out the type byte size (field_type_info.first) and
- // alignment (field_type_info.second) from the AST context.
- ClangASTType field_clang_type (m_ast, field->getType());
- assert(field_idx < record_layout.getFieldCount());
- child_byte_size = field_clang_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
-
- // Figure out the field offset within the current struct/union/class type
- bit_offset = record_layout.getFieldOffset (field_idx);
- child_byte_offset = bit_offset / 8;
- if (ClangASTContext::FieldIsBitfield (m_ast, *field, child_bitfield_bit_size))
- child_bitfield_bit_offset = bit_offset % 8;
-
- return field_clang_type;
- }
- }
- }
- break;
-
- case clang::Type::ObjCObject:
- case clang::Type::ObjCInterface:
- if (idx_is_valid && GetCompleteType())
- {
- const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(parent_qual_type.getTypePtr());
- assert (objc_class_type);
- if (objc_class_type)
- {
- uint32_t child_idx = 0;
- clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
-
- if (class_interface_decl)
- {
-
- const clang::ASTRecordLayout &interface_layout = m_ast->getASTObjCInterfaceLayout(class_interface_decl);
- clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass();
- if (superclass_interface_decl)
- {
- if (omit_empty_base_classes)
- {
- ClangASTType base_class_clang_type (m_ast, m_ast->getObjCInterfaceType(superclass_interface_decl));
- if (base_class_clang_type.GetNumChildren(omit_empty_base_classes) > 0)
- {
- if (idx == 0)
- {
- clang::QualType ivar_qual_type(m_ast->getObjCInterfaceType(superclass_interface_decl));
-
-
- child_name.assign(superclass_interface_decl->getNameAsString().c_str());
-
- clang::TypeInfo ivar_type_info = m_ast->getTypeInfo(ivar_qual_type.getTypePtr());
-
- child_byte_size = ivar_type_info.Width / 8;
- child_byte_offset = 0;
- child_is_base_class = true;
-
- return ClangASTType (m_ast, ivar_qual_type);
- }
-
- ++child_idx;
- }
- }
- else
- ++child_idx;
- }
-
- const uint32_t superclass_idx = child_idx;
-
- if (idx < (child_idx + class_interface_decl->ivar_size()))
- {
- clang::ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end();
-
- for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end; ++ivar_pos)
- {
- if (child_idx == idx)
- {
- clang::ObjCIvarDecl* ivar_decl = *ivar_pos;
-
- clang::QualType ivar_qual_type(ivar_decl->getType());
-
- child_name.assign(ivar_decl->getNameAsString().c_str());
-
- clang::TypeInfo ivar_type_info = m_ast->getTypeInfo(ivar_qual_type.getTypePtr());
-
- child_byte_size = ivar_type_info.Width / 8;
-
- // Figure out the field offset within the current struct/union/class type
- // For ObjC objects, we can't trust the bit offset we get from the Clang AST, since
- // that doesn't account for the space taken up by unbacked properties, or from
- // the changing size of base classes that are newer than this class.
- // So if we have a process around that we can ask about this object, do so.
- child_byte_offset = LLDB_INVALID_IVAR_OFFSET;
- Process *process = nullptr;
- if (exe_ctx)
- process = exe_ctx->GetProcessPtr();
- if (process)
- {
- ObjCLanguageRuntime *objc_runtime = process->GetObjCLanguageRuntime();
- if (objc_runtime != nullptr)
- {
- ClangASTType parent_ast_type (m_ast, parent_qual_type);
- child_byte_offset = objc_runtime->GetByteOffsetForIvar (parent_ast_type, ivar_decl->getNameAsString().c_str());
- }
- }
-
- // Setting this to UINT32_MAX to make sure we don't compute it twice...
- bit_offset = UINT32_MAX;
-
- if (child_byte_offset == static_cast<int32_t>(LLDB_INVALID_IVAR_OFFSET))
- {
- bit_offset = interface_layout.getFieldOffset (child_idx - superclass_idx);
- child_byte_offset = bit_offset / 8;
- }
-
- // Note, the ObjC Ivar Byte offset is just that, it doesn't account for the bit offset
- // of a bitfield within its containing object. So regardless of where we get the byte
- // offset from, we still need to get the bit offset for bitfields from the layout.
-
- if (ClangASTContext::FieldIsBitfield (m_ast, ivar_decl, child_bitfield_bit_size))
- {
- if (bit_offset == UINT32_MAX)
- bit_offset = interface_layout.getFieldOffset (child_idx - superclass_idx);
-
- child_bitfield_bit_offset = bit_offset % 8;
- }
- return ClangASTType (m_ast, ivar_qual_type);
- }
- ++child_idx;
- }
- }
- }
- }
- }
- break;
-
- case clang::Type::ObjCObjectPointer:
- if (idx_is_valid)
- {
- ClangASTType pointee_clang_type (GetPointeeType());
-
- if (transparent_pointers && pointee_clang_type.IsAggregateType())
- {
- child_is_deref_of_parent = false;
- bool tmp_child_is_deref_of_parent = false;
- return pointee_clang_type.GetChildClangTypeAtIndex (exe_ctx,
- idx,
- transparent_pointers,
- omit_empty_base_classes,
- ignore_array_bounds,
- child_name,
- child_byte_size,
- child_byte_offset,
- child_bitfield_bit_size,
- child_bitfield_bit_offset,
- child_is_base_class,
- tmp_child_is_deref_of_parent,
- valobj);
- }
- else
- {
- child_is_deref_of_parent = true;
- const char *parent_name = valobj ? valobj->GetName().GetCString() : NULL;
- if (parent_name)
- {
- child_name.assign(1, '*');
- child_name += parent_name;
- }
-
- // We have a pointer to an simple type
- if (idx == 0 && pointee_clang_type.GetCompleteType())
- {
- child_byte_size = pointee_clang_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
- child_byte_offset = 0;
- return pointee_clang_type;
- }
- }
- }
- break;
-
- case clang::Type::Vector:
- case clang::Type::ExtVector:
- if (idx_is_valid)
- {
- const clang::VectorType *array = llvm::cast<clang::VectorType>(parent_qual_type.getTypePtr());
- if (array)
- {
- ClangASTType element_type (m_ast, array->getElementType());
- if (element_type.GetCompleteType())
- {
- char element_name[64];
- ::snprintf(element_name, sizeof(element_name), "[%" PRIu64 "]", static_cast<uint64_t>(idx));
- child_name.assign(element_name);
- child_byte_size = element_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
- child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
- return element_type;
- }
- }
- }
- break;
-
- case clang::Type::ConstantArray:
- case clang::Type::IncompleteArray:
- if (ignore_array_bounds || idx_is_valid)
- {
- const clang::ArrayType *array = GetQualType()->getAsArrayTypeUnsafe();
- if (array)
- {
- ClangASTType element_type (m_ast, array->getElementType());
- if (element_type.GetCompleteType())
- {
- char element_name[64];
- ::snprintf(element_name, sizeof(element_name), "[%" PRIu64 "]", static_cast<uint64_t>(idx));
- child_name.assign(element_name);
- child_byte_size = element_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
- child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
- return element_type;
- }
- }
- }
- break;
-
-
- case clang::Type::Pointer:
- if (idx_is_valid)
- {
- ClangASTType pointee_clang_type (GetPointeeType());
-
- // Don't dereference "void *" pointers
- if (pointee_clang_type.IsVoidType())
- return ClangASTType();
-
- if (transparent_pointers && pointee_clang_type.IsAggregateType ())
- {
- child_is_deref_of_parent = false;
- bool tmp_child_is_deref_of_parent = false;
- return pointee_clang_type.GetChildClangTypeAtIndex (exe_ctx,
- idx,
- transparent_pointers,
- omit_empty_base_classes,
- ignore_array_bounds,
- child_name,
- child_byte_size,
- child_byte_offset,
- child_bitfield_bit_size,
- child_bitfield_bit_offset,
- child_is_base_class,
- tmp_child_is_deref_of_parent,
- valobj);
- }
- else
- {
- child_is_deref_of_parent = true;
-
- const char *parent_name = valobj ? valobj->GetName().GetCString() : NULL;
- if (parent_name)
- {
- child_name.assign(1, '*');
- child_name += parent_name;
- }
-
- // We have a pointer to an simple type
- if (idx == 0)
- {
- child_byte_size = pointee_clang_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
- child_byte_offset = 0;
- return pointee_clang_type;
- }
- }
- }
- break;
-
- case clang::Type::LValueReference:
- case clang::Type::RValueReference:
- if (idx_is_valid)
- {
- const clang::ReferenceType *reference_type = llvm::cast<clang::ReferenceType>(parent_qual_type.getTypePtr());
- ClangASTType pointee_clang_type (m_ast, reference_type->getPointeeType());
- if (transparent_pointers && pointee_clang_type.IsAggregateType ())
- {
- child_is_deref_of_parent = false;
- bool tmp_child_is_deref_of_parent = false;
- return pointee_clang_type.GetChildClangTypeAtIndex (exe_ctx,
- idx,
- transparent_pointers,
- omit_empty_base_classes,
- ignore_array_bounds,
- child_name,
- child_byte_size,
- child_byte_offset,
- child_bitfield_bit_size,
- child_bitfield_bit_offset,
- child_is_base_class,
- tmp_child_is_deref_of_parent,
- valobj);
- }
- else
- {
- const char *parent_name = valobj ? valobj->GetName().GetCString() : NULL;
- if (parent_name)
- {
- child_name.assign(1, '&');
- child_name += parent_name;
- }
-
- // We have a pointer to an simple type
- if (idx == 0)
- {
- child_byte_size = pointee_clang_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
- child_byte_offset = 0;
- return pointee_clang_type;
- }
- }
- }
- break;
-
- case clang::Type::Typedef:
- {
- ClangASTType typedefed_clang_type (m_ast, llvm::cast<clang::TypedefType>(parent_qual_type)->getDecl()->getUnderlyingType());
- return typedefed_clang_type.GetChildClangTypeAtIndex (exe_ctx,
- idx,
- transparent_pointers,
- omit_empty_base_classes,
- ignore_array_bounds,
- child_name,
- child_byte_size,
- child_byte_offset,
- child_bitfield_bit_size,
- child_bitfield_bit_offset,
- child_is_base_class,
- child_is_deref_of_parent,
- valobj);
- }
- break;
-
- case clang::Type::Elaborated:
- {
- ClangASTType elaborated_clang_type (m_ast, llvm::cast<clang::ElaboratedType>(parent_qual_type)->getNamedType());
- return elaborated_clang_type.GetChildClangTypeAtIndex (exe_ctx,
- idx,
- transparent_pointers,
- omit_empty_base_classes,
- ignore_array_bounds,
- child_name,
- child_byte_size,
- child_byte_offset,
- child_bitfield_bit_size,
- child_bitfield_bit_offset,
- child_is_base_class,
- child_is_deref_of_parent,
- valobj);
- }
-
- case clang::Type::Paren:
- {
- ClangASTType paren_clang_type (m_ast, llvm::cast<clang::ParenType>(parent_qual_type)->desugar());
- return paren_clang_type.GetChildClangTypeAtIndex (exe_ctx,
- idx,
- transparent_pointers,
- omit_empty_base_classes,
- ignore_array_bounds,
- child_name,
- child_byte_size,
- child_byte_offset,
- child_bitfield_bit_size,
- child_bitfield_bit_offset,
- child_is_base_class,
- child_is_deref_of_parent,
- valobj);
- }
-
-
- default:
- break;
- }
- return ClangASTType();
-}
-
-static inline bool
-BaseSpecifierIsEmpty (const clang::CXXBaseSpecifier *b)
-{
- return ClangASTContext::RecordHasFields(b->getType()->getAsCXXRecordDecl()) == false;
-}
-
-static uint32_t
-GetIndexForRecordBase
-(
- const clang::RecordDecl *record_decl,
- const clang::CXXBaseSpecifier *base_spec,
- bool omit_empty_base_classes
- )
-{
- uint32_t child_idx = 0;
-
- const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
-
- // const char *super_name = record_decl->getNameAsCString();
- // const char *base_name = base_spec->getType()->getAs<clang::RecordType>()->getDecl()->getNameAsCString();
- // printf ("GetIndexForRecordChild (%s, %s)\n", super_name, base_name);
- //
- if (cxx_record_decl)
- {
- clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
- for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
- base_class != base_class_end;
- ++base_class)
- {
- if (omit_empty_base_classes)
- {
- if (BaseSpecifierIsEmpty (base_class))
- continue;
- }
-
- // printf ("GetIndexForRecordChild (%s, %s) base[%u] = %s\n", super_name, base_name,
- // child_idx,
- // base_class->getType()->getAs<clang::RecordType>()->getDecl()->getNameAsCString());
- //
- //
- if (base_class == base_spec)
- return child_idx;
- ++child_idx;
- }
- }
-
- return UINT32_MAX;
-}
-
-
-static uint32_t
-GetIndexForRecordChild (const clang::RecordDecl *record_decl,
- clang::NamedDecl *canonical_decl,
- bool omit_empty_base_classes)
-{
- uint32_t child_idx = ClangASTContext::GetNumBaseClasses (llvm::dyn_cast<clang::CXXRecordDecl>(record_decl),
- omit_empty_base_classes);
-
- clang::RecordDecl::field_iterator field, field_end;
- for (field = record_decl->field_begin(), field_end = record_decl->field_end();
- field != field_end;
- ++field, ++child_idx)
- {
- if (field->getCanonicalDecl() == canonical_decl)
- return child_idx;
- }
-
- return UINT32_MAX;
-}
-
-// Look for a child member (doesn't include base classes, but it does include
-// their members) in the type hierarchy. Returns an index path into "clang_type"
-// on how to reach the appropriate member.
-//
-// class A
-// {
-// public:
-// int m_a;
-// int m_b;
-// };
-//
-// class B
-// {
-// };
-//
-// class C :
-// public B,
-// public A
-// {
-// };
-//
-// If we have a clang type that describes "class C", and we wanted to looked
-// "m_b" in it:
-//
-// With omit_empty_base_classes == false we would get an integer array back with:
-// { 1, 1 }
-// The first index 1 is the child index for "class A" within class C
-// The second index 1 is the child index for "m_b" within class A
-//
-// With omit_empty_base_classes == true we would get an integer array back with:
-// { 0, 1 }
-// The first index 0 is the child index for "class A" within class C (since class B doesn't have any members it doesn't count)
-// The second index 1 is the child index for "m_b" within class A
-
-size_t
-ClangASTType::GetIndexOfChildMemberWithName (const char *name,
- bool omit_empty_base_classes,
- std::vector<uint32_t>& child_indexes) const
-{
- if (IsValid() && name && name[0])
- {
- clang::QualType qual_type(GetCanonicalQualType());
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::Record:
- if (GetCompleteType ())
- {
- const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
-
- assert(record_decl);
- uint32_t child_idx = 0;
-
- const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
-
- // Try and find a field that matches NAME
- clang::RecordDecl::field_iterator field, field_end;
- llvm::StringRef name_sref(name);
- for (field = record_decl->field_begin(), field_end = record_decl->field_end();
- field != field_end;
- ++field, ++child_idx)
- {
- llvm::StringRef field_name = field->getName();
- if (field_name.empty())
- {
- ClangASTType field_type(m_ast,field->getType());
- child_indexes.push_back(child_idx);
- if (field_type.GetIndexOfChildMemberWithName(name, omit_empty_base_classes, child_indexes))
- return child_indexes.size();
- child_indexes.pop_back();
-
- }
- else if (field_name.equals (name_sref))
- {
- // We have to add on the number of base classes to this index!
- child_indexes.push_back (child_idx + ClangASTContext::GetNumBaseClasses (cxx_record_decl, omit_empty_base_classes));
- return child_indexes.size();
- }
- }
-
- if (cxx_record_decl)
- {
- const clang::RecordDecl *parent_record_decl = cxx_record_decl;
-
- //printf ("parent = %s\n", parent_record_decl->getNameAsCString());
-
- //const Decl *root_cdecl = cxx_record_decl->getCanonicalDecl();
- // Didn't find things easily, lets let clang do its thang...
- clang::IdentifierInfo & ident_ref = m_ast->Idents.get(name_sref);
- clang::DeclarationName decl_name(&ident_ref);
-
- clang::CXXBasePaths paths;
- if (cxx_record_decl->lookupInBases(clang::CXXRecordDecl::FindOrdinaryMember,
- decl_name.getAsOpaquePtr(),
- paths))
- {
- clang::CXXBasePaths::const_paths_iterator path, path_end = paths.end();
- for (path = paths.begin(); path != path_end; ++path)
- {
- const size_t num_path_elements = path->size();
- for (size_t e=0; e<num_path_elements; ++e)
- {
- clang::CXXBasePathElement elem = (*path)[e];
-
- child_idx = GetIndexForRecordBase (parent_record_decl, elem.Base, omit_empty_base_classes);
- if (child_idx == UINT32_MAX)
- {
- child_indexes.clear();
- return 0;
- }
- else
- {
- child_indexes.push_back (child_idx);
- parent_record_decl = llvm::cast<clang::RecordDecl>(elem.Base->getType()->getAs<clang::RecordType>()->getDecl());
- }
- }
- for (clang::NamedDecl *path_decl : path->Decls)
- {
- child_idx = GetIndexForRecordChild (parent_record_decl, path_decl, omit_empty_base_classes);
- if (child_idx == UINT32_MAX)
- {
- child_indexes.clear();
- return 0;
- }
- else
- {
- child_indexes.push_back (child_idx);
- }
- }
- }
- return child_indexes.size();
- }
- }
-
- }
- break;
-
- case clang::Type::ObjCObject:
- case clang::Type::ObjCInterface:
- if (GetCompleteType ())
- {
- llvm::StringRef name_sref(name);
- const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
- assert (objc_class_type);
- if (objc_class_type)
- {
- uint32_t child_idx = 0;
- clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
-
- if (class_interface_decl)
- {
- clang::ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end();
- clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass();
-
- for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end; ++ivar_pos, ++child_idx)
- {
- const clang::ObjCIvarDecl* ivar_decl = *ivar_pos;
-
- if (ivar_decl->getName().equals (name_sref))
- {
- if ((!omit_empty_base_classes && superclass_interface_decl) ||
- ( omit_empty_base_classes && ObjCDeclHasIVars (superclass_interface_decl, true)))
- ++child_idx;
-
- child_indexes.push_back (child_idx);
- return child_indexes.size();
- }
- }
-
- if (superclass_interface_decl)
- {
- // The super class index is always zero for ObjC classes,
- // so we push it onto the child indexes in case we find
- // an ivar in our superclass...
- child_indexes.push_back (0);
-
- ClangASTType superclass_clang_type (m_ast, m_ast->getObjCInterfaceType(superclass_interface_decl));
- if (superclass_clang_type.GetIndexOfChildMemberWithName (name,
- omit_empty_base_classes,
- child_indexes))
- {
- // We did find an ivar in a superclass so just
- // return the results!
- return child_indexes.size();
- }
-
- // We didn't find an ivar matching "name" in our
- // superclass, pop the superclass zero index that
- // we pushed on above.
- child_indexes.pop_back();
- }
- }
- }
- }
- break;
-
- case clang::Type::ObjCObjectPointer:
- {
- ClangASTType objc_object_clang_type (m_ast, llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())->getPointeeType());
- return objc_object_clang_type.GetIndexOfChildMemberWithName (name,
- omit_empty_base_classes,
- child_indexes);
- }
- break;
-
-
- case clang::Type::ConstantArray:
- {
- // const clang::ConstantArrayType *array = llvm::cast<clang::ConstantArrayType>(parent_qual_type.getTypePtr());
- // const uint64_t element_count = array->getSize().getLimitedValue();
- //
- // if (idx < element_count)
- // {
- // std::pair<uint64_t, unsigned> field_type_info = ast->getTypeInfo(array->getElementType());
- //
- // char element_name[32];
- // ::snprintf (element_name, sizeof (element_name), "%s[%u]", parent_name ? parent_name : "", idx);
- //
- // child_name.assign(element_name);
- // assert(field_type_info.first % 8 == 0);
- // child_byte_size = field_type_info.first / 8;
- // child_byte_offset = idx * child_byte_size;
- // return array->getElementType().getAsOpaquePtr();
- // }
- }
- break;
-
- // case clang::Type::MemberPointerType:
- // {
- // MemberPointerType *mem_ptr_type = llvm::cast<MemberPointerType>(qual_type.getTypePtr());
- // clang::QualType pointee_type = mem_ptr_type->getPointeeType();
- //
- // if (ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr()))
- // {
- // return GetIndexOfChildWithName (ast,
- // mem_ptr_type->getPointeeType().getAsOpaquePtr(),
- // name);
- // }
- // }
- // break;
- //
- case clang::Type::LValueReference:
- case clang::Type::RValueReference:
- {
- const clang::ReferenceType *reference_type = llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
- clang::QualType pointee_type(reference_type->getPointeeType());
- ClangASTType pointee_clang_type (m_ast, pointee_type);
-
- if (pointee_clang_type.IsAggregateType ())
- {
- return pointee_clang_type.GetIndexOfChildMemberWithName (name,
- omit_empty_base_classes,
- child_indexes);
- }
- }
- break;
-
- case clang::Type::Pointer:
- {
- ClangASTType pointee_clang_type (GetPointeeType());
-
- if (pointee_clang_type.IsAggregateType ())
- {
- return pointee_clang_type.GetIndexOfChildMemberWithName (name,
- omit_empty_base_classes,
- child_indexes);
- }
- }
- break;
-
- case clang::Type::Typedef:
- return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetIndexOfChildMemberWithName (name,
- omit_empty_base_classes,
- child_indexes);
-
- case clang::Type::Elaborated:
- return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetIndexOfChildMemberWithName (name,
- omit_empty_base_classes,
- child_indexes);
-
- case clang::Type::Paren:
- return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetIndexOfChildMemberWithName (name,
- omit_empty_base_classes,
- child_indexes);
-
- default:
- break;
- }
- }
- return 0;
-}
-
-
-// Get the index of the child of "clang_type" whose name matches. This function
-// doesn't descend into the children, but only looks one level deep and name
-// matches can include base class names.
-
-uint32_t
-ClangASTType::GetIndexOfChildWithName (const char *name, bool omit_empty_base_classes) const
-{
- if (IsValid() && name && name[0])
- {
- clang::QualType qual_type(GetCanonicalQualType());
-
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
-
- switch (type_class)
- {
- case clang::Type::Record:
- if (GetCompleteType ())
- {
- const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
-
- assert(record_decl);
- uint32_t child_idx = 0;
-
- const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
-
- if (cxx_record_decl)
- {
- clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
- for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
- base_class != base_class_end;
- ++base_class)
- {
- // Skip empty base classes
- clang::CXXRecordDecl *base_class_decl = llvm::cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl());
- if (omit_empty_base_classes && ClangASTContext::RecordHasFields(base_class_decl) == false)
- continue;
-
- ClangASTType base_class_clang_type (m_ast, base_class->getType());
- std::string base_class_type_name (base_class_clang_type.GetTypeName().AsCString(""));
- if (base_class_type_name.compare (name) == 0)
- return child_idx;
- ++child_idx;
- }
- }
-
- // Try and find a field that matches NAME
- clang::RecordDecl::field_iterator field, field_end;
- llvm::StringRef name_sref(name);
- for (field = record_decl->field_begin(), field_end = record_decl->field_end();
- field != field_end;
- ++field, ++child_idx)
- {
- if (field->getName().equals (name_sref))
- return child_idx;
- }
-
- }
- break;
-
- case clang::Type::ObjCObject:
- case clang::Type::ObjCInterface:
- if (GetCompleteType())
- {
- llvm::StringRef name_sref(name);
- const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
- assert (objc_class_type);
- if (objc_class_type)
- {
- uint32_t child_idx = 0;
- clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
-
- if (class_interface_decl)
- {
- clang::ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end();
- clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass();
-
- for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end; ++ivar_pos, ++child_idx)
- {
- const clang::ObjCIvarDecl* ivar_decl = *ivar_pos;
-
- if (ivar_decl->getName().equals (name_sref))
- {
- if ((!omit_empty_base_classes && superclass_interface_decl) ||
- ( omit_empty_base_classes && ObjCDeclHasIVars (superclass_interface_decl, true)))
- ++child_idx;
-
- return child_idx;
- }
- }
-
- if (superclass_interface_decl)
- {
- if (superclass_interface_decl->getName().equals (name_sref))
- return 0;
- }
- }
- }
- }
- break;
-
- case clang::Type::ObjCObjectPointer:
- {
- ClangASTType pointee_clang_type (m_ast, llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())->getPointeeType());
- return pointee_clang_type.GetIndexOfChildWithName (name, omit_empty_base_classes);
- }
- break;
-
- case clang::Type::ConstantArray:
- {
- // const clang::ConstantArrayType *array = llvm::cast<clang::ConstantArrayType>(parent_qual_type.getTypePtr());
- // const uint64_t element_count = array->getSize().getLimitedValue();
- //
- // if (idx < element_count)
- // {
- // std::pair<uint64_t, unsigned> field_type_info = ast->getTypeInfo(array->getElementType());
- //
- // char element_name[32];
- // ::snprintf (element_name, sizeof (element_name), "%s[%u]", parent_name ? parent_name : "", idx);
- //
- // child_name.assign(element_name);
- // assert(field_type_info.first % 8 == 0);
- // child_byte_size = field_type_info.first / 8;
- // child_byte_offset = idx * child_byte_size;
- // return array->getElementType().getAsOpaquePtr();
- // }
- }
- break;
-
- // case clang::Type::MemberPointerType:
- // {
- // MemberPointerType *mem_ptr_type = llvm::cast<MemberPointerType>(qual_type.getTypePtr());
- // clang::QualType pointee_type = mem_ptr_type->getPointeeType();
- //
- // if (ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr()))
- // {
- // return GetIndexOfChildWithName (ast,
- // mem_ptr_type->getPointeeType().getAsOpaquePtr(),
- // name);
- // }
- // }
- // break;
- //
- case clang::Type::LValueReference:
- case clang::Type::RValueReference:
- {
- const clang::ReferenceType *reference_type = llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
- ClangASTType pointee_type (m_ast, reference_type->getPointeeType());
-
- if (pointee_type.IsAggregateType ())
- {
- return pointee_type.GetIndexOfChildWithName (name, omit_empty_base_classes);
- }
- }
- break;
-
- case clang::Type::Pointer:
- {
- const clang::PointerType *pointer_type = llvm::cast<clang::PointerType>(qual_type.getTypePtr());
- ClangASTType pointee_type (m_ast, pointer_type->getPointeeType());
-
- if (pointee_type.IsAggregateType ())
- {
- return pointee_type.GetIndexOfChildWithName (name, omit_empty_base_classes);
- }
- else
- {
- // if (parent_name)
- // {
- // child_name.assign(1, '*');
- // child_name += parent_name;
- // }
- //
- // // We have a pointer to an simple type
- // if (idx == 0)
- // {
- // std::pair<uint64_t, unsigned> clang_type_info = ast->getTypeInfo(pointee_type);
- // assert(clang_type_info.first % 8 == 0);
- // child_byte_size = clang_type_info.first / 8;
- // child_byte_offset = 0;
- // return pointee_type.getAsOpaquePtr();
- // }
- }
- }
- break;
-
- case clang::Type::Elaborated:
- return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetIndexOfChildWithName (name, omit_empty_base_classes);
-
- case clang::Type::Paren:
- return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetIndexOfChildWithName (name, omit_empty_base_classes);
-
- case clang::Type::Typedef:
- return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetIndexOfChildWithName (name, omit_empty_base_classes);
-
- default:
- break;
- }
- }
- return UINT32_MAX;
-}
-
-
-size_t
-ClangASTType::GetNumTemplateArguments () const
-{
- if (IsValid())
- {
- clang::QualType qual_type (GetCanonicalQualType());
-
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::Record:
- if (GetCompleteType ())
- {
- const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
- if (cxx_record_decl)
- {
- const clang::ClassTemplateSpecializationDecl *template_decl = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(cxx_record_decl);
- if (template_decl)
- return template_decl->getTemplateArgs().size();
- }
- }
- break;
-
- case clang::Type::Typedef:
- return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetNumTemplateArguments();
-
- case clang::Type::Elaborated:
- return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetNumTemplateArguments();
-
- case clang::Type::Paren:
- return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetNumTemplateArguments();
-
- default:
- break;
- }
- }
- return 0;
-}
-
-ClangASTType
-ClangASTType::GetTemplateArgument (size_t arg_idx, lldb::TemplateArgumentKind &kind) const
-{
- if (IsValid())
- {
- clang::QualType qual_type (GetCanonicalQualType());
-
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::Record:
- if (GetCompleteType ())
- {
- const clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
- if (cxx_record_decl)
- {
- const clang::ClassTemplateSpecializationDecl *template_decl = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(cxx_record_decl);
- if (template_decl && arg_idx < template_decl->getTemplateArgs().size())
- {
- const clang::TemplateArgument &template_arg = template_decl->getTemplateArgs()[arg_idx];
- switch (template_arg.getKind())
- {
- case clang::TemplateArgument::Null:
- kind = eTemplateArgumentKindNull;
- return ClangASTType();
-
- case clang::TemplateArgument::Type:
- kind = eTemplateArgumentKindType;
- return ClangASTType(m_ast, template_arg.getAsType());
-
- case clang::TemplateArgument::Declaration:
- kind = eTemplateArgumentKindDeclaration;
- return ClangASTType();
-
- case clang::TemplateArgument::Integral:
- kind = eTemplateArgumentKindIntegral;
- return ClangASTType(m_ast, template_arg.getIntegralType());
-
- case clang::TemplateArgument::Template:
- kind = eTemplateArgumentKindTemplate;
- return ClangASTType();
-
- case clang::TemplateArgument::TemplateExpansion:
- kind = eTemplateArgumentKindTemplateExpansion;
- return ClangASTType();
-
- case clang::TemplateArgument::Expression:
- kind = eTemplateArgumentKindExpression;
- return ClangASTType();
-
- case clang::TemplateArgument::Pack:
- kind = eTemplateArgumentKindPack;
- return ClangASTType();
-
- default:
- assert (!"Unhandled clang::TemplateArgument::ArgKind");
- break;
- }
- }
- }
- }
- break;
-
- case clang::Type::Typedef:
- return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetTemplateArgument (arg_idx, kind);
-
- case clang::Type::Elaborated:
- return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetTemplateArgument (arg_idx, kind);
-
- case clang::Type::Paren:
- return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetTemplateArgument (arg_idx, kind);
-
- default:
- break;
- }
- }
- kind = eTemplateArgumentKindNull;
- return ClangASTType ();
-}
-
-static bool
-IsOperator (const char *name, clang::OverloadedOperatorKind &op_kind)
-{
- if (name == nullptr || name[0] == '\0')
- return false;
-
-#define OPERATOR_PREFIX "operator"
-#define OPERATOR_PREFIX_LENGTH (sizeof (OPERATOR_PREFIX) - 1)
-
- const char *post_op_name = nullptr;
-
- bool no_space = true;
-
- if (::strncmp(name, OPERATOR_PREFIX, OPERATOR_PREFIX_LENGTH))
- return false;
-
- post_op_name = name + OPERATOR_PREFIX_LENGTH;
-
- if (post_op_name[0] == ' ')
- {
- post_op_name++;
- no_space = false;
- }
-
-#undef OPERATOR_PREFIX
-#undef OPERATOR_PREFIX_LENGTH
-
- // This is an operator, set the overloaded operator kind to invalid
- // in case this is a conversion operator...
- op_kind = clang::NUM_OVERLOADED_OPERATORS;
-
- switch (post_op_name[0])
- {
- default:
- if (no_space)
- return false;
- break;
- case 'n':
- if (no_space)
- return false;
- if (strcmp (post_op_name, "new") == 0)
- op_kind = clang::OO_New;
- else if (strcmp (post_op_name, "new[]") == 0)
- op_kind = clang::OO_Array_New;
- break;
-
- case 'd':
- if (no_space)
- return false;
- if (strcmp (post_op_name, "delete") == 0)
- op_kind = clang::OO_Delete;
- else if (strcmp (post_op_name, "delete[]") == 0)
- op_kind = clang::OO_Array_Delete;
- break;
-
- case '+':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Plus;
- else if (post_op_name[2] == '\0')
- {
- if (post_op_name[1] == '=')
- op_kind = clang::OO_PlusEqual;
- else if (post_op_name[1] == '+')
- op_kind = clang::OO_PlusPlus;
- }
- break;
-
- case '-':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Minus;
- else if (post_op_name[2] == '\0')
- {
- switch (post_op_name[1])
- {
- case '=': op_kind = clang::OO_MinusEqual; break;
- case '-': op_kind = clang::OO_MinusMinus; break;
- case '>': op_kind = clang::OO_Arrow; break;
- }
- }
- else if (post_op_name[3] == '\0')
- {
- if (post_op_name[2] == '*')
- op_kind = clang::OO_ArrowStar; break;
- }
- break;
-
- case '*':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Star;
- else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
- op_kind = clang::OO_StarEqual;
- break;
-
- case '/':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Slash;
- else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
- op_kind = clang::OO_SlashEqual;
- break;
-
- case '%':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Percent;
- else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
- op_kind = clang::OO_PercentEqual;
- break;
-
-
- case '^':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Caret;
- else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
- op_kind = clang::OO_CaretEqual;
- break;
-
- case '&':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Amp;
- else if (post_op_name[2] == '\0')
- {
- switch (post_op_name[1])
- {
- case '=': op_kind = clang::OO_AmpEqual; break;
- case '&': op_kind = clang::OO_AmpAmp; break;
- }
- }
- break;
-
- case '|':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Pipe;
- else if (post_op_name[2] == '\0')
- {
- switch (post_op_name[1])
- {
- case '=': op_kind = clang::OO_PipeEqual; break;
- case '|': op_kind = clang::OO_PipePipe; break;
- }
- }
- break;
-
- case '~':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Tilde;
- break;
-
- case '!':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Exclaim;
- else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
- op_kind = clang::OO_ExclaimEqual;
- break;
-
- case '=':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Equal;
- else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
- op_kind = clang::OO_EqualEqual;
- break;
-
- case '<':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Less;
- else if (post_op_name[2] == '\0')
- {
- switch (post_op_name[1])
- {
- case '<': op_kind = clang::OO_LessLess; break;
- case '=': op_kind = clang::OO_LessEqual; break;
- }
- }
- else if (post_op_name[3] == '\0')
- {
- if (post_op_name[2] == '=')
- op_kind = clang::OO_LessLessEqual;
- }
- break;
-
- case '>':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Greater;
- else if (post_op_name[2] == '\0')
- {
- switch (post_op_name[1])
- {
- case '>': op_kind = clang::OO_GreaterGreater; break;
- case '=': op_kind = clang::OO_GreaterEqual; break;
- }
- }
- else if (post_op_name[1] == '>' &&
- post_op_name[2] == '=' &&
- post_op_name[3] == '\0')
- {
- op_kind = clang::OO_GreaterGreaterEqual;
- }
- break;
-
- case ',':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Comma;
- break;
-
- case '(':
- if (post_op_name[1] == ')' && post_op_name[2] == '\0')
- op_kind = clang::OO_Call;
- break;
-
- case '[':
- if (post_op_name[1] == ']' && post_op_name[2] == '\0')
- op_kind = clang::OO_Subscript;
- break;
- }
-
- return true;
-}
-
-clang::EnumDecl *
-ClangASTType::GetAsEnumDecl () const
-{
- const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(GetCanonicalQualType());
- if (enum_type)
- return enum_type->getDecl();
- return NULL;
-}
-
-clang::RecordDecl *
-ClangASTType::GetAsRecordDecl () const
-{
- const clang::RecordType *record_type = llvm::dyn_cast<clang::RecordType>(GetCanonicalQualType());
- if (record_type)
- return record_type->getDecl();
- return nullptr;
-}
-
-clang::CXXRecordDecl *
-ClangASTType::GetAsCXXRecordDecl () const
-{
- return GetCanonicalQualType()->getAsCXXRecordDecl();
-}
-
-clang::ObjCInterfaceDecl *
-ClangASTType::GetAsObjCInterfaceDecl () const
-{
- const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(GetCanonicalQualType());
- if (objc_class_type)
- return objc_class_type->getInterface();
- return nullptr;
-}
-
-clang::FieldDecl *
-ClangASTType::AddFieldToRecordType (const char *name,
- const ClangASTType &field_clang_type,
- AccessType access,
- uint32_t bitfield_bit_size)
-{
- if (!IsValid() || !field_clang_type.IsValid())
- return nullptr;
-
- clang::FieldDecl *field = nullptr;
-
- clang::Expr *bit_width = nullptr;
- if (bitfield_bit_size != 0)
- {
- llvm::APInt bitfield_bit_size_apint(m_ast->getTypeSize(m_ast->IntTy), bitfield_bit_size);
- bit_width = new (*m_ast)clang::IntegerLiteral (*m_ast, bitfield_bit_size_apint, m_ast->IntTy, clang::SourceLocation());
- }
-
- clang::RecordDecl *record_decl = GetAsRecordDecl ();
- if (record_decl)
- {
- field = clang::FieldDecl::Create (*m_ast,
- record_decl,
- clang::SourceLocation(),
- clang::SourceLocation(),
- name ? &m_ast->Idents.get(name) : nullptr, // Identifier
- field_clang_type.GetQualType(), // Field type
- nullptr, // TInfo *
- bit_width, // BitWidth
- false, // Mutable
- clang::ICIS_NoInit); // HasInit
-
- if (!name)
- {
- // Determine whether this field corresponds to an anonymous
- // struct or union.
- if (const clang::TagType *TagT = field->getType()->getAs<clang::TagType>()) {
- if (clang::RecordDecl *Rec = llvm::dyn_cast<clang::RecordDecl>(TagT->getDecl()))
- if (!Rec->getDeclName()) {
- Rec->setAnonymousStructOrUnion(true);
- field->setImplicit();
-
- }
- }
- }
-
- if (field)
- {
- field->setAccess (ClangASTContext::ConvertAccessTypeToAccessSpecifier (access));
-
- record_decl->addDecl(field);
-
-#ifdef LLDB_CONFIGURATION_DEBUG
- VerifyDecl(field);
-#endif
- }
- }
- else
- {
- clang::ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl ();
-
- if (class_interface_decl)
- {
- const bool is_synthesized = false;
-
- field_clang_type.GetCompleteType();
-
- field = clang::ObjCIvarDecl::Create (*m_ast,
- class_interface_decl,
- clang::SourceLocation(),
- clang::SourceLocation(),
- name ? &m_ast->Idents.get(name) : nullptr, // Identifier
- field_clang_type.GetQualType(), // Field type
- nullptr, // TypeSourceInfo *
- ConvertAccessTypeToObjCIvarAccessControl (access),
- bit_width,
- is_synthesized);
-
- if (field)
- {
- class_interface_decl->addDecl(field);
-
-#ifdef LLDB_CONFIGURATION_DEBUG
- VerifyDecl(field);
-#endif
- }
- }
- }
- return field;
-}
-
-void
-ClangASTType::BuildIndirectFields ()
-{
- clang::RecordDecl *record_decl = GetAsRecordDecl();
-
- if (!record_decl)
- return;
-
- typedef llvm::SmallVector <clang::IndirectFieldDecl *, 1> IndirectFieldVector;
-
- IndirectFieldVector indirect_fields;
- clang::RecordDecl::field_iterator field_pos;
- clang::RecordDecl::field_iterator field_end_pos = record_decl->field_end();
- clang::RecordDecl::field_iterator last_field_pos = field_end_pos;
- for (field_pos = record_decl->field_begin(); field_pos != field_end_pos; last_field_pos = field_pos++)
- {
- if (field_pos->isAnonymousStructOrUnion())
- {
- clang::QualType field_qual_type = field_pos->getType();
-
- const clang::RecordType *field_record_type = field_qual_type->getAs<clang::RecordType>();
-
- if (!field_record_type)
- continue;
-
- clang::RecordDecl *field_record_decl = field_record_type->getDecl();
-
- if (!field_record_decl)
- continue;
-
- for (clang::RecordDecl::decl_iterator di = field_record_decl->decls_begin(), de = field_record_decl->decls_end();
- di != de;
- ++di)
- {
- if (clang::FieldDecl *nested_field_decl = llvm::dyn_cast<clang::FieldDecl>(*di))
- {
- clang::NamedDecl **chain = new (*m_ast) clang::NamedDecl*[2];
- chain[0] = *field_pos;
- chain[1] = nested_field_decl;
- clang::IndirectFieldDecl *indirect_field = clang::IndirectFieldDecl::Create(*m_ast,
- record_decl,
- clang::SourceLocation(),
- nested_field_decl->getIdentifier(),
- nested_field_decl->getType(),
- chain,
- 2);
-
- indirect_field->setImplicit();
-
- indirect_field->setAccess(ClangASTContext::UnifyAccessSpecifiers(field_pos->getAccess(),
- nested_field_decl->getAccess()));
-
- indirect_fields.push_back(indirect_field);
- }
- else if (clang::IndirectFieldDecl *nested_indirect_field_decl = llvm::dyn_cast<clang::IndirectFieldDecl>(*di))
- {
- int nested_chain_size = nested_indirect_field_decl->getChainingSize();
- clang::NamedDecl **chain = new (*m_ast) clang::NamedDecl*[nested_chain_size + 1];
- chain[0] = *field_pos;
-
- int chain_index = 1;
- for (clang::IndirectFieldDecl::chain_iterator nci = nested_indirect_field_decl->chain_begin(),
- nce = nested_indirect_field_decl->chain_end();
- nci < nce;
- ++nci)
- {
- chain[chain_index] = *nci;
- chain_index++;
- }
-
- clang::IndirectFieldDecl *indirect_field = clang::IndirectFieldDecl::Create(*m_ast,
- record_decl,
- clang::SourceLocation(),
- nested_indirect_field_decl->getIdentifier(),
- nested_indirect_field_decl->getType(),
- chain,
- nested_chain_size + 1);
-
- indirect_field->setImplicit();
-
- indirect_field->setAccess(ClangASTContext::UnifyAccessSpecifiers(field_pos->getAccess(),
- nested_indirect_field_decl->getAccess()));
-
- indirect_fields.push_back(indirect_field);
- }
- }
- }
- }
-
- // Check the last field to see if it has an incomplete array type as its
- // last member and if it does, the tell the record decl about it
- if (last_field_pos != field_end_pos)
- {
- if (last_field_pos->getType()->isIncompleteArrayType())
- record_decl->hasFlexibleArrayMember();
- }
-
- for (IndirectFieldVector::iterator ifi = indirect_fields.begin(), ife = indirect_fields.end();
- ifi < ife;
- ++ifi)
- {
- record_decl->addDecl(*ifi);
- }
-}
-
-void
-ClangASTType::SetIsPacked ()
-{
- clang::RecordDecl *record_decl = GetAsRecordDecl();
-
- if (!record_decl)
- return;
-
- record_decl->addAttr(clang::PackedAttr::CreateImplicit(*m_ast));
-}
-
-clang::VarDecl *
-ClangASTType::AddVariableToRecordType (const char *name,
- const ClangASTType &var_type,
- AccessType access)
-{
- clang::VarDecl *var_decl = nullptr;
-
- if (!IsValid() || !var_type.IsValid())
- return nullptr;
-
- clang::RecordDecl *record_decl = GetAsRecordDecl ();
- if (record_decl)
- {
- var_decl = clang::VarDecl::Create (*m_ast, // ASTContext &
- record_decl, // DeclContext *
- clang::SourceLocation(), // clang::SourceLocation StartLoc
- clang::SourceLocation(), // clang::SourceLocation IdLoc
- name ? &m_ast->Idents.get(name) : nullptr, // clang::IdentifierInfo *
- var_type.GetQualType(), // Variable clang::QualType
- nullptr, // TypeSourceInfo *
- clang::SC_Static); // StorageClass
- if (var_decl)
- {
- var_decl->setAccess(ClangASTContext::ConvertAccessTypeToAccessSpecifier (access));
- record_decl->addDecl(var_decl);
-
-#ifdef LLDB_CONFIGURATION_DEBUG
- VerifyDecl(var_decl);
-#endif
- }
- }
- return var_decl;
-}
-
-
-clang::CXXMethodDecl *
-ClangASTType::AddMethodToCXXRecordType (const char *name,
- const ClangASTType &method_clang_type,
- lldb::AccessType access,
- bool is_virtual,
- bool is_static,
- bool is_inline,
- bool is_explicit,
- bool is_attr_used,
- bool is_artificial)
-{
- if (!IsValid() || !method_clang_type.IsValid() || name == nullptr || name[0] == '\0')
- return nullptr;
-
- clang::QualType record_qual_type(GetCanonicalQualType());
-
- clang::CXXRecordDecl *cxx_record_decl = record_qual_type->getAsCXXRecordDecl();
-
- if (cxx_record_decl == nullptr)
- return nullptr;
-
- clang::QualType method_qual_type (method_clang_type.GetQualType());
-
- clang::CXXMethodDecl *cxx_method_decl = nullptr;
-
- clang::DeclarationName decl_name (&m_ast->Idents.get(name));
-
- const clang::FunctionType *function_type = llvm::dyn_cast<clang::FunctionType>(method_qual_type.getTypePtr());
-
- if (function_type == nullptr)
- return nullptr;
-
- const clang::FunctionProtoType *method_function_prototype (llvm::dyn_cast<clang::FunctionProtoType>(function_type));
-
- if (!method_function_prototype)
- return nullptr;
-
- unsigned int num_params = method_function_prototype->getNumParams();
-
- clang::CXXDestructorDecl *cxx_dtor_decl(nullptr);
- clang::CXXConstructorDecl *cxx_ctor_decl(nullptr);
-
- if (is_artificial)
- return nullptr; // skip everything artificial
-
- if (name[0] == '~')
- {
- cxx_dtor_decl = clang::CXXDestructorDecl::Create (*m_ast,
- cxx_record_decl,
- clang::SourceLocation(),
- clang::DeclarationNameInfo (m_ast->DeclarationNames.getCXXDestructorName (m_ast->getCanonicalType (record_qual_type)), clang::SourceLocation()),
- method_qual_type,
- nullptr,
- is_inline,
- is_artificial);
- cxx_method_decl = cxx_dtor_decl;
- }
- else if (decl_name == cxx_record_decl->getDeclName())
- {
- cxx_ctor_decl = clang::CXXConstructorDecl::Create (*m_ast,
- cxx_record_decl,
- clang::SourceLocation(),
- clang::DeclarationNameInfo (m_ast->DeclarationNames.getCXXConstructorName (m_ast->getCanonicalType (record_qual_type)), clang::SourceLocation()),
- method_qual_type,
- nullptr, // TypeSourceInfo *
- is_explicit,
- is_inline,
- is_artificial,
- false /*is_constexpr*/);
- cxx_method_decl = cxx_ctor_decl;
- }
- else
- {
- clang::StorageClass SC = is_static ? clang::SC_Static : clang::SC_None;
- clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
-
- if (IsOperator (name, op_kind))
- {
- if (op_kind != clang::NUM_OVERLOADED_OPERATORS)
- {
- // Check the number of operator parameters. Sometimes we have
- // seen bad DWARF that doesn't correctly describe operators and
- // if we try to create a method and add it to the class, clang
- // will assert and crash, so we need to make sure things are
- // acceptable.
- if (!ClangASTContext::CheckOverloadedOperatorKindParameterCount (op_kind, num_params))
- return nullptr;
- cxx_method_decl = clang::CXXMethodDecl::Create (*m_ast,
- cxx_record_decl,
- clang::SourceLocation(),
- clang::DeclarationNameInfo (m_ast->DeclarationNames.getCXXOperatorName (op_kind), clang::SourceLocation()),
- method_qual_type,
- nullptr, // TypeSourceInfo *
- SC,
- is_inline,
- false /*is_constexpr*/,
- clang::SourceLocation());
- }
- else if (num_params == 0)
- {
- // Conversion operators don't take params...
- cxx_method_decl = clang::CXXConversionDecl::Create (*m_ast,
- cxx_record_decl,
- clang::SourceLocation(),
- clang::DeclarationNameInfo (m_ast->DeclarationNames.getCXXConversionFunctionName (m_ast->getCanonicalType (function_type->getReturnType())), clang::SourceLocation()),
- method_qual_type,
- nullptr, // TypeSourceInfo *
- is_inline,
- is_explicit,
- false /*is_constexpr*/,
- clang::SourceLocation());
- }
- }
-
- if (cxx_method_decl == nullptr)
- {
- cxx_method_decl = clang::CXXMethodDecl::Create (*m_ast,
- cxx_record_decl,
- clang::SourceLocation(),
- clang::DeclarationNameInfo (decl_name, clang::SourceLocation()),
- method_qual_type,
- nullptr, // TypeSourceInfo *
- SC,
- is_inline,
- false /*is_constexpr*/,
- clang::SourceLocation());
- }
- }
-
- clang::AccessSpecifier access_specifier = ClangASTContext::ConvertAccessTypeToAccessSpecifier (access);
-
- cxx_method_decl->setAccess (access_specifier);
- cxx_method_decl->setVirtualAsWritten (is_virtual);
-
- if (is_attr_used)
- cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(*m_ast));
-
- // Populate the method decl with parameter decls
-
- llvm::SmallVector<clang::ParmVarDecl *, 12> params;
-
- for (unsigned param_index = 0;
- param_index < num_params;
- ++param_index)
- {
- params.push_back (clang::ParmVarDecl::Create (*m_ast,
- cxx_method_decl,
- clang::SourceLocation(),
- clang::SourceLocation(),
- nullptr, // anonymous
- method_function_prototype->getParamType(param_index),
- nullptr,
- clang::SC_None,
- nullptr));
- }
-
- cxx_method_decl->setParams (llvm::ArrayRef<clang::ParmVarDecl*>(params));
-
- cxx_record_decl->addDecl (cxx_method_decl);
-
- // Sometimes the debug info will mention a constructor (default/copy/move),
- // destructor, or assignment operator (copy/move) but there won't be any
- // version of this in the code. So we check if the function was artificially
- // generated and if it is trivial and this lets the compiler/backend know
- // that it can inline the IR for these when it needs to and we can avoid a
- // "missing function" error when running expressions.
-
- if (is_artificial)
- {
- if (cxx_ctor_decl &&
- ((cxx_ctor_decl->isDefaultConstructor() && cxx_record_decl->hasTrivialDefaultConstructor ()) ||
- (cxx_ctor_decl->isCopyConstructor() && cxx_record_decl->hasTrivialCopyConstructor ()) ||
- (cxx_ctor_decl->isMoveConstructor() && cxx_record_decl->hasTrivialMoveConstructor ()) ))
- {
- cxx_ctor_decl->setDefaulted();
- cxx_ctor_decl->setTrivial(true);
- }
- else if (cxx_dtor_decl)
- {
- if (cxx_record_decl->hasTrivialDestructor())
- {
- cxx_dtor_decl->setDefaulted();
- cxx_dtor_decl->setTrivial(true);
- }
- }
- else if ((cxx_method_decl->isCopyAssignmentOperator() && cxx_record_decl->hasTrivialCopyAssignment()) ||
- (cxx_method_decl->isMoveAssignmentOperator() && cxx_record_decl->hasTrivialMoveAssignment()))
- {
- cxx_method_decl->setDefaulted();
- cxx_method_decl->setTrivial(true);
- }
- }
-
-#ifdef LLDB_CONFIGURATION_DEBUG
- VerifyDecl(cxx_method_decl);
-#endif
-
- // printf ("decl->isPolymorphic() = %i\n", cxx_record_decl->isPolymorphic());
- // printf ("decl->isAggregate() = %i\n", cxx_record_decl->isAggregate());
- // printf ("decl->isPOD() = %i\n", cxx_record_decl->isPOD());
- // printf ("decl->isEmpty() = %i\n", cxx_record_decl->isEmpty());
- // printf ("decl->isAbstract() = %i\n", cxx_record_decl->isAbstract());
- // printf ("decl->hasTrivialConstructor() = %i\n", cxx_record_decl->hasTrivialConstructor());
- // printf ("decl->hasTrivialCopyConstructor() = %i\n", cxx_record_decl->hasTrivialCopyConstructor());
- // printf ("decl->hasTrivialCopyAssignment() = %i\n", cxx_record_decl->hasTrivialCopyAssignment());
- // printf ("decl->hasTrivialDestructor() = %i\n", cxx_record_decl->hasTrivialDestructor());
- return cxx_method_decl;
-}
-
-
-#pragma mark C++ Base Classes
-
-clang::CXXBaseSpecifier *
-ClangASTType::CreateBaseClassSpecifier (AccessType access, bool is_virtual, bool base_of_class)
-{
- if (IsValid())
- return new clang::CXXBaseSpecifier (clang::SourceRange(),
- is_virtual,
- base_of_class,
- ClangASTContext::ConvertAccessTypeToAccessSpecifier (access),
- m_ast->getTrivialTypeSourceInfo (GetQualType()),
- clang::SourceLocation());
- return nullptr;
-}
-
-void
-ClangASTType::DeleteBaseClassSpecifiers (clang::CXXBaseSpecifier **base_classes, unsigned num_base_classes)
-{
- for (unsigned i=0; i<num_base_classes; ++i)
- {
- delete base_classes[i];
- base_classes[i] = nullptr;
- }
-}
-
-bool
-ClangASTType::SetBaseClassesForClassType (clang::CXXBaseSpecifier const * const *base_classes,
- unsigned num_base_classes)
-{
- if (IsValid())
- {
- clang::CXXRecordDecl *cxx_record_decl = GetAsCXXRecordDecl();
- if (cxx_record_decl)
- {
- cxx_record_decl->setBases(base_classes, num_base_classes);
- return true;
- }
- }
- return false;
-}
-
-bool
-ClangASTType::SetObjCSuperClass (const ClangASTType &superclass_clang_type)
-{
- if (IsValid() && superclass_clang_type.IsValid())
- {
- clang::ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl ();
- clang::ObjCInterfaceDecl *super_interface_decl = superclass_clang_type.GetAsObjCInterfaceDecl ();
- if (class_interface_decl && super_interface_decl)
- {
-
- class_interface_decl->setSuperClass(
- m_ast->getTrivialTypeSourceInfo(m_ast->getObjCInterfaceType(super_interface_decl)));
- return true;
- }
- }
- return false;
-}
-
-bool
-ClangASTType::AddObjCClassProperty (const char *property_name,
- const ClangASTType &property_clang_type,
- clang::ObjCIvarDecl *ivar_decl,
- const char *property_setter_name,
- const char *property_getter_name,
- uint32_t property_attributes,
- ClangASTMetadata *metadata)
-{
- if (!IsValid() || !property_clang_type.IsValid() || property_name == nullptr || property_name[0] == '\0')
- return false;
-
- clang::ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl ();
-
- if (class_interface_decl)
- {
- ClangASTType property_clang_type_to_access;
-
- if (property_clang_type.IsValid())
- property_clang_type_to_access = property_clang_type;
- else if (ivar_decl)
- property_clang_type_to_access = ClangASTType (m_ast, ivar_decl->getType());
-
- if (class_interface_decl && property_clang_type_to_access.IsValid())
- {
- clang::TypeSourceInfo *prop_type_source;
- if (ivar_decl)
- prop_type_source = m_ast->getTrivialTypeSourceInfo (ivar_decl->getType());
- else
- prop_type_source = m_ast->getTrivialTypeSourceInfo (property_clang_type.GetQualType());
-
- clang::ObjCPropertyDecl *property_decl = clang::ObjCPropertyDecl::Create (*m_ast,
- class_interface_decl,
- clang::SourceLocation(), // Source Location
- &m_ast->Idents.get(property_name),
- clang::SourceLocation(), //Source Location for AT
- clang::SourceLocation(), //Source location for (
- ivar_decl ? ivar_decl->getType() : property_clang_type.GetQualType(),
- prop_type_source);
-
- if (property_decl)
- {
- if (metadata)
- ClangASTContext::SetMetadata(m_ast, property_decl, *metadata);
-
- class_interface_decl->addDecl (property_decl);
-
- clang::Selector setter_sel, getter_sel;
-
- if (property_setter_name != nullptr)
- {
- std::string property_setter_no_colon(property_setter_name, strlen(property_setter_name) - 1);
- clang::IdentifierInfo *setter_ident = &m_ast->Idents.get(property_setter_no_colon.c_str());
- setter_sel = m_ast->Selectors.getSelector(1, &setter_ident);
- }
- else if (!(property_attributes & DW_APPLE_PROPERTY_readonly))
- {
- std::string setter_sel_string("set");
- setter_sel_string.push_back(::toupper(property_name[0]));
- setter_sel_string.append(&property_name[1]);
- clang::IdentifierInfo *setter_ident = &m_ast->Idents.get(setter_sel_string.c_str());
- setter_sel = m_ast->Selectors.getSelector(1, &setter_ident);
- }
- property_decl->setSetterName(setter_sel);
- property_decl->setPropertyAttributes (clang::ObjCPropertyDecl::OBJC_PR_setter);
-
- if (property_getter_name != nullptr)
- {
- clang::IdentifierInfo *getter_ident = &m_ast->Idents.get(property_getter_name);
- getter_sel = m_ast->Selectors.getSelector(0, &getter_ident);
- }
- else
- {
- clang::IdentifierInfo *getter_ident = &m_ast->Idents.get(property_name);
- getter_sel = m_ast->Selectors.getSelector(0, &getter_ident);
- }
- property_decl->setGetterName(getter_sel);
- property_decl->setPropertyAttributes (clang::ObjCPropertyDecl::OBJC_PR_getter);
-
- if (ivar_decl)
- property_decl->setPropertyIvarDecl (ivar_decl);
-
- if (property_attributes & DW_APPLE_PROPERTY_readonly)
- property_decl->setPropertyAttributes (clang::ObjCPropertyDecl::OBJC_PR_readonly);
- if (property_attributes & DW_APPLE_PROPERTY_readwrite)
- property_decl->setPropertyAttributes (clang::ObjCPropertyDecl::OBJC_PR_readwrite);
- if (property_attributes & DW_APPLE_PROPERTY_assign)
- property_decl->setPropertyAttributes (clang::ObjCPropertyDecl::OBJC_PR_assign);
- if (property_attributes & DW_APPLE_PROPERTY_retain)
- property_decl->setPropertyAttributes (clang::ObjCPropertyDecl::OBJC_PR_retain);
- if (property_attributes & DW_APPLE_PROPERTY_copy)
- property_decl->setPropertyAttributes (clang::ObjCPropertyDecl::OBJC_PR_copy);
- if (property_attributes & DW_APPLE_PROPERTY_nonatomic)
- property_decl->setPropertyAttributes (clang::ObjCPropertyDecl::OBJC_PR_nonatomic);
-
- if (!getter_sel.isNull() && !class_interface_decl->lookupInstanceMethod(getter_sel))
- {
- const bool isInstance = true;
- const bool isVariadic = false;
- const bool isSynthesized = false;
- const bool isImplicitlyDeclared = true;
- const bool isDefined = false;
- const clang::ObjCMethodDecl::ImplementationControl impControl = clang::ObjCMethodDecl::None;
- const bool HasRelatedResultType = false;
-
- clang::ObjCMethodDecl *getter = clang::ObjCMethodDecl::Create (*m_ast,
- clang::SourceLocation(),
- clang::SourceLocation(),
- getter_sel,
- property_clang_type_to_access.GetQualType(),
- nullptr,
- class_interface_decl,
- isInstance,
- isVariadic,
- isSynthesized,
- isImplicitlyDeclared,
- isDefined,
- impControl,
- HasRelatedResultType);
-
- if (getter && metadata)
- ClangASTContext::SetMetadata(m_ast, getter, *metadata);
-
- if (getter)
- {
- getter->setMethodParams(*m_ast, llvm::ArrayRef<clang::ParmVarDecl*>(), llvm::ArrayRef<clang::SourceLocation>());
-
- class_interface_decl->addDecl(getter);
- }
- }
-
- if (!setter_sel.isNull() && !class_interface_decl->lookupInstanceMethod(setter_sel))
- {
- clang::QualType result_type = m_ast->VoidTy;
-
- const bool isInstance = true;
- const bool isVariadic = false;
- const bool isSynthesized = false;
- const bool isImplicitlyDeclared = true;
- const bool isDefined = false;
- const clang::ObjCMethodDecl::ImplementationControl impControl = clang::ObjCMethodDecl::None;
- const bool HasRelatedResultType = false;
-
- clang::ObjCMethodDecl *setter = clang::ObjCMethodDecl::Create (*m_ast,
- clang::SourceLocation(),
- clang::SourceLocation(),
- setter_sel,
- result_type,
- nullptr,
- class_interface_decl,
- isInstance,
- isVariadic,
- isSynthesized,
- isImplicitlyDeclared,
- isDefined,
- impControl,
- HasRelatedResultType);
-
- if (setter && metadata)
- ClangASTContext::SetMetadata(m_ast, setter, *metadata);
-
- llvm::SmallVector<clang::ParmVarDecl *, 1> params;
-
- params.push_back (clang::ParmVarDecl::Create (*m_ast,
- setter,
- clang::SourceLocation(),
- clang::SourceLocation(),
- nullptr, // anonymous
- property_clang_type_to_access.GetQualType(),
- nullptr,
- clang::SC_Auto,
- nullptr));
-
- if (setter)
- {
- setter->setMethodParams(*m_ast, llvm::ArrayRef<clang::ParmVarDecl*>(params), llvm::ArrayRef<clang::SourceLocation>());
-
- class_interface_decl->addDecl(setter);
- }
- }
-
- return true;
- }
- }
- }
- return false;
-}
-
-bool
-ClangASTType::IsObjCClassTypeAndHasIVars (bool check_superclass) const
-{
- clang::ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl ();
- if (class_interface_decl)
- return ObjCDeclHasIVars (class_interface_decl, check_superclass);
- return false;
-}
-
-
-clang::ObjCMethodDecl *
-ClangASTType::AddMethodToObjCObjectType (const char *name, // the full symbol name as seen in the symbol table ("-[NString stringWithCString:]")
- const ClangASTType &method_clang_type,
- lldb::AccessType access,
- bool is_artificial)
-{
- if (!IsValid() || !method_clang_type.IsValid())
- return nullptr;
-
- clang::ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl();
-
- if (class_interface_decl == nullptr)
- return nullptr;
-
- const char *selector_start = ::strchr (name, ' ');
- if (selector_start == nullptr)
- return nullptr;
-
- selector_start++;
- llvm::SmallVector<clang::IdentifierInfo *, 12> selector_idents;
-
- size_t len = 0;
- const char *start;
- //printf ("name = '%s'\n", name);
-
- unsigned num_selectors_with_args = 0;
- for (start = selector_start;
- start && *start != '\0' && *start != ']';
- start += len)
- {
- len = ::strcspn(start, ":]");
- bool has_arg = (start[len] == ':');
- if (has_arg)
- ++num_selectors_with_args;
- selector_idents.push_back (&m_ast->Idents.get (llvm::StringRef (start, len)));
- if (has_arg)
- len += 1;
- }
-
-
- if (selector_idents.size() == 0)
- return nullptr;
-
- clang::Selector method_selector = m_ast->Selectors.getSelector (num_selectors_with_args ? selector_idents.size() : 0,
- selector_idents.data());
-
- clang::QualType method_qual_type (method_clang_type.GetQualType());
-
- // Populate the method decl with parameter decls
- const clang::Type *method_type(method_qual_type.getTypePtr());
-
- if (method_type == nullptr)
- return nullptr;
-
- const clang::FunctionProtoType *method_function_prototype (llvm::dyn_cast<clang::FunctionProtoType>(method_type));
-
- if (!method_function_prototype)
- return nullptr;
-
-
- bool is_variadic = false;
- bool is_synthesized = false;
- bool is_defined = false;
- clang::ObjCMethodDecl::ImplementationControl imp_control = clang::ObjCMethodDecl::None;
-
- const unsigned num_args = method_function_prototype->getNumParams();
-
- if (num_args != num_selectors_with_args)
- return nullptr; // some debug information is corrupt. We are not going to deal with it.
-
- clang::ObjCMethodDecl *objc_method_decl = clang::ObjCMethodDecl::Create (*m_ast,
- clang::SourceLocation(), // beginLoc,
- clang::SourceLocation(), // endLoc,
- method_selector,
- method_function_prototype->getReturnType(),
- nullptr, // TypeSourceInfo *ResultTInfo,
- GetDeclContextForType (),
- name[0] == '-',
- is_variadic,
- is_synthesized,
- true, // is_implicitly_declared; we force this to true because we don't have source locations
- is_defined,
- imp_control,
- false /*has_related_result_type*/);
-
-
- if (objc_method_decl == nullptr)
- return nullptr;
-
- if (num_args > 0)
- {
- llvm::SmallVector<clang::ParmVarDecl *, 12> params;
-
- for (unsigned param_index = 0; param_index < num_args; ++param_index)
- {
- params.push_back (clang::ParmVarDecl::Create (*m_ast,
- objc_method_decl,
- clang::SourceLocation(),
- clang::SourceLocation(),
- nullptr, // anonymous
- method_function_prototype->getParamType(param_index),
- nullptr,
- clang::SC_Auto,
- nullptr));
- }
-
- objc_method_decl->setMethodParams(*m_ast, llvm::ArrayRef<clang::ParmVarDecl*>(params), llvm::ArrayRef<clang::SourceLocation>());
- }
-
- class_interface_decl->addDecl (objc_method_decl);
-
-#ifdef LLDB_CONFIGURATION_DEBUG
- VerifyDecl(objc_method_decl);
-#endif
-
- return objc_method_decl;
-}
-
-
-clang::DeclContext *
-ClangASTType::GetDeclContextForType () const
-{
- if (!IsValid())
- return nullptr;
-
- clang::QualType qual_type(GetCanonicalQualType());
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::UnaryTransform: break;
- case clang::Type::FunctionNoProto: break;
- case clang::Type::FunctionProto: break;
- case clang::Type::IncompleteArray: break;
- case clang::Type::VariableArray: break;
- case clang::Type::ConstantArray: break;
- case clang::Type::DependentSizedArray: break;
- case clang::Type::ExtVector: break;
- case clang::Type::DependentSizedExtVector: break;
- case clang::Type::Vector: break;
- case clang::Type::Builtin: break;
- case clang::Type::BlockPointer: break;
- case clang::Type::Pointer: break;
- case clang::Type::LValueReference: break;
- case clang::Type::RValueReference: break;
- case clang::Type::MemberPointer: break;
- case clang::Type::Complex: break;
- case clang::Type::ObjCObject: break;
- case clang::Type::ObjCInterface: return llvm::cast<clang::ObjCObjectType>(qual_type.getTypePtr())->getInterface();
- case clang::Type::ObjCObjectPointer: return ClangASTType (m_ast, llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())->getPointeeType()).GetDeclContextForType();
- case clang::Type::Record: return llvm::cast<clang::RecordType>(qual_type)->getDecl();
- case clang::Type::Enum: return llvm::cast<clang::EnumType>(qual_type)->getDecl();
- case clang::Type::Typedef: return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).GetDeclContextForType();
- case clang::Type::Elaborated: return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).GetDeclContextForType();
- case clang::Type::Paren: return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).GetDeclContextForType();
- case clang::Type::TypeOfExpr: break;
- case clang::Type::TypeOf: break;
- case clang::Type::Decltype: break;
- //case clang::Type::QualifiedName: break;
- case clang::Type::TemplateSpecialization: break;
- case clang::Type::DependentTemplateSpecialization: break;
- case clang::Type::TemplateTypeParm: break;
- case clang::Type::SubstTemplateTypeParm: break;
- case clang::Type::SubstTemplateTypeParmPack:break;
- case clang::Type::PackExpansion: break;
- case clang::Type::UnresolvedUsing: break;
- case clang::Type::Attributed: break;
- case clang::Type::Auto: break;
- case clang::Type::InjectedClassName: break;
- case clang::Type::DependentName: break;
- case clang::Type::Atomic: break;
- case clang::Type::Adjusted: break;
-
- // pointer type decayed from an array or function type.
- case clang::Type::Decayed: break;
- }
- // No DeclContext in this type...
- return nullptr;
-}
-
-bool
-ClangASTType::SetDefaultAccessForRecordFields (int default_accessibility,
- int *assigned_accessibilities,
- size_t num_assigned_accessibilities)
-{
- if (IsValid())
- {
- clang::RecordDecl *record_decl = GetAsRecordDecl();
- if (record_decl)
- {
- uint32_t field_idx;
- clang::RecordDecl::field_iterator field, field_end;
- for (field = record_decl->field_begin(), field_end = record_decl->field_end(), field_idx = 0;
- field != field_end;
- ++field, ++field_idx)
- {
- // If no accessibility was assigned, assign the correct one
- if (field_idx < num_assigned_accessibilities && assigned_accessibilities[field_idx] == clang::AS_none)
- field->setAccess ((clang::AccessSpecifier)default_accessibility);
- }
- return true;
- }
- }
- return false;
-}
-
-
-bool
-ClangASTType::SetHasExternalStorage (bool has_extern)
-{
- if (!IsValid())
- return false;
-
- clang::QualType qual_type (GetCanonicalQualType());
-
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::Record:
- {
- clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
- if (cxx_record_decl)
- {
- cxx_record_decl->setHasExternalLexicalStorage (has_extern);
- cxx_record_decl->setHasExternalVisibleStorage (has_extern);
- return true;
- }
- }
- break;
-
- case clang::Type::Enum:
- {
- clang::EnumDecl *enum_decl = llvm::cast<clang::EnumType>(qual_type)->getDecl();
- if (enum_decl)
- {
- enum_decl->setHasExternalLexicalStorage (has_extern);
- enum_decl->setHasExternalVisibleStorage (has_extern);
- return true;
- }
- }
- break;
-
- case clang::Type::ObjCObject:
- case clang::Type::ObjCInterface:
- {
- const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
- assert (objc_class_type);
- if (objc_class_type)
- {
- clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
-
- if (class_interface_decl)
- {
- class_interface_decl->setHasExternalLexicalStorage (has_extern);
- class_interface_decl->setHasExternalVisibleStorage (has_extern);
- return true;
- }
- }
- }
- break;
-
- case clang::Type::Typedef:
- return ClangASTType (m_ast, llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType()).SetHasExternalStorage (has_extern);
-
- case clang::Type::Elaborated:
- return ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).SetHasExternalStorage (has_extern);
-
- case clang::Type::Paren:
- return ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).SetHasExternalStorage (has_extern);
-
- default:
- break;
- }
- return false;
-}
-
-bool
-ClangASTType::SetTagTypeKind (int kind) const
-{
- if (IsValid())
- {
- clang::QualType tag_qual_type(GetQualType());
- const clang::Type *clang_type = tag_qual_type.getTypePtr();
- if (clang_type)
- {
- const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(clang_type);
- if (tag_type)
- {
- clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(tag_type->getDecl());
- if (tag_decl)
- {
- tag_decl->setTagKind ((clang::TagDecl::TagKind)kind);
- return true;
- }
- }
- }
- }
- return false;
-}
-
-
-#pragma mark TagDecl
-
-bool
-ClangASTType::StartTagDeclarationDefinition ()
-{
- if (IsValid())
- {
- clang::QualType qual_type (GetQualType());
- const clang::Type *t = qual_type.getTypePtr();
- if (t)
- {
- const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(t);
- if (tag_type)
- {
- clang::TagDecl *tag_decl = tag_type->getDecl();
- if (tag_decl)
- {
- tag_decl->startDefinition();
- return true;
- }
- }
-
- const clang::ObjCObjectType *object_type = llvm::dyn_cast<clang::ObjCObjectType>(t);
- if (object_type)
- {
- clang::ObjCInterfaceDecl *interface_decl = object_type->getInterface();
- if (interface_decl)
- {
- interface_decl->startDefinition();
- return true;
- }
- }
- }
- }
- return false;
-}
-
-bool
-ClangASTType::CompleteTagDeclarationDefinition ()
-{
- if (IsValid())
- {
- clang::QualType qual_type (GetQualType());
-
- clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
-
- if (cxx_record_decl)
- {
- cxx_record_decl->completeDefinition();
-
- return true;
- }
-
- const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(qual_type.getTypePtr());
-
- if (enum_type)
- {
- clang::EnumDecl *enum_decl = enum_type->getDecl();
-
- if (enum_decl)
- {
- /// TODO This really needs to be fixed.
-
- unsigned NumPositiveBits = 1;
- unsigned NumNegativeBits = 0;
-
- clang::QualType promotion_qual_type;
- // If the enum integer type is less than an integer in bit width,
- // then we must promote it to an integer size.
- if (m_ast->getTypeSize(enum_decl->getIntegerType()) < m_ast->getTypeSize(m_ast->IntTy))
- {
- if (enum_decl->getIntegerType()->isSignedIntegerType())
- promotion_qual_type = m_ast->IntTy;
- else
- promotion_qual_type = m_ast->UnsignedIntTy;
- }
- else
- promotion_qual_type = enum_decl->getIntegerType();
-
- enum_decl->completeDefinition(enum_decl->getIntegerType(), promotion_qual_type, NumPositiveBits, NumNegativeBits);
- return true;
- }
- }
- }
- return false;
-}
-
-
-
-
-
-
-
-bool
-ClangASTType::AddEnumerationValueToEnumerationType (const ClangASTType &enumerator_clang_type,
- const Declaration &decl,
- const char *name,
- int64_t enum_value,
- uint32_t enum_value_bit_size)
-{
- if (IsValid() && enumerator_clang_type.IsValid() && name && name[0])
- {
- clang::QualType enum_qual_type (GetCanonicalQualType());
-
- bool is_signed = false;
- enumerator_clang_type.IsIntegerType (is_signed);
- const clang::Type *clang_type = enum_qual_type.getTypePtr();
- if (clang_type)
- {
- const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(clang_type);
-
- if (enum_type)
- {
- llvm::APSInt enum_llvm_apsint(enum_value_bit_size, is_signed);
- enum_llvm_apsint = enum_value;
- clang::EnumConstantDecl *enumerator_decl =
- clang::EnumConstantDecl::Create (*m_ast,
- enum_type->getDecl(),
- clang::SourceLocation(),
- name ? &m_ast->Idents.get(name) : nullptr, // Identifier
- enumerator_clang_type.GetQualType(),
- nullptr,
- enum_llvm_apsint);
-
- if (enumerator_decl)
- {
- enum_type->getDecl()->addDecl(enumerator_decl);
-
-#ifdef LLDB_CONFIGURATION_DEBUG
- VerifyDecl(enumerator_decl);
-#endif
-
- return true;
- }
- }
- }
- }
- return false;
-}
-
-
-ClangASTType
-ClangASTType::GetEnumerationIntegerType () const
-{
- clang::QualType enum_qual_type (GetCanonicalQualType());
- const clang::Type *clang_type = enum_qual_type.getTypePtr();
- if (clang_type)
- {
- const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(clang_type);
- if (enum_type)
- {
- clang::EnumDecl *enum_decl = enum_type->getDecl();
- if (enum_decl)
- return ClangASTType (m_ast, enum_decl->getIntegerType());
- }
- }
- return ClangASTType();
-}
-
-ClangASTType
-ClangASTType::CreateMemberPointerType (const ClangASTType &pointee_type) const
-{
- if (IsValid() && pointee_type.IsValid())
- {
- return ClangASTType (m_ast, m_ast->getMemberPointerType (pointee_type.GetQualType(),
- GetQualType().getTypePtr()));
- }
- return ClangASTType();
-}
-
-
-size_t
-ClangASTType::ConvertStringToFloatValue (const char *s, uint8_t *dst, size_t dst_size) const
-{
- if (IsValid())
- {
- clang::QualType qual_type (GetCanonicalQualType());
- uint32_t count = 0;
- bool is_complex = false;
- if (IsFloatingPointType (count, is_complex))
- {
- // TODO: handle complex and vector types
- if (count != 1)
- return false;
-
- llvm::StringRef s_sref(s);
- llvm::APFloat ap_float(m_ast->getFloatTypeSemantics(qual_type), s_sref);
-
- const uint64_t bit_size = m_ast->getTypeSize (qual_type);
- const uint64_t byte_size = bit_size / 8;
- if (dst_size >= byte_size)
- {
- if (bit_size == sizeof(float)*8)
- {
- float float32 = ap_float.convertToFloat();
- ::memcpy (dst, &float32, byte_size);
- return byte_size;
- }
- else if (bit_size >= 64)
- {
- llvm::APInt ap_int(ap_float.bitcastToAPInt());
- ::memcpy (dst, ap_int.getRawData(), byte_size);
- return byte_size;
- }
- }
- }
- }
- return 0;
-}
-
-
-
-//----------------------------------------------------------------------
-// Dumping types
-//----------------------------------------------------------------------
-#define DEPTH_INCREMENT 2
-
-void
-ClangASTType::DumpValue (ExecutionContext *exe_ctx,
- Stream *s,
- lldb::Format format,
- const lldb_private::DataExtractor &data,
- lldb::offset_t data_byte_offset,
- size_t data_byte_size,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset,
- bool show_types,
- bool show_summary,
- bool verbose,
- uint32_t depth)
-{
- if (!IsValid())
- return;
-
- clang::QualType qual_type(GetQualType());
- switch (qual_type->getTypeClass())
- {
- case clang::Type::Record:
- if (GetCompleteType ())
- {
- const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
- assert(record_decl);
- uint32_t field_bit_offset = 0;
- uint32_t field_byte_offset = 0;
- const clang::ASTRecordLayout &record_layout = m_ast->getASTRecordLayout(record_decl);
- uint32_t child_idx = 0;
-
- const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
- if (cxx_record_decl)
- {
- // We might have base classes to print out first
- clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
- for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
- base_class != base_class_end;
- ++base_class)
- {
- const clang::CXXRecordDecl *base_class_decl = llvm::cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl());
-
- // Skip empty base classes
- if (verbose == false && ClangASTContext::RecordHasFields(base_class_decl) == false)
- continue;
-
- if (base_class->isVirtual())
- field_bit_offset = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8;
- else
- field_bit_offset = record_layout.getBaseClassOffset(base_class_decl).getQuantity() * 8;
- field_byte_offset = field_bit_offset / 8;
- assert (field_bit_offset % 8 == 0);
- if (child_idx == 0)
- s->PutChar('{');
- else
- s->PutChar(',');
-
- clang::QualType base_class_qual_type = base_class->getType();
- std::string base_class_type_name(base_class_qual_type.getAsString());
-
- // Indent and print the base class type name
- s->Printf("\n%*s%s ", depth + DEPTH_INCREMENT, "", base_class_type_name.c_str());
-
- clang::TypeInfo base_class_type_info = m_ast->getTypeInfo(base_class_qual_type);
-
- // Dump the value of the member
- ClangASTType base_clang_type(m_ast, base_class_qual_type);
- base_clang_type.DumpValue (exe_ctx,
- s, // Stream to dump to
- base_clang_type.GetFormat(), // The format with which to display the member
- data, // Data buffer containing all bytes for this type
- data_byte_offset + field_byte_offset,// Offset into "data" where to grab value from
- base_class_type_info.Width / 8, // Size of this type in bytes
- 0, // Bitfield bit size
- 0, // Bitfield bit offset
- show_types, // Boolean indicating if we should show the variable types
- show_summary, // Boolean indicating if we should show a summary for the current type
- verbose, // Verbose output?
- depth + DEPTH_INCREMENT); // Scope depth for any types that have children
-
- ++child_idx;
- }
- }
- uint32_t field_idx = 0;
- clang::RecordDecl::field_iterator field, field_end;
- for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++field_idx, ++child_idx)
- {
- // Print the starting squiggly bracket (if this is the
- // first member) or comma (for member 2 and beyond) for
- // the struct/union/class member.
- if (child_idx == 0)
- s->PutChar('{');
- else
- s->PutChar(',');
-
- // Indent
- s->Printf("\n%*s", depth + DEPTH_INCREMENT, "");
-
- clang::QualType field_type = field->getType();
- // Print the member type if requested
- // Figure out the type byte size (field_type_info.first) and
- // alignment (field_type_info.second) from the AST context.
- clang::TypeInfo field_type_info = m_ast->getTypeInfo(field_type);
- assert(field_idx < record_layout.getFieldCount());
- // Figure out the field offset within the current struct/union/class type
- field_bit_offset = record_layout.getFieldOffset (field_idx);
- field_byte_offset = field_bit_offset / 8;
- uint32_t field_bitfield_bit_size = 0;
- uint32_t field_bitfield_bit_offset = 0;
- if (ClangASTContext::FieldIsBitfield (m_ast, *field, field_bitfield_bit_size))
- field_bitfield_bit_offset = field_bit_offset % 8;
-
- if (show_types)
- {
- std::string field_type_name(field_type.getAsString());
- if (field_bitfield_bit_size > 0)
- s->Printf("(%s:%u) ", field_type_name.c_str(), field_bitfield_bit_size);
- else
- s->Printf("(%s) ", field_type_name.c_str());
- }
- // Print the member name and equal sign
- s->Printf("%s = ", field->getNameAsString().c_str());
-
-
- // Dump the value of the member
- ClangASTType field_clang_type (m_ast, field_type);
- field_clang_type.DumpValue (exe_ctx,
- s, // Stream to dump to
- field_clang_type.GetFormat(), // The format with which to display the member
- data, // Data buffer containing all bytes for this type
- data_byte_offset + field_byte_offset,// Offset into "data" where to grab value from
- field_type_info.Width / 8, // Size of this type in bytes
- field_bitfield_bit_size, // Bitfield bit size
- field_bitfield_bit_offset, // Bitfield bit offset
- show_types, // Boolean indicating if we should show the variable types
- show_summary, // Boolean indicating if we should show a summary for the current type
- verbose, // Verbose output?
- depth + DEPTH_INCREMENT); // Scope depth for any types that have children
- }
-
- // Indent the trailing squiggly bracket
- if (child_idx > 0)
- s->Printf("\n%*s}", depth, "");
- }
- return;
-
- case clang::Type::Enum:
- if (GetCompleteType ())
- {
- const clang::EnumType *enum_type = llvm::cast<clang::EnumType>(qual_type.getTypePtr());
- const clang::EnumDecl *enum_decl = enum_type->getDecl();
- assert(enum_decl);
- clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
- lldb::offset_t offset = data_byte_offset;
- const int64_t enum_value = data.GetMaxU64Bitfield(&offset, data_byte_size, bitfield_bit_size, bitfield_bit_offset);
- for (enum_pos = enum_decl->enumerator_begin(), enum_end_pos = enum_decl->enumerator_end(); enum_pos != enum_end_pos; ++enum_pos)
- {
- if (enum_pos->getInitVal() == enum_value)
- {
- s->Printf("%s", enum_pos->getNameAsString().c_str());
- return;
- }
- }
- // If we have gotten here we didn't get find the enumerator in the
- // enum decl, so just print the integer.
- s->Printf("%" PRIi64, enum_value);
- }
- return;
-
- case clang::Type::ConstantArray:
- {
- const clang::ConstantArrayType *array = llvm::cast<clang::ConstantArrayType>(qual_type.getTypePtr());
- bool is_array_of_characters = false;
- clang::QualType element_qual_type = array->getElementType();
-
- const clang::Type *canonical_type = element_qual_type->getCanonicalTypeInternal().getTypePtr();
- if (canonical_type)
- is_array_of_characters = canonical_type->isCharType();
-
- const uint64_t element_count = array->getSize().getLimitedValue();
-
- clang::TypeInfo field_type_info = m_ast->getTypeInfo(element_qual_type);
-
- uint32_t element_idx = 0;
- uint32_t element_offset = 0;
- uint64_t element_byte_size = field_type_info.Width / 8;
- uint32_t element_stride = element_byte_size;
-
- if (is_array_of_characters)
- {
- s->PutChar('"');
- data.Dump(s, data_byte_offset, lldb::eFormatChar, element_byte_size, element_count, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0);
- s->PutChar('"');
- return;
- }
- else
- {
- ClangASTType element_clang_type(m_ast, element_qual_type);
- lldb::Format element_format = element_clang_type.GetFormat();
-
- for (element_idx = 0; element_idx < element_count; ++element_idx)
- {
- // Print the starting squiggly bracket (if this is the
- // first member) or comma (for member 2 and beyond) for
- // the struct/union/class member.
- if (element_idx == 0)
- s->PutChar('{');
- else
- s->PutChar(',');
-
- // Indent and print the index
- s->Printf("\n%*s[%u] ", depth + DEPTH_INCREMENT, "", element_idx);
-
- // Figure out the field offset within the current struct/union/class type
- element_offset = element_idx * element_stride;
-
- // Dump the value of the member
- element_clang_type.DumpValue (exe_ctx,
- s, // Stream to dump to
- element_format, // The format with which to display the element
- data, // Data buffer containing all bytes for this type
- data_byte_offset + element_offset,// Offset into "data" where to grab value from
- element_byte_size, // Size of this type in bytes
- 0, // Bitfield bit size
- 0, // Bitfield bit offset
- show_types, // Boolean indicating if we should show the variable types
- show_summary, // Boolean indicating if we should show a summary for the current type
- verbose, // Verbose output?
- depth + DEPTH_INCREMENT); // Scope depth for any types that have children
- }
-
- // Indent the trailing squiggly bracket
- if (element_idx > 0)
- s->Printf("\n%*s}", depth, "");
- }
- }
- return;
-
- case clang::Type::Typedef:
- {
- clang::QualType typedef_qual_type = llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType();
-
- ClangASTType typedef_clang_type (m_ast, typedef_qual_type);
- lldb::Format typedef_format = typedef_clang_type.GetFormat();
- clang::TypeInfo typedef_type_info = m_ast->getTypeInfo(typedef_qual_type);
- uint64_t typedef_byte_size = typedef_type_info.Width / 8;
-
- return typedef_clang_type.DumpValue (exe_ctx,
- s, // Stream to dump to
- typedef_format, // The format with which to display the element
- data, // Data buffer containing all bytes for this type
- data_byte_offset, // Offset into "data" where to grab value from
- typedef_byte_size, // Size of this type in bytes
- bitfield_bit_size, // Bitfield bit size
- bitfield_bit_offset,// Bitfield bit offset
- show_types, // Boolean indicating if we should show the variable types
- show_summary, // Boolean indicating if we should show a summary for the current type
- verbose, // Verbose output?
- depth); // Scope depth for any types that have children
- }
- break;
-
- case clang::Type::Elaborated:
- {
- clang::QualType elaborated_qual_type = llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType();
- ClangASTType elaborated_clang_type (m_ast, elaborated_qual_type);
- lldb::Format elaborated_format = elaborated_clang_type.GetFormat();
- clang::TypeInfo elaborated_type_info = m_ast->getTypeInfo(elaborated_qual_type);
- uint64_t elaborated_byte_size = elaborated_type_info.Width / 8;
-
- return elaborated_clang_type.DumpValue (exe_ctx,
- s, // Stream to dump to
- elaborated_format, // The format with which to display the element
- data, // Data buffer containing all bytes for this type
- data_byte_offset, // Offset into "data" where to grab value from
- elaborated_byte_size, // Size of this type in bytes
- bitfield_bit_size, // Bitfield bit size
- bitfield_bit_offset,// Bitfield bit offset
- show_types, // Boolean indicating if we should show the variable types
- show_summary, // Boolean indicating if we should show a summary for the current type
- verbose, // Verbose output?
- depth); // Scope depth for any types that have children
- }
- break;
-
- case clang::Type::Paren:
- {
- clang::QualType desugar_qual_type = llvm::cast<clang::ParenType>(qual_type)->desugar();
- ClangASTType desugar_clang_type (m_ast, desugar_qual_type);
-
- lldb::Format desugar_format = desugar_clang_type.GetFormat();
- clang::TypeInfo desugar_type_info = m_ast->getTypeInfo(desugar_qual_type);
- uint64_t desugar_byte_size = desugar_type_info.Width / 8;
-
- return desugar_clang_type.DumpValue (exe_ctx,
- s, // Stream to dump to
- desugar_format, // The format with which to display the element
- data, // Data buffer containing all bytes for this type
- data_byte_offset, // Offset into "data" where to grab value from
- desugar_byte_size, // Size of this type in bytes
- bitfield_bit_size, // Bitfield bit size
- bitfield_bit_offset,// Bitfield bit offset
- show_types, // Boolean indicating if we should show the variable types
- show_summary, // Boolean indicating if we should show a summary for the current type
- verbose, // Verbose output?
- depth); // Scope depth for any types that have children
- }
- break;
-
- default:
- // We are down to a scalar type that we just need to display.
- data.Dump(s,
- data_byte_offset,
- format,
- data_byte_size,
- 1,
- UINT32_MAX,
- LLDB_INVALID_ADDRESS,
- bitfield_bit_size,
- bitfield_bit_offset);
-
- if (show_summary)
- DumpSummary (exe_ctx, s, data, data_byte_offset, data_byte_size);
- break;
- }
-}
-
-
-
-
-bool
-ClangASTType::DumpTypeValue (Stream *s,
- lldb::Format format,
- const lldb_private::DataExtractor &data,
- lldb::offset_t byte_offset,
- size_t byte_size,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset,
- ExecutionContextScope *exe_scope)
-{
- if (!IsValid())
- return false;
- if (IsAggregateType())
- {
- return false;
- }
- else
- {
- clang::QualType qual_type(GetQualType());
-
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::Typedef:
- {
- clang::QualType typedef_qual_type = llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType();
- ClangASTType typedef_clang_type (m_ast, typedef_qual_type);
- if (format == eFormatDefault)
- format = typedef_clang_type.GetFormat();
- clang::TypeInfo typedef_type_info = m_ast->getTypeInfo(typedef_qual_type);
- uint64_t typedef_byte_size = typedef_type_info.Width / 8;
-
- return typedef_clang_type.DumpTypeValue (s,
- format, // The format with which to display the element
- data, // Data buffer containing all bytes for this type
- byte_offset, // Offset into "data" where to grab value from
- typedef_byte_size, // Size of this type in bytes
- bitfield_bit_size, // Size in bits of a bitfield value, if zero don't treat as a bitfield
- bitfield_bit_offset, // Offset in bits of a bitfield value if bitfield_bit_size != 0
- exe_scope);
- }
- break;
-
- case clang::Type::Enum:
- // If our format is enum or default, show the enumeration value as
- // its enumeration string value, else just display it as requested.
- if ((format == eFormatEnum || format == eFormatDefault) && GetCompleteType ())
- {
- const clang::EnumType *enum_type = llvm::cast<clang::EnumType>(qual_type.getTypePtr());
- const clang::EnumDecl *enum_decl = enum_type->getDecl();
- assert(enum_decl);
- clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
- const bool is_signed = qual_type->isSignedIntegerOrEnumerationType();
- lldb::offset_t offset = byte_offset;
- if (is_signed)
- {
- const int64_t enum_svalue = data.GetMaxS64Bitfield (&offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
- for (enum_pos = enum_decl->enumerator_begin(), enum_end_pos = enum_decl->enumerator_end(); enum_pos != enum_end_pos; ++enum_pos)
- {
- if (enum_pos->getInitVal().getSExtValue() == enum_svalue)
- {
- s->PutCString (enum_pos->getNameAsString().c_str());
- return true;
- }
- }
- // If we have gotten here we didn't get find the enumerator in the
- // enum decl, so just print the integer.
- s->Printf("%" PRIi64, enum_svalue);
- }
- else
- {
- const uint64_t enum_uvalue = data.GetMaxU64Bitfield (&offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
- for (enum_pos = enum_decl->enumerator_begin(), enum_end_pos = enum_decl->enumerator_end(); enum_pos != enum_end_pos; ++enum_pos)
- {
- if (enum_pos->getInitVal().getZExtValue() == enum_uvalue)
- {
- s->PutCString (enum_pos->getNameAsString().c_str());
- return true;
- }
- }
- // If we have gotten here we didn't get find the enumerator in the
- // enum decl, so just print the integer.
- s->Printf("%" PRIu64, enum_uvalue);
- }
- return true;
- }
- // format was not enum, just fall through and dump the value as requested....
-
- default:
- // We are down to a scalar type that we just need to display.
- {
- uint32_t item_count = 1;
- // A few formats, we might need to modify our size and count for depending
- // on how we are trying to display the value...
- switch (format)
- {
- default:
- case eFormatBoolean:
- case eFormatBinary:
- case eFormatComplex:
- case eFormatCString: // NULL terminated C strings
- case eFormatDecimal:
- case eFormatEnum:
- case eFormatHex:
- case eFormatHexUppercase:
- case eFormatFloat:
- case eFormatOctal:
- case eFormatOSType:
- case eFormatUnsigned:
- case eFormatPointer:
- case eFormatVectorOfChar:
- case eFormatVectorOfSInt8:
- case eFormatVectorOfUInt8:
- case eFormatVectorOfSInt16:
- case eFormatVectorOfUInt16:
- case eFormatVectorOfSInt32:
- case eFormatVectorOfUInt32:
- case eFormatVectorOfSInt64:
- case eFormatVectorOfUInt64:
- case eFormatVectorOfFloat32:
- case eFormatVectorOfFloat64:
- case eFormatVectorOfUInt128:
- break;
-
- case eFormatChar:
- case eFormatCharPrintable:
- case eFormatCharArray:
- case eFormatBytes:
- case eFormatBytesWithASCII:
- item_count = byte_size;
- byte_size = 1;
- break;
-
- case eFormatUnicode16:
- item_count = byte_size / 2;
- byte_size = 2;
- break;
-
- case eFormatUnicode32:
- item_count = byte_size / 4;
- byte_size = 4;
- break;
- }
- return data.Dump (s,
- byte_offset,
- format,
- byte_size,
- item_count,
- UINT32_MAX,
- LLDB_INVALID_ADDRESS,
- bitfield_bit_size,
- bitfield_bit_offset,
- exe_scope);
- }
- break;
- }
- }
- return 0;
-}
-
-
-
-void
-ClangASTType::DumpSummary (ExecutionContext *exe_ctx,
- Stream *s,
- const lldb_private::DataExtractor &data,
- lldb::offset_t data_byte_offset,
- size_t data_byte_size)
-{
- uint32_t length = 0;
- if (IsCStringType (length))
- {
- if (exe_ctx)
- {
- Process *process = exe_ctx->GetProcessPtr();
- if (process)
- {
- lldb::offset_t offset = data_byte_offset;
- lldb::addr_t pointer_address = data.GetMaxU64(&offset, data_byte_size);
- std::vector<uint8_t> buf;
- if (length > 0)
- buf.resize (length);
- else
- buf.resize (256);
-
- lldb_private::DataExtractor cstr_data(&buf.front(), buf.size(), process->GetByteOrder(), 4);
- buf.back() = '\0';
- size_t bytes_read;
- size_t total_cstr_len = 0;
- Error error;
- while ((bytes_read = process->ReadMemory (pointer_address, &buf.front(), buf.size(), error)) > 0)
- {
- const size_t len = strlen((const char *)&buf.front());
- if (len == 0)
- break;
- if (total_cstr_len == 0)
- s->PutCString (" \"");
- cstr_data.Dump(s, 0, lldb::eFormatChar, 1, len, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0);
- total_cstr_len += len;
- if (len < buf.size())
- break;
- pointer_address += total_cstr_len;
- }
- if (total_cstr_len > 0)
- s->PutChar ('"');
- }
- }
- }
-}
-
-void
-ClangASTType::DumpTypeDescription () const
-{
- StreamFile s (stdout, false);
- DumpTypeDescription (&s);
- ClangASTMetadata *metadata = ClangASTContext::GetMetadata (m_ast, m_type);
- if (metadata)
- {
- metadata->Dump (&s);
- }
-}
-
-void
-ClangASTType::DumpTypeDescription (Stream *s) const
-{
- if (IsValid())
- {
- clang::QualType qual_type(GetQualType());
-
- llvm::SmallVector<char, 1024> buf;
- llvm::raw_svector_ostream llvm_ostrm (buf);
-
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class)
- {
- case clang::Type::ObjCObject:
- case clang::Type::ObjCInterface:
- {
- GetCompleteType ();
-
- const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
- assert (objc_class_type);
- if (objc_class_type)
- {
- clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
- if (class_interface_decl)
- {
- clang::PrintingPolicy policy = m_ast->getPrintingPolicy();
- class_interface_decl->print(llvm_ostrm, policy, s->GetIndentLevel());
- }
- }
- }
- break;
-
- case clang::Type::Typedef:
- {
- const clang::TypedefType *typedef_type = qual_type->getAs<clang::TypedefType>();
- if (typedef_type)
- {
- const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
- std::string clang_typedef_name (typedef_decl->getQualifiedNameAsString());
- if (!clang_typedef_name.empty())
- {
- s->PutCString ("typedef ");
- s->PutCString (clang_typedef_name.c_str());
- }
- }
- }
- break;
-
- case clang::Type::Elaborated:
- ClangASTType (m_ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()).DumpTypeDescription(s);
- return;
-
- case clang::Type::Paren:
- ClangASTType (m_ast, llvm::cast<clang::ParenType>(qual_type)->desugar()).DumpTypeDescription(s);
- return;
-
- case clang::Type::Record:
- {
- GetCompleteType ();
-
- const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
- const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
-
- if (cxx_record_decl)
- cxx_record_decl->print(llvm_ostrm, m_ast->getPrintingPolicy(), s->GetIndentLevel());
- else
- record_decl->print(llvm_ostrm, m_ast->getPrintingPolicy(), s->GetIndentLevel());
- }
- break;
-
- default:
- {
- const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
- if (tag_type)
- {
- clang::TagDecl *tag_decl = tag_type->getDecl();
- if (tag_decl)
- tag_decl->print(llvm_ostrm, 0);
- }
- else
- {
- std::string clang_type_name(qual_type.getAsString());
- if (!clang_type_name.empty())
- s->PutCString (clang_type_name.c_str());
- }
- }
- }
-
- llvm_ostrm.flush();
- if (buf.size() > 0)
- {
- s->Write (buf.data(), buf.size());
- }
- }
-}
-
-bool
-ClangASTType::GetValueAsScalar (const lldb_private::DataExtractor &data,
- lldb::offset_t data_byte_offset,
- size_t data_byte_size,
- Scalar &value) const
-{
- if (!IsValid())
- return false;
-
- if (IsAggregateType ())
- {
- return false; // Aggregate types don't have scalar values
- }
- else
- {
- uint64_t count = 0;
- lldb::Encoding encoding = GetEncoding (count);
-
- if (encoding == lldb::eEncodingInvalid || count != 1)
- return false;
-
- const uint64_t byte_size = GetByteSize(nullptr);
- lldb::offset_t offset = data_byte_offset;
- switch (encoding)
- {
- case lldb::eEncodingInvalid:
- break;
- case lldb::eEncodingVector:
- break;
- case lldb::eEncodingUint:
- if (byte_size <= sizeof(unsigned long long))
- {
- uint64_t uval64 = data.GetMaxU64 (&offset, byte_size);
- if (byte_size <= sizeof(unsigned int))
- {
- value = (unsigned int)uval64;
- return true;
- }
- else if (byte_size <= sizeof(unsigned long))
- {
- value = (unsigned long)uval64;
- return true;
- }
- else if (byte_size <= sizeof(unsigned long long))
- {
- value = (unsigned long long )uval64;
- return true;
- }
- else
- value.Clear();
- }
- break;
-
- case lldb::eEncodingSint:
- if (byte_size <= sizeof(long long))
- {
- int64_t sval64 = data.GetMaxS64 (&offset, byte_size);
- if (byte_size <= sizeof(int))
- {
- value = (int)sval64;
- return true;
- }
- else if (byte_size <= sizeof(long))
- {
- value = (long)sval64;
- return true;
- }
- else if (byte_size <= sizeof(long long))
- {
- value = (long long )sval64;
- return true;
- }
- else
- value.Clear();
- }
- break;
-
- case lldb::eEncodingIEEE754:
- if (byte_size <= sizeof(long double))
- {
- uint32_t u32;
- uint64_t u64;
- if (byte_size == sizeof(float))
- {
- if (sizeof(float) == sizeof(uint32_t))
- {
- u32 = data.GetU32(&offset);
- value = *((float *)&u32);
- return true;
- }
- else if (sizeof(float) == sizeof(uint64_t))
- {
- u64 = data.GetU64(&offset);
- value = *((float *)&u64);
- return true;
- }
- }
- else
- if (byte_size == sizeof(double))
- {
- if (sizeof(double) == sizeof(uint32_t))
- {
- u32 = data.GetU32(&offset);
- value = *((double *)&u32);
- return true;
- }
- else if (sizeof(double) == sizeof(uint64_t))
- {
- u64 = data.GetU64(&offset);
- value = *((double *)&u64);
- return true;
- }
- }
- else
- if (byte_size == sizeof(long double))
- {
- if (sizeof(long double) == sizeof(uint32_t))
- {
- u32 = data.GetU32(&offset);
- value = *((long double *)&u32);
- return true;
- }
- else if (sizeof(long double) == sizeof(uint64_t))
- {
- u64 = data.GetU64(&offset);
- value = *((long double *)&u64);
- return true;
- }
- }
- }
- break;
- }
- }
- return false;
-}
-
-bool
-ClangASTType::SetValueFromScalar (const Scalar &value, Stream &strm)
-{
- // Aggregate types don't have scalar values
- if (!IsAggregateType ())
- {
- strm.GetFlags().Set(Stream::eBinary);
- uint64_t count = 0;
- lldb::Encoding encoding = GetEncoding (count);
-
- if (encoding == lldb::eEncodingInvalid || count != 1)
- return false;
-
- const uint64_t bit_width = GetBitSize(nullptr);
- // This function doesn't currently handle non-byte aligned assignments
- if ((bit_width % 8) != 0)
- return false;
-
- const uint64_t byte_size = (bit_width + 7 ) / 8;
- switch (encoding)
- {
- case lldb::eEncodingInvalid:
- break;
- case lldb::eEncodingVector:
- break;
- case lldb::eEncodingUint:
- switch (byte_size)
- {
- case 1: strm.PutHex8(value.UInt()); return true;
- case 2: strm.PutHex16(value.UInt()); return true;
- case 4: strm.PutHex32(value.UInt()); return true;
- case 8: strm.PutHex64(value.ULongLong()); return true;
- default:
- break;
- }
- break;
-
- case lldb::eEncodingSint:
- switch (byte_size)
- {
- case 1: strm.PutHex8(value.SInt()); return true;
- case 2: strm.PutHex16(value.SInt()); return true;
- case 4: strm.PutHex32(value.SInt()); return true;
- case 8: strm.PutHex64(value.SLongLong()); return true;
- default:
- break;
- }
- break;
-
- case lldb::eEncodingIEEE754:
- if (byte_size <= sizeof(long double))
- {
- if (byte_size == sizeof(float))
- {
- strm.PutFloat(value.Float());
- return true;
- }
- else
- if (byte_size == sizeof(double))
- {
- strm.PutDouble(value.Double());
- return true;
- }
- else
- if (byte_size == sizeof(long double))
- {
- strm.PutDouble(value.LongDouble());
- return true;
- }
- }
- break;
- }
- }
- return false;
-}
-
-bool
-ClangASTType::ReadFromMemory (lldb_private::ExecutionContext *exe_ctx,
- lldb::addr_t addr,
- AddressType address_type,
- lldb_private::DataExtractor &data)
-{
- if (!IsValid())
- return false;
-
- // Can't convert a file address to anything valid without more
- // context (which Module it came from)
- if (address_type == eAddressTypeFile)
- return false;
-
- if (!GetCompleteType())
- return false;
-
- const uint64_t byte_size = GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
- if (data.GetByteSize() < byte_size)
- {
- lldb::DataBufferSP data_sp(new DataBufferHeap (byte_size, '\0'));
- data.SetData(data_sp);
- }
-
- uint8_t* dst = (uint8_t*)data.PeekData(0, byte_size);
- if (dst != nullptr)
- {
- if (address_type == eAddressTypeHost)
- {
- if (addr == 0)
- return false;
- // The address is an address in this process, so just copy it
- memcpy (dst, (uint8_t*)nullptr + addr, byte_size);
- return true;
- }
- else
- {
- Process *process = nullptr;
- if (exe_ctx)
- process = exe_ctx->GetProcessPtr();
- if (process)
- {
- Error error;
- return process->ReadMemory(addr, dst, byte_size, error) == byte_size;
- }
- }
- }
- return false;
-}
-
-bool
-ClangASTType::WriteToMemory (lldb_private::ExecutionContext *exe_ctx,
- lldb::addr_t addr,
- AddressType address_type,
- StreamString &new_value)
-{
- if (!IsValid())
- return false;
-
- // Can't convert a file address to anything valid without more
- // context (which Module it came from)
- if (address_type == eAddressTypeFile)
- return false;
-
- if (!GetCompleteType())
- return false;
-
- const uint64_t byte_size = GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
-
- if (byte_size > 0)
- {
- if (address_type == eAddressTypeHost)
- {
- // The address is an address in this process, so just copy it
- memcpy ((void *)addr, new_value.GetData(), byte_size);
- return true;
- }
- else
- {
- Process *process = nullptr;
- if (exe_ctx)
- process = exe_ctx->GetProcessPtr();
- if (process)
- {
- Error error;
- return process->WriteMemory(addr, new_value.GetData(), byte_size, error) == byte_size;
- }
- }
- }
- return false;
-}
-
-
-//clang::CXXRecordDecl *
-//ClangASTType::GetAsCXXRecordDecl (lldb::clang_type_t opaque_clang_qual_type)
-//{
-// if (opaque_clang_qual_type)
-// return clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)->getAsCXXRecordDecl();
-// return NULL;
-//}
-
-bool
-lldb_private::operator == (const lldb_private::ClangASTType &lhs, const lldb_private::ClangASTType &rhs)
-{
- return lhs.GetASTContext() == rhs.GetASTContext() && lhs.GetOpaqueQualType() == rhs.GetOpaqueQualType();
-}
-
-
-bool
-lldb_private::operator != (const lldb_private::ClangASTType &lhs, const lldb_private::ClangASTType &rhs)
-{
- return lhs.GetASTContext() != rhs.GetASTContext() || lhs.GetOpaqueQualType() != rhs.GetOpaqueQualType();
-}
-
-
-
diff --git a/source/Symbol/ClangExternalASTSourceCallbacks.cpp b/source/Symbol/ClangExternalASTSourceCallbacks.cpp
index cd6972cce972..6c804f4d969c 100644
--- a/source/Symbol/ClangExternalASTSourceCallbacks.cpp
+++ b/source/Symbol/ClangExternalASTSourceCallbacks.cpp
@@ -41,6 +41,7 @@
#endif
#include "lldb/Core/Log.h"
+#include "clang/AST/Decl.h"
using namespace clang;
using namespace lldb_private;
@@ -160,3 +161,16 @@ ClangExternalASTSourceCallbacks::layoutRecordType(
return false;
}
+void
+ClangExternalASTSourceCallbacks::FindExternalLexicalDecls (const clang::DeclContext *decl_ctx,
+ llvm::function_ref<bool(clang::Decl::Kind)> IsKindWeWant,
+ llvm::SmallVectorImpl<clang::Decl *> &decls)
+{
+ if (m_callback_tag_decl && decl_ctx)
+ {
+ clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(const_cast<clang::DeclContext *>(decl_ctx));
+ if (tag_decl)
+ CompleteType(tag_decl);
+ }
+}
+
diff --git a/source/Symbol/ClangNamespaceDecl.cpp b/source/Symbol/ClangNamespaceDecl.cpp
deleted file mode 100644
index 568b0263f0fe..000000000000
--- a/source/Symbol/ClangNamespaceDecl.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-//===-- ClangNamespaceDecl.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/Symbol/ClangNamespaceDecl.h"
-
-#include "clang/AST/Decl.h"
-
-namespace lldb_private {
-
-std::string
-ClangNamespaceDecl::GetQualifiedName () const
-{
- if (m_namespace_decl)
- return m_namespace_decl->getQualifiedNameAsString();
- return std::string();
-}
-
-
-}
diff --git a/source/Symbol/CompactUnwindInfo.cpp b/source/Symbol/CompactUnwindInfo.cpp
index afef4e480e8e..233ca91ec8d8 100644
--- a/source/Symbol/CompactUnwindInfo.cpp
+++ b/source/Symbol/CompactUnwindInfo.cpp
@@ -297,7 +297,7 @@ CompactUnwindInfo::ScanIndex (const ProcessSP &process_sp)
Host::SystemLog (Host::eSystemLogError,
"error: Invalid offset encountered in compact unwind info, skipping\n");
// don't trust anything from this compact_unwind section if it looks
- // blatently invalid data in the header.
+ // blatantly invalid data in the header.
m_indexes_computed = eLazyBoolNo;
return;
}
@@ -693,7 +693,7 @@ enum x86_64_eh_regnum {
};
// Convert the compact_unwind_info.h register numbering scheme
-// to eRegisterKindGCC (eh_frame) register numbering scheme.
+// to eRegisterKindEHFrame (eh_frame) register numbering scheme.
uint32_t
translate_to_eh_frame_regnum_x86_64 (uint32_t unwind_regno)
{
@@ -722,7 +722,7 @@ CompactUnwindInfo::CreateUnwindPlan_x86_64 (Target &target, FunctionInfo &functi
unwind_plan.SetSourceName ("compact unwind info");
unwind_plan.SetSourcedFromCompiler (eLazyBoolYes);
unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolNo);
- unwind_plan.SetRegisterKind (eRegisterKindGCC);
+ unwind_plan.SetRegisterKind (eRegisterKindEHFrame);
unwind_plan.SetLSDAAddress (function_info.lsda_address);
unwind_plan.SetPersonalityFunctionPtr (function_info.personality_ptr_address);
@@ -976,7 +976,7 @@ enum i386_eh_regnum {
};
// Convert the compact_unwind_info.h register numbering scheme
-// to eRegisterKindGCC (eh_frame) register numbering scheme.
+// to eRegisterKindEHFrame (eh_frame) register numbering scheme.
uint32_t
translate_to_eh_frame_regnum_i386 (uint32_t unwind_regno)
{
@@ -1006,7 +1006,7 @@ CompactUnwindInfo::CreateUnwindPlan_i386 (Target &target, FunctionInfo &function
unwind_plan.SetSourceName ("compact unwind info");
unwind_plan.SetSourcedFromCompiler (eLazyBoolYes);
unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolNo);
- unwind_plan.SetRegisterKind (eRegisterKindGCC);
+ unwind_plan.SetRegisterKind (eRegisterKindEHFrame);
unwind_plan.SetLSDAAddress (function_info.lsda_address);
unwind_plan.SetPersonalityFunctionPtr (function_info.personality_ptr_address);
diff --git a/source/Symbol/CompileUnit.cpp b/source/Symbol/CompileUnit.cpp
index d43ef44a1376..50eda8806375 100644
--- a/source/Symbol/CompileUnit.cpp
+++ b/source/Symbol/CompileUnit.cpp
@@ -9,15 +9,15 @@
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/Language.h"
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/VariableList.h"
+#include "lldb/Target/Language.h"
using namespace lldb;
using namespace lldb_private;
-CompileUnit::CompileUnit (const lldb::ModuleSP &module_sp, void *user_data, const char *pathname, const lldb::user_id_t cu_sym_id, lldb::LanguageType language) :
+CompileUnit::CompileUnit (const lldb::ModuleSP &module_sp, void *user_data, const char *pathname, const lldb::user_id_t cu_sym_id, lldb::LanguageType language, bool is_optimized) :
ModuleChild(module_sp),
FileSpec (pathname, false),
UserID(cu_sym_id),
@@ -27,14 +27,15 @@ CompileUnit::CompileUnit (const lldb::ModuleSP &module_sp, void *user_data, cons
m_functions (),
m_support_files (),
m_line_table_ap (),
- m_variables()
+ m_variables(),
+ m_is_optimized (is_optimized)
{
if (language != eLanguageTypeUnknown)
m_flags.Set(flagsParsedLanguage);
assert(module_sp);
}
-CompileUnit::CompileUnit (const lldb::ModuleSP &module_sp, void *user_data, const FileSpec &fspec, const lldb::user_id_t cu_sym_id, lldb::LanguageType language) :
+CompileUnit::CompileUnit (const lldb::ModuleSP &module_sp, void *user_data, const FileSpec &fspec, const lldb::user_id_t cu_sym_id, lldb::LanguageType language, bool is_optimized) :
ModuleChild(module_sp),
FileSpec (fspec),
UserID(cu_sym_id),
@@ -44,7 +45,8 @@ CompileUnit::CompileUnit (const lldb::ModuleSP &module_sp, void *user_data, cons
m_functions (),
m_support_files (),
m_line_table_ap (),
- m_variables()
+ m_variables(),
+ m_is_optimized (is_optimized)
{
if (language != eLanguageTypeUnknown)
m_flags.Set(flagsParsedLanguage);
@@ -85,7 +87,7 @@ CompileUnit::DumpSymbolContext(Stream *s)
void
CompileUnit::GetDescription(Stream *s, lldb::DescriptionLevel level) const
{
- Language language(m_language);
+ const char* language = Language::GetNameForLanguageType(m_language);
*s << "id = " << (const UserID&)*this << ", file = \"" << (const FileSpec&)*this << "\", language = \"" << language << '"';
}
@@ -99,10 +101,12 @@ CompileUnit::GetDescription(Stream *s, lldb::DescriptionLevel level) const
void
CompileUnit::Dump(Stream *s, bool show_context) const
{
+ const char* language = Language::GetNameForLanguageType(m_language);
+
s->Printf("%p: ", static_cast<const void*>(this));
s->Indent();
*s << "CompileUnit" << static_cast<const UserID&>(*this)
- << ", language = \"" << reinterpret_cast<const Language&>(*this)
+ << ", language = \"" << language
<< "\", file = '" << static_cast<const FileSpec&>(*this) << "'\n";
// m_types.Dump(s);
@@ -264,6 +268,37 @@ CompileUnit::SetLineTable(LineTable* line_table)
m_line_table_ap.reset(line_table);
}
+DebugMacros*
+CompileUnit::GetDebugMacros()
+{
+ if (m_debug_macros_sp.get() == nullptr)
+ {
+ if (m_flags.IsClear(flagsParsedDebugMacros))
+ {
+ m_flags.Set(flagsParsedDebugMacros);
+ SymbolVendor* symbol_vendor = GetModule()->GetSymbolVendor();
+ if (symbol_vendor)
+ {
+ SymbolContext sc;
+ CalculateSymbolContext(&sc);
+ symbol_vendor->ParseCompileUnitDebugMacros(sc);
+ }
+ }
+ }
+
+ return m_debug_macros_sp.get();
+}
+
+void
+CompileUnit::SetDebugMacros(const DebugMacrosSP &debug_macros_sp)
+{
+ if (debug_macros_sp.get() == nullptr)
+ m_flags.Clear(flagsParsedDebugMacros);
+ else
+ m_flags.Set(flagsParsedDebugMacros);
+ m_debug_macros_sp = debug_macros_sp;
+}
+
VariableListSP
CompileUnit::GetVariableList(bool can_create)
{
@@ -430,6 +465,12 @@ CompileUnit::ResolveSymbolContext
return sc_list.GetSize() - prev_size;
}
+bool
+CompileUnit::GetIsOptimized ()
+{
+ return m_is_optimized;
+}
+
void
CompileUnit::SetVariableList(VariableListSP &variables)
{
diff --git a/source/Symbol/CompilerDecl.cpp b/source/Symbol/CompilerDecl.cpp
new file mode 100644
index 000000000000..42e5fb081071
--- /dev/null
+++ b/source/Symbol/CompilerDecl.cpp
@@ -0,0 +1,76 @@
+//===-- CompilerDecl.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/Symbol/CompilerDecl.h"
+#include "lldb/Symbol/CompilerDeclContext.h"
+#include "lldb/Symbol/TypeSystem.h"
+
+using namespace lldb_private;
+
+bool
+CompilerDecl::IsClang () const
+{
+ return IsValid() && m_type_system->getKind() == TypeSystem::eKindClang;
+}
+
+ConstString
+CompilerDecl::GetName() const
+{
+ return m_type_system->DeclGetName(m_opaque_decl);
+}
+
+ConstString
+CompilerDecl::GetMangledName () const
+{
+ return m_type_system->DeclGetMangledName(m_opaque_decl);
+}
+
+lldb::VariableSP
+CompilerDecl::GetAsVariable ()
+{
+ return m_type_system->DeclGetVariable(m_opaque_decl);
+}
+
+CompilerDeclContext
+CompilerDecl::GetDeclContext() const
+{
+ return m_type_system->DeclGetDeclContext(m_opaque_decl);
+}
+
+CompilerType
+CompilerDecl::GetFunctionReturnType() const
+{
+ return m_type_system->DeclGetFunctionReturnType(m_opaque_decl);
+}
+
+size_t
+CompilerDecl::GetNumFunctionArguments() const
+{
+ return m_type_system->DeclGetFunctionNumArguments(m_opaque_decl);
+}
+
+CompilerType
+CompilerDecl::GetFunctionArgumentType (size_t arg_idx) const
+{
+ return m_type_system->DeclGetFunctionArgumentType(m_opaque_decl, arg_idx);
+}
+
+bool
+lldb_private::operator == (const lldb_private::CompilerDecl &lhs, const lldb_private::CompilerDecl &rhs)
+{
+ return lhs.GetTypeSystem() == rhs.GetTypeSystem() && lhs.GetOpaqueDecl() == rhs.GetOpaqueDecl();
+}
+
+
+bool
+lldb_private::operator != (const lldb_private::CompilerDecl &lhs, const lldb_private::CompilerDecl &rhs)
+{
+ return lhs.GetTypeSystem() != rhs.GetTypeSystem() || lhs.GetOpaqueDecl() != rhs.GetOpaqueDecl();
+}
+
diff --git a/source/Symbol/CompilerDeclContext.cpp b/source/Symbol/CompilerDeclContext.cpp
new file mode 100644
index 000000000000..e44cee67284c
--- /dev/null
+++ b/source/Symbol/CompilerDeclContext.cpp
@@ -0,0 +1,75 @@
+//===-- CompilerDeclContext.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/Symbol/CompilerDeclContext.h"
+#include "lldb/Symbol/CompilerDecl.h"
+#include "lldb/Symbol/TypeSystem.h"
+#include <vector>
+
+using namespace lldb_private;
+
+std::vector<CompilerDecl>
+CompilerDeclContext::FindDeclByName (ConstString name)
+{
+ if (IsValid())
+ return m_type_system->DeclContextFindDeclByName(m_opaque_decl_ctx, name);
+ else
+ return std::vector<CompilerDecl>();
+}
+
+bool
+CompilerDeclContext::IsClang () const
+{
+ return IsValid() && m_type_system->getKind() == TypeSystem::eKindClang;
+}
+
+ConstString
+CompilerDeclContext::GetName () const
+{
+ if (IsValid())
+ return m_type_system->DeclContextGetName(m_opaque_decl_ctx);
+ else
+ return ConstString();
+}
+
+bool
+CompilerDeclContext::IsStructUnionOrClass () const
+{
+ if (IsValid())
+ return m_type_system->DeclContextIsStructUnionOrClass(m_opaque_decl_ctx);
+ else
+ return false;
+}
+
+bool
+CompilerDeclContext::IsClassMethod (lldb::LanguageType *language_ptr,
+ bool *is_instance_method_ptr,
+ ConstString *language_object_name_ptr)
+{
+ if (IsValid())
+ return m_type_system->DeclContextIsClassMethod (m_opaque_decl_ctx,
+ language_ptr,
+ is_instance_method_ptr,
+ language_object_name_ptr);
+ else
+ return false;
+}
+
+bool
+lldb_private::operator == (const lldb_private::CompilerDeclContext &lhs, const lldb_private::CompilerDeclContext &rhs)
+{
+ return lhs.GetTypeSystem() == rhs.GetTypeSystem() && lhs.GetOpaqueDeclContext() == rhs.GetOpaqueDeclContext();
+}
+
+
+bool
+lldb_private::operator != (const lldb_private::CompilerDeclContext &lhs, const lldb_private::CompilerDeclContext &rhs)
+{
+ return lhs.GetTypeSystem() != rhs.GetTypeSystem() || lhs.GetOpaqueDeclContext() != rhs.GetOpaqueDeclContext();
+}
diff --git a/source/Symbol/CompilerType.cpp b/source/Symbol/CompilerType.cpp
new file mode 100644
index 000000000000..000a949626c5
--- /dev/null
+++ b/source/Symbol/CompilerType.cpp
@@ -0,0 +1,1320 @@
+//===-- CompilerType.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/Symbol/CompilerType.h"
+
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Scalar.h"
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/StreamFile.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Process.h"
+
+#include <iterator>
+#include <mutex>
+
+using namespace lldb;
+using namespace lldb_private;
+
+CompilerType::CompilerType (TypeSystem *type_system,
+ lldb::opaque_compiler_type_t type) :
+ m_type (type),
+ m_type_system (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())
+ return m_type_system->IsAggregateType(m_type);
+ return false;
+}
+
+bool
+CompilerType::IsAnonymousType () const
+{
+ if (IsValid())
+ return m_type_system->IsAnonymousType(m_type);
+ return false;
+}
+
+bool
+CompilerType::IsArrayType (CompilerType *element_type_ptr,
+ uint64_t *size,
+ bool *is_incomplete) const
+{
+ if (IsValid())
+ return m_type_system->IsArrayType(m_type, element_type_ptr, size, is_incomplete);
+
+ if (element_type_ptr)
+ element_type_ptr->Clear();
+ if (size)
+ *size = 0;
+ if (is_incomplete)
+ *is_incomplete = false;
+ return false;
+}
+
+bool
+CompilerType::IsVectorType (CompilerType *element_type,
+ uint64_t *size) const
+{
+ if (IsValid())
+ return m_type_system->IsVectorType(m_type, element_type, size);
+ return false;
+}
+
+bool
+CompilerType::IsRuntimeGeneratedType () const
+{
+ if (IsValid())
+ return m_type_system->IsRuntimeGeneratedType(m_type);
+ return false;
+}
+
+bool
+CompilerType::IsCharType () const
+{
+ if (IsValid())
+ return m_type_system->IsCharType(m_type);
+ return false;
+}
+
+
+bool
+CompilerType::IsCompleteType () const
+{
+ if (IsValid())
+ return m_type_system->IsCompleteType(m_type);
+ return false;
+}
+
+bool
+CompilerType::IsConst() const
+{
+ if (IsValid())
+ return m_type_system->IsConst(m_type);
+ return false;
+}
+
+bool
+CompilerType::IsCStringType (uint32_t &length) const
+{
+ if (IsValid())
+ return m_type_system->IsCStringType(m_type, length);
+ return false;
+}
+
+bool
+CompilerType::IsFunctionType (bool *is_variadic_ptr) const
+{
+ if (IsValid())
+ return m_type_system->IsFunctionType(m_type, is_variadic_ptr);
+ return false;
+}
+
+// Used to detect "Homogeneous Floating-point Aggregates"
+uint32_t
+CompilerType::IsHomogeneousAggregate (CompilerType* base_type_ptr) const
+{
+ if (IsValid())
+ return m_type_system->IsHomogeneousAggregate(m_type, base_type_ptr);
+ return 0;
+}
+
+size_t
+CompilerType::GetNumberOfFunctionArguments () const
+{
+ if (IsValid())
+ return m_type_system->GetNumberOfFunctionArguments(m_type);
+ return 0;
+}
+
+CompilerType
+CompilerType::GetFunctionArgumentAtIndex (const size_t index) const
+{
+ if (IsValid())
+ return m_type_system->GetFunctionArgumentAtIndex(m_type, index);
+ return CompilerType();
+}
+
+bool
+CompilerType::IsFunctionPointerType () const
+{
+ if (IsValid())
+ return m_type_system->IsFunctionPointerType(m_type);
+ return false;
+
+}
+
+bool
+CompilerType::IsIntegerType (bool &is_signed) const
+{
+ if (IsValid())
+ return m_type_system->IsIntegerType(m_type, is_signed);
+ return false;
+}
+
+bool
+CompilerType::IsPointerType (CompilerType *pointee_type) const
+{
+ if (IsValid())
+ {
+ return m_type_system->IsPointerType(m_type, pointee_type);
+ }
+ if (pointee_type)
+ pointee_type->Clear();
+ return false;
+}
+
+
+bool
+CompilerType::IsPointerOrReferenceType (CompilerType *pointee_type) const
+{
+ if (IsValid())
+ {
+ return m_type_system->IsPointerOrReferenceType(m_type, pointee_type);
+ }
+ if (pointee_type)
+ pointee_type->Clear();
+ return false;
+}
+
+
+bool
+CompilerType::IsReferenceType (CompilerType *pointee_type, bool* is_rvalue) const
+{
+ if (IsValid())
+ {
+ return m_type_system->IsReferenceType(m_type, pointee_type, is_rvalue);
+ }
+ if (pointee_type)
+ pointee_type->Clear();
+ return false;
+}
+
+bool
+CompilerType::ShouldTreatScalarValueAsAddress () const
+{
+ if (IsValid())
+ return m_type_system->ShouldTreatScalarValueAsAddress(m_type);
+ return false;
+}
+
+bool
+CompilerType::IsFloatingPointType (uint32_t &count, bool &is_complex) const
+{
+ if (IsValid())
+ {
+ return m_type_system->IsFloatingPointType(m_type, count, is_complex);
+ }
+ count = 0;
+ is_complex = false;
+ return false;
+}
+
+
+bool
+CompilerType::IsDefined() const
+{
+ if (IsValid())
+ return m_type_system->IsDefined(m_type);
+ return true;
+}
+
+bool
+CompilerType::IsPolymorphicClass () const
+{
+ if (IsValid())
+ {
+ return m_type_system->IsPolymorphicClass(m_type);
+ }
+ return false;
+}
+
+bool
+CompilerType::IsPossibleDynamicType (CompilerType *dynamic_pointee_type,
+ bool check_cplusplus,
+ bool check_objc) const
+{
+ if (IsValid())
+ return m_type_system->IsPossibleDynamicType(m_type, dynamic_pointee_type, check_cplusplus, check_objc);
+ return false;
+}
+
+
+bool
+CompilerType::IsScalarType () const
+{
+ if (!IsValid())
+ return false;
+
+ return m_type_system->IsScalarType(m_type);
+}
+
+bool
+CompilerType::IsTypedefType () const
+{
+ if (!IsValid())
+ return false;
+ return m_type_system->IsTypedefType(m_type);
+}
+
+bool
+CompilerType::IsVoidType () const
+{
+ if (!IsValid())
+ return false;
+ return m_type_system->IsVoidType(m_type);
+}
+
+bool
+CompilerType::IsPointerToScalarType () const
+{
+ if (!IsValid())
+ return false;
+
+ return IsPointerType() && GetPointeeType().IsScalarType();
+}
+
+bool
+CompilerType::IsArrayOfScalarType () const
+{
+ CompilerType element_type;
+ if (IsArrayType(&element_type, nullptr, nullptr))
+ return element_type.IsScalarType();
+ return false;
+}
+
+bool
+CompilerType::IsBeingDefined () const
+{
+ if (!IsValid())
+ return false;
+ return m_type_system->IsBeingDefined(m_type);
+}
+
+//----------------------------------------------------------------------
+// Type Completion
+//----------------------------------------------------------------------
+
+bool
+CompilerType::GetCompleteType () const
+{
+ if (!IsValid())
+ return false;
+ return m_type_system->GetCompleteType(m_type);
+}
+
+//----------------------------------------------------------------------
+// AST related queries
+//----------------------------------------------------------------------
+size_t
+CompilerType::GetPointerByteSize () const
+{
+ if (m_type_system)
+ return m_type_system->GetPointerByteSize();
+ return 0;
+}
+
+ConstString
+CompilerType::GetConstQualifiedTypeName () const
+{
+ return GetConstTypeName ();
+}
+
+ConstString
+CompilerType::GetConstTypeName () const
+{
+ if (IsValid())
+ {
+ ConstString type_name (GetTypeName());
+ if (type_name)
+ return type_name;
+ }
+ return ConstString("<invalid>");
+}
+
+ConstString
+CompilerType::GetTypeName () const
+{
+ if (IsValid())
+ {
+ return m_type_system->GetTypeName(m_type);
+ }
+ return ConstString("<invalid>");
+}
+
+ConstString
+CompilerType::GetDisplayTypeName () const
+{
+ return GetTypeName();
+}
+
+uint32_t
+CompilerType::GetTypeInfo (CompilerType *pointee_or_element_compiler_type) const
+{
+ if (!IsValid())
+ return 0;
+
+ return m_type_system->GetTypeInfo(m_type, pointee_or_element_compiler_type);
+}
+
+
+
+lldb::LanguageType
+CompilerType::GetMinimumLanguage ()
+{
+ if (!IsValid())
+ return lldb::eLanguageTypeC;
+
+ return m_type_system->GetMinimumLanguage(m_type);
+}
+
+lldb::TypeClass
+CompilerType::GetTypeClass () const
+{
+ if (!IsValid())
+ return lldb::eTypeClassInvalid;
+
+ return m_type_system->GetTypeClass(m_type);
+
+}
+
+void
+CompilerType::SetCompilerType (TypeSystem* type_system, lldb::opaque_compiler_type_t type)
+{
+ m_type_system = type_system;
+ m_type = type;
+}
+
+void
+CompilerType::SetCompilerType (clang::ASTContext *ast, clang::QualType qual_type)
+{
+ m_type_system = ClangASTContext::GetASTContext(ast);
+ m_type = qual_type.getAsOpaquePtr();
+}
+
+unsigned
+CompilerType::GetTypeQualifiers() const
+{
+ if (IsValid())
+ return m_type_system->GetTypeQualifiers(m_type);
+ return 0;
+}
+
+//----------------------------------------------------------------------
+// Creating related types
+//----------------------------------------------------------------------
+
+CompilerType
+CompilerType::GetArrayElementType (uint64_t *stride) const
+{
+ if (IsValid())
+ {
+ return m_type_system->GetArrayElementType(m_type, stride);
+
+ }
+ return CompilerType();
+}
+
+CompilerType
+CompilerType::GetCanonicalType () const
+{
+ if (IsValid())
+ return m_type_system->GetCanonicalType(m_type);
+ return CompilerType();
+}
+
+CompilerType
+CompilerType::GetFullyUnqualifiedType () const
+{
+ if (IsValid())
+ return m_type_system->GetFullyUnqualifiedType(m_type);
+ return CompilerType();
+}
+
+
+int
+CompilerType::GetFunctionArgumentCount () const
+{
+ if (IsValid())
+ {
+ return m_type_system->GetFunctionArgumentCount(m_type);
+ }
+ return -1;
+}
+
+CompilerType
+CompilerType::GetFunctionArgumentTypeAtIndex (size_t idx) const
+{
+ if (IsValid())
+ {
+ return m_type_system->GetFunctionArgumentTypeAtIndex(m_type, idx);
+ }
+ return CompilerType();
+}
+
+CompilerType
+CompilerType::GetFunctionReturnType () const
+{
+ if (IsValid())
+ {
+ return m_type_system->GetFunctionReturnType(m_type);
+ }
+ return CompilerType();
+}
+
+size_t
+CompilerType::GetNumMemberFunctions () const
+{
+ if (IsValid())
+ {
+ return m_type_system->GetNumMemberFunctions(m_type);
+ }
+ return 0;
+}
+
+TypeMemberFunctionImpl
+CompilerType::GetMemberFunctionAtIndex (size_t idx)
+{
+ if (IsValid())
+ {
+ return m_type_system->GetMemberFunctionAtIndex(m_type, idx);
+ }
+ return TypeMemberFunctionImpl();
+}
+
+CompilerType
+CompilerType::GetNonReferenceType () const
+{
+ if (IsValid())
+ return m_type_system->GetNonReferenceType(m_type);
+ return CompilerType();
+}
+
+CompilerType
+CompilerType::GetPointeeType () const
+{
+ if (IsValid())
+ {
+ return m_type_system->GetPointeeType(m_type);
+ }
+ return CompilerType();
+}
+
+CompilerType
+CompilerType::GetPointerType () const
+{
+ if (IsValid())
+ {
+ return m_type_system->GetPointerType(m_type);
+ }
+ return CompilerType();
+}
+
+CompilerType
+CompilerType::GetLValueReferenceType () const
+{
+ if (IsValid())
+ return m_type_system->GetLValueReferenceType(m_type);
+ else
+ return CompilerType();
+}
+
+CompilerType
+CompilerType::GetRValueReferenceType () const
+{
+ if (IsValid())
+ return m_type_system->GetRValueReferenceType(m_type);
+ else
+ return CompilerType();
+}
+
+CompilerType
+CompilerType::AddConstModifier () const
+{
+ if (IsValid())
+ return m_type_system->AddConstModifier(m_type);
+ else
+ return CompilerType();
+}
+
+CompilerType
+CompilerType::AddVolatileModifier () const
+{
+ if (IsValid())
+ return m_type_system->AddVolatileModifier(m_type);
+ else
+ return CompilerType();
+}
+
+CompilerType
+CompilerType::AddRestrictModifier () const
+{
+ if (IsValid())
+ return m_type_system->AddRestrictModifier(m_type);
+ else
+ return CompilerType();
+}
+
+CompilerType
+CompilerType::CreateTypedef (const char *name, const CompilerDeclContext &decl_ctx) const
+{
+ if (IsValid())
+ return m_type_system->CreateTypedef(m_type, name, decl_ctx);
+ else
+ return CompilerType();
+}
+
+CompilerType
+CompilerType::GetTypedefedType () const
+{
+ if (IsValid())
+ return m_type_system->GetTypedefedType(m_type);
+ else
+ return CompilerType();
+}
+
+//----------------------------------------------------------------------
+// Create related types using the current type's AST
+//----------------------------------------------------------------------
+
+CompilerType
+CompilerType::GetBasicTypeFromAST (lldb::BasicType basic_type) const
+{
+ if (IsValid())
+ return m_type_system->GetBasicTypeFromAST(basic_type);
+ return CompilerType();
+}
+//----------------------------------------------------------------------
+// Exploring the type
+//----------------------------------------------------------------------
+
+uint64_t
+CompilerType::GetBitSize (ExecutionContextScope *exe_scope) const
+{
+ if (IsValid())
+ {
+ return m_type_system->GetBitSize(m_type, exe_scope);
+ }
+ return 0;
+}
+
+uint64_t
+CompilerType::GetByteSize (ExecutionContextScope *exe_scope) const
+{
+ return (GetBitSize (exe_scope) + 7) / 8;
+}
+
+
+size_t
+CompilerType::GetTypeBitAlign () const
+{
+ if (IsValid())
+ return m_type_system->GetTypeBitAlign(m_type);
+ return 0;
+}
+
+
+lldb::Encoding
+CompilerType::GetEncoding (uint64_t &count) const
+{
+ if (!IsValid())
+ return lldb::eEncodingInvalid;
+
+ return m_type_system->GetEncoding(m_type, count);
+}
+
+lldb::Format
+CompilerType::GetFormat () const
+{
+ if (!IsValid())
+ return lldb::eFormatDefault;
+
+ return m_type_system->GetFormat(m_type);
+}
+
+uint32_t
+CompilerType::GetNumChildren (bool omit_empty_base_classes) const
+{
+ if (!IsValid())
+ return 0;
+ return m_type_system->GetNumChildren(m_type, omit_empty_base_classes);
+}
+
+lldb::BasicType
+CompilerType::GetBasicTypeEnumeration () const
+{
+ if (IsValid())
+ return m_type_system->GetBasicTypeEnumeration(m_type);
+ return eBasicTypeInvalid;
+}
+
+void
+CompilerType::ForEachEnumerator (std::function <bool (const CompilerType &integer_type, const ConstString &name, const llvm::APSInt &value)> const &callback) const
+{
+ if (IsValid())
+ return m_type_system->ForEachEnumerator (m_type, callback);
+}
+
+
+uint32_t
+CompilerType::GetNumFields () const
+{
+ if (!IsValid())
+ return 0;
+ return m_type_system->GetNumFields(m_type);
+}
+
+CompilerType
+CompilerType::GetFieldAtIndex (size_t idx,
+ std::string& name,
+ uint64_t *bit_offset_ptr,
+ uint32_t *bitfield_bit_size_ptr,
+ bool *is_bitfield_ptr) const
+{
+ if (!IsValid())
+ return CompilerType();
+ return m_type_system->GetFieldAtIndex(m_type, idx, name, bit_offset_ptr, bitfield_bit_size_ptr, is_bitfield_ptr);
+}
+
+uint32_t
+CompilerType::GetNumDirectBaseClasses () const
+{
+ if (IsValid())
+ return m_type_system->GetNumDirectBaseClasses (m_type);
+ return 0;
+}
+
+uint32_t
+CompilerType::GetNumVirtualBaseClasses () const
+{
+ if (IsValid())
+ return m_type_system->GetNumVirtualBaseClasses (m_type);
+ return 0;
+}
+
+CompilerType
+CompilerType::GetDirectBaseClassAtIndex (size_t idx, uint32_t *bit_offset_ptr) const
+{
+ if (IsValid())
+ return m_type_system->GetDirectBaseClassAtIndex (m_type, idx, bit_offset_ptr);
+ return CompilerType();
+}
+
+CompilerType
+CompilerType::GetVirtualBaseClassAtIndex (size_t idx, uint32_t *bit_offset_ptr) const
+{
+ if (IsValid())
+ return m_type_system->GetVirtualBaseClassAtIndex (m_type, idx, bit_offset_ptr);
+ return CompilerType();
+}
+
+uint32_t
+CompilerType::GetIndexOfFieldWithName (const char* name,
+ CompilerType* field_compiler_type_ptr,
+ uint64_t *bit_offset_ptr,
+ uint32_t *bitfield_bit_size_ptr,
+ bool *is_bitfield_ptr) const
+{
+ unsigned count = GetNumFields();
+ std::string field_name;
+ for (unsigned index = 0; index < count; index++)
+ {
+ CompilerType field_compiler_type (GetFieldAtIndex(index, field_name, bit_offset_ptr, bitfield_bit_size_ptr, is_bitfield_ptr));
+ if (strcmp(field_name.c_str(), name) == 0)
+ {
+ if (field_compiler_type_ptr)
+ *field_compiler_type_ptr = field_compiler_type;
+ return index;
+ }
+ }
+ return UINT32_MAX;
+}
+
+
+CompilerType
+CompilerType::GetChildCompilerTypeAtIndex (ExecutionContext *exe_ctx,
+ size_t idx,
+ bool transparent_pointers,
+ bool omit_empty_base_classes,
+ bool ignore_array_bounds,
+ std::string& child_name,
+ uint32_t &child_byte_size,
+ int32_t &child_byte_offset,
+ uint32_t &child_bitfield_bit_size,
+ uint32_t &child_bitfield_bit_offset,
+ bool &child_is_base_class,
+ bool &child_is_deref_of_parent,
+ ValueObject *valobj,
+ uint64_t &language_flags) const
+{
+ if (!IsValid())
+ return CompilerType();
+ return m_type_system->GetChildCompilerTypeAtIndex(m_type,
+ exe_ctx,
+ idx,
+ transparent_pointers,
+ omit_empty_base_classes,
+ ignore_array_bounds,
+ child_name,
+ child_byte_size,
+ child_byte_offset,
+ child_bitfield_bit_size,
+ child_bitfield_bit_offset,
+ child_is_base_class,
+ child_is_deref_of_parent,
+ valobj,
+ language_flags);
+}
+
+// Look for a child member (doesn't include base classes, but it does include
+// their members) in the type hierarchy. Returns an index path into "clang_type"
+// on how to reach the appropriate member.
+//
+// class A
+// {
+// public:
+// int m_a;
+// int m_b;
+// };
+//
+// class B
+// {
+// };
+//
+// class C :
+// public B,
+// public A
+// {
+// };
+//
+// If we have a clang type that describes "class C", and we wanted to looked
+// "m_b" in it:
+//
+// With omit_empty_base_classes == false we would get an integer array back with:
+// { 1, 1 }
+// The first index 1 is the child index for "class A" within class C
+// The second index 1 is the child index for "m_b" within class A
+//
+// With omit_empty_base_classes == true we would get an integer array back with:
+// { 0, 1 }
+// The first index 0 is the child index for "class A" within class C (since class B doesn't have any members it doesn't count)
+// The second index 1 is the child index for "m_b" within class A
+
+size_t
+CompilerType::GetIndexOfChildMemberWithName (const char *name,
+ bool omit_empty_base_classes,
+ std::vector<uint32_t>& child_indexes) const
+{
+ if (IsValid() && name && name[0])
+ {
+ return m_type_system->GetIndexOfChildMemberWithName(m_type, name, omit_empty_base_classes, child_indexes);
+ }
+ return 0;
+}
+
+size_t
+CompilerType::GetNumTemplateArguments () const
+{
+ if (IsValid())
+ {
+ return m_type_system->GetNumTemplateArguments(m_type);
+ }
+ return 0;
+}
+
+CompilerType
+CompilerType::GetTemplateArgument (size_t idx,
+ lldb::TemplateArgumentKind &kind) const
+{
+ if (IsValid())
+ {
+ return m_type_system->GetTemplateArgument(m_type, idx, kind);
+ }
+ return CompilerType();
+}
+
+CompilerType
+CompilerType::GetTypeForFormatters () const
+{
+ if (IsValid())
+ return m_type_system->GetTypeForFormatters(m_type);
+ return CompilerType();
+}
+
+LazyBool
+CompilerType::ShouldPrintAsOneLiner (ValueObject* valobj) const
+{
+ if (IsValid())
+ return m_type_system->ShouldPrintAsOneLiner(m_type, valobj);
+ return eLazyBoolCalculate;
+}
+
+bool
+CompilerType::IsMeaninglessWithoutDynamicResolution () const
+{
+ if (IsValid())
+ return m_type_system->IsMeaninglessWithoutDynamicResolution(m_type);
+ return false;
+}
+
+// Get the index of the child of "clang_type" whose name matches. This function
+// doesn't descend into the children, but only looks one level deep and name
+// matches can include base class names.
+
+uint32_t
+CompilerType::GetIndexOfChildWithName (const char *name, bool omit_empty_base_classes) const
+{
+ if (IsValid() && name && name[0])
+ {
+ return m_type_system->GetIndexOfChildWithName(m_type, name, omit_empty_base_classes);
+ }
+ return UINT32_MAX;
+}
+
+size_t
+CompilerType::ConvertStringToFloatValue (const char *s, uint8_t *dst, size_t dst_size) const
+{
+ if (IsValid())
+ return m_type_system->ConvertStringToFloatValue(m_type, s, dst, dst_size);
+ return 0;
+}
+
+
+
+//----------------------------------------------------------------------
+// Dumping types
+//----------------------------------------------------------------------
+#define DEPTH_INCREMENT 2
+
+void
+CompilerType::DumpValue (ExecutionContext *exe_ctx,
+ Stream *s,
+ lldb::Format format,
+ const lldb_private::DataExtractor &data,
+ lldb::offset_t data_byte_offset,
+ size_t data_byte_size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset,
+ bool show_types,
+ bool show_summary,
+ bool verbose,
+ uint32_t depth)
+{
+ if (!IsValid())
+ return;
+ m_type_system->DumpValue(m_type, exe_ctx, s, format, data, data_byte_offset, data_byte_size, bitfield_bit_size, bitfield_bit_offset, show_types, show_summary, verbose, depth);
+}
+
+
+
+
+bool
+CompilerType::DumpTypeValue (Stream *s,
+ lldb::Format format,
+ const lldb_private::DataExtractor &data,
+ lldb::offset_t byte_offset,
+ size_t byte_size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset,
+ ExecutionContextScope *exe_scope)
+{
+ if (!IsValid())
+ return false;
+ return m_type_system->DumpTypeValue(m_type, s, format, data, byte_offset, byte_size, bitfield_bit_size, bitfield_bit_offset, exe_scope);
+}
+
+
+
+void
+CompilerType::DumpSummary (ExecutionContext *exe_ctx,
+ Stream *s,
+ const lldb_private::DataExtractor &data,
+ lldb::offset_t data_byte_offset,
+ size_t data_byte_size)
+{
+ if (IsValid())
+ m_type_system->DumpSummary(m_type, exe_ctx, s, data, data_byte_offset, data_byte_size);
+}
+
+void
+CompilerType::DumpTypeDescription () const
+{
+ if (IsValid())
+ m_type_system->DumpTypeDescription(m_type);
+}
+
+void
+CompilerType::DumpTypeDescription (Stream *s) const
+{
+ if (IsValid())
+ {
+ m_type_system->DumpTypeDescription(m_type, s);
+ }
+}
+
+bool
+CompilerType::GetValueAsScalar (const lldb_private::DataExtractor &data,
+ lldb::offset_t data_byte_offset,
+ size_t data_byte_size,
+ Scalar &value) const
+{
+ if (!IsValid())
+ return false;
+
+ if (IsAggregateType ())
+ {
+ return false; // Aggregate types don't have scalar values
+ }
+ else
+ {
+ uint64_t count = 0;
+ lldb::Encoding encoding = GetEncoding (count);
+
+ if (encoding == lldb::eEncodingInvalid || count != 1)
+ return false;
+
+ const uint64_t byte_size = GetByteSize(nullptr);
+ lldb::offset_t offset = data_byte_offset;
+ switch (encoding)
+ {
+ case lldb::eEncodingInvalid:
+ break;
+ case lldb::eEncodingVector:
+ break;
+ case lldb::eEncodingUint:
+ if (byte_size <= sizeof(unsigned long long))
+ {
+ uint64_t uval64 = data.GetMaxU64 (&offset, byte_size);
+ if (byte_size <= sizeof(unsigned int))
+ {
+ value = (unsigned int)uval64;
+ return true;
+ }
+ else if (byte_size <= sizeof(unsigned long))
+ {
+ value = (unsigned long)uval64;
+ return true;
+ }
+ else if (byte_size <= sizeof(unsigned long long))
+ {
+ value = (unsigned long long )uval64;
+ return true;
+ }
+ else
+ value.Clear();
+ }
+ break;
+
+ case lldb::eEncodingSint:
+ if (byte_size <= sizeof(long long))
+ {
+ int64_t sval64 = data.GetMaxS64 (&offset, byte_size);
+ if (byte_size <= sizeof(int))
+ {
+ value = (int)sval64;
+ return true;
+ }
+ else if (byte_size <= sizeof(long))
+ {
+ value = (long)sval64;
+ return true;
+ }
+ else if (byte_size <= sizeof(long long))
+ {
+ value = (long long )sval64;
+ return true;
+ }
+ else
+ value.Clear();
+ }
+ break;
+
+ case lldb::eEncodingIEEE754:
+ if (byte_size <= sizeof(long double))
+ {
+ uint32_t u32;
+ uint64_t u64;
+ if (byte_size == sizeof(float))
+ {
+ if (sizeof(float) == sizeof(uint32_t))
+ {
+ u32 = data.GetU32(&offset);
+ value = *((float *)&u32);
+ return true;
+ }
+ else if (sizeof(float) == sizeof(uint64_t))
+ {
+ u64 = data.GetU64(&offset);
+ value = *((float *)&u64);
+ return true;
+ }
+ }
+ else
+ if (byte_size == sizeof(double))
+ {
+ if (sizeof(double) == sizeof(uint32_t))
+ {
+ u32 = data.GetU32(&offset);
+ value = *((double *)&u32);
+ return true;
+ }
+ else if (sizeof(double) == sizeof(uint64_t))
+ {
+ u64 = data.GetU64(&offset);
+ value = *((double *)&u64);
+ return true;
+ }
+ }
+ else
+ if (byte_size == sizeof(long double))
+ {
+ if (sizeof(long double) == sizeof(uint32_t))
+ {
+ u32 = data.GetU32(&offset);
+ value = *((long double *)&u32);
+ return true;
+ }
+ else if (sizeof(long double) == sizeof(uint64_t))
+ {
+ u64 = data.GetU64(&offset);
+ value = *((long double *)&u64);
+ return true;
+ }
+ }
+ }
+ break;
+ }
+ }
+ return false;
+}
+
+bool
+CompilerType::SetValueFromScalar (const Scalar &value, Stream &strm)
+{
+ if (!IsValid())
+ return false;
+
+ // Aggregate types don't have scalar values
+ if (!IsAggregateType ())
+ {
+ strm.GetFlags().Set(Stream::eBinary);
+ uint64_t count = 0;
+ lldb::Encoding encoding = GetEncoding (count);
+
+ if (encoding == lldb::eEncodingInvalid || count != 1)
+ return false;
+
+ const uint64_t bit_width = GetBitSize(nullptr);
+ // This function doesn't currently handle non-byte aligned assignments
+ if ((bit_width % 8) != 0)
+ return false;
+
+ const uint64_t byte_size = (bit_width + 7 ) / 8;
+ switch (encoding)
+ {
+ case lldb::eEncodingInvalid:
+ break;
+ case lldb::eEncodingVector:
+ break;
+ case lldb::eEncodingUint:
+ switch (byte_size)
+ {
+ case 1: strm.PutHex8(value.UInt()); return true;
+ case 2: strm.PutHex16(value.UInt()); return true;
+ case 4: strm.PutHex32(value.UInt()); return true;
+ case 8: strm.PutHex64(value.ULongLong()); return true;
+ default:
+ break;
+ }
+ break;
+
+ case lldb::eEncodingSint:
+ switch (byte_size)
+ {
+ case 1: strm.PutHex8(value.SInt()); return true;
+ case 2: strm.PutHex16(value.SInt()); return true;
+ case 4: strm.PutHex32(value.SInt()); return true;
+ case 8: strm.PutHex64(value.SLongLong()); return true;
+ default:
+ break;
+ }
+ break;
+
+ case lldb::eEncodingIEEE754:
+ if (byte_size <= sizeof(long double))
+ {
+ if (byte_size == sizeof(float))
+ {
+ strm.PutFloat(value.Float());
+ return true;
+ }
+ else
+ if (byte_size == sizeof(double))
+ {
+ strm.PutDouble(value.Double());
+ return true;
+ }
+ else
+ if (byte_size == sizeof(long double))
+ {
+ strm.PutDouble(value.LongDouble());
+ return true;
+ }
+ }
+ break;
+ }
+ }
+ return false;
+}
+
+bool
+CompilerType::ReadFromMemory (lldb_private::ExecutionContext *exe_ctx,
+ lldb::addr_t addr,
+ AddressType address_type,
+ lldb_private::DataExtractor &data)
+{
+ if (!IsValid())
+ return false;
+
+ // Can't convert a file address to anything valid without more
+ // context (which Module it came from)
+ if (address_type == eAddressTypeFile)
+ return false;
+
+ if (!GetCompleteType())
+ return false;
+
+ const uint64_t byte_size = GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
+ if (data.GetByteSize() < byte_size)
+ {
+ lldb::DataBufferSP data_sp(new DataBufferHeap (byte_size, '\0'));
+ data.SetData(data_sp);
+ }
+
+ uint8_t* dst = const_cast<uint8_t*>(data.PeekData(0, byte_size));
+ if (dst != nullptr)
+ {
+ if (address_type == eAddressTypeHost)
+ {
+ if (addr == 0)
+ return false;
+ // The address is an address in this process, so just copy it
+ memcpy (dst, (uint8_t*)nullptr + addr, byte_size);
+ return true;
+ }
+ else
+ {
+ Process *process = nullptr;
+ if (exe_ctx)
+ process = exe_ctx->GetProcessPtr();
+ if (process)
+ {
+ Error error;
+ return process->ReadMemory(addr, dst, byte_size, error) == byte_size;
+ }
+ }
+ }
+ return false;
+}
+
+bool
+CompilerType::WriteToMemory (lldb_private::ExecutionContext *exe_ctx,
+ lldb::addr_t addr,
+ AddressType address_type,
+ StreamString &new_value)
+{
+ if (!IsValid())
+ return false;
+
+ // Can't convert a file address to anything valid without more
+ // context (which Module it came from)
+ if (address_type == eAddressTypeFile)
+ return false;
+
+ if (!GetCompleteType())
+ return false;
+
+ const uint64_t byte_size = GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
+
+ if (byte_size > 0)
+ {
+ if (address_type == eAddressTypeHost)
+ {
+ // The address is an address in this process, so just copy it
+ memcpy ((void *)addr, new_value.GetData(), byte_size);
+ return true;
+ }
+ else
+ {
+ Process *process = nullptr;
+ if (exe_ctx)
+ process = exe_ctx->GetProcessPtr();
+ if (process)
+ {
+ Error error;
+ return process->WriteMemory(addr, new_value.GetData(), byte_size, error) == byte_size;
+ }
+ }
+ }
+ return false;
+}
+
+//clang::CXXRecordDecl *
+//CompilerType::GetAsCXXRecordDecl (lldb::opaque_compiler_type_t opaque_compiler_qual_type)
+//{
+// if (opaque_compiler_qual_type)
+// return clang::QualType::getFromOpaquePtr(opaque_compiler_qual_type)->getAsCXXRecordDecl();
+// return NULL;
+//}
+
+bool
+lldb_private::operator == (const lldb_private::CompilerType &lhs, const lldb_private::CompilerType &rhs)
+{
+ return lhs.GetTypeSystem() == rhs.GetTypeSystem() && lhs.GetOpaqueQualType() == rhs.GetOpaqueQualType();
+}
+
+
+bool
+lldb_private::operator != (const lldb_private::CompilerType &lhs, const lldb_private::CompilerType &rhs)
+{
+ return lhs.GetTypeSystem() != rhs.GetTypeSystem() || lhs.GetOpaqueQualType() != rhs.GetOpaqueQualType();
+}
+
+
+
diff --git a/source/Symbol/DWARFCallFrameInfo.cpp b/source/Symbol/DWARFCallFrameInfo.cpp
index a5f9017918dd..c357a5001690 100644
--- a/source/Symbol/DWARFCallFrameInfo.cpp
+++ b/source/Symbol/DWARFCallFrameInfo.cpp
@@ -342,7 +342,7 @@ DWARFCallFrameInfo::GetFDEIndex ()
"error: Invalid fde/cie next entry offset of 0x%x found in cie/fde at 0x%x\n",
next_entry,
current_entry);
- // Don't trust anything in this eh_frame section if we find blatently
+ // Don't trust anything in this eh_frame section if we find blatantly
// invalid data.
m_fde_index.Clear();
m_fde_index_initialized = true;
@@ -354,7 +354,7 @@ DWARFCallFrameInfo::GetFDEIndex ()
"error: Invalid cie offset of 0x%x found in cie/fde at 0x%x\n",
cie_offset,
current_entry);
- // Don't trust anything in this eh_frame section if we find blatently
+ // Don't trust anything in this eh_frame section if we find blatantly
// invalid data.
m_fde_index.Clear();
m_fde_index_initialized = true;
@@ -535,7 +535,7 @@ DWARFCallFrameInfo::FDEToUnwindPlan (dw_offset_t dwarf_offset, Address startaddr
// We only keep enough register locations around to
// unwind what is in our thread, and these are organized
// by the register index in that state, so we need to convert our
- // GCC register number from the EH frame info, to a register index
+ // eh_frame register number from the EH frame info, to a register index
if (unwind_plan.IsValidRowIndex(0) && unwind_plan.GetRowAtIndex(0)->GetRegisterInfo(reg_num, reg_location))
row->SetRegisterInfo (reg_num, reg_location);
diff --git a/source/Symbol/DebugMacros.cpp b/source/Symbol/DebugMacros.cpp
new file mode 100644
index 000000000000..88a28ba75e69
--- /dev/null
+++ b/source/Symbol/DebugMacros.cpp
@@ -0,0 +1,65 @@
+//===-- DebugMacros.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/Symbol/DebugMacros.h"
+
+#include "lldb/Symbol/CompileUnit.h"
+
+using namespace lldb_private;
+
+DebugMacroEntry::DebugMacroEntry(EntryType type,
+ uint32_t line,
+ uint32_t debug_line_file_idx,
+ const char *str)
+ : m_type(type),
+ m_line(line),
+ m_debug_line_file_idx(debug_line_file_idx),
+ m_str(str)
+{ }
+
+DebugMacroEntry::DebugMacroEntry(EntryType type,
+ const DebugMacrosSP &debug_macros_sp)
+ : m_type(type), m_line(0), m_debug_line_file_idx(0), m_debug_macros_sp(debug_macros_sp)
+{ }
+
+const FileSpec&
+DebugMacroEntry::GetFileSpec(CompileUnit *comp_unit) const
+{
+ return comp_unit->GetSupportFiles().GetFileSpecAtIndex(m_debug_line_file_idx);
+}
+
+DebugMacroEntry
+DebugMacroEntry::CreateDefineEntry(uint32_t line, const char *str)
+{
+ return DebugMacroEntry(DebugMacroEntry::DEFINE, line, 0, str);
+}
+
+DebugMacroEntry
+DebugMacroEntry::CreateUndefEntry(uint32_t line, const char *str)
+{
+ return DebugMacroEntry(DebugMacroEntry::UNDEF, line, 0, str);
+}
+
+DebugMacroEntry
+DebugMacroEntry::CreateStartFileEntry(uint32_t line, uint32_t debug_line_file_idx)
+{
+ return DebugMacroEntry(DebugMacroEntry::START_FILE, line, debug_line_file_idx, nullptr);
+}
+
+DebugMacroEntry
+DebugMacroEntry::CreateEndFileEntry()
+{
+ return DebugMacroEntry(DebugMacroEntry::END_FILE, 0, 0, nullptr);
+}
+
+DebugMacroEntry
+DebugMacroEntry::CreateIndirectEntry(const DebugMacrosSP &debug_macros_sp)
+{
+ return DebugMacroEntry(DebugMacroEntry::INDIRECT, debug_macros_sp);
+}
diff --git a/source/Symbol/FuncUnwinders.cpp b/source/Symbol/FuncUnwinders.cpp
index 000df722bb9e..4c96b1a2bb1b 100644
--- a/source/Symbol/FuncUnwinders.cpp
+++ b/source/Symbol/FuncUnwinders.cpp
@@ -10,6 +10,7 @@
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/Address.h"
#include "lldb/Symbol/FuncUnwinders.h"
+#include "lldb/Symbol/ArmUnwindInfo.h"
#include "lldb/Symbol/DWARFCallFrameInfo.h"
#include "lldb/Symbol/CompactUnwindInfo.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -37,6 +38,7 @@ FuncUnwinders::FuncUnwinders (UnwindTable& unwind_table, AddressRange range) :
m_unwind_plan_eh_frame_sp (),
m_unwind_plan_eh_frame_augmented_sp (),
m_unwind_plan_compact_unwind (),
+ m_unwind_plan_arm_unwind_sp (),
m_unwind_plan_fast_sp (),
m_unwind_plan_arch_default_sp (),
m_unwind_plan_arch_default_at_func_entry_sp (),
@@ -44,6 +46,7 @@ FuncUnwinders::FuncUnwinders (UnwindTable& unwind_table, AddressRange range) :
m_tried_unwind_plan_eh_frame (false),
m_tried_unwind_plan_eh_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_arch_default (false),
m_tried_unwind_arch_default_at_func_entry (false),
@@ -65,12 +68,18 @@ FuncUnwinders::GetUnwindPlanAtCallSite (Target &target, int current_offset)
Mutex::Locker locker (m_mutex);
UnwindPlanSP unwind_plan_sp = GetEHFrameUnwindPlan (target, current_offset);
- if (unwind_plan_sp.get() == nullptr)
- {
- unwind_plan_sp = GetCompactUnwindUnwindPlan (target, current_offset);
- }
+ if (unwind_plan_sp)
+ return unwind_plan_sp;
+
+ unwind_plan_sp = GetCompactUnwindUnwindPlan (target, current_offset);
+ if (unwind_plan_sp)
+ return unwind_plan_sp;
+
+ unwind_plan_sp = GetArmUnwindUnwindPlan (target, current_offset);
+ if (unwind_plan_sp)
+ return unwind_plan_sp;
- return unwind_plan_sp;
+ return nullptr;
}
UnwindPlanSP
@@ -127,6 +136,30 @@ FuncUnwinders::GetEHFrameUnwindPlan (Target &target, int current_offset)
}
UnwindPlanSP
+FuncUnwinders::GetArmUnwindUnwindPlan (Target &target, int current_offset)
+{
+ if (m_unwind_plan_arm_unwind_sp.get() || m_tried_unwind_plan_arm_unwind)
+ return m_unwind_plan_arm_unwind_sp;
+
+ Mutex::Locker lock (m_mutex);
+ 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));
+ if (!arm_unwind_info->GetUnwindPlan (target, current_pc, *m_unwind_plan_arm_unwind_sp))
+ m_unwind_plan_arm_unwind_sp.reset();
+ }
+ }
+ return m_unwind_plan_arm_unwind_sp;
+}
+
+UnwindPlanSP
FuncUnwinders::GetEHFrameAugmentedUnwindPlan (Target &target, Thread &thread, int current_offset)
{
if (m_unwind_plan_eh_frame_augmented_sp.get() || m_tried_unwind_plan_eh_frame_augmented)
diff --git a/source/Symbol/Function.cpp b/source/Symbol/Function.cpp
index 77448d4f2a22..33cc0c4e264c 100644
--- a/source/Symbol/Function.cpp
+++ b/source/Symbol/Function.cpp
@@ -12,11 +12,12 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
#include "lldb/Host/Host.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Target/Language.h"
#include "llvm/Support/Casting.h"
using namespace lldb;
@@ -217,7 +218,7 @@ Function::Function
m_mangled (mangled),
m_block (func_uid),
m_range (range),
- m_frame_base (),
+ m_frame_base (nullptr),
m_flags (),
m_prologue_byte_size (0)
{
@@ -241,7 +242,7 @@ Function::Function
m_mangled (ConstString(mangled), true),
m_block (func_uid),
m_range (range),
- m_frame_base (),
+ m_frame_base (nullptr),
m_flags (),
m_prologue_byte_size (0)
{
@@ -466,6 +467,32 @@ Function::MemorySize () const
return mem_size;
}
+bool
+Function::GetIsOptimized ()
+{
+ bool result = false;
+
+ // Currently optimization is only indicted by the
+ // vendor extension DW_AT_APPLE_optimized which
+ // is set on a compile unit level.
+ if (m_comp_unit)
+ {
+ result = m_comp_unit->GetIsOptimized();
+ }
+ return result;
+}
+
+bool
+Function::IsTopLevelFunction ()
+{
+ bool result = false;
+
+ if (Language* language = Language::FindPlugin(GetLanguage()))
+ result = language->IsTopLevelFunction(*this);
+
+ return result;
+}
+
ConstString
Function::GetDisplayName () const
{
@@ -474,27 +501,24 @@ Function::GetDisplayName () const
return m_mangled.GetDisplayDemangledName(GetLanguage());
}
-clang::DeclContext *
-Function::GetClangDeclContext()
+CompilerDeclContext
+Function::GetDeclContext()
{
- SymbolContext sc;
-
- CalculateSymbolContext (&sc);
-
- if (!sc.module_sp)
- return nullptr;
-
- SymbolVendor *sym_vendor = sc.module_sp->GetSymbolVendor();
-
- if (!sym_vendor)
- return nullptr;
-
- SymbolFile *sym_file = sym_vendor->GetSymbolFile();
-
- if (!sym_file)
- return nullptr;
-
- return sym_file->GetClangDeclContextForTypeUID (sc, m_uid);
+ ModuleSP module_sp = CalculateSymbolContextModule ();
+
+ if (module_sp)
+ {
+ SymbolVendor *sym_vendor = module_sp->GetSymbolVendor();
+
+ if (sym_vendor)
+ {
+ SymbolFile *sym_file = sym_vendor->GetSymbolFile();
+
+ if (sym_file)
+ return sym_file->GetDeclContextForUID (GetID());
+ }
+ }
+ return CompilerDeclContext();
}
Type*
@@ -530,13 +554,13 @@ Function::GetType() const
return m_type;
}
-ClangASTType
-Function::GetClangType()
+CompilerType
+Function::GetCompilerType()
{
Type *function_type = GetType();
if (function_type)
- return function_type->GetClangFullType();
- return ClangASTType();
+ return function_type->GetFullCompilerType ();
+ return CompilerType();
}
uint32_t
diff --git a/source/Symbol/GoASTContext.cpp b/source/Symbol/GoASTContext.cpp
new file mode 100644
index 000000000000..4ba51f7580d7
--- /dev/null
+++ b/source/Symbol/GoASTContext.cpp
@@ -0,0 +1,1519 @@
+//===-- GoASTContext.cpp ----------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <mutex>
+#include <utility>
+#include <vector>
+
+#include "lldb/Core/Module.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/UniqueCStringMap.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/StringPrinter.h"
+#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/SymbolFile.h"
+#include "lldb/Symbol/GoASTContext.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Target.h"
+
+#include "Plugins/ExpressionParser/Go/GoUserExpression.h"
+#include "Plugins/SymbolFile/DWARF/DWARFASTParserGo.h"
+
+using namespace lldb;
+
+namespace lldb_private
+{
+class GoArray;
+class GoFunction;
+class GoStruct;
+
+class GoType
+{
+ public:
+ enum
+ {
+ KIND_BOOL = 1,
+ KIND_INT = 2,
+ KIND_INT8 = 3,
+ KIND_INT16 = 4,
+ KIND_INT32 = 5,
+ KIND_INT64 = 6,
+ KIND_UINT = 7,
+ KIND_UINT8 = 8,
+ KIND_UINT16 = 9,
+ KIND_UINT32 = 10,
+ KIND_UINT64 = 11,
+ KIND_UINTPTR = 12,
+ KIND_FLOAT32 = 13,
+ KIND_FLOAT64 = 14,
+ KIND_COMPLEX64 = 15,
+ KIND_COMPLEX128 = 16,
+ KIND_ARRAY = 17,
+ KIND_CHAN = 18,
+ KIND_FUNC = 19,
+ KIND_INTERFACE = 20,
+ KIND_MAP = 21,
+ KIND_PTR = 22,
+ KIND_SLICE = 23,
+ KIND_STRING = 24,
+ KIND_STRUCT = 25,
+ KIND_UNSAFEPOINTER = 26,
+ KIND_LLDB_VOID, // Extension for LLDB, not used by go runtime.
+ KIND_MASK = (1 << 5) - 1,
+ KIND_DIRECT_IFACE = 1 << 5
+ };
+ GoType(int kind, const ConstString &name)
+ : m_kind(kind & KIND_MASK)
+ , m_name(name)
+ {
+ if (m_kind == KIND_FUNC)
+ m_kind = KIND_FUNC;
+ }
+ virtual ~GoType() {}
+
+ int
+ GetGoKind() const
+ {
+ return m_kind;
+ }
+ const ConstString &
+ GetName() const
+ {
+ return m_name;
+ }
+ virtual CompilerType
+ GetElementType() const
+ {
+ return CompilerType();
+ }
+
+ bool
+ IsTypedef() const
+ {
+ switch (m_kind)
+ {
+ case KIND_CHAN:
+ case KIND_MAP:
+ case KIND_INTERFACE:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ GoArray *GetArray();
+ GoFunction *GetFunction();
+ GoStruct *GetStruct();
+
+ private:
+ int m_kind;
+ ConstString m_name;
+ GoType(const GoType &) = delete;
+ const GoType &operator=(const GoType &) = delete;
+};
+
+class GoElem : public GoType
+{
+ public:
+ GoElem(int kind, const ConstString &name, const CompilerType &elem)
+ : GoType(kind, name)
+ , m_elem(elem)
+ {
+ }
+ virtual CompilerType
+ GetElementType() const
+ {
+ return m_elem;
+ }
+
+ private:
+ // TODO: should we store this differently?
+ CompilerType m_elem;
+
+ GoElem(const GoElem &) = delete;
+ const GoElem &operator=(const GoElem &) = delete;
+};
+
+class GoArray : public GoElem
+{
+ public:
+ GoArray(const ConstString &name, uint64_t length, const CompilerType &elem)
+ : GoElem(KIND_ARRAY, name, elem)
+ , m_length(length)
+ {
+ }
+
+ uint64_t
+ GetLength() const
+ {
+ return m_length;
+ }
+
+ private:
+ uint64_t m_length;
+ GoArray(const GoArray &) = delete;
+ const GoArray &operator=(const GoArray &) = delete;
+};
+
+class GoFunction : public GoType
+{
+ public:
+ GoFunction(const ConstString &name, bool is_variadic)
+ : GoType(KIND_FUNC, name)
+ , m_is_variadic(is_variadic)
+ {
+ }
+
+ bool
+ IsVariadic() const
+ {
+ return m_is_variadic;
+ }
+
+ private:
+ bool m_is_variadic;
+ GoFunction(const GoFunction &) = delete;
+ const GoFunction &operator=(const GoFunction &) = delete;
+};
+
+class GoStruct : public GoType
+{
+ public:
+ struct Field
+ {
+ Field(const ConstString &name, const CompilerType &type, uint64_t offset)
+ : m_name(name)
+ , m_type(type)
+ , m_byte_offset(offset)
+ {
+ }
+ ConstString m_name;
+ CompilerType m_type;
+ uint64_t m_byte_offset;
+ };
+
+ GoStruct(int kind, const ConstString &name, int64_t byte_size)
+ : GoType(kind == 0 ? KIND_STRUCT : kind, name), m_is_complete(false), m_byte_size(byte_size)
+ {
+ }
+
+ uint32_t
+ GetNumFields() const
+ {
+ return m_fields.size();
+ }
+
+ const Field *
+ GetField(uint32_t i) const
+ {
+ if (i < m_fields.size())
+ return &m_fields[i];
+ return nullptr;
+ }
+
+ void
+ AddField(const ConstString &name, const CompilerType &type, uint64_t offset)
+ {
+ m_fields.push_back(Field(name, type, offset));
+ }
+
+ bool
+ IsComplete() const
+ {
+ return m_is_complete;
+ }
+
+ void
+ SetComplete()
+ {
+ m_is_complete = true;
+ }
+
+ int64_t
+ GetByteSize() const
+ {
+ return m_byte_size;
+ }
+
+ private:
+ bool m_is_complete;
+ int64_t m_byte_size;
+ std::vector<Field> m_fields;
+
+ GoStruct(const GoStruct &) = delete;
+ const GoStruct &operator=(const GoStruct &) = delete;
+};
+
+GoArray *
+GoType::GetArray()
+{
+ if (m_kind == KIND_ARRAY)
+ {
+ return static_cast<GoArray *>(this);
+ }
+ return nullptr;
+}
+
+GoFunction *
+GoType::GetFunction()
+{
+ if (m_kind == KIND_FUNC)
+ {
+ return static_cast<GoFunction *>(this);
+ }
+ return nullptr;
+}
+
+GoStruct *
+GoType::GetStruct()
+{
+ switch (m_kind)
+ {
+ case KIND_STRING:
+ case KIND_STRUCT:
+ case KIND_SLICE:
+ return static_cast<GoStruct *>(this);
+ }
+ return nullptr;
+}
+} // namespace lldb_private
+using namespace lldb_private;
+
+GoASTContext::GoASTContext()
+ : TypeSystem(eKindGo)
+ , m_pointer_byte_size(0)
+ , m_int_byte_size(0)
+ , m_types(new TypeMap)
+{
+}
+GoASTContext::~GoASTContext()
+{
+}
+
+//------------------------------------------------------------------
+// PluginInterface functions
+//------------------------------------------------------------------
+
+ConstString
+GoASTContext::GetPluginNameStatic()
+{
+ return ConstString("go");
+}
+
+ConstString
+GoASTContext::GetPluginName()
+{
+ return GoASTContext::GetPluginNameStatic();
+}
+
+uint32_t
+GoASTContext::GetPluginVersion()
+{
+ return 1;
+}
+
+lldb::TypeSystemSP
+GoASTContext::CreateInstance (lldb::LanguageType language, Module *module, Target *target)
+{
+ if (language == eLanguageTypeGo)
+ {
+ ArchSpec arch;
+ std::shared_ptr<GoASTContext> go_ast_sp;
+ if (module)
+ {
+ arch = module->GetArchitecture();
+ go_ast_sp = std::shared_ptr<GoASTContext>(new GoASTContext);
+ }
+ else if (target)
+ {
+ arch = target->GetArchitecture();
+ go_ast_sp = std::shared_ptr<GoASTContextForExpr>(new GoASTContextForExpr(target->shared_from_this()));
+ }
+
+ if (arch.IsValid())
+ {
+ go_ast_sp->SetAddressByteSize(arch.GetAddressByteSize());
+ return go_ast_sp;
+ }
+ }
+ return lldb::TypeSystemSP();
+}
+
+void
+GoASTContext::EnumerateSupportedLanguages(std::set<lldb::LanguageType> &languages_for_types, std::set<lldb::LanguageType> &languages_for_expressions)
+{
+ static std::vector<lldb::LanguageType> s_supported_languages_for_types({
+ lldb::eLanguageTypeGo});
+
+ static std::vector<lldb::LanguageType> s_supported_languages_for_expressions({});
+
+ languages_for_types.insert(s_supported_languages_for_types.begin(), s_supported_languages_for_types.end());
+ languages_for_expressions.insert(s_supported_languages_for_expressions.begin(), s_supported_languages_for_expressions.end());
+}
+
+
+void
+GoASTContext::Initialize()
+{
+ PluginManager::RegisterPlugin (GetPluginNameStatic(),
+ "AST context plug-in",
+ CreateInstance,
+ EnumerateSupportedLanguages);
+}
+
+void
+GoASTContext::Terminate()
+{
+ PluginManager::UnregisterPlugin (CreateInstance);
+}
+
+
+//----------------------------------------------------------------------
+// Tests
+//----------------------------------------------------------------------
+
+bool
+GoASTContext::IsArrayType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size, bool *is_incomplete)
+{
+ if (element_type)
+ element_type->Clear();
+ if (size)
+ *size = 0;
+ if (is_incomplete)
+ *is_incomplete = false;
+ GoArray *array = static_cast<GoType *>(type)->GetArray();
+ if (array)
+ {
+ if (size)
+ *size = array->GetLength();
+ if (element_type)
+ *element_type = array->GetElementType();
+ return true;
+ }
+ return false;
+}
+
+bool
+GoASTContext::IsVectorType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size)
+{
+ if (element_type)
+ element_type->Clear();
+ if (size)
+ *size = 0;
+ return false;
+}
+
+bool
+GoASTContext::IsAggregateType(lldb::opaque_compiler_type_t type)
+{
+ int kind = static_cast<GoType *>(type)->GetGoKind();
+ if (kind < GoType::KIND_ARRAY)
+ return false;
+ if (kind == GoType::KIND_PTR)
+ return false;
+ if (kind == GoType::KIND_CHAN)
+ return false;
+ if (kind == GoType::KIND_MAP)
+ return false;
+ if (kind == GoType::KIND_STRING)
+ return false;
+ if (kind == GoType::KIND_UNSAFEPOINTER)
+ return false;
+ return true;
+}
+
+bool
+GoASTContext::IsBeingDefined(lldb::opaque_compiler_type_t type)
+{
+ return false;
+}
+
+bool
+GoASTContext::IsCharType(lldb::opaque_compiler_type_t type)
+{
+ // Go's DWARF doesn't distinguish between rune and int32.
+ return false;
+}
+
+bool
+GoASTContext::IsCompleteType(lldb::opaque_compiler_type_t type)
+{
+ if (!type)
+ return false;
+ GoType *t = static_cast<GoType *>(type);
+ if (GoStruct *s = t->GetStruct())
+ return s->IsComplete();
+ if (t->IsTypedef() || t->GetGoKind() == GoType::KIND_PTR)
+ return t->GetElementType().IsCompleteType();
+ return true;
+}
+
+bool
+GoASTContext::IsConst(lldb::opaque_compiler_type_t type)
+{
+ return false;
+}
+
+bool
+GoASTContext::IsCStringType(lldb::opaque_compiler_type_t type, uint32_t &length)
+{
+ return false;
+}
+
+bool
+GoASTContext::IsDefined(lldb::opaque_compiler_type_t type)
+{
+ return type != nullptr;
+}
+
+bool
+GoASTContext::IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count, bool &is_complex)
+{
+ int kind = static_cast<GoType *>(type)->GetGoKind();
+ if (kind >= GoType::KIND_FLOAT32 && kind <= GoType::KIND_COMPLEX128)
+ {
+ if (kind >= GoType::KIND_COMPLEX64)
+ {
+ is_complex = true;
+ count = 2;
+ }
+ else
+ {
+ is_complex = false;
+ count = 1;
+ }
+ return true;
+ }
+ count = 0;
+ is_complex = false;
+ return false;
+}
+
+bool
+GoASTContext::IsFunctionType(lldb::opaque_compiler_type_t type, bool *is_variadic_ptr)
+{
+ GoFunction *func = static_cast<GoType *>(type)->GetFunction();
+ if (func)
+ {
+ if (is_variadic_ptr)
+ *is_variadic_ptr = func->IsVariadic();
+ return true;
+ }
+ if (is_variadic_ptr)
+ *is_variadic_ptr = false;
+ return false;
+}
+
+uint32_t
+GoASTContext::IsHomogeneousAggregate(lldb::opaque_compiler_type_t type, CompilerType *base_type_ptr)
+{
+ return false;
+}
+
+size_t
+GoASTContext::GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type)
+{
+ return 0;
+}
+
+CompilerType
+GoASTContext::GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type, const size_t index)
+{
+ return CompilerType();
+}
+
+bool
+GoASTContext::IsFunctionPointerType(lldb::opaque_compiler_type_t type)
+{
+ return IsFunctionType(type);
+}
+
+bool
+GoASTContext::IsIntegerType(lldb::opaque_compiler_type_t type, bool &is_signed)
+{
+ is_signed = false;
+ // TODO: Is bool an integer?
+ if (type)
+ {
+ int kind = static_cast<GoType *>(type)->GetGoKind();
+ if (kind <= GoType::KIND_UINTPTR)
+ {
+ is_signed = (kind != GoType::KIND_BOOL) & (kind <= GoType::KIND_INT64);
+ return true;
+ }
+ }
+ return false;
+}
+
+bool
+GoASTContext::IsPolymorphicClass(lldb::opaque_compiler_type_t type)
+{
+ return false;
+}
+
+bool
+GoASTContext::IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
+ CompilerType *target_type, // Can pass NULL
+ bool check_cplusplus, bool check_objc)
+{
+ if (target_type)
+ target_type->Clear();
+ if (type)
+ return static_cast<GoType *>(type)->GetGoKind() == GoType::KIND_INTERFACE;
+ return false;
+}
+
+bool
+GoASTContext::IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type)
+{
+ return false;
+}
+
+bool
+GoASTContext::IsPointerType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type)
+{
+ if (!type)
+ return false;
+ GoType *t = static_cast<GoType *>(type);
+ if (pointee_type)
+ {
+ *pointee_type = t->GetElementType();
+ }
+ switch (t->GetGoKind())
+ {
+ case GoType::KIND_PTR:
+ case GoType::KIND_UNSAFEPOINTER:
+ case GoType::KIND_CHAN:
+ case GoType::KIND_MAP:
+ // TODO: is function a pointer?
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool
+GoASTContext::IsPointerOrReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type)
+{
+ return IsPointerType(type, pointee_type);
+}
+
+bool
+GoASTContext::IsReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type, bool *is_rvalue)
+{
+ return false;
+}
+
+bool
+GoASTContext::IsScalarType(lldb::opaque_compiler_type_t type)
+{
+ return !IsAggregateType(type);
+}
+
+bool
+GoASTContext::IsTypedefType(lldb::opaque_compiler_type_t type)
+{
+ if (type)
+ return static_cast<GoType *>(type)->IsTypedef();
+ return false;
+}
+
+bool
+GoASTContext::IsVoidType(lldb::opaque_compiler_type_t type)
+{
+ if (!type)
+ return false;
+ return static_cast<GoType *>(type)->GetGoKind() == GoType::KIND_LLDB_VOID;
+}
+
+bool
+GoASTContext::SupportsLanguage (lldb::LanguageType language)
+{
+ return language == eLanguageTypeGo;
+}
+
+//----------------------------------------------------------------------
+// Type Completion
+//----------------------------------------------------------------------
+
+bool
+GoASTContext::GetCompleteType(lldb::opaque_compiler_type_t type)
+{
+ if (!type)
+ return false;
+ GoType *t = static_cast<GoType *>(type);
+ if (t->IsTypedef() || t->GetGoKind() == GoType::KIND_PTR || t->GetArray())
+ return t->GetElementType().GetCompleteType();
+ if (GoStruct *s = t->GetStruct())
+ {
+ if (s->IsComplete())
+ return true;
+ CompilerType compiler_type(this, s);
+ SymbolFile *symbols = GetSymbolFile();
+ return symbols && symbols->CompleteType(compiler_type);
+ }
+ return true;
+}
+
+//----------------------------------------------------------------------
+// AST related queries
+//----------------------------------------------------------------------
+
+uint32_t
+GoASTContext::GetPointerByteSize()
+{
+ return m_pointer_byte_size;
+}
+
+//----------------------------------------------------------------------
+// Accessors
+//----------------------------------------------------------------------
+
+ConstString
+GoASTContext::GetTypeName(lldb::opaque_compiler_type_t type)
+{
+ if (type)
+ return static_cast<GoType *>(type)->GetName();
+ return ConstString();
+}
+
+uint32_t
+GoASTContext::GetTypeInfo(lldb::opaque_compiler_type_t type, CompilerType *pointee_or_element_compiler_type)
+{
+ if (pointee_or_element_compiler_type)
+ pointee_or_element_compiler_type->Clear();
+ if (!type)
+ return 0;
+ GoType *t = static_cast<GoType *>(type);
+ if (pointee_or_element_compiler_type)
+ *pointee_or_element_compiler_type = t->GetElementType();
+ int kind = t->GetGoKind();
+ if (kind == GoType::KIND_ARRAY)
+ return eTypeHasChildren | eTypeIsArray;
+ if (kind < GoType::KIND_ARRAY)
+ {
+ uint32_t builtin_type_flags = eTypeIsBuiltIn | eTypeHasValue;
+ if (kind < GoType::KIND_FLOAT32)
+ {
+ builtin_type_flags |= eTypeIsInteger | eTypeIsScalar;
+ if (kind >= GoType::KIND_INT && kind <= GoType::KIND_INT64)
+ builtin_type_flags |= eTypeIsSigned;
+ }
+ else
+ {
+ builtin_type_flags |= eTypeIsFloat;
+ if (kind < GoType::KIND_COMPLEX64)
+ builtin_type_flags |= eTypeIsComplex;
+ else
+ builtin_type_flags |= eTypeIsScalar;
+ }
+ return builtin_type_flags;
+ }
+ if (kind == GoType::KIND_STRING)
+ return eTypeHasValue | eTypeIsBuiltIn;
+ if (kind == GoType::KIND_FUNC)
+ return eTypeIsFuncPrototype | eTypeHasValue;
+ if (IsPointerType(type))
+ return eTypeIsPointer | eTypeHasValue | eTypeHasChildren;
+ if (kind == GoType::KIND_LLDB_VOID)
+ return 0;
+ return eTypeHasChildren | eTypeIsStructUnion;
+}
+
+lldb::TypeClass
+GoASTContext::GetTypeClass(lldb::opaque_compiler_type_t type)
+{
+ if (!type)
+ return eTypeClassInvalid;
+ int kind = static_cast<GoType *>(type)->GetGoKind();
+ if (kind == GoType::KIND_FUNC)
+ return eTypeClassFunction;
+ if (IsPointerType(type))
+ return eTypeClassPointer;
+ if (kind < GoType::KIND_COMPLEX64)
+ return eTypeClassBuiltin;
+ if (kind <= GoType::KIND_COMPLEX128)
+ return eTypeClassComplexFloat;
+ if (kind == GoType::KIND_LLDB_VOID)
+ return eTypeClassInvalid;
+ return eTypeClassStruct;
+}
+
+lldb::BasicType
+GoASTContext::GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type)
+{
+ ConstString name = GetTypeName(type);
+ if (name)
+ {
+ typedef UniqueCStringMap<lldb::BasicType> TypeNameToBasicTypeMap;
+ static TypeNameToBasicTypeMap g_type_map;
+ static std::once_flag g_once_flag;
+ std::call_once(g_once_flag, [](){
+ // "void"
+ g_type_map.Append(ConstString("void").GetCString(), eBasicTypeVoid);
+ // "int"
+ g_type_map.Append(ConstString("int").GetCString(), eBasicTypeInt);
+ g_type_map.Append(ConstString("uint").GetCString(), eBasicTypeUnsignedInt);
+
+ // Miscellaneous
+ g_type_map.Append(ConstString("bool").GetCString(), eBasicTypeBool);
+
+ // Others. Should these map to C types?
+ g_type_map.Append(ConstString("byte").GetCString(), eBasicTypeOther);
+ g_type_map.Append(ConstString("uint8").GetCString(), eBasicTypeOther);
+ g_type_map.Append(ConstString("uint16").GetCString(), eBasicTypeOther);
+ g_type_map.Append(ConstString("uint32").GetCString(), eBasicTypeOther);
+ g_type_map.Append(ConstString("uint64").GetCString(), eBasicTypeOther);
+ g_type_map.Append(ConstString("int8").GetCString(), eBasicTypeOther);
+ g_type_map.Append(ConstString("int16").GetCString(), eBasicTypeOther);
+ g_type_map.Append(ConstString("int32").GetCString(), eBasicTypeOther);
+ g_type_map.Append(ConstString("int64").GetCString(), eBasicTypeOther);
+ g_type_map.Append(ConstString("float32").GetCString(), eBasicTypeOther);
+ g_type_map.Append(ConstString("float64").GetCString(), eBasicTypeOther);
+ g_type_map.Append(ConstString("uintptr").GetCString(), eBasicTypeOther);
+
+ g_type_map.Sort();
+ });
+
+ return g_type_map.Find(name.GetCString(), eBasicTypeInvalid);
+ }
+ return eBasicTypeInvalid;
+}
+
+lldb::LanguageType
+GoASTContext::GetMinimumLanguage(lldb::opaque_compiler_type_t type)
+{
+ return lldb::eLanguageTypeGo;
+}
+
+unsigned
+GoASTContext::GetTypeQualifiers(lldb::opaque_compiler_type_t type)
+{
+ return 0;
+}
+
+//----------------------------------------------------------------------
+// Creating related types
+//----------------------------------------------------------------------
+
+CompilerType
+GoASTContext::GetArrayElementType(lldb::opaque_compiler_type_t type, uint64_t *stride)
+{
+ GoArray *array = static_cast<GoType *>(type)->GetArray();
+ if (array)
+ {
+ if (stride)
+ {
+ *stride = array->GetElementType().GetByteSize(nullptr);
+ }
+ return array->GetElementType();
+ }
+ return CompilerType();
+}
+
+CompilerType
+GoASTContext::GetCanonicalType(lldb::opaque_compiler_type_t type)
+{
+ GoType *t = static_cast<GoType *>(type);
+ if (t->IsTypedef())
+ return t->GetElementType();
+ return CompilerType(this, type);
+}
+
+CompilerType
+GoASTContext::GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type)
+{
+ return CompilerType(this, type);
+}
+
+// Returns -1 if this isn't a function of if the function doesn't have a prototype
+// Returns a value >= 0 if there is a prototype.
+int
+GoASTContext::GetFunctionArgumentCount(lldb::opaque_compiler_type_t type)
+{
+ return GetNumberOfFunctionArguments(type);
+}
+
+CompilerType
+GoASTContext::GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type, size_t idx)
+{
+ return GetFunctionArgumentAtIndex(type, idx);
+}
+
+CompilerType
+GoASTContext::GetFunctionReturnType(lldb::opaque_compiler_type_t type)
+{
+ CompilerType result;
+ if (type)
+ {
+ GoType *t = static_cast<GoType *>(type);
+ if (t->GetGoKind() == GoType::KIND_FUNC)
+ result = t->GetElementType();
+ }
+ return result;
+}
+
+size_t
+GoASTContext::GetNumMemberFunctions(lldb::opaque_compiler_type_t type)
+{
+ return 0;
+}
+
+TypeMemberFunctionImpl
+GoASTContext::GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, size_t idx)
+{
+ return TypeMemberFunctionImpl();
+}
+
+CompilerType
+GoASTContext::GetNonReferenceType(lldb::opaque_compiler_type_t type)
+{
+ return CompilerType(this, type);
+}
+
+CompilerType
+GoASTContext::GetPointeeType(lldb::opaque_compiler_type_t type)
+{
+ if (!type)
+ return CompilerType();
+ return static_cast<GoType *>(type)->GetElementType();
+}
+
+CompilerType
+GoASTContext::GetPointerType(lldb::opaque_compiler_type_t type)
+{
+ if (!type)
+ return CompilerType();
+ ConstString type_name = GetTypeName(type);
+ ConstString pointer_name(std::string("*") + type_name.GetCString());
+ GoType *pointer = (*m_types)[pointer_name].get();
+ if (pointer == nullptr)
+ {
+ pointer = new GoElem(GoType::KIND_PTR, pointer_name, CompilerType(this, type));
+ (*m_types)[pointer_name].reset(pointer);
+ }
+ return CompilerType(this, pointer);
+}
+
+// If the current object represents a typedef type, get the underlying type
+CompilerType
+GoASTContext::GetTypedefedType(lldb::opaque_compiler_type_t type)
+{
+ if (IsTypedefType(type))
+ return static_cast<GoType *>(type)->GetElementType();
+ return CompilerType();
+}
+
+//----------------------------------------------------------------------
+// Create related types using the current type's AST
+//----------------------------------------------------------------------
+CompilerType
+GoASTContext::GetBasicTypeFromAST(lldb::BasicType basic_type)
+{
+ return CompilerType();
+}
+
+CompilerType
+GoASTContext::GetBuiltinTypeForEncodingAndBitSize (lldb::Encoding encoding,
+ size_t bit_size)
+{
+ return CompilerType();
+}
+
+
+//----------------------------------------------------------------------
+// Exploring the type
+//----------------------------------------------------------------------
+
+uint64_t
+GoASTContext::GetBitSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope)
+{
+ if (!type)
+ return 0;
+ if (!GetCompleteType(type))
+ return 0;
+ GoType *t = static_cast<GoType *>(type);
+ GoArray *array = nullptr;
+ switch (t->GetGoKind())
+ {
+ case GoType::KIND_BOOL:
+ case GoType::KIND_INT8:
+ case GoType::KIND_UINT8:
+ return 8;
+ case GoType::KIND_INT16:
+ case GoType::KIND_UINT16:
+ return 16;
+ case GoType::KIND_INT32:
+ case GoType::KIND_UINT32:
+ case GoType::KIND_FLOAT32:
+ return 32;
+ case GoType::KIND_INT64:
+ case GoType::KIND_UINT64:
+ case GoType::KIND_FLOAT64:
+ case GoType::KIND_COMPLEX64:
+ return 64;
+ case GoType::KIND_COMPLEX128:
+ return 128;
+ case GoType::KIND_INT:
+ case GoType::KIND_UINT:
+ return m_int_byte_size * 8;
+ case GoType::KIND_UINTPTR:
+ case GoType::KIND_FUNC: // I assume this is a pointer?
+ case GoType::KIND_CHAN:
+ case GoType::KIND_PTR:
+ case GoType::KIND_UNSAFEPOINTER:
+ case GoType::KIND_MAP:
+ return m_pointer_byte_size * 8;
+ case GoType::KIND_ARRAY:
+ array = t->GetArray();
+ return array->GetLength() * array->GetElementType().GetBitSize(exe_scope);
+ case GoType::KIND_INTERFACE:
+ return t->GetElementType().GetBitSize(exe_scope);
+ case GoType::KIND_SLICE:
+ case GoType::KIND_STRING:
+ case GoType::KIND_STRUCT:
+ return t->GetStruct()->GetByteSize() * 8;
+ default:
+ assert(false);
+ }
+ return 0;
+}
+
+lldb::Encoding
+GoASTContext::GetEncoding(lldb::opaque_compiler_type_t type, uint64_t &count)
+{
+ count = 1;
+ bool is_signed;
+ if (IsIntegerType(type, is_signed))
+ return is_signed ? lldb::eEncodingSint : eEncodingUint;
+ bool is_complex;
+ uint32_t complex_count;
+ if (IsFloatingPointType(type, complex_count, is_complex))
+ {
+ count = complex_count;
+ return eEncodingIEEE754;
+ }
+ if (IsPointerType(type))
+ return eEncodingUint;
+ return eEncodingInvalid;
+}
+
+lldb::Format
+GoASTContext::GetFormat(lldb::opaque_compiler_type_t type)
+{
+ if (!type)
+ return eFormatDefault;
+ switch (static_cast<GoType *>(type)->GetGoKind())
+ {
+ case GoType::KIND_BOOL:
+ return eFormatBoolean;
+ case GoType::KIND_INT:
+ case GoType::KIND_INT8:
+ case GoType::KIND_INT16:
+ case GoType::KIND_INT32:
+ case GoType::KIND_INT64:
+ return eFormatDecimal;
+ case GoType::KIND_UINT:
+ case GoType::KIND_UINT8:
+ case GoType::KIND_UINT16:
+ case GoType::KIND_UINT32:
+ case GoType::KIND_UINT64:
+ return eFormatUnsigned;
+ case GoType::KIND_FLOAT32:
+ case GoType::KIND_FLOAT64:
+ return eFormatFloat;
+ case GoType::KIND_COMPLEX64:
+ case GoType::KIND_COMPLEX128:
+ return eFormatComplexFloat;
+ case GoType::KIND_UINTPTR:
+ case GoType::KIND_CHAN:
+ case GoType::KIND_PTR:
+ case GoType::KIND_MAP:
+ case GoType::KIND_UNSAFEPOINTER:
+ return eFormatHex;
+ case GoType::KIND_STRING:
+ return eFormatCString;
+ case GoType::KIND_ARRAY:
+ case GoType::KIND_INTERFACE:
+ case GoType::KIND_SLICE:
+ case GoType::KIND_STRUCT:
+ default:
+ // Don't know how to display this.
+ return eFormatBytes;
+ }
+}
+
+size_t
+GoASTContext::GetTypeBitAlign(lldb::opaque_compiler_type_t type)
+{
+ return 0;
+}
+
+uint32_t
+GoASTContext::GetNumChildren(lldb::opaque_compiler_type_t type, bool omit_empty_base_classes)
+{
+ if (!type || !GetCompleteType(type))
+ return 0;
+ GoType *t = static_cast<GoType *>(type);
+ if (t->GetGoKind() == GoType::KIND_PTR)
+ {
+ CompilerType elem = t->GetElementType();
+ if (elem.IsAggregateType())
+ return elem.GetNumChildren(omit_empty_base_classes);
+ return 1;
+ }
+ else if (GoArray *array = t->GetArray())
+ {
+ return array->GetLength();
+ }
+ else if (t->IsTypedef())
+ {
+ return t->GetElementType().GetNumChildren(omit_empty_base_classes);
+ }
+
+ return GetNumFields(type);
+}
+
+uint32_t
+GoASTContext::GetNumFields(lldb::opaque_compiler_type_t type)
+{
+ if (!type || !GetCompleteType(type))
+ return 0;
+ GoType *t = static_cast<GoType *>(type);
+ if (t->IsTypedef())
+ return t->GetElementType().GetNumFields();
+ GoStruct *s = t->GetStruct();
+ if (s)
+ return s->GetNumFields();
+ return 0;
+}
+
+CompilerType
+GoASTContext::GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx, std::string &name, uint64_t *bit_offset_ptr,
+ uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr)
+{
+ if (bit_offset_ptr)
+ *bit_offset_ptr = 0;
+ if (bitfield_bit_size_ptr)
+ *bitfield_bit_size_ptr = 0;
+ if (is_bitfield_ptr)
+ *is_bitfield_ptr = false;
+
+ if (!type || !GetCompleteType(type))
+ return CompilerType();
+
+ GoType *t = static_cast<GoType *>(type);
+ if (t->IsTypedef())
+ return t->GetElementType().GetFieldAtIndex(idx, name, bit_offset_ptr, bitfield_bit_size_ptr, is_bitfield_ptr);
+
+ GoStruct *s = t->GetStruct();
+ if (s)
+ {
+ const auto *field = s->GetField(idx);
+ if (field)
+ {
+ name = field->m_name.GetStringRef();
+ if (bit_offset_ptr)
+ *bit_offset_ptr = field->m_byte_offset * 8;
+ return field->m_type;
+ }
+ }
+ return CompilerType();
+}
+
+CompilerType
+GoASTContext::GetChildCompilerTypeAtIndex(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers,
+ bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name,
+ uint32_t &child_byte_size, int32_t &child_byte_offset,
+ uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
+ bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags)
+{
+ child_name.clear();
+ child_byte_size = 0;
+ child_byte_offset = 0;
+ child_bitfield_bit_size = 0;
+ child_bitfield_bit_offset = 0;
+ child_is_base_class = false;
+ child_is_deref_of_parent = false;
+ language_flags = 0;
+
+ if (!type || !GetCompleteType(type))
+ return CompilerType();
+
+ GoType *t = static_cast<GoType *>(type);
+ if (t->GetStruct())
+ {
+ uint64_t bit_offset;
+ CompilerType ret = GetFieldAtIndex(type, idx, child_name, &bit_offset, nullptr, nullptr);
+ child_byte_size = ret.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr);
+ child_byte_offset = bit_offset / 8;
+ return ret;
+ }
+ else if (t->GetGoKind() == GoType::KIND_PTR)
+ {
+ CompilerType pointee = t->GetElementType();
+ if (!pointee.IsValid() || pointee.IsVoidType())
+ return CompilerType();
+ if (transparent_pointers && pointee.IsAggregateType())
+ {
+ bool tmp_child_is_deref_of_parent = false;
+ return pointee.GetChildCompilerTypeAtIndex(exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
+ ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
+ child_bitfield_bit_size, child_bitfield_bit_offset,
+ child_is_base_class, tmp_child_is_deref_of_parent, valobj, language_flags);
+ }
+ else
+ {
+ child_is_deref_of_parent = true;
+ const char *parent_name = valobj ? valobj->GetName().GetCString() : NULL;
+ if (parent_name)
+ {
+ child_name.assign(1, '*');
+ child_name += parent_name;
+ }
+
+ // We have a pointer to an simple type
+ if (idx == 0 && pointee.GetCompleteType())
+ {
+ child_byte_size = pointee.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
+ child_byte_offset = 0;
+ return pointee;
+ }
+ }
+ }
+ else if (GoArray *a = t->GetArray())
+ {
+ if (ignore_array_bounds || idx < a->GetLength())
+ {
+ CompilerType element_type = a->GetElementType();
+ if (element_type.GetCompleteType())
+ {
+ char element_name[64];
+ ::snprintf(element_name, sizeof(element_name), "[%zu]", idx);
+ child_name.assign(element_name);
+ child_byte_size = element_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
+ child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
+ return element_type;
+ }
+ }
+ }
+ else if (t->IsTypedef())
+ {
+ return t->GetElementType().GetChildCompilerTypeAtIndex(
+ exe_ctx, idx, transparent_pointers, omit_empty_base_classes, ignore_array_bounds, child_name,
+ child_byte_size, child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class,
+ child_is_deref_of_parent, valobj, language_flags);
+ }
+ return CompilerType();
+}
+
+// Lookup a child given a name. This function will match base class names
+// and member member names in "clang_type" only, not descendants.
+uint32_t
+GoASTContext::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, const char *name, bool omit_empty_base_classes)
+{
+ if (!type || !GetCompleteType(type))
+ return UINT_MAX;
+
+ GoType *t = static_cast<GoType *>(type);
+ GoStruct *s = t->GetStruct();
+ if (s)
+ {
+ for (uint32_t i = 0; i < s->GetNumFields(); ++i)
+ {
+ const GoStruct::Field *f = s->GetField(i);
+ if (f->m_name.GetStringRef() == name)
+ return i;
+ }
+ }
+ else if (t->GetGoKind() == GoType::KIND_PTR || t->IsTypedef())
+ {
+ return t->GetElementType().GetIndexOfChildWithName(name, omit_empty_base_classes);
+ }
+ return UINT_MAX;
+}
+
+// Lookup a child member given a name. This function will match member names
+// only and will descend into "clang_type" children in search for the first
+// member in this class, or any base class that matches "name".
+// TODO: Return all matches for a given name by returning a vector<vector<uint32_t>>
+// so we catch all names that match a given child name, not just the first.
+size_t
+GoASTContext::GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type, const char *name, bool omit_empty_base_classes,
+ std::vector<uint32_t> &child_indexes)
+{
+ uint32_t index = GetIndexOfChildWithName(type, name, omit_empty_base_classes);
+ if (index == UINT_MAX)
+ return 0;
+ child_indexes.push_back(index);
+ return 1;
+}
+
+// Converts "s" to a floating point value and place resulting floating
+// point bytes in the "dst" buffer.
+size_t
+GoASTContext::ConvertStringToFloatValue(lldb::opaque_compiler_type_t type, const char *s, uint8_t *dst, size_t dst_size)
+{
+ assert(false);
+ return 0;
+}
+//----------------------------------------------------------------------
+// Dumping types
+//----------------------------------------------------------------------
+void
+GoASTContext::DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, lldb::Format format,
+ const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size,
+ uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, bool show_types, bool show_summary,
+ bool verbose, uint32_t depth)
+{
+ assert(false);
+}
+
+bool
+GoASTContext::DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s, lldb::Format format, const DataExtractor &data,
+ lldb::offset_t byte_offset, size_t byte_size, uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope)
+{
+ if (!type)
+ return false;
+ if (IsAggregateType(type))
+ {
+ return false;
+ }
+ else
+ {
+ GoType *t = static_cast<GoType *>(type);
+ if (t->IsTypedef())
+ {
+ CompilerType typedef_compiler_type = t->GetElementType();
+ if (format == eFormatDefault)
+ format = typedef_compiler_type.GetFormat();
+ uint64_t typedef_byte_size = typedef_compiler_type.GetByteSize(exe_scope);
+
+ return typedef_compiler_type.DumpTypeValue(
+ s,
+ format, // The format with which to display the element
+ data, // Data buffer containing all bytes for this type
+ byte_offset, // Offset into "data" where to grab value from
+ typedef_byte_size, // Size of this type in bytes
+ bitfield_bit_size, // Size in bits of a bitfield value, if zero don't treat as a bitfield
+ bitfield_bit_offset, // Offset in bits of a bitfield value if bitfield_bit_size != 0
+ exe_scope);
+ }
+
+ uint32_t item_count = 1;
+ // A few formats, we might need to modify our size and count for depending
+ // on how we are trying to display the value...
+ switch (format)
+ {
+ default:
+ case eFormatBoolean:
+ case eFormatBinary:
+ case eFormatComplex:
+ case eFormatCString: // NULL terminated C strings
+ case eFormatDecimal:
+ case eFormatEnum:
+ case eFormatHex:
+ case eFormatHexUppercase:
+ case eFormatFloat:
+ case eFormatOctal:
+ case eFormatOSType:
+ case eFormatUnsigned:
+ case eFormatPointer:
+ case eFormatVectorOfChar:
+ case eFormatVectorOfSInt8:
+ case eFormatVectorOfUInt8:
+ case eFormatVectorOfSInt16:
+ case eFormatVectorOfUInt16:
+ case eFormatVectorOfSInt32:
+ case eFormatVectorOfUInt32:
+ case eFormatVectorOfSInt64:
+ case eFormatVectorOfUInt64:
+ case eFormatVectorOfFloat32:
+ case eFormatVectorOfFloat64:
+ case eFormatVectorOfUInt128:
+ break;
+
+ case eFormatChar:
+ case eFormatCharPrintable:
+ case eFormatCharArray:
+ case eFormatBytes:
+ case eFormatBytesWithASCII:
+ item_count = byte_size;
+ byte_size = 1;
+ break;
+
+ case eFormatUnicode16:
+ item_count = byte_size / 2;
+ byte_size = 2;
+ break;
+
+ case eFormatUnicode32:
+ item_count = byte_size / 4;
+ byte_size = 4;
+ break;
+ }
+ return data.Dump(s, byte_offset, format, byte_size, item_count, UINT32_MAX, LLDB_INVALID_ADDRESS,
+ bitfield_bit_size, bitfield_bit_offset, exe_scope);
+ }
+ return 0;
+}
+
+void
+GoASTContext::DumpSummary(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size)
+{
+ assert(false);
+}
+
+void
+GoASTContext::DumpTypeDescription(lldb::opaque_compiler_type_t type)
+{
+ assert(false);
+} // Dump to stdout
+
+void
+GoASTContext::DumpTypeDescription(lldb::opaque_compiler_type_t type, Stream *s)
+{
+ assert(false);
+}
+
+CompilerType
+GoASTContext::CreateArrayType(const ConstString &name, const CompilerType &element_type, uint64_t length)
+{
+ GoType *type = new GoArray(name, length, element_type);
+ (*m_types)[name].reset(type);
+ return CompilerType(this, type);
+}
+
+CompilerType
+GoASTContext::CreateBaseType(int go_kind, const lldb_private::ConstString &name, uint64_t byte_size)
+{
+ if (go_kind == GoType::KIND_UINT || go_kind == GoType::KIND_INT)
+ m_int_byte_size = byte_size;
+ GoType *type = new GoType(go_kind, name);
+ (*m_types)[name].reset(type);
+ return CompilerType(this, type);
+}
+
+CompilerType
+GoASTContext::CreateTypedefType(int kind, const ConstString &name, CompilerType impl)
+{
+ GoType *type = new GoElem(kind, name, impl);
+ (*m_types)[name].reset(type);
+ return CompilerType(this, type);
+}
+
+CompilerType
+GoASTContext::CreateVoidType(const lldb_private::ConstString &name)
+{
+ GoType *type = new GoType(GoType::KIND_LLDB_VOID, name);
+ (*m_types)[name].reset(type);
+ return CompilerType(this, type);
+}
+
+CompilerType
+GoASTContext::CreateStructType(int kind, const lldb_private::ConstString &name, uint32_t byte_size)
+{
+ GoType *type = new GoStruct(kind, name, byte_size);
+ (*m_types)[name].reset(type);
+ return CompilerType(this, type);
+}
+
+void
+GoASTContext::AddFieldToStruct(const lldb_private::CompilerType &struct_type, const lldb_private::ConstString &name,
+ const lldb_private::CompilerType &field_type, uint32_t byte_offset)
+{
+ if (!struct_type)
+ return;
+ GoASTContext *ast = llvm::dyn_cast_or_null<GoASTContext>(struct_type.GetTypeSystem());
+ if (!ast)
+ return;
+ GoType *type = static_cast<GoType *>(struct_type.GetOpaqueQualType());
+ if (GoStruct *s = type->GetStruct())
+ s->AddField(name, field_type, byte_offset);
+}
+
+void
+GoASTContext::CompleteStructType(const lldb_private::CompilerType &struct_type)
+{
+ if (!struct_type)
+ return;
+ GoASTContext *ast = llvm::dyn_cast_or_null<GoASTContext>(struct_type.GetTypeSystem());
+ if (!ast)
+ return;
+ GoType *type = static_cast<GoType *>(struct_type.GetOpaqueQualType());
+ if (GoStruct *s = type->GetStruct())
+ s->SetComplete();
+}
+
+CompilerType
+GoASTContext::CreateFunctionType(const lldb_private::ConstString &name, CompilerType *params, size_t params_count,
+ bool is_variadic)
+{
+ GoType *type = new GoFunction(name, is_variadic);
+ (*m_types)[name].reset(type);
+ return CompilerType(this, type);
+}
+
+bool
+GoASTContext::IsGoString(const lldb_private::CompilerType &type)
+{
+ if (!type.IsValid() || !llvm::dyn_cast_or_null<GoASTContext>(type.GetTypeSystem()))
+ return false;
+ return GoType::KIND_STRING == static_cast<GoType *>(type.GetOpaqueQualType())->GetGoKind();
+}
+
+bool
+GoASTContext::IsGoSlice(const lldb_private::CompilerType &type)
+{
+ if (!type.IsValid() || !llvm::dyn_cast_or_null<GoASTContext>(type.GetTypeSystem()))
+ return false;
+ return GoType::KIND_SLICE == static_cast<GoType *>(type.GetOpaqueQualType())->GetGoKind();
+}
+
+bool
+GoASTContext::IsGoInterface(const lldb_private::CompilerType &type)
+{
+ if (!type.IsValid() || !llvm::dyn_cast_or_null<GoASTContext>(type.GetTypeSystem()))
+ return false;
+ return GoType::KIND_INTERFACE == static_cast<GoType *>(type.GetOpaqueQualType())->GetGoKind();
+}
+
+bool
+GoASTContext::IsPointerKind(uint8_t kind)
+{
+ return (kind & GoType::KIND_MASK) == GoType::KIND_PTR;
+}
+
+bool
+GoASTContext::IsDirectIface(uint8_t kind)
+{
+ return (kind & GoType::KIND_DIRECT_IFACE) == GoType::KIND_DIRECT_IFACE;
+}
+
+DWARFASTParser *
+GoASTContext::GetDWARFParser()
+{
+ if (!m_dwarf_ast_parser_ap)
+ m_dwarf_ast_parser_ap.reset(new DWARFASTParserGo(*this));
+ return m_dwarf_ast_parser_ap.get();
+}
+
+UserExpression *
+GoASTContextForExpr::GetUserExpression(const char *expr, const char *expr_prefix, lldb::LanguageType language,
+ Expression::ResultType desired_type, const EvaluateExpressionOptions &options)
+{
+ TargetSP target = m_target_wp.lock();
+ if (target)
+ return new GoUserExpression(*target, expr, expr_prefix, language, desired_type, options);
+ return nullptr;
+}
diff --git a/source/Symbol/LineEntry.cpp b/source/Symbol/LineEntry.cpp
index 08a2392e1136..815101368bd1 100644
--- a/source/Symbol/LineEntry.cpp
+++ b/source/Symbol/LineEntry.cpp
@@ -244,3 +244,42 @@ LineEntry::Compare (const LineEntry& a, const LineEntry& b)
return FileSpec::Compare (a.file, b.file, true);
}
+AddressRange
+LineEntry::GetSameLineContiguousAddressRange () const
+{
+ // Add each LineEntry's range to complete_line_range until we find
+ // a different file / line number.
+ AddressRange complete_line_range = range;
+
+ 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);
+
+ if (next_line_sc.line_entry.IsValid()
+ && next_line_sc.line_entry.range.GetByteSize() > 0
+ && file == next_line_sc.line_entry.file)
+ {
+ // 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;
+ }
+ }
+ break;
+ }
+ return complete_line_range;
+}
diff --git a/source/Symbol/LineTable.cpp b/source/Symbol/LineTable.cpp
index 3b951f567660..01c171886430 100644
--- a/source/Symbol/LineTable.cpp
+++ b/source/Symbol/LineTable.cpp
@@ -104,7 +104,17 @@ LineTable::AppendLineEntryToSequence
// here to avoid these kinds of inconsistencies. We will need tor revisit this if the DWARF line
// tables are updated to allow multiple entries at the same address legally.
if (!entries.empty() && entries.back().file_addr == file_addr)
+ {
+ // GCC don't use the is_prologue_end flag to mark the first instruction after the prologue.
+ // Instead of it it is issueing a line table entry for the first instruction of the prologue
+ // and one for the first instruction after the prologue. If the size of the prologue is 0
+ // instruction then the 2 line entry will have the same file address. Removing it will remove
+ // our ability to properly detect the location of the end of prologe so we set the prologue_end
+ // flag to preserve this information (setting the prologue_end flag for an entry what is after
+ // the prologue end don't have any effect)
+ entry.is_prologue_end = entry.file_idx == entries.back().file_idx;
entries.back() = entry;
+ }
else
entries.push_back (entry);
}
@@ -215,7 +225,7 @@ LineTable::FindLineEntryByAddress (const Address &so_addr, LineEntry& line_entry
--pos;
else if (pos->file_addr == search_entry.file_addr)
{
- // If this is a termination entry, it should't match since
+ // If this is a termination entry, it shouldn't match since
// entries with the "is_terminal_entry" member set to true
// are termination entries that define the range for the
// previous entry.
@@ -529,7 +539,7 @@ LineTable::LinkLineTable (const FileRangeMap &file_range_map)
{
entry_linked_file_addr = entry.file_addr - file_range_entry->GetRangeBase() + file_range_entry->data;
// Determine if we need to terminate the previous entry when the previous
- // entry was not contguous with this one after being linked.
+ // entry was not contiguous with this one after being linked.
if (range_changed && prev_file_range_entry)
{
prev_end_entry_linked_file_addr = std::min<lldb::addr_t>(entry.file_addr, prev_file_range_entry->GetRangeEnd()) - prev_file_range_entry->GetRangeBase() + prev_file_range_entry->data;
diff --git a/source/Symbol/ObjectFile.cpp b/source/Symbol/ObjectFile.cpp
index 22a313cf6a20..99f9236a2cd9 100644
--- a/source/Symbol/ObjectFile.cpp
+++ b/source/Symbol/ObjectFile.cpp
@@ -351,25 +351,31 @@ ObjectFile::GetAddressClass (addr_t file_addr)
case eSectionTypeZeroFill:
case eSectionTypeDataObjCMessageRefs:
case eSectionTypeDataObjCCFStrings:
+ case eSectionTypeGoSymtab:
return eAddressClassData;
case eSectionTypeDebug:
case eSectionTypeDWARFDebugAbbrev:
+ case eSectionTypeDWARFDebugAddr:
case eSectionTypeDWARFDebugAranges:
case eSectionTypeDWARFDebugFrame:
case eSectionTypeDWARFDebugInfo:
case eSectionTypeDWARFDebugLine:
case eSectionTypeDWARFDebugLoc:
case eSectionTypeDWARFDebugMacInfo:
+ case eSectionTypeDWARFDebugMacro:
case eSectionTypeDWARFDebugPubNames:
case eSectionTypeDWARFDebugPubTypes:
case eSectionTypeDWARFDebugRanges:
case eSectionTypeDWARFDebugStr:
+ case eSectionTypeDWARFDebugStrOffsets:
case eSectionTypeDWARFAppleNames:
case eSectionTypeDWARFAppleTypes:
case eSectionTypeDWARFAppleNamespaces:
case eSectionTypeDWARFAppleObjC:
return eAddressClassDebug;
case eSectionTypeEHFrame:
+ case eSectionTypeARMexidx:
+ case eSectionTypeARMextab:
case eSectionTypeCompactUnwind:
return eAddressClassRuntime;
case eSectionTypeELFSymbolTable:
@@ -532,6 +538,7 @@ ObjectFile::ReadSectionData (const Section *section, DataExtractor& section_data
}
}
}
+ return GetData(section->GetFileOffset(), section->GetFileSize(), section_data);
}
else
{
@@ -600,16 +607,49 @@ ObjectFile::ClearSymtab ()
}
SectionList *
-ObjectFile::GetSectionList()
+ObjectFile::GetSectionList(bool update_module_section_list)
{
if (m_sections_ap.get() == nullptr)
{
- ModuleSP module_sp(GetModule());
- if (module_sp)
+ if (update_module_section_list)
+ {
+ ModuleSP module_sp(GetModule());
+ if (module_sp)
+ {
+ lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+ CreateSections(*module_sp->GetUnifiedSectionList());
+ }
+ }
+ else
{
- lldb_private::Mutex::Locker locker(module_sp->GetMutex());
- CreateSections(*module_sp->GetUnifiedSectionList());
+ SectionList unified_section_list;
+ CreateSections(unified_section_list);
}
}
return m_sections_ap.get();
}
+
+lldb::SymbolType
+ObjectFile::GetSymbolTypeFromName (llvm::StringRef name,
+ lldb::SymbolType symbol_type_hint)
+{
+ if (!name.empty())
+ {
+ if (name.startswith("_OBJC_"))
+ {
+ // ObjC
+ if (name.startswith("_OBJC_CLASS_$_"))
+ return lldb::eSymbolTypeObjCClass;
+ if (name.startswith("_OBJC_METACLASS_$_"))
+ return lldb::eSymbolTypeObjCMetaClass;
+ if (name.startswith("_OBJC_IVAR_$_"))
+ return lldb::eSymbolTypeObjCIVar;
+ }
+ else if (name.startswith(".objc_class_name_"))
+ {
+ // ObjC v1
+ return lldb::eSymbolTypeObjCClass;
+ }
+ }
+ return symbol_type_hint;
+}
diff --git a/source/Symbol/SymbolContext.cpp b/source/Symbol/SymbolContext.cpp
index 4fb0dbc237c8..54db5e090b80 100644
--- a/source/Symbol/SymbolContext.cpp
+++ b/source/Symbol/SymbolContext.cpp
@@ -391,24 +391,24 @@ SymbolContext::GetResolvedMask () const
void
SymbolContext::Dump(Stream *s, Target *target) const
{
- *s << (void *)this << ": ";
+ *s << this << ": ";
s->Indent();
s->PutCString("SymbolContext");
s->IndentMore();
s->EOL();
s->IndentMore();
s->Indent();
- *s << "Module = " << (void *)module_sp.get() << ' ';
+ *s << "Module = " << module_sp.get() << ' ';
if (module_sp)
module_sp->GetFileSpec().Dump(s);
s->EOL();
s->Indent();
- *s << "CompileUnit = " << (void *)comp_unit;
+ *s << "CompileUnit = " << comp_unit;
if (comp_unit != nullptr)
*s << " {0x" << comp_unit->GetID() << "} " << *(static_cast<FileSpec*> (comp_unit));
s->EOL();
s->Indent();
- *s << "Function = " << (void *)function;
+ *s << "Function = " << function;
if (function != nullptr)
{
*s << " {0x" << function->GetID() << "} " << function->GetType()->GetName() << ", address-range = ";
@@ -424,7 +424,7 @@ SymbolContext::Dump(Stream *s, Target *target) const
}
s->EOL();
s->Indent();
- *s << "Block = " << (void *)block;
+ *s << "Block = " << block;
if (block != nullptr)
*s << " {0x" << block->GetID() << '}';
// Dump the block and pass it a negative depth to we print all the parent blocks
@@ -436,11 +436,11 @@ SymbolContext::Dump(Stream *s, Target *target) const
line_entry.Dump (s, target, true, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress, true);
s->EOL();
s->Indent();
- *s << "Symbol = " << (void *)symbol;
+ *s << "Symbol = " << symbol;
if (symbol != nullptr && symbol->GetMangled())
*s << ' ' << symbol->GetName().AsCString();
s->EOL();
- *s << "Variable = " << (void *)variable;
+ *s << "Variable = " << variable;
if (variable != nullptr)
{
*s << " {0x" << variable->GetID() << "} " << variable->GetType()->GetName();
@@ -525,6 +525,38 @@ SymbolContext::GetAddressRange (uint32_t scope,
return false;
}
+LanguageType
+SymbolContext::GetLanguage () const
+{
+ LanguageType lang;
+ if (function &&
+ (lang = function->GetLanguage()) != eLanguageTypeUnknown)
+ {
+ return lang;
+ }
+ else if (variable &&
+ (lang = variable->GetLanguage()) != eLanguageTypeUnknown)
+ {
+ return lang;
+ }
+ else if (symbol &&
+ (lang = symbol->GetLanguage()) != eLanguageTypeUnknown)
+ {
+ return lang;
+ }
+ else if (comp_unit &&
+ (lang = comp_unit->GetLanguage()) != eLanguageTypeUnknown)
+ {
+ return lang;
+ }
+ else if (symbol)
+ {
+ // If all else fails, try to guess the language from the name.
+ return symbol->GetMangled().GuessLanguage();
+ }
+ return eLanguageTypeUnknown;
+}
+
bool
SymbolContext::GetParentOfInlinedScope (const Address &curr_frame_pc,
SymbolContext &next_frame_sc,
@@ -649,23 +681,124 @@ SymbolContext::GetFunctionMethodInfo (lldb::LanguageType &language,
{
- Block *function_block = GetFunctionBlock ();
+ Block *function_block = GetFunctionBlock();
if (function_block)
{
- clang::DeclContext *decl_context = function_block->GetClangDeclContext();
-
- if (decl_context)
+ CompilerDeclContext decl_ctx = function_block->GetDeclContext();
+ if (decl_ctx)
+ return decl_ctx.IsClassMethod(&language, &is_instance_method, &language_object_name);
+ }
+ return false;
+}
+
+void
+SymbolContext::SortTypeList(TypeMap &type_map, TypeList &type_list) const
+{
+ Block * curr_block = block;
+ bool isInlinedblock = false;
+ if (curr_block != nullptr && 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 {
+ SymbolContextScope *scs = type_sp->GetSymbolContextScope();
+ if (scs && curr_block == scs->CalculateSymbolContextBlock())
+ type_list.Insert(type_sp);
+ return true; // Keep iterating
+ });
+
+ // Remove any entries that are now in "type_list" from "type_map"
+ // since we can't remove from type_map while iterating
+ type_list.ForEach([&type_map](const lldb::TypeSP& type_sp) -> bool {
+ type_map.Remove(type_sp);
+ return true; // Keep iterating
+ });
+ 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 {
+ SymbolContextScope *scs = type_sp->GetSymbolContextScope();
+ if (scs && function == scs->CalculateSymbolContextFunction())
+ type_list.Insert(type_sp);
+ return true; // Keep iterating
+ });
+
+ // Remove any entries that are now in "type_list" from "type_map"
+ // since we can't remove from type_map while iterating
+ const size_t new_type_list_size = type_list.GetSize();
+ if (new_type_list_size > old_type_list_size)
{
- return ClangASTContext::GetClassMethodInfoForDeclContext (decl_context,
- language,
- is_instance_method,
- language_object_name);
+ for (size_t i=old_type_list_size; i<new_type_list_size; ++i)
+ type_map.Remove(type_list.GetTypeAtIndex(i));
}
}
- language = eLanguageTypeUnknown;
- is_instance_method = false;
- language_object_name.Clear();
- return false;
+ //----------------------------------------------------------------------
+ // 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();
+
+ type_map.ForEach([this, &type_list](const lldb::TypeSP& type_sp) -> bool {
+ SymbolContextScope *scs = type_sp->GetSymbolContextScope();
+ if (scs && comp_unit == scs->CalculateSymbolContextCompileUnit())
+ type_list.Insert(type_sp);
+ return true; // Keep iterating
+ });
+
+ // Remove any entries that are now in "type_list" from "type_map"
+ // since we can't remove from type_map while iterating
+ const size_t new_type_list_size = type_list.GetSize();
+ if (new_type_list_size > old_type_list_size)
+ {
+ for (size_t i=old_type_list_size; i<new_type_list_size; ++i)
+ 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 {
+ SymbolContextScope *scs = type_sp->GetSymbolContextScope();
+ if (scs && module_sp == scs->CalculateSymbolContextModule())
+ type_list.Insert(type_sp);
+ return true; // Keep iterating
+ });
+ // Remove any entries that are now in "type_list" from "type_map"
+ // since we can't remove from type_map while iterating
+ const size_t new_type_list_size = type_list.GetSize();
+ if (new_type_list_size > old_type_list_size)
+ {
+ for (size_t i=old_type_list_size; i<new_type_list_size; ++i)
+ 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);
+ return true; // Keep iterating
+ });
+ }
}
ConstString
@@ -930,7 +1063,7 @@ SymbolContextSpecifier::SymbolContextMatches(SymbolContext &sc)
}
else if (sc.symbol != nullptr)
{
- if (!sc.symbol->GetMangled().NameMatches(func_name, sc.function->GetLanguage()))
+ if (!sc.symbol->GetMangled().NameMatches(func_name, sc.symbol->GetLanguage()))
return false;
}
}
@@ -1178,7 +1311,7 @@ void
SymbolContextList::Dump(Stream *s, Target *target) const
{
- *s << (void *)this << ": ";
+ *s << this << ": ";
s->Indent();
s->PutCString("SymbolContextList");
s->EOL();
diff --git a/source/Symbol/SymbolFile.cpp b/source/Symbol/SymbolFile.cpp
index a5b138bb52af..51e35048d5cd 100644
--- a/source/Symbol/SymbolFile.cpp
+++ b/source/Symbol/SymbolFile.cpp
@@ -15,6 +15,9 @@
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/TypeMap.h"
+#include "lldb/Symbol/TypeSystem.h"
+#include "lldb/Symbol/VariableList.h"
using namespace lldb_private;
@@ -82,8 +85,68 @@ SymbolFile::GetTypeList ()
return nullptr;
}
-lldb_private::ClangASTContext &
-SymbolFile::GetClangASTContext ()
+TypeSystem *
+SymbolFile::GetTypeSystemForLanguage (lldb::LanguageType language)
{
- return m_obj_file->GetModule()->GetClangASTContext();
+ TypeSystem *type_system = m_obj_file->GetModule()->GetTypeSystemForLanguage(language);
+ if (type_system)
+ type_system->SetSymbolFile(this);
+ return type_system;
+}
+
+uint32_t
+SymbolFile::ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list)
+{
+ return 0;
+}
+
+
+uint32_t
+SymbolFile::FindGlobalVariables (const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, VariableList& variables)
+{
+ if (!append)
+ variables.Clear();
+ return 0;
+}
+
+
+uint32_t
+SymbolFile::FindGlobalVariables (const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables)
+{
+ if (!append)
+ variables.Clear();
+ return 0;
+}
+
+uint32_t
+SymbolFile::FindFunctions (const ConstString &name, const CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list)
+{
+ if (!append)
+ sc_list.Clear();
+ return 0;
+}
+
+uint32_t
+SymbolFile::FindFunctions (const RegularExpression& regex, bool include_inlines, bool append, SymbolContextList& sc_list)
+{
+ if (!append)
+ sc_list.Clear();
+ return 0;
+}
+
+uint32_t
+SymbolFile::FindTypes (const SymbolContext& sc, const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, TypeMap& types)
+{
+ if (!append)
+ types.Clear();
+ return 0;
+}
+
+
+size_t
+SymbolFile::FindTypes (const std::vector<CompilerContext> &context, bool append, TypeMap& types)
+{
+ if (!append)
+ types.Clear();
+ return 0;
}
diff --git a/source/Symbol/SymbolVendor.cpp b/source/Symbol/SymbolVendor.cpp
index 6ec9f3861ecf..b9ec9a1c8a79 100644
--- a/source/Symbol/SymbolVendor.cpp
+++ b/source/Symbol/SymbolVendor.cpp
@@ -77,7 +77,7 @@ SymbolVendor::~SymbolVendor()
}
//----------------------------------------------------------------------
-// Add a represention given an object file.
+// Add a representation given an object file.
//----------------------------------------------------------------------
void
SymbolVendor::AddSymbolFileRepresentation(const ObjectFileSP &objfile_sp)
@@ -186,6 +186,18 @@ SymbolVendor::ParseCompileUnitLineTable (const SymbolContext &sc)
}
bool
+SymbolVendor::ParseCompileUnitDebugMacros (const SymbolContext &sc)
+{
+ ModuleSP module_sp(GetModule());
+ if (module_sp)
+ {
+ lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+ if (m_sym_file_ap.get())
+ return m_sym_file_ap->ParseCompileUnitDebugMacros(sc);
+ }
+ return false;
+}
+bool
SymbolVendor::ParseCompileUnitSupportFiles (const SymbolContext& sc, FileSpecList& support_files)
{
ModuleSP module_sp(GetModule());
@@ -293,14 +305,14 @@ SymbolVendor::ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bo
}
size_t
-SymbolVendor::FindGlobalVariables (const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, size_t max_matches, VariableList& variables)
+SymbolVendor::FindGlobalVariables (const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, VariableList& variables)
{
ModuleSP module_sp(GetModule());
if (module_sp)
{
lldb_private::Mutex::Locker locker(module_sp->GetMutex());
if (m_sym_file_ap.get())
- return m_sym_file_ap->FindGlobalVariables(name, namespace_decl, append, max_matches, variables);
+ return m_sym_file_ap->FindGlobalVariables(name, parent_decl_ctx, append, max_matches, variables);
}
return 0;
}
@@ -319,14 +331,14 @@ SymbolVendor::FindGlobalVariables (const RegularExpression& regex, bool append,
}
size_t
-SymbolVendor::FindFunctions(const ConstString &name, const ClangNamespaceDecl *namespace_decl, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list)
+SymbolVendor::FindFunctions(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list)
{
ModuleSP module_sp(GetModule());
if (module_sp)
{
lldb_private::Mutex::Locker locker(module_sp->GetMutex());
if (m_sym_file_ap.get())
- return m_sym_file_ap->FindFunctions(name, namespace_decl, name_type_mask, include_inlines, append, sc_list);
+ return m_sym_file_ap->FindFunctions(name, parent_decl_ctx, name_type_mask, include_inlines, append, sc_list);
}
return 0;
}
@@ -346,14 +358,29 @@ SymbolVendor::FindFunctions(const RegularExpression& regex, bool include_inlines
size_t
-SymbolVendor::FindTypes (const SymbolContext& sc, const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, size_t max_matches, TypeList& types)
+SymbolVendor::FindTypes (const SymbolContext& sc, const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, TypeMap& types)
+{
+ ModuleSP module_sp(GetModule());
+ if (module_sp)
+ {
+ lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+ if (m_sym_file_ap.get())
+ return m_sym_file_ap->FindTypes(sc, name, parent_decl_ctx, append, max_matches, types);
+ }
+ if (!append)
+ types.Clear();
+ return 0;
+}
+
+size_t
+SymbolVendor::FindTypes (const std::vector<CompilerContext> &context, bool append, TypeMap& types)
{
ModuleSP module_sp(GetModule());
if (module_sp)
{
lldb_private::Mutex::Locker locker(module_sp->GetMutex());
if (m_sym_file_ap.get())
- return m_sym_file_ap->FindTypes(sc, name, namespace_decl, append, max_matches, types);
+ return m_sym_file_ap->FindTypes(context, append, types);
}
if (!append)
types.Clear();
@@ -375,18 +402,18 @@ SymbolVendor::GetTypes (SymbolContextScope *sc_scope,
return 0;
}
-ClangNamespaceDecl
-SymbolVendor::FindNamespace(const SymbolContext& sc, const ConstString &name, const ClangNamespaceDecl *parent_namespace_decl)
+CompilerDeclContext
+SymbolVendor::FindNamespace(const SymbolContext& sc, const ConstString &name, const CompilerDeclContext *parent_decl_ctx)
{
- ClangNamespaceDecl namespace_decl;
+ CompilerDeclContext namespace_decl_ctx;
ModuleSP module_sp(GetModule());
if (module_sp)
{
lldb_private::Mutex::Locker locker(module_sp->GetMutex());
if (m_sym_file_ap.get())
- namespace_decl = m_sym_file_ap->FindNamespace (sc, name, parent_namespace_decl);
+ namespace_decl_ctx = m_sym_file_ap->FindNamespace (sc, name, parent_decl_ctx);
}
- return namespace_decl;
+ return namespace_decl_ctx;
}
void
diff --git a/source/Symbol/Symtab.cpp b/source/Symbol/Symtab.cpp
index c11efc0d9b24..b20504addec9 100644
--- a/source/Symbol/Symtab.cpp
+++ b/source/Symbol/Symtab.cpp
@@ -8,17 +8,19 @@
//===----------------------------------------------------------------------===//
#include <map>
+#include <set>
#include "lldb/Core/Module.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/Section.h"
+#include "lldb/Core/Stream.h"
#include "lldb/Core/Timer.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/Symtab.h"
-#include "lldb/Target/CPPLanguageRuntime.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "Plugins/Language/ObjC/ObjCLanguage.h"
+#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
using namespace lldb;
using namespace lldb_private;
@@ -329,7 +331,7 @@ Symtab::InitNameIndexes()
entry.cstring[2] != 'G' && // avoid guard variables
entry.cstring[2] != 'Z')) // named local entities (if we eventually handle eSymbolTypeData, we will want this back)
{
- CPPLanguageRuntime::MethodName cxx_method (mangled.GetDemangledName(lldb::eLanguageTypeC_plus_plus));
+ CPlusPlusLanguage::MethodName cxx_method (mangled.GetDemangledName(lldb::eLanguageTypeC_plus_plus));
entry.cstring = ConstString(cxx_method.GetBasename()).GetCString();
if (entry.cstring && entry.cstring[0])
{
@@ -392,7 +394,7 @@ Symtab::InitNameIndexes()
// 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.
- ObjCLanguageRuntime::MethodName objc_method (entry.cstring, true);
+ ObjCLanguage::MethodName objc_method (entry.cstring, true);
if (objc_method.IsValid(true))
{
entry.cstring = objc_method.GetSelector().GetCString();
diff --git a/source/Symbol/Type.cpp b/source/Symbol/Type.cpp
index 0927d55f1ee2..8061e016ca59 100644
--- a/source/Symbol/Type.cpp
+++ b/source/Symbol/Type.cpp
@@ -7,22 +7,26 @@
//
//===----------------------------------------------------------------------===//
-// Other libraries and framework includes
+// C Includes
+#include <stdio.h>
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Core/StreamString.h"
-#include "lldb/Symbol/ClangASTType.h"
-#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContextScope.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Symbol/TypeList.h"
+#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
@@ -36,6 +40,26 @@
using namespace lldb;
using namespace lldb_private;
+void
+CompilerContext::Dump() const
+{
+ switch (type)
+ {
+ case CompilerContextKind::Invalid: printf("Invalid"); break;
+ case CompilerContextKind::TranslationUnit: printf("TranslationUnit"); break;
+ case CompilerContextKind::Module: printf("Module"); break;
+ case CompilerContextKind::Namespace: printf("Namespace"); break;
+ case CompilerContextKind::Class: printf("Class"); break;
+ case CompilerContextKind::Structure: printf("Structure"); break;
+ case CompilerContextKind::Union: printf("Union"); break;
+ case CompilerContextKind::Function: printf("Function"); break;
+ case CompilerContextKind::Variable: printf("Variable"); break;
+ case CompilerContextKind::Enumeration: printf("Enumeration"); break;
+ case CompilerContextKind::Typedef: printf("Typedef"); break;
+ }
+ printf("(\"%s\")\n", name.GetCString());
+}
+
class TypeAppendVisitor
{
public:
@@ -62,6 +86,13 @@ TypeListImpl::Append (const lldb_private::TypeList &type_list)
type_list.ForEach(cb);
}
+SymbolFileType::SymbolFileType (SymbolFile &symbol_file, const lldb::TypeSP &type_sp) :
+ UserID (type_sp ? type_sp->GetID() : LLDB_INVALID_UID),
+ m_symbol_file (symbol_file),
+ m_type_sp (type_sp)
+{
+}
+
Type *
SymbolFileType::GetType ()
@@ -86,8 +117,8 @@ Type::Type
user_id_t encoding_uid,
EncodingDataType encoding_uid_type,
const Declaration& decl,
- const ClangASTType &clang_type,
- ResolveState clang_type_resolve_state
+ const CompilerType &compiler_type,
+ ResolveState compiler_type_resolve_state
) :
std::enable_shared_from_this<Type> (),
UserID (uid),
@@ -99,9 +130,9 @@ Type::Type
m_encoding_uid_type (encoding_uid_type),
m_byte_size (byte_size),
m_decl (decl),
- m_clang_type (clang_type)
+ m_compiler_type (compiler_type)
{
- m_flags.clang_type_resolve_state = (clang_type ? clang_type_resolve_state : eResolveStateUnresolved);
+ m_flags.compiler_type_resolve_state = (compiler_type ? compiler_type_resolve_state : eResolveStateUnresolved);
m_flags.is_complete_objc_class = false;
}
@@ -116,9 +147,9 @@ Type::Type () :
m_encoding_uid_type (eEncodingInvalid),
m_byte_size (0),
m_decl (),
- m_clang_type ()
+ m_compiler_type ()
{
- m_flags.clang_type_resolve_state = eResolveStateUnresolved;
+ m_flags.compiler_type_resolve_state = eResolveStateUnresolved;
m_flags.is_complete_objc_class = false;
}
@@ -134,7 +165,7 @@ Type::Type (const Type &rhs) :
m_encoding_uid_type (rhs.m_encoding_uid_type),
m_byte_size (rhs.m_byte_size),
m_decl (rhs.m_decl),
- m_clang_type (rhs.m_clang_type),
+ m_compiler_type (rhs.m_compiler_type),
m_flags (rhs.m_flags)
{
}
@@ -175,10 +206,10 @@ Type::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_name)
bool show_fullpaths = (level == lldb::eDescriptionLevelVerbose);
m_decl.Dump(s, show_fullpaths);
- if (m_clang_type.IsValid())
+ if (m_compiler_type.IsValid())
{
- *s << ", clang_type = \"";
- GetClangForwardType().DumpTypeDescription(s);
+ *s << ", compiler_type = \"";
+ GetForwardCompilerType ().DumpTypeDescription(s);
*s << '"';
}
else if (m_encoding_uid != LLDB_INVALID_UID)
@@ -223,10 +254,10 @@ Type::Dump (Stream *s, bool show_context)
bool show_fullpaths = false;
m_decl.Dump (s,show_fullpaths);
- if (m_clang_type.IsValid())
+ if (m_compiler_type.IsValid())
{
- *s << ", clang_type = " << m_clang_type.GetOpaqueQualType() << ' ';
- GetClangForwardType().DumpTypeDescription (s);
+ *s << ", compiler_type = " << m_compiler_type.GetOpaqueQualType() << ' ';
+ GetForwardCompilerType ().DumpTypeDescription (s);
}
else if (m_encoding_uid != LLDB_INVALID_UID)
{
@@ -256,7 +287,7 @@ const ConstString &
Type::GetName()
{
if (!m_name)
- m_name = GetClangForwardType().GetConstTypeName();
+ m_name = GetForwardCompilerType ().GetConstTypeName();
return m_name;
}
@@ -291,7 +322,7 @@ Type::DumpValue
s->PutCString(") ");
}
- GetClangForwardType().DumpValue (exe_ctx,
+ GetForwardCompilerType ().DumpValue (exe_ctx,
s,
format == lldb::eFormatDefault ? GetFormat() : format,
data,
@@ -336,7 +367,7 @@ Type::GetByteSize()
if (encoding_type)
m_byte_size = encoding_type->GetByteSize();
if (m_byte_size == 0)
- m_byte_size = GetClangLayoutType().GetByteSize(nullptr);
+ m_byte_size = GetLayoutCompilerType ().GetByteSize(nullptr);
}
break;
@@ -344,7 +375,11 @@ Type::GetByteSize()
case eEncodingIsPointerUID:
case eEncodingIsLValueReferenceUID:
case eEncodingIsRValueReferenceUID:
- m_byte_size = m_symbol_file->GetClangASTContext().GetPointerByteSize();
+ {
+ ArchSpec arch;
+ if (m_symbol_file->GetObjectFile()->GetArchitecture(arch))
+ m_byte_size = arch.GetAddressByteSize();
+ }
break;
}
}
@@ -355,13 +390,13 @@ Type::GetByteSize()
uint32_t
Type::GetNumChildren (bool omit_empty_base_classes)
{
- return GetClangForwardType().GetNumChildren(omit_empty_base_classes);
+ return GetForwardCompilerType ().GetNumChildren(omit_empty_base_classes);
}
bool
Type::IsAggregateType ()
{
- return GetClangForwardType().IsAggregateType();
+ return GetForwardCompilerType ().IsAggregateType();
}
lldb::TypeSP
@@ -382,7 +417,7 @@ Type::GetTypedefType()
lldb::Format
Type::GetFormat ()
{
- return GetClangForwardType().GetFormat();
+ return GetForwardCompilerType ().GetFormat();
}
@@ -391,7 +426,7 @@ lldb::Encoding
Type::GetEncoding (uint64_t &count)
{
// Make sure we resolve our type if it already hasn't been.
- return GetClangForwardType().GetEncoding(count);
+ return GetForwardCompilerType ().GetEncoding(count);
}
bool
@@ -441,7 +476,7 @@ Type::ReadFromMemory (ExecutionContext *exe_ctx, lldb::addr_t addr, AddressType
data.SetData(data_sp);
}
- uint8_t* dst = (uint8_t*)data.PeekData(0, byte_size);
+ uint8_t* dst = const_cast<uint8_t*>(data.PeekData(0, byte_size));
if (dst != nullptr)
{
if (address_type == eAddressTypeHost)
@@ -489,10 +524,11 @@ Type::GetDeclaration () const
}
bool
-Type::ResolveClangType (ResolveState clang_type_resolve_state)
+Type::ResolveClangType (ResolveState compiler_type_resolve_state)
{
+ // TODO: This needs to consider the correct type system to use.
Type *encoding_type = nullptr;
- if (!m_clang_type.IsValid())
+ if (!m_compiler_type.IsValid())
{
encoding_type = GetEncodingType();
if (encoding_type)
@@ -501,43 +537,43 @@ Type::ResolveClangType (ResolveState clang_type_resolve_state)
{
case eEncodingIsUID:
{
- ClangASTType encoding_clang_type = encoding_type->GetClangForwardType();
- if (encoding_clang_type.IsValid())
+ CompilerType encoding_compiler_type = encoding_type->GetForwardCompilerType ();
+ if (encoding_compiler_type.IsValid())
{
- m_clang_type = encoding_clang_type;
- m_flags.clang_type_resolve_state = encoding_type->m_flags.clang_type_resolve_state;
+ m_compiler_type = encoding_compiler_type;
+ m_flags.compiler_type_resolve_state = encoding_type->m_flags.compiler_type_resolve_state;
}
}
break;
case eEncodingIsConstUID:
- m_clang_type = encoding_type->GetClangForwardType().AddConstModifier();
+ m_compiler_type = encoding_type->GetForwardCompilerType ().AddConstModifier();
break;
case eEncodingIsRestrictUID:
- m_clang_type = encoding_type->GetClangForwardType().AddRestrictModifier();
+ m_compiler_type = encoding_type->GetForwardCompilerType ().AddRestrictModifier();
break;
case eEncodingIsVolatileUID:
- m_clang_type = encoding_type->GetClangForwardType().AddVolatileModifier();
+ m_compiler_type = encoding_type->GetForwardCompilerType ().AddVolatileModifier();
break;
case eEncodingIsTypedefUID:
- m_clang_type = encoding_type->GetClangForwardType().CreateTypedefType (GetName().AsCString(),
- GetSymbolFile()->GetClangDeclContextContainingTypeUID(GetID()));
+ m_compiler_type = encoding_type->GetForwardCompilerType ().CreateTypedef(GetName().AsCString(),
+ GetSymbolFile()->GetDeclContextContainingUID(GetID()));
m_name.Clear();
break;
case eEncodingIsPointerUID:
- m_clang_type = encoding_type->GetClangForwardType().GetPointerType();
+ m_compiler_type = encoding_type->GetForwardCompilerType ().GetPointerType();
break;
case eEncodingIsLValueReferenceUID:
- m_clang_type = encoding_type->GetClangForwardType().GetLValueReferenceType();
+ m_compiler_type = encoding_type->GetForwardCompilerType ().GetLValueReferenceType();
break;
case eEncodingIsRValueReferenceUID:
- m_clang_type = encoding_type->GetClangForwardType().GetRValueReferenceType();
+ m_compiler_type = encoding_type->GetForwardCompilerType ().GetRValueReferenceType();
break;
default:
@@ -548,40 +584,41 @@ Type::ResolveClangType (ResolveState clang_type_resolve_state)
else
{
// We have no encoding type, return void?
- ClangASTType void_clang_type (ClangASTContext::GetBasicType(GetClangASTContext().getASTContext(), eBasicTypeVoid));
+ TypeSystem *type_system = m_symbol_file->GetTypeSystemForLanguage(eLanguageTypeC);
+ CompilerType void_compiler_type = type_system->GetBasicTypeFromAST(eBasicTypeVoid);
switch (m_encoding_uid_type)
{
case eEncodingIsUID:
- m_clang_type = void_clang_type;
+ m_compiler_type = void_compiler_type;
break;
case eEncodingIsConstUID:
- m_clang_type = void_clang_type.AddConstModifier ();
+ m_compiler_type = void_compiler_type.AddConstModifier();
break;
case eEncodingIsRestrictUID:
- m_clang_type = void_clang_type.AddRestrictModifier ();
+ m_compiler_type = void_compiler_type.AddRestrictModifier();
break;
case eEncodingIsVolatileUID:
- m_clang_type = void_clang_type.AddVolatileModifier ();
+ m_compiler_type = void_compiler_type.AddVolatileModifier();
break;
case eEncodingIsTypedefUID:
- m_clang_type = void_clang_type.CreateTypedefType (GetName().AsCString(),
- GetSymbolFile()->GetClangDeclContextContainingTypeUID(GetID()));
+ m_compiler_type = void_compiler_type.CreateTypedef(GetName().AsCString(),
+ GetSymbolFile()->GetDeclContextContainingUID(GetID()));
break;
case eEncodingIsPointerUID:
- m_clang_type = void_clang_type.GetPointerType ();
+ m_compiler_type = void_compiler_type.GetPointerType ();
break;
case eEncodingIsLValueReferenceUID:
- m_clang_type = void_clang_type.GetLValueReferenceType ();
+ m_compiler_type = void_compiler_type.GetLValueReferenceType();
break;
case eEncodingIsRValueReferenceUID:
- m_clang_type = void_clang_type.GetRValueReferenceType ();
+ m_compiler_type = void_compiler_type.GetRValueReferenceType();
break;
default:
@@ -590,25 +627,25 @@ Type::ResolveClangType (ResolveState clang_type_resolve_state)
}
}
- // When we have a EncodingUID, our "m_flags.clang_type_resolve_state" is set to eResolveStateUnresolved
+ // When we have a EncodingUID, our "m_flags.compiler_type_resolve_state" is set to eResolveStateUnresolved
// so we need to update it to say that we now have a forward declaration since that is what we created
// above.
- if (m_clang_type.IsValid())
- m_flags.clang_type_resolve_state = eResolveStateForward;
+ if (m_compiler_type.IsValid())
+ m_flags.compiler_type_resolve_state = eResolveStateForward;
}
// Check if we have a forward reference to a class/struct/union/enum?
- if (clang_type_resolve_state == eResolveStateLayout || clang_type_resolve_state == eResolveStateFull)
+ if (compiler_type_resolve_state == eResolveStateLayout || compiler_type_resolve_state == eResolveStateFull)
{
// Check if we have a forward reference to a class/struct/union/enum?
- if (m_clang_type.IsValid() && m_flags.clang_type_resolve_state < clang_type_resolve_state)
+ if (m_compiler_type.IsValid() && m_flags.compiler_type_resolve_state < compiler_type_resolve_state)
{
- m_flags.clang_type_resolve_state = eResolveStateFull;
- if (!m_clang_type.IsDefined ())
+ m_flags.compiler_type_resolve_state = eResolveStateFull;
+ if (!m_compiler_type.IsDefined ())
{
// We have a forward declaration, we need to resolve it to a complete definition.
- m_symbol_file->ResolveClangOpaqueTypeDefinition (m_clang_type);
+ m_symbol_file->CompleteType (m_compiler_type);
}
}
}
@@ -621,25 +658,25 @@ Type::ResolveClangType (ResolveState clang_type_resolve_state)
encoding_type = GetEncodingType();
if (encoding_type)
{
- ResolveState encoding_clang_type_resolve_state = clang_type_resolve_state;
+ ResolveState encoding_compiler_type_resolve_state = compiler_type_resolve_state;
- if (clang_type_resolve_state == eResolveStateLayout)
+ if (compiler_type_resolve_state == eResolveStateLayout)
{
switch (m_encoding_uid_type)
{
case eEncodingIsPointerUID:
case eEncodingIsLValueReferenceUID:
case eEncodingIsRValueReferenceUID:
- encoding_clang_type_resolve_state = eResolveStateForward;
+ encoding_compiler_type_resolve_state = eResolveStateForward;
break;
default:
break;
}
}
- encoding_type->ResolveClangType (encoding_clang_type_resolve_state);
+ encoding_type->ResolveClangType (encoding_compiler_type_resolve_state);
}
}
- return m_clang_type.IsValid();
+ return m_compiler_type.IsValid();
}
uint32_t
Type::GetEncodingMask ()
@@ -652,31 +689,25 @@ Type::GetEncodingMask ()
return encoding_mask;
}
-ClangASTType
-Type::GetClangFullType ()
+CompilerType
+Type::GetFullCompilerType ()
{
ResolveClangType(eResolveStateFull);
- return m_clang_type;
+ return m_compiler_type;
}
-ClangASTType
-Type::GetClangLayoutType ()
+CompilerType
+Type::GetLayoutCompilerType ()
{
ResolveClangType(eResolveStateLayout);
- return m_clang_type;
+ return m_compiler_type;
}
-ClangASTType
-Type::GetClangForwardType ()
+CompilerType
+Type::GetForwardCompilerType ()
{
ResolveClangType (eResolveStateForward);
- return m_clang_type;
-}
-
-ClangASTContext &
-Type::GetClangASTContext ()
-{
- return m_symbol_file->GetClangASTContext();
+ return m_compiler_type;
}
int
@@ -690,64 +721,14 @@ Type::Compare(const Type &a, const Type &b)
if (a_uid > b_uid)
return 1;
return 0;
-// if (a.getQualType() == b.getQualType())
-// return 0;
-}
-
-
-#if 0 // START REMOVE
-// Move this into ClangASTType
-void *
-Type::CreateClangPointerType (Type *type)
-{
- assert(type);
- return GetClangASTContext().CreatePointerType(type->GetClangForwardType());
-}
-
-void *
-Type::CreateClangTypedefType (Type *typedef_type, Type *base_type)
-{
- assert(typedef_type && base_type);
- return GetClangASTContext().CreateTypedefType (typedef_type->GetName().AsCString(),
- base_type->GetClangForwardType(),
- typedef_type->GetSymbolFile()->GetClangDeclContextContainingTypeUID(typedef_type->GetID()));
-}
-
-void *
-Type::CreateClangLValueReferenceType (Type *type)
-{
- assert(type);
- return GetClangASTContext().CreateLValueReferenceType(type->GetClangForwardType());
-}
-
-void *
-Type::CreateClangRValueReferenceType (Type *type)
-{
- assert(type);
- return GetClangASTContext().CreateRValueReferenceType (type->GetClangForwardType());
-}
-#endif // END REMOVE
-
-bool
-Type::IsRealObjCClass()
-{
- // For now we are just skipping ObjC classes that get made by hand from the runtime, because
- // those don't have any information. We could extend this to only return true for "full
- // definitions" if we can figure that out.
-
- if (m_clang_type.IsObjCObjectOrInterfaceType() && GetByteSize() != 0)
- return true;
- else
- return false;
}
ConstString
Type::GetQualifiedName ()
{
- return GetClangForwardType().GetConstTypeName();
+ return GetForwardCompilerType ().GetConstTypeName();
}
-
bool
Type::GetTypeScopeAndBasename (const char* &name_cstr,
std::string &scope,
@@ -905,9 +886,9 @@ TypeAndOrName::SetTypeSP (lldb::TypeSP type_sp)
}
void
-TypeAndOrName::SetClangASTType (ClangASTType clang_type)
+TypeAndOrName::SetCompilerType (CompilerType compiler_type)
{
- m_type_pair.SetType(clang_type);
+ m_type_pair.SetType(compiler_type);
if (m_type_pair)
m_type_name = m_type_pair.GetName();
}
@@ -941,9 +922,9 @@ TypeAndOrName::HasTypeSP () const
}
bool
-TypeAndOrName::HasClangASTType () const
+TypeAndOrName::HasCompilerType () const
{
- return m_type_pair.GetClangASTType().IsValid();
+ return m_type_pair.GetCompilerType().IsValid();
}
@@ -969,15 +950,15 @@ TypeImpl::TypeImpl (const lldb::TypeSP &type_sp) :
SetType (type_sp);
}
-TypeImpl::TypeImpl (const ClangASTType &clang_type) :
+TypeImpl::TypeImpl (const CompilerType &compiler_type) :
m_module_wp (),
m_static_type(),
m_dynamic_type()
{
- SetType (clang_type);
+ SetType (compiler_type);
}
-TypeImpl::TypeImpl (const lldb::TypeSP &type_sp, const ClangASTType &dynamic) :
+TypeImpl::TypeImpl (const lldb::TypeSP &type_sp, const CompilerType &dynamic) :
m_module_wp (),
m_static_type (type_sp),
m_dynamic_type(dynamic)
@@ -985,7 +966,7 @@ TypeImpl::TypeImpl (const lldb::TypeSP &type_sp, const ClangASTType &dynamic) :
SetType (type_sp, dynamic);
}
-TypeImpl::TypeImpl (const ClangASTType &static_type, const ClangASTType &dynamic_type) :
+TypeImpl::TypeImpl (const CompilerType &static_type, const CompilerType &dynamic_type) :
m_module_wp (),
m_static_type (),
m_dynamic_type()
@@ -993,7 +974,7 @@ TypeImpl::TypeImpl (const ClangASTType &static_type, const ClangASTType &dynamic
SetType (static_type, dynamic_type);
}
-TypeImpl::TypeImpl (const TypePair &pair, const ClangASTType &dynamic) :
+TypeImpl::TypeImpl (const TypePair &pair, const CompilerType &dynamic) :
m_module_wp (),
m_static_type (),
m_dynamic_type()
@@ -1012,29 +993,29 @@ TypeImpl::SetType (const lldb::TypeSP &type_sp)
}
void
-TypeImpl::SetType (const ClangASTType &clang_type)
+TypeImpl::SetType (const CompilerType &compiler_type)
{
m_module_wp = lldb::ModuleWP();
- m_static_type.SetType (clang_type);
+ m_static_type.SetType (compiler_type);
}
void
-TypeImpl::SetType (const lldb::TypeSP &type_sp, const ClangASTType &dynamic)
+TypeImpl::SetType (const lldb::TypeSP &type_sp, const CompilerType &dynamic)
{
SetType (type_sp);
m_dynamic_type = dynamic;
}
void
-TypeImpl::SetType (const ClangASTType &clang_type, const ClangASTType &dynamic)
+TypeImpl::SetType (const CompilerType &compiler_type, const CompilerType &dynamic)
{
m_module_wp = lldb::ModuleWP();
- m_static_type.SetType (clang_type);
+ m_static_type.SetType (compiler_type);
m_dynamic_type = dynamic;
}
void
-TypeImpl::SetType (const TypePair &pair, const ClangASTType &dynamic)
+TypeImpl::SetType (const TypePair &pair, const CompilerType &dynamic)
{
m_module_wp = pair.GetModule();
m_static_type = pair;
@@ -1249,8 +1230,8 @@ TypeImpl::GetCanonicalType() const
return TypeImpl();
}
-ClangASTType
-TypeImpl::GetClangASTType (bool prefer_dynamic)
+CompilerType
+TypeImpl::GetCompilerType (bool prefer_dynamic)
{
ModuleSP module_sp;
if (CheckModule (module_sp))
@@ -1260,13 +1241,13 @@ TypeImpl::GetClangASTType (bool prefer_dynamic)
if (m_dynamic_type.IsValid())
return m_dynamic_type;
}
- return m_static_type.GetClangASTType();
+ return m_static_type.GetCompilerType();
}
- return ClangASTType();
+ return CompilerType();
}
-clang::ASTContext *
-TypeImpl::GetClangASTContext (bool prefer_dynamic)
+TypeSystem *
+TypeImpl::GetTypeSystem (bool prefer_dynamic)
{
ModuleSP module_sp;
if (CheckModule (module_sp))
@@ -1274,9 +1255,9 @@ TypeImpl::GetClangASTContext (bool prefer_dynamic)
if (prefer_dynamic)
{
if (m_dynamic_type.IsValid())
- return m_dynamic_type.GetASTContext();
+ return m_dynamic_type.GetTypeSystem();
}
- return m_static_type.GetClangASTContext();
+ return m_static_type.GetCompilerType().GetTypeSystem();
}
return NULL;
}
@@ -1294,7 +1275,7 @@ TypeImpl::GetDescription (lldb_private::Stream &strm,
m_dynamic_type.DumpTypeDescription(&strm);
strm.Printf("\nStatic:\n");
}
- m_static_type.GetClangASTType().DumpTypeDescription(&strm);
+ m_static_type.GetCompilerType().DumpTypeDescription(&strm);
}
else
{
@@ -1303,19 +1284,6 @@ TypeImpl::GetDescription (lldb_private::Stream &strm,
return true;
}
-TypeMemberFunctionImpl&
-TypeMemberFunctionImpl::operator = (const TypeMemberFunctionImpl& rhs)
-{
- if (this != &rhs)
- {
- m_type = rhs.m_type;
- m_objc_method_decl = rhs.m_objc_method_decl;
- m_name = rhs.m_name;
- m_kind = rhs.m_kind;
- }
- return *this;
-}
-
bool
TypeMemberFunctionImpl::IsValid ()
{
@@ -1328,7 +1296,13 @@ TypeMemberFunctionImpl::GetName () const
return m_name;
}
-ClangASTType
+ConstString
+TypeMemberFunctionImpl::GetMangledName () const
+{
+ return m_decl.GetMangledName();
+}
+
+CompilerType
TypeMemberFunctionImpl::GetType () const
{
return m_type;
@@ -1340,21 +1314,6 @@ TypeMemberFunctionImpl::GetKind () const
return m_kind;
}
-std::string
-TypeMemberFunctionImpl::GetPrintableTypeName ()
-{
- if (m_type)
- return m_type.GetTypeName().AsCString("<unknown>");
- if (m_objc_method_decl)
- {
- if (m_objc_method_decl->getClassInterface())
- {
- return m_objc_method_decl->getClassInterface()->getName();
- }
- }
- return "<unknown>";
-}
-
bool
TypeMemberFunctionImpl::GetDescription (Stream& stream)
{
@@ -1362,33 +1321,31 @@ TypeMemberFunctionImpl::GetDescription (Stream& stream)
case lldb::eMemberFunctionKindUnknown:
return false;
case lldb::eMemberFunctionKindConstructor:
- stream.Printf("constructor for %s", GetPrintableTypeName().c_str());
+ stream.Printf("constructor for %s", m_type.GetTypeName().AsCString("<unknown>"));
break;
case lldb::eMemberFunctionKindDestructor:
- stream.Printf("destructor for %s", GetPrintableTypeName().c_str());
+ stream.Printf("destructor for %s", m_type.GetTypeName().AsCString("<unknown>"));
break;
case lldb::eMemberFunctionKindInstanceMethod:
stream.Printf("instance method %s of type %s",
m_name.AsCString(),
- GetPrintableTypeName().c_str());
+ m_decl.GetDeclContext().GetName().AsCString());
break;
case lldb::eMemberFunctionKindStaticMethod:
stream.Printf("static method %s of type %s",
m_name.AsCString(),
- GetPrintableTypeName().c_str());
+ m_decl.GetDeclContext().GetName().AsCString());
break;
}
return true;
}
-ClangASTType
+CompilerType
TypeMemberFunctionImpl::GetReturnType () const
{
if (m_type)
return m_type.GetFunctionReturnType();
- if (m_objc_method_decl)
- return ClangASTType(&m_objc_method_decl->getASTContext(),m_objc_method_decl->getReturnType().getAsOpaquePtr());
- return ClangASTType();
+ return m_decl.GetFunctionReturnType();
}
size_t
@@ -1396,37 +1353,26 @@ TypeMemberFunctionImpl::GetNumArguments () const
{
if (m_type)
return m_type.GetNumberOfFunctionArguments();
- if (m_objc_method_decl)
- return m_objc_method_decl->param_size();
- return 0;
+ else
+ return m_decl.GetNumFunctionArguments();
}
-ClangASTType
+CompilerType
TypeMemberFunctionImpl::GetArgumentAtIndex (size_t idx) const
{
if (m_type)
return m_type.GetFunctionArgumentAtIndex (idx);
- if (m_objc_method_decl)
- {
- if (idx < m_objc_method_decl->param_size())
- return ClangASTType(&m_objc_method_decl->getASTContext(), m_objc_method_decl->parameters()[idx]->getOriginalType().getAsOpaquePtr());
- }
- return ClangASTType();
+ else
+ return m_decl.GetFunctionArgumentType(idx);
}
-TypeEnumMemberImpl::TypeEnumMemberImpl (const clang::EnumConstantDecl* enum_member_decl,
- const lldb_private::ClangASTType& integer_type) :
- m_integer_type_sp(),
- m_name(),
- m_value(),
- m_valid(false)
+TypeEnumMemberImpl::TypeEnumMemberImpl (const lldb::TypeImplSP &integer_type_sp,
+ const 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)
{
- if (enum_member_decl)
- {
- m_integer_type_sp.reset(new TypeImpl(integer_type));
- m_name = ConstString(enum_member_decl->getNameAsString().c_str());
- m_value = enum_member_decl->getInitVal();
- m_valid = true;
- }
}
diff --git a/source/Symbol/TypeList.cpp b/source/Symbol/TypeList.cpp
index 8d97b2ba25cc..f181dd66463c 100644
--- a/source/Symbol/TypeList.cpp
+++ b/source/Symbol/TypeList.cpp
@@ -13,18 +13,6 @@
#include <vector>
// Other libraries and framework includes
-#include "clang/AST/ASTConsumer.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/DeclCXX.h"
-#include "clang/AST/DeclGroup.h"
-
-#include "clang/Basic/Builtins.h"
-#include "clang/Basic/IdentifierTable.h"
-#include "clang/Basic/LangOptions.h"
-#include "clang/Basic/SourceManager.h"
-#include "clang/Basic/TargetInfo.h"
-
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/raw_ostream.h"
@@ -36,7 +24,6 @@
using namespace lldb;
using namespace lldb_private;
-using namespace clang;
TypeList::TypeList() :
m_types ()
@@ -55,26 +42,7 @@ TypeList::Insert (const TypeSP& type_sp)
{
// Just push each type on the back for now. We will worry about uniquing later
if (type_sp)
- m_types.insert(std::make_pair(type_sp->GetID(), type_sp));
-}
-
-
-bool
-TypeList::InsertUnique (const TypeSP& type_sp)
-{
- if (type_sp)
- {
- user_id_t type_uid = type_sp->GetID();
- iterator pos, end = m_types.end();
-
- for (pos = m_types.find(type_uid); pos != end && pos->second->GetID() == type_uid; ++pos)
- {
- if (pos->second.get() == type_sp.get())
- return false;
- }
- }
- Insert (type_sp);
- return true;
+ m_types.push_back(type_sp);
}
//----------------------------------------------------------------------
@@ -129,7 +97,7 @@ TypeList::GetTypeAtIndex(uint32_t idx)
for (pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
{
if (i == 0)
- return pos->second;
+ return *pos;
--i;
}
return TypeSP();
@@ -140,7 +108,7 @@ TypeList::ForEach (std::function <bool(const lldb::TypeSP &type_sp)> const &call
{
for (auto pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
{
- if (!callback(pos->second))
+ if (!callback(*pos))
break;
}
}
@@ -150,32 +118,17 @@ TypeList::ForEach (std::function <bool(lldb::TypeSP &type_sp)> const &callback)
{
for (auto pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
{
- if (!callback(pos->second))
+ if (!callback(*pos))
break;
}
}
-
-bool
-TypeList::RemoveTypeWithUID (user_id_t uid)
-{
- iterator pos = m_types.find(uid);
-
- if (pos != m_types.end())
- {
- m_types.erase(pos);
- return true;
- }
- return false;
-}
-
-
void
TypeList::Dump(Stream *s, bool show_context)
{
for (iterator pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
{
- pos->second->Dump(s, show_context);
+ pos->get()->Dump(s, show_context);
}
}
@@ -210,13 +163,13 @@ TypeList::RemoveMismatchedTypes (const std::string &type_scope,
for (pos = m_types.begin(); pos != end; ++pos)
{
- Type* the_type = pos->second.get();
+ Type* the_type = pos->get();
bool keep_match = false;
TypeClass match_type_class = eTypeClassAny;
if (type_class != eTypeClassAny)
{
- match_type_class = the_type->GetClangForwardType().GetTypeClass ();
+ match_type_class = the_type->GetForwardCompilerType ().GetTypeClass ();
if ((match_type_class & type_class) == 0)
continue;
}
@@ -249,9 +202,9 @@ TypeList::RemoveMismatchedTypes (const std::string &type_scope,
{
if (type_scope_pos >= 2)
{
- // Our match scope ends with the type scope we were lookikng for,
+ // Our match scope ends with the type scope we were looking for,
// but we need to make sure what comes before the matching
- // type scope is a namepace boundary in case we are trying to match:
+ // type scope is a namespace boundary in case we are trying to match:
// type_basename = "d"
// type_scope = "b::c::"
// We want to match:
@@ -282,7 +235,7 @@ TypeList::RemoveMismatchedTypes (const std::string &type_scope,
if (keep_match)
{
- matching_types.insert (*pos);
+ matching_types.push_back(*pos);
}
}
m_types.swap(matching_types);
@@ -304,10 +257,10 @@ TypeList::RemoveMismatchedTypes (TypeClass type_class)
for (pos = m_types.begin(); pos != end; ++pos)
{
- Type* the_type = pos->second.get();
- TypeClass match_type_class = the_type->GetClangForwardType().GetTypeClass ();
+ Type* the_type = pos->get();
+ TypeClass match_type_class = the_type->GetForwardCompilerType ().GetTypeClass ();
if (match_type_class & type_class)
- matching_types.insert (*pos);
+ matching_types.push_back (*pos);
}
m_types.swap(matching_types);
}
diff --git a/source/Symbol/TypeMap.cpp b/source/Symbol/TypeMap.cpp
new file mode 100644
index 000000000000..6dc22ccbda96
--- /dev/null
+++ b/source/Symbol/TypeMap.cpp
@@ -0,0 +1,322 @@
+//===-- TypeMap.cpp --------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// C Includes
+// C++ Includes
+#include <vector>
+
+// Other libraries and framework includes
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclGroup.h"
+
+#include "clang/Basic/Builtins.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TargetInfo.h"
+
+#include "llvm/Support/FormattedStream.h"
+#include "llvm/Support/raw_ostream.h"
+
+// Project includes
+#include "lldb/Symbol/SymbolFile.h"
+#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/TypeMap.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace clang;
+
+TypeMap::TypeMap() :
+ m_types ()
+{
+}
+
+//----------------------------------------------------------------------
+// Destructor
+//----------------------------------------------------------------------
+TypeMap::~TypeMap()
+{
+}
+
+void
+TypeMap::Insert (const TypeSP& type_sp)
+{
+ // Just push each type on the back for now. We will worry about uniquing later
+ if (type_sp)
+ m_types.insert(std::make_pair(type_sp->GetID(), type_sp));
+}
+
+
+bool
+TypeMap::InsertUnique (const TypeSP& type_sp)
+{
+ if (type_sp)
+ {
+ user_id_t type_uid = type_sp->GetID();
+ iterator pos, end = m_types.end();
+
+ for (pos = m_types.find(type_uid); pos != end && pos->second->GetID() == type_uid; ++pos)
+ {
+ if (pos->second.get() == type_sp.get())
+ return false;
+ }
+ Insert (type_sp);
+ }
+ return true;
+}
+
+//----------------------------------------------------------------------
+// Find a base type by its unique ID.
+//----------------------------------------------------------------------
+//TypeSP
+//TypeMap::FindType(lldb::user_id_t uid)
+//{
+// iterator pos = m_types.find(uid);
+// if (pos != m_types.end())
+// return pos->second;
+// return TypeSP();
+//}
+
+//----------------------------------------------------------------------
+// Find a type by name.
+//----------------------------------------------------------------------
+//TypeMap
+//TypeMap::FindTypes (const 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.
+// TypeMap types(m_ast.getTargetInfo()->getTriple().getTriple().c_str());
+// iterator pos, end;
+// for (pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
+// if (pos->second->GetName() == name)
+// types.Insert (pos->second);
+// return types;
+//}
+
+void
+TypeMap::Clear()
+{
+ m_types.clear();
+}
+
+uint32_t
+TypeMap::GetSize() const
+{
+ return m_types.size();
+}
+
+bool
+TypeMap::Empty() const
+{
+ return m_types.empty();
+}
+
+// GetTypeAtIndex isn't used a lot for large type lists, currently only for
+// type lists that are returned for "image dump -t TYPENAME" commands and other
+// simple symbol queries that grab the first result...
+
+TypeSP
+TypeMap::GetTypeAtIndex(uint32_t idx)
+{
+ iterator pos, end;
+ uint32_t i = idx;
+ for (pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
+ {
+ if (i == 0)
+ return pos->second;
+ --i;
+ }
+ return TypeSP();
+}
+
+void
+TypeMap::ForEach (std::function <bool(const lldb::TypeSP &type_sp)> const &callback) const
+{
+ for (auto pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
+ {
+ if (!callback(pos->second))
+ break;
+ }
+}
+
+void
+TypeMap::ForEach (std::function <bool(lldb::TypeSP &type_sp)> const &callback)
+{
+ for (auto pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
+ {
+ if (!callback(pos->second))
+ break;
+ }
+}
+
+bool
+TypeMap::Remove (const lldb::TypeSP &type_sp)
+{
+ if (type_sp)
+ {
+ lldb::user_id_t uid = type_sp->GetID();
+ for (iterator pos = m_types.find(uid), end = m_types.end(); pos != end && pos->first == uid; ++pos)
+ {
+ if (pos->second == type_sp)
+ {
+ m_types.erase(pos);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+void
+TypeMap::Dump(Stream *s, bool show_context)
+{
+ for (iterator pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
+ {
+ pos->second->Dump(s, show_context);
+ }
+}
+
+void
+TypeMap::RemoveMismatchedTypes (const char *qualified_typename,
+ bool exact_match)
+{
+ std::string type_scope;
+ std::string type_basename;
+ TypeClass type_class = eTypeClassAny;
+ if (!Type::GetTypeScopeAndBasename (qualified_typename, type_scope, type_basename, type_class))
+ {
+ type_basename = qualified_typename;
+ type_scope.clear();
+ }
+ return RemoveMismatchedTypes (type_scope, type_basename, type_class, exact_match);
+}
+
+void
+TypeMap::RemoveMismatchedTypes (const std::string &type_scope,
+ const std::string &type_basename,
+ TypeClass type_class,
+ bool exact_match)
+{
+ // Our "collection" type currently is a std::map which doesn't
+ // have any good way to iterate and remove items from the map
+ // so we currently just make a new list and add all of the matching
+ // types to it, and then swap it into m_types at the end
+ collection matching_types;
+
+ iterator pos, end = m_types.end();
+
+ for (pos = m_types.begin(); pos != end; ++pos)
+ {
+ Type* the_type = pos->second.get();
+ bool keep_match = false;
+ TypeClass match_type_class = eTypeClassAny;
+
+ if (type_class != eTypeClassAny)
+ {
+ match_type_class = the_type->GetForwardCompilerType ().GetTypeClass ();
+ if ((match_type_class & type_class) == 0)
+ continue;
+ }
+
+ ConstString match_type_name_const_str (the_type->GetQualifiedName());
+ if (match_type_name_const_str)
+ {
+ const char *match_type_name = match_type_name_const_str.GetCString();
+ std::string match_type_scope;
+ std::string match_type_basename;
+ if (Type::GetTypeScopeAndBasename (match_type_name,
+ match_type_scope,
+ match_type_basename,
+ match_type_class))
+ {
+ if (match_type_basename == type_basename)
+ {
+ const size_t type_scope_size = type_scope.size();
+ const size_t match_type_scope_size = match_type_scope.size();
+ if (exact_match || (type_scope_size == match_type_scope_size))
+ {
+ keep_match = match_type_scope == type_scope;
+ }
+ else
+ {
+ if (match_type_scope_size > type_scope_size)
+ {
+ const size_t type_scope_pos = match_type_scope.rfind(type_scope);
+ if (type_scope_pos == match_type_scope_size - type_scope_size)
+ {
+ if (type_scope_pos >= 2)
+ {
+ // Our match scope ends with the type scope we were looking for,
+ // but we need to make sure what comes before the matching
+ // type scope is a namespace boundary in case we are trying to match:
+ // type_basename = "d"
+ // type_scope = "b::c::"
+ // We want to match:
+ // match_type_scope "a::b::c::"
+ // But not:
+ // match_type_scope "a::bb::c::"
+ // So below we make sure what comes before "b::c::" in match_type_scope
+ // is "::", or the namespace boundary
+ if (match_type_scope[type_scope_pos - 1] == ':' &&
+ match_type_scope[type_scope_pos - 2] == ':')
+ {
+ keep_match = true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ // The type we are currently looking at doesn't exists
+ // in a namespace or class, so it only matches if there
+ // is no type scope...
+ keep_match = type_scope.empty() && type_basename.compare(match_type_name) == 0;
+ }
+ }
+
+ if (keep_match)
+ {
+ matching_types.insert (*pos);
+ }
+ }
+ m_types.swap(matching_types);
+}
+
+void
+TypeMap::RemoveMismatchedTypes (TypeClass type_class)
+{
+ if (type_class == eTypeClassAny)
+ return;
+
+ // Our "collection" type currently is a std::map which doesn't
+ // have any good way to iterate and remove items from the map
+ // so we currently just make a new list and add all of the matching
+ // types to it, and then swap it into m_types at the end
+ collection matching_types;
+
+ iterator pos, end = m_types.end();
+
+ for (pos = m_types.begin(); pos != end; ++pos)
+ {
+ Type* the_type = pos->second.get();
+ TypeClass match_type_class = the_type->GetForwardCompilerType ().GetTypeClass ();
+ if (match_type_class & type_class)
+ matching_types.insert (*pos);
+ }
+ m_types.swap(matching_types);
+}
diff --git a/source/Symbol/TypeSystem.cpp b/source/Symbol/TypeSystem.cpp
new file mode 100644
index 000000000000..5c2ab5cceab6
--- /dev/null
+++ b/source/Symbol/TypeSystem.cpp
@@ -0,0 +1,255 @@
+//
+// TypeSystem.cpp
+// lldb
+//
+// Created by Ryan Brown on 3/29/15.
+//
+//
+
+#include "lldb/Symbol/TypeSystem.h"
+
+#include <set>
+
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Symbol/CompilerType.h"
+
+using namespace lldb_private;
+
+TypeSystem::TypeSystem(LLVMCastKind kind) :
+ m_kind (kind),
+ m_sym_file (nullptr)
+{
+}
+
+TypeSystem::~TypeSystem()
+{
+}
+
+lldb::TypeSystemSP
+TypeSystem::CreateInstance (lldb::LanguageType language, Module *module)
+{
+ uint32_t i = 0;
+ TypeSystemCreateInstance create_callback;
+ while ((create_callback = PluginManager::GetTypeSystemCreateCallbackAtIndex (i++)) != nullptr)
+ {
+ lldb::TypeSystemSP type_system_sp = create_callback(language, module, nullptr);
+ if (type_system_sp)
+ return type_system_sp;
+ }
+
+ return lldb::TypeSystemSP();
+}
+
+lldb::TypeSystemSP
+TypeSystem::CreateInstance (lldb::LanguageType language, Target *target)
+{
+ uint32_t i = 0;
+ TypeSystemCreateInstance create_callback;
+ while ((create_callback = PluginManager::GetTypeSystemCreateCallbackAtIndex (i++)) != nullptr)
+ {
+ lldb::TypeSystemSP type_system_sp = create_callback(language, nullptr, target);
+ if (type_system_sp)
+ return type_system_sp;
+ }
+
+ return lldb::TypeSystemSP();
+}
+
+bool
+TypeSystem::IsAnonymousType (lldb::opaque_compiler_type_t type)
+{
+ return false;
+}
+
+CompilerType
+TypeSystem::GetLValueReferenceType (lldb::opaque_compiler_type_t type)
+{
+ return CompilerType();
+}
+
+CompilerType
+TypeSystem::GetRValueReferenceType (lldb::opaque_compiler_type_t type)
+{
+ return CompilerType();
+}
+
+CompilerType
+TypeSystem::AddConstModifier (lldb::opaque_compiler_type_t type)
+{
+ return CompilerType();
+}
+
+CompilerType
+TypeSystem::AddVolatileModifier (lldb::opaque_compiler_type_t type)
+{
+ return CompilerType();
+}
+
+CompilerType
+TypeSystem::AddRestrictModifier (lldb::opaque_compiler_type_t type)
+{
+ return CompilerType();
+}
+
+CompilerType
+TypeSystem::CreateTypedef (lldb::opaque_compiler_type_t type, const char *name, const CompilerDeclContext &decl_ctx)
+{
+ return CompilerType();
+}
+
+CompilerType
+TypeSystem::GetBuiltinTypeByName (const ConstString &name)
+{
+ return CompilerType();
+}
+
+CompilerType
+TypeSystem::GetTypeForFormatters (void* type)
+{
+ return CompilerType(this, type);
+}
+
+LazyBool
+TypeSystem::ShouldPrintAsOneLiner (void* type, ValueObject* valobj)
+{
+ return eLazyBoolCalculate;
+}
+
+bool
+TypeSystem::IsMeaninglessWithoutDynamicResolution (void* type)
+{
+ return false;
+}
+
+ConstString
+TypeSystem::DeclGetMangledName (void *opaque_decl)
+{
+ return ConstString();
+}
+
+CompilerDeclContext
+TypeSystem::DeclGetDeclContext (void *opaque_decl)
+{
+ return CompilerDeclContext();
+}
+
+CompilerType
+TypeSystem::DeclGetFunctionReturnType(void *opaque_decl)
+{
+ return CompilerType();
+}
+
+size_t
+TypeSystem::DeclGetFunctionNumArguments(void *opaque_decl)
+{
+ return 0;
+}
+
+CompilerType
+TypeSystem::DeclGetFunctionArgumentType (void *opaque_decl, size_t arg_idx)
+{
+ return CompilerType();
+}
+
+
+std::vector<CompilerDecl>
+TypeSystem::DeclContextFindDeclByName (void *opaque_decl_ctx, ConstString name)
+{
+ return std::vector<CompilerDecl>();
+}
+
+
+#pragma mark TypeSystemMap
+
+TypeSystemMap::TypeSystemMap() :
+ m_mutex (),
+ m_map ()
+{
+}
+
+TypeSystemMap::~TypeSystemMap()
+{
+}
+
+void
+TypeSystemMap::Clear ()
+{
+ Mutex::Locker locker (m_mutex);
+ m_map.clear();
+}
+
+
+void
+TypeSystemMap::ForEach (std::function <bool(TypeSystem *)> const &callback)
+{
+ Mutex::Locker locker (m_mutex);
+ // Use a std::set so we only call the callback once for each unique
+ // TypeSystem instance
+ std::set<TypeSystem *> visited;
+ for (auto pair : m_map)
+ {
+ TypeSystem *type_system = pair.second.get();
+ if (type_system && !visited.count(type_system))
+ {
+ visited.insert(type_system);
+ if (callback (type_system) == false)
+ break;
+ }
+ }
+}
+
+TypeSystem *
+TypeSystemMap::GetTypeSystemForLanguage (lldb::LanguageType language, Module *module, bool can_create)
+{
+ Mutex::Locker locker (m_mutex);
+ collection::iterator pos = m_map.find(language);
+ if (pos != m_map.end())
+ return pos->second.get();
+
+ for (const auto &pair : m_map)
+ {
+ if (pair.second && pair.second->SupportsLanguage(language))
+ {
+ // Add a new mapping for "language" to point to an already existing
+ // TypeSystem that supports this language
+ m_map[language] = pair.second;
+ return pair.second.get();
+ }
+ }
+
+ if (!can_create)
+ return nullptr;
+
+ // Cache even if we get a shared pointer that contains null type system back
+ lldb::TypeSystemSP type_system_sp = TypeSystem::CreateInstance (language, module);
+ m_map[language] = type_system_sp;
+ return type_system_sp.get();
+}
+
+TypeSystem *
+TypeSystemMap::GetTypeSystemForLanguage (lldb::LanguageType language, Target *target, bool can_create)
+{
+ Mutex::Locker locker (m_mutex);
+ collection::iterator pos = m_map.find(language);
+ if (pos != m_map.end())
+ return pos->second.get();
+
+ for (const auto &pair : m_map)
+ {
+ if (pair.second && pair.second->SupportsLanguage(language))
+ {
+ // Add a new mapping for "language" to point to an already existing
+ // TypeSystem that supports this language
+ m_map[language] = pair.second;
+ return pair.second.get();
+ }
+ }
+
+ if (!can_create)
+ return nullptr;
+
+ // Cache even if we get a shared pointer that contains null type system back
+ lldb::TypeSystemSP type_system_sp = TypeSystem::CreateInstance (language, target);
+ m_map[language] = type_system_sp;
+ return type_system_sp.get();
+}
diff --git a/source/Symbol/UnwindTable.cpp b/source/Symbol/UnwindTable.cpp
index 90b33a69a789..ac7a9b0fda87 100644
--- a/source/Symbol/UnwindTable.cpp
+++ b/source/Symbol/UnwindTable.cpp
@@ -17,6 +17,7 @@
#include "lldb/Symbol/FuncUnwinders.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/DWARFCallFrameInfo.h"
+#include "lldb/Symbol/ArmUnwindInfo.h"
#include "lldb/Symbol/CompactUnwindInfo.h"
// There is one UnwindTable object per ObjectFile.
@@ -31,8 +32,9 @@ UnwindTable::UnwindTable (ObjectFile& objfile) :
m_unwinds (),
m_initialized (false),
m_mutex (),
- m_eh_frame (nullptr),
- m_compact_unwind (nullptr)
+ m_eh_frame_up (),
+ m_compact_unwind_up (),
+ m_arm_unwind_up ()
{
}
@@ -56,12 +58,21 @@ UnwindTable::Initialize ()
SectionSP sect = sl->FindSectionByType (eSectionTypeEHFrame, true);
if (sect.get())
{
- m_eh_frame = new DWARFCallFrameInfo(m_object_file, sect, eRegisterKindGCC, true);
+ m_eh_frame_up.reset(new DWARFCallFrameInfo(m_object_file, sect, eRegisterKindEHFrame, true));
}
sect = sl->FindSectionByType (eSectionTypeCompactUnwind, true);
if (sect.get())
{
- m_compact_unwind = new CompactUnwindInfo(m_object_file, sect);
+ m_compact_unwind_up.reset(new CompactUnwindInfo(m_object_file, sect));
+ }
+ sect = sl->FindSectionByType (eSectionTypeARMexidx, true);
+ if (sect.get())
+ {
+ SectionSP sect_extab = sl->FindSectionByType (eSectionTypeARMextab, true);
+ if (sect_extab.get())
+ {
+ m_arm_unwind_up.reset(new ArmUnwindInfo(m_object_file, sect, sect_extab));
+ }
}
}
@@ -70,8 +81,6 @@ UnwindTable::Initialize ()
UnwindTable::~UnwindTable ()
{
- if (m_eh_frame)
- delete m_eh_frame;
}
FuncUnwindersSP
@@ -102,7 +111,7 @@ UnwindTable::GetFuncUnwindersContainingAddress (const Address& addr, SymbolConte
if (!sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0, false, range) || !range.GetBaseAddress().IsValid())
{
// Does the eh_frame unwind info has a function bounds for this addr?
- if (m_eh_frame == nullptr || !m_eh_frame->GetAddressRange (addr, range))
+ if (m_eh_frame_up == nullptr || !m_eh_frame_up->GetAddressRange (addr, range))
{
return no_unwind_found;
}
@@ -129,7 +138,7 @@ UnwindTable::GetUncachedFuncUnwindersContainingAddress (const Address& addr, Sym
if (!sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0, false, range) || !range.GetBaseAddress().IsValid())
{
// Does the eh_frame unwind info has a function bounds for this addr?
- if (m_eh_frame == nullptr || !m_eh_frame->GetAddressRange (addr, range))
+ if (m_eh_frame_up == nullptr || !m_eh_frame_up->GetAddressRange (addr, range))
{
return no_unwind_found;
}
@@ -158,14 +167,21 @@ DWARFCallFrameInfo *
UnwindTable::GetEHFrameInfo ()
{
Initialize();
- return m_eh_frame;
+ return m_eh_frame_up.get();
}
CompactUnwindInfo *
UnwindTable::GetCompactUnwindInfo ()
{
Initialize();
- return m_compact_unwind;
+ return m_compact_unwind_up.get();
+}
+
+ArmUnwindInfo *
+UnwindTable::GetArmUnwindInfo ()
+{
+ Initialize();
+ return m_arm_unwind_up.get();
}
bool
diff --git a/source/Symbol/Variable.cpp b/source/Symbol/Variable.cpp
index 2490e98ac1e8..51d11b7ca8e9 100644
--- a/source/Symbol/Variable.cpp
+++ b/source/Symbol/Variable.cpp
@@ -15,10 +15,14 @@
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Symbol/Block.h"
+#include "lldb/Symbol/CompilerDecl.h"
+#include "lldb/Symbol/CompilerDeclContext.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/Process.h"
@@ -33,19 +37,17 @@ 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.
- const lldb::SymbolFileTypeSP &symfile_type_sp,
- ValueType scope,
- SymbolContextScope *context,
- Declaration* decl_ptr,
- const DWARFExpression& location,
- bool external,
- bool artificial
-) :
+Variable::Variable (lldb::user_id_t uid,
+ const char *name,
+ const char *mangled, // The mangled or fully qualified name of the variable.
+ const lldb::SymbolFileTypeSP &symfile_type_sp,
+ ValueType scope,
+ SymbolContextScope *context,
+ Declaration* decl_ptr,
+ const DWARFExpression& location,
+ bool external,
+ bool artificial,
+ bool static_member) :
UserID(uid),
m_name(name),
m_mangled (ConstString(mangled)),
@@ -55,7 +57,8 @@ Variable::Variable
m_declaration(decl_ptr),
m_location(location),
m_external(external),
- m_artificial(artificial)
+ m_artificial(artificial),
+ m_static_member(static_member)
{
}
@@ -87,6 +90,13 @@ Variable::GetName() const
return m_name;
}
+ConstString
+Variable::GetUnqualifiedName() const
+{
+ return m_name;
+}
+
+
bool
Variable::NameMatches (const ConstString &name) const
{
@@ -228,6 +238,22 @@ Variable::MemorySize() const
return sizeof(Variable);
}
+CompilerDeclContext
+Variable::GetDeclContext ()
+{
+ Type *type = GetType();
+ return type->GetSymbolFile()->GetDeclContextContainingUID(GetID());
+}
+
+CompilerDecl
+Variable::GetDecl ()
+{
+ Type *type = GetType();
+ CompilerDecl decl = type->GetSymbolFile()->GetDeclForUID(GetID());
+ if (decl)
+ decl.GetTypeSystem()->DeclLinkToObject(decl.GetOpaqueDecl(), shared_from_this());
+ return decl;
+}
void
Variable::CalculateSymbolContext (SymbolContext *sc)
@@ -558,7 +584,7 @@ static void
PrivateAutoComplete (StackFrame *frame,
const std::string &partial_path,
const std::string &prefix_path, // Anything that has been resolved already will be in here
- const ClangASTType& clang_type,
+ const CompilerType& compiler_type,
StringList &matches,
bool &word_complete);
@@ -567,7 +593,7 @@ PrivateAutoCompleteMembers (StackFrame *frame,
const std::string &partial_member_name,
const std::string &partial_path,
const std::string &prefix_path, // Anything that has been resolved already will be in here
- const ClangASTType& clang_type,
+ const CompilerType& compiler_type,
StringList &matches,
bool &word_complete);
@@ -576,19 +602,19 @@ PrivateAutoCompleteMembers (StackFrame *frame,
const std::string &partial_member_name,
const std::string &partial_path,
const std::string &prefix_path, // Anything that has been resolved already will be in here
- const ClangASTType& clang_type,
+ const CompilerType& compiler_type,
StringList &matches,
bool &word_complete)
{
// We are in a type parsing child members
- const uint32_t num_bases = clang_type.GetNumDirectBaseClasses();
+ const uint32_t num_bases = compiler_type.GetNumDirectBaseClasses();
if (num_bases > 0)
{
for (uint32_t i = 0; i < num_bases; ++i)
{
- ClangASTType base_class_type (clang_type.GetDirectBaseClassAtIndex (i, nullptr));
+ CompilerType base_class_type = compiler_type.GetDirectBaseClassAtIndex(i, nullptr);
PrivateAutoCompleteMembers (frame,
partial_member_name,
@@ -600,13 +626,13 @@ PrivateAutoCompleteMembers (StackFrame *frame,
}
}
- const uint32_t num_vbases = clang_type.GetNumVirtualBaseClasses();
+ const uint32_t num_vbases = compiler_type.GetNumVirtualBaseClasses();
if (num_vbases > 0)
{
for (uint32_t i = 0; i < num_vbases; ++i)
{
- ClangASTType vbase_class_type (clang_type.GetVirtualBaseClassAtIndex(i,nullptr));
+ CompilerType vbase_class_type = compiler_type.GetVirtualBaseClassAtIndex(i,nullptr);
PrivateAutoCompleteMembers (frame,
partial_member_name,
@@ -619,7 +645,7 @@ PrivateAutoCompleteMembers (StackFrame *frame,
}
// We are in a type parsing child members
- const uint32_t num_fields = clang_type.GetNumFields();
+ const uint32_t num_fields = compiler_type.GetNumFields();
if (num_fields > 0)
{
@@ -627,7 +653,7 @@ PrivateAutoCompleteMembers (StackFrame *frame,
{
std::string member_name;
- ClangASTType member_clang_type = clang_type.GetFieldAtIndex (i, member_name, nullptr, nullptr, nullptr);
+ CompilerType member_compiler_type = compiler_type.GetFieldAtIndex (i, member_name, nullptr, nullptr, nullptr);
if (partial_member_name.empty() ||
member_name.find(partial_member_name) == 0)
@@ -637,7 +663,7 @@ PrivateAutoCompleteMembers (StackFrame *frame,
PrivateAutoComplete (frame,
partial_path,
prefix_path + member_name, // Anything that has been resolved already will be in here
- member_clang_type.GetCanonicalType(),
+ member_compiler_type.GetCanonicalType(),
matches,
word_complete);
}
@@ -654,17 +680,17 @@ static void
PrivateAutoComplete (StackFrame *frame,
const std::string &partial_path,
const std::string &prefix_path, // Anything that has been resolved already will be in here
- const ClangASTType& clang_type,
+ const CompilerType& compiler_type,
StringList &matches,
bool &word_complete)
{
// printf ("\nPrivateAutoComplete()\n\tprefix_path = '%s'\n\tpartial_path = '%s'\n", prefix_path.c_str(), partial_path.c_str());
std::string remaining_partial_path;
- const lldb::TypeClass type_class = clang_type.GetTypeClass();
+ const lldb::TypeClass type_class = compiler_type.GetTypeClass();
if (partial_path.empty())
{
- if (clang_type.IsValid())
+ if (compiler_type.IsValid())
{
switch (type_class)
{
@@ -700,7 +726,7 @@ PrivateAutoComplete (StackFrame *frame,
case eTypeClassPointer:
{
bool omit_empty_base_classes = true;
- if (clang_type.GetNumChildren (omit_empty_base_classes) > 0)
+ if (compiler_type.GetNumChildren (omit_empty_base_classes) > 0)
matches.AppendString (prefix_path + "->");
else
{
@@ -742,7 +768,7 @@ PrivateAutoComplete (StackFrame *frame,
PrivateAutoComplete (frame,
partial_path.substr(1),
std::string("*"),
- clang_type,
+ compiler_type,
matches,
word_complete);
}
@@ -754,7 +780,7 @@ PrivateAutoComplete (StackFrame *frame,
PrivateAutoComplete (frame,
partial_path.substr(1),
std::string("&"),
- clang_type,
+ compiler_type,
matches,
word_complete);
}
@@ -767,7 +793,7 @@ PrivateAutoComplete (StackFrame *frame,
{
case lldb::eTypeClassPointer:
{
- ClangASTType pointee_type(clang_type.GetPointeeType());
+ CompilerType pointee_type(compiler_type.GetPointeeType());
if (partial_path[2])
{
// If there is more after the "->", then search deeper
@@ -797,7 +823,7 @@ PrivateAutoComplete (StackFrame *frame,
break;
case '.':
- if (clang_type.IsValid())
+ if (compiler_type.IsValid())
{
switch (type_class)
{
@@ -810,7 +836,7 @@ PrivateAutoComplete (StackFrame *frame,
PrivateAutoComplete (frame,
partial_path.substr(1),
prefix_path + ".",
- clang_type,
+ compiler_type,
matches,
word_complete);
@@ -822,7 +848,7 @@ PrivateAutoComplete (StackFrame *frame,
std::string(),
partial_path,
prefix_path + ".",
- clang_type,
+ compiler_type,
matches,
word_complete);
}
@@ -850,13 +876,13 @@ PrivateAutoComplete (StackFrame *frame,
std::string token(partial_path, 0, pos);
remaining_partial_path = partial_path.substr(pos);
- if (clang_type.IsValid())
+ if (compiler_type.IsValid())
{
PrivateAutoCompleteMembers (frame,
token,
remaining_partial_path,
prefix_path,
- clang_type,
+ compiler_type,
matches,
word_complete);
}
@@ -886,11 +912,11 @@ PrivateAutoComplete (StackFrame *frame,
Type *variable_type = variable->GetType();
if (variable_type)
{
- ClangASTType variable_clang_type (variable_type->GetClangForwardType());
+ CompilerType variable_compiler_type (variable_type->GetForwardCompilerType ());
PrivateAutoComplete (frame,
remaining_partial_path,
prefix_path + token, // Anything that has been resolved already will be in here
- variable_clang_type.GetCanonicalType(),
+ variable_compiler_type.GetCanonicalType(),
matches,
word_complete);
}
@@ -923,14 +949,14 @@ Variable::AutoComplete (const ExecutionContext &exe_ctx,
word_complete = false;
std::string partial_path;
std::string prefix_path;
- ClangASTType clang_type;
+ CompilerType compiler_type;
if (partial_path_cstr && partial_path_cstr[0])
partial_path = partial_path_cstr;
PrivateAutoComplete (exe_ctx.GetFramePtr(),
partial_path,
prefix_path,
- clang_type,
+ compiler_type,
matches,
word_complete);
diff --git a/source/Symbol/VariableList.cpp b/source/Symbol/VariableList.cpp
index 75eb8700c9ff..487c57194346 100644
--- a/source/Symbol/VariableList.cpp
+++ b/source/Symbol/VariableList.cpp
@@ -100,7 +100,7 @@ VariableList::FindVariableIndex (const VariableSP &var_sp)
}
VariableSP
-VariableList::FindVariable(const ConstString& name)
+VariableList::FindVariable(const ConstString& name, bool include_static_members)
{
VariableSP var_sp;
iterator pos, end = m_variables.end();
@@ -108,15 +108,18 @@ VariableList::FindVariable(const ConstString& name)
{
if ((*pos)->NameMatches(name))
{
- var_sp = (*pos);
- break;
+ if (include_static_members || !(*pos)->IsStaticMember())
+ {
+ var_sp = (*pos);
+ break;
+ }
}
}
return var_sp;
}
VariableSP
-VariableList::FindVariable (const ConstString& name, lldb::ValueType value_type)
+VariableList::FindVariable (const ConstString& name, lldb::ValueType value_type, bool include_static_members)
{
VariableSP var_sp;
iterator pos, end = m_variables.end();
@@ -124,8 +127,11 @@ VariableList::FindVariable (const ConstString& name, lldb::ValueType value_type)
{
if ((*pos)->NameMatches(name) && (*pos)->GetScope() == value_type)
{
- var_sp = (*pos);
- break;
+ if (include_static_members || !(*pos)->IsStaticMember())
+ {
+ var_sp = (*pos);
+ break;
+ }
}
}
return var_sp;
diff --git a/source/Target/ABI.cpp b/source/Target/ABI.cpp
index 8809c1e51d0c..4d67cb46abe4 100644
--- a/source/Target/ABI.cpp
+++ b/source/Target/ABI.cpp
@@ -11,8 +11,9 @@
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
-#include "lldb/Expression/ClangPersistentVariables.h"
-#include "lldb/Symbol/ClangASTType.h"
+#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
+#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
@@ -84,7 +85,7 @@ ABI::GetRegisterInfoByName (const ConstString &name, RegisterInfo &info)
bool
ABI::GetRegisterInfoByKind (RegisterKind reg_kind, uint32_t reg_num, RegisterInfo &info)
{
- if (reg_kind < eRegisterKindGCC || reg_kind >= kNumRegisterKinds)
+ if (reg_kind < eRegisterKindEHFrame || reg_kind >= kNumRegisterKinds)
return false;
uint32_t count = 0;
@@ -105,7 +106,7 @@ ABI::GetRegisterInfoByKind (RegisterKind reg_kind, uint32_t reg_num, RegisterInf
ValueObjectSP
ABI::GetReturnValueObject (Thread &thread,
- ClangASTType &ast_type,
+ CompilerType &ast_type,
bool persistent) const
{
if (!ast_type.IsValid())
@@ -123,8 +124,12 @@ ABI::GetReturnValueObject (Thread &thread,
if (persistent)
{
- ClangPersistentVariables& persistent_variables = thread.CalculateTarget()->GetPersistentVariables();
- ConstString persistent_variable_name (persistent_variables.GetNextPersistentVariableName());
+ PersistentExpressionState *persistent_expression_state = thread.CalculateTarget()->GetPersistentExpressionStateForLanguage(ast_type.GetMinimumLanguage());
+
+ if (!persistent_expression_state)
+ return ValueObjectSP();
+
+ ConstString persistent_variable_name (persistent_expression_state->GetNextPersistentVariableName());
lldb::ValueObjectSP const_valobj_sp;
@@ -141,7 +146,7 @@ ABI::GetReturnValueObject (Thread &thread,
return_valobj_sp = const_valobj_sp;
- ClangExpressionVariableSP clang_expr_variable_sp(persistent_variables.CreatePersistentVariable(return_valobj_sp));
+ ExpressionVariableSP clang_expr_variable_sp(persistent_expression_state->CreatePersistentVariable(return_valobj_sp));
assert (clang_expr_variable_sp.get());
diff --git a/source/Target/CPPLanguageRuntime.cpp b/source/Target/CPPLanguageRuntime.cpp
index f048c6706a9b..28cfab1cefd7 100644
--- a/source/Target/CPPLanguageRuntime.cpp
+++ b/source/Target/CPPLanguageRuntime.cpp
@@ -20,137 +20,6 @@
using namespace lldb;
using namespace lldb_private;
-class CPPRuntimeEquivalents
-{
-public:
- CPPRuntimeEquivalents ()
- {
-
- m_impl.Append(ConstString("std::basic_string<char, std::char_traits<char>, std::allocator<char> >").AsCString(), ConstString("basic_string<char>"));
-
- // these two (with a prefixed std::) occur when c++stdlib string class occurs as a template argument in some STL container
- m_impl.Append(ConstString("std::basic_string<char, std::char_traits<char>, std::allocator<char> >").AsCString(), ConstString("std::basic_string<char>"));
-
- m_impl.Sort();
- }
-
- void
- Add (ConstString& type_name,
- ConstString& type_equivalent)
- {
- m_impl.Insert(type_name.AsCString(), type_equivalent);
- }
-
- uint32_t
- FindExactMatches (ConstString& type_name,
- std::vector<ConstString>& equivalents)
- {
-
- uint32_t count = 0;
-
- for (ImplData match = m_impl.FindFirstValueForName(type_name.AsCString());
- match != NULL;
- match = m_impl.FindNextValueForName(match))
- {
- equivalents.push_back(match->value);
- count++;
- }
-
- return count;
- }
-
- // partial matches can occur when a name with equivalents is a template argument.
- // e.g. we may have "class Foo" be a match for "struct Bar". if we have a typename
- // such as "class Templatized<class Foo, Anything>" we want this to be replaced with
- // "class Templatized<struct Bar, Anything>". Since partial matching is time consuming
- // once we get a partial match, we add it to the exact matches list for faster retrieval
- uint32_t
- FindPartialMatches (ConstString& type_name,
- std::vector<ConstString>& equivalents)
- {
-
- uint32_t count = 0;
-
- const char* type_name_cstr = type_name.AsCString();
-
- size_t items_count = m_impl.GetSize();
-
- for (size_t item = 0; item < items_count; item++)
- {
- const char* key_cstr = m_impl.GetCStringAtIndex(item);
- if ( strstr(type_name_cstr,key_cstr) )
- {
- count += AppendReplacements(type_name_cstr,
- key_cstr,
- equivalents);
- }
- }
-
- return count;
-
- }
-
-private:
-
- std::string& replace (std::string& target,
- std::string& pattern,
- std::string& with)
- {
- size_t pos;
- size_t pattern_len = pattern.size();
-
- while ( (pos = target.find(pattern)) != std::string::npos )
- target.replace(pos, pattern_len, with);
-
- return target;
- }
-
- uint32_t
- AppendReplacements (const char* original,
- const char *matching_key,
- std::vector<ConstString>& equivalents)
- {
-
- std::string matching_key_str(matching_key);
- ConstString original_const(original);
-
- uint32_t count = 0;
-
- for (ImplData match = m_impl.FindFirstValueForName(matching_key);
- match != NULL;
- match = m_impl.FindNextValueForName(match))
- {
- std::string target(original);
- std::string equiv_class(match->value.AsCString());
-
- replace (target, matching_key_str, equiv_class);
-
- ConstString target_const(target.c_str());
-
-// you will most probably want to leave this off since it might make this map grow indefinitely
-#ifdef ENABLE_CPP_EQUIVALENTS_MAP_TO_GROW
- Add(original_const, target_const);
-#endif
- equivalents.push_back(target_const);
-
- count++;
- }
-
- return count;
- }
-
- typedef UniqueCStringMap<ConstString> Impl;
- typedef const Impl::Entry* ImplData;
- Impl m_impl;
-};
-
-static CPPRuntimeEquivalents&
-GetEquivalentsMap ()
-{
- static CPPRuntimeEquivalents g_equivalents_map;
- return g_equivalents_map;
-}
-
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
@@ -177,244 +46,3 @@ CPPLanguageRuntime::GetObjectDescription (Stream &str, Value &value, ExecutionCo
// C++ has no generic way to do this.
return false;
}
-
-bool
-CPPLanguageRuntime::IsCPPMangledName (const char *name)
-{
- // FIXME, we should really run through all the known C++ Language plugins and ask each one if
- // this is a C++ mangled name, but we can put that off till there is actually more than one
- // we care about.
-
- if (name && name[0] == '_' && name[1] == 'Z')
- return true;
- else
- return false;
-}
-
-bool
-CPPLanguageRuntime::ExtractContextAndIdentifier (const char *name, llvm::StringRef &context, llvm::StringRef &identifier)
-{
- static RegularExpression g_basename_regex("^(([A-Za-z_][A-Za-z_0-9]*::)*)([A-Za-z_][A-Za-z_0-9]*)$");
- RegularExpression::Match match(4);
- if (g_basename_regex.Execute (name, &match))
- {
- match.GetMatchAtIndex(name, 1, context);
- match.GetMatchAtIndex(name, 3, identifier);
- return true;
- }
- return false;
-}
-
-uint32_t
-CPPLanguageRuntime::FindEquivalentNames(ConstString type_name, std::vector<ConstString>& equivalents)
-{
- uint32_t count = GetEquivalentsMap().FindExactMatches(type_name, equivalents);
-
- bool might_have_partials=
- ( count == 0 ) // if we have a full name match just use it
- && (strchr(type_name.AsCString(), '<') != NULL // we should only have partial matches when templates are involved, check that we have
- && strchr(type_name.AsCString(), '>') != NULL); // angle brackets in the type_name before trying to scan for partial matches
-
- if ( might_have_partials )
- count = GetEquivalentsMap().FindPartialMatches(type_name, equivalents);
-
- return count;
-}
-
-void
-CPPLanguageRuntime::MethodName::Clear()
-{
- m_full.Clear();
- m_basename = llvm::StringRef();
- m_context = llvm::StringRef();
- m_arguments = llvm::StringRef();
- m_qualifiers = llvm::StringRef();
- m_type = eTypeInvalid;
- m_parsed = false;
- m_parse_error = false;
-}
-
-bool
-ReverseFindMatchingChars (const llvm::StringRef &s,
- const llvm::StringRef &left_right_chars,
- size_t &left_pos,
- size_t &right_pos,
- size_t pos = llvm::StringRef::npos)
-{
- assert (left_right_chars.size() == 2);
- left_pos = llvm::StringRef::npos;
- const char left_char = left_right_chars[0];
- const char right_char = left_right_chars[1];
- pos = s.find_last_of(left_right_chars, pos);
- if (pos == llvm::StringRef::npos || s[pos] == left_char)
- return false;
- right_pos = pos;
- uint32_t depth = 1;
- while (pos > 0 && depth > 0)
- {
- pos = s.find_last_of(left_right_chars, pos);
- if (pos == llvm::StringRef::npos)
- return false;
- if (s[pos] == left_char)
- {
- if (--depth == 0)
- {
- left_pos = pos;
- return left_pos < right_pos;
- }
- }
- else if (s[pos] == right_char)
- {
- ++depth;
- }
- }
- return false;
-}
-
-
-void
-CPPLanguageRuntime::MethodName::Parse()
-{
- if (!m_parsed && m_full)
- {
-// ConstString mangled;
-// m_full.GetMangledCounterpart(mangled);
-// printf ("\n parsing = '%s'\n", m_full.GetCString());
-// if (mangled)
-// printf (" mangled = '%s'\n", mangled.GetCString());
- m_parse_error = false;
- m_parsed = true;
- llvm::StringRef full (m_full.GetCString());
-
- size_t arg_start, arg_end;
- llvm::StringRef parens("()", 2);
- if (ReverseFindMatchingChars (full, parens, arg_start, arg_end))
- {
- m_arguments = full.substr(arg_start, arg_end - arg_start + 1);
- if (arg_end + 1 < full.size())
- m_qualifiers = full.substr(arg_end + 1);
- if (arg_start > 0)
- {
- size_t basename_end = arg_start;
- size_t context_start = 0;
- size_t context_end = llvm::StringRef::npos;
- if (basename_end > 0 && full[basename_end-1] == '>')
- {
- // TODO: handle template junk...
- // Templated function
- size_t template_start, template_end;
- llvm::StringRef lt_gt("<>", 2);
- if (ReverseFindMatchingChars (full, lt_gt, template_start, template_end, basename_end))
- {
- context_end = full.rfind(':', template_start);
- if (context_end == llvm::StringRef::npos)
- {
- // Check for templated functions that include return type like:
- // 'void foo<Int>()'
- context_end = full.rfind(' ', template_start);
- if (context_end != llvm::StringRef::npos)
- {
- context_start = context_end;
- }
- }
- }
- else
- {
- context_end = full.rfind(':', basename_end);
- }
- }
- else if (context_end == llvm::StringRef::npos)
- {
- context_end = full.rfind(':', basename_end);
- }
-
- if (context_end == llvm::StringRef::npos)
- m_basename = full.substr(0, basename_end);
- else
- {
- if (context_start < context_end)
- m_context = full.substr(context_start, context_end - 1);
- const size_t basename_begin = context_end + 1;
- m_basename = full.substr(basename_begin, basename_end - basename_begin);
- }
- m_type = eTypeUnknownMethod;
- }
- else
- {
- m_parse_error = true;
- return;
- }
-
-// if (!m_context.empty())
-// printf (" context = '%s'\n", m_context.str().c_str());
-// if (m_basename)
-// printf (" basename = '%s'\n", m_basename.GetCString());
-// if (!m_arguments.empty())
-// printf (" arguments = '%s'\n", m_arguments.str().c_str());
-// if (!m_qualifiers.empty())
-// printf ("qualifiers = '%s'\n", m_qualifiers.str().c_str());
-
- // Make sure we have a valid C++ basename with optional template args
- static RegularExpression g_identifier_regex("^~?([A-Za-z_][A-Za-z_0-9]*)(<.*>)?$");
- std::string basename_str(m_basename.str());
- bool basename_is_valid = g_identifier_regex.Execute (basename_str.c_str(), NULL);
- if (!basename_is_valid)
- {
- // Check for C++ operators
- if (m_basename.startswith("operator"))
- {
- static RegularExpression g_operator_regex("^(operator)( ?)([A-Za-z_][A-Za-z_0-9]*|\\(\\)|\\[\\]|[\\^<>=!\\/*+-]+)(<.*>)?(\\[\\])?$");
- basename_is_valid = g_operator_regex.Execute(basename_str.c_str(), NULL);
- }
- }
- if (!basename_is_valid)
- {
- // The C++ basename doesn't match our regular expressions so this can't
- // be a valid C++ method, clear everything out and indicate an error
- m_context = llvm::StringRef();
- m_basename = llvm::StringRef();
- m_arguments = llvm::StringRef();
- m_qualifiers = llvm::StringRef();
- m_parse_error = true;
- }
- }
- else
- {
- m_parse_error = true;
-// printf ("error: didn't find matching parens for arguments\n");
- }
- }
-}
-
-llvm::StringRef
-CPPLanguageRuntime::MethodName::GetBasename ()
-{
- if (!m_parsed)
- Parse();
- return m_basename;
-}
-
-llvm::StringRef
-CPPLanguageRuntime::MethodName::GetContext ()
-{
- if (!m_parsed)
- Parse();
- return m_context;
-}
-
-llvm::StringRef
-CPPLanguageRuntime::MethodName::GetArguments ()
-{
- if (!m_parsed)
- Parse();
- return m_arguments;
-}
-
-llvm::StringRef
-CPPLanguageRuntime::MethodName::GetQualifiers ()
-{
- if (!m_parsed)
- Parse();
- return m_qualifiers;
-}
-
diff --git a/source/Target/ExecutionContext.cpp b/source/Target/ExecutionContext.cpp
index 03714728559c..ff584361c296 100644
--- a/source/Target/ExecutionContext.cpp
+++ b/source/Target/ExecutionContext.cpp
@@ -262,7 +262,7 @@ ExecutionContext::GetByteOrder() const
m_target_sp->GetArchitecture().GetByteOrder();
if (m_process_sp)
m_process_sp->GetByteOrder();
- return lldb::endian::InlHostByteOrder();
+ return endian::InlHostByteOrder();
}
RegisterContext *
diff --git a/source/Target/Language.cpp b/source/Target/Language.cpp
new file mode 100644
index 000000000000..d6c7e0a4c4bb
--- /dev/null
+++ b/source/Target/Language.cpp
@@ -0,0 +1,458 @@
+//===-- Language.cpp -------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <functional>
+#include <map>
+#include <mutex>
+
+#include "lldb/Target/Language.h"
+
+#include "lldb/Host/Mutex.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Stream.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+typedef std::unique_ptr<Language> LanguageUP;
+typedef std::map<lldb::LanguageType, LanguageUP> LanguagesMap;
+
+static LanguagesMap&
+GetLanguagesMap ()
+{
+ static LanguagesMap *g_map = nullptr;
+ static std::once_flag g_initialize;
+
+ std::call_once(g_initialize, [] {
+ g_map = new LanguagesMap(); // NOTE: INTENTIONAL LEAK due to global destructor chain
+ });
+
+ return *g_map;
+}
+static Mutex&
+GetLanguagesMutex ()
+{
+ static Mutex *g_mutex = nullptr;
+ static std::once_flag g_initialize;
+
+ std::call_once(g_initialize, [] {
+ g_mutex = new Mutex(); // NOTE: INTENTIONAL LEAK due to global destructor chain
+ });
+
+ return *g_mutex;
+}
+
+Language*
+Language::FindPlugin (lldb::LanguageType language)
+{
+ Mutex::Locker locker(GetLanguagesMutex());
+ LanguagesMap& map(GetLanguagesMap());
+ auto iter = map.find(language), end = map.end();
+ if (iter != end)
+ return iter->second.get();
+
+ Language *language_ptr = nullptr;
+ LanguageCreateInstance create_callback;
+
+ for (uint32_t idx = 0;
+ (create_callback = PluginManager::GetLanguageCreateCallbackAtIndex(idx)) != nullptr;
+ ++idx)
+ {
+ language_ptr = create_callback(language);
+
+ if (language_ptr)
+ {
+ map[language] = std::unique_ptr<Language>(language_ptr);
+ return language_ptr;
+ }
+ }
+
+ return nullptr;
+}
+
+void
+Language::ForEach (std::function<bool(Language*)> callback)
+{
+ Mutex::Locker locker(GetLanguagesMutex());
+ LanguagesMap& map(GetLanguagesMap());
+ for (const auto& entry : map)
+ {
+ if (!callback(entry.second.get()))
+ break;
+ }
+}
+
+bool
+Language::IsTopLevelFunction (Function& function)
+{
+ return false;
+}
+
+lldb::TypeCategoryImplSP
+Language::GetFormatters ()
+{
+ return nullptr;
+}
+
+HardcodedFormatters::HardcodedFormatFinder
+Language::GetHardcodedFormats ()
+{
+ return {};
+}
+
+HardcodedFormatters::HardcodedSummaryFinder
+Language::GetHardcodedSummaries ()
+{
+ return {};
+}
+
+HardcodedFormatters::HardcodedSyntheticFinder
+Language::GetHardcodedSynthetics ()
+{
+ return {};
+}
+
+HardcodedFormatters::HardcodedValidatorFinder
+Language::GetHardcodedValidators ()
+{
+ return {};
+}
+
+std::vector<ConstString>
+Language::GetPossibleFormattersMatches (ValueObject& valobj, lldb::DynamicValueType use_dynamic)
+{
+ return {};
+}
+
+lldb_private::formatters::StringPrinter::EscapingHelper
+Language::GetStringPrinterEscapingHelper (lldb_private::formatters::StringPrinter::GetPrintableElementType elem_type)
+{
+ return StringPrinter::GetDefaultEscapingHelper(elem_type);
+}
+
+struct language_name_pair {
+ const char *name;
+ LanguageType type;
+};
+
+struct language_name_pair language_names[] =
+{
+ // To allow GetNameForLanguageType to be a simple array lookup, the first
+ // part of this array must follow enum LanguageType exactly.
+ { "unknown", eLanguageTypeUnknown },
+ { "c89", eLanguageTypeC89 },
+ { "c", eLanguageTypeC },
+ { "ada83", eLanguageTypeAda83 },
+ { "c++", eLanguageTypeC_plus_plus },
+ { "cobol74", eLanguageTypeCobol74 },
+ { "cobol85", eLanguageTypeCobol85 },
+ { "fortran77", eLanguageTypeFortran77 },
+ { "fortran90", eLanguageTypeFortran90 },
+ { "pascal83", eLanguageTypePascal83 },
+ { "modula2", eLanguageTypeModula2 },
+ { "java", eLanguageTypeJava },
+ { "c99", eLanguageTypeC99 },
+ { "ada95", eLanguageTypeAda95 },
+ { "fortran95", eLanguageTypeFortran95 },
+ { "pli", eLanguageTypePLI },
+ { "objective-c", eLanguageTypeObjC },
+ { "objective-c++", eLanguageTypeObjC_plus_plus },
+ { "upc", eLanguageTypeUPC },
+ { "d", eLanguageTypeD },
+ { "python", eLanguageTypePython },
+ { "opencl", eLanguageTypeOpenCL },
+ { "go", eLanguageTypeGo },
+ { "modula3", eLanguageTypeModula3 },
+ { "haskell", eLanguageTypeHaskell },
+ { "c++03", eLanguageTypeC_plus_plus_03 },
+ { "c++11", eLanguageTypeC_plus_plus_11 },
+ { "ocaml", eLanguageTypeOCaml },
+ { "rust", eLanguageTypeRust },
+ { "c11", eLanguageTypeC11 },
+ { "swift", eLanguageTypeSwift },
+ { "julia", eLanguageTypeJulia },
+ { "dylan", eLanguageTypeDylan },
+ { "c++14", eLanguageTypeC_plus_plus_14 },
+ { "fortran03", eLanguageTypeFortran03 },
+ { "fortran08", eLanguageTypeFortran08 },
+ // Vendor Extensions
+ { "mipsassem", eLanguageTypeMipsAssembler },
+ { "renderscript", eLanguageTypeExtRenderScript},
+ // Now synonyms, in arbitrary order
+ { "objc", eLanguageTypeObjC },
+ { "objc++", eLanguageTypeObjC_plus_plus },
+ { "pascal", eLanguageTypePascal83 }
+};
+
+static uint32_t num_languages = sizeof(language_names) / sizeof (struct language_name_pair);
+
+LanguageType
+Language::GetLanguageTypeFromString (const char *string)
+{
+ for (uint32_t i = 0; i < num_languages; i++)
+ {
+ if (strcasecmp (language_names[i].name, string) == 0)
+ return (LanguageType) language_names[i].type;
+ }
+ return eLanguageTypeUnknown;
+}
+
+const char *
+Language::GetNameForLanguageType (LanguageType language)
+{
+ if (language < num_languages)
+ return language_names[language].name;
+ else
+ return language_names[eLanguageTypeUnknown].name;
+}
+
+void
+Language::PrintAllLanguages (Stream &s, const char *prefix, const char *suffix)
+{
+ for (uint32_t i = 1; i < num_languages; i++)
+ {
+ s.Printf("%s%s%s", prefix, language_names[i].name, suffix);
+ }
+}
+
+void
+Language::ForAllLanguages (std::function<bool(lldb::LanguageType)> callback)
+{
+ for (uint32_t i = 1; i < num_languages; i++)
+ {
+ if (!callback(language_names[i].type))
+ break;
+ }
+}
+
+bool
+Language::LanguageIsCPlusPlus (LanguageType language)
+{
+ switch (language)
+ {
+ case eLanguageTypeC_plus_plus:
+ case eLanguageTypeC_plus_plus_03:
+ case eLanguageTypeC_plus_plus_11:
+ case eLanguageTypeC_plus_plus_14:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool
+Language::LanguageIsObjC (LanguageType language)
+{
+ switch (language)
+ {
+ case eLanguageTypeObjC:
+ case eLanguageTypeObjC_plus_plus:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool
+Language::LanguageIsC (LanguageType language)
+{
+ switch (language)
+ {
+ case eLanguageTypeC:
+ case eLanguageTypeC89:
+ case eLanguageTypeC99:
+ case eLanguageTypeC11:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool
+Language::LanguageIsPascal (LanguageType language)
+{
+ switch (language)
+ {
+ case eLanguageTypePascal83:
+ return true;
+ default:
+ return false;
+ }
+}
+
+LanguageType
+Language::GetPrimaryLanguage (LanguageType language)
+{
+ switch (language)
+ {
+ case eLanguageTypeC_plus_plus:
+ case eLanguageTypeC_plus_plus_03:
+ case eLanguageTypeC_plus_plus_11:
+ case eLanguageTypeC_plus_plus_14:
+ return eLanguageTypeC_plus_plus;
+ case eLanguageTypeC:
+ case eLanguageTypeC89:
+ case eLanguageTypeC99:
+ case eLanguageTypeC11:
+ return eLanguageTypeC;
+ case eLanguageTypeObjC:
+ case eLanguageTypeObjC_plus_plus:
+ return eLanguageTypeObjC;
+ case eLanguageTypePascal83:
+ case eLanguageTypeCobol74:
+ case eLanguageTypeCobol85:
+ case eLanguageTypeFortran77:
+ case eLanguageTypeFortran90:
+ case eLanguageTypeFortran95:
+ case eLanguageTypeFortran03:
+ case eLanguageTypeFortran08:
+ case eLanguageTypeAda83:
+ case eLanguageTypeAda95:
+ case eLanguageTypeModula2:
+ case eLanguageTypeJava:
+ case eLanguageTypePLI:
+ case eLanguageTypeUPC:
+ case eLanguageTypeD:
+ case eLanguageTypePython:
+ case eLanguageTypeOpenCL:
+ case eLanguageTypeGo:
+ case eLanguageTypeModula3:
+ case eLanguageTypeHaskell:
+ case eLanguageTypeOCaml:
+ case eLanguageTypeRust:
+ case eLanguageTypeSwift:
+ case eLanguageTypeJulia:
+ case eLanguageTypeDylan:
+ case eLanguageTypeMipsAssembler:
+ case eLanguageTypeExtRenderScript:
+ case eLanguageTypeUnknown:
+ default:
+ return language;
+ }
+}
+
+void
+Language::GetLanguagesSupportingTypeSystems (std::set<lldb::LanguageType> &languages,
+ std::set<lldb::LanguageType> &languages_for_expressions)
+{
+ uint32_t idx = 0;
+
+ while (TypeSystemEnumerateSupportedLanguages enumerate = PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex(idx++))
+ {
+ (*enumerate)(languages, languages_for_expressions);
+ }
+}
+
+void
+Language::GetLanguagesSupportingREPLs (std::set<lldb::LanguageType> &languages)
+{
+ uint32_t idx = 0;
+
+ while (REPLEnumerateSupportedLanguages enumerate = PluginManager::GetREPLEnumerateSupportedLanguagesCallbackAtIndex(idx++))
+ {
+ (*enumerate)(languages);
+ }
+}
+
+std::unique_ptr<Language::TypeScavenger>
+Language::GetTypeScavenger ()
+{
+ return nullptr;
+}
+
+size_t
+Language::TypeScavenger::Find (ExecutionContextScope *exe_scope,
+ const char *key,
+ ResultSet &results,
+ bool append)
+{
+ if (!exe_scope || !exe_scope->CalculateTarget().get())
+ return false;
+
+ if (!key || !key[0])
+ return false;
+
+ if (!append)
+ results.clear();
+
+ size_t old_size = results.size();
+
+ if (this->Find_Impl(exe_scope, key, results))
+ return results.size() - old_size;
+ return 0;
+}
+
+bool
+Language::GetFormatterPrefixSuffix (ValueObject& valobj, ConstString type_hint,
+ std::string& prefix, std::string& suffix)
+{
+ return false;
+}
+
+DumpValueObjectOptions::DeclPrintingHelper
+Language::GetDeclPrintingHelper ()
+{
+ return nullptr;
+}
+
+LazyBool
+Language::IsLogicalTrue (ValueObject& valobj,
+ Error& error)
+{
+ return eLazyBoolCalculate;
+}
+
+bool
+Language::IsNilReference (ValueObject& valobj)
+{
+ return false;
+}
+
+bool
+Language::IsUninitializedReference (ValueObject& valobj)
+{
+ return false;
+}
+
+bool
+Language::GetFunctionDisplayName (const SymbolContext *sc,
+ const ExecutionContext *exe_ctx,
+ FunctionNameRepresentation representation,
+ Stream& s)
+{
+ return false;
+}
+
+void
+Language::GetExceptionResolverDescription(bool catch_on, bool throw_on, Stream &s)
+{
+ GetDefaultExceptionResolverDescription(catch_on, throw_on, s);
+}
+
+void
+Language::GetDefaultExceptionResolverDescription(bool catch_on, bool throw_on, Stream &s)
+{
+ 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 9c7b441d4c53..b1e2b3eb04fc 100644
--- a/source/Target/LanguageRuntime.cpp
+++ b/source/Target/LanguageRuntime.cpp
@@ -1,4 +1,4 @@
-//===-- LanguageRuntime.cpp -------------------------------------------------*- C++ -*-===//
+//===-- LanguageRuntime.cpp -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,7 +7,13 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Target/LanguageRuntime.h"
+#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
+#include "Plugins/Language/ObjC/ObjCLanguage.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
#include "lldb/Core/PluginManager.h"
@@ -17,7 +23,6 @@
using namespace lldb;
using namespace lldb_private;
-
class ExceptionSearchFilter : public SearchFilter
{
public:
@@ -33,8 +38,7 @@ public:
UpdateModuleListIfNeeded ();
}
- virtual
- ~ExceptionSearchFilter() {};
+ ~ExceptionSearchFilter() override = default;
bool
ModulePasses (const lldb::ModuleSP &module_sp) override
@@ -52,7 +56,6 @@ public:
if (m_filter_sp)
return m_filter_sp->ModulePasses (spec);
return false;
-
}
void
@@ -133,11 +136,8 @@ public:
{
}
- virtual
- ~ExceptionBreakpointResolver()
- {
- }
-
+ ~ExceptionBreakpointResolver() override = default;
+
Searcher::CallbackReturn
SearchCallback (SearchFilter &filter,
SymbolContext &context,
@@ -163,10 +163,12 @@ public:
void
GetDescription (Stream *s) override
{
- s->Printf ("Exception breakpoint (catch: %s throw: %s)",
- m_catch_bp ? "on" : "off",
- m_throw_bp ? "on" : "off");
-
+ Language *language_plugin = Language::FindPlugin(m_language);
+ if (language_plugin)
+ language_plugin->GetExceptionResolverDescription(m_catch_bp, m_throw_bp, *s);
+ else
+ Language::GetDefaultExceptionResolverDescription(m_catch_bp, m_throw_bp, *s);
+
SetActualResolver();
if (m_actual_resolver_sp)
{
@@ -187,6 +189,7 @@ public:
static inline bool classof(const BreakpointResolver *V) {
return V->getResolverID() == BreakpointResolver::ExceptionResolver;
}
+
protected:
BreakpointResolverSP
CopyForBreakpoint (Breakpoint &breakpoint) override
@@ -244,7 +247,6 @@ protected:
bool m_throw_bp;
};
-
LanguageRuntime*
LanguageRuntime::FindPlugin (Process *process, lldb::LanguageType language)
{
@@ -264,20 +266,12 @@ LanguageRuntime::FindPlugin (Process *process, lldb::LanguageType language)
return NULL;
}
-//----------------------------------------------------------------------
-// Constructor
-//----------------------------------------------------------------------
LanguageRuntime::LanguageRuntime(Process *process) :
m_process (process)
{
}
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-LanguageRuntime::~LanguageRuntime()
-{
-}
+LanguageRuntime::~LanguageRuntime() = default;
Breakpoint::BreakpointPreconditionSP
LanguageRuntime::CreateExceptionPrecondition (lldb::LanguageType language,
@@ -321,105 +315,6 @@ LanguageRuntime::CreateExceptionBreakpoint (Target &target,
return exc_breakpt_sp;
}
-struct language_name_pair {
- const char *name;
- LanguageType type;
-};
-
-struct language_name_pair language_names[] =
-{
- // To allow GetNameForLanguageType to be a simple array lookup, the first
- // part of this array must follow enum LanguageType exactly.
- { "unknown", eLanguageTypeUnknown },
- { "c89", eLanguageTypeC89 },
- { "c", eLanguageTypeC },
- { "ada83", eLanguageTypeAda83 },
- { "c++", eLanguageTypeC_plus_plus },
- { "cobol74", eLanguageTypeCobol74 },
- { "cobol85", eLanguageTypeCobol85 },
- { "fortran77", eLanguageTypeFortran77 },
- { "fortran90", eLanguageTypeFortran90 },
- { "pascal83", eLanguageTypePascal83 },
- { "modula2", eLanguageTypeModula2 },
- { "java", eLanguageTypeJava },
- { "c99", eLanguageTypeC99 },
- { "ada95", eLanguageTypeAda95 },
- { "fortran95", eLanguageTypeFortran95 },
- { "pli", eLanguageTypePLI },
- { "objective-c", eLanguageTypeObjC },
- { "objective-c++", eLanguageTypeObjC_plus_plus },
- { "upc", eLanguageTypeUPC },
- { "d", eLanguageTypeD },
- { "python", eLanguageTypePython },
- { "opencl", eLanguageTypeOpenCL },
- { "go", eLanguageTypeGo },
- { "modula3", eLanguageTypeModula3 },
- { "haskell", eLanguageTypeHaskell },
- { "c++03", eLanguageTypeC_plus_plus_03 },
- { "c++11", eLanguageTypeC_plus_plus_11 },
- { "ocaml", eLanguageTypeOCaml },
- { "rust", eLanguageTypeRust },
- { "c11", eLanguageTypeC11 },
- { "swift", eLanguageTypeSwift },
- { "julia", eLanguageTypeJulia },
- { "dylan", eLanguageTypeDylan },
- { "c++14", eLanguageTypeC_plus_plus_14 },
- { "fortran03", eLanguageTypeFortran03 },
- { "fortran08", eLanguageTypeFortran08 },
- // Vendor Extensions
- { "mipsassem", eLanguageTypeMipsAssembler },
- { "renderscript", eLanguageTypeExtRenderScript},
- // Now synonyms, in arbitrary order
- { "objc", eLanguageTypeObjC },
- { "objc++", eLanguageTypeObjC_plus_plus }
-};
-
-static uint32_t num_languages = sizeof(language_names) / sizeof (struct language_name_pair);
-
-LanguageType
-LanguageRuntime::GetLanguageTypeFromString (const char *string)
-{
- for (uint32_t i = 0; i < num_languages; i++)
- {
- if (strcasecmp (language_names[i].name, string) == 0)
- return (LanguageType) language_names[i].type;
- }
- return eLanguageTypeUnknown;
-}
-
-const char *
-LanguageRuntime::GetNameForLanguageType (LanguageType language)
-{
- if (language < num_languages)
- return language_names[language].name;
- else
- return language_names[eLanguageTypeUnknown].name;
-}
-
-void
-LanguageRuntime::PrintAllLanguages (Stream &s, const char *prefix, const char *suffix)
-{
- for (uint32_t i = 1; i < num_languages; i++)
- {
- s.Printf("%s%s%s", prefix, language_names[i].name, suffix);
- }
-}
-
-bool
-LanguageRuntime::LanguageIsCPlusPlus (LanguageType language)
-{
- switch (language)
- {
- case eLanguageTypeC_plus_plus:
- case eLanguageTypeC_plus_plus_03:
- case eLanguageTypeC_plus_plus_11:
- case eLanguageTypeC_plus_plus_14:
- return true;
- default:
- return false;
- }
-}
-
void
LanguageRuntime::InitializeCommands (CommandObject* parent)
{
@@ -452,6 +347,3 @@ LanguageRuntime::CreateExceptionSearchFilter ()
{
return m_process->GetTarget().GetSearchFilterForModule(NULL);
}
-
-
-
diff --git a/source/Target/Memory.cpp b/source/Target/Memory.cpp
index e61b3ab91e7b..c89fd5101147 100644
--- a/source/Target/Memory.cpp
+++ b/source/Target/Memory.cpp
@@ -164,24 +164,16 @@ MemoryCache::Read (addr_t addr,
if (!m_L1_cache.empty())
{
AddrRange read_range(addr, dst_len);
- BlockMap::iterator pos = m_L1_cache.lower_bound(addr);
- if (pos != m_L1_cache.end())
+ BlockMap::iterator pos = m_L1_cache.upper_bound(addr);
+ if (pos != m_L1_cache.begin ())
{
- AddrRange chunk_range(pos->first, pos->second->GetByteSize());
- bool match = chunk_range.Contains(read_range);
- if (!match && pos != m_L1_cache.begin())
- {
- --pos;
- chunk_range.SetRangeBase(pos->first);
- chunk_range.SetByteSize(pos->second->GetByteSize());
- match = chunk_range.Contains(read_range);
- }
-
- if (match)
- {
- memcpy(dst, pos->second->GetBytes() + addr - chunk_range.GetRangeBase(), dst_len);
- return dst_len;
- }
+ --pos;
+ }
+ AddrRange chunk_range(pos->first, pos->second->GetByteSize());
+ if (chunk_range.Contains(read_range))
+ {
+ memcpy(dst, pos->second->GetBytes() + addr - chunk_range.GetRangeBase(), dst_len);
+ return dst_len;
}
}
diff --git a/source/Target/ObjCLanguageRuntime.cpp b/source/Target/ObjCLanguageRuntime.cpp
index e54dd5b4920a..a18e4c69c571 100644
--- a/source/Target/ObjCLanguageRuntime.cpp
+++ b/source/Target/ObjCLanguageRuntime.cpp
@@ -136,7 +136,7 @@ ObjCLanguageRuntime::LookupInCompleteClassCache (ConstString &name)
{
TypeSP type_sp (types.GetTypeAtIndex(i));
- if (type_sp->GetClangForwardType().IsObjCObjectOrInterfaceType())
+ if (ClangASTContext::IsObjCObjectOrInterfaceType(type_sp->GetForwardCompilerType ()))
{
if (type_sp->IsCompleteObjCClass())
{
@@ -152,288 +152,11 @@ ObjCLanguageRuntime::LookupInCompleteClassCache (ConstString &name)
}
size_t
-ObjCLanguageRuntime::GetByteOffsetForIvar (ClangASTType &parent_qual_type, const char *ivar_name)
+ObjCLanguageRuntime::GetByteOffsetForIvar (CompilerType &parent_qual_type, const char *ivar_name)
{
return LLDB_INVALID_IVAR_OFFSET;
}
-void
-ObjCLanguageRuntime::MethodName::Clear()
-{
- m_full.Clear();
- m_class.Clear();
- m_category.Clear();
- m_selector.Clear();
- m_type = eTypeUnspecified;
- m_category_is_valid = false;
-}
-
-//bool
-//ObjCLanguageRuntime::MethodName::SetName (const char *name, bool strict)
-//{
-// Clear();
-// if (name && name[0])
-// {
-// // If "strict" is true. then the method must be specified with a
-// // '+' or '-' at the beginning. If "strict" is false, then the '+'
-// // or '-' can be omitted
-// bool valid_prefix = false;
-//
-// if (name[0] == '+' || name[0] == '-')
-// {
-// valid_prefix = name[1] == '[';
-// }
-// else if (!strict)
-// {
-// // "strict" is false, the name just needs to start with '['
-// valid_prefix = name[0] == '[';
-// }
-//
-// if (valid_prefix)
-// {
-// static RegularExpression g_regex("^([-+]?)\\[([A-Za-z_][A-Za-z_0-9]*)(\\([A-Za-z_][A-Za-z_0-9]*\\))? ([A-Za-z_][A-Za-z_0-9:]*)\\]$");
-// llvm::StringRef matches[4];
-// // Since we are using a global regular expression, we must use the threadsafe version of execute
-// if (g_regex.ExecuteThreadSafe(name, matches, 4))
-// {
-// m_full.SetCString(name);
-// if (matches[0].empty())
-// m_type = eTypeUnspecified;
-// else if (matches[0][0] == '+')
-// m_type = eTypeClassMethod;
-// else
-// m_type = eTypeInstanceMethod;
-// m_class.SetString(matches[1]);
-// m_selector.SetString(matches[3]);
-// if (!matches[2].empty())
-// m_category.SetString(matches[2]);
-// }
-// }
-// }
-// return IsValid(strict);
-//}
-
-bool
-ObjCLanguageRuntime::MethodName::SetName (const char *name, bool strict)
-{
- Clear();
- if (name && name[0])
- {
- // If "strict" is true. then the method must be specified with a
- // '+' or '-' at the beginning. If "strict" is false, then the '+'
- // or '-' can be omitted
- bool valid_prefix = false;
-
- if (name[0] == '+' || name[0] == '-')
- {
- valid_prefix = name[1] == '[';
- if (name[0] == '+')
- m_type = eTypeClassMethod;
- else
- m_type = eTypeInstanceMethod;
- }
- else if (!strict)
- {
- // "strict" is false, the name just needs to start with '['
- valid_prefix = name[0] == '[';
- }
-
- if (valid_prefix)
- {
- int name_len = strlen (name);
- // Objective C methods must have at least:
- // "-[" or "+[" prefix
- // One character for a class name
- // One character for the space between the class name
- // One character for the method name
- // "]" suffix
- if (name_len >= (5 + (strict ? 1 : 0)) && name[name_len - 1] == ']')
- {
- m_full.SetCStringWithLength(name, name_len);
- }
- }
- }
- return IsValid(strict);
-}
-
-const ConstString &
-ObjCLanguageRuntime::MethodName::GetClassName ()
-{
- if (!m_class)
- {
- if (IsValid(false))
- {
- const char *full = m_full.GetCString();
- const char *class_start = (full[0] == '[' ? full + 1 : full + 2);
- const char *paren_pos = strchr (class_start, '(');
- if (paren_pos)
- {
- m_class.SetCStringWithLength (class_start, paren_pos - class_start);
- }
- else
- {
- // No '(' was found in the full name, we can definitively say
- // that our category was valid (and empty).
- m_category_is_valid = true;
- const char *space_pos = strchr (full, ' ');
- if (space_pos)
- {
- m_class.SetCStringWithLength (class_start, space_pos - class_start);
- if (!m_class_category)
- {
- // No category in name, so we can also fill in the m_class_category
- m_class_category = m_class;
- }
- }
- }
- }
- }
- return m_class;
-}
-
-const ConstString &
-ObjCLanguageRuntime::MethodName::GetClassNameWithCategory ()
-{
- if (!m_class_category)
- {
- if (IsValid(false))
- {
- const char *full = m_full.GetCString();
- const char *class_start = (full[0] == '[' ? full + 1 : full + 2);
- const char *space_pos = strchr (full, ' ');
- if (space_pos)
- {
- m_class_category.SetCStringWithLength (class_start, space_pos - class_start);
- // If m_class hasn't been filled in and the class with category doesn't
- // contain a '(', then we can also fill in the m_class
- if (!m_class && strchr (m_class_category.GetCString(), '(') == NULL)
- {
- m_class = m_class_category;
- // No '(' was found in the full name, we can definitively say
- // that our category was valid (and empty).
- m_category_is_valid = true;
-
- }
- }
- }
- }
- return m_class_category;
-}
-
-const ConstString &
-ObjCLanguageRuntime::MethodName::GetSelector ()
-{
- if (!m_selector)
- {
- if (IsValid(false))
- {
- const char *full = m_full.GetCString();
- const char *space_pos = strchr (full, ' ');
- if (space_pos)
- {
- ++space_pos; // skip the space
- m_selector.SetCStringWithLength (space_pos, m_full.GetLength() - (space_pos - full) - 1);
- }
- }
- }
- return m_selector;
-}
-
-const ConstString &
-ObjCLanguageRuntime::MethodName::GetCategory ()
-{
- if (!m_category_is_valid && !m_category)
- {
- if (IsValid(false))
- {
- m_category_is_valid = true;
- const char *full = m_full.GetCString();
- const char *class_start = (full[0] == '[' ? full + 1 : full + 2);
- const char *open_paren_pos = strchr (class_start, '(');
- if (open_paren_pos)
- {
- ++open_paren_pos; // Skip the open paren
- const char *close_paren_pos = strchr (open_paren_pos, ')');
- if (close_paren_pos)
- m_category.SetCStringWithLength (open_paren_pos, close_paren_pos - open_paren_pos);
- }
- }
- }
- return m_category;
-}
-
-ConstString
-ObjCLanguageRuntime::MethodName::GetFullNameWithoutCategory (bool empty_if_no_category)
-{
- if (IsValid(false))
- {
- if (HasCategory())
- {
- StreamString strm;
- if (m_type == eTypeClassMethod)
- strm.PutChar('+');
- else if (m_type == eTypeInstanceMethod)
- strm.PutChar('-');
- strm.Printf("[%s %s]", GetClassName().GetCString(), GetSelector().GetCString());
- return ConstString(strm.GetString().c_str());
- }
-
- if (!empty_if_no_category)
- {
- // Just return the full name since it doesn't have a category
- return GetFullName();
- }
- }
- return ConstString();
-}
-
-size_t
-ObjCLanguageRuntime::MethodName::GetFullNames (std::vector<ConstString> &names, bool append)
-{
- if (!append)
- names.clear();
- if (IsValid(false))
- {
- 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.push_back(ConstString(strm.GetString().c_str()));
- }
- }
- else
- {
- const ConstString &class_name = GetClassName();
- const ConstString &selector = GetSelector();
- strm.Printf("+[%s %s]", class_name.GetCString(), selector.GetCString());
- names.push_back(ConstString(strm.GetString().c_str()));
- strm.Clear();
- strm.Printf("-[%s %s]", class_name.GetCString(), selector.GetCString());
- names.push_back(ConstString(strm.GetString().c_str()));
- strm.Clear();
- if (category)
- {
- strm.Printf("+[%s(%s) %s]", class_name.GetCString(), category.GetCString(), selector.GetCString());
- names.push_back(ConstString(strm.GetString().c_str()));
- strm.Clear();
- strm.Printf("-[%s(%s) %s]", class_name.GetCString(), category.GetCString(), selector.GetCString());
- names.push_back(ConstString(strm.GetString().c_str()));
- }
- }
- }
- return names.size();
-}
-
-
bool
ObjCLanguageRuntime::ClassDescriptor::IsPointerValid (lldb::addr_t value,
uint32_t ptr_size,
@@ -549,7 +272,7 @@ ObjCLanguageRuntime::GetClassDescriptor (ValueObject& valobj)
// if we get an invalid VO (which might still happen when playing around
// with pointers returned by the expression parser, don't consider this
// a valid ObjC object)
- if (valobj.GetClangType().IsValid())
+ if (valobj.GetCompilerType().IsValid())
{
addr_t isa_pointer = valobj.GetPointerValue();
if (isa_pointer != LLDB_INVALID_ADDRESS)
@@ -619,20 +342,20 @@ ObjCLanguageRuntime::GetNonKVOClassDescriptor (ObjCISA isa)
}
-ClangASTType
+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);
- return ClangASTType();
+ return CompilerType();
}
-ClangASTType
+CompilerType
ObjCLanguageRuntime::EncodingToType::RealizeType (ClangASTContext& ast_ctx, const char* name, bool for_expression)
{
clang::ASTContext *clang_ast = ast_ctx.getASTContext();
if (!clang_ast)
- return ClangASTType();
+ return CompilerType();
return RealizeType(*clang_ast, name, for_expression);
}
@@ -645,16 +368,16 @@ ObjCLanguageRuntime::GetEncodingToType ()
}
bool
-ObjCLanguageRuntime::GetTypeBitSize (const ClangASTType& clang_type,
+ObjCLanguageRuntime::GetTypeBitSize (const CompilerType& compiler_type,
uint64_t &size)
{
- void *opaque_ptr = clang_type.GetQualType().getAsOpaquePtr();
+ void *opaque_ptr = compiler_type.GetOpaqueQualType();
size = m_type_size_cache.Lookup(opaque_ptr);
// an ObjC object will at least have an ISA, so 0 is definitely not OK
if (size > 0)
return true;
- ClassDescriptorSP class_descriptor_sp = GetClassDescriptorFromClassName(clang_type.GetTypeName());
+ ClassDescriptorSP class_descriptor_sp = GetClassDescriptorFromClassName(compiler_type.GetTypeName());
if (!class_descriptor_sp)
return false;
@@ -703,7 +426,7 @@ ObjCLanguageRuntime::ObjCExceptionPrecondition::EvaluatePrecondition(StoppointCa
}
void
-ObjCLanguageRuntime::ObjCExceptionPrecondition::DescribePrecondition(Stream &stream, lldb::DescriptionLevel level)
+ObjCLanguageRuntime::ObjCExceptionPrecondition::GetDescription(Stream &stream, lldb::DescriptionLevel level)
{
}
diff --git a/source/Target/Platform.cpp b/source/Target/Platform.cpp
index 2b586933ccd4..5077ca23bf74 100644
--- a/source/Target/Platform.cpp
+++ b/source/Target/Platform.cpp
@@ -26,6 +26,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/StreamFile.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/FileSystem.h"
@@ -39,9 +40,11 @@
#include "lldb/Target/UnixSignals.h"
#include "lldb/Utility/Utils.h"
#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
#include "Utility/ModuleCache.h"
+
// Define these constants from POSIX mman.h rather than include the file
// so that they will be correct even when compiled on Linux.
#define MAP_PRIVATE 2
@@ -99,13 +102,17 @@ PlatformProperties::PlatformProperties ()
m_collection_sp->Initialize (g_properties);
auto module_cache_dir = GetModuleCacheDirectory ();
- if (!module_cache_dir)
- {
- if (!HostInfo::GetLLDBPath (ePathTypeGlobalLLDBTempSystemDir, module_cache_dir))
- module_cache_dir = FileSpec ("/tmp/lldb", false);
- module_cache_dir.AppendPathComponent ("module_cache");
- SetModuleCacheDirectory (module_cache_dir);
- }
+ if (module_cache_dir)
+ return;
+
+ llvm::SmallString<64> user_home_dir;
+ if (!llvm::sys::path::home_directory (user_home_dir))
+ return;
+
+ module_cache_dir = FileSpec (user_home_dir.c_str(), false);
+ module_cache_dir.AppendPathComponent (".lldb");
+ module_cache_dir.AppendPathComponent ("module_cache");
+ SetModuleCacheDirectory (module_cache_dir);
}
bool
@@ -272,8 +279,11 @@ Platform::GetSharedModule (const ModuleSpec &module_spec,
module_sp,
[&](const ModuleSpec &spec)
{
- return ModuleList::GetSharedModule (
+ Error error = ModuleList::GetSharedModule (
spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr, false);
+ if (error.Success() && module_sp)
+ module_sp->SetPlatformFileSpec(spec.GetFileSpec());
+ return error;
},
did_create_ptr);
}
@@ -466,7 +476,11 @@ Platform::GetStatus (Stream &strm)
if (arch.IsValid())
{
if (!arch.GetTriple().str().empty())
- strm.Printf(" Triple: %s\n", arch.GetTriple().str().c_str());
+ {
+ strm.Printf(" Triple: ");
+ arch.DumpTriple(strm);
+ strm.EOL();
+ }
}
if (GetOSVersion(major, minor, update))
@@ -515,7 +529,8 @@ Platform::GetStatus (Stream &strm)
bool
Platform::GetOSVersion (uint32_t &major,
uint32_t &minor,
- uint32_t &update)
+ uint32_t &update,
+ Process *process)
{
Mutex::Locker locker (m_mutex);
@@ -566,6 +581,12 @@ Platform::GetOSVersion (uint32_t &major,
minor = m_minor_os_version;
update = m_update_os_version;
}
+ else if (process)
+ {
+ // Check with the process in case it can answer the question if
+ // a process was provided
+ return process->GetHostOSVersion(major, minor, update);
+ }
return success;
}
@@ -947,6 +968,12 @@ Platform::GetHostname ()
return m_name.c_str();
}
+ConstString
+Platform::GetFullNameForDylib (ConstString basename)
+{
+ return basename;
+}
+
bool
Platform::SetRemoteWorkingDirectory(const FileSpec &working_dir)
{
@@ -1811,7 +1838,7 @@ Platform::GetRemoteSharedModule (const ModuleSpec &module_spec,
{
// Try to get module information from the process
if (process->GetModuleSpec (module_spec.GetFileSpec (), module_spec.GetArchitecture (), resolved_module_spec))
- got_module_spec = true;
+ got_module_spec = true;
}
if (!got_module_spec)
@@ -1838,7 +1865,8 @@ Platform::GetCachedSharedModule (const ModuleSpec &module_spec,
bool *did_create_ptr)
{
if (IsHost() ||
- !GetGlobalPlatformProperties ()->GetUseModuleCache ())
+ !GetGlobalPlatformProperties ()->GetUseModuleCache () ||
+ !GetGlobalPlatformProperties ()->GetModuleCacheDirectory ())
return false;
Log *log = GetLogIfAnyCategoriesSet (LIBLLDB_LOG_PLATFORM);
@@ -1848,7 +1876,7 @@ Platform::GetCachedSharedModule (const ModuleSpec &module_spec,
GetModuleCacheRoot (),
GetCacheHostname (),
module_spec,
- [=](const ModuleSpec &module_spec, const FileSpec &tmp_download_file_spec)
+ [this](const ModuleSpec &module_spec, const FileSpec &tmp_download_file_spec)
{
return DownloadModuleSlice (module_spec.GetFileSpec (),
module_spec.GetObjectOffset (),
@@ -1856,6 +1884,10 @@ Platform::GetCachedSharedModule (const ModuleSpec &module_spec,
tmp_download_file_spec);
},
+ [this](const ModuleSP& module_sp, const FileSpec& tmp_download_file_spec)
+ {
+ return DownloadSymbolFile (module_sp, tmp_download_file_spec);
+ },
module_sp,
did_create_ptr);
if (error.Success ())
@@ -1918,6 +1950,12 @@ Platform::DownloadModuleSlice (const FileSpec& src_file_spec,
return error;
}
+Error
+Platform::DownloadSymbolFile (const lldb::ModuleSP& module_sp, const FileSpec& dst_file_spec)
+{
+ return Error ("Symbol file downloading not supported by the default platform.");
+}
+
FileSpec
Platform::GetModuleCacheRoot ()
{
@@ -1946,3 +1984,106 @@ Platform::GetUnixSignals()
return Host::GetUnixSignals();
return GetRemoteUnixSignals();
}
+
+uint32_t
+Platform::LoadImage(lldb_private::Process* process,
+ const lldb_private::FileSpec& local_file,
+ const lldb_private::FileSpec& remote_file,
+ lldb_private::Error& error)
+{
+ if (local_file && remote_file)
+ {
+ // Both local and remote file was specified. Install the local file to the given location.
+ if (IsRemote() || local_file != remote_file)
+ {
+ error = Install(local_file, remote_file);
+ if (error.Fail())
+ return LLDB_INVALID_IMAGE_TOKEN;
+ }
+ return DoLoadImage(process, remote_file, error);
+ }
+
+ if (local_file)
+ {
+ // Only local file was specified. Install it to the current working directory.
+ FileSpec target_file = GetWorkingDirectory();
+ target_file.AppendPathComponent(local_file.GetFilename().AsCString());
+ if (IsRemote() || local_file != target_file)
+ {
+ error = Install(local_file, target_file);
+ if (error.Fail())
+ return LLDB_INVALID_IMAGE_TOKEN;
+ }
+ return DoLoadImage(process, target_file, error);
+ }
+
+ if (remote_file)
+ {
+ // Only remote file was specified so we don't have to do any copying
+ return DoLoadImage(process, remote_file, error);
+ }
+
+ error.SetErrorString("Neither local nor remote file was specified");
+ return LLDB_INVALID_IMAGE_TOKEN;
+}
+
+uint32_t
+Platform::DoLoadImage (lldb_private::Process* process,
+ const lldb_private::FileSpec& remote_file,
+ lldb_private::Error& error)
+{
+ error.SetErrorString("LoadImage is not supported on the current platform");
+ return LLDB_INVALID_IMAGE_TOKEN;
+}
+
+Error
+Platform::UnloadImage(lldb_private::Process* process, uint32_t image_token)
+{
+ return Error("UnloadImage is not supported on the current platform");
+}
+
+lldb::ProcessSP
+Platform::ConnectProcess(const char* connect_url,
+ const char* plugin_name,
+ lldb_private::Debugger &debugger,
+ lldb_private::Target *target,
+ lldb_private::Error &error)
+{
+ error.Clear();
+
+ if (!target)
+ {
+ TargetSP new_target_sp;
+ error = debugger.GetTargetList().CreateTarget(debugger,
+ nullptr,
+ nullptr,
+ false,
+ nullptr,
+ new_target_sp);
+ target = new_target_sp.get();
+ }
+
+ if (!target || error.Fail())
+ return nullptr;
+
+ debugger.GetTargetList().SetSelectedTarget(target);
+
+ lldb::ProcessSP process_sp = target->CreateProcess(debugger.GetListener(),
+ plugin_name,
+ nullptr);
+ if (!process_sp)
+ return nullptr;
+
+ error = process_sp->ConnectRemote(debugger.GetOutputFile().get(), connect_url);
+ if (error.Fail())
+ return nullptr;
+
+ return process_sp;
+}
+
+size_t
+Platform::ConnectToWaitingProcesses(lldb_private::Debugger& debugger, lldb_private::Error& error)
+{
+ error.Clear();
+ return 0;
+}
diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp
index 3abae4fce5b1..6bc9f2b0c9d8 100644
--- a/source/Target/Process.cpp
+++ b/source/Target/Process.cpp
@@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Target/Process.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
@@ -18,9 +22,10 @@
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/State.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Expression/ClangUserExpression.h"
+#include "lldb/Expression/UserExpression.h"
#include "lldb/Expression/IRDynamicChecks.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/Pipe.h"
@@ -28,6 +33,7 @@
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/OptionValueProperties.h"
+#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/DynamicLoader.h"
@@ -56,7 +62,6 @@
using namespace lldb;
using namespace lldb_private;
-
// Comment out line below to disable memory caching, overriding the process setting
// target.process.disable-memory-cache
#define ENABLE_MEMORY_CACHING
@@ -83,8 +88,8 @@ public:
{
}
- virtual const Property *
- GetPropertyAtIndex (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
+ const Property *
+ GetPropertyAtIndex(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const override
{
// When getting the value for a key from the process options, we will always
// try and grab the setting from the current process if there is one. Else we just
@@ -115,6 +120,7 @@ g_properties[] =
{ "stop-on-sharedlibrary-events" , OptionValue::eTypeBoolean, true, false, NULL, NULL, "If true, stop when a shared library is loaded or unloaded." },
{ "detach-keeps-stopped" , OptionValue::eTypeBoolean, true, false, NULL, NULL, "If true, detach will attempt to keep the process stopped." },
{ "memory-cache-line-size" , OptionValue::eTypeUInt64, false, 512, NULL, NULL, "The memory cache line size" },
+ { "optimization-warnings" , OptionValue::eTypeBoolean, false, true, NULL, NULL, "If true, warn when stopped in code that is optimized where stepping and variable availability may not behave as expected." },
{ NULL , OptionValue::eTypeInvalid, false, 0, NULL, NULL, NULL }
};
@@ -126,7 +132,8 @@ enum {
ePropertyPythonOSPluginPath,
ePropertyStopOnSharedLibraryEvents,
ePropertyDetachKeepsStopped,
- ePropertyMemCacheLineSize
+ ePropertyMemCacheLineSize,
+ ePropertyWarningOptimization
};
ProcessProperties::ProcessProperties (lldb_private::Process *process) :
@@ -150,9 +157,7 @@ ProcessProperties::ProcessProperties (lldb_private::Process *process) :
}
}
-ProcessProperties::~ProcessProperties()
-{
-}
+ProcessProperties::~ProcessProperties() = default;
void
ProcessProperties::OptionValueChangedCallback (void *baton, OptionValue *option_value)
@@ -206,7 +211,6 @@ ProcessProperties::SetPythonOSPluginPath (const FileSpec &file)
m_collection_sp->SetPropertyAtIndexAsFileSpec(NULL, idx, file);
}
-
bool
ProcessProperties::GetIgnoreBreakpointsInExpressions () const
{
@@ -263,6 +267,13 @@ ProcessProperties::SetDetachKeepsStopped (bool stop)
m_collection_sp->SetPropertyAtIndexAsBoolean(NULL, idx, stop);
}
+bool
+ProcessProperties::GetWarningsOptimization () const
+{
+ const uint32_t idx = ePropertyWarningOptimization;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+}
+
void
ProcessInstanceInfo::Dump (Stream &s, Platform *platform) const
{
@@ -306,8 +317,12 @@ ProcessInstanceInfo::Dump (Stream &s, Platform *platform) const
}
}
- if (m_arch.IsValid())
- s.Printf (" arch = %s\n", m_arch.GetTriple().str().c_str());
+ if (m_arch.IsValid())
+ {
+ s.Printf (" arch = ");
+ m_arch.DumpTriple(s);
+ s.EOL();
+ }
if (m_uid != UINT32_MAX)
{
@@ -360,7 +375,10 @@ ProcessInstanceInfo::DumpAsTableRow (Stream &s, Platform *platform, bool show_ar
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);
@@ -386,13 +404,14 @@ ProcessInstanceInfo::DumpAsTableRow (Stream &s, Platform *platform, bool show_ar
s.Printf ("%-10s ", cstr);
else
s.Printf ("%-10u ", m_egid);
- s.Printf ("%-24s ", m_arch.IsValid() ? m_arch.GetTriple().str().c_str() : "");
+
+ s.Printf ("%-24s ", arch_strm.GetString().c_str());
}
else
{
s.Printf ("%-10s %-24s ",
platform->GetUserName (m_euid),
- m_arch.IsValid() ? m_arch.GetTriple().str().c_str() : "");
+ arch_strm.GetString().c_str());
}
if (verbose || show_args)
@@ -460,7 +479,7 @@ ProcessLaunchCommandOptions::SetOptionValue (uint32_t option_idx, const char *op
case 'n': // Disable STDIO
{
FileAction action;
- const FileSpec dev_null{"/dev/null", false};
+ const FileSpec dev_null{FileSystem::DEV_NULL, false};
if (action.Open(STDIN_FILENO, dev_null, true, false))
launch_info.AppendFileAction (action);
if (action.Open(STDOUT_FILENO, dev_null, false, true))
@@ -545,8 +564,6 @@ ProcessLaunchCommandOptions::g_option_table[] =
{ 0 , false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
};
-
-
bool
ProcessInstanceInfoMatch::NameMatches (const char *process_name) const
{
@@ -626,7 +643,6 @@ ProcessInstanceInfoMatch::MatchAllProcesses () const
return false;
return true;
-
}
void
@@ -638,7 +654,7 @@ ProcessInstanceInfoMatch::Clear()
}
ProcessSP
-Process::FindPlugin (Target &target, const char *plugin_name, Listener &listener, const FileSpec *crash_file_path)
+Process::FindPlugin (lldb::TargetSP target_sp, const char *plugin_name, Listener &listener, const FileSpec *crash_file_path)
{
static uint32_t g_process_unique_id = 0;
@@ -650,10 +666,10 @@ Process::FindPlugin (Target &target, const char *plugin_name, Listener &listener
create_callback = PluginManager::GetProcessCreateCallbackForPluginName (const_plugin_name);
if (create_callback)
{
- process_sp = create_callback(target, listener, crash_file_path);
+ process_sp = create_callback(target_sp, listener, crash_file_path);
if (process_sp)
{
- if (process_sp->CanDebug(target, true))
+ if (process_sp->CanDebug(target_sp, true))
{
process_sp->m_process_unique_id = ++g_process_unique_id;
}
@@ -666,10 +682,10 @@ Process::FindPlugin (Target &target, const char *plugin_name, Listener &listener
{
for (uint32_t idx = 0; (create_callback = PluginManager::GetProcessCreateCallbackAtIndex(idx)) != NULL; ++idx)
{
- process_sp = create_callback(target, listener, crash_file_path);
+ process_sp = create_callback(target_sp, listener, crash_file_path);
if (process_sp)
{
- if (process_sp->CanDebug(target, false))
+ if (process_sp->CanDebug(target_sp, false))
{
process_sp->m_process_unique_id = ++g_process_unique_id;
break;
@@ -689,21 +705,18 @@ Process::GetStaticBroadcasterClass ()
return class_name;
}
-//----------------------------------------------------------------------
-// Process constructor
-//----------------------------------------------------------------------
-Process::Process(Target &target, Listener &listener) :
- Process(target, listener, UnixSignals::Create(HostInfo::GetArchitecture()))
+Process::Process(lldb::TargetSP target_sp, Listener &listener) :
+ Process(target_sp, listener, UnixSignals::Create(HostInfo::GetArchitecture()))
{
// This constructor just delegates to the full Process constructor,
// defaulting to using the Host's UnixSignals.
}
-Process::Process(Target &target, Listener &listener, const UnixSignalsSP &unix_signals_sp) :
+Process::Process(lldb::TargetSP target_sp, Listener &listener, const UnixSignalsSP &unix_signals_sp) :
ProcessProperties (this),
UserID (LLDB_INVALID_PROCESS_ID),
- Broadcaster (&(target.GetDebugger()), Process::GetStaticBroadcasterClass().AsCString()),
- m_target (target),
+ Broadcaster (&(target_sp->GetDebugger()), Process::GetStaticBroadcasterClass().AsCString()),
+ m_target_sp (target_sp),
m_public_state (eStateUnloaded),
m_private_state (eStateUnloaded),
m_private_state_broadcaster (NULL, "lldb.process.internal_state_broadcaster"),
@@ -746,7 +759,6 @@ Process::Process(Target &target, Listener &listener, const UnixSignalsSP &unix_s
m_next_event_action_ap(),
m_public_run_lock (),
m_private_run_lock (),
- m_currently_handling_event(false),
m_stop_info_override_callback (NULL),
m_finalizing (false),
m_finalize_called (false),
@@ -755,6 +767,7 @@ Process::Process(Target &target, Listener &listener, const UnixSignalsSP &unix_s
m_last_broadcast_state (eStateInvalid),
m_destroy_in_process (false),
m_can_interpret_function_calls(false),
+ m_warnings_issued (),
m_can_jit(eCanJITDontKnow)
{
CheckInWithManager ();
@@ -793,11 +806,15 @@ Process::Process(Target &target, Listener &listener, const UnixSignalsSP &unix_s
eBroadcastInternalStateControlResume);
// We need something valid here, even if just the default UnixSignalsSP.
assert (m_unix_signals_sp && "null m_unix_signals_sp after initialization");
+
+ // Allow the platform to override the default cache line size
+ OptionValueSP value_sp =
+ m_collection_sp->GetPropertyAtIndex(nullptr, true, ePropertyMemCacheLineSize)->GetValue();
+ uint32_t platform_cache_line_size = target_sp->GetPlatform()->GetDefaultMemoryCacheLineSize();
+ if (! value_sp->OptionWasSet() && platform_cache_line_size != 0)
+ value_sp->SetUInt64Value(platform_cache_line_size);
}
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
Process::~Process()
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
@@ -974,7 +991,8 @@ Process::WaitForProcessToStop (const TimeValue *timeout,
EventSP *event_sp_ptr,
bool wait_always,
Listener *hijack_listener,
- Stream *stream)
+ Stream *stream,
+ bool use_run_lock)
{
// We can't just wait for a "stopped" event, because the stopped event may have restarted the target.
// We have to actually check each event, and in the case of a stopped event check the restarted flag
@@ -1001,7 +1019,7 @@ Process::WaitForProcessToStop (const TimeValue *timeout,
__FUNCTION__);
// We need to toggle the run lock as this won't get done in
// SetPublicState() if the process is hijacked.
- if (hijack_listener)
+ if (hijack_listener && use_run_lock)
m_public_run_lock.SetStopped();
return state;
}
@@ -1024,7 +1042,7 @@ Process::WaitForProcessToStop (const TimeValue *timeout,
case eStateUnloaded:
// We need to toggle the run lock as this won't get done in
// SetPublicState() if the process is hijacked.
- if (hijack_listener)
+ if (hijack_listener && use_run_lock)
m_public_run_lock.SetStopped();
return state;
case eStateStopped:
@@ -1034,7 +1052,7 @@ Process::WaitForProcessToStop (const TimeValue *timeout,
{
// We need to toggle the run lock as this won't get done in
// SetPublicState() if the process is hijacked.
- if (hijack_listener)
+ if (hijack_listener && use_run_lock)
m_public_run_lock.SetStopped();
return state;
}
@@ -1247,14 +1265,10 @@ Process::HandleProcessStateChangedEvent (const EventSP &event_sp,
return true;
}
-
StateType
-Process::WaitForState
-(
- const TimeValue *timeout,
- const StateType *match_states,
- const uint32_t num_match_states
-)
+Process::WaitForState(const TimeValue *timeout,
+ const StateType *match_states,
+ const uint32_t num_match_states)
{
EventSP event_sp;
uint32_t i;
@@ -1294,23 +1308,6 @@ Process::RestoreProcessEvents ()
RestoreBroadcaster();
}
-bool
-Process::HijackPrivateProcessEvents (Listener *listener)
-{
- if (listener != NULL)
- {
- return m_private_state_broadcaster.HijackBroadcaster(listener, eBroadcastBitStateChanged | eBroadcastBitInterrupt);
- }
- else
- return false;
-}
-
-void
-Process::RestorePrivateProcessEvents ()
-{
- m_private_state_broadcaster.RestoreBroadcaster();
-}
-
StateType
Process::WaitForStateChangedEvents (const TimeValue *timeout, EventSP &event_sp, Listener *hijack_listener)
{
@@ -1429,7 +1426,6 @@ Process::GetExitStatus ()
return -1;
}
-
const char *
Process::GetExitDescription ()
{
@@ -1468,12 +1464,7 @@ Process::SetExitStatus (int status, const char *cstr)
else
m_exit_string.clear();
- // When we exit, we no longer need to the communication channel
- m_stdio_communication.Disconnect();
- m_stdio_communication.StopReadThread();
- m_stdin_forward = false;
-
- // And we don't need the input reader anymore as well
+ // When we exit, we don't need the input reader anymore
if (m_process_input_reader)
{
m_process_input_reader->SetIsDone(true);
@@ -1493,6 +1484,29 @@ Process::SetExitStatus (int status, const char *cstr)
return true;
}
+bool
+Process::IsAlive ()
+{
+ switch (m_private_state.GetValue())
+ {
+ case eStateInvalid:
+ case eStateUnloaded:
+ case eStateDetached:
+ case eStateExited:
+ return false;
+
+ case eStateConnected:
+ case eStateAttaching:
+ case eStateLaunching:
+ case eStateStopped:
+ case eStateRunning:
+ case eStateStepping:
+ case eStateCrashed:
+ case eStateSuspended:
+ return true;
+ }
+}
+
// This static callback can be used to watch for local child processes on
// the current host. The child process exits, the process will be
// found in the global target list (we want to be completely sure that the
@@ -1534,7 +1548,6 @@ Process::SetProcessExitStatus (void *callback_baton,
return false;
}
-
void
Process::UpdateThreadListIfNeeded ()
{
@@ -1558,41 +1571,38 @@ Process::UpdateThreadListIfNeeded ()
// Don't call into the OperatingSystem to update the thread list if we are shutting down, since
// that may call back into the SBAPI's, requiring the API lock which is already held by whoever is
// shutting us down, causing a deadlock.
- if (!m_destroy_in_process)
+ OperatingSystem *os = GetOperatingSystem ();
+ if (os && !m_destroy_in_process)
{
- OperatingSystem *os = GetOperatingSystem ();
- if (os)
- {
- // Clear any old backing threads where memory threads might have been
- // backed by actual threads from the lldb_private::Process subclass
- size_t num_old_threads = old_thread_list.GetSize(false);
- for (size_t i=0; i<num_old_threads; ++i)
- old_thread_list.GetThreadAtIndex(i, false)->ClearBackingThread();
-
- // Turn off dynamic types to ensure we don't run any expressions. Objective C
- // can run an expression to determine if a SBValue is a dynamic type or not
- // and we need to avoid this. OperatingSystem plug-ins can't run expressions
- // that require running code...
-
- Target &target = GetTarget();
- const lldb::DynamicValueType saved_prefer_dynamic = target.GetPreferDynamicValue ();
- if (saved_prefer_dynamic != lldb::eNoDynamicValues)
- target.SetPreferDynamicValue(lldb::eNoDynamicValues);
-
- // Now let the OperatingSystem plug-in update the thread list
-
- os->UpdateThreadList (old_thread_list, // Old list full of threads created by OS plug-in
- real_thread_list, // The actual thread list full of threads created by each lldb_private::Process subclass
- new_thread_list); // The new thread list that we will show to the user that gets filled in
-
- if (saved_prefer_dynamic != lldb::eNoDynamicValues)
- target.SetPreferDynamicValue(saved_prefer_dynamic);
- }
- else
- {
- // No OS plug-in, the new thread list is the same as the real thread list
- new_thread_list = real_thread_list;
- }
+ // Clear any old backing threads where memory threads might have been
+ // backed by actual threads from the lldb_private::Process subclass
+ size_t num_old_threads = old_thread_list.GetSize(false);
+ for (size_t i=0; i<num_old_threads; ++i)
+ old_thread_list.GetThreadAtIndex(i, false)->ClearBackingThread();
+
+ // Turn off dynamic types to ensure we don't run any expressions. Objective C
+ // can run an expression to determine if a SBValue is a dynamic type or not
+ // and we need to avoid this. OperatingSystem plug-ins can't run expressions
+ // that require running code...
+
+ Target &target = GetTarget();
+ const lldb::DynamicValueType saved_prefer_dynamic = target.GetPreferDynamicValue ();
+ if (saved_prefer_dynamic != lldb::eNoDynamicValues)
+ target.SetPreferDynamicValue(lldb::eNoDynamicValues);
+
+ // Now let the OperatingSystem plug-in update the thread list
+
+ os->UpdateThreadList (old_thread_list, // Old list full of threads created by OS plug-in
+ real_thread_list, // The actual thread list full of threads created by each lldb_private::Process subclass
+ new_thread_list); // The new thread list that we will show to the user that gets filled in
+
+ if (saved_prefer_dynamic != lldb::eNoDynamicValues)
+ target.SetPreferDynamicValue(saved_prefer_dynamic);
+ }
+ else
+ {
+ // No OS plug-in, the new thread list is the same as the real thread list
+ new_thread_list = real_thread_list;
}
m_thread_list_real.Update(real_thread_list);
@@ -1648,15 +1658,7 @@ Process::GetNextThreadIndexID (uint64_t thread_id)
bool
Process::HasAssignedIndexIDToThread(uint64_t thread_id)
{
- std::map<uint64_t, uint32_t>::iterator iterator = m_thread_id_to_index_id_map.find(thread_id);
- if (iterator == m_thread_id_to_index_id_map.end())
- {
- return false;
- }
- else
- {
- return true;
- }
+ return (m_thread_id_to_index_id_map.find(thread_id) != m_thread_id_to_index_id_map.end());
}
uint32_t
@@ -1866,225 +1868,11 @@ Process::GetImageInfoAddress()
return LLDB_INVALID_ADDRESS;
}
-//----------------------------------------------------------------------
-// LoadImage
-//
-// This function provides a default implementation that works for most
-// unix variants. Any Process subclasses that need to do shared library
-// loading differently should override LoadImage and UnloadImage and
-// do what is needed.
-//----------------------------------------------------------------------
-uint32_t
-Process::LoadImage (const FileSpec &image_spec, Error &error)
-{
- if (m_finalizing)
- {
- error.SetErrorString("process is tearing itself down");
- return LLDB_INVALID_IMAGE_TOKEN;
- }
-
- char path[PATH_MAX];
- image_spec.GetPath(path, sizeof(path));
-
- DynamicLoader *loader = GetDynamicLoader();
- if (loader)
- {
- error = loader->CanLoadImage();
- if (error.Fail())
- return LLDB_INVALID_IMAGE_TOKEN;
- }
-
- if (error.Success())
- {
- ThreadSP thread_sp(GetThreadList ().GetSelectedThread());
-
- if (thread_sp)
- {
- StackFrameSP frame_sp (thread_sp->GetStackFrameAtIndex (0));
-
- if (frame_sp)
- {
- ExecutionContext exe_ctx;
- frame_sp->CalculateExecutionContext (exe_ctx);
- EvaluateExpressionOptions expr_options;
- expr_options.SetUnwindOnError(true);
- expr_options.SetIgnoreBreakpoints(true);
- expr_options.SetExecutionPolicy(eExecutionPolicyAlways);
- expr_options.SetResultIsInternal(true);
-
- StreamString expr;
- expr.Printf(R"(
- struct __lldb_dlopen_result { void *image_ptr; const char *error_str; } the_result;
- the_result.image_ptr = dlopen ("%s", 2);
- if (the_result.image_ptr == (void *) 0x0)
- {
- the_result.error_str = dlerror();
- }
- else
- {
- the_result.error_str = (const char *) 0x0;
- }
- the_result;
- )",
- path);
- const char *prefix = R"(
- extern "C" void* dlopen (const char *path, int mode);
- extern "C" const char *dlerror (void);
- )";
- lldb::ValueObjectSP result_valobj_sp;
- Error expr_error;
- ClangUserExpression::Evaluate (exe_ctx,
- expr_options,
- expr.GetData(),
- prefix,
- result_valobj_sp,
- expr_error);
- if (expr_error.Success())
- {
- error = result_valobj_sp->GetError();
- if (error.Success())
- {
- Scalar scalar;
- ValueObjectSP image_ptr_sp = result_valobj_sp->GetChildAtIndex(0, true);
- if (image_ptr_sp && image_ptr_sp->ResolveValue (scalar))
- {
- addr_t image_ptr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
- if (image_ptr != 0 && image_ptr != LLDB_INVALID_ADDRESS)
- {
- uint32_t image_token = m_image_tokens.size();
- m_image_tokens.push_back (image_ptr);
- return image_token;
- }
- else if (image_ptr == 0)
- {
- ValueObjectSP error_str_sp = result_valobj_sp->GetChildAtIndex(1, true);
- if (error_str_sp)
- {
- if (error_str_sp->IsCStringContainer(true))
- {
- DataBufferSP buffer_sp(new DataBufferHeap(10240,0));
- size_t num_chars = error_str_sp->ReadPointedString (buffer_sp, error, 10240);
- if (error.Success() && num_chars > 0)
- {
- error.Clear();
- error.SetErrorStringWithFormat("dlopen error: %s", buffer_sp->GetBytes());
- }
- else
- {
- error.Clear();
- error.SetErrorStringWithFormat("dlopen failed for unknown reasons.");
- }
- }
- }
- }
- }
- }
- }
- else
- error = expr_error;
- }
- }
- }
- if (!error.AsCString())
- error.SetErrorStringWithFormat("unable to load '%s'", path);
- return LLDB_INVALID_IMAGE_TOKEN;
-}
-
-//----------------------------------------------------------------------
-// UnloadImage
-//
-// This function provides a default implementation that works for most
-// unix variants. Any Process subclasses that need to do shared library
-// loading differently should override LoadImage and UnloadImage and
-// do what is needed.
-//----------------------------------------------------------------------
-Error
-Process::UnloadImage (uint32_t image_token)
-{
- Error error;
-
- if (m_finalizing)
- {
- error.SetErrorString("process is tearing itself down");
- return error;
- }
-
- if (image_token < m_image_tokens.size())
- {
- const addr_t image_addr = m_image_tokens[image_token];
- if (image_addr == LLDB_INVALID_ADDRESS)
- {
- error.SetErrorString("image already unloaded");
- }
- else
- {
- DynamicLoader *loader = GetDynamicLoader();
- if (loader)
- error = loader->CanLoadImage();
-
- if (error.Success())
- {
- ThreadSP thread_sp(GetThreadList ().GetSelectedThread());
-
- if (thread_sp)
- {
- StackFrameSP frame_sp (thread_sp->GetStackFrameAtIndex (0));
-
- if (frame_sp)
- {
- ExecutionContext exe_ctx;
- frame_sp->CalculateExecutionContext (exe_ctx);
- EvaluateExpressionOptions expr_options;
- expr_options.SetUnwindOnError(true);
- expr_options.SetIgnoreBreakpoints(true);
- expr_options.SetExecutionPolicy(eExecutionPolicyAlways);
- StreamString expr;
- expr.Printf("dlclose ((void *)0x%" PRIx64 ")", image_addr);
- const char *prefix = "extern \"C\" int dlclose(void* handle);\n";
- lldb::ValueObjectSP result_valobj_sp;
- Error expr_error;
- ClangUserExpression::Evaluate (exe_ctx,
- expr_options,
- expr.GetData(),
- prefix,
- result_valobj_sp,
- expr_error);
- if (result_valobj_sp->GetError().Success())
- {
- Scalar scalar;
- if (result_valobj_sp->ResolveValue (scalar))
- {
- if (scalar.UInt(1))
- {
- error.SetErrorStringWithFormat("expression failed: \"%s\"", expr.GetData());
- }
- else
- {
- m_image_tokens[image_token] = LLDB_INVALID_ADDRESS;
- }
- }
- }
- else
- {
- error = result_valobj_sp->GetError();
- }
- }
- }
- }
- }
- }
- else
- {
- error.SetErrorString("invalid image token");
- }
- return error;
-}
-
const lldb::ABISP &
Process::GetABI()
{
if (!m_abi_sp)
- m_abi_sp = ABI::FindPlugin(m_target.GetArchitecture());
+ m_abi_sp = ABI::FindPlugin(GetTarget().GetArchitecture());
return m_abi_sp;
}
@@ -2167,7 +1955,6 @@ Process::GetBreakpointSiteList() const
return m_breakpoint_site_list;
}
-
void
Process::DisableAllBreakpointSites ()
{
@@ -2264,22 +2051,22 @@ Process::CreateBreakpointSite (const BreakpointLocationSP &owner, bool use_hardw
load_addr = ResolveIndirectFunction (&symbol_address, error);
if (!error.Success() && show_error)
{
- m_target.GetDebugger().GetErrorFile()->Printf ("warning: failed to resolve indirect function at 0x%" PRIx64 " for breakpoint %i.%i: %s\n",
- symbol->GetLoadAddress(&m_target),
- owner->GetBreakpoint().GetID(),
- owner->GetID(),
- error.AsCString() ? error.AsCString() : "unknown error");
+ GetTarget().GetDebugger().GetErrorFile()->Printf ("warning: failed to resolve indirect function at 0x%" PRIx64 " for breakpoint %i.%i: %s\n",
+ symbol->GetLoadAddress(&GetTarget()),
+ owner->GetBreakpoint().GetID(),
+ owner->GetID(),
+ error.AsCString() ? error.AsCString() : "unknown error");
return LLDB_INVALID_BREAK_ID;
}
Address resolved_address(load_addr);
- load_addr = resolved_address.GetOpcodeLoadAddress (&m_target);
+ load_addr = resolved_address.GetOpcodeLoadAddress (&GetTarget());
owner->SetIsIndirect(true);
}
else
- load_addr = owner->GetAddress().GetOpcodeLoadAddress (&m_target);
+ load_addr = owner->GetAddress().GetOpcodeLoadAddress (&GetTarget());
}
else
- load_addr = owner->GetAddress().GetOpcodeLoadAddress (&m_target);
+ load_addr = owner->GetAddress().GetOpcodeLoadAddress (&GetTarget());
if (load_addr != LLDB_INVALID_ADDRESS)
{
@@ -2312,11 +2099,11 @@ Process::CreateBreakpointSite (const BreakpointLocationSP &owner, bool use_hardw
if (show_error)
{
// Report error for setting breakpoint...
- m_target.GetDebugger().GetErrorFile()->Printf ("warning: failed to set breakpoint site at 0x%" PRIx64 " for breakpoint %i.%i: %s\n",
- load_addr,
- owner->GetBreakpoint().GetID(),
- owner->GetID(),
- error.AsCString() ? error.AsCString() : "unknown error");
+ GetTarget().GetDebugger().GetErrorFile()->Printf ("warning: failed to set breakpoint site at 0x%" PRIx64 " for breakpoint %i.%i: %s\n",
+ load_addr,
+ owner->GetBreakpoint().GetID(),
+ owner->GetID(),
+ error.AsCString() ? error.AsCString() : "unknown error");
}
}
}
@@ -2324,7 +2111,6 @@ Process::CreateBreakpointSite (const BreakpointLocationSP &owner, bool use_hardw
}
// We failed to enable the breakpoint
return LLDB_INVALID_BREAK_ID;
-
}
void
@@ -2340,7 +2126,6 @@ Process::RemoveOwnerFromBreakpointSite (lldb::user_id_t owner_id, lldb::user_id_
}
}
-
size_t
Process::RemoveBreakpointOpcodesFromBuffer (addr_t bp_addr, size_t size, uint8_t *buf) const
{
@@ -2369,14 +2154,12 @@ Process::RemoveBreakpointOpcodesFromBuffer (addr_t bp_addr, size_t size, uint8_t
return bytes_removed;
}
-
-
size_t
Process::GetSoftwareBreakpointTrapOpcode (BreakpointSite* bp_site)
{
- PlatformSP platform_sp (m_target.GetPlatform());
+ PlatformSP platform_sp (GetTarget().GetPlatform());
if (platform_sp)
- return platform_sp->GetSoftwareBreakpointTrapOpcode (m_target, bp_site);
+ return platform_sp->GetSoftwareBreakpointTrapOpcode (GetTarget(), bp_site);
return 0;
}
@@ -2550,7 +2333,6 @@ Process::DisableSoftwareBreakpoint (BreakpointSite *bp_site)
(uint64_t)bp_addr,
error.AsCString());
return error;
-
}
// Uncomment to verify memory caching works after making changes to caching code
@@ -2622,7 +2404,6 @@ Process::ReadCStringFromMemory (addr_t addr, std::string &out_str, Error &error)
return out_str.size();
}
-
size_t
Process::ReadStringFromMemory (addr_t addr, char *dst, size_t max_bytes, Error &error,
size_t type_width)
@@ -2772,7 +2553,6 @@ Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error)
return LLDB_INVALID_ADDRESS;
}
-
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr,
lldb::addr_t ptr_value,
@@ -2843,6 +2623,7 @@ Process::WriteMemory (addr_t addr, const void *buf, size_t size, Error &error)
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);
@@ -2975,6 +2756,18 @@ Process::AllocateMemory(size_t size, uint32_t permissions, Error &error)
#endif
}
+addr_t
+Process::CallocateMemory(size_t size, uint32_t permissions, Error &error)
+{
+ addr_t return_addr = AllocateMemory(size, permissions, error);
+ if (error.Success())
+ {
+ std::string buffer(size, 0);
+ WriteMemory(return_addr, buffer.c_str(), size, error);
+ }
+ return return_addr;
+}
+
bool
Process::CanJIT ()
{
@@ -3042,12 +2835,16 @@ Process::DeallocateMemory (addr_t ptr)
return error;
}
-
ModuleSP
Process::ReadModuleFromMemory (const FileSpec& file_spec,
lldb::addr_t header_addr,
size_t size_to_read)
{
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ if (log)
+ {
+ log->Printf ("Process::ReadModuleFromMemory reading %s binary from memory", file_spec.GetPath().c_str());
+ }
ModuleSP module_sp (new Module (file_spec, ArchSpec()));
if (module_sp)
{
@@ -3148,7 +2945,7 @@ Process::Launch (ProcessLaunchInfo &launch_info)
m_process_input_reader.reset();
m_stop_info_override_callback = NULL;
- Module *exe_module = m_target.GetExecutableModulePointer();
+ Module *exe_module = GetTarget().GetExecutableModulePointer();
if (exe_module)
{
char local_exec_file_path[PATH_MAX];
@@ -3214,7 +3011,6 @@ Process::Launch (ProcessLaunchInfo &launch_info)
}
else if (state == eStateStopped || state == eStateCrashed)
{
-
DidLaunch ();
DynamicLoader *dyld = GetDynamicLoader ();
@@ -3264,7 +3060,6 @@ Process::Launch (ProcessLaunchInfo &launch_info)
return error;
}
-
Error
Process::LoadCore ()
{
@@ -3495,7 +3290,7 @@ Process::Attach (ProcessAttachInfo &attach_info)
else
{
ProcessInstanceInfoList process_infos;
- PlatformSP platform_sp (m_target.GetPlatform ());
+ PlatformSP platform_sp (GetTarget().GetPlatform ());
if (platform_sp)
{
@@ -3597,7 +3392,7 @@ Process::CompleteAttach ()
if (process_arch.IsValid())
{
- m_target.SetArchitecture(process_arch);
+ GetTarget().SetArchitecture(process_arch);
if (log)
{
const char *triple_str = process_arch.GetTriple().getTriple().c_str ();
@@ -3609,19 +3404,19 @@ Process::CompleteAttach ()
// We just attached. If we have a platform, ask it for the process architecture, and if it isn't
// the same as the one we've already set, switch architectures.
- PlatformSP platform_sp (m_target.GetPlatform ());
+ PlatformSP platform_sp (GetTarget().GetPlatform ());
assert (platform_sp.get());
if (platform_sp)
{
- const ArchSpec &target_arch = m_target.GetArchitecture();
+ const ArchSpec &target_arch = GetTarget().GetArchitecture();
if (target_arch.IsValid() && !platform_sp->IsCompatibleArchitecture (target_arch, false, NULL))
{
ArchSpec platform_arch;
platform_sp = platform_sp->GetPlatformForArchitecture (target_arch, &platform_arch);
if (platform_sp)
{
- m_target.SetPlatform (platform_sp);
- m_target.SetArchitecture(platform_arch);
+ GetTarget().SetPlatform (platform_sp);
+ GetTarget().SetArchitecture(platform_arch);
if (log)
log->Printf ("Process::%s switching platform to %s and architecture to %s based on info from attach", __FUNCTION__, platform_sp->GetName().AsCString (""), platform_arch.GetTriple().getTriple().c_str ());
}
@@ -3631,9 +3426,9 @@ Process::CompleteAttach ()
ProcessInstanceInfo process_info;
platform_sp->GetProcessInfo (GetID(), process_info);
const ArchSpec &process_arch = process_info.GetArchitecture();
- if (process_arch.IsValid() && !m_target.GetArchitecture().IsExactMatch(process_arch))
+ if (process_arch.IsValid() && !GetTarget().GetArchitecture().IsExactMatch(process_arch))
{
- m_target.SetArchitecture (process_arch);
+ GetTarget().SetArchitecture (process_arch);
if (log)
log->Printf ("Process::%s switching architecture to %s based on info the platform retrieved for pid %" PRIu64, __FUNCTION__, process_arch.GetTriple().getTriple().c_str (), GetID ());
}
@@ -3648,7 +3443,7 @@ Process::CompleteAttach ()
dyld->DidAttach();
if (log)
{
- ModuleSP exe_module_sp = m_target.GetExecutableModule ();
+ ModuleSP exe_module_sp = GetTarget().GetExecutableModule ();
log->Printf ("Process::%s after DynamicLoader::DidAttach(), target executable is %s (using %s plugin)",
__FUNCTION__,
exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str () : "<none>",
@@ -3664,7 +3459,7 @@ Process::CompleteAttach ()
system_runtime->DidAttach();
if (log)
{
- ModuleSP exe_module_sp = m_target.GetExecutableModule ();
+ ModuleSP exe_module_sp = GetTarget().GetExecutableModule ();
log->Printf ("Process::%s after SystemRuntime::DidAttach(), target executable is %s (using %s plugin)",
__FUNCTION__,
exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str () : "<none>",
@@ -3674,7 +3469,7 @@ Process::CompleteAttach ()
m_os_ap.reset (OperatingSystem::FindPlugin (this, NULL));
// Figure out which one is the executable, and set that in our target:
- const ModuleList &target_modules = m_target.GetImages();
+ const ModuleList &target_modules = GetTarget().GetImages();
Mutex::Locker modules_locker(target_modules.GetMutex());
size_t num_modules = target_modules.GetSize();
ModuleSP new_executable_module_sp;
@@ -3684,17 +3479,17 @@ Process::CompleteAttach ()
ModuleSP module_sp (target_modules.GetModuleAtIndexUnlocked (i));
if (module_sp && module_sp->IsExecutable())
{
- if (m_target.GetExecutableModulePointer() != module_sp.get())
+ if (GetTarget().GetExecutableModulePointer() != module_sp.get())
new_executable_module_sp = module_sp;
break;
}
}
if (new_executable_module_sp)
{
- m_target.SetExecutableModule (new_executable_module_sp, false);
+ GetTarget().SetExecutableModule (new_executable_module_sp, false);
if (log)
{
- ModuleSP exe_module_sp = m_target.GetExecutableModule ();
+ ModuleSP exe_module_sp = GetTarget().GetExecutableModule ();
log->Printf ("Process::%s after looping through modules, target executable is %s",
__FUNCTION__,
exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str () : "<none>");
@@ -3742,7 +3537,6 @@ Process::ConnectRemote (Stream *strm, const char *remote_url)
return error;
}
-
Error
Process::PrivateResume ()
{
@@ -3803,150 +3597,99 @@ Process::PrivateResume ()
}
Error
-Process::Halt (bool clear_thread_plans)
+Process::Halt (bool clear_thread_plans, bool use_run_lock)
{
+ if (! StateIsRunningState(m_public_state.GetValue()))
+ return Error("Process is not running.");
+
// Don't clear the m_clear_thread_plans_on_stop, only set it to true if
// in case it was already set and some thread plan logic calls halt on its
// own.
m_clear_thread_plans_on_stop |= clear_thread_plans;
- // First make sure we aren't in the middle of handling an event, or we might restart. This is pretty weak, since
- // we could just straightaway get another event. It just narrows the window...
- m_currently_handling_event.WaitForValueEqualTo(false);
-
-
- // Pause our private state thread so we can ensure no one else eats
- // the stop event out from under us.
Listener halt_listener ("lldb.process.halt_listener");
- HijackPrivateProcessEvents(&halt_listener);
+ HijackProcessEvents(&halt_listener);
EventSP event_sp;
- Error error (WillHalt());
- bool restored_process_events = false;
- if (error.Success())
+ SendAsyncInterrupt();
+
+ if (m_public_state.GetValue() == eStateAttaching)
{
-
- bool caused_stop = false;
-
- // Ask the process subclass to actually halt our process
- error = DoHalt(caused_stop);
- if (error.Success())
- {
- if (m_public_state.GetValue() == eStateAttaching)
- {
- // Don't hijack and eat the eStateExited as the code that was doing
- // the attach will be waiting for this event...
- RestorePrivateProcessEvents();
- restored_process_events = true;
- SetExitStatus(SIGKILL, "Cancelled async attach.");
- Destroy (false);
- }
- else
- {
- // If "caused_stop" is true, then DoHalt stopped the process. If
- // "caused_stop" is false, the process was already stopped.
- // If the DoHalt caused the process to stop, then we want to catch
- // this event and set the interrupted bool to true before we pass
- // this along so clients know that the process was interrupted by
- // a halt command.
- if (caused_stop)
- {
- // Wait for 1 second for the process to stop.
- TimeValue timeout_time;
- timeout_time = TimeValue::Now();
- timeout_time.OffsetWithSeconds(10);
- bool got_event = halt_listener.WaitForEvent (&timeout_time, event_sp);
- StateType state = ProcessEventData::GetStateFromEvent(event_sp.get());
-
- if (!got_event || state == eStateInvalid)
- {
- // We timeout out and didn't get a stop event...
- error.SetErrorStringWithFormat ("Halt timed out. State = %s", StateAsCString(GetState()));
- }
- else
- {
- if (StateIsStoppedState (state, false))
- {
- // We caused the process to interrupt itself, so mark this
- // as such in the stop event so clients can tell an interrupted
- // process from a natural stop
- ProcessEventData::SetInterruptedInEvent (event_sp.get(), true);
- }
- else
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("Process::Halt() failed to stop, state is: %s", StateAsCString(state));
- error.SetErrorString ("Did not get stopped event after halt.");
- }
- }
- }
- DidHalt();
- }
- }
+ // Don't hijack and eat the eStateExited as the code that was doing
+ // the attach will be waiting for this event...
+ RestoreProcessEvents();
+ SetExitStatus(SIGKILL, "Cancelled async attach.");
+ Destroy (false);
+ return Error();
}
- // Resume our private state thread before we post the event (if any)
- if (!restored_process_events)
- RestorePrivateProcessEvents();
- // Post any event we might have consumed. If all goes well, we will have
- // stopped the process, intercepted the event and set the interrupted
- // bool in the event. Post it to the private event queue and that will end up
- // correctly setting the state.
- if (event_sp)
- m_private_state_broadcaster.BroadcastEvent(event_sp);
+ // Wait for 10 second for the process to stop.
+ TimeValue timeout_time;
+ timeout_time = TimeValue::Now();
+ timeout_time.OffsetWithSeconds(10);
+ StateType state = WaitForProcessToStop(&timeout_time, &event_sp, true, &halt_listener,
+ nullptr, use_run_lock);
+ RestoreProcessEvents();
- return error;
+ if (state == eStateInvalid || ! event_sp)
+ {
+ // We timed out and didn't get a stop event...
+ return Error("Halt timed out. State = %s", StateAsCString(GetState()));
+ }
+
+ BroadcastEvent(event_sp);
+
+ return Error();
}
Error
-Process::HaltForDestroyOrDetach(lldb::EventSP &exit_event_sp)
+Process::StopForDestroyOrDetach(lldb::EventSP &exit_event_sp)
{
Error error;
if (m_public_state.GetValue() == eStateRunning)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
if (log)
- log->Printf("Process::Destroy() About to halt.");
- error = Halt();
- if (error.Success())
+ log->Printf("Process::%s() About to stop.", __FUNCTION__);
+
+ ListenerSP listener_sp (new Listener("lldb.Process.StopForDestroyOrDetach.hijack"));
+ HijackProcessEvents(listener_sp.get());
+
+ SendAsyncInterrupt();
+
+ // Consume the interrupt event.
+ TimeValue timeout (TimeValue::Now());
+ timeout.OffsetWithSeconds(10);
+
+ StateType state = WaitForProcessToStop (&timeout, &exit_event_sp, true, listener_sp.get());
+
+ RestoreProcessEvents();
+
+ // If the process exited while we were waiting for it to stop, put the exited event into
+ // the shared pointer passed in and return. Our caller doesn't need to do anything else, since
+ // they don't have a process anymore...
+
+ if (state == eStateExited || m_private_state.GetValue() == eStateExited)
{
- // Consume the halt event.
- TimeValue timeout (TimeValue::Now());
- timeout.OffsetWithSeconds(1);
- StateType state = WaitForProcessToStop (&timeout, &exit_event_sp);
-
- // If the process exited while we were waiting for it to stop, put the exited event into
- // the shared pointer passed in and return. Our caller doesn't need to do anything else, since
- // they don't have a process anymore...
-
- if (state == eStateExited || m_private_state.GetValue() == eStateExited)
- {
- if (log)
- log->Printf("Process::HaltForDestroyOrDetach() Process exited while waiting to Halt.");
- return error;
- }
- else
- exit_event_sp.reset(); // It is ok to consume any non-exit stop events
-
- if (state != eStateStopped)
- {
- if (log)
- log->Printf("Process::HaltForDestroyOrDetach() Halt failed to stop, state is: %s", StateAsCString(state));
- // If we really couldn't stop the process then we should just error out here, but if the
- // lower levels just bobbled sending the event and we really are stopped, then continue on.
- StateType private_state = m_private_state.GetValue();
- if (private_state != eStateStopped)
- {
- return error;
- }
- }
+ if (log)
+ log->Printf("Process::%s() Process exited while waiting to stop.", __FUNCTION__);
+ return error;
}
else
+ exit_event_sp.reset(); // It is ok to consume any non-exit stop events
+
+ if (state != eStateStopped)
{
if (log)
- log->Printf("Process::HaltForDestroyOrDetach() Halt got error: %s", error.AsCString());
+ log->Printf("Process::%s() failed to stop, state is: %s", __FUNCTION__, StateAsCString(state));
+ // If we really couldn't stop the process then we should just error out here, but if the
+ // lower levels just bobbled sending the event and we really are stopped, then continue on.
+ StateType private_state = m_private_state.GetValue();
+ if (private_state != eStateStopped)
+ {
+ return error;
+ }
}
}
return error;
@@ -3965,7 +3708,7 @@ Process::Detach (bool keep_stopped)
{
if (DetachRequiresHalt())
{
- error = HaltForDestroyOrDetach (exit_event_sp);
+ error = StopForDestroyOrDetach (exit_event_sp);
if (!error.Success())
{
m_destroy_in_process = false;
@@ -4016,7 +3759,7 @@ Process::Detach (bool keep_stopped)
Error
Process::Destroy (bool force_kill)
{
-
+
// Tell ourselves we are in the process of destroying the process, so that we don't do any unnecessary work
// that might hinder the destruction. Remember to set this back to false when we are done. That way if the attempt
// failed and the process stays around for some reason it won't be in a confused state.
@@ -4039,7 +3782,7 @@ Process::Destroy (bool force_kill)
EventSP exit_event_sp;
if (DestroyRequiresHalt())
{
- error = HaltForDestroyOrDetach(exit_event_sp);
+ error = StopForDestroyOrDetach(exit_event_sp);
}
if (m_public_state.GetValue() != eStateRunning)
@@ -4103,7 +3846,7 @@ Process::Signal (int signal)
}
void
-Process::SetUnixSignals (const UnixSignalsSP &signals_sp)
+Process::SetUnixSignals(UnixSignalsSP &&signals_sp)
{
assert (signals_sp && "null signals_sp");
m_unix_signals_sp = signals_sp;
@@ -4119,16 +3862,15 @@ Process::GetUnixSignals ()
lldb::ByteOrder
Process::GetByteOrder () const
{
- return m_target.GetArchitecture().GetByteOrder();
+ return GetTarget().GetArchitecture().GetByteOrder();
}
uint32_t
Process::GetAddressByteSize () const
{
- return m_target.GetArchitecture().GetAddressByteSize();
+ return GetTarget().GetArchitecture().GetAddressByteSize();
}
-
bool
Process::ShouldBroadcastEvent (Event *event_ptr)
{
@@ -4142,6 +3884,10 @@ Process::ShouldBroadcastEvent (Event *event_ptr)
case eStateExited:
case eStateUnloaded:
m_stdio_communication.SynchronizeWithReadThread();
+ m_stdio_communication.Disconnect();
+ m_stdio_communication.StopReadThread();
+ m_stdin_forward = false;
+
// fall-through
case eStateConnected:
case eStateAttaching:
@@ -4258,7 +4004,6 @@ Process::ShouldBroadcastEvent (Event *event_ptr)
ProcessEventData::SetRestartedInEvent(event_ptr, true);
PrivateResume ();
}
-
}
else
{
@@ -4291,7 +4036,6 @@ Process::ShouldBroadcastEvent (Event *event_ptr)
return return_value;
}
-
bool
Process::StartPrivateStateThread (bool is_secondary_thread)
{
@@ -4326,7 +4070,7 @@ Process::StartPrivateStateThread (bool is_secondary_thread)
// Create the private state thread, and start it running.
PrivateStateThreadArgs args = {this, is_secondary_thread};
- m_private_state_thread = ThreadLauncher::LaunchThread(thread_name, Process::PrivateStateThread, (void *) &args, NULL);
+ m_private_state_thread = ThreadLauncher::LaunchThread(thread_name, Process::PrivateStateThread, (void *) &args, NULL, 8 * 1024 * 1024);
if (m_private_state_thread.IsJoinable())
{
ResumePrivateStateThread();
@@ -4432,8 +4176,6 @@ Process::HandlePrivateEvent (EventSP &event_sp)
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
m_resume_requested = false;
- m_currently_handling_event.SetValue(true, eBroadcastNever);
-
const StateType new_state = Process::ProcessEventData::GetStateFromEvent(event_sp.get());
// First check to see if anybody wants a shot at this event:
@@ -4460,7 +4202,6 @@ Process::HandlePrivateEvent (EventSP &event_sp)
{
// FIXME: should cons up an exited event, and discard this one.
SetExitStatus(0, m_next_event_action_ap->GetExitString());
- m_currently_handling_event.SetValue(false, eBroadcastAlways);
SetNextEventAction(NULL);
return;
}
@@ -4532,7 +4273,7 @@ Process::HandlePrivateEvent (EventSP &event_sp)
// events) and we do need the IO handler to be pushed and popped
// correctly.
- if (is_hijacked || m_target.GetDebugger().IsHandlingEvents() == false)
+ if (is_hijacked || GetTarget().GetDebugger().IsHandlingEvents() == false)
PopProcessIOHandler ();
}
}
@@ -4550,7 +4291,22 @@ Process::HandlePrivateEvent (EventSP &event_sp)
StateAsCString (GetState ()));
}
}
- m_currently_handling_event.SetValue(false, eBroadcastAlways);
+}
+
+Error
+Process::HaltPrivate()
+{
+ EventSP event_sp;
+ Error error (WillHalt());
+ if (error.Fail())
+ return error;
+
+ // Ask the process subclass to actually halt our process
+ bool caused_stop;
+ error = DoHalt(caused_stop);
+
+ DidHalt();
+ return error;
}
thread_result_t
@@ -4573,6 +4329,7 @@ Process::RunPrivateStateThread (bool is_secondary_thread)
__FUNCTION__, static_cast<void*>(this), GetID());
bool exit_now = false;
+ bool interrupt_requested = false;
while (!exit_now)
{
EventSP event_sp;
@@ -4612,13 +4369,32 @@ Process::RunPrivateStateThread (bool is_secondary_thread)
GetID());
BroadcastEvent (eBroadcastBitInterrupt, NULL);
}
- else
+ else if(StateIsRunningState(m_last_broadcast_state))
{
if (log)
log->Printf ("Process::%s (arg = %p, pid = %" PRIu64 ") woke up with an interrupt - Halting.",
__FUNCTION__, static_cast<void*>(this),
GetID());
- Halt();
+ Error error = HaltPrivate();
+ if (error.Fail() && log)
+ log->Printf ("Process::%s (arg = %p, pid = %" PRIu64 ") failed to halt the process: %s",
+ __FUNCTION__, static_cast<void*>(this),
+ GetID(), error.AsCString());
+ // Halt should generate a stopped event. Make a note of the fact that we were
+ // doing the interrupt, so we can set the interrupted flag after we receive the
+ // event. We deliberately set this to true even if HaltPrivate failed, so that we
+ // can interrupt on the next natural stop.
+ interrupt_requested = true;
+ }
+ else
+ {
+ // This can happen when someone (e.g. Process::Halt) sees that we are running and
+ // sends an interrupt request, but the process actually stops before we receive
+ // it. In that case, we can just ignore the request. We use
+ // m_last_broadcast_state, because the Stopped event may not have been popped of
+ // the event queue yet, which is when the public state gets updated.
+ if (log)
+ log->Printf("Process::%s ignoring interrupt as we have already stopped.", __FUNCTION__);
}
continue;
}
@@ -4633,6 +4409,23 @@ Process::RunPrivateStateThread (bool is_secondary_thread)
m_clear_thread_plans_on_stop = false;
m_thread_list.DiscardThreadPlans();
}
+
+ if (interrupt_requested)
+ {
+ if (StateIsStoppedState (internal_state, true))
+ {
+ // We requested the interrupt, so mark this as such in the stop event so
+ // clients can tell an interrupted process from a natural stop
+ ProcessEventData::SetInterruptedInEvent (event_sp.get(), true);
+ interrupt_requested = false;
+ }
+ else if (log)
+ {
+ log->Printf("Process::%s interrupt_requested, but a non-stopped state '%s' received.",
+ __FUNCTION__, StateAsCString(internal_state));
+ }
+ }
+
HandlePrivateEvent (event_sp);
}
@@ -4690,9 +4483,7 @@ Process::ProcessEventData::ProcessEventData (const ProcessSP &process_sp, StateT
m_process_wp = process_sp;
}
-Process::ProcessEventData::~ProcessEventData()
-{
-}
+Process::ProcessEventData::~ProcessEventData() = default;
const ConstString &
Process::ProcessEventData::GetFlavorString ()
@@ -4734,7 +4525,12 @@ Process::ProcessEventData::DoOnRemoval (Event *event_ptr)
// If we're stopped and haven't restarted, then do the StopInfo actions here:
if (m_state == eStateStopped && ! m_restarted)
- {
+ {
+ // Let process subclasses know we are about to do a public stop and
+ // do anything they might need to in order to speed up register and
+ // memory accesses.
+ process_sp->WillPublicStop();
+
ThreadList &curr_thread_list = process_sp->GetThreadList();
uint32_t num_threads = curr_thread_list.GetSize();
uint32_t idx;
@@ -4818,7 +4614,6 @@ Process::ProcessEventData::DoOnRemoval (Event *event_ptr)
still_should_stop = this_thread_wants_to_stop;
}
}
-
if (!GetRestarted())
{
@@ -4967,13 +4762,13 @@ Process::ProcessEventData::SetUpdateStateOnRemoval (Event *event_ptr)
lldb::TargetSP
Process::CalculateTarget ()
{
- return m_target.shared_from_this();
+ return m_target_sp.lock();
}
void
Process::CalculateExecutionContext (ExecutionContext &exe_ctx)
{
- exe_ctx.SetTargetPtr (&m_target);
+ exe_ctx.SetTargetPtr (&GetTarget());
exe_ctx.SetProcessPtr (this);
exe_ctx.SetThreadPtr(NULL);
exe_ctx.SetFramePtr (NULL);
@@ -5052,7 +4847,6 @@ Process::GetAsyncProfileData (char *buf, size_t buf_size, Error &error)
return bytes_available;
}
-
//------------------------------------------------------------------
// Process STDIO
//------------------------------------------------------------------
@@ -5084,7 +4878,6 @@ Process::GetSTDOUT (char *buf, size_t buf_size, Error &error)
return bytes_available;
}
-
size_t
Process::GetSTDERR (char *buf, size_t buf_size, Error &error)
{
@@ -5135,12 +4928,8 @@ public:
m_read_file.SetDescriptor(GetInputFD(), false);
}
- virtual
- ~IOHandlerProcessSTDIO ()
- {
-
- }
-
+ ~IOHandlerProcessSTDIO() override = default;
+
// Each IOHandler gets to run until it is done. It should read data
// from the "in" and place output into "out" and "err and return
// when done.
@@ -5207,7 +4996,7 @@ public:
break;
case 'i':
if (StateIsRunningState(m_process->GetState()))
- m_process->Halt();
+ m_process->SendAsyncInterrupt();
break;
}
}
@@ -5232,8 +5021,8 @@ public:
// Do only things that are safe to do in an interrupt context (like in
// a SIGINT handler), like write 1 byte to a file descriptor. This will
// interrupt the IOHandlerProcessSTDIO::Run() and we can look at the byte
- // that was written to the pipe and then call m_process->Halt() from a
- // much safer location in code.
+ // that was written to the pipe and then call m_process->SendAsyncInterrupt()
+ // from a much safer location in code.
if (m_active)
{
char ch = 'i'; // Send 'i' for interrupt
@@ -5263,7 +5052,6 @@ public:
void
GotEOF() override
{
-
}
protected:
@@ -5301,7 +5089,7 @@ Process::ProcessIOHandlerIsActive ()
{
IOHandlerSP io_handler_sp (m_process_input_reader);
if (io_handler_sp)
- return m_target.GetDebugger().IsTopIOHandler (io_handler_sp);
+ return GetTarget().GetDebugger().IsTopIOHandler (io_handler_sp);
return false;
}
bool
@@ -5315,7 +5103,7 @@ Process::PushProcessIOHandler ()
log->Printf("Process::%s pushing IO handler", __FUNCTION__);
io_handler_sp->SetIsDone(false);
- m_target.GetDebugger().PushIOHandler (io_handler_sp);
+ GetTarget().GetDebugger().PushIOHandler (io_handler_sp);
return true;
}
return false;
@@ -5326,7 +5114,7 @@ Process::PopProcessIOHandler ()
{
IOHandlerSP io_handler_sp (m_process_input_reader);
if (io_handler_sp)
- return m_target.GetDebugger().PopIOHandler (io_handler_sp);
+ return GetTarget().GetDebugger().PopIOHandler (io_handler_sp);
return false;
}
@@ -5343,6 +5131,54 @@ Process::SettingsTerminate ()
Thread::SettingsTerminate ();
}
+namespace
+{
+ // RestorePlanState is used to record the "is private", "is master" and "okay to discard" fields of
+ // the plan we are running, and reset it on Clean or on destruction.
+ // It will only reset the state once, so you can call Clean and then monkey with the state and it
+ // won't get reset on you again.
+
+ class RestorePlanState
+ {
+ public:
+ RestorePlanState (lldb::ThreadPlanSP thread_plan_sp) :
+ m_thread_plan_sp(thread_plan_sp),
+ m_already_reset(false)
+ {
+ if (m_thread_plan_sp)
+ {
+ m_private = m_thread_plan_sp->GetPrivate();
+ m_is_master = m_thread_plan_sp->IsMasterPlan();
+ m_okay_to_discard = m_thread_plan_sp->OkayToDiscard();
+ }
+ }
+
+ ~RestorePlanState()
+ {
+ Clean();
+ }
+
+ void
+ Clean ()
+ {
+ if (!m_already_reset && m_thread_plan_sp)
+ {
+ m_already_reset = true;
+ m_thread_plan_sp->SetPrivate(m_private);
+ m_thread_plan_sp->SetIsMasterPlan (m_is_master);
+ m_thread_plan_sp->SetOkayToDiscard(m_okay_to_discard);
+ }
+ }
+
+ private:
+ lldb::ThreadPlanSP m_thread_plan_sp;
+ bool m_already_reset;
+ bool m_private;
+ bool m_is_master;
+ bool m_okay_to_discard;
+ };
+} // anonymous namespace
+
ExpressionResults
Process::RunThreadPlan (ExecutionContext &exe_ctx,
lldb::ThreadPlanSP &thread_plan_sp,
@@ -5376,12 +5212,22 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
return eExpressionSetupError;
}
+ // We need to change some of the thread plan attributes for the thread plan runner. This will restore them
+ // when we are done:
+
+ RestorePlanState thread_plan_restorer(thread_plan_sp);
+
// We rely on the thread plan we are running returning "PlanCompleted" if when it successfully completes.
// For that to be true the plan can't be private - since private plans suppress themselves in the
// GetCompletedPlan call.
- bool orig_plan_private = thread_plan_sp->GetPrivate();
thread_plan_sp->SetPrivate(false);
+
+ // The plans run with RunThreadPlan also need to be terminal master plans or when they are done we will end
+ // up asking the plan above us whether we should stop, which may give the wrong answer.
+
+ thread_plan_sp->SetIsMasterPlan (true);
+ thread_plan_sp->SetOkayToDiscard(false);
if (m_private_state.GetValue() != eStateStopped)
{
@@ -5553,7 +5399,6 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
}
one_thread_timeout_usec = computed_one_thread_timeout;
all_threads_timeout_usec = timeout_usec - one_thread_timeout_usec;
-
}
}
@@ -5595,8 +5440,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
#endif
TimeValue one_thread_timeout;
TimeValue final_timeout;
-
-
+
while (1)
{
// We usually want to resume the process if we get to the top of the loop.
@@ -5664,7 +5508,9 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
{
// This is probably an overabundance of caution, I don't think I should ever get a stopped & restarted
// event here. But if I do, the best thing is to Halt and then get out of here.
- Halt();
+ const bool clear_thread_plans = false;
+ const bool use_run_lock = false;
+ Halt(clear_thread_plans, use_run_lock);
}
errors.Printf("Didn't get running event after initial resume, got %s instead.",
@@ -5758,7 +5604,9 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
bool keep_going = false;
if (event_sp->GetType() == eBroadcastBitInterrupt)
{
- Halt();
+ const bool clear_thread_plans = false;
+ const bool use_run_lock = false;
+ Halt(clear_thread_plans, use_run_lock);
return_value = eExpressionInterrupted;
errors.Printf ("Execution halted by user interrupt.");
if (log)
@@ -5796,7 +5644,6 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
keep_going = true;
do_resume = false;
handle_running_event = true;
-
}
else
{
@@ -5811,10 +5658,10 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
{
if (log)
log->PutCString ("Process::RunThreadPlan(): execution completed successfully.");
- // Now mark this plan as private so it doesn't get reported as the stop reason
- // after this point.
- if (thread_plan_sp)
- thread_plan_sp->SetPrivate (orig_plan_private);
+
+ // Restore the plan state so it will get reported as intended when we are done.
+ thread_plan_restorer.Clean();
+
return_value = eExpressionCompleted;
}
else
@@ -5827,6 +5674,13 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
return_value = eExpressionHitBreakpoint;
if (!options.DoesIgnoreBreakpoints())
{
+ // Restore the plan state and then force Private to false. We are
+ // going to stop because of this plan so we need it to become a public
+ // plan or it won't report correctly when we continue to its termination
+ // later on.
+ thread_plan_restorer.Clean();
+ if (thread_plan_sp)
+ thread_plan_sp->SetPrivate(false);
event_to_broadcast_sp = event_sp;
}
}
@@ -5929,7 +5783,9 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
{
if (log)
log->Printf ("Process::RunThreadPlan(): Running Halt.");
- halt_error = Halt();
+ const bool clear_thread_plans = false;
+ const bool use_run_lock = false;
+ Halt(clear_thread_plans, use_run_lock);
}
if (halt_error.Success())
{
@@ -6045,6 +5901,19 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
m_public_state.SetValueNoLock(old_state);
}
+ if (return_value != eExpressionCompleted && log)
+ {
+ // Print a backtrace into the log so we can figure out where we are:
+ StreamString s;
+ s.PutCString("Thread state after unsuccessful completion: \n");
+ thread->GetStackFrameStatus (s,
+ 0,
+ UINT32_MAX,
+ true,
+ UINT32_MAX);
+ log->PutCString(s.GetData());
+
+ }
// Restore the thread state if we are going to discard the plan execution. There are three cases where this
// could happen:
// 1) The execution successfully completed
@@ -6133,7 +6002,8 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
else
ts.Printf("[ip unknown] ");
- lldb::StopInfoSP stop_info_sp = thread->GetStopInfo();
+ // Show the private stop info here, the public stop info will be from the last natural stop.
+ lldb::StopInfoSP stop_info_sp = thread->GetPrivateStopInfo();
if (stop_info_sp)
{
const char *stop_desc = stop_info_sp->GetDescription();
@@ -6159,7 +6029,6 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
log->Printf ("Process::RunThreadPlan: ExecutionInterrupted - discarding thread plans up to %p.",
static_cast<void*>(thread_plan_sp.get()));
thread->DiscardThreadPlansUpToPlan (thread_plan_sp);
- thread_plan_sp->SetPrivate (orig_plan_private);
}
else
{
@@ -6176,7 +6045,6 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
if (options.DoesUnwindOnError())
{
thread->DiscardThreadPlansUpToPlan (thread_plan_sp);
- thread_plan_sp->SetPrivate (orig_plan_private);
}
}
else
@@ -6202,7 +6070,6 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
if (log)
log->PutCString("Process::RunThreadPlan(): discarding thread plan 'cause unwind_on_error is set.");
thread->DiscardThreadPlansUpToPlan (thread_plan_sp);
- thread_plan_sp->SetPrivate (orig_plan_private);
}
}
}
@@ -6360,7 +6227,6 @@ Process::GetThreadStatus (Stream &strm,
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_PROCESS));
if (log)
log->Printf("Process::GetThreadStatus - thread 0x" PRIu64 " vanished while running Thread::GetStatus.");
-
}
}
return num_thread_infos_dumped;
@@ -6529,6 +6395,65 @@ Process::ModulesDidLoad (ModuleList &module_list)
if (language_runtime_sp)
language_runtime_sp->ModulesDidLoad(module_list);
}
+
+ LoadOperatingSystemPlugin(false);
+}
+
+void
+Process::PrintWarning (uint64_t warning_type, const void *repeat_key, const char *fmt, ...)
+{
+ bool print_warning = true;
+
+ StreamSP stream_sp = GetTarget().GetDebugger().GetAsyncOutputStream();
+ if (stream_sp.get() == nullptr)
+ return;
+ if (warning_type == eWarningsOptimization
+ && GetWarningsOptimization() == false)
+ {
+ return;
+ }
+
+ if (repeat_key != nullptr)
+ {
+ WarningsCollection::iterator it = m_warnings_issued.find (warning_type);
+ if (it == m_warnings_issued.end())
+ {
+ m_warnings_issued[warning_type] = WarningsPointerSet();
+ m_warnings_issued[warning_type].insert (repeat_key);
+ }
+ else
+ {
+ if (it->second.find (repeat_key) != it->second.end())
+ {
+ print_warning = false;
+ }
+ else
+ {
+ it->second.insert (repeat_key);
+ }
+ }
+ }
+
+ if (print_warning)
+ {
+ va_list args;
+ va_start (args, fmt);
+ stream_sp->PrintfVarArg (fmt, args);
+ va_end (args);
+ }
+}
+
+void
+Process::PrintWarningOptimization (const SymbolContext &sc)
+{
+ if (GetWarningsOptimization() == true
+ && sc.module_sp.get()
+ && sc.module_sp->GetFileSpec().GetFilename().IsEmpty() == false
+ && sc.function
+ && sc.function->GetIsOptimized() == true)
+ {
+ PrintWarning (Process::Warnings::eWarningsOptimization, sc.module_sp.get(), "%s was compiled with optimization - stepping may behave oddly; variables may not be available.\n", sc.module_sp->GetFileSpec().GetFilename().GetCString());
+ }
}
ThreadCollectionSP
@@ -6568,3 +6493,25 @@ Process::GetModuleSpec(const FileSpec& module_file_spec,
module_spec.Clear();
return false;
}
+
+size_t
+Process::AddImageToken(lldb::addr_t image_ptr)
+{
+ m_image_tokens.push_back(image_ptr);
+ return m_image_tokens.size() - 1;
+}
+
+lldb::addr_t
+Process::GetImagePtrFromToken(size_t token) const
+{
+ if (token < m_image_tokens.size())
+ return m_image_tokens[token];
+ return LLDB_INVALID_IMAGE_TOKEN;
+}
+
+void
+Process::ResetImageToken(size_t token)
+{
+ if (token < m_image_tokens.size())
+ m_image_tokens[token] = LLDB_INVALID_IMAGE_TOKEN;
+}
diff --git a/source/Target/ProcessLaunchInfo.cpp b/source/Target/ProcessLaunchInfo.cpp
index bd2e1bc4c4a1..fc17fe614c5c 100644
--- a/source/Target/ProcessLaunchInfo.cpp
+++ b/source/Target/ProcessLaunchInfo.cpp
@@ -11,6 +11,7 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Target/ProcessLaunchInfo.h"
#include "lldb/Target/FileAction.h"
#include "lldb/Target/Target.h"
@@ -129,7 +130,7 @@ bool
ProcessLaunchInfo::AppendSuppressFileAction (int fd, bool read, bool write)
{
FileAction file_action;
- if (file_action.Open(fd, FileSpec{"/dev/null", false}, read, write))
+ if (file_action.Open(fd, FileSpec{FileSystem::DEV_NULL, false}, read, write))
{
AppendFileAction (file_action);
return true;
diff --git a/source/Target/RegisterContext.cpp b/source/Target/RegisterContext.cpp
index 97f6f21c53c8..afc815ba4a4e 100644
--- a/source/Target/RegisterContext.cpp
+++ b/source/Target/RegisterContext.cpp
@@ -20,6 +20,7 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
@@ -103,7 +104,20 @@ uint64_t
RegisterContext::GetPC(uint64_t fail_value)
{
uint32_t reg = ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
- return ReadRegisterAsUnsigned (reg, fail_value);
+ uint64_t pc = ReadRegisterAsUnsigned (reg, fail_value);
+
+ if (pc != fail_value)
+ {
+ TargetSP target_sp = m_thread.CalculateTarget();
+ if (target_sp)
+ {
+ Target *target = target_sp.get();
+ if (target)
+ pc = target->GetOpcodeLoadAddress (pc, eAddressClassCode);
+ }
+ }
+
+ return pc;
}
bool
@@ -557,7 +571,7 @@ RegisterContext::ConvertBetweenRegisterKinds (lldb::RegisterKind source_rk, uint
// case 1:
// {
// int8_t v;
-// if (data.ExtractBytes (0, sizeof (int8_t), lldb::endian::InlHostByteOrder(), &v) != sizeof (int8_t))
+// if (data.ExtractBytes (0, sizeof (int8_t), endian::InlHostByteOrder(), &v) != sizeof (int8_t))
// return false;
// value = v;
// return true;
@@ -565,7 +579,7 @@ RegisterContext::ConvertBetweenRegisterKinds (lldb::RegisterKind source_rk, uint
// case 2:
// {
// int16_t v;
-// if (data.ExtractBytes (0, sizeof (int16_t), lldb::endian::InlHostByteOrder(), &v) != sizeof (int16_t))
+// if (data.ExtractBytes (0, sizeof (int16_t), endian::InlHostByteOrder(), &v) != sizeof (int16_t))
// return false;
// value = v;
// return true;
@@ -573,7 +587,7 @@ RegisterContext::ConvertBetweenRegisterKinds (lldb::RegisterKind source_rk, uint
// case 4:
// {
// int32_t v;
-// if (data.ExtractBytes (0, sizeof (int32_t), lldb::endian::InlHostByteOrder(), &v) != sizeof (int32_t))
+// if (data.ExtractBytes (0, sizeof (int32_t), endian::InlHostByteOrder(), &v) != sizeof (int32_t))
// return false;
// value = v;
// return true;
@@ -581,7 +595,7 @@ RegisterContext::ConvertBetweenRegisterKinds (lldb::RegisterKind source_rk, uint
// case 8:
// {
// int64_t v;
-// if (data.ExtractBytes (0, sizeof (int64_t), lldb::endian::InlHostByteOrder(), &v) != sizeof (int64_t))
+// if (data.ExtractBytes (0, sizeof (int64_t), endian::InlHostByteOrder(), &v) != sizeof (int64_t))
// return false;
// value = v;
// return true;
@@ -594,7 +608,7 @@ RegisterContext::ConvertBetweenRegisterKinds (lldb::RegisterKind source_rk, uint
// case sizeof (float):
// {
// float v;
-// if (data.ExtractBytes (0, sizeof (float), lldb::endian::InlHostByteOrder(), &v) != sizeof (float))
+// if (data.ExtractBytes (0, sizeof (float), endian::InlHostByteOrder(), &v) != sizeof (float))
// return false;
// value = v;
// return true;
@@ -602,7 +616,7 @@ RegisterContext::ConvertBetweenRegisterKinds (lldb::RegisterKind source_rk, uint
// case sizeof (double):
// {
// double v;
-// if (data.ExtractBytes (0, sizeof (double), lldb::endian::InlHostByteOrder(), &v) != sizeof (double))
+// if (data.ExtractBytes (0, sizeof (double), endian::InlHostByteOrder(), &v) != sizeof (double))
// return false;
// value = v;
// return true;
@@ -610,7 +624,7 @@ RegisterContext::ConvertBetweenRegisterKinds (lldb::RegisterKind source_rk, uint
// case sizeof (long double):
// {
// double v;
-// if (data.ExtractBytes (0, sizeof (long double), lldb::endian::InlHostByteOrder(), &v) != sizeof (long double))
+// if (data.ExtractBytes (0, sizeof (long double), endian::InlHostByteOrder(), &v) != sizeof (long double))
// return false;
// value = v;
// return true;
diff --git a/source/Target/StackFrame.cpp b/source/Target/StackFrame.cpp
index 7c5b022dac7c..e835521e7884 100644
--- a/source/Target/StackFrame.cpp
+++ b/source/Target/StackFrame.cpp
@@ -24,6 +24,7 @@
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContextScope.h"
+#include "lldb/Symbol/Type.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
@@ -259,7 +260,7 @@ StackFrame::GetFrameCodeAddress()
TargetSP target_sp (thread_sp->CalculateTarget());
if (target_sp)
{
- if (m_frame_code_addr.SetOpcodeLoadAddress (m_frame_code_addr.GetOffset(), target_sp.get()))
+ if (m_frame_code_addr.SetOpcodeLoadAddress (m_frame_code_addr.GetOffset(), target_sp.get(), eAddressClassCode))
{
ModuleSP module_sp (m_frame_code_addr.GetModule());
if (module_sp)
@@ -659,7 +660,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
else
name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx);
- var_sp = variable_list->FindVariable(name_const_string);
+ var_sp = variable_list->FindVariable(name_const_string, false);
bool synthetically_added_instance_object = false;
@@ -667,7 +668,8 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
{
var_path.erase (0, name_const_string.GetLength ());
}
- else if (options & eExpressionPathOptionsAllowDirectIVarAccess)
+
+ if (!var_sp && (options & eExpressionPathOptionsAllowDirectIVarAccess))
{
// Check for direct ivars access which helps us with implicit
// access to ivars with the "this->" or "self->"
@@ -689,13 +691,43 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
}
}
}
+
+ if (!var_sp && (options & eExpressionPathOptionsInspectAnonymousUnions))
+ {
+ // Check if any anonymous unions are there which contain a variable with the name we need
+ for (size_t i = 0;
+ i < variable_list->GetSize();
+ i++)
+ {
+ if (VariableSP variable_sp = variable_list->GetVariableAtIndex(i))
+ {
+ if (variable_sp->GetName().IsEmpty())
+ {
+ if (Type *var_type = variable_sp->GetType())
+ {
+ if (var_type->GetForwardCompilerType().IsAnonymousType())
+ {
+ valobj_sp = GetValueObjectForFrameVariable (variable_sp, use_dynamic);
+ if (!valobj_sp)
+ return valobj_sp;
+ valobj_sp = valobj_sp->GetChildMemberWithName(name_const_string, true);
+ if (valobj_sp)
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
- if (var_sp)
+ if (var_sp && !valobj_sp)
{
valobj_sp = GetValueObjectForFrameVariable (var_sp, use_dynamic);
if (!valobj_sp)
return valobj_sp;
-
+ }
+ if (valobj_sp)
+ {
// We are dumping at least one child
while (separator_idx != std::string::npos)
{
@@ -713,7 +745,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
{
// Make sure we aren't trying to deref an objective
// C ivar if this is not allowed
- const uint32_t pointer_type_flags = valobj_sp->GetClangType().GetTypeInfo (NULL);
+ const uint32_t pointer_type_flags = valobj_sp->GetCompilerType().GetTypeInfo (NULL);
if ((pointer_type_flags & eTypeIsObjC) &&
(pointer_type_flags & eTypeIsPointer))
{
@@ -827,7 +859,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
if (end && *end == ']'
&& *(end-1) != '[') // this code forces an error in the case of arr[]. as bitfield[] is not a good syntax we're good to go
{
- if (valobj_sp->GetClangType().IsPointerToScalarType() && deref)
+ if (valobj_sp->GetCompilerType().IsPointerToScalarType() && deref)
{
// what we have is *ptr[low]. the most similar C++ syntax is to deref ptr
// and extract bit low out of it. reading array item low
@@ -845,7 +877,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
valobj_sp = temp;
deref = false;
}
- else if (valobj_sp->GetClangType().IsArrayOfScalarType() && deref)
+ else if (valobj_sp->GetCompilerType().IsArrayOfScalarType() && deref)
{
// what we have is *arr[low]. the most similar C++ syntax is to get arr[0]
// (an operation that is equivalent to deref-ing arr)
@@ -870,9 +902,9 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
{
bool is_objc_pointer = true;
- if (valobj_sp->GetClangType().GetMinimumLanguage() != eLanguageTypeObjC)
+ if (valobj_sp->GetCompilerType().GetMinimumLanguage() != eLanguageTypeObjC)
is_objc_pointer = false;
- else if (!valobj_sp->GetClangType().IsPointerType())
+ else if (!valobj_sp->GetCompilerType().IsPointerType())
is_objc_pointer = false;
if (no_synth_child && is_objc_pointer)
@@ -929,7 +961,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
}
}
}
- else if (valobj_sp->GetClangType().IsArrayType (NULL, NULL, &is_incomplete_array))
+ else if (valobj_sp->GetCompilerType().IsArrayType (NULL, NULL, &is_incomplete_array))
{
// Pass false to dynamic_value here so we can tell the difference between
// no dynamic value and no member of this type...
@@ -946,7 +978,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
var_expr_path_strm.GetString().c_str());
}
}
- else if (valobj_sp->GetClangType().IsScalarType())
+ else if (valobj_sp->GetCompilerType().IsScalarType())
{
// this is a bitfield asking to display just one bit
child_valobj_sp = valobj_sp->GetSyntheticBitFieldChild(child_index, child_index, true);
@@ -1029,7 +1061,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
final_index = temp;
}
- if (valobj_sp->GetClangType().IsPointerToScalarType() && deref)
+ if (valobj_sp->GetCompilerType().IsPointerToScalarType() && deref)
{
// what we have is *ptr[low-high]. the most similar C++ syntax is to deref ptr
// and extract bits low thru high out of it. reading array items low thru high
@@ -1047,7 +1079,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
valobj_sp = temp;
deref = false;
}
- else if (valobj_sp->GetClangType().IsArrayOfScalarType() && deref)
+ else if (valobj_sp->GetCompilerType().IsArrayOfScalarType() && deref)
{
// what we have is *arr[low-high]. the most similar C++ syntax is to get arr[0]
// (an operation that is equivalent to deref-ing arr)
@@ -1316,6 +1348,15 @@ StackFrame::IsInlined ()
return false;
}
+lldb::LanguageType
+StackFrame::GetLanguage ()
+{
+ CompileUnit *cu = GetSymbolContext(eSymbolContextCompUnit).comp_unit;
+ if (cu)
+ return cu->GetLanguage();
+ return lldb::eLanguageTypeUnknown;
+}
+
TargetSP
StackFrame::CalculateTarget ()
{
@@ -1478,7 +1519,7 @@ StackFrame::GetStatus (Stream& strm,
if (show_source)
{
ExecutionContext exe_ctx (shared_from_this());
- bool have_source = false;
+ bool have_source = false, have_debuginfo = false;
Debugger::StopDisassemblyType disasm_display = Debugger::eStopDisassemblyTypeNever;
Target *target = exe_ctx.GetTargetPtr();
if (target)
@@ -1491,26 +1532,35 @@ StackFrame::GetStatus (Stream& strm,
GetSymbolContext(eSymbolContextCompUnit | eSymbolContextLineEntry);
if (m_sc.comp_unit && m_sc.line_entry.IsValid())
{
- have_source = true;
+ have_debuginfo = true;
if (source_lines_before > 0 || source_lines_after > 0)
{
- target->GetSourceManager().DisplaySourceLinesWithLineNumbers (m_sc.line_entry.file,
+ size_t num_lines = target->GetSourceManager().DisplaySourceLinesWithLineNumbers (m_sc.line_entry.file,
m_sc.line_entry.line,
source_lines_before,
source_lines_after,
"->",
&strm);
+ if (num_lines != 0)
+ have_source = true;
+ // TODO: Give here a one time warning if source file is missing.
}
}
switch (disasm_display)
{
case Debugger::eStopDisassemblyTypeNever:
break;
-
+
+ case Debugger::eStopDisassemblyTypeNoDebugInfo:
+ if (have_debuginfo)
+ break;
+ // Fall through to next case
+
case Debugger::eStopDisassemblyTypeNoSource:
if (have_source)
break;
// Fall through to next case
+
case Debugger::eStopDisassemblyTypeAlways:
if (target)
{
diff --git a/source/Target/StackFrameList.cpp b/source/Target/StackFrameList.cpp
index 05923d70ce42..f2f3cad471fe 100644
--- a/source/Target/StackFrameList.cpp
+++ b/source/Target/StackFrameList.cpp
@@ -105,9 +105,13 @@ StackFrameList::GetCurrentInlinedDepth ()
void
StackFrameList::ResetCurrentInlinedDepth ()
{
+ Mutex::Locker locker (m_mutex);
+
if (m_show_inlined_frames)
{
GetFramesUpTo(0);
+ if (m_frames.size() == 0)
+ return;
if (!m_frames[0]->IsInlined())
{
m_current_inlined_depth = UINT32_MAX;
@@ -362,8 +366,8 @@ StackFrameList::GetFramesUpTo(uint32_t end_idx)
// adjustment it will point to an other section. In that case resolve the
// address again to the correct section plus offset form.
TargetSP target = m_thread.CalculateTarget();
- addr_t load_addr = curr_frame_address.GetOpcodeLoadAddress(target.get());
- curr_frame_address.SetOpcodeLoadAddress(load_addr - 1, target.get());
+ addr_t load_addr = curr_frame_address.GetOpcodeLoadAddress(target.get(), eAddressClassCode);
+ curr_frame_address.SetOpcodeLoadAddress(load_addr - 1, target.get(), eAddressClassCode);
}
else
{
@@ -457,9 +461,9 @@ StackFrameList::GetFramesUpTo(uint32_t end_idx)
}
#if defined (DEBUG_STACK_FRAMES)
- s.PutCString("\n\nNew frames:\n");
- Dump (&s);
- s.EOL();
+ s.PutCString("\n\nNew frames:\n");
+ Dump (&s);
+ s.EOL();
#endif
}
else
diff --git a/source/Target/StopInfo.cpp b/source/Target/StopInfo.cpp
index 9bbb00dbf0da..e88b6467f7c6 100644
--- a/source/Target/StopInfo.cpp
+++ b/source/Target/StopInfo.cpp
@@ -1,4 +1,4 @@
-//===-- StopInfo.cpp ---------------------------------------------*- C++ -*-===//
+//===-- StopInfo.cpp --------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,14 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/StopInfo.h"
-
// C Includes
// C++ Includes
#include <string>
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/StopInfo.h"
#include "lldb/Core/Log.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
@@ -23,7 +22,7 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObject.h"
-#include "lldb/Expression/ClangUserExpression.h"
+#include "lldb/Expression/UserExpression.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
@@ -133,6 +132,8 @@ public:
StoreBPInfo();
}
+ ~StopInfoBreakpoint() override = default;
+
void
StoreBPInfo ()
{
@@ -156,12 +157,8 @@ public:
}
}
- virtual ~StopInfoBreakpoint ()
- {
- }
-
- virtual bool
- IsValidForOperatingSystemThread (Thread &thread)
+ bool
+ IsValidForOperatingSystemThread(Thread &thread) override
{
ProcessSP process_sp (thread.GetProcess());
if (process_sp)
@@ -173,14 +170,14 @@ public:
return false;
}
- virtual StopReason
- GetStopReason () const
+ StopReason
+ GetStopReason() const override
{
return eStopReasonBreakpoint;
}
- virtual bool
- ShouldStopSynchronous (Event *event_ptr)
+ bool
+ ShouldStopSynchronous(Event *event_ptr) override
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
@@ -212,8 +209,8 @@ public:
return false;
}
- virtual bool
- DoShouldNotify (Event *event_ptr)
+ bool
+ DoShouldNotify(Event *event_ptr) override
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
@@ -237,8 +234,8 @@ public:
return true;
}
- virtual const char *
- GetDescription ()
+ const char *
+ GetDescription() override
{
if (m_description.empty())
{
@@ -312,7 +309,7 @@ public:
protected:
bool
- ShouldStop (Event *event_ptr)
+ ShouldStop(Event *event_ptr) override
{
// This just reports the work done by PerformAction or the synchronous stop. It should
// only ever get called after they have had a chance to run.
@@ -320,8 +317,8 @@ protected:
return m_should_stop;
}
- virtual void
- PerformAction (Event *event_ptr)
+ void
+ PerformAction(Event *event_ptr) override
{
if (!m_should_perform_action)
return;
@@ -350,7 +347,10 @@ protected:
if (bp_site_sp)
{
- size_t num_owners = bp_site_sp->GetNumberOfOwners();
+ // Let's copy the owners list out of the site and store them in a local list. That way if
+ // one of the breakpoint actions changes the site, then we won't be operating on a bad list.
+ BreakpointLocationCollection site_locations;
+ size_t num_owners = bp_site_sp->CopyOwnersList(site_locations);
if (num_owners == 0)
{
@@ -416,20 +416,16 @@ protected:
StoppointCallbackContext context (event_ptr, exe_ctx, false);
- // Let's copy the breakpoint locations out of the site and store them in a local list. That way if
- // one of the breakpoint actions changes the site, then we won't be operating on a bad list.
// For safety's sake let's also grab an extra reference to the breakpoint owners of the locations we're
// going to examine, since the locations are going to have to get back to their breakpoints, and the
// locations don't keep their owners alive. I'm just sticking the BreakpointSP's in a vector since
- // I'm only really using it to locally increment their retain counts.
+ // I'm only using it to locally increment their retain counts.
- BreakpointLocationCollection site_locations;
std::vector<lldb::BreakpointSP> location_owners;
for (size_t j = 0; j < num_owners; j++)
{
- BreakpointLocationSP loc(bp_site_sp->GetOwnerAtIndex(j));
- site_locations.Add(loc);
+ BreakpointLocationSP loc(site_locations.GetByIndex(j));
location_owners.push_back(loc->GetBreakpoint().shared_from_this());
}
@@ -576,7 +572,6 @@ private:
bool m_was_one_shot;
};
-
//----------------------------------------------------------------------
// StopInfoWatchpoint
//----------------------------------------------------------------------
@@ -598,6 +593,7 @@ public:
process->DisableWatchpoint(watchpoint, notify);
}
}
+
~WatchpointSentry()
{
if (process && watchpoint)
@@ -610,6 +606,7 @@ public:
watchpoint->TurnOffEphemeralMode();
}
}
+
private:
Process *process;
Watchpoint *watchpoint;
@@ -622,19 +619,17 @@ public:
m_watch_hit_addr(watch_hit_addr)
{
}
-
- virtual ~StopInfoWatchpoint ()
- {
- }
- virtual StopReason
- GetStopReason () const
+ ~StopInfoWatchpoint() override = default;
+
+ StopReason
+ GetStopReason() const override
{
return eStopReasonWatchpoint;
}
- virtual const char *
- GetDescription ()
+ const char *
+ GetDescription() override
{
if (m_description.empty())
{
@@ -646,8 +641,8 @@ public:
}
protected:
- virtual bool
- ShouldStopSynchronous (Event *event_ptr)
+ bool
+ ShouldStopSynchronous(Event *event_ptr) override
{
// ShouldStop() method is idempotent and should not affect hit count.
// See Process::RunPrivateStateThread()->Process()->HandlePrivateEvent()
@@ -686,7 +681,7 @@ protected:
}
bool
- ShouldStop (Event *event_ptr)
+ ShouldStop(Event *event_ptr) override
{
// This just reports the work done by PerformAction or the synchronous stop. It should
// only ever get called after they have had a chance to run.
@@ -694,8 +689,8 @@ protected:
return m_should_stop;
}
- virtual void
- PerformAction (Event *event_ptr)
+ void
+ PerformAction(Event *event_ptr) override
{
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS);
// We're going to calculate if we should stop or not in some way during the course of
@@ -758,9 +753,22 @@ protected:
{
WatchpointSP wp_hit_sp = thread_sp->CalculateTarget()->GetWatchpointList().FindByAddress(m_watch_hit_addr);
if (!wp_hit_sp)
+ {
m_should_stop = false;
+ wp_sp->IncrementFalseAlarmsAndReviseHitCount();
+ }
}
-
+
+ // TODO: This condition should be checked in the synchronous part of the watchpoint code
+ // (Watchpoint::ShouldStop), so that we avoid pulling an event even if the watchpoint fails
+ // the ignore count condition. It is moved here temporarily, because for archs with
+ // watchpoint_exceptions_received=before, the code in the previous lines takes care of moving
+ // the inferior to next PC. We have to check the ignore count condition after this is done,
+ // otherwise we will hit same watchpoint multiple times until we pass ignore condition, but we
+ // won't actually be ignoring them.
+ if (wp_sp->GetHitCount() <= wp_sp->GetIgnoreCount())
+ m_should_stop = false;
+
if (m_should_stop && wp_sp->GetConditionText() != NULL)
{
// We need to make sure the user sees any parse errors in their condition, so we'll hook the
@@ -771,12 +779,13 @@ protected:
expr_options.SetIgnoreBreakpoints(true);
ValueObjectSP result_value_sp;
Error error;
- result_code = ClangUserExpression::Evaluate (exe_ctx,
- expr_options,
- wp_sp->GetConditionText(),
- NULL,
- result_value_sp,
- error);
+ result_code = UserExpression::Evaluate (exe_ctx,
+ expr_options,
+ wp_sp->GetConditionText(),
+ NULL,
+ result_value_sp,
+ error);
+
if (result_code == eExpressionCompleted)
{
if (result_value_sp)
@@ -876,8 +885,6 @@ private:
lldb::addr_t m_watch_hit_addr;
};
-
-
//----------------------------------------------------------------------
// StopInfoUnixSignal
//----------------------------------------------------------------------
@@ -885,26 +892,22 @@ private:
class StopInfoUnixSignal : public StopInfo
{
public:
-
StopInfoUnixSignal (Thread &thread, int signo, const char *description) :
StopInfo (thread, signo)
{
SetDescription (description);
}
-
- virtual ~StopInfoUnixSignal ()
- {
- }
+ ~StopInfoUnixSignal() override = default;
- virtual StopReason
- GetStopReason () const
+ StopReason
+ GetStopReason() const override
{
return eStopReasonSignal;
}
- virtual bool
- ShouldStopSynchronous (Event *event_ptr)
+ bool
+ ShouldStopSynchronous(Event *event_ptr) override
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
@@ -912,19 +915,18 @@ public:
return false;
}
- virtual bool
- ShouldStop (Event *event_ptr)
+ bool
+ ShouldStop(Event *event_ptr) override
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
return thread_sp->GetProcess()->GetUnixSignals()->GetShouldStop(m_value);
return false;
}
-
-
+
// If should stop returns false, check if we should notify of this event
- virtual bool
- DoShouldNotify (Event *event_ptr)
+ bool
+ DoShouldNotify(Event *event_ptr) override
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
@@ -943,9 +945,8 @@ public:
return true;
}
-
- virtual void
- WillResume (lldb::StateType resume_state)
+ void
+ WillResume(lldb::StateType resume_state) override
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
@@ -955,8 +956,8 @@ public:
}
}
- virtual const char *
- GetDescription ()
+ const char *
+ GetDescription() override
{
if (m_description.empty())
{
@@ -983,33 +984,29 @@ public:
class StopInfoTrace : public StopInfo
{
public:
-
StopInfoTrace (Thread &thread) :
StopInfo (thread, LLDB_INVALID_UID)
{
}
-
- virtual ~StopInfoTrace ()
- {
- }
-
- virtual StopReason
- GetStopReason () const
+
+ ~StopInfoTrace() override = default;
+
+ StopReason
+ GetStopReason() const override
{
return eStopReasonTrace;
}
- virtual const char *
- GetDescription ()
+ const char *
+ GetDescription() override
{
if (m_description.empty())
- return "trace";
+ return "trace";
else
return m_description.c_str();
}
};
-
//----------------------------------------------------------------------
// StopInfoException
//----------------------------------------------------------------------
@@ -1017,27 +1014,23 @@ public:
class StopInfoException : public StopInfo
{
public:
-
StopInfoException (Thread &thread, const char *description) :
StopInfo (thread, LLDB_INVALID_UID)
{
if (description)
SetDescription (description);
}
-
- virtual
- ~StopInfoException ()
- {
- }
-
- virtual StopReason
- GetStopReason () const
+
+ ~StopInfoException() override = default;
+
+ StopReason
+ GetStopReason() const override
{
return eStopReasonException;
}
- virtual const char *
- GetDescription ()
+ const char *
+ GetDescription() override
{
if (m_description.empty())
return "exception";
@@ -1046,7 +1039,6 @@ public:
}
};
-
//----------------------------------------------------------------------
// StopInfoThreadPlan
//----------------------------------------------------------------------
@@ -1054,27 +1046,24 @@ public:
class StopInfoThreadPlan : public StopInfo
{
public:
-
- StopInfoThreadPlan (ThreadPlanSP &plan_sp, ValueObjectSP &return_valobj_sp, ClangExpressionVariableSP &expression_variable_sp) :
+ StopInfoThreadPlan (ThreadPlanSP &plan_sp, ValueObjectSP &return_valobj_sp, ExpressionVariableSP &expression_variable_sp) :
StopInfo (plan_sp->GetThread(), LLDB_INVALID_UID),
m_plan_sp (plan_sp),
m_return_valobj_sp (return_valobj_sp),
m_expression_variable_sp (expression_variable_sp)
{
}
-
- virtual ~StopInfoThreadPlan ()
- {
- }
- virtual StopReason
- GetStopReason () const
+ ~StopInfoThreadPlan() override = default;
+
+ StopReason
+ GetStopReason() const override
{
return eStopReasonPlanComplete;
}
- virtual const char *
- GetDescription ()
+ const char *
+ GetDescription() override
{
if (m_description.empty())
{
@@ -1091,15 +1080,15 @@ public:
return m_return_valobj_sp;
}
- ClangExpressionVariableSP
+ ExpressionVariableSP
GetExpressionVariable()
{
return m_expression_variable_sp;
}
protected:
- virtual bool
- ShouldStop (Event *event_ptr)
+ bool
+ ShouldStop(Event *event_ptr) override
{
if (m_plan_sp)
return m_plan_sp->ShouldStop(event_ptr);
@@ -1110,39 +1099,35 @@ protected:
private:
ThreadPlanSP m_plan_sp;
ValueObjectSP m_return_valobj_sp;
- ClangExpressionVariableSP m_expression_variable_sp;
+ ExpressionVariableSP m_expression_variable_sp;
};
class StopInfoExec : public StopInfo
{
public:
-
StopInfoExec (Thread &thread) :
StopInfo (thread, LLDB_INVALID_UID),
m_performed_action (false)
{
}
-
- virtual
- ~StopInfoExec ()
- {
- }
-
- virtual StopReason
- GetStopReason () const
+
+ ~StopInfoExec() override = default;
+
+ StopReason
+ GetStopReason() const override
{
return eStopReasonExec;
}
- virtual const char *
- GetDescription ()
+ const char *
+ GetDescription() override
{
return "exec";
}
+
protected:
-
- virtual void
- PerformAction (Event *event_ptr)
+ void
+ PerformAction(Event *event_ptr) override
{
// Only perform the action once
if (m_performed_action)
@@ -1191,7 +1176,7 @@ StopInfo::CreateStopReasonToTrace (Thread &thread)
StopInfoSP
StopInfo::CreateStopReasonWithPlan (ThreadPlanSP &plan_sp,
ValueObjectSP return_valobj_sp,
- ClangExpressionVariableSP expression_variable_sp)
+ ExpressionVariableSP expression_variable_sp)
{
return StopInfoSP (new StopInfoThreadPlan (plan_sp, return_valobj_sp, expression_variable_sp));
}
@@ -1220,7 +1205,7 @@ StopInfo::GetReturnValueObject(StopInfoSP &stop_info_sp)
return ValueObjectSP();
}
-ClangExpressionVariableSP
+ExpressionVariableSP
StopInfo::GetExpressionVariable(StopInfoSP &stop_info_sp)
{
if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonPlanComplete)
@@ -1229,5 +1214,5 @@ StopInfo::GetExpressionVariable(StopInfoSP &stop_info_sp)
return plan_stop_info->GetExpressionVariable();
}
else
- return ClangExpressionVariableSP();
+ return ExpressionVariableSP();
}
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index 6ba09f4ee948..d2aa1bac49f6 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/Target.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/Target.h"
#include "lldb/Breakpoint/BreakpointResolver.h"
#include "lldb/Breakpoint/BreakpointResolverAddress.h"
#include "lldb/Breakpoint/BreakpointResolverFileLine.h"
@@ -31,10 +30,11 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
#include "lldb/Core/ValueObject.h"
-#include "lldb/Expression/ClangASTSource.h"
-#include "lldb/Expression/ClangPersistentVariables.h"
-#include "lldb/Expression/ClangUserExpression.h"
-#include "lldb/Expression/ClangModulesDeclVendor.h"
+#include "lldb/Expression/REPL.h"
+#include "lldb/Expression/UserExpression.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTSource.h"
+#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
+#include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -44,6 +44,9 @@
#include "lldb/Interpreter/Property.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/Function.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"
@@ -52,6 +55,7 @@
#include "lldb/Target/SystemRuntime.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadSpec.h"
+#include "lldb/Utility/LLDBAssert.h"
using namespace lldb;
using namespace lldb_private;
@@ -63,9 +67,6 @@ Target::GetStaticBroadcasterClass ()
return class_name;
}
-//----------------------------------------------------------------------
-// Target constructor
-//----------------------------------------------------------------------
Target::Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::PlatformSP &platform_sp, bool is_dummy_target) :
TargetProperties (this),
Broadcaster (&debugger, Target::GetStaticBroadcasterClass().AsCString()),
@@ -82,10 +83,7 @@ Target::Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::Plat
m_process_sp (),
m_search_filter_sp (),
m_image_search_paths (ImageSearchPathsChanged, this),
- m_scratch_ast_context_ap (),
- m_scratch_ast_source_ap (),
- m_ast_importer_ap (),
- m_persistent_variables (new ClangPersistentVariables),
+ m_ast_importer_sp (),
m_source_manager_ap(),
m_stop_hooks (),
m_stop_hook_next_id (0),
@@ -111,6 +109,14 @@ Target::Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::Plat
}
}
+Target::~Target()
+{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
+ if (log)
+ log->Printf ("%p Target::~Target()", static_cast<void*>(this));
+ DeleteCurrentProcess ();
+}
+
void
Target::PrimeFromDummyTarget(Target *target)
{
@@ -129,17 +135,6 @@ Target::PrimeFromDummyTarget(Target *target)
}
}
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-Target::~Target()
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf ("%p Target::~Target()", static_cast<void*>(this));
- DeleteCurrentProcess ();
-}
-
void
Target::Dump (Stream *s, lldb::DescriptionLevel description_level)
{
@@ -183,7 +178,7 @@ Target::CleanupProcess ()
void
Target::DeleteCurrentProcess ()
{
- if (m_process_sp.get())
+ if (m_process_sp)
{
m_section_load_history.Clear();
if (m_process_sp->IsAlive())
@@ -201,7 +196,7 @@ const lldb::ProcessSP &
Target::CreateProcess (Listener &listener, const char *plugin_name, const FileSpec *crash_file)
{
DeleteCurrentProcess ();
- m_process_sp = Process::FindPlugin(*this, plugin_name, listener, crash_file);
+ m_process_sp = Process::FindPlugin(shared_from_this(), plugin_name, listener, crash_file);
return m_process_sp;
}
@@ -211,6 +206,69 @@ Target::GetProcessSP () const
return m_process_sp;
}
+lldb::REPLSP
+Target::GetREPL (Error &err, lldb::LanguageType language, const char *repl_options, bool can_create)
+{
+ if (language == eLanguageTypeUnknown)
+ {
+ std::set<LanguageType> repl_languages;
+
+ Language::GetLanguagesSupportingREPLs(repl_languages);
+
+ if (repl_languages.size() == 1)
+ {
+ language = *repl_languages.begin();
+ }
+ else if (repl_languages.size() == 0)
+ {
+ err.SetErrorStringWithFormat("LLDB isn't configured with support support for any REPLs.");
+ return REPLSP();
+ }
+ else
+ {
+ err.SetErrorStringWithFormat("Multiple possible REPL languages. Please specify a language.");
+ return REPLSP();
+ }
+ }
+
+ REPLMap::iterator pos = m_repl_map.find(language);
+
+ if (pos != m_repl_map.end())
+ {
+ return pos->second;
+ }
+
+ if (!can_create)
+ {
+ err.SetErrorStringWithFormat("Couldn't find an existing REPL for %s, and can't create a new one", Language::GetNameForLanguageType(language));
+ return lldb::REPLSP();
+ }
+
+ Debugger *const debugger = nullptr;
+ lldb::REPLSP ret = REPL::Create(err, language, debugger, this, repl_options);
+
+ if (ret)
+ {
+ m_repl_map[language] = ret;
+ return m_repl_map[language];
+ }
+
+ if (err.Success())
+ {
+ err.SetErrorStringWithFormat("Couldn't create a REPL for %s", Language::GetNameForLanguageType(language));
+ }
+
+ return lldb::REPLSP();
+}
+
+void
+Target::SetREPL (lldb::LanguageType language, lldb::REPLSP repl_sp)
+{
+ lldbassert(!m_repl_map.count(language));
+
+ m_repl_map[language] = repl_sp;
+}
+
void
Target::Destroy()
{
@@ -228,13 +286,11 @@ Target::Destroy()
m_last_created_watchpoint.reset();
m_search_filter_sp.reset();
m_image_search_paths.Clear(notify);
- m_persistent_variables->Clear();
m_stop_hooks.clear();
m_stop_hook_next_id = 0;
m_suppress_stop_hooks = false;
}
-
BreakpointList &
Target::GetBreakpointList(bool internal)
{
@@ -277,11 +333,10 @@ Target::CreateSourceRegexBreakpoint (const FileSpecList *containingModules,
SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList (containingModules, source_file_spec_list));
if (move_to_nearest_code == eLazyBoolCalculate)
move_to_nearest_code = GetMoveToNearestCode() ? eLazyBoolYes : eLazyBoolNo;
- BreakpointResolverSP resolver_sp(new BreakpointResolverFileRegex (NULL, source_regex, !static_cast<bool>(move_to_nearest_code)));
+ BreakpointResolverSP resolver_sp(new BreakpointResolverFileRegex(nullptr, source_regex, !static_cast<bool>(move_to_nearest_code)));
return CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
}
-
BreakpointSP
Target::CreateBreakpoint (const FileSpecList *containingModules,
const FileSpec &file,
@@ -330,20 +385,23 @@ Target::CreateBreakpoint (const FileSpecList *containingModules,
if (move_to_nearest_code == eLazyBoolCalculate)
move_to_nearest_code = GetMoveToNearestCode() ? eLazyBoolYes : eLazyBoolNo;
- BreakpointResolverSP resolver_sp(new BreakpointResolverFileLine (NULL,
- file,
- line_no,
- check_inlines,
- skip_prologue,
- !static_cast<bool>(move_to_nearest_code)));
+ BreakpointResolverSP resolver_sp(new BreakpointResolverFileLine(nullptr,
+ file,
+ line_no,
+ check_inlines,
+ skip_prologue,
+ !static_cast<bool>(move_to_nearest_code)));
return CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
}
-
BreakpointSP
Target::CreateBreakpoint (lldb::addr_t addr, bool internal, bool hardware)
{
Address so_addr;
+
+ // Check for any reason we want to move this breakpoint to other address.
+ addr = GetBreakableLoadAddress(addr);
+
// Attempt to resolve our load address if possible, though it is ok if
// it doesn't resolve to section/offset.
@@ -359,18 +417,30 @@ Target::CreateBreakpoint (lldb::addr_t addr, bool internal, bool hardware)
}
BreakpointSP
-Target::CreateBreakpoint (Address &addr, bool internal, bool hardware)
+Target::CreateBreakpoint (const Address &addr, bool internal, bool hardware)
{
SearchFilterSP filter_sp(new SearchFilterForUnconstrainedSearches (shared_from_this()));
- BreakpointResolverSP resolver_sp (new BreakpointResolverAddress (NULL, addr));
+ BreakpointResolverSP resolver_sp(new BreakpointResolverAddress(nullptr, addr));
return CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, false);
}
+lldb::BreakpointSP
+Target::CreateAddressInModuleBreakpoint (lldb::addr_t file_addr,
+ bool internal,
+ const FileSpec *file_spec,
+ bool request_hardware)
+{
+ SearchFilterSP filter_sp(new SearchFilterForUnconstrainedSearches (shared_from_this()));
+ BreakpointResolverSP resolver_sp(new BreakpointResolverAddress(nullptr, file_addr, file_spec));
+ return CreateBreakpoint (filter_sp, resolver_sp, internal, request_hardware, false);
+}
+
BreakpointSP
Target::CreateBreakpoint (const FileSpecList *containingModules,
const FileSpecList *containingSourceFiles,
const char *func_name,
uint32_t func_name_type_mask,
+ LanguageType language,
LazyBool skip_prologue,
bool internal,
bool hardware)
@@ -382,12 +452,15 @@ Target::CreateBreakpoint (const FileSpecList *containingModules,
if (skip_prologue == eLazyBoolCalculate)
skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo;
-
- BreakpointResolverSP resolver_sp (new BreakpointResolverName (NULL,
- func_name,
- func_name_type_mask,
- Breakpoint::Exact,
- skip_prologue));
+ if (language == lldb::eLanguageTypeUnknown)
+ language = GetLanguage();
+
+ BreakpointResolverSP resolver_sp(new BreakpointResolverName(nullptr,
+ func_name,
+ func_name_type_mask,
+ language,
+ Breakpoint::Exact,
+ skip_prologue));
bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
}
return bp_sp;
@@ -398,6 +471,7 @@ Target::CreateBreakpoint (const FileSpecList *containingModules,
const FileSpecList *containingSourceFiles,
const std::vector<std::string> &func_names,
uint32_t func_name_type_mask,
+ LanguageType language,
LazyBool skip_prologue,
bool internal,
bool hardware)
@@ -410,11 +484,14 @@ Target::CreateBreakpoint (const FileSpecList *containingModules,
if (skip_prologue == eLazyBoolCalculate)
skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo;
-
- BreakpointResolverSP resolver_sp (new BreakpointResolverName (NULL,
- func_names,
- func_name_type_mask,
- skip_prologue));
+ if (language == lldb::eLanguageTypeUnknown)
+ language = GetLanguage();
+
+ BreakpointResolverSP resolver_sp(new BreakpointResolverName(nullptr,
+ func_names,
+ func_name_type_mask,
+ language,
+ skip_prologue));
bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
}
return bp_sp;
@@ -426,6 +503,7 @@ Target::CreateBreakpoint (const FileSpecList *containingModules,
const char *func_names[],
size_t num_names,
uint32_t func_name_type_mask,
+ LanguageType language,
LazyBool skip_prologue,
bool internal,
bool hardware)
@@ -437,12 +515,15 @@ Target::CreateBreakpoint (const FileSpecList *containingModules,
if (skip_prologue == eLazyBoolCalculate)
skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo;
-
- BreakpointResolverSP resolver_sp (new BreakpointResolverName (NULL,
- func_names,
- num_names,
- func_name_type_mask,
- skip_prologue));
+ if (language == lldb::eLanguageTypeUnknown)
+ language = GetLanguage();
+
+ BreakpointResolverSP resolver_sp(new BreakpointResolverName(nullptr,
+ func_names,
+ num_names,
+ func_name_type_mask,
+ language,
+ skip_prologue));
bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
}
return bp_sp;
@@ -452,7 +533,7 @@ SearchFilterSP
Target::GetSearchFilterForModule (const FileSpec *containingModule)
{
SearchFilterSP filter_sp;
- if (containingModule != NULL)
+ 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
@@ -460,7 +541,7 @@ Target::GetSearchFilterForModule (const FileSpec *containingModule)
}
else
{
- if (m_search_filter_sp.get() == NULL)
+ if (!m_search_filter_sp)
m_search_filter_sp.reset (new SearchFilterForUnconstrainedSearches (shared_from_this()));
filter_sp = m_search_filter_sp;
}
@@ -479,7 +560,7 @@ Target::GetSearchFilterForModuleList (const FileSpecList *containingModules)
}
else
{
- if (m_search_filter_sp.get() == NULL)
+ if (!m_search_filter_sp)
m_search_filter_sp.reset (new SearchFilterForUnconstrainedSearches (shared_from_this()));
filter_sp = m_search_filter_sp;
}
@@ -490,11 +571,11 @@ SearchFilterSP
Target::GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules,
const FileSpecList *containingSourceFiles)
{
- if (containingSourceFiles == NULL || containingSourceFiles->GetSize() == 0)
+ if (containingSourceFiles == nullptr || containingSourceFiles->GetSize() == 0)
return GetSearchFilterForModuleList(containingModules);
SearchFilterSP filter_sp;
- if (containingModules == NULL)
+ if (containingModules == nullptr)
{
// We could make a special "CU List only SearchFilter". Better yet was if these could be composable,
// but that will take a little reworking.
@@ -512,6 +593,7 @@ BreakpointSP
Target::CreateFuncRegexBreakpoint (const FileSpecList *containingModules,
const FileSpecList *containingSourceFiles,
RegularExpression &func_regex,
+ lldb::LanguageType requested_language,
LazyBool skip_prologue,
bool internal,
bool hardware)
@@ -520,9 +602,10 @@ Target::CreateFuncRegexBreakpoint (const FileSpecList *containingModules,
bool skip =
(skip_prologue == eLazyBoolCalculate) ? GetSkipPrologue()
: static_cast<bool>(skip_prologue);
- BreakpointResolverSP resolver_sp(new BreakpointResolverName (NULL,
- func_regex,
- skip));
+ BreakpointResolverSP resolver_sp(new BreakpointResolverName(nullptr,
+ func_regex,
+ requested_language,
+ skip));
return CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
}
@@ -608,7 +691,7 @@ CheckIfWatchpointsExhausted(Target *target, Error &error)
// See also Watchpoint::SetWatchpointType(uint32_t type) and
// the OptionGroupWatchpoint::WatchType enum type.
WatchpointSP
-Target::CreateWatchpoint(lldb::addr_t addr, size_t size, const ClangASTType *type, uint32_t kind, Error &error)
+Target::CreateWatchpoint(lldb::addr_t addr, size_t size, const CompilerType *type, uint32_t kind, Error &error)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
if (log)
@@ -1105,9 +1188,8 @@ Target::ClearModules(bool delete_locations)
ModulesDidUnload (m_images, delete_locations);
m_section_load_history.Clear();
m_images.Clear();
- m_scratch_ast_context_ap.reset();
- m_scratch_ast_source_ap.reset();
- m_ast_importer_ap.reset();
+ m_scratch_type_system_map.Clear();
+ m_ast_importer_sp.reset();
}
void
@@ -1124,7 +1206,7 @@ Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files)
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TARGET));
ClearModules(false);
- if (executable_sp.get())
+ if (executable_sp)
{
Timer scoped_timer (__PRETTY_FUNCTION__,
"Target::SetExecutableModule (executable = '%s')",
@@ -1151,13 +1233,13 @@ Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files)
FileSpec dependent_file_spec (dependent_files.GetFileSpecPointerAtIndex(i));
FileSpec platform_dependent_file_spec;
if (m_platform_sp)
- m_platform_sp->GetFileWithUUID (dependent_file_spec, NULL, platform_dependent_file_spec);
+ m_platform_sp->GetFileWithUUID(dependent_file_spec, nullptr, platform_dependent_file_spec);
else
platform_dependent_file_spec = dependent_file_spec;
ModuleSpec module_spec (platform_dependent_file_spec, m_arch);
ModuleSP image_module_sp(GetSharedModule (module_spec));
- if (image_module_sp.get())
+ if (image_module_sp)
{
ObjectFile *objfile = image_module_sp->GetObjectFile();
if (objfile)
@@ -1168,49 +1250,74 @@ Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files)
}
}
-
bool
Target::SetArchitecture (const ArchSpec &arch_spec)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TARGET));
- if (m_arch.IsCompatibleMatch(arch_spec) || !m_arch.IsValid())
+ bool missing_local_arch = !m_arch.IsValid();
+ bool replace_local_arch = true;
+ bool compatible_local_arch = false;
+ ArchSpec other(arch_spec);
+
+ if (!missing_local_arch)
+ {
+ if (m_arch.IsCompatibleMatch(arch_spec))
+ {
+ other.MergeFrom(m_arch);
+
+ if (m_arch.IsCompatibleMatch(other))
+ {
+ compatible_local_arch = true;
+ bool arch_changed, vendor_changed, os_changed, os_ver_changed, env_changed;
+
+ m_arch.PiecewiseTripleCompare(other,
+ arch_changed,
+ vendor_changed,
+ os_changed,
+ os_ver_changed,
+ env_changed);
+
+ if (!arch_changed && !vendor_changed && !os_changed)
+ replace_local_arch = false;
+ }
+ }
+ }
+
+ if (compatible_local_arch || missing_local_arch)
{
- // If we haven't got a valid arch spec, or the architectures are
- // compatible, so just update the architecture. Architectures can be
- // equal, yet the triple OS and vendor might change, so we need to do
- // the assignment here just in case.
- m_arch = arch_spec;
+ // If we haven't got a valid arch spec, or the architectures are compatible
+ // update the architecture, unless the one we already have is more specified
+ if (replace_local_arch)
+ m_arch = other;
if (log)
- log->Printf ("Target::SetArchitecture setting architecture to %s (%s)", arch_spec.GetArchitectureName(), arch_spec.GetTriple().getTriple().c_str());
+ log->Printf ("Target::SetArchitecture set architecture to %s (%s)", m_arch.GetArchitectureName(), m_arch.GetTriple().getTriple().c_str());
return true;
}
- else
+
+ // If we have an executable file, try to reset the executable to the desired architecture
+ if (log)
+ log->Printf ("Target::SetArchitecture changing architecture to %s (%s)", arch_spec.GetArchitectureName(), arch_spec.GetTriple().getTriple().c_str());
+ m_arch = other;
+ ModuleSP executable_sp = GetExecutableModule ();
+
+ ClearModules(true);
+ // Need to do something about unsetting breakpoints.
+
+ if (executable_sp)
{
- // If we have an executable file, try to reset the executable to the desired architecture
if (log)
- log->Printf ("Target::SetArchitecture changing architecture to %s (%s)", arch_spec.GetArchitectureName(), arch_spec.GetTriple().getTriple().c_str());
- m_arch = arch_spec;
- ModuleSP executable_sp = GetExecutableModule ();
-
- ClearModules(true);
- // Need to do something about unsetting breakpoints.
-
- if (executable_sp)
+ log->Printf("Target::SetArchitecture Trying to select executable file architecture %s (%s)", arch_spec.GetArchitectureName(), arch_spec.GetTriple().getTriple().c_str());
+ ModuleSpec module_spec (executable_sp->GetFileSpec(), other);
+ Error error = ModuleList::GetSharedModule(module_spec,
+ executable_sp,
+ &GetExecutableSearchPaths(),
+ nullptr,
+ nullptr);
+
+ if (!error.Fail() && executable_sp)
{
- if (log)
- log->Printf("Target::SetArchitecture Trying to select executable file architecture %s (%s)", arch_spec.GetArchitectureName(), arch_spec.GetTriple().getTriple().c_str());
- ModuleSpec module_spec (executable_sp->GetFileSpec(), arch_spec);
- Error error = ModuleList::GetSharedModule (module_spec,
- executable_sp,
- &GetExecutableSearchPaths(),
- NULL,
- NULL);
-
- if (!error.Fail() && executable_sp)
- {
- SetExecutableModule (executable_sp, true);
- return true;
- }
+ SetExecutableModule (executable_sp, true);
+ return true;
}
}
return false;
@@ -1261,7 +1368,7 @@ Target::ModuleAdded (const ModuleList& module_list, const ModuleSP &module_sp)
void
Target::ModuleRemoved (const ModuleList& module_list, const ModuleSP &module_sp)
{
- // A module is being added to this target for the first time
+ // A module is being removed from this target.
if (m_valid)
{
ModuleList my_module_list;
@@ -1275,7 +1382,10 @@ Target::ModuleUpdated (const ModuleList& module_list, const ModuleSP &old_module
{
// A module is replacing an already added module
if (m_valid)
+ {
m_breakpoint_list.UpdateBreakpointsWhenModuleIsReplaced(old_module_sp, new_module_sp);
+ m_internal_breakpoint_list.UpdateBreakpointsWhenModuleIsReplaced(old_module_sp, new_module_sp);
+ }
}
void
@@ -1284,6 +1394,7 @@ Target::ModulesDidLoad (ModuleList &module_list)
if (m_valid && module_list.GetSize())
{
m_breakpoint_list.UpdateBreakpoints (module_list, true, false);
+ m_internal_breakpoint_list.UpdateBreakpoints (module_list, true, false);
if (m_process_sp)
{
m_process_sp->ModulesDidLoad (module_list);
@@ -1308,6 +1419,7 @@ Target::SymbolsDidLoad (ModuleList &module_list)
}
m_breakpoint_list.UpdateBreakpoints (module_list, true, false);
+ m_internal_breakpoint_list.UpdateBreakpoints (module_list, true, false);
BroadcastEvent (eBroadcastBitSymbolsLoaded, new TargetEventData (this->shared_from_this(), module_list));
}
}
@@ -1319,6 +1431,7 @@ Target::ModulesDidUnload (ModuleList &module_list, bool delete_locations)
{
UnloadModuleSections (module_list);
m_breakpoint_list.UpdateBreakpoints (module_list, false, delete_locations);
+ m_internal_breakpoint_list.UpdateBreakpoints (module_list, false, delete_locations);
BroadcastEvent (eBroadcastBitModulesUnloaded, new TargetEventData (this->shared_from_this(), module_list));
}
}
@@ -1439,7 +1552,6 @@ Target::ReadMemory (const Address& addr,
}
if (!resolved_addr.IsValid())
resolved_addr = addr;
-
if (prefer_file_cache)
{
@@ -1526,7 +1638,6 @@ Target::ReadCStringFromMemory (const Address& addr, std::string &out_str, Error
return out_str.size();
}
-
size_t
Target::ReadCStringFromMemory (const Address& addr, char *dst, size_t dst_max_len, Error &result_error)
{
@@ -1575,7 +1686,7 @@ Target::ReadCStringFromMemory (const Address& addr, char *dst, size_t dst_max_le
}
else
{
- if (dst == NULL)
+ if (dst == nullptr)
result_error.SetErrorString("invalid arguments");
else
result_error.Clear();
@@ -1821,7 +1932,6 @@ Target::GetSharedModule (const ModuleSpec &module_spec, Error *error_ptr)
return module_sp;
}
-
TargetSP
Target::CalculateTarget ()
{
@@ -1860,11 +1970,8 @@ Target::GetImageSearchPathList ()
}
void
-Target::ImageSearchPathsChanged
-(
- const PathMappingList &path_list,
- void *baton
-)
+Target::ImageSearchPathsChanged(const PathMappingList &path_list,
+ void *baton)
{
Target *target = (Target *)baton;
ModuleSP exe_module_sp (target->GetExecutableModule());
@@ -1872,33 +1979,157 @@ Target::ImageSearchPathsChanged
target->SetExecutableModule (exe_module_sp, true);
}
+TypeSystem *
+Target::GetScratchTypeSystemForLanguage (Error *error, lldb::LanguageType language, bool create_on_demand)
+{
+ if (!m_valid)
+ return nullptr;
+
+ if (error)
+ {
+ error->Clear();
+ }
+
+ if (language == eLanguageTypeMipsAssembler // GNU AS and LLVM use it for all assembly code
+ || language == eLanguageTypeUnknown)
+ {
+ std::set<lldb::LanguageType> languages_for_types;
+ std::set<lldb::LanguageType> languages_for_expressions;
+
+ Language::GetLanguagesSupportingTypeSystems(languages_for_types, languages_for_expressions);
+
+ if (languages_for_expressions.count(eLanguageTypeC))
+ {
+ language = eLanguageTypeC; // LLDB's default. Override by setting the target language.
+ }
+ else
+ {
+ if (languages_for_expressions.empty())
+ {
+ return nullptr;
+ }
+ else
+ {
+ language = *languages_for_expressions.begin();
+ }
+ }
+ }
+
+ return m_scratch_type_system_map.GetTypeSystemForLanguage(language, this, create_on_demand);
+}
+
+PersistentExpressionState *
+Target::GetPersistentExpressionStateForLanguage (lldb::LanguageType language)
+{
+ TypeSystem *type_system = GetScratchTypeSystemForLanguage(nullptr, language, true);
+
+ if (type_system)
+ {
+ return type_system->GetPersistentExpressionState();
+ }
+ else
+ {
+ return nullptr;
+ }
+}
+
+UserExpression *
+Target::GetUserExpressionForLanguage(const char *expr,
+ const char *expr_prefix,
+ lldb::LanguageType language,
+ Expression::ResultType desired_type,
+ const EvaluateExpressionOptions &options,
+ Error &error)
+{
+ Error type_system_error;
+
+ TypeSystem *type_system = GetScratchTypeSystemForLanguage (&type_system_error, language);
+ UserExpression *user_expr = nullptr;
+
+ if (!type_system)
+ {
+ error.SetErrorStringWithFormat("Could not find type system for language %s: %s", Language::GetNameForLanguageType(language), type_system_error.AsCString());
+ return nullptr;
+ }
+
+ user_expr = type_system->GetUserExpression(expr, expr_prefix, language, desired_type, options);
+ if (!user_expr)
+ error.SetErrorStringWithFormat("Could not create an expression for language %s", Language::GetNameForLanguageType(language));
+
+ return user_expr;
+}
+
+FunctionCaller *
+Target::GetFunctionCallerForLanguage (lldb::LanguageType language,
+ const CompilerType &return_type,
+ const Address& function_address,
+ const ValueList &arg_value_list,
+ const char *name,
+ Error &error)
+{
+ Error type_system_error;
+ TypeSystem *type_system = GetScratchTypeSystemForLanguage (&type_system_error, language);
+ FunctionCaller *persistent_fn = nullptr;
+
+ if (!type_system)
+ {
+ error.SetErrorStringWithFormat("Could not find type system for language %s: %s", Language::GetNameForLanguageType(language), type_system_error.AsCString());
+ return persistent_fn;
+ }
+
+ persistent_fn = type_system->GetFunctionCaller (return_type, function_address, arg_value_list, name);
+ if (!persistent_fn)
+ error.SetErrorStringWithFormat("Could not create an expression for language %s", Language::GetNameForLanguageType(language));
+
+ return persistent_fn;
+}
+
+UtilityFunction *
+Target::GetUtilityFunctionForLanguage (const char *text,
+ lldb::LanguageType language,
+ const char *name,
+ Error &error)
+{
+ Error type_system_error;
+ TypeSystem *type_system = GetScratchTypeSystemForLanguage (&type_system_error, language);
+ UtilityFunction *utility_fn = nullptr;
+
+ if (!type_system)
+ {
+ error.SetErrorStringWithFormat("Could not find type system for language %s: %s", Language::GetNameForLanguageType(language), type_system_error.AsCString());
+ return utility_fn;
+ }
+
+ utility_fn = type_system->GetUtilityFunction (text, name);
+ if (!utility_fn)
+ error.SetErrorStringWithFormat("Could not create an expression for language %s", Language::GetNameForLanguageType(language));
+
+ return utility_fn;
+}
+
ClangASTContext *
Target::GetScratchClangASTContext(bool create_on_demand)
{
- // Now see if we know the target triple, and if so, create our scratch AST context:
- if (m_scratch_ast_context_ap.get() == NULL && m_arch.IsValid() && create_on_demand)
+ if (m_valid)
{
- m_scratch_ast_context_ap.reset (new ClangASTContext(m_arch.GetTriple().str().c_str()));
- m_scratch_ast_source_ap.reset (new ClangASTSource(shared_from_this()));
- m_scratch_ast_source_ap->InstallASTContext(m_scratch_ast_context_ap->getASTContext());
- llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source(m_scratch_ast_source_ap->CreateProxy());
- m_scratch_ast_context_ap->SetExternalSource(proxy_ast_source);
+ if (TypeSystem* type_system = GetScratchTypeSystemForLanguage(nullptr, eLanguageTypeC, create_on_demand))
+ return llvm::dyn_cast<ClangASTContext>(type_system);
}
- return m_scratch_ast_context_ap.get();
+ return nullptr;
}
-ClangASTImporter *
+ClangASTImporterSP
Target::GetClangASTImporter()
{
- ClangASTImporter *ast_importer = m_ast_importer_ap.get();
-
- if (!ast_importer)
+ if (m_valid)
{
- ast_importer = new ClangASTImporter();
- m_ast_importer_ap.reset(ast_importer);
+ if (!m_ast_importer_sp)
+ {
+ m_ast_importer_sp.reset(new ClangASTImporter());
+ }
+ return m_ast_importer_sp;
}
-
- return ast_importer;
+ return ClangASTImporterSP();
}
void
@@ -1967,28 +2198,25 @@ Target::GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr, const Symbol
// the "target_sp" member of SymbolContext. This accessor helper function
// will get the target from one of these locations.
- Target *target = NULL;
- if (sc_ptr != NULL)
+ Target *target = nullptr;
+ if (sc_ptr != nullptr)
target = sc_ptr->target_sp.get();
- if (target == NULL && exe_ctx_ptr)
+ if (target == nullptr && exe_ctx_ptr)
target = exe_ctx_ptr->GetTargetPtr();
return target;
}
ExpressionResults
-Target::EvaluateExpression
-(
- const char *expr_cstr,
- StackFrame *frame,
- lldb::ValueObjectSP &result_valobj_sp,
- const EvaluateExpressionOptions& options
-)
+Target::EvaluateExpression(const char *expr_cstr,
+ ExecutionContextScope *exe_scope,
+ lldb::ValueObjectSP &result_valobj_sp,
+ const EvaluateExpressionOptions& options)
{
result_valobj_sp.reset();
ExpressionResults execution_results = eExpressionSetupError;
- if (expr_cstr == NULL || expr_cstr[0] == '\0')
+ if (expr_cstr == nullptr || expr_cstr[0] == '\0')
return execution_results;
// We shouldn't run stop hooks in expressions.
@@ -1998,9 +2226,9 @@ Target::EvaluateExpression
ExecutionContext exe_ctx;
- if (frame)
+ if (exe_scope)
{
- frame->CalculateExecutionContext(exe_ctx);
+ exe_scope->CalculateExecutionContext(exe_ctx);
}
else if (m_process_sp)
{
@@ -2013,10 +2241,10 @@ Target::EvaluateExpression
// Make sure we aren't just trying to see the value of a persistent
// variable (something like "$0")
- lldb::ClangExpressionVariableSP persistent_var_sp;
+ lldb::ExpressionVariableSP persistent_var_sp;
// Only check for persistent variables the expression starts with a '$'
if (expr_cstr[0] == '$')
- persistent_var_sp = m_persistent_variables->GetVariable (expr_cstr);
+ persistent_var_sp = GetScratchTypeSystemForLanguage(nullptr, eLanguageTypeC)->GetPersistentExpressionState()->GetVariable (expr_cstr);
if (persistent_var_sp)
{
@@ -2027,12 +2255,12 @@ Target::EvaluateExpression
{
const char *prefix = GetExpressionPrefixContentsAsCString();
Error error;
- execution_results = ClangUserExpression::Evaluate (exe_ctx,
- options,
- expr_cstr,
- prefix,
- result_valobj_sp,
- error);
+ execution_results = UserExpression::Evaluate (exe_ctx,
+ options,
+ expr_cstr,
+ prefix,
+ result_valobj_sp,
+ error);
}
m_suppress_stop_hooks = old_suppress_value;
@@ -2040,10 +2268,40 @@ Target::EvaluateExpression
return execution_results;
}
-ClangPersistentVariables &
-Target::GetPersistentVariables()
+lldb::ExpressionVariableSP
+Target::GetPersistentVariable(const ConstString &name)
{
- return *m_persistent_variables;
+ lldb::ExpressionVariableSP variable_sp;
+ m_scratch_type_system_map.ForEach([this, name, &variable_sp](TypeSystem *type_system) -> bool
+ {
+ if (PersistentExpressionState *persistent_state = type_system->GetPersistentExpressionState())
+ {
+ variable_sp = persistent_state->GetVariable(name);
+
+ if (variable_sp)
+ return false; // Stop iterating the ForEach
+ }
+ return true; // Keep iterating the ForEach
+ });
+ return variable_sp;
+}
+
+lldb::addr_t
+Target::GetPersistentSymbol(const ConstString &name)
+{
+ lldb::addr_t address = LLDB_INVALID_ADDRESS;
+
+ m_scratch_type_system_map.ForEach([this, name, &address](TypeSystem *type_system) -> bool
+ {
+ if (PersistentExpressionState *persistent_state = type_system->GetPersistentExpressionState())
+ {
+ address = persistent_state->LookupSymbol(name);
+ if (address != LLDB_INVALID_ADDRESS)
+ return false; // Stop iterating the ForEach
+ }
+ return true; // Keep iterating the ForEach
+ });
+ return address;
}
lldb::addr_t
@@ -2052,6 +2310,27 @@ Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class)
addr_t code_addr = load_addr;
switch (m_arch.GetMachine())
{
+ case llvm::Triple::mips:
+ case llvm::Triple::mipsel:
+ case llvm::Triple::mips64:
+ case llvm::Triple::mips64el:
+ switch (addr_class)
+ {
+ case eAddressClassData:
+ case eAddressClassDebug:
+ return LLDB_INVALID_ADDRESS;
+
+ case eAddressClassUnknown:
+ case eAddressClassInvalid:
+ case eAddressClassCode:
+ case eAddressClassCodeAlternateISA:
+ case eAddressClassRuntime:
+ if ((code_addr & 2ull) || (addr_class == eAddressClassCodeAlternateISA))
+ code_addr |= 1ull;
+ break;
+ }
+ break;
+
case llvm::Triple::arm:
case llvm::Triple::thumb:
switch (addr_class)
@@ -2097,6 +2376,10 @@ Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) c
addr_t opcode_addr = load_addr;
switch (m_arch.GetMachine())
{
+ case llvm::Triple::mips:
+ case llvm::Triple::mipsel:
+ case llvm::Triple::mips64:
+ case llvm::Triple::mips64el:
case llvm::Triple::arm:
case llvm::Triple::thumb:
switch (addr_class)
@@ -2121,10 +2404,174 @@ Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) c
return opcode_addr;
}
+lldb::addr_t
+Target::GetBreakableLoadAddress (lldb::addr_t addr)
+{
+ addr_t breakable_addr = addr;
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+
+ switch (m_arch.GetMachine())
+ {
+ default:
+ break;
+ case llvm::Triple::mips:
+ case llvm::Triple::mipsel:
+ case llvm::Triple::mips64:
+ case llvm::Triple::mips64el:
+ {
+ addr_t function_start = 0;
+ addr_t current_offset = 0;
+ uint32_t loop_count = 0;
+ Address resolved_addr;
+ uint32_t arch_flags = m_arch.GetFlags ();
+ bool IsMips16 = arch_flags & ArchSpec::eMIPSAse_mips16;
+ bool IsMicromips = arch_flags & ArchSpec::eMIPSAse_micromips;
+ SectionLoadList &section_load_list = GetSectionLoadList();
+
+ if (section_load_list.IsEmpty())
+ // No sections are loaded, so we must assume we are not running yet
+ // and need to operate only on file address.
+ m_images.ResolveFileAddress (addr, resolved_addr);
+ else
+ section_load_list.ResolveLoadAddress(addr, resolved_addr);
+
+ // Get the function boundaries to make sure we don't scan back before the beginning of the current function.
+ ModuleSP temp_addr_module_sp (resolved_addr.GetModule());
+ if (temp_addr_module_sp)
+ {
+ SymbolContext sc;
+ uint32_t resolve_scope = eSymbolContextFunction | eSymbolContextSymbol;
+ temp_addr_module_sp->ResolveSymbolContextForAddress(resolved_addr, resolve_scope, sc);
+ if (sc.function)
+ {
+ function_start = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress(this);
+ if (function_start == LLDB_INVALID_ADDRESS)
+ function_start = sc.function->GetAddressRange().GetBaseAddress().GetFileAddress();
+ }
+ else if (sc.symbol)
+ {
+ Address sym_addr = sc.symbol->GetAddress();
+ function_start = sym_addr.GetFileAddress();
+ }
+ current_offset = addr - function_start;
+ }
+
+ // If breakpoint address is start of function then we dont have to do anything.
+ if (current_offset == 0)
+ return breakable_addr;
+ else
+ loop_count = current_offset / 2;
+
+ if (loop_count > 3)
+ {
+ // Scan previous 6 bytes
+ if (IsMips16 | IsMicromips)
+ loop_count = 3;
+ // For mips-only, instructions are always 4 bytes, so scan previous 4 bytes only.
+ else
+ loop_count = 2;
+ }
+
+ // Create Disassembler Instance
+ lldb::DisassemblerSP disasm_sp(Disassembler::FindPlugin(m_arch, nullptr, nullptr));
+
+ ExecutionContext exe_ctx;
+ CalculateExecutionContext(exe_ctx);
+ InstructionList instruction_list;
+ InstructionSP prev_insn;
+ bool prefer_file_cache = true; // Read from file
+ uint32_t inst_to_choose = 0;
+
+ for (uint32_t i = 1; i <= loop_count; i++)
+ {
+ // Adjust the address to read from.
+ resolved_addr.Slide (-2);
+ AddressRange range(resolved_addr, i*2);
+ uint32_t insn_size = 0;
+
+ disasm_sp->ParseInstructions(&exe_ctx, range, nullptr, prefer_file_cache);
+
+ uint32_t num_insns = disasm_sp->GetInstructionList().GetSize();
+ if (num_insns)
+ {
+ prev_insn = disasm_sp->GetInstructionList().GetInstructionAtIndex(0);
+ insn_size = prev_insn->GetOpcode().GetByteSize();
+ if (i == 1 && insn_size == 2)
+ {
+ // This looks like a valid 2-byte instruction (but it could be a part of upper 4 byte instruction).
+ instruction_list.Append(prev_insn);
+ inst_to_choose = 1;
+ }
+ else if (i == 2)
+ {
+ // Here we may get one 4-byte instruction or two 2-byte instructions.
+ if (num_insns == 2)
+ {
+ // Looks like there are two 2-byte instructions above our breakpoint target address.
+ // Now the upper 2-byte instruction is either a valid 2-byte instruction or could be a part of it's upper 4-byte instruction.
+ // In both cases we don't care because in this case lower 2-byte instruction is definitely a valid instruction
+ // and whatever i=1 iteration has found out is true.
+ inst_to_choose = 1;
+ break;
+ }
+ else if (insn_size == 4)
+ {
+ // This instruction claims its a valid 4-byte instruction. But it could be a part of it's upper 4-byte instruction.
+ // Lets try scanning upper 2 bytes to verify this.
+ instruction_list.Append(prev_insn);
+ inst_to_choose = 2;
+ }
+ }
+ else if (i == 3)
+ {
+ if (insn_size == 4)
+ // FIXME: We reached here that means instruction at [target - 4] has already claimed to be a 4-byte instruction,
+ // and now instruction at [target - 6] is also claiming that it's a 4-byte instruction. This can not be true.
+ // In this case we can not decide the valid previous instruction so we let lldb set the breakpoint at the address given by user.
+ inst_to_choose = 0;
+ else
+ // This is straight-forward
+ inst_to_choose = 2;
+ break;
+ }
+ }
+ else
+ {
+ // Decode failed, bytes do not form a valid instruction. So whatever previous iteration has found out is true.
+ if (i > 1)
+ {
+ inst_to_choose = i - 1;
+ break;
+ }
+ }
+ }
+
+ // Check if we are able to find any valid instruction.
+ if (inst_to_choose)
+ {
+ if (inst_to_choose > instruction_list.GetSize())
+ inst_to_choose--;
+ prev_insn = instruction_list.GetInstructionAtIndex(inst_to_choose - 1);
+
+ if (prev_insn->HasDelaySlot())
+ {
+ uint32_t shift_size = prev_insn->GetOpcode().GetByteSize();
+ // Adjust the breakable address
+ breakable_addr = addr - shift_size;
+ if (log)
+ log->Printf ("Target::%s Breakpoint at 0x%8.8" PRIx64 " is adjusted to 0x%8.8" PRIx64 " due to delay slot\n", __FUNCTION__, addr, breakable_addr);
+ }
+ }
+ break;
+ }
+ }
+ return breakable_addr;
+}
+
SourceManager &
Target::GetSourceManager ()
{
- if (m_source_manager_ap.get() == NULL)
+ if (!m_source_manager_ap)
m_source_manager_ap.reset (new SourceManager(shared_from_this()));
return *m_source_manager_ap;
}
@@ -2158,12 +2605,8 @@ Target::CreateStopHook ()
bool
Target::RemoveStopHookByID (lldb::user_id_t user_id)
{
- size_t num_removed;
- num_removed = m_stop_hooks.erase (user_id);
- if (num_removed == 0)
- return false;
- else
- return true;
+ size_t num_removed = m_stop_hooks.erase(user_id);
+ return (num_removed != 0);
}
void
@@ -2266,19 +2709,9 @@ Target::RunStopHooks ()
bool keep_going = true;
bool hooks_ran = false;
- bool print_hook_header;
- bool print_thread_header;
+ bool print_hook_header = (m_stop_hooks.size() != 1);
+ bool print_thread_header = (num_exe_ctx != 1);
- if (num_exe_ctx == 1)
- print_thread_header = false;
- else
- print_thread_header = true;
-
- if (m_stop_hooks.size() == 1)
- print_hook_header = false;
- else
- print_hook_header = true;
-
for (pos = m_stop_hooks.begin(); keep_going && pos != end; pos++)
{
// result.Clear();
@@ -2289,9 +2722,9 @@ Target::RunStopHooks ()
bool any_thread_matched = false;
for (size_t i = 0; keep_going && i < num_exe_ctx; i++)
{
- if ((cur_hook_sp->GetSpecifier () == NULL
+ if ((cur_hook_sp->GetSpecifier() == nullptr
|| cur_hook_sp->GetSpecifier()->SymbolContextMatches(sym_ctx_with_reasons[i]))
- && (cur_hook_sp->GetThreadSpecifier() == NULL
+ && (cur_hook_sp->GetThreadSpecifier() == nullptr
|| cur_hook_sp->GetThreadSpecifier()->ThreadPassesBasicTests(exc_ctx_with_reasons[i].GetThreadRef())))
{
if (!hooks_ran)
@@ -2302,7 +2735,7 @@ Target::RunStopHooks ()
{
const char *cmd = (cur_hook_sp->GetCommands().GetSize() == 1 ?
cur_hook_sp->GetCommands().GetStringAtIndex(0) :
- NULL);
+ nullptr);
if (cmd)
result.AppendMessageWithFormat("\n- Hook %" PRIu64 " (%s)\n", cur_hook_sp->GetID(), cmd);
else
@@ -2347,7 +2780,7 @@ Target::GetGlobalProperties()
static TargetPropertiesSP g_settings_sp;
if (!g_settings_sp)
{
- g_settings_sp.reset (new TargetProperties (NULL));
+ g_settings_sp.reset(new TargetProperties(nullptr));
}
return g_settings_sp;
}
@@ -2439,7 +2872,6 @@ Target::SetSectionLoadAddress (const SectionSP &section_sp, addr_t new_section_l
return true; // Return true if the section load address was changed...
}
return false; // Return false to indicate nothing changed
-
}
size_t
@@ -2506,7 +2938,6 @@ Target::ClearAllLoadedSections ()
m_section_load_history.Clear();
}
-
Error
Target::Launch (ProcessLaunchInfo &launch_info, Stream *stream)
{
@@ -2609,7 +3040,7 @@ Target::Launch (ProcessLaunchInfo &launch_info, Stream *stream)
{
// Use a Process plugin to construct the process.
const char *plugin_name = launch_info.GetProcessPluginName();
- CreateProcess (launch_info.GetListenerForProcess(debugger), plugin_name, NULL);
+ CreateProcess(launch_info.GetListenerForProcess(debugger), plugin_name, nullptr);
}
// Since we didn't have a platform launch the process, launch it here.
@@ -2626,7 +3057,7 @@ Target::Launch (ProcessLaunchInfo &launch_info, Stream *stream)
if (error.Success())
{
- if (synchronous_execution || launch_info.GetFlags().Test(eLaunchFlagStopAtEntry) == false)
+ if (synchronous_execution || !launch_info.GetFlags().Test(eLaunchFlagStopAtEntry))
{
ListenerSP hijack_listener_sp (launch_info.GetHijackListener());
if (!hijack_listener_sp)
@@ -2636,7 +3067,7 @@ Target::Launch (ProcessLaunchInfo &launch_info, Stream *stream)
m_process_sp->HijackProcessEvents(hijack_listener_sp.get());
}
- StateType state = m_process_sp->WaitForProcessToStop (NULL, NULL, false, hijack_listener_sp.get(), NULL);
+ StateType state = m_process_sp->WaitForProcessToStop(nullptr, nullptr, false, hijack_listener_sp.get(), nullptr);
if (state == eStateStopped)
{
@@ -2647,7 +3078,7 @@ Target::Launch (ProcessLaunchInfo &launch_info, Stream *stream)
error = m_process_sp->PrivateResume();
if (error.Success())
{
- state = m_process_sp->WaitForProcessToStop (NULL, NULL, true, hijack_listener_sp.get(), stream);
+ state = m_process_sp->WaitForProcessToStop(nullptr, nullptr, true, hijack_listener_sp.get(), stream);
const bool must_be_alive = false; // eStateExited is ok, so this must be false
if (!StateIsStoppedState(state, must_be_alive))
{
@@ -2721,9 +3152,6 @@ Target::Attach (ProcessAttachInfo &attach_info, Stream *stream)
}
}
- ListenerSP hijack_listener_sp (new Listener ("lldb.Target.Attach.attach.hijack"));
- attach_info.SetHijackListener (hijack_listener_sp);
-
const ModuleSP old_exec_module_sp = GetExecutableModule ();
// If no process info was specified, then use the target executable
@@ -2740,6 +3168,13 @@ Target::Attach (ProcessAttachInfo &attach_info, Stream *stream)
}
const auto platform_sp = GetDebugger ().GetPlatformList ().GetSelectedPlatform ();
+ ListenerSP hijack_listener_sp;
+ const bool async = attach_info.GetAsync();
+ if (!async)
+ {
+ hijack_listener_sp.reset (new Listener ("lldb.Target.Attach.attach.hijack"));
+ attach_info.SetHijackListener (hijack_listener_sp);
+ }
Error error;
if (state != eStateConnected && platform_sp != nullptr && platform_sp->CanDebugProcess ())
@@ -2759,23 +3194,31 @@ Target::Attach (ProcessAttachInfo &attach_info, Stream *stream)
return error;
}
}
- process_sp->HijackProcessEvents (hijack_listener_sp.get ());
+ if (hijack_listener_sp)
+ process_sp->HijackProcessEvents (hijack_listener_sp.get ());
error = process_sp->Attach (attach_info);
}
if (error.Success () && process_sp)
{
- state = process_sp->WaitForProcessToStop (nullptr, nullptr, false, attach_info.GetHijackListener ().get (), stream);
- process_sp->RestoreProcessEvents ();
-
- if (state != eStateStopped)
+ if (async)
{
- const char *exit_desc = process_sp->GetExitDescription ();
- if (exit_desc)
- error.SetErrorStringWithFormat ("attach failed: %s", exit_desc);
- else
- error.SetErrorString ("attach failed: process did not stop (no such process or permission problem?)");
- process_sp->Destroy (false);
+ process_sp->RestoreProcessEvents ();
+ }
+ else
+ {
+ state = process_sp->WaitForProcessToStop (nullptr, nullptr, false, attach_info.GetHijackListener ().get (), stream);
+ process_sp->RestoreProcessEvents ();
+
+ if (state != eStateStopped)
+ {
+ const char *exit_desc = process_sp->GetExitDescription ();
+ if (exit_desc)
+ error.SetErrorStringWithFormat ("%s", exit_desc);
+ else
+ error.SetErrorString ("process did not stop (no such process or permission problem?)");
+ process_sp->Destroy (false);
+ }
}
}
return error;
@@ -2802,14 +3245,11 @@ Target::StopHook::StopHook (const StopHook &rhs) :
m_thread_spec_ap (),
m_active (rhs.m_active)
{
- if (rhs.m_thread_spec_ap.get() != NULL)
+ if (rhs.m_thread_spec_ap)
m_thread_spec_ap.reset (new ThreadSpec(*rhs.m_thread_spec_ap.get()));
}
-
-Target::StopHook::~StopHook ()
-{
-}
+Target::StopHook::~StopHook() = default;
void
Target::StopHook::SetSpecifier(SymbolContextSpecifier *specifier)
@@ -2822,7 +3262,6 @@ Target::StopHook::SetThreadSpecifier (ThreadSpec *specifier)
{
m_thread_spec_ap.reset (specifier);
}
-
void
Target::StopHook::GetDescription (Stream *s, lldb::DescriptionLevel level) const
@@ -2846,7 +3285,7 @@ Target::StopHook::GetDescription (Stream *s, lldb::DescriptionLevel level) const
s->SetIndentLevel (indent_level + 2);
}
- if (m_thread_spec_ap.get() != NULL)
+ if (m_thread_spec_ap)
{
StreamString tmp;
s->Indent("Thread:\n");
@@ -2878,7 +3317,7 @@ lldb_private::g_dynamic_value_types[] =
{ eNoDynamicValues, "no-dynamic-values", "Don't calculate the dynamic type of values"},
{ eDynamicCanRunTarget, "run-target", "Calculate the dynamic type of values even if you have to run the target."},
{ eDynamicDontRunTarget, "no-run-target", "Calculate the dynamic type of values, but don't run the target."},
- { 0, NULL, NULL }
+ { 0, nullptr, nullptr }
};
static OptionEnumValueElement
@@ -2887,7 +3326,7 @@ g_inline_breakpoint_enums[] =
{ eInlineBreakpointsNever, "never", "Never look for inline breakpoint locations (fastest). This setting should only be used if you know that no inlining occurs in your programs."},
{ eInlineBreakpointsHeaders, "headers", "Only check for inline breakpoint locations when setting breakpoints in header files, but not when setting breakpoint in implementation source files (default)."},
{ eInlineBreakpointsAlways, "always", "Always look for inline breakpoint locations when setting file and line breakpoints (slower but most accurate)."},
- { 0, NULL, NULL }
+ { 0, nullptr, nullptr }
};
typedef enum x86DisassemblyFlavor
@@ -2903,7 +3342,7 @@ g_x86_dis_flavor_value_types[] =
{ eX86DisFlavorDefault, "default", "Disassembler default (currently att)."},
{ eX86DisFlavorIntel, "intel", "Intel disassembler flavor."},
{ eX86DisFlavorATT, "att", "AT&T disassembler flavor."},
- { 0, NULL, NULL }
+ { 0, nullptr, nullptr }
};
static OptionEnumValueElement
@@ -2911,7 +3350,7 @@ g_hex_immediate_style_values[] =
{
{ Disassembler::eHexStyleC, "c", "C-style (0xffff)."},
{ Disassembler::eHexStyleAsm, "asm", "Asm-style (0ffffh)."},
- { 0, NULL, NULL }
+ { 0, nullptr, nullptr }
};
static OptionEnumValueElement
@@ -2920,52 +3359,52 @@ g_load_script_from_sym_file_values[] =
{ eLoadScriptFromSymFileTrue, "true", "Load debug scripts inside symbol files"},
{ eLoadScriptFromSymFileFalse, "false", "Do not load debug scripts inside symbol files."},
{ eLoadScriptFromSymFileWarn, "warn", "Warn about debug scripts inside symbol files but do not load them."},
- { 0, NULL, NULL }
+ { 0, nullptr, nullptr }
};
-
static OptionEnumValueElement
g_memory_module_load_level_values[] =
{
{ eMemoryModuleLoadLevelMinimal, "minimal" , "Load minimal information when loading modules from memory. Currently this setting loads sections only."},
{ eMemoryModuleLoadLevelPartial, "partial" , "Load partial information when loading modules from memory. Currently this setting loads sections and function bounds."},
{ eMemoryModuleLoadLevelComplete, "complete", "Load complete information when loading modules from memory. Currently this setting loads sections and all symbols."},
- { 0, NULL, NULL }
+ { 0, nullptr, nullptr }
};
static PropertyDefinition
g_properties[] =
{
- { "default-arch" , OptionValue::eTypeArch , true , 0 , NULL, NULL, "Default architecture to choose, when there's a choice." },
- { "move-to-nearest-code" , OptionValue::eTypeBoolean , false, true , NULL, NULL, "Move breakpoints to nearest code." },
- { "expr-prefix" , OptionValue::eTypeFileSpec , false, 0 , NULL, NULL, "Path to a file containing expressions to be prepended to all expressions." },
- { "prefer-dynamic-value" , OptionValue::eTypeEnum , false, eDynamicDontRunTarget , NULL, g_dynamic_value_types, "Should printed values be shown as their dynamic value." },
- { "enable-synthetic-value" , OptionValue::eTypeBoolean , false, true , NULL, NULL, "Should synthetic values be used by default whenever available." },
- { "skip-prologue" , OptionValue::eTypeBoolean , false, true , NULL, NULL, "Skip function prologues when setting breakpoints by name." },
- { "source-map" , OptionValue::eTypePathMap , false, 0 , NULL, NULL, "Source path remappings used to track the change of location between a source file when built, and "
+ { "default-arch" , OptionValue::eTypeArch , true , 0 , nullptr, nullptr, "Default architecture to choose, when there's a choice." },
+ { "move-to-nearest-code" , OptionValue::eTypeBoolean , false, true , nullptr, nullptr, "Move breakpoints to nearest code." },
+ { "language" , OptionValue::eTypeLanguage , false, eLanguageTypeUnknown , nullptr, nullptr, "The language to use when interpreting expressions entered in commands." },
+ { "expr-prefix" , OptionValue::eTypeFileSpec , false, 0 , nullptr, nullptr, "Path to a file containing expressions to be prepended to all expressions." },
+ { "prefer-dynamic-value" , OptionValue::eTypeEnum , false, eDynamicDontRunTarget , nullptr, g_dynamic_value_types, "Should printed values be shown as their dynamic value." },
+ { "enable-synthetic-value" , OptionValue::eTypeBoolean , false, true , nullptr, nullptr, "Should synthetic values be used by default whenever available." },
+ { "skip-prologue" , OptionValue::eTypeBoolean , false, true , nullptr, nullptr, "Skip function prologues when setting breakpoints by name." },
+ { "source-map" , OptionValue::eTypePathMap , false, 0 , nullptr, nullptr, "Source path remappings are used to track the change of location between a source file when built, and "
"where it exists on the current system. It consists of an array of duples, the first element of each duple is "
"some part (starting at the root) of the path to the file when it was built, "
"and the second is where the remainder of the original build hierarchy is rooted on the local system. "
"Each element of the array is checked in order and the first one that results in a match wins." },
- { "exec-search-paths" , OptionValue::eTypeFileSpecList, false, 0 , NULL, NULL, "Executable search paths to use when locating executable files whose paths don't match the local file system." },
- { "debug-file-search-paths" , OptionValue::eTypeFileSpecList, false, 0 , NULL, NULL, "List of directories to be searched when locating debug symbol files." },
- { "clang-module-search-paths" , OptionValue::eTypeFileSpecList, false, 0 , NULL, NULL, "List of directories to be searched when locating modules for Clang." },
- { "auto-import-clang-modules" , OptionValue::eTypeBoolean , false, false , NULL, NULL, "Automatically load Clang modules referred to by the program." },
- { "max-children-count" , OptionValue::eTypeSInt64 , false, 256 , NULL, NULL, "Maximum number of children to expand in any level of depth." },
- { "max-string-summary-length" , OptionValue::eTypeSInt64 , false, 1024 , NULL, NULL, "Maximum number of characters to show when using %s in summary strings." },
- { "max-memory-read-size" , OptionValue::eTypeSInt64 , false, 1024 , NULL, NULL, "Maximum number of bytes that 'memory read' will fetch before --force must be specified." },
- { "breakpoints-use-platform-avoid-list", OptionValue::eTypeBoolean , false, true , NULL, NULL, "Consult the platform module avoid list when setting non-module specific breakpoints." },
- { "arg0" , OptionValue::eTypeString , false, 0 , NULL, NULL, "The first argument passed to the program in the argument array which can be different from the executable itself." },
- { "run-args" , OptionValue::eTypeArgs , false, 0 , NULL, NULL, "A list containing all the arguments to be passed to the executable when it is run. Note that this does NOT include the argv[0] which is in target.arg0." },
- { "env-vars" , OptionValue::eTypeDictionary, false, OptionValue::eTypeString , NULL, NULL, "A list of all the environment variables to be passed to the executable's environment, and their values." },
- { "inherit-env" , OptionValue::eTypeBoolean , false, true , NULL, NULL, "Inherit the environment from the process that is running LLDB." },
- { "input-path" , OptionValue::eTypeFileSpec , false, 0 , NULL, NULL, "The file/path to be used by the executable program for reading its standard input." },
- { "output-path" , OptionValue::eTypeFileSpec , false, 0 , NULL, NULL, "The file/path to be used by the executable program for writing its standard output." },
- { "error-path" , OptionValue::eTypeFileSpec , false, 0 , NULL, NULL, "The file/path to be used by the executable program for writing its standard error." },
- { "detach-on-error" , OptionValue::eTypeBoolean , false, true , NULL, NULL, "debugserver will detach (rather than killing) a process if it loses connection with lldb." },
- { "disable-aslr" , OptionValue::eTypeBoolean , false, true , NULL, NULL, "Disable Address Space Layout Randomization (ASLR)" },
- { "disable-stdio" , OptionValue::eTypeBoolean , false, false , NULL, NULL, "Disable stdin/stdout for process (e.g. for a GUI application)" },
- { "inline-breakpoint-strategy" , OptionValue::eTypeEnum , false, eInlineBreakpointsAlways , NULL, g_inline_breakpoint_enums, "The strategy to use when settings breakpoints by file and line. "
+ { "exec-search-paths" , OptionValue::eTypeFileSpecList, false, 0 , nullptr, nullptr, "Executable search paths to use when locating executable files whose paths don't match the local file system." },
+ { "debug-file-search-paths" , OptionValue::eTypeFileSpecList, false, 0 , nullptr, nullptr, "List of directories to be searched when locating debug symbol files." },
+ { "clang-module-search-paths" , OptionValue::eTypeFileSpecList, false, 0 , nullptr, nullptr, "List of directories to be searched when locating modules for Clang." },
+ { "auto-import-clang-modules" , OptionValue::eTypeBoolean , false, false , nullptr, nullptr, "Automatically load Clang modules referred to by the program." },
+ { "max-children-count" , OptionValue::eTypeSInt64 , false, 256 , nullptr, nullptr, "Maximum number of children to expand in any level of depth." },
+ { "max-string-summary-length" , OptionValue::eTypeSInt64 , false, 1024 , nullptr, nullptr, "Maximum number of characters to show when using %s in summary strings." },
+ { "max-memory-read-size" , OptionValue::eTypeSInt64 , false, 1024 , nullptr, nullptr, "Maximum number of bytes that 'memory read' will fetch before --force must be specified." },
+ { "breakpoints-use-platform-avoid-list", OptionValue::eTypeBoolean , false, true , nullptr, nullptr, "Consult the platform module avoid list when setting non-module specific breakpoints." },
+ { "arg0" , OptionValue::eTypeString , false, 0 , nullptr, nullptr, "The first argument passed to the program in the argument array which can be different from the executable itself." },
+ { "run-args" , OptionValue::eTypeArgs , false, 0 , nullptr, nullptr, "A list containing all the arguments to be passed to the executable when it is run. Note that this does NOT include the argv[0] which is in target.arg0." },
+ { "env-vars" , OptionValue::eTypeDictionary, false, OptionValue::eTypeString , nullptr, nullptr, "A list of all the environment variables to be passed to the executable's environment, and their values." },
+ { "inherit-env" , OptionValue::eTypeBoolean , false, true , nullptr, nullptr, "Inherit the environment from the process that is running LLDB." },
+ { "input-path" , OptionValue::eTypeFileSpec , false, 0 , nullptr, nullptr, "The file/path to be used by the executable program for reading its standard input." },
+ { "output-path" , OptionValue::eTypeFileSpec , false, 0 , nullptr, nullptr, "The file/path to be used by the executable program for writing its standard output." },
+ { "error-path" , OptionValue::eTypeFileSpec , false, 0 , nullptr, nullptr, "The file/path to be used by the executable program for writing its standard error." },
+ { "detach-on-error" , OptionValue::eTypeBoolean , false, true , nullptr, nullptr, "debugserver will detach (rather than killing) a process if it loses connection with lldb." },
+ { "disable-aslr" , OptionValue::eTypeBoolean , false, true , nullptr, nullptr, "Disable Address Space Layout Randomization (ASLR)" },
+ { "disable-stdio" , OptionValue::eTypeBoolean , false, false , nullptr, nullptr, "Disable stdin/stdout for process (e.g. for a GUI application)" },
+ { "inline-breakpoint-strategy" , OptionValue::eTypeEnum , false, eInlineBreakpointsAlways , nullptr, g_inline_breakpoint_enums, "The strategy to use when settings breakpoints by file and line. "
"Breakpoint locations can end up being inlined by the compiler, so that a compile unit 'a.c' might contain an inlined function from another source file. "
"Usually this is limited to breakpoint locations from inlined functions from header or other include files, or more accurately non-implementation source files. "
"Sometimes code might #include implementation files and cause inlined breakpoint locations in inlined implementation files. "
@@ -2974,28 +3413,29 @@ g_properties[] =
"This setting allows you to control exactly which strategy is used when setting "
"file and line breakpoints." },
// FIXME: This is the wrong way to do per-architecture settings, but we don't have a general per architecture settings system in place yet.
- { "x86-disassembly-flavor" , OptionValue::eTypeEnum , false, eX86DisFlavorDefault, NULL, g_x86_dis_flavor_value_types, "The default disassembly flavor to use for x86 or x86-64 targets." },
- { "use-hex-immediates" , OptionValue::eTypeBoolean , false, true, NULL, NULL, "Show immediates in disassembly as hexadecimal." },
- { "hex-immediate-style" , OptionValue::eTypeEnum , false, Disassembler::eHexStyleC, NULL, g_hex_immediate_style_values, "Which style to use for printing hexadecimal disassembly values." },
- { "use-fast-stepping" , OptionValue::eTypeBoolean , false, true, NULL, NULL, "Use a fast stepping algorithm based on running from branch to branch rather than instruction single-stepping." },
- { "load-script-from-symbol-file" , OptionValue::eTypeEnum , false, eLoadScriptFromSymFileWarn, NULL, g_load_script_from_sym_file_values, "Allow LLDB to load scripting resources embedded in symbol files when available." },
- { "memory-module-load-level" , OptionValue::eTypeEnum , false, eMemoryModuleLoadLevelComplete, NULL, g_memory_module_load_level_values,
+ { "x86-disassembly-flavor" , OptionValue::eTypeEnum , false, eX86DisFlavorDefault, nullptr, g_x86_dis_flavor_value_types, "The default disassembly flavor to use for x86 or x86-64 targets." },
+ { "use-hex-immediates" , OptionValue::eTypeBoolean , false, true, nullptr, nullptr, "Show immediates in disassembly as hexadecimal." },
+ { "hex-immediate-style" , OptionValue::eTypeEnum , false, Disassembler::eHexStyleC, nullptr, g_hex_immediate_style_values, "Which style to use for printing hexadecimal disassembly values." },
+ { "use-fast-stepping" , OptionValue::eTypeBoolean , false, true, nullptr, nullptr, "Use a fast stepping algorithm based on running from branch to branch rather than instruction single-stepping." },
+ { "load-script-from-symbol-file" , OptionValue::eTypeEnum , false, eLoadScriptFromSymFileWarn, nullptr, g_load_script_from_sym_file_values, "Allow LLDB to load scripting resources embedded in symbol files when available." },
+ { "memory-module-load-level" , OptionValue::eTypeEnum , false, eMemoryModuleLoadLevelComplete, nullptr, g_memory_module_load_level_values,
"Loading modules from memory can be slow as reading the symbol tables and other data can take a long time depending on your connection to the debug target. "
"This setting helps users control how much information gets loaded when loading modules from memory."
"'complete' is the default value for this setting which will load all sections and symbols by reading them from memory (slowest, most accurate). "
"'partial' will load sections and attempt to find function bounds without downloading the symbol table (faster, still accurate, missing symbol names). "
"'minimal' is the fastest setting and will load section data with no symbols, but should rarely be used as stack frames in these memory regions will be inaccurate and not provide any context (fastest). " },
- { "display-expression-in-crashlogs" , OptionValue::eTypeBoolean , false, false, NULL, NULL, "Expressions that crash will show up in crash logs if the host system supports executable specific crash log strings and this setting is set to true." },
- { "trap-handler-names" , OptionValue::eTypeArray , true, OptionValue::eTypeString, NULL, NULL, "A list of trap handler function names, e.g. a common Unix user process one is _sigtramp." },
- { "display-runtime-support-values" , OptionValue::eTypeBoolean , false, false, NULL, NULL, "If true, LLDB will show variables that are meant to support the operation of a language's runtime support." },
- { "non-stop-mode" , OptionValue::eTypeBoolean , false, 0, NULL, NULL, "Disable lock-step debugging, instead control threads independently." },
- { NULL , OptionValue::eTypeInvalid , false, 0 , NULL, NULL, NULL }
+ { "display-expression-in-crashlogs" , OptionValue::eTypeBoolean , false, false, nullptr, nullptr, "Expressions that crash will show up in crash logs if the host system supports executable specific crash log strings and this setting is set to true." },
+ { "trap-handler-names" , OptionValue::eTypeArray , true, OptionValue::eTypeString, nullptr, nullptr, "A list of trap handler function names, e.g. a common Unix user process one is _sigtramp." },
+ { "display-runtime-support-values" , OptionValue::eTypeBoolean , false, false, nullptr, nullptr, "If true, LLDB will show variables that are meant to support the operation of a language's runtime support." },
+ { "non-stop-mode" , OptionValue::eTypeBoolean , false, 0, nullptr, nullptr, "Disable lock-step debugging, instead control threads independently." },
+ { nullptr , OptionValue::eTypeInvalid , false, 0 , nullptr, nullptr, nullptr }
};
enum
{
ePropertyDefaultArch,
ePropertyMoveToNearestCode,
+ ePropertyLanguage,
ePropertyExprPrefix,
ePropertyPreferDynamic,
ePropertyEnableSynthetic,
@@ -3032,13 +3472,12 @@ enum
ePropertyNonStopModeEnabled
};
-
class TargetOptionValueProperties : public OptionValueProperties
{
public:
TargetOptionValueProperties (const ConstString &name) :
OptionValueProperties (name),
- m_target (NULL),
+ m_target(nullptr),
m_got_host_env (false)
{
}
@@ -3053,8 +3492,8 @@ public:
{
}
- virtual const Property *
- GetPropertyAtIndex (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
+ const Property *
+ GetPropertyAtIndex(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const override
{
// When getting the value for a key from the target options, we will always
// try and grab the setting from the current target if there is one. Else we just
@@ -3082,7 +3521,6 @@ public:
}
protected:
-
void
GetHostEnvironmentIfNeeded () const
{
@@ -3092,7 +3530,7 @@ protected:
{
m_got_host_env = true;
const uint32_t idx = ePropertyInheritEnv;
- if (GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0))
+ if (GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0))
{
PlatformSP platform_sp (m_target->GetPlatform());
if (platform_sp)
@@ -3100,7 +3538,7 @@ protected:
StringList env;
if (platform_sp->GetEnvironment(env))
{
- OptionValueDictionary *env_dict = GetPropertyAtIndexAsOptionValueDictionary (NULL, ePropertyEnvVars);
+ OptionValueDictionary *env_dict = GetPropertyAtIndexAsOptionValueDictionary(nullptr, ePropertyEnvVars);
if (env_dict)
{
const bool can_replace = false;
@@ -3113,7 +3551,7 @@ protected:
const char *equal_pos = ::strchr(env_entry, '=');
ConstString key;
// It is ok to have environment variables with no values
- const char *value = NULL;
+ const char *value = nullptr;
if (equal_pos)
{
key.SetCStringWithLength(env_entry, equal_pos - env_entry);
@@ -3162,15 +3600,15 @@ TargetProperties::TargetProperties (Target *target) :
m_collection_sp->SetValueChangedCallback(ePropertyDisableSTDIO, TargetProperties::DisableSTDIOValueChangedCallback, this);
// Update m_launch_info once it was created
- Arg0ValueChangedCallback(this, NULL);
- RunArgsValueChangedCallback(this, NULL);
- //EnvVarsValueChangedCallback(this, NULL); // FIXME: cause segfault in Target::GetPlatform()
- InputPathValueChangedCallback(this, NULL);
- OutputPathValueChangedCallback(this, NULL);
- ErrorPathValueChangedCallback(this, NULL);
- DetachOnErrorValueChangedCallback(this, NULL);
- DisableASLRValueChangedCallback(this, NULL);
- DisableSTDIOValueChangedCallback(this, NULL);
+ Arg0ValueChangedCallback(this, nullptr);
+ RunArgsValueChangedCallback(this, nullptr);
+ //EnvVarsValueChangedCallback(this, nullptr); // FIXME: cause segfault in Target::GetPlatform()
+ InputPathValueChangedCallback(this, nullptr);
+ OutputPathValueChangedCallback(this, nullptr);
+ ErrorPathValueChangedCallback(this, nullptr);
+ DetachOnErrorValueChangedCallback(this, nullptr);
+ DisableASLRValueChangedCallback(this, nullptr);
+ DisableSTDIOValueChangedCallback(this, nullptr);
}
else
{
@@ -3181,16 +3619,14 @@ TargetProperties::TargetProperties (Target *target) :
true,
Process::GetGlobalProperties()->GetValueProperties());
}
-
}
-TargetProperties::~TargetProperties ()
-{
-}
+TargetProperties::~TargetProperties() = default;
+
ArchSpec
TargetProperties::GetDefaultArchitecture () const
{
- OptionValueArch *value = m_collection_sp->GetPropertyAtIndexAsOptionValueArch (NULL, ePropertyDefaultArch);
+ OptionValueArch *value = m_collection_sp->GetPropertyAtIndexAsOptionValueArch(nullptr, ePropertyDefaultArch);
if (value)
return value->GetCurrentValue();
return ArchSpec();
@@ -3199,7 +3635,7 @@ TargetProperties::GetDefaultArchitecture () const
void
TargetProperties::SetDefaultArchitecture (const ArchSpec& arch)
{
- OptionValueArch *value = m_collection_sp->GetPropertyAtIndexAsOptionValueArch (NULL, ePropertyDefaultArch);
+ OptionValueArch *value = m_collection_sp->GetPropertyAtIndexAsOptionValueArch(nullptr, ePropertyDefaultArch);
if (value)
return value->SetCurrentValue(arch, true);
}
@@ -3208,64 +3644,63 @@ bool
TargetProperties::GetMoveToNearestCode() const
{
const uint32_t idx = ePropertyMoveToNearestCode;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
lldb::DynamicValueType
TargetProperties::GetPreferDynamicValue() const
{
const uint32_t idx = ePropertyPreferDynamic;
- return (lldb::DynamicValueType)m_collection_sp->GetPropertyAtIndexAsEnumeration (NULL, idx, g_properties[idx].default_uint_value);
+ return (lldb::DynamicValueType)m_collection_sp->GetPropertyAtIndexAsEnumeration(nullptr, idx, g_properties[idx].default_uint_value);
}
bool
TargetProperties::SetPreferDynamicValue (lldb::DynamicValueType d)
{
const uint32_t idx = ePropertyPreferDynamic;
- return m_collection_sp->SetPropertyAtIndexAsEnumeration(NULL, idx, d);
+ return m_collection_sp->SetPropertyAtIndexAsEnumeration(nullptr, idx, d);
}
-
bool
TargetProperties::GetDisableASLR () const
{
const uint32_t idx = ePropertyDisableASLR;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
void
TargetProperties::SetDisableASLR (bool b)
{
const uint32_t idx = ePropertyDisableASLR;
- m_collection_sp->SetPropertyAtIndexAsBoolean (NULL, idx, b);
+ m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
}
bool
TargetProperties::GetDetachOnError () const
{
const uint32_t idx = ePropertyDetachOnError;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
void
TargetProperties::SetDetachOnError (bool b)
{
const uint32_t idx = ePropertyDetachOnError;
- m_collection_sp->SetPropertyAtIndexAsBoolean (NULL, idx, b);
+ m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
}
bool
TargetProperties::GetDisableSTDIO () const
{
const uint32_t idx = ePropertyDisableSTDIO;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
void
TargetProperties::SetDisableSTDIO (bool b)
{
const uint32_t idx = ePropertyDisableSTDIO;
- m_collection_sp->SetPropertyAtIndexAsBoolean (NULL, idx, b);
+ m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
}
const char *
@@ -3274,7 +3709,7 @@ TargetProperties::GetDisassemblyFlavor () const
const uint32_t idx = ePropertyDisassemblyFlavor;
const char *return_value;
- x86DisassemblyFlavor flavor_value = (x86DisassemblyFlavor) m_collection_sp->GetPropertyAtIndexAsEnumeration (NULL, idx, g_properties[idx].default_uint_value);
+ x86DisassemblyFlavor flavor_value = (x86DisassemblyFlavor) m_collection_sp->GetPropertyAtIndexAsEnumeration(nullptr, idx, g_properties[idx].default_uint_value);
return_value = g_x86_dis_flavor_value_types[flavor_value].string_value;
return return_value;
}
@@ -3283,21 +3718,21 @@ InlineStrategy
TargetProperties::GetInlineStrategy () const
{
const uint32_t idx = ePropertyInlineStrategy;
- return (InlineStrategy)m_collection_sp->GetPropertyAtIndexAsEnumeration (NULL, idx, g_properties[idx].default_uint_value);
+ return (InlineStrategy)m_collection_sp->GetPropertyAtIndexAsEnumeration(nullptr, idx, g_properties[idx].default_uint_value);
}
const char *
TargetProperties::GetArg0 () const
{
const uint32_t idx = ePropertyArg0;
- return m_collection_sp->GetPropertyAtIndexAsString (NULL, idx, NULL);
+ return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, nullptr);
}
void
TargetProperties::SetArg0 (const char *arg)
{
const uint32_t idx = ePropertyArg0;
- m_collection_sp->SetPropertyAtIndexAsString (NULL, idx, arg);
+ m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, arg);
m_launch_info.SetArg0(arg);
}
@@ -3305,14 +3740,14 @@ bool
TargetProperties::GetRunArguments (Args &args) const
{
const uint32_t idx = ePropertyRunArgs;
- return m_collection_sp->GetPropertyAtIndexAsArgs (NULL, idx, args);
+ return m_collection_sp->GetPropertyAtIndexAsArgs(nullptr, idx, args);
}
void
TargetProperties::SetRunArguments (const Args &args)
{
const uint32_t idx = ePropertyRunArgs;
- m_collection_sp->SetPropertyAtIndexFromArgs (NULL, idx, args);
+ m_collection_sp->SetPropertyAtIndexFromArgs(nullptr, idx, args);
m_launch_info.GetArguments() = args;
}
@@ -3320,14 +3755,14 @@ size_t
TargetProperties::GetEnvironmentAsArgs (Args &env) const
{
const uint32_t idx = ePropertyEnvVars;
- return m_collection_sp->GetPropertyAtIndexAsArgs (NULL, idx, env);
+ return m_collection_sp->GetPropertyAtIndexAsArgs(nullptr, idx, env);
}
void
TargetProperties::SetEnvironmentFromArgs (const Args &env)
{
const uint32_t idx = ePropertyEnvVars;
- m_collection_sp->SetPropertyAtIndexFromArgs (NULL, idx, env);
+ m_collection_sp->SetPropertyAtIndexFromArgs(nullptr, idx, env);
m_launch_info.GetEnvironmentEntries() = env;
}
@@ -3335,14 +3770,14 @@ bool
TargetProperties::GetSkipPrologue() const
{
const uint32_t idx = ePropertySkipPrologue;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
PathMappingList &
TargetProperties::GetSourcePathMap () const
{
const uint32_t idx = ePropertySourceMap;
- OptionValuePathMappings *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValuePathMappings (NULL, false, idx);
+ OptionValuePathMappings *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValuePathMappings(nullptr, false, idx);
assert(option_value);
return option_value->GetCurrentValue();
}
@@ -3351,7 +3786,7 @@ FileSpecList &
TargetProperties::GetExecutableSearchPaths ()
{
const uint32_t idx = ePropertyExecutableSearchPaths;
- OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList (NULL, false, idx);
+ OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr, false, idx);
assert(option_value);
return option_value->GetCurrentValue();
}
@@ -3360,7 +3795,7 @@ FileSpecList &
TargetProperties::GetDebugFileSearchPaths ()
{
const uint32_t idx = ePropertyDebugFileSearchPaths;
- OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList (NULL, false, idx);
+ OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr, false, idx);
assert(option_value);
return option_value->GetCurrentValue();
}
@@ -3369,7 +3804,7 @@ FileSpecList &
TargetProperties::GetClangModuleSearchPaths ()
{
const uint32_t idx = ePropertyClangModuleSearchPaths;
- OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList (NULL, false, idx);
+ OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr, false, idx);
assert(option_value);
return option_value->GetCurrentValue();
}
@@ -3378,77 +3813,86 @@ bool
TargetProperties::GetEnableAutoImportClangModules() const
{
const uint32_t idx = ePropertyAutoImportClangModules;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
bool
TargetProperties::GetEnableSyntheticValue () const
{
const uint32_t idx = ePropertyEnableSynthetic;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
uint32_t
TargetProperties::GetMaximumNumberOfChildrenToDisplay() const
{
const uint32_t idx = ePropertyMaxChildrenCount;
- return m_collection_sp->GetPropertyAtIndexAsSInt64 (NULL, idx, g_properties[idx].default_uint_value);
+ return m_collection_sp->GetPropertyAtIndexAsSInt64(nullptr, idx, g_properties[idx].default_uint_value);
}
uint32_t
TargetProperties::GetMaximumSizeOfStringSummary() const
{
const uint32_t idx = ePropertyMaxSummaryLength;
- return m_collection_sp->GetPropertyAtIndexAsSInt64 (NULL, idx, g_properties[idx].default_uint_value);
+ return m_collection_sp->GetPropertyAtIndexAsSInt64(nullptr, idx, g_properties[idx].default_uint_value);
}
uint32_t
TargetProperties::GetMaximumMemReadSize () const
{
const uint32_t idx = ePropertyMaxMemReadSize;
- return m_collection_sp->GetPropertyAtIndexAsSInt64 (NULL, idx, g_properties[idx].default_uint_value);
+ return m_collection_sp->GetPropertyAtIndexAsSInt64(nullptr, idx, g_properties[idx].default_uint_value);
}
FileSpec
TargetProperties::GetStandardInputPath () const
{
const uint32_t idx = ePropertyInputPath;
- return m_collection_sp->GetPropertyAtIndexAsFileSpec (NULL, idx);
+ return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
}
void
TargetProperties::SetStandardInputPath (const char *p)
{
const uint32_t idx = ePropertyInputPath;
- m_collection_sp->SetPropertyAtIndexAsString (NULL, idx, p);
+ m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, p);
}
FileSpec
TargetProperties::GetStandardOutputPath () const
{
const uint32_t idx = ePropertyOutputPath;
- return m_collection_sp->GetPropertyAtIndexAsFileSpec (NULL, idx);
+ return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
}
void
TargetProperties::SetStandardOutputPath (const char *p)
{
const uint32_t idx = ePropertyOutputPath;
- m_collection_sp->SetPropertyAtIndexAsString (NULL, idx, p);
+ m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, p);
}
FileSpec
TargetProperties::GetStandardErrorPath () const
{
const uint32_t idx = ePropertyErrorPath;
- return m_collection_sp->GetPropertyAtIndexAsFileSpec(NULL, idx);
+ return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
+}
+
+LanguageType
+TargetProperties::GetLanguage () const
+{
+ OptionValueLanguage *value = m_collection_sp->GetPropertyAtIndexAsOptionValueLanguage(nullptr, ePropertyLanguage);
+ if (value)
+ return value->GetCurrentValue();
+ return LanguageType();
}
const char *
TargetProperties::GetExpressionPrefixContentsAsCString ()
{
const uint32_t idx = ePropertyExprPrefix;
- OptionValueFileSpec *file = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpec (NULL, false, idx);
+ OptionValueFileSpec *file = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpec(nullptr, false, idx);
if (file)
{
const bool null_terminate = true;
@@ -3456,105 +3900,105 @@ TargetProperties::GetExpressionPrefixContentsAsCString ()
if (data_sp)
return (const char *) data_sp->GetBytes();
}
- return NULL;
+ return nullptr;
}
void
TargetProperties::SetStandardErrorPath (const char *p)
{
const uint32_t idx = ePropertyErrorPath;
- m_collection_sp->SetPropertyAtIndexAsString (NULL, idx, p);
+ m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, p);
}
bool
TargetProperties::GetBreakpointsConsultPlatformAvoidList ()
{
const uint32_t idx = ePropertyBreakpointUseAvoidList;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
bool
TargetProperties::GetUseHexImmediates () const
{
const uint32_t idx = ePropertyUseHexImmediates;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
bool
TargetProperties::GetUseFastStepping () const
{
const uint32_t idx = ePropertyUseFastStepping;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
bool
TargetProperties::GetDisplayExpressionsInCrashlogs () const
{
const uint32_t idx = ePropertyDisplayExpressionsInCrashlogs;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
LoadScriptFromSymFile
TargetProperties::GetLoadScriptFromSymbolFile () const
{
const uint32_t idx = ePropertyLoadScriptFromSymbolFile;
- return (LoadScriptFromSymFile)m_collection_sp->GetPropertyAtIndexAsEnumeration(NULL, idx, g_properties[idx].default_uint_value);
+ return (LoadScriptFromSymFile)m_collection_sp->GetPropertyAtIndexAsEnumeration(nullptr, idx, g_properties[idx].default_uint_value);
}
Disassembler::HexImmediateStyle
TargetProperties::GetHexImmediateStyle () const
{
const uint32_t idx = ePropertyHexImmediateStyle;
- return (Disassembler::HexImmediateStyle)m_collection_sp->GetPropertyAtIndexAsEnumeration(NULL, idx, g_properties[idx].default_uint_value);
+ return (Disassembler::HexImmediateStyle)m_collection_sp->GetPropertyAtIndexAsEnumeration(nullptr, idx, g_properties[idx].default_uint_value);
}
MemoryModuleLoadLevel
TargetProperties::GetMemoryModuleLoadLevel() const
{
const uint32_t idx = ePropertyMemoryModuleLoadLevel;
- return (MemoryModuleLoadLevel)m_collection_sp->GetPropertyAtIndexAsEnumeration(NULL, idx, g_properties[idx].default_uint_value);
+ return (MemoryModuleLoadLevel)m_collection_sp->GetPropertyAtIndexAsEnumeration(nullptr, idx, g_properties[idx].default_uint_value);
}
bool
TargetProperties::GetUserSpecifiedTrapHandlerNames (Args &args) const
{
const uint32_t idx = ePropertyTrapHandlerNames;
- return m_collection_sp->GetPropertyAtIndexAsArgs (NULL, idx, args);
+ return m_collection_sp->GetPropertyAtIndexAsArgs(nullptr, idx, args);
}
void
TargetProperties::SetUserSpecifiedTrapHandlerNames (const Args &args)
{
const uint32_t idx = ePropertyTrapHandlerNames;
- m_collection_sp->SetPropertyAtIndexFromArgs (NULL, idx, args);
+ m_collection_sp->SetPropertyAtIndexFromArgs(nullptr, idx, args);
}
bool
TargetProperties::GetDisplayRuntimeSupportValues () const
{
const uint32_t idx = ePropertyDisplayRuntimeSupportValues;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, false);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, false);
}
void
TargetProperties::SetDisplayRuntimeSupportValues (bool b)
{
const uint32_t idx = ePropertyDisplayRuntimeSupportValues;
- m_collection_sp->SetPropertyAtIndexAsBoolean (NULL, idx, b);
+ m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
}
bool
TargetProperties::GetNonStopModeEnabled () const
{
const uint32_t idx = ePropertyNonStopModeEnabled;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, false);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, false);
}
void
TargetProperties::SetNonStopModeEnabled (bool b)
{
const uint32_t idx = ePropertyNonStopModeEnabled;
- m_collection_sp->SetPropertyAtIndexAsBoolean (NULL, idx, b);
+ m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
}
const ProcessLaunchInfo &
@@ -3691,9 +4135,7 @@ Target::TargetEventData::TargetEventData (const lldb::TargetSP &target_sp, const
{
}
-Target::TargetEventData::~TargetEventData()
-{
-}
+Target::TargetEventData::~TargetEventData() = default;
const ConstString &
Target::TargetEventData::GetFlavorString ()
@@ -3716,7 +4158,7 @@ Target::TargetEventData::GetEventDataFromEvent (const Event *event_ptr)
if (event_data && event_data->GetFlavor() == TargetEventData::GetFlavorString())
return static_cast <const TargetEventData *> (event_ptr->GetData());
}
- return NULL;
+ return nullptr;
}
TargetSP
diff --git a/source/Target/TargetList.cpp b/source/Target/TargetList.cpp
index 552e951496f2..ffec758ac215 100644
--- a/source/Target/TargetList.cpp
+++ b/source/Target/TargetList.cpp
@@ -10,6 +10,8 @@
// C Includes
// C++ Includes
// Other libraries and framework includes
+#include "llvm/ADT/SmallString.h"
+
// Project includes
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Debugger.h"
@@ -27,8 +29,6 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/TargetList.h"
-#include "llvm/ADT/SmallString.h"
-
using namespace lldb;
using namespace lldb_private;
@@ -179,9 +179,14 @@ TargetList::CreateTargetInternal (Debugger &debugger,
}
else
{
+ StreamString platform_arch_strm;
+ StreamString module_arch_strm;
+
+ platform_arch.DumpTriple(platform_arch_strm);
+ matching_module_spec.GetArchitecture().DumpTriple(module_arch_strm);
error.SetErrorStringWithFormat("the specified architecture '%s' is not compatible with '%s' in '%s'",
- platform_arch.GetTriple().str().c_str(),
- matching_module_spec.GetArchitecture().GetTriple().str().c_str(),
+ platform_arch_strm.GetString().c_str(),
+ module_arch_strm.GetString().c_str(),
module_spec.GetFileSpec().GetPath().c_str());
return error;
}
@@ -222,7 +227,7 @@ TargetList::CreateTargetInternal (Debugger &debugger,
// since the user may have specified it.
if (platform_sp)
{
- if (platform_sp->IsCompatibleArchitecture(module_spec.GetArchitecture(), false, NULL))
+ if (platform_sp->IsCompatibleArchitecture(module_spec.GetArchitecture(), false, nullptr))
{
platforms.push_back(platform_sp);
continue;
@@ -232,7 +237,7 @@ TargetList::CreateTargetInternal (Debugger &debugger,
// Next check the host platform it if wasn't already checked above
if (host_platform_sp && (!platform_sp || host_platform_sp->GetName() != platform_sp->GetName()))
{
- if (host_platform_sp->IsCompatibleArchitecture(module_spec.GetArchitecture(), false, NULL))
+ if (host_platform_sp->IsCompatibleArchitecture(module_spec.GetArchitecture(), false, nullptr))
{
platforms.push_back(host_platform_sp);
continue;
@@ -240,18 +245,24 @@ TargetList::CreateTargetInternal (Debugger &debugger,
}
// Just find a platform that matches the architecture in the executable file
- platforms.push_back(Platform::GetPlatformForArchitecture(module_spec.GetArchitecture(), nullptr));
+ PlatformSP fallback_platform_sp (Platform::GetPlatformForArchitecture(module_spec.GetArchitecture(), nullptr));
+ if (fallback_platform_sp)
+ {
+ platforms.push_back(fallback_platform_sp);
+ }
}
}
- Platform *platform_ptr = NULL;
+ Platform *platform_ptr = nullptr;
+ bool more_than_one_platforms = false;
for (const auto &the_platform_sp : platforms)
{
if (platform_ptr)
{
if (platform_ptr->GetName() != the_platform_sp->GetName())
{
- platform_ptr = NULL;
+ more_than_one_platforms = true;
+ platform_ptr = nullptr;
break;
}
}
@@ -266,6 +277,12 @@ TargetList::CreateTargetInternal (Debugger &debugger,
// All platforms for all modules in the exectuable match, so we can select this platform
platform_sp = platforms.front();
}
+ else if (more_than_one_platforms == false)
+ {
+ // No platforms claim to support this file
+ error.SetErrorString ("No matching platforms found for this file, specify one with the --platform option");
+ return error;
+ }
else
{
// More than one platform claims to support this file, so the --platform option must be specified
@@ -369,7 +386,6 @@ TargetList::CreateTargetInternal (Debugger &debugger,
lldb::TargetSP &target_sp,
bool is_dummy_target)
{
-
Timer scoped_timer (__PRETTY_FUNCTION__,
"TargetList::CreateTarget (file = '%s', arch = '%s')",
user_exe_path,
@@ -380,7 +396,7 @@ TargetList::CreateTargetInternal (Debugger &debugger,
if (arch.IsValid())
{
- if (!platform_sp || !platform_sp->IsCompatibleArchitecture(arch, false, NULL))
+ if (!platform_sp || !platform_sp->IsCompatibleArchitecture(arch, false, nullptr))
platform_sp = Platform::GetPlatformForArchitecture(specified_arch, &arch);
}
@@ -436,14 +452,14 @@ TargetList::CreateTargetInternal (Debugger &debugger,
{
FileSpecList executable_search_paths (Target::GetDefaultExecutableSearchPaths());
ModuleSpec module_spec(file, arch);
- error = platform_sp->ResolveExecutable (module_spec,
- exe_module_sp,
- executable_search_paths.GetSize() ? &executable_search_paths : NULL);
+ error = platform_sp->ResolveExecutable(module_spec,
+ exe_module_sp,
+ executable_search_paths.GetSize() ? &executable_search_paths : nullptr);
}
if (error.Success() && exe_module_sp)
{
- if (exe_module_sp->GetObjectFile() == NULL)
+ if (exe_module_sp->GetObjectFile() == nullptr)
{
if (arch.IsValid())
{
@@ -531,13 +547,9 @@ TargetList::DeleteTarget (TargetSP &target_sp)
return false;
}
-
TargetSP
-TargetList::FindTargetWithExecutableAndArchitecture
-(
- const FileSpec &exe_file_spec,
- const ArchSpec *exe_arch_ptr
-) const
+TargetList::FindTargetWithExecutableAndArchitecture(const FileSpec &exe_file_spec,
+ const ArchSpec *exe_arch_ptr) const
{
Mutex::Locker locker (m_target_list_mutex);
TargetSP target_sp;
@@ -583,7 +595,6 @@ TargetList::FindTargetWithProcessID (lldb::pid_t pid) const
return target_sp;
}
-
TargetSP
TargetList::FindTargetWithProcess (Process *process) const
{
@@ -632,7 +643,7 @@ TargetList::SendAsyncInterrupt (lldb::pid_t pid)
if (pid != LLDB_INVALID_PROCESS_ID)
{
TargetSP target_sp(FindTargetWithProcessID (pid));
- if (target_sp.get())
+ if (target_sp)
{
Process* process = target_sp->GetProcessSP().get();
if (process)
@@ -646,7 +657,7 @@ TargetList::SendAsyncInterrupt (lldb::pid_t pid)
{
// We don't have a valid pid to broadcast to, so broadcast to the target
// list's async broadcaster...
- BroadcastEvent (Process::eBroadcastBitInterrupt, NULL);
+ BroadcastEvent(Process::eBroadcastBitInterrupt, nullptr);
}
return num_async_interrupts_sent;
@@ -656,7 +667,7 @@ uint32_t
TargetList::SignalIfRunning (lldb::pid_t pid, int signo)
{
uint32_t num_signals_sent = 0;
- Process *process = NULL;
+ Process *process = nullptr;
if (pid == LLDB_INVALID_PROCESS_ID)
{
// Signal all processes with signal
@@ -679,7 +690,7 @@ TargetList::SignalIfRunning (lldb::pid_t pid, int signo)
{
// Signal a specific process with signal
TargetSP target_sp(FindTargetWithProcessID (pid));
- if (target_sp.get())
+ if (target_sp)
{
process = target_sp->GetProcessSP().get();
if (process)
diff --git a/source/Target/Thread.cpp b/source/Target/Thread.cpp
index 29ba86a7e84d..9f9da9726605 100644
--- a/source/Target/Thread.cpp
+++ b/source/Target/Thread.cpp
@@ -7,14 +7,20 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/FormatEntity.h"
+#include "lldb/Core/Module.h"
#include "lldb/Core/State.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/RegularExpression.h"
+#include "lldb/Core/ValueObject.h"
#include "lldb/Host/Host.h"
#include "lldb/Interpreter/OptionValueFileSpecList.h"
#include "lldb/Interpreter/OptionValueProperties.h"
@@ -23,7 +29,6 @@
#include "lldb/Target/ABI.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StopInfo.h"
@@ -47,11 +52,9 @@
#include "Plugins/Process/Utility/UnwindLLDB.h"
#include "Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h"
-
using namespace lldb;
using namespace lldb_private;
-
const ThreadPropertiesSP &
Thread::GetGlobalProperties()
{
@@ -64,13 +67,13 @@ Thread::GetGlobalProperties()
static PropertyDefinition
g_properties[] =
{
- { "step-in-avoid-nodebug", OptionValue::eTypeBoolean, true, true, NULL, NULL, "If true, step-in will not stop in functions with no debug information." },
- { "step-out-avoid-nodebug", OptionValue::eTypeBoolean, true, false, NULL, NULL, "If true, when step-in/step-out/step-over leave the current frame, they will continue to step out till they come to a function with "
+ { "step-in-avoid-nodebug", OptionValue::eTypeBoolean, true, true, nullptr, nullptr, "If true, step-in will not stop in functions with no debug information." },
+ { "step-out-avoid-nodebug", OptionValue::eTypeBoolean, true, false, nullptr, nullptr, "If true, when step-in/step-out/step-over leave the current frame, they will continue to step out till they come to a function with "
"debug information. Passing a frame argument to step-out will override this option." },
- { "step-avoid-regexp", OptionValue::eTypeRegex , true , 0, "^std::", NULL, "A regular expression defining functions step-in won't stop in." },
- { "step-avoid-libraries", OptionValue::eTypeFileSpecList , true , 0, NULL, NULL, "A list of libraries that source stepping won't stop in." },
- { "trace-thread", OptionValue::eTypeBoolean, false, false, NULL, NULL, "If true, this thread will single-step and log execution." },
- { NULL , OptionValue::eTypeInvalid, false, 0 , NULL, NULL, NULL }
+ { "step-avoid-regexp", OptionValue::eTypeRegex , true , 0, "^std::", nullptr, "A regular expression defining functions step-in won't stop in." },
+ { "step-avoid-libraries", OptionValue::eTypeFileSpecList , true , 0, nullptr, nullptr, "A list of libraries that source stepping won't stop in." },
+ { "trace-thread", OptionValue::eTypeBoolean, false, false, nullptr, nullptr, "If true, this thread will single-step and log execution." },
+ { nullptr , OptionValue::eTypeInvalid, false, 0 , nullptr, nullptr, nullptr }
};
enum {
@@ -81,7 +84,6 @@ enum {
ePropertyEnableThreadTrace
};
-
class ThreadOptionValueProperties : public OptionValueProperties
{
public:
@@ -98,8 +100,8 @@ public:
{
}
- virtual const Property *
- GetPropertyAtIndex (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
+ const Property *
+ GetPropertyAtIndex(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const override
{
// When getting the value for a key from the thread options, we will always
// try and grab the setting from the current thread if there is one. Else we just
@@ -118,8 +120,6 @@ public:
}
};
-
-
ThreadProperties::ThreadProperties (bool is_global) :
Properties ()
{
@@ -132,22 +132,20 @@ ThreadProperties::ThreadProperties (bool is_global) :
m_collection_sp.reset (new ThreadOptionValueProperties(Thread::GetGlobalProperties().get()));
}
-ThreadProperties::~ThreadProperties()
-{
-}
+ThreadProperties::~ThreadProperties() = default;
const RegularExpression *
ThreadProperties::GetSymbolsToAvoidRegexp()
{
const uint32_t idx = ePropertyStepAvoidRegex;
- return m_collection_sp->GetPropertyAtIndexAsOptionValueRegex (NULL, idx);
+ return m_collection_sp->GetPropertyAtIndexAsOptionValueRegex(nullptr, idx);
}
FileSpecList &
ThreadProperties::GetLibrariesToAvoid() const
{
const uint32_t idx = ePropertyStepAvoidLibraries;
- OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList (NULL, false, idx);
+ OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr, false, idx);
assert(option_value);
return option_value->GetCurrentValue();
}
@@ -156,29 +154,27 @@ bool
ThreadProperties::GetTraceEnabledState() const
{
const uint32_t idx = ePropertyEnableThreadTrace;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
bool
ThreadProperties::GetStepInAvoidsNoDebug() const
{
const uint32_t idx = ePropertyStepInAvoidsNoDebug;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
bool
ThreadProperties::GetStepOutAvoidsNoDebug() const
{
const uint32_t idx = ePropertyStepOutAvoidsNoDebug;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, g_properties[idx].default_uint_value != 0);
}
-
//------------------------------------------------------------------
// Thread Event Data
//------------------------------------------------------------------
-
const ConstString &
Thread::ThreadEventData::GetFlavorString ()
{
@@ -204,14 +200,11 @@ Thread::ThreadEventData::ThreadEventData () :
{
}
-Thread::ThreadEventData::~ThreadEventData ()
-{
-}
+Thread::ThreadEventData::~ThreadEventData() = default;
void
Thread::ThreadEventData::Dump (Stream *s) const
{
-
}
const Thread::ThreadEventData *
@@ -223,7 +216,7 @@ Thread::ThreadEventData::GetEventDataFromEvent (const Event *event_ptr)
if (event_data && event_data->GetFlavor() == ThreadEventData::GetFlavorString())
return static_cast <const ThreadEventData *> (event_ptr->GetData());
}
- return NULL;
+ return nullptr;
}
ThreadSP
@@ -308,7 +301,6 @@ Thread::Thread (Process &process, lldb::tid_t tid, bool use_invalid_index_id) :
QueueFundamentalPlan(true);
}
-
Thread::~Thread()
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
@@ -360,12 +352,22 @@ Thread::BroadcastSelectedFrameChange(StackID &new_frame_id)
BroadcastEvent(eBroadcastBitSelectedFrameChanged, new ThreadEventData (this->shared_from_this(), new_frame_id));
}
+lldb::StackFrameSP
+Thread::GetSelectedFrame()
+{
+ StackFrameListSP stack_frame_list_sp(GetStackFrameList());
+ StackFrameSP frame_sp = stack_frame_list_sp->GetFrameAtIndex (stack_frame_list_sp->GetSelectedFrameIndex());
+ FunctionOptimizationWarning (frame_sp.get());
+ return frame_sp;
+}
+
uint32_t
Thread::SetSelectedFrame (lldb_private::StackFrame *frame, bool broadcast)
{
uint32_t ret_value = GetStackFrameList()->SetSelectedFrame(frame);
if (broadcast)
BroadcastSelectedFrameChange(frame->GetStackID());
+ FunctionOptimizationWarning (frame);
return ret_value;
}
@@ -378,6 +380,7 @@ Thread::SetSelectedFrameByIndex (uint32_t frame_idx, bool broadcast)
GetStackFrameList()->SetSelectedFrame(frame_sp.get());
if (broadcast)
BroadcastSelectedFrameChange(frame_sp->GetStackID());
+ FunctionOptimizationWarning (frame_sp.get());
return true;
}
else
@@ -403,6 +406,7 @@ Thread::SetSelectedFrameByIndexNoisily (uint32_t frame_idx, Stream &output_strea
bool show_frame_info = true;
bool show_source = !already_shown;
+ FunctionOptimizationWarning (frame_sp.get());
return frame_sp->GetStatus (output_stream, show_frame_info, show_source);
}
return false;
@@ -411,6 +415,15 @@ Thread::SetSelectedFrameByIndexNoisily (uint32_t frame_idx, Stream &output_strea
return false;
}
+void
+Thread::FunctionOptimizationWarning (StackFrame *frame)
+{
+ if (frame && frame->HasDebugInformation() && GetProcess()->GetWarningsOptimization())
+ {
+ SymbolContext sc = frame->GetSymbolContext (eSymbolContextFunction | eSymbolContextModule);
+ GetProcess()->PrintWarningOptimization (sc);
+ }
+}
lldb::StopInfoSP
Thread::GetStopInfo ()
@@ -464,7 +477,7 @@ Thread::GetPrivateStopInfo ()
if (!m_stop_info_sp)
{
- if (CalculateStopInfo() == false)
+ if (!CalculateStopInfo())
SetStopInfo (StopInfoSP());
}
}
@@ -490,7 +503,6 @@ Thread::GetPrivateStopInfo ()
return m_stop_info_sp;
}
-
lldb::StopReason
Thread::GetStopReason()
{
@@ -500,7 +512,15 @@ Thread::GetStopReason()
return eStopReasonNone;
}
-
+bool
+Thread::StopInfoIsUpToDate() const
+{
+ ProcessSP process_sp (GetProcess());
+ if (process_sp)
+ return m_stop_info_stop_id == process_sp->GetStopID();
+ else
+ return true; // Process is no longer around so stop info is always up to date...
+}
void
Thread::SetStopInfo (const lldb::StopInfoSP &stop_info_sp)
@@ -650,7 +670,6 @@ Thread::SetupForResume ()
{
if (GetResumeState() != eStateSuspended)
{
-
// If we're at a breakpoint push the step-over breakpoint plan. Do this before
// telling the current plan it will resume, since we might change what the current
// plan is.
@@ -707,14 +726,17 @@ Thread::ShouldResume (StateType resume_state)
m_discarded_plan_stack.clear();
m_override_should_notify = eLazyBoolCalculate;
- m_temporary_resume_state = resume_state;
+ StateType prev_resume_state = GetTemporaryResumeState();
+
+ SetTemporaryResumeState(resume_state);
lldb::ThreadSP backing_thread_sp (GetBackingThread ());
if (backing_thread_sp)
- backing_thread_sp->m_temporary_resume_state = resume_state;
+ backing_thread_sp->SetTemporaryResumeState(resume_state);
- // Make sure m_stop_info_sp is valid
- GetPrivateStopInfo();
+ // Make sure m_stop_info_sp is valid. Don't do this for threads we suspended in the previous run.
+ if (prev_resume_state != eStateSuspended)
+ GetPrivateStopInfo();
// This is a little dubious, but we are trying to limit how often we actually fetch stop info from
// the target, 'cause that slows down single stepping. So assume that if we got to the point where
@@ -739,7 +761,7 @@ Thread::ShouldResume (StateType resume_state)
{
need_to_resume = plan_ptr->WillResume(resume_state, true);
- while ((plan_ptr = GetPreviousPlan(plan_ptr)) != NULL)
+ while ((plan_ptr = GetPreviousPlan(plan_ptr)) != nullptr)
{
plan_ptr->WillResume (resume_state, false);
}
@@ -804,7 +826,7 @@ Thread::ShouldStop (Event* event_ptr)
// thread caused the process to stop. NOTE: this must take place before
// the plan is moved from the current plan stack to the completed plan
// stack.
- if (ThreadStoppedForAReason() == false)
+ if (!ThreadStoppedForAReason())
{
if (log)
log->Printf ("Thread::%s for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64 ", pc = 0x%16.16" PRIx64 ", should_stop = 0 (ignore since no stop reason)",
@@ -835,7 +857,7 @@ Thread::ShouldStop (Event* event_ptr)
// command on internal breakpoints. If a synchronous stop reason says we should not stop, then we don't have to
// do any more work on this stop.
StopInfoSP private_stop_info (GetPrivateStopInfo());
- if (private_stop_info && private_stop_info->ShouldStopSynchronous(event_ptr) == false)
+ if (private_stop_info && !private_stop_info->ShouldStopSynchronous(event_ptr))
{
if (log)
log->Printf ("StopInfo::ShouldStop async callback says we should not stop, returning ShouldStop of false.");
@@ -868,7 +890,7 @@ Thread::ShouldStop (Event* event_ptr)
// If the current plan doesn't explain the stop, then find one that
// does and let it handle the situation.
ThreadPlan *plan_ptr = current_plan;
- while ((plan_ptr = GetPreviousPlan(plan_ptr)) != NULL)
+ while ((plan_ptr = GetPreviousPlan(plan_ptr)) != nullptr)
{
if (plan_ptr->PlanExplainsStop(event_ptr))
{
@@ -891,17 +913,13 @@ Thread::ShouldStop (Event* event_ptr)
while ((current_plan = GetCurrentPlan()) != prev_plan_ptr);
// Now, if the responsible plan was not "Okay to discard" then we're done,
// otherwise we forward this to the next plan in the stack below.
- if (plan_ptr->IsMasterPlan() && !plan_ptr->OkayToDiscard())
- done_processing_current_plan = true;
- else
- done_processing_current_plan = false;
+ done_processing_current_plan = (plan_ptr->IsMasterPlan() && !plan_ptr->OkayToDiscard());
}
else
done_processing_current_plan = true;
break;
}
-
}
}
}
@@ -949,11 +967,10 @@ Thread::ShouldStop (Event* event_ptr)
}
else
{
-
PopPlan();
current_plan = GetCurrentPlan();
- if (current_plan == NULL)
+ if (current_plan == nullptr)
{
break;
}
@@ -968,7 +985,6 @@ Thread::ShouldStop (Event* event_ptr)
if (over_ride_stop)
should_stop = false;
-
}
// One other potential problem is that we set up a master plan, then stop in before it is complete - for instance
@@ -1103,10 +1119,7 @@ Thread::ShouldReportRun (Event* event_ptr)
bool
Thread::MatchesSpec (const ThreadSpec *spec)
{
- if (spec == NULL)
- return true;
-
- return spec->ThreadPassesBasicTests(*this);
+ return (spec == nullptr) ? true : spec->ThreadPassesBasicTests(*this);
}
void
@@ -1174,9 +1187,7 @@ Thread::GetCurrentPlan ()
{
// There will always be at least the base plan. If somebody is mucking with a
// thread with an empty plan stack, we should assert right away.
- if (m_plan_stack.empty())
- return NULL;
- return m_plan_stack.back().get();
+ return m_plan_stack.empty() ? nullptr : m_plan_stack.back().get();
}
ThreadPlanSP
@@ -1212,20 +1223,20 @@ Thread::GetReturnValueObject ()
return ValueObjectSP();
}
-ClangExpressionVariableSP
+ExpressionVariableSP
Thread::GetExpressionVariable ()
{
if (!m_completed_plan_stack.empty())
{
for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--)
{
- ClangExpressionVariableSP expression_variable_sp;
+ ExpressionVariableSP expression_variable_sp;
expression_variable_sp = m_completed_plan_stack[i]->GetExpressionVariable();
if (expression_variable_sp)
return expression_variable_sp;
}
}
- return ClangExpressionVariableSP();
+ return ExpressionVariableSP();
}
bool
@@ -1259,8 +1270,8 @@ Thread::WasThreadPlanDiscarded (ThreadPlan *plan)
ThreadPlan *
Thread::GetPreviousPlan (ThreadPlan *current_plan)
{
- if (current_plan == NULL)
- return NULL;
+ if (current_plan == nullptr)
+ return nullptr;
int stack_size = m_completed_plan_stack.size();
for (int i = stack_size - 1; i > 0; i--)
@@ -1271,10 +1282,7 @@ Thread::GetPreviousPlan (ThreadPlan *current_plan)
if (stack_size > 0 && m_completed_plan_stack[0].get() == current_plan)
{
- if (m_plan_stack.size() > 0)
- return m_plan_stack.back().get();
- else
- return NULL;
+ return GetCurrentPlan();
}
stack_size = m_plan_stack.size();
@@ -1283,7 +1291,7 @@ Thread::GetPreviousPlan (ThreadPlan *current_plan)
if (current_plan == m_plan_stack[i].get())
return m_plan_stack[i-1].get();
}
- return NULL;
+ return nullptr;
}
void
@@ -1295,7 +1303,6 @@ Thread::QueueThreadPlan (ThreadPlanSP &thread_plan_sp, bool abort_other_plans)
PushPlan (thread_plan_sp);
}
-
void
Thread::EnableTracer (bool value, bool single_stepping)
{
@@ -1346,7 +1353,6 @@ Thread::DiscardUserThreadPlansUpToIndex (uint32_t thread_index)
DiscardThreadPlansUpToPlan(up_to_plan_ptr);
return true;
}
-
void
Thread::DiscardThreadPlansUpToPlan (lldb::ThreadPlanSP &up_to_plan_sp)
@@ -1364,10 +1370,10 @@ Thread::DiscardThreadPlansUpToPlan (ThreadPlan *up_to_plan_ptr)
int stack_size = m_plan_stack.size();
- // If the input plan is NULL, discard all plans. Otherwise make sure this plan is in the
+ // If the input plan is nullptr, discard all plans. Otherwise make sure this plan is in the
// stack, and if so discard up to and including it.
- if (up_to_plan_ptr == NULL)
+ if (up_to_plan_ptr == nullptr)
{
for (int i = stack_size - 1; i > 0; i--)
DiscardPlan();
@@ -1391,7 +1397,6 @@ Thread::DiscardThreadPlansUpToPlan (ThreadPlan *up_to_plan_ptr)
}
}
}
- return;
}
void
@@ -1415,7 +1420,6 @@ Thread::DiscardThreadPlans(bool force)
while (1)
{
-
int master_plan_idx;
bool discard = true;
@@ -1434,7 +1438,6 @@ Thread::DiscardThreadPlans(bool force)
// First pop all the dependent plans:
for (int i = m_plan_stack.size() - 1; i > master_plan_idx; i--)
{
-
// FIXME: Do we need a finalize here, or is the rule that "PrepareForStop"
// for the plan leaves it in a state that it is safe to pop the plan
// with no more notice?
@@ -1454,7 +1457,6 @@ Thread::DiscardThreadPlans(bool force)
// If the master plan doesn't want to get discarded, then we're done.
break;
}
-
}
}
@@ -1475,7 +1477,7 @@ Thread::UnwindInnermostExpression()
Error error;
int stack_size = m_plan_stack.size();
- // If the input plan is NULL, discard all plans. Otherwise make sure this plan is in the
+ // If the input plan is nullptr, discard all plans. Otherwise make sure this plan is in the
// stack, and if so discard up to and including it.
for (int i = stack_size - 1; i > 0; i--)
@@ -1490,7 +1492,6 @@ Thread::UnwindInnermostExpression()
return error;
}
-
ThreadPlanSP
Thread::QueueFundamentalPlan (bool abort_other_plans)
{
@@ -1500,12 +1501,9 @@ Thread::QueueFundamentalPlan (bool abort_other_plans)
}
ThreadPlanSP
-Thread::QueueThreadPlanForStepSingleInstruction
-(
- bool step_over,
- bool abort_other_plans,
- bool stop_other_threads
-)
+Thread::QueueThreadPlanForStepSingleInstruction(bool step_over,
+ bool abort_other_plans,
+ bool stop_other_threads)
{
ThreadPlanSP thread_plan_sp (new ThreadPlanStepInstruction (*this, step_over, stop_other_threads, eVoteNoOpinion, eVoteNoOpinion));
QueueThreadPlan (thread_plan_sp, abort_other_plans);
@@ -1513,14 +1511,11 @@ Thread::QueueThreadPlanForStepSingleInstruction
}
ThreadPlanSP
-Thread::QueueThreadPlanForStepOverRange
-(
- bool abort_other_plans,
- const AddressRange &range,
- const SymbolContext &addr_context,
- lldb::RunMode stop_other_threads,
- LazyBool step_out_avoids_code_withoug_debug_info
-)
+Thread::QueueThreadPlanForStepOverRange(bool abort_other_plans,
+ const AddressRange &range,
+ const SymbolContext &addr_context,
+ lldb::RunMode stop_other_threads,
+ LazyBool step_out_avoids_code_withoug_debug_info)
{
ThreadPlanSP thread_plan_sp;
thread_plan_sp.reset (new ThreadPlanStepOverRange (*this, range, addr_context, stop_other_threads, step_out_avoids_code_withoug_debug_info));
@@ -1529,17 +1524,29 @@ Thread::QueueThreadPlanForStepOverRange
return thread_plan_sp;
}
+// Call the QueueThreadPlanForStepOverRange method which takes an address range.
ThreadPlanSP
-Thread::QueueThreadPlanForStepInRange
-(
- bool abort_other_plans,
- const AddressRange &range,
- const SymbolContext &addr_context,
- const char *step_in_target,
- lldb::RunMode stop_other_threads,
- LazyBool step_in_avoids_code_without_debug_info,
- LazyBool step_out_avoids_code_without_debug_info
-)
+Thread::QueueThreadPlanForStepOverRange(bool abort_other_plans,
+ const LineEntry &line_entry,
+ const SymbolContext &addr_context,
+ lldb::RunMode stop_other_threads,
+ LazyBool step_out_avoids_code_withoug_debug_info)
+{
+ return QueueThreadPlanForStepOverRange (abort_other_plans,
+ line_entry.GetSameLineContiguousAddressRange(),
+ addr_context,
+ stop_other_threads,
+ step_out_avoids_code_withoug_debug_info);
+}
+
+ThreadPlanSP
+Thread::QueueThreadPlanForStepInRange(bool abort_other_plans,
+ const AddressRange &range,
+ const SymbolContext &addr_context,
+ const char *step_in_target,
+ lldb::RunMode stop_other_threads,
+ LazyBool step_in_avoids_code_without_debug_info,
+ LazyBool step_out_avoids_code_without_debug_info)
{
ThreadPlanSP thread_plan_sp (new ThreadPlanStepInRange (*this,
range,
@@ -1556,19 +1563,35 @@ Thread::QueueThreadPlanForStepInRange
return thread_plan_sp;
}
+// Call the QueueThreadPlanForStepInRange method which takes an address range.
+ThreadPlanSP
+Thread::QueueThreadPlanForStepInRange(bool abort_other_plans,
+ const LineEntry &line_entry,
+ const SymbolContext &addr_context,
+ const char *step_in_target,
+ lldb::RunMode stop_other_threads,
+ LazyBool step_in_avoids_code_without_debug_info,
+ LazyBool step_out_avoids_code_without_debug_info)
+{
+ return QueueThreadPlanForStepInRange (abort_other_plans,
+ line_entry.GetSameLineContiguousAddressRange(),
+ addr_context,
+ step_in_target,
+ stop_other_threads,
+ step_in_avoids_code_without_debug_info,
+ step_out_avoids_code_without_debug_info);
+}
+
ThreadPlanSP
-Thread::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,
- LazyBool step_out_avoids_code_withoug_debug_info
-)
+Thread::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,
+ LazyBool step_out_avoids_code_withoug_debug_info)
{
ThreadPlanSP thread_plan_sp (new ThreadPlanStepOut (*this,
addr_context,
@@ -1579,7 +1602,7 @@ Thread::QueueThreadPlanForStepOut
frame_idx,
step_out_avoids_code_withoug_debug_info));
- if (thread_plan_sp->ValidatePlan(NULL))
+ if (thread_plan_sp->ValidatePlan(nullptr))
{
QueueThreadPlan (thread_plan_sp, abort_other_plans);
return thread_plan_sp;
@@ -1591,16 +1614,13 @@ Thread::QueueThreadPlanForStepOut
}
ThreadPlanSP
-Thread::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
-)
+Thread::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)
{
ThreadPlanSP thread_plan_sp(new ThreadPlanStepOut (*this,
addr_context,
@@ -1614,7 +1634,7 @@ Thread::QueueThreadPlanForStepOutNoShouldStop
ThreadPlanStepOut *new_plan = static_cast<ThreadPlanStepOut *>(thread_plan_sp.get());
new_plan->ClearShouldStopHereCallbacks();
- if (thread_plan_sp->ValidatePlan(NULL))
+ if (thread_plan_sp->ValidatePlan(nullptr))
{
QueueThreadPlan (thread_plan_sp, abort_other_plans);
return thread_plan_sp;
@@ -1629,7 +1649,7 @@ ThreadPlanSP
Thread::QueueThreadPlanForStepThrough (StackID &return_stack_id, bool abort_other_plans, bool stop_other_threads)
{
ThreadPlanSP thread_plan_sp(new ThreadPlanStepThrough (*this, return_stack_id, stop_other_threads));
- if (!thread_plan_sp || !thread_plan_sp->ValidatePlan (NULL))
+ if (!thread_plan_sp || !thread_plan_sp->ValidatePlan(nullptr))
return ThreadPlanSP();
QueueThreadPlan (thread_plan_sp, abort_other_plans);
@@ -1677,7 +1697,6 @@ Thread::QueueThreadPlanForStepScripted (bool abort_other_plans,
}
else
return thread_plan_sp;
-
}
uint32_t
@@ -1768,7 +1787,6 @@ Thread::CalculateTarget ()
if (process_sp)
target_sp = process_sp->CalculateTarget();
return target_sp;
-
}
ProcessSP
@@ -1795,7 +1813,6 @@ Thread::CalculateExecutionContext (ExecutionContext &exe_ctx)
exe_ctx.SetContext (shared_from_this());
}
-
StackFrameListSP
Thread::GetStackFrameList ()
{
@@ -1839,7 +1856,6 @@ Thread::GetFrameWithConcreteFrameIndex (uint32_t unwind_idx)
return GetStackFrameList()->GetFrameWithConcreteFrameIndex (unwind_idx);
}
-
Error
Thread::ReturnFromFrameWithIndex (uint32_t frame_idx, lldb::ValueObjectSP return_value_sp, bool broadcast)
{
@@ -1886,12 +1902,12 @@ Thread::ReturnFromFrame (lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return
// 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 != NULL)
+ if (/* DISABLES CODE */ (0) && sc.function != nullptr)
{
Type *function_type = sc.function->GetType();
if (function_type)
{
- ClangASTType return_type = sc.function->GetClangType().GetFunctionReturnType();
+ CompilerType return_type = sc.function->GetCompilerType().GetFunctionReturnType();
if (return_type)
{
StreamString s;
@@ -2024,7 +2040,7 @@ Thread::DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx)
{
ExecutionContext exe_ctx (shared_from_this());
Process *process = exe_ctx.GetProcessPtr();
- if (process == NULL)
+ if (process == nullptr)
return;
StackFrameSP frame_sp;
@@ -2044,10 +2060,10 @@ Thread::DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx)
FormatEntity::Format(*thread_format,
strm,
- frame_sp ? &frame_sc : NULL,
+ frame_sp ? &frame_sc : nullptr,
&exe_ctx,
- NULL,
- NULL,
+ nullptr,
+ nullptr,
false,
false);
}
@@ -2119,7 +2135,6 @@ Thread::StopReasonAsCString (lldb::StopReason reason)
case eStopReasonInstrumentation: return "instrumentation break";
}
-
static char unknown_state_string[64];
snprintf(unknown_state_string, sizeof (unknown_state_string), "StopReason = %i", reason);
return unknown_state_string;
@@ -2176,7 +2191,7 @@ Thread::GetStatus (Stream &strm, uint32_t start_frame, uint32_t num_frames, uint
const bool show_frame_info = true;
- const char *selected_frame_marker = NULL;
+ const char *selected_frame_marker = nullptr;
if (num_frames == 1 || (GetID() != GetProcess()->GetThreadList().GetSelectedThread()->GetID()))
strm.IndentMore ();
else
@@ -2302,7 +2317,7 @@ Thread::GetStackFrameStatus (Stream& strm,
Unwind *
Thread::GetUnwinder ()
{
- if (m_unwinder_ap.get() == NULL)
+ if (!m_unwinder_ap)
{
const ArchSpec target_arch (CalculateTarget()->GetArchitecture ());
const llvm::Triple::ArchType machine = target_arch.GetMachine();
@@ -2332,7 +2347,6 @@ Thread::GetUnwinder ()
return m_unwinder_ap.get();
}
-
void
Thread::Flush ()
{
@@ -2364,7 +2378,6 @@ Thread::IsStillAtLastBreakpointHit ()
return false;
}
-
Error
Thread::StepIn (bool source_step,
LazyBool step_in_avoids_code_without_debug_info,
@@ -2383,13 +2396,13 @@ Thread::StepIn (bool source_step,
if (source_step && frame_sp && frame_sp->HasDebugInformation ())
{
SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
- new_plan_sp = QueueThreadPlanForStepInRange (abort_other_plans,
- sc.line_entry.range,
- sc,
- NULL,
- run_mode,
- step_in_avoids_code_without_debug_info,
- step_out_avoids_code_without_debug_info);
+ new_plan_sp = QueueThreadPlanForStepInRange(abort_other_plans,
+ sc.line_entry,
+ sc,
+ nullptr,
+ run_mode,
+ step_in_avoids_code_without_debug_info,
+ step_out_avoids_code_without_debug_info);
}
else
{
@@ -2430,7 +2443,7 @@ Thread::StepOver (bool source_step,
{
SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
new_plan_sp = QueueThreadPlanForStepOverRange (abort_other_plans,
- sc.line_entry.range,
+ sc.line_entry,
sc,
run_mode,
step_out_avoids_code_without_debug_info);
@@ -2467,13 +2480,13 @@ Thread::StepOut ()
const bool stop_other_threads = false;
const bool abort_other_plans = false;
- ThreadPlanSP new_plan_sp(QueueThreadPlanForStepOut (abort_other_plans,
- NULL,
- first_instruction,
- stop_other_threads,
- eVoteYes,
- eVoteNoOpinion,
- 0));
+ ThreadPlanSP new_plan_sp(QueueThreadPlanForStepOut(abort_other_plans,
+ nullptr,
+ first_instruction,
+ stop_other_threads,
+ eVoteYes,
+ eVoteNoOpinion,
+ 0));
new_plan_sp->SetIsMasterPlan(true);
new_plan_sp->SetOkayToDiscard(false);
diff --git a/source/Target/ThreadList.cpp b/source/Target/ThreadList.cpp
index d581a7c96060..a34cb0fa143a 100644
--- a/source/Target/ThreadList.cpp
+++ b/source/Target/ThreadList.cpp
@@ -6,10 +6,15 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
+
+// C Includes
#include <stdlib.h>
+// C++ Includes
#include <algorithm>
+// Other libraries and framework includes
+// Project includes
#include "lldb/Core/Log.h"
#include "lldb/Core/State.h"
#include "lldb/Target/RegisterContext.h"
@@ -18,6 +23,7 @@
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/Process.h"
#include "lldb/Utility/ConvertEnum.h"
+#include "lldb/Utility/LLDBAssert.h"
using namespace lldb;
using namespace lldb_private;
@@ -46,7 +52,7 @@ ThreadList::operator = (const ThreadList& rhs)
if (this != &rhs)
{
// Lock both mutexes to make sure neither side changes anyone on us
- // while the assignement occurs
+ // while the assignment occurs
Mutex::Locker locker(GetMutex());
m_process = rhs.m_process;
m_stop_id = rhs.m_stop_id;
@@ -257,7 +263,24 @@ ThreadList::ShouldStop (Event *event_ptr)
Mutex::Locker locker(GetMutex());
m_process->UpdateThreadListIfNeeded();
- threads_copy = m_threads;
+ for (lldb::ThreadSP thread_sp : m_threads)
+ {
+ // This is an optimization... If we didn't let a thread run in between the previous stop and this
+ // one, we shouldn't have to consult it for ShouldStop. So just leave it off the list we are going to
+ // inspect.
+ // On Linux, if a thread-specific conditional breakpoint was hit, it won't necessarily be the thread
+ // that hit the breakpoint itself that evaluates the conditional expression, so the thread that hit
+ // the breakpoint could still be asked to stop, even though it hasn't been allowed to run since the
+ // previous stop.
+ if (thread_sp->GetTemporaryResumeState () != eStateSuspended || thread_sp->IsStillAtLastBreakpointHit())
+ threads_copy.push_back(thread_sp);
+ }
+
+ // It is possible the threads we were allowing to run all exited and then maybe the user interrupted
+ // or something, then fall back on looking at all threads:
+
+ if (threads_copy.size() == 0)
+ threads_copy = m_threads;
}
collection::iterator pos, end = threads_copy.end();
@@ -265,7 +288,10 @@ ThreadList::ShouldStop (Event *event_ptr)
if (log)
{
log->PutCString("");
- log->Printf ("ThreadList::%s: %" PRIu64 " threads", __FUNCTION__, (uint64_t)m_threads.size());
+ log->Printf ("ThreadList::%s: %" PRIu64 " threads, %" PRIu64 " unsuspended threads",
+ __FUNCTION__,
+ (uint64_t)m_threads.size(),
+ (uint64_t)threads_copy.size());
}
bool did_anybody_stop_for_a_reason = false;
@@ -518,6 +544,7 @@ ThreadList::WillResume ()
for (pos = m_threads.begin(); pos != end; ++pos)
{
+ lldbassert((*pos)->GetCurrentPlan() && "thread should not have null thread plan");
if ((*pos)->GetResumeState() != eStateSuspended &&
(*pos)->GetCurrentPlan()->StopOthers())
{
@@ -750,7 +777,7 @@ ThreadList::Update (ThreadList &rhs)
if (this != &rhs)
{
// Lock both mutexes to make sure neither side changes anyone on us
- // while the assignement occurs
+ // while the assignment occurs
Mutex::Locker locker(GetMutex());
m_process = rhs.m_process;
m_stop_id = rhs.m_stop_id;
@@ -773,7 +800,8 @@ ThreadList::Update (ThreadList &rhs)
const uint32_t num_threads = m_threads.size();
for (uint32_t idx = 0; idx < num_threads; ++idx)
{
- if (m_threads[idx]->GetID() == tid)
+ ThreadSP backing_thread = m_threads[idx]->GetBackingThread();
+ if (m_threads[idx]->GetID() == tid || (backing_thread && backing_thread->GetID() == tid))
{
thread_is_alive = true;
break;
diff --git a/source/Target/ThreadPlan.cpp b/source/Target/ThreadPlan.cpp
index 094a6bff3722..24323337accb 100644
--- a/source/Target/ThreadPlan.cpp
+++ b/source/Target/ThreadPlan.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/ThreadPlan.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/ThreadPlan.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/State.h"
@@ -48,9 +47,7 @@ ThreadPlan::ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread, Vo
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-ThreadPlan::~ThreadPlan()
-{
-}
+ThreadPlan::~ThreadPlan() = default;
bool
ThreadPlan::PlanExplainsStop (Event *event_ptr)
@@ -130,10 +127,7 @@ ThreadPlan::StopOthers ()
{
ThreadPlan *prev_plan;
prev_plan = GetPreviousPlan ();
- if (prev_plan == NULL)
- return false;
- else
- return prev_plan->StopOthers();
+ return (prev_plan == nullptr) ? false : prev_plan->StopOthers();
}
void
@@ -191,10 +185,7 @@ ThreadPlan::WillPop()
bool
ThreadPlan::OkayToDiscard()
{
- if (!IsMasterPlan())
- return true;
- else
- return m_okay_to_discard;
+ return IsMasterPlan() ? m_okay_to_discard : true;
}
lldb::StateType
@@ -206,6 +197,23 @@ ThreadPlan::RunState ()
return GetPlanRunState();
}
+bool
+ThreadPlan::IsUsuallyUnexplainedStopReason(lldb::StopReason reason)
+{
+ switch (reason)
+ {
+ case eStopReasonWatchpoint:
+ case eStopReasonSignal:
+ case eStopReasonException:
+ case eStopReasonExec:
+ case eStopReasonThreadExiting:
+ case eStopReasonInstrumentation:
+ return true;
+ default:
+ return false;
+ }
+}
+
//----------------------------------------------------------------------
// ThreadPlanNull
//----------------------------------------------------------------------
@@ -219,9 +227,7 @@ ThreadPlanNull::ThreadPlanNull (Thread &thread) :
{
}
-ThreadPlanNull::~ThreadPlanNull ()
-{
-}
+ThreadPlanNull::~ThreadPlanNull() = default;
void
ThreadPlanNull::GetDescription (Stream *s,
diff --git a/source/Target/ThreadPlanCallFunction.cpp b/source/Target/ThreadPlanCallFunction.cpp
index e7b3abd3c941..01ca1267dd92 100644
--- a/source/Target/ThreadPlanCallFunction.cpp
+++ b/source/Target/ThreadPlanCallFunction.cpp
@@ -7,13 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/ThreadPlanCallFunction.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
-
// Project includes
+#include "lldb/Target/ThreadPlanCallFunction.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Address.h"
@@ -76,7 +74,7 @@ ThreadPlanCallFunction::ConstructorSetup (Thread &thread,
Module *exe_module = GetTarget().GetExecutableModulePointer();
- if (exe_module == NULL)
+ if (exe_module == nullptr)
{
m_constructor_errors.Printf ("Can't execute code without an executable module.");
if (log)
@@ -135,7 +133,7 @@ ThreadPlanCallFunction::ConstructorSetup (Thread &thread,
ThreadPlanCallFunction::ThreadPlanCallFunction (Thread &thread,
const Address &function,
- const ClangASTType &return_type,
+ const CompilerType &return_type,
llvm::ArrayRef<addr_t> args,
const EvaluateExpressionOptions &options) :
ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion),
@@ -188,9 +186,8 @@ ThreadPlanCallFunction::ThreadPlanCallFunction(Thread &thread,
m_should_clear_objc_exception_bp(false),
m_should_clear_cxx_exception_bp(false),
m_stop_address(LLDB_INVALID_ADDRESS),
- m_return_type(ClangASTType())
+ m_return_type(CompilerType())
{
-
}
ThreadPlanCallFunction::~ThreadPlanCallFunction ()
@@ -263,7 +260,6 @@ ThreadPlanCallFunction::DoTakedown (bool success)
ClearBreakpoints();
if (log && log->GetVerbose())
ReportRegisterState ("Restoring thread state after function call. Restored register state:");
-
}
else
{
@@ -312,7 +308,6 @@ ThreadPlanCallFunction::ValidatePlan (Stream *error)
return true;
}
-
Vote
ThreadPlanCallFunction::ShouldReportStop(Event *event_ptr)
{
@@ -330,7 +325,7 @@ ThreadPlanCallFunction::DoPlanExplainsStop (Event *event_ptr)
// If our subplan knows why we stopped, even if it's done (which would forward the question to us)
// we answer yes.
- if (m_subplan_sp.get() != NULL && m_subplan_sp->PlanExplainsStop(event_ptr))
+ if (m_subplan_sp && m_subplan_sp->PlanExplainsStop(event_ptr))
{
SetPlanComplete();
return true;
@@ -360,8 +355,7 @@ ThreadPlanCallFunction::DoPlanExplainsStop (Event *event_ptr)
// We control breakpoints separately from other "stop reasons." So first,
// check the case where we stopped for an internal breakpoint, in that case, continue on.
// If it is not an internal breakpoint, consult m_ignore_breakpoints.
-
-
+
if (stop_reason == eStopReasonBreakpoint)
{
ProcessSP process_sp (m_thread.CalculateProcess());
@@ -426,15 +420,7 @@ ThreadPlanCallFunction::DoPlanExplainsStop (Event *event_ptr)
if (m_real_stop_info_sp && m_real_stop_info_sp->ShouldStopSynchronous(event_ptr))
{
SetPlanComplete(false);
- if (m_subplan_sp)
- {
- if (m_unwind_on_error)
- return true;
- else
- return false;
- }
- else
- return false;
+ return m_subplan_sp ? m_unwind_on_error : false;
}
else
return true;
@@ -583,19 +569,17 @@ ThreadPlanCallFunction::SetStopOthers (bool new_value)
m_subplan_sp->SetStopOthers(new_value);
}
-
bool
ThreadPlanCallFunction::RestoreThreadState()
{
return GetThread().RestoreThreadStateFromCheckpoint(m_stored_thread_state);
}
-
void
ThreadPlanCallFunction::SetReturnValue()
{
ProcessSP process_sp(m_thread.GetProcess());
- const ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
+ const ABI *abi = process_sp ? process_sp->GetABI().get() : nullptr;
if (abi && m_return_type.IsValid())
{
const bool persistent = false;
diff --git a/source/Target/ThreadPlanCallFunctionUsingABI.cpp b/source/Target/ThreadPlanCallFunctionUsingABI.cpp
index 53fabd2464e6..df23edc0fd14 100644
--- a/source/Target/ThreadPlanCallFunctionUsingABI.cpp
+++ b/source/Target/ThreadPlanCallFunctionUsingABI.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadPlanCallFunctionUsingABI.cpp ------------------------------*- C++ -*-===//
+//===-- ThreadPlanCallFunctionUsingABI.cpp ----------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,13 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/ThreadPlanCallFunctionUsingABI.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
-
// Project includes
+#include "lldb/Target/ThreadPlanCallFunctionUsingABI.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Stream.h"
@@ -57,10 +55,7 @@ ThreadPlanCallFunctionUsingABI::ThreadPlanCallFunctionUsingABI (Thread &thread,
m_valid = true;
}
-ThreadPlanCallFunctionUsingABI::~ThreadPlanCallFunctionUsingABI()
-{
-
-}
+ThreadPlanCallFunctionUsingABI::~ThreadPlanCallFunctionUsingABI() = default;
void
ThreadPlanCallFunctionUsingABI::GetDescription(Stream *s, DescriptionLevel level)
@@ -80,7 +75,7 @@ void
ThreadPlanCallFunctionUsingABI::SetReturnValue()
{
ProcessSP process_sp(m_thread.GetProcess());
- const ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
+ const ABI *abi = process_sp ? process_sp->GetABI().get() : nullptr;
// Ask the abi for the return value
if (abi)
diff --git a/source/Target/ThreadPlanCallUserExpression.cpp b/source/Target/ThreadPlanCallUserExpression.cpp
index 1773777cc4da..b24f74b10dfa 100644
--- a/source/Target/ThreadPlanCallUserExpression.cpp
+++ b/source/Target/ThreadPlanCallUserExpression.cpp
@@ -19,7 +19,7 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Stream.h"
-#include "lldb/Expression/ClangUserExpression.h"
+#include "lldb/Expression/UserExpression.h"
#include "lldb/Expression/IRDynamicChecks.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Target/LanguageRuntime.h"
@@ -41,8 +41,8 @@ ThreadPlanCallUserExpression::ThreadPlanCallUserExpression (Thread &thread,
Address &function,
llvm::ArrayRef<lldb::addr_t> args,
const EvaluateExpressionOptions &options,
- lldb::ClangUserExpressionSP &user_expression_sp) :
- ThreadPlanCallFunction (thread, function, ClangASTType(), args, options),
+ lldb::UserExpressionSP &user_expression_sp) :
+ ThreadPlanCallFunction (thread, function, CompilerType(), args, options),
m_user_expression_sp (user_expression_sp)
{
// User expressions are generally "User generated" so we should set them up to stop when done.
diff --git a/source/Target/ThreadPlanRunToAddress.cpp b/source/Target/ThreadPlanRunToAddress.cpp
index 54ae1dc22981..18c43dafd7b3 100644
--- a/source/Target/ThreadPlanRunToAddress.cpp
+++ b/source/Target/ThreadPlanRunToAddress.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/ThreadPlanRunToAddress.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/ThreadPlanRunToAddress.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Stream.h"
#include "lldb/Target/Target.h"
@@ -88,7 +87,7 @@ ThreadPlanRunToAddress::SetInitialBreakpoints ()
{
Breakpoint *breakpoint;
breakpoint = m_thread.CalculateTarget()->CreateBreakpoint (m_addresses[i], true, false).get();
- if (breakpoint != NULL)
+ if (breakpoint != nullptr)
{
m_break_ids[i] = breakpoint->GetID();
breakpoint->SetThreadID(m_thread.GetID());
@@ -195,7 +194,7 @@ ThreadPlanRunToAddress::DoPlanExplainsStop (Event *event_ptr)
bool
ThreadPlanRunToAddress::ShouldStop (Event *event_ptr)
{
- return false;
+ return AtOurAddress();
}
bool
diff --git a/source/Target/ThreadPlanShouldStopHere.cpp b/source/Target/ThreadPlanShouldStopHere.cpp
index e89f5d2bde1b..88f8db2bd7e7 100644
--- a/source/Target/ThreadPlanShouldStopHere.cpp
+++ b/source/Target/ThreadPlanShouldStopHere.cpp
@@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanShouldStopHere.h"
@@ -15,19 +19,14 @@
using namespace lldb;
using namespace lldb_private;
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-
//----------------------------------------------------------------------
// ThreadPlanShouldStopHere constructor
//----------------------------------------------------------------------
ThreadPlanShouldStopHere::ThreadPlanShouldStopHere(ThreadPlan *owner) :
- m_callbacks (),
- m_baton (NULL),
- m_owner (owner),
- m_flags (ThreadPlanShouldStopHere::eNone)
+ m_callbacks(),
+ m_baton(nullptr),
+ m_owner(owner),
+ m_flags(ThreadPlanShouldStopHere::eNone)
{
m_callbacks.should_stop_here_callback = ThreadPlanShouldStopHere::DefaultShouldStopHereCallback;
m_callbacks.step_from_here_callback = ThreadPlanShouldStopHere::DefaultStepFromHereCallback;
@@ -42,12 +41,7 @@ ThreadPlanShouldStopHere::ThreadPlanShouldStopHere(ThreadPlan *owner, const Thre
SetShouldStopHereCallbacks(callbacks, baton);
}
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-ThreadPlanShouldStopHere::~ThreadPlanShouldStopHere()
-{
-}
+ThreadPlanShouldStopHere::~ThreadPlanShouldStopHere() = default;
bool
ThreadPlanShouldStopHere::InvokeShouldStopHereCallback (FrameComparison operation)
@@ -135,13 +129,13 @@ ThreadPlanShouldStopHere::DefaultStepFromHereCallback (ThreadPlan *current_plan,
}
if (!return_plan_sp)
- return_plan_sp = current_plan->GetThread().QueueThreadPlanForStepOutNoShouldStop (false,
- NULL,
- true,
- stop_others,
- eVoteNo,
- eVoteNoOpinion,
- frame_index);
+ return_plan_sp = current_plan->GetThread().QueueThreadPlanForStepOutNoShouldStop(false,
+ nullptr,
+ true,
+ stop_others,
+ eVoteNo,
+ eVoteNoOpinion,
+ frame_index);
return return_plan_sp;
}
@@ -154,7 +148,6 @@ ThreadPlanShouldStopHere::QueueStepOutFromHerePlan(lldb_private::Flags &flags, l
return_plan_sp = m_callbacks.step_from_here_callback (m_owner, flags, operation, m_baton);
}
return return_plan_sp;
-
}
lldb::ThreadPlanSP
@@ -165,4 +158,3 @@ ThreadPlanShouldStopHere::CheckShouldStopHereAndQueueStepOut (lldb::FrameCompari
else
return ThreadPlanSP();
}
-
diff --git a/source/Target/ThreadPlanStepInRange.cpp b/source/Target/ThreadPlanStepInRange.cpp
index 3ee57928b1db..3771e210c1a4 100644
--- a/source/Target/ThreadPlanStepInRange.cpp
+++ b/source/Target/ThreadPlanStepInRange.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/ThreadPlanStepInRange.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/ThreadPlanStepInRange.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Stream.h"
@@ -76,9 +75,7 @@ ThreadPlanStepInRange::ThreadPlanStepInRange
SetupAvoidNoDebug(step_in_avoids_code_without_debug_info, step_out_avoids_code_without_debug_info);
}
-ThreadPlanStepInRange::~ThreadPlanStepInRange ()
-{
-}
+ThreadPlanStepInRange::~ThreadPlanStepInRange() = default;
void
ThreadPlanStepInRange::SetupAvoidNoDebug(LazyBool step_in_avoids_code_without_debug_info,
@@ -193,11 +190,7 @@ ThreadPlanStepInRange::ShouldStop (Event *event_ptr)
// Stepping through should be done running other threads in general, since we're setting a breakpoint and
// continuing. So only stop others if we are explicitly told to do so.
- bool stop_others;
- if (m_stop_others == lldb::eOnlyThisThread)
- stop_others = true;
- else
- stop_others = false;
+ bool stop_others = (m_stop_others == lldb::eOnlyThisThread);
FrameComparison frame_order = CompareCurrentFrameToStartFrame();
@@ -220,7 +213,6 @@ ThreadPlanStepInRange::ShouldStop (Event *event_ptr)
{
log->Printf("Thought I stepped out, but in fact arrived at a trampoline.");
}
-
}
else if (frame_order == eFrameCompareEqual && InSymbol())
{
@@ -322,7 +314,7 @@ ThreadPlanStepInRange::ShouldStop (Event *event_ptr)
void
ThreadPlanStepInRange::SetAvoidRegexp(const char *name)
{
- if (m_avoid_regexp_ap.get() == NULL)
+ if (!m_avoid_regexp_ap)
m_avoid_regexp_ap.reset (new RegularExpression(name));
m_avoid_regexp_ap->Compile (name);
@@ -367,15 +359,15 @@ ThreadPlanStepInRange::FrameMatchesAvoidCriteria ()
return true;
const RegularExpression *avoid_regexp_to_use = m_avoid_regexp_ap.get();
- if (avoid_regexp_to_use == NULL)
+ if (avoid_regexp_to_use == nullptr)
avoid_regexp_to_use = GetThread().GetSymbolsToAvoidRegexp();
- if (avoid_regexp_to_use != NULL)
+ if (avoid_regexp_to_use != nullptr)
{
SymbolContext sc = frame->GetSymbolContext(eSymbolContextFunction|eSymbolContextBlock|eSymbolContextSymbol);
- if (sc.symbol != NULL)
+ if (sc.symbol != nullptr)
{
- const char *frame_function_name = sc.GetFunctionName().GetCString();
+ const char *frame_function_name = sc.GetFunctionName(Mangled::ePreferDemangledWithoutArguments).GetCString();
if (frame_function_name)
{
size_t num_matches = 0;
@@ -424,7 +416,7 @@ ThreadPlanStepInRange::DefaultShouldStopHereCallback (ThreadPlan *current_plan,
if (step_in_range_plan->m_step_into_target)
{
SymbolContext sc = frame->GetSymbolContext(eSymbolContextFunction|eSymbolContextBlock|eSymbolContextSymbol);
- if (sc.symbol != NULL)
+ if (sc.symbol != nullptr)
{
// First try an exact match, since that's cheap with ConstStrings. Then do a strstr compare.
if (step_in_range_plan->m_step_into_target == sc.GetFunctionName())
@@ -436,9 +428,9 @@ ThreadPlanStepInRange::DefaultShouldStopHereCallback (ThreadPlan *current_plan,
const char *target_name = step_in_range_plan->m_step_into_target.AsCString();
const char *function_name = sc.GetFunctionName().AsCString();
- if (function_name == NULL)
+ if (function_name == nullptr)
should_stop_here = false;
- else if (strstr (function_name, target_name) == NULL)
+ else if (strstr(function_name, target_name) == nullptr)
should_stop_here = false;
}
if (log && !should_stop_here)
@@ -476,7 +468,7 @@ ThreadPlanStepInRange::DoPlanExplainsStop (Event *event_ptr)
// The only variation is that if we are doing "step by running to next branch" in which case
// if we hit our branch breakpoint we don't set the plan to complete.
- bool return_value;
+ bool return_value = false;
if (m_virtual_step)
{
@@ -488,30 +480,24 @@ ThreadPlanStepInRange::DoPlanExplainsStop (Event *event_ptr)
if (stop_info_sp)
{
StopReason reason = stop_info_sp->GetStopReason();
-
- switch (reason)
+
+ if (reason == eStopReasonBreakpoint)
{
- case eStopReasonBreakpoint:
if (NextRangeBreakpointExplainsStop(stop_info_sp))
{
return_value = true;
- break;
- }
- case eStopReasonWatchpoint:
- case eStopReasonSignal:
- case eStopReasonException:
- case eStopReasonExec:
- case eStopReasonThreadExiting:
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
- if (log)
- log->PutCString ("ThreadPlanStepInRange got asked if it explains the stop for some reason other than step.");
}
+ }
+ else if (IsUsuallyUnexplainedStopReason(reason))
+ {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
+ if (log)
+ log->PutCString ("ThreadPlanStepInRange got asked if it explains the stop for some reason other than step.");
return_value = false;
- break;
- default:
+ }
+ else
+ {
return_value = true;
- break;
}
}
else
@@ -549,5 +535,5 @@ ThreadPlanStepInRange::DoWillResume (lldb::StateType resume_state, bool current_
bool
ThreadPlanStepInRange::IsVirtualStep()
{
- return m_virtual_step;
+ return m_virtual_step;
}
diff --git a/source/Target/ThreadPlanStepInstruction.cpp b/source/Target/ThreadPlanStepInstruction.cpp
index 1ce26df78fe6..9d7d52167ffc 100644
--- a/source/Target/ThreadPlanStepInstruction.cpp
+++ b/source/Target/ThreadPlanStepInstruction.cpp
@@ -7,13 +7,11 @@
//
//===----------------------------------------------------------------------===//
-
-#include "lldb/Target/ThreadPlanStepInstruction.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/ThreadPlanStepInstruction.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Stream.h"
#include "lldb/Target/Process.h"
@@ -46,9 +44,7 @@ ThreadPlanStepInstruction::ThreadPlanStepInstruction
SetUpState();
}
-ThreadPlanStepInstruction::~ThreadPlanStepInstruction ()
-{
-}
+ThreadPlanStepInstruction::~ThreadPlanStepInstruction() = default;
void
ThreadPlanStepInstruction::SetUpState()
@@ -57,7 +53,7 @@ ThreadPlanStepInstruction::SetUpState()
StackFrameSP start_frame_sp(m_thread.GetStackFrameAtIndex(0));
m_stack_id = start_frame_sp->GetStackID();
- m_start_has_symbol = start_frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol != NULL;
+ m_start_has_symbol = start_frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol != nullptr;
StackFrameSP parent_frame_sp = m_thread.GetStackFrameAtIndex(1);
if (parent_frame_sp)
@@ -103,10 +99,7 @@ ThreadPlanStepInstruction::DoPlanExplainsStop (Event *event_ptr)
if (stop_info_sp)
{
StopReason reason = stop_info_sp->GetStopReason();
- if (reason == eStopReasonTrace || reason == eStopReasonNone)
- return true;
- else
- return false;
+ return (reason == eStopReasonTrace || reason == eStopReasonNone);
}
return false;
}
@@ -118,19 +111,13 @@ ThreadPlanStepInstruction::IsPlanStale ()
StackID cur_frame_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
if (cur_frame_id == m_stack_id)
{
- if (m_thread.GetRegisterContext()->GetPC(0) != m_instruction_addr)
- return true;
- else
- return false;
+ return (m_thread.GetRegisterContext()->GetPC(0) != m_instruction_addr);
}
else if (cur_frame_id < m_stack_id)
{
// If the current frame is younger than the start frame and we are stepping over, then we need to continue,
// but if we are doing just one step, we're done.
- if (m_step_over)
- return false;
- else
- return true;
+ return !m_step_over;
}
else
{
@@ -222,7 +209,7 @@ ThreadPlanStepInstruction::ShouldStop (Event *event_ptr)
// run others.
const bool stop_others = false;
m_thread.QueueThreadPlanForStepOutNoShouldStop(false,
- NULL,
+ nullptr,
true,
stop_others,
eVoteNo,
@@ -248,9 +235,7 @@ ThreadPlanStepInstruction::ShouldStop (Event *event_ptr)
SetPlanComplete();
return true;
}
-
}
-
}
else
{
@@ -308,4 +293,3 @@ ThreadPlanStepInstruction::MischiefManaged ()
return false;
}
}
-
diff --git a/source/Target/ThreadPlanStepOut.cpp b/source/Target/ThreadPlanStepOut.cpp
index 8b702a20ccd2..92403cb92ed3 100644
--- a/source/Target/ThreadPlanStepOut.cpp
+++ b/source/Target/ThreadPlanStepOut.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/ThreadPlanStepOut.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/ThreadPlanStepOut.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Value.h"
@@ -53,7 +52,7 @@ ThreadPlanStepOut::ThreadPlanStepOut
m_return_bp_id (LLDB_INVALID_BREAK_ID),
m_return_addr (LLDB_INVALID_ADDRESS),
m_stop_others (stop_others),
- m_immediate_step_from_function(NULL)
+ m_immediate_step_from_function(nullptr)
{
SetFlagsToDefault();
SetupAvoidNoDebug(step_out_avoids_code_without_debug_info);
@@ -80,14 +79,14 @@ ThreadPlanStepOut::ThreadPlanStepOut
{
// 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_thread,
- NULL,
- false,
- stop_others,
- eVoteNoOpinion,
- eVoteNoOpinion,
- frame_idx - 1,
- eLazyBoolNo));
+ m_step_out_to_inline_plan_sp.reset(new ThreadPlanStepOut(m_thread,
+ nullptr,
+ false,
+ stop_others,
+ eVoteNoOpinion,
+ eVoteNoOpinion,
+ frame_idx - 1,
+ eLazyBoolNo));
static_cast<ThreadPlanStepOut *>(m_step_out_to_inline_plan_sp.get())->SetShouldStopHereCallbacks(nullptr, nullptr);
m_step_out_to_inline_plan_sp->SetPrivate(true);
}
@@ -96,7 +95,6 @@ ThreadPlanStepOut::ThreadPlanStepOut
// If we're already at the inlined frame we're stepping through, then just do that now.
QueueInlinedStepPlan(false);
}
-
}
else if (return_frame_sp)
{
@@ -109,7 +107,7 @@ ThreadPlanStepOut::ThreadPlanStepOut
return;
Breakpoint *return_bp = m_thread.CalculateTarget()->CreateBreakpoint (m_return_addr, true, false).get();
- if (return_bp != NULL)
+ if (return_bp != nullptr)
{
return_bp->SetThreadID(m_thread.GetID());
m_return_bp_id = return_bp->GetID();
@@ -125,7 +123,6 @@ ThreadPlanStepOut::ThreadPlanStepOut
}
}
}
-
}
void
@@ -192,7 +189,7 @@ ThreadPlanStepOut::GetDescription (Stream *s, lldb::DescriptionLevel level)
// FIXME: find some useful way to present the m_return_id, since there may be multiple copies of the
// same function on the stack.
- s->Printf ("returning to frame at ");
+ s->Printf (" returning to frame at ");
if (tmp_address.SetLoadAddress (m_return_addr, &GetTarget()))
{
tmp_address.Dump(s, &GetThread(), Address::DumpStyleResolvedDescription, Address::DumpStyleLoadAddress);
@@ -231,10 +228,7 @@ ThreadPlanStepOut::DoPlanExplainsStop (Event *event_ptr)
// If the step out plan is done, then we just need to step through the inlined frame.
if (m_step_out_to_inline_plan_sp)
{
- if (m_step_out_to_inline_plan_sp->MischiefManaged())
- return true;
- else
- return false;
+ return m_step_out_to_inline_plan_sp->MischiefManaged();
}
else if (m_step_through_inline_plan_sp)
{
@@ -249,10 +243,7 @@ ThreadPlanStepOut::DoPlanExplainsStop (Event *event_ptr)
}
else if (m_step_out_further_plan_sp)
{
- if (m_step_out_further_plan_sp->MischiefManaged())
- return true;
- else
- return false;
+ return m_step_out_further_plan_sp->MischiefManaged();
}
// We don't explain signals or breakpoints (breakpoints that handle stepping in or
@@ -262,9 +253,7 @@ ThreadPlanStepOut::DoPlanExplainsStop (Event *event_ptr)
if (stop_info_sp)
{
StopReason reason = stop_info_sp->GetStopReason();
- switch (reason)
- {
- case eStopReasonBreakpoint:
+ if (reason == eStopReasonBreakpoint)
{
// If this is OUR breakpoint, we're fine, otherwise we don't know why this happened...
BreakpointSiteSP site_sp (m_thread.GetProcess()->GetBreakpointSiteList().FindByID (stop_info_sp->GetValue()));
@@ -284,10 +273,7 @@ ThreadPlanStepOut::DoPlanExplainsStop (Event *event_ptr)
}
else
{
- if (m_immediate_step_from_id < frame_zero_id)
- done = true;
- else
- done = false;
+ done = (m_immediate_step_from_id < frame_zero_id);
}
if (done)
@@ -306,20 +292,13 @@ ThreadPlanStepOut::DoPlanExplainsStop (Event *event_ptr)
if (site_sp->GetNumberOfOwners() == 1)
return true;
-
}
return false;
}
- case eStopReasonWatchpoint:
- case eStopReasonSignal:
- case eStopReasonException:
- case eStopReasonExec:
- case eStopReasonThreadExiting:
+ else if (IsUsuallyUnexplainedStopReason(reason))
return false;
-
- default:
+ else
return true;
- }
}
return true;
}
@@ -367,10 +346,7 @@ ThreadPlanStepOut::ShouldStop (Event *event_ptr)
if (!done)
{
StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
- if (frame_zero_id < m_step_out_to_id)
- done = false;
- else
- done = true;
+ done = !(frame_zero_id < m_step_out_to_id);
}
// The normal step out computations think we are done, so all we need to do is consult the ShouldStopHere,
@@ -417,7 +393,7 @@ ThreadPlanStepOut::DoWillResume (StateType resume_state, bool current_plan)
if (current_plan)
{
Breakpoint *return_bp = m_thread.CalculateTarget()->GetBreakpointByID(m_return_bp_id).get();
- if (return_bp != NULL)
+ if (return_bp != nullptr)
return_bp->SetEnabled (true);
}
return true;
@@ -429,7 +405,7 @@ ThreadPlanStepOut::WillStop ()
if (m_return_bp_id != LLDB_INVALID_BREAK_ID)
{
Breakpoint *return_bp = m_thread.CalculateTarget()->GetBreakpointByID(m_return_bp_id).get();
- if (return_bp != NULL)
+ if (return_bp != nullptr)
return_bp->SetEnabled (false);
}
@@ -539,14 +515,14 @@ ThreadPlanStepOut::CalculateReturnValue ()
if (m_return_valobj_sp)
return;
- if (m_immediate_step_from_function != NULL)
+ if (m_immediate_step_from_function != nullptr)
{
- ClangASTType return_clang_type = m_immediate_step_from_function->GetClangType().GetFunctionReturnType();
- if (return_clang_type)
+ CompilerType return_compiler_type = m_immediate_step_from_function->GetCompilerType().GetFunctionReturnType();
+ if (return_compiler_type)
{
lldb::ABISP abi_sp = m_thread.GetProcess()->GetABI();
if (abi_sp)
- m_return_valobj_sp = abi_sp->GetReturnValueObject(m_thread, return_clang_type);
+ m_return_valobj_sp = abi_sp->GetReturnValueObject(m_thread, return_compiler_type);
}
}
}
@@ -558,8 +534,5 @@ ThreadPlanStepOut::IsPlanStale()
// there's something for us to do. Otherwise, we're stale.
StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
- if (frame_zero_id < m_step_out_to_id)
- return false;
- else
- return true;
+ return !(frame_zero_id < m_step_out_to_id);
}
diff --git a/source/Target/ThreadPlanStepOverRange.cpp b/source/Target/ThreadPlanStepOverRange.cpp
index aba89224239c..08655be24395 100644
--- a/source/Target/ThreadPlanStepOverRange.cpp
+++ b/source/Target/ThreadPlanStepOverRange.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/ThreadPlanStepOverRange.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/ThreadPlanStepOverRange.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Stream.h"
#include "lldb/Symbol/Block.h"
@@ -52,9 +51,7 @@ ThreadPlanStepOverRange::ThreadPlanStepOverRange
SetupAvoidNoDebug(step_out_avoids_code_without_debug_info);
}
-ThreadPlanStepOverRange::~ThreadPlanStepOverRange ()
-{
-}
+ThreadPlanStepOverRange::~ThreadPlanStepOverRange() = default;
void
ThreadPlanStepOverRange::GetDescription (Stream *s, lldb::DescriptionLevel level)
@@ -111,7 +108,6 @@ ThreadPlanStepOverRange::SetupAvoidNoDebug(LazyBool step_out_avoids_code_without
bool
ThreadPlanStepOverRange::IsEquivalentContext(const SymbolContext &context)
{
-
// Match as much as is specified in the m_addr_context:
// This is a fairly loose sanity check. Note, sometimes the target doesn't get filled
// in so I left out the target check. And sometimes the module comes in as the .o file from the
@@ -150,14 +146,8 @@ ThreadPlanStepOverRange::ShouldStop (Event *event_ptr)
// If we're out of the range but in the same frame or in our caller's frame
// then we should stop.
// When stepping out we only stop others if we are forcing running one thread.
- bool stop_others;
- if (m_stop_others == lldb::eOnlyThisThread)
- stop_others = true;
- else
- stop_others = false;
-
+ bool stop_others = (m_stop_others == lldb::eOnlyThisThread);
ThreadPlanSP new_plan_sp;
-
FrameComparison frame_order = CompareCurrentFrameToStartFrame();
if (frame_order == eFrameCompareOlder)
@@ -189,13 +179,13 @@ ThreadPlanStepOverRange::ShouldStop (Event *event_ptr)
const SymbolContext &older_context = older_frame_sp->GetSymbolContext(eSymbolContextEverything);
if (IsEquivalentContext(older_context))
{
- new_plan_sp = m_thread.QueueThreadPlanForStepOutNoShouldStop (false,
- NULL,
- true,
- stop_others,
- eVoteNo,
- eVoteNoOpinion,
- 0);
+ new_plan_sp = m_thread.QueueThreadPlanForStepOutNoShouldStop(false,
+ nullptr,
+ true,
+ stop_others,
+ eVoteNo,
+ eVoteNoOpinion,
+ 0);
break;
}
else
@@ -216,7 +206,6 @@ ThreadPlanStepOverRange::ShouldStop (Event *event_ptr)
return false;
}
-
if (!InSymbol())
{
// This one is a little tricky. Sometimes we may be in a stub or something similar,
@@ -283,7 +272,6 @@ ThreadPlanStepOverRange::ShouldStop (Event *event_ptr)
step_past_remaining_inline = true;
}
-
}
}
}
@@ -303,10 +291,14 @@ ThreadPlanStepOverRange::ShouldStop (Event *event_ptr)
if (next_line_entry.file == m_addr_context.line_entry.file)
{
const bool abort_other_plans = false;
- const bool stop_other_threads = false;
- new_plan_sp = m_thread.QueueThreadPlanForRunToAddress(abort_other_plans,
- next_line_address,
- stop_other_threads);
+ const RunMode stop_other_threads = RunMode::eAllThreads;
+ lldb::addr_t cur_pc = m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
+ AddressRange step_range(cur_pc, next_line_address.GetLoadAddress(&GetTarget()) - cur_pc);
+
+ new_plan_sp = m_thread.QueueThreadPlanForStepOverRange (abort_other_plans,
+ step_range,
+ sc,
+ stop_other_threads);
break;
}
look_ahead_step++;
@@ -368,27 +360,19 @@ ThreadPlanStepOverRange::DoPlanExplainsStop (Event *event_ptr)
{
StopReason reason = stop_info_sp->GetStopReason();
- switch (reason)
+ if (reason == eStopReasonTrace)
{
- case eStopReasonTrace:
return_value = true;
- break;
- case eStopReasonBreakpoint:
- if (NextRangeBreakpointExplainsStop(stop_info_sp))
- return_value = true;
- else
- return_value = false;
- break;
- case eStopReasonWatchpoint:
- case eStopReasonSignal:
- case eStopReasonException:
- case eStopReasonExec:
- case eStopReasonThreadExiting:
- default:
+ }
+ else if (reason == eStopReasonBreakpoint)
+ {
+ return_value = NextRangeBreakpointExplainsStop(stop_info_sp);
+ }
+ else
+ {
if (log)
log->PutCString ("ThreadPlanStepInRange got asked if it explains the stop for some reason other than step.");
return_value = false;
- break;
}
}
else
@@ -447,4 +431,3 @@ ThreadPlanStepOverRange::DoWillResume (lldb::StateType resume_state, bool curren
return true;
}
-
diff --git a/source/Target/ThreadPlanStepRange.cpp b/source/Target/ThreadPlanStepRange.cpp
index 3aed85859507..02667f8236ea 100644
--- a/source/Target/ThreadPlanStepRange.cpp
+++ b/source/Target/ThreadPlanStepRange.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/ThreadPlanStepRange.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/ThreadPlanStepRange.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/BreakpointSite.h"
#include "lldb/Core/Disassembler.h"
@@ -31,7 +30,6 @@
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.
@@ -127,7 +125,7 @@ ThreadPlanStepRange::DumpRanges(Stream *s)
{
for (size_t i = 0; i < num_ranges; i++)
{
- s->PutCString("%d: ");
+ s->Printf(" %" PRIu64 ": ", uint64_t(i));
m_address_ranges[i].Dump (s, m_thread.CalculateTarget().get(), Address::DumpStyleLoadAddress);
}
}
@@ -162,7 +160,7 @@ ThreadPlanStepRange::InRange ()
if (m_addr_context.line_entry.line == new_context.line_entry.line)
{
m_addr_context = new_context;
- AddRange(m_addr_context.line_entry.range);
+ AddRange(m_addr_context.line_entry.GetSameLineContiguousAddressRange());
ret_value = true;
if (log)
{
@@ -181,7 +179,7 @@ ThreadPlanStepRange::InRange ()
{
new_context.line_entry.line = m_addr_context.line_entry.line;
m_addr_context = new_context;
- AddRange(m_addr_context.line_entry.range);
+ AddRange(m_addr_context.line_entry.GetSameLineContiguousAddressRange());
ret_value = true;
if (log)
{
@@ -221,12 +219,9 @@ ThreadPlanStepRange::InRange ()
new_context.line_entry.line,
s.GetData());
}
-
}
}
-
}
-
}
if (!ret_value && log)
@@ -239,7 +234,7 @@ bool
ThreadPlanStepRange::InSymbol()
{
lldb::addr_t cur_pc = m_thread.GetRegisterContext()->GetPC();
- if (m_addr_context.function != NULL)
+ if (m_addr_context.function != nullptr)
{
return m_addr_context.function->GetAddressRange().ContainsLoadAddress (cur_pc, m_thread.CalculateTarget().get());
}
@@ -291,11 +286,7 @@ ThreadPlanStepRange::CompareCurrentFrameToStartFrame()
bool
ThreadPlanStepRange::StopOthers ()
{
- if (m_stop_others == lldb::eOnlyThisThread
- || m_stop_others == lldb::eOnlyDuringStepping)
- return true;
- else
- return false;
+ return (m_stop_others == lldb::eOnlyThisThread || m_stop_others == lldb::eOnlyDuringStepping);
}
InstructionList *
@@ -308,14 +299,14 @@ ThreadPlanStepRange::GetInstructionsForAddress(lldb::addr_t addr, size_t &range_
{
// Some joker added a zero size range to the stepping range...
if (m_address_ranges[i].GetByteSize() == 0)
- return NULL;
+ return nullptr;
if (!m_instruction_ranges[i])
{
//Disassemble the address range given:
ExecutionContext exe_ctx (m_thread.GetProcess());
- const char *plugin_name = NULL;
- const char *flavor = NULL;
+ const char *plugin_name = nullptr;
+ const char *flavor = nullptr;
const bool prefer_file_cache = true;
m_instruction_ranges[i] = Disassembler::DisassembleRange(GetTarget().GetArchitecture(),
plugin_name,
@@ -323,18 +314,17 @@ ThreadPlanStepRange::GetInstructionsForAddress(lldb::addr_t addr, size_t &range_
exe_ctx,
m_address_ranges[i],
prefer_file_cache);
-
}
if (!m_instruction_ranges[i])
- return NULL;
+ return nullptr;
else
{
// Find where we are in the instruction list as well. If we aren't at an instruction,
- // return NULL. In this case, we're probably lost, and shouldn't try to do anything fancy.
+ // return nullptr. In this case, we're probably lost, and shouldn't try to do anything fancy.
insn_offset = m_instruction_ranges[i]->GetInstructionList().GetIndexOfInstructionAtLoadAddress(addr, GetTarget());
if (insn_offset == UINT32_MAX)
- return NULL;
+ return nullptr;
else
{
range_index = i;
@@ -343,7 +333,7 @@ ThreadPlanStepRange::GetInstructionsForAddress(lldb::addr_t addr, size_t &range_
}
}
}
- return NULL;
+ return nullptr;
}
void
@@ -376,7 +366,7 @@ ThreadPlanStepRange::SetNextBranchBreakpoint ()
size_t pc_index;
size_t range_index;
InstructionList *instructions = GetInstructionsForAddress (cur_addr, range_index, pc_index);
- if (instructions == NULL)
+ if (instructions == nullptr)
return false;
else
{
@@ -389,13 +379,23 @@ ThreadPlanStepRange::SetNextBranchBreakpoint ()
// If we didn't find a branch, run to the end of the range.
if (branch_index == UINT32_MAX)
{
- branch_index = instructions->GetSize() - 1;
+ uint32_t last_index = instructions->GetSize() - 1;
+ if (last_index - pc_index > 1)
+ {
+ InstructionSP last_inst = instructions->GetInstructionAtIndex(last_index);
+ size_t last_inst_size = last_inst->GetOpcode().GetByteSize();
+ run_to_address = last_inst->GetAddress();
+ run_to_address.Slide(last_inst_size);
+ }
+ }
+ else if (branch_index - pc_index > 1)
+ {
+ run_to_address = instructions->GetInstructionAtIndex(branch_index)->GetAddress();
}
- if (branch_index - pc_index > 1)
+ if (run_to_address.IsValid())
{
const bool is_internal = true;
- run_to_address = instructions->GetInstructionAtIndex(branch_index)->GetAddress();
m_next_branch_bp_sp = GetTarget().CreateBreakpoint(run_to_address, is_internal, false);
if (m_next_branch_bp_sp)
{
@@ -501,15 +501,7 @@ ThreadPlanStepRange::MischiefManaged ()
else
{
FrameComparison frame_order = CompareCurrentFrameToStartFrame();
- if (frame_order != eFrameCompareOlder)
- {
- if (m_no_more_plans)
- done = true;
- else
- done = false;
- }
- else
- done = true;
+ done = (frame_order != eFrameCompareOlder) ? m_no_more_plans : true;
}
}
@@ -526,7 +518,6 @@ ThreadPlanStepRange::MischiefManaged ()
{
return false;
}
-
}
bool
diff --git a/source/Target/ThreadPlanStepThrough.cpp b/source/Target/ThreadPlanStepThrough.cpp
index 068d8e6584fd..a5346a4cddee 100644
--- a/source/Target/ThreadPlanStepThrough.cpp
+++ b/source/Target/ThreadPlanStepThrough.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/ThreadPlanStepThrough.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/ThreadPlanStepThrough.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Stream.h"
#include "lldb/Target/DynamicLoader.h"
@@ -39,7 +38,6 @@ ThreadPlanStepThrough::ThreadPlanStepThrough (Thread &thread, StackID &m_stack_i
m_return_stack_id (m_stack_id),
m_stop_others (stop_others)
{
-
LookForPlanToStepThroughFromCurrentPC();
// If we don't get a valid step through plan, don't bother to set up a backstop.
@@ -56,7 +54,7 @@ ThreadPlanStepThrough::ThreadPlanStepThrough (Thread &thread, StackID &m_stack_i
{
m_backstop_addr = return_frame_sp->GetFrameCodeAddress().GetLoadAddress(m_thread.CalculateTarget().get());
Breakpoint *return_bp = m_thread.GetProcess()->GetTarget().CreateBreakpoint (m_backstop_addr, true, false).get();
- if (return_bp != NULL)
+ if (return_bp != nullptr)
{
return_bp->SetThreadID(m_thread.GetID());
m_backstop_bkpt_id = return_bp->GetID();
@@ -137,7 +135,7 @@ ThreadPlanStepThrough::GetDescription (Stream *s, lldb::DescriptionLevel level)
bool
ThreadPlanStepThrough::ValidatePlan (Stream *error)
{
- return m_sub_plan_sp.get() != NULL;
+ return m_sub_plan_sp.get() != nullptr;
}
bool
@@ -147,10 +145,7 @@ ThreadPlanStepThrough::DoPlanExplainsStop (Event *event_ptr)
// we won't get asked. The only time we would be the one directly asked this question
// is if we hit our backstop breakpoint.
- if (HitOurBackstopBreakpoint())
- return true;
- else
- return false;
+ return HitOurBackstopBreakpoint();
}
bool
@@ -289,4 +284,3 @@ ThreadPlanStepThrough::HitOurBackstopBreakpoint()
}
return false;
}
-
diff --git a/source/Target/ThreadPlanStepUntil.cpp b/source/Target/ThreadPlanStepUntil.cpp
index 4c3d4a6a049e..2581fc7b522f 100644
--- a/source/Target/ThreadPlanStepUntil.cpp
+++ b/source/Target/ThreadPlanStepUntil.cpp
@@ -6,17 +6,12 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//m_should_stop
-
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Target/ThreadPlanStepUntil.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/ThreadPlanStepUntil.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Core/Log.h"
#include "lldb/Target/Process.h"
@@ -68,7 +63,7 @@ ThreadPlanStepUntil::ThreadPlanStepUntil
// TODO: add inline functionality
m_return_addr = return_frame_sp->GetStackID().GetPC();
Breakpoint *return_bp = target_sp->CreateBreakpoint (m_return_addr, true, false).get();
- if (return_bp != NULL)
+ if (return_bp != nullptr)
{
return_bp->SetThreadID(thread_id);
m_return_bp_id = return_bp->GetID();
@@ -82,7 +77,7 @@ ThreadPlanStepUntil::ThreadPlanStepUntil
for (size_t i = 0; i < num_addresses; i++)
{
Breakpoint *until_bp = target_sp->CreateBreakpoint (address_list[i], true, false).get();
- if (until_bp != NULL)
+ if (until_bp != nullptr)
{
until_bp->SetThreadID(thread_id);
m_until_points[address_list[i]] = until_bp->GetID();
@@ -183,122 +178,111 @@ ThreadPlanStepUntil::AnalyzeStop()
{
StopReason reason = stop_info_sp->GetStopReason();
- switch (reason)
+ if (reason == eStopReasonBreakpoint)
{
- case eStopReasonBreakpoint:
+ // If this is OUR breakpoint, we're fine, otherwise we don't know why this happened...
+ BreakpointSiteSP this_site = m_thread.GetProcess()->GetBreakpointSiteList().FindByID (stop_info_sp->GetValue());
+ if (!this_site)
{
- // If this is OUR breakpoint, we're fine, otherwise we don't know why this happened...
- BreakpointSiteSP this_site = m_thread.GetProcess()->GetBreakpointSiteList().FindByID (stop_info_sp->GetValue());
- if (!this_site)
- {
- m_explains_stop = false;
- return;
- }
+ m_explains_stop = false;
+ return;
+ }
- if (this_site->IsBreakpointAtThisSite (m_return_bp_id))
+ if (this_site->IsBreakpointAtThisSite (m_return_bp_id))
+ {
+ // If we are at our "step out" breakpoint, and the stack depth has shrunk, then
+ // this is indeed our stop.
+ // If the stack depth has grown, then we've hit our step out breakpoint recursively.
+ // If we are the only breakpoint at that location, then we do explain the stop, and
+ // we'll just continue.
+ // If there was another breakpoint here, then we don't explain the stop, but we won't
+ // mark ourselves Completed, because maybe that breakpoint will continue, and then
+ // we'll finish the "until".
+ bool done;
+ StackID cur_frame_zero_id;
+
+ done = (m_stack_id < cur_frame_zero_id);
+
+ if (done)
{
- // If we are at our "step out" breakpoint, and the stack depth has shrunk, then
- // this is indeed our stop.
- // If the stack depth has grown, then we've hit our step out breakpoint recursively.
- // If we are the only breakpoint at that location, then we do explain the stop, and
- // we'll just continue.
- // If there was another breakpoint here, then we don't explain the stop, but we won't
- // mark ourselves Completed, because maybe that breakpoint will continue, and then
- // we'll finish the "until".
- bool done;
- StackID cur_frame_zero_id;
-
- if (m_stack_id < cur_frame_zero_id)
- done = true;
- else
- done = false;
-
- if (done)
- {
- m_stepped_out = true;
- SetPlanComplete();
- }
- else
- m_should_stop = false;
-
- if (this_site->GetNumberOfOwners() == 1)
- m_explains_stop = true;
- else
- m_explains_stop = false;
- return;
+ m_stepped_out = true;
+ SetPlanComplete();
}
else
+ m_should_stop = false;
+
+ if (this_site->GetNumberOfOwners() == 1)
+ m_explains_stop = true;
+ else
+ m_explains_stop = false;
+ return;
+ }
+ else
+ {
+ // Check if we've hit one of our "until" breakpoints.
+ until_collection::iterator pos, end = m_until_points.end();
+ for (pos = m_until_points.begin(); pos != end; pos++)
{
- // Check if we've hit one of our "until" breakpoints.
- until_collection::iterator pos, end = m_until_points.end();
- for (pos = m_until_points.begin(); pos != end; pos++)
+ if (this_site->IsBreakpointAtThisSite ((*pos).second))
{
- if (this_site->IsBreakpointAtThisSite ((*pos).second))
+ // If we're at the right stack depth, then we're done.
+
+ bool done;
+ StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
+
+ if (frame_zero_id == m_stack_id)
+ done = true;
+ else if (frame_zero_id < m_stack_id)
+ done = false;
+ else
{
- // If we're at the right stack depth, then we're done.
-
- bool done;
- StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
-
- if (frame_zero_id == m_stack_id)
- done = true;
- else if (frame_zero_id < m_stack_id)
- done = false;
- else
+ StackFrameSP older_frame_sp = m_thread.GetStackFrameAtIndex(1);
+
+ // But if we can't even unwind one frame we should just get out of here & stop...
+ if (older_frame_sp)
{
- StackFrameSP older_frame_sp = m_thread.GetStackFrameAtIndex(1);
-
- // But if we can't even unwind one frame we should just get out of here & stop...
- if (older_frame_sp)
- {
- const SymbolContext &older_context
- = older_frame_sp->GetSymbolContext(eSymbolContextEverything);
- SymbolContext stack_context;
- m_stack_id.GetSymbolContextScope()->CalculateSymbolContext(&stack_context);
-
- if (older_context == stack_context)
- done = true;
- else
- done = false;
- }
- else
- done = false;
+ const SymbolContext &older_context
+ = older_frame_sp->GetSymbolContext(eSymbolContextEverything);
+ SymbolContext stack_context;
+ m_stack_id.GetSymbolContextScope()->CalculateSymbolContext(&stack_context);
+
+ done = (older_context == stack_context);
}
-
- if (done)
- SetPlanComplete();
- else
- m_should_stop = false;
-
- // Otherwise we've hit this breakpoint recursively. If we're the
- // only breakpoint here, then we do explain the stop, and we'll continue.
- // If not then we should let higher plans handle this stop.
- if (this_site->GetNumberOfOwners() == 1)
- m_explains_stop = true;
else
- {
- m_should_stop = true;
- m_explains_stop = false;
- }
- return;
+ done = false;
+ }
+
+ if (done)
+ SetPlanComplete();
+ else
+ m_should_stop = false;
+
+ // Otherwise we've hit this breakpoint recursively. If we're the
+ // only breakpoint here, then we do explain the stop, and we'll continue.
+ // If not then we should let higher plans handle this stop.
+ if (this_site->GetNumberOfOwners() == 1)
+ m_explains_stop = true;
+ else
+ {
+ m_should_stop = true;
+ m_explains_stop = false;
}
+ return;
}
}
- // If we get here we haven't hit any of our breakpoints, so let the higher
- // plans take care of the stop.
- m_explains_stop = false;
- return;
}
- case eStopReasonWatchpoint:
- case eStopReasonSignal:
- case eStopReasonException:
- case eStopReasonExec:
- case eStopReasonThreadExiting:
- m_explains_stop = false;
- break;
- default:
- m_explains_stop = true;
- break;
+ // If we get here we haven't hit any of our breakpoints, so let the higher
+ // plans take care of the stop.
+ m_explains_stop = false;
+ return;
+ }
+ else if (IsUsuallyUnexplainedStopReason(reason))
+ {
+ m_explains_stop = false;
+ }
+ else
+ {
+ m_explains_stop = true;
}
}
}
@@ -348,14 +332,14 @@ ThreadPlanStepUntil::DoWillResume (StateType resume_state, bool current_plan)
if (target_sp)
{
Breakpoint *return_bp = target_sp->GetBreakpointByID(m_return_bp_id).get();
- if (return_bp != NULL)
+ if (return_bp != nullptr)
return_bp->SetEnabled (true);
until_collection::iterator pos, end = m_until_points.end();
for (pos = m_until_points.begin(); pos != end; pos++)
{
Breakpoint *until_bp = target_sp->GetBreakpointByID((*pos).second).get();
- if (until_bp != NULL)
+ if (until_bp != nullptr)
until_bp->SetEnabled (true);
}
}
@@ -374,14 +358,14 @@ ThreadPlanStepUntil::WillStop ()
if (target_sp)
{
Breakpoint *return_bp = target_sp->GetBreakpointByID(m_return_bp_id).get();
- if (return_bp != NULL)
+ if (return_bp != nullptr)
return_bp->SetEnabled (false);
until_collection::iterator pos, end = m_until_points.end();
for (pos = m_until_points.begin(); pos != end; pos++)
{
Breakpoint *until_bp = target_sp->GetBreakpointByID((*pos).second).get();
- if (until_bp != NULL)
+ if (until_bp != nullptr)
until_bp->SetEnabled (false);
}
}
@@ -391,7 +375,6 @@ ThreadPlanStepUntil::WillStop ()
bool
ThreadPlanStepUntil::MischiefManaged ()
{
-
// I'm letting "PlanExplainsStop" do all the work, and just reporting that here.
bool done = false;
if (IsPlanComplete())
@@ -407,6 +390,4 @@ ThreadPlanStepUntil::MischiefManaged ()
ThreadPlan::MischiefManaged ();
return done;
-
}
-
diff --git a/source/Target/ThreadPlanTracer.cpp b/source/Target/ThreadPlanTracer.cpp
index 406708f8c396..e3fcbaaaef75 100644
--- a/source/Target/ThreadPlanTracer.cpp
+++ b/source/Target/ThreadPlanTracer.cpp
@@ -7,13 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/ThreadPlan.h"
-
// C Includes
-#include <string.h>
// C++ Includes
+#include <cstring>
+
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/ThreadPlan.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataExtractor.h"
@@ -24,8 +24,8 @@
#include "lldb/Core/State.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/Value.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/TypeList.h"
+#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Thread.h"
@@ -57,8 +57,7 @@ ThreadPlanTracer::ThreadPlanTracer (Thread &thread) :
Stream *
ThreadPlanTracer::GetLogStream ()
{
-
- if (m_stream_sp.get())
+ if (m_stream_sp)
return m_stream_sp.get();
else
{
@@ -66,7 +65,7 @@ ThreadPlanTracer::GetLogStream ()
if (target_sp)
return target_sp->GetDebugger().GetOutputFile().get();
}
- return NULL;
+ return nullptr;
}
void
@@ -83,7 +82,6 @@ ThreadPlanTracer::Log()
stream->Printf("\n");
stream->Flush();
}
-
}
bool
@@ -92,10 +90,7 @@ ThreadPlanTracer::TracerExplainsStop ()
if (m_enabled && m_single_step)
{
lldb::StopInfoSP stop_info = m_thread.GetStopInfo();
- if (stop_info->GetStopReason() == eStopReasonTrace)
- return true;
- else
- return false;
+ return (stop_info->GetStopReason() == eStopReasonTrace);
}
else
return false;
@@ -122,8 +117,8 @@ ThreadPlanAssemblyTracer::ThreadPlanAssemblyTracer (Thread &thread) :
Disassembler *
ThreadPlanAssemblyTracer::GetDisassembler ()
{
- if (m_disassembler_sp.get() == NULL)
- m_disassembler_sp = Disassembler::FindPlugin(m_thread.GetProcess()->GetTarget().GetArchitecture(), NULL, NULL);
+ if (!m_disassembler_sp)
+ m_disassembler_sp = Disassembler::FindPlugin(m_thread.GetProcess()->GetTarget().GetArchitecture(), nullptr, nullptr);
return m_disassembler_sp.get();
}
@@ -135,29 +130,22 @@ ThreadPlanAssemblyTracer::GetIntPointerType()
TargetSP target_sp (m_thread.CalculateTarget());
if (target_sp)
{
- Module *exe_module = target_sp->GetExecutableModulePointer();
-
- if (exe_module)
- {
- m_intptr_type = TypeFromUser(exe_module->GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, target_sp->GetArchitecture().GetAddressByteSize() * 8));
- }
+ TypeSystem *type_system = target_sp->GetScratchTypeSystemForLanguage(nullptr, eLanguageTypeC);
+ if (type_system)
+ m_intptr_type = TypeFromUser(type_system->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, target_sp->GetArchitecture().GetAddressByteSize() * 8));
}
}
return m_intptr_type;
}
-
-
-ThreadPlanAssemblyTracer::~ThreadPlanAssemblyTracer()
-{
-}
+ThreadPlanAssemblyTracer::~ThreadPlanAssemblyTracer() = default;
void
ThreadPlanAssemblyTracer::TracingStarted ()
{
RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
- if (m_register_values.size() == 0)
+ if (m_register_values.empty())
m_register_values.resize (reg_ctx->GetRegisterCount());
}
@@ -214,15 +202,15 @@ ThreadPlanAssemblyTracer::Log ()
const bool show_address = true;
Instruction *instruction = instruction_list.GetInstructionAtIndex(0).get();
const FormatEntity::Entry *disassemble_format = m_thread.GetProcess()->GetTarget().GetDebugger().GetDisassemblyFormat();
- instruction->Dump (stream,
- max_opcode_byte_size,
- show_address,
- show_bytes,
- NULL,
- NULL,
- NULL,
- disassemble_format,
- 0);
+ instruction->Dump(stream,
+ max_opcode_byte_size,
+ show_address,
+ show_bytes,
+ nullptr,
+ nullptr,
+ nullptr,
+ disassemble_format,
+ 0);
}
}
}
@@ -240,7 +228,7 @@ ThreadPlanAssemblyTracer::Log ()
Value value;
value.SetValueType (Value::eValueTypeScalar);
// value.SetContext (Value::eContextTypeClangType, intptr_type.GetOpaqueQualType());
- value.SetClangType (intptr_type);
+ value.SetCompilerType (intptr_type);
value_list.PushValue (value);
}
@@ -255,8 +243,7 @@ ThreadPlanAssemblyTracer::Log ()
}
}
}
-
-
+
RegisterValue reg_value;
for (uint32_t reg_num = 0, num_registers = reg_ctx->GetRegisterCount();
reg_num < num_registers;
diff --git a/source/Target/ThreadSpec.cpp b/source/Target/ThreadSpec.cpp
index cb54469ba901..f877f521bd51 100644
--- a/source/Target/ThreadSpec.cpp
+++ b/source/Target/ThreadSpec.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadSpec.cpp ----------------------------------------------*- C++ -*-===//
+//===-- ThreadSpec.cpp ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadSpec.h"
@@ -21,7 +25,7 @@ ThreadSpec::ThreadSpec() :
{
}
-ThreadSpec::ThreadSpec (const ThreadSpec &rhs) :
+ThreadSpec::ThreadSpec(const ThreadSpec &rhs) :
m_index(rhs.m_index),
m_tid(rhs.m_tid),
m_name(rhs.m_name),
@@ -42,19 +46,13 @@ ThreadSpec::operator=(const ThreadSpec &rhs)
const char *
ThreadSpec::GetName () const
{
- if (m_name.empty())
- return NULL;
- else
- return m_name.c_str();
+ return m_name.empty() ? nullptr : m_name.c_str();
}
const char *
ThreadSpec::GetQueueName () const
{
- if (m_queue_name.empty())
- return NULL;
- else
- return m_queue_name.c_str();
+ return m_queue_name.empty() ? nullptr : m_queue_name.c_str();
}
bool
@@ -66,6 +64,7 @@ ThreadSpec::TIDMatches (Thread &thread) const
lldb::tid_t thread_id = thread.GetID();
return TIDMatches (thread_id);
}
+
bool
ThreadSpec::IndexMatches (Thread &thread) const
{
@@ -74,6 +73,7 @@ ThreadSpec::IndexMatches (Thread &thread) const
uint32_t index = thread.GetIndexID();
return IndexMatches (index);
}
+
bool
ThreadSpec::NameMatches (Thread &thread) const
{
@@ -83,6 +83,7 @@ ThreadSpec::NameMatches (Thread &thread) const
const char *name = thread.GetName();
return NameMatches (name);
}
+
bool
ThreadSpec::QueueNameMatches (Thread &thread) const
{
@@ -96,7 +97,6 @@ ThreadSpec::QueueNameMatches (Thread &thread) const
bool
ThreadSpec::ThreadPassesBasicTests (Thread &thread) const
{
-
if (!HasSpecification())
return true;
@@ -113,7 +113,6 @@ ThreadSpec::ThreadPassesBasicTests (Thread &thread) const
return false;
return true;
-
}
bool
@@ -121,6 +120,7 @@ ThreadSpec::HasSpecification() const
{
return (m_index != UINT32_MAX || m_tid != LLDB_INVALID_THREAD_ID || !m_name.empty() || !m_queue_name.empty());
}
+
void
ThreadSpec::GetDescription (Stream *s, lldb::DescriptionLevel level) const
{
diff --git a/source/Target/UnixSignals.cpp b/source/Target/UnixSignals.cpp
index 91579e8d7852..8a98c21560d7 100644
--- a/source/Target/UnixSignals.cpp
+++ b/source/Target/UnixSignals.cpp
@@ -19,20 +19,21 @@
#include "Plugins/Process/Utility/FreeBSDSignals.h"
#include "Plugins/Process/Utility/LinuxSignals.h"
#include "Plugins/Process/Utility/MipsLinuxSignals.h"
+#include "Plugins/Process/Utility/NetBSDSignals.h"
using namespace lldb_private;
UnixSignals::Signal::Signal
(
const char *name,
- const char *short_name,
bool default_suppress,
bool default_stop,
bool default_notify,
- const char *description
+ const char *description,
+ const char *alias
) :
m_name (name),
- m_short_name (short_name),
+ m_alias (alias),
m_description (),
m_suppress (default_suppress),
m_stop (default_stop),
@@ -63,8 +64,9 @@ UnixSignals::Create(const ArchSpec &arch)
}
case llvm::Triple::FreeBSD:
case llvm::Triple::OpenBSD:
- case llvm::Triple::NetBSD:
return std::make_shared<FreeBSDSignals>();
+ case llvm::Triple::NetBSD:
+ return std::make_shared<NetBSDSignals>();
default:
return std::make_shared<UnixSignals>();
}
@@ -97,39 +99,39 @@ UnixSignals::Reset ()
// order, you can either subclass this class, and use Add & Remove to change them
// or you can subclass and build them afresh in your constructor;
m_signals.clear();
- // SIGNO NAME SHORT NAME SUPPRESS STOP NOTIFY DESCRIPTION
- // ====== ============ ========== ======== ====== ====== ===================================================
- AddSignal (1, "SIGHUP", "HUP", false, true , true , "hangup");
- AddSignal (2, "SIGINT", "INT", true , true , true , "interrupt");
- AddSignal (3, "SIGQUIT", "QUIT", false, true , true , "quit");
- AddSignal (4, "SIGILL", "ILL", false, true , true , "illegal instruction");
- AddSignal (5, "SIGTRAP", "TRAP", true , true , true , "trace trap (not reset when caught)");
- AddSignal (6, "SIGABRT", "ABRT", false, true , true , "abort()");
- AddSignal (7, "SIGEMT", "EMT", false, true , true , "pollable event");
- AddSignal (8, "SIGFPE", "FPE", false, true , true , "floating point exception");
- AddSignal (9, "SIGKILL", "KILL", false, true , true , "kill");
- AddSignal (10, "SIGBUS", "BUS", false, true , true , "bus error");
- AddSignal (11, "SIGSEGV", "SEGV", false, true , true , "segmentation violation");
- AddSignal (12, "SIGSYS", "SYS", false, true , true , "bad argument to system call");
- AddSignal (13, "SIGPIPE", "PIPE", false, true , true , "write on a pipe with no one to read it");
- AddSignal (14, "SIGALRM", "ALRM", false, false, false, "alarm clock");
- AddSignal (15, "SIGTERM", "TERM", false, true , true , "software termination signal from kill");
- AddSignal (16, "SIGURG", "URG", false, false, false, "urgent condition on IO channel");
- AddSignal (17, "SIGSTOP", "STOP", true , true , true , "sendable stop signal not from tty");
- AddSignal (18, "SIGTSTP", "TSTP", false, true , true , "stop signal from tty");
- AddSignal (19, "SIGCONT", "CONT", false, true , true , "continue a stopped process");
- AddSignal (20, "SIGCHLD", "CHLD", false, false, false, "to parent on child stop or exit");
- AddSignal (21, "SIGTTIN", "TTIN", false, true , true , "to readers process group upon background tty read");
- AddSignal (22, "SIGTTOU", "TTOU", false, true , true , "to readers process group upon background tty write");
- AddSignal (23, "SIGIO", "IO", false, false, false, "input/output possible signal");
- AddSignal (24, "SIGXCPU", "XCPU", false, true , true , "exceeded CPU time limit");
- AddSignal (25, "SIGXFSZ", "XFSZ", false, true , true , "exceeded file size limit");
- AddSignal (26, "SIGVTALRM", "VTALRM", false, false, false, "virtual time alarm");
- AddSignal (27, "SIGPROF", "PROF", false, false, false, "profiling time alarm");
- AddSignal (28, "SIGWINCH", "WINCH", false, false, false, "window size changes");
- AddSignal (29, "SIGINFO", "INFO", false, true , true , "information request");
- AddSignal (30, "SIGUSR1", "USR1", false, true , true , "user defined signal 1");
- AddSignal (31, "SIGUSR2", "USR2", false, true , true , "user defined signal 2");
+ // SIGNO NAME SUPPRESS STOP NOTIFY DESCRIPTION
+ // ====== ============ ======== ====== ====== ===================================================
+ AddSignal (1, "SIGHUP", false, true , true , "hangup");
+ AddSignal (2, "SIGINT", true , true , true , "interrupt");
+ AddSignal (3, "SIGQUIT", false, true , true , "quit");
+ AddSignal (4, "SIGILL", false, true , true , "illegal instruction");
+ AddSignal (5, "SIGTRAP", true , true , true , "trace trap (not reset when caught)");
+ AddSignal (6, "SIGABRT", false, true , true , "abort()");
+ AddSignal (7, "SIGEMT", false, true , true , "pollable event");
+ AddSignal (8, "SIGFPE", false, true , true , "floating point exception");
+ AddSignal (9, "SIGKILL", false, true , true , "kill");
+ AddSignal (10, "SIGBUS", false, true , true , "bus error");
+ AddSignal (11, "SIGSEGV", false, true , true , "segmentation violation");
+ AddSignal (12, "SIGSYS", false, true , true , "bad argument to system call");
+ AddSignal (13, "SIGPIPE", false, true , true , "write on a pipe with no one to read it");
+ AddSignal (14, "SIGALRM", false, false, false, "alarm clock");
+ AddSignal (15, "SIGTERM", false, true , true , "software termination signal from kill");
+ AddSignal (16, "SIGURG", false, false, false, "urgent condition on IO channel");
+ AddSignal (17, "SIGSTOP", true , true , true , "sendable stop signal not from tty");
+ AddSignal (18, "SIGTSTP", false, true , true , "stop signal from tty");
+ AddSignal (19, "SIGCONT", false, true , true , "continue a stopped process");
+ AddSignal (20, "SIGCHLD", false, false, false, "to parent on child stop or exit");
+ AddSignal (21, "SIGTTIN", false, true , true , "to readers process group upon background tty read");
+ AddSignal (22, "SIGTTOU", false, true , true , "to readers process group upon background tty write");
+ AddSignal (23, "SIGIO", false, false, false, "input/output possible signal");
+ AddSignal (24, "SIGXCPU", false, true , true , "exceeded CPU time limit");
+ AddSignal (25, "SIGXFSZ", false, true , true , "exceeded file size limit");
+ AddSignal (26, "SIGVTALRM", false, false, false, "virtual time alarm");
+ AddSignal (27, "SIGPROF", false, false, false, "profiling time alarm");
+ AddSignal (28, "SIGWINCH", false, false, false, "window size changes");
+ AddSignal (29, "SIGINFO", false, true , true , "information request");
+ AddSignal (30, "SIGUSR1", false, true , true , "user defined signal 1");
+ AddSignal (31, "SIGUSR2", false, true , true , "user defined signal 2");
}
void
@@ -137,14 +139,14 @@ UnixSignals::AddSignal
(
int signo,
const char *name,
- const char *short_name,
bool default_suppress,
bool default_stop,
bool default_notify,
- const char *description
+ const char *description,
+ const char *alias
)
{
- Signal new_signal (name, short_name, default_suppress, default_stop, default_notify, description);
+ Signal new_signal (name, default_suppress, default_stop, default_notify, description, alias);
m_signals.insert (std::make_pair(signo, new_signal));
}
@@ -173,6 +175,16 @@ UnixSignals::SignalIsValid (int32_t signo) const
return m_signals.find (signo) != m_signals.end();
}
+ConstString
+UnixSignals::GetShortName(ConstString name) const
+{
+ if (name)
+ {
+ char* signame = (char*)(name.AsCString());
+ return ConstString(signame + 3); // Remove "SIG" from name
+ }
+ return name;
+}
int32_t
UnixSignals::GetSignalNumberFromName (const char *name) const
@@ -182,7 +194,8 @@ UnixSignals::GetSignalNumberFromName (const char *name) const
collection::const_iterator pos, end = m_signals.end ();
for (pos = m_signals.begin (); pos != end; pos++)
{
- if ((const_name == pos->second.m_name) || (const_name == pos->second.m_short_name))
+ if ((const_name == pos->second.m_name) || (const_name == pos->second.m_alias) ||
+ (const_name == GetShortName(pos->second.m_name)) || (const_name == GetShortName(pos->second.m_alias)))
return pos->first;
}
diff --git a/source/Utility/ARM64_GCC_Registers.h b/source/Utility/ARM64_ehframe_Registers.h
index 2166b3bf591a..0a5c68c63b7e 100644
--- a/source/Utility/ARM64_GCC_Registers.h
+++ b/source/Utility/ARM64_ehframe_Registers.h
@@ -1,4 +1,4 @@
-//===-- ARM64_gdb_Registers.h -------------------------------------*- C++ -*-===//
+//===-- ARM64_ehframe_Registers.h -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,10 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef utility_ARM64_gdb_Registers_h_
-#define utility_ARM64_gdb_Registers_h_
+#ifndef utility_ARM64_ehframe_Registers_h_
+#define utility_ARM64_ehframe_Registers_h_
-namespace arm64_gcc {
+// The register numbers used in the eh_frame unwind information.
+// Should be the same as DWARF register numbers.
+
+namespace arm64_ehframe {
enum
{
@@ -88,5 +91,5 @@ enum
}
-#endif // utility_ARM64_gdb_Registers_h_
+#endif // utility_ARM64_ehframe_Registers_h_
diff --git a/source/Utility/ARM_GCC_Registers.h b/source/Utility/ARM_GCC_Registers.h
deleted file mode 100644
index 974d01bfc78a..000000000000
--- a/source/Utility/ARM_GCC_Registers.h
+++ /dev/null
@@ -1,146 +0,0 @@
-//===-- ARM_GCC_Registers.h -------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef utility_ARM_GCC_Registers_h_
-#define utility_ARM_GCC_Registers_h_
-
-enum
-{
- gcc_r0 = 0,
- gcc_r1,
- gcc_r2,
- gcc_r3,
- gcc_r4,
- gcc_r5,
- gcc_r6,
- gcc_r7,
- gcc_r8,
- gcc_r9,
- gcc_r10,
- gcc_r11,
- gcc_r12,
- gcc_sp,
- gcc_lr,
- gcc_pc,
- gcc_cpsr
-};
-
-enum
-{
-// Name Nr Rel Offset Size Type Raw value
- gdb_arm_r0 = 0, // 0 0 4 int32_t
- gdb_arm_r1 = 1, // 1 4 4 int32_t
- gdb_arm_r2 = 2, // 2 8 4 int32_t
- gdb_arm_r3 = 3, // 3 12 4 int32_t
- gdb_arm_r4 = 4, // 4 16 4 int32_t
- gdb_arm_r5 = 5, // 5 20 4 int32_t
- gdb_arm_r6 = 6, // 6 24 4 int32_t
- gdb_arm_r7 = 7, // 7 28 4 int32_t
- gdb_arm_r8 = 8, // 8 32 4 int32_t
- gdb_arm_r9 = 9, // 9 36 4 int32_t
- gdb_arm_r10 = 10, // 10 40 4 int32_t
- gdb_arm_r11 = 11, // 11 44 4 int32_t
- gdb_arm_r12 = 12, // 12 48 4 int32_t
- gdb_arm_sp = 13, // 13 52 4 int32_t
- gdb_arm_lr = 14, // 14 56 4 int32_t
- gdb_arm_pc = 15, // 15 60 4 int32_t
- gdb_arm_f0 = 16, // 16 64 12 _arm_ext_littlebyte_bigword
- gdb_arm_f1 = 17, // 17 76 12 _arm_ext_littlebyte_bigword
- gdb_arm_f2 = 18, // 18 88 12 _arm_ext_littlebyte_bigword
- gdb_arm_f3 = 19, // 19 100 12 _arm_ext_littlebyte_bigword
- gdb_arm_f4 = 20, // 20 112 12 _arm_ext_littlebyte_bigword
- gdb_arm_f5 = 21, // 21 124 12 _arm_ext_littlebyte_bigword
- gdb_arm_f6 = 22, // 22 136 12 _arm_ext_littlebyte_bigword
- gdb_arm_f7 = 23, // 23 148 12 _arm_ext_littlebyte_bigword
- gdb_arm_f8 = 24, // 24 160 12 _arm_ext_littlebyte_bigword
- gdb_arm_cpsr = 25, // 25 172 4 int32_t
- gdb_arm_s0 = 26, // 26 176 4 _ieee_single_little
- gdb_arm_s1 = 27, // 27 180 4 _ieee_single_little
- gdb_arm_s2 = 28, // 28 184 4 _ieee_single_little
- gdb_arm_s3 = 29, // 29 188 4 _ieee_single_little
- gdb_arm_s4 = 30, // 30 192 4 _ieee_single_little
- gdb_arm_s5 = 31, // 31 196 4 _ieee_single_little
- gdb_arm_s6 = 32, // 32 200 4 _ieee_single_little
- gdb_arm_s7 = 33, // 33 204 4 _ieee_single_little
- gdb_arm_s8 = 34, // 34 208 4 _ieee_single_little
- gdb_arm_s9 = 35, // 35 212 4 _ieee_single_little
- gdb_arm_s10 = 36, // 36 216 4 _ieee_single_little
- gdb_arm_s11 = 37, // 37 220 4 _ieee_single_little
- gdb_arm_s12 = 38, // 38 224 4 _ieee_single_little
- gdb_arm_s13 = 39, // 39 228 4 _ieee_single_little
- gdb_arm_s14 = 40, // 40 232 4 _ieee_single_little
- gdb_arm_s15 = 41, // 41 236 4 _ieee_single_little
- gdb_arm_s16 = 42, // 42 240 4 _ieee_single_little
- gdb_arm_s17 = 43, // 43 244 4 _ieee_single_little
- gdb_arm_s18 = 44, // 44 248 4 _ieee_single_little
- gdb_arm_s19 = 45, // 45 252 4 _ieee_single_little
- gdb_arm_s20 = 46, // 46 256 4 _ieee_single_little
- gdb_arm_s21 = 47, // 47 260 4 _ieee_single_little
- gdb_arm_s22 = 48, // 48 264 4 _ieee_single_little
- gdb_arm_s23 = 49, // 49 268 4 _ieee_single_little
- gdb_arm_s24 = 50, // 50 272 4 _ieee_single_little
- gdb_arm_s25 = 51, // 51 276 4 _ieee_single_little
- gdb_arm_s26 = 52, // 52 280 4 _ieee_single_little
- gdb_arm_s27 = 53, // 53 284 4 _ieee_single_little
- gdb_arm_s28 = 54, // 54 288 4 _ieee_single_little
- gdb_arm_s29 = 55, // 55 292 4 _ieee_single_little
- gdb_arm_s30 = 56, // 56 296 4 _ieee_single_little
- gdb_arm_s31 = 57, // 57 300 4 _ieee_single_little
- gdb_arm_fpscr = 58, // 58 304 4 int32_t
- gdb_arm_d16 = 59, // 59 308 8 _ieee_double_little
- gdb_arm_d17 = 60, // 60 316 8 _ieee_double_little
- gdb_arm_d18 = 61, // 61 324 8 _ieee_double_little
- gdb_arm_d19 = 62, // 62 332 8 _ieee_double_little
- gdb_arm_d20 = 63, // 63 340 8 _ieee_double_little
- gdb_arm_d21 = 64, // 64 348 8 _ieee_double_little
- gdb_arm_d22 = 65, // 65 356 8 _ieee_double_little
- gdb_arm_d23 = 66, // 66 364 8 _ieee_double_little
- gdb_arm_d24 = 67, // 67 372 8 _ieee_double_little
- gdb_arm_d25 = 68, // 68 380 8 _ieee_double_little
- gdb_arm_d26 = 69, // 69 388 8 _ieee_double_little
- gdb_arm_d27 = 70, // 70 396 8 _ieee_double_little
- gdb_arm_d28 = 71, // 71 404 8 _ieee_double_little
- gdb_arm_d29 = 72, // 72 412 8 _ieee_double_little
- gdb_arm_d30 = 73, // 73 420 8 _ieee_double_little
- gdb_arm_d31 = 74, // 74 428 8 _ieee_double_little
- gdb_arm_d0 = 75, // 0 436 8 _ieee_double_little
- gdb_arm_d1 = 76, // 1 444 8 _ieee_double_little
- gdb_arm_d2 = 77, // 2 452 8 _ieee_double_little
- gdb_arm_d3 = 78, // 3 460 8 _ieee_double_little
- gdb_arm_d4 = 79, // 4 468 8 _ieee_double_little
- gdb_arm_d5 = 80, // 5 476 8 _ieee_double_little
- gdb_arm_d6 = 81, // 6 484 8 _ieee_double_little
- gdb_arm_d7 = 82, // 7 492 8 _ieee_double_little
- gdb_arm_d8 = 83, // 8 500 8 _ieee_double_little
- gdb_arm_d9 = 84, // 9 508 8 _ieee_double_little
- gdb_arm_d10 = 85, // 10 516 8 _ieee_double_little
- gdb_arm_d11 = 86, // 11 524 8 _ieee_double_little
- gdb_arm_d12 = 87, // 12 532 8 _ieee_double_little
- gdb_arm_d13 = 88, // 13 540 8 _ieee_double_little
- gdb_arm_d14 = 89, // 14 548 8 _ieee_double_little
- gdb_arm_d15 = 90, // 15 556 8 _ieee_double_little
- gdb_arm_q0 = 91, // 16 564 16 _vec128
- gdb_arm_q1 = 92, // 17 580 16 _vec128
- gdb_arm_q2 = 93, // 18 596 16 _vec128
- gdb_arm_q3 = 94, // 19 612 16 _vec128
- gdb_arm_q4 = 95, // 20 628 16 _vec128
- gdb_arm_q5 = 96, // 21 644 16 _vec128
- gdb_arm_q6 = 97, // 22 660 16 _vec128
- gdb_arm_q7 = 98, // 23 676 16 _vec128
- gdb_arm_q8 = 99, // 24 692 16 _vec128
- gdb_arm_q9 = 100, // 25 708 16 _vec128
- gdb_arm_q10 = 101, // 26 724 16 _vec128
- gdb_arm_q11 = 102, // 27 740 16 _vec128
- gdb_arm_q12 = 103, // 28 756 16 _vec128
- gdb_arm_q13 = 104, // 29 772 16 _vec128
- gdb_arm_q14 = 105, // 30 788 16 _vec128
- gdb_arm_q15 = 106 // 31 804 16 _vec128
-};
-#endif // utility_ARM_GCC_Registers_h_
-
diff --git a/source/Utility/ARM_ehframe_Registers.h b/source/Utility/ARM_ehframe_Registers.h
new file mode 100644
index 000000000000..7d4951d6ce89
--- /dev/null
+++ b/source/Utility/ARM_ehframe_Registers.h
@@ -0,0 +1,38 @@
+//===-- 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.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef utility_ARM_ehframe_Registers_h_
+#define utility_ARM_ehframe_Registers_h_
+
+// The register numbers used in the eh_frame unwind information.
+// Should be the same as DWARF register numbers.
+
+enum
+{
+ ehframe_r0 = 0,
+ ehframe_r1,
+ ehframe_r2,
+ ehframe_r3,
+ ehframe_r4,
+ ehframe_r5,
+ ehframe_r6,
+ ehframe_r7,
+ ehframe_r8,
+ ehframe_r9,
+ ehframe_r10,
+ ehframe_r11,
+ ehframe_r12,
+ ehframe_sp,
+ ehframe_lr,
+ ehframe_pc,
+ ehframe_cpsr
+};
+
+#endif // utility_ARM_ehframe_Registers_h_
+
diff --git a/source/Utility/ConvertEnum.cpp b/source/Utility/ConvertEnum.cpp
index e108f5e75420..3231397a05e3 100644
--- a/source/Utility/ConvertEnum.cpp
+++ b/source/Utility/ConvertEnum.cpp
@@ -63,6 +63,8 @@ lldb_private::GetSectionTypeAsCString(lldb::SectionType sect_type)
return "objc-cfstrings";
case eSectionTypeDWARFDebugAbbrev:
return "dwarf-abbrev";
+ case eSectionTypeDWARFDebugAddr:
+ return "dwarf-addr";
case eSectionTypeDWARFDebugAranges:
return "dwarf-aranges";
case eSectionTypeDWARFDebugFrame:
@@ -75,6 +77,8 @@ lldb_private::GetSectionTypeAsCString(lldb::SectionType sect_type)
return "dwarf-loc";
case eSectionTypeDWARFDebugMacInfo:
return "dwarf-macinfo";
+ case eSectionTypeDWARFDebugMacro:
+ return "dwarf-macro";
case eSectionTypeDWARFDebugPubNames:
return "dwarf-pubnames";
case eSectionTypeDWARFDebugPubTypes:
@@ -83,6 +87,8 @@ lldb_private::GetSectionTypeAsCString(lldb::SectionType sect_type)
return "dwarf-ranges";
case eSectionTypeDWARFDebugStr:
return "dwarf-str";
+ case eSectionTypeDWARFDebugStrOffsets:
+ return "dwarf-str-offsets";
case eSectionTypeELFSymbolTable:
return "elf-symbol-table";
case eSectionTypeELFDynamicSymbols:
@@ -101,8 +107,14 @@ lldb_private::GetSectionTypeAsCString(lldb::SectionType sect_type)
return "apple-objc";
case eSectionTypeEHFrame:
return "eh-frame";
+ case eSectionTypeARMexidx:
+ return "ARM.exidx";
+ case eSectionTypeARMextab:
+ return "ARM.extab";
case eSectionTypeCompactUnwind:
return "compact-unwind";
+ case eSectionTypeGoSymtab:
+ return "go-symtab";
case eSectionTypeOther:
return "regular";
}
diff --git a/source/Utility/JSON.cpp b/source/Utility/JSON.cpp
index 1e16a5ac9952..8b96a06e08e8 100644
--- a/source/Utility/JSON.cpp
+++ b/source/Utility/JSON.cpp
@@ -12,6 +12,7 @@
#include <limits.h>
#include "lldb/Core/StreamString.h"
#include "lldb/Host/StringConvert.h"
+#include "llvm/Support/ErrorHandling.h"
using namespace lldb_private;
@@ -60,38 +61,66 @@ JSONString::Write (Stream& s)
s.Printf("\"%s\"", json_string_quote_metachars(m_data).c_str());
}
-JSONNumber::JSONNumber () :
- JSONValue(JSONValue::Kind::Number),
- m_is_integer(true),
- m_data(0),
- m_double(0.0)
+uint64_t
+JSONNumber::GetAsUnsigned() const
{
+ switch (m_data_type)
+ {
+ case DataType::Unsigned:
+ return m_data.m_unsigned;
+ case DataType::Signed:
+ return (uint64_t)m_data.m_signed;
+ case DataType::Double:
+ return (uint64_t)m_data.m_double;
+ }
+ llvm_unreachable("Unhandled data type");
}
-JSONNumber::JSONNumber (uint64_t i) :
- JSONValue(JSONValue::Kind::Number),
- m_is_integer(true),
- m_data(i),
- m_double(0.0)
+int64_t
+JSONNumber::GetAsSigned() const
{
+ switch (m_data_type)
+ {
+ case DataType::Unsigned:
+ return (int64_t)m_data.m_unsigned;
+ case DataType::Signed:
+ return m_data.m_signed;
+ case DataType::Double:
+ return (int64_t)m_data.m_double;
+ }
+ llvm_unreachable("Unhandled data type");
}
-
-JSONNumber::JSONNumber (double d) :
- JSONValue(JSONValue::Kind::Number),
- m_is_integer(false),
- m_data(0),
- m_double(d)
+double
+JSONNumber::GetAsDouble() const
{
+ switch (m_data_type)
+ {
+ case DataType::Unsigned:
+ return (double)m_data.m_unsigned;
+ case DataType::Signed:
+ return (double)m_data.m_signed;
+ case DataType::Double:
+ return m_data.m_double;
+ }
+ llvm_unreachable("Unhandled data type");
}
void
JSONNumber::Write (Stream& s)
{
- if (m_is_integer)
- s.Printf("%" PRIu64, m_data);
- else
- s.Printf("%g", m_double);
+ switch (m_data_type)
+ {
+ case DataType::Unsigned:
+ s.Printf("%" PRIu64, m_data.m_unsigned);
+ break;
+ case DataType::Signed:
+ s.Printf("%" PRId64, m_data.m_signed);
+ break;
+ case DataType::Double:
+ s.Printf("%g", m_data.m_double);
+ break;
+ }
}
JSONTrue::JSONTrue () :
@@ -392,7 +421,7 @@ JSONParser::GetToken (std::string &value)
case 'E':
if (exp_index != 0)
{
- error.Printf("error: extra expenent character found at offset %" PRIu64, start_index);
+ error.Printf("error: extra exponent character found at offset %" PRIu64, start_index);
value = std::move(error.GetString());
return Token::Error;
}
@@ -617,10 +646,20 @@ JSONParser::ParseJSONValue ()
case JSONParser::Token::Integer:
{
- bool success = false;
- uint64_t uval = StringConvert::ToUInt64(value.c_str(), 0, 0, &success);
- if (success)
- return JSONValue::SP(new JSONNumber(uval));
+ if (value.front() == '-')
+ {
+ bool success = false;
+ int64_t sval = StringConvert::ToSInt64(value.c_str(), 0, 0, &success);
+ if (success)
+ return JSONValue::SP(new JSONNumber(sval));
+ }
+ else
+ {
+ bool success = false;
+ uint64_t uval = StringConvert::ToUInt64(value.c_str(), 0, 0, &success);
+ if (success)
+ return JSONValue::SP(new JSONNumber(uval));
+ }
}
break;
diff --git a/source/Utility/ModuleCache.cpp b/source/Utility/ModuleCache.cpp
index ce0df241dc22..7c57d0baeccd 100644
--- a/source/Utility/ModuleCache.cpp
+++ b/source/Utility/ModuleCache.cpp
@@ -9,7 +9,9 @@
#include "ModuleCache.h"
+#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Host/File.h"
#include "lldb/Host/FileSystem.h"
@@ -27,8 +29,22 @@ using namespace lldb_private;
namespace {
const char* kModulesSubdir = ".cache";
-const char* kLockFileName = ".lock";
+const char* kLockDirName = ".lock";
const char* kTempFileName = ".temp";
+const char* kTempSymFileName = ".symtemp";
+const char* kSymFileExtension = ".sym";
+
+class ModuleLock
+{
+private:
+ File m_file;
+ std::unique_ptr<lldb_private::LockFile> m_lock;
+ FileSpec m_file_spec;
+
+public:
+ ModuleLock (const FileSpec &root_dir_spec, const UUID &uuid, Error& error);
+ void Delete ();
+};
FileSpec
JoinPath (const FileSpec &path1, const char* path2)
@@ -59,13 +75,76 @@ GetModuleDirectory (const FileSpec &root_dir_spec, const UUID &uuid)
return JoinPath (modules_dir_spec, uuid.GetAsString ().c_str ());
}
+FileSpec
+GetSymbolFileSpec(const FileSpec& module_file_spec)
+{
+ return FileSpec((module_file_spec.GetPath() + kSymFileExtension).c_str(), false);
+}
+
+void
+DeleteExistingModule (const FileSpec &root_dir_spec, const FileSpec &sysroot_module_path_spec)
+{
+ Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_MODULES));
+ UUID module_uuid;
+ {
+ auto module_sp = std::make_shared<Module>(ModuleSpec (sysroot_module_path_spec));
+ module_uuid = module_sp->GetUUID ();
+ }
+
+ if (!module_uuid.IsValid ())
+ return;
+
+ Error error;
+ ModuleLock lock (root_dir_spec, module_uuid, error);
+ if (error.Fail ())
+ {
+ if (log)
+ log->Printf ("Failed to lock module %s: %s",
+ module_uuid.GetAsString ().c_str (),
+ error.AsCString ());
+ }
+
+ auto link_count = FileSystem::GetHardlinkCount (sysroot_module_path_spec);
+ if (link_count == -1)
+ return;
+
+ if (link_count > 2) // module is referred by other hosts.
+ return;
+
+ const auto module_spec_dir = GetModuleDirectory (root_dir_spec, module_uuid);
+ FileSystem::DeleteDirectory (module_spec_dir, true);
+ lock.Delete();
+}
+
+void
+DecrementRefExistingModule (const FileSpec &root_dir_spec, const FileSpec &sysroot_module_path_spec)
+{
+ // Remove $platform/.cache/$uuid folder if nobody else references it.
+ DeleteExistingModule (root_dir_spec, sysroot_module_path_spec);
+
+ // Remove sysroot link.
+ FileSystem::Unlink (sysroot_module_path_spec);
+
+ FileSpec symfile_spec = GetSymbolFileSpec (sysroot_module_path_spec);
+ if (symfile_spec.Exists ()) // delete module's symbol file if exists.
+ FileSystem::Unlink (symfile_spec);
+}
+
Error
-CreateHostSysRootModuleLink (const FileSpec &root_dir_spec, const char *hostname, const FileSpec &platform_module_spec, const FileSpec &local_module_spec)
+CreateHostSysRootModuleLink (const FileSpec &root_dir_spec, const char *hostname,
+ const FileSpec &platform_module_spec,
+ const FileSpec &local_module_spec,
+ bool delete_existing)
{
const auto sysroot_module_path_spec = JoinPath (
JoinPath (root_dir_spec, hostname), platform_module_spec.GetPath ().c_str ());
if (sysroot_module_path_spec.Exists())
- return Error ();
+ {
+ if (!delete_existing)
+ return Error ();
+
+ DecrementRefExistingModule (root_dir_spec, sysroot_module_path_spec);
+ }
const auto error = MakeDirectory (FileSpec (sysroot_module_path_spec.GetDirectory ().AsCString (), false));
if (error.Fail ())
@@ -76,14 +155,48 @@ CreateHostSysRootModuleLink (const FileSpec &root_dir_spec, const char *hostname
} // namespace
+ModuleLock::ModuleLock (const FileSpec &root_dir_spec, const UUID &uuid, Error& error)
+{
+ const auto lock_dir_spec = JoinPath (root_dir_spec, kLockDirName);
+ error = MakeDirectory (lock_dir_spec);
+ if (error.Fail ())
+ return;
+
+ m_file_spec = JoinPath (lock_dir_spec, uuid.GetAsString ().c_str ());
+ m_file.Open (m_file_spec.GetCString (),
+ File::eOpenOptionWrite | File::eOpenOptionCanCreate | File::eOpenOptionCloseOnExec);
+ if (!m_file)
+ {
+ error.SetErrorToErrno ();
+ return;
+ }
+
+ m_lock.reset (new lldb_private::LockFile (m_file.GetDescriptor ()));
+ error = m_lock->WriteLock (0, 1);
+ if (error.Fail ())
+ error.SetErrorStringWithFormat ("Failed to lock file: %s", error.AsCString ());
+}
+
+void ModuleLock::Delete ()
+{
+ if (!m_file)
+ return;
+
+ m_file.Close ();
+ FileSystem::Unlink (m_file_spec);
+}
+
+/////////////////////////////////////////////////////////////////////////
+
Error
ModuleCache::Put (const FileSpec &root_dir_spec,
const char *hostname,
const ModuleSpec &module_spec,
- const FileSpec &tmp_file)
+ const FileSpec &tmp_file,
+ const FileSpec &target_file)
{
const auto module_spec_dir = GetModuleDirectory (root_dir_spec, module_spec.GetUUID ());
- const auto module_file_path = JoinPath (module_spec_dir, module_spec.GetFileSpec ().GetFilename ().AsCString ());
+ const auto module_file_path = JoinPath (module_spec_dir, target_file.GetFilename ().AsCString ());
const auto tmp_file_path = tmp_file.GetPath ();
const auto err_code = llvm::sys::fs::rename (tmp_file_path.c_str (), module_file_path.GetPath ().c_str ());
@@ -91,7 +204,7 @@ ModuleCache::Put (const FileSpec &root_dir_spec,
return Error ("Failed to rename file %s to %s: %s",
tmp_file_path.c_str (), module_file_path.GetPath ().c_str (), err_code.message ().c_str ());
- const auto error = CreateHostSysRootModuleLink(root_dir_spec, hostname, module_spec.GetFileSpec(), module_file_path);
+ const auto error = CreateHostSysRootModuleLink(root_dir_spec, hostname, target_file, module_file_path, true);
if (error.Fail ())
return Error ("Failed to create link to %s: %s", module_file_path.GetPath ().c_str (), error.AsCString ());
return Error ();
@@ -122,7 +235,7 @@ ModuleCache::Get (const FileSpec &root_dir_spec,
return Error ("Module %s has invalid file size", module_file_path.GetPath ().c_str ());
// We may have already cached module but downloaded from an another host - in this case let's create a link to it.
- const auto error = CreateHostSysRootModuleLink(root_dir_spec, hostname, module_spec.GetFileSpec(), module_file_path);
+ auto error = CreateHostSysRootModuleLink(root_dir_spec, hostname, module_spec.GetFileSpec(), module_file_path, false);
if (error.Fail ())
return Error ("Failed to create link to %s: %s", module_file_path.GetPath().c_str(), error.AsCString());
@@ -130,9 +243,19 @@ ModuleCache::Get (const FileSpec &root_dir_spec,
cached_module_spec.GetUUID ().Clear (); // Clear UUID since it may contain md5 content hash instead of real UUID.
cached_module_spec.GetFileSpec () = module_file_path;
cached_module_spec.GetPlatformFileSpec () = module_spec.GetFileSpec ();
- cached_module_sp.reset (new Module (cached_module_spec));
- if (did_create_ptr)
- *did_create_ptr = true;
+
+ error = ModuleList::GetSharedModule(cached_module_spec,
+ cached_module_sp,
+ nullptr,
+ nullptr,
+ did_create_ptr,
+ false);
+ if (error.Fail())
+ return error;
+
+ FileSpec symfile_spec = GetSymbolFileSpec(cached_module_sp->GetFileSpec ());
+ if (symfile_spec.Exists ())
+ cached_module_sp->SetSymbolFileFileSpec (symfile_spec);
m_loaded_modules.insert (std::make_pair (module_spec.GetUUID ().GetAsString (), cached_module_sp));
@@ -143,7 +266,8 @@ Error
ModuleCache::GetAndPut (const FileSpec &root_dir_spec,
const char *hostname,
const ModuleSpec &module_spec,
- const Downloader &downloader,
+ const ModuleDownloader &module_downloader,
+ const SymfileDownloader &symfile_downloader,
lldb::ModuleSP &cached_module_sp,
bool *did_create_ptr)
{
@@ -152,18 +276,9 @@ ModuleCache::GetAndPut (const FileSpec &root_dir_spec,
if (error.Fail ())
return error;
- // Open lock file.
- const auto lock_file_spec = JoinPath (module_spec_dir, kLockFileName);
- File lock_file (lock_file_spec, File::eOpenOptionWrite | File::eOpenOptionCanCreate | File::eOpenOptionCloseOnExec);
- if (!lock_file)
- {
- error.SetErrorToErrno ();
- return Error("Failed to open lock file %s: %s", lock_file_spec.GetPath ().c_str (), error.AsCString ());
- }
- LockFile lock (lock_file.GetDescriptor ());
- error = lock.WriteLock (0, 1);
+ ModuleLock lock (root_dir_spec, module_spec.GetUUID (), error);
if (error.Fail ())
- return Error("Failed to lock file %s:%s", lock_file_spec.GetPath ().c_str (), error.AsCString ());
+ return Error("Failed to lock module %s: %s", module_spec.GetUUID ().GetAsString().c_str(), error.AsCString ());
// Check local cache for a module.
error = Get (root_dir_spec, hostname, module_spec, cached_module_sp, did_create_ptr);
@@ -171,16 +286,37 @@ ModuleCache::GetAndPut (const FileSpec &root_dir_spec,
return error;
const auto tmp_download_file_spec = JoinPath (module_spec_dir, kTempFileName);
- error = downloader (module_spec, tmp_download_file_spec);
+ error = module_downloader (module_spec, tmp_download_file_spec);
llvm::FileRemover tmp_file_remover (tmp_download_file_spec.GetPath ().c_str ());
if (error.Fail ())
return Error("Failed to download module: %s", error.AsCString ());
// Put downloaded file into local module cache.
- error = Put (root_dir_spec, hostname, module_spec, tmp_download_file_spec);
+ error = Put (root_dir_spec, hostname, module_spec, tmp_download_file_spec, module_spec.GetFileSpec ());
if (error.Fail ())
return Error ("Failed to put module into cache: %s", error.AsCString ());
tmp_file_remover.releaseFile ();
- return Get (root_dir_spec, hostname, module_spec, cached_module_sp, did_create_ptr);
+ error = Get (root_dir_spec, hostname, module_spec, cached_module_sp, did_create_ptr);
+ if (error.Fail ())
+ return error;
+
+ // Fetching a symbol file for the module
+ const auto tmp_download_sym_file_spec = JoinPath (module_spec_dir, kTempSymFileName);
+ error = symfile_downloader (cached_module_sp, tmp_download_sym_file_spec);
+ llvm::FileRemover tmp_symfile_remover (tmp_download_sym_file_spec.GetPath ().c_str ());
+ if (error.Fail ())
+ // Failed to download a symfile but fetching the module was successful. The module might
+ // contain the neccessary symbols and the debugging is also possible without a symfile.
+ return Error ();
+
+ error = Put (root_dir_spec, hostname, module_spec, tmp_download_sym_file_spec, GetSymbolFileSpec(module_spec.GetFileSpec ()));
+ if (error.Fail ())
+ return Error ("Failed to put symbol file into cache: %s", error.AsCString ());
+
+ tmp_symfile_remover.releaseFile();
+
+ FileSpec symfile_spec = GetSymbolFileSpec (cached_module_sp->GetFileSpec ());
+ cached_module_sp->SetSymbolFileFileSpec (symfile_spec);
+ return Error ();
}
diff --git a/source/Utility/ModuleCache.h b/source/Utility/ModuleCache.h
index 791e2b35ae3d..bb9b308304b6 100644
--- a/source/Utility/ModuleCache.h
+++ b/source/Utility/ModuleCache.h
@@ -46,13 +46,15 @@ class UUID;
class ModuleCache
{
public:
- using Downloader = std::function<Error (const ModuleSpec&, const FileSpec&)>;
+ using ModuleDownloader = std::function<Error (const ModuleSpec&, const FileSpec&)>;
+ using SymfileDownloader = std::function<Error (const lldb::ModuleSP&, const FileSpec&)>;
Error
GetAndPut(const FileSpec &root_dir_spec,
const char *hostname,
const ModuleSpec &module_spec,
- const Downloader &downloader,
+ const ModuleDownloader &module_downloader,
+ const SymfileDownloader &symfile_downloader,
lldb::ModuleSP &cached_module_sp,
bool *did_create_ptr);
@@ -61,7 +63,8 @@ private:
Put (const FileSpec &root_dir_spec,
const char *hostname,
const ModuleSpec &module_spec,
- const FileSpec &tmp_file);
+ const FileSpec &tmp_file,
+ const FileSpec &target_file);
Error
Get (const FileSpec &root_dir_spec,
diff --git a/source/Utility/SharingPtr.cpp b/source/Utility/SharingPtr.cpp
index 4083975bba7c..7f1278567ff1 100644
--- a/source/Utility/SharingPtr.cpp
+++ b/source/Utility/SharingPtr.cpp
@@ -11,7 +11,7 @@
#if defined (ENABLE_SP_LOGGING)
-// If ENABLE_SP_LOGGING is defined, then log all shared pointer assignements
+// If ENABLE_SP_LOGGING is defined, then log all shared pointer assignments
// and allow them to be queried using a pointer by a call to:
#include <execinfo.h>
#include <map>
diff --git a/source/Utility/StringExtractor.cpp b/source/Utility/StringExtractor.cpp
index 6302c033c0c1..ae92704668fc 100644
--- a/source/Utility/StringExtractor.cpp
+++ b/source/Utility/StringExtractor.cpp
@@ -120,19 +120,30 @@ StringExtractor::DecodeHexU8()
//----------------------------------------------------------------------
// Extract an unsigned character from two hex ASCII chars in the packet
-// string
+// 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
+ GetHexU8Ex(fail_value, set_eof_on_fail);
+ return fail_value;
+}
+
+bool
+StringExtractor::GetHexU8Ex (uint8_t& ch, bool set_eof_on_fail)
+{
int byte = DecodeHexU8();
if (byte == -1)
{
if (set_eof_on_fail || m_index >= m_packet.size())
m_index = UINT64_MAX;
- return fail_value;
+ // ch should not be changed in case of failure
+ return false;
}
- return (uint8_t)byte;
+ ch = (uint8_t)byte;
+ return true;
}
uint32_t
diff --git a/source/Utility/StringExtractorGDBRemote.cpp b/source/Utility/StringExtractorGDBRemote.cpp
index 17ee0b63f3e5..56df0be21edf 100644
--- a/source/Utility/StringExtractorGDBRemote.cpp
+++ b/source/Utility/StringExtractorGDBRemote.cpp
@@ -163,12 +163,12 @@ StringExtractorGDBRemote::GetServerPacketType () const
case 'K':
if (PACKET_STARTS_WITH ("qKillSpawnedProcess")) return eServerPacketType_qKillSpawnedProcess;
break;
-
+
case 'L':
if (PACKET_STARTS_WITH ("qLaunchGDBServer")) return eServerPacketType_qLaunchGDBServer;
if (PACKET_MATCHES ("qLaunchSuccess")) return eServerPacketType_qLaunchSuccess;
break;
-
+
case 'M':
if (PACKET_STARTS_WITH ("qMemoryRegionInfo:")) return eServerPacketType_qMemoryRegionInfo;
if (PACKET_MATCHES ("qMemoryRegionInfo")) return eServerPacketType_qMemoryRegionInfoSupported;
@@ -182,7 +182,11 @@ StringExtractorGDBRemote::GetServerPacketType () const
if (PACKET_STARTS_WITH ("qPlatform_chmod:")) return eServerPacketType_qPlatform_chmod;
if (PACKET_MATCHES ("qProcessInfo")) return eServerPacketType_qProcessInfo;
break;
-
+
+ case 'Q':
+ if (PACKET_MATCHES ("qQueryGDBServer")) return eServerPacketType_qQueryGDBServer;
+ break;
+
case 'R':
if (PACKET_STARTS_WITH ("qRcmd,")) return eServerPacketType_qRcmd;
if (PACKET_STARTS_WITH ("qRegisterInfo")) return eServerPacketType_qRegisterInfo;
@@ -221,7 +225,9 @@ StringExtractorGDBRemote::GetServerPacketType () const
break;
case 'j':
- if (PACKET_MATCHES("jSignalInfo")) return eServerPacketType_jSignalsInfo;
+ if (PACKET_MATCHES("jSignalsInfo")) return eServerPacketType_jSignalsInfo;
+ if (PACKET_MATCHES("jThreadsInfo")) return eServerPacketType_jThreadsInfo;
+
case 'v':
if (PACKET_STARTS_WITH("vFile:"))
@@ -308,6 +314,12 @@ StringExtractorGDBRemote::GetServerPacketType () const
case 'S':
return eServerPacketType_S;
+ case 'x':
+ return eServerPacketType_x;
+
+ case 'X':
+ return eServerPacketType_X;
+
case 'T':
return eServerPacketType_T;
diff --git a/source/Utility/StringExtractorGDBRemote.h b/source/Utility/StringExtractorGDBRemote.h
index 475b5a8e36c8..7e2f1e7c6962 100644
--- a/source/Utility/StringExtractorGDBRemote.h
+++ b/source/Utility/StringExtractorGDBRemote.h
@@ -54,6 +54,7 @@ public:
eServerPacketType_qGroupName,
eServerPacketType_qHostInfo,
eServerPacketType_qLaunchGDBServer,
+ eServerPacketType_qQueryGDBServer,
eServerPacketType_qKillSpawnedProcess,
eServerPacketType_qLaunchSuccess,
eServerPacketType_qModuleInfo,
@@ -97,6 +98,7 @@ public:
eServerPacketType_QSyncThreadState,
eServerPacketType_QThreadSuffixSupported,
+ eServerPacketType_jThreadsInfo,
eServerPacketType_qsThreadInfo,
eServerPacketType_qfThreadInfo,
eServerPacketType_qGetPid,
@@ -144,6 +146,8 @@ public:
eServerPacketType_s,
eServerPacketType_S,
eServerPacketType_T,
+ eServerPacketType_x,
+ eServerPacketType_X,
eServerPacketType_Z,
eServerPacketType_z,
diff --git a/source/Utility/TaskPool.cpp b/source/Utility/TaskPool.cpp
new file mode 100644
index 000000000000..75fe59d1e711
--- /dev/null
+++ b/source/Utility/TaskPool.cpp
@@ -0,0 +1,88 @@
+//===--------------------- TaskPool.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/Utility/TaskPool.h"
+
+namespace
+{
+ class TaskPoolImpl
+ {
+ public:
+ static TaskPoolImpl&
+ GetInstance();
+
+ void
+ AddTask(std::function<void()>&& task_fn);
+
+ private:
+ TaskPoolImpl();
+
+ static void
+ Worker(TaskPoolImpl* pool);
+
+ std::queue<std::function<void()>> m_tasks;
+ std::mutex m_tasks_mutex;
+ uint32_t m_thread_count;
+ };
+
+} // end of anonymous namespace
+
+TaskPoolImpl&
+TaskPoolImpl::GetInstance()
+{
+ static TaskPoolImpl g_task_pool_impl;
+ return g_task_pool_impl;
+}
+
+void
+TaskPool::AddTaskImpl(std::function<void()>&& task_fn)
+{
+ TaskPoolImpl::GetInstance().AddTask(std::move(task_fn));
+}
+
+TaskPoolImpl::TaskPoolImpl() :
+ m_thread_count(0)
+{
+}
+
+void
+TaskPoolImpl::AddTask(std::function<void()>&& task_fn)
+{
+ static const uint32_t max_threads = std::thread::hardware_concurrency();
+
+ std::unique_lock<std::mutex> lock(m_tasks_mutex);
+ m_tasks.emplace(std::move(task_fn));
+ if (m_thread_count < max_threads)
+ {
+ m_thread_count++;
+ lock.unlock();
+
+ std::thread (Worker, this).detach();
+ }
+}
+
+void
+TaskPoolImpl::Worker(TaskPoolImpl* pool)
+{
+ while (true)
+ {
+ std::unique_lock<std::mutex> lock(pool->m_tasks_mutex);
+ if (pool->m_tasks.empty())
+ {
+ pool->m_thread_count--;
+ break;
+ }
+
+ std::function<void()> f = pool->m_tasks.front();
+ pool->m_tasks.pop();
+ lock.unlock();
+
+ f();
+ }
+}
diff --git a/source/Utility/UriParser.cpp b/source/Utility/UriParser.cpp
index 86020d17fc3e..77e16b02aaed 100644
--- a/source/Utility/UriParser.cpp
+++ b/source/Utility/UriParser.cpp
@@ -10,10 +10,10 @@
#include "Utility/UriParser.h"
// C Includes
-#include <stdlib.h>
-#include <stdio.h>
// C++ Includes
+#include <cstring>
+
// Other libraries and framework includes
// Project includes
#include "lldb/Host/StringConvert.h"
@@ -24,43 +24,71 @@ using namespace lldb_private;
// UriParser::Parse
//----------------------------------------------------------------------
bool
-UriParser::Parse(const char* uri,
- std::string& scheme,
- std::string& hostname,
- int& port,
- std::string& path
- )
+UriParser::Parse(const std::string& uri,
+ std::string& scheme,
+ std::string& hostname,
+ int& port,
+ std::string& path)
{
- char scheme_buf[100] = {0};
- char hostname_buf[256] = {0};
- char port_buf[11] = {0}; // 10==strlen(2^32)
- char path_buf[2049] = {'/', 0};
-
- bool ok = false;
- if (4==sscanf(uri, "%99[^:/]://%255[^/:]:%10[^/]/%2047s", scheme_buf, hostname_buf, port_buf, path_buf+1)) { ok = true; }
- else if (3==sscanf(uri, "%99[^:/]://%255[^/:]:%10[^/]", scheme_buf, hostname_buf, port_buf)) { ok = true; }
- else if (3==sscanf(uri, "%99[^:/]://%255[^/]/%2047s", scheme_buf, hostname_buf, path_buf+1)) { ok = true; }
- else if (2==sscanf(uri, "%99[^:/]://%255[^/]", scheme_buf, hostname_buf)) { ok = true; }
+ std::string tmp_scheme, tmp_hostname, tmp_port, tmp_path;
+
+ static const char* kSchemeSep = "://";
+ auto pos = uri.find(kSchemeSep);
+ if (pos == std::string::npos)
+ return false;
+
+ // Extract path.
+ tmp_scheme = uri.substr(0, pos);
+ auto host_pos = pos + strlen(kSchemeSep);
+ auto path_pos = uri.find('/', host_pos);
+ if (path_pos != std::string::npos)
+ tmp_path = uri.substr(path_pos);
+ else
+ tmp_path = "/";
+
+ auto host_port = uri.substr(
+ host_pos, ((path_pos != std::string::npos) ? path_pos : uri.size()) - host_pos);
+
+ // Extract hostname
+ if (host_port[0] == '[')
+ {
+ // hostname is enclosed with square brackets.
+ pos = host_port.find(']');
+ if (pos == std::string::npos)
+ return false;
+
+ tmp_hostname = host_port.substr(1, pos - 1);
+ host_port.erase(0, pos + 1);
+ }
+ else
+ {
+ pos = host_port.find(':');
+ tmp_hostname = host_port.substr(0, (pos != std::string::npos) ? pos : host_port.size());
+ host_port.erase(0, (pos != std::string::npos) ? pos : host_port.size());
+ }
- bool success = false;
- int port_tmp = -1;
- if (port_buf[0])
+ // Extract port
+ tmp_port = host_port;
+ if (!tmp_port.empty())
{
- port_tmp = StringConvert::ToUInt32(port_buf, UINT32_MAX, 10, &success);
+ if (tmp_port[0] != ':')
+ return false;
+ tmp_port = tmp_port.substr(1);
+ bool success = false;
+ auto port_tmp = StringConvert::ToUInt32(tmp_port.c_str(), UINT32_MAX, 10, &success);
if (!success || port_tmp > 65535)
{
// there are invalid characters in port_buf
return false;
}
- }
-
- if (ok)
- {
- scheme.assign(scheme_buf);
- hostname.assign(hostname_buf);
port = port_tmp;
- path.assign(path_buf);
}
- return ok;
+ else
+ port = -1;
+
+ scheme = tmp_scheme;
+ hostname = tmp_hostname;
+ path = tmp_path;
+ return true;
}
diff --git a/source/Utility/UriParser.h b/source/Utility/UriParser.h
index fb129eaf79d5..8cbaaeab18cd 100644
--- a/source/Utility/UriParser.h
+++ b/source/Utility/UriParser.h
@@ -28,12 +28,12 @@ public:
//
// if the url is invalid, function returns false and
// output parameters remain unchanged
- static bool Parse(const char* uri,
- std::string& scheme,
- std::string& hostname,
- int& port,
- std::string& path
- );
+ static bool
+ Parse(const std::string& uri,
+ std::string& scheme,
+ std::string& hostname,
+ int& port,
+ std::string& path);
};
#endif // utility_UriParser_h_
diff --git a/source/lldb.cpp b/source/lldb.cpp
index 89bb485a612e..1e02d2ada66f 100644
--- a/source/lldb.cpp
+++ b/source/lldb.cpp
@@ -67,7 +67,7 @@ lldb_private::GetVersion ()
return g_version_string;
#else
- // On Linux/FreeBSD/Windows, report a version number in the same style as the clang tool.
+ // On platforms other than Darwin, report a version number in the same style as the clang tool.
static std::string g_version_str;
if (g_version_str.empty())
{
diff --git a/tools/argdumper/exports b/tools/argdumper/argdumper.exports
index e69de29bb2d1..e69de29bb2d1 100644
--- a/tools/argdumper/exports
+++ b/tools/argdumper/argdumper.exports
diff --git a/tools/driver/Driver.cpp b/tools/driver/Driver.cpp
index 3b2eadd836b3..0b72e22c80c8 100644
--- a/tools/driver/Driver.cpp
+++ b/tools/driver/Driver.cpp
@@ -35,6 +35,7 @@
#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBEvent.h"
#include "lldb/API/SBHostOS.h"
+#include "lldb/API/SBLanguageRuntime.h"
#include "lldb/API/SBListener.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBTarget.h"
@@ -132,6 +133,10 @@ static OptionDefinition g_options[] =
"extensions have been implemented." },
{ LLDB_3_TO_5, false, "debug" , 'd', no_argument , 0, eArgTypeNone,
"Tells the debugger to print out extra information for debugging itself." },
+ { LLDB_OPT_SET_7, true , "repl" , 'r', optional_argument, 0, eArgTypeNone,
+ "Runs lldb in REPL mode with a stub process." },
+ { LLDB_OPT_SET_7, true , "repl-language" , 'R', required_argument, 0, eArgTypeNone,
+ "Chooses the language for the REPL." },
{ 0, false, NULL , 0 , 0 , 0, eArgTypeNone, NULL }
};
@@ -341,21 +346,27 @@ ShowUsage (FILE *out, OptionDefinition *option_table, Driver::OptionData data)
indent_level, "");
indent_level += 5;
- fprintf (out, "\n%*sMultiple \"-s\" and \"-o\" options can be provided. They will be processed from left to right in order, "
- "\n%*swith the source files and commands interleaved. The same is true of the \"-S\" and \"-O\" options."
- "\n%*sThe before file and after file sets can intermixed freely, the command parser will sort them out."
- "\n%*sThe order of the file specifiers (\"-c\", \"-f\", etc.) is not significant in this regard.\n\n",
+ fprintf (out, "\n%*sMultiple \"-s\" and \"-o\" options can be provided. They will be processed"
+ "\n%*sfrom left to right in order, with the source files and commands"
+ "\n%*sinterleaved. The same is true of the \"-S\" and \"-O\" options. The before"
+ "\n%*sfile and after file sets can intermixed freely, the command parser will"
+ "\n%*ssort them out. The order of the file specifiers (\"-c\", \"-f\", etc.) is"
+ "\n%*snot significant in this regard.\n\n",
indent_level, "",
indent_level, "",
indent_level, "",
+ indent_level, "",
+ indent_level, "",
indent_level, "");
- fprintf (out, "\n%*sIf you don't provide -f then the first argument will be the file to be debugged"
- "\n%*swhich means that '%s -- <filename> [<ARG1> [<ARG2>]]' also works."
- "\n%*sBut remember to end the options with \"--\" if any of your arguments have a \"-\" in them.\n\n",
+ fprintf (out, "\n%*sIf you don't provide -f then the first argument will be the file to be"
+ "\n%*sdebugged which means that '%s -- <filename> [<ARG1> [<ARG2>]]' also"
+ "\n%*sworks. But remember to end the options with \"--\" if any of your"
+ "\n%*sarguments have a \"-\" in them.\n\n",
indent_level, "",
indent_level, "",
name,
+ indent_level, "",
indent_level, "");
}
@@ -408,6 +419,9 @@ Driver::OptionData::OptionData () :
m_print_python_path (false),
m_print_help (false),
m_wait_for(false),
+ m_repl (false),
+ m_repl_lang (eLanguageTypeUnknown),
+ m_repl_options (),
m_process_name(),
m_process_pid(LLDB_INVALID_PROCESS_ID),
m_use_external_editor(false),
@@ -769,6 +783,23 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exiting)
optarg);
}
break;
+
+ case 'r':
+ m_option_data.m_repl = true;
+ if (optarg && optarg[0])
+ m_option_data.m_repl_options = optarg;
+ else
+ m_option_data.m_repl_options.clear();
+ break;
+
+ case 'R':
+ m_option_data.m_repl_lang = SBLanguageRuntime::GetLanguageTypeFromString (optarg);
+ if (m_option_data.m_repl_lang == eLanguageTypeUnknown)
+ {
+ error.SetErrorStringWithFormat ("Unrecognized language name: \"%s\"", optarg);
+ }
+ break;
+
case 's':
m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterFile, true, error);
break;
@@ -1056,96 +1087,114 @@ Driver::MainLoop ()
bool handle_events = true;
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 && commands_size)
+ if (m_option_data.m_repl)
{
- int initial_commands_fds[2];
- bool success = true;
- FILE *commands_file = PrepareCommandsForSourcing (commands_data, commands_size, initial_commands_fds);
- if (commands_file)
+ const char *repl_options = NULL;
+ 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())
{
- 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())
+ const char *error_cstr = error.GetCString();
+ if (error_cstr && error_cstr[0])
+ fprintf (stderr, "error: %s\n", error_cstr);
+ else
+ fprintf (stderr, "error: %u\n", error.GetError());
+ }
+ }
+ 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 && commands_size)
+ {
+ int initial_commands_fds[2];
+ bool success = true;
+ FILE *commands_file = PrepareCommandsForSourcing (commands_data, commands_size, initial_commands_fds);
+ if (commands_file)
{
- 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)
+ 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())
{
- 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;
+ 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)
+ {
+ 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);
}
- m_debugger.SetAsync(old_async);
- }
- else
- success = false;
+ else
+ success = false;
- // Close any pipes that we still have ownership of
- CleanupAfterCommandSourcing(initial_commands_fds);
+ // Close any pipes that we still have ownership of
+ CleanupAfterCommandSourcing(initial_commands_fds);
- // Something went wrong with command pipe
- if (!success)
- {
- exit(1);
- }
+ // 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
+ // 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
- bool go_interactive = true;
- if (quit_requested)
- go_interactive = false;
- else if (m_option_data.m_batch && !stopped_for_crash)
- go_interactive = false;
+ 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);
- m_debugger.RunCommandInterpreter(handle_events, spawn_thread);
+ if (go_interactive)
+ {
+ m_debugger.SetInputFileHandle (stdin, true);
+ m_debugger.RunCommandInterpreter(handle_events, spawn_thread);
+ }
}
reset_stdin_termios();
diff --git a/tools/driver/Driver.h b/tools/driver/Driver.h
index b1e536d43c05..639ac41d7fe6 100644
--- a/tools/driver/Driver.h
+++ b/tools/driver/Driver.h
@@ -105,6 +105,9 @@ public:
bool m_print_python_path;
bool m_print_help;
bool m_wait_for;
+ bool m_repl;
+ lldb::LanguageType m_repl_lang;
+ std::string m_repl_options;
std::string m_process_name;
lldb::pid_t m_process_pid;
bool m_use_external_editor; // FIXME: When we have set/show variables we can remove this from here.
diff --git a/tools/lldb-mi/MICmdArgContext.cpp b/tools/lldb-mi/MICmdArgContext.cpp
index 7a1bbf77d31a..8ce5bfb3c88f 100644
--- a/tools/lldb-mi/MICmdArgContext.cpp
+++ b/tools/lldb-mi/MICmdArgContext.cpp
@@ -1,4 +1,4 @@
-//===-- MICmnArgContext.cpp -------------------------------------*- C++ -*-===//
+//===-- MICmdArgContext.cpp -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -17,7 +17,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdArgContext::CMICmdArgContext(void)
+CMICmdArgContext::CMICmdArgContext()
{
}
@@ -40,7 +40,7 @@ CMICmdArgContext::CMICmdArgContext(const CMIUtilString &vrCmdLineArgsRaw)
// Return: None.
// Throws: None.
//--
-CMICmdArgContext::~CMICmdArgContext(void)
+CMICmdArgContext::~CMICmdArgContext()
{
}
@@ -52,7 +52,7 @@ CMICmdArgContext::~CMICmdArgContext(void)
// Throws: None.
//--
const CMIUtilString &
-CMICmdArgContext::GetArgsLeftToParse(void) const
+CMICmdArgContext::GetArgsLeftToParse() const
{
return m_strCmdArgsAndOptions;
}
@@ -65,7 +65,7 @@ CMICmdArgContext::GetArgsLeftToParse(void) const
// Throws: None.
//--
bool
-CMICmdArgContext::IsEmpty(void) const
+CMICmdArgContext::IsEmpty() const
{
return m_strCmdArgsAndOptions.empty();
}
@@ -130,7 +130,7 @@ CMICmdArgContext::RemoveArg(const CMIUtilString &vArg)
}
const size_t nPosEnd = nLen + nExtraSpace;
- m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.replace(nPos, nPosEnd, "").c_str();
+ m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.replace(nPos, nPosEnd, "");
m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.Trim();
return MIstatus::success;
@@ -149,9 +149,9 @@ CMICmdArgContext::RemoveArg(const CMIUtilString &vArg)
// Throws: None.
//--
bool
-CMICmdArgContext::RemoveArgAtPos(const CMIUtilString &vArg, const MIuint nArgIndex)
+CMICmdArgContext::RemoveArgAtPos(const CMIUtilString &vArg, size_t nArgIndex)
{
- MIuint nWordIndex = 0;
+ size_t nWordIndex = 0;
CMIUtilString strBuildContextUp;
const CMIUtilString::VecString_t vecWords(GetArgs());
const bool bSpaceRequired(GetNumberArgsPresent() > 2);
@@ -202,11 +202,11 @@ CMICmdArgContext::RemoveArgAtPos(const CMIUtilString &vArg, const MIuint nArgInd
// Details: Retrieve number of arguments or options present in the command's option text.
// Type: Method.
// Args: None.
-// Return: MIuint - 0 to n arguments present.
+// Return: size_t - 0 to n arguments present.
// Throws: None.
//--
-MIuint
-CMICmdArgContext::GetNumberArgsPresent(void) const
+size_t
+CMICmdArgContext::GetNumberArgsPresent() const
{
CMIUtilString::VecString_t vecOptions;
return m_strCmdArgsAndOptions.SplitConsiderQuotes(" ", vecOptions);
@@ -220,7 +220,7 @@ CMICmdArgContext::GetNumberArgsPresent(void) const
// Throws: None.
//--
CMIUtilString::VecString_t
-CMICmdArgContext::GetArgs(void) const
+CMICmdArgContext::GetArgs() const
{
CMIUtilString::VecString_t vecOptions;
m_strCmdArgsAndOptions.SplitConsiderQuotes(" ", vecOptions);
diff --git a/tools/lldb-mi/MICmdArgContext.h b/tools/lldb-mi/MICmdArgContext.h
index baeb9232ef50..2b32c4b84276 100644
--- a/tools/lldb-mi/MICmdArgContext.h
+++ b/tools/lldb-mi/MICmdArgContext.h
@@ -16,30 +16,27 @@
// Details: MI common code class. Command arguments and options string. Holds
// the context string.
// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 14/04/2014.
-// Changes: None.
//--
class CMICmdArgContext
{
// Methods:
public:
- /* ctor */ CMICmdArgContext(void);
+ /* ctor */ CMICmdArgContext();
/* ctor */ CMICmdArgContext(const CMIUtilString &vrCmdLineArgsRaw);
//
- const CMIUtilString &GetArgsLeftToParse(void) const;
- MIuint GetNumberArgsPresent(void) const;
- CMIUtilString::VecString_t GetArgs(void) const;
- bool IsEmpty(void) const;
+ const CMIUtilString &GetArgsLeftToParse() const;
+ size_t GetNumberArgsPresent() const;
+ CMIUtilString::VecString_t GetArgs() const;
+ bool IsEmpty() const;
bool RemoveArg(const CMIUtilString &vArg);
- bool RemoveArgAtPos(const CMIUtilString &vArg, const MIuint nArgIndex);
+ bool RemoveArgAtPos(const CMIUtilString &vArg, size_t nArgIndex);
//
CMICmdArgContext &operator=(const CMICmdArgContext &vOther);
// Overridden:
public:
// From CMIUtilString
- /* dtor */ virtual ~CMICmdArgContext(void);
+ /* dtor */ virtual ~CMICmdArgContext();
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmdArgSet.cpp b/tools/lldb-mi/MICmdArgSet.cpp
index 3d63a6138f7f..9fe5b2d97dc2 100644
--- a/tools/lldb-mi/MICmdArgSet.cpp
+++ b/tools/lldb-mi/MICmdArgSet.cpp
@@ -20,7 +20,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdArgSet::CMICmdArgSet(void)
+CMICmdArgSet::CMICmdArgSet()
: m_bIsArgsPresentButNotHandledByCmd(false)
, m_constStrCommaSpc(", ")
{
@@ -33,7 +33,7 @@ CMICmdArgSet::CMICmdArgSet(void)
// Return: None.
// Throws: None.
//--
-CMICmdArgSet::~CMICmdArgSet(void)
+CMICmdArgSet::~CMICmdArgSet()
{
// Tidy up
Destroy();
@@ -47,7 +47,7 @@ CMICmdArgSet::~CMICmdArgSet(void)
// Throws: None.
//--
void
-CMICmdArgSet::Destroy(void)
+CMICmdArgSet::Destroy()
{
// Delete command argument objects
if (!m_setCmdArgs.empty())
@@ -81,7 +81,7 @@ CMICmdArgSet::Destroy(void)
// Throws: None.
//--
bool
-CMICmdArgSet::IsArgsPresentButNotHandledByCmd(void) const
+CMICmdArgSet::IsArgsPresentButNotHandledByCmd() const
{
return m_bIsArgsPresentButNotHandledByCmd;
}
@@ -90,17 +90,13 @@ CMICmdArgSet::IsArgsPresentButNotHandledByCmd(void) const
// Details: Add the list of command's arguments to parse and validate another one.
// Type: Method.
// Args: vArg - (R) A command argument object.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
+// Return: None.
// Throws: None.
//--
-bool
-CMICmdArgSet::Add(const CMICmdArgValBase &vArg)
+void
+CMICmdArgSet::Add(CMICmdArgValBase *vArg)
{
- CMICmdArgValBase *pArg = const_cast<CMICmdArgValBase *>(&vArg);
- m_setCmdArgs.push_back(pArg);
-
- return MIstatus::success;
+ m_setCmdArgs.push_back(vArg);
}
//++ ------------------------------------------------------------------------------------
@@ -113,7 +109,7 @@ CMICmdArgSet::Add(const CMICmdArgValBase &vArg)
// Throws: None.
//--
const CMICmdArgSet::SetCmdArgs_t &
-CMICmdArgSet::GetArgsThatAreMissing(void) const
+CMICmdArgSet::GetArgsThatAreMissing() const
{
return m_setCmdArgsThatAreMissing;
}
@@ -128,7 +124,7 @@ CMICmdArgSet::GetArgsThatAreMissing(void) const
// Throws: None.
//--
const CMICmdArgSet::SetCmdArgs_t &
-CMICmdArgSet::GetArgsThatInvalid(void) const
+CMICmdArgSet::GetArgsThatInvalid() const
{
return m_setCmdArgsThatNotValid;
}
@@ -146,7 +142,7 @@ CMICmdArgSet::GetArgsThatInvalid(void) const
// Throws: None.
//--
const CMICmdArgSet::SetCmdArgs_t &
-CMICmdArgSet::GetArgsNotHandledByCmd(void) const
+CMICmdArgSet::GetArgsNotHandledByCmd() const
{
return m_setCmdArgsNotHandledByCmd;
}
@@ -172,25 +168,25 @@ CMICmdArgSet::Validate(const CMIUtilString &vStrMiCmd, CMICmdArgContext &vwCmdAr
SetCmdArgs_t::const_iterator it = m_setCmdArgs.begin();
while (it != m_setCmdArgs.end())
{
- const CMICmdArgValBase *pArg(*it);
+ CMICmdArgValBase *pArg = *it;
- if (!const_cast<CMICmdArgValBase *>(pArg)->Validate(vwCmdArgsText))
+ if (!pArg->Validate(vwCmdArgsText))
{
if (pArg->GetFound())
{
if (pArg->GetIsMissingOptions())
- m_setCmdArgsMissingInfo.push_back(const_cast<CMICmdArgValBase *>(pArg));
+ m_setCmdArgsMissingInfo.push_back(pArg);
else if (!pArg->GetValid())
- m_setCmdArgsThatNotValid.push_back(const_cast<CMICmdArgValBase *>(pArg));
+ m_setCmdArgsThatNotValid.push_back(pArg);
}
else if (pArg->GetIsMandatory())
- m_setCmdArgsThatAreMissing.push_back(const_cast<CMICmdArgValBase *>(pArg));
+ m_setCmdArgsThatAreMissing.push_back(pArg);
}
if (pArg->GetFound() && !pArg->GetIsHandledByCmd())
{
m_bIsArgsPresentButNotHandledByCmd = true;
- m_setCmdArgsNotHandledByCmd.push_back(const_cast<CMICmdArgValBase *>(pArg));
+ m_setCmdArgsNotHandledByCmd.push_back(pArg);
}
// Next
@@ -326,7 +322,7 @@ CMICmdArgSet::ValidationFormErrorMessages(const CMICmdArgContext &vwCmdArgsText)
// Throws: None.
//--
bool
-CMICmdArgSet::IsArgContextEmpty(void) const
+CMICmdArgSet::IsArgContextEmpty() const
{
return m_cmdArgContext.IsEmpty();
}
@@ -335,11 +331,11 @@ CMICmdArgSet::IsArgContextEmpty(void) const
// Details: Retrieve the number of arguments that are being used for the command.
// Type: Method.
// Args: None.
-// Return: MIuint - Argument count.
+// Return: size_t - Argument count.
// Throws: None.
//--
-MIuint
-CMICmdArgSet::GetCount(void) const
+size_t
+CMICmdArgSet::GetCount() const
{
return m_setCmdArgs.size();
}
diff --git a/tools/lldb-mi/MICmdArgSet.h b/tools/lldb-mi/MICmdArgSet.h
index 0dd2933f3bb8..2b4392565e05 100644
--- a/tools/lldb-mi/MICmdArgSet.h
+++ b/tools/lldb-mi/MICmdArgSet.h
@@ -9,10 +9,12 @@
#pragma once
-// Third party headers:
+// C Includes
+// C++ Includes
#include <vector>
-// In-house headers:
+// Other libraries and framework includes
+// Project includes
#include "MICmnBase.h"
#include "MICmdArgContext.h"
@@ -30,9 +32,6 @@ class CMICmdArgValBase;
// objects on the heap.
// It is assumed the arguments to be parsed are read from left to right in
// order. The order added to *this container is the order they will parsed.
-// Gotchas: None.
-// Authors: Illya Rudkin 14/04/2014.
-// Changes: None.
//--
class CMICmdArgSet : public CMICmnBase
{
@@ -44,48 +43,44 @@ class CMICmdArgSet : public CMICmnBase
class IArg
{
public:
- virtual bool GetFound(void) const = 0;
- virtual bool GetIsHandledByCmd(void) const = 0;
- virtual bool GetIsMandatory(void) const = 0;
- virtual bool GetIsMissingOptions(void) const = 0;
- virtual const CMIUtilString &GetName(void) const = 0;
- virtual bool GetValid(void) const = 0;
+ virtual bool GetFound() const = 0;
+ virtual bool GetIsHandledByCmd() const = 0;
+ virtual bool GetIsMandatory() const = 0;
+ virtual bool GetIsMissingOptions() const = 0;
+ virtual const CMIUtilString &GetName() const = 0;
+ virtual bool GetValid() const = 0;
virtual bool Validate(CMICmdArgContext &vwArgContext) = 0;
- /* dtor */ virtual ~IArg(void){};
+ virtual ~IArg() = default;
};
// Typedefs:
- public:
typedef std::vector<CMICmdArgValBase *> SetCmdArgs_t;
// Methods:
- public:
- /* ctor */ CMICmdArgSet(void);
+ CMICmdArgSet();
- bool Add(const CMICmdArgValBase &vArg);
+ void Add(CMICmdArgValBase *vArg);
bool GetArg(const CMIUtilString &vArgName, CMICmdArgValBase *&vpArg) const;
- const SetCmdArgs_t &GetArgsThatAreMissing(void) const;
- const SetCmdArgs_t &GetArgsThatInvalid(void) const;
- MIuint GetCount(void) const;
- bool IsArgContextEmpty(void) const;
- bool IsArgsPresentButNotHandledByCmd(void) const;
+ const SetCmdArgs_t &GetArgsThatAreMissing() const;
+ const SetCmdArgs_t &GetArgsThatInvalid() const;
+ size_t GetCount() const;
+ bool IsArgContextEmpty() const;
+ bool IsArgsPresentButNotHandledByCmd() const;
void WarningArgsNotHandledbyCmdLogFile(const CMIUtilString &vrCmdName);
bool Validate(const CMIUtilString &vStrMiCmd, CMICmdArgContext &vwCmdArgsText);
// Overrideable:
- public:
- /* dtor */ virtual ~CMICmdArgSet(void);
+ ~CMICmdArgSet() override;
// Methods:
private:
- const SetCmdArgs_t &GetArgsNotHandledByCmd(void) const;
+ const SetCmdArgs_t &GetArgsNotHandledByCmd() const;
void
- Destroy(void); // Release resources used by *this object
+ Destroy(); // Release resources used by *this object
bool ValidationFormErrorMessages(const CMICmdArgContext &vwCmdArgsText);
// Attributes:
- private:
bool m_bIsArgsPresentButNotHandledByCmd; // True = The driver's client presented the command with options recognised but not handled by
// a command, false = all args handled
SetCmdArgs_t m_setCmdArgs; // The set of arguments that are that the command is expecting to find in the options string
diff --git a/tools/lldb-mi/MICmdArgValBase.cpp b/tools/lldb-mi/MICmdArgValBase.cpp
index dfaacbc6e7b2..ddbf957ea477 100644
--- a/tools/lldb-mi/MICmdArgValBase.cpp
+++ b/tools/lldb-mi/MICmdArgValBase.cpp
@@ -7,7 +7,10 @@
//
//===----------------------------------------------------------------------===//
-// In-house headers:
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "MICmdArgValBase.h"
#include "MIUtilString.h"
#include "MICmdArgContext.h"
@@ -19,7 +22,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdArgValBase::CMICmdArgValBase(void)
+CMICmdArgValBase::CMICmdArgValBase()
: m_bFound(false)
, m_bValid(false)
, m_bMandatory(false)
@@ -48,17 +51,6 @@ CMICmdArgValBase::CMICmdArgValBase(const CMIUtilString &vrArgName, const bool vb
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValBase destructor.
-// Type: Overrideable.
-// Args: None.
-// Return: None.
-// Throws: None.
-//--
-CMICmdArgValBase::~CMICmdArgValBase(void)
-{
-}
-
-//++ ------------------------------------------------------------------------------------
// Details: Retrieve the state flag of whether the argument is handled by the command or
// not.
// Type: Method.
@@ -68,7 +60,7 @@ CMICmdArgValBase::~CMICmdArgValBase(void)
// Throws: None.
//--
bool
-CMICmdArgValBase::GetIsMissingOptions(void) const
+CMICmdArgValBase::GetIsMissingOptions() const
{
return m_bIsMissingOptions;
}
@@ -83,7 +75,7 @@ CMICmdArgValBase::GetIsMissingOptions(void) const
// Throws: None.
//--
bool
-CMICmdArgValBase::GetIsHandledByCmd(void) const
+CMICmdArgValBase::GetIsHandledByCmd() const
{
return m_bHandled;
}
@@ -96,7 +88,7 @@ CMICmdArgValBase::GetIsHandledByCmd(void) const
// Throws: None.
//--
const CMIUtilString &
-CMICmdArgValBase::GetName(void) const
+CMICmdArgValBase::GetName() const
{
return m_strArgName;
}
@@ -111,7 +103,7 @@ CMICmdArgValBase::GetName(void) const
// Throws: None.
//--
bool
-CMICmdArgValBase::GetFound(void) const
+CMICmdArgValBase::GetFound() const
{
return m_bFound;
}
@@ -126,7 +118,7 @@ CMICmdArgValBase::GetFound(void) const
// Throws: None.
//--
bool
-CMICmdArgValBase::GetValid(void) const
+CMICmdArgValBase::GetValid() const
{
return m_bValid;
}
@@ -141,7 +133,7 @@ CMICmdArgValBase::GetValid(void) const
// Throws: None.
//--
bool
-CMICmdArgValBase::GetIsMandatory(void) const
+CMICmdArgValBase::GetIsMandatory() const
{
return m_bMandatory;
}
diff --git a/tools/lldb-mi/MICmdArgValBase.h b/tools/lldb-mi/MICmdArgValBase.h
index 3aaae499e5fc..c343b3338c3f 100644
--- a/tools/lldb-mi/MICmdArgValBase.h
+++ b/tools/lldb-mi/MICmdArgValBase.h
@@ -1,4 +1,4 @@
-//===-- CMICmdArgValBase.h --------------------------------------*- C++ -*-===//
+//===-- MICmdArgValBase.h ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -9,7 +9,10 @@
#pragma once
-// In-house headers:
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "MIUtilString.h"
#include "MICmdArgSet.h"
@@ -30,30 +33,25 @@
// hardwired to fail and catch arguments or options that presented by
// different driver clients.
// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 14/04/2014.
-// Changes: None.
//--
class CMICmdArgValBase : public CMICmdArgSet::IArg
{
// Methods:
public:
- /* ctor */ CMICmdArgValBase(void);
- /* ctor */ CMICmdArgValBase(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
+ CMICmdArgValBase();
+ CMICmdArgValBase(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
// Overrideable:
- public:
- /* dtor */ ~CMICmdArgValBase(void) override;
+ ~CMICmdArgValBase() override = default;
// Overridden:
- public:
// From CMICmdArgSet::IArg
- bool GetFound(void) const override;
- bool GetIsHandledByCmd(void) const override;
- bool GetIsMandatory(void) const override;
- bool GetIsMissingOptions(void) const override;
- const CMIUtilString &GetName(void) const override;
- bool GetValid(void) const override;
+ bool GetFound() const override;
+ bool GetIsHandledByCmd() const override;
+ bool GetIsMandatory() const override;
+ bool GetIsMissingOptions() const override;
+ const CMIUtilString &GetName() const override;
+ bool GetValid() const override;
bool Validate(CMICmdArgContext &vwArgContext) override;
// Attributes:
@@ -68,22 +66,18 @@ class CMICmdArgValBase : public CMICmdArgSet::IArg
//++ ============================================================================
// Details: MI common code class. Templated command argument base class.
-// Gotchas: None.
-// Authors: Illya Rudkin 14/04/2014.
-// Changes: None.
//--
template <class T> class CMICmdArgValBaseTemplate : public CMICmdArgValBase
{
// Methods:
public:
- /* ctor */ CMICmdArgValBaseTemplate(void);
- /* ctor */ CMICmdArgValBaseTemplate(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
+ CMICmdArgValBaseTemplate() = default;
+ CMICmdArgValBaseTemplate(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
//
- const T &GetValue(void) const;
+ const T &GetValue() const;
// Overrideable:
- public:
- /* dtor */ virtual ~CMICmdArgValBaseTemplate(void);
+ ~CMICmdArgValBaseTemplate() override = default;
// Attributes:
protected:
@@ -93,17 +87,6 @@ template <class T> class CMICmdArgValBaseTemplate : public CMICmdArgValBase
//++ ------------------------------------------------------------------------------------
// Details: CMICmdArgValBaseTemplate constructor.
// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
-//--
-template <class T> CMICmdArgValBaseTemplate<T>::CMICmdArgValBaseTemplate(void)
-{
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValBaseTemplate constructor.
-// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
// vbMandatory - (R) True = Yes must be present, false = optional argument.
// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
@@ -117,17 +100,6 @@ CMICmdArgValBaseTemplate<T>::CMICmdArgValBaseTemplate(const CMIUtilString &vrArg
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValBaseTemplate destructor.
-// Type: Overrideable.
-// Args: None.
-// Return: None.
-// Throws: None.
-//--
-template <class T> CMICmdArgValBaseTemplate<T>::~CMICmdArgValBaseTemplate(void)
-{
-}
-
-//++ ------------------------------------------------------------------------------------
// Details: Retrieve the value the argument parsed from the command's argument / options
// text string.
// Type: Method.
@@ -137,7 +109,7 @@ template <class T> CMICmdArgValBaseTemplate<T>::~CMICmdArgValBaseTemplate(void)
//--
template <class T>
const T &
-CMICmdArgValBaseTemplate<T>::GetValue(void) const
+CMICmdArgValBaseTemplate<T>::GetValue() const
{
return m_argValue;
}
diff --git a/tools/lldb-mi/MICmdArgValConsume.cpp b/tools/lldb-mi/MICmdArgValConsume.cpp
index c2fe9940d878..12d32912c370 100644
--- a/tools/lldb-mi/MICmdArgValConsume.cpp
+++ b/tools/lldb-mi/MICmdArgValConsume.cpp
@@ -1,4 +1,4 @@
-//===-- MICmdArgValConsume.cpp -------------------------------------*- C++ -*-===//
+//===-- MICmdArgValConsume.cpp ----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -18,7 +18,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdArgValConsume::CMICmdArgValConsume(void)
+CMICmdArgValConsume::CMICmdArgValConsume()
{
}
@@ -42,7 +42,7 @@ CMICmdArgValConsume::CMICmdArgValConsume(const CMIUtilString &vrArgName, const b
// Return: None.
// Throws: None.
//--
-CMICmdArgValConsume::~CMICmdArgValConsume(void)
+CMICmdArgValConsume::~CMICmdArgValConsume()
{
}
@@ -72,12 +72,10 @@ CMICmdArgValConsume::Validate(CMICmdArgContext &vwArgContext)
{
m_bFound = true;
m_bValid = true;
+ if ( !vwArgContext.RemoveArg( rTxt ) )
+ return MIstatus::failure;
return MIstatus::success;
}
-
- if ( !vwArgContext.RemoveArg( rTxt ) )
- return MIstatus::failure;
-
// Next
++it;
}
@@ -94,7 +92,7 @@ CMICmdArgValConsume::Validate(CMICmdArgContext &vwArgContext)
// Throws: None.
//--
bool
-CMICmdArgValConsume::IsOk(void) const
+CMICmdArgValConsume::IsOk() const
{
return true;
}
diff --git a/tools/lldb-mi/MICmdArgValConsume.h b/tools/lldb-mi/MICmdArgValConsume.h
index 75768ff52e61..792a9bed6480 100644
--- a/tools/lldb-mi/MICmdArgValConsume.h
+++ b/tools/lldb-mi/MICmdArgValConsume.h
@@ -1,4 +1,4 @@
-//===-- MICmdArgValConsume.h ---------------------------------------*- C++ -*-===//
+//===-- MICmdArgValConsume.h ------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -29,23 +29,20 @@ class CMICmdArgContext;
// a value for the argument but is not the case for *this argument type
// object.
// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 20/05/2014.
-// Changes: None.
//--
class CMICmdArgValConsume : public CMICmdArgValBaseTemplate<CMIUtilString>
{
// Methods:
public:
- /* ctor */ CMICmdArgValConsume(void);
+ /* ctor */ CMICmdArgValConsume();
/* ctor */ CMICmdArgValConsume(const CMIUtilString &vrArgName, const bool vbMandatory);
//
- bool IsOk(void) const;
+ bool IsOk() const;
// Overridden:
public:
// From CMICmdArgValBase
- /* dtor */ ~CMICmdArgValConsume(void) override;
+ /* dtor */ ~CMICmdArgValConsume() override;
// From CMICmdArgSet::IArg
bool Validate(CMICmdArgContext &vwArgContext) override;
};
diff --git a/tools/lldb-mi/MICmdArgValFile.cpp b/tools/lldb-mi/MICmdArgValFile.cpp
index 400610ff6ba6..7f5b20ec3140 100644
--- a/tools/lldb-mi/MICmdArgValFile.cpp
+++ b/tools/lldb-mi/MICmdArgValFile.cpp
@@ -18,7 +18,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdArgValFile::CMICmdArgValFile(void)
+CMICmdArgValFile::CMICmdArgValFile()
{
}
@@ -43,7 +43,7 @@ CMICmdArgValFile::CMICmdArgValFile(const CMIUtilString &vrArgName, const bool vb
// Return: None.
// Throws: None.
//--
-CMICmdArgValFile::~CMICmdArgValFile(void)
+CMICmdArgValFile::~CMICmdArgValFile()
{
}
@@ -142,23 +142,23 @@ CMICmdArgValFile::IsFilePath(const CMIUtilString &vrFileNamePath) const
if (vrFileNamePath.empty())
return false;
- const bool bHavePosSlash = (vrFileNamePath.find_first_of("/") != std::string::npos);
- const bool bHaveBckSlash = (vrFileNamePath.find_first_of("\\") != std::string::npos);
+ const bool bHavePosSlash = (vrFileNamePath.find('/') != std::string::npos);
+ const bool bHaveBckSlash = (vrFileNamePath.find('\\') != std::string::npos);
// Look for --someLongOption
- size_t nPos = vrFileNamePath.find_first_of("--");
+ size_t nPos = vrFileNamePath.find("--");
const bool bLong = (nPos == 0);
if (bLong)
return false;
// Look for -f type short parameters
- nPos = vrFileNamePath.find_first_of("-");
+ nPos = vrFileNamePath.find('-');
const bool bShort = (nPos == 0);
if (bShort)
return false;
// Look for i1 i2 i3....
- nPos = vrFileNamePath.find_first_of("i");
+ nPos = vrFileNamePath.find('i');
const bool bFoundI1 = ((nPos == 0) && (::isdigit(vrFileNamePath[1])));
if (bFoundI1)
return false;
diff --git a/tools/lldb-mi/MICmdArgValFile.h b/tools/lldb-mi/MICmdArgValFile.h
index 07abc4baa242..25d9842ec07c 100644
--- a/tools/lldb-mi/MICmdArgValFile.h
+++ b/tools/lldb-mi/MICmdArgValFile.h
@@ -22,15 +22,12 @@ class CMICmdArgContext;
// interpret the options (context) string to find and validate a matching
// argument and so extract a value from it .
// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 15/04/2014.
-// Changes: None.
//--
class CMICmdArgValFile : public CMICmdArgValBaseTemplate<CMIUtilString>
{
// Methods:
public:
- /* ctor */ CMICmdArgValFile(void);
+ /* ctor */ CMICmdArgValFile();
/* ctor */ CMICmdArgValFile(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
//
bool IsFilePath(const CMIUtilString &vrFileNamePath) const;
@@ -39,7 +36,7 @@ class CMICmdArgValFile : public CMICmdArgValBaseTemplate<CMIUtilString>
// Overridden:
public:
// From CMICmdArgValBase
- /* dtor */ ~CMICmdArgValFile(void) override;
+ /* dtor */ ~CMICmdArgValFile() override;
// From CMICmdArgSet::IArg
bool Validate(CMICmdArgContext &vwArgContext) override;
diff --git a/tools/lldb-mi/MICmdArgValListBase.cpp b/tools/lldb-mi/MICmdArgValListBase.cpp
index 61d72fb823c7..05396284e225 100644
--- a/tools/lldb-mi/MICmdArgValListBase.cpp
+++ b/tools/lldb-mi/MICmdArgValListBase.cpp
@@ -25,7 +25,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdArgValListBase::CMICmdArgValListBase(void)
+CMICmdArgValListBase::CMICmdArgValListBase()
: m_eArgType(eArgValType_invalid)
{
}
@@ -69,7 +69,7 @@ CMICmdArgValListBase::CMICmdArgValListBase(const CMIUtilString &vrArgName, const
// Return: None.
// Throws: None.
//--
-CMICmdArgValListBase::~CMICmdArgValListBase(void)
+CMICmdArgValListBase::~CMICmdArgValListBase()
{
// Tidy up
Destroy();
@@ -83,7 +83,7 @@ CMICmdArgValListBase::~CMICmdArgValListBase(void)
// Throws: None.
//--
void
-CMICmdArgValListBase::Destroy(void)
+CMICmdArgValListBase::Destroy()
{
// Tidy up
VecArgObjPtr_t::const_iterator it = m_argValue.begin();
diff --git a/tools/lldb-mi/MICmdArgValListBase.h b/tools/lldb-mi/MICmdArgValListBase.h
index f0135620321f..59ef3bb6019d 100644
--- a/tools/lldb-mi/MICmdArgValListBase.h
+++ b/tools/lldb-mi/MICmdArgValListBase.h
@@ -31,9 +31,6 @@ class CMICmdArgContext;
// container. The option arguments belong to that derived class and will
// be deleted that object goes out of scope.
// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 16/04/2014.
-// Changes: None.
//--
class CMICmdArgValListBase : public CMICmdArgValBaseTemplate<std::vector<CMICmdArgValBase *>>
{
@@ -67,7 +64,7 @@ class CMICmdArgValListBase : public CMICmdArgValBaseTemplate<std::vector<CMICmdA
// Methods:
public:
- /* ctor */ CMICmdArgValListBase(void);
+ /* ctor */ CMICmdArgValListBase();
/* ctor */ CMICmdArgValListBase(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
/* ctor */ CMICmdArgValListBase(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
const ArgValType_e veType);
@@ -75,7 +72,7 @@ class CMICmdArgValListBase : public CMICmdArgValBaseTemplate<std::vector<CMICmdA
// Overridden:
public:
// From CMICmdArgValBase
- /* dtor */ ~CMICmdArgValListBase(void) override;
+ /* dtor */ ~CMICmdArgValListBase() override;
// Methods:
protected:
@@ -88,5 +85,5 @@ class CMICmdArgValListBase : public CMICmdArgValBaseTemplate<std::vector<CMICmdA
// Methods:
private:
- void Destroy(void);
+ void Destroy();
};
diff --git a/tools/lldb-mi/MICmdArgValListOfN.cpp b/tools/lldb-mi/MICmdArgValListOfN.cpp
index 8e479d52e79a..78f5fdc65f49 100644
--- a/tools/lldb-mi/MICmdArgValListOfN.cpp
+++ b/tools/lldb-mi/MICmdArgValListOfN.cpp
@@ -24,7 +24,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdArgValListOfN::CMICmdArgValListOfN(void)
+CMICmdArgValListOfN::CMICmdArgValListOfN()
{
}
@@ -51,7 +51,7 @@ CMICmdArgValListOfN::CMICmdArgValListOfN(const CMIUtilString &vrArgName, const b
// Return: None.
// Throws: None.
//--
-CMICmdArgValListOfN::~CMICmdArgValListOfN(void)
+CMICmdArgValListOfN::~CMICmdArgValListOfN()
{
}
@@ -170,7 +170,7 @@ CMICmdArgValListOfN::IsListOfN(const CMIUtilString &vrTxt) const
// Throws: None.
//--
const CMICmdArgValListBase::VecArgObjPtr_t &
-CMICmdArgValListOfN::GetExpectedOptions(void) const
+CMICmdArgValListOfN::GetExpectedOptions() const
{
return m_argValue;
}
diff --git a/tools/lldb-mi/MICmdArgValListOfN.h b/tools/lldb-mi/MICmdArgValListOfN.h
index 496bc6581117..7499a7f7e91b 100644
--- a/tools/lldb-mi/MICmdArgValListOfN.h
+++ b/tools/lldb-mi/MICmdArgValListOfN.h
@@ -31,25 +31,22 @@ class CMICmdArgContext;
// If vbMandatory argument is true it takes on the (...)+ specification
// otherwise assumed to be (...)* specification.
// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 16/04/2014.
-// Changes: None.
//--
class CMICmdArgValListOfN : public CMICmdArgValListBase
{
// Methods:
public:
- /* ctor */ CMICmdArgValListOfN(void);
+ /* ctor */ CMICmdArgValListOfN();
/* ctor */ CMICmdArgValListOfN(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
const ArgValType_e veType);
//
- const VecArgObjPtr_t &GetExpectedOptions(void) const;
+ const VecArgObjPtr_t &GetExpectedOptions() const;
template <class T1, typename T2> bool GetExpectedOption(T2 &vrwValue, const VecArgObjPtr_t::size_type vnAt = 0) const;
// Overridden:
public:
// From CMICmdArgValBase
- /* dtor */ ~CMICmdArgValListOfN(void) override;
+ /* dtor */ ~CMICmdArgValListOfN() override;
// From CMICmdArgSet::IArg
bool Validate(CMICmdArgContext &vArgContext) override;
diff --git a/tools/lldb-mi/MICmdArgValNumber.cpp b/tools/lldb-mi/MICmdArgValNumber.cpp
index 75e9700c874d..5d907ca9f1ed 100644
--- a/tools/lldb-mi/MICmdArgValNumber.cpp
+++ b/tools/lldb-mi/MICmdArgValNumber.cpp
@@ -18,7 +18,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdArgValNumber::CMICmdArgValNumber(void)
+CMICmdArgValNumber::CMICmdArgValNumber()
: m_nNumberFormatMask(CMICmdArgValNumber::eArgValNumberFormat_Decimal)
, m_nNumber(0)
{
@@ -49,7 +49,7 @@ CMICmdArgValNumber::CMICmdArgValNumber(const CMIUtilString &vrArgName, const boo
// Return: None.
// Throws: None.
//--
-CMICmdArgValNumber::~CMICmdArgValNumber(void)
+CMICmdArgValNumber::~CMICmdArgValNumber()
{
}
@@ -165,7 +165,7 @@ CMICmdArgValNumber::ExtractNumber(const CMIUtilString &vrTxt)
// Throws: None.
//--
MIint64
-CMICmdArgValNumber::GetNumber(void) const
+CMICmdArgValNumber::GetNumber() const
{
return m_nNumber;
}
diff --git a/tools/lldb-mi/MICmdArgValNumber.h b/tools/lldb-mi/MICmdArgValNumber.h
index 58a28b379e3e..0b05e57c6bff 100644
--- a/tools/lldb-mi/MICmdArgValNumber.h
+++ b/tools/lldb-mi/MICmdArgValNumber.h
@@ -22,9 +22,6 @@ class CMICmdArgContext;
// interpret the options (context) string to find and validate a matching
// argument and so extract a value from it .
// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 14/04/2014.
-// Changes: None.
//--
class CMICmdArgValNumber : public CMICmdArgValBaseTemplate<MIint64>
{
@@ -43,7 +40,7 @@ class CMICmdArgValNumber : public CMICmdArgValBaseTemplate<MIint64>
// Methods:
public:
- /* ctor */ CMICmdArgValNumber(void);
+ /* ctor */ CMICmdArgValNumber();
/* ctor */ CMICmdArgValNumber(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
const MIuint vnNumberFormatMask = eArgValNumberFormat_Decimal);
//
@@ -52,14 +49,14 @@ class CMICmdArgValNumber : public CMICmdArgValBaseTemplate<MIint64>
// Overridden:
public:
// From CMICmdArgValBase
- /* dtor */ ~CMICmdArgValNumber(void) override;
+ /* dtor */ ~CMICmdArgValNumber() override;
// From CMICmdArgSet::IArg
bool Validate(CMICmdArgContext &vwArgContext) override;
// Methods:
private:
bool ExtractNumber(const CMIUtilString &vrTxt);
- MIint64 GetNumber(void) const;
+ MIint64 GetNumber() const;
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmdArgValOptionLong.cpp b/tools/lldb-mi/MICmdArgValOptionLong.cpp
index 0eaf6e0d055f..3c9578943072 100644
--- a/tools/lldb-mi/MICmdArgValOptionLong.cpp
+++ b/tools/lldb-mi/MICmdArgValOptionLong.cpp
@@ -18,7 +18,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdArgValOptionLong::CMICmdArgValOptionLong(void)
+CMICmdArgValOptionLong::CMICmdArgValOptionLong()
: m_nExpectingNOptions(0)
, m_eExpectingOptionType(eArgValType_invalid)
{
@@ -66,7 +66,7 @@ CMICmdArgValOptionLong::CMICmdArgValOptionLong(const CMIUtilString &vrArgName, c
// Return: None.
// Throws: None.
//--
-CMICmdArgValOptionLong::~CMICmdArgValOptionLong(void)
+CMICmdArgValOptionLong::~CMICmdArgValOptionLong()
{
// Tidy up
Destroy();
@@ -80,7 +80,7 @@ CMICmdArgValOptionLong::~CMICmdArgValOptionLong(void)
// Throws: None.
//--
void
-CMICmdArgValOptionLong::Destroy(void)
+CMICmdArgValOptionLong::Destroy()
{
// Tidy up
VecArgObjPtr_t::const_iterator it = m_vecArgsExpected.begin();
@@ -249,19 +249,19 @@ CMICmdArgValOptionLong::ExtractExpectedOptions(CMICmdArgContext &vrwTxt, const M
bool
CMICmdArgValOptionLong::IsArgLongOption(const CMIUtilString &vrTxt) const
{
- const bool bHavePosSlash = (vrTxt.find_first_of("/") != std::string::npos);
- const bool bHaveBckSlash = (vrTxt.find_first_of("\\") != std::string::npos);
+ const bool bHavePosSlash = (vrTxt.find('/') != std::string::npos);
+ const bool bHaveBckSlash = (vrTxt.find('\\') != std::string::npos);
if (bHavePosSlash || bHaveBckSlash)
return false;
- const size_t nPos = vrTxt.find_first_of("--");
+ const size_t nPos = vrTxt.find("--");
if (nPos != 0)
return false;
if (vrTxt.length() < 3)
return false;
- const CMIUtilString strArg = vrTxt.substr(2).c_str();
+ const CMIUtilString strArg = vrTxt.substr(2);
if (strArg.IsNumber())
return false;
@@ -293,7 +293,7 @@ CMICmdArgValOptionLong::IsArgOptionCorrect(const CMIUtilString &vrTxt) const
bool
CMICmdArgValOptionLong::ArgNameMatch(const CMIUtilString &vrTxt) const
{
- const CMIUtilString strArg = vrTxt.substr(2).c_str();
+ const CMIUtilString strArg = vrTxt.substr(2);
return (strArg == GetName());
}
@@ -307,7 +307,7 @@ CMICmdArgValOptionLong::ArgNameMatch(const CMIUtilString &vrTxt) const
// Throws: None.
//--
const CMICmdArgValListBase::VecArgObjPtr_t &
-CMICmdArgValOptionLong::GetExpectedOptions(void) const
+CMICmdArgValOptionLong::GetExpectedOptions() const
{
return m_vecArgsExpected;
}
diff --git a/tools/lldb-mi/MICmdArgValOptionLong.h b/tools/lldb-mi/MICmdArgValOptionLong.h
index ac55c47fb7af..9d074fc07459 100644
--- a/tools/lldb-mi/MICmdArgValOptionLong.h
+++ b/tools/lldb-mi/MICmdArgValOptionLong.h
@@ -26,27 +26,24 @@ class CMIUtilString;
// created to hold each of those option's values belong to *this argument
// object and so are deleted when *this object goes out of scope.
// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 16/04/2014.
-// Changes: None.
//--
class CMICmdArgValOptionLong : public CMICmdArgValListBase
{
// Methods:
public:
- /* ctor */ CMICmdArgValOptionLong(void);
+ /* ctor */ CMICmdArgValOptionLong();
/* ctor */ CMICmdArgValOptionLong(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
/* ctor */ CMICmdArgValOptionLong(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
const ArgValType_e veType, const MIuint vnExpectingNOptions);
//
bool IsArgLongOption(const CMIUtilString &vrTxt) const;
- const VecArgObjPtr_t &GetExpectedOptions(void) const;
+ const VecArgObjPtr_t &GetExpectedOptions() const;
template <class T1, typename T2> bool GetExpectedOption(T2 &vrwValue) const;
// Overridden:
public:
// From CMICmdArgValBase
- /* dtor */ ~CMICmdArgValOptionLong(void) override;
+ /* dtor */ ~CMICmdArgValOptionLong() override;
// From CMICmdArgSet::IArg
bool Validate(CMICmdArgContext &vArgContext) override;
@@ -61,7 +58,7 @@ class CMICmdArgValOptionLong : public CMICmdArgValListBase
// Methods:
private:
- void Destroy(void);
+ void Destroy();
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmdArgValOptionShort.cpp b/tools/lldb-mi/MICmdArgValOptionShort.cpp
index d18f72eaa8b1..d5bdfa0fa2cb 100644
--- a/tools/lldb-mi/MICmdArgValOptionShort.cpp
+++ b/tools/lldb-mi/MICmdArgValOptionShort.cpp
@@ -18,7 +18,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdArgValOptionShort::CMICmdArgValOptionShort(void)
+CMICmdArgValOptionShort::CMICmdArgValOptionShort()
{
}
@@ -60,7 +60,7 @@ CMICmdArgValOptionShort::CMICmdArgValOptionShort(const CMIUtilString &vrArgName,
// Return: None.
// Throws: None.
//--
-CMICmdArgValOptionShort::~CMICmdArgValOptionShort(void)
+CMICmdArgValOptionShort::~CMICmdArgValOptionShort()
{
}
@@ -115,6 +115,6 @@ CMICmdArgValOptionShort::IsArgOptionCorrect(const CMIUtilString &vrTxt) const
bool
CMICmdArgValOptionShort::ArgNameMatch(const CMIUtilString &vrTxt) const
{
- const CMIUtilString strArg = vrTxt.substr(1).c_str();
+ const CMIUtilString strArg = vrTxt.substr(1);
return (strArg == GetName());
}
diff --git a/tools/lldb-mi/MICmdArgValOptionShort.h b/tools/lldb-mi/MICmdArgValOptionShort.h
index 9157b37bb8dc..0f1c2fc12c3d 100644
--- a/tools/lldb-mi/MICmdArgValOptionShort.h
+++ b/tools/lldb-mi/MICmdArgValOptionShort.h
@@ -26,15 +26,12 @@ class CMIUtilString;
// created to hold each of those option's values belong to *this argument
// object and so are deleted when *this object goes out of scope.
// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 16/04/2014.
-// Changes: None.
//--
class CMICmdArgValOptionShort : public CMICmdArgValOptionLong
{
// Methods:
public:
- /* ctor */ CMICmdArgValOptionShort(void);
+ /* ctor */ CMICmdArgValOptionShort();
/* ctor */ CMICmdArgValOptionShort(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
/* ctor */ CMICmdArgValOptionShort(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
const ArgValType_e veType, const MIuint vnExpectingNOptions);
@@ -44,7 +41,7 @@ class CMICmdArgValOptionShort : public CMICmdArgValOptionLong
// Overridden:
public:
// From CMICmdArgValBase
- /* dtor */ ~CMICmdArgValOptionShort(void) override;
+ /* dtor */ ~CMICmdArgValOptionShort() override;
// Overridden:
private:
diff --git a/tools/lldb-mi/MICmdArgValPrintValues.cpp b/tools/lldb-mi/MICmdArgValPrintValues.cpp
index 3030782a3a29..3b6eddd315ac 100644
--- a/tools/lldb-mi/MICmdArgValPrintValues.cpp
+++ b/tools/lldb-mi/MICmdArgValPrintValues.cpp
@@ -18,7 +18,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdArgValPrintValues::CMICmdArgValPrintValues(void)
+CMICmdArgValPrintValues::CMICmdArgValPrintValues()
: m_nPrintValues(0)
{
}
@@ -45,7 +45,7 @@ CMICmdArgValPrintValues::CMICmdArgValPrintValues(const CMIUtilString &vrArgName,
// Return: None.
// Throws: None.
//--
-CMICmdArgValPrintValues::~CMICmdArgValPrintValues(void)
+CMICmdArgValPrintValues::~CMICmdArgValPrintValues()
{
}
@@ -123,7 +123,7 @@ CMICmdArgValPrintValues::ExtractPrintValues(const CMIUtilString &vrTxt)
// Throws: None.
//--
MIuint
-CMICmdArgValPrintValues::GetPrintValues(void) const
+CMICmdArgValPrintValues::GetPrintValues() const
{
return m_nPrintValues;
}
diff --git a/tools/lldb-mi/MICmdArgValPrintValues.h b/tools/lldb-mi/MICmdArgValPrintValues.h
index 9ac3238aeb75..fa8ec8a54773 100644
--- a/tools/lldb-mi/MICmdArgValPrintValues.h
+++ b/tools/lldb-mi/MICmdArgValPrintValues.h
@@ -30,7 +30,7 @@ class CMICmdArgValPrintValues : public CMICmdArgValBaseTemplate<MIuint>
{
// Methods:
public:
- /* ctor */ CMICmdArgValPrintValues(void);
+ /* ctor */ CMICmdArgValPrintValues();
/* ctor */ CMICmdArgValPrintValues(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
//
bool IsArgPrintValues(const CMIUtilString &vrTxt) const;
@@ -38,14 +38,14 @@ class CMICmdArgValPrintValues : public CMICmdArgValBaseTemplate<MIuint>
// Overridden:
public:
// From CMICmdArgValBase
- /* dtor */ ~CMICmdArgValPrintValues(void) override;
+ /* dtor */ ~CMICmdArgValPrintValues() override;
// From CMICmdArgSet::IArg
bool Validate(CMICmdArgContext &vArgContext) override;
// Methods:
private:
bool ExtractPrintValues(const CMIUtilString &vrTxt);
- MIuint GetPrintValues(void) const;
+ MIuint GetPrintValues() const;
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmdArgValString.cpp b/tools/lldb-mi/MICmdArgValString.cpp
index 1c3e5f84d3dd..bea593552327 100644
--- a/tools/lldb-mi/MICmdArgValString.cpp
+++ b/tools/lldb-mi/MICmdArgValString.cpp
@@ -18,7 +18,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdArgValString::CMICmdArgValString(void)
+CMICmdArgValString::CMICmdArgValString()
: m_bHandleQuotedString(false)
, m_bAcceptNumbers(false)
, m_bHandleDirPaths(false)
@@ -91,7 +91,7 @@ CMICmdArgValString::CMICmdArgValString(const CMIUtilString &vrArgName, const boo
// Return: None.
// Throws: None.
//--
-CMICmdArgValString::~CMICmdArgValString(void)
+CMICmdArgValString::~CMICmdArgValString()
{
}
@@ -220,8 +220,8 @@ CMICmdArgValString::IsStringArgSingleText(const CMIUtilString &vrTxt) const
if (!m_bHandleDirPaths)
{
// Look for directory file paths, if found reject
- const bool bHavePosSlash = (vrTxt.find_first_of("/") != std::string::npos);
- const bool bHaveBckSlash = (vrTxt.find_first_of("\\") != std::string::npos);
+ const bool bHavePosSlash = (vrTxt.find('/') != std::string::npos);
+ const bool bHaveBckSlash = (vrTxt.find('\\') != std::string::npos);
if (bHavePosSlash || bHaveBckSlash)
return false;
}
diff --git a/tools/lldb-mi/MICmdArgValString.h b/tools/lldb-mi/MICmdArgValString.h
index 8b58a0a88dd6..cf4d00e192cc 100644
--- a/tools/lldb-mi/MICmdArgValString.h
+++ b/tools/lldb-mi/MICmdArgValString.h
@@ -22,15 +22,12 @@ class CMICmdArgContext;
// interpret the options (context) string to find and validate a matching
// argument and so extract a value from it .
// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 15/04/2014.
-// Changes: None.
//--
class CMICmdArgValString : public CMICmdArgValBaseTemplate<CMIUtilString>
{
// Methods:
public:
- /* ctor */ CMICmdArgValString(void);
+ /* ctor */ CMICmdArgValString();
/* ctor */ CMICmdArgValString(const bool vbAnything);
/* ctor */ CMICmdArgValString(const bool vbHandleQuotes, const bool vbAcceptNumbers, const bool vbHandleDirPaths);
/* ctor */ CMICmdArgValString(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
@@ -41,7 +38,7 @@ class CMICmdArgValString : public CMICmdArgValBaseTemplate<CMIUtilString>
// Overridden:
public:
// From CMICmdArgValBase
- /* dtor */ ~CMICmdArgValString(void) override;
+ /* dtor */ ~CMICmdArgValString() override;
// From CMICmdArgSet::IArg
bool Validate(CMICmdArgContext &vrwArgContext) override;
diff --git a/tools/lldb-mi/MICmdArgValThreadGrp.cpp b/tools/lldb-mi/MICmdArgValThreadGrp.cpp
index c7e663c4721b..43e9c724dca1 100644
--- a/tools/lldb-mi/MICmdArgValThreadGrp.cpp
+++ b/tools/lldb-mi/MICmdArgValThreadGrp.cpp
@@ -18,7 +18,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdArgValThreadGrp::CMICmdArgValThreadGrp(void)
+CMICmdArgValThreadGrp::CMICmdArgValThreadGrp()
: m_nThreadGrp(0)
{
}
@@ -45,7 +45,7 @@ CMICmdArgValThreadGrp::CMICmdArgValThreadGrp(const CMIUtilString &vrArgName, con
// Return: None.
// Throws: None.
//--
-CMICmdArgValThreadGrp::~CMICmdArgValThreadGrp(void)
+CMICmdArgValThreadGrp::~CMICmdArgValThreadGrp()
{
}
@@ -117,11 +117,11 @@ bool
CMICmdArgValThreadGrp::IsArgThreadGrp(const CMIUtilString &vrTxt) const
{
// Look for i1 i2 i3....
- const MIint nPos = vrTxt.find_first_of("i");
+ const MIint nPos = vrTxt.find('i');
if (nPos != 0)
return false;
- const CMIUtilString strNum = vrTxt.substr(1).c_str();
+ const CMIUtilString strNum = vrTxt.substr(1);
if (!strNum.IsNumber())
return false;
@@ -139,7 +139,7 @@ CMICmdArgValThreadGrp::IsArgThreadGrp(const CMIUtilString &vrTxt) const
bool
CMICmdArgValThreadGrp::ExtractNumber(const CMIUtilString &vrTxt)
{
- const CMIUtilString strNum = vrTxt.substr(1).c_str();
+ const CMIUtilString strNum = vrTxt.substr(1);
MIint64 nNumber = 0;
bool bOk = strNum.ExtractNumber(nNumber);
if (bOk)
@@ -158,7 +158,7 @@ CMICmdArgValThreadGrp::ExtractNumber(const CMIUtilString &vrTxt)
// Throws: None.
//--
MIuint
-CMICmdArgValThreadGrp::GetNumber(void) const
+CMICmdArgValThreadGrp::GetNumber() const
{
return m_nThreadGrp;
}
diff --git a/tools/lldb-mi/MICmdArgValThreadGrp.h b/tools/lldb-mi/MICmdArgValThreadGrp.h
index 64c11405e8ab..5c4936c01520 100644
--- a/tools/lldb-mi/MICmdArgValThreadGrp.h
+++ b/tools/lldb-mi/MICmdArgValThreadGrp.h
@@ -23,15 +23,12 @@ class CMICmdArgContext;
// argument and so extract a value from it. Thread group looks like
// "i1" in the options text.
// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 15/04/2014.
-// Changes: None.
//--
class CMICmdArgValThreadGrp : public CMICmdArgValBaseTemplate<MIuint>
{
// Methods:
public:
- /* ctor */ CMICmdArgValThreadGrp(void);
+ /* ctor */ CMICmdArgValThreadGrp();
/* ctor */ CMICmdArgValThreadGrp(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
//
bool IsArgThreadGrp(const CMIUtilString &vrTxt) const;
@@ -39,14 +36,14 @@ class CMICmdArgValThreadGrp : public CMICmdArgValBaseTemplate<MIuint>
// Overridden:
public:
// From CMICmdArgValBase
- /* dtor */ ~CMICmdArgValThreadGrp(void) override;
+ /* dtor */ ~CMICmdArgValThreadGrp() override;
// From CMICmdArgSet::IArg
bool Validate(CMICmdArgContext &vArgContext) override;
// Methods:
private:
bool ExtractNumber(const CMIUtilString &vrTxt);
- MIuint GetNumber(void) const;
+ MIuint GetNumber() const;
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmdBase.cpp b/tools/lldb-mi/MICmdBase.cpp
index 97bf5a074d6d..2f63205dd9b7 100644
--- a/tools/lldb-mi/MICmdBase.cpp
+++ b/tools/lldb-mi/MICmdBase.cpp
@@ -11,6 +11,8 @@
#include "MICmdBase.h"
#include "MICmnMIValueConst.h"
#include "MICmnLLDBDebugSessionInfo.h"
+#include "MICmdArgValOptionLong.h"
+#include "MICmdArgValConsume.h"
//++ ------------------------------------------------------------------------------------
// Details: CMICmdBase constructor.
@@ -19,10 +21,17 @@
// Return: None.
// Throws: None.
//--
-CMICmdBase::CMICmdBase(void)
+CMICmdBase::CMICmdBase()
: m_pSelfCreatorFn(nullptr)
, m_rLLDBDebugSessionInfo(CMICmnLLDBDebugSessionInfo::Instance())
, m_bHasResultRecordExtra(false)
+ , m_constStrArgThreadGroup("thread-group")
+ , m_constStrArgThread("thread")
+ , m_constStrArgFrame("frame")
+ , m_constStrArgConsume("--")
+ , m_ThreadGrpArgMandatory(false)
+ , m_ThreadArgMandatory(false)
+ , m_FrameArgMandatory(false)
{
}
@@ -33,7 +42,7 @@ CMICmdBase::CMICmdBase(void)
// Return: None.
// Throws: None.
//--
-CMICmdBase::~CMICmdBase(void)
+CMICmdBase::~CMICmdBase()
{
}
@@ -45,7 +54,7 @@ CMICmdBase::~CMICmdBase(void)
// Throws: None.
//--
const SMICmdData &
-CMICmdBase::GetCmdData(void) const
+CMICmdBase::GetCmdData() const
{
return m_cmdData;
}
@@ -59,7 +68,7 @@ CMICmdBase::GetCmdData(void) const
// Throws: None.
//--
const CMIUtilString &
-CMICmdBase::GetErrorDescription(void) const
+CMICmdBase::GetErrorDescription() const
{
return m_strCurrentErrDescription;
}
@@ -73,26 +82,38 @@ CMICmdBase::GetErrorDescription(void) const
// Throws: None.
//--
const CMIUtilString &
-CMICmdBase::GetMiCmd(void) const
+CMICmdBase::GetMiCmd() const
{
return m_strMiCmd;
}
//++ ------------------------------------------------------------------------------------
+// Details: Help parse the arguments that are common to all commands.
+// Args: None.
+// Return: None
+// Throws: None.
+//--
+void
+CMICmdBase::AddCommonArgs()
+{
+ m_setCmdArgs.Add(new CMICmdArgValOptionLong(m_constStrArgThreadGroup, m_ThreadGrpArgMandatory, true, CMICmdArgValListBase::eArgValType_ThreadGrp, 1));
+ m_setCmdArgs.Add(new CMICmdArgValOptionLong(m_constStrArgThread, m_ThreadArgMandatory, true, CMICmdArgValListBase::eArgValType_Number, 1));
+ m_setCmdArgs.Add(new CMICmdArgValOptionLong(m_constStrArgFrame, m_FrameArgMandatory, true, CMICmdArgValListBase::eArgValType_Number, 1));
+ m_setCmdArgs.Add(new CMICmdArgValConsume(m_constStrArgConsume, false));
+}
+
+//++ ------------------------------------------------------------------------------------
// Details: The invoker requires this function. A command must be given working data and
// provide data about its status or provide information to other objects.
// Type: Overridden.
// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
+// Return: None.
// Throws: None.
//--
-bool
+void
CMICmdBase::SetCmdData(const SMICmdData &vCmdData)
{
m_cmdData = vCmdData;
-
- return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
@@ -104,7 +125,7 @@ CMICmdBase::SetCmdData(const SMICmdData &vCmdData)
// Throws: None.
//--
CMICmdFactory::CmdCreatorFnPtr
-CMICmdBase::GetCmdCreatorFn(void) const
+CMICmdBase::GetCmdCreatorFn() const
{
return m_pSelfCreatorFn;
}
@@ -120,7 +141,7 @@ CMICmdBase::GetCmdCreatorFn(void) const
// Throws: None.
//--
void
-CMICmdBase::CmdFinishedTellInvoker(void) const
+CMICmdBase::CmdFinishedTellInvoker() const
{
CMICmdInvoker::Instance().CmdExecuteFinished(const_cast<CMICmdBase &>(*this));
}
@@ -134,7 +155,7 @@ CMICmdBase::CmdFinishedTellInvoker(void) const
// Throws: None.
//--
const CMIUtilString &
-CMICmdBase::GetMIResultRecord(void) const
+CMICmdBase::GetMIResultRecord() const
{
return m_miResultRecord.GetString();
}
@@ -149,7 +170,7 @@ CMICmdBase::GetMIResultRecord(void) const
// Throws: None.
//--
const CMIUtilString &
-CMICmdBase::GetMIResultRecordExtra(void) const
+CMICmdBase::GetMIResultRecordExtra() const
{
return m_miResultRecordExtra;
}
@@ -164,7 +185,7 @@ CMICmdBase::GetMIResultRecordExtra(void) const
// Throws: None.
//--
bool
-CMICmdBase::HasMIResultRecordExtra(void) const
+CMICmdBase::HasMIResultRecordExtra() const
{
return m_bHasResultRecordExtra;
}
@@ -198,7 +219,7 @@ CMICmdBase::SetError(const CMIUtilString &rErrMsg)
// Throws: None.
//--
MIuint
-CMICmdBase::GetGUID(void)
+CMICmdBase::GetGUID()
{
MIuint64 vptr = reinterpret_cast<MIuint64>(this);
MIuint id = (vptr)&0xFFFFFFFF;
@@ -217,7 +238,7 @@ CMICmdBase::GetGUID(void)
// Throws: None.
//--
bool
-CMICmdBase::ParseArgs(void)
+CMICmdBase::ParseArgs()
{
// Do nothing - override to implement
@@ -236,7 +257,7 @@ CMICmdBase::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdBase::ParseValidateCmdOptions(void)
+CMICmdBase::ParseValidateCmdOptions()
{
CMICmdArgContext argCntxt(m_cmdData.strMiCmdOption);
if (m_setCmdArgs.Validate(m_cmdData.strMiCmd, argCntxt))
@@ -259,7 +280,7 @@ CMICmdBase::ParseValidateCmdOptions(void)
// Throws: None.
//--
bool
-CMICmdBase::GetExitAppOnCommandFailure(void) const
+CMICmdBase::GetExitAppOnCommandFailure() const
{
return false;
}
diff --git a/tools/lldb-mi/MICmdBase.h b/tools/lldb-mi/MICmdBase.h
index df1e429bdce6..aa5674823965 100644
--- a/tools/lldb-mi/MICmdBase.h
+++ b/tools/lldb-mi/MICmdBase.h
@@ -9,7 +9,10 @@
#pragma once
-// In-house headers:
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "MIUtilString.h"
#include "MICmnBase.h"
#include "MICmnResources.h"
@@ -42,46 +45,41 @@ class CMICmnLLDBDebugSessionInfo;
// to factor handling and parsing of different types of arguments
// presented to a command. A command will produce an error should it
// be presented with arguments or options it does not understand.
-// Gotchas: None.
-// Authors: Illya Rudkin 18/02/2014.
-// Changes: None.
//--
class CMICmdBase : public CMICmnBase, public CMICmdInvoker::ICmd, public CMICmdFactory::ICmd
{
// Methods:
public:
- /* ctor */ CMICmdBase(void);
+ CMICmdBase();
// Overridden:
- public:
// From CMICmdInvoker::ICmd
- virtual const SMICmdData &GetCmdData(void) const;
- virtual const CMIUtilString &GetErrorDescription(void) const;
- virtual bool SetCmdData(const SMICmdData &vCmdData);
- virtual void CmdFinishedTellInvoker(void) const;
- virtual const CMIUtilString &GetMIResultRecord(void) const;
- virtual const CMIUtilString &GetMIResultRecordExtra(void) const;
- virtual bool HasMIResultRecordExtra(void) const;
- virtual bool ParseArgs(void);
+ const SMICmdData &GetCmdData() const override;
+ const CMIUtilString &GetErrorDescription() const override;
+ void SetCmdData(const SMICmdData &vCmdData) override;
+ void CmdFinishedTellInvoker() const override;
+ const CMIUtilString &GetMIResultRecord() const override;
+ const CMIUtilString &GetMIResultRecordExtra() const override;
+ bool HasMIResultRecordExtra() const override;
+ bool ParseArgs() override;
// From CMICmdFactory::ICmd
- virtual const CMIUtilString &GetMiCmd(void) const;
- virtual CMICmdFactory::CmdCreatorFnPtr GetCmdCreatorFn(void) const;
+ const CMIUtilString &GetMiCmd() const override;
+ CMICmdFactory::CmdCreatorFnPtr GetCmdCreatorFn() const override;
- virtual MIuint GetGUID(void);
+ virtual MIuint GetGUID();
+ void AddCommonArgs();
// Overrideable:
- public:
- /* dtor */ virtual ~CMICmdBase(void);
- virtual bool GetExitAppOnCommandFailure(void) const;
+ ~CMICmdBase() override;
+ virtual bool GetExitAppOnCommandFailure() const;
// Methods:
protected:
void SetError(const CMIUtilString &rErrMsg);
template <class T> T *GetOption(const CMIUtilString &vStrOptionName);
- bool ParseValidateCmdOptions(void);
+ bool ParseValidateCmdOptions();
// Attributes:
- protected:
CMICmdFactory::CmdCreatorFnPtr m_pSelfCreatorFn;
CMIUtilString m_strCurrentErrDescription; // Reason for Execute or Acknowledge function failure
SMICmdData m_cmdData; // Holds information/status of *this command. Used by other MI code to report or determine state of a command.
@@ -97,6 +95,16 @@ class CMICmdBase : public CMICmnBase, public CMICmdInvoker::ICmd, public CMICmdF
bool m_bHasResultRecordExtra; // True = Yes command produced additional MI output to its 1 line response, false = no extra MI output
// formed.
CMICmdArgSet m_setCmdArgs; // The list of arguments *this command needs to parse from the options string to carry out work.
+ const CMIUtilString m_constStrArgThreadGroup;
+ const CMIUtilString m_constStrArgThread;
+ const CMIUtilString m_constStrArgFrame;
+ const CMIUtilString m_constStrArgConsume;
+
+ // These 3 members can be used by the derived classes to make any of
+ // "thread", "frame" or "thread-group" mandatory.
+ bool m_ThreadGrpArgMandatory;
+ bool m_ThreadArgMandatory;
+ bool m_FrameArgMandatory;
};
//++ ------------------------------------------------------------------------------------
@@ -109,7 +117,7 @@ class CMICmdBase : public CMICmnBase, public CMICmdInvoker::ICmd, public CMICmdF
// Args: vStrOptionName - (R) The text name of the argument or option to search for in
// the list of the command's possible arguments or options.
// Return: T * - CMICmdArgValBase derived object.
-// - NULL = function has failed, unable to retrieve the option/arg object.
+// - nullptr = function has failed, unable to retrieve the option/arg object.
// Throws: None.
//--
template <class T>
@@ -136,7 +144,7 @@ CMICmdBase::GetOption(const CMIUtilString &vStrOptionName)
// c - (R) The text name of the argument or option to search for in the list of
// the command's possible arguments or options.
// Return: T * - CMICmdArgValBase derived object.
-// - NULL = function has failed, unable to retrieve the option/arg object.
+// - nullptr = function has failed, unable to retrieve the option/arg object.
// Throws: None.
//--
#define CMICMDBASE_GETOPTION(a, b, c) \
diff --git a/tools/lldb-mi/MICmdCmd.cpp b/tools/lldb-mi/MICmdCmd.cpp
index fbfc60995c5a..c6661112ea3e 100644
--- a/tools/lldb-mi/MICmdCmd.cpp
+++ b/tools/lldb-mi/MICmdCmd.cpp
@@ -22,7 +22,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdCmdEnablePrettyPrinting::CMICmdCmdEnablePrettyPrinting(void)
+CMICmdCmdEnablePrettyPrinting::CMICmdCmdEnablePrettyPrinting()
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "enable-pretty-printing";
@@ -38,7 +38,7 @@ CMICmdCmdEnablePrettyPrinting::CMICmdCmdEnablePrettyPrinting(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdEnablePrettyPrinting::~CMICmdCmdEnablePrettyPrinting(void)
+CMICmdCmdEnablePrettyPrinting::~CMICmdCmdEnablePrettyPrinting()
{
}
@@ -52,7 +52,7 @@ CMICmdCmdEnablePrettyPrinting::~CMICmdCmdEnablePrettyPrinting(void)
// Throws: None.
//--
bool
-CMICmdCmdEnablePrettyPrinting::Execute(void)
+CMICmdCmdEnablePrettyPrinting::Execute()
{
// Do nothing
return MIstatus::success;
@@ -68,7 +68,7 @@ CMICmdCmdEnablePrettyPrinting::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdEnablePrettyPrinting::Acknowledge(void)
+CMICmdCmdEnablePrettyPrinting::Acknowledge()
{
const CMICmnMIValueConst miValueConst("0");
const CMICmnMIValueResult miValueResult("supported", miValueConst);
@@ -87,7 +87,7 @@ CMICmdCmdEnablePrettyPrinting::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdEnablePrettyPrinting::CreateSelf(void)
+CMICmdCmdEnablePrettyPrinting::CreateSelf()
{
return new CMICmdCmdEnablePrettyPrinting();
}
@@ -103,7 +103,7 @@ CMICmdCmdEnablePrettyPrinting::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdSource::CMICmdCmdSource(void)
+CMICmdCmdSource::CMICmdCmdSource()
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "source";
@@ -119,7 +119,7 @@ CMICmdCmdSource::CMICmdCmdSource(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdSource::~CMICmdCmdSource(void)
+CMICmdCmdSource::~CMICmdCmdSource()
{
}
@@ -133,7 +133,7 @@ CMICmdCmdSource::~CMICmdCmdSource(void)
// Throws: None.
//--
bool
-CMICmdCmdSource::Execute(void)
+CMICmdCmdSource::Execute()
{
// Do nothing
return MIstatus::success;
@@ -149,7 +149,7 @@ CMICmdCmdSource::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdSource::Acknowledge(void)
+CMICmdCmdSource::Acknowledge()
{
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
m_miResultRecord = miRecordResult;
@@ -166,7 +166,7 @@ CMICmdCmdSource::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdSource::CreateSelf(void)
+CMICmdCmdSource::CreateSelf()
{
return new CMICmdCmdSource();
}
diff --git a/tools/lldb-mi/MICmdCmd.h b/tools/lldb-mi/MICmdCmd.h
index 26697643c5e3..6753c3b53909 100644
--- a/tools/lldb-mi/MICmdCmd.h
+++ b/tools/lldb-mi/MICmdCmd.h
@@ -41,53 +41,47 @@ MI commands implemented are:
// *this class implements MI command "enable-pretty-printing".
// Enables Python base pretty printing.
// Ref: http://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Variable-Objects.html
-// Gotchas: None.
-// Authors: Illya Rudkin 03/03/2014.
-// Changes: None.
//--
class CMICmdCmdEnablePrettyPrinting : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdEnablePrettyPrinting(void);
+ /* ctor */ CMICmdCmdEnablePrettyPrinting();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdEnablePrettyPrinting(void) override;
+ /* dtor */ ~CMICmdCmdEnablePrettyPrinting() override;
};
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "source".
-// Gotchas: None.
-// Authors: Illya Rudkin 05/03/2014.
-// Changes: None.
//--
class CMICmdCmdSource : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdSource(void);
+ /* ctor */ CMICmdCmdSource();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdSource(void) override;
+ /* dtor */ ~CMICmdCmdSource() override;
};
diff --git a/tools/lldb-mi/MICmdCmdBreak.cpp b/tools/lldb-mi/MICmdCmdBreak.cpp
index 8a310c79d02b..e758a3dcccef 100644
--- a/tools/lldb-mi/MICmdCmdBreak.cpp
+++ b/tools/lldb-mi/MICmdCmdBreak.cpp
@@ -40,7 +40,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdCmdBreakInsert::CMICmdCmdBreakInsert(void)
+CMICmdCmdBreakInsert::CMICmdCmdBreakInsert()
: m_bBrkPtIsTemp(false)
, m_bBrkPtIsPending(false)
, m_nBrkPtIgnoreCount(0)
@@ -57,7 +57,6 @@ CMICmdCmdBreakInsert::CMICmdCmdBreakInsert(void)
, m_constStrArgNamedInoreCnt("i")
, m_constStrArgNamedRestrictBrkPtToThreadId("p")
, m_constStrArgNamedLocation("location")
- , m_constStrArgNamedThreadGroup("thread-group")
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "break-insert";
@@ -73,7 +72,7 @@ CMICmdCmdBreakInsert::CMICmdCmdBreakInsert(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdBreakInsert::~CMICmdCmdBreakInsert(void)
+CMICmdCmdBreakInsert::~CMICmdCmdBreakInsert()
{
}
@@ -87,29 +86,41 @@ CMICmdCmdBreakInsert::~CMICmdCmdBreakInsert(void)
// Throws: None.
//--
bool
-CMICmdCmdBreakInsert::ParseArgs(void)
+CMICmdCmdBreakInsert::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValOptionShort(m_constStrArgNamedTempBrkPt, false, true)));
- // Not implemented bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgNamedHWBrkPt, false, false ) ) );
- bOk = bOk &&
- m_setCmdArgs.Add(*(new CMICmdArgValOptionShort(m_constStrArgNamedPendinfBrkPt, false, true,
- CMICmdArgValListBase::eArgValType_StringQuotedNumberPath, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionShort(m_constStrArgNamedDisableBrkPt, false, false)));
- // Not implemented bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgNamedTracePt, false, false ) ) );
- bOk = bOk &&
- m_setCmdArgs.Add(*(new CMICmdArgValOptionShort(m_constStrArgNamedConditionalBrkPt, false, true,
- CMICmdArgValListBase::eArgValType_StringQuoted, 1)));
- bOk = bOk &&
- m_setCmdArgs.Add(
- *(new CMICmdArgValOptionShort(m_constStrArgNamedInoreCnt, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk &&
- m_setCmdArgs.Add(*(new CMICmdArgValOptionShort(m_constStrArgNamedRestrictBrkPtToThreadId, false, true,
- CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgNamedLocation, false, true)));
- bOk = bOk &&
- m_setCmdArgs.Add(
- *(new CMICmdArgValOptionLong(m_constStrArgNamedThreadGroup, false, true, CMICmdArgValListBase::eArgValType_ThreadGrp, 1)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedTempBrkPt, false, true));
+ // Not implemented m_setCmdArgs.Add(new CMICmdArgValOptionShort( m_constStrArgNamedHWBrkPt, false, false));
+ m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedPendinfBrkPt, false, true,
+ CMICmdArgValListBase::eArgValType_StringQuotedNumberPath, 1));
+ m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedDisableBrkPt, false, false));
+ // Not implemented m_setCmdArgs.Add(new CMICmdArgValOptionShort( m_constStrArgNamedTracePt, false, false));
+ m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedConditionalBrkPt, false, true,
+ CMICmdArgValListBase::eArgValType_StringQuoted, 1));
+ m_setCmdArgs.Add(
+ new CMICmdArgValOptionShort(m_constStrArgNamedInoreCnt, false, true, CMICmdArgValListBase::eArgValType_Number, 1));
+ m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedRestrictBrkPtToThreadId, false, true,
+ CMICmdArgValListBase::eArgValType_Number, 1));
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgNamedLocation, false, true));
+ return ParseValidateCmdOptions();
+}
+
+//++ ------------------------------------------------------------------------------------
+// Helper function for CMICmdCmdBreakInsert::Execute().
+//
+// Given a string, return the position of the ':' separator in 'file:func'
+// or 'file:line', if any. If not found, return npos. For example, return
+// 5 for 'foo.c:std::string'.
+//--
+static size_t findFileSeparatorPos(const std::string& x)
+{
+ // Full paths in windows can have ':' after a drive letter, so we
+ // search backwards, taking care to skip C++ namespace tokens '::'.
+ size_t n = x.rfind(':');
+ while (n != std::string::npos && n > 1 && x[n-1] == ':')
+ {
+ n = x.rfind(':', n - 2);
+ }
+ return n;
}
//++ ------------------------------------------------------------------------------------
@@ -122,10 +133,10 @@ CMICmdCmdBreakInsert::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdBreakInsert::Execute(void)
+CMICmdCmdBreakInsert::Execute()
{
CMICMDBASE_GETOPTION(pArgTempBrkPt, OptionShort, m_constStrArgNamedTempBrkPt);
- CMICMDBASE_GETOPTION(pArgThreadGroup, OptionLong, m_constStrArgNamedThreadGroup);
+ CMICMDBASE_GETOPTION(pArgThreadGroup, OptionLong, m_constStrArgThreadGroup);
CMICMDBASE_GETOPTION(pArgLocation, String, m_constStrArgNamedLocation);
CMICMDBASE_GETOPTION(pArgIgnoreCnt, OptionShort, m_constStrArgNamedInoreCnt);
CMICMDBASE_GETOPTION(pArgPendingBrkPt, OptionShort, m_constStrArgNamedPendinfBrkPt);
@@ -166,17 +177,16 @@ CMICmdCmdBreakInsert::Execute(void)
// Determine if break on a file line or at a function
BreakPoint_e eBrkPtType = eBreakPoint_NotDefineYet;
- const CMIUtilString cColon = ":";
CMIUtilString fileName;
MIuint nFileLine = 0;
CMIUtilString strFileFn;
CMIUtilString rStrLineOrFn;
- // Full path in windows can have : after drive letter. So look for the
- // last colon
- const size_t nPosColon = m_brkName.find_last_of(cColon);
+ // Is the string in the form 'file:func' or 'file:line'?
+ // If so, find the position of the ':' separator.
+ const size_t nPosColon = findFileSeparatorPos(m_brkName);
if (nPosColon != std::string::npos)
{
- // extract file name and line number from it
+ // Extract file name and line number from it
fileName = m_brkName.substr(0, nPosColon);
rStrLineOrFn = m_brkName.substr(nPosColon + 1, m_brkName.size() - nPosColon - 1);
@@ -226,8 +236,13 @@ CMICmdCmdBreakInsert::Execute(void)
m_brkPt = sbTarget.BreakpointCreateByAddress(nAddress);
break;
case eBreakPoint_ByFileFn:
- m_brkPt = sbTarget.BreakpointCreateByName(strFileFn.c_str(), fileName.c_str());
+ {
+ lldb::SBFileSpecList module; // search in all modules
+ lldb::SBFileSpecList compUnit;
+ compUnit.Append (lldb::SBFileSpec(fileName.c_str()));
+ m_brkPt = sbTarget.BreakpointCreateByName(strFileFn.c_str(), module, compUnit);
break;
+ }
case eBreakPoint_ByFileLine:
m_brkPt = sbTarget.BreakpointCreateByLocation(fileName.c_str(), nFileLine);
break;
@@ -306,7 +321,7 @@ CMICmdCmdBreakInsert::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdBreakInsert::Acknowledge(void)
+CMICmdCmdBreakInsert::Acknowledge()
{
// Get breakpoint information
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
@@ -336,7 +351,7 @@ CMICmdCmdBreakInsert::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdBreakInsert::CreateSelf(void)
+CMICmdCmdBreakInsert::CreateSelf()
{
return new CMICmdCmdBreakInsert();
}
@@ -352,9 +367,8 @@ CMICmdCmdBreakInsert::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdBreakDelete::CMICmdCmdBreakDelete(void)
+CMICmdCmdBreakDelete::CMICmdCmdBreakDelete()
: m_constStrArgNamedBrkPt("breakpoint")
- , m_constStrArgNamedThreadGrp("thread-group")
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "break-delete";
@@ -370,7 +384,7 @@ CMICmdCmdBreakDelete::CMICmdCmdBreakDelete(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdBreakDelete::~CMICmdCmdBreakDelete(void)
+CMICmdCmdBreakDelete::~CMICmdCmdBreakDelete()
{
}
@@ -384,13 +398,10 @@ CMICmdCmdBreakDelete::~CMICmdCmdBreakDelete(void)
// Throws: None.
//--
bool
-CMICmdCmdBreakDelete::ParseArgs(void)
+CMICmdCmdBreakDelete::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(
- *(new CMICmdArgValOptionLong(m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1)));
- bOk =
- bOk && m_setCmdArgs.Add(*(new CMICmdArgValListOfN(m_constStrArgNamedBrkPt, true, true, CMICmdArgValListBase::eArgValType_Number)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValListOfN(m_constStrArgNamedBrkPt, true, true, CMICmdArgValListBase::eArgValType_Number));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -403,7 +414,7 @@ CMICmdCmdBreakDelete::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdBreakDelete::Execute(void)
+CMICmdCmdBreakDelete::Execute()
{
CMICMDBASE_GETOPTION(pArgBrkPt, ListOfN, m_constStrArgNamedBrkPt);
@@ -437,7 +448,7 @@ CMICmdCmdBreakDelete::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdBreakDelete::Acknowledge(void)
+CMICmdCmdBreakDelete::Acknowledge()
{
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
m_miResultRecord = miRecordResult;
@@ -454,7 +465,7 @@ CMICmdCmdBreakDelete::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdBreakDelete::CreateSelf(void)
+CMICmdCmdBreakDelete::CreateSelf()
{
return new CMICmdCmdBreakDelete();
}
@@ -470,9 +481,8 @@ CMICmdCmdBreakDelete::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdBreakDisable::CMICmdCmdBreakDisable(void)
- : m_constStrArgNamedThreadGrp("thread-group")
- , m_constStrArgNamedBrkPt("breakpoint")
+CMICmdCmdBreakDisable::CMICmdCmdBreakDisable()
+ : m_constStrArgNamedBrkPt("breakpoint")
, m_bBrkPtDisabledOk(false)
, m_nBrkPtId(0)
{
@@ -490,7 +500,7 @@ CMICmdCmdBreakDisable::CMICmdCmdBreakDisable(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdBreakDisable::~CMICmdCmdBreakDisable(void)
+CMICmdCmdBreakDisable::~CMICmdCmdBreakDisable()
{
}
@@ -504,13 +514,10 @@ CMICmdCmdBreakDisable::~CMICmdCmdBreakDisable(void)
// Throws: None.
//--
bool
-CMICmdCmdBreakDisable::ParseArgs(void)
+CMICmdCmdBreakDisable::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(
- *(new CMICmdArgValOptionLong(m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1)));
- bOk =
- bOk && m_setCmdArgs.Add(*(new CMICmdArgValListOfN(m_constStrArgNamedBrkPt, true, true, CMICmdArgValListBase::eArgValType_Number)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValListOfN(m_constStrArgNamedBrkPt, true, true, CMICmdArgValListBase::eArgValType_Number));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -523,7 +530,7 @@ CMICmdCmdBreakDisable::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdBreakDisable::Execute(void)
+CMICmdCmdBreakDisable::Execute()
{
CMICMDBASE_GETOPTION(pArgBrkPt, ListOfN, m_constStrArgNamedBrkPt);
@@ -557,7 +564,7 @@ CMICmdCmdBreakDisable::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdBreakDisable::Acknowledge(void)
+CMICmdCmdBreakDisable::Acknowledge()
{
if (m_bBrkPtDisabledOk)
{
@@ -566,10 +573,10 @@ CMICmdCmdBreakDisable::Acknowledge(void)
CMICmnMIValueTuple miValueTuple(miValueResult);
const CMICmnMIValueConst miValueConst2("n");
const CMICmnMIValueResult miValueResult2("enabled", miValueConst2);
- bool bOk = miValueTuple.Add(miValueResult2);
+ miValueTuple.Add(miValueResult2);
const CMICmnMIValueResult miValueResult3("bkpt", miValueTuple);
const CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, miValueResult3);
- bOk = bOk && CMICmnStreamStdout::TextToStdout(miOutOfBandRecord.GetString());
+ bool bOk = CMICmnStreamStdout::TextToStdout(miOutOfBandRecord.GetString());
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
m_miResultRecord = miRecordResult;
@@ -594,7 +601,7 @@ CMICmdCmdBreakDisable::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdBreakDisable::CreateSelf(void)
+CMICmdCmdBreakDisable::CreateSelf()
{
return new CMICmdCmdBreakDisable();
}
@@ -610,9 +617,8 @@ CMICmdCmdBreakDisable::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdBreakEnable::CMICmdCmdBreakEnable(void)
- : m_constStrArgNamedThreadGrp("thread-group")
- , m_constStrArgNamedBrkPt("breakpoint")
+CMICmdCmdBreakEnable::CMICmdCmdBreakEnable()
+ : m_constStrArgNamedBrkPt("breakpoint")
, m_bBrkPtEnabledOk(false)
, m_nBrkPtId(0)
{
@@ -630,7 +636,7 @@ CMICmdCmdBreakEnable::CMICmdCmdBreakEnable(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdBreakEnable::~CMICmdCmdBreakEnable(void)
+CMICmdCmdBreakEnable::~CMICmdCmdBreakEnable()
{
}
@@ -644,13 +650,10 @@ CMICmdCmdBreakEnable::~CMICmdCmdBreakEnable(void)
// Throws: None.
//--
bool
-CMICmdCmdBreakEnable::ParseArgs(void)
+CMICmdCmdBreakEnable::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(
- *(new CMICmdArgValOptionLong(m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1)));
- bOk =
- bOk && m_setCmdArgs.Add(*(new CMICmdArgValListOfN(m_constStrArgNamedBrkPt, true, true, CMICmdArgValListBase::eArgValType_Number)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValListOfN(m_constStrArgNamedBrkPt, true, true, CMICmdArgValListBase::eArgValType_Number));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -663,7 +666,7 @@ CMICmdCmdBreakEnable::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdBreakEnable::Execute(void)
+CMICmdCmdBreakEnable::Execute()
{
CMICMDBASE_GETOPTION(pArgBrkPt, ListOfN, m_constStrArgNamedBrkPt);
@@ -697,7 +700,7 @@ CMICmdCmdBreakEnable::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdBreakEnable::Acknowledge(void)
+CMICmdCmdBreakEnable::Acknowledge()
{
if (m_bBrkPtEnabledOk)
{
@@ -706,10 +709,10 @@ CMICmdCmdBreakEnable::Acknowledge(void)
CMICmnMIValueTuple miValueTuple(miValueResult);
const CMICmnMIValueConst miValueConst2("y");
const CMICmnMIValueResult miValueResult2("enabled", miValueConst2);
- bool bOk = miValueTuple.Add(miValueResult2);
+ miValueTuple.Add(miValueResult2);
const CMICmnMIValueResult miValueResult3("bkpt", miValueTuple);
const CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, miValueResult3);
- bOk = bOk && CMICmnStreamStdout::TextToStdout(miOutOfBandRecord.GetString());
+ bool bOk = CMICmnStreamStdout::TextToStdout(miOutOfBandRecord.GetString());
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
m_miResultRecord = miRecordResult;
@@ -734,7 +737,7 @@ CMICmdCmdBreakEnable::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdBreakEnable::CreateSelf(void)
+CMICmdCmdBreakEnable::CreateSelf()
{
return new CMICmdCmdBreakEnable();
}
@@ -750,9 +753,8 @@ CMICmdCmdBreakEnable::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdBreakAfter::CMICmdCmdBreakAfter(void)
- : m_constStrArgNamedThreadGrp("thread-group")
- , m_constStrArgNamedNumber("number")
+CMICmdCmdBreakAfter::CMICmdCmdBreakAfter()
+ : m_constStrArgNamedNumber("number")
, m_constStrArgNamedCount("count")
, m_nBrkPtId(0)
, m_nBrkPtCount(0)
@@ -771,7 +773,7 @@ CMICmdCmdBreakAfter::CMICmdCmdBreakAfter(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdBreakAfter::~CMICmdCmdBreakAfter(void)
+CMICmdCmdBreakAfter::~CMICmdCmdBreakAfter()
{
}
@@ -785,13 +787,11 @@ CMICmdCmdBreakAfter::~CMICmdCmdBreakAfter(void)
// Throws: None.
//--
bool
-CMICmdCmdBreakAfter::ParseArgs(void)
+CMICmdCmdBreakAfter::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(
- *(new CMICmdArgValOptionLong(m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgNamedNumber, true, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgNamedCount, true, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNamedNumber, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNamedCount, true, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -804,7 +804,7 @@ CMICmdCmdBreakAfter::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdBreakAfter::Execute(void)
+CMICmdCmdBreakAfter::Execute()
{
CMICMDBASE_GETOPTION(pArgNumber, Number, m_constStrArgNamedNumber);
CMICMDBASE_GETOPTION(pArgCount, Number, m_constStrArgNamedCount);
@@ -847,7 +847,7 @@ CMICmdCmdBreakAfter::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdBreakAfter::Acknowledge(void)
+CMICmdCmdBreakAfter::Acknowledge()
{
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
m_miResultRecord = miRecordResult;
@@ -864,7 +864,7 @@ CMICmdCmdBreakAfter::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdBreakAfter::CreateSelf(void)
+CMICmdCmdBreakAfter::CreateSelf()
{
return new CMICmdCmdBreakAfter();
}
@@ -880,9 +880,8 @@ CMICmdCmdBreakAfter::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdBreakCondition::CMICmdCmdBreakCondition(void)
- : m_constStrArgNamedThreadGrp("thread-group")
- , m_constStrArgNamedNumber("number")
+CMICmdCmdBreakCondition::CMICmdCmdBreakCondition()
+ : m_constStrArgNamedNumber("number")
, m_constStrArgNamedExpr("expr")
, m_constStrArgNamedExprNoQuotes(
"expression not surround by quotes") // Not specified in MI spec, we need to handle expressions not surrounded by quotes
@@ -902,7 +901,7 @@ CMICmdCmdBreakCondition::CMICmdCmdBreakCondition(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdBreakCondition::~CMICmdCmdBreakCondition(void)
+CMICmdCmdBreakCondition::~CMICmdCmdBreakCondition()
{
}
@@ -916,16 +915,13 @@ CMICmdCmdBreakCondition::~CMICmdCmdBreakCondition(void)
// Throws: None.
//--
bool
-CMICmdCmdBreakCondition::ParseArgs(void)
+CMICmdCmdBreakCondition::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(
- *(new CMICmdArgValOptionLong(m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgNamedNumber, true, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgNamedExpr, true, true, true, true)));
- bOk = bOk &&
- m_setCmdArgs.Add(*(new CMICmdArgValListOfN(m_constStrArgNamedExprNoQuotes, true, false,
- CMICmdArgValListBase::eArgValType_StringQuotedNumber)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNamedNumber, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgNamedExpr, true, true, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValListOfN(m_constStrArgNamedExprNoQuotes, false, false,
+ CMICmdArgValListBase::eArgValType_StringQuotedNumber));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -938,7 +934,7 @@ CMICmdCmdBreakCondition::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdBreakCondition::Execute(void)
+CMICmdCmdBreakCondition::Execute()
{
CMICMDBASE_GETOPTION(pArgNumber, Number, m_constStrArgNamedNumber);
CMICMDBASE_GETOPTION(pArgExpr, String, m_constStrArgNamedExpr);
@@ -982,7 +978,7 @@ CMICmdCmdBreakCondition::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdBreakCondition::Acknowledge(void)
+CMICmdCmdBreakCondition::Acknowledge()
{
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
m_miResultRecord = miRecordResult;
@@ -999,7 +995,7 @@ CMICmdCmdBreakCondition::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdBreakCondition::CreateSelf(void)
+CMICmdCmdBreakCondition::CreateSelf()
{
return new CMICmdCmdBreakCondition();
}
@@ -1021,14 +1017,13 @@ CMICmdCmdBreakCondition::CreateSelf(void)
// Throws: None.
//--
CMIUtilString
-CMICmdCmdBreakCondition::GetRestOfExpressionNotSurroundedInQuotes(void)
+CMICmdCmdBreakCondition::GetRestOfExpressionNotSurroundedInQuotes()
{
CMIUtilString strExpression;
CMICmdArgValListOfN *pArgExprNoQuotes = CMICmdBase::GetOption<CMICmdArgValListOfN>(m_constStrArgNamedExprNoQuotes);
if (pArgExprNoQuotes != nullptr)
{
- CMIUtilString strExpression;
const CMICmdArgValListBase::VecArgObjPtr_t &rVecExprParts(pArgExprNoQuotes->GetExpectedOptions());
if (!rVecExprParts.empty())
{
diff --git a/tools/lldb-mi/MICmdCmdBreak.h b/tools/lldb-mi/MICmdCmdBreak.h
index 476ab45762de..b8c4240a8a57 100644
--- a/tools/lldb-mi/MICmdCmdBreak.h
+++ b/tools/lldb-mi/MICmdCmdBreak.h
@@ -35,29 +35,26 @@
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "break-insert".
// This command does not follow the MI documentation exactly.
-// Gotchas: None.
-// Authors: Illya Rudkin 11/03/2014.
-// Changes: None.
//--
class CMICmdCmdBreakInsert : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdBreakInsert(void);
+ /* ctor */ CMICmdCmdBreakInsert();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdBreakInsert(void) override;
+ /* dtor */ ~CMICmdCmdBreakInsert() override;
// Enumerations:
private:
@@ -98,72 +95,63 @@ class CMICmdCmdBreakInsert : public CMICmdBase
const CMIUtilString m_constStrArgNamedInoreCnt;
const CMIUtilString m_constStrArgNamedRestrictBrkPtToThreadId;
const CMIUtilString m_constStrArgNamedLocation;
- const CMIUtilString m_constStrArgNamedThreadGroup; // Not specified in MI spec but Eclipse gives this option sometimes
};
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "break-delete".
-// Gotchas: None.
-// Authors: Illya Rudkin 11/03/2014.
-// Changes: None.
//--
class CMICmdCmdBreakDelete : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdBreakDelete(void);
+ /* ctor */ CMICmdCmdBreakDelete();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdBreakDelete(void) override;
+ /* dtor */ ~CMICmdCmdBreakDelete() override;
// Attributes:
private:
const CMIUtilString m_constStrArgNamedBrkPt;
- const CMIUtilString m_constStrArgNamedThreadGrp; // Not specified in MI spec but Eclipse gives this option
};
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "break-disable".
-// Gotchas: None.
-// Authors: Illya Rudkin 19/05/2014.
-// Changes: None.
//--
class CMICmdCmdBreakDisable : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdBreakDisable(void);
+ /* ctor */ CMICmdCmdBreakDisable();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdBreakDisable(void) override;
+ /* dtor */ ~CMICmdCmdBreakDisable() override;
// Attributes:
private:
- const CMIUtilString m_constStrArgNamedThreadGrp; // Not specified in MI spec but Eclipse gives this option
const CMIUtilString m_constStrArgNamedBrkPt;
bool m_bBrkPtDisabledOk;
MIuint m_nBrkPtId;
@@ -172,33 +160,29 @@ class CMICmdCmdBreakDisable : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "break-enable".
-// Gotchas: None.
-// Authors: Illya Rudkin 19/05/2014.
-// Changes: None.
//--
class CMICmdCmdBreakEnable : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdBreakEnable(void);
+ /* ctor */ CMICmdCmdBreakEnable();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdBreakEnable(void) override;
+ /* dtor */ ~CMICmdCmdBreakEnable() override;
// Attributes:
private:
- const CMIUtilString m_constStrArgNamedThreadGrp; // Not specified in MI spec but Eclipse gives this option
const CMIUtilString m_constStrArgNamedBrkPt;
bool m_bBrkPtEnabledOk;
MIuint m_nBrkPtId;
@@ -207,33 +191,29 @@ class CMICmdCmdBreakEnable : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "break-after".
-// Gotchas: None.
-// Authors: Illya Rudkin 29/05/2014.
-// Changes: None.
//--
class CMICmdCmdBreakAfter : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdBreakAfter(void);
+ /* ctor */ CMICmdCmdBreakAfter();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdBreakAfter(void) override;
+ /* dtor */ ~CMICmdCmdBreakAfter() override;
// Attributes:
private:
- const CMIUtilString m_constStrArgNamedThreadGrp; // Not specified in MI spec but Eclipse gives this option
const CMIUtilString m_constStrArgNamedNumber;
const CMIUtilString m_constStrArgNamedCount;
MIuint m_nBrkPtId;
@@ -243,37 +223,33 @@ class CMICmdCmdBreakAfter : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "break-condition".
-// Gotchas: None.
-// Authors: Illya Rudkin 29/05/2014.
-// Changes: None.
//--
class CMICmdCmdBreakCondition : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdBreakCondition(void);
+ /* ctor */ CMICmdCmdBreakCondition();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdBreakCondition(void) override;
+ /* dtor */ ~CMICmdCmdBreakCondition() override;
// Methods:
private:
- CMIUtilString GetRestOfExpressionNotSurroundedInQuotes(void);
+ CMIUtilString GetRestOfExpressionNotSurroundedInQuotes();
// Attributes:
private:
- const CMIUtilString m_constStrArgNamedThreadGrp; // Not specified in MI spec but Eclipse gives this option
const CMIUtilString m_constStrArgNamedNumber;
const CMIUtilString m_constStrArgNamedExpr;
const CMIUtilString m_constStrArgNamedExprNoQuotes; // Not specified in MI spec, we need to handle expressions not surrounded by quotes
diff --git a/tools/lldb-mi/MICmdCmdData.cpp b/tools/lldb-mi/MICmdCmdData.cpp
index 21036f865d9e..0e0cf12b0080 100644
--- a/tools/lldb-mi/MICmdCmdData.cpp
+++ b/tools/lldb-mi/MICmdCmdData.cpp
@@ -42,6 +42,7 @@
#include "MICmdArgValConsume.h"
#include "MICmnLLDBDebugSessionInfoVarObj.h"
#include "MICmnLLDBUtilSBValue.h"
+#include "MIUtilParse.h"
//++ ------------------------------------------------------------------------------------
// Details: CMICmdCmdDataEvaluateExpression constructor.
@@ -50,15 +51,12 @@
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataEvaluateExpression::CMICmdCmdDataEvaluateExpression(void)
+CMICmdCmdDataEvaluateExpression::CMICmdCmdDataEvaluateExpression()
: m_bExpressionValid(true)
, m_bEvaluatedExpression(true)
, m_strValue("??")
- , m_bCompositeVarType(false)
, m_bFoundInvalidChar(false)
, m_cExpressionInvalidChar(0x00)
- , m_constStrArgThread("thread")
- , m_constStrArgFrame("frame")
, m_constStrArgExpr("expr")
{
// Command factory matches this name with that received from the stdin stream
@@ -75,7 +73,7 @@ CMICmdCmdDataEvaluateExpression::CMICmdCmdDataEvaluateExpression(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataEvaluateExpression::~CMICmdCmdDataEvaluateExpression(void)
+CMICmdCmdDataEvaluateExpression::~CMICmdCmdDataEvaluateExpression()
{
}
@@ -89,14 +87,10 @@ CMICmdCmdDataEvaluateExpression::~CMICmdCmdDataEvaluateExpression(void)
// Throws: None.
//--
bool
-CMICmdCmdDataEvaluateExpression::ParseArgs(void)
+CMICmdCmdDataEvaluateExpression::ParseArgs()
{
- bool bOk =
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, false, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk &&
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgFrame, false, false, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgExpr, true, true, true, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgExpr, true, true, true, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -109,7 +103,7 @@ CMICmdCmdDataEvaluateExpression::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdDataEvaluateExpression::Execute(void)
+CMICmdCmdDataEvaluateExpression::Execute()
{
CMICMDBASE_GETOPTION(pArgExpr, String, m_constStrArgExpr);
@@ -147,41 +141,7 @@ CMICmdCmdDataEvaluateExpression::Execute(void)
m_strValue = rExpression.Trim('\"');
return MIstatus::success;
}
-
- MIuint64 nNumber = 0;
- if (CMICmnLLDBProxySBValue::GetValueAsUnsigned(value, nNumber) == MIstatus::success)
- {
- const lldb::ValueType eValueType = value.GetValueType();
- MIunused(eValueType);
- m_strValue = utilValue.GetValue().Escape().AddSlashes();
- return MIstatus::success;
- }
-
- // Composite type i.e. struct
- m_bCompositeVarType = true;
- const MIuint nChild = value.GetNumChildren();
- for (MIuint i = 0; i < nChild; i++)
- {
- lldb::SBValue member = value.GetChildAtIndex(i);
- const bool bValid = member.IsValid();
- CMIUtilString strType(MIRSRC(IDS_WORD_UNKNOWNTYPE_BRKTS));
- if (bValid)
- {
- const CMIUtilString strValue(
- CMICmnLLDBDebugSessionInfoVarObj::GetValueStringFormatted(member, CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Natural));
- const char *pTypeName = member.GetName();
- if (pTypeName != nullptr)
- strType = pTypeName;
-
- // MI print "{variable = 1, variable2 = 3, variable3 = 5}"
- const bool bNoQuotes = true;
- const CMICmnMIValueConst miValueConst(strValue, bNoQuotes);
- const bool bUseSpaces = true;
- const CMICmnMIValueResult miValueResult(strType, miValueConst, bUseSpaces);
- m_miValueTuple.Add(miValueResult, bUseSpaces);
- }
- }
-
+ m_strValue = utilValue.GetValue(true).Escape().AddSlashes();
return MIstatus::success;
}
@@ -195,21 +155,12 @@ CMICmdCmdDataEvaluateExpression::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdDataEvaluateExpression::Acknowledge(void)
+CMICmdCmdDataEvaluateExpression::Acknowledge()
{
if (m_bExpressionValid)
{
if (m_bEvaluatedExpression)
{
- if (m_bCompositeVarType)
- {
- const CMICmnMIValueConst miValueConst(m_miValueTuple.GetString());
- const CMICmnMIValueResult miValueResult("value", miValueConst);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
- m_miResultRecord = miRecordResult;
- return MIstatus::success;
- }
-
if (m_bFoundInvalidChar)
{
const CMICmnMIValueConst miValueConst(
@@ -251,7 +202,7 @@ CMICmdCmdDataEvaluateExpression::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdDataEvaluateExpression::CreateSelf(void)
+CMICmdCmdDataEvaluateExpression::CreateSelf()
{
return new CMICmdCmdDataEvaluateExpression();
}
@@ -285,11 +236,9 @@ CMICmdCmdDataEvaluateExpression::HaveInvalidCharacterInExpression(const CMIUtilS
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataDisassemble::CMICmdCmdDataDisassemble(void)
- : m_constStrArgThread("thread")
- , m_constStrArgAddrStart("s")
+CMICmdCmdDataDisassemble::CMICmdCmdDataDisassemble()
+ : m_constStrArgAddrStart("s")
, m_constStrArgAddrEnd("e")
- , m_constStrArgConsume("--")
, m_constStrArgMode("mode")
, m_miValueList(true)
{
@@ -307,7 +256,7 @@ CMICmdCmdDataDisassemble::CMICmdCmdDataDisassemble(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataDisassemble::~CMICmdCmdDataDisassemble(void)
+CMICmdCmdDataDisassemble::~CMICmdCmdDataDisassemble()
{
}
@@ -321,19 +270,14 @@ CMICmdCmdDataDisassemble::~CMICmdCmdDataDisassemble(void)
// Throws: None.
//--
bool
-CMICmdCmdDataDisassemble::ParseArgs(void)
+CMICmdCmdDataDisassemble::ParseArgs()
{
- bool bOk =
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk &&
- m_setCmdArgs.Add(
- *(new CMICmdArgValOptionShort(m_constStrArgAddrStart, true, true, CMICmdArgValListBase::eArgValType_StringQuotedNumber, 1)));
- bOk = bOk &&
- m_setCmdArgs.Add(
- *(new CMICmdArgValOptionShort(m_constStrArgAddrEnd, true, true, CMICmdArgValListBase::eArgValType_StringQuotedNumber, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValConsume(m_constStrArgConsume, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgMode, true, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(
+ new CMICmdArgValOptionShort(m_constStrArgAddrStart, true, true, CMICmdArgValListBase::eArgValType_StringQuotedNumber, 1));
+ m_setCmdArgs.Add(
+ new CMICmdArgValOptionShort(m_constStrArgAddrEnd, true, true, CMICmdArgValListBase::eArgValType_StringQuotedNumber, 1));
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgMode, true, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -346,7 +290,7 @@ CMICmdCmdDataDisassemble::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdDataDisassemble::Execute(void)
+CMICmdCmdDataDisassemble::Execute()
{
CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
CMICMDBASE_GETOPTION(pArgAddrStart, OptionShort, m_constStrArgAddrStart);
@@ -476,7 +420,7 @@ CMICmdCmdDataDisassemble::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdDataDisassemble::Acknowledge(void)
+CMICmdCmdDataDisassemble::Acknowledge()
{
const CMICmnMIValueResult miValueResult("asm_insns", m_miValueList);
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
@@ -494,7 +438,7 @@ CMICmdCmdDataDisassemble::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdDataDisassemble::CreateSelf(void)
+CMICmdCmdDataDisassemble::CreateSelf()
{
return new CMICmdCmdDataDisassemble();
}
@@ -510,10 +454,8 @@ CMICmdCmdDataDisassemble::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataReadMemoryBytes::CMICmdCmdDataReadMemoryBytes(void)
- : m_constStrArgThread("thread")
- , m_constStrArgFrame("frame")
- , m_constStrArgByteOffset("o")
+CMICmdCmdDataReadMemoryBytes::CMICmdCmdDataReadMemoryBytes()
+ : m_constStrArgByteOffset("o")
, m_constStrArgAddrExpr("address")
, m_constStrArgNumBytes("count")
, m_pBufferMemory(nullptr)
@@ -534,7 +476,7 @@ CMICmdCmdDataReadMemoryBytes::CMICmdCmdDataReadMemoryBytes(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataReadMemoryBytes::~CMICmdCmdDataReadMemoryBytes(void)
+CMICmdCmdDataReadMemoryBytes::~CMICmdCmdDataReadMemoryBytes()
{
if (m_pBufferMemory != nullptr)
{
@@ -553,18 +495,12 @@ CMICmdCmdDataReadMemoryBytes::~CMICmdCmdDataReadMemoryBytes(void)
// Throws: None.
//--
bool
-CMICmdCmdDataReadMemoryBytes::ParseArgs(void)
+CMICmdCmdDataReadMemoryBytes::ParseArgs()
{
- bool bOk =
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk &&
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgFrame, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk =
- bOk &&
- m_setCmdArgs.Add(*(new CMICmdArgValOptionShort(m_constStrArgByteOffset, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgAddrExpr, true, true, true, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgNumBytes, true, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgByteOffset, false, true, CMICmdArgValListBase::eArgValType_Number, 1));
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgAddrExpr, true, true, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumBytes, true, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -577,7 +513,7 @@ CMICmdCmdDataReadMemoryBytes::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdDataReadMemoryBytes::Execute(void)
+CMICmdCmdDataReadMemoryBytes::Execute()
{
CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
CMICMDBASE_GETOPTION(pArgFrame, OptionLong, m_constStrArgFrame);
@@ -700,7 +636,7 @@ CMICmdCmdDataReadMemoryBytes::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdDataReadMemoryBytes::Acknowledge(void)
+CMICmdCmdDataReadMemoryBytes::Acknowledge()
{
// MI: memory=[{begin=\"0x%016" PRIx64 "\",offset=\"0x%016" PRIx64" \",end=\"0x%016" PRIx64 "\",contents=\" \" }]"
const CMICmnMIValueConst miValueConst(CMIUtilString::Format("0x%016" PRIx64, m_nAddrStart));
@@ -742,7 +678,7 @@ CMICmdCmdDataReadMemoryBytes::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdDataReadMemoryBytes::CreateSelf(void)
+CMICmdCmdDataReadMemoryBytes::CreateSelf()
{
return new CMICmdCmdDataReadMemoryBytes();
}
@@ -758,7 +694,7 @@ CMICmdCmdDataReadMemoryBytes::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataReadMemory::CMICmdCmdDataReadMemory(void)
+CMICmdCmdDataReadMemory::CMICmdCmdDataReadMemory()
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "data-read-memory";
@@ -774,7 +710,7 @@ CMICmdCmdDataReadMemory::CMICmdCmdDataReadMemory(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataReadMemory::~CMICmdCmdDataReadMemory(void)
+CMICmdCmdDataReadMemory::~CMICmdCmdDataReadMemory()
{
}
@@ -788,7 +724,7 @@ CMICmdCmdDataReadMemory::~CMICmdCmdDataReadMemory(void)
// Throws: None.
//--
bool
-CMICmdCmdDataReadMemory::Execute(void)
+CMICmdCmdDataReadMemory::Execute()
{
// Do nothing - command deprecated use "data-read-memory-bytes" command
return MIstatus::success;
@@ -804,7 +740,7 @@ CMICmdCmdDataReadMemory::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdDataReadMemory::Acknowledge(void)
+CMICmdCmdDataReadMemory::Acknowledge()
{
// Command CMICmdCmdSupportListFeatures sends "data-read-memory-bytes" which causes this command not to be called
const CMICmnMIValueConst miValueConst(MIRSRC(IDS_CMD_ERR_NOT_IMPLEMENTED_DEPRECATED));
@@ -824,7 +760,7 @@ CMICmdCmdDataReadMemory::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdDataReadMemory::CreateSelf(void)
+CMICmdCmdDataReadMemory::CreateSelf()
{
return new CMICmdCmdDataReadMemory();
}
@@ -840,9 +776,8 @@ CMICmdCmdDataReadMemory::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataListRegisterNames::CMICmdCmdDataListRegisterNames(void)
- : m_constStrArgThreadGroup("thread-group")
- , m_constStrArgRegNo("regno")
+CMICmdCmdDataListRegisterNames::CMICmdCmdDataListRegisterNames()
+ : m_constStrArgRegNo("regno")
, m_miValueList(true)
{
// Command factory matches this name with that received from the stdin stream
@@ -859,7 +794,7 @@ CMICmdCmdDataListRegisterNames::CMICmdCmdDataListRegisterNames(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataListRegisterNames::~CMICmdCmdDataListRegisterNames(void)
+CMICmdCmdDataListRegisterNames::~CMICmdCmdDataListRegisterNames()
{
}
@@ -873,12 +808,10 @@ CMICmdCmdDataListRegisterNames::~CMICmdCmdDataListRegisterNames(void)
// Throws: None.
//--
bool
-CMICmdCmdDataListRegisterNames::ParseArgs(void)
+CMICmdCmdDataListRegisterNames::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(
- *(new CMICmdArgValOptionLong(m_constStrArgThreadGroup, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValListOfN(m_constStrArgRegNo, false, false, CMICmdArgValListBase::eArgValType_Number)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValListOfN(m_constStrArgRegNo, false, false, CMICmdArgValListBase::eArgValType_Number));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -891,7 +824,7 @@ CMICmdCmdDataListRegisterNames::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdDataListRegisterNames::Execute(void)
+CMICmdCmdDataListRegisterNames::Execute()
{
CMICMDBASE_GETOPTION(pArgRegNo, ListOfN, m_constStrArgRegNo);
@@ -940,9 +873,7 @@ CMICmdCmdDataListRegisterNames::Execute(void)
if (regValue.IsValid())
{
const CMICmnMIValueConst miValueConst(CMICmnLLDBUtilSBValue(regValue).GetName());
- const bool bOk = m_miValueList.Add(miValueConst);
- if (!bOk)
- return MIstatus::failure;
+ m_miValueList.Add(miValueConst);
}
}
}
@@ -961,7 +892,7 @@ CMICmdCmdDataListRegisterNames::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdDataListRegisterNames::Acknowledge(void)
+CMICmdCmdDataListRegisterNames::Acknowledge()
{
const CMICmnMIValueResult miValueResult("register-names", m_miValueList);
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
@@ -979,7 +910,7 @@ CMICmdCmdDataListRegisterNames::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdDataListRegisterNames::CreateSelf(void)
+CMICmdCmdDataListRegisterNames::CreateSelf()
{
return new CMICmdCmdDataListRegisterNames();
}
@@ -1031,9 +962,8 @@ CMICmdCmdDataListRegisterNames::GetRegister(const MIuint vRegisterIndex) const
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataListRegisterValues::CMICmdCmdDataListRegisterValues(void)
- : m_constStrArgThread("thread")
- , m_constStrArgSkip("skip-unavailable")
+CMICmdCmdDataListRegisterValues::CMICmdCmdDataListRegisterValues()
+ : m_constStrArgSkip("skip-unavailable")
, m_constStrArgFormat("fmt")
, m_constStrArgRegNo("regno")
, m_miValueList(true)
@@ -1052,7 +982,7 @@ CMICmdCmdDataListRegisterValues::CMICmdCmdDataListRegisterValues(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataListRegisterValues::~CMICmdCmdDataListRegisterValues(void)
+CMICmdCmdDataListRegisterValues::~CMICmdCmdDataListRegisterValues()
{
}
@@ -1066,14 +996,13 @@ CMICmdCmdDataListRegisterValues::~CMICmdCmdDataListRegisterValues(void)
// Throws: None.
//--
bool
-CMICmdCmdDataListRegisterValues::ParseArgs(void)
+CMICmdCmdDataListRegisterValues::ParseArgs()
{
- bool bOk =
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, false, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgSkip, false, false)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgFormat, true, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValListOfN(m_constStrArgRegNo, false, true, CMICmdArgValListBase::eArgValType_Number)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValOptionLong(m_constStrArgThread, false, false, CMICmdArgValListBase::eArgValType_Number, 1));
+ m_setCmdArgs.Add(new CMICmdArgValOptionLong(m_constStrArgSkip, false, false));
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgFormat, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValListOfN(m_constStrArgRegNo, false, true, CMICmdArgValListBase::eArgValType_Number));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -1086,7 +1015,7 @@ CMICmdCmdDataListRegisterValues::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdDataListRegisterValues::Execute(void)
+CMICmdCmdDataListRegisterValues::Execute()
{
CMICMDBASE_GETOPTION(pArgFormat, String, m_constStrArgFormat);
CMICMDBASE_GETOPTION(pArgRegNo, ListOfN, m_constStrArgRegNo);
@@ -1124,9 +1053,7 @@ CMICmdCmdDataListRegisterValues::Execute(void)
lldb::SBValue regValue = GetRegister(nRegIndex);
if (regValue.IsValid())
{
- const bool bOk = AddToOutput(nRegIndex, regValue, eFormat);
- if (!bOk)
- return MIstatus::failure;
+ AddToOutput(nRegIndex, regValue, eFormat);
}
// Next
@@ -1150,9 +1077,7 @@ CMICmdCmdDataListRegisterValues::Execute(void)
lldb::SBValue regValue = value.GetChildAtIndex(j);
if (regValue.IsValid())
{
- const bool bOk = AddToOutput(nRegIndex, regValue, eFormat);
- if (!bOk)
- return MIstatus::failure;
+ AddToOutput(nRegIndex, regValue, eFormat);
}
// Next
@@ -1174,7 +1099,7 @@ CMICmdCmdDataListRegisterValues::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdDataListRegisterValues::Acknowledge(void)
+CMICmdCmdDataListRegisterValues::Acknowledge()
{
const CMICmnMIValueResult miValueResult("register-values", m_miValueList);
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
@@ -1192,7 +1117,7 @@ CMICmdCmdDataListRegisterValues::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdDataListRegisterValues::CreateSelf(void)
+CMICmdCmdDataListRegisterValues::CreateSelf()
{
return new CMICmdCmdDataListRegisterValues();
}
@@ -1240,7 +1165,7 @@ CMICmdCmdDataListRegisterValues::GetRegister(const MIuint vRegisterIndex) const
// Return: None
// Throws: None.
//--
-bool
+void
CMICmdCmdDataListRegisterValues::AddToOutput(const MIuint vnIndex, const lldb::SBValue &vrValue,
CMICmnLLDBDebugSessionInfoVarObj::varFormat_e veVarFormat)
{
@@ -1250,8 +1175,8 @@ CMICmdCmdDataListRegisterValues::AddToOutput(const MIuint vnIndex, const lldb::S
const CMIUtilString strRegValue(CMICmnLLDBDebugSessionInfoVarObj::GetValueStringFormatted(vrValue, veVarFormat));
const CMICmnMIValueConst miValueConst2(strRegValue);
const CMICmnMIValueResult miValueResult2("value", miValueConst2);
- bool bOk = miValueTuple.Add(miValueResult2);
- return bOk && m_miValueList.Add(miValueTuple);
+ miValueTuple.Add(miValueResult2);
+ m_miValueList.Add(miValueTuple);
}
//---------------------------------------------------------------------------------------
@@ -1265,7 +1190,7 @@ CMICmdCmdDataListRegisterValues::AddToOutput(const MIuint vnIndex, const lldb::S
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataListRegisterChanged::CMICmdCmdDataListRegisterChanged(void)
+CMICmdCmdDataListRegisterChanged::CMICmdCmdDataListRegisterChanged()
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "data-list-changed-registers";
@@ -1281,7 +1206,7 @@ CMICmdCmdDataListRegisterChanged::CMICmdCmdDataListRegisterChanged(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataListRegisterChanged::~CMICmdCmdDataListRegisterChanged(void)
+CMICmdCmdDataListRegisterChanged::~CMICmdCmdDataListRegisterChanged()
{
}
@@ -1295,7 +1220,7 @@ CMICmdCmdDataListRegisterChanged::~CMICmdCmdDataListRegisterChanged(void)
// Throws: None.
//--
bool
-CMICmdCmdDataListRegisterChanged::Execute(void)
+CMICmdCmdDataListRegisterChanged::Execute()
{
// Do nothing
@@ -1312,7 +1237,7 @@ CMICmdCmdDataListRegisterChanged::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdDataListRegisterChanged::Acknowledge(void)
+CMICmdCmdDataListRegisterChanged::Acknowledge()
{
const CMICmnMIValueConst miValueConst(MIRSRC(IDS_WORD_NOT_IMPLEMENTED));
const CMICmnMIValueResult miValueResult("msg", miValueConst);
@@ -1331,7 +1256,7 @@ CMICmdCmdDataListRegisterChanged::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdDataListRegisterChanged::CreateSelf(void)
+CMICmdCmdDataListRegisterChanged::CreateSelf()
{
return new CMICmdCmdDataListRegisterChanged();
}
@@ -1347,9 +1272,8 @@ CMICmdCmdDataListRegisterChanged::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataWriteMemoryBytes::CMICmdCmdDataWriteMemoryBytes(void)
- : m_constStrArgThread("thread")
- , m_constStrArgAddr("address")
+CMICmdCmdDataWriteMemoryBytes::CMICmdCmdDataWriteMemoryBytes()
+ : m_constStrArgAddr("address")
, m_constStrArgContents("contents")
, m_constStrArgCount("count")
{
@@ -1367,7 +1291,7 @@ CMICmdCmdDataWriteMemoryBytes::CMICmdCmdDataWriteMemoryBytes(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataWriteMemoryBytes::~CMICmdCmdDataWriteMemoryBytes(void)
+CMICmdCmdDataWriteMemoryBytes::~CMICmdCmdDataWriteMemoryBytes()
{
}
@@ -1381,14 +1305,12 @@ CMICmdCmdDataWriteMemoryBytes::~CMICmdCmdDataWriteMemoryBytes(void)
// Throws: None.
//--
bool
-CMICmdCmdDataWriteMemoryBytes::ParseArgs(void)
+CMICmdCmdDataWriteMemoryBytes::ParseArgs()
{
- bool bOk =
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, false, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgAddr, true, true, false, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgContents, true, true, true, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgCount, false, true, false, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgAddr, true, true, false, true));
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgContents, true, true, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgCount, false, true, false, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -1401,7 +1323,7 @@ CMICmdCmdDataWriteMemoryBytes::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdDataWriteMemoryBytes::Execute(void)
+CMICmdCmdDataWriteMemoryBytes::Execute()
{
// Do nothing - not reproduceable (yet) in Eclipse
// CMICMDBASE_GETOPTION( pArgOffset, OptionShort, m_constStrArgOffset );
@@ -1425,7 +1347,7 @@ CMICmdCmdDataWriteMemoryBytes::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdDataWriteMemoryBytes::Acknowledge(void)
+CMICmdCmdDataWriteMemoryBytes::Acknowledge()
{
const CMICmnMIValueConst miValueConst(MIRSRC(IDS_WORD_NOT_IMPLEMENTED));
const CMICmnMIValueResult miValueResult("msg", miValueConst);
@@ -1444,7 +1366,7 @@ CMICmdCmdDataWriteMemoryBytes::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdDataWriteMemoryBytes::CreateSelf(void)
+CMICmdCmdDataWriteMemoryBytes::CreateSelf()
{
return new CMICmdCmdDataWriteMemoryBytes();
}
@@ -1460,9 +1382,8 @@ CMICmdCmdDataWriteMemoryBytes::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataWriteMemory::CMICmdCmdDataWriteMemory(void)
- : m_constStrArgThread("thread")
- , m_constStrArgOffset("o")
+CMICmdCmdDataWriteMemory::CMICmdCmdDataWriteMemory()
+ : m_constStrArgOffset("o")
, m_constStrArgAddr("address")
, m_constStrArgD("d")
, m_constStrArgNumber("a number")
@@ -1485,7 +1406,7 @@ CMICmdCmdDataWriteMemory::CMICmdCmdDataWriteMemory(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataWriteMemory::~CMICmdCmdDataWriteMemory(void)
+CMICmdCmdDataWriteMemory::~CMICmdCmdDataWriteMemory()
{
if (m_pBufferMemory != nullptr)
{
@@ -1504,17 +1425,14 @@ CMICmdCmdDataWriteMemory::~CMICmdCmdDataWriteMemory(void)
// Throws: None.
//--
bool
-CMICmdCmdDataWriteMemory::ParseArgs(void)
+CMICmdCmdDataWriteMemory::ParseArgs()
{
- bool bOk =
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, false, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk &&
- m_setCmdArgs.Add(*(new CMICmdArgValOptionShort(m_constStrArgOffset, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgAddr, true, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgD, true, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgNumber, true, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgContents, true, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgOffset, false, true, CMICmdArgValListBase::eArgValType_Number, 1));
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgAddr, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgD, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumber, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgContents, true, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -1527,7 +1445,7 @@ CMICmdCmdDataWriteMemory::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdDataWriteMemory::Execute(void)
+CMICmdCmdDataWriteMemory::Execute()
{
CMICMDBASE_GETOPTION(pArgOffset, OptionShort, m_constStrArgOffset);
CMICMDBASE_GETOPTION(pArgAddr, Number, m_constStrArgAddr);
@@ -1585,7 +1503,7 @@ CMICmdCmdDataWriteMemory::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdDataWriteMemory::Acknowledge(void)
+CMICmdCmdDataWriteMemory::Acknowledge()
{
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
m_miResultRecord = miRecordResult;
@@ -1602,7 +1520,7 @@ CMICmdCmdDataWriteMemory::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdDataWriteMemory::CreateSelf(void)
+CMICmdCmdDataWriteMemory::CreateSelf()
{
return new CMICmdCmdDataWriteMemory();
}
@@ -1618,7 +1536,7 @@ CMICmdCmdDataWriteMemory::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataInfoLine::CMICmdCmdDataInfoLine(void)
+CMICmdCmdDataInfoLine::CMICmdCmdDataInfoLine()
: m_constStrArgLocation("location")
{
// Command factory matches this name with that received from the stdin stream
@@ -1635,7 +1553,7 @@ CMICmdCmdDataInfoLine::CMICmdCmdDataInfoLine(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataInfoLine::~CMICmdCmdDataInfoLine(void)
+CMICmdCmdDataInfoLine::~CMICmdCmdDataInfoLine()
{
}
@@ -1649,10 +1567,10 @@ CMICmdCmdDataInfoLine::~CMICmdCmdDataInfoLine(void)
// Throws: None.
//--
bool
-CMICmdCmdDataInfoLine::ParseArgs(void)
+CMICmdCmdDataInfoLine::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgLocation, true, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgLocation, true, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -1665,7 +1583,7 @@ CMICmdCmdDataInfoLine::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdDataInfoLine::Execute(void)
+CMICmdCmdDataInfoLine::Execute()
{
CMICMDBASE_GETOPTION(pArgLocation, String, m_constStrArgLocation);
@@ -1676,7 +1594,7 @@ CMICmdCmdDataInfoLine::Execute(void)
// Parse argument:
// *0x12345
// ^^^^^^^ -- address
- const CMIUtilString strAddress(strLocation.c_str() + 1);
+ const CMIUtilString strAddress(strLocation.substr(1));
strCmdOptionsLocation = CMIUtilString::Format("--address %s", strAddress.c_str());
}
else
@@ -1692,8 +1610,8 @@ CMICmdCmdDataInfoLine::Execute(void)
// hello.cpp:5
// ^^^^^^^^^ -- file
// ^ -- line
- const CMIUtilString strFile(strLocation.substr(0, nLineStartPos).c_str());
- const CMIUtilString strLine(strLocation.substr(nLineStartPos + 1).c_str());
+ const CMIUtilString strFile(strLocation.substr(0, nLineStartPos));
+ const CMIUtilString strLine(strLocation.substr(nLineStartPos + 1));
strCmdOptionsLocation = CMIUtilString::Format("--file \"%s\" --line %s", strFile.AddSlashes().c_str(), strLine.c_str());
}
const CMIUtilString strCmd(CMIUtilString::Format("target modules lookup -v %s", strCmdOptionsLocation.c_str()));
@@ -1706,6 +1624,53 @@ CMICmdCmdDataInfoLine::Execute(void)
}
//++ ------------------------------------------------------------------------------------
+// Details: Helper function for parsing a line entry returned from lldb for the command:
+// target modules lookup -v <location>
+// where the line entry is of the format:
+// LineEntry: \[0x0000000100000f37-0x0000000100000f45\): /path/file:3[:1]
+// start end file line column(opt)
+// Args: input - (R) Input string to parse.
+// start - (W) String representing the start address.
+// end - (W) String representing the end address.
+// file - (W) String representing the file.
+// line - (W) String representing the line.
+// Return: bool - True = input was parsed successfully, false = input could not be parsed.
+// Throws: None.
+//--
+static bool
+ParseLLDBLineEntry(const char *input, CMIUtilString &start, CMIUtilString &end,
+ CMIUtilString &file, CMIUtilString &line)
+{
+ // Note: Ambiguities arise because the column is optional, and
+ // because : can appear in filenames or as a byte in a multibyte
+ // UTF8 character. We keep those cases to a minimum by using regex
+ // to work on the string from both the left and right, so that what
+ // is remains is assumed to be the filename.
+
+ // Match LineEntry using regex.
+ static MIUtilParse::CRegexParser g_lineentry_nocol_regex(
+ "^ *LineEntry: \\[(0x[0-9a-fA-F]+)-(0x[0-9a-fA-F]+)\\): (.+):([0-9]+)$");
+ static MIUtilParse::CRegexParser g_lineentry_col_regex(
+ "^ *LineEntry: \\[(0x[0-9a-fA-F]+)-(0x[0-9a-fA-F]+)\\): (.+):([0-9]+):[0-9]+$");
+ // ^1=start ^2=end ^3=f ^4=line ^5=:col(opt)
+
+ MIUtilParse::CRegexParser::Match match(6);
+
+ // First try matching the LineEntry with the column,
+ // then try without the column.
+ const bool ok = g_lineentry_col_regex.Execute(input, match) ||
+ g_lineentry_nocol_regex.Execute(input, match);
+ if (ok)
+ {
+ start = match.GetMatchAtIndex(1);
+ end = match.GetMatchAtIndex(2);
+ file = match.GetMatchAtIndex(3);
+ line = match.GetMatchAtIndex(4);
+ }
+ return ok;
+}
+
+//++ ------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record Result
// for the work carried out in the Execute().
// Type: Overridden.
@@ -1715,7 +1680,7 @@ CMICmdCmdDataInfoLine::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdDataInfoLine::Acknowledge(void)
+CMICmdCmdDataInfoLine::Acknowledge()
{
if (m_lldbResult.GetErrorSize() > 0)
{
@@ -1736,67 +1701,28 @@ CMICmdCmdDataInfoLine::Acknowledge(void)
// String looks like:
// LineEntry: \[0x0000000100000f37-0x0000000100000f45\): /path/to/file:3[:1]
const CMIUtilString &rLine(vecLines[i]);
+ CMIUtilString strStart;
+ CMIUtilString strEnd;
+ CMIUtilString strFile;
+ CMIUtilString strLine;
- // LineEntry: \[0x0000000100000f37-0x0000000100000f45\): /path/to/file:3[:1]
- // ^^^^^^^^^ -- property
- const size_t nPropertyStartPos = rLine.find_first_not_of(' ');
- const size_t nPropertyEndPos = rLine.find(':');
- const size_t nPropertyLen = nPropertyEndPos - nPropertyStartPos;
- const CMIUtilString strProperty(rLine.substr(nPropertyStartPos, nPropertyLen).c_str());
-
- // Skip all except LineEntry
- if (!CMIUtilString::Compare(strProperty, "LineEntry"))
+ if (!ParseLLDBLineEntry(rLine.c_str(), strStart, strEnd, strFile, strLine))
continue;
- // LineEntry: \[0x0000000100000f37-0x0000000100000f45\): /path/to/file:3[:1]
- // ^^^^^^^^^^^^^^^^^^ -- start address
- const size_t nStartAddressStartPos = rLine.find('[');
- const size_t nStartAddressEndPos = rLine.find('-');
- const size_t nStartAddressLen = nStartAddressEndPos - nStartAddressStartPos - 1;
- const CMIUtilString strStartAddress(rLine.substr(nStartAddressStartPos + 1, nStartAddressLen).c_str());
- const CMICmnMIValueConst miValueConst(strStartAddress);
+ const CMICmnMIValueConst miValueConst(strStart);
const CMICmnMIValueResult miValueResult("start", miValueConst);
- CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
-
- // LineEntry: \[0x0000000100000f37-0x0000000100000f45\): /path/to/file:3[:1]
- // ^^^^^^^^^^^^^^^^^^ -- end address
- const size_t nEndAddressEndPos = rLine.find(')');
- const size_t nEndAddressLen = nEndAddressEndPos - nStartAddressEndPos - 1;
- const CMIUtilString strEndAddress(rLine.substr(nStartAddressEndPos + 1, nEndAddressLen).c_str());
- const CMICmnMIValueConst miValueConst2(strEndAddress);
+ CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken,
+ CMICmnMIResultRecord::eResultClass_Done,
+ miValueResult);
+ const CMICmnMIValueConst miValueConst2(strEnd);
const CMICmnMIValueResult miValueResult2("end", miValueConst2);
- bool bOk = miRecordResult.Add(miValueResult2);
- if (!bOk)
- return MIstatus::failure;
-
- // LineEntry: \[0x0000000100000f37-0x0000000100000f45\): /path/to/file:3[:1]
- // ^^^^^^^^^^^^^ -- file
- // ^ -- line
- // ^ -- column (optional)
- const size_t nFileStartPos = rLine.find_first_not_of(' ', nEndAddressEndPos + 2);
- const size_t nFileOrLineEndPos = rLine.rfind(':');
- const size_t nFileOrLineStartPos = rLine.rfind(':', nFileOrLineEndPos - 1);
- const size_t nFileEndPos = nFileStartPos < nFileOrLineStartPos ? nFileOrLineStartPos : nFileOrLineEndPos;
- const size_t nFileLen = nFileEndPos - nFileStartPos;
- const CMIUtilString strFile(rLine.substr(nFileStartPos, nFileLen).c_str());
+ miRecordResult.Add(miValueResult2);
const CMICmnMIValueConst miValueConst3(strFile);
const CMICmnMIValueResult miValueResult3("file", miValueConst3);
- bOk = miRecordResult.Add(miValueResult3);
- if (!bOk)
- return MIstatus::failure;
-
- // LineEntry: \[0x0000000100000f37-0x0000000100000f45\): /path/to/file:3[:1]
- // ^ -- line
- const size_t nLineStartPos = nFileEndPos + 1;
- const size_t nLineEndPos = rLine.find(':', nLineStartPos);
- const size_t nLineLen = nLineEndPos != std::string::npos ? nLineEndPos - nLineStartPos
- : std::string::npos;
- const CMIUtilString strLine(rLine.substr(nLineStartPos, nLineLen).c_str());
+ miRecordResult.Add(miValueResult3);
const CMICmnMIValueConst miValueConst4(strLine);
const CMICmnMIValueResult miValueResult4("line", miValueConst4);
- bOk = miRecordResult.Add(miValueResult4);
- if (!bOk)
- return MIstatus::failure;
+ miRecordResult.Add(miValueResult4);
// MI print "%s^done,start=\"%d\",end=\"%d\"",file=\"%s\",line=\"%d\"
m_miResultRecord = miRecordResult;
@@ -1823,7 +1749,7 @@ CMICmdCmdDataInfoLine::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdDataInfoLine::CreateSelf(void)
+CMICmdCmdDataInfoLine::CreateSelf()
{
return new CMICmdCmdDataInfoLine();
}
diff --git a/tools/lldb-mi/MICmdCmdData.h b/tools/lldb-mi/MICmdCmdData.h
index 576441024a37..028c71387f31 100644
--- a/tools/lldb-mi/MICmdCmdData.h
+++ b/tools/lldb-mi/MICmdCmdData.h
@@ -42,29 +42,26 @@
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "data-evaluate-expression".
-// Gotchas: None.
-// Authors: Illya Rudkin 26/03/2014.
-// Changes: None.
//--
class CMICmdCmdDataEvaluateExpression : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdDataEvaluateExpression(void);
+ /* ctor */ CMICmdCmdDataEvaluateExpression();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdDataEvaluateExpression(void) override;
+ /* dtor */ ~CMICmdCmdDataEvaluateExpression() override;
// Methods:
private:
@@ -76,47 +73,39 @@ class CMICmdCmdDataEvaluateExpression : public CMICmdBase
bool m_bEvaluatedExpression; // True = yes is expression evaluated, false = failed
CMIUtilString m_strValue;
CMICmnMIValueTuple m_miValueTuple;
- bool m_bCompositeVarType; // True = yes composite type, false = internal type
bool m_bFoundInvalidChar; // True = yes found unexpected character in the expression, false = all ok
char m_cExpressionInvalidChar;
- const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option. Not handled by command.
- const CMIUtilString m_constStrArgFrame; // Not specified in MI spec but Eclipse gives this option. Not handled by command.
const CMIUtilString m_constStrArgExpr;
};
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "data-disassemble".
-// Gotchas: None.
-// Authors: Illya Rudkin 19/05/2014.
-// Changes: None.
//--
class CMICmdCmdDataDisassemble : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdDataDisassemble(void);
+ /* ctor */ CMICmdCmdDataDisassemble();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdDataDisassemble(void) override;
+ /* dtor */ ~CMICmdCmdDataDisassemble() override;
// Attributes:
private:
- const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option. Not handled by command.
const CMIUtilString m_constStrArgAddrStart; // MI spec non mandatory, *this command mandatory
const CMIUtilString m_constStrArgAddrEnd; // MI spec non mandatory, *this command mandatory
- const CMIUtilString m_constStrArgConsume;
const CMIUtilString m_constStrArgMode;
CMICmnMIValueList m_miValueList;
};
@@ -124,34 +113,29 @@ class CMICmdCmdDataDisassemble : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "data-read-memory-bytes".
-// Gotchas: None.
-// Authors: Illya Rudkin 20/05/2014.
-// Changes: None.
//--
class CMICmdCmdDataReadMemoryBytes : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdDataReadMemoryBytes(void);
+ /* ctor */ CMICmdCmdDataReadMemoryBytes();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdDataReadMemoryBytes(void) override;
+ /* dtor */ ~CMICmdCmdDataReadMemoryBytes() override;
// Attributes:
private:
- const CMIUtilString m_constStrArgThread; // Not in the MI spec but implemented by GDB.
- const CMIUtilString m_constStrArgFrame; // Not in the MI spec but implemented by GDB.
const CMIUtilString m_constStrArgByteOffset;
const CMIUtilString m_constStrArgAddrExpr;
const CMIUtilString m_constStrArgNumBytes;
@@ -163,56 +147,50 @@ class CMICmdCmdDataReadMemoryBytes : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "data-read-memory".
-// Gotchas: None.
-// Authors: Illya Rudkin 21/05/2014.
-// Changes: None.
//--
class CMICmdCmdDataReadMemory : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdDataReadMemory(void);
+ /* ctor */ CMICmdCmdDataReadMemory();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdDataReadMemory(void) override;
+ /* dtor */ ~CMICmdCmdDataReadMemory() override;
};
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "data-list-register-names".
-// Gotchas: None.
-// Authors: Illya Rudkin 21/05/2014.
-// Changes: None.
//--
class CMICmdCmdDataListRegisterNames : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdDataListRegisterNames(void);
+ /* ctor */ CMICmdCmdDataListRegisterNames();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdDataListRegisterNames(void) override;
+ /* dtor */ ~CMICmdCmdDataListRegisterNames() override;
// Methods:
private:
@@ -220,7 +198,6 @@ class CMICmdCmdDataListRegisterNames : public CMICmdBase
// Attributes:
private:
- const CMIUtilString m_constStrArgThreadGroup; // Not specified in MI spec but Eclipse gives this option
const CMIUtilString m_constStrArgRegNo; // Not handled by *this command
CMICmnMIValueList m_miValueList;
};
@@ -228,38 +205,34 @@ class CMICmdCmdDataListRegisterNames : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "data-list-register-values".
-// Gotchas: None.
-// Authors: Illya Rudkin 21/05/2014.
-// Changes: None.
//--
class CMICmdCmdDataListRegisterValues : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdDataListRegisterValues(void);
+ /* ctor */ CMICmdCmdDataListRegisterValues();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdDataListRegisterValues(void) override;
+ /* dtor */ ~CMICmdCmdDataListRegisterValues() override;
// Methods:
private:
lldb::SBValue GetRegister(const MIuint vRegisterIndex) const;
- bool AddToOutput(const MIuint vnIndex, const lldb::SBValue &vrValue, CMICmnLLDBDebugSessionInfoVarObj::varFormat_e veVarFormat);
+ void AddToOutput(const MIuint vnIndex, const lldb::SBValue &vrValue, CMICmnLLDBDebugSessionInfoVarObj::varFormat_e veVarFormat);
// Attributes:
private:
- const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option
const CMIUtilString m_constStrArgSkip; // Not handled by *this command
const CMIUtilString m_constStrArgFormat;
const CMIUtilString m_constStrArgRegNo;
@@ -269,60 +242,53 @@ class CMICmdCmdDataListRegisterValues : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "data-list-changed-registers".
-// Gotchas: None.
-// Authors: Illya Rudkin 22/05/2014.
-// Changes: None.
//--
class CMICmdCmdDataListRegisterChanged : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdDataListRegisterChanged(void);
+ /* ctor */ CMICmdCmdDataListRegisterChanged();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdDataListRegisterChanged(void) override;
+ /* dtor */ ~CMICmdCmdDataListRegisterChanged() override;
};
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "data-read-memory-bytes".
-// Gotchas: None.
-// Authors: Illya Rudkin 30/05/2014.
-// Changes: None.
//--
class CMICmdCmdDataWriteMemoryBytes : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdDataWriteMemoryBytes(void);
+ /* ctor */ CMICmdCmdDataWriteMemoryBytes();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdDataWriteMemoryBytes(void) override;
+ /* dtor */ ~CMICmdCmdDataWriteMemoryBytes() override;
// Attributes:
private:
- const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option. Not handled by command.
const CMIUtilString m_constStrArgAddr;
const CMIUtilString m_constStrArgContents;
const CMIUtilString m_constStrArgCount;
@@ -333,33 +299,29 @@ class CMICmdCmdDataWriteMemoryBytes : public CMICmdBase
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "data-read-memory".
// Not specified in MI spec but Eclipse gives *this command.
-// Gotchas: None.
-// Authors: Illya Rudkin 02/05/2014.
-// Changes: None.
//--
class CMICmdCmdDataWriteMemory : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdDataWriteMemory(void);
+ /* ctor */ CMICmdCmdDataWriteMemory();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdDataWriteMemory(void) override;
+ /* dtor */ ~CMICmdCmdDataWriteMemory() override;
// Attributes:
private:
- const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option. Not handled by command.
const CMIUtilString m_constStrArgOffset; // Not specified in MI spec but Eclipse gives this option.
const CMIUtilString m_constStrArgAddr; // Not specified in MI spec but Eclipse gives this option.
const CMIUtilString m_constStrArgD; // Not specified in MI spec but Eclipse gives this option.
@@ -381,20 +343,20 @@ class CMICmdCmdDataInfoLine : public CMICmdBase
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdDataInfoLine(void);
+ /* ctor */ CMICmdCmdDataInfoLine();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdDataInfoLine(void) override;
+ /* dtor */ ~CMICmdCmdDataInfoLine() override;
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmdCmdEnviro.cpp b/tools/lldb-mi/MICmdCmdEnviro.cpp
index dd167841032a..adacc2a5780b 100644
--- a/tools/lldb-mi/MICmdCmdEnviro.cpp
+++ b/tools/lldb-mi/MICmdCmdEnviro.cpp
@@ -24,7 +24,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdCmdEnvironmentCd::CMICmdCmdEnvironmentCd(void)
+CMICmdCmdEnvironmentCd::CMICmdCmdEnvironmentCd()
: m_constStrArgNamePathDir("pathdir")
{
// Command factory matches this name with that received from the stdin stream
@@ -41,7 +41,7 @@ CMICmdCmdEnvironmentCd::CMICmdCmdEnvironmentCd(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdEnvironmentCd::~CMICmdCmdEnvironmentCd(void)
+CMICmdCmdEnvironmentCd::~CMICmdCmdEnvironmentCd()
{
}
@@ -55,11 +55,11 @@ CMICmdCmdEnvironmentCd::~CMICmdCmdEnvironmentCd(void)
// Throws: None.
//--
bool
-CMICmdCmdEnvironmentCd::ParseArgs(void)
+CMICmdCmdEnvironmentCd::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValFile(m_constStrArgNamePathDir, true, true)));
+ m_setCmdArgs.Add(new CMICmdArgValFile(m_constStrArgNamePathDir, true, true));
CMICmdArgContext argCntxt(m_cmdData.strMiCmdOption);
- return (bOk && ParseValidateCmdOptions());
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -72,7 +72,7 @@ CMICmdCmdEnvironmentCd::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdEnvironmentCd::Execute(void)
+CMICmdCmdEnvironmentCd::Execute()
{
CMICMDBASE_GETOPTION(pArgPathDir, File, m_constStrArgNamePathDir);
const CMIUtilString &strWkDir(pArgPathDir->GetValue());
@@ -104,7 +104,7 @@ CMICmdCmdEnvironmentCd::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdEnvironmentCd::Acknowledge(void)
+CMICmdCmdEnvironmentCd::Acknowledge()
{
const CMIUtilString &rStrKeyWkDir(m_rLLDBDebugSessionInfo.m_constStrSharedDataKeyWkDir);
CMIUtilString strWkDir;
@@ -131,7 +131,7 @@ CMICmdCmdEnvironmentCd::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdEnvironmentCd::CreateSelf(void)
+CMICmdCmdEnvironmentCd::CreateSelf()
{
return new CMICmdCmdEnvironmentCd();
}
diff --git a/tools/lldb-mi/MICmdCmdEnviro.h b/tools/lldb-mi/MICmdCmdEnviro.h
index 7d5cf98dd4bc..6f06cb69c7ec 100644
--- a/tools/lldb-mi/MICmdCmdEnviro.h
+++ b/tools/lldb-mi/MICmdCmdEnviro.h
@@ -28,29 +28,26 @@
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "environment-cd".
-// Gotchas: None.
-// Authors: Illya Rudkin 03/03/2014.
-// Changes: None.
//--
class CMICmdCmdEnvironmentCd : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdEnvironmentCd(void);
+ /* ctor */ CMICmdCmdEnvironmentCd();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdEnvironmentCd(void) override;
+ /* dtor */ ~CMICmdCmdEnvironmentCd() override;
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmdCmdExec.cpp b/tools/lldb-mi/MICmdCmdExec.cpp
index f0208c83d58d..dccfe129b2c0 100644
--- a/tools/lldb-mi/MICmdCmdExec.cpp
+++ b/tools/lldb-mi/MICmdCmdExec.cpp
@@ -47,7 +47,8 @@
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecRun::CMICmdCmdExecRun(void)
+CMICmdCmdExecRun::CMICmdCmdExecRun()
+ : m_constStrArgStart("start")
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "exec-run";
@@ -63,11 +64,28 @@ CMICmdCmdExecRun::CMICmdCmdExecRun(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecRun::~CMICmdCmdExecRun(void)
+CMICmdCmdExecRun::~CMICmdCmdExecRun()
{
}
//++ ------------------------------------------------------------------------------------
+// Details: The invoker requires this function. It parses the command line options'
+// arguments to extract values for each of those arguments.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool
+CMICmdCmdExecRun::ParseArgs()
+{
+ m_setCmdArgs.Add(
+ new CMICmdArgValOptionLong(m_constStrArgStart, false, true, CMICmdArgValListBase::eArgValType_OptionLong, 0));
+ 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 here.
// Type: Overridden.
@@ -77,13 +95,21 @@ CMICmdCmdExecRun::~CMICmdCmdExecRun(void)
// Throws: None.
//--
bool
-CMICmdCmdExecRun::Execute(void)
+CMICmdCmdExecRun::Execute()
{
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
lldb::SBError error;
lldb::SBStream errMsg;
lldb::SBLaunchInfo launchInfo = rSessionInfo.GetTarget().GetLaunchInfo();
launchInfo.SetListener(rSessionInfo.GetListener());
+
+ // Run to first instruction or main() requested?
+ CMICMDBASE_GETOPTION(pArgStart, OptionLong, m_constStrArgStart);
+ if (pArgStart->GetFound())
+ {
+ launchInfo.SetLaunchFlags(launchInfo.GetLaunchFlags() | lldb::eLaunchFlagStopAtEntry);
+ }
+
lldb::SBProcess process = rSessionInfo.GetTarget().Launch(launchInfo, error);
if ((!process.IsValid()) || (error.Fail()))
{
@@ -103,6 +129,7 @@ CMICmdCmdExecRun::Execute(void)
//++ ------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record Result
// for the work carried out in the Execute().
+// Called only if Execute() set status as successful on completion.
// Type: Overridden.
// Args: None.
// Return: MIstatus::success - Functional succeeded.
@@ -110,33 +137,23 @@ CMICmdCmdExecRun::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdExecRun::Acknowledge(void)
+CMICmdCmdExecRun::Acknowledge()
{
- if (m_lldbResult.GetErrorSize() > 0)
- {
- const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
- const CMICmnMIValueResult miValueResult("message", miValueConst);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
- m_miResultRecord = miRecordResult;
- }
- else
- {
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
- m_miResultRecord = miRecordResult;
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
+ m_miResultRecord = miRecordResult;
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::pid_t pid = rSessionInfo.GetProcess().GetProcessID();
- // Give the client '=thread-group-started,id="i1" pid="xyz"'
- m_bHasResultRecordExtra = true;
- const CMICmnMIValueConst miValueConst2("i1");
- const CMICmnMIValueResult miValueResult2("id", miValueConst2);
- const CMIUtilString strPid(CMIUtilString::Format("%lld", pid));
- const CMICmnMIValueConst miValueConst(strPid);
- const CMICmnMIValueResult miValueResult("pid", miValueConst);
- CMICmnMIOutOfBandRecord miOutOfBand(CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, miValueResult2);
- miOutOfBand.Add(miValueResult);
- m_miResultRecordExtra = miOutOfBand.GetString();
- }
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::pid_t pid = rSessionInfo.GetProcess().GetProcessID();
+ // Give the client '=thread-group-started,id="i1" pid="xyz"'
+ m_bHasResultRecordExtra = true;
+ const CMICmnMIValueConst miValueConst2("i1");
+ const CMICmnMIValueResult miValueResult2("id", miValueConst2);
+ const CMIUtilString strPid(CMIUtilString::Format("%lld", pid));
+ const CMICmnMIValueConst miValueConst(strPid);
+ const CMICmnMIValueResult miValueResult("pid", miValueConst);
+ CMICmnMIOutOfBandRecord miOutOfBand(CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, miValueResult2);
+ miOutOfBand.Add(miValueResult);
+ m_miResultRecordExtra = miOutOfBand.GetString();
return MIstatus::success;
}
@@ -150,7 +167,7 @@ CMICmdCmdExecRun::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdExecRun::CreateSelf(void)
+CMICmdCmdExecRun::CreateSelf()
{
return new CMICmdCmdExecRun();
}
@@ -166,7 +183,7 @@ CMICmdCmdExecRun::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecContinue::CMICmdCmdExecContinue(void)
+CMICmdCmdExecContinue::CMICmdCmdExecContinue()
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "exec-continue";
@@ -182,7 +199,7 @@ CMICmdCmdExecContinue::CMICmdCmdExecContinue(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecContinue::~CMICmdCmdExecContinue(void)
+CMICmdCmdExecContinue::~CMICmdCmdExecContinue()
{
}
@@ -196,7 +213,7 @@ CMICmdCmdExecContinue::~CMICmdCmdExecContinue(void)
// Throws: None.
//--
bool
-CMICmdCmdExecContinue::Execute(void)
+CMICmdCmdExecContinue::Execute()
{
const char *pCmd = "continue";
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
@@ -238,7 +255,7 @@ CMICmdCmdExecContinue::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdExecContinue::Acknowledge(void)
+CMICmdCmdExecContinue::Acknowledge()
{
if (m_lldbResult.GetErrorSize() > 0)
{
@@ -265,7 +282,7 @@ CMICmdCmdExecContinue::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdExecContinue::CreateSelf(void)
+CMICmdCmdExecContinue::CreateSelf()
{
return new CMICmdCmdExecContinue();
}
@@ -281,9 +298,8 @@ CMICmdCmdExecContinue::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecNext::CMICmdCmdExecNext(void)
- : m_constStrArgThread("thread")
- , m_constStrArgNumber("number")
+CMICmdCmdExecNext::CMICmdCmdExecNext()
+ : m_constStrArgNumber("number")
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "exec-next";
@@ -299,7 +315,7 @@ CMICmdCmdExecNext::CMICmdCmdExecNext(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecNext::~CMICmdCmdExecNext(void)
+CMICmdCmdExecNext::~CMICmdCmdExecNext()
{
}
@@ -313,12 +329,10 @@ CMICmdCmdExecNext::~CMICmdCmdExecNext(void)
// Throws: None.
//--
bool
-CMICmdCmdExecNext::ParseArgs(void)
+CMICmdCmdExecNext::ParseArgs()
{
- bool bOk =
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgNumber, false, false)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumber, false, false));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -331,7 +345,7 @@ CMICmdCmdExecNext::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdExecNext::Execute(void)
+CMICmdCmdExecNext::Execute()
{
CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
@@ -363,7 +377,7 @@ CMICmdCmdExecNext::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdExecNext::Acknowledge(void)
+CMICmdCmdExecNext::Acknowledge()
{
if (m_lldbResult.GetErrorSize() > 0)
{
@@ -392,7 +406,7 @@ CMICmdCmdExecNext::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdExecNext::CreateSelf(void)
+CMICmdCmdExecNext::CreateSelf()
{
return new CMICmdCmdExecNext();
}
@@ -408,9 +422,8 @@ CMICmdCmdExecNext::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecStep::CMICmdCmdExecStep(void)
- : m_constStrArgThread("thread")
- , m_constStrArgNumber("number")
+CMICmdCmdExecStep::CMICmdCmdExecStep()
+ : m_constStrArgNumber("number")
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "exec-step";
@@ -426,7 +439,7 @@ CMICmdCmdExecStep::CMICmdCmdExecStep(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecStep::~CMICmdCmdExecStep(void)
+CMICmdCmdExecStep::~CMICmdCmdExecStep()
{
}
@@ -440,12 +453,10 @@ CMICmdCmdExecStep::~CMICmdCmdExecStep(void)
// Throws: None.
//--
bool
-CMICmdCmdExecStep::ParseArgs(void)
+CMICmdCmdExecStep::ParseArgs()
{
- bool bOk =
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgNumber, false, false)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumber, false, false));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -458,7 +469,7 @@ CMICmdCmdExecStep::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdExecStep::Execute(void)
+CMICmdCmdExecStep::Execute()
{
CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
@@ -490,7 +501,7 @@ CMICmdCmdExecStep::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdExecStep::Acknowledge(void)
+CMICmdCmdExecStep::Acknowledge()
{
if (m_lldbResult.GetErrorSize() > 0)
{
@@ -519,7 +530,7 @@ CMICmdCmdExecStep::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdExecStep::CreateSelf(void)
+CMICmdCmdExecStep::CreateSelf()
{
return new CMICmdCmdExecStep();
}
@@ -535,9 +546,8 @@ CMICmdCmdExecStep::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecNextInstruction::CMICmdCmdExecNextInstruction(void)
- : m_constStrArgThread("thread")
- , m_constStrArgNumber("number")
+CMICmdCmdExecNextInstruction::CMICmdCmdExecNextInstruction()
+ : m_constStrArgNumber("number")
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "exec-next-instruction";
@@ -553,7 +563,7 @@ CMICmdCmdExecNextInstruction::CMICmdCmdExecNextInstruction(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecNextInstruction::~CMICmdCmdExecNextInstruction(void)
+CMICmdCmdExecNextInstruction::~CMICmdCmdExecNextInstruction()
{
}
@@ -567,12 +577,10 @@ CMICmdCmdExecNextInstruction::~CMICmdCmdExecNextInstruction(void)
// Throws: None.
//--
bool
-CMICmdCmdExecNextInstruction::ParseArgs(void)
+CMICmdCmdExecNextInstruction::ParseArgs()
{
- bool bOk =
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgNumber, false, false)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumber, false, false));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -585,7 +593,7 @@ CMICmdCmdExecNextInstruction::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdExecNextInstruction::Execute(void)
+CMICmdCmdExecNextInstruction::Execute()
{
CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
@@ -617,7 +625,7 @@ CMICmdCmdExecNextInstruction::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdExecNextInstruction::Acknowledge(void)
+CMICmdCmdExecNextInstruction::Acknowledge()
{
if (m_lldbResult.GetErrorSize() > 0)
{
@@ -646,7 +654,7 @@ CMICmdCmdExecNextInstruction::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdExecNextInstruction::CreateSelf(void)
+CMICmdCmdExecNextInstruction::CreateSelf()
{
return new CMICmdCmdExecNextInstruction();
}
@@ -662,9 +670,8 @@ CMICmdCmdExecNextInstruction::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecStepInstruction::CMICmdCmdExecStepInstruction(void)
- : m_constStrArgThread("thread")
- , m_constStrArgNumber("number")
+CMICmdCmdExecStepInstruction::CMICmdCmdExecStepInstruction()
+ : m_constStrArgNumber("number")
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "exec-step-instruction";
@@ -680,7 +687,7 @@ CMICmdCmdExecStepInstruction::CMICmdCmdExecStepInstruction(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecStepInstruction::~CMICmdCmdExecStepInstruction(void)
+CMICmdCmdExecStepInstruction::~CMICmdCmdExecStepInstruction()
{
}
@@ -694,12 +701,10 @@ CMICmdCmdExecStepInstruction::~CMICmdCmdExecStepInstruction(void)
// Throws: None.
//--
bool
-CMICmdCmdExecStepInstruction::ParseArgs(void)
+CMICmdCmdExecStepInstruction::ParseArgs()
{
- bool bOk =
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgNumber, false, false)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumber, false, false));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -712,7 +717,7 @@ CMICmdCmdExecStepInstruction::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdExecStepInstruction::Execute(void)
+CMICmdCmdExecStepInstruction::Execute()
{
CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
@@ -744,7 +749,7 @@ CMICmdCmdExecStepInstruction::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdExecStepInstruction::Acknowledge(void)
+CMICmdCmdExecStepInstruction::Acknowledge()
{
if (m_lldbResult.GetErrorSize() > 0)
{
@@ -773,7 +778,7 @@ CMICmdCmdExecStepInstruction::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdExecStepInstruction::CreateSelf(void)
+CMICmdCmdExecStepInstruction::CreateSelf()
{
return new CMICmdCmdExecStepInstruction();
}
@@ -789,9 +794,7 @@ CMICmdCmdExecStepInstruction::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecFinish::CMICmdCmdExecFinish(void)
- : m_constStrArgThread("thread")
- , m_constStrArgFrame("frame")
+CMICmdCmdExecFinish::CMICmdCmdExecFinish()
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "exec-finish";
@@ -807,7 +810,7 @@ CMICmdCmdExecFinish::CMICmdCmdExecFinish(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecFinish::~CMICmdCmdExecFinish(void)
+CMICmdCmdExecFinish::~CMICmdCmdExecFinish()
{
}
@@ -821,13 +824,9 @@ CMICmdCmdExecFinish::~CMICmdCmdExecFinish(void)
// Throws: None.
//--
bool
-CMICmdCmdExecFinish::ParseArgs(void)
+CMICmdCmdExecFinish::ParseArgs()
{
- bool bOk =
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk &&
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgFrame, false, false, CMICmdArgValListBase::eArgValType_Number, 1)));
- return (bOk && ParseValidateCmdOptions());
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -840,7 +839,7 @@ CMICmdCmdExecFinish::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdExecFinish::Execute(void)
+CMICmdCmdExecFinish::Execute()
{
CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
@@ -872,7 +871,7 @@ CMICmdCmdExecFinish::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdExecFinish::Acknowledge(void)
+CMICmdCmdExecFinish::Acknowledge()
{
if (m_lldbResult.GetErrorSize() > 0)
{
@@ -901,7 +900,7 @@ CMICmdCmdExecFinish::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdExecFinish::CreateSelf(void)
+CMICmdCmdExecFinish::CreateSelf()
{
return new CMICmdCmdExecFinish();
}
@@ -917,7 +916,7 @@ CMICmdCmdExecFinish::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecInterrupt::CMICmdCmdExecInterrupt(void)
+CMICmdCmdExecInterrupt::CMICmdCmdExecInterrupt()
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "exec-interrupt";
@@ -933,7 +932,7 @@ CMICmdCmdExecInterrupt::CMICmdCmdExecInterrupt(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecInterrupt::~CMICmdCmdExecInterrupt(void)
+CMICmdCmdExecInterrupt::~CMICmdCmdExecInterrupt()
{
}
@@ -947,7 +946,7 @@ CMICmdCmdExecInterrupt::~CMICmdCmdExecInterrupt(void)
// Throws: None.
//--
bool
-CMICmdCmdExecInterrupt::Execute(void)
+CMICmdCmdExecInterrupt::Execute()
{
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
@@ -976,7 +975,7 @@ CMICmdCmdExecInterrupt::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdExecInterrupt::Acknowledge(void)
+CMICmdCmdExecInterrupt::Acknowledge()
{
if (m_lldbResult.GetErrorSize() > 0)
{
@@ -1003,7 +1002,7 @@ CMICmdCmdExecInterrupt::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdExecInterrupt::CreateSelf(void)
+CMICmdCmdExecInterrupt::CreateSelf()
{
return new CMICmdCmdExecInterrupt();
}
@@ -1019,7 +1018,7 @@ CMICmdCmdExecInterrupt::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecArguments::CMICmdCmdExecArguments(void)
+CMICmdCmdExecArguments::CMICmdCmdExecArguments()
: m_constStrArgArguments("arguments")
{
// Command factory matches this name with that received from the stdin stream
@@ -1036,7 +1035,7 @@ CMICmdCmdExecArguments::CMICmdCmdExecArguments(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecArguments::~CMICmdCmdExecArguments(void)
+CMICmdCmdExecArguments::~CMICmdCmdExecArguments()
{
}
@@ -1050,11 +1049,11 @@ CMICmdCmdExecArguments::~CMICmdCmdExecArguments(void)
// Throws: None.
//--
bool
-CMICmdCmdExecArguments::ParseArgs(void)
+CMICmdCmdExecArguments::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(
- *(new CMICmdArgValListOfN(m_constStrArgArguments, false, true, CMICmdArgValListBase::eArgValType_StringAnything)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(
+ new CMICmdArgValListOfN(m_constStrArgArguments, false, true, CMICmdArgValListBase::eArgValType_StringAnything));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -1067,7 +1066,7 @@ CMICmdCmdExecArguments::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdExecArguments::Execute(void)
+CMICmdCmdExecArguments::Execute()
{
CMICMDBASE_GETOPTION(pArgArguments, ListOfN, m_constStrArgArguments);
@@ -1106,7 +1105,7 @@ CMICmdCmdExecArguments::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdExecArguments::Acknowledge(void)
+CMICmdCmdExecArguments::Acknowledge()
{
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
m_miResultRecord = miRecordResult;
@@ -1123,7 +1122,7 @@ CMICmdCmdExecArguments::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdExecArguments::CreateSelf(void)
+CMICmdCmdExecArguments::CreateSelf()
{
return new CMICmdCmdExecArguments();
}
@@ -1139,7 +1138,7 @@ CMICmdCmdExecArguments::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecAbort::CMICmdCmdExecAbort(void)
+CMICmdCmdExecAbort::CMICmdCmdExecAbort()
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "exec-abort";
@@ -1155,7 +1154,7 @@ CMICmdCmdExecAbort::CMICmdCmdExecAbort(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecAbort::~CMICmdCmdExecAbort(void)
+CMICmdCmdExecAbort::~CMICmdCmdExecAbort()
{
}
@@ -1169,7 +1168,7 @@ CMICmdCmdExecAbort::~CMICmdCmdExecAbort(void)
// Throws: None.
//--
bool
-CMICmdCmdExecAbort::Execute(void)
+CMICmdCmdExecAbort::Execute()
{
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
@@ -1199,7 +1198,7 @@ CMICmdCmdExecAbort::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdExecAbort::Acknowledge(void)
+CMICmdCmdExecAbort::Acknowledge()
{
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
m_miResultRecord = miRecordResult;
@@ -1215,7 +1214,7 @@ CMICmdCmdExecAbort::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdExecAbort::CreateSelf(void)
+CMICmdCmdExecAbort::CreateSelf()
{
return new CMICmdCmdExecAbort();
}
diff --git a/tools/lldb-mi/MICmdCmdExec.h b/tools/lldb-mi/MICmdCmdExec.h
index 94d646fd8325..c131132870bc 100644
--- a/tools/lldb-mi/MICmdCmdExec.h
+++ b/tools/lldb-mi/MICmdCmdExec.h
@@ -38,59 +38,55 @@
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "exec-run".
-// Gotchas: None.
-// Authors: Illya Rudkin 07/03/2014.
-// Changes: None.
//--
class CMICmdCmdExecRun : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdExecRun(void);
+ /* ctor */ CMICmdCmdExecRun();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdExecRun(void) override;
+ /* dtor */ ~CMICmdCmdExecRun() override;
// Attributes:
private:
+ const CMIUtilString m_constStrArgStart; // StopAtEntry - run to first instruction or main() if specified
lldb::SBCommandReturnObject m_lldbResult;
};
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "exec-continue".
-// Gotchas: None.
-// Authors: Illya Rudkin 07/03/2014.
-// Changes: None.
//--
class CMICmdCmdExecContinue : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdExecContinue(void);
+ /* ctor */ CMICmdCmdExecContinue();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdExecContinue(void) override;
+ /* dtor */ ~CMICmdCmdExecContinue() override;
// Attributes:
private:
@@ -100,171 +96,150 @@ class CMICmdCmdExecContinue : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "exec-next".
-// Gotchas: None.
-// Authors: Illya Rudkin 25/03/2014.
-// Changes: None.
//--
class CMICmdCmdExecNext : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdExecNext(void);
+ /* ctor */ CMICmdCmdExecNext();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdExecNext(void) override;
+ /* dtor */ ~CMICmdCmdExecNext() override;
// Attributes:
private:
lldb::SBCommandReturnObject m_lldbResult;
- const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option
const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but Eclipse gives this option
};
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "exec-step".
-// Gotchas: None.
-// Authors: Illya Rudkin 25/03/2014.
-// Changes: None.
//--
class CMICmdCmdExecStep : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdExecStep(void);
+ /* ctor */ CMICmdCmdExecStep();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdExecStep(void) override;
+ /* dtor */ ~CMICmdCmdExecStep() override;
// Attributes:
private:
lldb::SBCommandReturnObject m_lldbResult;
- const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option
const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but Eclipse gives this option
};
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "exec-next-instruction".
-// Gotchas: None.
-// Authors: Illya Rudkin 25/03/2014.
-// Changes: None.
//--
class CMICmdCmdExecNextInstruction : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdExecNextInstruction(void);
+ /* ctor */ CMICmdCmdExecNextInstruction();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdExecNextInstruction(void) override;
+ /* dtor */ ~CMICmdCmdExecNextInstruction() override;
// Attributes:
private:
lldb::SBCommandReturnObject m_lldbResult;
- const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option
const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but Eclipse gives this option
};
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "exec-step-instruction".
-// Gotchas: None.
-// Authors: Illya Rudkin 25/03/2014.
-// Changes: None.
//--
class CMICmdCmdExecStepInstruction : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdExecStepInstruction(void);
+ /* ctor */ CMICmdCmdExecStepInstruction();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdExecStepInstruction(void) override;
+ /* dtor */ ~CMICmdCmdExecStepInstruction() override;
// Attributes:
private:
lldb::SBCommandReturnObject m_lldbResult;
- const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option
const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but Eclipse gives this option
};
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "exec-finish".
-// Gotchas: None.
-// Authors: Illya Rudkin 25/03/2014.
-// Changes: None.
//--
class CMICmdCmdExecFinish : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdExecFinish(void);
+ /* ctor */ CMICmdCmdExecFinish();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdExecFinish(void) override;
+ /* dtor */ ~CMICmdCmdExecFinish() override;
// Attributes:
private:
lldb::SBCommandReturnObject m_lldbResult;
- const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option
- const CMIUtilString m_constStrArgFrame; // Not specified in MI spec but Eclipse gives this option
};
// CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM
@@ -273,27 +248,25 @@ class CMICmdCmdExecFinish : public CMICmdBase
// *this class implements MI command "exec-interrupt".
// Gotchas: Using Eclipse this command is injected into the command system when a
// SIGINT signal is received while running an inferior program.
-// Authors: Illya Rudkin 03/06/2014.
-// Changes: None.
//--
class CMICmdCmdExecInterrupt : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdExecInterrupt(void);
+ /* ctor */ CMICmdCmdExecInterrupt();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdExecInterrupt(void) override;
+ /* dtor */ ~CMICmdCmdExecInterrupt() override;
// Attributes:
private:
@@ -303,29 +276,26 @@ class CMICmdCmdExecInterrupt : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "exec-arguments".
-// Gotchas: None.
-// Authors: Ilia Kirianovskii 25/11/2014.
-// Changes: None.
//--
class CMICmdCmdExecArguments : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdExecArguments(void);
+ /* ctor */ CMICmdCmdExecArguments();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdExecArguments(void) override;
+ /* dtor */ ~CMICmdCmdExecArguments() override;
// Attributes:
private:
@@ -341,17 +311,17 @@ class CMICmdCmdExecAbort : public CMICmdBase
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdExecAbort(void);
+ /* ctor */ CMICmdCmdExecAbort();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdExecAbort(void) override;
+ /* dtor */ ~CMICmdCmdExecAbort() override;
};
diff --git a/tools/lldb-mi/MICmdCmdFile.cpp b/tools/lldb-mi/MICmdCmdFile.cpp
index b28060e29f25..3316c8eccaf9 100644
--- a/tools/lldb-mi/MICmdCmdFile.cpp
+++ b/tools/lldb-mi/MICmdCmdFile.cpp
@@ -30,9 +30,8 @@
// Return: None.
// Throws: None.
//--
-CMICmdCmdFileExecAndSymbols::CMICmdCmdFileExecAndSymbols(void)
+CMICmdCmdFileExecAndSymbols::CMICmdCmdFileExecAndSymbols()
: m_constStrArgNameFile("file")
- , m_constStrArgThreadGrp("thread-group")
, m_constStrArgNamedPlatformName("p")
, m_constStrArgNamedRemotePath("r")
{
@@ -50,7 +49,7 @@ CMICmdCmdFileExecAndSymbols::CMICmdCmdFileExecAndSymbols(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdFileExecAndSymbols::~CMICmdCmdFileExecAndSymbols(void)
+CMICmdCmdFileExecAndSymbols::~CMICmdCmdFileExecAndSymbols()
{
}
@@ -64,18 +63,14 @@ CMICmdCmdFileExecAndSymbols::~CMICmdCmdFileExecAndSymbols(void)
// Throws: None.
//--
bool
-CMICmdCmdFileExecAndSymbols::ParseArgs(void)
+CMICmdCmdFileExecAndSymbols::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(
- *(new CMICmdArgValOptionLong(m_constStrArgThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValFile(m_constStrArgNameFile, true, true)));
- bOk = bOk &&
- m_setCmdArgs.Add(*(new CMICmdArgValOptionShort(m_constStrArgNamedPlatformName, false, true,
- CMICmdArgValListBase::eArgValType_String, 1)));
- bOk = bOk &&
- m_setCmdArgs.Add(*(new CMICmdArgValOptionShort(m_constStrArgNamedRemotePath, false, true,
- CMICmdArgValListBase::eArgValType_StringQuotedNumberPath, 1)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValFile(m_constStrArgNameFile, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedPlatformName, false, true,
+ CMICmdArgValListBase::eArgValType_String, 1));
+ m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedRemotePath, false, true,
+ CMICmdArgValListBase::eArgValType_StringQuotedNumberPath, 1));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -90,7 +85,7 @@ CMICmdCmdFileExecAndSymbols::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdFileExecAndSymbols::Execute(void)
+CMICmdCmdFileExecAndSymbols::Execute()
{
CMICMDBASE_GETOPTION(pArgNamedFile, File, m_constStrArgNameFile);
CMICMDBASE_GETOPTION(pArgPlatformName, OptionShort, m_constStrArgNamedPlatformName);
@@ -168,7 +163,7 @@ CMICmdCmdFileExecAndSymbols::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdFileExecAndSymbols::Acknowledge(void)
+CMICmdCmdFileExecAndSymbols::Acknowledge()
{
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
m_miResultRecord = miRecordResult;
@@ -185,7 +180,7 @@ CMICmdCmdFileExecAndSymbols::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdFileExecAndSymbols::CreateSelf(void)
+CMICmdCmdFileExecAndSymbols::CreateSelf()
{
return new CMICmdCmdFileExecAndSymbols();
}
@@ -202,7 +197,7 @@ CMICmdCmdFileExecAndSymbols::CreateSelf(void)
// Throws: None.
//--
bool
-CMICmdCmdFileExecAndSymbols::GetExitAppOnCommandFailure(void) const
+CMICmdCmdFileExecAndSymbols::GetExitAppOnCommandFailure() const
{
return true;
}
diff --git a/tools/lldb-mi/MICmdCmdFile.h b/tools/lldb-mi/MICmdCmdFile.h
index 2c1b59ca47ad..b6bf5e5ccc6c 100644
--- a/tools/lldb-mi/MICmdCmdFile.h
+++ b/tools/lldb-mi/MICmdCmdFile.h
@@ -31,35 +31,31 @@
// This command does not follow the MI documentation exactly.
// Gotchas: This command has additional flags that were not available in GDB MI.
// See MIextensions.txt for details.
-// Authors: Illya Rudkin 25/02/2014.
-// Changes: None.
//--
class CMICmdCmdFileExecAndSymbols : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdFileExecAndSymbols(void);
+ /* ctor */ CMICmdCmdFileExecAndSymbols();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdFileExecAndSymbols(void) override;
- bool GetExitAppOnCommandFailure(void) const override;
+ /* dtor */ ~CMICmdCmdFileExecAndSymbols() override;
+ bool GetExitAppOnCommandFailure() const override;
// Attributes:
private:
const CMIUtilString m_constStrArgNameFile;
- const CMIUtilString
- m_constStrArgThreadGrp; // Not handled by *this command. Not specified in MI spec but Eclipse gives this option sometimes
const CMIUtilString m_constStrArgNamedPlatformName; // Added to support iOS platform selection
const CMIUtilString m_constStrArgNamedRemotePath; // Added to support iOS device remote file location
};
diff --git a/tools/lldb-mi/MICmdCmdGdbInfo.cpp b/tools/lldb-mi/MICmdCmdGdbInfo.cpp
index 25e0ff4ffbe8..c57c4ac6f02b 100644
--- a/tools/lldb-mi/MICmdCmdGdbInfo.cpp
+++ b/tools/lldb-mi/MICmdCmdGdbInfo.cpp
@@ -1,4 +1,4 @@
-//===-- MICmdCmdGdbInfo.cpp ------------------------*- C++ -*-===//
+//===-- MICmdCmdGdbInfo.cpp -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -32,7 +32,7 @@ const CMICmdCmdGdbInfo::MapPrintFnNameToPrintFn_t CMICmdCmdGdbInfo::ms_mapPrintF
// Return: None.
// Throws: None.
//--
-CMICmdCmdGdbInfo::CMICmdCmdGdbInfo(void)
+CMICmdCmdGdbInfo::CMICmdCmdGdbInfo()
: m_constStrArgNamedPrint("print")
, m_bPrintFnRecognised(true)
, m_bPrintFnSuccessful(false)
@@ -52,7 +52,7 @@ CMICmdCmdGdbInfo::CMICmdCmdGdbInfo(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdGdbInfo::~CMICmdCmdGdbInfo(void)
+CMICmdCmdGdbInfo::~CMICmdCmdGdbInfo()
{
}
@@ -66,10 +66,10 @@ CMICmdCmdGdbInfo::~CMICmdCmdGdbInfo(void)
// Throws: None.
//--
bool
-CMICmdCmdGdbInfo::ParseArgs(void)
+CMICmdCmdGdbInfo::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgNamedPrint, true, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgNamedPrint, true, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -82,7 +82,7 @@ CMICmdCmdGdbInfo::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdGdbInfo::Execute(void)
+CMICmdCmdGdbInfo::Execute()
{
CMICMDBASE_GETOPTION(pArgPrint, String, m_constStrArgNamedPrint);
const CMIUtilString &rPrintRequest(pArgPrint->GetValue());
@@ -110,7 +110,7 @@ CMICmdCmdGdbInfo::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdGdbInfo::Acknowledge(void)
+CMICmdCmdGdbInfo::Acknowledge()
{
if (!m_bPrintFnRecognised)
{
@@ -145,7 +145,7 @@ CMICmdCmdGdbInfo::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdGdbInfo::CreateSelf(void)
+CMICmdCmdGdbInfo::CreateSelf()
{
return new CMICmdCmdGdbInfo();
}
@@ -183,7 +183,7 @@ CMICmdCmdGdbInfo::GetPrintFn(const CMIUtilString &vrPrintFnName, FnPrintPtr &vrw
// Throws: None.
//--
bool
-CMICmdCmdGdbInfo::PrintFnSharedLibrary(void)
+CMICmdCmdGdbInfo::PrintFnSharedLibrary()
{
CMICmnStreamStdout &rStdout = CMICmnStreamStdout::Instance();
bool bOk = rStdout.TextToStdout("~\"From To Syms Read Shared Object Library\"");
diff --git a/tools/lldb-mi/MICmdCmdGdbInfo.h b/tools/lldb-mi/MICmdCmdGdbInfo.h
index a1b5770e200b..6a7a2137ff45 100644
--- a/tools/lldb-mi/MICmdCmdGdbInfo.h
+++ b/tools/lldb-mi/MICmdCmdGdbInfo.h
@@ -1,4 +1,4 @@
-//===-- MICmdCmdGdbInfo.h --------------------------*- C++ -*-===//
+//===-- MICmdCmdGdbInfo.h ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -37,29 +37,26 @@
// class instantiates a request info command for a matching request. The
// design/code of *this class then does not then become bloated. Use a
// lightweight version of the current MI command system.
-// Gotchas: None.
-// Authors: Illya Rudkin 05/06/2014.
-// Changes: None.
//--
class CMICmdCmdGdbInfo : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdGdbInfo(void);
+ /* ctor */ CMICmdCmdGdbInfo();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdGdbInfo(void) override;
+ /* dtor */ ~CMICmdCmdGdbInfo() override;
// Typedefs:
private:
@@ -69,7 +66,7 @@ class CMICmdCmdGdbInfo : public CMICmdBase
// Methods:
private:
bool GetPrintFn(const CMIUtilString &vrPrintFnName, FnPrintPtr &vrwpFn) const;
- bool PrintFnSharedLibrary(void);
+ bool PrintFnSharedLibrary();
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmdCmdGdbSet.cpp b/tools/lldb-mi/MICmdCmdGdbSet.cpp
index 452ac516f2e4..1d68b0b5e27f 100644
--- a/tools/lldb-mi/MICmdCmdGdbSet.cpp
+++ b/tools/lldb-mi/MICmdCmdGdbSet.cpp
@@ -34,9 +34,8 @@ const CMICmdCmdGdbSet::MapGdbOptionNameToFnGdbOptionPtr_t CMICmdCmdGdbSet::ms_ma
// Return: None.
// Throws: None.
//--
-CMICmdCmdGdbSet::CMICmdCmdGdbSet(void)
- : m_constStrArgNamedThreadGrp("thread-group")
- , m_constStrArgNamedGdbOption("option")
+CMICmdCmdGdbSet::CMICmdCmdGdbSet()
+ : m_constStrArgNamedGdbOption("option")
, m_bGdbOptionRecognised(true)
, m_bGdbOptionFnSuccessful(false)
, m_bGbbOptionFnHasError(false)
@@ -56,7 +55,7 @@ CMICmdCmdGdbSet::CMICmdCmdGdbSet(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdGdbSet::~CMICmdCmdGdbSet(void)
+CMICmdCmdGdbSet::~CMICmdCmdGdbSet()
{
}
@@ -70,14 +69,11 @@ CMICmdCmdGdbSet::~CMICmdCmdGdbSet(void)
// Throws: None.
//--
bool
-CMICmdCmdGdbSet::ParseArgs(void)
+CMICmdCmdGdbSet::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(
- *(new CMICmdArgValOptionLong(m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1)));
- bOk = bOk &&
- m_setCmdArgs.Add(
- *(new CMICmdArgValListOfN(m_constStrArgNamedGdbOption, true, true, CMICmdArgValListBase::eArgValType_StringAnything)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(
+ new CMICmdArgValListOfN(m_constStrArgNamedGdbOption, true, true, CMICmdArgValListBase::eArgValType_StringAnything));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -90,7 +86,7 @@ CMICmdCmdGdbSet::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdGdbSet::Execute(void)
+CMICmdCmdGdbSet::Execute()
{
CMICMDBASE_GETOPTION(pArgGdbOption, ListOfN, m_constStrArgNamedGdbOption);
const CMICmdArgValListBase::VecArgObjPtr_t &rVecWords(pArgGdbOption->GetExpectedOptions());
@@ -143,7 +139,7 @@ CMICmdCmdGdbSet::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdGdbSet::Acknowledge(void)
+CMICmdCmdGdbSet::Acknowledge()
{
// Print error if option isn't recognized:
// ^error,msg="The request '%s' was not recognized, not implemented"
@@ -184,7 +180,7 @@ CMICmdCmdGdbSet::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdGdbSet::CreateSelf(void)
+CMICmdCmdGdbSet::CreateSelf()
{
return new CMICmdCmdGdbSet();
}
diff --git a/tools/lldb-mi/MICmdCmdGdbSet.h b/tools/lldb-mi/MICmdCmdGdbSet.h
index 84d21f0557b7..db33f6580a26 100644
--- a/tools/lldb-mi/MICmdCmdGdbSet.h
+++ b/tools/lldb-mi/MICmdCmdGdbSet.h
@@ -37,29 +37,26 @@
// class instantiates a request info command for a matching request. The
// design/code of *this class then does not then become bloated. Use a
// lightweight version of the current MI command system.
-// Gotchas: None.
-// Authors: Illya Rudkin 03/03/2014.
-// Changes: None.
//--
class CMICmdCmdGdbSet : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdGdbSet(void);
+ /* ctor */ CMICmdCmdGdbSet();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdGdbSet(void) override;
+ /* dtor */ ~CMICmdCmdGdbSet() override;
// Typedefs:
private:
@@ -79,7 +76,6 @@ class CMICmdCmdGdbSet : public CMICmdBase
private:
const static MapGdbOptionNameToFnGdbOptionPtr_t ms_mapGdbOptionNameToFnGdbOptionPtr;
//
- const CMIUtilString m_constStrArgNamedThreadGrp;
const CMIUtilString m_constStrArgNamedGdbOption;
bool m_bGdbOptionRecognised; // True = This command has a function with a name that matches the Print argument, false = not found
bool m_bGdbOptionFnSuccessful; // True = The print function completed its task ok, false = function failed for some reason
diff --git a/tools/lldb-mi/MICmdCmdGdbShow.cpp b/tools/lldb-mi/MICmdCmdGdbShow.cpp
index f1f40ccbed1a..147e76798bfa 100644
--- a/tools/lldb-mi/MICmdCmdGdbShow.cpp
+++ b/tools/lldb-mi/MICmdCmdGdbShow.cpp
@@ -38,9 +38,8 @@ const CMICmdCmdGdbShow::MapGdbOptionNameToFnGdbOptionPtr_t CMICmdCmdGdbShow::ms_
// Return: None.
// Throws: None.
//--
-CMICmdCmdGdbShow::CMICmdCmdGdbShow(void)
- : m_constStrArgNamedThreadGrp("thread-group")
- , m_constStrArgNamedGdbOption("option")
+CMICmdCmdGdbShow::CMICmdCmdGdbShow()
+ : m_constStrArgNamedGdbOption("option")
, m_bGdbOptionRecognised(true)
, m_bGdbOptionFnSuccessful(false)
, m_bGbbOptionFnHasError(false)
@@ -60,7 +59,7 @@ CMICmdCmdGdbShow::CMICmdCmdGdbShow(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdGdbShow::~CMICmdCmdGdbShow(void)
+CMICmdCmdGdbShow::~CMICmdCmdGdbShow()
{
}
@@ -74,14 +73,11 @@ CMICmdCmdGdbShow::~CMICmdCmdGdbShow(void)
// Throws: None.
//--
bool
-CMICmdCmdGdbShow::ParseArgs(void)
+CMICmdCmdGdbShow::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(
- *(new CMICmdArgValOptionLong(m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1)));
- bOk = bOk &&
- m_setCmdArgs.Add(
- *(new CMICmdArgValListOfN(m_constStrArgNamedGdbOption, true, true, CMICmdArgValListBase::eArgValType_StringAnything)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(
+ new CMICmdArgValListOfN(m_constStrArgNamedGdbOption, true, true, CMICmdArgValListBase::eArgValType_StringAnything));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -93,7 +89,7 @@ CMICmdCmdGdbShow::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdGdbShow::Execute(void)
+CMICmdCmdGdbShow::Execute()
{
CMICMDBASE_GETOPTION(pArgGdbOption, ListOfN, m_constStrArgNamedGdbOption);
const CMICmdArgValListBase::VecArgObjPtr_t &rVecWords(pArgGdbOption->GetExpectedOptions());
@@ -146,7 +142,7 @@ CMICmdCmdGdbShow::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdGdbShow::Acknowledge(void)
+CMICmdCmdGdbShow::Acknowledge()
{
// Print error if option isn't recognized:
// ^error,msg="The request '%s' was not recognized, not implemented"
@@ -196,7 +192,7 @@ CMICmdCmdGdbShow::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdGdbShow::CreateSelf(void)
+CMICmdCmdGdbShow::CreateSelf()
{
return new CMICmdCmdGdbShow();
}
diff --git a/tools/lldb-mi/MICmdCmdGdbShow.h b/tools/lldb-mi/MICmdCmdGdbShow.h
index 6ca5ef8781a0..934105312da3 100644
--- a/tools/lldb-mi/MICmdCmdGdbShow.h
+++ b/tools/lldb-mi/MICmdCmdGdbShow.h
@@ -43,20 +43,20 @@ class CMICmdCmdGdbShow : public CMICmdBase
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdGdbShow(void);
+ /* ctor */ CMICmdCmdGdbShow();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdGdbShow(void) override;
+ /* dtor */ ~CMICmdCmdGdbShow() override;
// Typedefs:
private:
@@ -74,8 +74,7 @@ class CMICmdCmdGdbShow : public CMICmdBase
// Attributes:
private:
const static MapGdbOptionNameToFnGdbOptionPtr_t ms_mapGdbOptionNameToFnGdbOptionPtr;
- //
- const CMIUtilString m_constStrArgNamedThreadGrp;
+
const CMIUtilString m_constStrArgNamedGdbOption;
bool m_bGdbOptionRecognised; // True = This command has a function with a name that matches the Print argument, false = not found
bool m_bGdbOptionFnSuccessful; // True = The print function completed its task ok, false = function failed for some reason
diff --git a/tools/lldb-mi/MICmdCmdGdbThread.cpp b/tools/lldb-mi/MICmdCmdGdbThread.cpp
index 40f2eeccb6b4..5f71b0547609 100644
--- a/tools/lldb-mi/MICmdCmdGdbThread.cpp
+++ b/tools/lldb-mi/MICmdCmdGdbThread.cpp
@@ -21,7 +21,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdCmdGdbThread::CMICmdCmdGdbThread(void)
+CMICmdCmdGdbThread::CMICmdCmdGdbThread()
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "thread";
@@ -37,7 +37,7 @@ CMICmdCmdGdbThread::CMICmdCmdGdbThread(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdGdbThread::~CMICmdCmdGdbThread(void)
+CMICmdCmdGdbThread::~CMICmdCmdGdbThread()
{
}
@@ -51,7 +51,7 @@ CMICmdCmdGdbThread::~CMICmdCmdGdbThread(void)
// Throws: None.
//--
bool
-CMICmdCmdGdbThread::Execute(void)
+CMICmdCmdGdbThread::Execute()
{
// Do nothing
@@ -68,7 +68,7 @@ CMICmdCmdGdbThread::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdGdbThread::Acknowledge(void)
+CMICmdCmdGdbThread::Acknowledge()
{
const CMICmnMIValueConst miValueConst(MIRSRC(IDS_WORD_NOT_IMPLEMENTED));
const CMICmnMIValueResult miValueResult("msg", miValueConst);
@@ -87,7 +87,7 @@ CMICmdCmdGdbThread::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdGdbThread::CreateSelf(void)
+CMICmdCmdGdbThread::CreateSelf()
{
return new CMICmdCmdGdbThread();
}
diff --git a/tools/lldb-mi/MICmdCmdGdbThread.h b/tools/lldb-mi/MICmdCmdGdbThread.h
index 6a3804a1c89b..40d8b7837898 100644
--- a/tools/lldb-mi/MICmdCmdGdbThread.h
+++ b/tools/lldb-mi/MICmdCmdGdbThread.h
@@ -26,26 +26,23 @@
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements GDB command "thread".
-// Gotchas: None.
-// Authors: Illya Rudkin 25/02/2014.
-// Changes: None.
//--
class CMICmdCmdGdbThread : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdGdbThread(void);
+ /* ctor */ CMICmdCmdGdbThread();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdGdbThread(void) override;
+ /* dtor */ ~CMICmdCmdGdbThread() override;
};
diff --git a/tools/lldb-mi/MICmdCmdMiscellanous.cpp b/tools/lldb-mi/MICmdCmdMiscellanous.cpp
index 3abc7c488d8b..d534a6fafa0d 100644
--- a/tools/lldb-mi/MICmdCmdMiscellanous.cpp
+++ b/tools/lldb-mi/MICmdCmdMiscellanous.cpp
@@ -41,7 +41,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdCmdGdbExit::CMICmdCmdGdbExit(void)
+CMICmdCmdGdbExit::CMICmdCmdGdbExit()
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "gdb-exit";
@@ -57,7 +57,7 @@ CMICmdCmdGdbExit::CMICmdCmdGdbExit(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdGdbExit::~CMICmdCmdGdbExit(void)
+CMICmdCmdGdbExit::~CMICmdCmdGdbExit()
{
}
@@ -71,7 +71,7 @@ CMICmdCmdGdbExit::~CMICmdCmdGdbExit(void)
// Throws: None.
//--
bool
-CMICmdCmdGdbExit::Execute(void)
+CMICmdCmdGdbExit::Execute()
{
CMICmnLLDBDebugger::Instance().GetDriver().SetExitApplicationFlag(true);
const lldb::SBError sbErr = m_rLLDBDebugSessionInfo.GetProcess().Destroy();
@@ -90,7 +90,7 @@ CMICmdCmdGdbExit::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdGdbExit::Acknowledge(void)
+CMICmdCmdGdbExit::Acknowledge()
{
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Exit);
m_miResultRecord = miRecordResult;
@@ -115,7 +115,7 @@ CMICmdCmdGdbExit::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdGdbExit::CreateSelf(void)
+CMICmdCmdGdbExit::CreateSelf()
{
return new CMICmdCmdGdbExit();
}
@@ -131,7 +131,7 @@ CMICmdCmdGdbExit::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdListThreadGroups::CMICmdCmdListThreadGroups(void)
+CMICmdCmdListThreadGroups::CMICmdCmdListThreadGroups()
: m_bIsI1(false)
, m_bHaveArgOption(false)
, m_bHaveArgRecurse(false)
@@ -154,7 +154,7 @@ CMICmdCmdListThreadGroups::CMICmdCmdListThreadGroups(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdListThreadGroups::~CMICmdCmdListThreadGroups(void)
+CMICmdCmdListThreadGroups::~CMICmdCmdListThreadGroups()
{
m_vecMIValueTuple.clear();
}
@@ -169,16 +169,14 @@ CMICmdCmdListThreadGroups::~CMICmdCmdListThreadGroups(void)
// Throws: None.
//--
bool
-CMICmdCmdListThreadGroups::ParseArgs(void)
+CMICmdCmdListThreadGroups::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgNamedAvailable, false, true)));
- bOk = bOk &&
- m_setCmdArgs.Add(
- *(new CMICmdArgValOptionLong(m_constStrArgNamedRecurse, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk =
- bOk && m_setCmdArgs.Add(*(new CMICmdArgValListOfN(m_constStrArgNamedGroup, false, true, CMICmdArgValListBase::eArgValType_Number)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValThreadGrp(m_constStrArgNamedThreadGroup, false, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValOptionLong(m_constStrArgNamedAvailable, false, true));
+ m_setCmdArgs.Add(
+ new CMICmdArgValOptionLong(m_constStrArgNamedRecurse, false, true, CMICmdArgValListBase::eArgValType_Number, 1));
+ m_setCmdArgs.Add(new CMICmdArgValListOfN(m_constStrArgNamedGroup, false, true, CMICmdArgValListBase::eArgValType_Number));
+ m_setCmdArgs.Add(new CMICmdArgValThreadGrp(m_constStrArgNamedThreadGroup, false, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -196,7 +194,7 @@ CMICmdCmdListThreadGroups::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdListThreadGroups::Execute(void)
+CMICmdCmdListThreadGroups::Execute()
{
if (m_setCmdArgs.IsArgContextEmpty())
// No options so "top level thread groups"
@@ -259,7 +257,7 @@ CMICmdCmdListThreadGroups::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdListThreadGroups::Acknowledge(void)
+CMICmdCmdListThreadGroups::Acknowledge()
{
if (m_bHaveArgOption)
{
@@ -382,7 +380,7 @@ CMICmdCmdListThreadGroups::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdListThreadGroups::CreateSelf(void)
+CMICmdCmdListThreadGroups::CreateSelf()
{
return new CMICmdCmdListThreadGroups();
}
@@ -398,7 +396,7 @@ CMICmdCmdListThreadGroups::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdInterpreterExec::CMICmdCmdInterpreterExec(void)
+CMICmdCmdInterpreterExec::CMICmdCmdInterpreterExec()
: m_constStrArgNamedInterpreter("interpreter")
, m_constStrArgNamedCommand("command")
{
@@ -416,7 +414,7 @@ CMICmdCmdInterpreterExec::CMICmdCmdInterpreterExec(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdInterpreterExec::~CMICmdCmdInterpreterExec(void)
+CMICmdCmdInterpreterExec::~CMICmdCmdInterpreterExec()
{
}
@@ -430,11 +428,11 @@ CMICmdCmdInterpreterExec::~CMICmdCmdInterpreterExec(void)
// Throws: None.
//--
bool
-CMICmdCmdInterpreterExec::ParseArgs(void)
+CMICmdCmdInterpreterExec::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgNamedInterpreter, true, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgNamedCommand, true, true, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgNamedInterpreter, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgNamedCommand, true, true, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -447,7 +445,7 @@ CMICmdCmdInterpreterExec::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdInterpreterExec::Execute(void)
+CMICmdCmdInterpreterExec::Execute()
{
CMICMDBASE_GETOPTION(pArgInterpreter, String, m_constStrArgNamedInterpreter);
CMICMDBASE_GETOPTION(pArgCommand, String, m_constStrArgNamedCommand);
@@ -476,7 +474,7 @@ CMICmdCmdInterpreterExec::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdInterpreterExec::Acknowledge(void)
+CMICmdCmdInterpreterExec::Acknowledge()
{
if (m_lldbResult.GetOutputSize() > 0)
{
@@ -506,7 +504,7 @@ CMICmdCmdInterpreterExec::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdInterpreterExec::CreateSelf(void)
+CMICmdCmdInterpreterExec::CreateSelf()
{
return new CMICmdCmdInterpreterExec();
}
@@ -522,7 +520,7 @@ CMICmdCmdInterpreterExec::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdInferiorTtySet::CMICmdCmdInferiorTtySet(void)
+CMICmdCmdInferiorTtySet::CMICmdCmdInferiorTtySet()
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "inferior-tty-set";
@@ -538,7 +536,7 @@ CMICmdCmdInferiorTtySet::CMICmdCmdInferiorTtySet(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdInferiorTtySet::~CMICmdCmdInferiorTtySet(void)
+CMICmdCmdInferiorTtySet::~CMICmdCmdInferiorTtySet()
{
}
@@ -552,7 +550,7 @@ CMICmdCmdInferiorTtySet::~CMICmdCmdInferiorTtySet(void)
// Throws: None.
//--
bool
-CMICmdCmdInferiorTtySet::Execute(void)
+CMICmdCmdInferiorTtySet::Execute()
{
// Do nothing
@@ -569,7 +567,7 @@ CMICmdCmdInferiorTtySet::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdInferiorTtySet::Acknowledge(void)
+CMICmdCmdInferiorTtySet::Acknowledge()
{
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error);
m_miResultRecord = miRecordResult;
@@ -586,7 +584,7 @@ CMICmdCmdInferiorTtySet::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdInferiorTtySet::CreateSelf(void)
+CMICmdCmdInferiorTtySet::CreateSelf()
{
return new CMICmdCmdInferiorTtySet();
}
diff --git a/tools/lldb-mi/MICmdCmdMiscellanous.h b/tools/lldb-mi/MICmdCmdMiscellanous.h
index 876554981e34..9f82195c9980 100644
--- a/tools/lldb-mi/MICmdCmdMiscellanous.h
+++ b/tools/lldb-mi/MICmdCmdMiscellanous.h
@@ -34,28 +34,25 @@
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "gdb-exit".
-// Gotchas: None.
-// Authors: Illya Rudkin 04/03/2014.
-// Changes: None.
//--
class CMICmdCmdGdbExit : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdGdbExit(void);
+ /* ctor */ CMICmdCmdGdbExit();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdGdbExit(void) override;
+ /* dtor */ ~CMICmdCmdGdbExit() override;
};
//++ ============================================================================
@@ -63,29 +60,26 @@ class CMICmdCmdGdbExit : public CMICmdBase
// *this class implements MI command "list-thread-groups".
// This command does not follow the MI documentation exactly.
// http://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Miscellaneous-Commands.html#GDB_002fMI-Miscellaneous-Commands
-// Gotchas: None.
-// Authors: Illya Rudkin 06/03/2014.
-// Changes: None.
//--
class CMICmdCmdListThreadGroups : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdListThreadGroups(void);
+ /* ctor */ CMICmdCmdListThreadGroups();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdListThreadGroups(void) override;
+ /* dtor */ ~CMICmdCmdListThreadGroups() override;
// Typedefs:
private:
@@ -106,29 +100,26 @@ class CMICmdCmdListThreadGroups : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "interpreter-exec".
-// Gotchas: None.
-// Authors: Illya Rudkin 16/05/2014.
-// Changes: None.
//--
class CMICmdCmdInterpreterExec : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdInterpreterExec(void);
+ /* ctor */ CMICmdCmdInterpreterExec();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdInterpreterExec(void) override;
+ /* dtor */ ~CMICmdCmdInterpreterExec() override;
// Attributes:
private:
@@ -140,26 +131,23 @@ class CMICmdCmdInterpreterExec : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "inferior-tty-set".
-// Gotchas: None.
-// Authors: Illya Rudkin 22/07/2014.
-// Changes: None.
//--
class CMICmdCmdInferiorTtySet : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdInferiorTtySet(void);
+ /* ctor */ CMICmdCmdInferiorTtySet();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdInferiorTtySet(void) override;
+ /* dtor */ ~CMICmdCmdInferiorTtySet() override;
};
diff --git a/tools/lldb-mi/MICmdCmdStack.cpp b/tools/lldb-mi/MICmdCmdStack.cpp
index 7f767e727f97..bc3483313f37 100644
--- a/tools/lldb-mi/MICmdCmdStack.cpp
+++ b/tools/lldb-mi/MICmdCmdStack.cpp
@@ -39,9 +39,8 @@
// Return: None.
// Throws: None.
//--
-CMICmdCmdStackInfoDepth::CMICmdCmdStackInfoDepth(void)
+CMICmdCmdStackInfoDepth::CMICmdCmdStackInfoDepth()
: m_nThreadFrames(0)
- , m_constStrArgThread("thread")
, m_constStrArgMaxDepth("max-depth")
{
// Command factory matches this name with that received from the stdin stream
@@ -58,7 +57,7 @@ CMICmdCmdStackInfoDepth::CMICmdCmdStackInfoDepth(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdStackInfoDepth::~CMICmdCmdStackInfoDepth(void)
+CMICmdCmdStackInfoDepth::~CMICmdCmdStackInfoDepth()
{
}
@@ -72,12 +71,10 @@ CMICmdCmdStackInfoDepth::~CMICmdCmdStackInfoDepth(void)
// Throws: None.
//--
bool
-CMICmdCmdStackInfoDepth::ParseArgs(void)
+CMICmdCmdStackInfoDepth::ParseArgs()
{
- bool bOk =
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgMaxDepth, false, false)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgMaxDepth, false, false));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -90,7 +87,7 @@ CMICmdCmdStackInfoDepth::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdStackInfoDepth::Execute(void)
+CMICmdCmdStackInfoDepth::Execute()
{
CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
CMICMDBASE_GETOPTION(pArgMaxDepth, Number, m_constStrArgMaxDepth);
@@ -121,7 +118,7 @@ CMICmdCmdStackInfoDepth::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdStackInfoDepth::Acknowledge(void)
+CMICmdCmdStackInfoDepth::Acknowledge()
{
const CMIUtilString strDepth(CMIUtilString::Format("%d", m_nThreadFrames));
const CMICmnMIValueConst miValueConst(strDepth);
@@ -141,7 +138,7 @@ CMICmdCmdStackInfoDepth::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdStackInfoDepth::CreateSelf(void)
+CMICmdCmdStackInfoDepth::CreateSelf()
{
return new CMICmdCmdStackInfoDepth();
}
@@ -157,7 +154,7 @@ CMICmdCmdStackInfoDepth::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdStackInfoFrame::CMICmdCmdStackInfoFrame(void)
+CMICmdCmdStackInfoFrame::CMICmdCmdStackInfoFrame()
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "stack-info-frame";
@@ -173,7 +170,7 @@ CMICmdCmdStackInfoFrame::CMICmdCmdStackInfoFrame(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdStackInfoFrame::~CMICmdCmdStackInfoFrame(void)
+CMICmdCmdStackInfoFrame::~CMICmdCmdStackInfoFrame()
{
}
@@ -187,7 +184,7 @@ CMICmdCmdStackInfoFrame::~CMICmdCmdStackInfoFrame(void)
// Throws: None.
//--
bool
-CMICmdCmdStackInfoFrame::ParseArgs(void)
+CMICmdCmdStackInfoFrame::ParseArgs()
{
return ParseValidateCmdOptions();
}
@@ -202,7 +199,7 @@ CMICmdCmdStackInfoFrame::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdStackInfoFrame::Execute(void)
+CMICmdCmdStackInfoFrame::Execute()
{
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
@@ -230,7 +227,7 @@ CMICmdCmdStackInfoFrame::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdStackInfoFrame::Acknowledge(void)
+CMICmdCmdStackInfoFrame::Acknowledge()
{
const CMICmnMIValueResult miValueResult("frame", m_miValueTuple);
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
@@ -248,7 +245,7 @@ CMICmdCmdStackInfoFrame::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdStackInfoFrame::CreateSelf(void)
+CMICmdCmdStackInfoFrame::CreateSelf()
{
return new CMICmdCmdStackInfoFrame();
}
@@ -264,9 +261,8 @@ CMICmdCmdStackInfoFrame::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdStackListFrames::CMICmdCmdStackListFrames(void)
+CMICmdCmdStackListFrames::CMICmdCmdStackListFrames()
: m_nThreadFrames(0)
- , m_constStrArgThread("thread")
, m_constStrArgFrameLow("low-frame")
, m_constStrArgFrameHigh("high-frame")
{
@@ -284,7 +280,7 @@ CMICmdCmdStackListFrames::CMICmdCmdStackListFrames(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdStackListFrames::~CMICmdCmdStackListFrames(void)
+CMICmdCmdStackListFrames::~CMICmdCmdStackListFrames()
{
m_vecMIValueResult.clear();
}
@@ -299,13 +295,11 @@ CMICmdCmdStackListFrames::~CMICmdCmdStackListFrames(void)
// Throws: None.
//--
bool
-CMICmdCmdStackListFrames::ParseArgs(void)
+CMICmdCmdStackListFrames::ParseArgs()
{
- bool bOk =
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgFrameLow, false, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgFrameHigh, false, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgFrameLow, false, true));
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgFrameHigh, false, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -318,7 +312,7 @@ CMICmdCmdStackListFrames::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdStackListFrames::Execute(void)
+CMICmdCmdStackListFrames::Execute()
{
CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
CMICMDBASE_GETOPTION(pArgFrameLow, Number, m_constStrArgFrameLow);
@@ -377,7 +371,7 @@ CMICmdCmdStackListFrames::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdStackListFrames::Acknowledge(void)
+CMICmdCmdStackListFrames::Acknowledge()
{
if (m_nThreadFrames == 0)
{
@@ -429,7 +423,7 @@ CMICmdCmdStackListFrames::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdStackListFrames::CreateSelf(void)
+CMICmdCmdStackListFrames::CreateSelf()
{
return new CMICmdCmdStackListFrames();
}
@@ -445,10 +439,9 @@ CMICmdCmdStackListFrames::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdStackListArguments::CMICmdCmdStackListArguments(void)
+CMICmdCmdStackListArguments::CMICmdCmdStackListArguments()
: m_bThreadInvalid(false)
, m_miValueList(true)
- , m_constStrArgThread("thread")
, m_constStrArgPrintValues("print-values")
, m_constStrArgFrameLow("low-frame")
, m_constStrArgFrameHigh("high-frame")
@@ -467,7 +460,7 @@ CMICmdCmdStackListArguments::CMICmdCmdStackListArguments(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdStackListArguments::~CMICmdCmdStackListArguments(void)
+CMICmdCmdStackListArguments::~CMICmdCmdStackListArguments()
{
}
@@ -481,14 +474,12 @@ CMICmdCmdStackListArguments::~CMICmdCmdStackListArguments(void)
// Throws: None.
//--
bool
-CMICmdCmdStackListArguments::ParseArgs(void)
+CMICmdCmdStackListArguments::ParseArgs()
{
- bool bOk =
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValPrintValues(m_constStrArgPrintValues, true, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgFrameLow, false, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgFrameHigh, false, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValPrintValues(m_constStrArgPrintValues, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgFrameLow, false, true));
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgFrameHigh, false, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -501,7 +492,7 @@ CMICmdCmdStackListArguments::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdStackListArguments::Execute(void)
+CMICmdCmdStackListArguments::Execute()
{
CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
CMICMDBASE_GETOPTION(pArgPrintValues, PrintValues, m_constStrArgPrintValues);
@@ -587,7 +578,7 @@ CMICmdCmdStackListArguments::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdStackListArguments::Acknowledge(void)
+CMICmdCmdStackListArguments::Acknowledge()
{
if (m_bThreadInvalid)
{
@@ -616,7 +607,7 @@ CMICmdCmdStackListArguments::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdStackListArguments::CreateSelf(void)
+CMICmdCmdStackListArguments::CreateSelf()
{
return new CMICmdCmdStackListArguments();
}
@@ -632,11 +623,9 @@ CMICmdCmdStackListArguments::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdStackListLocals::CMICmdCmdStackListLocals(void)
+CMICmdCmdStackListLocals::CMICmdCmdStackListLocals()
: m_bThreadInvalid(false)
, m_miValueList(true)
- , m_constStrArgThread("thread")
- , m_constStrArgFrame("frame")
, m_constStrArgPrintValues("print-values")
{
// Command factory matches this name with that received from the stdin stream
@@ -653,7 +642,7 @@ CMICmdCmdStackListLocals::CMICmdCmdStackListLocals(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdStackListLocals::~CMICmdCmdStackListLocals(void)
+CMICmdCmdStackListLocals::~CMICmdCmdStackListLocals()
{
}
@@ -667,14 +656,10 @@ CMICmdCmdStackListLocals::~CMICmdCmdStackListLocals(void)
// Throws: None.
//--
bool
-CMICmdCmdStackListLocals::ParseArgs(void)
+CMICmdCmdStackListLocals::ParseArgs()
{
- bool bOk =
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk &&
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgFrame, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValPrintValues(m_constStrArgPrintValues, true, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValPrintValues(m_constStrArgPrintValues, true, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -687,7 +672,7 @@ CMICmdCmdStackListLocals::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdStackListLocals::Execute(void)
+CMICmdCmdStackListLocals::Execute()
{
CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
CMICMDBASE_GETOPTION(pArgFrame, OptionLong, m_constStrArgFrame);
@@ -752,7 +737,7 @@ CMICmdCmdStackListLocals::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdStackListLocals::Acknowledge(void)
+CMICmdCmdStackListLocals::Acknowledge()
{
if (m_bThreadInvalid)
{
@@ -781,7 +766,7 @@ CMICmdCmdStackListLocals::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdStackListLocals::CreateSelf(void)
+CMICmdCmdStackListLocals::CreateSelf()
{
return new CMICmdCmdStackListLocals();
}
@@ -797,11 +782,9 @@ CMICmdCmdStackListLocals::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdStackListVariables::CMICmdCmdStackListVariables(void)
+CMICmdCmdStackListVariables::CMICmdCmdStackListVariables()
: m_bThreadInvalid(false)
, m_miValueList(true)
- , m_constStrArgThread("thread")
- , m_constStrArgFrame("frame")
, m_constStrArgPrintValues("print-values")
{
// Command factory matches this name with that received from the stdin stream
@@ -818,7 +801,7 @@ CMICmdCmdStackListVariables::CMICmdCmdStackListVariables(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdStackListVariables::~CMICmdCmdStackListVariables(void)
+CMICmdCmdStackListVariables::~CMICmdCmdStackListVariables()
{
}
@@ -832,14 +815,10 @@ CMICmdCmdStackListVariables::~CMICmdCmdStackListVariables(void)
// Throws: None.
//--
bool
-CMICmdCmdStackListVariables::ParseArgs(void)
+CMICmdCmdStackListVariables::ParseArgs()
{
- bool bOk =
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk &&
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgFrame, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValPrintValues(m_constStrArgPrintValues, true, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValPrintValues(m_constStrArgPrintValues, true, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -852,7 +831,7 @@ CMICmdCmdStackListVariables::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdStackListVariables::Execute(void)
+CMICmdCmdStackListVariables::Execute()
{
CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
CMICMDBASE_GETOPTION(pArgFrame, OptionLong, m_constStrArgFrame);
@@ -916,7 +895,7 @@ CMICmdCmdStackListVariables::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdStackListVariables::Acknowledge(void)
+CMICmdCmdStackListVariables::Acknowledge()
{
if (m_bThreadInvalid)
{
@@ -945,7 +924,7 @@ CMICmdCmdStackListVariables::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdStackListVariables::CreateSelf(void)
+CMICmdCmdStackListVariables::CreateSelf()
{
return new CMICmdCmdStackListVariables();
}
@@ -961,9 +940,9 @@ CMICmdCmdStackListVariables::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdStackSelectFrame::CMICmdCmdStackSelectFrame(void)
+CMICmdCmdStackSelectFrame::CMICmdCmdStackSelectFrame()
: m_bFrameInvalid(false)
- , m_constStrArgFrame("frame")
+ , m_constStrArgFrameId("frame_id")
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "stack-select-frame";
@@ -979,7 +958,7 @@ CMICmdCmdStackSelectFrame::CMICmdCmdStackSelectFrame(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdStackSelectFrame::~CMICmdCmdStackSelectFrame(void)
+CMICmdCmdStackSelectFrame::~CMICmdCmdStackSelectFrame()
{
}
@@ -993,10 +972,10 @@ CMICmdCmdStackSelectFrame::~CMICmdCmdStackSelectFrame(void)
// Throws: None.
//--
bool
-CMICmdCmdStackSelectFrame::ParseArgs(void)
+CMICmdCmdStackSelectFrame::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgFrame, true, false)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgFrameId, true, false));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -1009,9 +988,9 @@ CMICmdCmdStackSelectFrame::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdStackSelectFrame::Execute(void)
+CMICmdCmdStackSelectFrame::Execute()
{
- CMICMDBASE_GETOPTION(pArgFrame, Number, m_constStrArgFrame);
+ CMICMDBASE_GETOPTION(pArgFrame, Number, m_constStrArgFrameId);
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
lldb::SBThread sbThread = rSessionInfo.GetProcess().GetSelectedThread();
@@ -1037,7 +1016,7 @@ CMICmdCmdStackSelectFrame::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdStackSelectFrame::Acknowledge(void)
+CMICmdCmdStackSelectFrame::Acknowledge()
{
if (m_bFrameInvalid)
{
@@ -1066,7 +1045,7 @@ CMICmdCmdStackSelectFrame::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdStackSelectFrame::CreateSelf(void)
+CMICmdCmdStackSelectFrame::CreateSelf()
{
return new CMICmdCmdStackSelectFrame();
}
diff --git a/tools/lldb-mi/MICmdCmdStack.h b/tools/lldb-mi/MICmdCmdStack.h
index 274415aaafc4..e22a703545bb 100644
--- a/tools/lldb-mi/MICmdCmdStack.h
+++ b/tools/lldb-mi/MICmdCmdStack.h
@@ -33,34 +33,30 @@
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "stack-info-depth".
-// Gotchas: None.
-// Authors: Illya Rudkin 21/03/2014.
-// Changes: None.
//--
class CMICmdCmdStackInfoDepth : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdStackInfoDepth(void);
+ /* ctor */ CMICmdCmdStackInfoDepth();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdStackInfoDepth(void) override;
+ /* dtor */ ~CMICmdCmdStackInfoDepth() override;
// Attributes:
private:
MIuint m_nThreadFrames;
- const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option
const CMIUtilString m_constStrArgMaxDepth; // Not handled by *this command
};
@@ -73,20 +69,20 @@ class CMICmdCmdStackInfoFrame : public CMICmdBase
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdStackInfoFrame(void);
+ /* ctor */ CMICmdCmdStackInfoFrame();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdStackInfoFrame(void) override;
+ /* dtor */ ~CMICmdCmdStackInfoFrame() override;
// Attributes:
private:
@@ -96,29 +92,26 @@ class CMICmdCmdStackInfoFrame : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "stack-list-frames".
-// Gotchas: None.
-// Authors: Illya Rudkin 21/03/2014.
-// Changes: None.
//--
class CMICmdCmdStackListFrames : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdStackListFrames(void);
+ /* ctor */ CMICmdCmdStackListFrames();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdStackListFrames(void) override;
+ /* dtor */ ~CMICmdCmdStackListFrames() override;
// Typedefs:
private:
@@ -128,7 +121,6 @@ class CMICmdCmdStackListFrames : public CMICmdBase
private:
MIuint m_nThreadFrames;
VecMIValueResult_t m_vecMIValueResult;
- const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option
const CMIUtilString m_constStrArgFrameLow;
const CMIUtilString m_constStrArgFrameHigh;
};
@@ -136,35 +128,31 @@ class CMICmdCmdStackListFrames : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "stack-list-arguments".
-// Gotchas: None.
-// Authors: Illya Rudkin 24/03/2014.
-// Changes: None.
//--
class CMICmdCmdStackListArguments : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdStackListArguments(void);
+ /* ctor */ CMICmdCmdStackListArguments();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdStackListArguments(void) override;
+ /* dtor */ ~CMICmdCmdStackListArguments() override;
// Attributes:
private:
bool m_bThreadInvalid; // True = yes invalid thread, false = thread object valid
CMICmnMIValueList m_miValueList;
- const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option
const CMIUtilString m_constStrArgPrintValues;
const CMIUtilString m_constStrArgFrameLow;
const CMIUtilString m_constStrArgFrameHigh;
@@ -173,36 +161,31 @@ class CMICmdCmdStackListArguments : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "stack-list-locals".
-// Gotchas: None.
-// Authors: Illya Rudkin 24/03/2014.
-// Changes: None.
//--
class CMICmdCmdStackListLocals : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdStackListLocals(void);
+ /* ctor */ CMICmdCmdStackListLocals();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdStackListLocals(void) override;
+ /* dtor */ ~CMICmdCmdStackListLocals() override;
// Attributes:
private:
bool m_bThreadInvalid; // True = yes invalid thread, false = thread object valid
CMICmnMIValueList m_miValueList;
- const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option
- const CMIUtilString m_constStrArgFrame; // Not specified in MI spec but Eclipse gives this option
const CMIUtilString m_constStrArgPrintValues;
};
@@ -215,27 +198,25 @@ class CMICmdCmdStackListVariables : public CMICmdBase
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdStackListVariables(void);
+ /* ctor */ CMICmdCmdStackListVariables();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdStackListVariables(void) override;
+ /* dtor */ ~CMICmdCmdStackListVariables() override;
// Attributes
private:
bool m_bThreadInvalid; // True = yes invalid thread, false = thread object valid
CMICmnMIValueList m_miValueList;
- const CMIUtilString m_constStrArgThread;
- const CMIUtilString m_constStrArgFrame;
const CMIUtilString m_constStrArgPrintValues;
};
@@ -248,23 +229,23 @@ class CMICmdCmdStackSelectFrame : public CMICmdBase
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdStackSelectFrame(void);
+ /* ctor */ CMICmdCmdStackSelectFrame();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdStackSelectFrame(void) override;
+ /* dtor */ ~CMICmdCmdStackSelectFrame() override;
// Attributes:
private:
bool m_bFrameInvalid; // True = yes invalid frame, false = ok
- const CMIUtilString m_constStrArgFrame;
+ const CMIUtilString m_constStrArgFrameId;
};
diff --git a/tools/lldb-mi/MICmdCmdSupportInfo.cpp b/tools/lldb-mi/MICmdCmdSupportInfo.cpp
index 2d04ef8dddf9..9d926441dd2f 100644
--- a/tools/lldb-mi/MICmdCmdSupportInfo.cpp
+++ b/tools/lldb-mi/MICmdCmdSupportInfo.cpp
@@ -24,7 +24,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdCmdSupportInfoMiCmdQuery::CMICmdCmdSupportInfoMiCmdQuery(void)
+CMICmdCmdSupportInfoMiCmdQuery::CMICmdCmdSupportInfoMiCmdQuery()
: m_bCmdFound(false)
, m_constStrArgCmdName("cmd_name")
{
@@ -42,7 +42,7 @@ CMICmdCmdSupportInfoMiCmdQuery::CMICmdCmdSupportInfoMiCmdQuery(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdSupportInfoMiCmdQuery::~CMICmdCmdSupportInfoMiCmdQuery(void)
+CMICmdCmdSupportInfoMiCmdQuery::~CMICmdCmdSupportInfoMiCmdQuery()
{
}
@@ -56,10 +56,10 @@ CMICmdCmdSupportInfoMiCmdQuery::~CMICmdCmdSupportInfoMiCmdQuery(void)
// Throws: None.
//--
bool
-CMICmdCmdSupportInfoMiCmdQuery::ParseArgs(void)
+CMICmdCmdSupportInfoMiCmdQuery::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgCmdName, true, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgCmdName, true, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -72,7 +72,7 @@ CMICmdCmdSupportInfoMiCmdQuery::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdSupportInfoMiCmdQuery::Execute(void)
+CMICmdCmdSupportInfoMiCmdQuery::Execute()
{
CMICMDBASE_GETOPTION(pArgNamedCmdName, String, m_constStrArgCmdName);
const CMIUtilString &rCmdToQuery(pArgNamedCmdName->GetValue());
@@ -96,7 +96,7 @@ CMICmdCmdSupportInfoMiCmdQuery::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdSupportInfoMiCmdQuery::Acknowledge(void)
+CMICmdCmdSupportInfoMiCmdQuery::Acknowledge()
{
const CMICmnMIValueConst miValueConst(m_bCmdFound ? "true" : "false");
const CMICmnMIValueResult miValueResult("exists", miValueConst);
@@ -117,7 +117,7 @@ CMICmdCmdSupportInfoMiCmdQuery::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdSupportInfoMiCmdQuery::CreateSelf(void)
+CMICmdCmdSupportInfoMiCmdQuery::CreateSelf()
{
return new CMICmdCmdSupportInfoMiCmdQuery();
}
diff --git a/tools/lldb-mi/MICmdCmdSupportInfo.h b/tools/lldb-mi/MICmdCmdSupportInfo.h
index 8dfcfba8ed7d..62b71261f188 100644
--- a/tools/lldb-mi/MICmdCmdSupportInfo.h
+++ b/tools/lldb-mi/MICmdCmdSupportInfo.h
@@ -27,29 +27,26 @@
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "info-gdb-mi-command".
// This command does not follow the MI documentation exactly.
-// Gotchas: None.
-// Authors: Illya Rudkin 06/05/2014.
-// Changes: None.
//--
class CMICmdCmdSupportInfoMiCmdQuery : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdSupportInfoMiCmdQuery(void);
+ /* ctor */ CMICmdCmdSupportInfoMiCmdQuery();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdSupportInfoMiCmdQuery(void) override;
+ /* dtor */ ~CMICmdCmdSupportInfoMiCmdQuery() override;
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmdCmdSupportList.cpp b/tools/lldb-mi/MICmdCmdSupportList.cpp
index 6cf4b0b533bc..06d63612de6e 100644
--- a/tools/lldb-mi/MICmdCmdSupportList.cpp
+++ b/tools/lldb-mi/MICmdCmdSupportList.cpp
@@ -22,7 +22,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdCmdSupportListFeatures::CMICmdCmdSupportListFeatures(void)
+CMICmdCmdSupportListFeatures::CMICmdCmdSupportListFeatures()
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "list-features";
@@ -38,7 +38,7 @@ CMICmdCmdSupportListFeatures::CMICmdCmdSupportListFeatures(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdSupportListFeatures::~CMICmdCmdSupportListFeatures(void)
+CMICmdCmdSupportListFeatures::~CMICmdCmdSupportListFeatures()
{
}
@@ -52,7 +52,7 @@ CMICmdCmdSupportListFeatures::~CMICmdCmdSupportListFeatures(void)
// Throws: None.
//--
bool
-CMICmdCmdSupportListFeatures::Execute(void)
+CMICmdCmdSupportListFeatures::Execute()
{
// Do nothing
@@ -69,10 +69,15 @@ CMICmdCmdSupportListFeatures::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdSupportListFeatures::Acknowledge(void)
+CMICmdCmdSupportListFeatures::Acknowledge()
{
- const CMICmnMIValueConst miValueConst("data-read-memory-bytes");
- const CMICmnMIValueList miValueList(miValueConst);
+ // Declare supported features here
+ const CMICmnMIValueConst miValueConst1("data-read-memory-bytes");
+ const CMICmnMIValueConst miValueConst2("exec-run-start-option");
+ // Some features may depend on host and/or target, decide what to add below
+ CMICmnMIValueList miValueList(true);
+ miValueList.Add(miValueConst1);
+ miValueList.Add(miValueConst2);
const CMICmnMIValueResult miValueResult("features", miValueList);
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
m_miResultRecord = miRecordResult;
@@ -89,7 +94,7 @@ CMICmdCmdSupportListFeatures::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdSupportListFeatures::CreateSelf(void)
+CMICmdCmdSupportListFeatures::CreateSelf()
{
return new CMICmdCmdSupportListFeatures();
}
diff --git a/tools/lldb-mi/MICmdCmdSupportList.h b/tools/lldb-mi/MICmdCmdSupportList.h
index a317b079247b..5ac95a34c3bb 100644
--- a/tools/lldb-mi/MICmdCmdSupportList.h
+++ b/tools/lldb-mi/MICmdCmdSupportList.h
@@ -27,26 +27,23 @@
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "list-features".
// This command does not follow the MI documentation exactly.
-// Gotchas: None.
-// Authors: Illya Rudkin 03/03/2014.
-// Changes: None.
//--
class CMICmdCmdSupportListFeatures : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdSupportListFeatures(void);
+ /* ctor */ CMICmdCmdSupportListFeatures();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdSupportListFeatures(void) override;
+ /* dtor */ ~CMICmdCmdSupportListFeatures() override;
};
diff --git a/tools/lldb-mi/MICmdCmdSymbol.cpp b/tools/lldb-mi/MICmdCmdSymbol.cpp
index 2649389d7686..d99ceef22498 100644
--- a/tools/lldb-mi/MICmdCmdSymbol.cpp
+++ b/tools/lldb-mi/MICmdCmdSymbol.cpp
@@ -19,6 +19,7 @@
#include "MICmnMIResultRecord.h"
#include "MICmnMIValueList.h"
#include "MICmnMIValueTuple.h"
+#include "MIUtilParse.h"
//++ ------------------------------------------------------------------------------------
// Details: CMICmdCmdSymbolListLines constructor.
@@ -27,7 +28,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdCmdSymbolListLines::CMICmdCmdSymbolListLines(void)
+CMICmdCmdSymbolListLines::CMICmdCmdSymbolListLines()
: m_constStrArgNameFile("file")
{
// Command factory matches this name with that received from the stdin stream
@@ -44,7 +45,7 @@ CMICmdCmdSymbolListLines::CMICmdCmdSymbolListLines(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdSymbolListLines::~CMICmdCmdSymbolListLines(void)
+CMICmdCmdSymbolListLines::~CMICmdCmdSymbolListLines()
{
}
@@ -58,10 +59,10 @@ CMICmdCmdSymbolListLines::~CMICmdCmdSymbolListLines(void)
// Throws: None.
//--
bool
-CMICmdCmdSymbolListLines::ParseArgs(void)
+CMICmdCmdSymbolListLines::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValFile(m_constStrArgNameFile, true, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValFile(m_constStrArgNameFile, true, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -76,11 +77,15 @@ CMICmdCmdSymbolListLines::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdSymbolListLines::Execute(void)
+CMICmdCmdSymbolListLines::Execute()
{
CMICMDBASE_GETOPTION(pArgFile, File, m_constStrArgNameFile);
const CMIUtilString &strFilePath(pArgFile->GetValue());
+ // FIXME: this won't work for header files! To try and use existing
+ // commands to get this to work for header files would be too slow.
+ // Instead, this code should be rewritten to use APIs and/or support
+ // should be added to lldb which would work for header files.
const CMIUtilString strCmd(CMIUtilString::Format("target modules dump line-table \"%s\"", strFilePath.AddSlashes().c_str()));
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
@@ -91,6 +96,77 @@ CMICmdCmdSymbolListLines::Execute(void)
}
//++ ------------------------------------------------------------------------------------
+// Details: Helper function for parsing the header returned from lldb for the command:
+// target modules dump line-table <file>
+// where the header is of the format:
+// Line table for /path/to/file in `/path/to/module
+// Args: input - (R) Input string to parse.
+// file - (W) String representing the file.
+// Return: bool - True = input was parsed successfully, false = input could not be parsed.
+// Throws: None.
+//--
+static bool
+ParseLLDBLineAddressHeader(const char *input, CMIUtilString &file)
+{
+ // Match LineEntry using regex.
+ static MIUtilParse::CRegexParser g_lineentry_header_regex(
+ "^ *Line table for (.+) in `(.+)$");
+ // ^1=file ^2=module
+
+ MIUtilParse::CRegexParser::Match match(3);
+
+ const bool ok = g_lineentry_header_regex.Execute(input, match);
+ if (ok)
+ file = match.GetMatchAtIndex(1);
+ return ok;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Helper function for parsing a line entry returned from lldb for the command:
+// target modules dump line-table <file>
+// where the line entry is of the format:
+// 0x0000000100000e70: /path/to/file:3002[:4]
+// addr file line column(opt)
+// Args: input - (R) Input string to parse.
+// addr - (W) String representing the pc address.
+// file - (W) String representing the file.
+// line - (W) String representing the line.
+// Return: bool - True = input was parsed successfully, false = input could not be parsed.
+// Throws: None.
+//--
+static bool
+ParseLLDBLineAddressEntry(const char *input, CMIUtilString &addr,
+ CMIUtilString &file, CMIUtilString &line)
+{
+ // Note: Ambiguities arise because the column is optional, and
+ // because : can appear in filenames or as a byte in a multibyte
+ // UTF8 character. We keep those cases to a minimum by using regex
+ // to work on the string from both the left and right, so that what
+ // is remains is assumed to be the filename.
+
+ // Match LineEntry using regex.
+ static MIUtilParse::CRegexParser g_lineentry_nocol_regex(
+ "^ *(0x[0-9a-fA-F]+): (.+):([0-9]+)$");
+ static MIUtilParse::CRegexParser g_lineentry_col_regex(
+ "^ *(0x[0-9a-fA-F]+): (.+):([0-9]+):[0-9]+$");
+ // ^1=addr ^2=f ^3=line ^4=:col(opt)
+
+ MIUtilParse::CRegexParser::Match match(5);
+
+ // First try matching the LineEntry with the column,
+ // then try without the column.
+ const bool ok = g_lineentry_col_regex.Execute(input, match) ||
+ g_lineentry_nocol_regex.Execute(input, match);
+ if (ok)
+ {
+ addr = match.GetMatchAtIndex(1);
+ file = match.GetMatchAtIndex(2);
+ line = match.GetMatchAtIndex(3);
+ }
+ return ok;
+}
+
+//++ ------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record Result
// for the work carried out in the Execute().
// Type: Overridden.
@@ -100,7 +176,7 @@ CMICmdCmdSymbolListLines::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdSymbolListLines::Acknowledge(void)
+CMICmdCmdSymbolListLines::Acknowledge()
{
if (m_lldbResult.GetErrorSize() > 0)
{
@@ -117,36 +193,48 @@ CMICmdCmdSymbolListLines::Acknowledge(void)
const CMIUtilString strLldbMsg(m_lldbResult.GetOutput());
const MIuint nLines(strLldbMsg.SplitLines(vecLines));
+ // Parse the file from the header.
+ const CMIUtilString &rWantFile(vecLines[0]);
+ CMIUtilString strWantFile;
+ if (!ParseLLDBLineAddressHeader(rWantFile.c_str(), strWantFile))
+ {
+ // Unexpected error - parsing failed.
+ // MI print "%s^error,msg=\"Command '-symbol-list-lines'. Error: Line address header is absent or has an unknown format.\""
+ const CMICmnMIValueConst miValueConst(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SOME_ERROR), m_cmdData.strMiCmd.c_str(), "Line address header is absent or has an unknown format."));
+ const CMICmnMIValueResult miValueResult("msg", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
+ }
+
+ // Parse the line address entries.
CMICmnMIValueList miValueList(true);
for (MIuint i = 1; i < nLines; ++i)
{
// String looks like:
// 0x0000000100000e70: /path/to/file:3[:4]
const CMIUtilString &rLine(vecLines[i]);
+ CMIUtilString strAddr;
+ CMIUtilString strFile;
+ CMIUtilString strLine;
+
+ if (!ParseLLDBLineAddressEntry(rLine.c_str(), strAddr, strFile, strLine))
+ continue;
+
+ // Skip entries which don't match the desired source.
+ if (strWantFile != strFile)
+ continue;
- // 0x0000000100000e70: /path/to/file:3[:4]
- // ^^^^^^^^^^^^^^^^^^ -- pc
- const size_t nAddrEndPos = rLine.find(':');
- const CMIUtilString strAddr(rLine.substr(0, nAddrEndPos).c_str());
const CMICmnMIValueConst miValueConst(strAddr);
const CMICmnMIValueResult miValueResult("pc", miValueConst);
CMICmnMIValueTuple miValueTuple(miValueResult);
- // 0x0000000100000e70: /path/to/file:3[:4]
- // ^ -- line
- const size_t nLineOrColumnStartPos = rLine.rfind(':');
- const CMIUtilString strLineOrColumn(rLine.substr(nLineOrColumnStartPos + 1).c_str());
- const size_t nPathOrLineStartPos = rLine.rfind(':', nLineOrColumnStartPos - 1);
- const size_t nPathOrLineLen = nLineOrColumnStartPos - nPathOrLineStartPos - 1;
- const CMIUtilString strPathOrLine(rLine.substr(nPathOrLineStartPos + 1, nPathOrLineLen).c_str());
- const CMIUtilString strLine(strPathOrLine.IsNumber() ? strPathOrLine : strLineOrColumn);
const CMICmnMIValueConst miValueConst2(strLine);
const CMICmnMIValueResult miValueResult2("line", miValueConst2);
- bool bOk = miValueTuple.Add(miValueResult2);
+ miValueTuple.Add(miValueResult2);
- bOk = bOk && miValueList.Add(miValueTuple);
- if (!bOk)
- return MIstatus::failure;
+ miValueList.Add(miValueTuple);
}
// MI print "%s^done,lines=[{pc=\"%d\",line=\"%d\"}...]"
@@ -167,7 +255,7 @@ CMICmdCmdSymbolListLines::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdSymbolListLines::CreateSelf(void)
+CMICmdCmdSymbolListLines::CreateSelf()
{
return new CMICmdCmdSymbolListLines();
}
diff --git a/tools/lldb-mi/MICmdCmdSymbol.h b/tools/lldb-mi/MICmdCmdSymbol.h
index ef268bbdb598..5bffd4fe91db 100644
--- a/tools/lldb-mi/MICmdCmdSymbol.h
+++ b/tools/lldb-mi/MICmdCmdSymbol.h
@@ -35,20 +35,20 @@ class CMICmdCmdSymbolListLines : public CMICmdBase
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdSymbolListLines(void);
+ /* ctor */ CMICmdCmdSymbolListLines();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdSymbolListLines(void) override;
+ /* dtor */ ~CMICmdCmdSymbolListLines() override;
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmdCmdTarget.cpp b/tools/lldb-mi/MICmdCmdTarget.cpp
index 6655682eee38..030024bb267e 100644
--- a/tools/lldb-mi/MICmdCmdTarget.cpp
+++ b/tools/lldb-mi/MICmdCmdTarget.cpp
@@ -33,7 +33,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdCmdTargetSelect::CMICmdCmdTargetSelect(void)
+CMICmdCmdTargetSelect::CMICmdCmdTargetSelect()
: m_constStrArgNamedType("type")
, m_constStrArgNamedParameters("parameters")
{
@@ -51,7 +51,7 @@ CMICmdCmdTargetSelect::CMICmdCmdTargetSelect(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdTargetSelect::~CMICmdCmdTargetSelect(void)
+CMICmdCmdTargetSelect::~CMICmdCmdTargetSelect()
{
}
@@ -65,11 +65,11 @@ CMICmdCmdTargetSelect::~CMICmdCmdTargetSelect(void)
// Throws: None.
//--
bool
-CMICmdCmdTargetSelect::ParseArgs(void)
+CMICmdCmdTargetSelect::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgNamedType, true, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgNamedParameters, true, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgNamedType, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgNamedParameters, true, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -84,7 +84,7 @@ CMICmdCmdTargetSelect::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdTargetSelect::Execute(void)
+CMICmdCmdTargetSelect::Execute()
{
CMICMDBASE_GETOPTION(pArgType, String, m_constStrArgNamedType);
CMICMDBASE_GETOPTION(pArgParameters, String, m_constStrArgNamedParameters);
@@ -172,7 +172,7 @@ CMICmdCmdTargetSelect::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdTargetSelect::Acknowledge(void)
+CMICmdCmdTargetSelect::Acknowledge()
{
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Connected);
m_miResultRecord = miRecordResult;
@@ -203,7 +203,7 @@ CMICmdCmdTargetSelect::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdTargetSelect::CreateSelf(void)
+CMICmdCmdTargetSelect::CreateSelf()
{
return new CMICmdCmdTargetSelect();
}
@@ -215,7 +215,7 @@ CMICmdCmdTargetSelect::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdTargetAttach::CMICmdCmdTargetAttach(void)
+CMICmdCmdTargetAttach::CMICmdCmdTargetAttach()
: m_constStrArgPid("pid")
, m_constStrArgNamedFile("n")
, m_constStrArgWaitFor("waitfor")
@@ -234,7 +234,7 @@ CMICmdCmdTargetAttach::CMICmdCmdTargetAttach(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdTargetAttach::~CMICmdCmdTargetAttach(void)
+CMICmdCmdTargetAttach::~CMICmdCmdTargetAttach()
{
}
@@ -248,13 +248,13 @@ CMICmdCmdTargetAttach::~CMICmdCmdTargetAttach(void)
// Throws: None.
//--
bool
-CMICmdCmdTargetAttach::ParseArgs(void)
+CMICmdCmdTargetAttach::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgPid, false, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionShort(m_constStrArgNamedFile, false, true,
- CMICmdArgValListBase::eArgValType_String, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgWaitFor, false, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgPid, false, true));
+ m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedFile, false, true,
+ CMICmdArgValListBase::eArgValType_String, 1));
+ m_setCmdArgs.Add(new CMICmdArgValOptionLong(m_constStrArgWaitFor, false, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -269,7 +269,7 @@ CMICmdCmdTargetAttach::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdTargetAttach::Execute(void)
+CMICmdCmdTargetAttach::Execute()
{
CMICMDBASE_GETOPTION(pArgPid, Number, m_constStrArgPid);
CMICMDBASE_GETOPTION(pArgFile, OptionShort, m_constStrArgNamedFile);
@@ -330,7 +330,7 @@ CMICmdCmdTargetAttach::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdTargetAttach::Acknowledge(void)
+CMICmdCmdTargetAttach::Acknowledge()
{
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
m_miResultRecord = miRecordResult;
@@ -361,7 +361,7 @@ CMICmdCmdTargetAttach::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdTargetAttach::CreateSelf(void)
+CMICmdCmdTargetAttach::CreateSelf()
{
return new CMICmdCmdTargetAttach();
}
@@ -389,7 +389,7 @@ CMICmdCmdTargetDetach::CMICmdCmdTargetDetach()
// Return: None.
// Throws: None.
//--
-CMICmdCmdTargetDetach::~CMICmdCmdTargetDetach(void)
+CMICmdCmdTargetDetach::~CMICmdCmdTargetDetach()
{
}
@@ -403,7 +403,7 @@ CMICmdCmdTargetDetach::~CMICmdCmdTargetDetach(void)
// Throws: None.
//--
bool
-CMICmdCmdTargetDetach::ParseArgs(void)
+CMICmdCmdTargetDetach::ParseArgs()
{
return MIstatus::success;
}
@@ -420,7 +420,7 @@ CMICmdCmdTargetDetach::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdTargetDetach::Execute(void)
+CMICmdCmdTargetDetach::Execute()
{
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
@@ -447,7 +447,7 @@ CMICmdCmdTargetDetach::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdTargetDetach::Acknowledge(void)
+CMICmdCmdTargetDetach::Acknowledge()
{
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
m_miResultRecord = miRecordResult;
@@ -463,7 +463,7 @@ CMICmdCmdTargetDetach::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdTargetDetach::CreateSelf(void)
+CMICmdCmdTargetDetach::CreateSelf()
{
return new CMICmdCmdTargetDetach();
}
diff --git a/tools/lldb-mi/MICmdCmdTarget.h b/tools/lldb-mi/MICmdCmdTarget.h
index 62f77eed47c5..e4c04b11145f 100644
--- a/tools/lldb-mi/MICmdCmdTarget.h
+++ b/tools/lldb-mi/MICmdCmdTarget.h
@@ -29,29 +29,26 @@
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "target-select".
// http://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Target-Manipulation.html#GDB_002fMI-Target-Manipulation
-// Gotchas: None.
-// Authors: Illya Rudkin 05/03/2014.
-// Changes: None.
//--
class CMICmdCmdTargetSelect : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdTargetSelect(void);
+ /* ctor */ CMICmdCmdTargetSelect();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdTargetSelect(void) override;
+ /* dtor */ ~CMICmdCmdTargetSelect() override;
// Attributes:
private:
@@ -69,20 +66,20 @@ class CMICmdCmdTargetAttach : public CMICmdBase
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdTargetAttach(void);
+ /* ctor */ CMICmdCmdTargetAttach();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdTargetAttach(void) override;
+ /* dtor */ ~CMICmdCmdTargetAttach() override;
// Attributes:
private:
@@ -101,19 +98,19 @@ class CMICmdCmdTargetDetach : public CMICmdBase
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdTargetDetach(void);
+ /* ctor */ CMICmdCmdTargetDetach();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdTargetDetach(void) override;
+ /* dtor */ ~CMICmdCmdTargetDetach() override;
};
diff --git a/tools/lldb-mi/MICmdCmdThread.cpp b/tools/lldb-mi/MICmdCmdThread.cpp
index df6de269bd49..823a3748248c 100644
--- a/tools/lldb-mi/MICmdCmdThread.cpp
+++ b/tools/lldb-mi/MICmdCmdThread.cpp
@@ -28,7 +28,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdCmdThreadInfo::CMICmdCmdThreadInfo(void)
+CMICmdCmdThreadInfo::CMICmdCmdThreadInfo()
: m_bSingleThread(false)
, m_bThreadInvalid(true)
, m_constStrArgNamedThreadId("thread-id")
@@ -47,7 +47,7 @@ CMICmdCmdThreadInfo::CMICmdCmdThreadInfo(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdThreadInfo::~CMICmdCmdThreadInfo(void)
+CMICmdCmdThreadInfo::~CMICmdCmdThreadInfo()
{
m_vecMIValueTuple.clear();
}
@@ -62,10 +62,10 @@ CMICmdCmdThreadInfo::~CMICmdCmdThreadInfo(void)
// Throws: None.
//--
bool
-CMICmdCmdThreadInfo::ParseArgs(void)
+CMICmdCmdThreadInfo::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgNamedThreadId, false, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNamedThreadId, false, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -78,7 +78,7 @@ CMICmdCmdThreadInfo::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdThreadInfo::Execute(void)
+CMICmdCmdThreadInfo::Execute()
{
CMICMDBASE_GETOPTION(pArgThreadId, Number, m_constStrArgNamedThreadId);
MIuint nThreadId = 0;
@@ -137,7 +137,7 @@ CMICmdCmdThreadInfo::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdThreadInfo::Acknowledge(void)
+CMICmdCmdThreadInfo::Acknowledge()
{
if (m_bSingleThread)
{
@@ -195,7 +195,7 @@ CMICmdCmdThreadInfo::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdThreadInfo::CreateSelf(void)
+CMICmdCmdThreadInfo::CreateSelf()
{
return new CMICmdCmdThreadInfo();
}
diff --git a/tools/lldb-mi/MICmdCmdThread.h b/tools/lldb-mi/MICmdCmdThread.h
index 7bce823a0b24..7031eabddc33 100644
--- a/tools/lldb-mi/MICmdCmdThread.h
+++ b/tools/lldb-mi/MICmdCmdThread.h
@@ -28,29 +28,26 @@
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "thread-info".
-// Gotchas: None.
-// Authors: Illya Rudkin 07/03/2014.
-// Changes: None.
//--
class CMICmdCmdThreadInfo : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdThreadInfo(void);
+ /* ctor */ CMICmdCmdThreadInfo();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdThreadInfo(void) override;
+ /* dtor */ ~CMICmdCmdThreadInfo() override;
// Typedefs:
private:
diff --git a/tools/lldb-mi/MICmdCmdTrace.cpp b/tools/lldb-mi/MICmdCmdTrace.cpp
index c0d5fc920373..4eab75bc71f6 100644
--- a/tools/lldb-mi/MICmdCmdTrace.cpp
+++ b/tools/lldb-mi/MICmdCmdTrace.cpp
@@ -21,7 +21,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdCmdTraceStatus::CMICmdCmdTraceStatus(void)
+CMICmdCmdTraceStatus::CMICmdCmdTraceStatus()
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "trace-status";
@@ -37,7 +37,7 @@ CMICmdCmdTraceStatus::CMICmdCmdTraceStatus(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdTraceStatus::~CMICmdCmdTraceStatus(void)
+CMICmdCmdTraceStatus::~CMICmdCmdTraceStatus()
{
}
@@ -51,7 +51,7 @@ CMICmdCmdTraceStatus::~CMICmdCmdTraceStatus(void)
// Throws: None.
//--
bool
-CMICmdCmdTraceStatus::Execute(void)
+CMICmdCmdTraceStatus::Execute()
{
// Do nothing
return MIstatus::success;
@@ -67,7 +67,7 @@ CMICmdCmdTraceStatus::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdTraceStatus::Acknowledge(void)
+CMICmdCmdTraceStatus::Acknowledge()
{
const CMICmnMIValueConst miValueConst(MIRSRC(IDS_CMD_ERR_NOT_IMPLEMENTED));
const CMICmnMIValueResult miValueResult("msg", miValueConst);
@@ -86,7 +86,7 @@ CMICmdCmdTraceStatus::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdTraceStatus::CreateSelf(void)
+CMICmdCmdTraceStatus::CreateSelf()
{
return new CMICmdCmdTraceStatus();
}
diff --git a/tools/lldb-mi/MICmdCmdTrace.h b/tools/lldb-mi/MICmdCmdTrace.h
index cafe2d89420e..d3751607338d 100644
--- a/tools/lldb-mi/MICmdCmdTrace.h
+++ b/tools/lldb-mi/MICmdCmdTrace.h
@@ -26,26 +26,23 @@
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "trace-status".
-// Gotchas: None.
-// Authors: Illya Rudkin 07/03/2014.
-// Changes: None.
//--
class CMICmdCmdTraceStatus : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdTraceStatus(void);
+ /* ctor */ CMICmdCmdTraceStatus();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdTraceStatus(void) override;
+ /* dtor */ ~CMICmdCmdTraceStatus() override;
};
diff --git a/tools/lldb-mi/MICmdCmdVar.cpp b/tools/lldb-mi/MICmdCmdVar.cpp
index 8c4abbda1128..8e30a2ad0da4 100644
--- a/tools/lldb-mi/MICmdCmdVar.cpp
+++ b/tools/lldb-mi/MICmdCmdVar.cpp
@@ -45,15 +45,12 @@
// Return: None.
// Throws: None.
//--
-CMICmdCmdVarCreate::CMICmdCmdVarCreate(void)
+CMICmdCmdVarCreate::CMICmdCmdVarCreate()
: m_nChildren(0)
, m_nThreadId(0)
, m_strType("??")
, m_bValid(false)
, m_strValue("??")
- , m_constStrArgThread("thread")
- , m_constStrArgThreadGroup("thread-group")
- , m_constStrArgFrame("frame")
, m_constStrArgName("name")
, m_constStrArgFrameAddr("frame-addr")
, m_constStrArgExpression("expression")
@@ -72,7 +69,7 @@ CMICmdCmdVarCreate::CMICmdCmdVarCreate(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdVarCreate::~CMICmdCmdVarCreate(void)
+CMICmdCmdVarCreate::~CMICmdCmdVarCreate()
{
}
@@ -86,19 +83,12 @@ CMICmdCmdVarCreate::~CMICmdCmdVarCreate(void)
// Throws: None.
//--
bool
-CMICmdCmdVarCreate::ParseArgs(void)
+CMICmdCmdVarCreate::ParseArgs()
{
- bool bOk =
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk &&
- m_setCmdArgs.Add(
- *(new CMICmdArgValOptionLong(m_constStrArgThreadGroup, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1)));
- bOk = bOk &&
- m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgFrame, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgName, false, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgFrameAddr, false, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgExpression, true, true, true, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgName, false, true));
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgFrameAddr, false, true));
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgExpression, true, true, true, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -111,7 +101,7 @@ CMICmdCmdVarCreate::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdVarCreate::Execute(void)
+CMICmdCmdVarCreate::Execute()
{
CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
CMICMDBASE_GETOPTION(pArgFrame, OptionLong, m_constStrArgFrame);
@@ -182,7 +172,7 @@ CMICmdCmdVarCreate::Execute(void)
if (rStrExpression[0] == '$')
{
- const CMIUtilString rStrRegister(rStrExpression.substr(1).c_str());
+ const CMIUtilString rStrRegister(rStrExpression.substr(1));
value = frame.FindRegister(rStrRegister.c_str());
}
else
@@ -229,7 +219,7 @@ CMICmdCmdVarCreate::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdVarCreate::Acknowledge(void)
+CMICmdCmdVarCreate::Acknowledge()
{
if (m_bValid)
{
@@ -258,7 +248,7 @@ CMICmdCmdVarCreate::Acknowledge(void)
CMIUtilString strErrMsg(m_strValue);
if (m_strValue.empty())
strErrMsg = CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_VARIABLE_CREATION_FAILED), m_strExpression.c_str());
- const CMICmnMIValueConst miValueConst(strErrMsg);
+ const CMICmnMIValueConst miValueConst(strErrMsg.Escape(true /* vbEscapeQuotes */));
CMICmnMIValueResult miValueResult("msg", miValueConst);
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
m_miResultRecord = miRecordResult;
@@ -275,7 +265,7 @@ CMICmdCmdVarCreate::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdVarCreate::CreateSelf(void)
+CMICmdCmdVarCreate::CreateSelf()
{
return new CMICmdCmdVarCreate();
}
@@ -320,7 +310,7 @@ CMICmdCmdVarCreate::CompleteSBValue(lldb::SBValue &vrwValue)
// Return: None.
// Throws: None.
//--
-CMICmdCmdVarUpdate::CMICmdCmdVarUpdate(void)
+CMICmdCmdVarUpdate::CMICmdCmdVarUpdate()
: m_constStrArgPrintValues("print-values")
, m_constStrArgName("name")
, m_bValueChanged(false)
@@ -340,7 +330,7 @@ CMICmdCmdVarUpdate::CMICmdCmdVarUpdate(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdVarUpdate::~CMICmdCmdVarUpdate(void)
+CMICmdCmdVarUpdate::~CMICmdCmdVarUpdate()
{
}
@@ -354,11 +344,11 @@ CMICmdCmdVarUpdate::~CMICmdCmdVarUpdate(void)
// Throws: None.
//--
bool
-CMICmdCmdVarUpdate::ParseArgs(void)
+CMICmdCmdVarUpdate::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValPrintValues(m_constStrArgPrintValues, false, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgName, true, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValPrintValues(m_constStrArgPrintValues, false, true));
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgName, true, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -371,7 +361,7 @@ CMICmdCmdVarUpdate::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdVarUpdate::Execute(void)
+CMICmdCmdVarUpdate::Execute()
{
CMICMDBASE_GETOPTION(pArgPrintValues, PrintValues, m_constStrArgPrintValues);
CMICMDBASE_GETOPTION(pArgName, String, m_constStrArgName);
@@ -399,7 +389,7 @@ CMICmdCmdVarUpdate::Execute(void)
(eVarInfoFormat == CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_SimpleValues && rValue.GetNumChildren() == 0));
const CMIUtilString strValue(bPrintValue ? varObj.GetValueFormatted() : "");
const CMIUtilString strInScope(rValue.IsInScope() ? "true" : "false");
- return MIFormResponse(rVarObjName, bPrintValue ? strValue.c_str() : nullptr, strInScope);
+ MIFormResponse(rVarObjName, bPrintValue ? strValue.c_str() : nullptr, strInScope);
}
return MIstatus::success;
@@ -415,7 +405,7 @@ CMICmdCmdVarUpdate::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdVarUpdate::Acknowledge(void)
+CMICmdCmdVarUpdate::Acknowledge()
{
if (m_bValueChanged)
{
@@ -445,7 +435,7 @@ CMICmdCmdVarUpdate::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdVarUpdate::CreateSelf(void)
+CMICmdCmdVarUpdate::CreateSelf()
{
return new CMICmdCmdVarUpdate();
}
@@ -456,36 +446,32 @@ CMICmdCmdVarUpdate::CreateSelf(void)
// Args: vrStrVarName - (R) Session var object's name.
// vpValue - (R) Text version of the value held in the variable.
// vrStrScope - (R) In scope "yes" or "no".
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
+// Return: None.
// Throws: None.
//--
-bool
+void
CMICmdCmdVarUpdate::MIFormResponse(const CMIUtilString &vrStrVarName, const char *const vpValue, const CMIUtilString &vrStrScope)
{
// MI print "[{name=\"%s\",value=\"%s\",in_scope=\"%s\",type_changed=\"false\",has_more=\"0\"}]"
const CMICmnMIValueConst miValueConst(vrStrVarName);
const CMICmnMIValueResult miValueResult("name", miValueConst);
CMICmnMIValueTuple miValueTuple(miValueResult);
- bool bOk = true;
if (vpValue != nullptr)
{
const CMICmnMIValueConst miValueConst2(vpValue);
const CMICmnMIValueResult miValueResult2("value", miValueConst2);
- bOk = bOk && miValueTuple.Add(miValueResult2);
+ miValueTuple.Add(miValueResult2);
}
const CMICmnMIValueConst miValueConst3(vrStrScope);
const CMICmnMIValueResult miValueResult3("in_scope", miValueConst3);
- bOk = bOk && miValueTuple.Add(miValueResult3);
+ miValueTuple.Add(miValueResult3);
const CMICmnMIValueConst miValueConst4("false");
const CMICmnMIValueResult miValueResult4("type_changed", miValueConst4);
- bOk = bOk && miValueTuple.Add(miValueResult4);
+ miValueTuple.Add(miValueResult4);
const CMICmnMIValueConst miValueConst5("0");
const CMICmnMIValueResult miValueResult5("has_more", miValueConst5);
- bOk = bOk && miValueTuple.Add(miValueResult5);
- bOk = bOk && m_miValueList.Add(miValueTuple);
-
- return bOk;
+ miValueTuple.Add(miValueResult5);
+ m_miValueList.Add(miValueTuple);
}
//++ ------------------------------------------------------------------------------------
@@ -543,7 +529,7 @@ CMICmdCmdVarUpdate::ExamineSBValueForChange(lldb::SBValue &vrwValue, bool &vrwbC
// Return: None.
// Throws: None.
//--
-CMICmdCmdVarDelete::CMICmdCmdVarDelete(void)
+CMICmdCmdVarDelete::CMICmdCmdVarDelete()
: m_constStrArgName("name")
{
// Command factory matches this name with that received from the stdin stream
@@ -563,10 +549,10 @@ CMICmdCmdVarDelete::CMICmdCmdVarDelete(void)
// Throws: None.
//--
bool
-CMICmdCmdVarDelete::ParseArgs(void)
+CMICmdCmdVarDelete::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgName, true, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgName, true, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -576,7 +562,7 @@ CMICmdCmdVarDelete::ParseArgs(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdVarDelete::~CMICmdCmdVarDelete(void)
+CMICmdCmdVarDelete::~CMICmdCmdVarDelete()
{
}
@@ -590,7 +576,7 @@ CMICmdCmdVarDelete::~CMICmdCmdVarDelete(void)
// Throws: None.
//--
bool
-CMICmdCmdVarDelete::Execute(void)
+CMICmdCmdVarDelete::Execute()
{
CMICMDBASE_GETOPTION(pArgName, String, m_constStrArgName);
@@ -610,7 +596,7 @@ CMICmdCmdVarDelete::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdVarDelete::Acknowledge(void)
+CMICmdCmdVarDelete::Acknowledge()
{
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
m_miResultRecord = miRecordResult;
@@ -627,7 +613,7 @@ CMICmdCmdVarDelete::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdVarDelete::CreateSelf(void)
+CMICmdCmdVarDelete::CreateSelf()
{
return new CMICmdCmdVarDelete();
}
@@ -643,7 +629,7 @@ CMICmdCmdVarDelete::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdVarAssign::CMICmdCmdVarAssign(void)
+CMICmdCmdVarAssign::CMICmdCmdVarAssign()
: m_bOk(true)
, m_constStrArgName("name")
, m_constStrArgExpression("expression")
@@ -662,7 +648,7 @@ CMICmdCmdVarAssign::CMICmdCmdVarAssign(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdVarAssign::~CMICmdCmdVarAssign(void)
+CMICmdCmdVarAssign::~CMICmdCmdVarAssign()
{
}
@@ -676,11 +662,11 @@ CMICmdCmdVarAssign::~CMICmdCmdVarAssign(void)
// Throws: None.
//--
bool
-CMICmdCmdVarAssign::ParseArgs(void)
+CMICmdCmdVarAssign::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgName, true, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgExpression, true, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgName, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgExpression, true, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -693,7 +679,7 @@ CMICmdCmdVarAssign::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdVarAssign::Execute(void)
+CMICmdCmdVarAssign::Execute()
{
CMICMDBASE_GETOPTION(pArgName, String, m_constStrArgName);
CMICMDBASE_GETOPTION(pArgExpression, String, m_constStrArgExpression);
@@ -729,7 +715,7 @@ CMICmdCmdVarAssign::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdVarAssign::Acknowledge(void)
+CMICmdCmdVarAssign::Acknowledge()
{
if (m_bOk)
{
@@ -761,7 +747,7 @@ CMICmdCmdVarAssign::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdVarAssign::CreateSelf(void)
+CMICmdCmdVarAssign::CreateSelf()
{
return new CMICmdCmdVarAssign();
}
@@ -777,7 +763,7 @@ CMICmdCmdVarAssign::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdVarSetFormat::CMICmdCmdVarSetFormat(void)
+CMICmdCmdVarSetFormat::CMICmdCmdVarSetFormat()
: m_constStrArgName("name")
, m_constStrArgFormatSpec("format-spec")
{
@@ -795,7 +781,7 @@ CMICmdCmdVarSetFormat::CMICmdCmdVarSetFormat(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdVarSetFormat::~CMICmdCmdVarSetFormat(void)
+CMICmdCmdVarSetFormat::~CMICmdCmdVarSetFormat()
{
}
@@ -809,11 +795,11 @@ CMICmdCmdVarSetFormat::~CMICmdCmdVarSetFormat(void)
// Throws: None.
//--
bool
-CMICmdCmdVarSetFormat::ParseArgs(void)
+CMICmdCmdVarSetFormat::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgName, true, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgFormatSpec, true, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgName, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgFormatSpec, true, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -826,7 +812,7 @@ CMICmdCmdVarSetFormat::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdVarSetFormat::Execute(void)
+CMICmdCmdVarSetFormat::Execute()
{
CMICMDBASE_GETOPTION(pArgName, String, m_constStrArgName);
CMICMDBASE_GETOPTION(pArgFormatSpec, String, m_constStrArgFormatSpec);
@@ -863,7 +849,7 @@ CMICmdCmdVarSetFormat::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdVarSetFormat::Acknowledge(void)
+CMICmdCmdVarSetFormat::Acknowledge()
{
// MI print "%s^done,changelist=[{name=\"%s\",value=\"%s\",in_scope=\"%s\",type_changed=\"false\",has_more=\"0\"}]"
CMICmnLLDBDebugSessionInfoVarObj varObj;
@@ -902,7 +888,7 @@ CMICmdCmdVarSetFormat::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdVarSetFormat::CreateSelf(void)
+CMICmdCmdVarSetFormat::CreateSelf()
{
return new CMICmdCmdVarSetFormat();
}
@@ -918,7 +904,7 @@ CMICmdCmdVarSetFormat::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdVarListChildren::CMICmdCmdVarListChildren(void)
+CMICmdCmdVarListChildren::CMICmdCmdVarListChildren()
: m_constStrArgPrintValues("print-values")
, m_constStrArgName("name")
, m_constStrArgFrom("from")
@@ -942,7 +928,7 @@ CMICmdCmdVarListChildren::CMICmdCmdVarListChildren(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdVarListChildren::~CMICmdCmdVarListChildren(void)
+CMICmdCmdVarListChildren::~CMICmdCmdVarListChildren()
{
}
@@ -956,13 +942,13 @@ CMICmdCmdVarListChildren::~CMICmdCmdVarListChildren(void)
// Throws: None.
//--
bool
-CMICmdCmdVarListChildren::ParseArgs(void)
+CMICmdCmdVarListChildren::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValPrintValues(m_constStrArgPrintValues, false, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgName, true, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgFrom, false, true)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgTo, false, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValPrintValues(m_constStrArgPrintValues, false, true));
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgName, true, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgFrom, false, true));
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgTo, false, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -975,7 +961,7 @@ CMICmdCmdVarListChildren::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdVarListChildren::Execute(void)
+CMICmdCmdVarListChildren::Execute()
{
CMICMDBASE_GETOPTION(pArgPrintValues, PrintValues, m_constStrArgPrintValues);
CMICMDBASE_GETOPTION(pArgName, String, m_constStrArgName);
@@ -1022,46 +1008,47 @@ CMICmdCmdVarListChildren::Execute(void)
lldb::SBValue member = rValue.GetChildAtIndex(i);
const CMICmnLLDBUtilSBValue utilValue(member);
const CMIUtilString strExp = utilValue.GetName();
- const CMIUtilString name(CMIUtilString::Format("%s.%s", rVarObjName.c_str(), strExp.c_str()));
+ const CMIUtilString name(strExp.empty() ?
+ CMIUtilString::Format("%s.$%u", rVarObjName.c_str(), i) :
+ CMIUtilString::Format("%s.%s", rVarObjName.c_str(), strExp.c_str()));
const MIuint nChildren = member.GetNumChildren();
const CMIUtilString strThreadId(CMIUtilString::Format("%u", member.GetThread().GetIndexID()));
+ // Varobj gets added to CMICmnLLDBDebugSessionInfoVarObj static container of varObjs
+ CMICmnLLDBDebugSessionInfoVarObj var(strExp, name, member, rVarObjName);
+
// MI print "child={name=\"%s\",exp=\"%s\",numchild=\"%d\",value=\"%s\",type=\"%s\",thread-id=\"%u\",has_more=\"%u\"}"
const CMICmnMIValueConst miValueConst(name);
const CMICmnMIValueResult miValueResult("name", miValueConst);
CMICmnMIValueTuple miValueTuple(miValueResult);
const CMICmnMIValueConst miValueConst2(strExp);
const CMICmnMIValueResult miValueResult2("exp", miValueConst2);
- bool bOk = miValueTuple.Add(miValueResult2);
+ miValueTuple.Add(miValueResult2);
const CMIUtilString strNumChild(CMIUtilString::Format("%u", nChildren));
const CMICmnMIValueConst miValueConst3(strNumChild);
const CMICmnMIValueResult miValueResult3("numchild", miValueConst3);
- bOk = bOk && miValueTuple.Add(miValueResult3);
+ miValueTuple.Add(miValueResult3);
const CMICmnMIValueConst miValueConst5(utilValue.GetTypeNameDisplay());
const CMICmnMIValueResult miValueResult5("type", miValueConst5);
- bOk = bOk && miValueTuple.Add(miValueResult5);
+ miValueTuple.Add(miValueResult5);
const CMICmnMIValueConst miValueConst6(strThreadId);
const CMICmnMIValueResult miValueResult6("thread-id", miValueConst6);
- bOk = bOk && miValueTuple.Add(miValueResult6);
+ miValueTuple.Add(miValueResult6);
// nChildren == 0 is used to check for simple values
if (eVarInfoFormat == CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_AllValues ||
(eVarInfoFormat == CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_SimpleValues && nChildren == 0))
{
- // Varobj gets added to CMICmnLLDBDebugSessionInfoVarObj static container of varObjs
- CMICmnLLDBDebugSessionInfoVarObj var(strExp, name, member, rVarObjName);
const CMIUtilString strValue(
CMICmnLLDBDebugSessionInfoVarObj::GetValueStringFormatted(member, CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Natural));
const CMICmnMIValueConst miValueConst7(strValue);
const CMICmnMIValueResult miValueResult7("value", miValueConst7);
- bOk = bOk && miValueTuple.Add(miValueResult7);
+ miValueTuple.Add(miValueResult7);
}
const CMICmnMIValueConst miValueConst8("0");
const CMICmnMIValueResult miValueResult8("has_more", miValueConst8);
- bOk = bOk && miValueTuple.Add(miValueResult8);
+ miValueTuple.Add(miValueResult8);
const CMICmnMIValueResult miValueResult9("child", miValueTuple);
- bOk = bOk && m_miValueList.Add(miValueResult9);
- if (!bOk)
- return MIstatus::failure;
+ m_miValueList.Add(miValueResult9);
}
return MIstatus::success;
@@ -1077,7 +1064,7 @@ CMICmdCmdVarListChildren::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdVarListChildren::Acknowledge(void)
+CMICmdCmdVarListChildren::Acknowledge()
{
if (m_bValueValid)
{
@@ -1085,14 +1072,11 @@ CMICmdCmdVarListChildren::Acknowledge(void)
const CMIUtilString strNumChild(CMIUtilString::Format("%u", m_nChildren));
const CMICmnMIValueConst miValueConst(strNumChild);
CMICmnMIValueResult miValueResult("numchild", miValueConst);
- bool bOk = MIstatus::success;
if (m_nChildren != 0)
- bOk = bOk && miValueResult.Add("children", m_miValueList);
+ miValueResult.Add("children", m_miValueList);
const CMIUtilString strHasMore(m_bHasMore ? "1" : "0");
const CMICmnMIValueConst miValueConst2(strHasMore);
- bOk = bOk && miValueResult.Add("has_more", miValueConst2);
- if (!bOk)
- return MIstatus::failure;
+ miValueResult.Add("has_more", miValueConst2);
const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
m_miResultRecord = miRecordResult;
@@ -1118,7 +1102,7 @@ CMICmdCmdVarListChildren::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdVarListChildren::CreateSelf(void)
+CMICmdCmdVarListChildren::CreateSelf()
{
return new CMICmdCmdVarListChildren();
}
@@ -1134,7 +1118,7 @@ CMICmdCmdVarListChildren::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdVarEvaluateExpression::CMICmdCmdVarEvaluateExpression(void)
+CMICmdCmdVarEvaluateExpression::CMICmdCmdVarEvaluateExpression()
: m_bValueValid(true)
, m_constStrArgFormatSpec("-f")
, m_constStrArgName("name")
@@ -1153,7 +1137,7 @@ CMICmdCmdVarEvaluateExpression::CMICmdCmdVarEvaluateExpression(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdVarEvaluateExpression::~CMICmdCmdVarEvaluateExpression(void)
+CMICmdCmdVarEvaluateExpression::~CMICmdCmdVarEvaluateExpression()
{
}
@@ -1167,12 +1151,12 @@ CMICmdCmdVarEvaluateExpression::~CMICmdCmdVarEvaluateExpression(void)
// Throws: None.
//--
bool
-CMICmdCmdVarEvaluateExpression::ParseArgs(void)
+CMICmdCmdVarEvaluateExpression::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(
- *(new CMICmdArgValOptionShort(m_constStrArgFormatSpec, false, false, CMICmdArgValListBase::eArgValType_String, 1)));
- bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgName, true, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(
+ new CMICmdArgValOptionShort(m_constStrArgFormatSpec, false, false, CMICmdArgValListBase::eArgValType_String, 1));
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgName, true, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -1185,7 +1169,7 @@ CMICmdCmdVarEvaluateExpression::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdVarEvaluateExpression::Execute(void)
+CMICmdCmdVarEvaluateExpression::Execute()
{
CMICMDBASE_GETOPTION(pArgName, String, m_constStrArgName);
@@ -1218,7 +1202,7 @@ CMICmdCmdVarEvaluateExpression::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdVarEvaluateExpression::Acknowledge(void)
+CMICmdCmdVarEvaluateExpression::Acknowledge()
{
if (m_bValueValid)
{
@@ -1247,7 +1231,7 @@ CMICmdCmdVarEvaluateExpression::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdVarEvaluateExpression::CreateSelf(void)
+CMICmdCmdVarEvaluateExpression::CreateSelf()
{
return new CMICmdCmdVarEvaluateExpression();
}
@@ -1263,7 +1247,7 @@ CMICmdCmdVarEvaluateExpression::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdVarInfoPathExpression::CMICmdCmdVarInfoPathExpression(void)
+CMICmdCmdVarInfoPathExpression::CMICmdCmdVarInfoPathExpression()
: m_bValueValid(true)
, m_constStrArgName("name")
{
@@ -1281,7 +1265,7 @@ CMICmdCmdVarInfoPathExpression::CMICmdCmdVarInfoPathExpression(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdVarInfoPathExpression::~CMICmdCmdVarInfoPathExpression(void)
+CMICmdCmdVarInfoPathExpression::~CMICmdCmdVarInfoPathExpression()
{
}
@@ -1295,10 +1279,10 @@ CMICmdCmdVarInfoPathExpression::~CMICmdCmdVarInfoPathExpression(void)
// Throws: None.
//--
bool
-CMICmdCmdVarInfoPathExpression::ParseArgs(void)
+CMICmdCmdVarInfoPathExpression::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgName, true, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgName, true, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -1311,7 +1295,7 @@ CMICmdCmdVarInfoPathExpression::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdVarInfoPathExpression::Execute(void)
+CMICmdCmdVarInfoPathExpression::Execute()
{
CMICMDBASE_GETOPTION(pArgName, String, m_constStrArgName);
@@ -1380,7 +1364,7 @@ CMICmdCmdVarInfoPathExpression::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdVarInfoPathExpression::Acknowledge(void)
+CMICmdCmdVarInfoPathExpression::Acknowledge()
{
if (m_bValueValid)
{
@@ -1408,7 +1392,7 @@ CMICmdCmdVarInfoPathExpression::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdVarInfoPathExpression::CreateSelf(void)
+CMICmdCmdVarInfoPathExpression::CreateSelf()
{
return new CMICmdCmdVarInfoPathExpression();
}
@@ -1424,7 +1408,7 @@ CMICmdCmdVarInfoPathExpression::CreateSelf(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdVarShowAttributes::CMICmdCmdVarShowAttributes(void)
+CMICmdCmdVarShowAttributes::CMICmdCmdVarShowAttributes()
: m_constStrArgName("name")
{
// Command factory matches this name with that received from the stdin stream
@@ -1441,7 +1425,7 @@ CMICmdCmdVarShowAttributes::CMICmdCmdVarShowAttributes(void)
// Return: None.
// Throws: None.
//--
-CMICmdCmdVarShowAttributes::~CMICmdCmdVarShowAttributes(void)
+CMICmdCmdVarShowAttributes::~CMICmdCmdVarShowAttributes()
{
}
@@ -1455,10 +1439,10 @@ CMICmdCmdVarShowAttributes::~CMICmdCmdVarShowAttributes(void)
// Throws: None.
//--
bool
-CMICmdCmdVarShowAttributes::ParseArgs(void)
+CMICmdCmdVarShowAttributes::ParseArgs()
{
- bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgName, true, true)));
- return (bOk && ParseValidateCmdOptions());
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgName, true, true));
+ return ParseValidateCmdOptions();
}
//++ ------------------------------------------------------------------------------------
@@ -1471,7 +1455,7 @@ CMICmdCmdVarShowAttributes::ParseArgs(void)
// Throws: None.
//--
bool
-CMICmdCmdVarShowAttributes::Execute(void)
+CMICmdCmdVarShowAttributes::Execute()
{
CMICMDBASE_GETOPTION(pArgName, String, m_constStrArgName);
@@ -1496,7 +1480,7 @@ CMICmdCmdVarShowAttributes::Execute(void)
// Throws: None.
//--
bool
-CMICmdCmdVarShowAttributes::Acknowledge(void)
+CMICmdCmdVarShowAttributes::Acknowledge()
{
// MI output: "%s^done,status=\"editable\"]"
const CMICmnMIValueConst miValueConst("editable");
@@ -1516,7 +1500,7 @@ CMICmdCmdVarShowAttributes::Acknowledge(void)
// Throws: None.
//--
CMICmdBase *
-CMICmdCmdVarShowAttributes::CreateSelf(void)
+CMICmdCmdVarShowAttributes::CreateSelf()
{
return new CMICmdCmdVarShowAttributes();
}
diff --git a/tools/lldb-mi/MICmdCmdVar.h b/tools/lldb-mi/MICmdCmdVar.h
index 9f5ad1c3a11c..a6790877346f 100644
--- a/tools/lldb-mi/MICmdCmdVar.h
+++ b/tools/lldb-mi/MICmdCmdVar.h
@@ -41,32 +41,29 @@ class CMICmnLLDBDebugSessionInfoVarObj;
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "var-create".
-// Gotchas: None.
-// Authors: Illya Rudkin 24/03/2014.
-// Changes: None.
//--
class CMICmdCmdVarCreate : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdVarCreate(void);
+ /* ctor */ CMICmdCmdVarCreate();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// Overridden:
public:
// From CMICmnBase
- /* dtor */ ~CMICmdCmdVarCreate(void) override;
+ /* dtor */ ~CMICmdCmdVarCreate() override;
// Methods:
private:
@@ -81,9 +78,6 @@ class CMICmdCmdVarCreate : public CMICmdBase
bool m_bValid; // True = Variable is valid, false = not valid
CMIUtilString m_strExpression;
CMIUtilString m_strValue;
- const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option
- const CMIUtilString m_constStrArgThreadGroup; // Not specified in MI spec but Eclipse gives this option
- const CMIUtilString m_constStrArgFrame; // Not specified in MI spec but Eclipse gives this option
const CMIUtilString m_constStrArgName;
const CMIUtilString m_constStrArgFrameAddr;
const CMIUtilString m_constStrArgExpression;
@@ -92,37 +86,34 @@ class CMICmdCmdVarCreate : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "var-update".
-// Gotchas: None.
-// Authors: Illya Rudkin 25/03/2014.
-// Changes: None.
//--
class CMICmdCmdVarUpdate : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdVarUpdate(void);
+ /* ctor */ CMICmdCmdVarUpdate();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// Overridden:
public:
// From CMICmnBase
- /* dtor */ ~CMICmdCmdVarUpdate(void) override;
+ /* dtor */ ~CMICmdCmdVarUpdate() override;
// Methods:
private:
bool ExamineSBValueForChange(lldb::SBValue &vrwValue, bool &vrwbChanged);
- bool MIFormResponse(const CMIUtilString &vrStrVarName, const char *const vpValue, const CMIUtilString &vrStrScope);
+ void MIFormResponse(const CMIUtilString &vrStrVarName, const char *const vpValue, const CMIUtilString &vrStrScope);
// Attribute:
private:
@@ -135,29 +126,26 @@ class CMICmdCmdVarUpdate : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "var-delete".
-// Gotchas: None.
-// Authors: Illya Rudkin 25/03/2014.
-// Changes: None.
//--
class CMICmdCmdVarDelete : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdVarDelete(void);
+ /* ctor */ CMICmdCmdVarDelete();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdVarDelete(void) override;
+ /* dtor */ ~CMICmdCmdVarDelete() override;
// Attribute:
private:
@@ -167,29 +155,26 @@ class CMICmdCmdVarDelete : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "var-assign".
-// Gotchas: None.
-// Authors: Illya Rudkin 25/03/2014.
-// Changes: None.
//--
class CMICmdCmdVarAssign : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdVarAssign(void);
+ /* ctor */ CMICmdCmdVarAssign();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdVarAssign(void) override;
+ /* dtor */ ~CMICmdCmdVarAssign() override;
// Attributes:
private:
@@ -202,29 +187,26 @@ class CMICmdCmdVarAssign : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "var-set-format".
-// Gotchas: None.
-// Authors: Illya Rudkin 26/03/2014.
-// Changes: None.
//--
class CMICmdCmdVarSetFormat : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdVarSetFormat(void);
+ /* ctor */ CMICmdCmdVarSetFormat();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdVarSetFormat(void) override;
+ /* dtor */ ~CMICmdCmdVarSetFormat() override;
// Attributes:
private:
@@ -236,29 +218,26 @@ class CMICmdCmdVarSetFormat : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "var-list-children".
-// Gotchas: None.
-// Authors: Illya Rudkin 26/03/2014.
-// Changes: None.
//--
class CMICmdCmdVarListChildren : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdVarListChildren(void);
+ /* ctor */ CMICmdCmdVarListChildren();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdVarListChildren(void) override;
+ /* dtor */ ~CMICmdCmdVarListChildren() override;
// Attributes:
private:
@@ -275,29 +254,26 @@ class CMICmdCmdVarListChildren : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "var-evaluate-expression".
-// Gotchas: None.
-// Authors: Illya Rudkin 26/03/2014.
-// Changes: None.
//--
class CMICmdCmdVarEvaluateExpression : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdVarEvaluateExpression(void);
+ /* ctor */ CMICmdCmdVarEvaluateExpression();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdVarEvaluateExpression(void) override;
+ /* dtor */ ~CMICmdCmdVarEvaluateExpression() override;
// Attributes:
private:
@@ -310,29 +286,26 @@ class CMICmdCmdVarEvaluateExpression : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "var-info-path-expression".
-// Gotchas: None.
-// Authors: Illya Rudkin 26/03/2014.
-// Changes: None.
//--
class CMICmdCmdVarInfoPathExpression : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdVarInfoPathExpression(void);
+ /* ctor */ CMICmdCmdVarInfoPathExpression();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdVarInfoPathExpression(void) override;
+ /* dtor */ ~CMICmdCmdVarInfoPathExpression() override;
// Attributes:
private:
@@ -344,29 +317,26 @@ class CMICmdCmdVarInfoPathExpression : public CMICmdBase
//++ ============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "var-show-attributes".
-// Gotchas: None.
-// Authors: Illya Rudkin 19/05/2014.
-// Changes: None.
//--
class CMICmdCmdVarShowAttributes : public CMICmdBase
{
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf(void);
+ static CMICmdBase *CreateSelf();
// Methods:
public:
- /* ctor */ CMICmdCmdVarShowAttributes(void);
+ /* ctor */ CMICmdCmdVarShowAttributes();
// Overridden:
public:
// From CMICmdInvoker::ICmd
- bool Execute(void) override;
- bool Acknowledge(void) override;
- bool ParseArgs(void) override;
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
// From CMICmnBase
- /* dtor */ ~CMICmdCmdVarShowAttributes(void) override;
+ /* dtor */ ~CMICmdCmdVarShowAttributes() override;
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmdCommands.cpp b/tools/lldb-mi/MICmdCommands.cpp
index 90a5d651f2af..e97cc72f0770 100644
--- a/tools/lldb-mi/MICmdCommands.cpp
+++ b/tools/lldb-mi/MICmdCommands.cpp
@@ -41,7 +41,7 @@
namespace MICmnCommands
{
-template <typename T> static bool Register(void);
+template <typename T> static bool Register();
}
//++ ------------------------------------------------------------------------------------
@@ -53,7 +53,7 @@ template <typename T> static bool Register(void);
//--
template <typename T>
static bool
-MICmnCommands::Register(void)
+MICmnCommands::Register()
{
static CMICmdFactory &rCmdFactory = CMICmdFactory::Instance();
const CMIUtilString strMiCmd = T().GetMiCmd();
@@ -70,7 +70,7 @@ MICmnCommands::Register(void)
// Throws: None.
//--
bool
-MICmnCommands::RegisterAll(void)
+MICmnCommands::RegisterAll()
{
bool bOk = MIstatus::success;
diff --git a/tools/lldb-mi/MICmdCommands.h b/tools/lldb-mi/MICmdCommands.h
index a99d09c8057a..27f128ef4bd4 100644
--- a/tools/lldb-mi/MICmdCommands.h
+++ b/tools/lldb-mi/MICmdCommands.h
@@ -15,9 +15,6 @@ namespace MICmnCommands
//++ ============================================================================
// Details: MI Command are instantiated and registered automatically with the
// Command Factory
-// Gotchas: None.
-// Authors: Illya Rudkin 18/02/2014.
-// Changes: None.
//--
-bool RegisterAll(void);
+bool RegisterAll();
}
diff --git a/tools/lldb-mi/MICmdData.h b/tools/lldb-mi/MICmdData.h
index d58de903a68f..dcd5754617f5 100644
--- a/tools/lldb-mi/MICmdData.h
+++ b/tools/lldb-mi/MICmdData.h
@@ -15,18 +15,15 @@
//++ ============================================================================
// Details: MI command metadata. Holds the command's name, MI number and options
// as found on stdin. Holds the command's MI output (written to stdout).
-// Gotchas: None.
-// Authors: Illya Rudkin 18/02/2014.
-// Changes: None.
//--
struct SMICmdData
{
- SMICmdData(void)
+ SMICmdData()
: id(0)
, bCmdValid(false)
, bCmdExecutedSuccessfully(false)
, bMIOldStyle(false)
- , bHasResultRecordExtra(false){};
+ , bHasResultRecordExtra(false){}
MIuint id; // A command's unique ID i.e. GUID
CMIUtilString strMiCmdToken; // The command's MI token (a number)
@@ -43,7 +40,7 @@ struct SMICmdData
bHasResultRecordExtra; // True = Yes command produced additional MI output to its 1 line response, false = no extra MI output formed
void
- Clear(void)
+ Clear()
{
id = 0;
strMiCmdToken.clear();
diff --git a/tools/lldb-mi/MICmdFactory.cpp b/tools/lldb-mi/MICmdFactory.cpp
index 717a497a96be..e2a8b5bc2cae 100644
--- a/tools/lldb-mi/MICmdFactory.cpp
+++ b/tools/lldb-mi/MICmdFactory.cpp
@@ -21,7 +21,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdFactory::CMICmdFactory(void)
+CMICmdFactory::CMICmdFactory()
{
}
@@ -32,7 +32,7 @@ CMICmdFactory::CMICmdFactory(void)
// Return: None.
// Throws: None.
//--
-CMICmdFactory::~CMICmdFactory(void)
+CMICmdFactory::~CMICmdFactory()
{
Shutdown();
}
@@ -46,7 +46,7 @@ CMICmdFactory::~CMICmdFactory(void)
// Throws: None.
//--
bool
-CMICmdFactory::Initialize(void)
+CMICmdFactory::Initialize()
{
m_clientUsageRefCnt++;
@@ -69,7 +69,7 @@ CMICmdFactory::Initialize(void)
// Throws: None.
//--
bool
-CMICmdFactory::Shutdown(void)
+CMICmdFactory::Shutdown()
{
if (--m_clientUsageRefCnt > 0)
return MIstatus::success;
@@ -194,8 +194,6 @@ CMICmdFactory::CmdExist(const CMIUtilString &vMiCmd) const
bool
CMICmdFactory::CmdCreate(const CMIUtilString &vMiCmd, const SMICmdData &vCmdData, CMICmdBase *&vpNewCmd)
{
- bool bOk = MIstatus::success;
-
vpNewCmd = nullptr;
if (!IsValid(vMiCmd))
@@ -217,9 +215,8 @@ CMICmdFactory::CmdCreate(const CMIUtilString &vMiCmd, const SMICmdData &vCmdData
SMICmdData cmdData(vCmdData);
cmdData.id = pCmd->GetGUID();
- bOk = pCmd->SetCmdData(cmdData);
- if (bOk)
- vpNewCmd = pCmd;
+ pCmd->SetCmdData(cmdData);
+ vpNewCmd = pCmd;
- return bOk;
+ return MIstatus::success;
}
diff --git a/tools/lldb-mi/MICmdFactory.h b/tools/lldb-mi/MICmdFactory.h
index 9a5e07690a34..99f6f0cb2396 100644
--- a/tools/lldb-mi/MICmdFactory.h
+++ b/tools/lldb-mi/MICmdFactory.h
@@ -25,9 +25,6 @@ struct SMICmdData;
// MI application understands to interpret. Creates commands objects.
// The Command Factory is carried out in the main thread.
// A singleton class.
-// Gotchas: None.
-// Authors: Illya Rudkin 19/02/2014.
-// Changes: None.
//--
class CMICmdFactory : public CMICmnBase, public MI::ISingleton<CMICmdFactory>
{
@@ -35,7 +32,7 @@ class CMICmdFactory : public CMICmnBase, public MI::ISingleton<CMICmdFactory>
// Typedefs:
public:
- typedef CMICmdBase *(*CmdCreatorFnPtr)(void);
+ typedef CMICmdBase *(*CmdCreatorFnPtr)();
// Class:
public:
@@ -45,25 +42,25 @@ class CMICmdFactory : public CMICmnBase, public MI::ISingleton<CMICmdFactory>
class ICmd
{
public:
- virtual const CMIUtilString &GetMiCmd(void) const = 0;
- virtual CmdCreatorFnPtr GetCmdCreatorFn(void) const = 0;
+ virtual const CMIUtilString &GetMiCmd() const = 0;
+ virtual CmdCreatorFnPtr GetCmdCreatorFn() const = 0;
// virtual CMICmdBase * CreateSelf( void ) = 0; // Not possible as require a static creator
// function in the command class, here for awareness
- /* dtor */ virtual ~ICmd(void){};
+ /* dtor */ virtual ~ICmd(){}
};
// Methods:
public:
- bool Initialize(void) override;
- bool Shutdown(void) override;
+ bool Initialize() override;
+ bool Shutdown() override;
bool CmdRegister(const CMIUtilString &vMiCmd, CmdCreatorFnPtr vCmdCreateFn);
bool CmdCreate(const CMIUtilString &vMiCmd, const SMICmdData &vCmdData, CMICmdBase *&vpNewCmd);
bool CmdExist(const CMIUtilString &vMiCmd) const;
// Methods:
private:
- /* ctor */ CMICmdFactory(void);
+ /* ctor */ CMICmdFactory();
/* ctor */ CMICmdFactory(const CMICmdFactory &);
void operator=(const CMICmdFactory &);
@@ -73,7 +70,7 @@ class CMICmdFactory : public CMICmnBase, public MI::ISingleton<CMICmdFactory>
// Overridden:
private:
// From CMICmnBase
- /* dtor */ ~CMICmdFactory(void) override;
+ /* dtor */ ~CMICmdFactory() override;
// Typedefs:
private:
diff --git a/tools/lldb-mi/MICmdInterpreter.cpp b/tools/lldb-mi/MICmdInterpreter.cpp
index 3c5285fc8cc8..1abcc9a3f427 100644
--- a/tools/lldb-mi/MICmdInterpreter.cpp
+++ b/tools/lldb-mi/MICmdInterpreter.cpp
@@ -18,7 +18,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdInterpreter::CMICmdInterpreter(void)
+CMICmdInterpreter::CMICmdInterpreter()
: m_rCmdFactory(CMICmdFactory::Instance())
{
}
@@ -30,7 +30,7 @@ CMICmdInterpreter::CMICmdInterpreter(void)
// Return: None.
// Throws: None.
//--
-CMICmdInterpreter::~CMICmdInterpreter(void)
+CMICmdInterpreter::~CMICmdInterpreter()
{
Shutdown();
}
@@ -44,7 +44,7 @@ CMICmdInterpreter::~CMICmdInterpreter(void)
// Throws: None.
//--
bool
-CMICmdInterpreter::Initialize(void)
+CMICmdInterpreter::Initialize()
{
m_clientUsageRefCnt++;
@@ -65,7 +65,7 @@ CMICmdInterpreter::Initialize(void)
// Throws: None.
//--
bool
-CMICmdInterpreter::Shutdown(void)
+CMICmdInterpreter::Shutdown()
{
if (--m_clientUsageRefCnt > 0)
return MIstatus::success;
@@ -160,10 +160,10 @@ CMICmdInterpreter::MiHasCmdTokenEndingHyphen(const CMIUtilString &vTextLine)
if (MiHasCmdTokenPresent(vTextLine))
{
const std::string strNum = vTextLine.substr(0, nPos);
- if (!CMIUtilString(strNum.c_str()).IsNumber())
+ if (!CMIUtilString(strNum).IsNumber())
return false;
- m_miCmdData.strMiCmdToken = strNum.c_str();
+ m_miCmdData.strMiCmdToken = strNum;
}
m_miCmdData.bMIOldStyle = false;
@@ -256,20 +256,20 @@ CMICmdInterpreter::MiHasCmd(const CMIUtilString &vTextLine)
{
if (nPos2 == nLen)
return false;
- const CMIUtilString cmd = CMIUtilString(vTextLine.substr(nPos + 1, nPos2 - nPos - 1).c_str());
+ const CMIUtilString cmd = CMIUtilString(vTextLine.substr(nPos + 1, nPos2 - nPos - 1));
if (cmd.empty())
return false;
m_miCmdData.strMiCmd = cmd;
if (nPos2 < nLen)
- m_miCmdData.strMiCmdOption = CMIUtilString(vTextLine.substr(nPos2 + 1, nLen - nPos2 - 1).c_str());
+ m_miCmdData.strMiCmdOption = CMIUtilString(vTextLine.substr(nPos2 + 1, nLen - nPos2 - 1));
bFoundCmd = true;
}
else
{
- const CMIUtilString cmd = CMIUtilString(vTextLine.substr(nPos + 1, nLen - nPos - 1).c_str());
+ const CMIUtilString cmd = CMIUtilString(vTextLine.substr(nPos + 1, nLen - nPos - 1));
if (cmd.empty())
return false;
m_miCmdData.strMiCmd = cmd;
@@ -291,7 +291,7 @@ CMICmdInterpreter::MiHasCmd(const CMIUtilString &vTextLine)
// Throws: None.
//--
const SMICmdData &
-CMICmdInterpreter::MiGetCmdData(void) const
+CMICmdInterpreter::MiGetCmdData() const
{
return m_miCmdData;
}
diff --git a/tools/lldb-mi/MICmdInterpreter.h b/tools/lldb-mi/MICmdInterpreter.h
index e24308484d23..5aa9445c97c0 100644
--- a/tools/lldb-mi/MICmdInterpreter.h
+++ b/tools/lldb-mi/MICmdInterpreter.h
@@ -23,9 +23,6 @@ class CMICmdFactory;
// matches Machine Interface (MI) format and commands defined in the
// MI application.
// A singleton class.
-// Gotchas: None.
-// Authors: Illya Rudkin 18/02/2014.
-// Changes: None.
//--
class CMICmdInterpreter : public CMICmnBase, public MI::ISingleton<CMICmdInterpreter>
{
@@ -35,13 +32,13 @@ class CMICmdInterpreter : public CMICmnBase, public MI::ISingleton<CMICmdInterpr
public:
// Methods:
public:
- bool Initialize(void) override;
- bool Shutdown(void) override;
+ bool Initialize() override;
+ bool Shutdown() override;
bool ValidateIsMi(const CMIUtilString &vTextLine, bool &vwbYesValid, bool &vwbCmdNotInCmdFactor, SMICmdData &rwCmdData);
// Methods:
private:
- /* ctor */ CMICmdInterpreter(void);
+ /* ctor */ CMICmdInterpreter();
/* ctor */ CMICmdInterpreter(const CMICmdInterpreter &);
void operator=(const CMICmdInterpreter &);
@@ -55,7 +52,7 @@ class CMICmdInterpreter : public CMICmnBase, public MI::ISingleton<CMICmdInterpr
// Overridden:
private:
// From CMICmnBase
- /* dtor */ ~CMICmdInterpreter(void) override;
+ /* dtor */ ~CMICmdInterpreter() override;
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmdInvoker.cpp b/tools/lldb-mi/MICmdInvoker.cpp
index 9f82e92dc4bb..124a82d162e7 100644
--- a/tools/lldb-mi/MICmdInvoker.cpp
+++ b/tools/lldb-mi/MICmdInvoker.cpp
@@ -22,7 +22,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdInvoker::CMICmdInvoker(void)
+CMICmdInvoker::CMICmdInvoker()
: m_rStreamOut(CMICmnStreamStdout::Instance())
{
}
@@ -34,7 +34,7 @@ CMICmdInvoker::CMICmdInvoker(void)
// Return: None.
// Throws: None.
//--
-CMICmdInvoker::~CMICmdInvoker(void)
+CMICmdInvoker::~CMICmdInvoker()
{
Shutdown();
}
@@ -48,7 +48,7 @@ CMICmdInvoker::~CMICmdInvoker(void)
// Throws: None.
//--
bool
-CMICmdInvoker::Initialize(void)
+CMICmdInvoker::Initialize()
{
m_clientUsageRefCnt++;
@@ -69,7 +69,7 @@ CMICmdInvoker::Initialize(void)
// Throws: None.
//--
bool
-CMICmdInvoker::Shutdown(void)
+CMICmdInvoker::Shutdown()
{
if (--m_clientUsageRefCnt > 0)
return MIstatus::success;
@@ -92,7 +92,7 @@ CMICmdInvoker::Shutdown(void)
// Throws: None.
//--
void
-CMICmdInvoker::CmdDeleteAll(void)
+CMICmdInvoker::CmdDeleteAll()
{
CMICmdMgr &rMgr = CMICmdMgr::Instance();
MapCmdIdToCmd_t::const_iterator it = m_mapCmdIdToCmd.begin();
@@ -189,16 +189,20 @@ CMICmdInvoker::CmdExecute(CMICmdBase &vCmd)
{
bool bOk = CmdAdd(vCmd);
- if (bOk && !vCmd.ParseArgs())
+ if (bOk)
{
- // Report command execution failed
- const SMICmdData cmdData(vCmd.GetCmdData());
- CmdStdout(cmdData);
- CmdCauseAppExit(vCmd);
- CmdDelete(cmdData.id);
-
- // Proceed to wait or execute next command
- return MIstatus::success;
+ vCmd.AddCommonArgs();
+ if (!vCmd.ParseArgs())
+ {
+ // Report command execution failed
+ const SMICmdData cmdData(vCmd.GetCmdData());
+ CmdStdout(cmdData);
+ CmdCauseAppExit(vCmd);
+ CmdDelete(cmdData.id);
+
+ // Proceed to wait or execute next command
+ return MIstatus::success;
+ }
}
if (bOk && !vCmd.Execute())
diff --git a/tools/lldb-mi/MICmdInvoker.h b/tools/lldb-mi/MICmdInvoker.h
index b178d4322577..d70a5296c9f3 100644
--- a/tools/lldb-mi/MICmdInvoker.h
+++ b/tools/lldb-mi/MICmdInvoker.h
@@ -36,9 +36,6 @@ class CMICmnStreamStdout;
// The Invoker takes ownership of any commands created which means it
// is the only object to delete them when a command is finished working.
// A singleton class.
-// Gotchas: None.
-// Authors: Illya Rudkin 19/02/2014.
-// Changes: None.
//--
class CMICmdInvoker : public CMICmnBase, public CMICmdMgrSetCmdDeleteCallback::ICallback, public MI::ISingleton<CMICmdInvoker>
{
@@ -52,24 +49,24 @@ class CMICmdInvoker : public CMICmnBase, public CMICmdMgrSetCmdDeleteCallback::I
class ICmd
{
public:
- virtual bool Acknowledge(void) = 0;
- virtual bool Execute(void) = 0;
- virtual bool ParseArgs(void) = 0;
- virtual bool SetCmdData(const SMICmdData &vCmdData) = 0;
- virtual const SMICmdData &GetCmdData(void) const = 0;
- virtual const CMIUtilString &GetErrorDescription(void) const = 0;
- virtual void CmdFinishedTellInvoker(void) const = 0;
- virtual const CMIUtilString &GetMIResultRecord(void) const = 0;
- virtual const CMIUtilString &GetMIResultRecordExtra(void) const = 0;
- virtual bool HasMIResultRecordExtra(void) const = 0;
+ virtual bool Acknowledge() = 0;
+ virtual bool Execute() = 0;
+ virtual bool ParseArgs() = 0;
+ virtual void SetCmdData(const SMICmdData &vCmdData) = 0;
+ virtual const SMICmdData &GetCmdData() const = 0;
+ virtual const CMIUtilString &GetErrorDescription() const = 0;
+ virtual void CmdFinishedTellInvoker() const = 0;
+ virtual const CMIUtilString &GetMIResultRecord() const = 0;
+ virtual const CMIUtilString &GetMIResultRecordExtra() const = 0;
+ virtual bool HasMIResultRecordExtra() const = 0;
- /* dtor */ virtual ~ICmd(void){};
+ /* dtor */ virtual ~ICmd(){}
};
// Methods:
public:
- bool Initialize(void) override;
- bool Shutdown(void) override;
+ bool Initialize() override;
+ bool Shutdown() override;
bool CmdExecute(CMICmdBase &vCmd);
bool CmdExecuteFinished(CMICmdBase &vCmd);
@@ -80,10 +77,10 @@ class CMICmdInvoker : public CMICmnBase, public CMICmdMgrSetCmdDeleteCallback::I
// Methods:
private:
- /* ctor */ CMICmdInvoker(void);
+ /* ctor */ CMICmdInvoker();
/* ctor */ CMICmdInvoker(const CMICmdInvoker &);
void operator=(const CMICmdInvoker &);
- void CmdDeleteAll(void);
+ void CmdDeleteAll();
bool CmdDelete(const MIuint vCmdId, const bool vbYesDeleteCmd = false);
bool CmdAdd(const CMICmdBase &vCmd);
bool CmdStdout(const SMICmdData &vCmdData) const;
@@ -92,7 +89,7 @@ class CMICmdInvoker : public CMICmnBase, public CMICmdMgrSetCmdDeleteCallback::I
// Overridden:
private:
// From CMICmnBase
- /* dtor */ ~CMICmdInvoker(void) override;
+ /* dtor */ ~CMICmdInvoker() override;
// From CMICmdMgrSetCmdDeleteCallback::ICallback
void Delete(SMICmdData &vCmd) override;
diff --git a/tools/lldb-mi/MICmdMgr.cpp b/tools/lldb-mi/MICmdMgr.cpp
index 76dbff69dbe7..449be44e1152 100644
--- a/tools/lldb-mi/MICmdMgr.cpp
+++ b/tools/lldb-mi/MICmdMgr.cpp
@@ -25,7 +25,7 @@
// Return: None.
// Throws: None.
//--
-CMICmdMgr::CMICmdMgr(void)
+CMICmdMgr::CMICmdMgr()
: m_interpretor(CMICmdInterpreter::Instance())
, m_factory(CMICmdFactory::Instance())
, m_invoker(CMICmdInvoker::Instance())
@@ -39,7 +39,7 @@ CMICmdMgr::CMICmdMgr(void)
// Return: None.
// Throws: None.
//--
-CMICmdMgr::~CMICmdMgr(void)
+CMICmdMgr::~CMICmdMgr()
{
Shutdown();
}
@@ -53,7 +53,7 @@ CMICmdMgr::~CMICmdMgr(void)
// Throws: None.
//--
bool
-CMICmdMgr::Initialize(void)
+CMICmdMgr::Initialize()
{
m_clientUsageRefCnt++;
@@ -102,7 +102,7 @@ CMICmdMgr::Initialize(void)
// Throws: None.
//--
bool
-CMICmdMgr::Shutdown(void)
+CMICmdMgr::Shutdown()
{
if (--m_clientUsageRefCnt > 0)
return MIstatus::success;
diff --git a/tools/lldb-mi/MICmdMgr.h b/tools/lldb-mi/MICmdMgr.h
index 4956d5c3a376..31363594a9de 100644
--- a/tools/lldb-mi/MICmdMgr.h
+++ b/tools/lldb-mi/MICmdMgr.h
@@ -30,9 +30,6 @@ class CMICmdBase;
// Command Invoker, Command Factory and Command Monitor while independent
// units are overseen/managed by *this manager.
// A singleton class.
-// Gotchas: None.
-// Authors: Illya Rudkin 19/02/2014.
-// Changes: None.
//--
class CMICmdMgr : public CMICmnBase, public MI::ISingleton<CMICmdMgr>
{
@@ -40,8 +37,8 @@ class CMICmdMgr : public CMICmnBase, public MI::ISingleton<CMICmdMgr>
// Methods:
public:
- bool Initialize(void) override;
- bool Shutdown(void) override;
+ bool Initialize() override;
+ bool Shutdown() override;
bool CmdInterpret(const CMIUtilString &vTextLine, bool &vwbYesValid, bool &vwbCmdNotInCmdFactor, SMICmdData &rwCmdData);
bool CmdExecute(const SMICmdData &vCmdData);
@@ -51,14 +48,14 @@ class CMICmdMgr : public CMICmnBase, public MI::ISingleton<CMICmdMgr>
// Methods:
private:
- /* ctor */ CMICmdMgr(void);
+ /* ctor */ CMICmdMgr();
/* ctor */ CMICmdMgr(const CMICmdMgr &);
void operator=(const CMICmdMgr &);
// Overridden:
public:
// From CMICmnBase
- /* dtor */ ~CMICmdMgr(void) override;
+ /* dtor */ ~CMICmdMgr() override;
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.cpp b/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.cpp
index 3f2ccfd10ce6..3bef535390f7 100644
--- a/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.cpp
+++ b/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.cpp
@@ -20,7 +20,7 @@ namespace CMICmdMgrSetCmdDeleteCallback
// Return: None.
// Throws: None.
//--
-CSetClients::CSetClients(void)
+CSetClients::CSetClients()
: m_bClientUnregistered(false)
{
}
@@ -32,7 +32,7 @@ CSetClients::CSetClients(void)
// Return: None.
// Throws: None.
//--
-CSetClients::~CSetClients(void)
+CSetClients::~CSetClients()
{
}
diff --git a/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.h b/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.h
index 1c9be826c516..7e95d67d8716 100644
--- a/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.h
+++ b/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.h
@@ -28,16 +28,13 @@ namespace CMICmdMgrSetCmdDeleteCallback
// inherit this interface and register interest in command object
// deletion. An object deleting a command must not do it itself but call
// the Command Manager CmdDelete() function to delete a command object.
-// Gotchas: None.
-// Authors: Illya Rudkin 21/02/2014.
-// Changes: None.
//--
class ICallback
{
public:
virtual void Delete(SMICmdData &vCmd) = 0;
- /* dtor */ virtual ~ICallback(void){};
+ /* dtor */ virtual ~ICallback(){}
};
//++ ============================================================================
@@ -47,15 +44,12 @@ class ICallback
// Manager to delete the command object. In so do all other registered
// objects get called to about the deletion including the object wanting
// to do the delete in the first place.
-// Gotchas: None.
-// Authors: Illya Rudkin 21/02/2014.
-// Changes: None.
//--
class CSetClients : public std::set<class ICallback *>, public CMICmnBase
{
// Methods:
public:
- /* ctor */ CSetClients(void);
+ /* ctor */ CSetClients();
bool Register(class ICallback &vObject);
bool Unregister(class ICallback &vObject);
@@ -64,7 +58,7 @@ class CSetClients : public std::set<class ICallback *>, public CMICmnBase
// Overridden:
public:
// From CMICmnBase
- /* dtor */ ~CSetClients(void) override;
+ /* dtor */ ~CSetClients() override;
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmnBase.cpp b/tools/lldb-mi/MICmnBase.cpp
index 0d9eda70f0b0..1240df7802d2 100644
--- a/tools/lldb-mi/MICmnBase.cpp
+++ b/tools/lldb-mi/MICmnBase.cpp
@@ -22,7 +22,7 @@
// Return: None.
// Throws: None.
//--
-CMICmnBase::CMICmnBase(void)
+CMICmnBase::CMICmnBase()
: m_strMILastErrorDescription(CMIUtilString())
, m_bInitialized(false)
, m_pLog(&CMICmnLog::Instance())
@@ -37,7 +37,7 @@ CMICmnBase::CMICmnBase(void)
// Return: None.
// Throws: None.
//--
-CMICmnBase::~CMICmnBase(void)
+CMICmnBase::~CMICmnBase()
{
m_pLog = NULL;
}
@@ -50,7 +50,7 @@ CMICmnBase::~CMICmnBase(void)
// Throws: None.
//--
bool
-CMICmnBase::HaveErrorDescription(void) const
+CMICmnBase::HaveErrorDescription() const
{
return m_strMILastErrorDescription.empty();
}
@@ -63,7 +63,7 @@ CMICmnBase::HaveErrorDescription(void) const
// Throws: None.
//--
const CMIUtilString &
-CMICmnBase::GetErrorDescription(void) const
+CMICmnBase::GetErrorDescription() const
{
return m_strMILastErrorDescription;
}
@@ -111,7 +111,7 @@ CMICmnBase::SetErrorDescriptionNoLog(const CMIUtilString &vrTxt) const
// Throws: None.
//--
void
-CMICmnBase::ClrErrorDescription(void) const
+CMICmnBase::ClrErrorDescription() const
{
m_strMILastErrorDescription.clear();
}
diff --git a/tools/lldb-mi/MICmnBase.h b/tools/lldb-mi/MICmnBase.h
index d2e2bcdf10d2..befadbeeba88 100644
--- a/tools/lldb-mi/MICmnBase.h
+++ b/tools/lldb-mi/MICmnBase.h
@@ -18,26 +18,23 @@ class CMICmnLog;
//++ ============================================================================
// Details: MI common code implementation base class.
-// Gotchas: None.
-// Authors: Illya Rudkin 28/01/2014.
-// Changes: None.
//--
class CMICmnBase
{
// Methods:
public:
- /* ctor */ CMICmnBase(void);
+ /* ctor */ CMICmnBase();
- bool HaveErrorDescription(void) const;
- const CMIUtilString &GetErrorDescription(void) const;
+ bool HaveErrorDescription() const;
+ const CMIUtilString &GetErrorDescription() const;
void SetErrorDescription(const CMIUtilString &vrTxt) const;
void SetErrorDescriptionn(const CMIUtilString vFormat, ...) const;
void SetErrorDescriptionNoLog(const CMIUtilString &vrTxt) const;
- void ClrErrorDescription(void) const;
+ void ClrErrorDescription() const;
// Overrideable:
public:
- /* dtor */ virtual ~CMICmnBase(void);
+ /* dtor */ virtual ~CMICmnBase();
// Attributes:
protected:
diff --git a/tools/lldb-mi/MICmnLLDBBroadcaster.cpp b/tools/lldb-mi/MICmnLLDBBroadcaster.cpp
index 8bad24313b78..1d51abd1320d 100644
--- a/tools/lldb-mi/MICmnLLDBBroadcaster.cpp
+++ b/tools/lldb-mi/MICmnLLDBBroadcaster.cpp
@@ -17,7 +17,7 @@
// Return: None.
// Throws: None.
//--
-CMICmnLLDBBroadcaster::CMICmnLLDBBroadcaster(void)
+CMICmnLLDBBroadcaster::CMICmnLLDBBroadcaster()
: lldb::SBBroadcaster("MI driver")
{
}
@@ -29,7 +29,7 @@ CMICmnLLDBBroadcaster::CMICmnLLDBBroadcaster(void)
// Return: None.
// Throws: None.
//--
-CMICmnLLDBBroadcaster::~CMICmnLLDBBroadcaster(void)
+CMICmnLLDBBroadcaster::~CMICmnLLDBBroadcaster()
{
Shutdown();
}
@@ -43,7 +43,7 @@ CMICmnLLDBBroadcaster::~CMICmnLLDBBroadcaster(void)
// Throws: None.
//--
bool
-CMICmnLLDBBroadcaster::Initialize(void)
+CMICmnLLDBBroadcaster::Initialize()
{
m_clientUsageRefCnt++;
@@ -64,7 +64,7 @@ CMICmnLLDBBroadcaster::Initialize(void)
// Throws: None.
//--
bool
-CMICmnLLDBBroadcaster::Shutdown(void)
+CMICmnLLDBBroadcaster::Shutdown()
{
if (--m_clientUsageRefCnt > 0)
return MIstatus::success;
diff --git a/tools/lldb-mi/MICmnLLDBBroadcaster.h b/tools/lldb-mi/MICmnLLDBBroadcaster.h
index dc0de47d3bb3..09b95f482a79 100644
--- a/tools/lldb-mi/MICmnLLDBBroadcaster.h
+++ b/tools/lldb-mi/MICmnLLDBBroadcaster.h
@@ -21,9 +21,6 @@
// *** not
//
// A singleton class.
-// Gotchas: None.
-// Authors: Illya Rudkin 28/02/2014.
-// Changes: None.
//--
class CMICmnLLDBBroadcaster : public CMICmnBase, public lldb::SBBroadcaster, public MI::ISingleton<CMICmnLLDBBroadcaster>
{
@@ -31,16 +28,16 @@ class CMICmnLLDBBroadcaster : public CMICmnBase, public lldb::SBBroadcaster, pub
// Methods:
public:
- bool Initialize(void) override;
- bool Shutdown(void) override;
+ bool Initialize() override;
+ bool Shutdown() override;
// Methods:
private:
- /* ctor */ CMICmnLLDBBroadcaster(void);
+ /* ctor */ CMICmnLLDBBroadcaster();
/* ctor */ CMICmnLLDBBroadcaster(const CMICmnLLDBBroadcaster &);
void operator=(const CMICmnLLDBBroadcaster &);
// Overridden:
private:
// From CMICmnBase
- /* dtor */ ~CMICmnLLDBBroadcaster(void) override;
+ /* dtor */ ~CMICmnLLDBBroadcaster() override;
};
diff --git a/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp b/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
index cf74fe58fbd9..ef99ac9a4207 100644
--- a/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
+++ b/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
@@ -35,7 +35,7 @@
// Return: None.
// Throws: None.
//--
-CMICmnLLDBDebugSessionInfo::CMICmnLLDBDebugSessionInfo(void)
+CMICmnLLDBDebugSessionInfo::CMICmnLLDBDebugSessionInfo()
: m_nBrkPointCntMax(INT32_MAX)
, m_currentSelectedThread(LLDB_INVALID_THREAD_ID)
, m_constStrSharedDataKeyWkDir("Working Directory")
@@ -53,7 +53,7 @@ CMICmnLLDBDebugSessionInfo::CMICmnLLDBDebugSessionInfo(void)
// Return: None.
// Throws: None.
//--
-CMICmnLLDBDebugSessionInfo::~CMICmnLLDBDebugSessionInfo(void)
+CMICmnLLDBDebugSessionInfo::~CMICmnLLDBDebugSessionInfo()
{
Shutdown();
}
@@ -67,7 +67,7 @@ CMICmnLLDBDebugSessionInfo::~CMICmnLLDBDebugSessionInfo(void)
// Throws: None.
//--
bool
-CMICmnLLDBDebugSessionInfo::Initialize(void)
+CMICmnLLDBDebugSessionInfo::Initialize()
{
m_clientUsageRefCnt++;
@@ -91,7 +91,7 @@ CMICmnLLDBDebugSessionInfo::Initialize(void)
// Throws: None.
//--
bool
-CMICmnLLDBDebugSessionInfo::Shutdown(void)
+CMICmnLLDBDebugSessionInfo::Shutdown()
{
if (--m_clientUsageRefCnt > 0)
return MIstatus::success;
@@ -99,16 +99,9 @@ CMICmnLLDBDebugSessionInfo::Shutdown(void)
if (!m_bInitialized)
return MIstatus::success;
- bool bOk = MIstatus::success;
- CMIUtilString errMsg;
-
// Tidy up
- bOk = SharedDataDestroy();
- if (!bOk)
- {
- errMsg = CMIUtilString::Format(MIRSRC(IDS_DBGSESSION_ERR_SHARED_DATA_RELEASE));
- errMsg += "\n";
- }
+ SharedDataDestroy();
+
m_vecActiveThreadId.clear();
CMICmnLLDBDebugSessionInfoVarObj::VarObjClear();
@@ -125,18 +118,15 @@ CMICmnLLDBDebugSessionInfo::Shutdown(void)
// stopped i.e. application shutdown.
// Type: Method.
// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
+// Return: None.
// Throws: None.
//--
-bool
-CMICmnLLDBDebugSessionInfo::SharedDataDestroy(void)
+void
+CMICmnLLDBDebugSessionInfo::SharedDataDestroy()
{
m_mapIdToSessionData.Clear();
m_vecVarObj.clear();
m_mapBrkPtIdToBrkPtInfo.clear();
-
- return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
@@ -376,8 +366,7 @@ CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo(const SMICmdData &vCmdData,
const CMIUtilString strId(CMIUtilString::Format("%d", rThread.GetIndexID()));
const CMICmnMIValueConst miValueConst1(strId);
const CMICmnMIValueResult miValueResult1("id", miValueConst1);
- if (!vwrMIValueTuple.Add(miValueResult1))
- return MIstatus::failure;
+ vwrMIValueTuple.Add(miValueResult1);
// Add "target-id"
const char *pThreadName = rThread.GetName();
@@ -392,8 +381,7 @@ CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo(const SMICmdData &vCmdData,
strThread = CMIUtilString::Format(pThrdFmt, rThread.GetIndexID());
const CMICmnMIValueConst miValueConst2(strThread);
const CMICmnMIValueResult miValueResult2("target-id", miValueConst2);
- if (!vwrMIValueTuple.Add(miValueResult2))
- return MIstatus::failure;
+ vwrMIValueTuple.Add(miValueResult2);
// Add "frame"
if (veThreadInfoFormat != eThreadInfoFormat_NoFrames)
@@ -403,15 +391,13 @@ CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo(const SMICmdData &vCmdData,
return MIstatus::failure;
const CMICmnMIValueConst miValueConst3(strFrames, true);
- if (!vwrMIValueTuple.Add(miValueConst3, false))
- return MIstatus::failure;
+ vwrMIValueTuple.Add(miValueConst3, false);
}
// Add "state"
const CMICmnMIValueConst miValueConst4(strState);
const CMICmnMIValueResult miValueResult4("state", miValueConst4);
- if (!vwrMIValueTuple.Add(miValueResult4))
- return MIstatus::failure;
+ vwrMIValueTuple.Add(miValueResult4);
return MIstatus::success;
}
@@ -461,9 +447,8 @@ CMICmnLLDBDebugSessionInfo::MIResponseForVariableInfoInternal(const VariableInfo
const bool vbIsArgs,
const bool vbMarkArgs)
{
- bool bOk = MIstatus::success;
const MIuint nArgs = vwrSBValueList.GetSize();
- for (MIuint i = 0; bOk && (i < nArgs); i++)
+ for (MIuint i = 0; i < nArgs; i++)
{
CMICmnMIValueTuple miValueTuple;
lldb::SBValue value = vwrSBValueList.GetValueAtIndex(i);
@@ -514,7 +499,7 @@ CMICmnLLDBDebugSessionInfo::MIResponseForVariableInfoInternal(const VariableInfo
vwrMiValueList.Add(miValueResultName);
}
}
- return bOk;
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
@@ -567,17 +552,14 @@ CMICmnLLDBDebugSessionInfo::MIResponseFormFrameInfo(const lldb::SBThread &vrThre
const CMIUtilString strLevel(CMIUtilString::Format("%d", vnLevel));
const CMICmnMIValueConst miValueConst(strLevel);
const CMICmnMIValueResult miValueResult("level", miValueConst);
- if (!vwrMiValueTuple.Add(miValueResult))
- return MIstatus::failure;
+ vwrMiValueTuple.Add(miValueResult);
const CMIUtilString strAddr(CMIUtilString::Format("0x%016" PRIx64, pc));
const CMICmnMIValueConst miValueConst2(strAddr);
const CMICmnMIValueResult miValueResult2("addr", miValueConst2);
- if (!vwrMiValueTuple.Add(miValueResult2))
- return MIstatus::failure;
+ vwrMiValueTuple.Add(miValueResult2);
const CMICmnMIValueConst miValueConst3(fnName);
const CMICmnMIValueResult miValueResult3("func", miValueConst3);
- if (!vwrMiValueTuple.Add(miValueResult3))
- return MIstatus::failure;
+ vwrMiValueTuple.Add(miValueResult3);
if (veFrameInfoFormat != eFrameInfoFormat_NoArguments)
{
CMICmnMIValueList miValueList(true);
@@ -592,22 +574,18 @@ CMICmnLLDBDebugSessionInfo::MIResponseFormFrameInfo(const lldb::SBThread &vrThre
return MIstatus::failure;
const CMICmnMIValueResult miValueResult4("args", miValueList);
- if (!vwrMiValueTuple.Add(miValueResult4))
- return MIstatus::failure;
+ vwrMiValueTuple.Add(miValueResult4);
}
const CMICmnMIValueConst miValueConst5(fileName);
const CMICmnMIValueResult miValueResult5("file", miValueConst5);
- if (!vwrMiValueTuple.Add(miValueResult5))
- return MIstatus::failure;
+ vwrMiValueTuple.Add(miValueResult5);
const CMICmnMIValueConst miValueConst6(path);
const CMICmnMIValueResult miValueResult6("fullname", miValueConst6);
- if (!vwrMiValueTuple.Add(miValueResult6))
- return MIstatus::failure;
+ vwrMiValueTuple.Add(miValueResult6);
const CMIUtilString strLine(CMIUtilString::Format("%d", nLine));
const CMICmnMIValueConst miValueConst7(strLine);
const CMICmnMIValueResult miValueResult7("line", miValueConst7);
- if (!vwrMiValueTuple.Add(miValueResult7))
- return MIstatus::failure;
+ vwrMiValueTuple.Add(miValueResult7);
return MIstatus::success;
}
@@ -659,38 +637,30 @@ CMICmnLLDBDebugSessionInfo::GetFrameInfo(const lldb::SBFrame &vrFrame, lldb::add
// Type: Method.
// Args: vrBrkPtInfo - (R) Break point information object.
// vwrMIValueTuple - (W) MI value tuple object.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
+// Return: None.
// Throws: None.
//--
-bool
+void
CMICmnLLDBDebugSessionInfo::MIResponseFormBrkPtFrameInfo(const SBrkPtInfo &vrBrkPtInfo, CMICmnMIValueTuple &vwrMiValueTuple)
{
const CMIUtilString strAddr(CMIUtilString::Format("0x%016" PRIx64, vrBrkPtInfo.m_pc));
const CMICmnMIValueConst miValueConst2(strAddr);
const CMICmnMIValueResult miValueResult2("addr", miValueConst2);
- if (!vwrMiValueTuple.Add(miValueResult2))
- return MIstatus::failure;
+ vwrMiValueTuple.Add(miValueResult2);
const CMICmnMIValueConst miValueConst3(vrBrkPtInfo.m_fnName);
const CMICmnMIValueResult miValueResult3("func", miValueConst3);
- if (!vwrMiValueTuple.Add(miValueResult3))
- return MIstatus::failure;
+ vwrMiValueTuple.Add(miValueResult3);
const CMICmnMIValueConst miValueConst5(vrBrkPtInfo.m_fileName);
const CMICmnMIValueResult miValueResult5("file", miValueConst5);
- if (!vwrMiValueTuple.Add(miValueResult5))
- return MIstatus::failure;
+ vwrMiValueTuple.Add(miValueResult5);
const CMIUtilString strN5 = CMIUtilString::Format("%s/%s", vrBrkPtInfo.m_path.c_str(), vrBrkPtInfo.m_fileName.c_str());
const CMICmnMIValueConst miValueConst6(strN5);
const CMICmnMIValueResult miValueResult6("fullname", miValueConst6);
- if (!vwrMiValueTuple.Add(miValueResult6))
- return MIstatus::failure;
+ vwrMiValueTuple.Add(miValueResult6);
const CMIUtilString strLine(CMIUtilString::Format("%d", vrBrkPtInfo.m_nLine));
const CMICmnMIValueConst miValueConst7(strLine);
const CMICmnMIValueResult miValueResult7("line", miValueConst7);
- if (!vwrMiValueTuple.Add(miValueResult7))
- return MIstatus::failure;
-
- return MIstatus::success;
+ vwrMiValueTuple.Add(miValueResult7);
}
//++ ------------------------------------------------------------------------------------
@@ -716,65 +686,65 @@ CMICmnLLDBDebugSessionInfo::MIResponseFormBrkPtInfo(const SBrkPtInfo &vrBrkPtInf
// "type="
const CMICmnMIValueConst miValueConst2(vrBrkPtInfo.m_strType);
const CMICmnMIValueResult miValueResult2("type", miValueConst2);
- bool bOk = miValueTuple.Add(miValueResult2);
+ miValueTuple.Add(miValueResult2);
// "disp="
const CMICmnMIValueConst miValueConst3(vrBrkPtInfo.m_bDisp ? "del" : "keep");
const CMICmnMIValueResult miValueResult3("disp", miValueConst3);
- bOk = bOk && miValueTuple.Add(miValueResult3);
+ miValueTuple.Add(miValueResult3);
// "enabled="
const CMICmnMIValueConst miValueConst4(vrBrkPtInfo.m_bEnabled ? "y" : "n");
const CMICmnMIValueResult miValueResult4("enabled", miValueConst4);
- bOk = bOk && miValueTuple.Add(miValueResult4);
+ miValueTuple.Add(miValueResult4);
// "addr="
// "func="
// "file="
// "fullname="
// "line="
- bOk = bOk && MIResponseFormBrkPtFrameInfo(vrBrkPtInfo, miValueTuple);
+ MIResponseFormBrkPtFrameInfo(vrBrkPtInfo, miValueTuple);
// "pending="
if (vrBrkPtInfo.m_bPending)
{
const CMICmnMIValueConst miValueConst(vrBrkPtInfo.m_strOrigLoc);
const CMICmnMIValueList miValueList(miValueConst);
const CMICmnMIValueResult miValueResult("pending", miValueList);
- bOk = bOk && miValueTuple.Add(miValueResult);
+ miValueTuple.Add(miValueResult);
}
if (vrBrkPtInfo.m_bHaveArgOptionThreadGrp)
{
const CMICmnMIValueConst miValueConst(vrBrkPtInfo.m_strOptThrdGrp);
const CMICmnMIValueList miValueList(miValueConst);
const CMICmnMIValueResult miValueResult("thread-groups", miValueList);
- bOk = bOk && miValueTuple.Add(miValueResult);
+ miValueTuple.Add(miValueResult);
}
// "times="
const CMICmnMIValueConst miValueConstB(CMIUtilString::Format("%d", vrBrkPtInfo.m_nTimes));
const CMICmnMIValueResult miValueResultB("times", miValueConstB);
- bOk = bOk && miValueTuple.Add(miValueResultB);
+ miValueTuple.Add(miValueResultB);
// "thread="
if (vrBrkPtInfo.m_bBrkPtThreadId)
{
const CMICmnMIValueConst miValueConst(CMIUtilString::Format("%d", vrBrkPtInfo.m_nBrkPtThreadId));
const CMICmnMIValueResult miValueResult("thread", miValueConst);
- bOk = bOk && miValueTuple.Add(miValueResult);
+ miValueTuple.Add(miValueResult);
}
// "cond="
if (vrBrkPtInfo.m_bCondition)
{
const CMICmnMIValueConst miValueConst(vrBrkPtInfo.m_strCondition);
const CMICmnMIValueResult miValueResult("cond", miValueConst);
- bOk = bOk && miValueTuple.Add(miValueResult);
+ miValueTuple.Add(miValueResult);
}
// "ignore="
if (vrBrkPtInfo.m_nIgnore != 0)
{
const CMICmnMIValueConst miValueConst(CMIUtilString::Format("%d", vrBrkPtInfo.m_nIgnore));
const CMICmnMIValueResult miValueResult("ignore", miValueConst);
- bOk = bOk && miValueTuple.Add(miValueResult);
+ miValueTuple.Add(miValueResult);
}
// "original-location="
const CMICmnMIValueConst miValueConstC(vrBrkPtInfo.m_strOrigLoc);
const CMICmnMIValueResult miValueResultC("original-location", miValueConstC);
- bOk = bOk && miValueTuple.Add(miValueResultC);
+ miValueTuple.Add(miValueResultC);
vwrMiValueTuple = miValueTuple;
diff --git a/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h b/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
index 7e0ce6ab8246..dbad0c86159a 100644
--- a/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
+++ b/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
@@ -38,9 +38,6 @@ class CMICmnMIValueList;
// retrieved by the same or other subsequent commands.
// It primarily holds LLDB type objects.
// A singleton class.
-// Gotchas: None.
-// Authors: Illya Rudkin 04/03/2014.
-// Changes: None.
//--
class CMICmnLLDBDebugSessionInfo : public CMICmnBase, public MI::ISingleton<CMICmnLLDBDebugSessionInfo>
{
@@ -55,7 +52,7 @@ class CMICmnLLDBDebugSessionInfo : public CMICmnBase, public MI::ISingleton<CMIC
//--
struct SBrkPtInfo
{
- SBrkPtInfo(void)
+ SBrkPtInfo()
: m_id(0)
, m_bDisp(false)
, m_bEnabled(false)
@@ -140,13 +137,13 @@ class CMICmnLLDBDebugSessionInfo : public CMICmnBase, public MI::ISingleton<CMIC
// Methods:
public:
- bool Initialize(void) override;
- bool Shutdown(void) override;
+ bool Initialize() override;
+ bool Shutdown() override;
// Variant type data which can be assigned and retrieved across all command instances
template <typename T> bool SharedDataAdd(const CMIUtilString &vKey, const T &vData);
template <typename T> bool SharedDataRetrieve(const CMIUtilString &vKey, T &vwData);
- bool SharedDataDestroy(void);
+ void SharedDataDestroy();
// Common command required functionality
bool AccessPath(const CMIUtilString &vPath, bool &vwbYesAccessible);
@@ -159,7 +156,7 @@ class CMICmnLLDBDebugSessionInfo : public CMICmnBase, public MI::ISingleton<CMIC
bool MIResponseFormVariableInfo(const lldb::SBFrame &vrFrame, const MIuint vMaskVarTypes,
const VariableInfoFormat_e veVarInfoFormat, CMICmnMIValueList &vwrMiValueList,
const MIuint vnMaxDepth = 10, const bool vbMarkArgs = false);
- bool MIResponseFormBrkPtFrameInfo(const SBrkPtInfo &vrBrkPtInfo, CMICmnMIValueTuple &vwrMiValueTuple);
+ void MIResponseFormBrkPtFrameInfo(const SBrkPtInfo &vrBrkPtInfo, CMICmnMIValueTuple &vwrMiValueTuple);
bool MIResponseFormBrkPtInfo(const SBrkPtInfo &vrBrkPtInfo, CMICmnMIValueTuple &vwrMiValueTuple);
bool GetBrkPtInfo(const lldb::SBBreakpoint &vBrkPt, SBrkPtInfo &vrwBrkPtInfo) const;
bool RecordBrkPtInfo(const MIuint vnBrkPtId, const SBrkPtInfo &vrBrkPtInfo);
@@ -194,7 +191,7 @@ class CMICmnLLDBDebugSessionInfo : public CMICmnBase, public MI::ISingleton<CMIC
// Methods:
private:
- /* ctor */ CMICmnLLDBDebugSessionInfo(void);
+ /* ctor */ CMICmnLLDBDebugSessionInfo();
/* ctor */ CMICmnLLDBDebugSessionInfo(const CMICmnLLDBDebugSessionInfo &);
void operator=(const CMICmnLLDBDebugSessionInfo &);
//
@@ -209,7 +206,7 @@ class CMICmnLLDBDebugSessionInfo : public CMICmnBase, public MI::ISingleton<CMIC
// Overridden:
private:
// From CMICmnBase
- /* dtor */ ~CMICmnLLDBDebugSessionInfo(void) override;
+ /* dtor */ ~CMICmnLLDBDebugSessionInfo() override;
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp b/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp
index 62130844d22d..d4d2896f7eeb 100644
--- a/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp
+++ b/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp
@@ -32,7 +32,7 @@ CMICmnLLDBDebugSessionInfoVarObj::varFormat_e CMICmnLLDBDebugSessionInfoVarObj::
// Return: None.
// Throws: None.
//--
-CMICmnLLDBDebugSessionInfoVarObj::CMICmnLLDBDebugSessionInfoVarObj(void)
+CMICmnLLDBDebugSessionInfoVarObj::CMICmnLLDBDebugSessionInfoVarObj()
: m_eVarFormat(eVarFormat_Natural)
, m_eVarType(eVarType_Internal)
{
@@ -205,7 +205,7 @@ CMICmnLLDBDebugSessionInfoVarObj::MoveOther(CMICmnLLDBDebugSessionInfoVarObj &vr
// Return: None.
// Throws: None.
//--
-CMICmnLLDBDebugSessionInfoVarObj::~CMICmnLLDBDebugSessionInfoVarObj(void)
+CMICmnLLDBDebugSessionInfoVarObj::~CMICmnLLDBDebugSessionInfoVarObj()
{
}
@@ -285,7 +285,7 @@ CMICmnLLDBDebugSessionInfoVarObj::GetValueStringFormatted(const lldb::SBValue &v
}
}
- return utilValue.GetValue().Escape().AddSlashes();
+ return utilValue.GetValue().AddSlashes();
}
//++ ------------------------------------------------------------------------------------
@@ -340,7 +340,7 @@ CMICmnLLDBDebugSessionInfoVarObj::GetStringFormatted(const MIuint64 vnValue, con
// Throws: None.
//--
void
-CMICmnLLDBDebugSessionInfoVarObj::VarObjClear(void)
+CMICmnLLDBDebugSessionInfoVarObj::VarObjClear()
{
ms_mapVarIdToVarObj.clear();
}
@@ -421,7 +421,7 @@ CMICmnLLDBDebugSessionInfoVarObj::VarObjGet(const CMIUtilString &vrVarName, CMIC
// Throws: None.
//--
void
-CMICmnLLDBDebugSessionInfoVarObj::VarObjIdResetToZero(void)
+CMICmnLLDBDebugSessionInfoVarObj::VarObjIdResetToZero()
{
ms_nVarUniqueId = 0;
}
@@ -449,7 +449,7 @@ CMICmnLLDBDebugSessionInfoVarObj::VarObjSetFormat(varFormat_e eDefaultFormat)
// Throws: None.
//--
void
-CMICmnLLDBDebugSessionInfoVarObj::VarObjIdInc(void)
+CMICmnLLDBDebugSessionInfoVarObj::VarObjIdInc()
{
ms_nVarUniqueId++;
}
@@ -463,7 +463,7 @@ CMICmnLLDBDebugSessionInfoVarObj::VarObjIdInc(void)
// Throws: None.
//--
MIuint
-CMICmnLLDBDebugSessionInfoVarObj::VarObjIdGet(void)
+CMICmnLLDBDebugSessionInfoVarObj::VarObjIdGet()
{
return ms_nVarUniqueId;
}
@@ -476,7 +476,7 @@ CMICmnLLDBDebugSessionInfoVarObj::VarObjIdGet(void)
// Throws: None.
//--
const CMIUtilString &
-CMICmnLLDBDebugSessionInfoVarObj::GetName(void) const
+CMICmnLLDBDebugSessionInfoVarObj::GetName() const
{
return m_strName;
}
@@ -490,7 +490,7 @@ CMICmnLLDBDebugSessionInfoVarObj::GetName(void) const
// Throws: None.
//--
const CMIUtilString &
-CMICmnLLDBDebugSessionInfoVarObj::GetNameReal(void) const
+CMICmnLLDBDebugSessionInfoVarObj::GetNameReal() const
{
return m_strNameReal;
}
@@ -503,7 +503,7 @@ CMICmnLLDBDebugSessionInfoVarObj::GetNameReal(void) const
// Throws: None.
//--
const CMIUtilString &
-CMICmnLLDBDebugSessionInfoVarObj::GetValueFormatted(void) const
+CMICmnLLDBDebugSessionInfoVarObj::GetValueFormatted() const
{
return m_strFormattedValue;
}
@@ -516,7 +516,7 @@ CMICmnLLDBDebugSessionInfoVarObj::GetValueFormatted(void) const
// Throws: None.
//--
lldb::SBValue &
-CMICmnLLDBDebugSessionInfoVarObj::GetValue(void)
+CMICmnLLDBDebugSessionInfoVarObj::GetValue()
{
return m_SBValue;
}
@@ -529,7 +529,7 @@ CMICmnLLDBDebugSessionInfoVarObj::GetValue(void)
// Throws: None.
//--
const lldb::SBValue &
-CMICmnLLDBDebugSessionInfoVarObj::GetValue(void) const
+CMICmnLLDBDebugSessionInfoVarObj::GetValue() const
{
return m_SBValue;
}
@@ -561,7 +561,7 @@ CMICmnLLDBDebugSessionInfoVarObj::SetVarFormat(const varFormat_e veVarFormat)
// Throws: None.
//--
void
-CMICmnLLDBDebugSessionInfoVarObj::UpdateValue(void)
+CMICmnLLDBDebugSessionInfoVarObj::UpdateValue()
{
m_strFormattedValue = GetValueStringFormatted(m_SBValue, m_eVarFormat);
@@ -580,7 +580,7 @@ CMICmnLLDBDebugSessionInfoVarObj::UpdateValue(void)
// Throws: None.
//--
CMICmnLLDBDebugSessionInfoVarObj::varType_e
-CMICmnLLDBDebugSessionInfoVarObj::GetType(void) const
+CMICmnLLDBDebugSessionInfoVarObj::GetType() const
{
return m_eVarType;
}
@@ -595,7 +595,7 @@ CMICmnLLDBDebugSessionInfoVarObj::GetType(void) const
// Throws: None.
//--
const CMIUtilString &
-CMICmnLLDBDebugSessionInfoVarObj::GetVarParentName(void) const
+CMICmnLLDBDebugSessionInfoVarObj::GetVarParentName() const
{
return m_strVarObjParentName;
}
diff --git a/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h b/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h
index e768c5fdf0cc..c4ae8e8e44b3 100644
--- a/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h
+++ b/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h
@@ -19,9 +19,6 @@
//++ ============================================================================
// Details: MI debug session variable object. The static functionality in *this
// class manages a map container of *these variable objects.
-// Gotchas: None.
-// Authors: Illya Rudkin 24/03/2014.
-// Changes: None.
//--
class CMICmnLLDBDebugSessionInfoVarObj
{
@@ -63,15 +60,15 @@ class CMICmnLLDBDebugSessionInfoVarObj
static void VarObjDelete(const CMIUtilString &vrVarName);
static bool VarObjGet(const CMIUtilString &vrVarName, CMICmnLLDBDebugSessionInfoVarObj &vrwVarObj);
static void VarObjUpdate(const CMICmnLLDBDebugSessionInfoVarObj &vrVarObj);
- static void VarObjIdInc(void);
- static MIuint VarObjIdGet(void);
- static void VarObjIdResetToZero(void);
- static void VarObjClear(void);
+ static void VarObjIdInc();
+ static MIuint VarObjIdGet();
+ static void VarObjIdResetToZero();
+ static void VarObjClear();
static void VarObjSetFormat(varFormat_e eDefaultFormat);
// Methods:
public:
- /* ctor */ CMICmnLLDBDebugSessionInfoVarObj(void);
+ /* ctor */ CMICmnLLDBDebugSessionInfoVarObj();
/* ctor */ CMICmnLLDBDebugSessionInfoVarObj(const CMIUtilString &vrStrNameReal, const CMIUtilString &vrStrName,
const lldb::SBValue &vrValue);
/* ctor */ CMICmnLLDBDebugSessionInfoVarObj(const CMIUtilString &vrStrNameReal, const CMIUtilString &vrStrName,
@@ -83,20 +80,20 @@ class CMICmnLLDBDebugSessionInfoVarObj
CMICmnLLDBDebugSessionInfoVarObj &operator=(const CMICmnLLDBDebugSessionInfoVarObj &vrOther);
CMICmnLLDBDebugSessionInfoVarObj &operator=(CMICmnLLDBDebugSessionInfoVarObj &&vrwOther);
//
- const CMIUtilString &GetName(void) const;
- const CMIUtilString &GetNameReal(void) const;
- const CMIUtilString &GetValueFormatted(void) const;
- lldb::SBValue &GetValue(void);
- const lldb::SBValue &GetValue(void) const;
- varType_e GetType(void) const;
+ const CMIUtilString &GetName() const;
+ const CMIUtilString &GetNameReal() const;
+ const CMIUtilString &GetValueFormatted() const;
+ lldb::SBValue &GetValue();
+ const lldb::SBValue &GetValue() const;
+ varType_e GetType() const;
bool SetVarFormat(const varFormat_e veVarFormat);
- const CMIUtilString &GetVarParentName(void) const;
- void UpdateValue(void);
+ const CMIUtilString &GetVarParentName() const;
+ void UpdateValue();
// Overridden:
public:
// From CMICmnBase
- /* dtor */ virtual ~CMICmnLLDBDebugSessionInfoVarObj(void);
+ /* dtor */ virtual ~CMICmnLLDBDebugSessionInfoVarObj();
// Typedefs:
private:
diff --git a/tools/lldb-mi/MICmnLLDBDebugger.cpp b/tools/lldb-mi/MICmnLLDBDebugger.cpp
index b626ccc3f12d..3042e1c8125d 100644
--- a/tools/lldb-mi/MICmnLLDBDebugger.cpp
+++ b/tools/lldb-mi/MICmnLLDBDebugger.cpp
@@ -12,6 +12,11 @@
#include "lldb/API/SBThread.h"
#include "lldb/API/SBProcess.h"
#include "lldb/API/SBCommandInterpreter.h"
+#include "lldb/API/SBTypeSummary.h"
+#include "lldb/API/SBTypeCategory.h"
+#include "lldb/API/SBTypeNameSpecifier.h"
+#include "lldb/API/SBStream.h"
+#include "lldb/API/SBType.h"
// In-house headers:
#include "MICmnLLDBDebugger.h"
@@ -24,13 +29,50 @@
#include "MIUtilSingletonHelper.h"
//++ ------------------------------------------------------------------------------------
+// MI private summary providers
+static inline bool
+MI_char_summary_provider(lldb::SBValue value, lldb::SBTypeSummaryOptions options, lldb::SBStream &stream)
+{
+ if (!value.IsValid())
+ return false;
+
+ lldb::SBType value_type = value.GetType();
+ if(!value_type.IsValid())
+ return false;
+
+ lldb::BasicType type_code = value_type.GetBasicType();
+ if (type_code == lldb::eBasicTypeSignedChar)
+ stream.Printf("%d %s", (int)value.GetValueAsSigned(), value.GetValue());
+ else if (type_code == lldb::eBasicTypeUnsignedChar)
+ stream.Printf("%u %s", (unsigned)value.GetValueAsUnsigned(), value.GetValue());
+ else
+ return false;
+
+ return true;
+}
+
+//++ ------------------------------------------------------------------------------------
+// MI summary helper routines
+static inline bool
+MI_add_summary(lldb::SBTypeCategory category, const char *typeName, lldb::SBTypeSummary::FormatCallback cb,
+ uint32_t options, bool regex = false)
+{
+#if defined(LLDB_DISABLE_PYTHON)
+ return false;
+#else
+ lldb::SBTypeSummary summary = lldb::SBTypeSummary::CreateWithCallback(cb, options);
+ return summary.IsValid() ? category.AddTypeSummary(lldb::SBTypeNameSpecifier(typeName, regex), summary) : false;
+#endif
+}
+
+//++ ------------------------------------------------------------------------------------
// Details: CMICmnLLDBDebugger constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmnLLDBDebugger::CMICmnLLDBDebugger(void)
+CMICmnLLDBDebugger::CMICmnLLDBDebugger()
: m_constStrThisThreadId("MI debugger event")
{
}
@@ -42,7 +84,7 @@ CMICmnLLDBDebugger::CMICmnLLDBDebugger(void)
// Return: None.
// Throws: None.
//--
-CMICmnLLDBDebugger::~CMICmnLLDBDebugger(void)
+CMICmnLLDBDebugger::~CMICmnLLDBDebugger()
{
Shutdown();
}
@@ -56,7 +98,7 @@ CMICmnLLDBDebugger::~CMICmnLLDBDebugger(void)
// Throws: None.
//--
bool
-CMICmnLLDBDebugger::Initialize(void)
+CMICmnLLDBDebugger::Initialize()
{
m_clientUsageRefCnt++;
@@ -98,7 +140,7 @@ CMICmnLLDBDebugger::Initialize(void)
errMsg += GetErrorDescription().c_str();
}
bOk = bOk && InitStdStreams();
-
+ bOk = bOk && RegisterMISummaryProviders();
m_bInitialized = bOk;
if (!bOk && !HaveErrorDescription())
@@ -119,7 +161,7 @@ CMICmnLLDBDebugger::Initialize(void)
// Throws: None.
//--
bool
-CMICmnLLDBDebugger::Shutdown(void)
+CMICmnLLDBDebugger::Shutdown()
{
if (--m_clientUsageRefCnt > 0)
return MIstatus::success;
@@ -173,7 +215,7 @@ CMICmnLLDBDebugger::Shutdown(void)
// Throws: None.
//--
lldb::SBDebugger &
-CMICmnLLDBDebugger::GetTheDebugger(void)
+CMICmnLLDBDebugger::GetTheDebugger()
{
return m_lldbDebugger;
}
@@ -186,7 +228,7 @@ CMICmnLLDBDebugger::GetTheDebugger(void)
// Throws: None.
//--
lldb::SBListener &
-CMICmnLLDBDebugger::GetTheListener(void)
+CMICmnLLDBDebugger::GetTheListener()
{
return m_lldbListener;
}
@@ -216,7 +258,7 @@ CMICmnLLDBDebugger::SetDriver(const CMIDriverBase &vClientDriver)
// Throws: None.
//--
CMIDriverBase &
-CMICmnLLDBDebugger::GetDriver(void) const
+CMICmnLLDBDebugger::GetDriver() const
{
return *m_pClientDriver;
}
@@ -234,7 +276,7 @@ CMICmnLLDBDebugger::GetDriver(void) const
// Throws: None.
//--
void
-CMICmnLLDBDebugger::WaitForHandleEvent(void)
+CMICmnLLDBDebugger::WaitForHandleEvent()
{
std::unique_lock<std::mutex> lock(m_mutexEventQueue);
@@ -254,7 +296,7 @@ CMICmnLLDBDebugger::WaitForHandleEvent(void)
// Throws: None.
//--
bool
-CMICmnLLDBDebugger::CheckIfNeedToRebroadcastStopEvent(void)
+CMICmnLLDBDebugger::CheckIfNeedToRebroadcastStopEvent()
{
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
if (!rSessionInfo.GetDebugger().GetAsync())
@@ -276,7 +318,7 @@ CMICmnLLDBDebugger::CheckIfNeedToRebroadcastStopEvent(void)
// Throws: None.
//--
void
-CMICmnLLDBDebugger::RebroadcastStopEvent(void)
+CMICmnLLDBDebugger::RebroadcastStopEvent()
{
lldb::SBProcess process = CMICmnLLDBDebugSessionInfo::Instance().GetProcess();
const bool include_expression_stops = false;
@@ -297,7 +339,7 @@ CMICmnLLDBDebugger::RebroadcastStopEvent(void)
// Throws: None.
//--
bool
-CMICmnLLDBDebugger::InitSBDebugger(void)
+CMICmnLLDBDebugger::InitSBDebugger()
{
m_lldbDebugger = lldb::SBDebugger::Create(false);
if (!m_lldbDebugger.IsValid())
@@ -321,7 +363,7 @@ CMICmnLLDBDebugger::InitSBDebugger(void)
// Throws: None.
//--
bool
-CMICmnLLDBDebugger::InitStdStreams(void)
+CMICmnLLDBDebugger::InitStdStreams()
{
// This is not required when operating the MI driver's code as it has its own
// streams. Setting the Stdin for the lldbDebugger especially on LINUX will cause
@@ -342,7 +384,7 @@ CMICmnLLDBDebugger::InitStdStreams(void)
// Throws: None.
//--
bool
-CMICmnLLDBDebugger::InitSBListener(void)
+CMICmnLLDBDebugger::InitSBListener()
{
m_lldbListener = m_lldbDebugger.GetListener();
if (!m_lldbListener.IsValid())
@@ -585,7 +627,7 @@ CMICmnLLDBDebugger::ClientGetMaskForAllClients(const CMIUtilString &vBroadcaster
while (it != m_mapIdToEventMask.end())
{
const CMIUtilString &rId((*it).first);
- if (rId.find(vBroadcasterClass.c_str()) != std::string::npos)
+ if (rId.find(vBroadcasterClass) != std::string::npos)
{
const MIuint clientsMask = (*it).second;
mask |= clientsMask;
@@ -678,9 +720,7 @@ CMICmnLLDBDebugger::ClientGetTheirMask(const CMIUtilString &vClientName, const C
return MIstatus::failure;
}
- CMIUtilString strId(vBroadcasterClass.c_str());
- strId += vClientName;
-
+ const CMIUtilString strId(vBroadcasterClass + vClientName);
const MapIdToEventMask_t::const_iterator it = m_mapIdToEventMask.find(strId);
if (it != m_mapIdToEventMask.end())
{
@@ -776,7 +816,7 @@ CMICmnLLDBDebugger::ThreadRun(bool &vrbIsAlive)
// Throws: None.
//--
bool
-CMICmnLLDBDebugger::ThreadFinish(void)
+CMICmnLLDBDebugger::ThreadFinish()
{
return MIstatus::success;
}
@@ -789,7 +829,58 @@ CMICmnLLDBDebugger::ThreadFinish(void)
// Throws: None.
//--
const CMIUtilString &
-CMICmnLLDBDebugger::ThreadGetName(void) const
+CMICmnLLDBDebugger::ThreadGetName() const
{
return m_constStrThisThreadId;
}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Loads lldb-mi formatters
+// Type: Method.
+// Args: None.
+// Return: true - Functionality succeeded.
+// false - Functionality failed.
+// Throws: None.
+//--
+bool
+CMICmnLLDBDebugger::LoadMIFormatters(lldb::SBTypeCategory miCategory)
+{
+ if (!MI_add_summary(miCategory, "char", MI_char_summary_provider,
+ lldb::eTypeOptionHideValue | lldb::eTypeOptionSkipPointers))
+ return false;
+
+ if (!MI_add_summary(miCategory, "unsigned char", MI_char_summary_provider,
+ lldb::eTypeOptionHideValue | lldb::eTypeOptionSkipPointers))
+ return false;
+
+ if (!MI_add_summary(miCategory, "signed char", MI_char_summary_provider,
+ lldb::eTypeOptionHideValue | lldb::eTypeOptionSkipPointers))
+ return false;
+
+ return true;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Registers lldb-mi custom summary providers
+// Type: Method.
+// Args: None.
+// Return: true - Functionality succeeded.
+// false - Functionality failed.
+// Throws: None.
+//--
+bool
+CMICmnLLDBDebugger::RegisterMISummaryProviders()
+{
+ static const char* miCategoryName = "lldb-mi";
+ lldb::SBTypeCategory miCategory = m_lldbDebugger.CreateCategory(miCategoryName);
+ if (!miCategory.IsValid())
+ return false;
+
+ if (!LoadMIFormatters(miCategory))
+ {
+ m_lldbDebugger.DeleteCategory(miCategoryName);
+ return false;
+ }
+ miCategory.SetEnabled(true);
+ return true;
+}
diff --git a/tools/lldb-mi/MICmnLLDBDebugger.h b/tools/lldb-mi/MICmnLLDBDebugger.h
index de7611221522..83bc3c06bf69 100644
--- a/tools/lldb-mi/MICmnLLDBDebugger.h
+++ b/tools/lldb-mi/MICmnLLDBDebugger.h
@@ -32,9 +32,6 @@ class CMICmnLLDBDebuggerHandleEvents;
// to facilitate their work effort. The instance runs in its own worker
// thread.
// A singleton class.
-// Gotchas: None.
-// Authors: Illya Rudkin 26/02/2014.
-// Changes: None.
//--
class CMICmnLLDBDebugger : public CMICmnBase, public CMIUtilThreadActiveObjBase, public MI::ISingleton<CMICmnLLDBDebugger>
{
@@ -42,16 +39,16 @@ class CMICmnLLDBDebugger : public CMICmnBase, public CMIUtilThreadActiveObjBase,
// Methods:
public:
- bool Initialize(void) override;
- bool Shutdown(void) override;
+ bool Initialize() override;
+ bool Shutdown() override;
bool SetDriver(const CMIDriverBase &vClientDriver);
- CMIDriverBase &GetDriver(void) const;
- lldb::SBDebugger &GetTheDebugger(void);
- lldb::SBListener &GetTheListener(void);
- void WaitForHandleEvent(void);
- bool CheckIfNeedToRebroadcastStopEvent(void);
- void RebroadcastStopEvent(void);
+ CMIDriverBase &GetDriver() const;
+ lldb::SBDebugger &GetTheDebugger();
+ lldb::SBListener &GetTheListener();
+ void WaitForHandleEvent();
+ bool CheckIfNeedToRebroadcastStopEvent();
+ void RebroadcastStopEvent();
// MI Commands can use these functions to listen for events they require
bool RegisterForEvent(const CMIUtilString &vClientName, const CMIUtilString &vBroadcasterClass, const MIuint vEventMask);
@@ -62,13 +59,13 @@ class CMICmnLLDBDebugger : public CMICmnBase, public CMIUtilThreadActiveObjBase,
// Overridden:
public:
// From CMIUtilThreadActiveObjBase
- const CMIUtilString &ThreadGetName(void) const override;
+ const CMIUtilString &ThreadGetName() const override;
// Overridden:
protected:
// From CMIUtilThreadActiveObjBase
bool ThreadRun(bool &vrIsAlive) override;
- bool ThreadFinish(void) override;
+ bool ThreadFinish() override;
// Typedefs:
private:
@@ -79,13 +76,13 @@ class CMICmnLLDBDebugger : public CMICmnBase, public CMIUtilThreadActiveObjBase,
// Methods:
private:
- /* ctor */ CMICmnLLDBDebugger(void);
+ /* ctor */ CMICmnLLDBDebugger();
/* ctor */ CMICmnLLDBDebugger(const CMICmnLLDBDebugger &);
void operator=(const CMICmnLLDBDebugger &);
- bool InitSBDebugger(void);
- bool InitSBListener(void);
- bool InitStdStreams(void);
+ bool InitSBDebugger();
+ bool InitSBListener();
+ bool InitStdStreams();
bool MonitorSBListenerEvents(bool &vrbYesExit);
bool BroadcasterGetMask(const CMIUtilString &vBroadcasterClass, MIuint &vEventMask) const;
@@ -96,11 +93,12 @@ class CMICmnLLDBDebugger : public CMICmnBase, public CMIUtilThreadActiveObjBase,
bool ClientSaveMask(const CMIUtilString &vClientName, const CMIUtilString &vBroadcasterClass, const MIuint vEventMask);
bool ClientRemoveTheirMask(const CMIUtilString &vClientName, const CMIUtilString &vBroadcasterClass);
bool ClientGetTheirMask(const CMIUtilString &vClientName, const CMIUtilString &vBroadcasterClass, MIuint &vwEventMask);
-
+ bool LoadMIFormatters(lldb::SBTypeCategory miCategory);
+ bool RegisterMISummaryProviders();
// Overridden:
private:
// From CMICmnBase
- /* dtor */ ~CMICmnLLDBDebugger(void) override;
+ /* dtor */ ~CMICmnLLDBDebugger() override;
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp b/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
index 29ff15c92f44..848529f0b46a 100644
--- a/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
+++ b/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
@@ -1,4 +1,4 @@
-//===-- MICmnLLDBDebuggerHandleEvents.cpp --------------------------------------------*- C++ -*-===//
+//===-- MICmnLLDBDebuggerHandleEvents.cpp -----------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -47,7 +47,7 @@
// Return: None.
// Throws: None.
//--
-CMICmnLLDBDebuggerHandleEvents::CMICmnLLDBDebuggerHandleEvents(void)
+CMICmnLLDBDebuggerHandleEvents::CMICmnLLDBDebuggerHandleEvents()
{
}
@@ -58,7 +58,7 @@ CMICmnLLDBDebuggerHandleEvents::CMICmnLLDBDebuggerHandleEvents(void)
// Return: None.
// Throws: None.
//--
-CMICmnLLDBDebuggerHandleEvents::~CMICmnLLDBDebuggerHandleEvents(void)
+CMICmnLLDBDebuggerHandleEvents::~CMICmnLLDBDebuggerHandleEvents()
{
Shutdown();
}
@@ -72,7 +72,7 @@ CMICmnLLDBDebuggerHandleEvents::~CMICmnLLDBDebuggerHandleEvents(void)
// Throws: None.
//--
bool
-CMICmnLLDBDebuggerHandleEvents::Initialize(void)
+CMICmnLLDBDebuggerHandleEvents::Initialize()
{
m_clientUsageRefCnt++;
@@ -98,7 +98,7 @@ CMICmnLLDBDebuggerHandleEvents::Initialize(void)
// Throws: None.
//--
bool
-CMICmnLLDBDebuggerHandleEvents::Shutdown(void)
+CMICmnLLDBDebuggerHandleEvents::Shutdown()
{
if (--m_clientUsageRefCnt > 0)
return MIstatus::success;
@@ -351,7 +351,8 @@ CMICmnLLDBDebuggerHandleEvents::HandleEventSBBreakpointCmn(const lldb::SBEvent &
const CMICmnMIValueResult miValueResultC("bkpt", miValueTuple);
const CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, miValueResultC);
- const bool bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord);
+ bool bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord);
+ bOk = bOk && CMICmnStreamStdout::WritePrompt();
return bOk;
}
@@ -440,6 +441,7 @@ CMICmnLLDBDebuggerHandleEvents::HandleEventSBBreakpointAdded(const lldb::SBEvent
const CMICmnMIValueResult miValueResult("bkpt", miValueTuple);
const CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, miValueResult);
bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord);
+ bOk = bOk && CMICmnStreamStdout::WritePrompt();
}
else
{
@@ -462,6 +464,7 @@ CMICmnLLDBDebuggerHandleEvents::HandleEventSBBreakpointAdded(const lldb::SBEvent
const CMICmnMIValueResult miValueResult("bkpt", miValueTuple);
const CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated, miValueResult);
bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord);
+ bOk = bOk && CMICmnStreamStdout::WritePrompt();
}
return bOk;
@@ -543,10 +546,8 @@ CMICmnLLDBDebuggerHandleEvents::HandleEventSBThreadSuspended(const lldb::SBEvent
const CMIUtilString strSignal(CMIUtilString::Format("%lld", nId));
const CMICmnMIValueConst miValueConst2(strSignal);
const CMICmnMIValueResult miValueResult2("signal", miValueConst2);
- bool bOk = miOutOfBandRecord.Add(miValueResult2);
- bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord);
-
- return bOk;
+ miOutOfBandRecord.Add(miValueResult2);
+ return MiOutOfBandRecordToStdout(miOutOfBandRecord);
}
//++ ------------------------------------------------------------------------------------
@@ -690,19 +691,19 @@ CMICmnLLDBDebuggerHandleEvents::MiHelpGetModuleInfo(const lldb::SBModule &vModul
std::unique_ptr<char[]> apPath(new char[PATH_MAX]);
vModule.GetFileSpec().GetPath(apPath.get(), PATH_MAX);
const CMIUtilString strTargetPath(apPath.get());
- const CMICmnMIValueConst miValueConst(strTargetPath);
+ const CMICmnMIValueConst miValueConst(strTargetPath.AddSlashes());
const CMICmnMIValueResult miValueResult("id", miValueConst);
- bOk = bOk && vwrMiOutOfBandRecord.Add(miValueResult);
+ vwrMiOutOfBandRecord.Add(miValueResult);
// Build "target-name" field
- const CMICmnMIValueConst miValueConst2(strTargetPath);
+ const CMICmnMIValueConst miValueConst2(strTargetPath.AddSlashes());
const CMICmnMIValueResult miValueResult2("target-name", miValueConst2);
- bOk = bOk && vwrMiOutOfBandRecord.Add(miValueResult2);
+ vwrMiOutOfBandRecord.Add(miValueResult2);
// Build "host-name" field
vModule.GetPlatformFileSpec().GetPath(apPath.get(), PATH_MAX);
const CMIUtilString strHostPath(apPath.get());
- const CMICmnMIValueConst miValueConst3(strHostPath);
+ const CMICmnMIValueConst miValueConst3(strHostPath.AddSlashes());
const CMICmnMIValueResult miValueResult3("host-name", miValueConst3);
- bOk = bOk && vwrMiOutOfBandRecord.Add(miValueResult3);
+ vwrMiOutOfBandRecord.Add(miValueResult3);
// Then build extra fields if needed:
if (vbWithExtraFields)
@@ -713,23 +714,30 @@ CMICmnLLDBDebuggerHandleEvents::MiHelpGetModuleInfo(const lldb::SBModule &vModul
const bool bSymbolsLoaded = !CMIUtilString::Compare(strHostPath, strSymbolsPath);
const CMICmnMIValueConst miValueConst4(CMIUtilString::Format("%d", bSymbolsLoaded));
const CMICmnMIValueResult miValueResult4("symbols-loaded", miValueConst4);
- bOk = bOk && vwrMiOutOfBandRecord.Add(miValueResult4);
+ vwrMiOutOfBandRecord.Add(miValueResult4);
// Build "symbols-path" field
if (bSymbolsLoaded)
{
- const CMICmnMIValueConst miValueConst5(strSymbolsPath);
+ const CMICmnMIValueConst miValueConst5(strSymbolsPath.AddSlashes());
const CMICmnMIValueResult miValueResult5("symbols-path", miValueConst5);
- bOk = bOk && vwrMiOutOfBandRecord.Add(miValueResult5);
+ vwrMiOutOfBandRecord.Add(miValueResult5);
}
// Build "loaded_addr" field
- const lldb::SBAddress sbAddress(vModule.GetObjectFileHeaderAddress());
+ lldb::SBAddress sbAddress(vModule.GetObjectFileHeaderAddress());
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
const lldb::addr_t nLoadAddress(sbAddress.GetLoadAddress(rSessionInfo.GetTarget()));
const CMIUtilString strLoadedAddr(nLoadAddress != LLDB_INVALID_ADDRESS ?
CMIUtilString::Format("0x%016" PRIx64, nLoadAddress) : "-");
const CMICmnMIValueConst miValueConst6(strLoadedAddr);
const CMICmnMIValueResult miValueResult6("loaded_addr", miValueConst6);
- bOk = bOk && vwrMiOutOfBandRecord.Add(miValueResult6);
+ vwrMiOutOfBandRecord.Add(miValueResult6);
+
+ // Build "size" field
+ lldb::SBSection sbSection = sbAddress.GetSection();
+ const CMIUtilString strSize(CMIUtilString::Format("%" PRIu64, sbSection.GetByteSize()));
+ const CMICmnMIValueConst miValueConst7(strSize);
+ const CMICmnMIValueResult miValueResult7("size", miValueConst7);
+ vwrMiOutOfBandRecord.Add(miValueResult7);
}
return bOk;
@@ -1018,21 +1026,21 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal(const lldb::SBEvent
CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult);
const CMICmnMIValueConst miValueConst2("SIGINT");
const CMICmnMIValueResult miValueResult2("signal-name", miValueConst2);
- bOk = miOutOfBandRecord.Add(miValueResult2);
+ miOutOfBandRecord.Add(miValueResult2);
const CMICmnMIValueConst miValueConst3("Interrupt");
const CMICmnMIValueResult miValueResult3("signal-meaning", miValueConst3);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult3);
+ miOutOfBandRecord.Add(miValueResult3);
CMICmnMIValueTuple miValueTuple;
bOk = bOk && MiHelpGetCurrentThreadFrame(miValueTuple);
const CMICmnMIValueResult miValueResult4("frame", miValueTuple);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult4);
+ miOutOfBandRecord.Add(miValueResult4);
const CMIUtilString strThreadId(CMIUtilString::Format("%" PRIu32, sbProcess.GetSelectedThread().GetIndexID()));
const CMICmnMIValueConst miValueConst5(strThreadId);
const CMICmnMIValueResult miValueResult5("thread-id", miValueConst5);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult5);
+ miOutOfBandRecord.Add(miValueResult5);
const CMICmnMIValueConst miValueConst6("all");
const CMICmnMIValueResult miValueResult6("stopped-threads", miValueConst6);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult6);
+ miOutOfBandRecord.Add(miValueResult6);
bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord);
bOk = bOk && CMICmnStreamStdout::WritePrompt();
}
@@ -1044,21 +1052,21 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal(const lldb::SBEvent
CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult);
const CMICmnMIValueConst miValueConst2("SIGSTOP");
const CMICmnMIValueResult miValueResult2("signal-name", miValueConst2);
- bOk = miOutOfBandRecord.Add(miValueResult2);
+ miOutOfBandRecord.Add(miValueResult2);
const CMICmnMIValueConst miValueConst3("Stop");
const CMICmnMIValueResult miValueResult3("signal-meaning", miValueConst3);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult3);
+ miOutOfBandRecord.Add(miValueResult3);
CMICmnMIValueTuple miValueTuple;
bOk = bOk && MiHelpGetCurrentThreadFrame(miValueTuple);
const CMICmnMIValueResult miValueResult4("frame", miValueTuple);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult4);
+ miOutOfBandRecord.Add(miValueResult4);
const CMIUtilString strThreadId(CMIUtilString::Format("%" PRIu32, sbProcess.GetSelectedThread().GetIndexID()));
const CMICmnMIValueConst miValueConst5(strThreadId);
const CMICmnMIValueResult miValueResult5("thread-id", miValueConst5);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult5);
+ miOutOfBandRecord.Add(miValueResult5);
const CMICmnMIValueConst miValueConst6("all");
const CMICmnMIValueResult miValueResult6("stopped-threads", miValueConst6);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult6);
+ miOutOfBandRecord.Add(miValueResult6);
bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord);
bOk = bOk && CMICmnStreamStdout::WritePrompt();
}
@@ -1070,18 +1078,18 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal(const lldb::SBEvent
CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult);
const CMICmnMIValueConst miValueConst2("SIGSEGV");
const CMICmnMIValueResult miValueResult2("signal-name", miValueConst2);
- bOk = miOutOfBandRecord.Add(miValueResult2);
+ miOutOfBandRecord.Add(miValueResult2);
const CMICmnMIValueConst miValueConst3("Segmentation fault");
const CMICmnMIValueResult miValueResult3("signal-meaning", miValueConst3);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult3);
+ miOutOfBandRecord.Add(miValueResult3);
CMICmnMIValueTuple miValueTuple;
bOk = bOk && MiHelpGetCurrentThreadFrame(miValueTuple);
const CMICmnMIValueResult miValueResult4("frame", miValueTuple);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult4);
+ miOutOfBandRecord.Add(miValueResult4);
const CMIUtilString strThreadId(CMIUtilString::Format("%d", sbProcess.GetSelectedThread().GetIndexID()));
const CMICmnMIValueConst miValueConst5(strThreadId);
const CMICmnMIValueResult miValueResult5("thread-id", miValueConst5);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult5);
+ miOutOfBandRecord.Add(miValueResult5);
bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord);
// Note no "(gdb)" output here
}
@@ -1119,22 +1127,22 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal(const lldb::SBEvent
{
const CMICmnMIValueConst miValueConst2(pSignal);
const CMICmnMIValueResult miValueResult2("signal-name", miValueConst2);
- bOk = miOutOfBandRecord.Add(miValueResult2);
+ miOutOfBandRecord.Add(miValueResult2);
}
else
{
const CMIUtilString strSignal(CMIUtilString::Format("%" PRIu64, nStopReason));
const CMICmnMIValueConst miValueConst2(strSignal);
const CMICmnMIValueResult miValueResult2("signal", miValueConst2);
- bOk = miOutOfBandRecord.Add(miValueResult2);
+ miOutOfBandRecord.Add(miValueResult2);
}
const CMIUtilString strThreadId(CMIUtilString::Format("%d", sbProcess.GetSelectedThread().GetIndexID()));
const CMICmnMIValueConst miValueConst3(strThreadId);
const CMICmnMIValueResult miValueResult3("thread-id", miValueConst3);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult3);
+ miOutOfBandRecord.Add(miValueResult3);
const CMICmnMIValueConst miValueConst4("all");
const CMICmnMIValueResult miValueResult4("stopped-threads", miValueConst4);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult4);
+ miOutOfBandRecord.Add(miValueResult4);
bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord);
bOk = bOk && CMICmnStreamStdout::WritePrompt();
}
@@ -1150,7 +1158,7 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal(const lldb::SBEvent
// Throws: None.
//--
bool
-CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopException(void)
+CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopException()
{
const lldb::SBProcess sbProcess = CMICmnLLDBDebugSessionInfo::Instance().GetProcess();
lldb::SBThread sbThread = sbProcess.GetSelectedThread();
@@ -1165,15 +1173,15 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopException(void)
const CMIUtilString strReason(apStopDescription.get());
const CMICmnMIValueConst miValueConst2(strReason);
const CMICmnMIValueResult miValueResult2("exception", miValueConst2);
- bool bOk = miOutOfBandRecord.Add(miValueResult2);
+ miOutOfBandRecord.Add(miValueResult2);
const CMIUtilString strThreadId(CMIUtilString::Format("%d", sbThread.GetIndexID()));
const CMICmnMIValueConst miValueConst3(strThreadId);
const CMICmnMIValueResult miValueResult3("thread-id", miValueConst3);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult3);
+ miOutOfBandRecord.Add(miValueResult3);
const CMICmnMIValueConst miValueConst4("all");
const CMICmnMIValueResult miValueResult4("stopped-threads", miValueConst4);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult4);
- bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord);
+ miOutOfBandRecord.Add(miValueResult4);
+ bool bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord);
bOk = bOk && CMICmnStreamStdout::WritePrompt();
return bOk;
@@ -1235,7 +1243,7 @@ CMICmnLLDBDebuggerHandleEvents::MiHelpGetCurrentThreadFrame(CMICmnMIValueTuple &
// Throws: None.
//--
bool
-CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopReasonBreakpoint(void)
+CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopReasonBreakpoint()
{
// CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM
if (!CMIDriver::Instance().SetDriverStateRunningNotDebugging())
@@ -1278,21 +1286,21 @@ CMICmnLLDBDebuggerHandleEvents::MiStoppedAtBreakPoint(const MIuint64 vBrkPtId, c
CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult);
const CMICmnMIValueConst miValueConst2("del");
const CMICmnMIValueResult miValueResult2("disp", miValueConst2);
- bOk = miOutOfBandRecord.Add(miValueResult2);
+ miOutOfBandRecord.Add(miValueResult2);
const CMIUtilString strBkp(CMIUtilString::Format("%d", vBrkPtId));
const CMICmnMIValueConst miValueConst3(strBkp);
CMICmnMIValueResult miValueResult3("bkptno", miValueConst3);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult3);
+ miOutOfBandRecord.Add(miValueResult3);
const CMICmnMIValueConst miValueConst4("{}");
const CMICmnMIValueResult miValueResult4("frame", miValueConst4);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult4);
+ miOutOfBandRecord.Add(miValueResult4);
const CMIUtilString strThreadId(CMIUtilString::Format("%d", vBrkPt.GetThreadIndex()));
const CMICmnMIValueConst miValueConst5(strThreadId);
const CMICmnMIValueResult miValueResult5("thread-id", miValueConst5);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult5);
+ miOutOfBandRecord.Add(miValueResult5);
const CMICmnMIValueConst miValueConst6("all");
const CMICmnMIValueResult miValueResult6("stopped-threads", miValueConst6);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult6);
+ miOutOfBandRecord.Add(miValueResult6);
bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord);
bOk = bOk && CMICmnStreamStdout::WritePrompt();
return bOk;
@@ -1307,11 +1315,11 @@ CMICmnLLDBDebuggerHandleEvents::MiStoppedAtBreakPoint(const MIuint64 vBrkPtId, c
CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult);
const CMICmnMIValueConst miValueConstA("del");
const CMICmnMIValueResult miValueResultA("disp", miValueConstA);
- bOk = miOutOfBandRecord.Add(miValueResultA);
+ miOutOfBandRecord.Add(miValueResultA);
const CMIUtilString strBkp(CMIUtilString::Format("%d", vBrkPtId));
const CMICmnMIValueConst miValueConstB(strBkp);
CMICmnMIValueResult miValueResultB("bkptno", miValueConstB);
- bOk = bOk && miOutOfBandRecord.Add(miValueResultB);
+ miOutOfBandRecord.Add(miValueResultB);
// frame={addr=\"0x%016" PRIx64 "\",func=\"%s\",args=[],file=\"%s\",fullname=\"%s\",line=\"%d\"}
if (bOk)
@@ -1319,7 +1327,7 @@ CMICmnLLDBDebuggerHandleEvents::MiStoppedAtBreakPoint(const MIuint64 vBrkPtId, c
CMICmnMIValueTuple miValueTuple;
bOk = bOk && rSessionInfo.MIResponseFormFrameInfo(thread, 0, CMICmnLLDBDebugSessionInfo::eFrameInfoFormat_AllArguments, miValueTuple);
const CMICmnMIValueResult miValueResult8("frame", miValueTuple);
- bOk = bOk && miOutOfBandRecord.Add(miValueResult8);
+ miOutOfBandRecord.Add(miValueResult8);
}
// Add to MI thread-id=\"%d\",stopped-threads=\"all\"
@@ -1328,13 +1336,13 @@ CMICmnLLDBDebuggerHandleEvents::MiStoppedAtBreakPoint(const MIuint64 vBrkPtId, c
const CMIUtilString strThreadId(CMIUtilString::Format("%d", thread.GetIndexID()));
const CMICmnMIValueConst miValueConst8(strThreadId);
const CMICmnMIValueResult miValueResult8("thread-id", miValueConst8);
- bOk = miOutOfBandRecord.Add(miValueResult8);
+ miOutOfBandRecord.Add(miValueResult8);
}
if (bOk)
{
const CMICmnMIValueConst miValueConst9("all");
const CMICmnMIValueResult miValueResult9("stopped-threads", miValueConst9);
- bOk = miOutOfBandRecord.Add(miValueResult9);
+ miOutOfBandRecord.Add(miValueResult9);
bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord);
bOk = bOk && CMICmnStreamStdout::WritePrompt();
}
@@ -1351,7 +1359,7 @@ CMICmnLLDBDebuggerHandleEvents::MiStoppedAtBreakPoint(const MIuint64 vBrkPtId, c
// Throws: None.
//--
bool
-CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopReasonTrace(void)
+CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopReasonTrace()
{
bool bOk = true;
lldb::SBProcess sbProcess = CMICmnLLDBDebugSessionInfo::Instance().GetProcess();
@@ -1365,7 +1373,7 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopReasonTrace(void)
CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult);
const CMICmnMIValueConst miValueConst2("all");
const CMICmnMIValueResult miValueResult2("stopped-threads", miValueConst2);
- bOk = miOutOfBandRecord.Add(miValueResult2);
+ miOutOfBandRecord.Add(miValueResult2);
bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord);
bOk = bOk && CMICmnStreamStdout::WritePrompt();
return bOk;
@@ -1385,24 +1393,19 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopReasonTrace(void)
const CMICmnMIValueResult miValueResult("reason", miValueConst);
CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult);
const CMICmnMIValueResult miValueResult2("frame", miValueTuple);
- bOk = miOutOfBandRecord.Add(miValueResult2);
+ miOutOfBandRecord.Add(miValueResult2);
// Add to MI thread-id=\"%d\",stopped-threads=\"all\"
- if (bOk)
- {
- const CMIUtilString strThreadId(CMIUtilString::Format("%d", thread.GetIndexID()));
- const CMICmnMIValueConst miValueConst8(strThreadId);
- const CMICmnMIValueResult miValueResult8("thread-id", miValueConst8);
- bOk = miOutOfBandRecord.Add(miValueResult8);
- }
- if (bOk)
- {
- const CMICmnMIValueConst miValueConst9("all");
- const CMICmnMIValueResult miValueResult9("stopped-threads", miValueConst9);
- bOk = miOutOfBandRecord.Add(miValueResult9);
- bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord);
- bOk = bOk && CMICmnStreamStdout::WritePrompt();
- }
+ const CMIUtilString strThreadId(CMIUtilString::Format("%d", thread.GetIndexID()));
+ const CMICmnMIValueConst miValueConst8(strThreadId);
+ const CMICmnMIValueResult miValueResult8("thread-id", miValueConst8);
+ miOutOfBandRecord.Add(miValueResult8);
+
+ const CMICmnMIValueConst miValueConst9("all");
+ const CMICmnMIValueResult miValueResult9("stopped-threads", miValueConst9);
+ miOutOfBandRecord.Add(miValueResult9);
+ bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord);
+ bOk = bOk && CMICmnStreamStdout::WritePrompt();
return bOk;
}
@@ -1416,7 +1419,7 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopReasonTrace(void)
// Throws: None.
//--
bool
-CMICmnLLDBDebuggerHandleEvents::UpdateSelectedThread(void)
+CMICmnLLDBDebuggerHandleEvents::UpdateSelectedThread()
{
lldb::SBProcess process = CMICmnLLDBDebugSessionInfo::Instance().GetDebugger().GetSelectedTarget().GetProcess();
if (!process.IsValid())
@@ -1487,7 +1490,7 @@ CMICmnLLDBDebuggerHandleEvents::UpdateSelectedThread(void)
// Throws: None.
//--
bool
-CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateRunning(void)
+CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateRunning()
{
CMICmnMIValueConst miValueConst("all");
CMICmnMIValueResult miValueResult("thread-id", miValueConst);
@@ -1510,7 +1513,7 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateRunning(void)
// Throws: None.
//--
bool
-CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateExited(void)
+CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateExited()
{
const CMIUtilString strId(CMIUtilString::Format("%ld", 1));
CMICmnMIValueConst miValueConst(strId);
@@ -1518,8 +1521,8 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateExited(void)
CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited, miValueResult);
CMICmnMIValueConst miValueConst2("i1");
CMICmnMIValueResult miValueResult2("group-id", miValueConst2);
- bool bOk = miOutOfBandRecord.Add(miValueResult2);
- bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord);
+ miOutOfBandRecord.Add(miValueResult2);
+ bool bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord);
if (bOk)
{
CMICmnMIValueConst miValueConst3("i1");
@@ -1527,7 +1530,7 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateExited(void)
CMICmnMIOutOfBandRecord miOutOfBandRecord2(CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited, miValueResult3);
CMICmnMIValueConst miValueConst2("0");
CMICmnMIValueResult miValueResult2("exit-code", miValueConst2);
- bOk = miOutOfBandRecord2.Add(miValueResult2);
+ miOutOfBandRecord2.Add(miValueResult2);
bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord2);
}
if (bOk)
@@ -1553,7 +1556,7 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateExited(void)
// Throws: None.
//--
bool
-CMICmnLLDBDebuggerHandleEvents::GetProcessStdout(void)
+CMICmnLLDBDebuggerHandleEvents::GetProcessStdout()
{
CMIUtilString text;
std::unique_ptr<char[]> apStdoutBuffer(new char[1024]);
@@ -1569,7 +1572,7 @@ CMICmnLLDBDebuggerHandleEvents::GetProcessStdout(void)
if (nNewLine == std::string::npos)
break;
- const CMIUtilString line(text.substr(0, nNewLine + 1).c_str());
+ const CMIUtilString line(text.substr(0, nNewLine + 1));
text.erase(0, nNewLine + 1);
const bool bEscapeQuotes(true);
CMICmnMIValueConst miValueConst(line.Escape(bEscapeQuotes));
@@ -1606,7 +1609,7 @@ CMICmnLLDBDebuggerHandleEvents::GetProcessStdout(void)
// Throws: None.
//--
bool
-CMICmnLLDBDebuggerHandleEvents::GetProcessStderr(void)
+CMICmnLLDBDebuggerHandleEvents::GetProcessStderr()
{
CMIUtilString text;
std::unique_ptr<char[]> apStderrBuffer(new char[1024]);
@@ -1622,7 +1625,7 @@ CMICmnLLDBDebuggerHandleEvents::GetProcessStderr(void)
if (nNewLine == std::string::npos)
break;
- const CMIUtilString line(text.substr(0, nNewLine + 1).c_str());
+ const CMIUtilString line(text.substr(0, nNewLine + 1));
const bool bEscapeQuotes(true);
CMICmnMIValueConst miValueConst(line.Escape(bEscapeQuotes));
CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput, miValueConst);
@@ -1656,7 +1659,7 @@ CMICmnLLDBDebuggerHandleEvents::GetProcessStderr(void)
// Throws: None.
//--
bool
-CMICmnLLDBDebuggerHandleEvents::ChkForStateChanges(void)
+CMICmnLLDBDebuggerHandleEvents::ChkForStateChanges()
{
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
@@ -1686,8 +1689,8 @@ CMICmnLLDBDebuggerHandleEvents::ChkForStateChanges(void)
CMICmnMIOutOfBandRecord miOutOfBand(CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated, miValueResult);
const CMICmnMIValueConst miValueConst2("i1");
const CMICmnMIValueResult miValueResult2("group-id", miValueConst2);
- bool bOk = miOutOfBand.Add(miValueResult2);
- bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBand);
+ miOutOfBand.Add(miValueResult2);
+ bool bOk = MiOutOfBandRecordToStdout(miOutOfBand);
if (!bOk)
return MIstatus::failure;
}
@@ -1726,8 +1729,8 @@ CMICmnLLDBDebuggerHandleEvents::ChkForStateChanges(void)
CMICmnMIOutOfBandRecord miOutOfBand(CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited, miValueResult);
const CMICmnMIValueConst miValueConst2("i1");
const CMICmnMIValueResult miValueResult2("group-id", miValueConst2);
- bool bOk = miOutOfBand.Add(miValueResult2);
- bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBand);
+ miOutOfBand.Add(miValueResult2);
+ bool bOk = MiOutOfBandRecordToStdout(miOutOfBand);
if (!bOk)
return MIstatus::failure;
diff --git a/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h b/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
index 1abb52012979..f5075d10209c 100644
--- a/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
+++ b/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
@@ -26,9 +26,6 @@ class CMICmnMIOutOfBandRecord;
// MI Out-of-band records from the information inside the event object.
// These records are then pushed to stdout.
// A singleton class.
-// Gotchas: None.
-// Authors: Illya Rudkin 02/03/2014.
-// Changes: None.
//--
class CMICmnLLDBDebuggerHandleEvents : public CMICmnBase, public MI::ISingleton<CMICmnLLDBDebuggerHandleEvents>
{
@@ -36,20 +33,20 @@ class CMICmnLLDBDebuggerHandleEvents : public CMICmnBase, public MI::ISingleton<
// Methods:
public:
- bool Initialize(void) override;
- bool Shutdown(void) override;
+ bool Initialize() override;
+ bool Shutdown() override;
//
bool HandleEvent(const lldb::SBEvent &vEvent, bool &vrbHandledEvent);
// Methods:
private:
- /* ctor */ CMICmnLLDBDebuggerHandleEvents(void);
+ /* ctor */ CMICmnLLDBDebuggerHandleEvents();
/* ctor */ CMICmnLLDBDebuggerHandleEvents(const CMICmnLLDBDebuggerHandleEvents &);
void operator=(const CMICmnLLDBDebuggerHandleEvents &);
//
- bool ChkForStateChanges(void);
- bool GetProcessStdout(void);
- bool GetProcessStderr(void);
+ bool ChkForStateChanges();
+ bool GetProcessStdout();
+ bool GetProcessStderr();
bool HandleEventSBBreakPoint(const lldb::SBEvent &vEvent);
bool HandleEventSBBreakpointCmn(const lldb::SBEvent &vEvent);
bool HandleEventSBBreakpointAdded(const lldb::SBEvent &vEvent);
@@ -61,13 +58,13 @@ class CMICmnLLDBDebuggerHandleEvents : public CMICmnBase, public MI::ISingleton<
bool HandleEventSBThreadSuspended(const lldb::SBEvent &vEvent);
bool HandleEventSBCommandInterpreter(const lldb::SBEvent &vEvent);
bool HandleProcessEventBroadcastBitStateChanged(const lldb::SBEvent &vEvent);
- bool HandleProcessEventStateRunning(void);
- bool HandleProcessEventStateExited(void);
+ bool HandleProcessEventStateRunning();
+ bool HandleProcessEventStateExited();
bool HandleProcessEventStateStopped(const lldb::SBEvent &vrEvent, bool &vwrbShouldBrk);
- bool HandleProcessEventStopReasonTrace(void);
- bool HandleProcessEventStopReasonBreakpoint(void);
+ bool HandleProcessEventStopReasonTrace();
+ bool HandleProcessEventStopReasonBreakpoint();
bool HandleProcessEventStopSignal(const lldb::SBEvent &vrEvent);
- bool HandleProcessEventStopException(void);
+ bool HandleProcessEventStopException();
bool HandleProcessEventStateSuspended(const lldb::SBEvent &vEvent);
bool HandleTargetEventBroadcastBitModulesLoaded(const lldb::SBEvent &vEvent);
bool HandleTargetEventBroadcastBitModulesUnloaded(const lldb::SBEvent &vEvent);
@@ -79,12 +76,12 @@ class CMICmnLLDBDebuggerHandleEvents : public CMICmnBase, public MI::ISingleton<
bool MiStoppedAtBreakPoint(const MIuint64 vBrkPtId, const lldb::SBBreakpoint &vBrkPt);
bool TextToStdout(const CMIUtilString &vrTxt);
bool TextToStderr(const CMIUtilString &vrTxt);
- bool UpdateSelectedThread(void);
+ bool UpdateSelectedThread();
// Overridden:
private:
// From CMICmnBase
- /* dtor */ ~CMICmnLLDBDebuggerHandleEvents(void) override;
+ /* dtor */ ~CMICmnLLDBDebuggerHandleEvents() override;
void InitializeSignals();
bool m_bSignalsInitialized;
MIuint64 m_SIGINT;
diff --git a/tools/lldb-mi/MICmnLLDBProxySBValue.h b/tools/lldb-mi/MICmnLLDBProxySBValue.h
index c9cd3a9f995f..2ae3acf3d7e7 100644
--- a/tools/lldb-mi/MICmnLLDBProxySBValue.h
+++ b/tools/lldb-mi/MICmnLLDBProxySBValue.h
@@ -21,9 +21,6 @@ class CMIUtilString;
//++ ============================================================================
// Details: MI proxy wrapper class to lldb::SBValue. The class provides functionality
// to assist in the use of SBValue's particular function usage.
-// Gotchas: None.
-// Authors: Illya Rudkin 03/04/2014.
-// Changes: None.
//--
class CMICmnLLDBProxySBValue
{
diff --git a/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp b/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
index 45f030bf535f..d3d85d32c038 100644
--- a/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
+++ b/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
@@ -9,6 +9,7 @@
// Third party headers:
#include <cinttypes>
+#include "lldb/API/SBTypeSummary.h"
// In-house headers:
#include "MICmnLLDBUtilSBValue.h"
@@ -44,7 +45,7 @@ CMICmnLLDBUtilSBValue::CMICmnLLDBUtilSBValue(const lldb::SBValue &vrValue, const
// Return: None.
// Throws: None.
//--
-CMICmnLLDBUtilSBValue::~CMICmnLLDBUtilSBValue(void)
+CMICmnLLDBUtilSBValue::~CMICmnLLDBUtilSBValue()
{
}
@@ -57,10 +58,10 @@ CMICmnLLDBUtilSBValue::~CMICmnLLDBUtilSBValue(void)
// Throws: None.
//--
CMIUtilString
-CMICmnLLDBUtilSBValue::GetName(void) const
+CMICmnLLDBUtilSBValue::GetName() const
{
const char *pName = m_bValidSBValue ? m_rValue.GetName() : nullptr;
- const CMIUtilString text((pName != nullptr) ? pName : m_pUnkwn);
+ const CMIUtilString text((pName != nullptr) ? pName : CMIUtilString());
return text;
}
@@ -122,31 +123,13 @@ CMICmnLLDBUtilSBValue::GetSimpleValue(const bool vbHandleArrayType, CMIUtilStrin
const MIuint nChildren = m_rValue.GetNumChildren();
if (nChildren == 0)
{
- if (m_bHandleCharType && IsCharType())
- {
- vwrValue = GetSimpleValueChar();
- return MIstatus::success;
- }
- else
- {
- const char *pValue = m_rValue.GetValue();
- vwrValue = pValue != nullptr ? pValue : m_pUnkwn;
- return MIstatus::success;
- }
+ vwrValue = GetValueSummary(!m_bHandleCharType && IsCharType(), m_pUnkwn);
+ return MIstatus::success;
}
else if (IsPointerType())
{
- if (m_bHandleCharType && IsFirstChildCharType())
- {
- vwrValue = GetSimpleValueCStringPointer();
- return MIstatus::success;
- }
- else
- {
- const char *pValue = m_rValue.GetValue();
- vwrValue = pValue != nullptr ? pValue : m_pUnkwn;
- return MIstatus::success;
- }
+ vwrValue = GetValueSummary(!m_bHandleCharType && IsPointeeCharType(), m_pUnkwn);
+ return MIstatus::success;
}
else if (IsArrayType())
{
@@ -156,7 +139,7 @@ CMICmnLLDBUtilSBValue::GetSimpleValue(const bool vbHandleArrayType, CMIUtilStrin
bPrintCharArrayAsString) && bPrintCharArrayAsString;
if (bPrintCharArrayAsString && m_bHandleCharType && IsFirstChildCharType())
{
- vwrValue = GetSimpleValueCStringArray();
+ vwrValue = GetValueSummary(false);
return MIstatus::success;
}
else if (vbHandleArrayType)
@@ -165,140 +148,17 @@ CMICmnLLDBUtilSBValue::GetSimpleValue(const bool vbHandleArrayType, CMIUtilStrin
return MIstatus::success;
}
}
-
- // Composite variable type i.e. struct
- return MIstatus::failure;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve from the LLDB SB Value object the char value of the variable.
-// Type: Method.
-// Args: None.
-// Return: CMIUtilString - The char value of the variable.
-// Throws: None.
-//--
-CMIUtilString
-CMICmnLLDBUtilSBValue::GetSimpleValueChar(void) const
-{
- const uint64_t value = m_rValue.GetValueAsUnsigned();
- if (value == 0)
- {
- const uint64_t nFailValue = 1;
- if (nFailValue == m_rValue.GetValueAsUnsigned(nFailValue))
- return m_pUnkwn;
- }
-
- const lldb::BasicType eType = m_rValue.GetType().GetBasicType();
- switch (eType)
- {
- default:
- assert(0 && "value must be a char type");
- case lldb::eBasicTypeChar:
- case lldb::eBasicTypeSignedChar:
- case lldb::eBasicTypeUnsignedChar:
- {
- const CMIUtilString prefix(CMIUtilString::ConvertToPrintableASCII((char)value));
- return CMIUtilString::Format("%" PRIu8 " '%s'", (uint8_t)value, prefix.c_str());
- }
- case lldb::eBasicTypeChar16:
- {
- const CMIUtilString prefix(CMIUtilString::ConvertToPrintableASCII((char16_t)value));
- return CMIUtilString::Format("U+%04" PRIx16 " u'%s'", (uint16_t)value, prefix.c_str());
- }
- case lldb::eBasicTypeChar32:
- {
- const CMIUtilString prefix(CMIUtilString::ConvertToPrintableASCII((char32_t)value));
- return CMIUtilString::Format("U+%08" PRIx32 " U'%s'", (uint32_t)value, prefix.c_str());
- }
- }
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve from the LLDB SB Value object of type char* the c-string value.
-// Type: Method.
-// Args: None.
-// Return: CMIUtilString - The c-string value of the variable.
-// Throws: None.
-//--
-CMIUtilString
-CMICmnLLDBUtilSBValue::GetSimpleValueCStringPointer(void) const
-{
- const char *value = m_rValue.GetValue();
- if (value == nullptr)
- return m_pUnkwn;
-
- lldb::SBValue child = m_rValue.GetChildAtIndex(0);
- const lldb::BasicType eType = child.GetType().GetBasicType();
- switch (eType)
+ else
{
- default:
- assert(0 && "child must be a char type");
- case lldb::eBasicTypeChar:
- case lldb::eBasicTypeSignedChar:
- case lldb::eBasicTypeUnsignedChar:
- {
- // FIXME Add slashes before double quotes
- const CMIUtilString prefix(ReadCStringFromHostMemory<char>(child).AddSlashes());
- // Note code that has const in will not show the text suffix to the string pointer
- // i.e. const char * pMyStr = "blah"; ==> "0x00007000"" <-- Eclipse shows this
- // but char * pMyStr = "blah"; ==> "0x00007000" "blah"" <-- Eclipse shows this
- return CMIUtilString::Format("%s \"%s\"", value, prefix.c_str());
- }
- case lldb::eBasicTypeChar16:
- {
- // FIXME Add slashes before double quotes
- const CMIUtilString prefix(ReadCStringFromHostMemory<char16_t>(child).AddSlashes());
- return CMIUtilString::Format("%s u\"%s\"", value, prefix.c_str());
- }
- case lldb::eBasicTypeChar32:
- {
- // FIXME Add slashes before double quotes
- const CMIUtilString prefix(ReadCStringFromHostMemory<char32_t>(child).AddSlashes());
- return CMIUtilString::Format("%s U\"%s\"", value, prefix.c_str());
- }
+ // Treat composite value which has registered summary
+ // (for example with AddCXXSummary) as simple value
+ vwrValue = GetValueSummary(false);
+ if (!vwrValue.empty())
+ return MIstatus::success;
}
-}
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve from the LLDB SB Value object of type char[] the c-string value.
-// Type: Method.
-// Args: None.
-// Return: CMIUtilString - The c-string value of the variable.
-// Throws: None.
-//--
-CMIUtilString
-CMICmnLLDBUtilSBValue::GetSimpleValueCStringArray(void) const
-{
- const MIuint nChildren = m_rValue.GetNumChildren();
- lldb::SBValue child = m_rValue.GetChildAtIndex(0);
- const lldb::BasicType eType = child.GetType().GetBasicType();
- switch (eType)
- {
- default:
- assert(0 && "value must be a char[] type");
- case lldb::eBasicTypeChar:
- case lldb::eBasicTypeSignedChar:
- case lldb::eBasicTypeUnsignedChar:
- {
- // FIXME Add slashes before double quotes
- const CMIUtilString prefix(ReadCStringFromHostMemory<char>(m_rValue, nChildren).AddSlashes());
- // TODO: to match char* it should be the following
- // return CMIUtilString::Format("[%u] \"%s\"", nChildren, prefix.c_str());
- return CMIUtilString::Format("\"%s\"", prefix.c_str());
- }
- case lldb::eBasicTypeChar16:
- {
- // FIXME Add slashes before double quotes
- const CMIUtilString prefix(ReadCStringFromHostMemory<char16_t>(m_rValue, nChildren).AddSlashes());
- return CMIUtilString::Format("u\"%s\"", prefix.c_str());
- }
- case lldb::eBasicTypeChar32:
- {
- // FIXME Add slashes before double quotes
- const CMIUtilString prefix(ReadCStringFromHostMemory<char32_t>(m_rValue, nChildren).AddSlashes());
- return CMIUtilString::Format("U\"%s\"", prefix.c_str());
- }
- }
+ // Composite variable type i.e. struct
+ return MIstatus::failure;
}
bool
@@ -341,34 +201,61 @@ CMICmnLLDBUtilSBValue::GetCompositeValue(const bool vbPrintFieldNames, CMICmnMIV
{
const bool bUseSpacing = true;
const CMICmnMIValueResult miValueResult(utilMember.GetName(), miValueConst, bUseSpacing);
- const bool bOk = vwrMiValueTuple.Add(miValueResult, bUseSpacing);
- if (!bOk)
- return MIstatus::failure;
+ vwrMiValueTuple.Add(miValueResult, bUseSpacing);
}
else
{
const bool bUseSpacing = false;
- const bool bOk = vwrMiValueTuple.Add(miValueConst, bUseSpacing);
- if (!bOk)
- return MIstatus::failure;
+ vwrMiValueTuple.Add(miValueConst, bUseSpacing);
}
}
return MIstatus::success;
}
+// Returns value or value + summary, depending on valueOnly parameter value.
+// If result is an empty string returns failVal.
+CMIUtilString
+CMICmnLLDBUtilSBValue::GetValueSummary(bool valueOnly, const CMIUtilString& failVal) const
+{
+ if (!m_rValue.IsValid())
+ return failVal;
+
+ CMIUtilString value, valSummary;
+ const char* c_value = m_rValue.GetValue();
+ if (valueOnly)
+ return c_value == nullptr ? failVal : c_value;
+
+ const char* c_summary = m_rValue.GetSummary();
+ if (c_value)
+ value = c_value;
+ else if (c_summary == nullptr)
+ return failVal;
+
+ if (c_summary && c_summary[0])
+ {
+ valSummary = c_summary;
+ lldb::SBTypeSummary summary = m_rValue.GetTypeSummary();
+ if (summary.IsValid() && summary.DoesPrintValue(m_rValue) && !value.empty())
+ {
+ valSummary.insert(0, value + " ");
+ }
+ return valSummary;
+ }
+ // no summary - return just value
+ return value;
+}
+
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the flag stating whether this value object is a char type or some
-// other type. Char type can be signed or unsigned.
-// Type: Method.
-// Args: None.
+// Details: Check that basic type is a char type. Char type can be signed or unsigned.
+// Type: Static.
+// Args: eType - type to check
// Return: bool - True = Yes is a char type, false = some other type.
// Throws: None.
//--
bool
-CMICmnLLDBUtilSBValue::IsCharType(void) const
+CMICmnLLDBUtilSBValue::IsCharBasicType(lldb::BasicType eType)
{
- const lldb::BasicType eType = m_rValue.GetType().GetBasicType();
switch (eType)
{
case lldb::eBasicTypeChar:
@@ -383,6 +270,21 @@ CMICmnLLDBUtilSBValue::IsCharType(void) const
}
//++ ------------------------------------------------------------------------------------
+// Details: Retrieve the flag stating whether this value object is a char type or some
+// other type. Char type can be signed or unsigned.
+// Type: Method.
+// Args: None.
+// Return: bool - True = Yes is a char type, false = some other type.
+// Throws: None.
+//--
+bool
+CMICmnLLDBUtilSBValue::IsCharType() const
+{
+ const lldb::BasicType eType = m_rValue.GetType().GetBasicType();
+ return IsCharBasicType(eType);
+}
+
+//++ ------------------------------------------------------------------------------------
// 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 children. Char
// type can be signed or unsigned.
@@ -392,7 +294,7 @@ CMICmnLLDBUtilSBValue::IsCharType(void) const
// Throws: None.
//--
bool
-CMICmnLLDBUtilSBValue::IsFirstChildCharType(void) const
+CMICmnLLDBUtilSBValue::IsFirstChildCharType() const
{
const MIuint nChildren = m_rValue.GetNumChildren();
@@ -406,6 +308,28 @@ CMICmnLLDBUtilSBValue::IsFirstChildCharType(void) 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
+// type can be signed or unsigned.
+// Type: Method.
+// Args: None.
+// Return: bool - True = Yes is a char type, false = some other type.
+// Throws: None.
+//--
+bool
+CMICmnLLDBUtilSBValue::IsPointeeCharType() const
+{
+ const MIuint nChildren = m_rValue.GetNumChildren();
+
+ // Is it a basic type
+ if (nChildren == 0)
+ return false;
+
+ const lldb::BasicType eType = m_rValue.GetType().GetPointeeType().GetBasicType();
+ return IsCharBasicType(eType);
+}
+
+//++ ------------------------------------------------------------------------------------
// 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 long/very long.
// Type: Method.
@@ -414,7 +338,7 @@ CMICmnLLDBUtilSBValue::IsFirstChildCharType(void) const
// Throws: None.
//--
bool
-CMICmnLLDBUtilSBValue::IsIntegerType(void) const
+CMICmnLLDBUtilSBValue::IsIntegerType() const
{
const lldb::BasicType eType = m_rValue.GetType().GetBasicType();
return ((eType == lldb::eBasicTypeShort) || (eType == lldb::eBasicTypeUnsignedShort) ||
@@ -433,7 +357,7 @@ CMICmnLLDBUtilSBValue::IsIntegerType(void) const
// Throws: None.
//--
bool
-CMICmnLLDBUtilSBValue::IsPointerType(void) const
+CMICmnLLDBUtilSBValue::IsPointerType() const
{
return m_rValue.GetType().IsPointerType();
}
@@ -447,7 +371,7 @@ CMICmnLLDBUtilSBValue::IsPointerType(void) const
// Throws: None.
//--
bool
-CMICmnLLDBUtilSBValue::IsArrayType(void) const
+CMICmnLLDBUtilSBValue::IsArrayType() const
{
return m_rValue.GetType().IsArrayType();
}
@@ -476,11 +400,11 @@ CMICmnLLDBUtilSBValue::ReadCStringFromHostMemory(lldb::SBValue &vrValue, const M
return m_pUnkwn;
else if (ch == 0)
break;
- result.append(CMIUtilString::ConvertToPrintableASCII(ch));
+ result.append(CMIUtilString::ConvertToPrintableASCII(ch, true /* bEscapeQuotes */));
addr += sizeof(ch);
}
- return result.c_str();
+ return result;
}
//++ ------------------------------------------------------------------------------------
@@ -491,7 +415,7 @@ CMICmnLLDBUtilSBValue::ReadCStringFromHostMemory(lldb::SBValue &vrValue, const M
// Throws: None.
//--
bool
-CMICmnLLDBUtilSBValue::IsNameUnknown(void) const
+CMICmnLLDBUtilSBValue::IsNameUnknown() const
{
const CMIUtilString name(GetName());
return (name == m_pUnkwn);
@@ -505,7 +429,7 @@ CMICmnLLDBUtilSBValue::IsNameUnknown(void) const
// Throws: None.
//--
bool
-CMICmnLLDBUtilSBValue::IsValueUnknown(void) const
+CMICmnLLDBUtilSBValue::IsValueUnknown() const
{
const CMIUtilString value(GetValue());
return (value == m_pUnkwn);
@@ -519,7 +443,7 @@ CMICmnLLDBUtilSBValue::IsValueUnknown(void) const
// Throws: None.
//--
CMIUtilString
-CMICmnLLDBUtilSBValue::GetTypeName(void) const
+CMICmnLLDBUtilSBValue::GetTypeName() const
{
const char *pName = m_bValidSBValue ? m_rValue.GetTypeName() : nullptr;
const CMIUtilString text((pName != nullptr) ? pName : m_pUnkwn);
@@ -535,7 +459,7 @@ CMICmnLLDBUtilSBValue::GetTypeName(void) const
// Throws: None.
//--
CMIUtilString
-CMICmnLLDBUtilSBValue::GetTypeNameDisplay(void) const
+CMICmnLLDBUtilSBValue::GetTypeNameDisplay() const
{
const char *pName = m_bValidSBValue ? m_rValue.GetDisplayTypeName() : nullptr;
const CMIUtilString text((pName != nullptr) ? pName : m_pUnkwn);
@@ -551,7 +475,7 @@ CMICmnLLDBUtilSBValue::GetTypeNameDisplay(void) const
// Throws: None.
//--
bool
-CMICmnLLDBUtilSBValue::IsValid(void) const
+CMICmnLLDBUtilSBValue::IsValid() const
{
return m_bValidSBValue;
}
@@ -565,7 +489,7 @@ CMICmnLLDBUtilSBValue::IsValid(void) const
// Throws: None.
//--
bool
-CMICmnLLDBUtilSBValue::HasName(void) const
+CMICmnLLDBUtilSBValue::HasName() const
{
bool bHasAName = false;
@@ -586,7 +510,7 @@ CMICmnLLDBUtilSBValue::HasName(void) const
// Throws: None.
//--
bool
-CMICmnLLDBUtilSBValue::IsLLDBVariable(void) const
+CMICmnLLDBUtilSBValue::IsLLDBVariable() const
{
return (GetName().at(0) == '$');
}
diff --git a/tools/lldb-mi/MICmnLLDBUtilSBValue.h b/tools/lldb-mi/MICmnLLDBUtilSBValue.h
index 8bb6783a2a34..36264da1e16d 100644
--- a/tools/lldb-mi/MICmnLLDBUtilSBValue.h
+++ b/tools/lldb-mi/MICmnLLDBUtilSBValue.h
@@ -22,9 +22,6 @@ class CMIUtilString;
//++ ============================================================================
// Details: Utility helper class to lldb::SBValue. Using a lldb::SBValue extract
// value object information to help form verbose debug information.
-// Gotchas: None.
-// Authors: Illya Rudkin 08/07/2014.
-// Changes: None.
//--
class CMICmnLLDBUtilSBValue
{
@@ -32,31 +29,34 @@ class CMICmnLLDBUtilSBValue
public:
/* ctor */ CMICmnLLDBUtilSBValue(const lldb::SBValue &vrValue, const bool vbHandleCharType = false,
const bool vbHandleArrayType = true);
- /* dtor */ ~CMICmnLLDBUtilSBValue(void);
+ /* dtor */ ~CMICmnLLDBUtilSBValue();
//
- CMIUtilString GetName(void) const;
+ CMIUtilString GetName() const;
CMIUtilString GetValue(const bool vbExpandAggregates = false) const;
- CMIUtilString GetTypeName(void) const;
- CMIUtilString GetTypeNameDisplay(void) const;
- bool IsCharType(void) const;
- bool IsFirstChildCharType(void) const;
- bool IsIntegerType(void) const;
- bool IsPointerType(void) const;
- bool IsArrayType(void) const;
- bool IsLLDBVariable(void) const;
- bool IsNameUnknown(void) const;
- bool IsValueUnknown(void) const;
- bool IsValid(void) const;
- bool HasName(void) const;
+ CMIUtilString GetTypeName() const;
+ CMIUtilString GetTypeNameDisplay() const;
+ bool IsCharType() const;
+ bool IsFirstChildCharType() const;
+ bool IsPointeeCharType() const;
+ bool IsIntegerType() const;
+ bool IsPointerType() const;
+ bool IsArrayType() const;
+ bool IsLLDBVariable() const;
+ bool IsNameUnknown() const;
+ bool IsValueUnknown() const;
+ bool IsValid() const;
+ bool HasName() const;
// Methods:
private:
template <typename charT> CMIUtilString ReadCStringFromHostMemory(lldb::SBValue &vrValue, const MIuint vnMaxLen = UINT32_MAX) const;
bool GetSimpleValue(const bool vbHandleArrayType, CMIUtilString &vrValue) const;
- CMIUtilString GetSimpleValueChar(void) const;
- CMIUtilString GetSimpleValueCStringPointer(void) const;
- CMIUtilString GetSimpleValueCStringArray(void) const;
bool GetCompositeValue(const bool vbPrintFieldNames, CMICmnMIValueTuple &vwrMiValueTuple, const MIuint vnDepth = 1) const;
+ CMIUtilString GetValueSummary(bool valueOnly, const CMIUtilString& failVal = CMIUtilString()) const;
+
+ // Statics:
+ private:
+ static bool IsCharBasicType(lldb::BasicType eType);
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmnLog.cpp b/tools/lldb-mi/MICmnLog.cpp
index a88ba6b5782a..e85ddba316a4 100644
--- a/tools/lldb-mi/MICmnLog.cpp
+++ b/tools/lldb-mi/MICmnLog.cpp
@@ -21,7 +21,7 @@
// Return: None.
// Throws: None.
//--
-CMICmnLog::CMICmnLog(void)
+CMICmnLog::CMICmnLog()
: m_bEnabled(false)
, m_bInitializingATM(false)
{
@@ -35,7 +35,7 @@ CMICmnLog::CMICmnLog(void)
// Return: None.
// Throws: None.
//--
-CMICmnLog::~CMICmnLog(void)
+CMICmnLog::~CMICmnLog()
{
Shutdown();
}
@@ -49,7 +49,7 @@ CMICmnLog::~CMICmnLog(void)
// Throws: None.
//--
bool
-CMICmnLog::Initialize(void)
+CMICmnLog::Initialize()
{
m_clientUsageRefCnt++;
@@ -102,7 +102,7 @@ CMICmnLog::Initialize(void)
// Throws: None.
//--
bool
-CMICmnLog::Shutdown(void)
+CMICmnLog::Shutdown()
{
if (--m_clientUsageRefCnt > 0)
return MIstatus::success;
@@ -144,7 +144,7 @@ CMICmnLog::SetEnabled(const bool vbYes)
// Throws: None.
//--
bool
-CMICmnLog::GetEnabled(void) const
+CMICmnLog::GetEnabled() const
{
return m_bEnabled;
}
@@ -158,7 +158,7 @@ CMICmnLog::GetEnabled(void) const
// Throws: None.
//--
bool
-CMICmnLog::UnregisterMediumAll(void)
+CMICmnLog::UnregisterMediumAll()
{
MapMediumToName_t::const_iterator it = m_mapMediumToName.begin();
for (; it != m_mapMediumToName.end(); it++)
@@ -325,7 +325,7 @@ CMICmnLog::WriteLog(const CMIUtilString &vData)
// Throws: None.
//--
const CMIUtilString &
-CMICmnLog::GetErrorDescription(void) const
+CMICmnLog::GetErrorDescription() const
{
return m_strMILastErrorDescription;
}
@@ -351,7 +351,7 @@ CMICmnLog::SetErrorDescription(const CMIUtilString &vrTxt) const
// Throws: None.
//--
void
-CMICmnLog::ClrErrorDescription(void) const
+CMICmnLog::ClrErrorDescription() const
{
m_strMILastErrorDescription = CMIUtilString("");
}
diff --git a/tools/lldb-mi/MICmnLog.h b/tools/lldb-mi/MICmnLog.h
index f0ae534e840b..a346cf4bd1db 100644
--- a/tools/lldb-mi/MICmnLog.h
+++ b/tools/lldb-mi/MICmnLog.h
@@ -26,9 +26,6 @@
// *this logs initialization so it will always have a file log for the
// application.
// Singleton class.
-// Gotchas: None.
-// Authors: Illya Rudkin 01/02/2012.
-// Changes: None.
//--
class CMICmnLog : public MI::ISingleton<CMICmnLog>
{
@@ -59,17 +56,17 @@ class CMICmnLog : public MI::ISingleton<CMICmnLog>
class IMedium
{
public:
- virtual bool Initialize(void) = 0;
- virtual const CMIUtilString &GetName(void) const = 0;
+ virtual bool Initialize() = 0;
+ virtual const CMIUtilString &GetName() const = 0;
virtual bool Write(const CMIUtilString &vData, const ELogVerbosity veType) = 0;
- virtual const CMIUtilString &GetError(void) const = 0;
- virtual bool Shutdown(void) = 0;
+ virtual const CMIUtilString &GetError() const = 0;
+ virtual bool Shutdown() = 0;
// Not part of the interface, ignore
// AD: This virtual destructor seems to hit a bug in the stdlib
// where vector delete is incorrectly called. Workaround is
// to comment this out while I investigate.
- /* dtor */ virtual ~IMedium(void) {}
+ /* dtor */ virtual ~IMedium() {}
};
// Statics:
@@ -82,30 +79,30 @@ class CMICmnLog : public MI::ISingleton<CMICmnLog>
bool UnregisterMedium(const IMedium &vrMedium);
bool Write(const CMIUtilString &vData, const ELogVerbosity veType);
bool SetEnabled(const bool vbYes);
- bool GetEnabled(void) const;
+ bool GetEnabled() const;
// MI common object handling - duplicate of CMICmnBase functions, necessary for LINUX build
// Done to stop locking on object construction init circular dependency.
- const CMIUtilString &GetErrorDescription(void) const;
+ const CMIUtilString &GetErrorDescription() const;
void SetErrorDescription(const CMIUtilString &vrTxt) const;
- void ClrErrorDescription(void) const;
+ void ClrErrorDescription() const;
// Overridden:
public:
// From MI::ISingleton
- bool Initialize(void) override;
- bool Shutdown(void) override;
+ bool Initialize() override;
+ bool Shutdown() override;
// Methods:
private:
- /* ctor */ CMICmnLog(void);
+ /* ctor */ CMICmnLog();
/* ctor */ CMICmnLog(const CMICmnLog &);
void operator=(const CMICmnLog &);
// Overridden:
private:
// From CMICmnBase
- /* dtor */ ~CMICmnLog(void) override;
+ /* dtor */ ~CMICmnLog() override;
// Typedef:
private:
@@ -115,7 +112,7 @@ class CMICmnLog : public MI::ISingleton<CMICmnLog>
// Methods:
private:
bool HaveMediumAlready(const IMedium &vrMedium) const;
- bool UnregisterMediumAll(void);
+ bool UnregisterMediumAll();
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmnLogMediumFile.cpp b/tools/lldb-mi/MICmnLogMediumFile.cpp
index 67b8086221cd..e74fca9aa5b0 100644
--- a/tools/lldb-mi/MICmnLogMediumFile.cpp
+++ b/tools/lldb-mi/MICmnLogMediumFile.cpp
@@ -10,13 +10,6 @@
// In-house headers:
#include "MICmnLogMediumFile.h"
#include "MICmnResources.h"
-#if defined(_MSC_VER)
-#include "MIUtilSystemWindows.h"
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__linux__)
-#include "MIUtilSystemLinux.h"
-#elif defined(__APPLE__)
-#include "MIUtilSystemOsx.h"
-#endif // defined( _MSC_VER )
//++ ------------------------------------------------------------------------------------
// Details: CMICmnLogMediumFile constructor.
@@ -25,11 +18,11 @@
// Return: None.
// Throws: None.
//--
-CMICmnLogMediumFile::CMICmnLogMediumFile(void)
+CMICmnLogMediumFile::CMICmnLogMediumFile()
: m_constThisMediumName(MIRSRC(IDS_MEDIUMFILE_NAME))
, m_constMediumFileNameFormat("lldb-mi-%s.log")
, m_strMediumFileName(MIRSRC(IDS_MEDIUMFILE_ERR_INVALID_PATH))
- , m_strMediumFileDirectory(MIRSRC(IDS_MEDIUMFILE_ERR_INVALID_PATH))
+ , m_strMediumFileDirectory(".")
, m_fileNamePath(MIRSRC(IDS_MEDIUMFILE_ERR_INVALID_PATH))
, m_eVerbosityType(CMICmnLog::eLogVerbosity_Log)
, m_strDate(CMIUtilDateTimeStd().GetDate())
@@ -44,7 +37,7 @@ CMICmnLogMediumFile::CMICmnLogMediumFile(void)
// Return: None.
// Throws: None.
//--
-CMICmnLogMediumFile::~CMICmnLogMediumFile(void)
+CMICmnLogMediumFile::~CMICmnLogMediumFile()
{
}
@@ -56,7 +49,7 @@ CMICmnLogMediumFile::~CMICmnLogMediumFile(void)
// Throws: None.
//--
CMICmnLogMediumFile &
-CMICmnLogMediumFile::Instance(void)
+CMICmnLogMediumFile::Instance()
{
static CMICmnLogMediumFile instance;
@@ -72,12 +65,10 @@ CMICmnLogMediumFile::Instance(void)
// Throws: None.
//--
bool
-CMICmnLogMediumFile::Initialize(void)
+CMICmnLogMediumFile::Initialize()
{
- m_bInitialized = CMIUtilSystem().GetLogFilesPath(m_strMediumFileDirectory);
- m_bInitialized &= FileFormFileNamePath();
-
- return m_bInitialized;
+ m_bInitialized = true;
+ return FileFormFileNamePath();
}
//++ ------------------------------------------------------------------------------------
@@ -88,7 +79,7 @@ CMICmnLogMediumFile::Initialize(void)
// Throws: None.
//--
bool
-CMICmnLogMediumFile::Shutdown(void)
+CMICmnLogMediumFile::Shutdown()
{
if (m_bInitialized)
{
@@ -106,7 +97,7 @@ CMICmnLogMediumFile::Shutdown(void)
// Throws: None.
//--
const CMIUtilString &
-CMICmnLogMediumFile::GetName(void) const
+CMICmnLogMediumFile::GetName() const
{
return m_constThisMediumName;
}
@@ -155,7 +146,7 @@ CMICmnLogMediumFile::Write(const CMIUtilString &vData, const CMICmnLog::ELogVerb
// Throws: None.
//--
const CMIUtilString &
-CMICmnLogMediumFile::GetError(void) const
+CMICmnLogMediumFile::GetError() const
{
return m_strMILastErrorDescription;
}
@@ -183,7 +174,7 @@ CMICmnLogMediumFile::SetVerbosity(const MIuint veType)
// Throws: None.
//--
MIuint
-CMICmnLogMediumFile::GetVerbosity(void) const
+CMICmnLogMediumFile::GetVerbosity() const
{
return m_eVerbosityType;
}
@@ -210,29 +201,22 @@ CMICmnLogMediumFile::FileWriteEnglish(const CMIUtilString &vData)
// Throws: None.
//--
bool
-CMICmnLogMediumFile::FileFormFileNamePath(void)
+CMICmnLogMediumFile::FileFormFileNamePath()
{
ClrErrorDescription();
m_fileNamePath = MIRSRC(IDS_MEDIUMFILE_ERR_INVALID_PATH);
- if (m_strMediumFileDirectory.compare(MIRSRC(IDS_MEDIUMFILE_ERR_INVALID_PATH)) != 0)
- {
- CMIUtilDateTimeStd date;
- m_strMediumFileName = CMIUtilString::Format(m_constMediumFileNameFormat.c_str(), date.GetDateTimeLogFilename().c_str());
+ CMIUtilDateTimeStd date;
+ m_strMediumFileName = CMIUtilString::Format(m_constMediumFileNameFormat.c_str(), date.GetDateTimeLogFilename().c_str());
#if defined(_MSC_VER)
- m_fileNamePath = CMIUtilString::Format("%s\\%s", m_strMediumFileDirectory.c_str(), m_strMediumFileName.c_str());
+ m_fileNamePath = CMIUtilString::Format("%s\\%s", m_strMediumFileDirectory.c_str(), m_strMediumFileName.c_str());
#else
- m_fileNamePath = CMIUtilString::Format("%s/%s", m_strMediumFileDirectory.c_str(), m_strMediumFileName.c_str());
+ m_fileNamePath = CMIUtilString::Format("%s/%s", m_strMediumFileDirectory.c_str(), m_strMediumFileName.c_str());
#endif // defined ( _MSC_VER )
- return MIstatus::success;
- }
-
- SetErrorDescription(MIRSRC(IDE_MEDIUMFILE_ERR_GET_FILE_PATHNAME_SYS));
-
- return MIstatus::failure;
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
@@ -243,7 +227,7 @@ CMICmnLogMediumFile::FileFormFileNamePath(void)
// Throws: None.
//--
const CMIUtilString &
-CMICmnLogMediumFile::GetFileNamePath(void) const
+CMICmnLogMediumFile::GetFileNamePath() const
{
return m_fileNamePath;
}
@@ -256,7 +240,7 @@ CMICmnLogMediumFile::GetFileNamePath(void) const
// Throws: None.
//--
const CMIUtilString &
-CMICmnLogMediumFile::GetFileName(void) const
+CMICmnLogMediumFile::GetFileName() const
{
return m_strMediumFileName;
}
@@ -332,7 +316,7 @@ CMICmnLogMediumFile::ConvertLogVerbosityTypeToId(const CMICmnLog::ELogVerbosity
// Throws: None.
//--
bool
-CMICmnLogMediumFile::IsOk(void) const
+CMICmnLogMediumFile::IsOk() const
{
return m_file.IsOk();
}
@@ -346,7 +330,7 @@ CMICmnLogMediumFile::IsOk(void) const
// Throws: None.
//--
bool
-CMICmnLogMediumFile::IsFileExist(void) const
+CMICmnLogMediumFile::IsFileExist() const
{
return m_file.IsFileExist(GetFileNamePath());
}
@@ -360,7 +344,7 @@ CMICmnLogMediumFile::IsFileExist(void) const
// Throws: None.
//--
bool
-CMICmnLogMediumFile::FileWriteHeader(void)
+CMICmnLogMediumFile::FileWriteHeader()
{
return FileWriteEnglish(ConvertCr(m_fileHeaderTxt));
}
@@ -419,7 +403,7 @@ CMICmnLogMediumFile::SetHeaderTxt(const CMIUtilString &vText)
// Throws: None.
//--
const CMIUtilString &
-CMICmnLogMediumFile::GetLineReturn(void) const
+CMICmnLogMediumFile::GetLineReturn() const
{
return m_file.GetLineReturn();
}
diff --git a/tools/lldb-mi/MICmnLogMediumFile.h b/tools/lldb-mi/MICmnLogMediumFile.h
index b79baf184880..249da71a42c0 100644
--- a/tools/lldb-mi/MICmnLogMediumFile.h
+++ b/tools/lldb-mi/MICmnLogMediumFile.h
@@ -23,49 +23,46 @@
// which the Logger when given data to write to registered medium comes
// *this medium.
// Singleton class.
-// Gotchas: None.
-// Authors: Illya Rudkin 30/01/2014.
-// Changes: None.
//--
class CMICmnLogMediumFile : public CMICmnBase, public CMICmnLog::IMedium
{
// Statics:
public:
- static CMICmnLogMediumFile &Instance(void);
+ static CMICmnLogMediumFile &Instance();
// Methods:
public:
bool SetHeaderTxt(const CMIUtilString &vText);
bool SetVerbosity(const MIuint veType);
- MIuint GetVerbosity(void) const;
- const CMIUtilString &GetFileName(void) const;
- const CMIUtilString &GetFileNamePath(void) const;
- bool IsOk(void) const;
- bool IsFileExist(void) const;
- const CMIUtilString &GetLineReturn(void) const;
+ MIuint GetVerbosity() const;
+ const CMIUtilString &GetFileName() const;
+ const CMIUtilString &GetFileNamePath() const;
+ bool IsOk() const;
+ bool IsFileExist() const;
+ const CMIUtilString &GetLineReturn() const;
bool SetDirectory(const CMIUtilString &vPath);
// Overridden:
public:
// From CMICmnBase
- /* dtor */ ~CMICmnLogMediumFile(void) override;
+ /* dtor */ ~CMICmnLogMediumFile() override;
// From CMICmnLog::IMedium
- bool Initialize(void) override;
- const CMIUtilString &GetName(void) const override;
+ bool Initialize() override;
+ const CMIUtilString &GetName() const override;
bool Write(const CMIUtilString &vData, const CMICmnLog::ELogVerbosity veType) override;
- const CMIUtilString &GetError(void) const override;
- bool Shutdown(void) override;
+ const CMIUtilString &GetError() const override;
+ bool Shutdown() override;
// Methods:
private:
- /* ctor */ CMICmnLogMediumFile(void);
+ /* ctor */ CMICmnLogMediumFile();
/* ctor */ CMICmnLogMediumFile(const CMICmnLogMediumFile &);
void operator=(const CMICmnLogMediumFile &);
bool FileWriteEnglish(const CMIUtilString &vData);
- bool FileFormFileNamePath(void);
+ bool FileFormFileNamePath();
CMIUtilString MassagedData(const CMIUtilString &vData, const CMICmnLog::ELogVerbosity veType);
- bool FileWriteHeader(void);
+ bool FileWriteHeader();
char ConvertLogVerbosityTypeToId(const CMICmnLog::ELogVerbosity veType) const;
CMIUtilString ConvertCr(const CMIUtilString &vData) const;
diff --git a/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp b/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp
index 84c6695de354..e633e5a61fa9 100644
--- a/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp
+++ b/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp
@@ -1,4 +1,4 @@
-//===-- MICmnMIOutOfBandRecord.cpp --------------------------------------------*- C++ -*-===//
+//===-- MICmnMIOutOfBandRecord.cpp ------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,43 +7,106 @@
//
//===----------------------------------------------------------------------===//
+// Third Party Headers:
+#include <assert.h>
+
// In-house headers:
#include "MICmnMIOutOfBandRecord.h"
#include "MICmnResources.h"
// Instantiations:
-CMICmnMIOutOfBandRecord::MapOutOfBandToOutOfBandText_t ms_MapOutOfBandToOutOfBandText = {
- {CMICmnMIOutOfBandRecord::eOutOfBand_Running, "running"},
- {CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, "stopped"},
- {CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated, "breakpoint-created"},
- {CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, "breakpoint-modified"},
- {CMICmnMIOutOfBandRecord::eOutOfBand_Thread, ""}, // "" Meant to be empty
- {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded, "thread-group-added"},
- {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited, "thread-group-exited"},
- {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved, "thread-group-removed"},
- {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, "thread-group-started"},
- {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated, "thread-created"},
- {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited, "thread-exited"},
- {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected, "thread-selected"},
- {CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleLoaded, "library-loaded"},
- {CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleUnloaded, "library-unloaded"},
- {CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput, ""}};
-CMICmnMIOutOfBandRecord::MapOutOfBandToOutOfBandText_t ms_constMapAsyncRecordTextToToken = {
- {CMICmnMIOutOfBandRecord::eOutOfBand_Running, "*"},
- {CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, "*"},
- {CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated, "="},
- {CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, "="},
- {CMICmnMIOutOfBandRecord::eOutOfBand_Thread, "@"},
- {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded, "="},
- {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited, "="},
- {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved, "="},
- {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, "="},
- {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated, "="},
- {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited, "="},
- {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected, "="},
- {CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleLoaded, "="},
- {CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleUnloaded, "="},
- {CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput, "@"}};
+static const char *
+MapOutOfBandToText(CMICmnMIOutOfBandRecord::OutOfBand_e veType)
+{
+ switch (veType)
+ {
+ case CMICmnMIOutOfBandRecord::eOutOfBand_Running:
+ return "running";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_Stopped:
+ return "stopped";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated:
+ return "breakpoint-created";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified:
+ return "breakpoint-modified";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_Thread:
+ return ""; // "" Meant to be empty
+ case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded:
+ return "thread-group-added";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited:
+ return "thread-group-exited";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved:
+ return "thread-group-removed";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted:
+ return "thread-group-started";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated:
+ return "thread-created";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited:
+ return "thread-exited";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected:
+ return "thread-selected";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleLoaded:
+ return "library-loaded";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleUnloaded:
+ return "library-unloaded";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput:
+ return "";
+ }
+ assert(false && "unknown CMICmnMIOutofBandRecord::OutOfBand_e");
+ return NULL;
+}
+
+static const char *
+MapOutOfBandToToken(CMICmnMIOutOfBandRecord::OutOfBand_e veType)
+{
+ switch (veType)
+ {
+ case CMICmnMIOutOfBandRecord::eOutOfBand_Running:
+ return "*";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_Stopped:
+ return "*";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated:
+ return "=";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified:
+ return "=";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_Thread:
+ return "@";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded:
+ return "=";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited:
+ return "=";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved:
+ return "=";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted:
+ return "=";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated:
+ return "=";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited:
+ return "=";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected:
+ return "=";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleLoaded:
+ return "=";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleUnloaded:
+ return "=";
+ case CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput:
+ return "@";
+ }
+ assert(false && "unknown CMICmnMIOutofBandRecord::OutOfBand_e");
+ return NULL;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Build the Out-of-band record's mandatory data part. The part up to the first
+// (additional) result i.e. async-record ==> "*" type.
+// Args: veType - (R) A MI Out-of-Band enumeration.
+// Return: CMIUtilString - The async record text.
+// Throws: None.
+//--
+static CMIUtilString
+BuildAsyncRecord(CMICmnMIOutOfBandRecord::OutOfBand_e veType)
+{
+ return CMIUtilString::Format("%s%s", MapOutOfBandToToken(veType), MapOutOfBandToText(veType));
+}
//++ ------------------------------------------------------------------------------------
// Details: CMICmnMIOutOfBandRecord constructor.
@@ -52,7 +115,7 @@ CMICmnMIOutOfBandRecord::MapOutOfBandToOutOfBandText_t ms_constMapAsyncRecordTex
// Return: None.
// Throws: None.
//--
-CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(void)
+CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord()
: m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION))
{
}
@@ -64,11 +127,9 @@ CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(void)
// Return: None.
// Throws: None.
//--
-CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(const OutOfBand_e veType)
- : m_eResultAsyncRecordClass(veType)
- , m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION))
+CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(OutOfBand_e veType)
+ : m_strAsyncRecord(BuildAsyncRecord(veType))
{
- BuildAsyncRecord();
}
//++ ------------------------------------------------------------------------------------
@@ -79,11 +140,9 @@ CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(const OutOfBand_e veType)
// Return: None.
// Throws: None.
//--
-CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(const OutOfBand_e veType, const CMICmnMIValueConst &vConst)
- : m_eResultAsyncRecordClass(veType)
- , m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION))
+CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(OutOfBand_e veType, const CMICmnMIValueConst &vConst)
+ : m_strAsyncRecord(BuildAsyncRecord(veType))
{
- BuildAsyncRecord();
m_strAsyncRecord += vConst.GetString();
}
@@ -95,13 +154,10 @@ CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(const OutOfBand_e veType, const
// Return: None.
// Throws: None.
//--
-CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(const OutOfBand_e veType, const CMICmnMIValueResult &vResult)
- : m_eResultAsyncRecordClass(veType)
- , m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION))
- , m_partResult(vResult)
+CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(OutOfBand_e veType, const CMICmnMIValueResult &vResult)
+ : m_strAsyncRecord(BuildAsyncRecord(veType))
{
- BuildAsyncRecord();
- Add(m_partResult);
+ Add(vResult);
}
//++ ------------------------------------------------------------------------------------
@@ -111,7 +167,7 @@ CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(const OutOfBand_e veType, const
// Return: None.
// Throws: None.
//--
-CMICmnMIOutOfBandRecord::~CMICmnMIOutOfBandRecord(void)
+CMICmnMIOutOfBandRecord::~CMICmnMIOutOfBandRecord()
{
}
@@ -126,44 +182,21 @@ CMICmnMIOutOfBandRecord::~CMICmnMIOutOfBandRecord(void)
// Throws: None.
//--
const CMIUtilString &
-CMICmnMIOutOfBandRecord::GetString(void) const
+CMICmnMIOutOfBandRecord::GetString() const
{
return m_strAsyncRecord;
}
//++ ------------------------------------------------------------------------------------
-// Details: Build the Out-of-band record's mandatory data part. The part up to the first
-// (additional) result i.e. async-record ==> "*" type.
-// Type: Method.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
-//--
-bool
-CMICmnMIOutOfBandRecord::BuildAsyncRecord(void)
-{
- const char *pFormat = "%s%s";
- const CMIUtilString &rStrAsyncRecord(ms_MapOutOfBandToOutOfBandText[m_eResultAsyncRecordClass]);
- const CMIUtilString &rStrToken(ms_constMapAsyncRecordTextToToken[m_eResultAsyncRecordClass]);
- m_strAsyncRecord = CMIUtilString::Format(pFormat, rStrToken.c_str(), rStrAsyncRecord.c_str());
-
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
// Details: Add to *this Out-of-band record additional information.
// Type: Method.
// Args: vResult - (R) A MI result object.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
+// Return: None.
// Throws: None.
//--
-bool
+void
CMICmnMIOutOfBandRecord::Add(const CMICmnMIValueResult &vResult)
{
m_strAsyncRecord += ",";
m_strAsyncRecord += vResult.GetString();
-
- return MIstatus::success;
}
diff --git a/tools/lldb-mi/MICmnMIOutOfBandRecord.h b/tools/lldb-mi/MICmnMIOutOfBandRecord.h
index 6277e860878f..ad18e6ccac9c 100644
--- a/tools/lldb-mi/MICmnMIOutOfBandRecord.h
+++ b/tools/lldb-mi/MICmnMIOutOfBandRecord.h
@@ -9,9 +9,6 @@
#pragma once
-// Third party headers:
-#include <map>
-
// In-house headers:
#include "MICmnBase.h"
#include "MIUtilString.h"
@@ -37,9 +34,6 @@
//
// More information see:
// http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_chapter/gdb_22.html//
-// Gotchas: None.
-// Authors: Illya Rudkin 24/02/2014.
-// Changes: None.
//--
class CMICmnMIOutOfBandRecord : public CMICmnBase
{
@@ -64,40 +58,25 @@ class CMICmnMIOutOfBandRecord : public CMICmnBase
eOutOfBand_ThreadSelected,
eOutOfBand_TargetModuleLoaded,
eOutOfBand_TargetModuleUnloaded,
- eOutOfBand_TargetStreamOutput,
- eOutOfBand_count // Always the last one
+ eOutOfBand_TargetStreamOutput
};
- // Typedefs:
- public:
- typedef std::map<OutOfBand_e, CMIUtilString> MapOutOfBandToOutOfBandText_t;
- typedef std::map<OutOfBand_e, CMIUtilString> MapOutOfBandToToken_t;
-
// Methods:
public:
- /* ctor */ CMICmnMIOutOfBandRecord(void);
- /* ctor */ CMICmnMIOutOfBandRecord(const OutOfBand_e veType);
- /* ctor */ CMICmnMIOutOfBandRecord(const OutOfBand_e veType, const CMICmnMIValueConst &vConst);
- /* ctor */ CMICmnMIOutOfBandRecord(const OutOfBand_e veType, const CMICmnMIValueResult &vResult);
+ /* ctor */ CMICmnMIOutOfBandRecord();
+ /* ctor */ CMICmnMIOutOfBandRecord(OutOfBand_e veType);
+ /* ctor */ CMICmnMIOutOfBandRecord(OutOfBand_e veType, const CMICmnMIValueConst &vConst);
+ /* ctor */ CMICmnMIOutOfBandRecord(OutOfBand_e veType, const CMICmnMIValueResult &vResult);
//
- const CMIUtilString &GetString(void) const;
- bool Add(const CMICmnMIValueResult &vResult);
+ const CMIUtilString &GetString() const;
+ void Add(const CMICmnMIValueResult &vResult);
// Overridden:
public:
// From CMICmnBase
- /* dtor */ ~CMICmnMIOutOfBandRecord(void) override;
-
- // Methods:
- private:
- bool BuildAsyncRecord(void);
+ /* dtor */ ~CMICmnMIOutOfBandRecord() override;
// Attributes:
private:
- static MapOutOfBandToOutOfBandText_t ms_constMapOutOfBandToAsyncRecordText;
- static MapOutOfBandToToken_t ms_constMapOutOfBandTextToToken;
- //
- OutOfBand_e m_eResultAsyncRecordClass;
CMIUtilString m_strAsyncRecord; // Holds the text version of the result record to date
- CMICmnMIValueResult m_partResult;
};
diff --git a/tools/lldb-mi/MICmnMIResultRecord.cpp b/tools/lldb-mi/MICmnMIResultRecord.cpp
index 49a31c87519f..0348f8941316 100644
--- a/tools/lldb-mi/MICmnMIResultRecord.cpp
+++ b/tools/lldb-mi/MICmnMIResultRecord.cpp
@@ -1,4 +1,4 @@
-//===-- Platform.cpp --------------------------------------------*- C++ -*-===//
+//===-- MICmnMIResultRecord.cpp ---------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,18 +7,53 @@
//
//===----------------------------------------------------------------------===//
+// Third Party Headers:
+#include <assert.h>
+
// In-house headers:
#include "MICmnMIResultRecord.h"
#include "MICmnResources.h"
-// Instantiations:
-CMICmnMIResultRecord::MapResultClassToResultClassText_t ms_MapResultClassToResultClassText = {
- {CMICmnMIResultRecord::eResultClass_Done, "done"},
- {CMICmnMIResultRecord::eResultClass_Running, "running"},
- {CMICmnMIResultRecord::eResultClass_Connected, "connected"},
- {CMICmnMIResultRecord::eResultClass_Error, "error"},
- {CMICmnMIResultRecord::eResultClass_Exit, "exit"}};
-const CMIUtilString CMICmnMIResultRecord::ms_constStrResultRecordHat("^");
+//++ ------------------------------------------------------------------------------------
+// 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.
+// Throws: None.
+//--
+static const char*
+MapResultClassToResultClassText(CMICmnMIResultRecord::ResultClass_e veType)
+{
+ switch (veType)
+ {
+ case CMICmnMIResultRecord::eResultClass_Done:
+ return "done";
+ case CMICmnMIResultRecord::eResultClass_Running:
+ return "running";
+ case CMICmnMIResultRecord::eResultClass_Connected:
+ return "connected";
+ case CMICmnMIResultRecord::eResultClass_Error:
+ return "error";
+ case CMICmnMIResultRecord::eResultClass_Exit:
+ return "exit";
+ }
+ assert(false && "unknown CMICmnMIResultRecord::ResultClass_e");
+ return NULL;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Build the result record's mandatory data part. The part up to the first
+// (additional) result i.e. result-record ==> [ token ] "^" result-class.
+// Args: vrToken - (R) The command's transaction ID or token.
+// veType - (R) A MI result class enumeration.
+// Return: CMIUtilString & - MI result record mandatory data
+// Throws: None.
+//--
+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);
+}
//++ ------------------------------------------------------------------------------------
// Details: CMICmnMIResultRecord constructor.
@@ -27,7 +62,7 @@ const CMIUtilString CMICmnMIResultRecord::ms_constStrResultRecordHat("^");
// Return: None.
// Throws: None.
//--
-CMICmnMIResultRecord::CMICmnMIResultRecord(void)
+CMICmnMIResultRecord::CMICmnMIResultRecord()
: m_strResultRecord(MIRSRC(IDS_CMD_ERR_CMD_RUN_BUT_NO_ACTION))
{
}
@@ -40,12 +75,9 @@ CMICmnMIResultRecord::CMICmnMIResultRecord(void)
// Return: None.
// Throws: None.
//--
-CMICmnMIResultRecord::CMICmnMIResultRecord(const CMIUtilString &vrToken, const ResultClass_e veType)
- : m_strResultRecordToken(vrToken)
- , m_eResultRecordResultClass(veType)
- , m_strResultRecord(MIRSRC(IDS_CMD_ERR_CMD_RUN_BUT_NO_ACTION))
+CMICmnMIResultRecord::CMICmnMIResultRecord(const CMIUtilString &vrToken, ResultClass_e veType)
+ : m_strResultRecord(BuildResultRecord(vrToken, veType))
{
- BuildResultRecord();
}
//++ ------------------------------------------------------------------------------------
@@ -57,14 +89,10 @@ CMICmnMIResultRecord::CMICmnMIResultRecord(const CMIUtilString &vrToken, const R
// Return: None.
// Throws: None.
//--
-CMICmnMIResultRecord::CMICmnMIResultRecord(const CMIUtilString &vrToken, const ResultClass_e veType, const CMICmnMIValueResult &vValue)
- : m_strResultRecordToken(vrToken)
- , m_eResultRecordResultClass(veType)
- , m_strResultRecord(MIRSRC(IDS_CMD_ERR_CMD_RUN_BUT_NO_ACTION))
- , m_partResult(vValue)
+CMICmnMIResultRecord::CMICmnMIResultRecord(const CMIUtilString &vrToken, ResultClass_e veType, const CMICmnMIValueResult &vValue)
+ : m_strResultRecord(BuildResultRecord(vrToken, veType))
{
- BuildResultRecord();
- Add(m_partResult);
+ Add(vValue);
}
//++ ------------------------------------------------------------------------------------
@@ -74,7 +102,7 @@ CMICmnMIResultRecord::CMICmnMIResultRecord(const CMIUtilString &vrToken, const R
// Return: None.
// Throws: None.
//--
-CMICmnMIResultRecord::~CMICmnMIResultRecord(void)
+CMICmnMIResultRecord::~CMICmnMIResultRecord()
{
}
@@ -89,44 +117,21 @@ CMICmnMIResultRecord::~CMICmnMIResultRecord(void)
// Throws: None.
//--
const CMIUtilString &
-CMICmnMIResultRecord::GetString(void) const
+CMICmnMIResultRecord::GetString() const
{
return m_strResultRecord;
}
//++ ------------------------------------------------------------------------------------
-// Details: Build the result record's mandatory data part. The part up to the first
-// (additional) result i.e. result-record ==> [ token ] "^" result-class.
-// Type: Method.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
-//--
-bool
-CMICmnMIResultRecord::BuildResultRecord(void)
-{
- const char *pFormat = "%s%s%s";
- const CMIUtilString &rStrResultRecord(ms_MapResultClassToResultClassText[m_eResultRecordResultClass]);
- m_strResultRecord =
- CMIUtilString::Format(pFormat, m_strResultRecordToken.c_str(), ms_constStrResultRecordHat.c_str(), rStrResultRecord.c_str());
-
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
// Details: Add to *this result record additional information.
// Type: Method.
// Args: vMIValue - (R) A MI value derived object.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
+// Return: None.
// Throws: None.
//--
-bool
+void
CMICmnMIResultRecord::Add(const CMICmnMIValue &vMIValue)
{
m_strResultRecord += ",";
m_strResultRecord += vMIValue.GetString();
-
- return MIstatus::success;
}
diff --git a/tools/lldb-mi/MICmnMIResultRecord.h b/tools/lldb-mi/MICmnMIResultRecord.h
index 981cf3635d53..4408324a3709 100644
--- a/tools/lldb-mi/MICmnMIResultRecord.h
+++ b/tools/lldb-mi/MICmnMIResultRecord.h
@@ -9,9 +9,6 @@
#pragma once
-// Third party headers:
-#include <map>
-
// In-house headers:
#include "MICmnBase.h"
#include "MIUtilString.h"
@@ -39,9 +36,6 @@
// be returned.
// More information see:
// http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_chapter/gdb_22.html
-// Gotchas: None.
-// Authors: Illya Rudkin 24/02/2014.
-// Changes: None.
//--
class CMICmnMIResultRecord : public CMICmnBase
{
@@ -56,39 +50,24 @@ class CMICmnMIResultRecord : public CMICmnBase
eResultClass_Running,
eResultClass_Connected,
eResultClass_Error,
- eResultClass_Exit,
- eResultClass_count // Always the last one
+ eResultClass_Exit
};
- // Typedefs:
- public:
- typedef std::map<ResultClass_e, CMIUtilString> MapResultClassToResultClassText_t;
-
// Methods:
public:
- /* ctor */ CMICmnMIResultRecord(void);
- /* ctor */ CMICmnMIResultRecord(const CMIUtilString &vrToken, const ResultClass_e veType);
- /* ctor */ CMICmnMIResultRecord(const CMIUtilString &vrToken, const ResultClass_e veType, const CMICmnMIValueResult &vValue);
+ /* ctor */ CMICmnMIResultRecord();
+ /* ctor */ CMICmnMIResultRecord(const CMIUtilString &vrToken, ResultClass_e veType);
+ /* ctor */ CMICmnMIResultRecord(const CMIUtilString &vrToken, ResultClass_e veType, const CMICmnMIValueResult &vValue);
//
- const CMIUtilString &GetString(void) const;
- bool Add(const CMICmnMIValue &vMIValue);
+ const CMIUtilString &GetString() const;
+ void Add(const CMICmnMIValue &vMIValue);
// Overridden:
public:
// From CMICmnBase
- /* dtor */ ~CMICmnMIResultRecord(void) override;
-
- // Methods:
- private:
- bool BuildResultRecord(void);
+ /* dtor */ ~CMICmnMIResultRecord() override;
// Attributes:
private:
- static const CMIUtilString ms_constStrResultRecordHat;
- static MapResultClassToResultClassText_t ms_constMapResultClassToResultClassText;
- //
- CMIUtilString m_strResultRecordToken;
- ResultClass_e m_eResultRecordResultClass;
CMIUtilString m_strResultRecord; // Holds the text version of the result record to date
- CMICmnMIValueResult m_partResult;
};
diff --git a/tools/lldb-mi/MICmnMIValue.cpp b/tools/lldb-mi/MICmnMIValue.cpp
index 2f7041427d2b..d5895d70099b 100644
--- a/tools/lldb-mi/MICmnMIValue.cpp
+++ b/tools/lldb-mi/MICmnMIValue.cpp
@@ -1,4 +1,4 @@
-//===-- Platform.cpp --------------------------------------------*- C++ -*-===//
+//===-- MICmnMIValue.cpp ----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -18,7 +18,7 @@
// Return: None.
// Throws: None.
//--
-CMICmnMIValue::CMICmnMIValue(void)
+CMICmnMIValue::CMICmnMIValue()
: m_strValue(MIRSRC(IDS_WORD_INVALIDBRKTS))
, m_bJustConstructed(true)
{
@@ -31,7 +31,7 @@ CMICmnMIValue::CMICmnMIValue(void)
// Return: None.
// Throws: None.
//--
-CMICmnMIValue::~CMICmnMIValue(void)
+CMICmnMIValue::~CMICmnMIValue()
{
}
@@ -46,7 +46,7 @@ CMICmnMIValue::~CMICmnMIValue(void)
// Throws: None.
//--
const CMIUtilString &
-CMICmnMIValue::GetString(void) const
+CMICmnMIValue::GetString() const
{
return m_strValue;
}
diff --git a/tools/lldb-mi/MICmnMIValue.h b/tools/lldb-mi/MICmnMIValue.h
index 6a372e600146..dd11d6a8d118 100644
--- a/tools/lldb-mi/MICmnMIValue.h
+++ b/tools/lldb-mi/MICmnMIValue.h
@@ -28,22 +28,19 @@
// list ==> "[]" | "[" value ( "," value )* "]" | "[" result ( "," result )* "]"
// More information see:
// http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_chapter/gdb_22.html
-// Gotchas: None.
-// Authors: Illya Rudkin 24/02/2014.
-// Changes: None.
//--
class CMICmnMIValue : public CMICmnBase
{
// Methods:
public:
- /* ctor */ CMICmnMIValue(void);
+ /* ctor */ CMICmnMIValue();
//
- const CMIUtilString &GetString(void) const;
+ const CMIUtilString &GetString() const;
// Overridden:
public:
// From CMICmnBase
- /* dtor */ ~CMICmnMIValue(void) override;
+ /* dtor */ ~CMICmnMIValue() override;
// Attributes:
protected:
diff --git a/tools/lldb-mi/MICmnMIValueConst.cpp b/tools/lldb-mi/MICmnMIValueConst.cpp
index dd4b99344293..d8b11e9cb064 100644
--- a/tools/lldb-mi/MICmnMIValueConst.cpp
+++ b/tools/lldb-mi/MICmnMIValueConst.cpp
@@ -1,4 +1,4 @@
-//===-- Platform.cpp --------------------------------------------*- C++ -*-===//
+//===-- MICmnMIValueConst.cpp -----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -49,7 +49,7 @@ CMICmnMIValueConst::CMICmnMIValueConst(const CMIUtilString &vString, const bool
// Return: None.
// Throws: None.
//--
-CMICmnMIValueConst::~CMICmnMIValueConst(void)
+CMICmnMIValueConst::~CMICmnMIValueConst()
{
}
@@ -62,7 +62,7 @@ CMICmnMIValueConst::~CMICmnMIValueConst(void)
// Throws: None.
//--
bool
-CMICmnMIValueConst::BuildConst(void)
+CMICmnMIValueConst::BuildConst()
{
if (m_strPartConst.length() != 0)
{
diff --git a/tools/lldb-mi/MICmnMIValueConst.h b/tools/lldb-mi/MICmnMIValueConst.h
index 403619438919..7f6333e12f45 100644
--- a/tools/lldb-mi/MICmnMIValueConst.h
+++ b/tools/lldb-mi/MICmnMIValueConst.h
@@ -30,10 +30,6 @@
// http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_chapter/gdb_22.html
//
// The text formed in *this Result class is stripped of any '\n' characters.
-//
-// Gotchas: None.
-// Authors: Illya Rudkin 24/02/2014.
-// Changes: None.
//--
class CMICmnMIValueConst : public CMICmnMIValue
{
@@ -45,11 +41,11 @@ class CMICmnMIValueConst : public CMICmnMIValue
// Overridden:
public:
// From CMICmnBase
- /* dtor */ ~CMICmnMIValueConst(void) override;
+ /* dtor */ ~CMICmnMIValueConst() override;
// Methods:
private:
- bool BuildConst(void);
+ bool BuildConst();
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmnMIValueList.cpp b/tools/lldb-mi/MICmnMIValueList.cpp
index 30888cfbb59c..e4d3f408422b 100644
--- a/tools/lldb-mi/MICmnMIValueList.cpp
+++ b/tools/lldb-mi/MICmnMIValueList.cpp
@@ -1,4 +1,4 @@
-//===-- Platform.cpp --------------------------------------------*- C++ -*-===//
+//===-- MICmnMIValueList.cpp ------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -61,7 +61,7 @@ CMICmnMIValueList::CMICmnMIValueList(const CMICmnMIValue &vValue)
// Return: None.
// Throws: None.
//--
-CMICmnMIValueList::~CMICmnMIValueList(void)
+CMICmnMIValueList::~CMICmnMIValueList()
{
}
@@ -69,17 +69,14 @@ CMICmnMIValueList::~CMICmnMIValueList(void)
// Details: Build the result value's mandatory data part, one tuple
// Type: Method.
// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
+// Return: None.
// Throws: None.
//--
-bool
-CMICmnMIValueList::BuildList(void)
+void
+CMICmnMIValueList::BuildList()
{
const char *pFormat = "[%s]";
m_strValue = CMIUtilString::Format(pFormat, m_strValue.c_str());
-
- return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
@@ -88,14 +85,13 @@ CMICmnMIValueList::BuildList(void)
// will return MIstatus::failure.
// Type: Method.
// Args: vResult - (R) The MI result object.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
+// Return: None.
// Throws: None.
//--
-bool
+void
CMICmnMIValueList::Add(const CMICmnMIValueResult &vResult)
{
- return BuildList(vResult);
+ BuildList(vResult);
}
//++ ------------------------------------------------------------------------------------
@@ -104,14 +100,13 @@ CMICmnMIValueList::Add(const CMICmnMIValueResult &vResult)
// will return MIstatus::failure.
// Type: Method.
// Args: vValue - (R) The MI value object.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
+// Return: None.
// Throws: None.
//--
-bool
+void
CMICmnMIValueList::Add(const CMICmnMIValue &vValue)
{
- return BuildList(vValue);
+ BuildList(vValue);
}
//++ ------------------------------------------------------------------------------------
@@ -120,11 +115,10 @@ CMICmnMIValueList::Add(const CMICmnMIValue &vValue)
// will return MIstatus::failure.
// Type: Method.
// Args: vResult - (R) The MI result object.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
+// Return: None.
// Throws: None.
//--
-bool
+void
CMICmnMIValueList::BuildList(const CMICmnMIValueResult &vResult)
{
// Clear out the default "<Invalid>" text
@@ -132,14 +126,13 @@ CMICmnMIValueList::BuildList(const CMICmnMIValueResult &vResult)
{
m_bJustConstructed = false;
m_strValue = vResult.GetString();
- return BuildList();
+ BuildList();
+ return;
}
const CMIUtilString data(ExtractContentNoBrackets());
const char *pFormat = "[%s,%s]";
m_strValue = CMIUtilString::Format(pFormat, data.c_str(), vResult.GetString().c_str());
-
- return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
@@ -148,11 +141,10 @@ CMICmnMIValueList::BuildList(const CMICmnMIValueResult &vResult)
// will return MIstatus::failure.
// Type: Method.
// Args: vValue - (R) The MI value object.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
+// Return: None.
// Throws: None.
//--
-bool
+void
CMICmnMIValueList::BuildList(const CMICmnMIValue &vValue)
{
// Clear out the default "<Invalid>" text
@@ -160,7 +152,8 @@ CMICmnMIValueList::BuildList(const CMICmnMIValue &vValue)
{
m_bJustConstructed = false;
m_strValue = vValue.GetString();
- return BuildList();
+ BuildList();
+ return;
}
// Remove already present '[' and ']' from the start and end
@@ -170,8 +163,6 @@ CMICmnMIValueList::BuildList(const CMICmnMIValue &vValue)
m_strValue = m_strValue.substr(1, len - 2);
const char *pFormat = "[%s,%s]";
m_strValue = CMIUtilString::Format(pFormat, m_strValue.c_str(), vValue.GetString().c_str());
-
- return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
@@ -183,7 +174,7 @@ CMICmnMIValueList::BuildList(const CMICmnMIValue &vValue)
// Throws: None.
//--
CMIUtilString
-CMICmnMIValueList::ExtractContentNoBrackets(void) const
+CMICmnMIValueList::ExtractContentNoBrackets() const
{
CMIUtilString data(m_strValue);
diff --git a/tools/lldb-mi/MICmnMIValueList.h b/tools/lldb-mi/MICmnMIValueList.h
index 26a217dfc77b..0796cbe575c1 100644
--- a/tools/lldb-mi/MICmnMIValueList.h
+++ b/tools/lldb-mi/MICmnMIValueList.h
@@ -29,9 +29,6 @@
// list ==> "[]" | "[" value ( "," value )* "]" | "[" result ( "," result )* "]"
// More information see:
// http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_chapter/gdb_22.html
-// Gotchas: None.
-// Authors: Illya Rudkin 24/02/2014.
-// Changes: None.
//--
class CMICmnMIValueList : public CMICmnMIValue
{
@@ -41,18 +38,18 @@ class CMICmnMIValueList : public CMICmnMIValue
/* ctor */ CMICmnMIValueList(const CMICmnMIValueResult &vResult);
/* ctor */ CMICmnMIValueList(const CMICmnMIValue &vValue);
//
- bool Add(const CMICmnMIValueResult &vResult);
- bool Add(const CMICmnMIValue &vValue);
- CMIUtilString ExtractContentNoBrackets(void) const;
+ void Add(const CMICmnMIValueResult &vResult);
+ void Add(const CMICmnMIValue &vValue);
+ CMIUtilString ExtractContentNoBrackets() const;
// Overridden:
public:
// From CMICmnBase
- /* dtor */ ~CMICmnMIValueList(void) override;
+ /* dtor */ ~CMICmnMIValueList() override;
// Methods:
private:
- bool BuildList(void);
- bool BuildList(const CMICmnMIValueResult &vResult);
- bool BuildList(const CMICmnMIValue &vResult);
+ void BuildList();
+ void BuildList(const CMICmnMIValueResult &vResult);
+ void BuildList(const CMICmnMIValue &vResult);
};
diff --git a/tools/lldb-mi/MICmnMIValueResult.cpp b/tools/lldb-mi/MICmnMIValueResult.cpp
index 55d93ce40ca7..d86f724b7cf9 100644
--- a/tools/lldb-mi/MICmnMIValueResult.cpp
+++ b/tools/lldb-mi/MICmnMIValueResult.cpp
@@ -1,4 +1,4 @@
-//===-- Platform.cpp --------------------------------------------*- C++ -*-===//
+//===-- MICmnMIValueResult.cpp ----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -21,7 +21,7 @@ const CMIUtilString CMICmnMIValueResult::ms_constStrEqual("=");
// Return: None.
// Throws: None.
//--
-CMICmnMIValueResult::CMICmnMIValueResult(void)
+CMICmnMIValueResult::CMICmnMIValueResult()
: m_bEmptyConstruction(true)
{
}
@@ -68,7 +68,7 @@ CMICmnMIValueResult::CMICmnMIValueResult(const CMIUtilString &vrVariable, const
// Return: None.
// Throws: None.
//--
-CMICmnMIValueResult::~CMICmnMIValueResult(void)
+CMICmnMIValueResult::~CMICmnMIValueResult()
{
}
@@ -76,17 +76,14 @@ CMICmnMIValueResult::~CMICmnMIValueResult(void)
// Details: Build the MI value result string.
// Type: Method.
// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
+// Return: None.
// Throws: None.
//--
-bool
-CMICmnMIValueResult::BuildResult(void)
+void
+CMICmnMIValueResult::BuildResult()
{
const char *pFormat = m_bUseSpacing ? "%s %s %s" : "%s%s%s";
m_strValue = CMIUtilString::Format(pFormat, m_strPartVariable.c_str(), ms_constStrEqual.c_str(), m_partMIValue.GetString().c_str());
-
- return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
@@ -94,18 +91,15 @@ CMICmnMIValueResult::BuildResult(void)
// Type: Method.
// Args: vrVariable - (R) MI value's name.
// vrValue - (R) The MI value.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
+// Return: None.
// Throws: None.
//--
-bool
+void
CMICmnMIValueResult::BuildResult(const CMIUtilString &vVariable, const CMICmnMIValue &vValue)
{
const char *pFormat = m_bUseSpacing ? "%s, %s %s %s" : "%s,%s%s%s";
m_strValue =
CMIUtilString::Format(pFormat, m_strValue.c_str(), vVariable.c_str(), ms_constStrEqual.c_str(), vValue.GetString().c_str());
-
- return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
@@ -117,16 +111,16 @@ CMICmnMIValueResult::BuildResult(const CMIUtilString &vVariable, const CMICmnMIV
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
+void
CMICmnMIValueResult::Add(const CMIUtilString &vrVariable, const CMICmnMIValue &vrValue)
{
if (!m_bEmptyConstruction)
- return BuildResult(vrVariable, vrValue);
+ BuildResult(vrVariable, vrValue);
else
{
m_bEmptyConstruction = false;
m_strPartVariable = vrVariable;
m_partMIValue = vrValue;
- return BuildResult();
+ BuildResult();
}
}
diff --git a/tools/lldb-mi/MICmnMIValueResult.h b/tools/lldb-mi/MICmnMIValueResult.h
index 7c8e9801e4a0..cd96520b98f9 100644
--- a/tools/lldb-mi/MICmnMIValueResult.h
+++ b/tools/lldb-mi/MICmnMIValueResult.h
@@ -28,29 +28,26 @@
// list ==> "[]" | "[" value ( "," value )* "]" | "[" result ( "," result )* "]"
// More information see:
// http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_chapter/gdb_22.html
-// Gotchas: None.
-// Authors: Illya Rudkin 24/02/2014.
-// Changes: None.
//--
class CMICmnMIValueResult : public CMICmnMIValue
{
// Methods:
public:
- /* ctor */ CMICmnMIValueResult(void);
+ /* ctor */ CMICmnMIValueResult();
/* ctor */ CMICmnMIValueResult(const CMIUtilString &vVariable, const CMICmnMIValue &vValue);
/* ctor */ CMICmnMIValueResult(const CMIUtilString &vVariable, const CMICmnMIValue &vValue, const bool vbUseSpacing);
//
- bool Add(const CMIUtilString &vVariable, const CMICmnMIValue &vValue);
+ void Add(const CMIUtilString &vVariable, const CMICmnMIValue &vValue);
// Overridden:
public:
// From CMICmnBase
- /* dtor */ ~CMICmnMIValueResult(void) override;
+ /* dtor */ ~CMICmnMIValueResult() override;
// Methods:
private:
- bool BuildResult(void);
- bool BuildResult(const CMIUtilString &vVariable, const CMICmnMIValue &vValue);
+ void BuildResult();
+ void BuildResult(const CMIUtilString &vVariable, const CMICmnMIValue &vValue);
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmnMIValueTuple.cpp b/tools/lldb-mi/MICmnMIValueTuple.cpp
index aa92b1f62280..4ff1d6ce1fa5 100644
--- a/tools/lldb-mi/MICmnMIValueTuple.cpp
+++ b/tools/lldb-mi/MICmnMIValueTuple.cpp
@@ -1,4 +1,4 @@
-//===-- Platform.cpp --------------------------------------------*- C++ -*-===//
+//===-- MICmnMIValueTuple.cpp -----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -17,7 +17,7 @@
// Return: None.
// Throws: None.
//--
-CMICmnMIValueTuple::CMICmnMIValueTuple(void)
+CMICmnMIValueTuple::CMICmnMIValueTuple()
: m_bSpaceAfterComma(false)
{
m_strValue = "{}";
@@ -61,7 +61,7 @@ CMICmnMIValueTuple::CMICmnMIValueTuple(const CMICmnMIValueResult &vResult, const
// Return: None.
// Throws: None.
//--
-CMICmnMIValueTuple::~CMICmnMIValueTuple(void)
+CMICmnMIValueTuple::~CMICmnMIValueTuple()
{
}
@@ -69,28 +69,24 @@ CMICmnMIValueTuple::~CMICmnMIValueTuple(void)
// Details: Build the result value's mandatory data part, one tuple
// Type: Method.
// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
+// Return: None.
// Throws: None.
//--
-bool
-CMICmnMIValueTuple::BuildTuple(void)
+void
+CMICmnMIValueTuple::BuildTuple()
{
const char *pFormat = "{%s}";
m_strValue = CMIUtilString::Format(pFormat, m_strValue.c_str());
-
- return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
// Details: Add another MI result object to the value's list of tuples.
// Type: Method.
// Args: vResult - (R) The MI result object.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
+// Return: None.
// Throws: None.
//--
-bool
+void
CMICmnMIValueTuple::BuildTuple(const CMICmnMIValueResult &vResult)
{
// Clear out the default "<Invalid>" text
@@ -98,7 +94,8 @@ CMICmnMIValueTuple::BuildTuple(const CMICmnMIValueResult &vResult)
{
m_bJustConstructed = false;
m_strValue = vResult.GetString();
- return BuildTuple();
+ BuildTuple();
+ return;
}
if (m_strValue[0] == '{')
@@ -112,19 +109,16 @@ CMICmnMIValueTuple::BuildTuple(const CMICmnMIValueResult &vResult)
const char *pFormat = m_bSpaceAfterComma ? "{%s, %s}" : "{%s,%s}";
m_strValue = CMIUtilString::Format(pFormat, m_strValue.c_str(), vResult.GetString().c_str());
-
- return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
// Details: Add string value to the value's list of tuples.
// Type: Method.
// Args: vValue - (R) The string object.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
+// Return: None.
// Throws: None.
//--
-bool
+void
CMICmnMIValueTuple::BuildTuple(const CMIUtilString &vValue)
{
// Clear out the default "<Invalid>" text
@@ -132,14 +126,13 @@ CMICmnMIValueTuple::BuildTuple(const CMIUtilString &vValue)
{
m_bJustConstructed = false;
m_strValue = vValue;
- return BuildTuple();
+ BuildTuple();
+ return;
}
const CMIUtilString data(ExtractContentNoBrackets());
const char *pFormat = m_bSpaceAfterComma ? "{%s, %s}" : "{%s,%s}";
m_strValue = CMIUtilString::Format(pFormat, data.c_str(), vValue.c_str());
-
- return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
@@ -148,14 +141,13 @@ CMICmnMIValueTuple::BuildTuple(const CMIUtilString &vValue)
// will return MIstatus::failure.
// Type: Method.
// Args: vValue - (R) The MI value object.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
+// Return: None.
// Throws: None.
//--
-bool
+void
CMICmnMIValueTuple::Add(const CMICmnMIValueResult &vResult)
{
- return BuildTuple(vResult);
+ BuildTuple(vResult);
}
//++ ------------------------------------------------------------------------------------
@@ -165,15 +157,14 @@ CMICmnMIValueTuple::Add(const CMICmnMIValueResult &vResult)
// Type: Method.
// Args: vValue - (R) The MI value object.
// vbUseSpacing - (R) True = put space separators into the string, false = no spaces used.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
+// Return: None.
// Throws: None.
//--
-bool
+void
CMICmnMIValueTuple::Add(const CMICmnMIValueResult &vResult, const bool vbUseSpacing)
{
m_bSpaceAfterComma = vbUseSpacing;
- return BuildTuple(vResult);
+ BuildTuple(vResult);
}
//++ ------------------------------------------------------------------------------------
@@ -183,15 +174,14 @@ CMICmnMIValueTuple::Add(const CMICmnMIValueResult &vResult, const bool vbUseSpac
// Type: Method.
// Args: vValue - (R) The MI value object.
// vbUseSpacing - (R) True = put space separators into the string, false = no spaces used.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
+// Return: None.
// Throws: None.
//--
-bool
+void
CMICmnMIValueTuple::Add(const CMICmnMIValueConst &vValue, const bool vbUseSpacing)
{
m_bSpaceAfterComma = vbUseSpacing;
- return BuildTuple(vValue.GetString());
+ BuildTuple(vValue.GetString());
}
//++ ------------------------------------------------------------------------------------
@@ -203,7 +193,7 @@ CMICmnMIValueTuple::Add(const CMICmnMIValueConst &vValue, const bool vbUseSpacin
// Throws: None.
//--
CMIUtilString
-CMICmnMIValueTuple::ExtractContentNoBrackets(void) const
+CMICmnMIValueTuple::ExtractContentNoBrackets() const
{
CMIUtilString data(m_strValue);
diff --git a/tools/lldb-mi/MICmnMIValueTuple.h b/tools/lldb-mi/MICmnMIValueTuple.h
index ecf5402dc54c..8f36b4f69d01 100644
--- a/tools/lldb-mi/MICmnMIValueTuple.h
+++ b/tools/lldb-mi/MICmnMIValueTuple.h
@@ -30,33 +30,30 @@
// list ==> "[]" | "[" value ( "," value )* "]" | "[" result ( "," result )* "]"
// More information see:
// http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_chapter/gdb_22.html
-// Gotchas: None.
-// Authors: Illya Rudkin 24/02/2014.
-// Changes: None.
//--
class CMICmnMIValueTuple : public CMICmnMIValue
{
// Methods:
public:
- /* ctor */ CMICmnMIValueTuple(void);
+ /* ctor */ CMICmnMIValueTuple();
/* ctor */ CMICmnMIValueTuple(const CMICmnMIValueResult &vResult);
/* ctor */ CMICmnMIValueTuple(const CMICmnMIValueResult &vResult, const bool vbUseSpacing);
//
- bool Add(const CMICmnMIValueResult &vResult);
- bool Add(const CMICmnMIValueResult &vResult, const bool vbUseSpacing);
- bool Add(const CMICmnMIValueConst &vValue, const bool vbUseSpacing);
- CMIUtilString ExtractContentNoBrackets(void) const;
+ void Add(const CMICmnMIValueResult &vResult);
+ void Add(const CMICmnMIValueResult &vResult, const bool vbUseSpacing);
+ void Add(const CMICmnMIValueConst &vValue, const bool vbUseSpacing);
+ CMIUtilString ExtractContentNoBrackets() const;
// Overridden:
public:
// From CMICmnBase
- /* dtor */ ~CMICmnMIValueTuple(void) override;
+ /* dtor */ ~CMICmnMIValueTuple() override;
// Methods:
private:
- bool BuildTuple(void);
- bool BuildTuple(const CMICmnMIValueResult &vResult);
- bool BuildTuple(const CMIUtilString &vValue);
+ void BuildTuple();
+ void BuildTuple(const CMICmnMIValueResult &vResult);
+ void BuildTuple(const CMIUtilString &vValue);
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmnResources.cpp b/tools/lldb-mi/MICmnResources.cpp
index ee9c93d7eba2..50d6b795def6 100644
--- a/tools/lldb-mi/MICmnResources.cpp
+++ b/tools/lldb-mi/MICmnResources.cpp
@@ -45,7 +45,6 @@ const CMICmnResources::SRsrcTextData CMICmnResources::ms_pResourceId2TextData[]
{IDS_MEDIUMFILE_ERR_INVALID_PATH, "<Invalid - not set>"},
{IDS_MEDIUMFILE_ERR_FILE_HEADER, "<Invalid - header not set>"},
{IDS_MEDIUMFILE_NAME_LOG, "File medium. %s"},
- {IDE_MEDIUMFILE_ERR_GET_FILE_PATHNAME_SYS, "File Medium. Failed to retrieve the system/executable path for the Log file"},
{IDE_OS_ERR_UNKNOWN, "Unknown OS error"},
{IDE_OS_ERR_RETRIEVING, "Unabled to retrieve OS error message"},
{IDS_DRIVERMGR_DRIVER_ERR_INIT, "Driver Manager. Driver '%s' (ID:'%s') initialise failed. %s"},
@@ -142,8 +141,6 @@ const CMICmnResources::SRsrcTextData CMICmnResources::ms_pResourceId2TextData[]
"LLDB Out-of-band. %s. Event handler tried to set new MI Driver running state and failed. %s"},
{IDS_LLDBOUTOFBAND_ERR_BRKPT_CNT_EXCEEDED,
"LLDB Out-of-band. '%s'. Number of valid breakpoint exceeded %d. Cannot create new breakpoint with ID %d"},
- {IDS_DBGSESSION_ERR_SHARED_DATA_RELEASE,
- "LLDB debug session info. Release some or all of the data shared across command instances failed"},
{IDS_DBGSESSION_ERR_SHARED_DATA_ADD, "LLDB debug session info. Failed to add '%s' data to the shared data command container"},
{IDS_MI_SHTDWN_ERR_LOG, "Log. Error occurred during shutdown. %s"},
{IDS_MI_SHUTDOWN_ERR, "Server shutdown failure. %s"},
@@ -265,7 +262,7 @@ const CMICmnResources::SRsrcTextData CMICmnResources::ms_pResourceId2TextData[]
// Return: None.
// Throws: None.
//--
-CMICmnResources::CMICmnResources(void)
+CMICmnResources::CMICmnResources()
: m_nResourceId2TextDataSize(0)
{
// Do not use this constructor, use Initialize()
@@ -278,7 +275,7 @@ CMICmnResources::CMICmnResources(void)
// Return: None.
// Throws: None.
//--
-CMICmnResources::~CMICmnResources(void)
+CMICmnResources::~CMICmnResources()
{
// Do not use this destructor, use Shutdown()
}
@@ -292,7 +289,7 @@ CMICmnResources::~CMICmnResources(void)
// Throws: None.
//--
bool
-CMICmnResources::Initialize(void)
+CMICmnResources::Initialize()
{
m_clientUsageRefCnt++;
@@ -313,7 +310,7 @@ CMICmnResources::Initialize(void)
// Throws: None.
//--
bool
-CMICmnResources::Shutdown(void)
+CMICmnResources::Shutdown()
{
if (--m_clientUsageRefCnt > 0)
return MIstatus::success;
@@ -338,7 +335,7 @@ CMICmnResources::Shutdown(void)
// Throws: None.
//--
bool
-CMICmnResources::ReadResourceStringData(void)
+CMICmnResources::ReadResourceStringData()
{
m_nResourceId2TextDataSize = sizeof ms_pResourceId2TextData / sizeof ms_pResourceId2TextData[0];
for (MIuint i = 0; i < m_nResourceId2TextDataSize; i++)
diff --git a/tools/lldb-mi/MICmnResources.h b/tools/lldb-mi/MICmnResources.h
index 633eba8de9e4..dc9c52c6df60 100644
--- a/tools/lldb-mi/MICmnResources.h
+++ b/tools/lldb-mi/MICmnResources.h
@@ -50,7 +50,6 @@ enum
IDS_LOG_MEDIUM_ERR_INIT,
IDS_LOG_MEDIUM_ERR_WRITE_ANY,
IDS_LOG_MEDIUM_ERR_WRITE_MEDIUMFAIL,
- IDE_MEDIUMFILE_ERR_GET_FILE_PATHNAME_SYS,
IDS_MEDIUMFILE_NAME,
IDS_MEDIUMFILE_ERR_INVALID_PATH,
@@ -153,7 +152,6 @@ enum
IDS_LLDBOUTOFBAND_ERR_SETNEWDRIVERSTATE,
IDS_LLDBOUTOFBAND_ERR_BRKPT_CNT_EXCEEDED,
- IDS_DBGSESSION_ERR_SHARED_DATA_RELEASE,
IDS_DBGSESSION_ERR_SHARED_DATA_ADD,
IDS_MI_SHTDWN_ERR_LOG,
@@ -279,9 +277,6 @@ enum
// Details: MI common code implementation class. Handle application resources
// and locality.
// Singleton class.
-// Gotchas: None.
-// Authors: Illya Rudkin 29/01/2014.
-// Changes: None.
//--
class CMICmnResources : public CMICmnBase, public MI::ISingleton<CMICmnResources>
{
@@ -289,8 +284,8 @@ class CMICmnResources : public CMICmnBase, public MI::ISingleton<CMICmnResources
// Methods:
public:
- bool Initialize(void) override;
- bool Shutdown(void) override;
+ bool Initialize() override;
+ bool Shutdown() override;
CMIUtilString GetString(const MIuint vResourceId) const;
bool HasString(const MIuint vResourceId) const;
@@ -317,17 +312,17 @@ class CMICmnResources : public CMICmnBase, public MI::ISingleton<CMICmnResources
// Methods:
private:
- /* ctor */ CMICmnResources(void);
+ /* ctor */ CMICmnResources();
/* ctor */ CMICmnResources(const CMICmnResources &);
void operator=(const CMICmnResources &);
bool GetStringFromResource(const MIuint vResourceId, CMIUtilString &vrwResourceString) const;
- bool ReadResourceStringData(void);
+ bool ReadResourceStringData();
// Overridden:
private:
// From CMICmnBase
- /* dtor */ ~CMICmnResources(void) override;
+ /* dtor */ ~CMICmnResources() override;
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmnStreamStderr.cpp b/tools/lldb-mi/MICmnStreamStderr.cpp
index 5a18951b271c..e5c494ba38fd 100644
--- a/tools/lldb-mi/MICmnStreamStderr.cpp
+++ b/tools/lldb-mi/MICmnStreamStderr.cpp
@@ -20,7 +20,7 @@
// Return: None.
// Throws: None.
//--
-CMICmnStreamStderr::CMICmnStreamStderr(void)
+CMICmnStreamStderr::CMICmnStreamStderr()
{
}
@@ -31,7 +31,7 @@ CMICmnStreamStderr::CMICmnStreamStderr(void)
// Return: None.
// Throws: None.
//--
-CMICmnStreamStderr::~CMICmnStreamStderr(void)
+CMICmnStreamStderr::~CMICmnStreamStderr()
{
Shutdown();
}
@@ -45,7 +45,7 @@ CMICmnStreamStderr::~CMICmnStreamStderr(void)
// Throws: None.
//--
bool
-CMICmnStreamStderr::Initialize(void)
+CMICmnStreamStderr::Initialize()
{
m_clientUsageRefCnt++;
@@ -76,7 +76,7 @@ CMICmnStreamStderr::Initialize(void)
// Throws: None.
//--
bool
-CMICmnStreamStderr::Shutdown(void)
+CMICmnStreamStderr::Shutdown()
{
if (--m_clientUsageRefCnt > 0)
return MIstatus::success;
@@ -191,7 +191,7 @@ CMICmnStreamStderr::WritePriv(const CMIUtilString &vText, const CMIUtilString &v
// Throws: None.
//--
bool
-CMICmnStreamStderr::Lock(void)
+CMICmnStreamStderr::Lock()
{
m_mutex.Lock();
return MIstatus::success;
@@ -206,7 +206,7 @@ CMICmnStreamStderr::Lock(void)
// Throws: None.
//--
bool
-CMICmnStreamStderr::Unlock(void)
+CMICmnStreamStderr::Unlock()
{
m_mutex.Unlock();
return MIstatus::success;
diff --git a/tools/lldb-mi/MICmnStreamStderr.h b/tools/lldb-mi/MICmnStreamStderr.h
index afceada9ff2e..95085a2a3275 100644
--- a/tools/lldb-mi/MICmnStreamStderr.h
+++ b/tools/lldb-mi/MICmnStreamStderr.h
@@ -20,9 +20,6 @@
// CMICmnStreamStderr sets up and tears downs stderr for the driver.
//
// Singleton class.
-// Gotchas: None.
-// Authors: Illya Rudkin 19/03/2014.
-// Changes: None.
//--
class CMICmnStreamStderr : public CMICmnBase, public MI::ISingleton<CMICmnStreamStderr>
{
@@ -35,17 +32,17 @@ class CMICmnStreamStderr : public CMICmnBase, public MI::ISingleton<CMICmnStream
// Methods:
public:
- bool Initialize(void) override;
- bool Shutdown(void) override;
+ bool Initialize() override;
+ bool Shutdown() override;
//
- bool Lock(void);
- bool Unlock(void);
+ bool Lock();
+ bool Unlock();
bool Write(const CMIUtilString &vText, const bool vbSendToLog = true);
bool WriteLLDBMsg(const CMIUtilString &vText, const bool vbSendToLog = true);
// Methods:
private:
- /* ctor */ CMICmnStreamStderr(void);
+ /* ctor */ CMICmnStreamStderr();
/* ctor */ CMICmnStreamStderr(const CMICmnStreamStderr &);
void operator=(const CMICmnStreamStderr &);
//
@@ -54,7 +51,7 @@ class CMICmnStreamStderr : public CMICmnBase, public MI::ISingleton<CMICmnStream
// Overridden:
private:
// From CMICmnBase
- /* dtor */ ~CMICmnStreamStderr(void) override;
+ /* dtor */ ~CMICmnStreamStderr() override;
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmnStreamStdin.cpp b/tools/lldb-mi/MICmnStreamStdin.cpp
index 891b1c9bb994..60fa49c4988f 100644
--- a/tools/lldb-mi/MICmnStreamStdin.cpp
+++ b/tools/lldb-mi/MICmnStreamStdin.cpp
@@ -1,4 +1,4 @@
-//===-- MIUtilStreamStdin.cpp -----------------------------------*- C++ -*-===//
+//===-- MICmnStreamStdin.cpp ------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -28,7 +28,7 @@
// Return: None.
// Throws: None.
//--
-CMICmnStreamStdin::CMICmnStreamStdin(void)
+CMICmnStreamStdin::CMICmnStreamStdin()
: m_strPromptCurrent("(gdb)")
, m_bShowPrompt(true)
, m_pCmdBuffer(nullptr)
@@ -42,7 +42,7 @@ CMICmnStreamStdin::CMICmnStreamStdin(void)
// Return: None.
// Throws: None.
//--
-CMICmnStreamStdin::~CMICmnStreamStdin(void)
+CMICmnStreamStdin::~CMICmnStreamStdin()
{
Shutdown();
}
@@ -56,7 +56,7 @@ CMICmnStreamStdin::~CMICmnStreamStdin(void)
// Throws: None.
//--
bool
-CMICmnStreamStdin::Initialize(void)
+CMICmnStreamStdin::Initialize()
{
m_clientUsageRefCnt++;
@@ -95,7 +95,7 @@ CMICmnStreamStdin::Initialize(void)
// Throws: None.
//--
bool
-CMICmnStreamStdin::Shutdown(void)
+CMICmnStreamStdin::Shutdown()
{
if (--m_clientUsageRefCnt > 0)
return MIstatus::success;
@@ -158,7 +158,7 @@ CMICmnStreamStdin::SetPrompt(const CMIUtilString &vNewPrompt)
// Throws: None.
//--
const CMIUtilString &
-CMICmnStreamStdin::GetPrompt(void) const
+CMICmnStreamStdin::GetPrompt() const
{
return m_strPromptCurrent;
}
@@ -189,7 +189,7 @@ CMICmnStreamStdin::SetEnablePrompt(const bool vbYes)
// Throws: None.
//--
bool
-CMICmnStreamStdin::GetEnablePrompt(void) const
+CMICmnStreamStdin::GetEnablePrompt() const
{
return m_bShowPrompt;
}
diff --git a/tools/lldb-mi/MICmnStreamStdin.h b/tools/lldb-mi/MICmnStreamStdin.h
index 71076d6dcd4e..a4b12a594125 100644
--- a/tools/lldb-mi/MICmnStreamStdin.h
+++ b/tools/lldb-mi/MICmnStreamStdin.h
@@ -1,4 +1,4 @@
-//===-- MIUtilStreamStdin.h -------------------------------------*- C++ -*-===//
+//===-- MICmnStreamStdin.h --------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -21,9 +21,6 @@
// provide can receive callbacks when a new line of data is received.
// Each line is determined by a carriage return.
// A singleton class.
-// Gotchas: None.
-// Authors: Illya Rudkin 10/02/2014.
-// Changes: Factored out OS specific handling of reading stdin - IOR 16/06/2014.
//--
class CMICmnStreamStdin : public CMICmnBase, public MI::ISingleton<CMICmnStreamStdin>
{
@@ -32,25 +29,25 @@ class CMICmnStreamStdin : public CMICmnBase, public MI::ISingleton<CMICmnStreamS
// Methods:
public:
- bool Initialize(void) override;
- bool Shutdown(void) override;
+ bool Initialize() override;
+ bool Shutdown() override;
//
- const CMIUtilString &GetPrompt(void) const;
+ const CMIUtilString &GetPrompt() const;
bool SetPrompt(const CMIUtilString &vNewPrompt);
void SetEnablePrompt(const bool vbYes);
- bool GetEnablePrompt(void) const;
+ bool GetEnablePrompt() const;
const char *ReadLine(CMIUtilString &vwErrMsg);
// Methods:
private:
- /* ctor */ CMICmnStreamStdin(void);
+ /* ctor */ CMICmnStreamStdin();
/* ctor */ CMICmnStreamStdin(const CMICmnStreamStdin &);
void operator=(const CMICmnStreamStdin &);
// Overridden:
private:
// From CMICmnBase
- /* dtor */ ~CMICmnStreamStdin(void) override;
+ /* dtor */ ~CMICmnStreamStdin() override;
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmnStreamStdout.cpp b/tools/lldb-mi/MICmnStreamStdout.cpp
index 2c93c99e6c8a..8b65251423b5 100644
--- a/tools/lldb-mi/MICmnStreamStdout.cpp
+++ b/tools/lldb-mi/MICmnStreamStdout.cpp
@@ -1,4 +1,4 @@
-//===-- MIUtilStreamStdout.cpp ----------------------------------*- C++ -*-===//
+//===-- MICmnStreamStdout.cpp -----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -20,7 +20,7 @@
// Return: None.
// Throws: None.
//--
-CMICmnStreamStdout::CMICmnStreamStdout(void)
+CMICmnStreamStdout::CMICmnStreamStdout()
{
}
@@ -31,7 +31,7 @@ CMICmnStreamStdout::CMICmnStreamStdout(void)
// Return: None.
// Throws: None.
//--
-CMICmnStreamStdout::~CMICmnStreamStdout(void)
+CMICmnStreamStdout::~CMICmnStreamStdout()
{
Shutdown();
}
@@ -45,7 +45,7 @@ CMICmnStreamStdout::~CMICmnStreamStdout(void)
// Throws: None.
//--
bool
-CMICmnStreamStdout::Initialize(void)
+CMICmnStreamStdout::Initialize()
{
m_clientUsageRefCnt++;
@@ -76,7 +76,7 @@ CMICmnStreamStdout::Initialize(void)
// Throws: None.
//--
bool
-CMICmnStreamStdout::Shutdown(void)
+CMICmnStreamStdout::Shutdown()
{
if (--m_clientUsageRefCnt > 0)
return MIstatus::success;
@@ -183,7 +183,7 @@ CMICmnStreamStdout::WritePriv(const CMIUtilString &vText, const CMIUtilString &v
// Throws: None.
//--
bool
-CMICmnStreamStdout::Lock(void)
+CMICmnStreamStdout::Lock()
{
m_mutex.Lock();
return MIstatus::success;
@@ -198,7 +198,7 @@ CMICmnStreamStdout::Lock(void)
// Throws: None.
//--
bool
-CMICmnStreamStdout::Unlock(void)
+CMICmnStreamStdout::Unlock()
{
m_mutex.Unlock();
return MIstatus::success;
@@ -229,7 +229,7 @@ CMICmnStreamStdout::TextToStdout(const CMIUtilString &vrTxt)
// Throws: None.
//--
bool
-CMICmnStreamStdout::WritePrompt(void)
+CMICmnStreamStdout::WritePrompt()
{
const CMICmnStreamStdin &rStdinMan = CMICmnStreamStdin::Instance();
if (rStdinMan.GetEnablePrompt())
diff --git a/tools/lldb-mi/MICmnStreamStdout.h b/tools/lldb-mi/MICmnStreamStdout.h
index 664faae863da..9d7f91a1504b 100644
--- a/tools/lldb-mi/MICmnStreamStdout.h
+++ b/tools/lldb-mi/MICmnStreamStdout.h
@@ -20,9 +20,6 @@
// CMICmnStreamStdout sets up and tears downs stdout for the driver.
//
// Singleton class.
-// Gotchas: None.
-// Authors: Illya Rudkin 12/02/2014.
-// Changes: None.
//--
class CMICmnStreamStdout : public CMICmnBase, public MI::ISingleton<CMICmnStreamStdout>
{
@@ -31,21 +28,21 @@ class CMICmnStreamStdout : public CMICmnBase, public MI::ISingleton<CMICmnStream
// Statics:
public:
static bool TextToStdout(const CMIUtilString &vrTxt);
- static bool WritePrompt(void);
+ static bool WritePrompt();
// Methods:
public:
- bool Initialize(void) override;
- bool Shutdown(void) override;
+ bool Initialize() override;
+ bool Shutdown() override;
//
- bool Lock(void);
- bool Unlock(void);
+ bool Lock();
+ bool Unlock();
bool Write(const CMIUtilString &vText, const bool vbSendToLog = true);
bool WriteMIResponse(const CMIUtilString &vText, const bool vbSendToLog = true);
// Methods:
private:
- /* ctor */ CMICmnStreamStdout(void);
+ /* ctor */ CMICmnStreamStdout();
/* ctor */ CMICmnStreamStdout(const CMICmnStreamStdout &);
void operator=(const CMICmnStreamStdout &);
//
@@ -54,7 +51,7 @@ class CMICmnStreamStdout : public CMICmnBase, public MI::ISingleton<CMICmnStream
// Overridden:
private:
// From CMICmnBase
- /* dtor */ ~CMICmnStreamStdout(void) override;
+ /* dtor */ ~CMICmnStreamStdout() override;
// Attributes:
private:
diff --git a/tools/lldb-mi/MICmnThreadMgrStd.cpp b/tools/lldb-mi/MICmnThreadMgrStd.cpp
index f0185b8fcf1d..ec223b802f8e 100644
--- a/tools/lldb-mi/MICmnThreadMgrStd.cpp
+++ b/tools/lldb-mi/MICmnThreadMgrStd.cpp
@@ -1,4 +1,4 @@
-//===-- MICmnThreadMgr.cpp --------------------------------------*- C++ -*-===//
+//===-- MICmnThreadMgrStd.cpp -----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -20,7 +20,7 @@
// Return: None.
// Throws: None.
//--
-CMICmnThreadMgrStd::CMICmnThreadMgrStd(void)
+CMICmnThreadMgrStd::CMICmnThreadMgrStd()
{
}
@@ -31,7 +31,7 @@ CMICmnThreadMgrStd::CMICmnThreadMgrStd(void)
// Return: None.
// Throws: None.
//--
-CMICmnThreadMgrStd::~CMICmnThreadMgrStd(void)
+CMICmnThreadMgrStd::~CMICmnThreadMgrStd()
{
Shutdown();
}
@@ -45,7 +45,7 @@ CMICmnThreadMgrStd::~CMICmnThreadMgrStd(void)
// Throws: None.
//--
bool
-CMICmnThreadMgrStd::Initialize(void)
+CMICmnThreadMgrStd::Initialize()
{
m_clientUsageRefCnt++;
@@ -82,7 +82,7 @@ CMICmnThreadMgrStd::Initialize(void)
// Throws: None.
//--
bool
-CMICmnThreadMgrStd::Shutdown(void)
+CMICmnThreadMgrStd::Shutdown()
{
if (--m_clientUsageRefCnt > 0)
return MIstatus::success;
@@ -121,7 +121,7 @@ CMICmnThreadMgrStd::Shutdown(void)
// Throws: None.
//--
bool
-CMICmnThreadMgrStd::ThreadAllTerminate(void)
+CMICmnThreadMgrStd::ThreadAllTerminate()
{
ThreadList_t::const_iterator it = m_threadList.begin();
for (; it != m_threadList.end(); ++it)
diff --git a/tools/lldb-mi/MICmnThreadMgrStd.h b/tools/lldb-mi/MICmnThreadMgrStd.h
index fef999b2a7b1..fc0013f99498 100644
--- a/tools/lldb-mi/MICmnThreadMgrStd.h
+++ b/tools/lldb-mi/MICmnThreadMgrStd.h
@@ -25,9 +25,6 @@
// This manager will stop and delete all threads on *this manager's
// shutdown.
// Singleton class.
-// Gotchas: None.
-// Authors: Aidan Dodds 12/03/2014.
-// Changes: None.
//--
class CMICmnThreadMgrStd : public CMICmnBase, public MI::ISingleton<CMICmnThreadMgrStd>
{
@@ -35,10 +32,10 @@ class CMICmnThreadMgrStd : public CMICmnBase, public MI::ISingleton<CMICmnThread
// Methods:
public:
- bool Initialize(void) override;
- bool Shutdown(void) override;
+ bool Initialize() override;
+ bool Shutdown() override;
bool
- ThreadAllTerminate(void); // Ask all threads to stop (caution)
+ ThreadAllTerminate(); // Ask all threads to stop (caution)
template <typename T> // Ask the thread manager to start and stop threads on our behalf
bool ThreadStart(T &vrwObject);
@@ -48,7 +45,7 @@ class CMICmnThreadMgrStd : public CMICmnBase, public MI::ISingleton<CMICmnThread
// Methods:
private:
- /* ctor */ CMICmnThreadMgrStd(void);
+ /* ctor */ CMICmnThreadMgrStd();
/* ctor */ CMICmnThreadMgrStd(const CMICmnThreadMgrStd &);
void operator=(const CMICmnThreadMgrStd &);
//
@@ -58,7 +55,7 @@ class CMICmnThreadMgrStd : public CMICmnBase, public MI::ISingleton<CMICmnThread
// Overridden:
private:
// From CMICmnBase
- /* dtor */ ~CMICmnThreadMgrStd(void) override;
+ /* dtor */ ~CMICmnThreadMgrStd() override;
// Attributes:
private:
diff --git a/tools/lldb-mi/MIDataTypes.h b/tools/lldb-mi/MIDataTypes.h
index 33c5b20095d9..d749b0c661a8 100644
--- a/tools/lldb-mi/MIDataTypes.h
+++ b/tools/lldb-mi/MIDataTypes.h
@@ -39,15 +39,6 @@ const bool failure = false;
// Use to avoid "unused parameter" compiler warnings:
#define MIunused(x) (void) x;
-#ifdef _WIN32
-#define MI_NO_INITIALIZE_VTABLE __declspec(novtable)
-#define MI_FORCE_INLINE __forceinline
-#else
-#define MI_NO_INITIALIZE_VTABLE
-#define MI_FORCE_INLINE inline
-// __attribute__( ( always_inline ) )
-#endif // _WIN32
-
// Portability issues
#ifdef _WIN64
typedef unsigned __int64 size_t;
@@ -72,10 +63,3 @@ typedef unsigned int MIuint;
// Fundamentals:
typedef long long MIint64; // 64bit signed integer.
typedef unsigned long long MIuint64; // 64bit unsigned integer.
-
-// using namespace std; // Better to put this or std:: at translation units scope.
-
-//--------------------------------------------------------------------------------------
-// Common routines:
-
-//--------------------------------------------------------------------------------------
diff --git a/tools/lldb-mi/MIDriver.cpp b/tools/lldb-mi/MIDriver.cpp
index d4a31958d9ec..78172375b3d0 100644
--- a/tools/lldb-mi/MIDriver.cpp
+++ b/tools/lldb-mi/MIDriver.cpp
@@ -45,7 +45,7 @@ const CMIUtilString CMIDriver::ms_constAppNameLong(MIRSRC(IDS_MI_APPNAME_LONG));
// Return: None.
// Throws: None.
//--
-CMIDriver::CMIDriver(void)
+CMIDriver::CMIDriver()
: m_bFallThruToOtherDriverEnabled(false)
, m_bDriverIsExiting(false)
, m_handleMainThread(0)
@@ -66,7 +66,7 @@ CMIDriver::CMIDriver(void)
// Return: None.
// Throws: None.
//--
-CMIDriver::~CMIDriver(void)
+CMIDriver::~CMIDriver()
{
}
@@ -97,7 +97,7 @@ CMIDriver::SetEnableFallThru(const bool vbYes)
// Throws: None.
//--
bool
-CMIDriver::GetEnableFallThru(void) const
+CMIDriver::GetEnableFallThru() const
{
return m_bFallThruToOtherDriverEnabled;
}
@@ -110,7 +110,7 @@ CMIDriver::GetEnableFallThru(void) const
// Throws: None.
//--
const CMIUtilString &
-CMIDriver::GetAppNameShort(void) const
+CMIDriver::GetAppNameShort() const
{
return ms_constAppNameShort;
}
@@ -123,7 +123,7 @@ CMIDriver::GetAppNameShort(void) const
// Throws: None.
//--
const CMIUtilString &
-CMIDriver::GetAppNameLong(void) const
+CMIDriver::GetAppNameLong() const
{
return ms_constAppNameLong;
}
@@ -136,7 +136,7 @@ CMIDriver::GetAppNameLong(void) const
// Throws: None.
//--
const CMIUtilString &
-CMIDriver::GetVersionDescription(void) const
+CMIDriver::GetVersionDescription() const
{
return ms_constMIVersion;
}
@@ -150,7 +150,7 @@ CMIDriver::GetVersionDescription(void) const
// Throws: None.
//--
bool
-CMIDriver::Initialize(void)
+CMIDriver::Initialize()
{
m_eCurrentDriverState = eDriverState_Initialising;
m_clientUsageRefCnt++;
@@ -199,7 +199,7 @@ CMIDriver::Initialize(void)
// Throws: None.
//--
bool
-CMIDriver::Shutdown(void)
+CMIDriver::Shutdown()
{
if (--m_clientUsageRefCnt > 0)
return MIstatus::success;
@@ -260,7 +260,7 @@ CMIDriver::WriteMessageToLog(const CMIUtilString &vMessage)
// Throws: None.
//--
bool
-CMIDriver::DoInitialize(void)
+CMIDriver::DoInitialize()
{
return CMIDriver::Instance().Initialize();
}
@@ -275,7 +275,7 @@ CMIDriver::DoInitialize(void)
// Throws: None.
//--
bool
-CMIDriver::DoShutdown(void)
+CMIDriver::DoShutdown()
{
return CMIDriver::Instance().Shutdown();
}
@@ -288,7 +288,7 @@ CMIDriver::DoShutdown(void)
// Throws: None.
//--
const CMIUtilString &
-CMIDriver::GetName(void) const
+CMIDriver::GetName() const
{
const CMIUtilString &rName = GetAppNameLong();
const CMIUtilString &rVsn = GetVersionDescription();
@@ -305,7 +305,7 @@ CMIDriver::GetName(void) const
// Throws: None.
//--
CMIUtilString
-CMIDriver::GetError(void) const
+CMIDriver::GetError() const
{
return GetErrorDescription();
}
@@ -318,7 +318,7 @@ CMIDriver::GetError(void) const
// Throws: None.
//--
lldb::SBDebugger &
-CMIDriver::GetTheDebugger(void)
+CMIDriver::GetTheDebugger()
{
return m_rLldbDebugger.GetTheDebugger();
}
@@ -465,7 +465,7 @@ CMIDriver::ParseArgs(const int argc, const char *argv[], FILE *vpStdOut, bool &v
// Throws: None.
//--
bool
-CMIDriver::GetDriverIsGDBMICompatibleDriver(void) const
+CMIDriver::GetDriverIsGDBMICompatibleDriver() const
{
return true;
}
@@ -479,7 +479,7 @@ CMIDriver::GetDriverIsGDBMICompatibleDriver(void) const
// Throws: None.
//--
bool
-CMIDriver::StartWorkerThreads(void)
+CMIDriver::StartWorkerThreads()
{
bool bOk = MIstatus::success;
@@ -507,7 +507,7 @@ CMIDriver::StartWorkerThreads(void)
// Throws: None.
//--
bool
-CMIDriver::StopWorkerThreads(void)
+CMIDriver::StopWorkerThreads()
{
CMICmnThreadMgrStd &rThreadMgr = CMICmnThreadMgrStd::Instance();
return rThreadMgr.ThreadAllTerminate();
@@ -523,7 +523,7 @@ CMIDriver::StopWorkerThreads(void)
// Throws: None.
//--
bool
-CMIDriver::DoMainLoop(void)
+CMIDriver::DoMainLoop()
{
if (!InitClientIDEToMIDriver()) // Init Eclipse IDE
{
@@ -607,7 +607,7 @@ CMIDriver::DoMainLoop(void)
// Throws: None.
//--
bool
-CMIDriver::DoAppQuit(void)
+CMIDriver::DoAppQuit()
{
bool bYesQuit = true;
@@ -675,7 +675,7 @@ CMIDriver::InterpretCommandFallThruDriver(const CMIUtilString &vTextLine, bool &
// Throws: None.
//--
const CMIUtilString &
-CMIDriver::GetDriverName(void) const
+CMIDriver::GetDriverName() const
{
return GetName();
}
@@ -688,7 +688,7 @@ CMIDriver::GetDriverName(void) const
// Throws: None.
//--
const CMIUtilString &
-CMIDriver::GetDriverId(void) const
+CMIDriver::GetDriverId() const
{
return GetId();
}
@@ -727,7 +727,7 @@ CMIDriver::DoFallThruToAnotherDriver(const CMIUtilString &vCmd, CMIUtilString &v
// Throws: None.
//--
FILE *
-CMIDriver::GetStdin(void) const
+CMIDriver::GetStdin() const
{
// Note this fn is called on CMIDriverMgr register driver so stream has to be
// available before *this driver has been initialized! Flaw?
@@ -746,7 +746,7 @@ CMIDriver::GetStdin(void) const
// Throws: None.
//--
FILE *
-CMIDriver::GetStdout(void) const
+CMIDriver::GetStdout() const
{
// Note this fn is called on CMIDriverMgr register driver so stream has to be
// available before *this driver has been initialized! Flaw?
@@ -764,7 +764,7 @@ CMIDriver::GetStdout(void) const
// Throws: None.
//--
FILE *
-CMIDriver::GetStderr(void) const
+CMIDriver::GetStderr() const
{
// Note this fn is called on CMIDriverMgr register driver so stream has to be
// available before *this driver has been initialized! Flaw?
@@ -803,7 +803,7 @@ CMIDriver::SetId(const CMIUtilString &vId)
// Throws: None.
//--
const CMIUtilString &
-CMIDriver::GetId(void) const
+CMIDriver::GetId() const
{
return m_strDriverId;
}
@@ -893,7 +893,7 @@ CMIDriver::WrapCLICommandIntoMICommand(const CMIUtilString &vTextLine) const
const std::string vToken(vTextLine.begin(), vTextLine.begin() + nCommandOffset);
// 001target create "/path/to/file"
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- CLI command
- const CMIUtilString vCliCommand(std::string(vTextLine, nCommandOffset).c_str());
+ const CMIUtilString vCliCommand(std::string(vTextLine, nCommandOffset));
// 5. Escape special characters and embed the command in a string
// Result: it looks like -- target create \"/path/to/file\".
@@ -1033,7 +1033,7 @@ CMIDriver::SetExitApplicationFlag(const bool vbForceExit)
// Throws: None.
//--
bool
-CMIDriver::GetExitApplicationFlag(void) const
+CMIDriver::GetExitApplicationFlag() const
{
return m_bExitApp;
}
@@ -1046,7 +1046,7 @@ CMIDriver::GetExitApplicationFlag(void) const
// Throws: None.
//--
CMIDriver::DriverState_e
-CMIDriver::GetCurrentDriverState(void) const
+CMIDriver::GetCurrentDriverState() const
{
return m_eCurrentDriverState;
}
@@ -1061,7 +1061,7 @@ CMIDriver::GetCurrentDriverState(void) const
// Throws: None.
//--
bool
-CMIDriver::SetDriverStateRunningNotDebugging(void)
+CMIDriver::SetDriverStateRunningNotDebugging()
{
// CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM
@@ -1110,7 +1110,7 @@ CMIDriver::SetDriverStateRunningNotDebugging(void)
// Throws: None.
//--
bool
-CMIDriver::SetDriverStateRunningDebugging(void)
+CMIDriver::SetDriverStateRunningDebugging()
{
// CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM
@@ -1157,7 +1157,7 @@ CMIDriver::SetDriverStateRunningDebugging(void)
// Throws: None.
//--
bool
-CMIDriver::InitClientIDEToMIDriver(void) const
+CMIDriver::InitClientIDEToMIDriver() const
{
// Put other IDE init functions here
return InitClientIDEEclipse();
@@ -1174,7 +1174,7 @@ CMIDriver::InitClientIDEToMIDriver(void) const
// Throws: None.
//--
bool
-CMIDriver::InitClientIDEEclipse(void) const
+CMIDriver::InitClientIDEEclipse() const
{
return CMICmnStreamStdout::WritePrompt();
}
@@ -1191,7 +1191,7 @@ CMIDriver::InitClientIDEEclipse(void) const
// Throws: None.
//--
bool
-CMIDriver::HaveExecutableFileNamePathOnCmdLine(void) const
+CMIDriver::HaveExecutableFileNamePathOnCmdLine() const
{
return m_bHaveExecutableFileNamePathOnCmdLine;
}
@@ -1205,7 +1205,7 @@ CMIDriver::HaveExecutableFileNamePathOnCmdLine(void) const
// Throws: None.
//--
const CMIUtilString &
-CMIDriver::GetExecutableFileNamePathOnCmdLine(void) const
+CMIDriver::GetExecutableFileNamePathOnCmdLine() const
{
return m_strCmdLineArgExecuteableFileNamePath;
}
@@ -1221,7 +1221,7 @@ CMIDriver::GetExecutableFileNamePathOnCmdLine(void) const
// Throws: None.
//--
bool
-CMIDriver::LocalDebugSessionStartupExecuteCommands(void)
+CMIDriver::LocalDebugSessionStartupExecuteCommands()
{
const CMIUtilString strCmd(CMIUtilString::Format("-file-exec-and-symbols \"%s\"", m_strCmdLineArgExecuteableFileNamePath.AddSlashes().c_str()));
bool bOk = CMICmnStreamStdout::TextToStdout(strCmd);
@@ -1239,7 +1239,7 @@ CMIDriver::LocalDebugSessionStartupExecuteCommands(void)
// Throws: None.
//--
void
-CMIDriver::SetDriverDebuggingArgExecutable(void)
+CMIDriver::SetDriverDebuggingArgExecutable()
{
m_bDriverDebuggingArgExecutable = true;
}
@@ -1254,7 +1254,7 @@ CMIDriver::SetDriverDebuggingArgExecutable(void)
// Throws: None.
//--
bool
-CMIDriver::IsDriverDebuggingArgExecutable(void) const
+CMIDriver::IsDriverDebuggingArgExecutable() const
{
return m_bDriverDebuggingArgExecutable;
}
diff --git a/tools/lldb-mi/MIDriver.h b/tools/lldb-mi/MIDriver.h
index 55c662494e21..a90c31fbc757 100644
--- a/tools/lldb-mi/MIDriver.h
+++ b/tools/lldb-mi/MIDriver.h
@@ -32,9 +32,6 @@ class CMICmnStreamStdout;
// work depending on the one selected to work. A driver can if not able
// to handle an instruction or 'command' can pass that command onto
// another driver object registered with the Driver Manager.
-// Gotchas: None.
-// Authors: Illya Rudkin 29/01/2014.
-// Changes: None.
//--
class CMIDriver : public CMICmnBase,
public CMIDriverMgr::IDriver,
@@ -68,51 +65,51 @@ class CMIDriver : public CMICmnBase,
// Methods:
public:
// MI system
- bool Initialize(void) override;
- bool Shutdown(void) override;
+ bool Initialize() override;
+ bool Shutdown() override;
// MI state
- bool GetExitApplicationFlag(void) const;
- DriverState_e GetCurrentDriverState(void) const;
- bool SetDriverStateRunningNotDebugging(void);
- bool SetDriverStateRunningDebugging(void);
- void SetDriverDebuggingArgExecutable(void);
- bool IsDriverDebuggingArgExecutable(void) const;
+ bool GetExitApplicationFlag() const;
+ DriverState_e GetCurrentDriverState() const;
+ bool SetDriverStateRunningNotDebugging();
+ bool SetDriverStateRunningDebugging();
+ void SetDriverDebuggingArgExecutable();
+ bool IsDriverDebuggingArgExecutable() const;
// MI information about itself
- const CMIUtilString &GetAppNameShort(void) const;
- const CMIUtilString &GetAppNameLong(void) const;
- const CMIUtilString &GetVersionDescription(void) const;
+ const CMIUtilString &GetAppNameShort() const;
+ const CMIUtilString &GetAppNameLong() const;
+ const CMIUtilString &GetVersionDescription() const;
// MI do work
bool WriteMessageToLog(const CMIUtilString &vMessage);
bool SetEnableFallThru(const bool vbYes);
- bool GetEnableFallThru(void) const;
- bool HaveExecutableFileNamePathOnCmdLine(void) const;
- const CMIUtilString &GetExecutableFileNamePathOnCmdLine(void) const;
+ bool GetEnableFallThru() const;
+ bool HaveExecutableFileNamePathOnCmdLine() const;
+ const CMIUtilString &GetExecutableFileNamePathOnCmdLine() const;
// Overridden:
public:
// From CMIDriverMgr::IDriver
- bool DoInitialize(void) override;
- bool DoShutdown(void) override;
- bool DoMainLoop(void) override;
+ bool DoInitialize() override;
+ bool DoShutdown() override;
+ bool DoMainLoop() override;
lldb::SBError DoParseArgs(const int argc, const char *argv[], FILE *vpStdOut, bool &vwbExiting) override;
- CMIUtilString GetError(void) const override;
- const CMIUtilString &GetName(void) const override;
- lldb::SBDebugger &GetTheDebugger(void) override;
- bool GetDriverIsGDBMICompatibleDriver(void) const override;
+ CMIUtilString GetError() const override;
+ const CMIUtilString &GetName() const override;
+ lldb::SBDebugger &GetTheDebugger() override;
+ bool GetDriverIsGDBMICompatibleDriver() const override;
bool SetId(const CMIUtilString &vId) override;
- const CMIUtilString &GetId(void) const override;
+ const CMIUtilString &GetId() const override;
// From CMIDriverBase
void SetExitApplicationFlag(const bool vbForceExit) override;
bool DoFallThruToAnotherDriver(const CMIUtilString &vCmd, CMIUtilString &vwErrMsg) override;
bool SetDriverToFallThruTo(const CMIDriverBase &vrOtherDriver) override;
- FILE *GetStdin(void) const override;
- FILE *GetStdout(void) const override;
- FILE *GetStderr(void) const override;
- const CMIUtilString &GetDriverName(void) const override;
- const CMIUtilString &GetDriverId(void) const override;
+ FILE *GetStdin() const override;
+ FILE *GetStdout() const override;
+ FILE *GetStderr() const override;
+ const CMIUtilString &GetDriverName() const override;
+ const CMIUtilString &GetDriverId() const override;
void DeliverSignal(int signal) override;
// Typedefs:
@@ -121,28 +118,28 @@ class CMIDriver : public CMICmnBase,
// Methods:
private:
- /* ctor */ CMIDriver(void);
+ /* ctor */ CMIDriver();
/* ctor */ CMIDriver(const CMIDriver &);
void operator=(const CMIDriver &);
lldb::SBError ParseArgs(const int argc, const char *argv[], FILE *vpStdOut, bool &vwbExiting);
- bool DoAppQuit(void);
+ bool DoAppQuit();
bool InterpretCommand(const CMIUtilString &vTextLine);
bool InterpretCommandThisDriver(const CMIUtilString &vTextLine, bool &vwbCmdYesValid);
CMIUtilString WrapCLICommandIntoMICommand(const CMIUtilString &vTextLine) const;
bool InterpretCommandFallThruDriver(const CMIUtilString &vTextLine, bool &vwbCmdYesValid);
bool ExecuteCommand(const SMICmdData &vCmdData);
- bool StartWorkerThreads(void);
- bool StopWorkerThreads(void);
- bool InitClientIDEToMIDriver(void) const;
- bool InitClientIDEEclipse(void) const;
- bool LocalDebugSessionStartupExecuteCommands(void);
+ bool StartWorkerThreads();
+ bool StopWorkerThreads();
+ bool InitClientIDEToMIDriver() const;
+ bool InitClientIDEEclipse() const;
+ bool LocalDebugSessionStartupExecuteCommands();
bool ExecuteCommandFile(const bool vbAsyncMode);
// Overridden:
private:
// From CMICmnBase
- /* dtor */ ~CMIDriver(void) override;
+ /* dtor */ ~CMIDriver() override;
// Attributes:
private:
diff --git a/tools/lldb-mi/MIDriverBase.cpp b/tools/lldb-mi/MIDriverBase.cpp
index 6bf5ab6e3bec..6738497de75e 100644
--- a/tools/lldb-mi/MIDriverBase.cpp
+++ b/tools/lldb-mi/MIDriverBase.cpp
@@ -21,7 +21,7 @@
// Return: None.
// Throws: None.
//--
-CMIDriverBase::CMIDriverBase(void)
+CMIDriverBase::CMIDriverBase()
: m_pDriverFallThru(nullptr)
, m_pDriverParent(nullptr)
, m_bExitApp(false)
@@ -35,7 +35,7 @@ CMIDriverBase::CMIDriverBase(void)
// Return: None.
// Throws: None.
//--
-CMIDriverBase::~CMIDriverBase(void)
+CMIDriverBase::~CMIDriverBase()
{
m_pDriverFallThru = NULL;
}
@@ -107,7 +107,7 @@ CMIDriverBase::SetDriverParent(const CMIDriverBase &vrOtherDriver)
// Throws: None.
//--
CMIDriverBase *
-CMIDriverBase::GetDriversParent(void) const
+CMIDriverBase::GetDriversParent() const
{
return m_pDriverParent;
}
@@ -122,7 +122,7 @@ CMIDriverBase::GetDriversParent(void) const
// Throws: None.
//--
CMIDriverBase *
-CMIDriverBase::GetDriverToFallThruTo(void) const
+CMIDriverBase::GetDriverToFallThruTo() const
{
return m_pDriverFallThru;
}
@@ -137,7 +137,7 @@ CMIDriverBase::GetDriverToFallThruTo(void) const
// Throws: None.
//--
FILE *
-CMIDriverBase::GetStdin(void) const
+CMIDriverBase::GetStdin() const
{
// Do nothing - override and implement
return nullptr;
@@ -152,7 +152,7 @@ CMIDriverBase::GetStdin(void) const
// Throws: None.
//--
FILE *
-CMIDriverBase::GetStdout(void) const
+CMIDriverBase::GetStdout() const
{
// Do nothing - override and implement
return nullptr;
@@ -167,7 +167,7 @@ CMIDriverBase::GetStdout(void) const
// Throws: None.
//--
FILE *
-CMIDriverBase::GetStderr(void) const
+CMIDriverBase::GetStderr() const
{
// Do nothing - override and implement
return nullptr;
diff --git a/tools/lldb-mi/MIDriverBase.h b/tools/lldb-mi/MIDriverBase.h
index ad242116b5f0..9be407e0c147 100644
--- a/tools/lldb-mi/MIDriverBase.h
+++ b/tools/lldb-mi/MIDriverBase.h
@@ -31,34 +31,31 @@ class SBBroadcaster;
// CDriverMgr to manage either (any) driver to be operated on.
// Each driver instance (the CMIDriver, LLDB::Driver) has its own
// LLDB::SBDebugger object.
-// Gotchas: None.
-// Authors: Illya Rudkin 30/01/2014.
-// Changes: None.
//--
class CMIDriverBase
{
// Methods:
public:
- /* ctor */ CMIDriverBase(void);
+ /* ctor */ CMIDriverBase();
- CMIDriverBase *GetDriverToFallThruTo(void) const;
- CMIDriverBase *GetDriversParent(void) const;
+ CMIDriverBase *GetDriverToFallThruTo() const;
+ CMIDriverBase *GetDriversParent() const;
// Overrideable:
public:
- /* dtor */ virtual ~CMIDriverBase(void);
+ /* dtor */ virtual ~CMIDriverBase();
virtual bool DoFallThruToAnotherDriver(const CMIUtilString &vCmd, CMIUtilString &vwErrMsg);
virtual bool SetDriverToFallThruTo(const CMIDriverBase &vrOtherDriver);
virtual bool SetDriverParent(const CMIDriverBase &vrOtherDriver);
- virtual const CMIUtilString &GetDriverName(void) const = 0;
- virtual const CMIUtilString &GetDriverId(void) const = 0;
+ virtual const CMIUtilString &GetDriverName() const = 0;
+ virtual const CMIUtilString &GetDriverId() const = 0;
virtual void SetExitApplicationFlag(const bool vbForceExit);
// MI provide information for the pass through (child) assigned driver
- virtual FILE *GetStdin(void) const;
- virtual FILE *GetStdout(void) const;
- virtual FILE *GetStderr(void) const;
+ virtual FILE *GetStdin() const;
+ virtual FILE *GetStdout() const;
+ virtual FILE *GetStderr() const;
// Attributes:
protected:
diff --git a/tools/lldb-mi/MIDriverMain.cpp b/tools/lldb-mi/MIDriverMain.cpp
index 2f469bf6d976..ccbaf77f09e1 100644
--- a/tools/lldb-mi/MIDriverMain.cpp
+++ b/tools/lldb-mi/MIDriverMain.cpp
@@ -89,7 +89,7 @@ sigint_handler(int vSigno)
// Throws: None.
//--
bool
-DriverSystemInit(void)
+DriverSystemInit()
{
bool bOk = MIstatus::success;
CMIDriver &rMIDriver = CMIDriver::Instance();
diff --git a/tools/lldb-mi/MIDriverMgr.cpp b/tools/lldb-mi/MIDriverMgr.cpp
index f4987dba90bc..472fc60f6439 100644
--- a/tools/lldb-mi/MIDriverMgr.cpp
+++ b/tools/lldb-mi/MIDriverMgr.cpp
@@ -26,7 +26,7 @@
// Return: None.
// Throws: None.
//--
-CMIDriverMgr::CMIDriverMgr(void)
+CMIDriverMgr::CMIDriverMgr()
: m_pDriverCurrent(nullptr)
, m_bInMi2Mode(false)
{
@@ -39,7 +39,7 @@ CMIDriverMgr::CMIDriverMgr(void)
// Return: None.
// Throws: None.
//--
-CMIDriverMgr::~CMIDriverMgr(void)
+CMIDriverMgr::~CMIDriverMgr()
{
Shutdown();
}
@@ -53,7 +53,7 @@ CMIDriverMgr::~CMIDriverMgr(void)
// Throws: None.
//--
bool
-CMIDriverMgr::Initialize(void)
+CMIDriverMgr::Initialize()
{
m_clientUsageRefCnt++;
@@ -91,7 +91,7 @@ CMIDriverMgr::Initialize(void)
// Throws: None.
//--
bool
-CMIDriverMgr::Shutdown(void)
+CMIDriverMgr::Shutdown()
{
// Do not want a ref counter because this function needs to be called how ever this
// application stops running
@@ -132,7 +132,7 @@ CMIDriverMgr::Shutdown(void)
// Throws: None.
//--
bool
-CMIDriverMgr::UnregisterDriverAll(void)
+CMIDriverMgr::UnregisterDriverAll()
{
MapDriverIdToDriver_t::const_iterator it = m_mapDriverIdToDriver.begin();
while (it != m_mapDriverIdToDriver.end())
@@ -273,7 +273,7 @@ CMIDriverMgr::SetUseThisDriverToDoWork(const IDriver &vrADriver)
// Throws: None.
//--
CMIDriverMgr::IDriver *
-CMIDriverMgr::GetUseThisDriverToDoWork(void) const
+CMIDriverMgr::GetUseThisDriverToDoWork() const
{
return m_pDriverCurrent;
}
@@ -287,7 +287,7 @@ CMIDriverMgr::GetUseThisDriverToDoWork(void) const
// Throws: None.
//--
bool
-CMIDriverMgr::DriverMainLoop(void)
+CMIDriverMgr::DriverMainLoop()
{
if (m_pDriverCurrent != nullptr)
{
@@ -300,7 +300,7 @@ CMIDriverMgr::DriverMainLoop(void)
}
else
{
- const CMIUtilString errMsg(CMIUtilString::Format(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET)));
+ const CMIUtilString errMsg(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET));
CMICmnStreamStdout::Instance().Write(errMsg, true);
return MIstatus::failure;
}
@@ -327,7 +327,7 @@ CMIDriverMgr::DriverParseArgs(const int argc, const char *argv[], FILE *vpStdOut
{
if (m_pDriverCurrent == nullptr)
{
- const CMIUtilString errMsg(CMIUtilString::Format(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET)));
+ const CMIUtilString errMsg(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET));
CMICmnStreamStdout::Instance().Write(errMsg, true);
return MIstatus::failure;
}
@@ -357,13 +357,13 @@ CMIDriverMgr::DriverParseArgs(const int argc, const char *argv[], FILE *vpStdOut
// Throws: None.
//--
CMIUtilString
-CMIDriverMgr::DriverGetError(void) const
+CMIDriverMgr::DriverGetError() const
{
if (m_pDriverCurrent != nullptr)
return m_pDriverCurrent->GetError();
else
{
- const CMIUtilString errMsg(CMIUtilString::Format(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET)));
+ const CMIUtilString errMsg(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET));
CMICmnStreamStdout::Instance().Write(errMsg, true);
}
@@ -379,13 +379,13 @@ CMIDriverMgr::DriverGetError(void) const
// Throws: None.
//--
CMIUtilString
-CMIDriverMgr::DriverGetName(void) const
+CMIDriverMgr::DriverGetName() const
{
if (m_pDriverCurrent != nullptr)
return m_pDriverCurrent->GetName();
else
{
- const CMIUtilString errMsg(CMIUtilString::Format(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET)));
+ const CMIUtilString errMsg(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET));
CMICmnStreamStdout::Instance().Write(errMsg, true);
}
@@ -401,14 +401,14 @@ CMIDriverMgr::DriverGetName(void) const
// Throws: None.
//--
lldb::SBDebugger *
-CMIDriverMgr::DriverGetTheDebugger(void)
+CMIDriverMgr::DriverGetTheDebugger()
{
lldb::SBDebugger *pDebugger = nullptr;
if (m_pDriverCurrent != nullptr)
pDebugger = &m_pDriverCurrent->GetTheDebugger();
else
{
- const CMIUtilString errMsg(CMIUtilString::Format(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET)));
+ const CMIUtilString errMsg(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET));
CMICmnStreamStdout::Instance().Write(errMsg, true);
}
@@ -598,7 +598,7 @@ CMIDriverMgr::ParseArgs(const int argc, const char *argv[], bool &vwbExiting)
// Throws: None.
//--
CMIUtilString
-CMIDriverMgr::GetAppVersion(void) const
+CMIDriverMgr::GetAppVersion() const
{
const CMIUtilString strProj(MIRSRC(IDS_PROJNAME));
const CMIUtilString strVsn(CMIDriver::Instance().GetVersionDescription());
@@ -616,7 +616,7 @@ CMIDriverMgr::GetAppVersion(void) const
// Throws: None.
//--
CMIUtilString
-CMIDriverMgr::GetHelpOnCmdLineArgOptions(void) const
+CMIDriverMgr::GetHelpOnCmdLineArgOptions() const
{
const CMIUtilString pHelp[] = {
MIRSRC(IDE_MI_APP_DESCRIPTION),
@@ -653,7 +653,7 @@ CMIDriverMgr::GetHelpOnCmdLineArgOptions(void) const
// Throws: None.
//--
CMIDriverMgr::IDriver *
-CMIDriverMgr::GetFirstMIDriver(void) const
+CMIDriverMgr::GetFirstMIDriver() const
{
IDriver *pDriver = nullptr;
MapDriverIdToDriver_t::const_iterator it = m_mapDriverIdToDriver.begin();
@@ -684,7 +684,7 @@ CMIDriverMgr::GetFirstMIDriver(void) const
// Throws: None.
//--
CMIDriverMgr::IDriver *
-CMIDriverMgr::GetFirstNonMIDriver(void) const
+CMIDriverMgr::GetFirstNonMIDriver() const
{
IDriver *pDriver = nullptr;
MapDriverIdToDriver_t::const_iterator it = m_mapDriverIdToDriver.begin();
diff --git a/tools/lldb-mi/MIDriverMgr.h b/tools/lldb-mi/MIDriverMgr.h
index c84ef04c75c4..016e722ed7ba 100644
--- a/tools/lldb-mi/MIDriverMgr.h
+++ b/tools/lldb-mi/MIDriverMgr.h
@@ -39,9 +39,6 @@
// Each driver instance (the CMIDriver, LLDB::Driver) has its own
// LLDB::SBDebugger.
// Singleton class.
-// Gotchas: None.
-// Authors: Illya Rudkin 28/02/2014.
-// Changes: None.
//--
class CMIDriverMgr : public CMICmnBase, public MI::ISingleton<CMIDriverMgr>
{
@@ -56,43 +53,43 @@ class CMIDriverMgr : public CMICmnBase, public MI::ISingleton<CMIDriverMgr>
class IDriver
{
public:
- virtual bool DoInitialize(void) = 0;
- virtual bool DoShutdown(void) = 0;
- virtual bool DoMainLoop(void) = 0;
+ virtual bool DoInitialize() = 0;
+ virtual bool DoShutdown() = 0;
+ virtual bool DoMainLoop() = 0;
virtual lldb::SBError DoParseArgs(const int argc, const char *argv[], FILE *vpStdOut, bool &vwbExiting) = 0;
- virtual CMIUtilString GetError(void) const = 0;
- virtual const CMIUtilString &GetName(void) const = 0;
- virtual lldb::SBDebugger &GetTheDebugger(void) = 0;
- virtual bool GetDriverIsGDBMICompatibleDriver(void) const = 0;
+ virtual CMIUtilString GetError() const = 0;
+ virtual const CMIUtilString &GetName() const = 0;
+ virtual lldb::SBDebugger &GetTheDebugger() = 0;
+ virtual bool GetDriverIsGDBMICompatibleDriver() const = 0;
virtual bool SetId(const CMIUtilString &vId) = 0;
- virtual const CMIUtilString &GetId(void) const = 0;
+ virtual const CMIUtilString &GetId() const = 0;
virtual void DeliverSignal(int signal) = 0;
// Not part of the interface, ignore
- /* dtor */ virtual ~IDriver(void) {}
+ /* dtor */ virtual ~IDriver() {}
};
// Methods:
public:
// MI system
- bool Initialize(void) override;
- bool Shutdown(void) override;
+ bool Initialize() override;
+ bool Shutdown() override;
//
- CMIUtilString GetAppVersion(void) const;
+ CMIUtilString GetAppVersion() const;
bool RegisterDriver(const IDriver &vrADriver, const CMIUtilString &vrDriverID);
bool UnregisterDriver(const IDriver &vrADriver);
bool
SetUseThisDriverToDoWork(const IDriver &vrADriver); // Specify working main driver
- IDriver *GetUseThisDriverToDoWork(void) const;
+ IDriver *GetUseThisDriverToDoWork() const;
bool ParseArgs(const int argc, const char *argv[], bool &vwbExiting);
IDriver *GetDriver(const CMIUtilString &vrDriverId) const;
//
// MI Proxy fn to current specified working driver
- bool DriverMainLoop(void);
+ bool DriverMainLoop();
bool DriverParseArgs(const int argc, const char *argv[], FILE *vpStdOut, bool &vwbExiting);
- CMIUtilString DriverGetError(void) const;
- CMIUtilString DriverGetName(void) const;
- lldb::SBDebugger *DriverGetTheDebugger(void);
+ CMIUtilString DriverGetError() const;
+ CMIUtilString DriverGetName() const;
+ lldb::SBDebugger *DriverGetTheDebugger();
void DeliverSignal(int signal);
// Typedef:
@@ -102,20 +99,20 @@ class CMIDriverMgr : public CMICmnBase, public MI::ISingleton<CMIDriverMgr>
// Methods:
private:
- /* ctor */ CMIDriverMgr(void);
+ /* ctor */ CMIDriverMgr();
/* ctor */ CMIDriverMgr(const CMIDriverMgr &);
void operator=(const CMIDriverMgr &);
//
bool HaveDriverAlready(const IDriver &vrMedium) const;
- bool UnregisterDriverAll(void);
- IDriver *GetFirstMIDriver(void) const;
- IDriver *GetFirstNonMIDriver(void) const;
- CMIUtilString GetHelpOnCmdLineArgOptions(void) const;
+ bool UnregisterDriverAll();
+ IDriver *GetFirstMIDriver() const;
+ IDriver *GetFirstNonMIDriver() const;
+ CMIUtilString GetHelpOnCmdLineArgOptions() const;
// Overridden:
private:
// From CMICmnBase
- /* dtor */ ~CMIDriverMgr(void) override;
+ /* dtor */ ~CMIDriverMgr() override;
// Attributes:
private:
diff --git a/tools/lldb-mi/MIExtensions.txt b/tools/lldb-mi/MIExtensions.txt
index 966cb2f074c9..70508b1d37bd 100644
--- a/tools/lldb-mi/MIExtensions.txt
+++ b/tools/lldb-mi/MIExtensions.txt
@@ -83,21 +83,22 @@ Example:
# =library-loaded notification
-The =library-loaded notification has 3 extra fields:
+The =library-loaded notification has 4 extra fields:
symbols-loaded - indicates that there are symbols for the loaded library
symbols-path - if symbols are exist then it contains a path for symbols of the loaded library
loaded_addr - contains an address of the loaded library or "-" if address isn't resolved yet
+ size - contains the size in bytes of the section loaded at 'loaded_addr'
For example:
- =library-loaded,id="/Users/IliaK/p/hello",target-name="/Users/IliaK/p/hello",host-name="/Users/IliaK/p/hello",symbols-loaded="1",symbols-path="/Users/IliaK/p/hello.dSYM/Contents/Resources/DWARF/hello",loaded_addr="-"
- =library-loaded,id="/usr/lib/dyld",target-name="/usr/lib/dyld",host-name="/usr/lib/dyld",symbols-loaded="0",loaded_addr="0x00007fff5fc00000"
+ =library-loaded,id="/Users/IliaK/p/hello",target-name="/Users/IliaK/p/hello",host-name="/Users/IliaK/p/hello",symbols-loaded="1",symbols-path="/Users/IliaK/p/hello.dSYM/Contents/Resources/DWARF/hello",loaded_addr="-",size="4096"
+ =library-loaded,id="/usr/lib/dyld",target-name="/usr/lib/dyld",host-name="/usr/lib/dyld",symbols-loaded="0",loaded_addr="0x00007fff5fc00000",size="4096"
# -target-attach
Synopsis
Additional syntax provided by lldb-mi:
- -target-attach -n <executable-name> [--waitfor]
+ -target-attach -n <executable-name> [--waitfor]
Attach to an executable. Using -n allows specifying an executable name to attach to.
Using this with --watifor can do a deffered attach. The flags -n and --waitfor match the syntax of lldb proper's 'process attach' command.
diff --git a/tools/lldb-mi/MIUtilDateTimeStd.cpp b/tools/lldb-mi/MIUtilDateTimeStd.cpp
index 995441fb4dec..db730daeefc2 100644
--- a/tools/lldb-mi/MIUtilDateTimeStd.cpp
+++ b/tools/lldb-mi/MIUtilDateTimeStd.cpp
@@ -18,7 +18,7 @@
// Return: None.
// Throws: None.
//--
-CMIUtilDateTimeStd::CMIUtilDateTimeStd(void)
+CMIUtilDateTimeStd::CMIUtilDateTimeStd()
{
}
@@ -29,7 +29,7 @@ CMIUtilDateTimeStd::CMIUtilDateTimeStd(void)
// Return: None.
// Throws: None.
//--
-CMIUtilDateTimeStd::~CMIUtilDateTimeStd(void)
+CMIUtilDateTimeStd::~CMIUtilDateTimeStd()
{
}
@@ -41,7 +41,7 @@ CMIUtilDateTimeStd::~CMIUtilDateTimeStd(void)
// Throws: None.
//--
CMIUtilString
-CMIUtilDateTimeStd::GetDate(void)
+CMIUtilDateTimeStd::GetDate()
{
CMIUtilString strDate(MIRSRC(IDS_WORD_INVALIDBRKTS));
@@ -61,7 +61,7 @@ CMIUtilDateTimeStd::GetDate(void)
// Throws: None.
//--
CMIUtilString
-CMIUtilDateTimeStd::GetTime(void)
+CMIUtilDateTimeStd::GetTime()
{
std::time(&m_rawTime);
const std::tm *pTi = std::localtime(&m_rawTime);
@@ -80,7 +80,7 @@ CMIUtilDateTimeStd::GetTime(void)
// Throws: None.
//--
CMIUtilString
-CMIUtilDateTimeStd::GetDateTimeLogFilename(void)
+CMIUtilDateTimeStd::GetDateTimeLogFilename()
{
std::time(&m_rawTime);
const std::tm *pTi = std::localtime(&m_rawTime);
diff --git a/tools/lldb-mi/MIUtilDateTimeStd.h b/tools/lldb-mi/MIUtilDateTimeStd.h
index 4bc5e5815959..cb5f4988700e 100644
--- a/tools/lldb-mi/MIUtilDateTimeStd.h
+++ b/tools/lldb-mi/MIUtilDateTimeStd.h
@@ -18,24 +18,21 @@
//++ ============================================================================
// Details: MI common code utility class. Used to retrieve system local date
// time.
-// Gotchas: None.
-// Authors: Illya Rudkin 16/07/2014.
-// Changes: None.
//--
class CMIUtilDateTimeStd
{
// Methods:
public:
- /* ctor */ CMIUtilDateTimeStd(void);
+ /* ctor */ CMIUtilDateTimeStd();
- CMIUtilString GetDate(void);
- CMIUtilString GetTime(void);
- CMIUtilString GetDateTimeLogFilename(void);
+ CMIUtilString GetDate();
+ CMIUtilString GetTime();
+ CMIUtilString GetDateTimeLogFilename();
// Overrideable:
public:
// From CMICmnBase
- /* dtor */ virtual ~CMIUtilDateTimeStd(void);
+ /* dtor */ virtual ~CMIUtilDateTimeStd();
// Attributes:
private:
diff --git a/tools/lldb-mi/MIUtilDebug.cpp b/tools/lldb-mi/MIUtilDebug.cpp
index f7d461bfcd28..d49aaa20a8f9 100644
--- a/tools/lldb-mi/MIUtilDebug.cpp
+++ b/tools/lldb-mi/MIUtilDebug.cpp
@@ -24,7 +24,7 @@
// Return: None.
// Throws: None.
//--
-CMIUtilDebug::CMIUtilDebug(void)
+CMIUtilDebug::CMIUtilDebug()
{
}
@@ -35,7 +35,7 @@ CMIUtilDebug::CMIUtilDebug(void)
// Return: None.
// Throws: None.
//--
-CMIUtilDebug::~CMIUtilDebug(void)
+CMIUtilDebug::~CMIUtilDebug()
{
}
@@ -48,7 +48,7 @@ CMIUtilDebug::~CMIUtilDebug(void)
// Throws: None.
//--
void
-CMIUtilDebug::ShowDlgWaitForDbgAttach(void)
+CMIUtilDebug::ShowDlgWaitForDbgAttach()
{
const CMIUtilString strCaption(CMIDriver::Instance().GetAppNameShort());
#ifdef _WIN32
@@ -71,7 +71,7 @@ CMIUtilDebug::ShowDlgWaitForDbgAttach(void)
// Throws: None.
//--
void
-CMIUtilDebug::WaitForDbgAttachInfinteLoop(void)
+CMIUtilDebug::WaitForDbgAttachInfinteLoop()
{
MIuint i = 0;
while (i == 0)
@@ -110,7 +110,7 @@ CMIUtilDebugFnTrace::CMIUtilDebugFnTrace(const CMIUtilString &vFnName)
// Return: None.
// Throws: None.
//--
-CMIUtilDebugFnTrace::~CMIUtilDebugFnTrace(void)
+CMIUtilDebugFnTrace::~CMIUtilDebugFnTrace()
{
const CMIUtilString txt(CMIUtilString::Format("%d<%s", ms_fnDepthCnt--, m_strFnName.c_str()));
ms_rLog.Write(txt, CMICmnLog::eLogVerbosity_FnTrace);
diff --git a/tools/lldb-mi/MIUtilDebug.h b/tools/lldb-mi/MIUtilDebug.h
index b309c5dc2871..c5383883f522 100644
--- a/tools/lldb-mi/MIUtilDebug.h
+++ b/tools/lldb-mi/MIUtilDebug.h
@@ -19,25 +19,22 @@ class CMICmnLog;
//++ ============================================================================
// Details: MI debugging aid utility class.
-// Gotchas: None.
-// Authors:
-// Changes: None.
//--
class CMIUtilDebug
{
// Statics:
public:
- static void ShowDlgWaitForDbgAttach(void);
- static void WaitForDbgAttachInfinteLoop(void);
+ static void ShowDlgWaitForDbgAttach();
+ static void WaitForDbgAttachInfinteLoop();
// Methods:
public:
- /* ctor */ CMIUtilDebug(void);
+ /* ctor */ CMIUtilDebug();
// Overrideable:
public:
// From CMICmnBase
- /* dtor */ virtual ~CMIUtilDebug(void);
+ /* dtor */ virtual ~CMIUtilDebug();
};
//++ ============================================================================
@@ -48,9 +45,6 @@ class CMIUtilDebug
// the functions you wish to build up a trace off.
// Use preprocessor definition MI_USE_DEBUG_TRACE_FN to turn off or on
// tracing code.
-// Gotchas: None.
-// Authors: Illya Rudkin 07/03/2014.
-// Changes: None.
//--
class CMIUtilDebugFnTrace
{
@@ -61,7 +55,7 @@ class CMIUtilDebugFnTrace
// Overrideable:
public:
// From CMICmnBase
- /* dtor */ virtual ~CMIUtilDebugFnTrace(void);
+ /* dtor */ virtual ~CMIUtilDebugFnTrace();
// Attributes:
private:
diff --git a/tools/lldb-mi/MIUtilFileStd.cpp b/tools/lldb-mi/MIUtilFileStd.cpp
index a0fce65880c6..9e5d10d6ba38 100644
--- a/tools/lldb-mi/MIUtilFileStd.cpp
+++ b/tools/lldb-mi/MIUtilFileStd.cpp
@@ -24,7 +24,7 @@
// Return: None.
// Throws: None.
//--
-CMIUtilFileStd::CMIUtilFileStd(void)
+CMIUtilFileStd::CMIUtilFileStd()
: m_fileNamePath(CMIUtilString())
, m_pFileHandle(nullptr)
#if defined(_MSC_VER)
@@ -43,7 +43,7 @@ CMIUtilFileStd::CMIUtilFileStd(void)
// Return: None.
// Throws: None.
//--
-CMIUtilFileStd::~CMIUtilFileStd(void)
+CMIUtilFileStd::~CMIUtilFileStd()
{
Close();
}
@@ -183,7 +183,7 @@ CMIUtilFileStd::Write(const char *vpData, const MIuint vCharCnt)
// Throws: None.
//--
void
-CMIUtilFileStd::Close(void)
+CMIUtilFileStd::Close()
{
if (m_pFileHandle == nullptr)
return;
@@ -202,7 +202,7 @@ CMIUtilFileStd::Close(void)
// Throws: None.
//--
bool
-CMIUtilFileStd::IsOk(void) const
+CMIUtilFileStd::IsOk() const
{
return !m_bFileError;
}
@@ -240,7 +240,7 @@ CMIUtilFileStd::IsFileExist(const CMIUtilString &vFileNamePath) const
// Throws: None.
//--
const CMIUtilString &
-CMIUtilFileStd::GetLineReturn(void) const
+CMIUtilFileStd::GetLineReturn() const
{
return m_constCharNewLine;
}
@@ -277,7 +277,7 @@ CMIUtilFileStd::StripOffFileName(const CMIUtilString &vDirectoryPath)
// Throws: None.
//--
char
-CMIUtilFileStd::GetSlash(void)
+CMIUtilFileStd::GetSlash()
{
#if !defined(_MSC_VER)
return '/';
diff --git a/tools/lldb-mi/MIUtilFileStd.h b/tools/lldb-mi/MIUtilFileStd.h
index 5a2234897768..458f64a75df8 100644
--- a/tools/lldb-mi/MIUtilFileStd.h
+++ b/tools/lldb-mi/MIUtilFileStd.h
@@ -15,33 +15,30 @@
//++ ============================================================================
// Details: MI common code utility class. File handling.
-// Gotchas: None.
-// Authors: Aidan Dodds 10/03/2014.
-// Changes: None.
//--
class CMIUtilFileStd : public CMICmnBase
{
// Static:
public:
- static char GetSlash(void);
+ static char GetSlash();
// Methods:
public:
- /* ctor */ CMIUtilFileStd(void);
+ /* ctor */ CMIUtilFileStd();
//
bool CreateWrite(const CMIUtilString &vFileNamePath, bool &vwrbNewCreated);
bool Write(const CMIUtilString &vData);
bool Write(const char *vpData, const MIuint vCharCnt);
- void Close(void);
- bool IsOk(void) const;
+ void Close();
+ bool IsOk() const;
bool IsFileExist(const CMIUtilString &vFileNamePath) const;
- const CMIUtilString &GetLineReturn(void) const;
+ const CMIUtilString &GetLineReturn() const;
static CMIUtilString StripOffFileName(const CMIUtilString &vDirectoryPath);
// Overridden:
public:
// From CMICmnBase
- /* dtor */ ~CMIUtilFileStd(void) override;
+ /* dtor */ ~CMIUtilFileStd() override;
// Attributes:
private:
diff --git a/tools/lldb-mi/MIUtilMapIdToVariant.cpp b/tools/lldb-mi/MIUtilMapIdToVariant.cpp
index debac2081b8b..b35d97a20d19 100644
--- a/tools/lldb-mi/MIUtilMapIdToVariant.cpp
+++ b/tools/lldb-mi/MIUtilMapIdToVariant.cpp
@@ -17,7 +17,7 @@
// Return: None.
// Throws: None.
//--
-CMIUtilMapIdToVariant::CMIUtilMapIdToVariant(void)
+CMIUtilMapIdToVariant::CMIUtilMapIdToVariant()
{
}
@@ -28,7 +28,7 @@ CMIUtilMapIdToVariant::CMIUtilMapIdToVariant(void)
// Return: None.
// Throws: None.
//--
-CMIUtilMapIdToVariant::~CMIUtilMapIdToVariant(void)
+CMIUtilMapIdToVariant::~CMIUtilMapIdToVariant()
{
}
@@ -40,7 +40,7 @@ CMIUtilMapIdToVariant::~CMIUtilMapIdToVariant(void)
// Throws: None.
//--
void
-CMIUtilMapIdToVariant::Clear(void)
+CMIUtilMapIdToVariant::Clear()
{
m_mapKeyToVariantValue.clear();
}
@@ -71,7 +71,7 @@ CMIUtilMapIdToVariant::HaveAlready(const CMIUtilString &vId) const
// Throws: None.
//--
bool
-CMIUtilMapIdToVariant::IsEmpty(void) const
+CMIUtilMapIdToVariant::IsEmpty() const
{
return m_mapKeyToVariantValue.empty();
}
diff --git a/tools/lldb-mi/MIUtilMapIdToVariant.h b/tools/lldb-mi/MIUtilMapIdToVariant.h
index c77f0b946683..1a164907dd06 100644
--- a/tools/lldb-mi/MIUtilMapIdToVariant.h
+++ b/tools/lldb-mi/MIUtilMapIdToVariant.h
@@ -22,27 +22,24 @@
// Details: MI common code utility class. Map type container that hold general
// object types (by being a variant wrapper)
// objects by ID.
-// Gotchas: None.
-// Authors: Illya Rudkin 19/06/2014.
-// Changes: None.
//--
class CMIUtilMapIdToVariant : public CMICmnBase
{
// Methods:
public:
- /* ctor */ CMIUtilMapIdToVariant(void);
+ /* ctor */ CMIUtilMapIdToVariant();
template <typename T> bool Add(const CMIUtilString &vId, const T &vData);
- void Clear(void);
+ void Clear();
template <typename T> bool Get(const CMIUtilString &vId, T &vrwData, bool &vrwbFound) const;
bool HaveAlready(const CMIUtilString &vId) const;
- bool IsEmpty(void) const;
+ bool IsEmpty() const;
bool Remove(const CMIUtilString &vId);
// Overridden:
public:
// From CMICmnBase
- /* dtor */ ~CMIUtilMapIdToVariant(void) override;
+ /* dtor */ ~CMIUtilMapIdToVariant() override;
// Typedefs:
private:
diff --git a/tools/lldb-mi/MIUtilParse.cpp b/tools/lldb-mi/MIUtilParse.cpp
new file mode 100644
index 000000000000..27e25b8b7431
--- /dev/null
+++ b/tools/lldb-mi/MIUtilParse.cpp
@@ -0,0 +1,75 @@
+//===-- MIUtilParse.cpp ----------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Third party headers:
+#include <memory>
+
+// In-house headers:
+#include "MIUtilParse.h"
+
+//++ ------------------------------------------------------------------------------------
+// Details: CRegexParser constructor.
+// Type: Method.
+// Args: regexStr - Pointer to the regular expression to compile.
+// Return: None.
+// Throws: None.
+//--
+MIUtilParse::CRegexParser::CRegexParser(const char *regexStr)
+ : m_isValid(llvm_regcomp(&m_emma, regexStr, REG_EXTENDED) == 0)
+{
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: CRegexParser destructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
+//--
+MIUtilParse::CRegexParser::~CRegexParser()
+{
+ // Free up memory held within regex.
+ if (m_isValid)
+ llvm_regfree(&m_emma);
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: CRegexParser regex executer.
+// Match the input against the regular expression. Return an error
+// if the number of matches is less than minMatches. If the default
+// minMatches value of 0 is passed, an error will be returned if
+// the number of matches is less than the maxMatches value used to
+// initialize Match.
+// Type: Method.
+// Args: input (R) - Pointer to UTF8 text data to be parsed.
+// match (RW) - Reference to Match class.
+// minMatches (R) - Minimum number of regex matches expected.
+// Return: bool - True = minimum matches were met,
+// false = minimum matches were not met or regex failed.
+// Throws: None.
+//--
+bool
+MIUtilParse::CRegexParser::Execute(const char *input, Match& match, size_t minMatches)
+{
+ if (!m_isValid)
+ return false;
+
+ std::unique_ptr<llvm_regmatch_t[]> matches(new llvm_regmatch_t[match.m_maxMatches]); // Array of matches
+
+ if (llvm_regexec(&m_emma, input, match.m_maxMatches, matches.get(), 0) != 0)
+ return false;
+
+ size_t i;
+ for (i = 0; i < match.m_maxMatches && matches[i].rm_so >= 0; i++)
+ {
+ const int n = matches[i].rm_eo - matches[i].rm_so;
+ match.m_matchStrs[i].assign(input + matches[i].rm_so, n);
+ }
+ return i >= minMatches;
+}
diff --git a/tools/lldb-mi/MIUtilParse.h b/tools/lldb-mi/MIUtilParse.h
new file mode 100644
index 000000000000..d3569586f819
--- /dev/null
+++ b/tools/lldb-mi/MIUtilParse.h
@@ -0,0 +1,93 @@
+//===-- MIUtilParse.h ------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#pragma once
+
+// Third party headers:
+#include "../lib/Support/regex_impl.h"
+
+// In-house headers:
+#include "MIUtilString.h"
+
+namespace MIUtilParse
+{
+
+//++ ============================================================================
+// Details: MI common code utility class. Used to parse the output
+// returned from lldb commands using regex.
+//--
+class CRegexParser
+{
+ public:
+ // Helper class for keeping track of regex matches.
+ class Match
+ {
+ friend CRegexParser;
+ public:
+ /* ctor */ explicit Match(size_t nmatches)
+ : m_matchStrs(nmatches), m_maxMatches(nmatches)
+ {
+ }
+ size_t
+ GetMatchCount() const
+ {
+ return m_matchStrs.size();
+ }
+ CMIUtilString
+ GetMatchAtIndex(size_t i) const
+ {
+ if (m_matchStrs.size() > i)
+ return m_matchStrs[i];
+ return CMIUtilString();
+ }
+ private:
+ CMIUtilString::VecString_t m_matchStrs;
+ const size_t m_maxMatches;
+ };
+
+ // Methods:
+ // Compile the regular expression.
+ /* ctor */ explicit CRegexParser(const char *regexStr);
+
+ // Free the memory used by the regular expression.
+ /* dtor */ ~CRegexParser();
+
+ // No copies
+ CRegexParser(const CRegexParser&) = delete;
+ void operator=(CRegexParser&) = delete;
+
+ // Return the match at the index.
+ int
+ GetMatchCount(const Match& match) const
+ {
+ if (m_isValid)
+ return match.GetMatchCount();
+ return 0;
+ }
+
+ bool
+ IsValid() const
+ {
+ return m_isValid;
+ }
+
+ // Match the input against the regular expression. Return an error
+ // if the number of matches is less than minMatches. If the default
+ // minMatches value of 0 is passed, an error will be returned if
+ // the number of matches is less than the maxMatches value used to
+ // initialize Match.
+ bool
+ Execute(const char *input, Match& match, size_t minMatches = 0);
+
+ private:
+ llvm_regex_t m_emma;
+ const bool m_isValid;
+};
+
+}
diff --git a/tools/lldb-mi/MIUtilSingletonBase.h b/tools/lldb-mi/MIUtilSingletonBase.h
index 3649a73b9fa5..03ce8c8aa443 100644
--- a/tools/lldb-mi/MIUtilSingletonBase.h
+++ b/tools/lldb-mi/MIUtilSingletonBase.h
@@ -22,15 +22,13 @@ namespace MI
// // Overridden:
// public:
// // From MI::ISingleton
-// bool Initialize(void) override;
-// bool Shutdown(void) override;
+// bool Initialize() override;
+// bool Shutdown() override;
// };
//++ ============================================================================
// Details: Base class for the singleton pattern.
// Gotchas: Derived class must specify MI::ISingleton<> as a friend class.
-// Authors: Aidan Dodds 17/03/2014.
-// Changes: None.
//--
template <typename T> class ISingleton
{
@@ -38,7 +36,7 @@ template <typename T> class ISingleton
public:
// Return an instance of the derived class
static T &
- Instance(void)
+ Instance()
{
// This will fail if the derived class has not
// declared itself to be a friend of MI::ISingleton
@@ -49,10 +47,10 @@ template <typename T> class ISingleton
// Overrideable:
public:
- virtual bool Initialize(void) = 0;
- virtual bool Shutdown(void) = 0;
+ virtual bool Initialize() = 0;
+ virtual bool Shutdown() = 0;
//
- /* dtor */ virtual ~ISingleton(void){};
+ /* dtor */ virtual ~ISingleton(){}
};
} // namespace MI
diff --git a/tools/lldb-mi/MIUtilSingletonHelper.h b/tools/lldb-mi/MIUtilSingletonHelper.h
index 19cc3a92e82f..2b9f4c416651 100644
--- a/tools/lldb-mi/MIUtilSingletonHelper.h
+++ b/tools/lldb-mi/MIUtilSingletonHelper.h
@@ -6,9 +6,6 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
-// Copyright: None.
-//--
#pragma once
@@ -29,8 +26,6 @@ namespace MI
// vwrErrMsg - (W) MI driver module initialise error description on failure.
// Return: MIstatus::success - Functional succeeded.
// MIstatus::failure - Functional failed.
-// Authors: Aidan Dodds 17/03/2014.
-// Changes: None.
//--
template <typename T>
bool
@@ -58,8 +53,6 @@ ModuleInit(const MIint vErrorResrcId, bool &vwrbOk, CMIUtilString &vwrErrMsg)
// failure.
// Return: True - Module shutdown succeeded.
// False - Module shutdown failed.
-// Authors: Aidan Dodds 17/03/2014.
-// Changes: None.
//--
template <typename T>
bool
diff --git a/tools/lldb-mi/MIUtilString.cpp b/tools/lldb-mi/MIUtilString.cpp
index fc7717749da8..176d9a6de74a 100644
--- a/tools/lldb-mi/MIUtilString.cpp
+++ b/tools/lldb-mi/MIUtilString.cpp
@@ -25,7 +25,7 @@
// Return: None.
// Throws: None.
//--
-CMIUtilString::CMIUtilString(void)
+CMIUtilString::CMIUtilString()
: std::string()
{
}
@@ -45,12 +45,12 @@ CMIUtilString::CMIUtilString(const char *vpData)
//++ ------------------------------------------------------------------------------------
// Details: CMIUtilString constructor.
// Type: Method.
-// Args: vpData - Pointer to UTF8 text data.
+// Args: vpStr - Text data.
// Return: None.
// Throws: None.
//--
-CMIUtilString::CMIUtilString(const char *const *vpData)
- : std::string((const char *)vpData)
+CMIUtilString::CMIUtilString(const std::string& vrStr)
+ : std::string(vrStr)
{
}
@@ -63,14 +63,7 @@ CMIUtilString::CMIUtilString(const char *const *vpData)
//--
CMIUtilString &CMIUtilString::operator=(const char *vpRhs)
{
- if (*this == vpRhs)
- return *this;
-
- if (vpRhs != nullptr)
- {
- assign(vpRhs);
- }
-
+ assign(vpRhs);
return *this;
}
@@ -83,11 +76,7 @@ CMIUtilString &CMIUtilString::operator=(const char *vpRhs)
//--
CMIUtilString &CMIUtilString::operator=(const std::string &vrRhs)
{
- if (*this == vrRhs)
- return *this;
-
assign(vrRhs);
-
return *this;
}
@@ -98,7 +87,7 @@ CMIUtilString &CMIUtilString::operator=(const std::string &vrRhs)
// Return: None.
// Throws: None.
//--
-CMIUtilString::~CMIUtilString(void)
+CMIUtilString::~CMIUtilString()
{
}
@@ -230,7 +219,7 @@ CMIUtilString::Split(const CMIUtilString &vDelimiter, VecString_t &vwVecSplits)
// Extract string between delimiters
const size_t nSectionLen(nNextDelimiterPos - nSectionPos);
const std::string strSection(substr(nSectionPos, nSectionLen));
- vwVecSplits.push_back(strSection.c_str());
+ vwVecSplits.push_back(strSection);
// Next
nOffset = nNextDelimiterPos + 1;
@@ -286,7 +275,7 @@ CMIUtilString::SplitConsiderQuotes(const CMIUtilString &vDelimiter, VecString_t
// Extract string between delimiters
const size_t nSectionLen(nNextDelimiterPos - nSectionPos);
const std::string strSection(substr(nSectionPos, nSectionLen));
- vwVecSplits.push_back(strSection.c_str());
+ vwVecSplits.push_back(strSection);
// Next
nOffset = nNextDelimiterPos + 1;
@@ -318,13 +307,13 @@ CMIUtilString::SplitLines(VecString_t &vwVecSplits) const
// Throws: None.
//--
CMIUtilString
-CMIUtilString::StripCREndOfLine(void) const
+CMIUtilString::StripCREndOfLine() const
{
const size_t nPos = rfind('\n');
if (nPos == std::string::npos)
return *this;
- const CMIUtilString strNew(substr(0, nPos).c_str());
+ const CMIUtilString strNew(substr(0, nPos));
return strNew;
}
@@ -338,7 +327,7 @@ CMIUtilString::StripCREndOfLine(void) const
// Throws: None.
//--
CMIUtilString
-CMIUtilString::StripCRAll(void) const
+CMIUtilString::StripCRAll() const
{
return FindAndReplace("\n", " ");
}
@@ -381,7 +370,7 @@ CMIUtilString::FindAndReplace(const CMIUtilString &vFind, const CMIUtilString &v
// Throws: None.
//--
bool
-CMIUtilString::IsNumber(void) const
+CMIUtilString::IsNumber() const
{
if (empty())
return false;
@@ -404,7 +393,7 @@ CMIUtilString::IsNumber(void) const
// Throws: None.
//--
bool
-CMIUtilString::IsHexadecimalNumber(void) const
+CMIUtilString::IsHexadecimalNumber() const
{
// Compare '0x..' prefix
if ((strncmp(c_str(), "0x", 2) != 0) && (strncmp(c_str(), "0X", 2) != 0))
@@ -522,19 +511,19 @@ CMIUtilString::Compare(const CMIUtilString &vrLhs, const CMIUtilString &vrRhs)
// Throws: None.
//--
CMIUtilString
-CMIUtilString::Trim(void) const
+CMIUtilString::Trim() const
{
CMIUtilString strNew(*this);
const char *pWhiteSpace = " \t\n\v\f\r";
const size_t nPos = find_last_not_of(pWhiteSpace);
if (nPos != std::string::npos)
{
- strNew = substr(0, nPos + 1).c_str();
+ strNew = substr(0, nPos + 1);
}
const size_t nPos2 = strNew.find_first_not_of(pWhiteSpace);
if (nPos2 != std::string::npos)
{
- strNew = strNew.substr(nPos2).c_str();
+ strNew = strNew.substr(nPos2);
}
return strNew;
@@ -555,7 +544,7 @@ CMIUtilString::Trim(const char vChar) const
if (nLen > 1)
{
if ((strNew[0] == vChar) && (strNew[nLen - 1] == vChar))
- strNew = strNew.substr(1, nLen - 2).c_str();
+ strNew = strNew.substr(1, nLen - 2);
}
return strNew;
@@ -652,7 +641,7 @@ CMIUtilString::RemoveRepeatedCharacters(size_t vnPos, const char vChar)
// Throws: None.
//--
bool
-CMIUtilString::IsQuoted(void) const
+CMIUtilString::IsQuoted() const
{
const char cQuote = '"';
@@ -819,7 +808,7 @@ CMIUtilString::Escape(bool vbEscapeQuotes /* = false */) const
// Throws: None.
//--
CMIUtilString
-CMIUtilString::AddSlashes(void) const
+CMIUtilString::AddSlashes() const
{
const char cBckSlash('\\');
const size_t nLen(length());
@@ -856,7 +845,7 @@ CMIUtilString::AddSlashes(void) const
// Throws: None.
//--
CMIUtilString
-CMIUtilString::StripSlashes(void) const
+CMIUtilString::StripSlashes() const
{
const char cBckSlash('\\');
const size_t nLen(length());
@@ -895,7 +884,7 @@ CMIUtilString::StripSlashes(void) const
}
CMIUtilString
-CMIUtilString::ConvertToPrintableASCII(const char vChar)
+CMIUtilString::ConvertToPrintableASCII(const char vChar, bool bEscapeQuotes)
{
switch (vChar)
{
@@ -917,6 +906,10 @@ CMIUtilString::ConvertToPrintableASCII(const char vChar)
return "\\e";
case '\\':
return "\\\\";
+ case '"':
+ if (bEscapeQuotes)
+ return "\\\"";
+ // fall thru
default:
if (::isprint(vChar))
return Format("%c", vChar);
@@ -926,24 +919,65 @@ CMIUtilString::ConvertToPrintableASCII(const char vChar)
}
CMIUtilString
-CMIUtilString::ConvertToPrintableASCII(const char16_t vChar16)
+CMIUtilString::ConvertCharValueToPrintableASCII(char vChar, bool bEscapeQuotes)
+{
+ switch (vChar)
+ {
+ case '\a':
+ return "\\a";
+ case '\b':
+ return "\\b";
+ case '\t':
+ return "\\t";
+ case '\n':
+ return "\\n";
+ case '\v':
+ return "\\v";
+ case '\f':
+ return "\\f";
+ case '\r':
+ return "\\r";
+ case '\033':
+ return "\\e";
+ case '\\':
+ return "\\\\";
+ case '"':
+ if (bEscapeQuotes)
+ return "\\\"";
+ // fall thru
+ default:
+ if (::isprint(vChar))
+ return Format("%c", vChar);
+ else
+ return CMIUtilString();
+ }
+}
+
+CMIUtilString
+CMIUtilString::ConvertToPrintableASCII(const char16_t vChar16, bool bEscapeQuotes)
{
- if (vChar16 == (char16_t)(char)vChar16 && ::isprint(vChar16))
+ if (vChar16 == (char16_t)(char)vChar16)
+ {
// Convert char16_t to char (if possible)
- return Format("%c", vChar16);
- else
- return Format("\\u%02" PRIx8 "%02" PRIx8,
+ CMIUtilString str = ConvertCharValueToPrintableASCII((char)vChar16, bEscapeQuotes);
+ if (str.length() > 0)
+ return str;
+ }
+ return Format("\\u%02" PRIx8 "%02" PRIx8,
(vChar16 >> 8) & 0xff, vChar16 & 0xff);
}
CMIUtilString
-CMIUtilString::ConvertToPrintableASCII(const char32_t vChar32)
+CMIUtilString::ConvertToPrintableASCII(const char32_t vChar32, bool bEscapeQuotes)
{
- if (vChar32 == (char32_t)(char)vChar32 && ::isprint(vChar32))
+ if (vChar32 == (char32_t)(char)vChar32)
+ {
// Convert char32_t to char (if possible)
- return Format("%c", vChar32);
- else
- return Format("\\U%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8,
+ CMIUtilString str = ConvertCharValueToPrintableASCII((char)vChar32, bEscapeQuotes);
+ if (str.length() > 0)
+ return str;
+ }
+ return Format("\\U%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8,
(vChar32 >> 24) & 0xff, (vChar32 >> 16) & 0xff,
(vChar32 >> 8) & 0xff, vChar32 & 0xff);
}
diff --git a/tools/lldb-mi/MIUtilString.h b/tools/lldb-mi/MIUtilString.h
index 7b188edefefa..23261605f3db 100644
--- a/tools/lldb-mi/MIUtilString.h
+++ b/tools/lldb-mi/MIUtilString.h
@@ -13,6 +13,7 @@
#include <string>
#include <vector>
#include <cinttypes>
+#include <cstdarg>
// In-house headers:
#include "MIDataTypes.h"
@@ -20,9 +21,6 @@
//++ ============================================================================
// Details: MI common code utility class. Used to help handle text.
// Derived from std::string
-// Gotchas: None.
-// Authors: Illya Rudkin 02/02/2014.
-// Changes: None.
//--
class CMIUtilString : public std::string
{
@@ -37,47 +35,48 @@ class CMIUtilString : public std::string
static CMIUtilString FormatValist(const CMIUtilString &vrFormating, va_list vArgs);
static bool IsAllValidAlphaAndNumeric(const char *vpText);
static bool Compare(const CMIUtilString &vrLhs, const CMIUtilString &vrRhs);
- static CMIUtilString ConvertToPrintableASCII(const char vChar);
- static CMIUtilString ConvertToPrintableASCII(const char16_t vChar16);
- static CMIUtilString ConvertToPrintableASCII(const char32_t vChar32);
+ static CMIUtilString ConvertToPrintableASCII(const char vChar, bool bEscapeQuotes = false);
+ static CMIUtilString ConvertToPrintableASCII(const char16_t vChar16, bool bEscapeQuotes = false);
+ static CMIUtilString ConvertToPrintableASCII(const char32_t vChar32, bool bEscapeQuotes = false);
// Methods:
public:
- /* ctor */ CMIUtilString(void);
+ /* ctor */ CMIUtilString();
/* ctor */ CMIUtilString(const char *vpData);
- /* ctor */ CMIUtilString(const char *const *vpData);
+ /* ctor */ CMIUtilString(const std::string& vrStr);
//
bool ExtractNumber(MIint64 &vwrNumber) const;
CMIUtilString FindAndReplace(const CMIUtilString &vFind, const CMIUtilString &vReplaceWith) const;
- bool IsNumber(void) const;
- bool IsHexadecimalNumber(void) const;
- bool IsQuoted(void) const;
+ bool IsNumber() const;
+ bool IsHexadecimalNumber() const;
+ bool IsQuoted() const;
CMIUtilString RemoveRepeatedCharacters(const char vChar);
size_t Split(const CMIUtilString &vDelimiter, VecString_t &vwVecSplits) const;
size_t SplitConsiderQuotes(const CMIUtilString &vDelimiter, VecString_t &vwVecSplits) const;
size_t SplitLines(VecString_t &vwVecSplits) const;
- CMIUtilString StripCREndOfLine(void) const;
- CMIUtilString StripCRAll(void) const;
- CMIUtilString Trim(void) const;
+ CMIUtilString StripCREndOfLine() const;
+ CMIUtilString StripCRAll() const;
+ CMIUtilString Trim() const;
CMIUtilString Trim(const char vChar) const;
size_t FindFirst(const CMIUtilString &vrPattern, size_t vnPos = 0) const;
size_t FindFirst(const CMIUtilString &vrPattern, bool vbSkipQuotedText, bool &vrwbNotFoundClosedQuote,
size_t vnPos = 0) const;
size_t FindFirstNot(const CMIUtilString &vrPattern, size_t vnPos = 0) const;
CMIUtilString Escape(bool vbEscapeQuotes = false) const;
- CMIUtilString AddSlashes(void) const;
- CMIUtilString StripSlashes(void) const;
+ CMIUtilString AddSlashes() const;
+ CMIUtilString StripSlashes() const;
//
CMIUtilString &operator=(const char *vpRhs);
CMIUtilString &operator=(const std::string &vrRhs);
// Overrideable:
public:
- /* dtor */ virtual ~CMIUtilString(void);
+ /* dtor */ virtual ~CMIUtilString();
// Static method:
private:
static CMIUtilString FormatPriv(const CMIUtilString &vrFormat, va_list vArgs);
+ static CMIUtilString ConvertCharValueToPrintableASCII(char vChar, bool bEscapeQuotes);
// Methods:
private:
diff --git a/tools/lldb-mi/MIUtilSystemLinux.cpp b/tools/lldb-mi/MIUtilSystemLinux.cpp
deleted file mode 100644
index 8fd2470c992b..000000000000
--- a/tools/lldb-mi/MIUtilSystemLinux.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-//===-- MIUtilSystemLinux.cpp -----------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__linux__)
-
-// In-house headers:
-#include "MIUtilSystemLinux.h"
-#include "MICmnResources.h"
-
-//++ ------------------------------------------------------------------------------------
-// Details: CMIUtilSystemLinux constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
-//--
-CMIUtilSystemLinux::CMIUtilSystemLinux(void)
-{
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: CMIUtilSystemLinux destructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
-//--
-CMIUtilSystemLinux::~CMIUtilSystemLinux(void)
-{
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the OS system error message for the given system error code.
-// Type: Method.
-// Args: vError - (R) OS error code value.
-// vrwErrorMsg - (W) The error message.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
-//--
-bool
-CMIUtilSystemLinux::GetOSErrorMsg(const MIint vError, CMIUtilString &vrwErrorMsg) const
-{
- // Reset
- vrwErrorMsg.clear();
-
- bool bOk = MIstatus::failure;
-
- // ToDo: Implement LINUX version
-
- return bOk;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve if possible the OS last error description.
-// Type: Method.
-// Args: None.
-// Return: CMIUtilString - Error description.
-// Throws: None.
-//--
-CMIUtilString
-CMIUtilSystemLinux::GetOSLastError(void) const
-{
- CMIUtilString errorMsg("Error fn not implemented ");
-
- // ToDo: Implement LINUX version
-
- return errorMsg;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieves the fully qualified path for the this application. If the function
-// fails the string is filled with the error message.
-// Type: Method.
-// Args: vrwFileNamePath - (W) The executable's name and path or last error description.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
-//--
-bool
-CMIUtilSystemLinux::GetExecutablesPath(CMIUtilString &vrwFileNamePath) const
-{
- vrwFileNamePath = CMIUtilString(".");
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieves the fully qualified path for the Log file for this application.
-// If the function fails the string is filled with the error message.
-// Append a dummy file name on the end of the path. This will be stripped off
-// later and the real log file name replaces it.
-// Type: Method.
-// Args: vrwFileNamePath - (W) The Log file's name and path or last error description.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
-//--
-bool
-CMIUtilSystemLinux::GetLogFilesPath(CMIUtilString &vrwFileNamePath) const
-{
- vrwFileNamePath = CMIUtilString(".");
- return MIstatus::success;
-}
-
-#endif // #if defined( __linux__ )
diff --git a/tools/lldb-mi/MIUtilSystemLinux.h b/tools/lldb-mi/MIUtilSystemLinux.h
deleted file mode 100644
index 975714bd6f47..000000000000
--- a/tools/lldb-mi/MIUtilSystemLinux.h
+++ /dev/null
@@ -1,45 +0,0 @@
-//===-- CMIUtilSystemLinux.h ------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#pragma once
-
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__linux__)
-
-// In-house headers:
-#include "MIUtilString.h"
-
-//++ ============================================================================
-// Details: MI common code utility class. Used to set or retrieve information
-// about the current system or user.
-// *** If you change, remove or add functionality it must be replicated
-// *** for the all platforms supported; Windows, OSX, LINUX
-// Gotchas: None.
-// Authors: Illya Rudkin 29/01/2014.
-// Changes: None.
-//--
-class CMIUtilSystemLinux
-{
- // Methods:
- public:
- /* ctor */ CMIUtilSystemLinux(void);
-
- bool GetOSErrorMsg(const MIint vError, CMIUtilString &vrwErrorMsg) const;
- CMIUtilString GetOSLastError(void) const;
- bool GetExecutablesPath(CMIUtilString &vrwFileNamePath) const;
- bool GetLogFilesPath(CMIUtilString &vrwFileNamePath) const;
-
- // Overrideable:
- public:
- // From CMICmnBase
- /* dtor */ virtual ~CMIUtilSystemLinux(void);
-};
-
-typedef CMIUtilSystemLinux CMIUtilSystem;
-
-#endif // #if defined( __linux__ )
diff --git a/tools/lldb-mi/MIUtilSystemOsx.cpp b/tools/lldb-mi/MIUtilSystemOsx.cpp
deleted file mode 100644
index b926342973a6..000000000000
--- a/tools/lldb-mi/MIUtilSystemOsx.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-//===-- MIUtilSystemOsx.cpp -------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#if defined(__APPLE__)
-
-// In-house headers:
-#include "MIUtilSystemOsx.h"
-#include "MICmnResources.h"
-
-//++ ------------------------------------------------------------------------------------
-// Details: CMIUtilSystemOsx constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
-//--
-CMIUtilSystemOsx::CMIUtilSystemOsx(void)
-{
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: CMIUtilSystemOsx destructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
-//--
-CMIUtilSystemOsx::~CMIUtilSystemOsx(void)
-{
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the OS system error message for the given system error code.
-// Type: Method.
-// Args: vError - (R) OS error code value.
-// vrwErrorMsg - (W) The error message.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
-//--
-bool
-CMIUtilSystemOsx::GetOSErrorMsg(const MIint vError, CMIUtilString &vrwErrorMsg) const
-{
- // Reset
- vrwErrorMsg.clear();
-
- bool bOk = MIstatus::failure;
-
- // ToDo: Implement LINUX version
-
- return bOk;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve if possible the OS last error description.
-// Type: Method.
-// Args: None.
-// Return: CMIUtilString - Error description.
-// Throws: None.
-//--
-CMIUtilString
-CMIUtilSystemOsx::GetOSLastError(void) const
-{
- CMIUtilString errorMsg("Error fn not implemented");
-
- // ToDo: Implement LINUX version
-
- return errorMsg;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieves the fully qualified path for the this application. If the function
-// fails the string is filled with the error message.
-// Type: Method.
-// Args: vrwFileNamePath - (W) The executable's name and path or last error description.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
-//--
-bool
-CMIUtilSystemOsx::GetExecutablesPath(CMIUtilString &vrwFileNamePath) const
-{
- vrwFileNamePath = CMIUtilString(".");
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieves the fully qualified path for the Log file for this application.
-// If the function fails the string is filled with the error message.
-// Append a dummy file name on the end of the path. This will be stripped off
-// later and the real log file name replaces it.
-// Type: Method.
-// Args: vrwFileNamePath - (W) The Log file's name and path or last error description.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
-//--
-bool
-CMIUtilSystemOsx::GetLogFilesPath(CMIUtilString &vrwFileNamePath) const
-{
- vrwFileNamePath = CMIUtilString(".");
- return MIstatus::success;
-}
-
-#endif // #if defined( __APPLE__ )
diff --git a/tools/lldb-mi/MIUtilSystemOsx.h b/tools/lldb-mi/MIUtilSystemOsx.h
deleted file mode 100644
index b30e258626bd..000000000000
--- a/tools/lldb-mi/MIUtilSystemOsx.h
+++ /dev/null
@@ -1,45 +0,0 @@
-//===-- MICmnConfig.h -------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#pragma once
-
-#if defined(__APPLE__)
-
-// In-house headers:
-#include "MIUtilString.h"
-
-//++ ============================================================================
-// Details: MI common code utility class. Used to set or retrieve information
-// about the current system or user.
-// *** If you change, remove or add functionality it must be replicated
-// *** for the all platforms supported; Windows, OSX, LINUX
-// Gotchas: None.
-// Authors: Illya Rudkin 29/01/2014.
-// Changes: None.
-//--
-class CMIUtilSystemOsx
-{
- // Methods:
- public:
- /* ctor */ CMIUtilSystemOsx(void);
-
- bool GetOSErrorMsg(const MIint vError, CMIUtilString &vrwErrorMsg) const;
- CMIUtilString GetOSLastError(void) const;
- bool GetExecutablesPath(CMIUtilString &vrwFileNamePath) const;
- bool GetLogFilesPath(CMIUtilString &vrwFileNamePath) const;
-
- // Overrideable:
- public:
- // From CMICmnBase
- /* dtor */ virtual ~CMIUtilSystemOsx(void);
-};
-
-typedef CMIUtilSystemOsx CMIUtilSystem;
-
-#endif // #if defined( __APPLE__ )
diff --git a/tools/lldb-mi/MIUtilSystemWindows.cpp b/tools/lldb-mi/MIUtilSystemWindows.cpp
deleted file mode 100644
index 80f4aac7b63a..000000000000
--- a/tools/lldb-mi/MIUtilSystemWindows.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-//===-- MIUtilSystemWindows.cpp ---------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#if defined(_MSC_VER)
-
-// Third party headers
-#include <memory> // std::unique_ptr
-#include <Windows.h>
-#include <WinBase.h> // ::FormatMessage()
-
-// In-house headers:
-#include "MIUtilSystemWindows.h"
-#include "MICmnResources.h"
-#include "MIUtilFileStd.h"
-
-//++ ------------------------------------------------------------------------------------
-// Details: CMIUtilSystemWindows constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
-//--
-CMIUtilSystemWindows::CMIUtilSystemWindows(void)
-{
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: CMIUtilSystemWindows destructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
-//--
-CMIUtilSystemWindows::~CMIUtilSystemWindows(void)
-{
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the OS system error message for the given system error code.
-// Type: Method.
-// Args: vError - (R) OS error code value.
-// vrwErrorMsg - (W) The error message.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
-//--
-bool
-CMIUtilSystemWindows::GetOSErrorMsg(const MIint vError, CMIUtilString &vrwErrorMsg) const
-{
- // Reset
- vrwErrorMsg.clear();
-
- const MIuint nBufLen = 1024;
- std::unique_ptr<char[]> pBuffer;
- pBuffer.reset(new char[nBufLen]);
-
- // CMIUtilString Format is not used as cannot replicate the behavior of ::FormatMessage which
- // can take into account locality while retrieving the error message from the system.
- const int nLength = ::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, (DWORD)vError,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPTSTR>(&pBuffer[0]), nBufLen, nullptr);
- bool bOk = MIstatus::success;
- if (nLength != 0)
- vrwErrorMsg = &pBuffer[0];
- else
- bOk = MIstatus::failure;
-
- return bOk;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve if possible the OS last error description.
-// Type: Method.
-// Args: None.
-// Return: CMIUtilString - Error description.
-// Throws: None.
-//--
-CMIUtilString
-CMIUtilSystemWindows::GetOSLastError(void) const
-{
- CMIUtilString errorMsg;
- const DWORD dwLastError = ::GetLastError();
- if (dwLastError != 0)
- {
- if (!GetOSErrorMsg(dwLastError, errorMsg))
- errorMsg = MIRSRC(IDE_OS_ERR_RETRIEVING);
- }
- else
- errorMsg = MIRSRC(IDE_OS_ERR_UNKNOWN);
-
- return errorMsg;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieves the fully qualified path for the this application. If the function
-// fails the string is filled with the error message.
-// Type: Method.
-// Args: vrwFileNamePath - (W) The executable's name and path or last error description.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
-//--
-bool
-CMIUtilSystemWindows::GetExecutablesPath(CMIUtilString &vrwFileNamePath) const
-{
- bool bOk = MIstatus::success;
- HMODULE hModule = ::GetModuleHandle(nullptr);
- char pPath[MAX_PATH];
- if (!::GetModuleFileName(hModule, &pPath[0], MAX_PATH))
- {
- bOk = MIstatus::failure;
- vrwFileNamePath = GetOSLastError();
- }
- else
- vrwFileNamePath = &pPath[0];
-
- return bOk;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieves the fully qualified path for the Log file for this application.
-// If the function fails the string is filled with the error message.
-// Type: Method.
-// Args: vrwFileNamePath - (W) The Log file's name and path or last error description.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
-//--
-bool
-CMIUtilSystemWindows::GetLogFilesPath(CMIUtilString &vrwFileNamePath) const
-{
- vrwFileNamePath = CMIUtilString(".");
- return MIstatus::success;
-}
-
-#endif // #if defined( _MSC_VER )
diff --git a/tools/lldb-mi/MIUtilSystemWindows.h b/tools/lldb-mi/MIUtilSystemWindows.h
deleted file mode 100644
index 696c2b286dfc..000000000000
--- a/tools/lldb-mi/MIUtilSystemWindows.h
+++ /dev/null
@@ -1,44 +0,0 @@
-//===-- MIUtilSystemWindows.h -----------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-#pragma once
-
-#if defined(_MSC_VER)
-
-// In-house headers:
-#include "MIUtilString.h"
-
-//++ ============================================================================
-// Details: MI common code utility class. Used to set or retrieve information
-// about the current system or user.
-// *** If you change, remove or add functionality it must be replicated
-// *** for the all platforms supported; Windows, OSX, LINUX
-// Gotchas: None.
-// Authors: Illya Rudkin 29/01/2014.
-// Changes: None.
-//--
-class CMIUtilSystemWindows
-{
- // Methods:
- public:
- /* ctor */ CMIUtilSystemWindows(void);
-
- bool GetOSErrorMsg(const MIint vError, CMIUtilString &vrwErrorMsg) const;
- CMIUtilString GetOSLastError(void) const;
- bool GetExecutablesPath(CMIUtilString &vrwFileNamePath) const;
- bool GetLogFilesPath(CMIUtilString &vrwFileNamePath) const;
-
- // Overrideable:
- public:
- // From CMICmnBase
- /* dtor */ virtual ~CMIUtilSystemWindows(void);
-};
-
-typedef CMIUtilSystemWindows CMIUtilSystem;
-
-#endif // #if defined( _MSC_VER )
diff --git a/tools/lldb-mi/MIUtilThreadBaseStd.cpp b/tools/lldb-mi/MIUtilThreadBaseStd.cpp
index 96f53ff65bf5..fac0aa61729c 100644
--- a/tools/lldb-mi/MIUtilThreadBaseStd.cpp
+++ b/tools/lldb-mi/MIUtilThreadBaseStd.cpp
@@ -6,8 +6,6 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-// Copyright: None.
-//--
// Third Party Headers:
#include <assert.h>
@@ -23,7 +21,7 @@
// Return: None.
// Throws: None.
//--
-CMIUtilThreadActiveObjBase::CMIUtilThreadActiveObjBase(void)
+CMIUtilThreadActiveObjBase::CMIUtilThreadActiveObjBase()
: m_references(0)
, m_bHasBeenKilled(false)
{
@@ -36,7 +34,7 @@ CMIUtilThreadActiveObjBase::CMIUtilThreadActiveObjBase(void)
// Return: None.
// Throws: None.
//--
-CMIUtilThreadActiveObjBase::~CMIUtilThreadActiveObjBase(void)
+CMIUtilThreadActiveObjBase::~CMIUtilThreadActiveObjBase()
{
// Make sure our thread is not alive before we die
m_thread.Join();
@@ -51,7 +49,7 @@ CMIUtilThreadActiveObjBase::~CMIUtilThreadActiveObjBase(void)
// Throws: None.
//--
bool
-CMIUtilThreadActiveObjBase::ThreadIsActive(void)
+CMIUtilThreadActiveObjBase::ThreadIsActive()
{
// Create a new thread to occupy this threads Run() function
return m_thread.IsActive();
@@ -66,7 +64,7 @@ CMIUtilThreadActiveObjBase::ThreadIsActive(void)
// Throws: None.
//--
bool
-CMIUtilThreadActiveObjBase::ThreadExecute(void)
+CMIUtilThreadActiveObjBase::ThreadExecute()
{
// Create a new thread to occupy this threads Run() function
return m_thread.Start(ThreadEntry, this);
@@ -81,7 +79,7 @@ CMIUtilThreadActiveObjBase::ThreadExecute(void)
// Throws: None.
//--
bool
-CMIUtilThreadActiveObjBase::Acquire(void)
+CMIUtilThreadActiveObjBase::Acquire()
{
// Access to this function is serial
CMIUtilThreadLock serial(m_mutex);
@@ -101,7 +99,7 @@ CMIUtilThreadActiveObjBase::Acquire(void)
// Throws: None.
//--
bool
-CMIUtilThreadActiveObjBase::Release(void)
+CMIUtilThreadActiveObjBase::Release()
{
// Access to this function is serial
CMIUtilThreadLock serial(m_mutex);
@@ -121,7 +119,7 @@ CMIUtilThreadActiveObjBase::Release(void)
// Throws: None.
//--
bool
-CMIUtilThreadActiveObjBase::ThreadKill(void)
+CMIUtilThreadActiveObjBase::ThreadKill()
{
// Access to this function is serial
CMIUtilThreadLock serial(m_mutex);
@@ -141,7 +139,7 @@ CMIUtilThreadActiveObjBase::ThreadKill(void)
// Throws: None.
//--
bool
-CMIUtilThreadActiveObjBase::ThreadJoin(void)
+CMIUtilThreadActiveObjBase::ThreadJoin()
{
return m_thread.Join();
}
@@ -177,7 +175,7 @@ CMIUtilThreadActiveObjBase::ThreadEntry(void *vpThisClass)
// Throws: None.
//--
void
-CMIUtilThreadActiveObjBase::ThreadManage(void)
+CMIUtilThreadActiveObjBase::ThreadManage()
{
bool bAlive = true;
@@ -214,7 +212,7 @@ CMIUtilThreadActiveObjBase::ThreadManage(void)
//---------------------------------------------------------------------------------------
//
-CMIUtilThread::CMIUtilThread(void)
+CMIUtilThread::CMIUtilThread()
: m_pThread(nullptr)
, m_bIsActive(false)
{
@@ -227,7 +225,7 @@ CMIUtilThread::CMIUtilThread(void)
// Return: None.
// Throws: None.
//--
-CMIUtilThread::~CMIUtilThread(void)
+CMIUtilThread::~CMIUtilThread()
{
Join();
}
@@ -241,7 +239,7 @@ CMIUtilThread::~CMIUtilThread(void)
// Throws: None.
//--
bool
-CMIUtilThread::Join(void)
+CMIUtilThread::Join()
{
if (m_pThread != nullptr)
{
@@ -267,7 +265,7 @@ CMIUtilThread::Join(void)
// Throws: None.
//--
bool
-CMIUtilThread::IsActive(void)
+CMIUtilThread::IsActive()
{
// Lock while we access the thread status
CMIUtilThreadLock _lock(m_mutex);
@@ -282,7 +280,7 @@ CMIUtilThread::IsActive(void)
// Throws: None.
//--
void
-CMIUtilThread::Finish(void)
+CMIUtilThread::Finish()
{
// Lock while we access the thread status
CMIUtilThreadLock _lock(m_mutex);
@@ -326,7 +324,7 @@ CMIUtilThread::Start(FnThreadProc vpFn, void *vpArg)
// Throws: None.
//--
void
-CMIUtilThreadMutex::Lock(void)
+CMIUtilThreadMutex::Lock()
{
m_mutex.lock();
}
@@ -339,7 +337,7 @@ CMIUtilThreadMutex::Lock(void)
// Throws: None.
//--
void
-CMIUtilThreadMutex::Unlock(void)
+CMIUtilThreadMutex::Unlock()
{
m_mutex.unlock();
}
@@ -353,7 +351,7 @@ CMIUtilThreadMutex::Unlock(void)
// Throws: None.
//--
bool
-CMIUtilThreadMutex::TryLock(void)
+CMIUtilThreadMutex::TryLock()
{
return m_mutex.try_lock();
}
diff --git a/tools/lldb-mi/MIUtilThreadBaseStd.h b/tools/lldb-mi/MIUtilThreadBaseStd.h
index 504d8303de1d..738f295b657a 100644
--- a/tools/lldb-mi/MIUtilThreadBaseStd.h
+++ b/tools/lldb-mi/MIUtilThreadBaseStd.h
@@ -6,9 +6,6 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
-// Copyright: None.
-//--
#pragma once
@@ -26,27 +23,24 @@
//++ ============================================================================
// Details: MI common code utility class. Handle thread mutual exclusion.
// Embed Mutexes in your Active Object and then use them through Locks.
-// Gotchas: None.
-// Authors: Aidan Dodds 10/03/2014.
-// Changes: None.
//--
class CMIUtilThreadMutex
{
// Methods:
public:
- /* ctor */ CMIUtilThreadMutex(void){};
+ /* ctor */ CMIUtilThreadMutex(){}
//
void
- Lock(void); // Wait until mutex can be obtained
+ Lock(); // Wait until mutex can be obtained
void
- Unlock(void); // Release the mutex
+ Unlock(); // Release the mutex
bool
- TryLock(void); // Gain the lock if available
+ TryLock(); // Gain the lock if available
// Overrideable:
public:
// From CMICmnBase
- /* dtor */ virtual ~CMIUtilThreadMutex(void){};
+ /* dtor */ virtual ~CMIUtilThreadMutex(){}
// Attributes:
private:
@@ -55,9 +49,6 @@ class CMIUtilThreadMutex
//++ ============================================================================
// Details: MI common code utility class. Thread object.
-// Gotchas: None.
-// Authors: Aidan Dodds 10/03/2014.
-// Changes: None.
//--
class CMIUtilThread
{
@@ -67,20 +58,20 @@ class CMIUtilThread
// Methods:
public:
- /* ctor */ CMIUtilThread(void);
+ /* ctor */ CMIUtilThread();
//
bool
Start(FnThreadProc vpFn, void *vpArg); // Start execution of this thread
bool
- Join(void); // Wait for this thread to stop
+ Join(); // Wait for this thread to stop
bool
- IsActive(void); // Returns true if this thread is running
+ IsActive(); // Returns true if this thread is running
void
- Finish(void); // Finish this thread
+ Finish(); // Finish this thread
// Overrideable:
public:
- /* dtor */ virtual ~CMIUtilThread(void);
+ /* dtor */ virtual ~CMIUtilThread();
// Methods:
private:
@@ -92,36 +83,33 @@ class CMIUtilThread
//++ ============================================================================
// Details: MI common code utility class. Base class for a worker thread active
// object. Runs an 'captive thread'.
-// Gotchas: None.
-// Authors: Aidan Dodds 10/03/2014..
-// Changes: None.
//--
class CMIUtilThreadActiveObjBase
{
// Methods:
public:
- /* ctor */ CMIUtilThreadActiveObjBase(void);
+ /* ctor */ CMIUtilThreadActiveObjBase();
//
bool
- Acquire(void); // Obtain a reference to this object
+ Acquire(); // Obtain a reference to this object
bool
- Release(void); // Release a reference to this object
+ Release(); // Release a reference to this object
bool
- ThreadIsActive(void); // Return true if this object is running
+ ThreadIsActive(); // Return true if this object is running
bool
- ThreadJoin(void); // Wait for this thread to stop running
+ ThreadJoin(); // Wait for this thread to stop running
bool
- ThreadKill(void); // Force this thread to stop, regardless of references
+ ThreadKill(); // Force this thread to stop, regardless of references
bool
- ThreadExecute(void); // Start this objects execution in another thread
- void ThreadManage(void);
+ ThreadExecute(); // Start this objects execution in another thread
+ void ThreadManage();
// Overrideable:
public:
- /* dtor */ virtual ~CMIUtilThreadActiveObjBase(void);
+ /* dtor */ virtual ~CMIUtilThreadActiveObjBase();
//
// Each thread object must supple a unique name that can be used to locate it
- virtual const CMIUtilString &ThreadGetName(void) const = 0;
+ virtual const CMIUtilString &ThreadGetName() const = 0;
// Statics:
protected:
@@ -133,7 +121,7 @@ class CMIUtilThreadActiveObjBase
virtual bool
ThreadRun(bool &vrIsAlive) = 0; // Call the main worker method
virtual bool
- ThreadFinish(void) = 0; // Finish of what you were doing
+ ThreadFinish() = 0; // Finish of what you were doing
// Attributes:
protected:
@@ -148,9 +136,6 @@ class CMIUtilThreadActiveObjBase
// Details: MI common code utility class. Handle thread resource locking.
// Put Locks inside all the methods of your Active Object that access
// data shared with the captive thread.
-// Gotchas: None.
-// Authors: Aidan Dodds 10/03/2014.
-// Changes: None.
//--
class CMIUtilThreadLock
{
@@ -166,7 +151,7 @@ class CMIUtilThreadLock
// Overrideable:
public:
/* dtor */
- virtual ~CMIUtilThreadLock(void) { m_rMutex.Unlock(); }
+ virtual ~CMIUtilThreadLock() { m_rMutex.Unlock(); }
// Attributes:
private:
diff --git a/tools/lldb-mi/MIUtilVariant.cpp b/tools/lldb-mi/MIUtilVariant.cpp
index dff8072aa105..c5e864332420 100644
--- a/tools/lldb-mi/MIUtilVariant.cpp
+++ b/tools/lldb-mi/MIUtilVariant.cpp
@@ -6,8 +6,6 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-// Copyright: None.
-//--
// In-house headers:
#include "MIUtilVariant.h"
@@ -19,7 +17,7 @@
// Return: None.
// Throws: None.
//--
-CMIUtilVariant::CDataObjectBase::CDataObjectBase(void)
+CMIUtilVariant::CDataObjectBase::CDataObjectBase()
{
}
@@ -66,7 +64,7 @@ CMIUtilVariant::CDataObjectBase::CDataObjectBase(CDataObjectBase &&vrwOther)
// Return: None.
// Throws: None.
//--
-CMIUtilVariant::CDataObjectBase::~CDataObjectBase(void)
+CMIUtilVariant::CDataObjectBase::~CDataObjectBase()
{
Destroy();
}
@@ -106,7 +104,7 @@ CMIUtilVariant::CDataObjectBase &CMIUtilVariant::CDataObjectBase::operator=(CDat
// Throws: None.
//--
CMIUtilVariant::CDataObjectBase *
-CMIUtilVariant::CDataObjectBase::CreateCopyOfSelf(void)
+CMIUtilVariant::CDataObjectBase::CreateCopyOfSelf()
{
// Override to implement copying of variant's data object
return new CDataObjectBase();
@@ -120,7 +118,7 @@ CMIUtilVariant::CDataObjectBase::CreateCopyOfSelf(void)
// Throws: None.
//--
bool
-CMIUtilVariant::CDataObjectBase::GetIsDerivedClass(void) const
+CMIUtilVariant::CDataObjectBase::GetIsDerivedClass() const
{
// Override to in the derived class and return true
return false;
@@ -148,7 +146,7 @@ CMIUtilVariant::CDataObjectBase::Copy(const CDataObjectBase &vrOther)
// Throws: None.
//--
void
-CMIUtilVariant::CDataObjectBase::Destroy(void)
+CMIUtilVariant::CDataObjectBase::Destroy()
{
// Do nothing - override to implement
}
@@ -247,7 +245,7 @@ template <typename T> CMIUtilVariant::CDataObject<T> &CMIUtilVariant::CDataObjec
// Return: None.
// Throws: None.
//--
-CMIUtilVariant::CMIUtilVariant(void)
+CMIUtilVariant::CMIUtilVariant()
: m_pDataObject(nullptr)
{
}
@@ -308,7 +306,7 @@ CMIUtilVariant::CMIUtilVariant(CMIUtilVariant &&vrwOther)
// Return: None.
// Throws: None.
//--
-CMIUtilVariant::~CMIUtilVariant(void)
+CMIUtilVariant::~CMIUtilVariant()
{
Destroy();
}
@@ -354,7 +352,7 @@ CMIUtilVariant &CMIUtilVariant::operator=(CMIUtilVariant &&vrwOther)
// Throws: None.
//--
void
-CMIUtilVariant::Destroy(void)
+CMIUtilVariant::Destroy()
{
if (m_pDataObject != nullptr)
delete m_pDataObject;
diff --git a/tools/lldb-mi/MIUtilVariant.h b/tools/lldb-mi/MIUtilVariant.h
index a6c3ba439031..7fddb9ffda2f 100644
--- a/tools/lldb-mi/MIUtilVariant.h
+++ b/tools/lldb-mi/MIUtilVariant.h
@@ -6,8 +6,6 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-// Copyright: None.
-//--
#pragma once
@@ -20,22 +18,19 @@
// data object specified is made and stored in *this wrapper. When the
// *this object is destroyed the data object hold within calls its
// destructor should it have one.
-// Gotchas: None.
-// Authors: Illya Rudkin 18/06/2014.
-// Changes: None.
//--
class CMIUtilVariant
{
// Methods:
public:
- /* ctor */ CMIUtilVariant(void);
+ /* ctor */ CMIUtilVariant();
/* ctor */ CMIUtilVariant(const CMIUtilVariant &vrOther);
/* ctor */ CMIUtilVariant(CMIUtilVariant &vrOther);
/* ctor */ CMIUtilVariant(CMIUtilVariant &&vrwOther);
- /* dtor */ ~CMIUtilVariant(void);
+ /* dtor */ ~CMIUtilVariant();
template <typename T> void Set(const T &vArg);
- template <typename T> T *Get(void) const;
+ template <typename T> T *Get() const;
CMIUtilVariant &operator=(const CMIUtilVariant &vrOther);
CMIUtilVariant &operator=(CMIUtilVariant &&vrwOther);
@@ -52,7 +47,7 @@ class CMIUtilVariant
{
// Methods:
public:
- /* ctor */ CDataObjectBase(void);
+ /* ctor */ CDataObjectBase();
/* ctor */ CDataObjectBase(const CDataObjectBase &vrOther);
/* ctor */ CDataObjectBase(CDataObjectBase &vrOther);
/* ctor */ CDataObjectBase(CDataObjectBase &&vrwOther);
@@ -62,14 +57,14 @@ class CMIUtilVariant
// Overrideable:
public:
- virtual ~CDataObjectBase(void);
- virtual CDataObjectBase *CreateCopyOfSelf(void);
- virtual bool GetIsDerivedClass(void) const;
+ virtual ~CDataObjectBase();
+ virtual CDataObjectBase *CreateCopyOfSelf();
+ virtual bool GetIsDerivedClass() const;
// Overrideable:
protected:
virtual void Copy(const CDataObjectBase &vrOther);
- virtual void Destroy(void);
+ virtual void Destroy();
};
//++ ----------------------------------------------------------------------
@@ -81,7 +76,7 @@ class CMIUtilVariant
{
// Methods:
public:
- /* ctor */ CDataObject(void);
+ /* ctor */ CDataObject();
/* ctor */ CDataObject(const T &vArg);
/* ctor */ CDataObject(const CDataObject &vrOther);
/* ctor */ CDataObject(CDataObject &vrOther);
@@ -90,14 +85,14 @@ class CMIUtilVariant
CDataObject &operator=(const CDataObject &vrOther);
CDataObject &operator=(CDataObject &&vrwOther);
//
- T &GetDataObject(void);
+ T &GetDataObject();
// Overridden:
public:
// From CDataObjectBase
- ~CDataObject(void) override;
- CDataObjectBase *CreateCopyOfSelf(void) override;
- bool GetIsDerivedClass(void) const override;
+ ~CDataObject() override;
+ CDataObjectBase *CreateCopyOfSelf() override;
+ bool GetIsDerivedClass() const override;
// Overrideable:
private:
@@ -106,7 +101,7 @@ class CMIUtilVariant
// Overridden:
private:
// From CDataObjectBase
- void Destroy(void) override;
+ void Destroy() override;
// Attributes:
private:
@@ -115,7 +110,7 @@ class CMIUtilVariant
// Methods
private:
- void Destroy(void);
+ void Destroy();
void Copy(const CMIUtilVariant &vrOther);
// Attributes:
@@ -134,7 +129,7 @@ class CMIUtilVariant
// Return: None.
// Throws: None.
//--
-template <typename T> CMIUtilVariant::CDataObject<T>::CDataObject(void)
+template <typename T> CMIUtilVariant::CDataObject<T>::CDataObject()
{
}
@@ -158,7 +153,7 @@ template <typename T> CMIUtilVariant::CDataObject<T>::CDataObject(const T &vArg)
// Return: None.
// Throws: None.
//--
-template <typename T> CMIUtilVariant::CDataObject<T>::~CDataObject(void)
+template <typename T> CMIUtilVariant::CDataObject<T>::~CDataObject()
{
Destroy();
}
@@ -172,7 +167,7 @@ template <typename T> CMIUtilVariant::CDataObject<T>::~CDataObject(void)
//--
template <typename T>
T &
-CMIUtilVariant::CDataObject<T>::GetDataObject(void)
+CMIUtilVariant::CDataObject<T>::GetDataObject()
{
return m_dataObj;
}
@@ -186,7 +181,7 @@ CMIUtilVariant::CDataObject<T>::GetDataObject(void)
//--
template <typename T>
CMIUtilVariant::CDataObjectBase *
-CMIUtilVariant::CDataObject<T>::CreateCopyOfSelf(void)
+CMIUtilVariant::CDataObject<T>::CreateCopyOfSelf()
{
CDataObject *pCopy = new CDataObject<T>(m_dataObj);
@@ -203,7 +198,7 @@ CMIUtilVariant::CDataObject<T>::CreateCopyOfSelf(void)
//--
template <typename T>
bool
-CMIUtilVariant::CDataObject<T>::GetIsDerivedClass(void) const
+CMIUtilVariant::CDataObject<T>::GetIsDerivedClass() const
{
return true;
}
@@ -233,7 +228,7 @@ CMIUtilVariant::CDataObject<T>::Duplicate(const CDataObject &vrOther)
//--
template <typename T>
void
-CMIUtilVariant::CDataObject<T>::Destroy(void)
+CMIUtilVariant::CDataObject<T>::Destroy()
{
CDataObjectBase::Destroy();
}
@@ -266,7 +261,7 @@ CMIUtilVariant::Set(const T &vArg)
//--
template <typename T>
T *
-CMIUtilVariant::Get(void) const
+CMIUtilVariant::Get() const
{
if ((m_pDataObject != nullptr) && m_pDataObject->GetIsDerivedClass())
{
diff --git a/tools/lldb-server/exports b/tools/lldb-mi/lldb-mi.exports
index e69de29bb2d1..e69de29bb2d1 100644
--- a/tools/lldb-server/exports
+++ b/tools/lldb-mi/lldb-mi.exports
diff --git a/tools/lldb-server/Acceptor.cpp b/tools/lldb-server/Acceptor.cpp
new file mode 100644
index 000000000000..634319594853
--- /dev/null
+++ b/tools/lldb-server/Acceptor.cpp
@@ -0,0 +1,170 @@
+//===-- Acceptor.cpp --------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "Acceptor.h"
+
+#include "llvm/ADT/StringRef.h"
+
+#include "lldb/Core/StreamString.h"
+#include "lldb/Host/ConnectionFileDescriptor.h"
+#include "lldb/Host/common/TCPSocket.h"
+
+#include "Utility/UriParser.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::lldb_server;
+using namespace llvm;
+
+namespace {
+
+struct SocketScheme
+{
+ const char* m_scheme;
+ const Socket::SocketProtocol m_protocol;
+};
+
+SocketScheme socket_schemes[] = {
+ {"tcp", Socket::ProtocolTcp},
+ {"udp", Socket::ProtocolUdp},
+ {"unix", Socket::ProtocolUnixDomain},
+ {"unix-abstract", Socket::ProtocolUnixAbstract},
+};
+
+bool
+FindProtocolByScheme(const char* scheme, Socket::SocketProtocol& protocol)
+{
+ for (auto s: socket_schemes)
+ {
+ if (!strcmp(s.m_scheme, scheme))
+ {
+ protocol = s.m_protocol;
+ return true;
+ }
+ }
+ return false;
+}
+
+const char*
+FindSchemeByProtocol(const Socket::SocketProtocol protocol)
+{
+ for (auto s: socket_schemes)
+ {
+ if (s.m_protocol == protocol)
+ return s.m_scheme;
+ }
+ return nullptr;
+}
+
+}
+
+Error
+Acceptor::Listen(int backlog)
+{
+ return m_listener_socket_up->Listen(StringRef(m_name.c_str()),
+ backlog);
+}
+
+Error
+Acceptor::Accept(const bool child_processes_inherit, Connection *&conn)
+{
+ Socket* conn_socket = nullptr;
+ auto error = m_listener_socket_up->Accept(StringRef(m_name.c_str()),
+ child_processes_inherit,
+ conn_socket);
+ if (error.Success())
+ conn = new ConnectionFileDescriptor(conn_socket);
+
+ return error;
+}
+
+Socket::SocketProtocol
+Acceptor::GetSocketProtocol() const
+{
+ return m_listener_socket_up->GetSocketProtocol();
+}
+
+const char*
+Acceptor::GetSocketScheme() const
+{
+ return FindSchemeByProtocol(GetSocketProtocol());
+}
+
+std::string
+Acceptor::GetLocalSocketId() const
+{
+ return m_local_socket_id();
+}
+
+std::unique_ptr<Acceptor>
+Acceptor::Create(StringRef name, const bool child_processes_inherit, Error &error)
+{
+ error.Clear();
+
+ Socket::SocketProtocol socket_protocol = Socket::ProtocolUnixDomain;
+ int port;
+ std::string scheme, host, path;
+ // Try to match socket name as URL - e.g., tcp://localhost:5555
+ if (UriParser::Parse(name.str(), scheme, host, port, path))
+ {
+ if (!FindProtocolByScheme(scheme.c_str(), socket_protocol))
+ error.SetErrorStringWithFormat("Unknown protocol scheme \"%s\"", scheme.c_str());
+ else
+ name = name.drop_front(scheme.size() + strlen("://"));
+ }
+ else
+ {
+ std::string host_str;
+ std::string port_str;
+ int32_t port = INT32_MIN;
+ // Try to match socket name as $host:port - e.g., localhost:5555
+ if (Socket::DecodeHostAndPort (name, host_str, port_str, port, nullptr))
+ socket_protocol = Socket::ProtocolTcp;
+ }
+
+ if (error.Fail())
+ return std::unique_ptr<Acceptor>();
+
+ std::unique_ptr<Socket> listener_socket_up = Socket::Create(
+ socket_protocol, child_processes_inherit, error);
+
+ LocalSocketIdFunc local_socket_id;
+ if (error.Success())
+ {
+ if (listener_socket_up->GetSocketProtocol() == Socket::ProtocolTcp)
+ {
+ TCPSocket* tcp_socket = static_cast<TCPSocket*>(listener_socket_up.get());
+ local_socket_id = [tcp_socket]() {
+ auto local_port = tcp_socket->GetLocalPortNumber();
+ return (local_port != 0) ? std::to_string(local_port) : "";
+ };
+ }
+ else
+ {
+ const std::string socket_name = name;
+ local_socket_id = [socket_name](){
+ return socket_name;
+ };
+ }
+
+ return std::unique_ptr<Acceptor>(
+ new Acceptor(std::move(listener_socket_up), name, local_socket_id));
+ }
+
+ return std::unique_ptr<Acceptor>();
+}
+
+Acceptor::Acceptor(std::unique_ptr<Socket> &&listener_socket,
+ StringRef name,
+ const LocalSocketIdFunc &local_socket_id)
+ : m_listener_socket_up(std::move(listener_socket)),
+ m_name(name.str()),
+ m_local_socket_id(local_socket_id)
+{
+}
diff --git a/tools/lldb-server/Acceptor.h b/tools/lldb-server/Acceptor.h
new file mode 100644
index 000000000000..37fba26c881f
--- /dev/null
+++ b/tools/lldb-server/Acceptor.h
@@ -0,0 +1,68 @@
+//===-- Acceptor.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_server_Acceptor_h_
+#define lldb_server_Acceptor_h_
+
+#include "lldb/Core/Connection.h"
+#include "lldb/Core/Error.h"
+#include "lldb/Host/Socket.h"
+
+#include <functional>
+#include <memory>
+#include <string>
+
+namespace llvm
+{
+ class StringRef;
+}
+
+namespace lldb_private {
+namespace lldb_server {
+
+class Acceptor
+{
+public:
+ virtual ~Acceptor() = default;
+
+ Error
+ Listen(int backlog);
+
+ Error
+ Accept(const bool child_processes_inherit, Connection *&conn);
+
+ static std::unique_ptr<Acceptor>
+ Create(llvm::StringRef name, const bool child_processes_inherit, Error &error);
+
+ Socket::SocketProtocol
+ GetSocketProtocol() const;
+
+ const char*
+ GetSocketScheme() const;
+
+ // Returns either TCP port number as string or domain socket path.
+ // Empty string is returned in case of error.
+ std::string
+ GetLocalSocketId() const;
+
+private:
+ typedef std::function<std::string()> LocalSocketIdFunc;
+
+ Acceptor(std::unique_ptr<Socket> &&listener_socket,
+ llvm::StringRef name,
+ const LocalSocketIdFunc &local_socket_id);
+
+ const std::unique_ptr<Socket> m_listener_socket_up;
+ const std::string m_name;
+ const LocalSocketIdFunc m_local_socket_id;
+};
+
+} // namespace lldb_server
+} // namespace lldb_private
+
+#endif // lldb_server_Acceptor_h_
diff --git a/tools/lldb-server/LLDBServerUtilities.cpp b/tools/lldb-server/LLDBServerUtilities.cpp
index 8df4875e5d1d..438d9f127d63 100644
--- a/tools/lldb-server/LLDBServerUtilities.cpp
+++ b/tools/lldb-server/LLDBServerUtilities.cpp
@@ -42,7 +42,7 @@ LLDBServerUtilities::SetupLogging(const std::string& log_file,
}
SmallVector<StringRef, 32> channel_array;
- log_channels.split(channel_array, ":");
+ log_channels.split(channel_array, ":", /*MaxSplit*/ -1, /*KeepEmpty*/ false);
for (auto channel_with_categories : channel_array)
{
StreamString error_stream;
diff --git a/tools/lldb-server/lldb-gdbserver.cpp b/tools/lldb-server/lldb-gdbserver.cpp
index 30bb2d686770..df8cb6e68554 100644
--- a/tools/lldb-server/lldb-gdbserver.cpp
+++ b/tools/lldb-server/lldb-gdbserver.cpp
@@ -9,7 +9,6 @@
// C Includes
#include <errno.h>
-#include <getopt.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -25,17 +24,16 @@
// Other libraries and framework includes
#include "llvm/ADT/StringRef.h"
-#include "lldb/Core/ConnectionMachPort.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
-#include "lldb/Host/HostThread.h"
+#include "lldb/Host/HostGetOpt.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Host/Pipe.h"
#include "lldb/Host/Socket.h"
#include "lldb/Host/StringConvert.h"
-#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Target/Platform.h"
+#include "Acceptor.h"
#include "LLDBServerUtilities.h"
#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h"
#include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
@@ -54,15 +52,6 @@ using namespace lldb_private;
using namespace lldb_private::lldb_server;
using namespace lldb_private::process_gdb_remote;
-// lldb-gdbserver state
-
-namespace
-{
-HostThread s_listen_thread;
- std::unique_ptr<ConnectionFileDescriptor> s_listen_connection_up;
- std::string s_listen_url;
-}
-
//----------------------------------------------------------------------
// option descriptors for getopt_long_only()
//----------------------------------------------------------------------
@@ -263,64 +252,16 @@ handle_launch (GDBRemoteCommunicationServerLLGS &gdb_server, int argc, const cha
}
}
-static lldb::thread_result_t
-ListenThread (lldb::thread_arg_t /* arg */)
-{
- Error error;
-
- if (s_listen_connection_up)
- {
- // Do the listen on another thread so we can continue on...
- if (s_listen_connection_up->Connect(s_listen_url.c_str(), &error) != eConnectionStatusSuccess)
- s_listen_connection_up.reset();
- }
- return nullptr;
-}
-
-static Error
-StartListenThread (const char *hostname, uint16_t port)
-{
- Error error;
- if (s_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);
-
- s_listen_url = listen_url;
- s_listen_connection_up.reset (new ConnectionFileDescriptor ());
- s_listen_thread = ThreadLauncher::LaunchThread(listen_url, ListenThread, nullptr, &error);
- }
- return error;
-}
-
-static bool
-JoinListenThread ()
-{
- if (s_listen_thread.IsJoinable())
- s_listen_thread.Join(nullptr);
- return true;
-}
-
Error
-WritePortToPipe(Pipe &port_pipe, const uint16_t port)
+writeSocketIdToPipe(Pipe &port_pipe, const std::string &socket_id)
{
- char port_str[64];
- const auto port_str_len = ::snprintf(port_str, sizeof(port_str), "%u", port);
-
size_t bytes_written = 0;
// Write the port number as a C string with the NULL terminator.
- return port_pipe.Write(port_str, port_str_len + 1, bytes_written);
+ return port_pipe.Write(socket_id.c_str(), socket_id.size() + 1, bytes_written);
}
Error
-writePortToPipe(const char *const named_pipe_path, const uint16_t port)
+writeSocketIdToPipe(const char *const named_pipe_path, const std::string &socket_id)
{
Pipe port_name_pipe;
// Wait for 10 seconds for pipe to be opened.
@@ -328,17 +269,17 @@ writePortToPipe(const char *const named_pipe_path, const uint16_t port)
std::chrono::seconds{10});
if (error.Fail())
return error;
- return WritePortToPipe(port_name_pipe, port);
+ return writeSocketIdToPipe(port_name_pipe, socket_id);
}
Error
-writePortToPipe(int unnamed_pipe_fd, const uint16_t port)
+writeSocketIdToPipe(int unnamed_pipe_fd, const std::string &socket_id)
{
#if defined(_WIN32)
return Error("Unnamed pipes are not supported on Windows.");
#else
Pipe port_pipe{Pipe::kInvalidDescriptor, unnamed_pipe_fd};
- return WritePortToPipe(port_pipe, port);
+ return writeSocketIdToPipe(port_pipe, socket_id);
#endif
}
@@ -370,14 +311,8 @@ ConnectToRemote(MainLoop &mainloop, GDBRemoteCommunicationServerLLGS &gdb_server
connection_port = final_host_and_port.substr (colon_pos + 1);
connection_portno = StringConvert::ToUInt32 (connection_port.c_str (), 0);
}
- else
- {
- fprintf (stderr, "failed to parse host and port from connection string '%s'\n", final_host_and_port.c_str ());
- display_usage (progname, subcommand);
- exit (1);
- }
- std::unique_ptr<ConnectionFileDescriptor> connection_up;
+ std::unique_ptr<Connection> connection_up;
if (reverse_connect)
{
@@ -410,66 +345,51 @@ ConnectToRemote(MainLoop &mainloop, GDBRemoteCommunicationServerLLGS &gdb_server
}
else
{
- // llgs will listen for connections on the given port from the given address.
- // Start the listener on a new thread. We need to do this so we can resolve the
- // bound listener port.
- StartListenThread(connection_host.c_str (), static_cast<uint16_t> (connection_portno));
- printf ("Listening to port %s for a connection from %s...\n", connection_port.c_str (), connection_host.c_str ());
-
- // If we have a named pipe to write the port number back to, do that now.
- if (named_pipe_path && named_pipe_path[0] && connection_portno == 0)
+ std::unique_ptr<Acceptor> acceptor_up(Acceptor::Create(final_host_and_port, false, error));
+ if (error.Fail())
+ {
+ fprintf(stderr, "failed to create acceptor: %s", error.AsCString());
+ exit(1);
+ }
+ error = acceptor_up->Listen(1);
+ if (error.Fail())
{
- const uint16_t bound_port = s_listen_connection_up->GetListeningPort (10);
- if (bound_port > 0)
+ fprintf(stderr, "failed to listen: %s\n", error.AsCString());
+ exit(1);
+ }
+ const std::string socket_id = acceptor_up->GetLocalSocketId();
+ if (!socket_id.empty())
+ {
+ // If we have a named pipe to write the socket id back to, do that now.
+ if (named_pipe_path && named_pipe_path[0])
{
- error = writePortToPipe (named_pipe_path, bound_port);
+ error = writeSocketIdToPipe (named_pipe_path, socket_id);
if (error.Fail ())
- {
- fprintf (stderr, "failed to write to the named pipe \'%s\': %s", named_pipe_path, error.AsCString());
- }
+ fprintf (stderr, "failed to write to the named pipe \'%s\': %s",
+ named_pipe_path, error.AsCString());
}
- else
+ // If we have an unnamed pipe to write the socket id back to, do that now.
+ else if (unnamed_pipe_fd >= 0)
{
- fprintf (stderr, "unable to get the bound port for the listening connection\n");
- }
- }
-
- // If we have an unnamed pipe to write the port number back to, do that now.
- if (unnamed_pipe_fd >= 0 && connection_portno == 0)
- {
- const uint16_t bound_port = s_listen_connection_up->GetListeningPort(10);
- if (bound_port > 0)
- {
- error = writePortToPipe(unnamed_pipe_fd, bound_port);
+ error = writeSocketIdToPipe(unnamed_pipe_fd, socket_id);
if (error.Fail())
- {
fprintf(stderr, "failed to write to the unnamed pipe: %s",
error.AsCString());
- }
- }
- else
- {
- fprintf(stderr, "unable to get the bound port for the listening connection\n");
}
}
-
- // Join the listener thread.
- if (!JoinListenThread ())
+ else
{
- fprintf (stderr, "failed to join the listener thread\n");
- display_usage (progname, subcommand);
- exit (1);
+ fprintf (stderr, "unable to get the socket id for the listening connection\n");
}
- // Ensure we connected.
- if (s_listen_connection_up)
- connection_up = std::move(s_listen_connection_up);
- else
+ Connection* conn = nullptr;
+ error = acceptor_up->Accept(false, conn);
+ if (error.Fail())
{
- fprintf (stderr, "failed to connect to '%s': %s\n", final_host_and_port.c_str (), error.AsCString ());
- display_usage (progname, subcommand);
- exit (1);
+ printf ("failed to accept new connection: %s\n", error.AsCString());
+ exit(1);
}
+ connection_up.reset(conn);
}
error = gdb_server.InitializeConnection (std::move(connection_up));
if (error.Fail())
diff --git a/tools/lldb-server/lldb-platform.cpp b/tools/lldb-server/lldb-platform.cpp
index 4dfa7d23a4a8..3292080da63a 100644
--- a/tools/lldb-server/lldb-platform.cpp
+++ b/tools/lldb-server/lldb-platform.cpp
@@ -23,15 +23,17 @@
#include <fstream>
// Other libraries and framework includes
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
+
#include "lldb/Core/Error.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostGetOpt.h"
#include "lldb/Host/OptionParser.h"
-#include "lldb/Host/Socket.h"
-#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/FileUtilities.h"
+#include "lldb/Host/common/TCPSocket.h"
+#include "Acceptor.h"
#include "LLDBServerUtilities.h"
#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h"
#include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
@@ -61,7 +63,7 @@ static struct option g_long_options[] =
{ "gdbserver-port", required_argument, NULL, 'P' },
{ "min-gdbserver-port", required_argument, NULL, 'm' },
{ "max-gdbserver-port", required_argument, NULL, 'M' },
- { "port-file", required_argument, NULL, 'f' },
+ { "socket-file", required_argument, NULL, 'f' },
{ "server", no_argument, &g_server, 1 },
{ NULL, 0, NULL, 0 }
};
@@ -100,9 +102,9 @@ display_usage (const char *progname, const char *subcommand)
}
static Error
-save_port_to_file(const uint16_t port, const FileSpec &port_file_spec)
+save_socket_id_to_file(const std::string &socket_id, const FileSpec &file_spec)
{
- FileSpec temp_file_spec(port_file_spec.GetDirectory().AsCString(), false);
+ FileSpec temp_file_spec(file_spec.GetDirectory().AsCString(), false);
auto error = FileSystem::MakeDirectory(temp_file_spec, eFilePermissionsDirectoryDefault);
if (error.Fail())
return Error("Failed to create directory %s: %s", temp_file_spec.GetCString(), error.AsCString());
@@ -119,13 +121,13 @@ save_port_to_file(const uint16_t port, const FileSpec &port_file_spec)
std::ofstream temp_file(temp_file_path.c_str(), std::ios::out);
if (!temp_file.is_open())
return Error("Failed to open temp file %s", temp_file_path.c_str());
- temp_file << port;
+ temp_file << socket_id;
}
- err_code = llvm::sys::fs::rename(temp_file_path.c_str(), port_file_spec.GetPath().c_str());
+ err_code = llvm::sys::fs::rename(temp_file_path.c_str(), file_spec.GetPath().c_str());
if (err_code)
return Error("Failed to rename file %s to %s: %s",
- temp_file_path.c_str(), port_file_spec.GetPath().c_str(), err_code.message().c_str());
+ temp_file_path.c_str(), file_spec.GetPath().c_str(), err_code.message().c_str());
tmp_file_remover.releaseFile();
return Error();
@@ -156,7 +158,7 @@ main_platform (int argc, char *argv[])
int max_gdbserver_port = 0;
uint16_t port_offset = 0;
- FileSpec port_file;
+ FileSpec socket_file;
bool show_usage = false;
int option_error = 0;
int socket_error = -1;
@@ -191,9 +193,9 @@ main_platform (int argc, char *argv[])
log_channels = StringRef(optarg);
break;
- case 'f': // Port file
+ case 'f': // Socket file
if (optarg && optarg[0])
- port_file.SetFile(optarg, false);
+ socket_file.SetFile(optarg, false);
break;
case 'p':
@@ -282,36 +284,46 @@ main_platform (int argc, char *argv[])
display_usage(progname, subcommand);
exit(option_error);
}
-
- std::unique_ptr<Socket> listening_socket_up;
- Socket *socket = nullptr;
- const bool children_inherit_listen_socket = false;
+ // Skip any options we consumed with getopt_long_only.
+ argc -= optind;
+ argv += optind;
+ lldb_private::Args inferior_arguments;
+ inferior_arguments.SetArguments(argc, const_cast<const char**>(argv));
+
+ const bool children_inherit_listen_socket = false;
// the test suite makes many connections in parallel, let's not miss any.
- // The highest this should get reasonably is a function of the number
- // of target CPUs. For now, let's just use 100
+ // The highest this should get reasonably is a function of the number
+ // of target CPUs. For now, let's just use 100.
const int backlog = 100;
- error = Socket::TcpListen(listen_host_port.c_str(), children_inherit_listen_socket, socket, NULL, backlog);
+
+ std::unique_ptr<Acceptor> acceptor_up(Acceptor::Create(listen_host_port, children_inherit_listen_socket, error));
if (error.Fail())
{
- printf("error: %s\n", error.AsCString());
+ fprintf(stderr, "failed to create acceptor: %s", error.AsCString());
exit(socket_error);
}
- listening_socket_up.reset(socket);
- printf ("Listening for a connection from %u...\n", listening_socket_up->GetLocalPortNumber());
- if (port_file)
+
+ error = acceptor_up->Listen(backlog);
+ if (error.Fail())
+ {
+ printf("failed to listen: %s\n", error.AsCString());
+ exit(socket_error);
+ }
+ if (socket_file)
{
- error = save_port_to_file(listening_socket_up->GetLocalPortNumber(), port_file);
+ error = save_socket_id_to_file(acceptor_up->GetLocalSocketId(), socket_file);
if (error.Fail())
{
- fprintf(stderr, "failed to write port to %s: %s", port_file.GetPath().c_str(), error.AsCString());
+ fprintf(stderr, "failed to write socket id to %s: %s\n", socket_file.GetPath().c_str(), error.AsCString());
return 1;
}
}
do {
- GDBRemoteCommunicationServerPlatform platform;
-
+ GDBRemoteCommunicationServerPlatform platform(acceptor_up->GetSocketProtocol(),
+ acceptor_up->GetSocketScheme());
+
if (port_offset > 0)
platform.SetPortOffset(port_offset);
@@ -321,8 +333,8 @@ main_platform (int argc, char *argv[])
}
const bool children_inherit_accept_socket = true;
- socket = nullptr;
- error = listening_socket_up->BlockingAccept(listen_host_port.c_str(), children_inherit_accept_socket, socket);
+ Connection* conn = nullptr;
+ error = acceptor_up->Accept(children_inherit_accept_socket, conn);
if (error.Fail())
{
printf ("error: %s\n", error.AsCString());
@@ -336,8 +348,7 @@ main_platform (int argc, char *argv[])
if (fork())
{
// Parent doesn't need a connection to the lldb client
- delete socket;
- socket = nullptr;
+ delete conn;
// Parent will continue to listen for new connections.
continue;
@@ -347,19 +358,35 @@ main_platform (int argc, char *argv[])
// Child process will handle the connection and exit.
g_server = 0;
// Listening socket is owned by parent process.
- listening_socket_up.release();
+ acceptor_up.release();
}
}
else
{
// If not running as a server, this process will not accept
// connections while a connection is active.
- listening_socket_up.reset();
+ acceptor_up.reset();
}
- platform.SetConnection (new ConnectionFileDescriptor(socket));
+ platform.SetConnection (conn);
if (platform.IsConnected())
{
+ if (inferior_arguments.GetArgumentCount() > 0)
+ {
+ lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
+ uint16_t port = 0;
+ std::string socket_name;
+ Error error = platform.LaunchGDBServer(inferior_arguments,
+ "", // hostname
+ pid,
+ port,
+ socket_name);
+ if (error.Success())
+ platform.SetPendingGdbServer(pid, port, socket_name);
+ else
+ fprintf(stderr, "failed to start gdbserver: %s\n", error.AsCString());
+ }
+
// After we connected, we need to get an initial ack from...
if (platform.HandshakeWithClient())
{
diff --git a/tools/lldb-server/lldb-server.exports b/tools/lldb-server/lldb-server.exports
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/tools/lldb-server/lldb-server.exports